@authhero/kysely-adapter 10.115.0 → 10.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  var Oe = Object.defineProperty;
2
2
  var ke = (e, t, a) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
3
  var K = (e, t, a) => ke(e, typeof t != "symbol" ? t + "" : t, a);
4
- import { nanoid as b, customAlphabet as $e } from "nanoid";
5
- import { parseUserId as Ee, flowSchema as B, codeSchema as Ie, loginSessionSchema as ze, LoginSessionState as ie, promptSettingSchema as Pe, formSchema as q, resourceServerSchema as De } from "@authhero/adapter-interfaces";
4
+ import { nanoid as k, customAlphabet as $e } from "nanoid";
5
+ import { parseUserId as Ee, flowSchema as U, codeSchema as Ie, loginSessionSchema as ze, LoginSessionState as ie, promptSettingSchema as Pe, formSchema as q, resourceServerSchema as De } from "@authhero/adapter-interfaces";
6
6
  import "@hono/zod-openapi";
7
7
  import { sql as h, Migrator as ce } from "kysely";
8
8
  var F = class extends Error {
@@ -31,63 +31,49 @@ var F = class extends Error {
31
31
  });
32
32
  }
33
33
  };
34
- function Ae(e, t) {
35
- return async (a, n) => {
36
- const { identities: o, phone_verified: r, password: s, ...i } = n, c = {
37
- ...i,
38
- login_count: i.login_count ?? 0,
34
+ function Ae(e) {
35
+ return async (t, a) => {
36
+ const { identities: n, phone_verified: o, password: r, ...s } = a, i = {
37
+ ...s,
38
+ login_count: s.login_count ?? 0,
39
39
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
40
40
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
41
- tenant_id: a,
42
- email_verified: n.email_verified ? 1 : 0,
43
- phone_verified: r !== void 0 ? r ? 1 : 0 : null,
44
- is_social: n.is_social ? 1 : 0,
45
- app_metadata: JSON.stringify(n.app_metadata),
46
- user_metadata: JSON.stringify(n.user_metadata),
47
- address: n.address ? JSON.stringify(n.address) : null
41
+ tenant_id: t,
42
+ email_verified: a.email_verified ? 1 : 0,
43
+ phone_verified: o !== void 0 ? o ? 1 : 0 : null,
44
+ is_social: a.is_social ? 1 : 0,
45
+ app_metadata: JSON.stringify(a.app_metadata),
46
+ user_metadata: JSON.stringify(a.user_metadata),
47
+ address: a.address ? JSON.stringify(a.address) : null
48
48
  };
49
49
  try {
50
- if (t.useTransactions === !1) {
51
- if (await e.insertInto("users").values(c).execute(), s && c.user_id) {
52
- const d = {
53
- id: b(),
54
- user_id: c.user_id,
55
- password: s.hash,
56
- algorithm: s.algorithm,
50
+ const d = async (u) => {
51
+ if (await u.insertInto("users").values(i).execute(), r && i.user_id) {
52
+ const c = {
53
+ id: k(),
54
+ user_id: i.user_id,
55
+ password: r.hash,
56
+ algorithm: r.algorithm,
57
57
  is_current: 1,
58
58
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
59
59
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
60
- tenant_id: a
60
+ tenant_id: t
61
61
  };
62
- await e.insertInto("passwords").values(d).execute();
62
+ await u.insertInto("passwords").values(c).execute();
63
63
  }
64
- } else
65
- await e.transaction().execute(async (d) => {
66
- if (await d.insertInto("users").values(c).execute(), s && c.user_id) {
67
- const u = {
68
- id: b(),
69
- user_id: c.user_id,
70
- password: s.hash,
71
- algorithm: s.algorithm,
72
- is_current: 1,
73
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
74
- updated_at: (/* @__PURE__ */ new Date()).toISOString(),
75
- tenant_id: a
76
- };
77
- await d.insertInto("passwords").values(u).execute();
78
- }
79
- });
64
+ };
65
+ e.isTransaction ? await d(e) : await e.transaction().execute(d);
80
66
  } catch (d) {
81
67
  throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.message.includes("AlreadyExists") ? new F(409, { message: "User already exists" }) : new F(500, { message: `${d.code}, ${d.message}` });
82
68
  }
83
69
  return {
84
- ...c,
70
+ ...i,
85
71
  // TODO: check if this is correct. Should it be optional?
86
- email: c.email || "",
87
- email_verified: c.email_verified === 1,
88
- phone_verified: c.phone_verified !== null ? c.phone_verified === 1 : void 0,
89
- is_social: c.is_social === 1,
90
- address: n.address
72
+ email: i.email || "",
73
+ email_verified: i.email_verified === 1,
74
+ phone_verified: i.phone_verified !== null ? i.phone_verified === 1 : void 0,
75
+ is_social: i.is_social === 1,
76
+ address: a.address
91
77
  // Return original address object, not serialized string
92
78
  };
93
79
  };
@@ -118,7 +104,7 @@ const je = [
118
104
  "phone_verified",
119
105
  "username"
120
106
  ];
121
- function U(e, t = !1) {
107
+ function B(e, t = !1) {
122
108
  const a = {
123
109
  connection: e.connection,
124
110
  provider: e.provider,
@@ -160,94 +146,94 @@ function Fe(e) {
160
146
  user_metadata: JSON.parse(n.user_metadata),
161
147
  address: n.address ? JSON.parse(n.address) : void 0,
162
148
  identities: [
163
- U(n, !0),
164
- ...o.map((c) => U(c))
149
+ B(n, !0),
150
+ ...o.map((d) => B(d))
165
151
  ]
166
152
  };
167
153
  return w(i);
168
154
  };
169
155
  }
170
- function O(e, t, a, n) {
156
+ function S(e, t, a, n) {
171
157
  const o = a.split(/ OR /i);
172
158
  if (o.length > 1)
173
- return t.where((d) => {
174
- const u = o.map((l) => {
159
+ return t.where((u) => {
160
+ const c = o.map((l) => {
175
161
  const m = l.trim().match(/^([^:]+):(.+)$/);
176
162
  if (m) {
177
163
  const [, _, p] = m;
178
164
  if (!_ || !p) return null;
179
165
  const f = p.replace(/^"(.*)"$/, "$1");
180
- return d(_.trim(), "=", f.trim());
166
+ return u(_.trim(), "=", f.trim());
181
167
  }
182
168
  return null;
183
169
  }).filter(Boolean);
184
- return d.or(u);
170
+ return u.or(c);
185
171
  });
186
172
  const r = [];
187
173
  let s = "", i = !1;
188
- for (let d = 0; d < a.length; d++) {
189
- const u = a[d];
190
- u === '"' ? (i = !i, s += u) : u === " " && !i ? s.trim() && (r.push(s.trim()), s = "") : s += u;
174
+ for (let u = 0; u < a.length; u++) {
175
+ const c = a[u];
176
+ c === '"' ? (i = !i, s += c) : c === " " && !i ? s.trim() && (r.push(s.trim()), s = "") : s += c;
191
177
  }
192
- return s.trim() && r.push(s.trim()), r.map((d) => d.replace(/^([^:]+)=/g, "$1:")).map((d) => {
193
- let u = d.startsWith("-"), l = null, m = "", _ = !1, p;
194
- if (d.startsWith("-_exists_:"))
195
- l = d.substring(10), _ = !0, u = !0;
196
- else if (d.startsWith("_exists_:"))
197
- l = d.substring(9), _ = !0, u = !1;
198
- else if (d.includes(":")) {
199
- const f = u ? d.substring(1) : d, g = f.indexOf(":");
178
+ return s.trim() && r.push(s.trim()), r.map((u) => u.replace(/^([^:]+)=/g, "$1:")).map((u) => {
179
+ let c = u.startsWith("-"), l = null, m = "", _ = !1, p;
180
+ if (u.startsWith("-_exists_:"))
181
+ l = u.substring(10), _ = !0, c = !0;
182
+ else if (u.startsWith("_exists_:"))
183
+ l = u.substring(9), _ = !0, c = !1;
184
+ else if (u.includes(":")) {
185
+ const f = c ? u.substring(1) : u, g = f.indexOf(":");
200
186
  l = f.substring(0, g), m = f.substring(g + 1), _ = !1, m.startsWith(">=") ? (p = ">=", m = m.substring(2)) : m.startsWith(">") ? (p = ">", m = m.substring(1)) : m.startsWith("<=") ? (p = "<=", m = m.substring(2)) : m.startsWith("<") ? (p = "<", m = m.substring(1)) : p = "=", m.startsWith('"') && m.endsWith('"') && m.length > 1 && (m = m.slice(1, -1));
201
187
  } else
202
- l = null, m = d, _ = !1;
203
- return { key: l, value: m, isNegation: u, isExistsQuery: _, operator: p };
204
- }).forEach(({ key: d, value: u, isNegation: l, isExistsQuery: m, operator: _ }) => {
205
- if (d)
188
+ l = null, m = u, _ = !1;
189
+ return { key: l, value: m, isNegation: c, isExistsQuery: _, operator: p };
190
+ }).forEach(({ key: u, value: c, isNegation: l, isExistsQuery: m, operator: _ }) => {
191
+ if (u)
206
192
  if (m)
207
- l ? t = t.where(d, "is", null) : t = t.where(d, "is not", null);
193
+ l ? t = t.where(u, "is", null) : t = t.where(u, "is not", null);
208
194
  else if (l)
209
195
  switch (_) {
210
196
  case ">":
211
- t = t.where(d, "<=", u);
197
+ t = t.where(u, "<=", c);
212
198
  break;
213
199
  case ">=":
214
- t = t.where(d, "<", u);
200
+ t = t.where(u, "<", c);
215
201
  break;
216
202
  case "<":
217
- t = t.where(d, ">=", u);
203
+ t = t.where(u, ">=", c);
218
204
  break;
219
205
  case "<=":
220
- t = t.where(d, ">", u);
206
+ t = t.where(u, ">", c);
221
207
  break;
222
208
  default:
223
- t = t.where(d, "!=", u);
209
+ t = t.where(u, "!=", c);
224
210
  }
225
211
  else
226
- t = t.where(d, _, u);
227
- else if (u) {
228
- const { ref: p } = e.dynamic, f = u.includes("|") ? [...n, "user_id"] : n;
212
+ t = t.where(u, _, c);
213
+ else if (c) {
214
+ const { ref: p } = e.dynamic, f = c.includes("|") ? [...n, "user_id"] : n;
229
215
  t = t.where(
230
216
  (g) => g.or(
231
217
  f.map(
232
- (y) => y === "user_id" ? g(p(y), "=", u) : g(p(y), "like", `%${u}%`)
218
+ (y) => y === "user_id" ? g(p(y), "=", c) : g(p(y), "like", `%${c}%`)
233
219
  )
234
220
  )
235
221
  );
236
222
  }
237
223
  }), t;
238
224
  }
239
- function k(e) {
225
+ function O(e) {
240
226
  return typeof e == "string" ? parseInt(e, 10) : typeof e == "bigint" ? Number(e) : e;
241
227
  }
242
228
  function Re(e) {
243
229
  return async (t, a = {}) => {
244
230
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
245
- let c = e.selectFrom("users").where("users.tenant_id", "=", t);
246
- if (i && (c = O(e, c, i, ["email", "name", "phone_number"])), s && s.sort_by) {
231
+ let d = e.selectFrom("users").where("users.tenant_id", "=", t);
232
+ if (i && (d = S(e, d, i, ["email", "name", "phone_number"])), s && s.sort_by) {
247
233
  const { ref: f } = e.dynamic;
248
- c = c.orderBy(f(s.sort_by), s.sort_order);
234
+ d = d.orderBy(f(s.sort_by), s.sort_order);
249
235
  }
250
- const u = await c.offset(n * o).limit(o).selectAll().execute(), l = u.map((f) => f.user_id), m = l.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", l).orderBy("created_at", "asc").execute() : [], _ = u.map((f) => {
236
+ const c = await d.offset(n * o).limit(o).selectAll().execute(), l = c.map((f) => f.user_id), m = l.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", l).orderBy("created_at", "asc").execute() : [], _ = c.map((f) => {
251
237
  const g = m.filter(
252
238
  (y) => y.linked_to === f.user_id
253
239
  );
@@ -260,8 +246,8 @@ function Re(e) {
260
246
  user_metadata: JSON.parse(f.user_metadata),
261
247
  address: f.address ? JSON.parse(f.address) : void 0,
262
248
  identities: [
263
- U(f, !0),
264
- ...g.map((y) => U(y))
249
+ B(f, !0),
250
+ ...g.map((y) => B(y))
265
251
  ]
266
252
  });
267
253
  });
@@ -272,12 +258,12 @@ function Re(e) {
272
258
  limit: 0,
273
259
  length: 0
274
260
  };
275
- const { count: p } = await c.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
261
+ const { count: p } = await d.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
276
262
  return {
277
263
  users: _,
278
264
  start: n * o,
279
265
  limit: o,
280
- length: k(p)
266
+ length: O(p)
281
267
  };
282
268
  };
283
269
  }
@@ -338,9 +324,9 @@ function Le(e) {
338
324
  return (await e.updateTable("users").set(r).where("users.tenant_id", "=", t).where("users.user_id", "=", `${n}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
339
325
  };
340
326
  }
341
- function Ke(e, t) {
327
+ function Ke(e) {
342
328
  return {
343
- create: Ae(e, t),
329
+ create: Ae(e),
344
330
  remove: Me(e),
345
331
  get: Fe(e),
346
332
  list: Re(e),
@@ -351,8 +337,8 @@ function Ke(e, t) {
351
337
  }
352
338
  function qe(e) {
353
339
  return async (t, a) => {
354
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = B.parse({
355
- id: `af_${b()}`,
340
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = U.parse({
341
+ id: `af_${k()}`,
356
342
  ...a,
357
343
  actions: a.actions || [],
358
344
  created_at: n,
@@ -383,7 +369,7 @@ function de(e, t, a = { ...e }) {
383
369
  ));
384
370
  return a;
385
371
  }
386
- function Ue(e) {
372
+ function Be(e) {
387
373
  return async (t, a) => {
388
374
  const n = await e.selectFrom("flows").selectAll().where("flows.id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
389
375
  if (!n) return null;
@@ -391,34 +377,34 @@ function Ue(e) {
391
377
  ...n,
392
378
  actions: P(n.actions, [])
393
379
  };
394
- return B.parse(w(o));
380
+ return U.parse(w(o));
395
381
  };
396
382
  }
397
- function Be(e) {
383
+ function Ue(e) {
398
384
  return async (t, a = {}) => {
399
385
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
400
386
  let i = e.selectFrom("flows").where("tenant_id", "=", t);
401
- s && (i = O(e, i, s, []));
402
- const u = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
387
+ s && (i = S(e, i, s, []));
388
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
403
389
  const _ = {
404
390
  ...m,
405
391
  actions: P(m.actions, [])
406
392
  };
407
- return B.parse(w(_));
393
+ return U.parse(w(_));
408
394
  });
409
395
  if (!r)
410
396
  return {
411
- flows: u,
397
+ flows: c,
412
398
  start: 0,
413
399
  limit: 0,
414
400
  length: 0
415
401
  };
416
402
  const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
417
403
  return {
418
- flows: u,
404
+ flows: c,
419
405
  start: n * o,
420
406
  limit: o,
421
- length: k(l)
407
+ length: O(l)
422
408
  };
423
409
  };
424
410
  }
@@ -432,7 +418,7 @@ function Qe(e) {
432
418
  const { numUpdatedRows: r } = await e.updateTable("flows").set(o).where("id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
433
419
  if (r === 0n) return null;
434
420
  const s = await e.selectFrom("flows").selectAll().where("id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
435
- return s ? B.parse({
421
+ return s ? U.parse({
436
422
  ...s,
437
423
  actions: s.actions ? JSON.parse(s.actions) : []
438
424
  }) : null;
@@ -447,8 +433,8 @@ function He(e) {
447
433
  function Ye(e) {
448
434
  return {
449
435
  create: qe(e),
450
- get: Ue(e),
451
- list: Be(e),
436
+ get: Be(e),
437
+ list: Ue(e),
452
438
  update: Qe(e),
453
439
  remove: He(e)
454
440
  };
@@ -504,7 +490,7 @@ function Ge(e) {
504
490
  return async (t) => {
505
491
  var o, r;
506
492
  const a = {
507
- id: t.id || b(),
493
+ id: t.id || k(),
508
494
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
509
495
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
510
496
  ...t
@@ -539,15 +525,15 @@ function Xe(e) {
539
525
  const { ref: _ } = e.dynamic;
540
526
  a = a.orderBy(_(s.sort_by), s.sort_order);
541
527
  }
542
- i && (a = O(e, a, i, ["friendly_name"]));
543
- const u = (await a.offset(n * o).limit(o).selectAll().execute()).map(_e);
528
+ i && (a = S(e, a, i, ["friendly_name"]));
529
+ const c = (await a.offset(n * o).limit(o).selectAll().execute()).map(_e);
544
530
  if (!r)
545
531
  return {
546
- tenants: u
532
+ tenants: c
547
533
  };
548
- const { count: l } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = k(l);
534
+ const { count: l } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = O(l);
549
535
  return {
550
- tenants: u,
536
+ tenants: c,
551
537
  start: n * o,
552
538
  limit: o,
553
539
  length: m
@@ -582,18 +568,18 @@ function Z(e) {
582
568
  const at = 256;
583
569
  function nt(e) {
584
570
  return async (t, a) => {
585
- var i, c, d;
586
- const n = (i = a.user_agent) == null ? void 0 : i.slice(0, at), o = a.log_id || b(), { location_info: r, ...s } = a;
571
+ var i, d, u;
572
+ const n = (i = a.user_agent) == null ? void 0 : i.slice(0, at), o = a.log_id || k(), { location_info: r, ...s } = a;
587
573
  return await e.insertInto("logs").values({
588
574
  ...s,
589
575
  log_id: o,
590
576
  tenant_id: t,
591
577
  user_agent: n,
592
- description: (c = a.description) == null ? void 0 : c.substring(0, 256),
578
+ description: (d = a.description) == null ? void 0 : d.substring(0, 256),
593
579
  isMobile: a.isMobile ? 1 : 0,
594
580
  scope: a.scope,
595
581
  auth0_client: Z(a.auth0_client),
596
- details: (d = Z(a.details)) == null ? void 0 : d.substring(0, 8192),
582
+ details: (u = Z(a.details)) == null ? void 0 : u.substring(0, 8192),
597
583
  // Extract location_info fields for separate columns
598
584
  country_code: r == null ? void 0 : r.country_code,
599
585
  city_name: r == null ? void 0 : r.city_name,
@@ -641,15 +627,15 @@ function he(e) {
641
627
  function ot(e) {
642
628
  return async (t, a = {}) => {
643
629
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
644
- let c = e.selectFrom("logs").where("logs.tenant_id", "=", t);
645
- i && (c = O(e, c, i, ["user_id", "ip"]));
646
- let d = c;
630
+ let d = e.selectFrom("logs").where("logs.tenant_id", "=", t);
631
+ i && (d = S(e, d, i, ["user_id", "ip"]));
632
+ let u = d;
647
633
  if (s && s.sort_by) {
648
634
  const { ref: _ } = e.dynamic;
649
- d = d.orderBy(_(s.sort_by), s.sort_order);
635
+ u = u.orderBy(_(s.sort_by), s.sort_order);
650
636
  }
651
- d = d.offset(n * o).limit(o);
652
- const l = (await d.selectAll().execute()).map(he);
637
+ u = u.offset(n * o).limit(o);
638
+ const l = (await u.selectAll().execute()).map(he);
653
639
  if (!r)
654
640
  return {
655
641
  logs: l,
@@ -657,12 +643,12 @@ function ot(e) {
657
643
  limit: 0,
658
644
  length: 0
659
645
  };
660
- const { count: m } = await c.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
646
+ const { count: m } = await d.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
661
647
  return {
662
648
  logs: l,
663
649
  start: n * o,
664
650
  limit: o,
665
- length: k(m)
651
+ length: O(m)
666
652
  };
667
653
  };
668
654
  }
@@ -725,9 +711,9 @@ function it(e) {
725
711
  device: r,
726
712
  clients: s,
727
713
  created_at_ts: i,
728
- updated_at_ts: c,
729
- expires_at_ts: d,
730
- idle_expires_at_ts: u,
714
+ updated_at_ts: d,
715
+ expires_at_ts: u,
716
+ idle_expires_at_ts: c,
731
717
  authenticated_at_ts: l,
732
718
  last_interaction_at_ts: m,
733
719
  used_at_ts: _,
@@ -736,9 +722,9 @@ function it(e) {
736
722
  } = n, g = D(
737
723
  {
738
724
  created_at_ts: i,
739
- updated_at_ts: c,
740
- expires_at_ts: d,
741
- idle_expires_at_ts: u,
725
+ updated_at_ts: d,
726
+ expires_at_ts: u,
727
+ idle_expires_at_ts: c,
742
728
  authenticated_at_ts: l,
743
729
  last_interaction_at_ts: m,
744
730
  used_at_ts: _,
@@ -771,9 +757,9 @@ function ct(e) {
771
757
  }, {
772
758
  expires_at: s,
773
759
  idle_expires_at: i,
774
- used_at: c,
775
- revoked_at: d,
776
- device: u,
760
+ used_at: d,
761
+ revoked_at: u,
762
+ device: c,
777
763
  clients: l,
778
764
  ...m
779
765
  } = a;
@@ -786,9 +772,9 @@ function ct(e) {
786
772
  last_interaction_at_ts: n,
787
773
  expires_at_ts: v(s),
788
774
  idle_expires_at_ts: v(i),
789
- used_at_ts: v(c),
790
- revoked_at_ts: v(d),
791
- device: JSON.stringify(u),
775
+ used_at_ts: v(d),
776
+ revoked_at_ts: v(u),
777
+ device: JSON.stringify(c),
792
778
  clients: JSON.stringify(l)
793
779
  }).execute(), r;
794
780
  };
@@ -811,20 +797,20 @@ function dt(e) {
811
797
  function ut(e) {
812
798
  return async (t, a = {}) => {
813
799
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
814
- let c = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
815
- i && (c = O(e, c, i, ["user_id", "session_id"]));
816
- let d = c;
800
+ let d = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
801
+ i && (d = S(e, d, i, ["user_id", "session_id"]));
802
+ let u = d;
817
803
  if (s && s.sort_by) {
818
804
  const { ref: p } = e.dynamic;
819
- d = d.orderBy(p(s.sort_by), s.sort_order);
805
+ u = u.orderBy(p(s.sort_by), s.sort_order);
820
806
  }
821
- d = d.offset(n * o).limit(o);
822
- const l = (await d.selectAll().execute()).map((p) => {
807
+ u = u.offset(n * o).limit(o);
808
+ const l = (await u.selectAll().execute()).map((p) => {
823
809
  const {
824
810
  tenant_id: f,
825
811
  device: g,
826
812
  clients: y,
827
- created_at_ts: S,
813
+ created_at_ts: b,
828
814
  updated_at_ts: C,
829
815
  expires_at_ts: $,
830
816
  idle_expires_at_ts: I,
@@ -832,10 +818,10 @@ function ut(e) {
832
818
  last_interaction_at_ts: z,
833
819
  used_at_ts: X,
834
820
  revoked_at_ts: Ne,
835
- ...Se
836
- } = p, be = D(
821
+ ...be
822
+ } = p, Se = D(
837
823
  {
838
- created_at_ts: S,
824
+ created_at_ts: b,
839
825
  updated_at_ts: C,
840
826
  expires_at_ts: $,
841
827
  idle_expires_at_ts: I,
@@ -853,8 +839,8 @@ function ut(e) {
853
839
  ["expires_at_ts", "idle_expires_at_ts", "used_at_ts", "revoked_at_ts"]
854
840
  );
855
841
  return {
856
- ...Se,
857
842
  ...be,
843
+ ...Se,
858
844
  device: JSON.parse(g),
859
845
  clients: JSON.parse(y)
860
846
  };
@@ -866,7 +852,7 @@ function ut(e) {
866
852
  limit: 0,
867
853
  length: 0
868
854
  };
869
- const { count: m } = await c.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = k(m);
855
+ const { count: m } = await d.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = O(m);
870
856
  return {
871
857
  sessions: l,
872
858
  start: n * o,
@@ -898,7 +884,7 @@ function mt(e) {
898
884
  }
899
885
  function ht(e) {
900
886
  return async (t, a) => {
901
- const n = a.id || b(), o = a.is_current ?? !0, r = {
887
+ const n = a.id || k(), o = a.is_current ?? !0, r = {
902
888
  id: n,
903
889
  ...a,
904
890
  is_current: o,
@@ -944,24 +930,24 @@ function wt(e) {
944
930
  return async (t, a = {}) => {
945
931
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
946
932
  let i = e.selectFrom("codes").where("codes.tenant_id", "=", t);
947
- s && (i = O(e, i, s, ["code", "login_id"]));
948
- const u = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
933
+ s && (i = S(e, i, s, ["code", "login_id"]));
934
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
949
935
  const { tenant_id: _, ...p } = m;
950
936
  return Ie.parse(w(p));
951
937
  });
952
938
  if (!r)
953
939
  return {
954
- codes: u,
940
+ codes: c,
955
941
  start: 0,
956
942
  limit: 0,
957
943
  length: 0
958
944
  };
959
945
  const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
960
946
  return {
961
- codes: u,
947
+ codes: c,
962
948
  start: n * o,
963
949
  limit: o,
964
- length: k(l)
950
+ length: O(l)
965
951
  };
966
952
  };
967
953
  }
@@ -1004,7 +990,7 @@ function Nt(e) {
1004
990
  get: Ct(e)
1005
991
  };
1006
992
  }
1007
- const St = 17, bt = {
993
+ const bt = 17, St = {
1008
994
  organization: "org_",
1009
995
  connection: "con_",
1010
996
  action: "act_",
@@ -1015,8 +1001,8 @@ const St = 17, bt = {
1015
1001
  invite: "inv_"
1016
1002
  };
1017
1003
  function L(e) {
1018
- const n = $e("0123456789abcdefghijklmnopqrstuvwxyz", St)();
1019
- return `${bt[e]}${n}`;
1004
+ const n = $e("0123456789abcdefghijklmnopqrstuvwxyz", bt)();
1005
+ return `${St[e]}${n}`;
1020
1006
  }
1021
1007
  function Ot() {
1022
1008
  return L("organization");
@@ -1066,21 +1052,21 @@ function Dt(e) {
1066
1052
  return async (t, a = {}) => {
1067
1053
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1068
1054
  let i = e.selectFrom("connections").where("connections.tenant_id", "=", t);
1069
- s && (i = O(e, i, s, ["user_id", "ip"]));
1070
- const d = await i.offset(n * o).limit(o).selectAll().execute(), u = Pt(d);
1055
+ s && (i = S(e, i, s, ["user_id", "ip"]));
1056
+ const u = await i.offset(n * o).limit(o).selectAll().execute(), c = Pt(u);
1071
1057
  if (!r)
1072
1058
  return {
1073
- connections: u,
1059
+ connections: c,
1074
1060
  start: 0,
1075
1061
  limit: 0,
1076
1062
  length: 0
1077
1063
  };
1078
1064
  const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1079
1065
  return {
1080
- connections: u,
1066
+ connections: c,
1081
1067
  start: n * o,
1082
1068
  limit: o,
1083
- length: k(l)
1069
+ length: O(l)
1084
1070
  };
1085
1071
  };
1086
1072
  }
@@ -1273,53 +1259,92 @@ function Lt(e) {
1273
1259
  function Kt(e) {
1274
1260
  return async (t, a) => {
1275
1261
  let n = e.selectFrom("clients").where("clients.tenant_id", "=", t);
1276
- return a != null && a.per_page && (n = n.limit(a.per_page)), a != null && a.page && (a != null && a.per_page) && (n = n.offset((a.page - 1) * a.per_page)), {
1277
- clients: (await n.selectAll().execute()).map((s) => ({
1278
- ...s,
1279
- // Convert integer fields back to booleans
1280
- global: !!s.global,
1281
- is_first_party: !!s.is_first_party,
1282
- oidc_conformant: !!s.oidc_conformant,
1283
- auth0_conformant: !!s.auth0_conformant,
1284
- sso: !!s.sso,
1285
- sso_disabled: !!s.sso_disabled,
1286
- cross_origin_authentication: !!s.cross_origin_authentication,
1287
- custom_login_page_on: !!s.custom_login_page_on,
1288
- require_pushed_authorization_requests: !!s.require_pushed_authorization_requests,
1289
- require_proof_of_possession: !!s.require_proof_of_possession,
1290
- // Parse JSON string fields back to objects/arrays
1291
- callbacks: JSON.parse(s.callbacks),
1292
- allowed_origins: JSON.parse(s.allowed_origins),
1293
- web_origins: JSON.parse(s.web_origins),
1294
- client_aliases: JSON.parse(s.client_aliases),
1295
- allowed_clients: JSON.parse(s.allowed_clients),
1296
- connections: JSON.parse(s.connections || "[]"),
1297
- allowed_logout_urls: JSON.parse(s.allowed_logout_urls),
1298
- session_transfer: JSON.parse(s.session_transfer),
1299
- oidc_logout: JSON.parse(s.oidc_logout),
1300
- grant_types: JSON.parse(s.grant_types),
1301
- jwt_configuration: JSON.parse(s.jwt_configuration),
1302
- signing_keys: JSON.parse(s.signing_keys),
1303
- encryption_key: JSON.parse(s.encryption_key),
1304
- addons: JSON.parse(s.addons),
1305
- client_metadata: JSON.parse(s.client_metadata),
1306
- mobile: JSON.parse(s.mobile),
1307
- native_social_login: JSON.parse(s.native_social_login),
1308
- refresh_token: JSON.parse(s.refresh_token),
1309
- default_organization: JSON.parse(s.default_organization),
1310
- client_authentication_methods: JSON.parse(
1311
- s.client_authentication_methods
1312
- ),
1313
- signed_request_object: JSON.parse(s.signed_request_object),
1314
- token_quota: JSON.parse(s.token_quota)
1315
- }))
1262
+ if (a != null && a.q && (n = n.where(
1263
+ (c) => c.or([
1264
+ c("name", "like", `%${a.q}%`),
1265
+ c("client_id", "like", `%${a.q}%`)
1266
+ ])
1267
+ )), a != null && a.sort) {
1268
+ const c = a.sort.sort_order === "asc" ? "asc" : "desc", l = a.sort.sort_by;
1269
+ ["name", "client_id", "created_at", "updated_at"].includes(l) ? n = n.orderBy(l, c) : n = n.orderBy("created_at", "desc");
1270
+ } else
1271
+ n = n.orderBy("created_at", "desc");
1272
+ if ((a == null ? void 0 : a.from) !== void 0) {
1273
+ const c = parseInt(a.from, 10);
1274
+ isNaN(c) || (n = n.offset(c));
1275
+ } else if ((a == null ? void 0 : a.page) !== void 0) {
1276
+ const c = (a == null ? void 0 : a.per_page) || (a == null ? void 0 : a.take) || 10, l = a.page * c;
1277
+ n = n.offset(l);
1278
+ }
1279
+ const o = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10;
1280
+ n = n.limit(o);
1281
+ const r = await n.selectAll().execute();
1282
+ let s = r.length;
1283
+ if (a != null && a.include_totals) {
1284
+ let c = e.selectFrom("clients").select(h`count(*)`.as("count")).where("clients.tenant_id", "=", t);
1285
+ a != null && a.q && (c = c.where(
1286
+ (m) => m.or([
1287
+ m("name", "like", `%${a.q}%`),
1288
+ m("client_id", "like", `%${a.q}%`)
1289
+ ])
1290
+ ));
1291
+ const l = await c.executeTakeFirst();
1292
+ s = Number((l == null ? void 0 : l.count) || 0);
1293
+ }
1294
+ const i = r.map((c) => ({
1295
+ ...c,
1296
+ // Convert integer fields back to booleans
1297
+ global: !!c.global,
1298
+ is_first_party: !!c.is_first_party,
1299
+ oidc_conformant: !!c.oidc_conformant,
1300
+ auth0_conformant: !!c.auth0_conformant,
1301
+ sso: !!c.sso,
1302
+ sso_disabled: !!c.sso_disabled,
1303
+ cross_origin_authentication: !!c.cross_origin_authentication,
1304
+ custom_login_page_on: !!c.custom_login_page_on,
1305
+ require_pushed_authorization_requests: !!c.require_pushed_authorization_requests,
1306
+ require_proof_of_possession: !!c.require_proof_of_possession,
1307
+ // Parse JSON string fields back to objects/arrays
1308
+ callbacks: JSON.parse(c.callbacks),
1309
+ allowed_origins: JSON.parse(c.allowed_origins),
1310
+ web_origins: JSON.parse(c.web_origins),
1311
+ client_aliases: JSON.parse(c.client_aliases),
1312
+ allowed_clients: JSON.parse(c.allowed_clients),
1313
+ connections: JSON.parse(c.connections || "[]"),
1314
+ allowed_logout_urls: JSON.parse(c.allowed_logout_urls),
1315
+ session_transfer: JSON.parse(c.session_transfer),
1316
+ oidc_logout: JSON.parse(c.oidc_logout),
1317
+ grant_types: JSON.parse(c.grant_types),
1318
+ jwt_configuration: JSON.parse(c.jwt_configuration),
1319
+ signing_keys: JSON.parse(c.signing_keys),
1320
+ encryption_key: JSON.parse(c.encryption_key),
1321
+ addons: JSON.parse(c.addons),
1322
+ client_metadata: JSON.parse(c.client_metadata),
1323
+ mobile: JSON.parse(c.mobile),
1324
+ native_social_login: JSON.parse(c.native_social_login),
1325
+ refresh_token: JSON.parse(c.refresh_token),
1326
+ default_organization: JSON.parse(c.default_organization),
1327
+ client_authentication_methods: JSON.parse(
1328
+ c.client_authentication_methods
1329
+ ),
1330
+ signed_request_object: JSON.parse(c.signed_request_object),
1331
+ token_quota: JSON.parse(c.token_quota)
1332
+ })), d = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10, u = a != null && a.from ? parseInt(a.from, 10) : a != null && a.page ? a.page * d : 0;
1333
+ return {
1334
+ clients: i,
1335
+ totals: {
1336
+ start: isNaN(u) ? 0 : u,
1337
+ limit: d,
1338
+ length: i.length,
1339
+ total: s
1340
+ }
1316
1341
  };
1317
1342
  };
1318
1343
  }
1319
1344
  function qt(e) {
1320
1345
  return async (t, a) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
1321
1346
  }
1322
- function Ut(e) {
1347
+ function Bt(e) {
1323
1348
  return async (t, a, n) => {
1324
1349
  const o = {
1325
1350
  ...n,
@@ -1370,14 +1395,14 @@ function Ut(e) {
1370
1395
  ), (await e.updateTable("clients").set(o).where("clients.tenant_id", "=", t).where("clients.client_id", "=", a).executeTakeFirst()).numUpdatedRows > 0;
1371
1396
  };
1372
1397
  }
1373
- function Bt(e) {
1398
+ function Ut(e) {
1374
1399
  return {
1375
1400
  create: Mt(e),
1376
1401
  get: Jt(e),
1377
1402
  getByClientId: Lt(e),
1378
1403
  list: Kt(e),
1379
1404
  remove: qt(e),
1380
- update: Ut(e)
1405
+ update: Bt(e)
1381
1406
  };
1382
1407
  }
1383
1408
  function Qt(e) {
@@ -1445,7 +1470,7 @@ function Vt(e) {
1445
1470
  }
1446
1471
  function Xt(e) {
1447
1472
  return async (t, a) => {
1448
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = b(), { scope: r, authorization_details_types: s, ...i } = a, c = {
1473
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = k(), { scope: r, authorization_details_types: s, ...i } = a, d = {
1449
1474
  id: o,
1450
1475
  tenant_id: t,
1451
1476
  ...i,
@@ -1457,7 +1482,7 @@ function Xt(e) {
1457
1482
  created_at: n,
1458
1483
  updated_at: n
1459
1484
  };
1460
- return await e.insertInto("client_grants").values(c).execute(), w({
1485
+ return await e.insertInto("client_grants").values(d).execute(), w({
1461
1486
  id: o,
1462
1487
  tenant_id: t,
1463
1488
  ...i,
@@ -1496,27 +1521,27 @@ function Zt(e) {
1496
1521
  function ea(e) {
1497
1522
  return async (t, a = {}) => {
1498
1523
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
1499
- let c = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1524
+ let d = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1500
1525
  if (s) {
1501
- const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, y = g ? g[3] : "", S = /^(>=|>|<=|<)/.test(y || "");
1502
- if (g && !S && y) {
1526
+ const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, y = g ? g[3] : "", b = /^(>=|>|<=|<)/.test(y || "");
1527
+ if (g && !b && y) {
1503
1528
  const C = !!g[1], $ = g[2], { ref: I } = e.dynamic, E = I(`client_grants.${$}`);
1504
1529
  if ($ === "allow_any_organization") {
1505
1530
  const z = y === "true" ? 1 : 0;
1506
- C ? c = c.where(E, "!=", z) : c = c.where(E, "=", z);
1531
+ C ? d = d.where(E, "!=", z) : d = d.where(E, "=", z);
1507
1532
  } else
1508
- C ? c = c.where(E, "!=", y) : c = c.where(E, "=", y);
1533
+ C ? d = d.where(E, "!=", y) : d = d.where(E, "=", y);
1509
1534
  } else
1510
- c = O(e, c, _, []);
1535
+ d = S(e, d, _, []);
1511
1536
  }
1512
- let d = c;
1537
+ let u = d;
1513
1538
  if (i) {
1514
1539
  const { ref: _ } = e.dynamic;
1515
- d = d.orderBy(_(i.sort_by), i.sort_order);
1540
+ u = u.orderBy(_(i.sort_by), i.sort_order);
1516
1541
  } else
1517
- d = d.orderBy("client_grants.created_at", "desc");
1518
- d = d.limit(o).offset(n * o);
1519
- const l = (await d.selectAll().execute()).map((_) => {
1542
+ u = u.orderBy("client_grants.created_at", "desc");
1543
+ u = u.limit(o).offset(n * o);
1544
+ const l = (await u.selectAll().execute()).map((_) => {
1520
1545
  const p = {
1521
1546
  id: _.id,
1522
1547
  client_id: _.client_id,
@@ -1540,12 +1565,12 @@ function ea(e) {
1540
1565
  limit: 0,
1541
1566
  length: 0
1542
1567
  };
1543
- const { count: m } = await c.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1568
+ const { count: m } = await d.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1544
1569
  return {
1545
1570
  client_grants: l,
1546
1571
  start: n * o,
1547
1572
  limit: o,
1548
- length: k(m)
1573
+ length: O(m)
1549
1574
  };
1550
1575
  };
1551
1576
  }
@@ -1554,13 +1579,13 @@ function ta(e) {
1554
1579
  }
1555
1580
  function aa(e) {
1556
1581
  return async (t, a, n) => {
1557
- const o = (/* @__PURE__ */ new Date()).toISOString(), { scope: r, authorization_details_types: s, ...i } = n, c = {
1582
+ const o = (/* @__PURE__ */ new Date()).toISOString(), { scope: r, authorization_details_types: s, ...i } = n, d = {
1558
1583
  ...i,
1559
1584
  updated_at: o
1560
1585
  };
1561
- return r !== void 0 && (c.scope = JSON.stringify(r)), s !== void 0 && (c.authorization_details_types = JSON.stringify(
1586
+ return r !== void 0 && (d.scope = JSON.stringify(r)), s !== void 0 && (d.authorization_details_types = JSON.stringify(
1562
1587
  s
1563
- )), i.allow_any_organization !== void 0 && (c.allow_any_organization = i.allow_any_organization ? 1 : 0), i.is_system !== void 0 && (c.is_system = i.is_system ? 1 : 0), ((await e.updateTable("client_grants").set(c).where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", a).executeTakeFirst()).numUpdatedRows ?? 0n) > 0n;
1588
+ )), i.allow_any_organization !== void 0 && (d.allow_any_organization = i.allow_any_organization ? 1 : 0), i.is_system !== void 0 && (d.is_system = i.is_system ? 1 : 0), ((await e.updateTable("client_grants").set(d).where("client_grants.tenant_id", "=", t).where("client_grants.id", "=", a).executeTakeFirst()).numUpdatedRows ?? 0n) > 0n;
1564
1589
  };
1565
1590
  }
1566
1591
  function na(e) {
@@ -1587,28 +1612,28 @@ function oa(e) {
1587
1612
  _("revoked_at", "is", null)
1588
1613
  ])
1589
1614
  );
1590
- s && (i = O(e, i, s, [
1615
+ s && (i = S(e, i, s, [
1591
1616
  "kid",
1592
1617
  "connection",
1593
1618
  "fingerprint",
1594
1619
  "thumbprint",
1595
1620
  "type"
1596
1621
  ]));
1597
- let c = i.select((_) => _.fn.count("kid").as("count"));
1598
- const d = a * n;
1599
- i = i.limit(n).offset(d), r && (i = i.orderBy(r.sort_by, r.sort_order));
1600
- const u = await i.selectAll().execute();
1622
+ let d = i.select((_) => _.fn.count("kid").as("count"));
1623
+ const u = a * n;
1624
+ i = i.limit(n).offset(u), r && (i = i.orderBy(r.sort_by, r.sort_order));
1625
+ const c = await i.selectAll().execute();
1601
1626
  if (!o)
1602
1627
  return {
1603
- signingKeys: u,
1628
+ signingKeys: c,
1604
1629
  start: 0,
1605
1630
  limit: 0,
1606
1631
  length: 0
1607
1632
  };
1608
- const l = await c.executeTakeFirst(), m = k((l == null ? void 0 : l.count) ?? 0);
1633
+ const l = await d.executeTakeFirst(), m = O((l == null ? void 0 : l.count) ?? 0);
1609
1634
  return {
1610
- signingKeys: u,
1611
- start: d,
1635
+ signingKeys: c,
1636
+ start: u,
1612
1637
  limit: n,
1613
1638
  length: m
1614
1639
  };
@@ -1632,7 +1657,7 @@ function ia(e) {
1632
1657
  function ca(e) {
1633
1658
  return async (t, a) => {
1634
1659
  const n = {
1635
- custom_domain_id: a.custom_domain_id || b(),
1660
+ custom_domain_id: a.custom_domain_id || k(),
1636
1661
  status: "pending",
1637
1662
  primary: !1,
1638
1663
  ...a
@@ -1679,7 +1704,7 @@ function ua(e) {
1679
1704
  }
1680
1705
  function _a(e) {
1681
1706
  return async (t, a, n) => {
1682
- const { verification: o, domain_metadata: r, primary: s, ...i } = n, c = {
1707
+ const { verification: o, domain_metadata: r, primary: s, ...i } = n, d = {
1683
1708
  ...i,
1684
1709
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1685
1710
  ...s !== void 0 && { primary: s ? 1 : 0 },
@@ -1690,7 +1715,7 @@ function _a(e) {
1690
1715
  verification: JSON.stringify(o)
1691
1716
  }
1692
1717
  };
1693
- return (await e.updateTable("custom_domains").set(c).where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
1718
+ return (await e.updateTable("custom_domains").set(d).where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
1694
1719
  };
1695
1720
  }
1696
1721
  function ma(e) {
@@ -1727,36 +1752,36 @@ function pa(e) {
1727
1752
  colors_page_background_type: r,
1728
1753
  colors_page_background_start: s,
1729
1754
  colors_page_background_end: i,
1730
- colors_page_background_angle_dev: c,
1731
- font_url: d,
1732
- ...u
1755
+ colors_page_background_angle_dev: d,
1756
+ font_url: u,
1757
+ ...c
1733
1758
  } = a;
1734
1759
  return w({
1735
- ...u,
1760
+ ...c,
1736
1761
  colors: {
1737
1762
  primary: o,
1738
1763
  page_background: {
1739
1764
  type: r,
1740
1765
  start: s,
1741
1766
  end: i,
1742
- angle_deg: c
1767
+ angle_deg: d
1743
1768
  }
1744
1769
  },
1745
- font: d ? { url: d } : void 0
1770
+ font: u ? { url: u } : void 0
1746
1771
  });
1747
1772
  };
1748
1773
  }
1749
1774
  function fa(e) {
1750
1775
  return async (t, a) => {
1751
- var s, i, c, d, u, l, m, _, p, f, g, y, S, C, $, I, E, z;
1776
+ var s, i, d, u, c, l, m, _, p, f, g, y, b, C, $, I, E, z;
1752
1777
  const { colors: n, font: o, ...r } = a;
1753
1778
  try {
1754
1779
  await e.insertInto("branding").values({
1755
1780
  ...r,
1756
1781
  colors_primary: n == null ? void 0 : n.primary,
1757
1782
  colors_page_background_type: (i = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
1758
- colors_page_background_start: (d = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : d.start,
1759
- colors_page_background_end: (l = (u = a.colors) == null ? void 0 : u.page_background) == null ? void 0 : l.end,
1783
+ colors_page_background_start: (u = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : u.start,
1784
+ colors_page_background_end: (l = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : l.end,
1760
1785
  colors_page_background_angle_dev: (_ = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : _.angle_deg,
1761
1786
  font_url: (p = a.font) == null ? void 0 : p.url,
1762
1787
  tenant_id: t
@@ -1766,7 +1791,7 @@ function fa(e) {
1766
1791
  ...r,
1767
1792
  colors_primary: n == null ? void 0 : n.primary,
1768
1793
  colors_page_background_type: (g = (f = a.colors) == null ? void 0 : f.page_background) == null ? void 0 : g.type,
1769
- colors_page_background_start: (S = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : S.start,
1794
+ colors_page_background_start: (b = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : b.start,
1770
1795
  colors_page_background_end: ($ = (C = a.colors) == null ? void 0 : C.page_background) == null ? void 0 : $.end,
1771
1796
  colors_page_background_angle_dev: (E = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : E.angle_deg,
1772
1797
  font_url: (z = a.font) == null ? void 0 : z.url
@@ -1822,21 +1847,21 @@ function xa(e) {
1822
1847
  return async (t, a = {}) => {
1823
1848
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1824
1849
  let i = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
1825
- s && (i = O(e, i, s, ["url", "form_id", "template_id"]));
1826
- const u = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
1850
+ s && (i = S(e, i, s, ["url", "form_id", "template_id"]));
1851
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
1827
1852
  const {
1828
1853
  tenant_id: _,
1829
1854
  enabled: p,
1830
1855
  synchronous: f,
1831
1856
  created_at_ts: g,
1832
1857
  updated_at_ts: y,
1833
- ...S
1858
+ ...b
1834
1859
  } = m, C = D({ created_at_ts: g, updated_at_ts: y }, [
1835
1860
  "created_at_ts",
1836
1861
  "updated_at_ts"
1837
1862
  ]);
1838
1863
  return w({
1839
- ...S,
1864
+ ...b,
1840
1865
  ...C,
1841
1866
  enabled: !!p,
1842
1867
  synchronous: !!f
@@ -1844,17 +1869,17 @@ function xa(e) {
1844
1869
  });
1845
1870
  if (!r)
1846
1871
  return {
1847
- hooks: u,
1872
+ hooks: c,
1848
1873
  start: 0,
1849
1874
  limit: 0,
1850
1875
  length: 0
1851
1876
  };
1852
1877
  const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1853
1878
  return {
1854
- hooks: u,
1879
+ hooks: c,
1855
1880
  start: n * o,
1856
1881
  limit: o,
1857
- length: k(l)
1882
+ length: O(l)
1858
1883
  };
1859
1884
  };
1860
1885
  }
@@ -1868,13 +1893,13 @@ function Ta(e) {
1868
1893
  created_at_ts: r,
1869
1894
  updated_at_ts: s,
1870
1895
  ...i
1871
- } = n, c = D({ created_at_ts: r, updated_at_ts: s }, [
1896
+ } = n, d = D({ created_at_ts: r, updated_at_ts: s }, [
1872
1897
  "created_at_ts",
1873
1898
  "updated_at_ts"
1874
1899
  ]);
1875
1900
  return w({
1876
1901
  ...i,
1877
- ...c,
1902
+ ...d,
1878
1903
  enabled: !!i.enabled,
1879
1904
  synchronous: !!i.synchronous
1880
1905
  });
@@ -1883,11 +1908,11 @@ function Ta(e) {
1883
1908
  function Na(e) {
1884
1909
  return async (t, a) => (await e.deleteFrom("hooks").where("hooks.tenant_id", "=", t).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
1885
1910
  }
1886
- function Sa(e) {
1911
+ function ba(e) {
1887
1912
  return async (t, a) => {
1888
- const n = Date.now(), o = a.hook_id || $t(), { hook_id: r, enabled: s, synchronous: i, ...c } = a;
1913
+ const n = Date.now(), o = a.hook_id || $t(), { hook_id: r, enabled: s, synchronous: i, ...d } = a;
1889
1914
  return await e.insertInto("hooks").values({
1890
- ...c,
1915
+ ...d,
1891
1916
  hook_id: o,
1892
1917
  tenant_id: t,
1893
1918
  enabled: s ? 1 : 0,
@@ -1895,7 +1920,7 @@ function Sa(e) {
1895
1920
  created_at_ts: n,
1896
1921
  updated_at_ts: n
1897
1922
  }).execute(), {
1898
- ...c,
1923
+ ...d,
1899
1924
  hook_id: o,
1900
1925
  enabled: s ?? !1,
1901
1926
  synchronous: i ?? !1,
@@ -1904,7 +1929,7 @@ function Sa(e) {
1904
1929
  };
1905
1930
  };
1906
1931
  }
1907
- function ba(e) {
1932
+ function Sa(e) {
1908
1933
  return async (t, a, n) => {
1909
1934
  const { hook_id: o, ...r } = n, s = {
1910
1935
  ...r,
@@ -1917,17 +1942,17 @@ function ba(e) {
1917
1942
  }
1918
1943
  function Oa(e) {
1919
1944
  return {
1920
- create: Sa(e),
1945
+ create: ba(e),
1921
1946
  get: Ta(e),
1922
1947
  list: xa(e),
1923
- update: ba(e),
1948
+ update: Sa(e),
1924
1949
  remove: Na(e)
1925
1950
  };
1926
1951
  }
1927
1952
  function ka(e) {
1928
1953
  return async (t, a, n) => {
1929
1954
  const o = {
1930
- themeId: n || b(),
1955
+ themeId: n || k(),
1931
1956
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1932
1957
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1933
1958
  ...a
@@ -1988,7 +2013,7 @@ function Pa(e) {
1988
2013
  return async (t, a) => {
1989
2014
  const n = await e.selectFrom("login_sessions").where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1990
2015
  if (!n) return null;
1991
- const { created_at_ts: o, updated_at_ts: r, expires_at_ts: s, ...i } = n, c = D(
2016
+ const { created_at_ts: o, updated_at_ts: r, expires_at_ts: s, ...i } = n, d = D(
1992
2017
  { created_at_ts: o, updated_at_ts: r, expires_at_ts: s },
1993
2018
  ["created_at_ts", "updated_at_ts", "expires_at_ts"]
1994
2019
  );
@@ -1996,7 +2021,7 @@ function Pa(e) {
1996
2021
  le(
1997
2022
  w({
1998
2023
  ...i,
1999
- ...c,
2024
+ ...d,
2000
2025
  state: n.state || ie.PENDING,
2001
2026
  state_data: n.state_data,
2002
2027
  failure_reason: n.failure_reason
@@ -2049,9 +2074,9 @@ function Fa(e) {
2049
2074
  }
2050
2075
  function Ra(e) {
2051
2076
  return async (t, a, n) => {
2052
- const { created_at: o, updated_at: r, expires_at: s, ...i } = n, c = R(i);
2053
- return delete c.created_at_ts, delete c.updated_at_ts, delete c.expires_at_ts, delete c.id, delete c.tenant_id, (await e.updateTable("login_sessions").set({
2054
- ...c,
2077
+ const { created_at: o, updated_at: r, expires_at: s, ...i } = n, d = R(i);
2078
+ return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
2079
+ ...d,
2055
2080
  updated_at_ts: Date.now(),
2056
2081
  // Only update expires_at_ts if a new expires_at was provided
2057
2082
  // Use !== undefined to preserve null values (which mean "doesn't expire")
@@ -2109,7 +2134,7 @@ function qa(e) {
2109
2134
  set: Ka(e)
2110
2135
  };
2111
2136
  }
2112
- function Ua(e) {
2137
+ function Ba(e) {
2113
2138
  return async (t) => {
2114
2139
  const [a] = await e.selectFrom("email_providers").where("email_providers.tenant_id", "=", t).selectAll().execute();
2115
2140
  if (!a)
@@ -2129,7 +2154,7 @@ function Ua(e) {
2129
2154
  });
2130
2155
  };
2131
2156
  }
2132
- function Ba(e) {
2157
+ function Ua(e) {
2133
2158
  return async (t, a) => {
2134
2159
  const { credentials: n, settings: o, enabled: r, ...s } = a;
2135
2160
  await e.updateTable("email_providers").set({
@@ -2161,9 +2186,9 @@ function Ha(e) {
2161
2186
  }
2162
2187
  function Ya(e) {
2163
2188
  return {
2164
- get: Ua(e),
2189
+ get: Ba(e),
2165
2190
  create: Qa(e),
2166
- update: Ba(e),
2191
+ update: Ua(e),
2167
2192
  remove: Ha(e)
2168
2193
  };
2169
2194
  }
@@ -2177,21 +2202,21 @@ function Wa(e) {
2177
2202
  created_at_ts: r,
2178
2203
  expires_at_ts: s,
2179
2204
  idle_expires_at_ts: i,
2180
- last_exchanged_at_ts: c,
2181
- ...d
2182
- } = n, u = D(
2205
+ last_exchanged_at_ts: d,
2206
+ ...u
2207
+ } = n, c = D(
2183
2208
  {
2184
2209
  created_at_ts: r,
2185
2210
  expires_at_ts: s,
2186
2211
  idle_expires_at_ts: i,
2187
- last_exchanged_at_ts: c
2212
+ last_exchanged_at_ts: d
2188
2213
  },
2189
2214
  ["created_at_ts"],
2190
2215
  ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
2191
2216
  );
2192
2217
  return {
2193
- ...d,
2194
2218
  ...u,
2219
+ ...c,
2195
2220
  rotating: !!n.rotating,
2196
2221
  device: n.device ? JSON.parse(n.device) : {},
2197
2222
  resource_servers: n.resource_servers ? JSON.parse(n.resource_servers) : []
@@ -2207,17 +2232,17 @@ function Ga(e) {
2207
2232
  expires_at: r,
2208
2233
  idle_expires_at: s,
2209
2234
  last_exchanged_at: i,
2210
- device: c,
2211
- resource_servers: d,
2212
- rotating: u,
2235
+ device: d,
2236
+ resource_servers: u,
2237
+ rotating: c,
2213
2238
  ...l
2214
2239
  } = a, m = Date.now();
2215
2240
  return await e.insertInto("refresh_tokens").values({
2216
2241
  ...l,
2217
2242
  tenant_id: t,
2218
- rotating: u ? 1 : 0,
2219
- device: JSON.stringify(c),
2220
- resource_servers: JSON.stringify(d),
2243
+ rotating: c ? 1 : 0,
2244
+ device: JSON.stringify(d),
2245
+ resource_servers: JSON.stringify(u),
2221
2246
  created_at_ts: m,
2222
2247
  expires_at_ts: v(r),
2223
2248
  idle_expires_at_ts: s ? v(s) : null,
@@ -2235,15 +2260,15 @@ function Xa(e) {
2235
2260
  expires_at: r,
2236
2261
  idle_expires_at: s,
2237
2262
  last_exchanged_at: i,
2238
- device: c,
2239
- resource_servers: d,
2240
- rotating: u,
2263
+ device: d,
2264
+ resource_servers: u,
2265
+ rotating: c,
2241
2266
  ...l
2242
2267
  } = n, m = {
2243
2268
  ...l,
2244
- device: c ? JSON.stringify(c) : void 0,
2245
- resource_servers: d ? JSON.stringify(d) : void 0,
2246
- rotating: u !== void 0 ? u ? 1 : 0 : void 0,
2269
+ device: d ? JSON.stringify(d) : void 0,
2270
+ resource_servers: u ? JSON.stringify(u) : void 0,
2271
+ rotating: c !== void 0 ? c ? 1 : 0 : void 0,
2247
2272
  // Convert date fields to bigint format
2248
2273
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2249
2274
  expires_at_ts: r !== void 0 ? v(r) : void 0,
@@ -2256,27 +2281,27 @@ function Xa(e) {
2256
2281
  function Za(e) {
2257
2282
  return async (t, a = {}) => {
2258
2283
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
2259
- let c = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
2260
- i && (c = O(e, c, i, ["token", "login_id"]));
2261
- let d = c;
2284
+ let d = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
2285
+ i && (d = S(e, d, i, ["token", "login_id"]));
2286
+ let u = d;
2262
2287
  if (s && s.sort_by) {
2263
2288
  const { ref: p } = e.dynamic;
2264
- d = d.orderBy(p(s.sort_by), s.sort_order);
2289
+ u = u.orderBy(p(s.sort_by), s.sort_order);
2265
2290
  }
2266
- d = d.offset(n * o).limit(o);
2267
- const l = (await d.selectAll().execute()).map((p) => {
2291
+ u = u.offset(n * o).limit(o);
2292
+ const l = (await u.selectAll().execute()).map((p) => {
2268
2293
  const {
2269
2294
  tenant_id: f,
2270
2295
  created_at_ts: g,
2271
2296
  expires_at_ts: y,
2272
- idle_expires_at_ts: S,
2297
+ idle_expires_at_ts: b,
2273
2298
  last_exchanged_at_ts: C,
2274
2299
  ...$
2275
2300
  } = p, I = D(
2276
2301
  {
2277
2302
  created_at_ts: g,
2278
2303
  expires_at_ts: y,
2279
- idle_expires_at_ts: S,
2304
+ idle_expires_at_ts: b,
2280
2305
  last_exchanged_at_ts: C
2281
2306
  },
2282
2307
  ["created_at_ts"],
@@ -2297,7 +2322,7 @@ function Za(e) {
2297
2322
  limit: 0,
2298
2323
  length: 0
2299
2324
  };
2300
- const { count: m } = await c.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = k(m);
2325
+ const { count: m } = await d.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = O(m);
2301
2326
  return {
2302
2327
  refresh_tokens: l,
2303
2328
  start: n * o,
@@ -2318,10 +2343,10 @@ function en(e) {
2318
2343
  const tn = 7 * 24 * 60 * 60 * 1e3;
2319
2344
  function an(e) {
2320
2345
  return async (t) => {
2321
- var i, c, d;
2346
+ var i, d, u;
2322
2347
  const { tenant_id: a, user_id: n } = t || {}, r = Date.now() - tn, s = 1e3;
2323
2348
  try {
2324
- let u = 0;
2349
+ let c = 0;
2325
2350
  for (; ; ) {
2326
2351
  let _ = e.deleteFrom("refresh_tokens").where(
2327
2352
  (g) => g.or([
@@ -2339,7 +2364,7 @@ function an(e) {
2339
2364
  n
2340
2365
  ));
2341
2366
  const p = await _.limit(s).execute(), f = Number(((i = p[0]) == null ? void 0 : i.numDeletedRows) ?? 0);
2342
- if (u += f, f < s) break;
2367
+ if (c += f, f < s) break;
2343
2368
  }
2344
2369
  let l = 0;
2345
2370
  for (; ; ) {
@@ -2350,7 +2375,7 @@ function an(e) {
2350
2375
  ])
2351
2376
  );
2352
2377
  a && (_ = _.where("tenant_id", "=", a)), n && (_ = _.where("user_id", "=", n));
2353
- const p = await _.limit(s).execute(), f = Number(((c = p[0]) == null ? void 0 : c.numDeletedRows) ?? 0);
2378
+ const p = await _.limit(s).execute(), f = Number(((d = p[0]) == null ? void 0 : d.numDeletedRows) ?? 0);
2354
2379
  if (l += f, f < s) break;
2355
2380
  }
2356
2381
  let m = 0;
@@ -2365,21 +2390,21 @@ function an(e) {
2365
2390
  "=",
2366
2391
  n
2367
2392
  ));
2368
- const p = await _.limit(s).execute(), f = Number(((d = p[0]) == null ? void 0 : d.numDeletedRows) ?? 0);
2393
+ const p = await _.limit(s).execute(), f = Number(((u = p[0]) == null ? void 0 : u.numDeletedRows) ?? 0);
2369
2394
  if (m += f, f < s) break;
2370
2395
  }
2371
- (u > 0 || l > 0 || m > 0) && console.log(
2372
- `Session cleanup: deleted ${u} refresh_tokens, ${l} sessions, ${m} login_sessions`
2396
+ (c > 0 || l > 0 || m > 0) && console.log(
2397
+ `Session cleanup: deleted ${c} refresh_tokens, ${l} sessions, ${m} login_sessions`
2373
2398
  );
2374
- } catch (u) {
2375
- console.error("Error during session cleanup:", u);
2399
+ } catch (c) {
2400
+ console.error("Error during session cleanup:", c);
2376
2401
  }
2377
2402
  };
2378
2403
  }
2379
2404
  function nn(e) {
2380
2405
  return async (t, a) => {
2381
2406
  const n = q.parse({
2382
- id: b(),
2407
+ id: k(),
2383
2408
  ...a,
2384
2409
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
2385
2410
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -2398,8 +2423,8 @@ function on(e) {
2398
2423
  return async (t, a = {}) => {
2399
2424
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2400
2425
  let i = e.selectFrom("forms").where("tenant_id", "=", t);
2401
- s && (i = O(e, i, s, []));
2402
- const u = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2426
+ s && (i = S(e, i, s, []));
2427
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2403
2428
  const _ = { ...m };
2404
2429
  if (typeof _.nodes == "string")
2405
2430
  try {
@@ -2420,17 +2445,17 @@ function on(e) {
2420
2445
  });
2421
2446
  if (!r)
2422
2447
  return {
2423
- forms: u,
2448
+ forms: c,
2424
2449
  start: 0,
2425
2450
  limit: 0,
2426
2451
  length: 0
2427
2452
  };
2428
2453
  const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2429
2454
  return {
2430
- forms: u,
2455
+ forms: c,
2431
2456
  start: n * o,
2432
2457
  limit: o,
2433
- length: k(l)
2458
+ length: O(l)
2434
2459
  };
2435
2460
  };
2436
2461
  }
@@ -2493,9 +2518,9 @@ function dn(e) {
2493
2518
  }, r = De.parse(o), {
2494
2519
  verificationKey: s,
2495
2520
  scopes: i,
2496
- options: c,
2497
- skip_consent_for_verifiable_first_party_clients: d,
2498
- allow_offline_access: u,
2521
+ options: d,
2522
+ skip_consent_for_verifiable_first_party_clients: u,
2523
+ allow_offline_access: c,
2499
2524
  is_system: l,
2500
2525
  metadata: m,
2501
2526
  ..._
@@ -2503,9 +2528,9 @@ function dn(e) {
2503
2528
  ..._,
2504
2529
  tenant_id: t,
2505
2530
  scopes: i ? JSON.stringify(i) : "[]",
2506
- options: c ? JSON.stringify(c) : "{}",
2507
- skip_consent_for_verifiable_first_party_clients: d ? 1 : 0,
2508
- allow_offline_access: u ? 1 : 0,
2531
+ options: d ? JSON.stringify(d) : "{}",
2532
+ skip_consent_for_verifiable_first_party_clients: u ? 1 : 0,
2533
+ allow_offline_access: c ? 1 : 0,
2509
2534
  is_system: l ? 1 : 0,
2510
2535
  metadata: m ? JSON.stringify(m) : void 0,
2511
2536
  verification_key: s,
@@ -2523,18 +2548,18 @@ function un(e) {
2523
2548
  verification_key: r,
2524
2549
  scopes: s,
2525
2550
  options: i,
2526
- skip_consent_for_verifiable_first_party_clients: c,
2527
- allow_offline_access: d,
2528
- is_system: u,
2551
+ skip_consent_for_verifiable_first_party_clients: d,
2552
+ allow_offline_access: u,
2553
+ is_system: c,
2529
2554
  metadata: l,
2530
2555
  ...m
2531
2556
  } = o, _ = {
2532
2557
  ...m,
2533
2558
  scopes: s ? JSON.parse(s) : [],
2534
2559
  options: i ? JSON.parse(i) : {},
2535
- skip_consent_for_verifiable_first_party_clients: !!c,
2536
- allow_offline_access: !!d,
2537
- is_system: u ? !0 : void 0,
2560
+ skip_consent_for_verifiable_first_party_clients: !!d,
2561
+ allow_offline_access: !!u,
2562
+ is_system: c ? !0 : void 0,
2538
2563
  metadata: l ? JSON.parse(l) : void 0,
2539
2564
  // Convert verification_key back to verificationKey for API
2540
2565
  verificationKey: r
@@ -2549,21 +2574,21 @@ function _n(e) {
2549
2574
  if (s) {
2550
2575
  const m = s.trim(), _ = m.split(/\s+/), p = _.length === 1 ? _[0] : void 0, f = p ? p.match(/^(-)?(name|identifier):(.*)$/) : null, g = f ? f[3] : "", y = /^(>=|>|<=|<)/.test(g || "");
2551
2576
  if (f && !y) {
2552
- const S = !!f[1], C = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2553
- i = S ? i.where(C, "not like", `%${g}%`) : i.where(C, "like", `%${g}%`);
2577
+ const b = !!f[1], C = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2578
+ i = b ? i.where(C, "not like", `%${g}%`) : i.where(C, "like", `%${g}%`);
2554
2579
  } else
2555
- i = O(e, i, m, [
2580
+ i = S(e, i, m, [
2556
2581
  "resource_servers.name",
2557
2582
  "resource_servers.identifier"
2558
2583
  ]);
2559
2584
  }
2560
- const u = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2585
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2561
2586
  const _ = m, {
2562
2587
  verification_key: p,
2563
2588
  scopes: f,
2564
2589
  options: g,
2565
2590
  skip_consent_for_verifiable_first_party_clients: y,
2566
- allow_offline_access: S,
2591
+ allow_offline_access: b,
2567
2592
  is_system: C,
2568
2593
  metadata: $,
2569
2594
  ...I
@@ -2572,7 +2597,7 @@ function _n(e) {
2572
2597
  scopes: f ? JSON.parse(f) : [],
2573
2598
  options: g ? JSON.parse(g) : {},
2574
2599
  skip_consent_for_verifiable_first_party_clients: !!y,
2575
- allow_offline_access: !!S,
2600
+ allow_offline_access: !!b,
2576
2601
  is_system: C ? !0 : void 0,
2577
2602
  metadata: $ ? JSON.parse($) : void 0,
2578
2603
  // Convert verification_key back to verificationKey for API
@@ -2582,17 +2607,17 @@ function _n(e) {
2582
2607
  });
2583
2608
  if (!r)
2584
2609
  return {
2585
- resource_servers: u,
2610
+ resource_servers: c,
2586
2611
  start: 0,
2587
2612
  limit: 0,
2588
2613
  length: 0
2589
2614
  };
2590
2615
  const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2591
2616
  return {
2592
- resource_servers: u,
2617
+ resource_servers: c,
2593
2618
  start: n * o,
2594
2619
  limit: o,
2595
- length: k(l)
2620
+ length: O(l)
2596
2621
  };
2597
2622
  };
2598
2623
  }
@@ -2609,9 +2634,9 @@ function hn(e) {
2609
2634
  scopes: r,
2610
2635
  options: s,
2611
2636
  skip_consent_for_verifiable_first_party_clients: i,
2612
- allow_offline_access: c,
2613
- is_system: d,
2614
- metadata: u,
2637
+ allow_offline_access: d,
2638
+ is_system: u,
2639
+ metadata: c,
2615
2640
  ...l
2616
2641
  } = n, m = {
2617
2642
  ...l,
@@ -2621,7 +2646,7 @@ function hn(e) {
2621
2646
  const p = await e.selectFrom("resource_servers").select("options").where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst(), g = { ...p != null && p.options ? JSON.parse(p.options) : {}, ...s };
2622
2647
  m.options = JSON.stringify(g);
2623
2648
  }
2624
- u !== void 0 && (m.metadata = JSON.stringify(u)), i !== void 0 && (m.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), c !== void 0 && (m.allow_offline_access = c ? 1 : 0), d !== void 0 && (m.is_system = d ? 1 : 0);
2649
+ c !== void 0 && (m.metadata = JSON.stringify(c)), i !== void 0 && (m.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), d !== void 0 && (m.allow_offline_access = d ? 1 : 0), u !== void 0 && (m.is_system = u ? 1 : 0);
2625
2650
  const _ = await e.updateTable("resource_servers").set(m).where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
2626
2651
  return Number(_.numUpdatedRows) > 0;
2627
2652
  };
@@ -2637,18 +2662,18 @@ function pn(e) {
2637
2662
  }
2638
2663
  function fn(e) {
2639
2664
  return async (t, a) => {
2640
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || b(), { is_system: r, id: s, metadata: i, ...c } = a, d = {
2665
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || k(), { is_system: r, id: s, metadata: i, ...d } = a, u = {
2641
2666
  id: o,
2642
- ...c,
2667
+ ...d,
2643
2668
  tenant_id: t,
2644
2669
  is_system: r ? 1 : 0,
2645
2670
  metadata: i ? JSON.stringify(i) : void 0,
2646
2671
  created_at: n,
2647
2672
  updated_at: n
2648
2673
  };
2649
- return await e.insertInto("roles").values(d).execute(), {
2674
+ return await e.insertInto("roles").values(u).execute(), {
2650
2675
  id: o,
2651
- ...c,
2676
+ ...d,
2652
2677
  is_system: r ? !0 : void 0,
2653
2678
  metadata: i,
2654
2679
  created_at: n,
@@ -2660,9 +2685,9 @@ function gn(e) {
2660
2685
  return async (t, a) => {
2661
2686
  const n = await e.selectFrom("roles").selectAll().where("roles.tenant_id", "=", t).where("roles.id", "=", a).executeTakeFirst();
2662
2687
  if (!n) return null;
2663
- const o = n, { is_system: r, tenant_id: s, metadata: i, ...c } = o;
2688
+ const o = n, { is_system: r, tenant_id: s, metadata: i, ...d } = o;
2664
2689
  return {
2665
- ...c,
2690
+ ...d,
2666
2691
  is_system: r ? !0 : void 0,
2667
2692
  metadata: i ? JSON.parse(i) : void 0
2668
2693
  };
@@ -2672,8 +2697,8 @@ function wn(e) {
2672
2697
  return async (t, a) => {
2673
2698
  let n = e.selectFrom("roles").where("roles.tenant_id", "=", t);
2674
2699
  const { page: o = 0, per_page: r = 50, include_totals: s = !1 } = a;
2675
- a.q && (n = O(e, n, a.q, ["name"]));
2676
- const d = (await n.offset(o * r).limit(r).selectAll().execute()).map((l) => {
2700
+ a.q && (n = S(e, n, a.q, ["name"]));
2701
+ const u = (await n.offset(o * r).limit(r).selectAll().execute()).map((l) => {
2677
2702
  const m = l, { is_system: _, tenant_id: p, metadata: f, ...g } = m;
2678
2703
  return {
2679
2704
  ...g,
@@ -2683,17 +2708,17 @@ function wn(e) {
2683
2708
  });
2684
2709
  if (!s)
2685
2710
  return {
2686
- roles: d,
2711
+ roles: u,
2687
2712
  start: o * r,
2688
2713
  limit: r,
2689
- length: d.length
2714
+ length: u.length
2690
2715
  };
2691
- const { count: u } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
2716
+ const { count: c } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
2692
2717
  return {
2693
- roles: d,
2718
+ roles: u,
2694
2719
  start: o * r,
2695
2720
  limit: r,
2696
- length: k(u)
2721
+ length: O(c)
2697
2722
  };
2698
2723
  };
2699
2724
  }
@@ -2704,8 +2729,8 @@ function yn(e) {
2704
2729
  is_system: o !== void 0 ? o ? 1 : 0 : void 0,
2705
2730
  metadata: r !== void 0 ? JSON.stringify(r) : void 0,
2706
2731
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2707
- }, c = await e.updateTable("roles").set(i).where("roles.tenant_id", "=", t).where("roles.id", "=", a).executeTakeFirst();
2708
- return Number(c.numUpdatedRows) > 0;
2732
+ }, d = await e.updateTable("roles").set(i).where("roles.tenant_id", "=", t).where("roles.id", "=", a).executeTakeFirst();
2733
+ return Number(d.numUpdatedRows) > 0;
2709
2734
  };
2710
2735
  }
2711
2736
  function vn(e) {
@@ -2793,7 +2818,7 @@ function Nn(e) {
2793
2818
  "role_permissions.created_at",
2794
2819
  "resource_servers.name as resource_server_name"
2795
2820
  ]).where("role_permissions.tenant_id", "=", t).where("role_permissions.role_id", "=", a);
2796
- const u = (await i.offset(o * r).limit(r).execute()).map((l) => ({
2821
+ const c = (await i.offset(o * r).limit(r).execute()).map((l) => ({
2797
2822
  role_id: l.role_id,
2798
2823
  resource_server_identifier: l.resource_server_identifier,
2799
2824
  resource_server_name: l.resource_server_name || l.resource_server_identifier,
@@ -2803,17 +2828,17 @@ function Nn(e) {
2803
2828
  // No description available from role_permissions directly
2804
2829
  created_at: l.created_at
2805
2830
  }));
2806
- return s && await i.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), u;
2831
+ return s && await i.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c;
2807
2832
  };
2808
2833
  }
2809
- function Sn(e) {
2834
+ function bn(e) {
2810
2835
  return {
2811
2836
  assign: xn(e),
2812
2837
  remove: Tn(e),
2813
2838
  list: Nn(e)
2814
2839
  };
2815
2840
  }
2816
- function bn(e) {
2841
+ function Sn(e) {
2817
2842
  return async (t, a, n, o) => {
2818
2843
  const r = (/* @__PURE__ */ new Date()).toISOString();
2819
2844
  try {
@@ -2885,7 +2910,7 @@ function kn(e) {
2885
2910
  }
2886
2911
  function $n(e) {
2887
2912
  return {
2888
- create: bn(e),
2913
+ create: Sn(e),
2889
2914
  remove: On(e),
2890
2915
  list: kn(e)
2891
2916
  };
@@ -3000,20 +3025,20 @@ function Rn(e) {
3000
3025
  return async (t, a) => {
3001
3026
  let n = e.selectFrom("organizations").selectAll().where("tenant_id", "=", t);
3002
3027
  if (a != null && a.q && (n = n.where(
3003
- (u) => u.or([
3004
- u("name", "like", `%${a.q}%`),
3005
- u("display_name", "like", `%${a.q}%`)
3028
+ (c) => c.or([
3029
+ c("name", "like", `%${a.q}%`),
3030
+ c("display_name", "like", `%${a.q}%`)
3006
3031
  ])
3007
3032
  )), a != null && a.sort) {
3008
- const u = a.sort.sort_order === "asc" ? "asc" : "desc", l = a.sort.sort_by;
3009
- ["name", "display_name", "created_at"].includes(l) ? n = n.orderBy(l, u) : n = n.orderBy("created_at", "desc");
3033
+ const c = a.sort.sort_order === "asc" ? "asc" : "desc", l = a.sort.sort_by;
3034
+ ["name", "display_name", "created_at"].includes(l) ? n = n.orderBy(l, c) : n = n.orderBy("created_at", "desc");
3010
3035
  } else
3011
3036
  n = n.orderBy("created_at", "desc");
3012
3037
  if ((a == null ? void 0 : a.from) !== void 0) {
3013
- const u = parseInt(a.from, 10);
3014
- isNaN(u) || (n = n.offset(u));
3038
+ const c = parseInt(a.from, 10);
3039
+ isNaN(c) || (n = n.offset(c));
3015
3040
  } else if ((a == null ? void 0 : a.page) !== void 0) {
3016
- const u = (a == null ? void 0 : a.per_page) || (a == null ? void 0 : a.take) || 10, l = a.page * u;
3041
+ const c = (a == null ? void 0 : a.per_page) || (a == null ? void 0 : a.take) || 10, l = a.page * c;
3017
3042
  n = n.offset(l);
3018
3043
  }
3019
3044
  const o = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10;
@@ -3021,29 +3046,29 @@ function Rn(e) {
3021
3046
  const r = await n.execute();
3022
3047
  let s = r.length;
3023
3048
  if (a != null && a.include_totals) {
3024
- let u = e.selectFrom("organizations").select(h`count(*)`.as("count")).where("tenant_id", "=", t);
3025
- a != null && a.q && (u = u.where(
3049
+ let c = e.selectFrom("organizations").select(h`count(*)`.as("count")).where("tenant_id", "=", t);
3050
+ a != null && a.q && (c = c.where(
3026
3051
  (m) => m.or([
3027
3052
  m("name", "like", `%${a.q}%`),
3028
3053
  m("display_name", "like", `%${a.q}%`)
3029
3054
  ])
3030
3055
  ));
3031
- const l = await u.executeTakeFirst();
3056
+ const l = await c.executeTakeFirst();
3032
3057
  s = Number((l == null ? void 0 : l.count) || 0);
3033
3058
  }
3034
3059
  const i = r.map(
3035
- (u) => w({
3036
- ...u,
3037
- branding: u.branding ? JSON.parse(u.branding) : {},
3038
- metadata: u.metadata ? JSON.parse(u.metadata) : {},
3039
- enabled_connections: u.enabled_connections ? JSON.parse(u.enabled_connections) : [],
3040
- token_quota: u.token_quota ? JSON.parse(u.token_quota) : {}
3060
+ (c) => w({
3061
+ ...c,
3062
+ branding: c.branding ? JSON.parse(c.branding) : {},
3063
+ metadata: c.metadata ? JSON.parse(c.metadata) : {},
3064
+ enabled_connections: c.enabled_connections ? JSON.parse(c.enabled_connections) : [],
3065
+ token_quota: c.token_quota ? JSON.parse(c.token_quota) : {}
3041
3066
  })
3042
- ), c = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10, d = a != null && a.from ? parseInt(a.from, 10) : a != null && a.page ? a.page * c : 0;
3067
+ ), d = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10, u = a != null && a.from ? parseInt(a.from, 10) : a != null && a.page ? a.page * d : 0;
3043
3068
  return {
3044
3069
  organizations: i,
3045
- start: isNaN(d) ? 0 : d,
3046
- limit: c,
3070
+ start: isNaN(u) ? 0 : u,
3071
+ limit: d,
3047
3072
  length: i.length,
3048
3073
  total: s
3049
3074
  };
@@ -3054,15 +3079,15 @@ function Mn(e) {
3054
3079
  }
3055
3080
  function Jn(e) {
3056
3081
  return async (t, a, n) => {
3057
- const { branding: o, metadata: r, enabled_connections: s, token_quota: i, ...c } = n, d = {
3058
- ...c,
3082
+ const { branding: o, metadata: r, enabled_connections: s, token_quota: i, ...d } = n, u = {
3083
+ ...d,
3059
3084
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3060
3085
  };
3061
3086
  return J(
3062
3087
  n,
3063
3088
  ["branding", "metadata", "enabled_connections", "token_quota"],
3064
- d
3065
- ), (await e.updateTable("organizations").set(d).where("tenant_id", "=", t).where("id", "=", a).execute()).length > 0;
3089
+ u
3090
+ ), (await e.updateTable("organizations").set(u).where("tenant_id", "=", t).where("id", "=", a).execute()).length > 0;
3066
3091
  };
3067
3092
  }
3068
3093
  function Ln(e) {
@@ -3077,7 +3102,7 @@ function Ln(e) {
3077
3102
  function Kn(e) {
3078
3103
  return async (t, a) => {
3079
3104
  const n = {
3080
- id: b(),
3105
+ id: k(),
3081
3106
  tenant_id: t,
3082
3107
  user_id: a.user_id,
3083
3108
  organization_id: a.organization_id,
@@ -3108,7 +3133,7 @@ function qn(e) {
3108
3133
  } : null;
3109
3134
  };
3110
3135
  }
3111
- function Un(e) {
3136
+ function Bn(e) {
3112
3137
  return async (t, a) => {
3113
3138
  const n = (a == null ? void 0 : a.page) || 0, o = (a == null ? void 0 : a.per_page) || 50, r = n * o;
3114
3139
  let s = e.selectFrom("user_organizations").selectAll().where("tenant_id", "=", t);
@@ -3123,17 +3148,17 @@ function Un(e) {
3123
3148
  }
3124
3149
  s = s.orderBy("created_at", "desc"), o > 0 && (s = s.limit(o).offset(r));
3125
3150
  const i = await s.execute();
3126
- let c = e.selectFrom("user_organizations").select(e.fn.count("id").as("count")).where("tenant_id", "=", t);
3151
+ let d = e.selectFrom("user_organizations").select(e.fn.count("id").as("count")).where("tenant_id", "=", t);
3127
3152
  if (a != null && a.q) {
3128
3153
  if (a.q.startsWith("user_id:")) {
3129
3154
  const l = a.q.replace("user_id:", "");
3130
- c = c.where("user_id", "=", l);
3155
+ d = d.where("user_id", "=", l);
3131
3156
  } else if (a.q.startsWith("organization_id:")) {
3132
3157
  const l = a.q.replace("organization_id:", "");
3133
- c = c.where("organization_id", "=", l);
3158
+ d = d.where("organization_id", "=", l);
3134
3159
  }
3135
3160
  }
3136
- const d = await c.executeTakeFirst();
3161
+ const u = await d.executeTakeFirst();
3137
3162
  return {
3138
3163
  userOrganizations: i.map((l) => ({
3139
3164
  id: l.id,
@@ -3144,11 +3169,11 @@ function Un(e) {
3144
3169
  })),
3145
3170
  start: r,
3146
3171
  limit: o,
3147
- length: Number((d == null ? void 0 : d.count) || 0)
3172
+ length: Number((u == null ? void 0 : u.count) || 0)
3148
3173
  };
3149
3174
  };
3150
3175
  }
3151
- function Bn(e) {
3176
+ function Un(e) {
3152
3177
  return async (t, a, n) => {
3153
3178
  const o = (n == null ? void 0 : n.page) || 0, r = (n == null ? void 0 : n.per_page) || 50, s = o * r;
3154
3179
  let i = e.selectFrom("user_organizations").innerJoin(
@@ -3167,12 +3192,12 @@ function Bn(e) {
3167
3192
  "user_organizations.created_at as joined_at"
3168
3193
  ]).where("user_organizations.tenant_id", "=", t).where("user_organizations.user_id", "=", a);
3169
3194
  i = i.orderBy("user_organizations.created_at", "desc"), r > 0 && (i = i.limit(r).offset(s));
3170
- const c = await i.execute(), d = await e.selectFrom("user_organizations").innerJoin(
3195
+ const d = await i.execute(), u = await e.selectFrom("user_organizations").innerJoin(
3171
3196
  "organizations",
3172
3197
  (l) => l.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", t)
3173
3198
  ).select(e.fn.count("user_organizations.id").as("count")).where("user_organizations.tenant_id", "=", t).where("user_organizations.user_id", "=", a).executeTakeFirst();
3174
3199
  return {
3175
- organizations: c.map((l) => ({
3200
+ organizations: d.map((l) => ({
3176
3201
  id: l.id,
3177
3202
  name: l.name,
3178
3203
  display_name: l.display_name,
@@ -3187,7 +3212,7 @@ function Bn(e) {
3187
3212
  })),
3188
3213
  start: s,
3189
3214
  limit: r,
3190
- length: Number((d == null ? void 0 : d.count) || 0)
3215
+ length: Number((u == null ? void 0 : u.count) || 0)
3191
3216
  };
3192
3217
  };
3193
3218
  }
@@ -3208,8 +3233,8 @@ function Yn(e) {
3208
3233
  // CRUD operations
3209
3234
  create: Kn(e),
3210
3235
  get: qn(e),
3211
- list: Un(e),
3212
- listUserOrganizations: Bn(e),
3236
+ list: Bn(e),
3237
+ listUserOrganizations: Un(e),
3213
3238
  remove: Qn(e),
3214
3239
  update: Hn(e)
3215
3240
  };
@@ -3239,10 +3264,10 @@ function Wn(e) {
3239
3264
  );
3240
3265
  try {
3241
3266
  await e.insertInto("invites").values(i).execute();
3242
- } catch (c) {
3243
- throw c.code === "SQLITE_CONSTRAINT_UNIQUE" || c.message.includes("AlreadyExists") ? new F(409, {
3267
+ } catch (d) {
3268
+ throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.message.includes("AlreadyExists") ? new F(409, {
3244
3269
  message: "Invite already exists"
3245
- }) : c;
3270
+ }) : d;
3246
3271
  }
3247
3272
  return {
3248
3273
  id: n,
@@ -3358,9 +3383,9 @@ function ao(e) {
3358
3383
  async getDaily(t, a = {}) {
3359
3384
  const { from: n, to: o } = a, r = /* @__PURE__ */ new Date(), s = new Date(r);
3360
3385
  s.setDate(s.getDate() - 30);
3361
- const i = n ? oe(n) : re(s), c = o ? oe(o) : re(r), d = h`DATE(logs.date)`;
3362
- return (await e.selectFrom("logs").where("tenant_id", "=", t).where(d, ">=", i).where(d, "<=", c).select((l) => [
3363
- d.as("date"),
3386
+ const i = n ? oe(n) : re(s), d = o ? oe(o) : re(r), u = h`DATE(logs.date)`;
3387
+ return (await e.selectFrom("logs").where("tenant_id", "=", t).where(u, ">=", i).where(u, "<=", d).select((l) => [
3388
+ u.as("date"),
3364
3389
  l.fn.sum(
3365
3390
  l.case().when("type", "in", ne).then(1).else(0).end()
3366
3391
  ).as("logins"),
@@ -3370,7 +3395,7 @@ function ao(e) {
3370
3395
  ).as("leaked_passwords"),
3371
3396
  l.fn.min("date").as("first_event"),
3372
3397
  l.fn.max("date").as("last_event")
3373
- ]).groupBy(d).orderBy("date", "asc").execute()).map((l) => ({
3398
+ ]).groupBy(u).orderBy("date", "asc").execute()).map((l) => ({
3374
3399
  date: l.date,
3375
3400
  logins: Number(l.logins) || 0,
3376
3401
  signups: Number(l.signups) || 0,
@@ -3524,8 +3549,8 @@ function co(e) {
3524
3549
  }
3525
3550
  function lo(e) {
3526
3551
  return async (t, a) => {
3527
- const n = b();
3528
- await e.insertInto("outbox_events").values({
3552
+ const n = k();
3553
+ return await e.insertInto("outbox_events").values({
3529
3554
  id: n,
3530
3555
  tenant_id: t,
3531
3556
  event_type: a.event_type,
@@ -3538,10 +3563,21 @@ function lo(e) {
3538
3563
  retry_count: 0,
3539
3564
  next_retry_at: null,
3540
3565
  error: null
3541
- }).execute();
3566
+ }).execute(), n;
3542
3567
  };
3543
3568
  }
3544
3569
  function uo(e) {
3570
+ return async (t) => t.length === 0 ? [] : (await e.selectFrom("outbox_events").selectAll().where("id", "in", t).execute()).map((n) => ({
3571
+ ...JSON.parse(n.payload),
3572
+ id: n.id,
3573
+ created_at: n.created_at,
3574
+ processed_at: n.processed_at,
3575
+ retry_count: n.retry_count,
3576
+ next_retry_at: n.next_retry_at,
3577
+ error: n.error
3578
+ }));
3579
+ }
3580
+ function _o(e) {
3545
3581
  return async (t) => {
3546
3582
  const a = (/* @__PURE__ */ new Date()).toISOString();
3547
3583
  return (await e.selectFrom("outbox_events").selectAll().where("processed_at", "is", null).where(
@@ -3556,6 +3592,7 @@ function uo(e) {
3556
3592
  ])
3557
3593
  ).orderBy("created_at", "asc").orderBy("id", "asc").limit(t).execute()).map((o) => ({
3558
3594
  ...JSON.parse(o.payload),
3595
+ id: o.id,
3559
3596
  created_at: o.created_at,
3560
3597
  processed_at: o.processed_at,
3561
3598
  retry_count: o.retry_count,
@@ -3564,7 +3601,7 @@ function uo(e) {
3564
3601
  }));
3565
3602
  };
3566
3603
  }
3567
- function _o(e) {
3604
+ function mo(e) {
3568
3605
  return async (t, a, n) => {
3569
3606
  if (t.length === 0) return [];
3570
3607
  const o = (/* @__PURE__ */ new Date()).toISOString(), r = new Date(Date.now() + n).toISOString();
@@ -3579,14 +3616,14 @@ function _o(e) {
3579
3616
  ).execute(), (await e.selectFrom("outbox_events").select("id").where("id", "in", t).where("claimed_by", "=", a).where("claim_expires_at", "=", r).execute()).map((i) => i.id);
3580
3617
  };
3581
3618
  }
3582
- function mo(e) {
3619
+ function ho(e) {
3583
3620
  return async (t) => {
3584
3621
  if (t.length === 0) return;
3585
3622
  const a = (/* @__PURE__ */ new Date()).toISOString();
3586
3623
  await e.updateTable("outbox_events").set({ processed_at: a }).where("id", "in", t).execute();
3587
3624
  };
3588
3625
  }
3589
- function ho(e) {
3626
+ function po(e) {
3590
3627
  return async (t, a, n) => {
3591
3628
  await e.updateTable("outbox_events").set({
3592
3629
  error: a,
@@ -3595,20 +3632,21 @@ function ho(e) {
3595
3632
  }).where("id", "=", t).execute();
3596
3633
  };
3597
3634
  }
3598
- function po(e) {
3635
+ function fo(e) {
3599
3636
  return async (t) => {
3600
3637
  const a = await e.deleteFrom("outbox_events").where("processed_at", "is not", null).where("processed_at", "<", t).executeTakeFirst();
3601
3638
  return Number(a.numDeletedRows);
3602
3639
  };
3603
3640
  }
3604
- function fo(e) {
3641
+ function go(e) {
3605
3642
  return {
3606
3643
  create: lo(e),
3607
- getUnprocessed: uo(e),
3608
- claimEvents: _o(e),
3609
- markProcessed: mo(e),
3610
- markRetry: ho(e),
3611
- cleanup: po(e)
3644
+ getByIds: uo(e),
3645
+ getUnprocessed: _o(e),
3646
+ claimEvents: mo(e),
3647
+ markProcessed: ho(e),
3648
+ markRetry: po(e),
3649
+ cleanup: fo(e)
3612
3650
  };
3613
3651
  }
3614
3652
  class we {
@@ -3620,7 +3658,7 @@ class we {
3620
3658
  return this.migrations;
3621
3659
  }
3622
3660
  }
3623
- async function go(e) {
3661
+ async function wo(e) {
3624
3662
  await e.schema.createTable("tenants").addColumn("id", "varchar(255)", (t) => t.primaryKey()).addColumn("name", "varchar(255)").addColumn("audience", "varchar(255)").addColumn("sender_email", "varchar(255)").addColumn("sender_name", "varchar(255)").addColumn("language", "varchar(255)").addColumn("logo", "varchar(255)").addColumn("primary_color", "varchar(255)").addColumn("secondary_color", "varchar(255)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("updated_at", "varchar(255)", (t) => t.notNull()).execute(), await e.schema.createTable("users").addColumn("user_id", "varchar(255)", (t) => t.notNull()).addColumn(
3625
3663
  "tenant_id",
3626
3664
  "varchar(255)",
@@ -3692,35 +3730,35 @@ async function go(e) {
3692
3730
  (t) => t.references("tenants.id").onDelete("cascade").notNull()
3693
3731
  ).addColumn("domain", "varchar(255)", (t) => t.notNull()).addColumn("email_service", "varchar(255)").addColumn("email_api_key", "varchar(255)").addColumn("dkim_private_key", "varchar(2048)").addColumn("dkim_public_key", "varchar(2048)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("updated_at", "varchar(255)", (t) => t.notNull()).execute();
3694
3732
  }
3695
- async function wo(e) {
3733
+ async function yo(e) {
3696
3734
  await e.schema.dropTable("domains").execute(), await e.schema.dropTable("members").execute(), await e.schema.dropTable("users").execute(), await e.schema.dropTable("connections").execute(), await e.schema.dropTable("applications").execute(), await e.schema.dropTable("migrations").execute(), await e.schema.dropTable("tenants").execute();
3697
3735
  }
3698
- const yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3736
+ const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3699
3737
  __proto__: null,
3700
- down: wo,
3701
- up: go
3738
+ down: yo,
3739
+ up: wo
3702
3740
  }, Symbol.toStringTag, { value: "Module" }));
3703
- async function vo(e) {
3741
+ async function Co(e) {
3704
3742
  await e.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
3705
3743
  }
3706
- async function Co(e) {
3744
+ async function xo(e) {
3707
3745
  await e.schema.alterTable("tenants").dropColumn("support_url").execute();
3708
3746
  }
3709
- const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3747
+ const To = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3710
3748
  __proto__: null,
3711
- down: Co,
3712
- up: vo
3749
+ down: xo,
3750
+ up: Co
3713
3751
  }, Symbol.toStringTag, { value: "Module" }));
3714
- async function To(e) {
3715
- }
3716
3752
  async function No(e) {
3717
3753
  }
3754
+ async function bo(e) {
3755
+ }
3718
3756
  const So = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3719
3757
  __proto__: null,
3720
- down: No,
3721
- up: To
3758
+ down: bo,
3759
+ up: No
3722
3760
  }, Symbol.toStringTag, { value: "Module" }));
3723
- async function bo(e) {
3761
+ async function Oo(e) {
3724
3762
  await e.schema.createTable("logs").addColumn("id", "varchar(255)", (t) => t.notNull().primaryKey()).addColumn("category", "varchar(255)", (t) => t.notNull()).addColumn("tenant_id", "varchar(64)").addColumn("user_id", "varchar(64)").addForeignKeyConstraint(
3725
3763
  "tenant_id_constraint",
3726
3764
  ["tenant_id"],
@@ -3729,24 +3767,24 @@ async function bo(e) {
3729
3767
  (t) => t.onDelete("cascade")
3730
3768
  ).addColumn("ip", "varchar(255)").addColumn("type", "varchar(8)", (t) => t.notNull()).addColumn("date", "varchar(25)", (t) => t.notNull()).addColumn("client_id", "varchar(255)").addColumn("client_name", "varchar(255)").addColumn("user_agent", "varchar(255)").addColumn("description", "varchar(255)").addColumn("details", "varchar(2048)").execute();
3731
3769
  }
3732
- async function Oo(e) {
3770
+ async function ko(e) {
3733
3771
  await e.schema.dropTable("logs").execute();
3734
3772
  }
3735
- const ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3773
+ const $o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3736
3774
  __proto__: null,
3737
- down: Oo,
3738
- up: bo
3775
+ down: ko,
3776
+ up: Oo
3739
3777
  }, Symbol.toStringTag, { value: "Module" }));
3740
- async function $o(e) {
3741
- }
3742
3778
  async function Eo(e) {
3743
3779
  }
3744
- const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3780
+ async function Io(e) {
3781
+ }
3782
+ const zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3745
3783
  __proto__: null,
3746
- down: Eo,
3747
- up: $o
3784
+ down: Io,
3785
+ up: Eo
3748
3786
  }, Symbol.toStringTag, { value: "Module" }));
3749
- async function zo(e) {
3787
+ async function Po(e) {
3750
3788
  await e.schema.createTable("sessions").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3751
3789
  "user_id_constraint",
3752
3790
  ["user_id", "tenant_id"],
@@ -3771,15 +3809,15 @@ async function zo(e) {
3771
3809
  (t) => t.references("applications.id").onDelete("cascade").notNull()
3772
3810
  ).addColumn("code", "varchar(255)", (t) => t.notNull()).addColumn("email", "varchar(255)", (t) => t.notNull()).addColumn("user_id", "varchar(255)").addColumn("send", "varchar(255)").addColumn("nonce", "varchar(255)").addColumn("state", "varchar(1024)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute(), await e.schema.createIndex("otps_email_index").on("otps").column("email").execute(), await e.schema.createIndex("otps_expires_at_index").on("otps").column("expires_at").execute();
3773
3811
  }
3774
- async function Po(e) {
3812
+ async function Do(e) {
3775
3813
  await e.schema.dropTable("sessions").execute(), await e.schema.dropTable("tickets").execute(), await e.schema.dropTable("otps").execute();
3776
3814
  }
3777
- const Do = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3815
+ const Ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3778
3816
  __proto__: null,
3779
- down: Po,
3780
- up: zo
3817
+ down: Do,
3818
+ up: Po
3781
3819
  }, Symbol.toStringTag, { value: "Module" }));
3782
- async function Ao(e) {
3820
+ async function jo(e) {
3783
3821
  await e.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
3784
3822
  "user_id_constraint",
3785
3823
  ["user_id", "tenant_id"],
@@ -3794,24 +3832,24 @@ async function Ao(e) {
3794
3832
  (t) => t.onDelete("cascade")
3795
3833
  ).addColumn("type", "varchar(255)", (t) => t.notNull()).addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute(), await e.schema.createIndex("codes_expires_at_index").on("codes").column("expires_at").execute();
3796
3834
  }
3797
- async function jo(e) {
3835
+ async function Fo(e) {
3798
3836
  await e.schema.dropTable("passwords").execute(), await e.schema.dropTable("codes").execute();
3799
3837
  }
3800
- const Fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3838
+ const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3801
3839
  __proto__: null,
3802
- down: jo,
3803
- up: Ao
3840
+ down: Fo,
3841
+ up: jo
3804
3842
  }, Symbol.toStringTag, { value: "Module" }));
3805
- async function Ro(e) {
3806
- }
3807
3843
  async function Mo(e) {
3808
3844
  }
3809
- const Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3845
+ async function Jo(e) {
3846
+ }
3847
+ const Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3810
3848
  __proto__: null,
3811
- down: Mo,
3812
- up: Ro
3849
+ down: Jo,
3850
+ up: Mo
3813
3851
  }, Symbol.toStringTag, { value: "Module" }));
3814
- async function Lo(e) {
3852
+ async function Ko(e) {
3815
3853
  await e.schema.alterTable("passwords").addColumn(
3816
3854
  "password",
3817
3855
  "varchar(255)",
@@ -3819,86 +3857,86 @@ async function Lo(e) {
3819
3857
  (t) => t.notNull()
3820
3858
  ).execute();
3821
3859
  }
3822
- async function Ko(e) {
3860
+ async function qo(e) {
3823
3861
  await e.schema.alterTable("passwords").dropColumn("password").execute();
3824
3862
  }
3825
- const qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3863
+ const Bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3826
3864
  __proto__: null,
3827
- down: Ko,
3828
- up: Lo
3865
+ down: qo,
3866
+ up: Ko
3829
3867
  }, Symbol.toStringTag, { value: "Module" }));
3830
3868
  async function Uo(e) {
3831
3869
  }
3832
- async function Bo(e) {
3870
+ async function Qo(e) {
3833
3871
  }
3834
- const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3872
+ const Ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3835
3873
  __proto__: null,
3836
- down: Bo,
3874
+ down: Qo,
3837
3875
  up: Uo
3838
3876
  }, Symbol.toStringTag, { value: "Module" }));
3839
- async function Ho(e) {
3840
- }
3841
3877
  async function Yo(e) {
3842
3878
  }
3843
- const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3879
+ async function Wo(e) {
3880
+ }
3881
+ const Go = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3844
3882
  __proto__: null,
3845
- down: Yo,
3846
- up: Ho
3883
+ down: Wo,
3884
+ up: Yo
3847
3885
  }, Symbol.toStringTag, { value: "Module" }));
3848
- async function Go(e) {
3849
- }
3850
3886
  async function Vo(e) {
3851
3887
  }
3852
- const Xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3888
+ async function Xo(e) {
3889
+ }
3890
+ const Zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3853
3891
  __proto__: null,
3854
- down: Vo,
3855
- up: Go
3892
+ down: Xo,
3893
+ up: Vo
3856
3894
  }, Symbol.toStringTag, { value: "Module" }));
3857
- async function Zo(e) {
3895
+ async function er(e) {
3858
3896
  await e.schema.createIndex("users_email_index").on("users").column("email").execute();
3859
3897
  }
3860
- async function er(e) {
3898
+ async function tr(e) {
3861
3899
  await e.schema.dropIndex("users_email_index").execute();
3862
3900
  }
3863
- const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3901
+ const ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3864
3902
  __proto__: null,
3865
- down: er,
3866
- up: Zo
3903
+ down: tr,
3904
+ up: er
3867
3905
  }, Symbol.toStringTag, { value: "Module" }));
3868
- async function ar(e) {
3906
+ async function nr(e) {
3869
3907
  await e.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3870
3908
  }
3871
- async function nr(e) {
3909
+ async function or(e) {
3872
3910
  await e.schema.alterTable("users").dropColumn("profileData").execute();
3873
3911
  }
3874
- const or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3912
+ const rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3875
3913
  __proto__: null,
3876
- down: nr,
3877
- up: ar
3914
+ down: or,
3915
+ up: nr
3878
3916
  }, Symbol.toStringTag, { value: "Module" }));
3879
- async function rr(e) {
3917
+ async function sr(e) {
3880
3918
  await e.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3881
3919
  }
3882
- async function sr(e) {
3920
+ async function ir(e) {
3883
3921
  await e.schema.dropIndex("users_linked_to_index");
3884
3922
  }
3885
- const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3923
+ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3886
3924
  __proto__: null,
3887
- down: sr,
3888
- up: rr
3925
+ down: ir,
3926
+ up: sr
3889
3927
  }, Symbol.toStringTag, { value: "Module" }));
3890
- async function cr(e) {
3928
+ async function lr(e) {
3891
3929
  await e.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
3892
3930
  }
3893
- async function lr(e) {
3931
+ async function dr(e) {
3894
3932
  await e.schema.alterTable("users").dropColumn("locale").execute();
3895
3933
  }
3896
- const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3934
+ const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3897
3935
  __proto__: null,
3898
- down: lr,
3899
- up: cr
3936
+ down: dr,
3937
+ up: lr
3900
3938
  }, Symbol.toStringTag, { value: "Module" }));
3901
- async function ur(e) {
3939
+ async function _r(e) {
3902
3940
  await e.schema.createTable("keys").addColumn("kid", "varchar(255)", (t) => t.primaryKey()).addColumn(
3903
3941
  "tenant_id",
3904
3942
  "varchar(255)",
@@ -3913,202 +3951,202 @@ async function ur(e) {
3913
3951
  (t) => t.references("connections.id").onDelete("cascade")
3914
3952
  ).execute();
3915
3953
  }
3916
- async function _r(e) {
3954
+ async function mr(e) {
3917
3955
  await e.schema.dropTable("keys").execute();
3918
3956
  }
3919
- const mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3957
+ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3920
3958
  __proto__: null,
3921
- down: _r,
3922
- up: ur
3959
+ down: mr,
3960
+ up: _r
3923
3961
  }, Symbol.toStringTag, { value: "Module" }));
3924
- async function hr(e) {
3925
- }
3926
3962
  async function pr(e) {
3927
3963
  }
3928
- const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3964
+ async function fr(e) {
3965
+ }
3966
+ const gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3929
3967
  __proto__: null,
3930
- down: pr,
3931
- up: hr
3968
+ down: fr,
3969
+ up: pr
3932
3970
  }, Symbol.toStringTag, { value: "Module" }));
3933
- async function gr(e) {
3934
- }
3935
3971
  async function wr(e) {
3936
3972
  }
3937
- const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3973
+ async function yr(e) {
3974
+ }
3975
+ const vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3938
3976
  __proto__: null,
3939
- down: wr,
3940
- up: gr
3977
+ down: yr,
3978
+ up: wr
3941
3979
  }, Symbol.toStringTag, { value: "Module" }));
3942
- async function vr(e) {
3980
+ async function Cr(e) {
3943
3981
  await e.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3944
3982
  }
3945
- async function Cr(e) {
3983
+ async function xr(e) {
3946
3984
  await e.schema.alterTable("otps").dropColumn("audience").execute();
3947
3985
  }
3948
- const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3986
+ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3949
3987
  __proto__: null,
3950
- down: Cr,
3951
- up: vr
3988
+ down: xr,
3989
+ up: Cr
3952
3990
  }, Symbol.toStringTag, { value: "Module" }));
3953
- async function Tr(e) {
3954
- }
3955
3991
  async function Nr(e) {
3956
3992
  }
3993
+ async function br(e) {
3994
+ }
3957
3995
  const Sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3958
3996
  __proto__: null,
3959
- down: Nr,
3960
- up: Tr
3997
+ down: br,
3998
+ up: Nr
3961
3999
  }, Symbol.toStringTag, { value: "Module" }));
3962
- async function br(e) {
4000
+ async function Or(e) {
3963
4001
  await e.schema.alterTable("logs").dropColumn("category").execute();
3964
4002
  }
3965
- async function Or(e) {
4003
+ async function kr(e) {
3966
4004
  await e.schema.alterTable("logs").addColumn("category", "varchar(255)", (t) => t.notNull()).execute();
3967
4005
  }
3968
- const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4006
+ const $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3969
4007
  __proto__: null,
3970
- down: Or,
3971
- up: br
4008
+ down: kr,
4009
+ up: Or
3972
4010
  }, Symbol.toStringTag, { value: "Module" }));
3973
- async function $r(e) {
4011
+ async function Er(e) {
3974
4012
  await e.schema.alterTable("users").dropColumn("tags").execute();
3975
4013
  }
3976
- async function Er(e) {
4014
+ async function Ir(e) {
3977
4015
  await e.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3978
4016
  }
3979
- const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4017
+ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3980
4018
  __proto__: null,
3981
- down: Er,
3982
- up: $r
4019
+ down: Ir,
4020
+ up: Er
3983
4021
  }, Symbol.toStringTag, { value: "Module" }));
3984
- async function zr(e) {
4022
+ async function Pr(e) {
3985
4023
  await e.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(), await e.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(), await e.schema.createIndex("logs_date").on("logs").column("date").execute();
3986
4024
  }
3987
- async function Pr(e) {
4025
+ async function Dr(e) {
3988
4026
  await e.schema.dropIndex("logs_user_id"), await e.schema.dropIndex("logs_tenant_id"), await e.schema.dropIndex("logs_date");
3989
4027
  }
3990
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4028
+ const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3991
4029
  __proto__: null,
3992
- down: Pr,
3993
- up: zr
4030
+ down: Dr,
4031
+ up: Pr
3994
4032
  }, Symbol.toStringTag, { value: "Module" }));
3995
- async function Ar(e) {
4033
+ async function jr(e) {
3996
4034
  await e.schema.alterTable("logs").dropColumn("details").execute(), await e.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3997
4035
  }
3998
- async function jr(e) {
4036
+ async function Fr(e) {
3999
4037
  await e.schema.alterTable("logs").dropColumn("details").execute(), await e.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
4000
4038
  }
4001
- const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4039
+ const Rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4002
4040
  __proto__: null,
4003
- down: jr,
4004
- up: Ar
4041
+ down: Fr,
4042
+ up: jr
4005
4043
  }, Symbol.toStringTag, { value: "Module" }));
4006
- async function Rr(e) {
4044
+ async function Mr(e) {
4007
4045
  await e.schema.alterTable("logs").addColumn("user_name", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("auth0_client", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("isMobile", "boolean").execute(), await e.schema.alterTable("logs").addColumn("connection", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("connection_id", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("audience", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("scope", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("strategy", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("strategy_type", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("hostname", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("session_connection", "varchar(255)").execute();
4008
4046
  }
4009
- async function Mr(e) {
4047
+ async function Jr(e) {
4010
4048
  await e.schema.alterTable("logs").dropColumn("user_name").execute(), await e.schema.alterTable("logs").dropColumn("auth0_client").execute(), await e.schema.alterTable("logs").dropColumn("isMobile").execute(), await e.schema.alterTable("logs").dropColumn("connection").execute(), await e.schema.alterTable("logs").dropColumn("connection_id").execute(), await e.schema.alterTable("logs").dropColumn("audience").execute(), await e.schema.alterTable("logs").dropColumn("scope").execute(), await e.schema.alterTable("logs").dropColumn("strategy").execute(), await e.schema.alterTable("logs").dropColumn("strategy_type").execute(), await e.schema.alterTable("logs").dropColumn("hostname").execute(), await e.schema.alterTable("logs").dropColumn("session_connection").execute();
4011
4049
  }
4012
- const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4050
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4013
4051
  __proto__: null,
4014
- down: Mr,
4015
- up: Rr
4052
+ down: Jr,
4053
+ up: Mr
4016
4054
  }, Symbol.toStringTag, { value: "Module" }));
4017
- async function Lr(e) {
4055
+ async function Kr(e) {
4018
4056
  await e.schema.createIndex("users_name_index").on("users").column("name").execute();
4019
4057
  }
4020
- async function Kr(e) {
4058
+ async function qr(e) {
4021
4059
  await e.schema.dropIndex("users_name_index").execute();
4022
4060
  }
4023
- const qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4061
+ const Br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4024
4062
  __proto__: null,
4025
- down: Kr,
4026
- up: Lr
4063
+ down: qr,
4064
+ up: Kr
4027
4065
  }, Symbol.toStringTag, { value: "Module" }));
4028
4066
  async function Ur(e) {
4029
4067
  }
4030
- async function Br(e) {
4068
+ async function Qr(e) {
4031
4069
  await e.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
4032
4070
  }
4033
- const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4071
+ const Hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4034
4072
  __proto__: null,
4035
- down: Br,
4073
+ down: Qr,
4036
4074
  up: Ur
4037
4075
  }, Symbol.toStringTag, { value: "Module" }));
4038
- async function Hr(e) {
4076
+ async function Yr(e) {
4039
4077
  await e.schema.alterTable("otps").dropColumn("state").execute(), await e.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
4040
4078
  }
4041
- async function Yr(e) {
4079
+ async function Wr(e) {
4042
4080
  await e.schema.alterTable("otps").dropColumn("state").execute(), await e.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
4043
4081
  }
4044
- const Wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4082
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4045
4083
  __proto__: null,
4046
- down: Yr,
4047
- up: Hr
4084
+ down: Wr,
4085
+ up: Yr
4048
4086
  }, Symbol.toStringTag, { value: "Module" }));
4049
- async function Gr(e) {
4087
+ async function Vr(e) {
4050
4088
  await e.schema.alterTable("tickets").dropColumn("state").execute(), await e.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
4051
4089
  }
4052
- async function Vr(e) {
4090
+ async function Xr(e) {
4053
4091
  await e.schema.alterTable("tickets").dropColumn("state").execute(), await e.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
4054
4092
  }
4055
- const Xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4093
+ const Zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4056
4094
  __proto__: null,
4057
- down: Vr,
4058
- up: Gr
4095
+ down: Xr,
4096
+ up: Vr
4059
4097
  }, Symbol.toStringTag, { value: "Module" }));
4060
- async function Zr(e) {
4098
+ async function es(e) {
4061
4099
  await e.schema.createTable("branding").addColumn(
4062
4100
  "tenant_id",
4063
4101
  "varchar(255)",
4064
4102
  (t) => t.references("tenants.id").onDelete("cascade").notNull().primaryKey()
4065
4103
  ).addColumn("logo_url", "varchar(512)").addColumn("favicon_url", "varchar(512)").addColumn("font_url", "varchar(512)").addColumn("colors_primary", "varchar(8)").addColumn("colors_page_background_type", "varchar(32)").addColumn("colors_page_background_start", "varchar(8)").addColumn("colors_page_background_end", "varchar(8)").addColumn("colors_page_background_angle_dev", "integer").execute();
4066
4104
  }
4067
- async function es(e) {
4105
+ async function ts(e) {
4068
4106
  await e.schema.dropTable("branding").execute();
4069
4107
  }
4070
- const ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4108
+ const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4071
4109
  __proto__: null,
4072
- down: es,
4073
- up: Zr
4110
+ down: ts,
4111
+ up: es
4074
4112
  }, Symbol.toStringTag, { value: "Module" }));
4075
- async function as(e) {
4076
- }
4077
4113
  async function ns(e) {
4078
4114
  }
4079
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4115
+ async function os(e) {
4116
+ }
4117
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4080
4118
  __proto__: null,
4081
- down: ns,
4082
- up: as
4119
+ down: os,
4120
+ up: ns
4083
4121
  }, Symbol.toStringTag, { value: "Module" }));
4084
- async function rs(e) {
4085
- }
4086
4122
  async function ss(e) {
4087
4123
  }
4088
- const is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4124
+ async function is(e) {
4125
+ }
4126
+ const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4089
4127
  __proto__: null,
4090
- down: ss,
4091
- up: rs
4128
+ down: is,
4129
+ up: ss
4092
4130
  }, Symbol.toStringTag, { value: "Module" }));
4093
- async function cs(e) {
4094
- }
4095
4131
  async function ls(e) {
4096
4132
  }
4097
- const ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4133
+ async function ds(e) {
4134
+ }
4135
+ const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4098
4136
  __proto__: null,
4099
- down: ls,
4100
- up: cs
4137
+ down: ds,
4138
+ up: ls
4101
4139
  }, Symbol.toStringTag, { value: "Module" }));
4102
- async function us(e) {
4103
- }
4104
4140
  async function _s(e) {
4105
4141
  }
4106
- const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4142
+ async function ms(e) {
4143
+ }
4144
+ const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4107
4145
  __proto__: null,
4108
- down: _s,
4109
- up: us
4146
+ down: ms,
4147
+ up: _s
4110
4148
  }, Symbol.toStringTag, { value: "Module" }));
4111
- async function hs(e) {
4149
+ async function ps(e) {
4112
4150
  await e.schema.createTable("authentication_codes").addColumn(
4113
4151
  "tenant_id",
4114
4152
  "varchar(255)",
@@ -4119,55 +4157,55 @@ async function hs(e) {
4119
4157
  (t) => t.references("applications.id").onDelete("cascade").notNull()
4120
4158
  ).addColumn("user_id", "varchar(255)", (t) => t.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(8192)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4121
4159
  }
4122
- async function ps(e) {
4160
+ async function fs(e) {
4123
4161
  await e.schema.dropTable("authentication_codes").execute();
4124
4162
  }
4125
- const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4163
+ const gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4126
4164
  __proto__: null,
4127
- down: ps,
4128
- up: hs
4165
+ down: fs,
4166
+ up: ps
4129
4167
  }, Symbol.toStringTag, { value: "Module" }));
4130
- async function gs(e) {
4131
- }
4132
4168
  async function ws(e) {
4133
4169
  }
4134
- const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4170
+ async function ys(e) {
4171
+ }
4172
+ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4135
4173
  __proto__: null,
4136
- down: ws,
4137
- up: gs
4174
+ down: ys,
4175
+ up: ws
4138
4176
  }, Symbol.toStringTag, { value: "Module" }));
4139
- async function vs(e) {
4177
+ async function Cs(e) {
4140
4178
  await e.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
4141
4179
  }
4142
- async function Cs(e) {
4180
+ async function xs(e) {
4143
4181
  await e.schema.alterTable("otps").dropColumn("ip").execute();
4144
4182
  }
4145
- const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4183
+ const Ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4146
4184
  __proto__: null,
4147
- down: Cs,
4148
- up: vs
4185
+ down: xs,
4186
+ up: Cs
4149
4187
  }, Symbol.toStringTag, { value: "Module" }));
4150
- async function Ts(e) {
4188
+ async function Ns(e) {
4151
4189
  await e.schema.alterTable("logs").dropColumn("user_agent").execute(), await e.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
4152
4190
  }
4153
- async function Ns(e) {
4191
+ async function bs(e) {
4154
4192
  await e.schema.alterTable("logs").dropColumn("user_agent").execute(), await e.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
4155
4193
  }
4156
4194
  const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4157
4195
  __proto__: null,
4158
- down: Ns,
4159
- up: Ts
4196
+ down: bs,
4197
+ up: Ns
4160
4198
  }, Symbol.toStringTag, { value: "Module" }));
4161
- async function bs(e) {
4162
- }
4163
4199
  async function Os(e) {
4164
4200
  }
4165
- const ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4201
+ async function ks(e) {
4202
+ }
4203
+ const $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4166
4204
  __proto__: null,
4167
- down: Os,
4168
- up: bs
4205
+ down: ks,
4206
+ up: Os
4169
4207
  }, Symbol.toStringTag, { value: "Module" }));
4170
- async function $s(e) {
4208
+ async function Es(e) {
4171
4209
  await e.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (t) => t.notNull().primaryKey()).addColumn(
4172
4210
  "tenant_id",
4173
4211
  "varchar(255)",
@@ -4178,33 +4216,33 @@ async function $s(e) {
4178
4216
  (t) => t.defaultTo(!1).notNull()
4179
4217
  ).addColumn("priority", "integer").execute();
4180
4218
  }
4181
- async function Es(e) {
4219
+ async function Is(e) {
4182
4220
  await e.schema.dropTable("hooks").execute();
4183
4221
  }
4184
- const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4222
+ const zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4185
4223
  __proto__: null,
4186
- down: Es,
4187
- up: $s
4224
+ down: Is,
4225
+ up: Es
4188
4226
  }, Symbol.toStringTag, { value: "Module" }));
4189
- async function zs(e) {
4190
- }
4191
4227
  async function Ps(e) {
4192
4228
  }
4193
- const Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4229
+ async function Ds(e) {
4230
+ }
4231
+ const As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4194
4232
  __proto__: null,
4195
- down: Ps,
4196
- up: zs
4233
+ down: Ds,
4234
+ up: Ps
4197
4235
  }, Symbol.toStringTag, { value: "Module" }));
4198
- async function As(e) {
4199
- }
4200
4236
  async function js(e) {
4201
4237
  }
4202
- const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4238
+ async function Fs(e) {
4239
+ }
4240
+ const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4203
4241
  __proto__: null,
4204
- down: js,
4205
- up: As
4242
+ down: Fs,
4243
+ up: js
4206
4244
  }, Symbol.toStringTag, { value: "Module" }));
4207
- async function Rs(e) {
4245
+ async function Ms(e) {
4208
4246
  await e.schema.createTable("logins").addColumn("login_id", "varchar(255)", (t) => t.primaryKey()).addColumn(
4209
4247
  "tenant_id",
4210
4248
  "varchar(255)",
@@ -4221,7 +4259,7 @@ async function Rs(e) {
4221
4259
  (t) => t.onDelete("cascade")
4222
4260
  ).addColumn("code_type", "varchar(255)", (t) => t.notNull()).addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4223
4261
  }
4224
- async function Ms(e) {
4262
+ async function Js(e) {
4225
4263
  await e.schema.dropTable("logins").execute(), await e.schema.alterTable("passwords").dropColumn("algorithm").execute(), await e.schema.dropTable("codes").execute(), await e.schema.createTable("codes").addColumn("id", "varchar(255)", (t) => t.primaryKey()).addColumn("code", "varchar(255)", (t) => t.notNull()).addColumn("user_id", "varchar(255)").addColumn("tenant_id", "varchar(255)").addForeignKeyConstraint(
4226
4264
  "codes_user_id_tenant_id_constraint",
4227
4265
  ["user_id", "tenant_id"],
@@ -4230,90 +4268,90 @@ async function Ms(e) {
4230
4268
  (t) => t.onDelete("cascade")
4231
4269
  ).addColumn("type", "varchar(255)", (t) => t.notNull()).addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4232
4270
  }
4233
- const Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4271
+ const Ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4234
4272
  __proto__: null,
4235
- down: Ms,
4236
- up: Rs
4273
+ down: Js,
4274
+ up: Ms
4237
4275
  }, Symbol.toStringTag, { value: "Module" }));
4238
- async function Ls(e) {
4239
- }
4240
4276
  async function Ks(e) {
4241
4277
  }
4242
- const qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4278
+ async function qs(e) {
4279
+ }
4280
+ const Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4243
4281
  __proto__: null,
4244
- down: Ks,
4245
- up: Ls
4282
+ down: qs,
4283
+ up: Ks
4246
4284
  }, Symbol.toStringTag, { value: "Module" }));
4247
4285
  async function Us(e) {
4248
4286
  await e.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
4249
4287
  }
4250
- async function Bs(e) {
4288
+ async function Qs(e) {
4251
4289
  await e.schema.alterTable("logins").dropColumn("auth0Client").execute();
4252
4290
  }
4253
- const Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4291
+ const Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4254
4292
  __proto__: null,
4255
- down: Bs,
4293
+ down: Qs,
4256
4294
  up: Us
4257
4295
  }, Symbol.toStringTag, { value: "Module" }));
4258
- async function Hs(e) {
4296
+ async function Ys(e) {
4259
4297
  await e.schema.alterTable("logins").dropColumn("authParams_state").execute(), await e.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
4260
4298
  }
4261
- async function Ys(e) {
4299
+ async function Ws(e) {
4262
4300
  await e.schema.alterTable("logins").dropColumn("authParams_state").execute(), await e.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
4263
4301
  }
4264
- const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4302
+ const Gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4265
4303
  __proto__: null,
4266
- down: Ys,
4267
- up: Hs
4304
+ down: Ws,
4305
+ up: Ys
4268
4306
  }, Symbol.toStringTag, { value: "Module" }));
4269
- async function Gs(e) {
4270
- }
4271
4307
  async function Vs(e) {
4272
4308
  }
4273
- const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4309
+ async function Xs(e) {
4310
+ }
4311
+ const Zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4274
4312
  __proto__: null,
4275
- down: Vs,
4276
- up: Gs
4313
+ down: Xs,
4314
+ up: Vs
4277
4315
  }, Symbol.toStringTag, { value: "Module" }));
4278
- async function Zs(e) {
4279
- }
4280
4316
  async function ei(e) {
4281
4317
  }
4282
- const ti = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4318
+ async function ti(e) {
4319
+ }
4320
+ const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4283
4321
  __proto__: null,
4284
- down: ei,
4285
- up: Zs
4322
+ down: ti,
4323
+ up: ei
4286
4324
  }, Symbol.toStringTag, { value: "Module" }));
4287
- async function ai(e) {
4325
+ async function ni(e) {
4288
4326
  await e.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
4289
4327
  }
4290
- async function ni(e) {
4328
+ async function oi(e) {
4291
4329
  await e.schema.alterTable("logins").dropColumn("nonce").execute();
4292
4330
  }
4293
- const oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4331
+ const ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4294
4332
  __proto__: null,
4295
- down: ni,
4296
- up: ai
4333
+ down: oi,
4334
+ up: ni
4297
4335
  }, Symbol.toStringTag, { value: "Module" }));
4298
- async function ri(e) {
4299
- }
4300
4336
  async function si(e) {
4301
4337
  }
4302
- const ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4338
+ async function ii(e) {
4339
+ }
4340
+ const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4303
4341
  __proto__: null,
4304
- down: si,
4305
- up: ri
4342
+ down: ii,
4343
+ up: si
4306
4344
  }, Symbol.toStringTag, { value: "Module" }));
4307
- async function ci(e) {
4308
- }
4309
4345
  async function li(e) {
4310
4346
  }
4311
- const di = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4347
+ async function di(e) {
4348
+ }
4349
+ const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4312
4350
  __proto__: null,
4313
- down: li,
4314
- up: ci
4351
+ down: di,
4352
+ up: li
4315
4353
  }, Symbol.toStringTag, { value: "Module" }));
4316
- async function ui(e) {
4354
+ async function _i(e) {
4317
4355
  await e.schema.dropTable("codes").execute(), await e.schema.createTable("codes").addColumn("code_id", "varchar(255)", (t) => t.notNull()).addColumn(
4318
4356
  "tenant_id",
4319
4357
  "varchar(255)",
@@ -4329,7 +4367,7 @@ async function ui(e) {
4329
4367
  "code_type"
4330
4368
  ]).execute();
4331
4369
  }
4332
- async function _i(e) {
4370
+ async function mi(e) {
4333
4371
  await e.schema.dropTable("codes").execute(), await e.schema.createTable("codes").addColumn("code_id", "varchar(255)", (t) => t.primaryKey()).addColumn(
4334
4372
  "tenant_id",
4335
4373
  "varchar(255)",
@@ -4342,15 +4380,15 @@ async function _i(e) {
4342
4380
  (t) => t.onDelete("cascade")
4343
4381
  ).addColumn("code_type", "varchar(255)", (t) => t.notNull()).addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4344
4382
  }
4345
- const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4383
+ const hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4346
4384
  __proto__: null,
4347
- down: _i,
4348
- up: ui
4385
+ down: mi,
4386
+ up: _i
4349
4387
  }, Symbol.toStringTag, { value: "Module" }));
4350
- async function hi(e) {
4388
+ async function pi(e) {
4351
4389
  await e.schema.dropTable("otps").execute(), await e.schema.dropTable("authentication_codes").execute();
4352
4390
  }
4353
- async function pi(e) {
4391
+ async function fi(e) {
4354
4392
  await e.schema.alterTable("keys").addColumn("private_key", "varchar(2048)").addColumn("public_key", "varchar(2048)").execute(), await e.schema.createTable("otps").addColumn(
4355
4393
  "tenant_id",
4356
4394
  "varchar(255)",
@@ -4369,32 +4407,32 @@ async function pi(e) {
4369
4407
  (t) => t.references("applications.id").onDelete("cascade").notNull()
4370
4408
  ).addColumn("user_id", "varchar(255)", (t) => t.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(8192)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4371
4409
  }
4372
- const fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4410
+ const gi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4373
4411
  __proto__: null,
4374
- down: pi,
4375
- up: hi
4412
+ down: fi,
4413
+ up: pi
4376
4414
  }, Symbol.toStringTag, { value: "Module" }));
4377
- async function gi(e) {
4415
+ async function wi(e) {
4378
4416
  await e.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
4379
4417
  }
4380
- async function wi(e) {
4418
+ async function yi(e) {
4381
4419
  await e.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
4382
4420
  }
4383
- const yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4421
+ const vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4384
4422
  __proto__: null,
4385
- down: wi,
4386
- up: gi
4423
+ down: yi,
4424
+ up: wi
4387
4425
  }, Symbol.toStringTag, { value: "Module" }));
4388
- async function vi(e) {
4389
- }
4390
4426
  async function Ci(e) {
4391
4427
  }
4392
- const xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4428
+ async function xi(e) {
4429
+ }
4430
+ const Ti = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4393
4431
  __proto__: null,
4394
- down: Ci,
4395
- up: vi
4432
+ down: xi,
4433
+ up: Ci
4396
4434
  }, Symbol.toStringTag, { value: "Module" }));
4397
- async function Ti(e) {
4435
+ async function Ni(e) {
4398
4436
  await e.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (t) => t.primaryKey()).addColumn(
4399
4437
  "universal_login_experience",
4400
4438
  "varchar(16)",
@@ -4413,95 +4451,95 @@ async function Ti(e) {
4413
4451
  (t) => t.defaultTo(!1).notNull()
4414
4452
  ).execute();
4415
4453
  }
4416
- async function Ni(e) {
4454
+ async function bi(e) {
4417
4455
  await e.schema.dropTable("prompt_settings").execute();
4418
4456
  }
4419
4457
  const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4420
4458
  __proto__: null,
4421
- down: Ni,
4422
- up: Ti
4459
+ down: bi,
4460
+ up: Ni
4423
4461
  }, Symbol.toStringTag, { value: "Module" }));
4424
- async function bi(e) {
4425
- }
4426
4462
  async function Oi(e) {
4427
4463
  }
4428
- const ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4464
+ async function ki(e) {
4465
+ }
4466
+ const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4429
4467
  __proto__: null,
4430
- down: Oi,
4431
- up: bi
4468
+ down: ki,
4469
+ up: Oi
4432
4470
  }, Symbol.toStringTag, { value: "Module" }));
4433
- async function $i(e) {
4434
- }
4435
4471
  async function Ei(e) {
4436
4472
  }
4437
- const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4473
+ async function Ii(e) {
4474
+ }
4475
+ const zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4438
4476
  __proto__: null,
4439
- down: Ei,
4440
- up: $i
4477
+ down: Ii,
4478
+ up: Ei
4441
4479
  }, Symbol.toStringTag, { value: "Module" }));
4442
- async function zi(e) {
4443
- }
4444
4480
  async function Pi(e) {
4445
4481
  }
4446
- const Di = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4482
+ async function Di(e) {
4483
+ }
4484
+ const Ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4447
4485
  __proto__: null,
4448
- down: Pi,
4449
- up: zi
4486
+ down: Di,
4487
+ up: Pi
4450
4488
  }, Symbol.toStringTag, { value: "Module" }));
4451
- async function Ai(e) {
4489
+ async function ji(e) {
4452
4490
  await e.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
4453
4491
  }
4454
- async function ji(e) {
4492
+ async function Fi(e) {
4455
4493
  await e.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
4456
4494
  }
4457
- const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4495
+ const Ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4458
4496
  __proto__: null,
4459
- down: ji,
4460
- up: Ai
4497
+ down: Fi,
4498
+ up: ji
4461
4499
  }, Symbol.toStringTag, { value: "Module" }));
4462
- async function Ri(e) {
4500
+ async function Mi(e) {
4463
4501
  await e.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
4464
4502
  }
4465
- async function Mi(e) {
4503
+ async function Ji(e) {
4466
4504
  await e.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
4467
4505
  }
4468
- const Ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4506
+ const Li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4469
4507
  __proto__: null,
4470
- down: Mi,
4471
- up: Ri
4508
+ down: Ji,
4509
+ up: Mi
4472
4510
  }, Symbol.toStringTag, { value: "Module" }));
4473
- async function Li(e) {
4474
- }
4475
4511
  async function Ki(e) {
4476
4512
  }
4477
- const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4513
+ async function qi(e) {
4514
+ }
4515
+ const Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4478
4516
  __proto__: null,
4479
- down: Ki,
4480
- up: Li
4517
+ down: qi,
4518
+ up: Ki
4481
4519
  }, Symbol.toStringTag, { value: "Module" }));
4482
4520
  async function Ui(e) {
4483
4521
  await e.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
4484
4522
  }
4485
- async function Bi(e) {
4523
+ async function Qi(e) {
4486
4524
  await e.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
4487
4525
  }
4488
- const Qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4526
+ const Hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4489
4527
  __proto__: null,
4490
- down: Bi,
4528
+ down: Qi,
4491
4529
  up: Ui
4492
4530
  }, Symbol.toStringTag, { value: "Module" }));
4493
- async function Hi(e) {
4531
+ async function Yi(e) {
4494
4532
  await e.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
4495
4533
  }
4496
- async function Yi(e) {
4534
+ async function Wi(e) {
4497
4535
  await e.schema.alterTable("codes").dropColumn("code_verifier").execute();
4498
4536
  }
4499
- const Wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4537
+ const Gi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4500
4538
  __proto__: null,
4501
- down: Yi,
4502
- up: Hi
4539
+ down: Wi,
4540
+ up: Yi
4503
4541
  }, Symbol.toStringTag, { value: "Module" }));
4504
- async function Gi(e) {
4542
+ async function Vi(e) {
4505
4543
  await e.schema.createTable("email_providers").addColumn("tenant_id", "varchar(255)", (t) => t.primaryKey()).addColumn("name", "varchar(255)", (t) => t.notNull()).addColumn("enabled", "boolean", (t) => t.notNull()).addColumn("default_from_address", "varchar(255)").addColumn(
4506
4544
  "credentials",
4507
4545
  "varchar(2048)",
@@ -4512,18 +4550,18 @@ async function Gi(e) {
4512
4550
  (t) => t.notNull().defaultTo("{}")
4513
4551
  ).addColumn("created_at", "varchar(29)", (t) => t.notNull()).addColumn("updated_at", "varchar(29)", (t) => t.notNull()).execute();
4514
4552
  }
4515
- async function Vi(e) {
4553
+ async function Xi(e) {
4516
4554
  await e.schema.dropTable("email_providers").execute();
4517
4555
  }
4518
- const Xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4556
+ const Zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4519
4557
  __proto__: null,
4520
- down: Vi,
4521
- up: Gi
4558
+ down: Xi,
4559
+ up: Vi
4522
4560
  }, Symbol.toStringTag, { value: "Module" }));
4523
- async function Zi(e) {
4561
+ async function ec(e) {
4524
4562
  await e.schema.dropTable("tickets").execute();
4525
4563
  }
4526
- async function ec(e) {
4564
+ async function tc(e) {
4527
4565
  await e.schema.createTable("tickets").addColumn(
4528
4566
  "tenant_id",
4529
4567
  "varchar(255)",
@@ -4534,22 +4572,22 @@ async function ec(e) {
4534
4572
  (t) => t.references("applications.id").onDelete("cascade").notNull()
4535
4573
  ).addColumn("email", "varchar(255)", (t) => t.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(1024)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4536
4574
  }
4537
- const tc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4575
+ const ac = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4538
4576
  __proto__: null,
4539
- down: ec,
4540
- up: Zi
4577
+ down: tc,
4578
+ up: ec
4541
4579
  }, Symbol.toStringTag, { value: "Module" }));
4542
- async function ac(e) {
4543
- }
4544
4580
  async function nc(e) {
4581
+ }
4582
+ async function oc(e) {
4545
4583
  await e.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
4546
4584
  }
4547
- const oc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4585
+ const rc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4548
4586
  __proto__: null,
4549
- down: nc,
4550
- up: ac
4587
+ down: oc,
4588
+ up: nc
4551
4589
  }, Symbol.toStringTag, { value: "Module" }));
4552
- async function rc(e) {
4590
+ async function sc(e) {
4553
4591
  await e.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn(
4554
4592
  "client_id",
4555
4593
  "varchar(21)",
@@ -4562,27 +4600,27 @@ async function rc(e) {
4562
4600
  (t) => t.onDelete("cascade")
4563
4601
  ).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (t) => t.notNull()).addColumn("resource_servers", "varchar(2048)", (t) => t.notNull()).addColumn("rotating", "boolean", (t) => t.notNull()).execute();
4564
4602
  }
4565
- async function sc(e) {
4603
+ async function ic(e) {
4566
4604
  await e.schema.dropTable("refresh_tokens").execute();
4567
4605
  }
4568
- const ic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4606
+ const cc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4569
4607
  __proto__: null,
4570
- down: sc,
4571
- up: rc
4608
+ down: ic,
4609
+ up: sc
4572
4610
  }, Symbol.toStringTag, { value: "Module" }));
4573
- async function cc(e) {
4574
- }
4575
4611
  async function lc(e) {
4576
4612
  }
4577
- const dc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4613
+ async function dc(e) {
4614
+ }
4615
+ const uc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4578
4616
  __proto__: null,
4579
- down: lc,
4580
- up: cc
4617
+ down: dc,
4618
+ up: lc
4581
4619
  }, Symbol.toStringTag, { value: "Module" }));
4582
- async function uc(e) {
4620
+ async function _c(e) {
4583
4621
  await e.schema.dropTable("sessions").execute(), await e.schema.dropTable("refresh_tokens").execute();
4584
4622
  }
4585
- async function _c(e) {
4623
+ async function mc(e) {
4586
4624
  await e.schema.createTable("sessions").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4587
4625
  "sessions_user_id_constraint",
4588
4626
  ["user_id", "tenant_id"],
@@ -4601,12 +4639,12 @@ async function _c(e) {
4601
4639
  (t) => t.onDelete("cascade")
4602
4640
  ).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (t) => t.notNull()).addColumn("resource_servers", "varchar(2048)", (t) => t.notNull()).addColumn("rotating", "boolean", (t) => t.notNull()).execute();
4603
4641
  }
4604
- const mc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4642
+ const hc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4605
4643
  __proto__: null,
4606
- down: _c,
4607
- up: uc
4644
+ down: mc,
4645
+ up: _c
4608
4646
  }, Symbol.toStringTag, { value: "Module" }));
4609
- async function hc(e) {
4647
+ async function pc(e) {
4610
4648
  await e.schema.createTable("sessions_2").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4611
4649
  "sessions_2_user_id_constraint",
4612
4650
  ["user_id", "tenant_id"],
@@ -4625,15 +4663,15 @@ async function hc(e) {
4625
4663
  (t) => t.onDelete("cascade")
4626
4664
  ).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (t) => t.notNull()).addColumn("resource_servers", "varchar(2048)", (t) => t.notNull()).addColumn("rotating", "boolean", (t) => t.notNull()).execute();
4627
4665
  }
4628
- async function pc(e) {
4666
+ async function fc(e) {
4629
4667
  await e.schema.dropTable("sessions_2").execute(), await e.schema.dropTable("refresh_tokens_2").execute();
4630
4668
  }
4631
- const fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4669
+ const gc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4632
4670
  __proto__: null,
4633
- down: pc,
4634
- up: hc
4671
+ down: fc,
4672
+ up: pc
4635
4673
  }, Symbol.toStringTag, { value: "Module" }));
4636
- async function gc(e) {
4674
+ async function wc(e) {
4637
4675
  await e.schema.createTable("custom_domains").addColumn(
4638
4676
  "custom_domain_id",
4639
4677
  "varchar(21)",
@@ -4644,49 +4682,49 @@ async function gc(e) {
4644
4682
  (t) => t.references("tenants.id").onDelete("cascade").notNull()
4645
4683
  ).addColumn("domain", "varchar(255)", (t) => t.notNull()).addColumn("primary", "boolean", (t) => t.notNull()).addColumn("status", "varchar(50)", (t) => t.notNull()).addColumn("type", "varchar(50)", (t) => t.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).execute(), await e.schema.dropTable("domains").execute();
4646
4684
  }
4647
- async function wc(e) {
4685
+ async function yc(e) {
4648
4686
  await e.schema.dropTable("custom_domains").execute(), await e.schema.createTable("domains").addColumn("id", "varchar(255)", (t) => t.notNull().primaryKey()).addColumn(
4649
4687
  "tenant_id",
4650
4688
  "varchar(255)",
4651
4689
  (t) => t.references("tenants.id").onDelete("cascade").notNull()
4652
4690
  ).addColumn("domain", "varchar(255)", (t) => t.notNull()).addColumn("email_service", "varchar(255)").addColumn("email_api_key", "varchar(255)").addColumn("dkim_private_key", "varchar(2048)").addColumn("dkim_public_key", "varchar(2048)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("updated_at", "varchar(255)", (t) => t.notNull()).execute();
4653
4691
  }
4654
- const yc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4692
+ const vc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4655
4693
  __proto__: null,
4656
- down: wc,
4657
- up: gc
4694
+ down: yc,
4695
+ up: wc
4658
4696
  }, Symbol.toStringTag, { value: "Module" }));
4659
- async function vc(e) {
4660
- }
4661
4697
  async function Cc(e) {
4698
+ }
4699
+ async function xc(e) {
4662
4700
  await e.schema.alterTable("logins").dropColumn("authParams_organization").dropColumn("authorization_url").execute();
4663
4701
  }
4664
- const xc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4702
+ const Tc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4665
4703
  __proto__: null,
4666
- down: Cc,
4667
- up: vc
4704
+ down: xc,
4705
+ up: Cc
4668
4706
  }, Symbol.toStringTag, { value: "Module" }));
4669
- async function Tc(e) {
4707
+ async function Nc(e) {
4670
4708
  await e.schema.alterTable("logins").dropColumn("authorization_url").execute(), await e.schema.alterTable("logins").addColumn("authorization_url", "varchar(2048)").execute();
4671
4709
  }
4672
- async function Nc(e) {
4710
+ async function bc(e) {
4673
4711
  await e.schema.alterTable("logins").dropColumn("authorization_url").execute(), await e.schema.alterTable("logins").addColumn("authorization_url", "varchar(1024)").execute();
4674
4712
  }
4675
4713
  const Sc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4676
4714
  __proto__: null,
4677
- down: Nc,
4678
- up: Tc
4715
+ down: bc,
4716
+ up: Nc
4679
4717
  }, Symbol.toStringTag, { value: "Module" }));
4680
- async function bc(e) {
4681
- }
4682
4718
  async function Oc(e) {
4683
4719
  }
4684
- const kc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4720
+ async function kc(e) {
4721
+ }
4722
+ const $c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4685
4723
  __proto__: null,
4686
- down: Oc,
4687
- up: bc
4724
+ down: kc,
4725
+ up: Oc
4688
4726
  }, Symbol.toStringTag, { value: "Module" }));
4689
- async function $c(e) {
4727
+ async function Ec(e) {
4690
4728
  await e.schema.createTable("sessions").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4691
4729
  "sessions_user_id_constraint",
4692
4730
  ["user_id", "tenant_id"],
@@ -4713,25 +4751,25 @@ async function $c(e) {
4713
4751
  (t) => t.onDelete("cascade")
4714
4752
  ).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (t) => t.notNull()).addColumn("resource_servers", "varchar(2048)", (t) => t.notNull()).addColumn("rotating", "boolean", (t) => t.notNull()).execute();
4715
4753
  }
4716
- async function Ec(e) {
4754
+ async function Ic(e) {
4717
4755
  await e.schema.dropTable("sessions").execute(), await e.schema.dropTable("login_sessions").execute(), await e.schema.dropTable("refresh_tokens").execute();
4718
4756
  }
4719
- const Ic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4757
+ const zc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4720
4758
  __proto__: null,
4721
- down: Ec,
4722
- up: $c
4759
+ down: Ic,
4760
+ up: Ec
4723
4761
  }, Symbol.toStringTag, { value: "Module" }));
4724
- async function zc(e) {
4762
+ async function Pc(e) {
4725
4763
  await e.schema.dropTable("logins").execute(), await e.schema.dropTable("sessions_2").execute(), await e.schema.dropTable("refresh_tokens_2").execute();
4726
4764
  }
4727
- async function Pc(e) {
4765
+ async function Dc(e) {
4728
4766
  }
4729
- const Dc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4767
+ const Ac = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4730
4768
  __proto__: null,
4731
- down: Pc,
4732
- up: zc
4769
+ down: Dc,
4770
+ up: Pc
4733
4771
  }, Symbol.toStringTag, { value: "Module" }));
4734
- async function Ac(e) {
4772
+ async function jc(e) {
4735
4773
  await e.schema.dropTable("custom_domains").execute(), await e.schema.createTable("custom_domains").addColumn(
4736
4774
  "custom_domain_id",
4737
4775
  "varchar(256)",
@@ -4742,120 +4780,120 @@ async function Ac(e) {
4742
4780
  (t) => t.references("tenants.id").onDelete("cascade").notNull()
4743
4781
  ).addColumn("domain", "varchar(255)", (t) => t.notNull()).addColumn("primary", "boolean", (t) => t.notNull()).addColumn("status", "varchar(50)", (t) => t.notNull()).addColumn("type", "varchar(50)", (t) => t.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).execute();
4744
4782
  }
4745
- async function jc(e) {
4783
+ async function Fc(e) {
4746
4784
  }
4747
- const Fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4785
+ const Rc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4748
4786
  __proto__: null,
4749
- down: jc,
4750
- up: Ac
4787
+ down: Fc,
4788
+ up: jc
4751
4789
  }, Symbol.toStringTag, { value: "Module" }));
4752
- async function Rc(e) {
4753
- }
4754
4790
  async function Mc(e) {
4791
+ }
4792
+ async function Jc(e) {
4755
4793
  await e.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
4756
4794
  }
4757
- const Jc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4795
+ const Lc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4758
4796
  __proto__: null,
4759
- down: Mc,
4760
- up: Rc
4797
+ down: Jc,
4798
+ up: Mc
4761
4799
  }, Symbol.toStringTag, { value: "Module" }));
4762
- async function Lc(e) {
4800
+ async function Kc(e) {
4763
4801
  await e.schema.createTable("forms").addColumn("id", "varchar(255)", (t) => t.primaryKey()).addColumn("name", "varchar(255)", (t) => t.notNull()).addColumn("tenant_id", "varchar(255)", (t) => t.notNull()).addColumn("messages", "varchar(255)").addColumn("languages", "varchar(255)").addColumn("translations", "varchar(4096)").addColumn("nodes", "varchar(4096)").addColumn("start", "varchar(255)").addColumn("ending", "varchar(255)").addColumn("style", "varchar(1042)").addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("updated_at", "varchar(255)", (t) => t.notNull()).execute(), await e.schema.createIndex("forms_tenant_id_idx").on("forms").column("tenant_id").execute();
4764
4802
  }
4765
- async function Kc(e) {
4803
+ async function qc(e) {
4766
4804
  await e.schema.dropTable("forms").execute();
4767
4805
  }
4768
- const qc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4806
+ const Bc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4769
4807
  __proto__: null,
4770
- down: Kc,
4771
- up: Lc
4808
+ down: qc,
4809
+ up: Kc
4772
4810
  }, Symbol.toStringTag, { value: "Module" }));
4773
4811
  async function Uc(e) {
4774
4812
  await e.schema.alterTable("hooks").addColumn("form_id", "text").execute(), await e.schema.alterTable("hooks").addColumn("url_tmp", "varchar(512)").execute(), await e.updateTable("hooks").set((t) => ({ url_tmp: t.ref("url") })).execute(), await e.schema.alterTable("hooks").dropColumn("url").execute(), await e.schema.alterTable("hooks").renameColumn("url_tmp", "url").execute();
4775
4813
  }
4776
- async function Bc(e) {
4814
+ async function Qc(e) {
4777
4815
  await e.schema.dropTable("hooks").ifExists().execute(), await e.schema.createTable("hooks").addColumn("hook_id", "text", (t) => t.primaryKey()).addColumn("tenant_id", "text", (t) => t.notNull()).addColumn("trigger_id", "text", (t) => t.notNull()).addColumn("enabled", "integer", (t) => t.notNull().defaultTo(0)).addColumn("url", "varchar(512)", (t) => t.notNull()).addColumn("synchronous", "integer", (t) => t.notNull().defaultTo(0)).addColumn("priority", "integer").addColumn("created_at", "text", (t) => t.notNull()).addColumn("updated_at", "text", (t) => t.notNull()).execute();
4778
4816
  }
4779
- const Qc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4817
+ const Hc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4780
4818
  __proto__: null,
4781
- down: Bc,
4819
+ down: Qc,
4782
4820
  up: Uc
4783
4821
  }, Symbol.toStringTag, { value: "Module" }));
4784
- async function Hc(e) {
4822
+ async function Yc(e) {
4785
4823
  await e.schema.alterTable("login_sessions").addColumn(
4786
4824
  "login_completed",
4787
4825
  "boolean",
4788
4826
  (t) => t.notNull().defaultTo(0)
4789
4827
  ).execute();
4790
4828
  }
4791
- async function Yc(e) {
4829
+ async function Wc(e) {
4792
4830
  await e.schema.alterTable("login_sessions").dropColumn("login_completed").execute();
4793
4831
  }
4794
- const Wc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4832
+ const Gc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4795
4833
  __proto__: null,
4796
- down: Yc,
4797
- up: Hc
4834
+ down: Wc,
4835
+ up: Yc
4798
4836
  }, Symbol.toStringTag, { value: "Module" }));
4799
- async function Gc(e) {
4837
+ async function Vc(e) {
4800
4838
  await e.schema.alterTable("sessions").addColumn(
4801
4839
  "login_session_id",
4802
4840
  "varchar(21)",
4803
4841
  (t) => t.references("login_sessions.id").onDelete("set null")
4804
4842
  ).execute();
4805
4843
  }
4806
- async function Vc(e) {
4844
+ async function Xc(e) {
4807
4845
  await e.schema.alterTable("sessions").dropColumn("login_session_id").execute();
4808
4846
  }
4809
- const Xc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4847
+ const Zc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4810
4848
  __proto__: null,
4811
- down: Vc,
4812
- up: Gc
4849
+ down: Xc,
4850
+ up: Vc
4813
4851
  }, Symbol.toStringTag, { value: "Module" }));
4814
- async function Zc(e) {
4852
+ async function el(e) {
4815
4853
  await e.schema.createIndex("IDX_sessions_login_session_id").on("sessions").column("login_session_id").execute();
4816
4854
  }
4817
- async function el(e) {
4855
+ async function tl(e) {
4818
4856
  await e.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
4819
4857
  }
4820
- const tl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4858
+ const al = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4821
4859
  __proto__: null,
4822
- down: el,
4823
- up: Zc
4860
+ down: tl,
4861
+ up: el
4824
4862
  }, Symbol.toStringTag, { value: "Module" }));
4825
- async function al(e) {
4863
+ async function nl(e) {
4826
4864
  await e.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await e.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
4827
4865
  }
4828
- async function nl(e) {
4866
+ async function ol(e) {
4829
4867
  await e.schema.alterTable("codes").dropColumn("code_challenge").execute(), await e.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
4830
4868
  }
4831
- const ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4869
+ const rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4832
4870
  __proto__: null,
4833
- down: nl,
4834
- up: al
4871
+ down: ol,
4872
+ up: nl
4835
4873
  }, Symbol.toStringTag, { value: "Module" }));
4836
- async function rl(e) {
4874
+ async function sl(e) {
4837
4875
  await e.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
4838
4876
  }
4839
- async function sl(e) {
4877
+ async function il(e) {
4840
4878
  await e.schema.alterTable("codes").dropColumn("redirect_uri").execute();
4841
4879
  }
4842
- const il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4880
+ const cl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4843
4881
  __proto__: null,
4844
- down: sl,
4845
- up: rl
4882
+ down: il,
4883
+ up: sl
4846
4884
  }, Symbol.toStringTag, { value: "Module" }));
4847
- async function cl(e) {
4885
+ async function ll(e) {
4848
4886
  await e.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await e.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
4849
4887
  }
4850
- async function ll(e) {
4888
+ async function dl(e) {
4851
4889
  await e.schema.alterTable("codes").dropColumn("nonce").execute(), await e.schema.alterTable("codes").dropColumn("state").execute();
4852
4890
  }
4853
- const dl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4891
+ const ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4854
4892
  __proto__: null,
4855
- down: ll,
4856
- up: cl
4893
+ down: dl,
4894
+ up: ll
4857
4895
  }, Symbol.toStringTag, { value: "Module" }));
4858
- async function ul(e) {
4896
+ async function _l(e) {
4859
4897
  await e.schema.createTable("themes").addColumn(
4860
4898
  "tenant_id",
4861
4899
  "varchar(255)",
@@ -4930,26 +4968,26 @@ async function ul(e) {
4930
4968
  (t) => t.notNull()
4931
4969
  ).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).addPrimaryKeyConstraint("themes_pkey", ["tenant_id", "themeId"]).execute(), await e.schema.createIndex("themes_tenant_id_idx").on("themes").column("tenant_id").execute();
4932
4970
  }
4933
- async function _l(e) {
4971
+ async function ml(e) {
4934
4972
  await e.schema.dropTable("themes").execute();
4935
4973
  }
4936
- const ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4974
+ const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4937
4975
  __proto__: null,
4938
- down: _l,
4939
- up: ul
4976
+ down: ml,
4977
+ up: _l
4940
4978
  }, Symbol.toStringTag, { value: "Module" }));
4941
- async function hl(e) {
4979
+ async function pl(e) {
4942
4980
  await e.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (t) => t.notNull()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("identifier", "varchar(191)", (t) => t.notNull()).addColumn("name", "varchar(255)", (t) => t.notNull()).addColumn("scopes", "varchar(4096)").addColumn("signing_alg", "varchar(64)").addColumn("signing_secret", "varchar(2048)").addColumn("token_lifetime", "integer").addColumn("token_lifetime_for_web", "integer").addColumn("skip_consent_for_verifiable_first_party_clients", "integer").addColumn("allow_offline_access", "integer").addColumn("verification_key", "varchar(4096)").addColumn("options", "varchar(4096)").addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).addPrimaryKeyConstraint("resource_servers_pk", ["tenant_id", "id"]).execute(), await e.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await e.schema.createTable("roles").addColumn("id", "varchar(21)", (t) => t.notNull()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("name", "varchar(50)", (t) => t.notNull()).addColumn("description", "varchar(255)").addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).addPrimaryKeyConstraint("roles_pk", ["tenant_id", "id"]).execute(), await e.schema.createIndex("roles_tenant_name_uq").on("roles").columns(["tenant_id", "name"]).unique().execute();
4943
4981
  }
4944
- async function pl(e) {
4982
+ async function fl(e) {
4945
4983
  await e.schema.dropTable("roles").execute(), await e.schema.dropTable("resource_servers").execute();
4946
4984
  }
4947
- const fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4985
+ const gl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4948
4986
  __proto__: null,
4949
- down: pl,
4950
- up: hl
4987
+ down: fl,
4988
+ up: pl
4951
4989
  }, Symbol.toStringTag, { value: "Module" }));
4952
- async function gl(e) {
4990
+ async function wl(e) {
4953
4991
  await e.schema.createTable("role_permissions").addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("role_id", "varchar(21)", (t) => t.notNull()).addColumn(
4954
4992
  "resource_server_identifier",
4955
4993
  "varchar(191)",
@@ -4970,66 +5008,66 @@ async function gl(e) {
4970
5008
  "permission_name"
4971
5009
  ]).execute(), await e.schema.createIndex("user_permissions_user_fk").on("user_permissions").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("user_permissions_permission_fk").on("user_permissions").columns(["tenant_id", "resource_server_identifier", "permission_name"]).execute();
4972
5010
  }
4973
- async function wl(e) {
5011
+ async function yl(e) {
4974
5012
  await e.schema.dropTable("user_permissions").execute(), await e.schema.dropTable("role_permissions").execute();
4975
5013
  }
4976
- const yl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5014
+ const vl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4977
5015
  __proto__: null,
4978
- down: wl,
4979
- up: gl
5016
+ down: yl,
5017
+ up: wl
4980
5018
  }, Symbol.toStringTag, { value: "Module" }));
4981
- async function vl(e) {
5019
+ async function Cl(e) {
4982
5020
  await e.schema.createTable("user_roles").addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("user_id", "varchar(191)", (t) => t.notNull()).addColumn("role_id", "varchar(21)", (t) => t.notNull()).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addPrimaryKeyConstraint("user_roles_pk", [
4983
5021
  "tenant_id",
4984
5022
  "user_id",
4985
5023
  "role_id"
4986
5024
  ]).execute(), await e.schema.createIndex("user_roles_user_fk").on("user_roles").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("user_roles_role_fk").on("user_roles").columns(["tenant_id", "role_id"]).execute();
4987
5025
  }
4988
- async function Cl(e) {
5026
+ async function xl(e) {
4989
5027
  await e.schema.dropTable("user_roles").execute();
4990
5028
  }
4991
- const xl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5029
+ const Tl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4992
5030
  __proto__: null,
4993
- down: Cl,
4994
- up: vl
5031
+ down: xl,
5032
+ up: Cl
4995
5033
  }, Symbol.toStringTag, { value: "Module" }));
4996
- async function Tl(e) {
4997
- }
4998
5034
  async function Nl(e) {
5035
+ }
5036
+ async function bl(e) {
4999
5037
  await e.schema.alterTable("keys").dropColumn("connection").execute(), await e.schema.alterTable("keys").modifyColumn("cert", "varchar(2048)").execute(), await e.schema.alterTable("keys").modifyColumn("pkcs7", "varchar(2048)").execute(), await e.schema.alterTable("keys").dropColumn("type").execute();
5000
5038
  }
5001
5039
  const Sl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5002
5040
  __proto__: null,
5003
- down: Nl,
5004
- up: Tl
5041
+ down: bl,
5042
+ up: Nl
5005
5043
  }, Symbol.toStringTag, { value: "Module" }));
5006
- async function bl(e) {
5044
+ async function Ol(e) {
5007
5045
  await e.schema.createTable("organizations").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("name", "varchar(256)", (t) => t.notNull()).addColumn("display_name", "varchar(256)").addColumn("branding", "text").addColumn("metadata", "text").addColumn("enabled_connections", "text").addColumn("token_quota", "text").addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).execute(), await e.schema.createIndex("idx_organizations_tenant_id").on("organizations").column("tenant_id").execute(), await e.schema.createIndex("idx_organizations_tenant_name_unique").on("organizations").columns(["tenant_id", "name"]).unique().execute();
5008
5046
  }
5009
- async function Ol(e) {
5047
+ async function kl(e) {
5010
5048
  await e.schema.dropTable("organizations").execute();
5011
5049
  }
5012
- const kl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5050
+ const $l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5013
5051
  __proto__: null,
5014
- down: Ol,
5015
- up: bl
5052
+ down: kl,
5053
+ up: Ol
5016
5054
  }, Symbol.toStringTag, { value: "Module" }));
5017
- async function $l(e) {
5055
+ async function El(e) {
5018
5056
  await e.schema.createTable("user_organizations").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("user_id", "varchar(191)", (t) => t.notNull()).addColumn("organization_id", "varchar(21)", (t) => t.notNull()).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).addUniqueConstraint("user_organizations_unique", [
5019
5057
  "tenant_id",
5020
5058
  "user_id",
5021
5059
  "organization_id"
5022
5060
  ]).execute(), await e.schema.createIndex("idx_user_organizations_tenant_id").on("user_organizations").column("tenant_id").execute(), await e.schema.createIndex("idx_user_organizations_user_id").on("user_organizations").column("user_id").execute(), await e.schema.createIndex("idx_user_organizations_organization_id").on("user_organizations").column("organization_id").execute();
5023
5061
  }
5024
- async function El(e) {
5062
+ async function Il(e) {
5025
5063
  await e.schema.dropTable("user_organizations").execute();
5026
5064
  }
5027
- const Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5065
+ const zl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5028
5066
  __proto__: null,
5029
- down: El,
5030
- up: $l
5067
+ down: Il,
5068
+ up: El
5031
5069
  }, Symbol.toStringTag, { value: "Module" }));
5032
- async function zl(e) {
5070
+ async function Pl(e) {
5033
5071
  await e.schema.dropTable("user_permissions").execute(), await e.schema.dropTable("user_roles").execute(), await e.schema.createTable("user_permissions").addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("user_id", "varchar(191)", (t) => t.notNull()).addColumn(
5034
5072
  "resource_server_identifier",
5035
5073
  "varchar(21)",
@@ -5055,7 +5093,7 @@ async function zl(e) {
5055
5093
  "organization_id"
5056
5094
  ]).execute(), await e.schema.createIndex("user_roles_user_fk").on("user_roles").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("user_roles_role_fk").on("user_roles").columns(["tenant_id", "role_id"]).execute(), await e.schema.createIndex("user_roles_organization_fk").on("user_roles").column("organization_id").execute();
5057
5095
  }
5058
- async function Pl(e) {
5096
+ async function Dl(e) {
5059
5097
  await e.schema.dropTable("user_permissions").execute(), await e.schema.dropTable("user_roles").execute(), await e.schema.createTable("user_permissions").addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("user_id", "varchar(191)", (t) => t.notNull()).addColumn(
5060
5098
  "resource_server_identifier",
5061
5099
  "varchar(191)",
@@ -5071,12 +5109,12 @@ async function Pl(e) {
5071
5109
  "role_id"
5072
5110
  ]).execute(), await e.schema.createIndex("user_roles_user_fk").on("user_roles").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("user_roles_role_fk").on("user_roles").columns(["tenant_id", "role_id"]).execute();
5073
5111
  }
5074
- const Dl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5112
+ const Al = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5075
5113
  __proto__: null,
5076
- down: Pl,
5077
- up: zl
5114
+ down: Dl,
5115
+ up: Pl
5078
5116
  }, Symbol.toStringTag, { value: "Module" }));
5079
- async function Al(e) {
5117
+ async function jl(e) {
5080
5118
  await e.schema.createTable("clients").addColumn("client_id", "varchar(191)", (t) => t.notNull()).addColumn(
5081
5119
  "tenant_id",
5082
5120
  "varchar(191)",
@@ -5118,13 +5156,13 @@ async function Al(e) {
5118
5156
  "client_id"
5119
5157
  ]).execute();
5120
5158
  }
5121
- async function jl(e) {
5159
+ async function Fl(e) {
5122
5160
  await e.schema.dropTable("clients").execute();
5123
5161
  }
5124
- const Fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5162
+ const Rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5125
5163
  __proto__: null,
5126
- down: jl,
5127
- up: Al
5164
+ down: Fl,
5165
+ up: jl
5128
5166
  }, Symbol.toStringTag, { value: "Module" }));
5129
5167
  async function ye(e) {
5130
5168
  try {
@@ -5133,10 +5171,10 @@ async function ye(e) {
5133
5171
  return "sqlite";
5134
5172
  }
5135
5173
  }
5136
- async function Rl(e) {
5137
- await ye(e) === "mysql" ? await Ml(e) : await Jl(e);
5138
- }
5139
5174
  async function Ml(e) {
5175
+ await ye(e) === "mysql" ? await Jl(e) : await Ll(e);
5176
+ }
5177
+ async function Jl(e) {
5140
5178
  await e.transaction().execute(async (t) => {
5141
5179
  const a = await h`
5142
5180
  SELECT
@@ -5217,7 +5255,7 @@ async function Ml(e) {
5217
5255
  FROM login_sessions_backup`.execute(t), await h`DROP TABLE sessions_backup`.execute(t), await h`DROP TABLE login_sessions_backup`.execute(t), await h`DROP TABLE refresh_tokens_backup`.execute(t);
5218
5256
  });
5219
5257
  }
5220
- async function Jl(e) {
5258
+ async function Ll(e) {
5221
5259
  await e.transaction().execute(async (t) => {
5222
5260
  const a = [
5223
5261
  "sessions_backup",
@@ -5283,10 +5321,10 @@ async function Jl(e) {
5283
5321
  FROM login_sessions_backup`.execute(t), await h`DROP TABLE sessions_backup`.execute(t), await h`DROP TABLE login_sessions_backup`.execute(t), await h`DROP TABLE refresh_tokens_backup`.execute(t);
5284
5322
  });
5285
5323
  }
5286
- async function Ll(e) {
5287
- await ye(e) === "mysql" ? await Kl(e) : await ql(e);
5288
- }
5289
5324
  async function Kl(e) {
5325
+ await ye(e) === "mysql" ? await ql(e) : await Bl(e);
5326
+ }
5327
+ async function ql(e) {
5290
5328
  await e.transaction().execute(async (t) => {
5291
5329
  await h`ALTER TABLE refresh_tokens DROP FOREIGN KEY refresh_tokens_client_fk`.execute(
5292
5330
  t
@@ -5303,7 +5341,7 @@ async function Kl(e) {
5303
5341
  );
5304
5342
  });
5305
5343
  }
5306
- async function ql(e) {
5344
+ async function Bl(e) {
5307
5345
  await e.transaction().execute(async (t) => {
5308
5346
  await h`CREATE TABLE refresh_tokens_temp AS SELECT * FROM refresh_tokens`.execute(
5309
5347
  t
@@ -5335,10 +5373,10 @@ async function ql(e) {
5335
5373
  }
5336
5374
  const Ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5337
5375
  __proto__: null,
5338
- down: Ll,
5339
- up: Rl
5376
+ down: Kl,
5377
+ up: Ml
5340
5378
  }, Symbol.toStringTag, { value: "Module" }));
5341
- async function Bl(e) {
5379
+ async function Ql(e) {
5342
5380
  await e.schema.createTable("client_grants").addColumn("id", "varchar(21)", (t) => t.notNull()).addColumn(
5343
5381
  "tenant_id",
5344
5382
  "varchar(191)",
@@ -5355,89 +5393,89 @@ async function Bl(e) {
5355
5393
  (t) => t.onDelete("cascade")
5356
5394
  ).execute(), await e.schema.createIndex("uq_client_grants_tenant_client_audience").on("client_grants").columns(["tenant_id", "client_id", "audience"]).unique().execute(), await e.schema.createIndex("idx_client_grants_audience").on("client_grants").columns(["audience"]).execute();
5357
5395
  }
5358
- async function Ql(e) {
5396
+ async function Hl(e) {
5359
5397
  await e.schema.dropTable("client_grants").execute();
5360
5398
  }
5361
- const Hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5399
+ const Yl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5362
5400
  __proto__: null,
5363
- down: Ql,
5364
- up: Bl
5401
+ down: Hl,
5402
+ up: Ql
5365
5403
  }, Symbol.toStringTag, { value: "Module" }));
5366
- async function Yl(e) {
5404
+ async function Wl(e) {
5367
5405
  await e.schema.dropTable("applications").execute();
5368
5406
  }
5369
- async function Wl(e) {
5407
+ async function Gl(e) {
5370
5408
  await e.schema.createTable("applications").addColumn("id", "varchar(21)", (t) => t.notNull()).addColumn(
5371
5409
  "tenant_id",
5372
5410
  "varchar(191)",
5373
5411
  (t) => t.notNull().references("tenants.id").onDelete("cascade")
5374
5412
  ).addColumn("name", "varchar(255)", (t) => t.notNull()).addColumn("client_secret", "varchar(255)").addColumn("callbacks", "text", (t) => t.defaultTo("[]")).addColumn("allowed_origins", "text", (t) => t.defaultTo("[]")).addColumn("web_origins", "text", (t) => t.defaultTo("[]")).addColumn("allowed_logout_urls", "text", (t) => t.defaultTo("[]")).addColumn("allowed_clients", "text", (t) => t.defaultTo("[]")).addColumn("disable_sign_ups", "integer", (t) => t.defaultTo(0)).addColumn("addons", "text", (t) => t.defaultTo("{}")).addColumn("client_metadata", "text", (t) => t.defaultTo("{}")).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).addPrimaryKeyConstraint("pk_applications", ["tenant_id", "id"]).execute(), await e.schema.createIndex("idx_applications_tenant_id").on("applications").columns(["tenant_id"]).execute();
5375
5413
  }
5376
- const Gl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5414
+ const Vl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5377
5415
  __proto__: null,
5378
- down: Wl,
5379
- up: Yl
5416
+ down: Gl,
5417
+ up: Wl
5380
5418
  }, Symbol.toStringTag, { value: "Module" }));
5381
- async function Vl(e) {
5419
+ async function Xl(e) {
5382
5420
  await e.schema.createIndex("users_phone_tenant_provider_index").on("users").columns(["tenant_id", "phone_number", "provider"]).execute();
5383
5421
  }
5384
- async function Xl(e) {
5422
+ async function Zl(e) {
5385
5423
  await e.schema.dropIndex("users_phone_tenant_provider_index").execute();
5386
5424
  }
5387
- const Zl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5425
+ const ed = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5388
5426
  __proto__: null,
5389
- down: Xl,
5390
- up: Vl
5427
+ down: Zl,
5428
+ up: Xl
5391
5429
  }, Symbol.toStringTag, { value: "Module" }));
5392
- async function ed(e) {
5430
+ async function td(e) {
5393
5431
  await e.schema.createIndex("login_sessions_id_index").on("login_sessions").column("id").execute();
5394
5432
  }
5395
- async function td(e) {
5433
+ async function ad(e) {
5396
5434
  await e.schema.dropIndex("login_sessions_id_index").execute();
5397
5435
  }
5398
- const ad = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5436
+ const nd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5399
5437
  __proto__: null,
5400
- down: td,
5401
- up: ed
5438
+ down: ad,
5439
+ up: td
5402
5440
  }, Symbol.toStringTag, { value: "Module" }));
5403
- async function nd(e) {
5441
+ async function od(e) {
5404
5442
  await e.schema.createIndex("connections_tenant_id_index").on("connections").column("tenant_id").execute();
5405
5443
  }
5406
- async function od(e) {
5444
+ async function rd(e) {
5407
5445
  await e.schema.dropIndex("connections_tenant_id_index").execute();
5408
5446
  }
5409
- const rd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5447
+ const sd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5410
5448
  __proto__: null,
5411
- down: od,
5412
- up: nd
5449
+ down: rd,
5450
+ up: od
5413
5451
  }, Symbol.toStringTag, { value: "Module" }));
5414
- async function sd(e) {
5452
+ async function id(e) {
5415
5453
  await e.schema.dropIndex("idx_user_organizations_tenant_id").execute();
5416
5454
  }
5417
- async function id(e) {
5455
+ async function cd(e) {
5418
5456
  await e.schema.createIndex("idx_user_organizations_tenant_id").on("user_organizations").column("tenant_id").execute();
5419
5457
  }
5420
- const cd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5458
+ const ld = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5421
5459
  __proto__: null,
5422
- down: id,
5423
- up: sd
5460
+ down: cd,
5461
+ up: id
5424
5462
  }, Symbol.toStringTag, { value: "Module" }));
5425
- async function ld(e) {
5463
+ async function dd(e) {
5426
5464
  await e.schema.createTable("tenant_settings").addColumn(
5427
5465
  "tenant_id",
5428
5466
  "varchar(191)",
5429
5467
  (t) => t.references("tenants.id").onDelete("cascade").notNull().primaryKey()
5430
5468
  ).addColumn("idle_session_lifetime", "integer").addColumn("session_lifetime", "integer").addColumn("session_cookie", "text").addColumn("enable_client_connections", "integer").addColumn("default_redirection_uri", "text").addColumn("enabled_locales", "text").addColumn("default_directory", "varchar(255)").addColumn("error_page", "text").addColumn("flags", "text").addColumn("friendly_name", "varchar(255)").addColumn("picture_url", "text").addColumn("support_email", "varchar(255)").addColumn("support_url", "text").addColumn("sandbox_version", "varchar(50)").addColumn("sandbox_versions_available", "text").addColumn("change_password", "text").addColumn("guardian_mfa_page", "text").addColumn("default_audience", "varchar(255)").addColumn("default_organization", "varchar(255)").addColumn("sessions", "text").execute();
5431
5469
  }
5432
- async function dd(e) {
5470
+ async function ud(e) {
5433
5471
  await e.schema.dropTable("tenant_settings").execute();
5434
5472
  }
5435
- const ud = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5473
+ const _d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5436
5474
  __proto__: null,
5437
- down: dd,
5438
- up: ld
5475
+ down: ud,
5476
+ up: dd
5439
5477
  }, Symbol.toStringTag, { value: "Module" }));
5440
- async function _d(e) {
5478
+ async function md(e) {
5441
5479
  if (await e.schema.alterTable("tenants").addColumn("idle_session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("session_cookie", "text").execute(), await e.schema.alterTable("tenants").addColumn("allowed_logout_urls", "text").execute(), await e.schema.alterTable("tenants").addColumn("ephemeral_session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("idle_ephemeral_session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("default_redirection_uri", "text").execute(), await e.schema.alterTable("tenants").addColumn("enabled_locales", "text").execute(), await e.schema.alterTable("tenants").addColumn("default_directory", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("error_page", "text").execute(), await e.schema.alterTable("tenants").addColumn("flags", "text").execute(), await e.schema.alterTable("tenants").addColumn("friendly_name", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("picture_url", "text").execute(), await e.schema.alterTable("tenants").addColumn("support_email", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("sandbox_version", "varchar(50)").execute(), await e.schema.alterTable("tenants").addColumn("sandbox_versions_available", "text").execute(), await e.schema.alterTable("tenants").addColumn("legacy_sandbox_version", "varchar(50)").execute(), await e.schema.alterTable("tenants").addColumn("change_password", "text").execute(), await e.schema.alterTable("tenants").addColumn("guardian_mfa_page", "text").execute(), await e.schema.alterTable("tenants").addColumn("device_flow", "text").execute(), await e.schema.alterTable("tenants").addColumn("default_token_quota", "text").execute(), await e.schema.alterTable("tenants").addColumn("default_audience", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("default_organization", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("sessions", "text").execute(), await e.schema.alterTable("tenants").addColumn("oidc_logout", "text").execute(), await e.schema.alterTable("tenants").addColumn("allow_organization_name_in_authentication_api", "integer").execute(), await e.schema.alterTable("tenants").addColumn("customize_mfa_in_postlogin_action", "integer").execute(), await e.schema.alterTable("tenants").addColumn("acr_values_supported", "text").execute(), await e.schema.alterTable("tenants").addColumn("mtls", "text").execute(), await e.schema.alterTable("tenants").addColumn("pushed_authorization_requests_supported", "integer").execute(), await e.schema.alterTable("tenants").addColumn("authorization_response_iss_parameter_supported", "integer").execute(), await e.updateTable("tenants").set({
5442
5480
  friendly_name: h`name`
5443
5481
  }).execute(), await e.schema.alterTable("tenants").dropColumn("language").execute(), await e.schema.alterTable("tenants").dropColumn("logo").execute(), await e.schema.alterTable("tenants").dropColumn("primary_color").execute(), await e.schema.alterTable("tenants").dropColumn("secondary_color").execute(), await e.schema.alterTable("tenants").dropColumn("name").execute(), (await e.selectFrom("tenant_settings").select("tenant_id").limit(1).execute()).length > 0) {
@@ -5468,7 +5506,7 @@ async function _d(e) {
5468
5506
  }
5469
5507
  await e.schema.dropTable("tenant_settings").execute();
5470
5508
  }
5471
- async function md(e) {
5509
+ async function hd(e) {
5472
5510
  await e.schema.createTable("tenant_settings").addColumn(
5473
5511
  "tenant_id",
5474
5512
  "varchar(191)",
@@ -5525,45 +5563,45 @@ async function md(e) {
5525
5563
  name: h`COALESCE(friendly_name, id)`
5526
5564
  }).execute(), await e.schema.alterTable("tenants").addColumn("language", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("logo", "text").execute(), await e.schema.alterTable("tenants").addColumn("primary_color", "varchar(50)").execute(), await e.schema.alterTable("tenants").addColumn("secondary_color", "varchar(50)").execute();
5527
5565
  }
5528
- const hd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5566
+ const pd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5529
5567
  __proto__: null,
5530
- down: md,
5531
- up: _d
5568
+ down: hd,
5569
+ up: md
5532
5570
  }, Symbol.toStringTag, { value: "Module" }));
5533
- async function pd(e) {
5571
+ async function fd(e) {
5534
5572
  await e.schema.createTable("invites").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("organization_id", "varchar(21)", (t) => t.notNull()).addColumn("inviter", "text", (t) => t.notNull()).addColumn("invitee", "text", (t) => t.notNull()).addColumn("client_id", "varchar(191)", (t) => t.notNull()).addColumn("connection_id", "varchar(21)").addColumn("invitation_url", "text", (t) => t.notNull()).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("expires_at", "varchar(35)", (t) => t.notNull()).addColumn("app_metadata", "text").addColumn("user_metadata", "text").addColumn("roles", "text").addColumn("ticket_id", "varchar(191)").addColumn("ttl_sec", "integer").addColumn("send_invitation_email", "integer").execute(), await e.schema.createIndex("idx_invites_tenant_id").on("invites").column("tenant_id").execute(), await e.schema.createIndex("idx_invites_organization_id").on("invites").column("organization_id").execute(), await e.schema.createIndex("idx_invites_expires_at").on("invites").column("expires_at").execute(), await e.schema.createIndex("idx_invites_tenant_created").on("invites").columns(["tenant_id", "created_at"]).execute();
5535
5573
  }
5536
- async function fd(e) {
5574
+ async function gd(e) {
5537
5575
  await e.schema.dropTable("invites").execute();
5538
5576
  }
5539
- const gd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5577
+ const wd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5540
5578
  __proto__: null,
5541
- down: fd,
5542
- up: pd
5579
+ down: gd,
5580
+ up: fd
5543
5581
  }, Symbol.toStringTag, { value: "Module" }));
5544
- async function wd(e) {
5582
+ async function yd(e) {
5545
5583
  await e.schema.dropTable("logs").ifExists().execute(), await e.schema.createTable("logs").addColumn("log_id", "varchar(21)", (t) => t.primaryKey().notNull()).addColumn("category", "varchar(255)").addColumn("tenant_id", "varchar(64)").addColumn("user_id", "varchar(64)").addColumn("ip", "varchar(255)").addColumn("type", "varchar(8)", (t) => t.notNull()).addColumn("date", "varchar(25)", (t) => t.notNull()).addColumn("client_id", "varchar(255)").addColumn("client_name", "varchar(255)").addColumn("user_agent", "varchar(255)").addColumn("description", "varchar(255)").addColumn("details", "varchar(2048)").addColumn("isMobile", "integer").addColumn("user_name", "varchar(255)").addColumn("connection", "varchar(255)").addColumn("connection_id", "varchar(255)").addColumn("audience", "varchar(255)").addColumn("scope", "varchar(255)").addColumn("strategy", "varchar(255)").addColumn("strategy_type", "varchar(255)").addColumn("hostname", "varchar(255)").addColumn("auth0_client", "varchar(8192)").addColumn("session_connection", "varchar(255)").execute();
5546
5584
  }
5547
- async function yd(e) {
5585
+ async function vd(e) {
5548
5586
  await e.schema.dropTable("logs").ifExists().execute(), await e.schema.createTable("logs").addColumn("id", "varchar(255)", (t) => t.primaryKey().notNull()).addColumn("category", "varchar(255)", (t) => t.notNull()).addColumn("tenant_id", "varchar(64)").addColumn("user_id", "varchar(64)").addColumn("ip", "varchar(255)").addColumn("type", "varchar(8)", (t) => t.notNull()).addColumn("date", "varchar(25)", (t) => t.notNull()).addColumn("client_id", "varchar(255)").addColumn("client_name", "varchar(255)").addColumn("user_agent", "varchar(255)").addColumn("description", "varchar(255)").addColumn("details", "varchar(2048)").execute();
5549
5587
  }
5550
- const vd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5588
+ const Cd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5551
5589
  __proto__: null,
5552
- down: yd,
5553
- up: wd
5590
+ down: vd,
5591
+ up: yd
5554
5592
  }, Symbol.toStringTag, { value: "Module" }));
5555
- async function Cd(e) {
5593
+ async function xd(e) {
5556
5594
  await e.schema.alterTable("logs").addColumn("country_code", "varchar(2)").execute(), await e.schema.alterTable("logs").addColumn("city_name", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("latitude", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("longitude", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("time_zone", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("continent_code", "varchar(2)").execute();
5557
5595
  }
5558
- async function xd(e) {
5596
+ async function Td(e) {
5559
5597
  await e.schema.alterTable("logs").dropColumn("country_code").execute(), await e.schema.alterTable("logs").dropColumn("city_name").execute(), await e.schema.alterTable("logs").dropColumn("latitude").execute(), await e.schema.alterTable("logs").dropColumn("longitude").execute(), await e.schema.alterTable("logs").dropColumn("time_zone").execute(), await e.schema.alterTable("logs").dropColumn("continent_code").execute();
5560
5598
  }
5561
- const Td = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5599
+ const Nd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5562
5600
  __proto__: null,
5563
- down: xd,
5564
- up: Cd
5601
+ down: Td,
5602
+ up: xd
5565
5603
  }, Symbol.toStringTag, { value: "Module" })), j = 1e3;
5566
- async function Nd(e) {
5604
+ async function bd(e) {
5567
5605
  await e.schema.createTable("password_history").addColumn("id", "varchar(21)", (n) => n.primaryKey()).addColumn("user_id", "varchar(191)", (n) => n.notNull()).addColumn(
5568
5606
  "tenant_id",
5569
5607
  "varchar(191)",
@@ -5595,7 +5633,7 @@ async function Nd(e) {
5595
5633
  }
5596
5634
  for (const o of n)
5597
5635
  await e.insertInto("password_history").values({
5598
- id: b(),
5636
+ id: k(),
5599
5637
  user_id: o.user_id,
5600
5638
  tenant_id: o.tenant_id,
5601
5639
  password: o.password,
@@ -5656,56 +5694,56 @@ async function Sd(e) {
5656
5694
  }
5657
5695
  await e.schema.dropTable("password_history").execute();
5658
5696
  }
5659
- const bd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5697
+ const Od = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5660
5698
  __proto__: null,
5661
5699
  down: Sd,
5662
- up: Nd
5700
+ up: bd
5663
5701
  }, Symbol.toStringTag, { value: "Module" }));
5664
- async function Od(e) {
5702
+ async function kd(e) {
5665
5703
  await e.schema.alterTable("connections").addColumn("display_name", "varchar(255)").execute(), await e.schema.alterTable("connections").addColumn("is_domain_connection", "integer").execute(), await e.schema.alterTable("connections").addColumn("show_as_button", "integer").execute(), await e.schema.alterTable("connections").addColumn("metadata", "varchar(4096)").execute();
5666
5704
  }
5667
- async function kd(e) {
5705
+ async function $d(e) {
5668
5706
  await e.schema.alterTable("connections").dropColumn("display_name").execute(), await e.schema.alterTable("connections").dropColumn("is_domain_connection").execute(), await e.schema.alterTable("connections").dropColumn("show_as_button").execute(), await e.schema.alterTable("connections").dropColumn("metadata").execute();
5669
5707
  }
5670
- const $d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5708
+ const Ed = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5671
5709
  __proto__: null,
5672
- down: kd,
5673
- up: Od
5710
+ down: $d,
5711
+ up: kd
5674
5712
  }, Symbol.toStringTag, { value: "Module" }));
5675
- async function Ed(e) {
5713
+ async function Id(e) {
5676
5714
  await e.schema.alterTable("clients").addColumn("connections", "text", (t) => t.notNull().defaultTo("[]")).execute();
5677
5715
  }
5678
- async function Id(e) {
5716
+ async function zd(e) {
5679
5717
  await e.schema.alterTable("clients").dropColumn("connections").execute();
5680
5718
  }
5681
- const zd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5719
+ const Pd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5682
5720
  __proto__: null,
5683
- down: Id,
5684
- up: Ed
5721
+ down: zd,
5722
+ up: Id
5685
5723
  }, Symbol.toStringTag, { value: "Module" }));
5686
- async function Pd(e) {
5724
+ async function Dd(e) {
5687
5725
  await e.schema.createTable("flows").addColumn("id", "varchar(24)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("name", "varchar(150)", (t) => t.notNull()).addColumn("actions", "text").addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).execute(), await e.schema.createIndex("flows_tenant_id_idx").on("flows").column("tenant_id").execute(), await e.schema.dropTable("passwords_backup").execute();
5688
5726
  }
5689
- async function Dd(e) {
5727
+ async function Ad(e) {
5690
5728
  await e.schema.dropTable("flows").execute();
5691
5729
  }
5692
- const Ad = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5730
+ const jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5693
5731
  __proto__: null,
5694
- down: Dd,
5695
- up: Pd
5732
+ down: Ad,
5733
+ up: Dd
5696
5734
  }, Symbol.toStringTag, { value: "Module" }));
5697
- async function jd(e) {
5735
+ async function Fd(e) {
5698
5736
  await e.schema.alterTable("resource_servers").addColumn("is_system", "integer", (t) => t.defaultTo(0).notNull()).execute(), await e.schema.alterTable("roles").addColumn("is_system", "integer", (t) => t.defaultTo(0).notNull()).execute(), await e.schema.alterTable("connections").addColumn("is_system", "integer", (t) => t.defaultTo(0).notNull()).execute();
5699
5737
  }
5700
- async function Fd(e) {
5738
+ async function Rd(e) {
5701
5739
  await e.schema.alterTable("resource_servers").dropColumn("is_system").execute(), await e.schema.alterTable("roles").dropColumn("is_system").execute(), await e.schema.alterTable("connections").dropColumn("is_system").execute();
5702
5740
  }
5703
- const Rd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5741
+ const Md = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5704
5742
  __proto__: null,
5705
- down: Fd,
5706
- up: jd
5743
+ down: Rd,
5744
+ up: Fd
5707
5745
  }, Symbol.toStringTag, { value: "Module" }));
5708
- async function Md(e) {
5746
+ async function Jd(e) {
5709
5747
  const t = await e.selectFrom("keys").selectAll().execute();
5710
5748
  await e.schema.dropTable("keys").execute(), await h`ALTER TABLE connections RENAME TO connections_old`.execute(e), await e.schema.createTable("connections").addColumn("id", "varchar(255)", (a) => a.notNull()).addColumn(
5711
5749
  "tenant_id",
@@ -5738,7 +5776,7 @@ async function Md(e) {
5738
5776
  for (const a of t)
5739
5777
  await e.insertInto("keys").values(a).execute();
5740
5778
  }
5741
- async function Jd(e) {
5779
+ async function Ld(e) {
5742
5780
  const t = await e.selectFrom("keys").selectAll().execute();
5743
5781
  await e.schema.dropTable("keys").execute(), await h`ALTER TABLE connections RENAME TO connections_new`.execute(e), await e.schema.createTable("connections").addColumn("id", "varchar(255)", (a) => a.notNull().primaryKey()).addColumn(
5744
5782
  "tenant_id",
@@ -5775,12 +5813,12 @@ async function Jd(e) {
5775
5813
  for (const a of t)
5776
5814
  await e.insertInto("keys").values(a).execute();
5777
5815
  }
5778
- const Ld = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5816
+ const Kd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5779
5817
  __proto__: null,
5780
- down: Jd,
5781
- up: Md
5818
+ down: Ld,
5819
+ up: Jd
5782
5820
  }, Symbol.toStringTag, { value: "Module" }));
5783
- async function Kd(e) {
5821
+ async function qd(e) {
5784
5822
  await e.schema.alterTable("login_sessions").addColumn("state", "varchar(50)", (t) => t.defaultTo("pending")).execute(), await e.schema.alterTable("login_sessions").addColumn("state_data", "text").execute(), await e.schema.alterTable("login_sessions").addColumn("failure_reason", "text").execute(), await e.schema.alterTable("login_sessions").addColumn("user_id", "varchar(255)").execute(), await e.schema.createIndex("login_sessions_tenant_user_idx").on("login_sessions").columns(["tenant_id", "user_id"]).execute(), await e.updateTable("login_sessions").set({
5785
5823
  state: h`CASE
5786
5824
  WHEN login_completed = 1 THEN 'completed'
@@ -5789,28 +5827,28 @@ async function Kd(e) {
5789
5827
  END`
5790
5828
  }).execute(), await e.schema.alterTable("login_sessions").dropColumn("login_completed").execute(), await e.schema.createIndex("login_sessions_state_idx").on("login_sessions").column("state").execute(), await e.schema.createIndex("login_sessions_state_updated_idx").on("login_sessions").columns(["state", "updated_at"]).execute();
5791
5829
  }
5792
- async function qd(e) {
5830
+ async function Bd(e) {
5793
5831
  await e.schema.alterTable("login_sessions").addColumn("login_completed", "integer", (t) => t.defaultTo(0)).execute(), await e.updateTable("login_sessions").set({
5794
5832
  login_completed: h`CASE WHEN state = 'completed' THEN 1 ELSE 0 END`
5795
5833
  }).execute(), await e.schema.dropIndex("login_sessions_state_updated_idx").execute(), await e.schema.dropIndex("login_sessions_state_idx").execute(), await e.schema.dropIndex("login_sessions_tenant_user_idx").execute(), await e.schema.alterTable("login_sessions").dropColumn("state").dropColumn("state_data").dropColumn("failure_reason").dropColumn("user_id").execute();
5796
5834
  }
5797
5835
  const Ud = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5798
5836
  __proto__: null,
5799
- down: qd,
5800
- up: Kd
5837
+ down: Bd,
5838
+ up: qd
5801
5839
  }, Symbol.toStringTag, { value: "Module" }));
5802
- async function Bd(e) {
5840
+ async function Qd(e) {
5803
5841
  await e.schema.alterTable("roles").addColumn("metadata", "varchar(4096)").execute(), await e.schema.alterTable("resource_servers").addColumn("metadata", "varchar(4096)").execute();
5804
5842
  }
5805
- async function Qd(e) {
5843
+ async function Hd(e) {
5806
5844
  await e.schema.alterTable("roles").dropColumn("metadata").execute(), await e.schema.alterTable("resource_servers").dropColumn("metadata").execute();
5807
5845
  }
5808
- const Hd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5846
+ const Yd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5809
5847
  __proto__: null,
5810
- down: Qd,
5811
- up: Bd
5848
+ down: Hd,
5849
+ up: Qd
5812
5850
  }, Symbol.toStringTag, { value: "Module" }));
5813
- async function Yd(e) {
5851
+ async function Wd(e) {
5814
5852
  try {
5815
5853
  return await h`SELECT VERSION()`.execute(e), "mysql";
5816
5854
  } catch {
@@ -5830,8 +5868,8 @@ async function x(e, t, a, n) {
5830
5868
  throw o;
5831
5869
  }
5832
5870
  }
5833
- async function Wd(e) {
5834
- const t = await Yd(e);
5871
+ async function Gd(e) {
5872
+ const t = await Wd(e);
5835
5873
  await x(e, "refresh_tokens", "created_at_ts", "bigint"), await x(e, "refresh_tokens", "expires_at_ts", "bigint"), await x(e, "refresh_tokens", "idle_expires_at_ts", "bigint"), await x(e, "refresh_tokens", "last_exchanged_at_ts", "bigint"), await x(e, "sessions", "created_at_ts", "bigint"), await x(e, "sessions", "updated_at_ts", "bigint"), await x(e, "sessions", "expires_at_ts", "bigint"), await x(e, "sessions", "idle_expires_at_ts", "bigint"), await x(e, "sessions", "authenticated_at_ts", "bigint"), await x(e, "sessions", "last_interaction_at_ts", "bigint"), await x(e, "sessions", "used_at_ts", "bigint"), await x(e, "sessions", "revoked_at_ts", "bigint"), await x(e, "login_sessions", "created_at_ts", "bigint"), await x(e, "login_sessions", "updated_at_ts", "bigint"), await x(e, "login_sessions", "expires_at_ts", "bigint"), t === "mysql" && (await e.schema.alterTable("refresh_tokens").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("expires_at", "varchar(35)").execute()), await e.schema.createIndex("idx_sessions_user_id").on("sessions").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_user_id").on("refresh_tokens").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.createIndex("idx_refresh_tokens_expires_at_ts").on("refresh_tokens").column("expires_at_ts").execute(), await e.schema.createIndex("idx_sessions_expires_at_ts").on("sessions").column("expires_at_ts").execute(), await e.schema.createIndex("idx_login_sessions_expires_at_ts").on("login_sessions").column("expires_at_ts").execute();
5836
5874
  }
5837
5875
  async function A(e, t, a) {
@@ -5852,13 +5890,13 @@ async function T(e, t, a) {
5852
5890
  throw n;
5853
5891
  }
5854
5892
  }
5855
- async function Gd(e) {
5893
+ async function Vd(e) {
5856
5894
  await A(e, "idx_sessions_user_id", "sessions"), await A(e, "idx_refresh_tokens_user_id", "refresh_tokens"), await A(e, "idx_refresh_tokens_session_id", "refresh_tokens"), await A(e, "idx_refresh_tokens_expires_at_ts", "refresh_tokens"), await A(e, "idx_sessions_expires_at_ts", "sessions"), await A(e, "idx_login_sessions_expires_at_ts", "login_sessions"), await T(e, "refresh_tokens", "created_at_ts"), await T(e, "refresh_tokens", "expires_at_ts"), await T(e, "refresh_tokens", "idle_expires_at_ts"), await T(e, "refresh_tokens", "last_exchanged_at_ts"), await T(e, "sessions", "created_at_ts"), await T(e, "sessions", "updated_at_ts"), await T(e, "sessions", "expires_at_ts"), await T(e, "sessions", "idle_expires_at_ts"), await T(e, "sessions", "authenticated_at_ts"), await T(e, "sessions", "last_interaction_at_ts"), await T(e, "sessions", "used_at_ts"), await T(e, "sessions", "revoked_at_ts"), await T(e, "login_sessions", "created_at_ts"), await T(e, "login_sessions", "updated_at_ts"), await T(e, "login_sessions", "expires_at_ts");
5857
5895
  }
5858
- const Vd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5896
+ const Xd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5859
5897
  __proto__: null,
5860
- down: Gd,
5861
- up: Wd
5898
+ down: Vd,
5899
+ up: Gd
5862
5900
  }, Symbol.toStringTag, { value: "Module" }));
5863
5901
  async function ve(e) {
5864
5902
  try {
@@ -5881,7 +5919,7 @@ async function N(e, t, a) {
5881
5919
  throw n;
5882
5920
  }
5883
5921
  }
5884
- async function Xd(e) {
5922
+ async function Zd(e) {
5885
5923
  const t = await ve(e);
5886
5924
  console.log("Dropping indexes that depend on old date columns...");
5887
5925
  try {
@@ -5895,48 +5933,48 @@ async function Xd(e) {
5895
5933
  }
5896
5934
  console.log("Dropping old date columns..."), await N(e, "refresh_tokens", "created_at"), await N(e, "refresh_tokens", "expires_at"), await N(e, "refresh_tokens", "idle_expires_at"), await N(e, "refresh_tokens", "last_exchanged_at"), await N(e, "sessions", "created_at"), await N(e, "sessions", "updated_at"), await N(e, "sessions", "expires_at"), await N(e, "sessions", "idle_expires_at"), await N(e, "sessions", "authenticated_at"), await N(e, "sessions", "last_interaction_at"), await N(e, "sessions", "used_at"), await N(e, "sessions", "revoked_at"), await N(e, "login_sessions", "created_at"), await N(e, "login_sessions", "updated_at"), await N(e, "login_sessions", "expires_at"), t === "mysql" && (console.log("Increasing ID column sizes for ULID support..."), await e.schema.alterTable("login_sessions").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("session_id", "varchar(26)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("csrf_token", "varchar(26)").execute(), await e.schema.alterTable("sessions").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("sessions").modifyColumn("login_session_id", "varchar(26)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("session_id", "varchar(26)").execute()), console.log("Migration completed successfully");
5897
5935
  }
5898
- async function Zd(e) {
5936
+ async function eu(e) {
5899
5937
  await ve(e) === "mysql" && (console.log("Restoring ID column sizes to varchar(21)..."), await e.schema.alterTable("login_sessions").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("session_id", "varchar(21)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("csrf_token", "varchar(21)").execute(), await e.schema.alterTable("sessions").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("sessions").modifyColumn("login_session_id", "varchar(21)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("session_id", "varchar(21)").execute()), console.log("Re-adding old date columns (data will be empty)..."), await e.schema.alterTable("refresh_tokens").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("idle_expires_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("last_exchanged_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("idle_expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("authenticated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("last_interaction_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("used_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("revoked_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("expires_at", "varchar(35)").execute(), console.log("Rollback completed");
5900
5938
  }
5901
- const eu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5939
+ const tu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5902
5940
  __proto__: null,
5903
- down: Zd,
5904
- up: Xd
5941
+ down: eu,
5942
+ up: Zd
5905
5943
  }, Symbol.toStringTag, { value: "Module" }));
5906
- async function tu(e) {
5944
+ async function au(e) {
5907
5945
  await e.schema.alterTable("users").dropColumn("user_metadata").execute(), await e.schema.alterTable("users").addColumn("user_metadata", "text").execute(), await e.schema.alterTable("users").addColumn("middle_name", "varchar(100)").execute(), await e.schema.alterTable("users").addColumn("profile", "text").execute(), await e.schema.alterTable("users").addColumn("website", "text").execute(), await e.schema.alterTable("users").addColumn("gender", "varchar(50)").execute(), await e.schema.alterTable("users").addColumn("birthdate", "varchar(10)").execute(), await e.schema.alterTable("users").addColumn("zoneinfo", "varchar(100)").execute();
5908
5946
  }
5909
- async function au(e) {
5947
+ async function nu(e) {
5910
5948
  await e.schema.alterTable("users").dropColumn("middle_name").execute(), await e.schema.alterTable("users").dropColumn("profile").execute(), await e.schema.alterTable("users").dropColumn("website").execute(), await e.schema.alterTable("users").dropColumn("gender").execute(), await e.schema.alterTable("users").dropColumn("birthdate").execute(), await e.schema.alterTable("users").dropColumn("zoneinfo").execute(), await e.schema.alterTable("users").dropColumn("user_metadata").execute(), await e.schema.alterTable("users").addColumn("user_metadata", "varchar(4096)").execute();
5911
5949
  }
5912
- const nu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5950
+ const ou = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5913
5951
  __proto__: null,
5914
- down: au,
5915
- up: tu
5952
+ down: nu,
5953
+ up: au
5916
5954
  }, Symbol.toStringTag, { value: "Module" }));
5917
- async function ou(e) {
5955
+ async function ru(e) {
5918
5956
  await e.schema.alterTable("users").addColumn("preferred_username", "varchar(255)").execute();
5919
5957
  }
5920
- async function ru(e) {
5958
+ async function su(e) {
5921
5959
  await e.schema.alterTable("users").dropColumn("preferred_username").execute();
5922
5960
  }
5923
- const su = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5961
+ const iu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5924
5962
  __proto__: null,
5925
- down: ru,
5926
- up: ou
5963
+ down: su,
5964
+ up: ru
5927
5965
  }, Symbol.toStringTag, { value: "Module" }));
5928
- async function iu(e) {
5966
+ async function cu(e) {
5929
5967
  await e.schema.alterTable("users").addColumn("address", "text").execute();
5930
5968
  }
5931
- async function cu(e) {
5969
+ async function lu(e) {
5932
5970
  await e.schema.alterTable("users").dropColumn("address").execute();
5933
5971
  }
5934
- const lu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5972
+ const du = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5935
5973
  __proto__: null,
5936
- down: cu,
5937
- up: iu
5974
+ down: lu,
5975
+ up: cu
5938
5976
  }, Symbol.toStringTag, { value: "Module" }));
5939
- async function du(e) {
5977
+ async function uu(e) {
5940
5978
  try {
5941
5979
  await e.schema.alterTable("login_sessions").addColumn("authParams_max_age", "integer").execute(), console.log(" Added column authParams_max_age to login_sessions");
5942
5980
  } catch (t) {
@@ -5952,7 +5990,7 @@ async function du(e) {
5952
5990
  );
5953
5991
  }
5954
5992
  }
5955
- async function uu(e) {
5993
+ async function _u(e) {
5956
5994
  try {
5957
5995
  await e.schema.alterTable("login_sessions").dropColumn("authParams_max_age").execute();
5958
5996
  } catch (t) {
@@ -5968,38 +6006,38 @@ async function uu(e) {
5968
6006
  );
5969
6007
  }
5970
6008
  }
5971
- const _u = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6009
+ const mu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5972
6010
  __proto__: null,
5973
- down: uu,
5974
- up: du
6011
+ down: _u,
6012
+ up: uu
5975
6013
  }, Symbol.toStringTag, { value: "Module" }));
5976
- async function mu(e) {
6014
+ async function hu(e) {
5977
6015
  await e.schema.alterTable("clients").addColumn("auth0_conformant", "integer", (t) => t.defaultTo(1)).execute();
5978
6016
  }
5979
- async function hu(e) {
6017
+ async function pu(e) {
5980
6018
  await e.schema.alterTable("clients").dropColumn("auth0_conformant").execute();
5981
6019
  }
5982
- const pu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6020
+ const fu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5983
6021
  __proto__: null,
5984
- down: hu,
5985
- up: mu
6022
+ down: pu,
6023
+ up: hu
5986
6024
  }, Symbol.toStringTag, { value: "Module" }));
5987
- async function fu(e) {
6025
+ async function gu(e) {
5988
6026
  await e.schema.createTable("universal_login_templates").addColumn(
5989
6027
  "tenant_id",
5990
6028
  "varchar(191)",
5991
6029
  (t) => t.primaryKey().references("tenants.id").onDelete("cascade")
5992
6030
  ).addColumn("body", "text", (t) => t.notNull()).addColumn("updated_at_ts", "integer", (t) => t.notNull()).addColumn("created_at_ts", "integer", (t) => t.notNull()).execute();
5993
6031
  }
5994
- async function gu(e) {
6032
+ async function wu(e) {
5995
6033
  await e.schema.dropTable("universal_login_templates").execute();
5996
6034
  }
5997
- const wu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6035
+ const yu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5998
6036
  __proto__: null,
5999
- down: gu,
6000
- up: fu
6037
+ down: wu,
6038
+ up: gu
6001
6039
  }, Symbol.toStringTag, { value: "Module" }));
6002
- async function yu(e) {
6040
+ async function vu(e) {
6003
6041
  await e.schema.createTable("custom_text").addColumn(
6004
6042
  "tenant_id",
6005
6043
  "varchar(191)",
@@ -6010,24 +6048,24 @@ async function yu(e) {
6010
6048
  "language"
6011
6049
  ]).execute();
6012
6050
  }
6013
- async function vu(e) {
6051
+ async function Cu(e) {
6014
6052
  await e.schema.dropTable("custom_text").execute();
6015
6053
  }
6016
- const Cu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6054
+ const xu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6017
6055
  __proto__: null,
6018
- down: vu,
6019
- up: yu
6056
+ down: Cu,
6057
+ up: vu
6020
6058
  }, Symbol.toStringTag, { value: "Module" }));
6021
- async function xu(e) {
6059
+ async function Tu(e) {
6022
6060
  await e.schema.alterTable("tenants").addColumn("mfa", "text").execute();
6023
6061
  }
6024
- async function Tu(e) {
6062
+ async function Nu(e) {
6025
6063
  await e.schema.alterTable("tenants").dropColumn("mfa").execute();
6026
6064
  }
6027
- const Nu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6065
+ const bu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6028
6066
  __proto__: null,
6029
- down: Tu,
6030
- up: xu
6067
+ down: Nu,
6068
+ up: Tu
6031
6069
  }, Symbol.toStringTag, { value: "Module" }));
6032
6070
  async function Su(e) {
6033
6071
  try {
@@ -6049,7 +6087,7 @@ async function Q(e, t, a, n) {
6049
6087
  throw o;
6050
6088
  }
6051
6089
  }
6052
- async function bu(e) {
6090
+ async function Ou(e) {
6053
6091
  const t = await Su(e);
6054
6092
  await Q(e, "hooks", "template_id", "text"), await Q(e, "hooks", "created_at_ts", "bigint"), await Q(e, "hooks", "updated_at_ts", "bigint"), t === "mysql" ? await h`
6055
6093
  UPDATE hooks
@@ -6072,13 +6110,13 @@ async function H(e, t, a) {
6072
6110
  throw n;
6073
6111
  }
6074
6112
  }
6075
- async function Ou(e) {
6113
+ async function ku(e) {
6076
6114
  await H(e, "hooks", "template_id"), await H(e, "hooks", "created_at_ts"), await H(e, "hooks", "updated_at_ts");
6077
6115
  }
6078
- const ku = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6116
+ const $u = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6079
6117
  __proto__: null,
6080
- down: Ou,
6081
- up: bu
6118
+ down: ku,
6119
+ up: Ou
6082
6120
  }, Symbol.toStringTag, { value: "Module" }));
6083
6121
  async function Ce(e) {
6084
6122
  try {
@@ -6101,8 +6139,8 @@ async function se(e, t, a) {
6101
6139
  throw n;
6102
6140
  }
6103
6141
  }
6104
- async function $u(e) {
6105
- var r, s, i, c, d;
6142
+ async function Eu(e) {
6143
+ var r, s, i, d, u;
6106
6144
  const t = await Ce(e);
6107
6145
  console.log(
6108
6146
  "Running preflight integrity check on hooks timestamp columns..."
@@ -6117,11 +6155,11 @@ async function $u(e) {
6117
6155
  );
6118
6156
  if (console.log(" Preflight check passed — all _ts columns are populated."), t === "mysql") {
6119
6157
  console.log("Running preflight length check on columns being narrowed...");
6120
- const { rows: u } = await h`SELECT
6158
+ const { rows: c } = await h`SELECT
6121
6159
  SUM(CASE WHEN CHAR_LENGTH(hook_id) > 21 THEN 1 ELSE 0 END) AS long_hook_id,
6122
6160
  SUM(CASE WHEN CHAR_LENGTH(form_id) > 128 THEN 1 ELSE 0 END) AS long_form_id,
6123
6161
  SUM(CASE WHEN CHAR_LENGTH(template_id) > 64 THEN 1 ELSE 0 END) AS long_template_id
6124
- FROM hooks`.execute(e), l = Number(((i = u[0]) == null ? void 0 : i.long_hook_id) ?? 0), m = Number(((c = u[0]) == null ? void 0 : c.long_form_id) ?? 0), _ = Number(((d = u[0]) == null ? void 0 : d.long_template_id) ?? 0), p = [];
6162
+ FROM hooks`.execute(e), l = Number(((i = c[0]) == null ? void 0 : i.long_hook_id) ?? 0), m = Number(((d = c[0]) == null ? void 0 : d.long_form_id) ?? 0), _ = Number(((u = c[0]) == null ? void 0 : u.long_template_id) ?? 0), p = [];
6125
6163
  if (l > 0 && p.push(`${l} row(s) with hook_id longer than 21 chars`), m > 0 && p.push(
6126
6164
  `${m} row(s) with form_id longer than 128 chars`
6127
6165
  ), _ > 0 && p.push(
@@ -6137,10 +6175,10 @@ async function $u(e) {
6137
6175
  console.log("Dropping old date columns from hooks..."), await se(e, "hooks", "created_at"), await se(e, "hooks", "updated_at"), t === "mysql" && (console.log("Fixing hook column types..."), await e.schema.alterTable("hooks").modifyColumn(
6138
6176
  "hook_id",
6139
6177
  "varchar(21)",
6140
- (u) => u.notNull().primaryKey()
6178
+ (c) => c.notNull().primaryKey()
6141
6179
  ).execute(), await e.schema.alterTable("hooks").modifyColumn("form_id", "varchar(128)").execute(), await e.schema.alterTable("hooks").modifyColumn("template_id", "varchar(64)").execute());
6142
6180
  }
6143
- async function Eu(e) {
6181
+ async function Iu(e) {
6144
6182
  const t = await Ce(e);
6145
6183
  await e.schema.alterTable("hooks").addColumn("created_at", "varchar(255)").execute(), await e.schema.alterTable("hooks").addColumn("updated_at", "varchar(255)").execute(), t === "mysql" ? await h`
6146
6184
  UPDATE hooks
@@ -6158,12 +6196,12 @@ async function Eu(e) {
6158
6196
  (a) => a.notNull().primaryKey()
6159
6197
  ).execute(), await e.schema.alterTable("hooks").modifyColumn("form_id", "text").execute(), await e.schema.alterTable("hooks").modifyColumn("template_id", "text").execute());
6160
6198
  }
6161
- const Iu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6199
+ const zu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6162
6200
  __proto__: null,
6163
- down: Eu,
6164
- up: $u
6201
+ down: Iu,
6202
+ up: Eu
6165
6203
  }, Symbol.toStringTag, { value: "Module" }));
6166
- async function zu(e) {
6204
+ async function Pu(e) {
6167
6205
  const { rows: t } = await h`
6168
6206
  SELECT username, provider, tenant_id, COUNT(*) AS cnt
6169
6207
  FROM users
@@ -6199,24 +6237,24 @@ async function zu(e) {
6199
6237
  }
6200
6238
  await e.schema.createIndex("unique_username_provider").on("users").unique().columns(["username", "provider", "tenant_id"]).execute();
6201
6239
  }
6202
- async function Pu(e) {
6240
+ async function Du(e) {
6203
6241
  await e.schema.dropIndex("unique_username_provider").execute();
6204
6242
  }
6205
- const Du = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6243
+ const Au = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6206
6244
  __proto__: null,
6207
- down: Pu,
6208
- up: zu
6245
+ down: Du,
6246
+ up: Pu
6209
6247
  }, Symbol.toStringTag, { value: "Module" }));
6210
- async function Au(e) {
6248
+ async function ju(e) {
6211
6249
  await e.schema.alterTable("refresh_tokens").addColumn("login_id", "varchar(26)").execute(), await e.schema.createIndex("idx_refresh_tokens_login_id").on("refresh_tokens").column("login_id").execute();
6212
6250
  }
6213
- async function ju(e) {
6251
+ async function Fu(e) {
6214
6252
  await e.schema.dropIndex("idx_refresh_tokens_login_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("login_id").execute();
6215
6253
  }
6216
- const Fu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6254
+ const Ru = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6217
6255
  __proto__: null,
6218
- down: ju,
6219
- up: Au
6256
+ down: Fu,
6257
+ up: ju
6220
6258
  }, Symbol.toStringTag, { value: "Module" }));
6221
6259
  async function xe(e) {
6222
6260
  try {
@@ -6225,227 +6263,256 @@ async function xe(e) {
6225
6263
  return "sqlite";
6226
6264
  }
6227
6265
  }
6228
- async function Ru(e) {
6266
+ async function Mu(e) {
6229
6267
  await xe(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)", (a) => a.notNull()).execute(), await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute()) : (await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute());
6230
6268
  }
6231
- async function Mu(e) {
6269
+ async function Ju(e) {
6232
6270
  await xe(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(26)").execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)").execute()) : await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(21)").execute();
6233
6271
  }
6234
- const Ju = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6272
+ const Lu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6235
6273
  __proto__: null,
6236
- down: Mu,
6237
- up: Ru
6274
+ down: Ju,
6275
+ up: Mu
6238
6276
  }, Symbol.toStringTag, { value: "Module" }));
6239
- async function Lu(e) {
6277
+ async function Ku(e) {
6240
6278
  await e.schema.createIndex("idx_sessions_idle_expires_at_ts").on("sessions").column("idle_expires_at_ts").execute(), await e.schema.createIndex("idx_refresh_tokens_idle_expires_at_ts").on("refresh_tokens").column("idle_expires_at_ts").execute();
6241
6279
  }
6242
- async function Ku(e) {
6280
+ async function qu(e) {
6243
6281
  await e.schema.dropIndex("idx_sessions_idle_expires_at_ts").on("sessions").execute(), await e.schema.dropIndex("idx_refresh_tokens_idle_expires_at_ts").on("refresh_tokens").execute();
6244
6282
  }
6245
- const qu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6283
+ const Bu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6246
6284
  __proto__: null,
6247
- down: Ku,
6248
- up: Lu
6285
+ down: qu,
6286
+ up: Ku
6249
6287
  }, Symbol.toStringTag, { value: "Module" }));
6250
6288
  async function Uu(e) {
6251
6289
  await e.schema.alterTable("login_sessions").addColumn("auth_connection", "varchar(255)").execute();
6252
6290
  }
6253
- async function Bu(e) {
6291
+ async function Qu(e) {
6254
6292
  await e.schema.alterTable("login_sessions").dropColumn("auth_connection").execute();
6255
6293
  }
6256
- const Qu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6294
+ const Hu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6257
6295
  __proto__: null,
6258
- down: Bu,
6296
+ down: Qu,
6259
6297
  up: Uu
6260
6298
  }, Symbol.toStringTag, { value: "Module" }));
6261
- async function Hu(e) {
6299
+ async function Yu(e) {
6262
6300
  await e.schema.createTable("mfa_enrollments").addColumn("id", "varchar(26)", (t) => t.primaryKey()).addColumn(
6263
6301
  "tenant_id",
6264
6302
  "varchar(191)",
6265
6303
  (t) => t.references("tenants.id").onDelete("cascade").notNull()
6266
6304
  ).addColumn("user_id", "varchar(255)", (t) => t.notNull()).addColumn("type", "varchar(32)", (t) => t.notNull()).addColumn("phone_number", "varchar(32)").addColumn("totp_secret", "varchar(255)").addColumn("confirmed", "integer", (t) => t.notNull().defaultTo(0)).addColumn("created_at_ts", "bigint", (t) => t.notNull()).addColumn("updated_at_ts", "bigint", (t) => t.notNull()).execute(), await e.schema.createIndex("mfa_enrollments_tenant_user_idx").on("mfa_enrollments").columns(["tenant_id", "user_id"]).execute();
6267
6305
  }
6268
- async function Yu(e) {
6306
+ async function Wu(e) {
6269
6307
  await e.schema.dropTable("mfa_enrollments").execute();
6270
6308
  }
6271
- const Wu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6309
+ const Gu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6272
6310
  __proto__: null,
6273
- down: Yu,
6274
- up: Hu
6311
+ down: Wu,
6312
+ up: Yu
6275
6313
  }, Symbol.toStringTag, { value: "Module" }));
6276
- async function Gu(e) {
6314
+ async function Vu(e) {
6277
6315
  await e.schema.alterTable("codes").addColumn("otp", "varchar(32)").execute();
6278
6316
  }
6279
- async function Vu(e) {
6317
+ async function Xu(e) {
6280
6318
  await e.schema.alterTable("codes").dropColumn("otp").execute();
6281
6319
  }
6282
- const Xu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6320
+ const Zu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6283
6321
  __proto__: null,
6284
- down: Vu,
6285
- up: Gu
6322
+ down: Xu,
6323
+ up: Vu
6286
6324
  }, Symbol.toStringTag, { value: "Module" }));
6287
- async function Zu(e) {
6325
+ async function e_(e) {
6288
6326
  await e.schema.alterTable("mfa_enrollments").renameTo("authentication_methods").execute(), await e.schema.alterTable("authentication_methods").addColumn("credential_id", "varchar(512)").execute(), await e.schema.alterTable("authentication_methods").addColumn("public_key", "text").execute(), await e.schema.alterTable("authentication_methods").addColumn("sign_count", "integer").execute(), await e.schema.alterTable("authentication_methods").addColumn("credential_backed_up", "integer").execute(), await e.schema.alterTable("authentication_methods").addColumn("transports", "varchar(512)").execute(), await e.schema.alterTable("authentication_methods").addColumn("friendly_name", "varchar(255)").execute(), await e.schema.createIndex("authentication_methods_credential_id_idx").on("authentication_methods").column("credential_id").execute();
6289
6327
  }
6290
- async function e_(e) {
6328
+ async function t_(e) {
6291
6329
  await e.schema.dropIndex("authentication_methods_credential_id_idx").execute(), await e.schema.alterTable("authentication_methods").dropColumn("friendly_name").execute(), await e.schema.alterTable("authentication_methods").dropColumn("transports").execute(), await e.schema.alterTable("authentication_methods").dropColumn("credential_backed_up").execute(), await e.schema.alterTable("authentication_methods").dropColumn("sign_count").execute(), await e.schema.alterTable("authentication_methods").dropColumn("public_key").execute(), await e.schema.alterTable("authentication_methods").dropColumn("credential_id").execute(), await e.schema.alterTable("authentication_methods").renameTo("mfa_enrollments").execute();
6292
6330
  }
6293
- const t_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6331
+ const a_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6294
6332
  __proto__: null,
6295
- down: e_,
6296
- up: Zu
6333
+ down: t_,
6334
+ up: e_
6297
6335
  }, Symbol.toStringTag, { value: "Module" }));
6298
- async function a_(e) {
6336
+ async function n_(e) {
6299
6337
  await e.schema.createTable("outbox_events").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("event_type", "varchar(255)", (t) => t.notNull()).addColumn("log_type", "varchar(64)", (t) => t.notNull()).addColumn("aggregate_type", "varchar(64)", (t) => t.notNull()).addColumn("aggregate_id", "varchar(255)", (t) => t.notNull()).addColumn("payload", "text", (t) => t.notNull()).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("processed_at", "varchar(35)").addColumn("retry_count", "integer", (t) => t.notNull().defaultTo(0)).addColumn("next_retry_at", "varchar(35)").addColumn("error", "text").execute(), await e.schema.createIndex("idx_outbox_unprocessed").on("outbox_events").columns(["processed_at", "created_at"]).execute(), await e.schema.createIndex("idx_outbox_tenant_type").on("outbox_events").columns(["tenant_id", "event_type", "created_at"]).execute();
6300
6338
  }
6301
- async function n_(e) {
6339
+ async function o_(e) {
6302
6340
  await e.schema.dropTable("outbox_events").execute();
6303
6341
  }
6304
- const o_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6342
+ const r_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6343
+ __proto__: null,
6344
+ down: o_,
6345
+ up: n_
6346
+ }, Symbol.toStringTag, { value: "Module" }));
6347
+ async function s_(e) {
6348
+ await e.schema.alterTable("outbox_events").addColumn("claimed_by", "varchar(64)").execute(), await e.schema.alterTable("outbox_events").addColumn("claim_expires_at", "varchar(35)").execute();
6349
+ }
6350
+ async function i_(e) {
6351
+ await e.schema.alterTable("outbox_events").dropColumn("claimed_by").execute(), await e.schema.alterTable("outbox_events").dropColumn("claim_expires_at").execute();
6352
+ }
6353
+ const c_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6354
+ __proto__: null,
6355
+ down: i_,
6356
+ up: s_
6357
+ }, Symbol.toStringTag, { value: "Module" }));
6358
+ async function l_(e) {
6359
+ await e.schema.createIndex("idx_outbox_claim").on("outbox_events").columns([
6360
+ "processed_at",
6361
+ "claim_expires_at",
6362
+ "next_retry_at",
6363
+ "created_at"
6364
+ ]).execute();
6365
+ }
6366
+ async function d_(e) {
6367
+ await e.schema.dropIndex("idx_outbox_claim").on("outbox_events").execute();
6368
+ }
6369
+ const u_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6305
6370
  __proto__: null,
6306
- down: n_,
6307
- up: a_
6371
+ down: d_,
6372
+ up: l_
6308
6373
  }, Symbol.toStringTag, { value: "Module" })), Te = {
6309
- m1_init: yo,
6310
- m2_magicLink: xo,
6374
+ m1_init: vo,
6375
+ m2_magicLink: To,
6311
6376
  m3_updateAt: So,
6312
- m4_logTable: ko,
6313
- m5_userProfile: Io,
6314
- m6_sessions: Do,
6315
- m7_passwords: Fo,
6316
- m8_logsTableNewFields: Jo,
6317
- m9_passwordTableNewField: qo,
6318
- n01_codesTable: Qo,
6319
- n11_universalLoginSession: Wo,
6320
- n12_userFields: Xo,
6321
- n13_userEmailIndex: tr,
6322
- n14_profileDataField: or,
6323
- n15_userEmailIndex: ir,
6324
- n16_userLocale: dr,
6325
- n17_signingKeys: mr,
6326
- n18_logsFields: fr,
6327
- n19_connectionsUserinfo: yr,
6328
- n20_missingFields: xr,
6377
+ m4_logTable: $o,
6378
+ m5_userProfile: zo,
6379
+ m6_sessions: Ao,
6380
+ m7_passwords: Ro,
6381
+ m8_logsTableNewFields: Lo,
6382
+ m9_passwordTableNewField: Bo,
6383
+ n01_codesTable: Ho,
6384
+ n11_universalLoginSession: Go,
6385
+ n12_userFields: Zo,
6386
+ n13_userEmailIndex: ar,
6387
+ n14_profileDataField: rr,
6388
+ n15_userEmailIndex: cr,
6389
+ n16_userLocale: ur,
6390
+ n17_signingKeys: hr,
6391
+ n18_logsFields: gr,
6392
+ n19_connectionsUserinfo: vr,
6393
+ n20_missingFields: Tr,
6329
6394
  n21_sessionDeletedAt: Sr,
6330
- n22_dropLogsFields: kr,
6331
- n23_dropUsersFields: Ir,
6332
- n24_logsIndexes: Dr,
6333
- n25_logDescMaxLength: Fr,
6334
- n26_logsTableExtraFields: Jr,
6335
- n27_usersTableNameIndex: qr,
6336
- n28_usersEmailConstrain: Qr,
6337
- n29_increaseOtpStateLength: Wr,
6338
- n30_increaseTicketStateLength: Xr,
6339
- n31_branding: ts,
6340
- n32_indexesAndNotNull: os,
6341
- n33_vendorIdInUniversalLoginSession: is,
6342
- n34_auth0ClientInUniversalLoginSession: ds,
6343
- n35_increaseUniversalSessionStateLength: ms,
6344
- n36_authenticationCodes: fs,
6345
- n37_disableSignUps: ys,
6346
- n38_otpIpAddress: xs,
6395
+ n22_dropLogsFields: $r,
6396
+ n23_dropUsersFields: zr,
6397
+ n24_logsIndexes: Ar,
6398
+ n25_logDescMaxLength: Rr,
6399
+ n26_logsTableExtraFields: Lr,
6400
+ n27_usersTableNameIndex: Br,
6401
+ n28_usersEmailConstrain: Hr,
6402
+ n29_increaseOtpStateLength: Gr,
6403
+ n30_increaseTicketStateLength: Zr,
6404
+ n31_branding: as,
6405
+ n32_indexesAndNotNull: rs,
6406
+ n33_vendorIdInUniversalLoginSession: cs,
6407
+ n34_auth0ClientInUniversalLoginSession: us,
6408
+ n35_increaseUniversalSessionStateLength: hs,
6409
+ n36_authenticationCodes: gs,
6410
+ n37_disableSignUps: vs,
6411
+ n38_otpIpAddress: Ts,
6347
6412
  n39_increaseUserAgentLength: Ss,
6348
- n40_userId: ks,
6349
- n41_hooks: Is,
6350
- n42_userIdIndexes: Ds,
6351
- n43_userIdIndexes: Fs,
6352
- n44_codes: Js,
6353
- n45_hookProperties: qs,
6354
- n46_loginAuth0Client: Qs,
6355
- n47_loginAuth0Client: Ws,
6356
- n48_saml: Xs,
6357
- n49_removeFields: ti,
6358
- n50_authParamsNonce: oi,
6359
- n51_connectionid: ii,
6360
- n52_cert: di,
6361
- n53_codes_primary_key: mi,
6362
- n54_cleanup_tables: fi,
6363
- n55_logs_index: yi,
6364
- n56_application_fields: xi,
6413
+ n40_userId: $s,
6414
+ n41_hooks: zs,
6415
+ n42_userIdIndexes: As,
6416
+ n43_userIdIndexes: Rs,
6417
+ n44_codes: Ls,
6418
+ n45_hookProperties: Bs,
6419
+ n46_loginAuth0Client: Hs,
6420
+ n47_loginAuth0Client: Gs,
6421
+ n48_saml: Zs,
6422
+ n49_removeFields: ai,
6423
+ n50_authParamsNonce: ri,
6424
+ n51_connectionid: ci,
6425
+ n52_cert: ui,
6426
+ n53_codes_primary_key: hi,
6427
+ n54_cleanup_tables: gi,
6428
+ n55_logs_index: vi,
6429
+ n56_application_fields: Ti,
6365
6430
  n57_prompt_settings: Si,
6366
- n58_connection_client_id: ki,
6367
- n59_connection_options: Ii,
6368
- n60_users_metadata: Di,
6369
- n61_userLocales: Fi,
6370
- n62_prompt: Ji,
6371
- n63_connection_cleanup: qi,
6372
- n64_act_as: Qi,
6373
- n65_code_verifier: Wi,
6374
- n66_email_providers: Xi,
6375
- n67_drop_tickets: tc,
6376
- n68_login_useragents: oc,
6377
- n70_refresh_tokens: ic,
6378
- n71_session_new_fields: dc,
6379
- n72_session_primary_key: mc,
6380
- n73_drop_sessions: fc,
6381
- n74_custom_domains: yc,
6382
- n75_organizations: xc,
6431
+ n58_connection_client_id: $i,
6432
+ n59_connection_options: zi,
6433
+ n60_users_metadata: Ai,
6434
+ n61_userLocales: Ri,
6435
+ n62_prompt: Li,
6436
+ n63_connection_cleanup: Bi,
6437
+ n64_act_as: Hi,
6438
+ n65_code_verifier: Gi,
6439
+ n66_email_providers: Zi,
6440
+ n67_drop_tickets: ac,
6441
+ n68_login_useragents: rc,
6442
+ n70_refresh_tokens: cc,
6443
+ n71_session_new_fields: uc,
6444
+ n72_session_primary_key: hc,
6445
+ n73_drop_sessions: gc,
6446
+ n74_custom_domains: vc,
6447
+ n75_organizations: Tc,
6383
6448
  n76_authorization_url_length: Sc,
6384
- n77_drop_sessions: kc,
6385
- n78_login_sessions: Ic,
6386
- n79_drop_sessions_2: Dc,
6387
- n80_recreate_custom_domains: Fc,
6388
- n81_phone: Jc,
6389
- n82_forms: qc,
6390
- n83_addFormsIdToHooks: Qc,
6391
- n84_login_completed: Wc,
6392
- n85_add_login_session_id_to_sessions: Xc,
6393
- n86_index_sessions_login_session_id: tl,
6394
- n87_code_challenge: ol,
6395
- n88_add_redirect_uri_to_codes: il,
6396
- n89_add_nonce_and_state_to_codes: dl,
6397
- n90_themes: ml,
6398
- n91_resource_servers_rules_permissions: fl,
6399
- n92_role_permissions: yl,
6400
- n93_add_permissions_to_roles: xl,
6449
+ n77_drop_sessions: $c,
6450
+ n78_login_sessions: zc,
6451
+ n79_drop_sessions_2: Ac,
6452
+ n80_recreate_custom_domains: Rc,
6453
+ n81_phone: Lc,
6454
+ n82_forms: Bc,
6455
+ n83_addFormsIdToHooks: Hc,
6456
+ n84_login_completed: Gc,
6457
+ n85_add_login_session_id_to_sessions: Zc,
6458
+ n86_index_sessions_login_session_id: al,
6459
+ n87_code_challenge: rl,
6460
+ n88_add_redirect_uri_to_codes: cl,
6461
+ n89_add_nonce_and_state_to_codes: ul,
6462
+ n90_themes: hl,
6463
+ n91_resource_servers_rules_permissions: gl,
6464
+ n92_role_permissions: vl,
6465
+ n93_add_permissions_to_roles: Tl,
6401
6466
  n94_keys_connection_and_extend_columns: Sl,
6402
- n95_create_organizations_table: kl,
6403
- n96_create_user_organizations_table: Il,
6404
- n97_add_organization_to_user_permissions_and_roles: Dl,
6405
- n98_clients: Fl,
6467
+ n95_create_organizations_table: $l,
6468
+ n96_create_user_organizations_table: zl,
6469
+ n97_add_organization_to_user_permissions_and_roles: Al,
6470
+ n98_clients: Rl,
6406
6471
  n99_update_client_foreign_keys: Ul,
6407
- o001_client_grants: Hl,
6408
- o002_drop_applications: Gl,
6409
- o003_phone_number_index: Zl,
6410
- o004_login_sessions_id_index: ad,
6411
- o005_connections_tenant_index: rd,
6412
- o006_remove_redundant_user_organizations_tenant_index: cd,
6413
- o007_tenant_settings: ud,
6414
- o008_merge_tenant_settings_into_tenants: hd,
6415
- o009_create_invites_table: gd,
6416
- o010_add_log_id_to_logs: vd,
6417
- o011_add_location_info_to_logs: Td,
6418
- o012_add_password_history: bd,
6419
- o013_connection_display_name: $d,
6420
- o014_client_connections: zd,
6421
- o015_flows: Ad,
6422
- o016_add_is_system_column: Rd,
6423
- o017_connections_composite_key: Ld,
6472
+ o001_client_grants: Yl,
6473
+ o002_drop_applications: Vl,
6474
+ o003_phone_number_index: ed,
6475
+ o004_login_sessions_id_index: nd,
6476
+ o005_connections_tenant_index: sd,
6477
+ o006_remove_redundant_user_organizations_tenant_index: ld,
6478
+ o007_tenant_settings: _d,
6479
+ o008_merge_tenant_settings_into_tenants: pd,
6480
+ o009_create_invites_table: wd,
6481
+ o010_add_log_id_to_logs: Cd,
6482
+ o011_add_location_info_to_logs: Nd,
6483
+ o012_add_password_history: Od,
6484
+ o013_connection_display_name: Ed,
6485
+ o014_client_connections: Pd,
6486
+ o015_flows: jd,
6487
+ o016_add_is_system_column: Md,
6488
+ o017_connections_composite_key: Kd,
6424
6489
  o018_login_session_state: Ud,
6425
- o019_roles_resource_servers_metadata: Hd,
6426
- o020_session_add_timestamp_columns: Vd,
6427
- o021_session_cleanup_and_ulid: eu,
6428
- o022_oidc_profile_claims: nu,
6429
- o023_preferred_username: su,
6430
- o024_user_address: lu,
6431
- o025_authparams_max_age: _u,
6432
- o026_auth0_conformant: pu,
6433
- o027_universal_login_templates: wu,
6434
- o028_custom_text: Cu,
6435
- o029_guardian_mfa: Nu,
6436
- o030_add_template_id_to_hooks: ku,
6437
- o031_hooks_cleanup: Iu,
6438
- o032_unique_username_provider: Du,
6439
- o033_add_login_id_to_refresh_tokens: Fu,
6440
- o034_refresh_tokens_replace_session_id_with_login_id: Ju,
6441
- o035_idle_expires_at_ts_indexes: qu,
6442
- o036_add_connection_to_login_sessions: Qu,
6443
- o037_mfa_enrollments: Wu,
6444
- o038_add_otp_to_codes: Xu,
6445
- o039_rename_mfa_enrollments_to_authentication_methods: t_,
6446
- o040_create_outbox_events: o_
6490
+ o019_roles_resource_servers_metadata: Yd,
6491
+ o020_session_add_timestamp_columns: Xd,
6492
+ o021_session_cleanup_and_ulid: tu,
6493
+ o022_oidc_profile_claims: ou,
6494
+ o023_preferred_username: iu,
6495
+ o024_user_address: du,
6496
+ o025_authparams_max_age: mu,
6497
+ o026_auth0_conformant: fu,
6498
+ o027_universal_login_templates: yu,
6499
+ o028_custom_text: xu,
6500
+ o029_guardian_mfa: bu,
6501
+ o030_add_template_id_to_hooks: $u,
6502
+ o031_hooks_cleanup: zu,
6503
+ o032_unique_username_provider: Au,
6504
+ o033_add_login_id_to_refresh_tokens: Ru,
6505
+ o034_refresh_tokens_replace_session_id_with_login_id: Lu,
6506
+ o035_idle_expires_at_ts_indexes: Bu,
6507
+ o036_add_connection_to_login_sessions: Hu,
6508
+ o037_mfa_enrollments: Gu,
6509
+ o038_add_otp_to_codes: Zu,
6510
+ o039_rename_mfa_enrollments_to_authentication_methods: a_,
6511
+ o040_create_outbox_events: r_,
6512
+ o041_add_outbox_claim_columns: c_,
6513
+ o042_add_outbox_claim_index: u_
6447
6514
  };
6448
- async function u_(e, t = !1) {
6515
+ async function w_(e, t = !1) {
6449
6516
  t && console.log("migrating...");
6450
6517
  const a = new we(Te), n = new ce({
6451
6518
  db: e,
@@ -6458,7 +6525,7 @@ async function u_(e, t = !1) {
6458
6525
  }), o)
6459
6526
  throw console.error("failed to migrate"), console.error(o), o;
6460
6527
  }
6461
- async function __(e) {
6528
+ async function y_(e) {
6462
6529
  console.log("migrating...");
6463
6530
  const t = new we(Te), a = new ce({
6464
6531
  db: e,
@@ -6469,10 +6536,10 @@ async function __(e) {
6469
6536
  }), n)
6470
6537
  throw console.error("failed to migrate"), console.error(n), n;
6471
6538
  }
6472
- function r_(e, t = { useTransactions: !0 }) {
6539
+ function __(e, t = { useTransactions: !0 }) {
6473
6540
  const a = {
6474
6541
  branding: ga(e),
6475
- clients: Bt(e),
6542
+ clients: Ut(e),
6476
6543
  clientConnections: Vt(e),
6477
6544
  clientGrants: na(e),
6478
6545
  codes: Nt(e),
@@ -6491,7 +6558,7 @@ function r_(e, t = { useTransactions: !0 }) {
6491
6558
  promptSettings: qa(e),
6492
6559
  refreshTokens: en(e),
6493
6560
  resourceServers: pn(e),
6494
- rolePermissions: Sn(e),
6561
+ rolePermissions: bn(e),
6495
6562
  userPermissions: En(e),
6496
6563
  userRoles: An(e),
6497
6564
  roles: Cn(e),
@@ -6501,14 +6568,14 @@ function r_(e, t = { useTransactions: !0 }) {
6501
6568
  themes: za(e),
6502
6569
  universalLoginTemplates: Ca(e),
6503
6570
  customText: no(e),
6504
- users: Ke(e, t),
6571
+ users: Ke(e),
6505
6572
  organizations: Ln(e),
6506
6573
  userOrganizations: Yn(e),
6507
6574
  stats: ao(e),
6508
- outbox: fo(e),
6575
+ outbox: go(e),
6509
6576
  async transaction(n) {
6510
6577
  return t.useTransactions === !1 ? n(a) : e.transaction().execute(async (o) => {
6511
- const r = r_(o, t);
6578
+ const r = __(o, { ...t, useTransactions: !1 });
6512
6579
  return n(r);
6513
6580
  });
6514
6581
  }
@@ -6516,7 +6583,7 @@ function r_(e, t = { useTransactions: !0 }) {
6516
6583
  return a;
6517
6584
  }
6518
6585
  export {
6519
- r_ as default,
6520
- __ as migrateDown,
6521
- u_ as migrateToLatest
6586
+ __ as default,
6587
+ y_ as migrateDown,
6588
+ w_ as migrateToLatest
6522
6589
  };