@authhero/kysely-adapter 10.38.0 → 10.39.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,13 +1,13 @@
1
- var Ee = Object.defineProperty;
1
+ var Le = Object.defineProperty;
2
2
  var ue = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var Re = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
5
+ var Re = (t, e, a) => e in t ? Le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
6
  var R = (t, e, a) => Re(t, typeof e != "symbol" ? e + "" : e, a), X = (t, e, a) => e.has(t) || ue("Cannot " + a);
7
- var d = (t, e, a) => (X(t, e, "read from private field"), a ? a.call(t) : e.get(t)), O = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), K = (t, e, a, r) => (X(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), p = (t, e, a) => (X(t, e, "access private method"), a);
8
- import { parseUserId as ie, codeSchema as Ke, connectionSchema as Ue, loginSessionSchema as Be, promptSettingSchema as Qe, formSchema as G, resourceServerSchema as qe } from "@authhero/adapter-interfaces";
7
+ var u = (t, e, a) => (X(t, e, "read from private field"), a ? a.call(t) : e.get(t)), O = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), K = (t, e, a, r) => (X(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), p = (t, e, a) => (X(t, e, "access private method"), a);
8
+ import { parseUserId as ie, codeSchema as Ke, connectionSchema as Ue, loginSessionSchema as Be, promptSettingSchema as qe, formSchema as H, resourceServerSchema as Qe } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
- var H = class extends Error {
10
+ var q = class extends Error {
11
11
  constructor(e = 500, a) {
12
12
  super(a == null ? void 0 : a.message, { cause: a == null ? void 0 : a.cause });
13
13
  R(this, "res");
@@ -23,7 +23,7 @@ var H = class extends Error {
23
23
  });
24
24
  }
25
25
  };
26
- function Ve(t) {
26
+ function We(t) {
27
27
  return async (e, a) => {
28
28
  const { identities: r, ...n } = a, o = {
29
29
  ...n,
@@ -39,7 +39,7 @@ function Ve(t) {
39
39
  try {
40
40
  await t.insertInto("users").values(o).execute();
41
41
  } catch (s) {
42
- throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new H(409, { message: "User already exists" }) : new H(500, { message: `${s.code}, ${s.message}` });
42
+ throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new q(409, { message: "User already exists" }) : new q(500, { message: `${s.code}, ${s.message}` });
43
43
  }
44
44
  return {
45
45
  ...o,
@@ -88,7 +88,7 @@ function pe(t) {
88
88
  }
89
89
  };
90
90
  }
91
- function We(t) {
91
+ function Ve(t) {
92
92
  return async (e, a) => {
93
93
  const [r, n] = await Promise.all([
94
94
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
@@ -116,25 +116,25 @@ function We(t) {
116
116
  return y(i);
117
117
  };
118
118
  }
119
- function T(t, e, a, r) {
119
+ function S(t, e, a, r) {
120
120
  return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
121
- let s = o.startsWith("-"), i = null, c = "", u = !1, m;
121
+ let s = o.startsWith("-"), i = null, c = "", m = !1, _;
122
122
  if (o.startsWith("-_exists_:"))
123
- i = o.substring(10), u = !0, s = !0;
123
+ i = o.substring(10), m = !0, s = !0;
124
124
  else if (o.startsWith("_exists_:"))
125
- i = o.substring(9), u = !0, s = !1;
125
+ i = o.substring(9), m = !0, s = !1;
126
126
  else if (o.includes(":")) {
127
- const _ = s ? o.substring(1) : o, h = _.indexOf(":");
128
- i = _.substring(0, h), c = _.substring(h + 1), u = !1, c.startsWith(">=") ? (m = ">=", c = c.substring(2)) : c.startsWith(">") ? (m = ">", c = c.substring(1)) : c.startsWith("<=") ? (m = "<=", c = c.substring(2)) : c.startsWith("<") ? (m = "<", c = c.substring(1)) : m = "=";
127
+ const d = s ? o.substring(1) : o, h = d.indexOf(":");
128
+ i = d.substring(0, h), c = d.substring(h + 1), m = !1, c.startsWith(">=") ? (_ = ">=", c = c.substring(2)) : c.startsWith(">") ? (_ = ">", c = c.substring(1)) : c.startsWith("<=") ? (_ = "<=", c = c.substring(2)) : c.startsWith("<") ? (_ = "<", c = c.substring(1)) : _ = "=";
129
129
  } else
130
- i = null, c = o, u = !1;
131
- return { key: i, value: c, isNegation: s, isExistsQuery: u, operator: m };
132
- }).forEach(({ key: o, value: s, isNegation: i, isExistsQuery: c, operator: u }) => {
130
+ i = null, c = o, m = !1;
131
+ return { key: i, value: c, isNegation: s, isExistsQuery: m, operator: _ };
132
+ }).forEach(({ key: o, value: s, isNegation: i, isExistsQuery: c, operator: m }) => {
133
133
  if (o)
134
134
  if (c)
135
135
  i ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
136
136
  else if (i)
137
- switch (u) {
137
+ switch (m) {
138
138
  case ">":
139
139
  e = e.where(o, "<=", s);
140
140
  break;
@@ -151,12 +151,12 @@ function T(t, e, a, r) {
151
151
  e = e.where(o, "!=", s);
152
152
  }
153
153
  else
154
- e = e.where(o, u, s);
154
+ e = e.where(o, m, s);
155
155
  else if (s) {
156
- const { ref: m } = t.dynamic;
156
+ const { ref: _ } = t.dynamic;
157
157
  e = e.where(
158
- (_) => _.or(
159
- r.map((h) => _(m(h), "like", `%${s}%`))
158
+ (d) => d.or(
159
+ r.map((h) => d(_(h), "like", `%${s}%`))
160
160
  )
161
161
  );
162
162
  }
@@ -169,11 +169,11 @@ function Ge(t) {
169
169
  return async (e, a = {}) => {
170
170
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
171
171
  let c = t.selectFrom("users").where("users.tenant_id", "=", e);
172
- if (i && (c = T(t, c, i, ["email", "name"])), s && s.sort_by) {
172
+ if (i && (c = S(t, c, i, ["email", "name"])), s && s.sort_by) {
173
173
  const { ref: w } = t.dynamic;
174
174
  c = c.orderBy(w(s.sort_by), s.sort_order);
175
175
  }
176
- const m = await c.offset(r * n).limit(n).selectAll().execute(), _ = m.map((w) => w.user_id), h = _.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", _).execute() : [], f = m.map((w) => {
176
+ const _ = await c.offset(r * n).limit(n).selectAll().execute(), d = _.map((w) => w.user_id), h = d.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", d).execute() : [], f = _.map((w) => {
177
177
  const b = h.filter(
178
178
  (D) => D.linked_to === w.user_id
179
179
  );
@@ -213,11 +213,11 @@ function Ge(t) {
213
213
  function He(t) {
214
214
  return async (e, a) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1);
215
215
  }
216
- function E(t, e = "", a = {}) {
216
+ function L(t, e = "", a = {}) {
217
217
  for (let r in t)
218
218
  if (Object.prototype.hasOwnProperty.call(t, r)) {
219
219
  const n = e ? `${e}_${r}` : r, o = t[r];
220
- typeof o == "object" && o !== null && !Array.isArray(o) ? E(o, n, a) : typeof o == "boolean" ? a[n] = o ? 1 : 0 : a[n] = o;
220
+ typeof o == "object" && o !== null && !Array.isArray(o) ? L(o, n, a) : typeof o == "boolean" ? a[n] = o ? 1 : 0 : a[n] = o;
221
221
  }
222
222
  return a;
223
223
  }
@@ -241,7 +241,7 @@ function ge(t, e) {
241
241
  }
242
242
  function Ye(t) {
243
243
  return async (e, a, r) => {
244
- const n = E({
244
+ const n = L({
245
245
  ...r,
246
246
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
247
247
  app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
@@ -258,9 +258,9 @@ function Xe(t) {
258
258
  }
259
259
  function Ze(t) {
260
260
  return {
261
- create: Ve(t),
261
+ create: We(t),
262
262
  remove: He(t),
263
- get: We(t),
263
+ get: Ve(t),
264
264
  list: Ge(t),
265
265
  update: Ye(t),
266
266
  // TODO - think about this more when other issues fixed
@@ -268,7 +268,7 @@ function Ze(t) {
268
268
  };
269
269
  }
270
270
  const et = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
271
- let S = (t = 21) => {
271
+ let T = (t = 21) => {
272
272
  let e = "", a = crypto.getRandomValues(new Uint8Array(t));
273
273
  for (; t--; )
274
274
  e += et[a[t] & 63];
@@ -277,7 +277,7 @@ let S = (t = 21) => {
277
277
  function tt(t) {
278
278
  return async (e) => {
279
279
  const a = {
280
- id: e.id || S(),
280
+ id: e.id || T(),
281
281
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
282
282
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
283
283
  ...e
@@ -300,14 +300,14 @@ function rt(t) {
300
300
  a = a.orderBy(f(s.sort_by), s.sort_order);
301
301
  }
302
302
  i && (a = a.where((f) => f.or([f("name", "like", `%${i}%`)])));
303
- const m = (await a.offset(r * n).limit(n).selectAll().execute()).map(y);
303
+ const _ = (await a.offset(r * n).limit(n).selectAll().execute()).map(y);
304
304
  if (!o)
305
305
  return {
306
- tenants: m
306
+ tenants: _
307
307
  };
308
- const { count: _ } = await a.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow(), h = x(_);
308
+ const { count: d } = await a.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow(), h = x(d);
309
309
  return {
310
- tenants: m,
310
+ tenants: _,
311
311
  start: r * n,
312
312
  limit: n,
313
313
  length: h
@@ -344,7 +344,7 @@ function lt(t) {
344
344
  return async (e, a) => {
345
345
  var n, o, s;
346
346
  const r = {
347
- id: S(),
347
+ id: T(),
348
348
  ...a,
349
349
  user_agent: a.user_agent.slice(0, it)
350
350
  };
@@ -386,24 +386,24 @@ function ct(t) {
386
386
  return async (e, a = {}) => {
387
387
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
388
388
  let c = t.selectFrom("logs").where("logs.tenant_id", "=", e);
389
- i && (c = T(t, c, i, ["user_id", "ip"]));
390
- let u = c;
389
+ i && (c = S(t, c, i, ["user_id", "ip"]));
390
+ let m = c;
391
391
  if (s && s.sort_by) {
392
392
  const { ref: f } = t.dynamic;
393
- u = u.orderBy(f(s.sort_by), s.sort_order);
393
+ m = m.orderBy(f(s.sort_by), s.sort_order);
394
394
  }
395
- u = u.offset(r * n).limit(n);
396
- const _ = (await u.selectAll().execute()).map(we);
395
+ m = m.offset(r * n).limit(n);
396
+ const d = (await m.selectAll().execute()).map(we);
397
397
  if (!o)
398
398
  return {
399
- logs: _,
399
+ logs: d,
400
400
  start: 0,
401
401
  limit: 0,
402
402
  length: 0
403
403
  };
404
404
  const { count: h } = await c.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
405
405
  return {
406
- logs: _,
406
+ logs: d,
407
407
  start: r * n,
408
408
  limit: n,
409
409
  length: x(h)
@@ -471,28 +471,28 @@ function pt(t) {
471
471
  return async (e, a = {}) => {
472
472
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
473
473
  let c = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
474
- i && (c = T(t, c, i, ["user_id", "session_id"]));
475
- let u = c;
474
+ i && (c = S(t, c, i, ["user_id", "session_id"]));
475
+ let m = c;
476
476
  if (s && s.sort_by) {
477
477
  const { ref: g } = t.dynamic;
478
- u = u.orderBy(g(s.sort_by), s.sort_order);
478
+ m = m.orderBy(g(s.sort_by), s.sort_order);
479
479
  }
480
- u = u.offset(r * n).limit(n);
481
- const _ = (await u.selectAll().execute()).map((g) => ({
480
+ m = m.offset(r * n).limit(n);
481
+ const d = (await m.selectAll().execute()).map((g) => ({
482
482
  ...g,
483
483
  device: JSON.parse(g.device),
484
484
  clients: JSON.parse(g.clients)
485
485
  }));
486
486
  if (!o)
487
487
  return {
488
- sessions: _,
488
+ sessions: d,
489
489
  start: 0,
490
490
  limit: 0,
491
491
  length: 0
492
492
  };
493
493
  const { count: h } = await c.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = x(h);
494
494
  return {
495
- sessions: _,
495
+ sessions: d,
496
496
  start: r * n,
497
497
  limit: n,
498
498
  length: f
@@ -547,24 +547,24 @@ function Ct(t) {
547
547
  return async (e, a = {}) => {
548
548
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
549
549
  let i = t.selectFrom("codes").where("codes.tenant_id", "=", e);
550
- s && (i = T(t, i, s, ["code", "login_id"]));
551
- const m = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
550
+ s && (i = S(t, i, s, ["code", "login_id"]));
551
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
552
552
  const { tenant_id: f, ...g } = h;
553
553
  return Ke.parse(y(g));
554
554
  });
555
555
  if (!o)
556
556
  return {
557
- codes: m,
557
+ codes: _,
558
558
  start: 0,
559
559
  limit: 0,
560
560
  length: 0
561
561
  };
562
- const { count: _ } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
562
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
563
563
  return {
564
- codes: m,
564
+ codes: _,
565
565
  start: r * n,
566
566
  limit: n,
567
- length: x(_)
567
+ length: x(d)
568
568
  };
569
569
  };
570
570
  }
@@ -683,7 +683,7 @@ function jt(t) {
683
683
  function Ft(t) {
684
684
  return async (e, a) => {
685
685
  const r = {
686
- id: S(),
686
+ id: T(),
687
687
  ...a,
688
688
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
689
689
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -700,8 +700,8 @@ function At(t) {
700
700
  return async (e, a = {}) => {
701
701
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
702
702
  let i = t.selectFrom("connections").where("connections.tenant_id", "=", e);
703
- s && (i = T(t, i, s, ["user_id", "ip"]));
704
- const m = (await i.offset(r * n).limit(n).selectAll().execute()).map(
703
+ s && (i = S(t, i, s, ["user_id", "ip"]));
704
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map(
705
705
  (h) => y({
706
706
  ...h,
707
707
  options: JSON.parse(h.options)
@@ -709,17 +709,17 @@ function At(t) {
709
709
  );
710
710
  if (!o)
711
711
  return {
712
- connections: m,
712
+ connections: _,
713
713
  start: 0,
714
714
  limit: 0,
715
715
  length: 0
716
716
  };
717
- const { count: _ } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
717
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
718
718
  return {
719
- connections: m,
719
+ connections: _,
720
720
  start: r * n,
721
721
  limit: n,
722
- length: x(_)
722
+ length: x(d)
723
723
  };
724
724
  };
725
725
  }
@@ -747,7 +747,7 @@ function Jt(t) {
747
747
  }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
748
748
  };
749
749
  }
750
- function Lt(t) {
750
+ function Et(t) {
751
751
  return {
752
752
  create: Ft(t),
753
753
  get: zt(t),
@@ -756,7 +756,7 @@ function Lt(t) {
756
756
  update: Jt(t)
757
757
  };
758
758
  }
759
- function Et(t) {
759
+ function Lt(t) {
760
760
  return {
761
761
  get: async (e) => {
762
762
  const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
@@ -764,7 +764,7 @@ function Et(t) {
764
764
  return null;
765
765
  const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
766
766
  if (!r)
767
- throw new H(404, { message: "Tenant not found" });
767
+ throw new q(404, { message: "Tenant not found" });
768
768
  const n = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
769
769
  return {
770
770
  ...a,
@@ -804,7 +804,7 @@ function Rt(t) {
804
804
  f("revoked_at", "is", null)
805
805
  ])
806
806
  );
807
- s && (i = T(t, i, s, [
807
+ s && (i = S(t, i, s, [
808
808
  "kid",
809
809
  "connection",
810
810
  "fingerprint",
@@ -812,20 +812,20 @@ function Rt(t) {
812
812
  "type"
813
813
  ]));
814
814
  let c = i.select((f) => f.fn.count("kid").as("count"));
815
- const u = a * r;
816
- i = i.limit(r).offset(u), o && (i = i.orderBy(o.sort_by, o.sort_order));
817
- const m = await i.selectAll().execute();
815
+ const m = a * r;
816
+ i = i.limit(r).offset(m), o && (i = i.orderBy(o.sort_by, o.sort_order));
817
+ const _ = await i.selectAll().execute();
818
818
  if (!n)
819
819
  return {
820
- signingKeys: m,
820
+ signingKeys: _,
821
821
  start: 0,
822
822
  limit: 0,
823
823
  length: 0
824
824
  };
825
- const _ = await c.executeTakeFirst(), h = x((_ == null ? void 0 : _.count) ?? 0);
825
+ const d = await c.executeTakeFirst(), h = x((d == null ? void 0 : d.count) ?? 0);
826
826
  return {
827
- signingKeys: m,
828
- start: u,
827
+ signingKeys: _,
828
+ start: m,
829
829
  limit: r,
830
830
  length: h
831
831
  };
@@ -846,10 +846,10 @@ function Bt(t) {
846
846
  update: Ut(t)
847
847
  };
848
848
  }
849
- function Qt(t) {
849
+ function qt(t) {
850
850
  return async (e, a) => {
851
851
  const r = {
852
- custom_domain_id: S(),
852
+ custom_domain_id: T(),
853
853
  status: "pending",
854
854
  primary: !1,
855
855
  ...a
@@ -863,16 +863,16 @@ function Qt(t) {
863
863
  }).execute(), r;
864
864
  };
865
865
  }
866
- function qt(t) {
866
+ function Qt(t) {
867
867
  return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((r) => ({
868
868
  ...r,
869
869
  primary: r.primary === 1
870
870
  }));
871
871
  }
872
- function Vt(t) {
872
+ function Wt(t) {
873
873
  return async (e, a) => (await t.deleteFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
874
874
  }
875
- function Wt(t) {
875
+ function Vt(t) {
876
876
  return async (e, a) => {
877
877
  const r = await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).selectAll().executeTakeFirst();
878
878
  return r ? {
@@ -902,11 +902,11 @@ function Ht(t) {
902
902
  }
903
903
  function Yt(t) {
904
904
  return {
905
- create: Qt(t),
906
- get: Wt(t),
905
+ create: qt(t),
906
+ get: Vt(t),
907
907
  getByDomain: Ht(t),
908
- list: qt(t),
909
- remove: Vt(t),
908
+ list: Qt(t),
909
+ remove: Wt(t),
910
910
  update: Gt(t)
911
911
  };
912
912
  }
@@ -922,11 +922,11 @@ function Xt(t) {
922
922
  colors_page_background_start: s,
923
923
  colors_page_background_end: i,
924
924
  colors_page_background_angle_dev: c,
925
- font_url: u,
926
- ...m
925
+ font_url: m,
926
+ ..._
927
927
  } = a;
928
928
  return y({
929
- ...m,
929
+ ..._,
930
930
  colors: {
931
931
  primary: n,
932
932
  page_background: {
@@ -936,21 +936,21 @@ function Xt(t) {
936
936
  angle_deg: c
937
937
  }
938
938
  },
939
- font: u ? { url: u } : void 0
939
+ font: m ? { url: m } : void 0
940
940
  });
941
941
  };
942
942
  }
943
943
  function Zt(t) {
944
944
  return async (e, a) => {
945
- var s, i, c, u, m, _, h, f, g, w, b, D, A, P, V, le, ce, de;
945
+ var s, i, c, m, _, d, h, f, g, w, b, D, A, P, V, le, ce, de;
946
946
  const { colors: r, font: n, ...o } = a;
947
947
  try {
948
948
  await t.insertInto("branding").values({
949
949
  ...o,
950
950
  colors_primary: r == null ? void 0 : r.primary,
951
951
  colors_page_background_type: (i = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
952
- colors_page_background_start: (u = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : u.start,
953
- colors_page_background_end: (_ = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : _.end,
952
+ colors_page_background_start: (m = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : m.start,
953
+ colors_page_background_end: (d = (_ = a.colors) == null ? void 0 : _.page_background) == null ? void 0 : d.end,
954
954
  colors_page_background_angle_dev: (f = (h = a.colors) == null ? void 0 : h.page_background) == null ? void 0 : f.angle_deg,
955
955
  font_url: (g = a.font) == null ? void 0 : g.url,
956
956
  tenant_id: e
@@ -978,8 +978,8 @@ function ta(t) {
978
978
  return async (e, a = {}) => {
979
979
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
980
980
  let i = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
981
- s && (i = T(t, i, s, ["url", "form_id"]));
982
- const m = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
981
+ s && (i = S(t, i, s, ["url", "form_id"]));
982
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
983
983
  const { tenant_id: f, enabled: g, synchronous: w, ...b } = h;
984
984
  return y({
985
985
  ...b,
@@ -989,17 +989,17 @@ function ta(t) {
989
989
  });
990
990
  if (!o)
991
991
  return {
992
- hooks: m,
992
+ hooks: _,
993
993
  start: 0,
994
994
  limit: 0,
995
995
  length: 0
996
996
  };
997
- const { count: _ } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
997
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
998
998
  return {
999
- hooks: m,
999
+ hooks: _,
1000
1000
  start: r * n,
1001
1001
  limit: n,
1002
- length: x(_)
1002
+ length: x(d)
1003
1003
  };
1004
1004
  };
1005
1005
  }
@@ -1019,7 +1019,7 @@ function ra(t) {
1019
1019
  function na(t) {
1020
1020
  return async (e, a) => {
1021
1021
  const r = {
1022
- hook_id: S(),
1022
+ hook_id: T(),
1023
1023
  ...a,
1024
1024
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1025
1025
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1055,7 +1055,7 @@ function sa(t) {
1055
1055
  function ia(t) {
1056
1056
  return async (e, a) => {
1057
1057
  const r = {
1058
- themeId: S(),
1058
+ themeId: T(),
1059
1059
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1060
1060
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1061
1061
  ...a
@@ -1063,7 +1063,7 @@ function ia(t) {
1063
1063
  ...r,
1064
1064
  tenant_id: e
1065
1065
  };
1066
- return await t.insertInto("themes").values(E(n)).execute(), r;
1066
+ return await t.insertInto("themes").values(L(n)).execute(), r;
1067
1067
  };
1068
1068
  }
1069
1069
  function la(t) {
@@ -1097,7 +1097,7 @@ function ca(t) {
1097
1097
  }
1098
1098
  function da(t) {
1099
1099
  return async (e, a, r) => {
1100
- const n = E({
1100
+ const n = L({
1101
1101
  ...r,
1102
1102
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1103
1103
  });
@@ -1130,7 +1130,7 @@ function _a(t) {
1130
1130
  return async (e, a) => {
1131
1131
  var n;
1132
1132
  const r = {
1133
- id: S(),
1133
+ id: T(),
1134
1134
  ...a,
1135
1135
  authorization_url: (n = a.authorization_url) == null ? void 0 : n.slice(0, 1024),
1136
1136
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1138,14 +1138,14 @@ function _a(t) {
1138
1138
  login_completed: !!a.login_completed
1139
1139
  };
1140
1140
  return await t.insertInto("login_sessions").values({
1141
- ...E(r),
1141
+ ...L(r),
1142
1142
  tenant_id: e
1143
1143
  }).execute(), r;
1144
1144
  };
1145
1145
  }
1146
1146
  function ha(t) {
1147
1147
  return async (e, a, r) => (await t.updateTable("login_sessions").set(
1148
- E({
1148
+ L({
1149
1149
  ...r
1150
1150
  })
1151
1151
  ).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
@@ -1184,7 +1184,7 @@ function he(t) {
1184
1184
  function wa(t) {
1185
1185
  return async (e, a) => {
1186
1186
  try {
1187
- const r = Qe.parse(a);
1187
+ const r = qe.parse(a);
1188
1188
  await t.insertInto("prompt_settings").values({
1189
1189
  ...he(r),
1190
1190
  tenant_id: e
@@ -1296,14 +1296,14 @@ function ka(t) {
1296
1296
  return async (e, a = {}) => {
1297
1297
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
1298
1298
  let c = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1299
- i && (c = T(t, c, i, ["token", "session_id"]));
1300
- let u = c;
1299
+ i && (c = S(t, c, i, ["token", "session_id"]));
1300
+ let m = c;
1301
1301
  if (s && s.sort_by) {
1302
1302
  const { ref: g } = t.dynamic;
1303
- u = u.orderBy(g(s.sort_by), s.sort_order);
1303
+ m = m.orderBy(g(s.sort_by), s.sort_order);
1304
1304
  }
1305
- u = u.offset(r * n).limit(n);
1306
- const _ = (await u.selectAll().execute()).map((g) => ({
1305
+ m = m.offset(r * n).limit(n);
1306
+ const d = (await m.selectAll().execute()).map((g) => ({
1307
1307
  ...g,
1308
1308
  rotating: !!g.rotating,
1309
1309
  device: g.device ? JSON.parse(g.device) : {},
@@ -1311,14 +1311,14 @@ function ka(t) {
1311
1311
  }));
1312
1312
  if (!o)
1313
1313
  return {
1314
- refresh_tokens: _,
1314
+ refresh_tokens: d,
1315
1315
  start: 0,
1316
1316
  limit: 0,
1317
1317
  length: 0
1318
1318
  };
1319
1319
  const { count: h } = await c.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = x(h);
1320
1320
  return {
1321
- refresh_tokens: _,
1321
+ refresh_tokens: d,
1322
1322
  start: r * n,
1323
1323
  limit: n,
1324
1324
  length: f
@@ -1366,8 +1366,8 @@ function Ia(t) {
1366
1366
  }
1367
1367
  function Da(t) {
1368
1368
  return async (e, a) => {
1369
- const r = G.parse({
1370
- id: S(),
1369
+ const r = H.parse({
1370
+ id: T(),
1371
1371
  ...a,
1372
1372
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1373
1373
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1379,15 +1379,15 @@ function Da(t) {
1379
1379
  start: JSON.stringify(r.start || {}),
1380
1380
  ending: JSON.stringify(r.ending || {}),
1381
1381
  tenant_id: e
1382
- }).execute(), G.parse(r);
1382
+ }).execute(), H.parse(r);
1383
1383
  };
1384
1384
  }
1385
1385
  function Pa(t) {
1386
1386
  return async (e, a = {}) => {
1387
1387
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
1388
1388
  let i = t.selectFrom("forms").where("tenant_id", "=", e);
1389
- s && (i = T(t, i, s, []));
1390
- const m = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
1389
+ s && (i = S(t, i, s, []));
1390
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
1391
1391
  const f = { ...h };
1392
1392
  if (typeof f.nodes == "string")
1393
1393
  try {
@@ -1404,21 +1404,21 @@ function Pa(t) {
1404
1404
  f.ending = JSON.parse(f.ending);
1405
1405
  } catch {
1406
1406
  }
1407
- return G.parse(y(f));
1407
+ return H.parse(y(f));
1408
1408
  });
1409
1409
  if (!o)
1410
1410
  return {
1411
- forms: m,
1411
+ forms: _,
1412
1412
  start: 0,
1413
1413
  limit: 0,
1414
1414
  length: 0
1415
1415
  };
1416
- const { count: _ } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1416
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1417
1417
  return {
1418
- forms: m,
1418
+ forms: _,
1419
1419
  start: r * n,
1420
1420
  limit: n,
1421
- length: x(_)
1421
+ length: x(d)
1422
1422
  };
1423
1423
  };
1424
1424
  }
@@ -1448,7 +1448,7 @@ function Fa(t) {
1448
1448
  n.ending = JSON.parse(n.ending);
1449
1449
  } catch {
1450
1450
  }
1451
- return G.parse(y(n));
1451
+ return H.parse(y(n));
1452
1452
  };
1453
1453
  }
1454
1454
  function Aa(t) {
@@ -1474,24 +1474,24 @@ function Ma(t) {
1474
1474
  function za(t) {
1475
1475
  return async (e, a) => {
1476
1476
  const r = (/* @__PURE__ */ new Date()).toISOString(), n = {
1477
- id: S(),
1477
+ id: T(),
1478
1478
  ...a,
1479
1479
  created_at: r,
1480
1480
  updated_at: r
1481
- }, o = qe.parse(n), {
1481
+ }, o = Qe.parse(n), {
1482
1482
  verificationKey: s,
1483
1483
  scopes: i,
1484
1484
  options: c,
1485
- skip_consent_for_verifiable_first_party_clients: u,
1486
- allow_offline_access: m,
1487
- ..._
1485
+ skip_consent_for_verifiable_first_party_clients: m,
1486
+ allow_offline_access: _,
1487
+ ...d
1488
1488
  } = o, h = {
1489
- ..._,
1489
+ ...d,
1490
1490
  tenant_id: e,
1491
1491
  scopes: i ? JSON.stringify(i) : "[]",
1492
1492
  options: c ? JSON.stringify(c) : "{}",
1493
- skip_consent_for_verifiable_first_party_clients: u ? 1 : 0,
1494
- allow_offline_access: m ? 1 : 0,
1493
+ skip_consent_for_verifiable_first_party_clients: m ? 1 : 0,
1494
+ allow_offline_access: _ ? 1 : 0,
1495
1495
  verification_key: s,
1496
1496
  created_at: r,
1497
1497
  updated_at: r
@@ -1508,21 +1508,21 @@ function Ja(t) {
1508
1508
  scopes: s,
1509
1509
  options: i,
1510
1510
  skip_consent_for_verifiable_first_party_clients: c,
1511
- allow_offline_access: u,
1512
- ...m
1513
- } = n, _ = {
1514
- ...m,
1511
+ allow_offline_access: m,
1512
+ ..._
1513
+ } = n, d = {
1514
+ ..._,
1515
1515
  scopes: s ? JSON.parse(s) : [],
1516
1516
  options: i ? JSON.parse(i) : {},
1517
1517
  skip_consent_for_verifiable_first_party_clients: !!c,
1518
- allow_offline_access: !!u,
1518
+ allow_offline_access: !!m,
1519
1519
  // Convert verification_key back to verificationKey for API
1520
1520
  verificationKey: o
1521
1521
  };
1522
- return y(_);
1522
+ return y(d);
1523
1523
  };
1524
1524
  }
1525
- function La(t) {
1525
+ function Ea(t) {
1526
1526
  return async (e, a = {}) => {
1527
1527
  const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
1528
1528
  let i = t.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", e);
@@ -1532,12 +1532,12 @@ function La(t) {
1532
1532
  const A = !!w[1], P = w[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
1533
1533
  i = A ? i.where(P, "not like", `%${b}%`) : i.where(P, "like", `%${b}%`);
1534
1534
  } else
1535
- i = T(t, i, h, [
1535
+ i = S(t, i, h, [
1536
1536
  "resource_servers.name",
1537
1537
  "resource_servers.identifier"
1538
1538
  ]);
1539
1539
  }
1540
- const m = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
1540
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
1541
1541
  const f = h, {
1542
1542
  verification_key: g,
1543
1543
  scopes: w,
@@ -1558,21 +1558,21 @@ function La(t) {
1558
1558
  });
1559
1559
  if (!o)
1560
1560
  return {
1561
- resource_servers: m,
1561
+ resource_servers: _,
1562
1562
  start: 0,
1563
1563
  limit: 0,
1564
1564
  length: 0
1565
1565
  };
1566
- const { count: _ } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1566
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1567
1567
  return {
1568
- resource_servers: m,
1568
+ resource_servers: _,
1569
1569
  start: r * n,
1570
1570
  limit: n,
1571
- length: x(_)
1571
+ length: x(d)
1572
1572
  };
1573
1573
  };
1574
1574
  }
1575
- function Ea(t) {
1575
+ function La(t) {
1576
1576
  return async (e, a) => {
1577
1577
  const r = await t.deleteFrom("resource_servers").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1578
1578
  return Number(r.numDeletedRows) > 0;
@@ -1586,28 +1586,28 @@ function Ra(t) {
1586
1586
  options: s,
1587
1587
  skip_consent_for_verifiable_first_party_clients: i,
1588
1588
  allow_offline_access: c,
1589
- ...u
1590
- } = r, m = {
1591
- ...u,
1589
+ ...m
1590
+ } = r, _ = {
1591
+ ...m,
1592
1592
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1593
1593
  };
1594
- n !== void 0 && (m.verification_key = n), o !== void 0 && (m.scopes = JSON.stringify(o)), s !== void 0 && (m.options = JSON.stringify(s)), i !== void 0 && (m.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), c !== void 0 && (m.allow_offline_access = c ? 1 : 0);
1595
- const _ = await t.updateTable("resource_servers").set(m).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1596
- return Number(_.numUpdatedRows) > 0;
1594
+ n !== void 0 && (_.verification_key = n), o !== void 0 && (_.scopes = JSON.stringify(o)), s !== void 0 && (_.options = JSON.stringify(s)), i !== void 0 && (_.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), c !== void 0 && (_.allow_offline_access = c ? 1 : 0);
1595
+ const d = await t.updateTable("resource_servers").set(_).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1596
+ return Number(d.numUpdatedRows) > 0;
1597
1597
  };
1598
1598
  }
1599
1599
  function Ka(t) {
1600
1600
  return {
1601
1601
  create: za(t),
1602
1602
  get: Ja(t),
1603
- list: La(t),
1604
- remove: Ea(t),
1603
+ list: Ea(t),
1604
+ remove: La(t),
1605
1605
  update: Ra(t)
1606
1606
  };
1607
1607
  }
1608
1608
  function Ua(t) {
1609
1609
  return async (e, a) => {
1610
- const r = (/* @__PURE__ */ new Date()).toISOString(), n = S(), o = {
1610
+ const r = (/* @__PURE__ */ new Date()).toISOString(), n = T(), o = {
1611
1611
  id: n,
1612
1612
  ...a,
1613
1613
  tenant_id: e,
@@ -1630,11 +1630,11 @@ function Ba(t) {
1630
1630
  } : null;
1631
1631
  };
1632
1632
  }
1633
- function Qa(t) {
1633
+ function qa(t) {
1634
1634
  return async (e, a) => {
1635
1635
  let r = t.selectFrom("roles").where("roles.tenant_id", "=", e);
1636
1636
  const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = a;
1637
- a.q && (r = T(t, r, a.q, ["name"]));
1637
+ a.q && (r = S(t, r, a.q, ["name"]));
1638
1638
  const c = await r.offset(n * o).limit(o).selectAll().execute();
1639
1639
  if (!s)
1640
1640
  return {
@@ -1643,16 +1643,16 @@ function Qa(t) {
1643
1643
  limit: o,
1644
1644
  length: c.length
1645
1645
  };
1646
- const { count: u } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1646
+ const { count: m } = await r.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1647
1647
  return {
1648
1648
  roles: c,
1649
1649
  start: n * o,
1650
1650
  limit: o,
1651
- length: x(u)
1651
+ length: x(m)
1652
1652
  };
1653
1653
  };
1654
1654
  }
1655
- function qa(t) {
1655
+ function Qa(t) {
1656
1656
  return async (e, a, r) => {
1657
1657
  const n = {
1658
1658
  ...r,
@@ -1661,19 +1661,19 @@ function qa(t) {
1661
1661
  return Number(o.numUpdatedRows) > 0;
1662
1662
  };
1663
1663
  }
1664
- function Va(t) {
1664
+ function Wa(t) {
1665
1665
  return async (e, a) => {
1666
1666
  const r = await t.deleteFrom("roles").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1667
1667
  return Number(r.numDeletedRows) > 0;
1668
1668
  };
1669
1669
  }
1670
- function Wa(t) {
1670
+ function Va(t) {
1671
1671
  return {
1672
1672
  create: Ua(t),
1673
1673
  get: Ba(t),
1674
- list: Qa(t),
1675
- update: qa(t),
1676
- remove: Va(t)
1674
+ list: qa(t),
1675
+ update: Qa(t),
1676
+ remove: Wa(t)
1677
1677
  };
1678
1678
  }
1679
1679
  function Ga(t) {
@@ -1730,7 +1730,7 @@ function Ya(t) {
1730
1730
  const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = r;
1731
1731
  let i = t.selectFrom("role_permissions").leftJoin(
1732
1732
  "resource_servers",
1733
- (_) => _.onRef(
1733
+ (d) => d.onRef(
1734
1734
  "role_permissions.tenant_id",
1735
1735
  "=",
1736
1736
  "resource_servers.tenant_id"
@@ -1746,17 +1746,17 @@ function Ya(t) {
1746
1746
  "role_permissions.created_at",
1747
1747
  "resource_servers.name as resource_server_name"
1748
1748
  ]).where("role_permissions.tenant_id", "=", e).where("role_permissions.role_id", "=", a);
1749
- const m = (await i.offset(n * o).limit(o).execute()).map((_) => ({
1750
- role_id: _.role_id,
1751
- resource_server_identifier: _.resource_server_identifier,
1752
- resource_server_name: _.resource_server_name || _.resource_server_identifier,
1749
+ const _ = (await i.offset(n * o).limit(o).execute()).map((d) => ({
1750
+ role_id: d.role_id,
1751
+ resource_server_identifier: d.resource_server_identifier,
1752
+ resource_server_name: d.resource_server_name || d.resource_server_identifier,
1753
1753
  // Fallback to identifier if name is null
1754
- permission_name: _.permission_name,
1754
+ permission_name: d.permission_name,
1755
1755
  description: null,
1756
1756
  // No description available from role_permissions directly
1757
- created_at: _.created_at
1757
+ created_at: d.created_at
1758
1758
  }));
1759
- return s && await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m;
1759
+ return s && await i.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), _;
1760
1760
  };
1761
1761
  }
1762
1762
  function Xa(t) {
@@ -1896,7 +1896,7 @@ function ir(t) {
1896
1896
  return async (e, a) => {
1897
1897
  const r = {
1898
1898
  ...a,
1899
- id: a.id || S(),
1899
+ id: a.id || T(),
1900
1900
  tenant_id: e,
1901
1901
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1902
1902
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1910,7 +1910,7 @@ function ir(t) {
1910
1910
  try {
1911
1911
  await t.insertInto("organizations").values(r).execute();
1912
1912
  } catch (n) {
1913
- throw n.code === "SQLITE_CONSTRAINT_UNIQUE" || n.message.includes("AlreadyExists") ? new H(409, {
1913
+ throw n.code === "SQLITE_CONSTRAINT_UNIQUE" || n.message.includes("AlreadyExists") ? new q(409, {
1914
1914
  message: "Organization already exists"
1915
1915
  }) : n;
1916
1916
  }
@@ -1963,11 +1963,11 @@ function dr(t) {
1963
1963
  }
1964
1964
  function ur(t) {
1965
1965
  return async (e, a, r) => {
1966
- const { branding: n, metadata: o, enabled_connections: s, token_quota: i, ...c } = r, u = {
1966
+ const { branding: n, metadata: o, enabled_connections: s, token_quota: i, ...c } = r, m = {
1967
1967
  ...c,
1968
1968
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1969
1969
  };
1970
- return n !== void 0 && (u.branding = JSON.stringify(n)), o !== void 0 && (u.metadata = JSON.stringify(o)), s !== void 0 && (u.enabled_connections = JSON.stringify(s)), i !== void 0 && (u.token_quota = JSON.stringify(i)), (await t.updateTable("organizations").set(u).where("tenant_id", "=", e).where("id", "=", a).execute()).length > 0;
1970
+ return n !== void 0 && (m.branding = JSON.stringify(n)), o !== void 0 && (m.metadata = JSON.stringify(o)), s !== void 0 && (m.enabled_connections = JSON.stringify(s)), i !== void 0 && (m.token_quota = JSON.stringify(i)), (await t.updateTable("organizations").set(m).where("tenant_id", "=", e).where("id", "=", a).execute()).length > 0;
1971
1971
  };
1972
1972
  }
1973
1973
  function mr(t) {
@@ -1980,12 +1980,108 @@ function mr(t) {
1980
1980
  };
1981
1981
  }
1982
1982
  function _r(t) {
1983
+ return async (e, a) => {
1984
+ const r = {
1985
+ id: T(),
1986
+ tenant_id: e,
1987
+ user_id: a.user_id,
1988
+ organization_id: a.organization_id,
1989
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1990
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1991
+ };
1992
+ try {
1993
+ await t.insertInto("user_organizations").values(r).execute();
1994
+ } catch (n) {
1995
+ throw n.code === "SQLITE_CONSTRAINT_UNIQUE" || n.code === "ER_DUP_ENTRY" ? new q(409, {
1996
+ message: "User is already a member of this organization"
1997
+ }) : n;
1998
+ }
1999
+ return {
2000
+ ...r
2001
+ };
2002
+ };
2003
+ }
2004
+ function hr(t) {
2005
+ return async (e, a) => {
2006
+ const r = await t.selectFrom("user_organizations").selectAll().where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
2007
+ return r ? {
2008
+ id: r.id,
2009
+ user_id: r.user_id,
2010
+ organization_id: r.organization_id,
2011
+ created_at: r.created_at,
2012
+ updated_at: r.updated_at
2013
+ } : null;
2014
+ };
2015
+ }
2016
+ function fr(t) {
2017
+ return async (e, a) => {
2018
+ const r = (a == null ? void 0 : a.page) || 0, n = (a == null ? void 0 : a.per_page) || 50, o = r * n;
2019
+ let s = t.selectFrom("user_organizations").selectAll().where("tenant_id", "=", e);
2020
+ if (a != null && a.q) {
2021
+ if (a.q.startsWith("user_id:")) {
2022
+ const d = a.q.replace("user_id:", "");
2023
+ s = s.where("user_id", "=", d);
2024
+ } else if (a.q.startsWith("organization_id:")) {
2025
+ const d = a.q.replace("organization_id:", "");
2026
+ s = s.where("organization_id", "=", d);
2027
+ }
2028
+ }
2029
+ s = s.orderBy("created_at", "desc"), n > 0 && (s = s.limit(n).offset(o));
2030
+ const i = await s.execute();
2031
+ let c = t.selectFrom("user_organizations").select(t.fn.count("id").as("count")).where("tenant_id", "=", e);
2032
+ if (a != null && a.q) {
2033
+ if (a.q.startsWith("user_id:")) {
2034
+ const d = a.q.replace("user_id:", "");
2035
+ c = c.where("user_id", "=", d);
2036
+ } else if (a.q.startsWith("organization_id:")) {
2037
+ const d = a.q.replace("organization_id:", "");
2038
+ c = c.where("organization_id", "=", d);
2039
+ }
2040
+ }
2041
+ const m = await c.executeTakeFirst();
2042
+ return {
2043
+ userOrganizations: i.map((d) => ({
2044
+ id: d.id,
2045
+ user_id: d.user_id,
2046
+ organization_id: d.organization_id,
2047
+ created_at: d.created_at,
2048
+ updated_at: d.updated_at
2049
+ })),
2050
+ start: o,
2051
+ limit: n,
2052
+ length: Number((m == null ? void 0 : m.count) || 0)
2053
+ };
2054
+ };
2055
+ }
2056
+ function pr(t) {
2057
+ return async (e, a) => (await t.deleteFrom("user_organizations").where("id", "=", a).where("tenant_id", "=", e).execute()).length > 0;
2058
+ }
2059
+ function gr(t) {
2060
+ return async (e, a, r) => {
2061
+ const n = {
2062
+ ...r,
2063
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
2064
+ };
2065
+ return (await t.updateTable("user_organizations").set(n).where("id", "=", a).where("tenant_id", "=", e).execute()).length > 0;
2066
+ };
2067
+ }
2068
+ function wr(t) {
2069
+ return {
2070
+ // CRUD operations
2071
+ create: _r(t),
2072
+ get: hr(t),
2073
+ list: fr(t),
2074
+ remove: pr(t),
2075
+ update: gr(t)
2076
+ };
2077
+ }
2078
+ function yr(t) {
1983
2079
  return t[t.length - 1];
1984
2080
  }
1985
2081
  function C(t) {
1986
2082
  return Object.freeze(t);
1987
2083
  }
1988
- const W = C({
2084
+ const G = C({
1989
2085
  is(t) {
1990
2086
  return t.kind === "IdentifierNode";
1991
2087
  },
@@ -2002,17 +2098,17 @@ const W = C({
2002
2098
  create(t) {
2003
2099
  return C({
2004
2100
  kind: "SchemableIdentifierNode",
2005
- identifier: W.create(t)
2101
+ identifier: G.create(t)
2006
2102
  });
2007
2103
  },
2008
2104
  createWithSchema(t, e) {
2009
2105
  return C({
2010
2106
  kind: "SchemableIdentifierNode",
2011
- schema: W.create(t),
2012
- identifier: W.create(e)
2107
+ schema: G.create(t),
2108
+ identifier: G.create(e)
2013
2109
  });
2014
2110
  }
2015
- }), hr = C({
2111
+ }), vr = C({
2016
2112
  is(t) {
2017
2113
  return t.kind === "AliasNode";
2018
2114
  },
@@ -2041,7 +2137,7 @@ const W = C({
2041
2137
  }
2042
2138
  });
2043
2139
  var Y;
2044
- class fr {
2140
+ class Nr {
2045
2141
  constructor() {
2046
2142
  R(this, "nodeStack", []);
2047
2143
  O(this, Y, C({
@@ -2148,7 +2244,7 @@ class fr {
2148
2244
  return this.nodeStack.pop(), C(a);
2149
2245
  }
2150
2246
  transformNodeImpl(e) {
2151
- return d(this, Y)[e.kind](e);
2247
+ return u(this, Y)[e.kind](e);
2152
2248
  }
2153
2249
  transformNodeList(e) {
2154
2250
  return e && C(e.map((a) => this.transformNode(a)));
@@ -2875,7 +2971,7 @@ class fr {
2875
2971
  }
2876
2972
  }
2877
2973
  Y = new WeakMap();
2878
- const pr = C({
2974
+ const Cr = C({
2879
2975
  AlterTableNode: !0,
2880
2976
  CreateIndexNode: !0,
2881
2977
  CreateSchemaNode: !0,
@@ -2894,49 +2990,49 @@ const pr = C({
2894
2990
  UpdateQueryNode: !0,
2895
2991
  MergeQueryNode: !0
2896
2992
  });
2897
- var L, j, F, N, ye, ve, Ne, M, re, Ce;
2898
- class gr extends fr {
2993
+ var E, j, F, N, ye, ve, Ne, M, re, Ce;
2994
+ class br extends Nr {
2899
2995
  constructor(a) {
2900
2996
  super();
2901
2997
  O(this, N);
2902
- O(this, L);
2998
+ O(this, E);
2903
2999
  O(this, j, /* @__PURE__ */ new Set());
2904
3000
  O(this, F, /* @__PURE__ */ new Set());
2905
- K(this, L, a);
3001
+ K(this, E, a);
2906
3002
  }
2907
3003
  transformNodeImpl(a) {
2908
3004
  if (!p(this, N, ye).call(this, a))
2909
3005
  return super.transformNodeImpl(a);
2910
3006
  const r = p(this, N, Ne).call(this, a);
2911
3007
  for (const s of r)
2912
- d(this, F).add(s);
3008
+ u(this, F).add(s);
2913
3009
  const n = p(this, N, ve).call(this, a);
2914
3010
  for (const s of n)
2915
- d(this, j).add(s);
3011
+ u(this, j).add(s);
2916
3012
  const o = super.transformNodeImpl(a);
2917
3013
  for (const s of n)
2918
- d(this, j).delete(s);
3014
+ u(this, j).delete(s);
2919
3015
  for (const s of r)
2920
- d(this, F).delete(s);
3016
+ u(this, F).delete(s);
2921
3017
  return o;
2922
3018
  }
2923
3019
  transformSchemableIdentifier(a) {
2924
3020
  const r = super.transformSchemableIdentifier(a);
2925
- return r.schema || !d(this, j).has(a.identifier.name) ? r : {
3021
+ return r.schema || !u(this, j).has(a.identifier.name) ? r : {
2926
3022
  ...r,
2927
- schema: W.create(d(this, L))
3023
+ schema: G.create(u(this, E))
2928
3024
  };
2929
3025
  }
2930
3026
  transformReferences(a) {
2931
3027
  const r = super.transformReferences(a);
2932
3028
  return r.table.table.schema ? r : {
2933
3029
  ...r,
2934
- table: Z.createWithSchema(d(this, L), r.table.table.identifier.name)
3030
+ table: Z.createWithSchema(u(this, E), r.table.table.identifier.name)
2935
3031
  };
2936
3032
  }
2937
3033
  }
2938
- L = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakSet(), ye = function(a) {
2939
- return a.kind in pr;
3034
+ E = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakSet(), ye = function(a) {
3035
+ return a.kind in Cr;
2940
3036
  }, ve = function(a) {
2941
3037
  const r = /* @__PURE__ */ new Set();
2942
3038
  if ("name" in a && a.name && ae.is(a.name) && p(this, N, re).call(this, a.name, r), "from" in a && a.from)
@@ -2950,32 +3046,32 @@ L = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakSet(), ye =
2950
3046
  const r = /* @__PURE__ */ new Set();
2951
3047
  return "with" in a && a.with && p(this, N, Ce).call(this, a.with, r), r;
2952
3048
  }, M = function(a, r) {
2953
- const n = Z.is(a) ? a : hr.is(a) && Z.is(a.node) ? a.node : null;
3049
+ const n = Z.is(a) ? a : vr.is(a) && Z.is(a.node) ? a.node : null;
2954
3050
  n && p(this, N, re).call(this, n.table, r);
2955
3051
  }, re = function(a, r) {
2956
3052
  const n = a.identifier.name;
2957
- !d(this, j).has(n) && !d(this, F).has(n) && r.add(n);
3053
+ !u(this, j).has(n) && !u(this, F).has(n) && r.add(n);
2958
3054
  }, Ce = function(a, r) {
2959
3055
  for (const n of a.expressions) {
2960
3056
  const o = n.name.table.table.identifier.name;
2961
- d(this, F).has(o) || r.add(o);
3057
+ u(this, F).has(o) || r.add(o);
2962
3058
  }
2963
3059
  };
2964
3060
  var Q;
2965
- class wr {
3061
+ class xr {
2966
3062
  constructor(e) {
2967
3063
  O(this, Q);
2968
- K(this, Q, new gr(e));
3064
+ K(this, Q, new br(e));
2969
3065
  }
2970
3066
  transformQuery(e) {
2971
- return d(this, Q).transformNode(e.node);
3067
+ return u(this, Q).transformNode(e.node);
2972
3068
  }
2973
3069
  async transformResult(e) {
2974
3070
  return e.result;
2975
3071
  }
2976
3072
  }
2977
3073
  Q = new WeakMap();
2978
- class yr {
3074
+ class Tr {
2979
3075
  transformQuery(e) {
2980
3076
  return e.node;
2981
3077
  }
@@ -2983,7 +3079,7 @@ class yr {
2983
3079
  return e.result;
2984
3080
  }
2985
3081
  }
2986
- const vr = "kysely_migration", fe = "kysely_migration_lock", Nr = !1, ee = "migration_lock", Cr = C({ __noMigrations__: !0 });
3082
+ const Sr = "kysely_migration", fe = "kysely_migration_lock", Or = !1, ee = "migration_lock", kr = C({ __noMigrations__: !0 });
2987
3083
  var v, l, U, k, $, z, xe, I, Te, Se, Oe, ke, $e, ne, J, oe, Ie, De, Pe, se, je, Fe, Ae, Me, ze, B;
2988
3084
  class be {
2989
3085
  constructor(e) {
@@ -2997,7 +3093,7 @@ class be {
2997
3093
  * The returned array is sorted by migration name.
2998
3094
  */
2999
3095
  async getMigrations() {
3000
- const e = await p(this, l, J).call(this, d(this, l, $)) ? await d(this, v).db.withPlugin(d(this, l, I)).selectFrom(d(this, l, $)).select(["name", "timestamp"]).execute() : [];
3096
+ const e = await p(this, l, J).call(this, u(this, l, $)) ? await u(this, v).db.withPlugin(u(this, l, I)).selectFrom(u(this, l, $)).select(["name", "timestamp"]).execute() : [];
3001
3097
  return (await p(this, l, se).call(this)).map(({ name: r, ...n }) => {
3002
3098
  const o = e.find((s) => s.name === r);
3003
3099
  return {
@@ -3082,7 +3178,7 @@ class be {
3082
3178
  */
3083
3179
  async migrateTo(e) {
3084
3180
  return p(this, l, U).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: n }) => {
3085
- if (e === Cr)
3181
+ if (e === kr)
3086
3182
  return { direction: "Down", step: 1 / 0 };
3087
3183
  if (!a.find((i) => i.name === e))
3088
3184
  throw new Error(`migration "${e}" doesn't exist`);
@@ -3139,63 +3235,63 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3139
3235
  return a instanceof te ? a.resultSet : { error: a };
3140
3236
  }
3141
3237
  }, k = function() {
3142
- return d(this, v).migrationTableSchema;
3238
+ return u(this, v).migrationTableSchema;
3143
3239
  }, $ = function() {
3144
- return d(this, v).migrationTableName ?? vr;
3240
+ return u(this, v).migrationTableName ?? Sr;
3145
3241
  }, z = function() {
3146
- return d(this, v).migrationLockTableName ?? fe;
3242
+ return u(this, v).migrationLockTableName ?? fe;
3147
3243
  }, xe = function() {
3148
- return d(this, v).allowUnorderedMigrations ?? Nr;
3244
+ return u(this, v).allowUnorderedMigrations ?? Or;
3149
3245
  }, I = function() {
3150
- return d(this, l, k) ? new wr(d(this, l, k)) : new yr();
3246
+ return u(this, l, k) ? new xr(u(this, l, k)) : new Tr();
3151
3247
  }, Te = async function() {
3152
3248
  await p(this, l, Se).call(this), await p(this, l, Oe).call(this), await p(this, l, ke).call(this), await p(this, l, $e).call(this);
3153
3249
  }, Se = async function() {
3154
- if (d(this, l, k) && !await p(this, l, ne).call(this))
3250
+ if (u(this, l, k) && !await p(this, l, ne).call(this))
3155
3251
  try {
3156
- await p(this, l, B).call(this, d(this, v).db.schema.createSchema(d(this, l, k)));
3252
+ await p(this, l, B).call(this, u(this, v).db.schema.createSchema(u(this, l, k)));
3157
3253
  } catch (e) {
3158
3254
  if (!await p(this, l, ne).call(this))
3159
3255
  throw e;
3160
3256
  }
3161
3257
  }, Oe = async function() {
3162
- if (!await p(this, l, J).call(this, d(this, l, $)))
3258
+ if (!await p(this, l, J).call(this, u(this, l, $)))
3163
3259
  try {
3164
- d(this, l, k) && await p(this, l, B).call(this, d(this, v).db.schema.createSchema(d(this, l, k))), await p(this, l, B).call(this, d(this, v).db.schema.withPlugin(d(this, l, I)).createTable(d(this, l, $)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
3260
+ u(this, l, k) && await p(this, l, B).call(this, u(this, v).db.schema.createSchema(u(this, l, k))), await p(this, l, B).call(this, u(this, v).db.schema.withPlugin(u(this, l, I)).createTable(u(this, l, $)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
3165
3261
  } catch (e) {
3166
- if (!await p(this, l, J).call(this, d(this, l, $)))
3262
+ if (!await p(this, l, J).call(this, u(this, l, $)))
3167
3263
  throw e;
3168
3264
  }
3169
3265
  }, ke = async function() {
3170
- if (!await p(this, l, J).call(this, d(this, l, z)))
3266
+ if (!await p(this, l, J).call(this, u(this, l, z)))
3171
3267
  try {
3172
- await p(this, l, B).call(this, d(this, v).db.schema.withPlugin(d(this, l, I)).createTable(d(this, l, z)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
3268
+ await p(this, l, B).call(this, u(this, v).db.schema.withPlugin(u(this, l, I)).createTable(u(this, l, z)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
3173
3269
  } catch (e) {
3174
- if (!await p(this, l, J).call(this, d(this, l, z)))
3270
+ if (!await p(this, l, J).call(this, u(this, l, z)))
3175
3271
  throw e;
3176
3272
  }
3177
3273
  }, $e = async function() {
3178
3274
  if (!await p(this, l, oe).call(this))
3179
3275
  try {
3180
- await d(this, v).db.withPlugin(d(this, l, I)).insertInto(d(this, l, z)).values({ id: ee, is_locked: 0 }).execute();
3276
+ await u(this, v).db.withPlugin(u(this, l, I)).insertInto(u(this, l, z)).values({ id: ee, is_locked: 0 }).execute();
3181
3277
  } catch (e) {
3182
3278
  if (!await p(this, l, oe).call(this))
3183
3279
  throw e;
3184
3280
  }
3185
3281
  }, ne = async function() {
3186
- return (await d(this, v).db.introspection.getSchemas()).some((a) => a.name === d(this, l, k));
3282
+ return (await u(this, v).db.introspection.getSchemas()).some((a) => a.name === u(this, l, k));
3187
3283
  }, J = async function(e) {
3188
- const a = d(this, l, k);
3189
- return (await d(this, v).db.introspection.getTables({
3284
+ const a = u(this, l, k);
3285
+ return (await u(this, v).db.introspection.getTables({
3190
3286
  withInternalKyselyTables: !0
3191
3287
  })).some((n) => n.name === e && (!a || n.schema === a));
3192
3288
  }, oe = async function() {
3193
- return !!await d(this, v).db.withPlugin(d(this, l, I)).selectFrom(d(this, l, z)).where("id", "=", ee).select("id").executeTakeFirst();
3289
+ return !!await u(this, v).db.withPlugin(u(this, l, I)).selectFrom(u(this, l, z)).where("id", "=", ee).select("id").executeTakeFirst();
3194
3290
  }, Ie = async function(e) {
3195
- const a = d(this, v).db.getExecutor().adapter, r = C({
3196
- lockTable: d(this, v).migrationLockTableName ?? fe,
3291
+ const a = u(this, v).db.getExecutor().adapter, r = C({
3292
+ lockTable: u(this, v).migrationLockTableName ?? fe,
3197
3293
  lockRowId: ee,
3198
- lockTableSchema: d(this, v).migrationTableSchema
3294
+ lockTableSchema: u(this, v).migrationTableSchema
3199
3295
  }), n = async (o) => {
3200
3296
  try {
3201
3297
  await a.acquireMigrationLock(o, r);
@@ -3208,27 +3304,27 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3208
3304
  await a.releaseMigrationLock(o, r);
3209
3305
  }
3210
3306
  };
3211
- return a.supportsTransactionalDdl ? d(this, v).db.transaction().execute(n) : d(this, v).db.connection().execute(n);
3307
+ return a.supportsTransactionalDdl ? u(this, v).db.transaction().execute(n) : u(this, v).db.connection().execute(n);
3212
3308
  }, De = async function(e) {
3213
3309
  const a = await p(this, l, se).call(this), r = await p(this, l, je).call(this, e);
3214
- p(this, l, Fe).call(this, a, r), d(this, l, xe) || p(this, l, Ae).call(this, a, r);
3310
+ p(this, l, Fe).call(this, a, r), u(this, l, xe) || p(this, l, Ae).call(this, a, r);
3215
3311
  const n = p(this, l, Pe).call(this, a, r);
3216
3312
  return C({
3217
3313
  migrations: a,
3218
3314
  executedMigrations: r,
3219
- lastMigration: _r(r),
3315
+ lastMigration: yr(r),
3220
3316
  pendingMigrations: n
3221
3317
  });
3222
3318
  }, Pe = function(e, a) {
3223
3319
  return e.filter((r) => !a.includes(r.name));
3224
3320
  }, se = async function() {
3225
- const e = await d(this, v).provider.getMigrations();
3321
+ const e = await u(this, v).provider.getMigrations();
3226
3322
  return Object.keys(e).sort().map((a) => ({
3227
3323
  ...e[a],
3228
3324
  name: a
3229
3325
  }));
3230
3326
  }, je = async function(e) {
3231
- return (await e.withPlugin(d(this, l, I)).selectFrom(d(this, l, $)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
3327
+ return (await e.withPlugin(u(this, l, I)).selectFrom(u(this, l, $)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
3232
3328
  }, Fe = function(e, a) {
3233
3329
  for (const r of a)
3234
3330
  if (!e.some((n) => n.name === r))
@@ -3246,7 +3342,7 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3246
3342
  for (let s = 0; s < o.length; ++s) {
3247
3343
  const i = n[s];
3248
3344
  try {
3249
- i.down && (await i.down(e), await e.withPlugin(d(this, l, I)).deleteFrom(d(this, l, $)).where("name", "=", i.name).execute(), o[s] = {
3345
+ i.down && (await i.down(e), await e.withPlugin(u(this, l, I)).deleteFrom(u(this, l, $)).where("name", "=", i.name).execute(), o[s] = {
3250
3346
  migrationName: i.name,
3251
3347
  direction: "Down",
3252
3348
  status: "Success"
@@ -3272,7 +3368,7 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3272
3368
  for (let s = 0; s < o.length; s++) {
3273
3369
  const i = a.pendingMigrations[s];
3274
3370
  try {
3275
- await i.up(e), await e.withPlugin(d(this, l, I)).insertInto(d(this, l, $)).values({
3371
+ await i.up(e), await e.withPlugin(u(this, l, I)).insertInto(u(this, l, $)).values({
3276
3372
  name: i.name,
3277
3373
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3278
3374
  }).execute(), o[s] = {
@@ -3293,20 +3389,20 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3293
3389
  }
3294
3390
  return { results: o };
3295
3391
  }, B = async function(e) {
3296
- d(this, v).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
3392
+ u(this, v).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
3297
3393
  };
3298
- var q;
3394
+ var W;
3299
3395
  class te extends Error {
3300
3396
  constructor(a) {
3301
3397
  super();
3302
- O(this, q);
3303
- K(this, q, a);
3398
+ O(this, W);
3399
+ K(this, W, a);
3304
3400
  }
3305
3401
  get resultSet() {
3306
- return d(this, q);
3402
+ return u(this, W);
3307
3403
  }
3308
3404
  }
3309
- q = new WeakMap();
3405
+ W = new WeakMap();
3310
3406
  class Je {
3311
3407
  constructor(e) {
3312
3408
  R(this, "migrations");
@@ -3316,7 +3412,7 @@ class Je {
3316
3412
  return this.migrations;
3317
3413
  }
3318
3414
  }
3319
- async function br(t) {
3415
+ async function $r(t) {
3320
3416
  await t.schema.createTable("tenants").addColumn("id", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createTable("users").addColumn("user_id", "varchar(255)", (e) => e.notNull()).addColumn(
3321
3417
  "tenant_id",
3322
3418
  "varchar(255)",
@@ -3388,35 +3484,35 @@ async function br(t) {
3388
3484
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3389
3485
  ).addColumn("domain", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute();
3390
3486
  }
3391
- async function xr(t) {
3487
+ async function Ir(t) {
3392
3488
  await t.schema.dropTable("domains").execute(), await t.schema.dropTable("members").execute(), await t.schema.dropTable("users").execute(), await t.schema.dropTable("connections").execute(), await t.schema.dropTable("applications").execute(), await t.schema.dropTable("migrations").execute(), await t.schema.dropTable("tenants").execute();
3393
3489
  }
3394
- const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3490
+ const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3395
3491
  __proto__: null,
3396
- down: xr,
3397
- up: br
3492
+ down: Ir,
3493
+ up: $r
3398
3494
  }, Symbol.toStringTag, { value: "Module" }));
3399
- async function Sr(t) {
3495
+ async function Pr(t) {
3400
3496
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
3401
3497
  }
3402
- async function Or(t) {
3498
+ async function jr(t) {
3403
3499
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
3404
3500
  }
3405
- const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3501
+ const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3406
3502
  __proto__: null,
3407
- down: Or,
3408
- up: Sr
3503
+ down: jr,
3504
+ up: Pr
3409
3505
  }, Symbol.toStringTag, { value: "Module" }));
3410
- async function $r(t) {
3506
+ async function Ar(t) {
3411
3507
  }
3412
- async function Ir(t) {
3508
+ async function Mr(t) {
3413
3509
  }
3414
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3510
+ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3415
3511
  __proto__: null,
3416
- down: Ir,
3417
- up: $r
3512
+ down: Mr,
3513
+ up: Ar
3418
3514
  }, Symbol.toStringTag, { value: "Module" }));
3419
- async function Pr(t) {
3515
+ async function Jr(t) {
3420
3516
  await t.schema.createTable("logs").addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("category", "varchar(255)", (e) => e.notNull()).addColumn("tenant_id", "varchar(64)").addColumn("user_id", "varchar(64)").addForeignKeyConstraint(
3421
3517
  "tenant_id_constraint",
3422
3518
  ["tenant_id"],
@@ -3425,24 +3521,24 @@ async function Pr(t) {
3425
3521
  (e) => e.onDelete("cascade")
3426
3522
  ).addColumn("ip", "varchar(255)").addColumn("type", "varchar(8)", (e) => e.notNull()).addColumn("date", "varchar(25)", (e) => e.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();
3427
3523
  }
3428
- async function jr(t) {
3524
+ async function Er(t) {
3429
3525
  await t.schema.dropTable("logs").execute();
3430
3526
  }
3431
- const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3527
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3432
3528
  __proto__: null,
3433
- down: jr,
3434
- up: Pr
3529
+ down: Er,
3530
+ up: Jr
3435
3531
  }, Symbol.toStringTag, { value: "Module" }));
3436
- async function Ar(t) {
3532
+ async function Rr(t) {
3437
3533
  }
3438
- async function Mr(t) {
3534
+ async function Kr(t) {
3439
3535
  }
3440
- const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3536
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3441
3537
  __proto__: null,
3442
- down: Mr,
3443
- up: Ar
3538
+ down: Kr,
3539
+ up: Rr
3444
3540
  }, Symbol.toStringTag, { value: "Module" }));
3445
- async function Jr(t) {
3541
+ async function Br(t) {
3446
3542
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3447
3543
  "user_id_constraint",
3448
3544
  ["user_id", "tenant_id"],
@@ -3467,15 +3563,15 @@ async function Jr(t) {
3467
3563
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3468
3564
  ).addColumn("code", "varchar(255)", (e) => e.notNull()).addColumn("email", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute(), await t.schema.createIndex("otps_email_index").on("otps").column("email").execute(), await t.schema.createIndex("otps_expires_at_index").on("otps").column("expires_at").execute();
3469
3565
  }
3470
- async function Lr(t) {
3566
+ async function qr(t) {
3471
3567
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
3472
3568
  }
3473
- const Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3569
+ const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3474
3570
  __proto__: null,
3475
- down: Lr,
3476
- up: Jr
3571
+ down: qr,
3572
+ up: Br
3477
3573
  }, Symbol.toStringTag, { value: "Module" }));
3478
- async function Rr(t) {
3574
+ async function Wr(t) {
3479
3575
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
3480
3576
  "user_id_constraint",
3481
3577
  ["user_id", "tenant_id"],
@@ -3490,38 +3586,13 @@ async function Rr(t) {
3490
3586
  (e) => e.onDelete("cascade")
3491
3587
  ).addColumn("type", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute(), await t.schema.createIndex("codes_expires_at_index").on("codes").column("expires_at").execute();
3492
3588
  }
3493
- async function Kr(t) {
3494
- await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
3495
- }
3496
- const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3497
- __proto__: null,
3498
- down: Kr,
3499
- up: Rr
3500
- }, Symbol.toStringTag, { value: "Module" }));
3501
- async function Br(t) {
3502
- }
3503
- async function Qr(t) {
3504
- }
3505
- const qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3506
- __proto__: null,
3507
- down: Qr,
3508
- up: Br
3509
- }, Symbol.toStringTag, { value: "Module" }));
3510
3589
  async function Vr(t) {
3511
- await t.schema.alterTable("passwords").addColumn(
3512
- "password",
3513
- "varchar(255)",
3514
- // do we want not null?
3515
- (e) => e.notNull()
3516
- ).execute();
3517
- }
3518
- async function Wr(t) {
3519
- await t.schema.alterTable("passwords").dropColumn("password").execute();
3590
+ await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
3520
3591
  }
3521
3592
  const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3522
3593
  __proto__: null,
3523
- down: Wr,
3524
- up: Vr
3594
+ down: Vr,
3595
+ up: Wr
3525
3596
  }, Symbol.toStringTag, { value: "Module" }));
3526
3597
  async function Hr(t) {
3527
3598
  }
@@ -3533,8 +3604,15 @@ const Xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3533
3604
  up: Hr
3534
3605
  }, Symbol.toStringTag, { value: "Module" }));
3535
3606
  async function Zr(t) {
3607
+ await t.schema.alterTable("passwords").addColumn(
3608
+ "password",
3609
+ "varchar(255)",
3610
+ // do we want not null?
3611
+ (e) => e.notNull()
3612
+ ).execute();
3536
3613
  }
3537
3614
  async function en(t) {
3615
+ await t.schema.alterTable("passwords").dropColumn("password").execute();
3538
3616
  }
3539
3617
  const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3540
3618
  __proto__: null,
@@ -3551,10 +3629,8 @@ const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3551
3629
  up: an
3552
3630
  }, Symbol.toStringTag, { value: "Module" }));
3553
3631
  async function on(t) {
3554
- await t.schema.createIndex("users_email_index").on("users").column("email").execute();
3555
3632
  }
3556
3633
  async function sn(t) {
3557
- await t.schema.dropIndex("users_email_index").execute();
3558
3634
  }
3559
3635
  const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3560
3636
  __proto__: null,
@@ -3562,10 +3638,8 @@ const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3562
3638
  up: on
3563
3639
  }, Symbol.toStringTag, { value: "Module" }));
3564
3640
  async function cn(t) {
3565
- await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3566
3641
  }
3567
3642
  async function dn(t) {
3568
- await t.schema.alterTable("users").dropColumn("profileData").execute();
3569
3643
  }
3570
3644
  const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3571
3645
  __proto__: null,
@@ -3573,10 +3647,10 @@ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3573
3647
  up: cn
3574
3648
  }, Symbol.toStringTag, { value: "Module" }));
3575
3649
  async function mn(t) {
3576
- await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3650
+ await t.schema.createIndex("users_email_index").on("users").column("email").execute();
3577
3651
  }
3578
3652
  async function _n(t) {
3579
- await t.schema.dropIndex("users_linked_to_index");
3653
+ await t.schema.dropIndex("users_email_index").execute();
3580
3654
  }
3581
3655
  const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3582
3656
  __proto__: null,
@@ -3584,10 +3658,10 @@ const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3584
3658
  up: mn
3585
3659
  }, Symbol.toStringTag, { value: "Module" }));
3586
3660
  async function fn(t) {
3587
- await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
3661
+ await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3588
3662
  }
3589
3663
  async function pn(t) {
3590
- await t.schema.alterTable("users").dropColumn("locale").execute();
3664
+ await t.schema.alterTable("users").dropColumn("profileData").execute();
3591
3665
  }
3592
3666
  const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3593
3667
  __proto__: null,
@@ -3595,22 +3669,10 @@ const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3595
3669
  up: fn
3596
3670
  }, Symbol.toStringTag, { value: "Module" }));
3597
3671
  async function wn(t) {
3598
- await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
3599
- "tenant_id",
3600
- "varchar(255)",
3601
- (e) => e.references("tenants.id").onDelete("cascade")
3602
- ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn("cert", "varchar(4096)").addColumn("pkcs7", "varchar(4096)").addColumn("fingerprint", "varchar(256)").addColumn("thumbprint", "varchar(256)").addColumn("current_since", "varchar(256)").addColumn("current_until", "varchar(256)").addColumn(
3603
- "type",
3604
- "varchar(50)",
3605
- (e) => e.notNull().defaultTo("jwt_signing")
3606
- ).addColumn(
3607
- "connection",
3608
- "varchar(255)",
3609
- (e) => e.references("connections.id").onDelete("cascade")
3610
- ).execute();
3672
+ await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3611
3673
  }
3612
3674
  async function yn(t) {
3613
- await t.schema.dropTable("keys").execute();
3675
+ await t.schema.dropIndex("users_linked_to_index");
3614
3676
  }
3615
3677
  const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3616
3678
  __proto__: null,
@@ -3618,8 +3680,10 @@ const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3618
3680
  up: wn
3619
3681
  }, Symbol.toStringTag, { value: "Module" }));
3620
3682
  async function Nn(t) {
3683
+ await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
3621
3684
  }
3622
3685
  async function Cn(t) {
3686
+ await t.schema.alterTable("users").dropColumn("locale").execute();
3623
3687
  }
3624
3688
  const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3625
3689
  __proto__: null,
@@ -3627,8 +3691,22 @@ const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3627
3691
  up: Nn
3628
3692
  }, Symbol.toStringTag, { value: "Module" }));
3629
3693
  async function xn(t) {
3694
+ await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
3695
+ "tenant_id",
3696
+ "varchar(255)",
3697
+ (e) => e.references("tenants.id").onDelete("cascade")
3698
+ ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn("cert", "varchar(4096)").addColumn("pkcs7", "varchar(4096)").addColumn("fingerprint", "varchar(256)").addColumn("thumbprint", "varchar(256)").addColumn("current_since", "varchar(256)").addColumn("current_until", "varchar(256)").addColumn(
3699
+ "type",
3700
+ "varchar(50)",
3701
+ (e) => e.notNull().defaultTo("jwt_signing")
3702
+ ).addColumn(
3703
+ "connection",
3704
+ "varchar(255)",
3705
+ (e) => e.references("connections.id").onDelete("cascade")
3706
+ ).execute();
3630
3707
  }
3631
3708
  async function Tn(t) {
3709
+ await t.schema.dropTable("keys").execute();
3632
3710
  }
3633
3711
  const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3634
3712
  __proto__: null,
@@ -3636,10 +3714,8 @@ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3636
3714
  up: xn
3637
3715
  }, Symbol.toStringTag, { value: "Module" }));
3638
3716
  async function On(t) {
3639
- await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3640
3717
  }
3641
3718
  async function kn(t) {
3642
- await t.schema.alterTable("otps").dropColumn("audience").execute();
3643
3719
  }
3644
3720
  const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3645
3721
  __proto__: null,
@@ -3656,10 +3732,10 @@ const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3656
3732
  up: In
3657
3733
  }, Symbol.toStringTag, { value: "Module" }));
3658
3734
  async function jn(t) {
3659
- await t.schema.alterTable("logs").dropColumn("category").execute();
3735
+ await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3660
3736
  }
3661
3737
  async function Fn(t) {
3662
- await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
3738
+ await t.schema.alterTable("otps").dropColumn("audience").execute();
3663
3739
  }
3664
3740
  const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3665
3741
  __proto__: null,
@@ -3667,64 +3743,63 @@ const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3667
3743
  up: jn
3668
3744
  }, Symbol.toStringTag, { value: "Module" }));
3669
3745
  async function Mn(t) {
3670
- await t.schema.alterTable("users").dropColumn("tags").execute();
3671
3746
  }
3672
3747
  async function zn(t) {
3673
- await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3674
3748
  }
3675
3749
  const Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3676
3750
  __proto__: null,
3677
3751
  down: zn,
3678
3752
  up: Mn
3679
3753
  }, Symbol.toStringTag, { value: "Module" }));
3680
- async function Ln(t) {
3681
- await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(), await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(), await t.schema.createIndex("logs_date").on("logs").column("date").execute();
3682
- }
3683
3754
  async function En(t) {
3684
- await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3755
+ await t.schema.alterTable("logs").dropColumn("category").execute();
3756
+ }
3757
+ async function Ln(t) {
3758
+ await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
3685
3759
  }
3686
3760
  const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3687
3761
  __proto__: null,
3688
- down: En,
3689
- up: Ln
3762
+ down: Ln,
3763
+ up: En
3690
3764
  }, Symbol.toStringTag, { value: "Module" }));
3691
3765
  async function Kn(t) {
3692
- await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3766
+ await t.schema.alterTable("users").dropColumn("tags").execute();
3693
3767
  }
3694
3768
  async function Un(t) {
3695
- await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3769
+ await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3696
3770
  }
3697
3771
  const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3698
3772
  __proto__: null,
3699
3773
  down: Un,
3700
3774
  up: Kn
3701
3775
  }, Symbol.toStringTag, { value: "Module" }));
3702
- async function Qn(t) {
3703
- await t.schema.alterTable("logs").addColumn("user_name", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("auth0_client", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("isMobile", "boolean").execute(), await t.schema.alterTable("logs").addColumn("connection", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("connection_id", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("audience", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("scope", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy_type", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("hostname", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("session_connection", "varchar(255)").execute();
3704
- }
3705
3776
  async function qn(t) {
3706
- await t.schema.alterTable("logs").dropColumn("user_name").execute(), await t.schema.alterTable("logs").dropColumn("auth0_client").execute(), await t.schema.alterTable("logs").dropColumn("isMobile").execute(), await t.schema.alterTable("logs").dropColumn("connection").execute(), await t.schema.alterTable("logs").dropColumn("connection_id").execute(), await t.schema.alterTable("logs").dropColumn("audience").execute(), await t.schema.alterTable("logs").dropColumn("scope").execute(), await t.schema.alterTable("logs").dropColumn("strategy").execute(), await t.schema.alterTable("logs").dropColumn("strategy_type").execute(), await t.schema.alterTable("logs").dropColumn("hostname").execute(), await t.schema.alterTable("logs").dropColumn("session_connection").execute();
3777
+ await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(), await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(), await t.schema.createIndex("logs_date").on("logs").column("date").execute();
3778
+ }
3779
+ async function Qn(t) {
3780
+ await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3707
3781
  }
3708
- const Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3782
+ const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3709
3783
  __proto__: null,
3710
- down: qn,
3711
- up: Qn
3784
+ down: Qn,
3785
+ up: qn
3712
3786
  }, Symbol.toStringTag, { value: "Module" }));
3713
- async function Wn(t) {
3714
- await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3787
+ async function Vn(t) {
3788
+ await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3715
3789
  }
3716
3790
  async function Gn(t) {
3717
- await t.schema.dropIndex("users_name_index").execute();
3791
+ await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3718
3792
  }
3719
3793
  const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3720
3794
  __proto__: null,
3721
3795
  down: Gn,
3722
- up: Wn
3796
+ up: Vn
3723
3797
  }, Symbol.toStringTag, { value: "Module" }));
3724
3798
  async function Yn(t) {
3799
+ await t.schema.alterTable("logs").addColumn("user_name", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("auth0_client", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("isMobile", "boolean").execute(), await t.schema.alterTable("logs").addColumn("connection", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("connection_id", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("audience", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("scope", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy_type", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("hostname", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("session_connection", "varchar(255)").execute();
3725
3800
  }
3726
3801
  async function Xn(t) {
3727
- await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3802
+ await t.schema.alterTable("logs").dropColumn("user_name").execute(), await t.schema.alterTable("logs").dropColumn("auth0_client").execute(), await t.schema.alterTable("logs").dropColumn("isMobile").execute(), await t.schema.alterTable("logs").dropColumn("connection").execute(), await t.schema.alterTable("logs").dropColumn("connection_id").execute(), await t.schema.alterTable("logs").dropColumn("audience").execute(), await t.schema.alterTable("logs").dropColumn("scope").execute(), await t.schema.alterTable("logs").dropColumn("strategy").execute(), await t.schema.alterTable("logs").dropColumn("strategy_type").execute(), await t.schema.alterTable("logs").dropColumn("hostname").execute(), await t.schema.alterTable("logs").dropColumn("session_connection").execute();
3728
3803
  }
3729
3804
  const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3730
3805
  __proto__: null,
@@ -3732,10 +3807,10 @@ const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3732
3807
  up: Yn
3733
3808
  }, Symbol.toStringTag, { value: "Module" }));
3734
3809
  async function eo(t) {
3735
- await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3810
+ await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3736
3811
  }
3737
3812
  async function to(t) {
3738
- await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
3813
+ await t.schema.dropIndex("users_name_index").execute();
3739
3814
  }
3740
3815
  const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3741
3816
  __proto__: null,
@@ -3743,10 +3818,9 @@ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3743
3818
  up: eo
3744
3819
  }, Symbol.toStringTag, { value: "Module" }));
3745
3820
  async function ro(t) {
3746
- await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3747
3821
  }
3748
3822
  async function no(t) {
3749
- await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3823
+ await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3750
3824
  }
3751
3825
  const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3752
3826
  __proto__: null,
@@ -3754,14 +3828,10 @@ const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3754
3828
  up: ro
3755
3829
  }, Symbol.toStringTag, { value: "Module" }));
3756
3830
  async function so(t) {
3757
- await t.schema.createTable("branding").addColumn(
3758
- "tenant_id",
3759
- "varchar(255)",
3760
- (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3761
- ).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();
3831
+ await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3762
3832
  }
3763
3833
  async function io(t) {
3764
- await t.schema.dropTable("branding").execute();
3834
+ await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
3765
3835
  }
3766
3836
  const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3767
3837
  __proto__: null,
@@ -3769,8 +3839,10 @@ const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3769
3839
  up: so
3770
3840
  }, Symbol.toStringTag, { value: "Module" }));
3771
3841
  async function co(t) {
3842
+ await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3772
3843
  }
3773
3844
  async function uo(t) {
3845
+ await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3774
3846
  }
3775
3847
  const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3776
3848
  __proto__: null,
@@ -3778,8 +3850,14 @@ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3778
3850
  up: co
3779
3851
  }, Symbol.toStringTag, { value: "Module" }));
3780
3852
  async function _o(t) {
3853
+ await t.schema.createTable("branding").addColumn(
3854
+ "tenant_id",
3855
+ "varchar(255)",
3856
+ (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3857
+ ).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();
3781
3858
  }
3782
3859
  async function ho(t) {
3860
+ await t.schema.dropTable("branding").execute();
3783
3861
  }
3784
3862
  const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3785
3863
  __proto__: null,
@@ -3805,18 +3883,8 @@ const No = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3805
3883
  up: yo
3806
3884
  }, Symbol.toStringTag, { value: "Module" }));
3807
3885
  async function Co(t) {
3808
- await t.schema.createTable("authentication_codes").addColumn(
3809
- "tenant_id",
3810
- "varchar(255)",
3811
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3812
- ).addColumn("code", "varchar(255)", (e) => e.primaryKey()).addColumn(
3813
- "client_id",
3814
- "varchar(255)",
3815
- (e) => e.references("applications.id").onDelete("cascade").notNull()
3816
- ).addColumn("user_id", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3817
3886
  }
3818
3887
  async function bo(t) {
3819
- await t.schema.dropTable("authentication_codes").execute();
3820
3888
  }
3821
3889
  const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3822
3890
  __proto__: null,
@@ -3833,10 +3901,18 @@ const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3833
3901
  up: To
3834
3902
  }, Symbol.toStringTag, { value: "Module" }));
3835
3903
  async function ko(t) {
3836
- await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3904
+ await t.schema.createTable("authentication_codes").addColumn(
3905
+ "tenant_id",
3906
+ "varchar(255)",
3907
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
3908
+ ).addColumn("code", "varchar(255)", (e) => e.primaryKey()).addColumn(
3909
+ "client_id",
3910
+ "varchar(255)",
3911
+ (e) => e.references("applications.id").onDelete("cascade").notNull()
3912
+ ).addColumn("user_id", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3837
3913
  }
3838
3914
  async function $o(t) {
3839
- await t.schema.alterTable("otps").dropColumn("ip").execute();
3915
+ await t.schema.dropTable("authentication_codes").execute();
3840
3916
  }
3841
3917
  const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3842
3918
  __proto__: null,
@@ -3844,10 +3920,8 @@ const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3844
3920
  up: ko
3845
3921
  }, Symbol.toStringTag, { value: "Module" }));
3846
3922
  async function Do(t) {
3847
- await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3848
3923
  }
3849
3924
  async function Po(t) {
3850
- await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3851
3925
  }
3852
3926
  const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3853
3927
  __proto__: null,
@@ -3855,8 +3929,10 @@ const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3855
3929
  up: Do
3856
3930
  }, Symbol.toStringTag, { value: "Module" }));
3857
3931
  async function Fo(t) {
3932
+ await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3858
3933
  }
3859
3934
  async function Ao(t) {
3935
+ await t.schema.alterTable("otps").dropColumn("ip").execute();
3860
3936
  }
3861
3937
  const Mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3862
3938
  __proto__: null,
@@ -3864,43 +3940,63 @@ const Mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3864
3940
  up: Fo
3865
3941
  }, Symbol.toStringTag, { value: "Module" }));
3866
3942
  async function zo(t) {
3867
- await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3868
- "tenant_id",
3869
- "varchar(255)",
3870
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3871
- ).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("trigger_id", "varchar(255)", (e) => e.notNull()).addColumn("enabled", "boolean", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addColumn(
3872
- "synchronous",
3873
- "boolean",
3874
- (e) => e.defaultTo(!1).notNull()
3875
- ).addColumn("priority", "integer").execute();
3943
+ await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3876
3944
  }
3877
3945
  async function Jo(t) {
3878
- await t.schema.dropTable("hooks").execute();
3946
+ await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3879
3947
  }
3880
- const Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3948
+ const Eo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3881
3949
  __proto__: null,
3882
3950
  down: Jo,
3883
3951
  up: zo
3884
3952
  }, Symbol.toStringTag, { value: "Module" }));
3885
- async function Eo(t) {
3953
+ async function Lo(t) {
3886
3954
  }
3887
3955
  async function Ro(t) {
3888
3956
  }
3889
3957
  const Ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3890
3958
  __proto__: null,
3891
3959
  down: Ro,
3892
- up: Eo
3960
+ up: Lo
3893
3961
  }, Symbol.toStringTag, { value: "Module" }));
3894
3962
  async function Uo(t) {
3963
+ await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3964
+ "tenant_id",
3965
+ "varchar(255)",
3966
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
3967
+ ).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("trigger_id", "varchar(255)", (e) => e.notNull()).addColumn("enabled", "boolean", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addColumn(
3968
+ "synchronous",
3969
+ "boolean",
3970
+ (e) => e.defaultTo(!1).notNull()
3971
+ ).addColumn("priority", "integer").execute();
3895
3972
  }
3896
3973
  async function Bo(t) {
3974
+ await t.schema.dropTable("hooks").execute();
3897
3975
  }
3898
- const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3976
+ const qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3899
3977
  __proto__: null,
3900
3978
  down: Bo,
3901
3979
  up: Uo
3902
3980
  }, Symbol.toStringTag, { value: "Module" }));
3903
- async function qo(t) {
3981
+ async function Qo(t) {
3982
+ }
3983
+ async function Wo(t) {
3984
+ }
3985
+ const Vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3986
+ __proto__: null,
3987
+ down: Wo,
3988
+ up: Qo
3989
+ }, Symbol.toStringTag, { value: "Module" }));
3990
+ async function Go(t) {
3991
+ }
3992
+ async function Ho(t) {
3993
+ }
3994
+ const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3995
+ __proto__: null,
3996
+ down: Ho,
3997
+ up: Go
3998
+ }, Symbol.toStringTag, { value: "Module" }));
3999
+ async function Xo(t) {
3904
4000
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3905
4001
  "tenant_id",
3906
4002
  "varchar(255)",
@@ -3917,7 +4013,7 @@ async function qo(t) {
3917
4013
  (e) => e.onDelete("cascade")
3918
4014
  ).addColumn("code_type", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3919
4015
  }
3920
- async function Vo(t) {
4016
+ async function Zo(t) {
3921
4017
  await t.schema.dropTable("logins").execute(), await t.schema.alterTable("passwords").dropColumn("algorithm").execute(), await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("code", "varchar(255)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addColumn("tenant_id", "varchar(255)").addForeignKeyConstraint(
3922
4018
  "codes_user_id_tenant_id_constraint",
3923
4019
  ["user_id", "tenant_id"],
@@ -3926,36 +4022,14 @@ async function Vo(t) {
3926
4022
  (e) => e.onDelete("cascade")
3927
4023
  ).addColumn("type", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3928
4024
  }
3929
- const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3930
- __proto__: null,
3931
- down: Vo,
3932
- up: qo
3933
- }, Symbol.toStringTag, { value: "Module" }));
3934
- async function Go(t) {
3935
- }
3936
- async function Ho(t) {
3937
- }
3938
- const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3939
- __proto__: null,
3940
- down: Ho,
3941
- up: Go
3942
- }, Symbol.toStringTag, { value: "Module" }));
3943
- async function Xo(t) {
3944
- await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3945
- }
3946
- async function Zo(t) {
3947
- await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3948
- }
3949
4025
  const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3950
4026
  __proto__: null,
3951
4027
  down: Zo,
3952
4028
  up: Xo
3953
4029
  }, Symbol.toStringTag, { value: "Module" }));
3954
4030
  async function ts(t) {
3955
- await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3956
4031
  }
3957
4032
  async function as(t) {
3958
- await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3959
4033
  }
3960
4034
  const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3961
4035
  __proto__: null,
@@ -3963,8 +4037,10 @@ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3963
4037
  up: ts
3964
4038
  }, Symbol.toStringTag, { value: "Module" }));
3965
4039
  async function ns(t) {
4040
+ await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3966
4041
  }
3967
4042
  async function os(t) {
4043
+ await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3968
4044
  }
3969
4045
  const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3970
4046
  __proto__: null,
@@ -3972,8 +4048,10 @@ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3972
4048
  up: ns
3973
4049
  }, Symbol.toStringTag, { value: "Module" }));
3974
4050
  async function is(t) {
4051
+ await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3975
4052
  }
3976
4053
  async function ls(t) {
4054
+ await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3977
4055
  }
3978
4056
  const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3979
4057
  __proto__: null,
@@ -3981,10 +4059,8 @@ const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3981
4059
  up: is
3982
4060
  }, Symbol.toStringTag, { value: "Module" }));
3983
4061
  async function ds(t) {
3984
- await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3985
4062
  }
3986
4063
  async function us(t) {
3987
- await t.schema.alterTable("logins").dropColumn("nonce").execute();
3988
4064
  }
3989
4065
  const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3990
4066
  __proto__: null,
@@ -4001,8 +4077,10 @@ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4001
4077
  up: _s
4002
4078
  }, Symbol.toStringTag, { value: "Module" }));
4003
4079
  async function ps(t) {
4080
+ await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
4004
4081
  }
4005
4082
  async function gs(t) {
4083
+ await t.schema.alterTable("logins").dropColumn("nonce").execute();
4006
4084
  }
4007
4085
  const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4008
4086
  __proto__: null,
@@ -4010,6 +4088,24 @@ const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4010
4088
  up: ps
4011
4089
  }, Symbol.toStringTag, { value: "Module" }));
4012
4090
  async function ys(t) {
4091
+ }
4092
+ async function vs(t) {
4093
+ }
4094
+ const Ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4095
+ __proto__: null,
4096
+ down: vs,
4097
+ up: ys
4098
+ }, Symbol.toStringTag, { value: "Module" }));
4099
+ async function Cs(t) {
4100
+ }
4101
+ async function bs(t) {
4102
+ }
4103
+ const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4104
+ __proto__: null,
4105
+ down: bs,
4106
+ up: Cs
4107
+ }, Symbol.toStringTag, { value: "Module" }));
4108
+ async function Ts(t) {
4013
4109
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
4014
4110
  "tenant_id",
4015
4111
  "varchar(255)",
@@ -4025,7 +4121,7 @@ async function ys(t) {
4025
4121
  "code_type"
4026
4122
  ]).execute();
4027
4123
  }
4028
- async function vs(t) {
4124
+ async function Ss(t) {
4029
4125
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
4030
4126
  "tenant_id",
4031
4127
  "varchar(255)",
@@ -4038,15 +4134,15 @@ async function vs(t) {
4038
4134
  (e) => e.onDelete("cascade")
4039
4135
  ).addColumn("code_type", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
4040
4136
  }
4041
- const Ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4137
+ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4042
4138
  __proto__: null,
4043
- down: vs,
4044
- up: ys
4139
+ down: Ss,
4140
+ up: Ts
4045
4141
  }, Symbol.toStringTag, { value: "Module" }));
4046
- async function Cs(t) {
4142
+ async function ks(t) {
4047
4143
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
4048
4144
  }
4049
- async function bs(t) {
4145
+ async function $s(t) {
4050
4146
  await t.schema.alterTable("keys").addColumn("private_key", "varchar(2048)").addColumn("public_key", "varchar(2048)").execute(), await t.schema.createTable("otps").addColumn(
4051
4147
  "tenant_id",
4052
4148
  "varchar(255)",
@@ -4065,32 +4161,32 @@ async function bs(t) {
4065
4161
  (e) => e.references("applications.id").onDelete("cascade").notNull()
4066
4162
  ).addColumn("user_id", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
4067
4163
  }
4068
- const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4164
+ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4069
4165
  __proto__: null,
4070
- down: bs,
4071
- up: Cs
4166
+ down: $s,
4167
+ up: ks
4072
4168
  }, Symbol.toStringTag, { value: "Module" }));
4073
- async function Ts(t) {
4169
+ async function Ds(t) {
4074
4170
  await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
4075
4171
  }
4076
- async function Ss(t) {
4172
+ async function Ps(t) {
4077
4173
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
4078
4174
  }
4079
- const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4175
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4080
4176
  __proto__: null,
4081
- down: Ss,
4082
- up: Ts
4177
+ down: Ps,
4178
+ up: Ds
4083
4179
  }, Symbol.toStringTag, { value: "Module" }));
4084
- async function ks(t) {
4180
+ async function Fs(t) {
4085
4181
  }
4086
- async function $s(t) {
4182
+ async function As(t) {
4087
4183
  }
4088
- const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4184
+ const Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4089
4185
  __proto__: null,
4090
- down: $s,
4091
- up: ks
4186
+ down: As,
4187
+ up: Fs
4092
4188
  }, Symbol.toStringTag, { value: "Module" }));
4093
- async function Ds(t) {
4189
+ async function zs(t) {
4094
4190
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
4095
4191
  "universal_login_experience",
4096
4192
  "varchar(16)",
@@ -4109,66 +4205,46 @@ async function Ds(t) {
4109
4205
  (e) => e.defaultTo(!1).notNull()
4110
4206
  ).execute();
4111
4207
  }
4112
- async function Ps(t) {
4113
- await t.schema.dropTable("prompt_settings").execute();
4114
- }
4115
- const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4116
- __proto__: null,
4117
- down: Ps,
4118
- up: Ds
4119
- }, Symbol.toStringTag, { value: "Module" }));
4120
- async function Fs(t) {
4121
- }
4122
- async function As(t) {
4123
- }
4124
- const Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4125
- __proto__: null,
4126
- down: As,
4127
- up: Fs
4128
- }, Symbol.toStringTag, { value: "Module" }));
4129
- async function zs(t) {
4130
- }
4131
4208
  async function Js(t) {
4209
+ await t.schema.dropTable("prompt_settings").execute();
4132
4210
  }
4133
- const Ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4211
+ const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4134
4212
  __proto__: null,
4135
4213
  down: Js,
4136
4214
  up: zs
4137
4215
  }, Symbol.toStringTag, { value: "Module" }));
4138
- async function Es(t) {
4216
+ async function Ls(t) {
4139
4217
  }
4140
4218
  async function Rs(t) {
4141
4219
  }
4142
4220
  const Ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4143
4221
  __proto__: null,
4144
4222
  down: Rs,
4145
- up: Es
4223
+ up: Ls
4146
4224
  }, Symbol.toStringTag, { value: "Module" }));
4147
4225
  async function Us(t) {
4148
- await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
4149
4226
  }
4150
4227
  async function Bs(t) {
4151
- await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
4152
4228
  }
4153
- const Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4229
+ const qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4154
4230
  __proto__: null,
4155
4231
  down: Bs,
4156
4232
  up: Us
4157
4233
  }, Symbol.toStringTag, { value: "Module" }));
4158
- async function qs(t) {
4159
- await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
4234
+ async function Qs(t) {
4160
4235
  }
4161
- async function Vs(t) {
4162
- await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
4236
+ async function Ws(t) {
4163
4237
  }
4164
- const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4238
+ const Vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4165
4239
  __proto__: null,
4166
- down: Vs,
4167
- up: qs
4240
+ down: Ws,
4241
+ up: Qs
4168
4242
  }, Symbol.toStringTag, { value: "Module" }));
4169
4243
  async function Gs(t) {
4244
+ await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
4170
4245
  }
4171
4246
  async function Hs(t) {
4247
+ await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
4172
4248
  }
4173
4249
  const Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4174
4250
  __proto__: null,
@@ -4176,10 +4252,10 @@ const Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4176
4252
  up: Gs
4177
4253
  }, Symbol.toStringTag, { value: "Module" }));
4178
4254
  async function Xs(t) {
4179
- await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
4255
+ await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
4180
4256
  }
4181
4257
  async function Zs(t) {
4182
- await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
4258
+ await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
4183
4259
  }
4184
4260
  const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4185
4261
  __proto__: null,
@@ -4187,10 +4263,8 @@ const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4187
4263
  up: Xs
4188
4264
  }, Symbol.toStringTag, { value: "Module" }));
4189
4265
  async function ti(t) {
4190
- await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
4191
4266
  }
4192
4267
  async function ai(t) {
4193
- await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
4194
4268
  }
4195
4269
  const ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4196
4270
  __proto__: null,
@@ -4198,6 +4272,28 @@ const ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4198
4272
  up: ti
4199
4273
  }, Symbol.toStringTag, { value: "Module" }));
4200
4274
  async function ni(t) {
4275
+ await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
4276
+ }
4277
+ async function oi(t) {
4278
+ await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
4279
+ }
4280
+ const si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4281
+ __proto__: null,
4282
+ down: oi,
4283
+ up: ni
4284
+ }, Symbol.toStringTag, { value: "Module" }));
4285
+ async function ii(t) {
4286
+ await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
4287
+ }
4288
+ async function li(t) {
4289
+ await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
4290
+ }
4291
+ const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4292
+ __proto__: null,
4293
+ down: li,
4294
+ up: ii
4295
+ }, Symbol.toStringTag, { value: "Module" }));
4296
+ async function di(t) {
4201
4297
  await t.schema.createTable("email_providers").addColumn("tenant_id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("enabled", "boolean", (e) => e.notNull()).addColumn("default_from_address", "varchar(255)").addColumn(
4202
4298
  "credentials",
4203
4299
  "varchar(2048)",
@@ -4208,18 +4304,18 @@ async function ni(t) {
4208
4304
  (e) => e.notNull().defaultTo("{}")
4209
4305
  ).addColumn("created_at", "varchar(29)", (e) => e.notNull()).addColumn("updated_at", "varchar(29)", (e) => e.notNull()).execute();
4210
4306
  }
4211
- async function oi(t) {
4307
+ async function ui(t) {
4212
4308
  await t.schema.dropTable("email_providers").execute();
4213
4309
  }
4214
- const si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4310
+ const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4215
4311
  __proto__: null,
4216
- down: oi,
4217
- up: ni
4312
+ down: ui,
4313
+ up: di
4218
4314
  }, Symbol.toStringTag, { value: "Module" }));
4219
- async function ii(t) {
4315
+ async function _i(t) {
4220
4316
  await t.schema.dropTable("tickets").execute();
4221
4317
  }
4222
- async function li(t) {
4318
+ async function hi(t) {
4223
4319
  await t.schema.createTable("tickets").addColumn(
4224
4320
  "tenant_id",
4225
4321
  "varchar(255)",
@@ -4230,22 +4326,22 @@ async function li(t) {
4230
4326
  (e) => e.references("applications.id").onDelete("cascade").notNull()
4231
4327
  ).addColumn("email", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
4232
4328
  }
4233
- const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4329
+ const fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4234
4330
  __proto__: null,
4235
- down: li,
4236
- up: ii
4331
+ down: hi,
4332
+ up: _i
4237
4333
  }, Symbol.toStringTag, { value: "Module" }));
4238
- async function di(t) {
4334
+ async function pi(t) {
4239
4335
  }
4240
- async function ui(t) {
4336
+ async function gi(t) {
4241
4337
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
4242
4338
  }
4243
- const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4339
+ const wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4244
4340
  __proto__: null,
4245
- down: ui,
4246
- up: di
4341
+ down: gi,
4342
+ up: pi
4247
4343
  }, Symbol.toStringTag, { value: "Module" }));
4248
- async function _i(t) {
4344
+ async function yi(t) {
4249
4345
  await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
4250
4346
  "client_id",
4251
4347
  "varchar(21)",
@@ -4258,27 +4354,27 @@ async function _i(t) {
4258
4354
  (e) => e.onDelete("cascade")
4259
4355
  ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
4260
4356
  }
4261
- async function hi(t) {
4357
+ async function vi(t) {
4262
4358
  await t.schema.dropTable("refresh_tokens").execute();
4263
4359
  }
4264
- const fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4360
+ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4265
4361
  __proto__: null,
4266
- down: hi,
4267
- up: _i
4362
+ down: vi,
4363
+ up: yi
4268
4364
  }, Symbol.toStringTag, { value: "Module" }));
4269
- async function pi(t) {
4365
+ async function Ci(t) {
4270
4366
  }
4271
- async function gi(t) {
4367
+ async function bi(t) {
4272
4368
  }
4273
- const wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4369
+ const xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4274
4370
  __proto__: null,
4275
- down: gi,
4276
- up: pi
4371
+ down: bi,
4372
+ up: Ci
4277
4373
  }, Symbol.toStringTag, { value: "Module" }));
4278
- async function yi(t) {
4374
+ async function Ti(t) {
4279
4375
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
4280
4376
  }
4281
- async function vi(t) {
4377
+ async function Si(t) {
4282
4378
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4283
4379
  "sessions_user_id_constraint",
4284
4380
  ["user_id", "tenant_id"],
@@ -4297,12 +4393,12 @@ async function vi(t) {
4297
4393
  (e) => e.onDelete("cascade")
4298
4394
  ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
4299
4395
  }
4300
- const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4396
+ const Oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4301
4397
  __proto__: null,
4302
- down: vi,
4303
- up: yi
4398
+ down: Si,
4399
+ up: Ti
4304
4400
  }, Symbol.toStringTag, { value: "Module" }));
4305
- async function Ci(t) {
4401
+ async function ki(t) {
4306
4402
  await t.schema.createTable("sessions_2").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4307
4403
  "sessions_2_user_id_constraint",
4308
4404
  ["user_id", "tenant_id"],
@@ -4321,15 +4417,15 @@ async function Ci(t) {
4321
4417
  (e) => e.onDelete("cascade")
4322
4418
  ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
4323
4419
  }
4324
- async function bi(t) {
4420
+ async function $i(t) {
4325
4421
  await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4326
4422
  }
4327
- const xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4423
+ const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4328
4424
  __proto__: null,
4329
- down: bi,
4330
- up: Ci
4425
+ down: $i,
4426
+ up: ki
4331
4427
  }, Symbol.toStringTag, { value: "Module" }));
4332
- async function Ti(t) {
4428
+ async function Di(t) {
4333
4429
  await t.schema.createTable("custom_domains").addColumn(
4334
4430
  "custom_domain_id",
4335
4431
  "varchar(21)",
@@ -4340,49 +4436,49 @@ async function Ti(t) {
4340
4436
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4341
4437
  ).addColumn("domain", "varchar(255)", (e) => e.notNull()).addColumn("primary", "boolean", (e) => e.notNull()).addColumn("status", "varchar(50)", (e) => e.notNull()).addColumn("type", "varchar(50)", (e) => e.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).execute(), await t.schema.dropTable("domains").execute();
4342
4438
  }
4343
- async function Si(t) {
4439
+ async function Pi(t) {
4344
4440
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("domains").addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
4345
4441
  "tenant_id",
4346
4442
  "varchar(255)",
4347
4443
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4348
4444
  ).addColumn("domain", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute();
4349
4445
  }
4350
- const Oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4446
+ const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4351
4447
  __proto__: null,
4352
- down: Si,
4353
- up: Ti
4448
+ down: Pi,
4449
+ up: Di
4354
4450
  }, Symbol.toStringTag, { value: "Module" }));
4355
- async function ki(t) {
4451
+ async function Fi(t) {
4356
4452
  }
4357
- async function $i(t) {
4453
+ async function Ai(t) {
4358
4454
  await t.schema.alterTable("logins").dropColumn("authParams_organization").dropColumn("authorization_url").execute();
4359
4455
  }
4360
- const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4456
+ const Mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4361
4457
  __proto__: null,
4362
- down: $i,
4363
- up: ki
4458
+ down: Ai,
4459
+ up: Fi
4364
4460
  }, Symbol.toStringTag, { value: "Module" }));
4365
- async function Di(t) {
4461
+ async function zi(t) {
4366
4462
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(2048)").execute();
4367
4463
  }
4368
- async function Pi(t) {
4464
+ async function Ji(t) {
4369
4465
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(1024)").execute();
4370
4466
  }
4371
- const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4467
+ const Ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4372
4468
  __proto__: null,
4373
- down: Pi,
4374
- up: Di
4469
+ down: Ji,
4470
+ up: zi
4375
4471
  }, Symbol.toStringTag, { value: "Module" }));
4376
- async function Fi(t) {
4472
+ async function Li(t) {
4377
4473
  }
4378
- async function Ai(t) {
4474
+ async function Ri(t) {
4379
4475
  }
4380
- const Mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4476
+ const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4381
4477
  __proto__: null,
4382
- down: Ai,
4383
- up: Fi
4478
+ down: Ri,
4479
+ up: Li
4384
4480
  }, Symbol.toStringTag, { value: "Module" }));
4385
- async function zi(t) {
4481
+ async function Ui(t) {
4386
4482
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4387
4483
  "sessions_user_id_constraint",
4388
4484
  ["user_id", "tenant_id"],
@@ -4409,25 +4505,25 @@ async function zi(t) {
4409
4505
  (e) => e.onDelete("cascade")
4410
4506
  ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
4411
4507
  }
4412
- async function Ji(t) {
4508
+ async function Bi(t) {
4413
4509
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
4414
4510
  }
4415
- const Li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4511
+ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4416
4512
  __proto__: null,
4417
- down: Ji,
4418
- up: zi
4513
+ down: Bi,
4514
+ up: Ui
4419
4515
  }, Symbol.toStringTag, { value: "Module" }));
4420
- async function Ei(t) {
4516
+ async function Qi(t) {
4421
4517
  await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4422
4518
  }
4423
- async function Ri(t) {
4519
+ async function Wi(t) {
4424
4520
  }
4425
- const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4521
+ const Vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4426
4522
  __proto__: null,
4427
- down: Ri,
4428
- up: Ei
4523
+ down: Wi,
4524
+ up: Qi
4429
4525
  }, Symbol.toStringTag, { value: "Module" }));
4430
- async function Ui(t) {
4526
+ async function Gi(t) {
4431
4527
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
4432
4528
  "custom_domain_id",
4433
4529
  "varchar(256)",
@@ -4438,28 +4534,7 @@ async function Ui(t) {
4438
4534
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4439
4535
  ).addColumn("domain", "varchar(255)", (e) => e.notNull()).addColumn("primary", "boolean", (e) => e.notNull()).addColumn("status", "varchar(50)", (e) => e.notNull()).addColumn("type", "varchar(50)", (e) => e.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).execute();
4440
4536
  }
4441
- async function Bi(t) {
4442
- }
4443
- const Qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4444
- __proto__: null,
4445
- down: Bi,
4446
- up: Ui
4447
- }, Symbol.toStringTag, { value: "Module" }));
4448
- async function qi(t) {
4449
- }
4450
- async function Vi(t) {
4451
- await t.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
4452
- }
4453
- const Wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4454
- __proto__: null,
4455
- down: Vi,
4456
- up: qi
4457
- }, Symbol.toStringTag, { value: "Module" }));
4458
- async function Gi(t) {
4459
- await t.schema.createTable("forms").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("tenant_id", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createIndex("forms_tenant_id_idx").on("forms").column("tenant_id").execute();
4460
- }
4461
4537
  async function Hi(t) {
4462
- await t.schema.dropTable("forms").execute();
4463
4538
  }
4464
4539
  const Yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4465
4540
  __proto__: null,
@@ -4467,10 +4542,9 @@ const Yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4467
4542
  up: Gi
4468
4543
  }, Symbol.toStringTag, { value: "Module" }));
4469
4544
  async function Xi(t) {
4470
- await t.schema.alterTable("hooks").addColumn("form_id", "text").execute(), await t.schema.alterTable("hooks").addColumn("url_tmp", "varchar(512)").execute(), await t.updateTable("hooks").set((e) => ({ url_tmp: e.ref("url") })).execute(), await t.schema.alterTable("hooks").dropColumn("url").execute(), await t.schema.alterTable("hooks").renameColumn("url_tmp", "url").execute();
4471
4545
  }
4472
4546
  async function Zi(t) {
4473
- await t.schema.dropTable("hooks").ifExists().execute(), await t.schema.createTable("hooks").addColumn("hook_id", "text", (e) => e.primaryKey()).addColumn("tenant_id", "text", (e) => e.notNull()).addColumn("trigger_id", "text", (e) => e.notNull()).addColumn("enabled", "integer", (e) => e.notNull().defaultTo(0)).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("synchronous", "integer", (e) => e.notNull().defaultTo(0)).addColumn("priority", "integer").addColumn("created_at", "text", (e) => e.notNull()).addColumn("updated_at", "text", (e) => e.notNull()).execute();
4547
+ await t.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
4474
4548
  }
4475
4549
  const el = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4476
4550
  __proto__: null,
@@ -4478,14 +4552,10 @@ const el = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4478
4552
  up: Xi
4479
4553
  }, Symbol.toStringTag, { value: "Module" }));
4480
4554
  async function tl(t) {
4481
- await t.schema.alterTable("login_sessions").addColumn(
4482
- "login_completed",
4483
- "boolean",
4484
- (e) => e.notNull().defaultTo(0)
4485
- ).execute();
4555
+ await t.schema.createTable("forms").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("tenant_id", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createIndex("forms_tenant_id_idx").on("forms").column("tenant_id").execute();
4486
4556
  }
4487
4557
  async function al(t) {
4488
- await t.schema.alterTable("login_sessions").dropColumn("login_completed").execute();
4558
+ await t.schema.dropTable("forms").execute();
4489
4559
  }
4490
4560
  const rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4491
4561
  __proto__: null,
@@ -4493,14 +4563,10 @@ const rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4493
4563
  up: tl
4494
4564
  }, Symbol.toStringTag, { value: "Module" }));
4495
4565
  async function nl(t) {
4496
- await t.schema.alterTable("sessions").addColumn(
4497
- "login_session_id",
4498
- "varchar(21)",
4499
- (e) => e.references("login_sessions.id").onDelete("set null")
4500
- ).execute();
4566
+ await t.schema.alterTable("hooks").addColumn("form_id", "text").execute(), await t.schema.alterTable("hooks").addColumn("url_tmp", "varchar(512)").execute(), await t.updateTable("hooks").set((e) => ({ url_tmp: e.ref("url") })).execute(), await t.schema.alterTable("hooks").dropColumn("url").execute(), await t.schema.alterTable("hooks").renameColumn("url_tmp", "url").execute();
4501
4567
  }
4502
4568
  async function ol(t) {
4503
- await t.schema.alterTable("sessions").dropColumn("login_session_id").execute();
4569
+ await t.schema.dropTable("hooks").ifExists().execute(), await t.schema.createTable("hooks").addColumn("hook_id", "text", (e) => e.primaryKey()).addColumn("tenant_id", "text", (e) => e.notNull()).addColumn("trigger_id", "text", (e) => e.notNull()).addColumn("enabled", "integer", (e) => e.notNull().defaultTo(0)).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("synchronous", "integer", (e) => e.notNull().defaultTo(0)).addColumn("priority", "integer").addColumn("created_at", "text", (e) => e.notNull()).addColumn("updated_at", "text", (e) => e.notNull()).execute();
4504
4570
  }
4505
4571
  const sl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4506
4572
  __proto__: null,
@@ -4508,10 +4574,14 @@ const sl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4508
4574
  up: nl
4509
4575
  }, Symbol.toStringTag, { value: "Module" }));
4510
4576
  async function il(t) {
4511
- await t.schema.createIndex("IDX_sessions_login_session_id").on("sessions").column("login_session_id").execute();
4577
+ await t.schema.alterTable("login_sessions").addColumn(
4578
+ "login_completed",
4579
+ "boolean",
4580
+ (e) => e.notNull().defaultTo(0)
4581
+ ).execute();
4512
4582
  }
4513
4583
  async function ll(t) {
4514
- await t.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
4584
+ await t.schema.alterTable("login_sessions").dropColumn("login_completed").execute();
4515
4585
  }
4516
4586
  const cl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4517
4587
  __proto__: null,
@@ -4519,10 +4589,14 @@ const cl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4519
4589
  up: il
4520
4590
  }, Symbol.toStringTag, { value: "Module" }));
4521
4591
  async function dl(t) {
4522
- await t.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await t.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
4592
+ await t.schema.alterTable("sessions").addColumn(
4593
+ "login_session_id",
4594
+ "varchar(21)",
4595
+ (e) => e.references("login_sessions.id").onDelete("set null")
4596
+ ).execute();
4523
4597
  }
4524
4598
  async function ul(t) {
4525
- await t.schema.alterTable("codes").dropColumn("code_challenge").execute(), await t.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
4599
+ await t.schema.alterTable("sessions").dropColumn("login_session_id").execute();
4526
4600
  }
4527
4601
  const ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4528
4602
  __proto__: null,
@@ -4530,10 +4604,10 @@ const ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4530
4604
  up: dl
4531
4605
  }, Symbol.toStringTag, { value: "Module" }));
4532
4606
  async function _l(t) {
4533
- await t.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
4607
+ await t.schema.createIndex("IDX_sessions_login_session_id").on("sessions").column("login_session_id").execute();
4534
4608
  }
4535
4609
  async function hl(t) {
4536
- await t.schema.alterTable("codes").dropColumn("redirect_uri").execute();
4610
+ await t.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
4537
4611
  }
4538
4612
  const fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4539
4613
  __proto__: null,
@@ -4541,10 +4615,10 @@ const fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4541
4615
  up: _l
4542
4616
  }, Symbol.toStringTag, { value: "Module" }));
4543
4617
  async function pl(t) {
4544
- await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
4618
+ await t.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await t.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
4545
4619
  }
4546
4620
  async function gl(t) {
4547
- await t.schema.alterTable("codes").dropColumn("nonce").execute(), await t.schema.alterTable("codes").dropColumn("state").execute();
4621
+ await t.schema.alterTable("codes").dropColumn("code_challenge").execute(), await t.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
4548
4622
  }
4549
4623
  const wl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4550
4624
  __proto__: null,
@@ -4552,6 +4626,28 @@ const wl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4552
4626
  up: pl
4553
4627
  }, Symbol.toStringTag, { value: "Module" }));
4554
4628
  async function yl(t) {
4629
+ await t.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
4630
+ }
4631
+ async function vl(t) {
4632
+ await t.schema.alterTable("codes").dropColumn("redirect_uri").execute();
4633
+ }
4634
+ const Nl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4635
+ __proto__: null,
4636
+ down: vl,
4637
+ up: yl
4638
+ }, Symbol.toStringTag, { value: "Module" }));
4639
+ async function Cl(t) {
4640
+ await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
4641
+ }
4642
+ async function bl(t) {
4643
+ await t.schema.alterTable("codes").dropColumn("nonce").execute(), await t.schema.alterTable("codes").dropColumn("state").execute();
4644
+ }
4645
+ const xl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4646
+ __proto__: null,
4647
+ down: bl,
4648
+ up: Cl
4649
+ }, Symbol.toStringTag, { value: "Module" }));
4650
+ async function Tl(t) {
4555
4651
  await t.schema.createTable("themes").addColumn(
4556
4652
  "tenant_id",
4557
4653
  "varchar(255)",
@@ -4626,26 +4722,26 @@ async function yl(t) {
4626
4722
  (e) => e.notNull()
4627
4723
  ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("themes_pkey", ["tenant_id", "themeId"]).execute(), await t.schema.createIndex("themes_tenant_id_idx").on("themes").column("tenant_id").execute();
4628
4724
  }
4629
- async function vl(t) {
4725
+ async function Sl(t) {
4630
4726
  await t.schema.dropTable("themes").execute();
4631
4727
  }
4632
- const Nl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4728
+ const Ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4633
4729
  __proto__: null,
4634
- down: vl,
4635
- up: yl
4730
+ down: Sl,
4731
+ up: Tl
4636
4732
  }, Symbol.toStringTag, { value: "Module" }));
4637
- async function Cl(t) {
4733
+ async function kl(t) {
4638
4734
  await t.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("identifier", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.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)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("resource_servers_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await t.schema.createTable("roles").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(50)", (e) => e.notNull()).addColumn("description", "varchar(255)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("roles_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("roles_tenant_name_uq").on("roles").columns(["tenant_id", "name"]).unique().execute();
4639
4735
  }
4640
- async function bl(t) {
4736
+ async function $l(t) {
4641
4737
  await t.schema.dropTable("roles").execute(), await t.schema.dropTable("resource_servers").execute();
4642
4738
  }
4643
- const xl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4739
+ const Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4644
4740
  __proto__: null,
4645
- down: bl,
4646
- up: Cl
4741
+ down: $l,
4742
+ up: kl
4647
4743
  }, Symbol.toStringTag, { value: "Module" }));
4648
- async function Tl(t) {
4744
+ async function Dl(t) {
4649
4745
  await t.schema.createTable("role_permissions").addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("role_id", "varchar(21)", (e) => e.notNull()).addColumn(
4650
4746
  "resource_server_identifier",
4651
4747
  "varchar(191)",
@@ -4666,148 +4762,148 @@ async function Tl(t) {
4666
4762
  "permission_name"
4667
4763
  ]).execute(), await t.schema.createIndex("user_permissions_user_fk").on("user_permissions").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("user_permissions_permission_fk").on("user_permissions").columns(["tenant_id", "resource_server_identifier", "permission_name"]).execute();
4668
4764
  }
4669
- async function Sl(t) {
4765
+ async function Pl(t) {
4670
4766
  await t.schema.dropTable("user_permissions").execute(), await t.schema.dropTable("role_permissions").execute();
4671
4767
  }
4672
- const Ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4768
+ const jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4673
4769
  __proto__: null,
4674
- down: Sl,
4675
- up: Tl
4770
+ down: Pl,
4771
+ up: Dl
4676
4772
  }, Symbol.toStringTag, { value: "Module" }));
4677
- async function kl(t) {
4773
+ async function Fl(t) {
4678
4774
  await t.schema.createTable("user_roles").addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("user_id", "varchar(191)", (e) => e.notNull()).addColumn("role_id", "varchar(21)", (e) => e.notNull()).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("user_roles_pk", [
4679
4775
  "tenant_id",
4680
4776
  "user_id",
4681
4777
  "role_id"
4682
4778
  ]).execute(), await t.schema.createIndex("user_roles_user_fk").on("user_roles").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("user_roles_role_fk").on("user_roles").columns(["tenant_id", "role_id"]).execute();
4683
4779
  }
4684
- async function $l(t) {
4780
+ async function Al(t) {
4685
4781
  await t.schema.dropTable("user_roles").execute();
4686
4782
  }
4687
- const Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4783
+ const Ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4688
4784
  __proto__: null,
4689
- down: $l,
4690
- up: kl
4785
+ down: Al,
4786
+ up: Fl
4691
4787
  }, Symbol.toStringTag, { value: "Module" }));
4692
- async function Dl(t) {
4788
+ async function zl(t) {
4693
4789
  }
4694
- async function Pl(t) {
4790
+ async function Jl(t) {
4695
4791
  await t.schema.alterTable("keys").dropColumn("connection").execute(), await t.schema.alterTable("keys").modifyColumn("cert", "varchar(2048)").execute(), await t.schema.alterTable("keys").modifyColumn("pkcs7", "varchar(2048)").execute(), await t.schema.alterTable("keys").dropColumn("type").execute();
4696
4792
  }
4697
- const jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4793
+ const El = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4698
4794
  __proto__: null,
4699
- down: Pl,
4700
- up: Dl
4795
+ down: Jl,
4796
+ up: zl
4701
4797
  }, Symbol.toStringTag, { value: "Module" }));
4702
- async function Fl(t) {
4798
+ async function Ll(t) {
4703
4799
  await t.schema.createTable("organizations").addColumn("id", "varchar(256)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(256)", (e) => e.notNull()).addColumn("name", "varchar(256)", (e) => e.notNull()).addColumn("display_name", "varchar(256)").addColumn("branding", "text").addColumn("metadata", "text").addColumn("enabled_connections", "text").addColumn("token_quota", "text").addColumn("created_at", "varchar(256)", (e) => e.notNull()).addColumn("updated_at", "varchar(256)", (e) => e.notNull()).execute(), await t.schema.createIndex("idx_organizations_tenant_id").on("organizations").column("tenant_id").execute(), await t.schema.createIndex("idx_organizations_tenant_name_unique").on("organizations").columns(["tenant_id", "name"]).unique().execute();
4704
4800
  }
4705
- async function Al(t) {
4801
+ async function Rl(t) {
4706
4802
  await t.schema.dropTable("organizations").execute();
4707
4803
  }
4708
- const Ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4804
+ const Kl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4709
4805
  __proto__: null,
4710
- down: Al,
4711
- up: Fl
4712
- }, Symbol.toStringTag, { value: "Module" })), Le = {
4713
- m1_init: Tr,
4714
- m2_magicLink: kr,
4715
- m3_updateAt: Dr,
4716
- m4_logTable: Fr,
4717
- m5_userProfile: zr,
4718
- m6_sessions: Er,
4719
- m7_passwords: Ur,
4720
- m8_logsTableNewFields: qr,
4721
- m9_passwordTableNewField: Gr,
4722
- n01_codesTable: Xr,
4723
- n11_universalLoginSession: tn,
4724
- n12_userFields: nn,
4725
- n13_userEmailIndex: ln,
4726
- n14_profileDataField: un,
4727
- n15_userEmailIndex: hn,
4728
- n16_userLocale: gn,
4729
- n17_signingKeys: vn,
4730
- n18_logsFields: bn,
4731
- n19_connectionsUserinfo: Sn,
4732
- n20_missingFields: $n,
4733
- n21_sessionDeletedAt: Pn,
4734
- n22_dropLogsFields: An,
4735
- n23_dropUsersFields: Jn,
4736
- n24_logsIndexes: Rn,
4737
- n25_logDescMaxLength: Bn,
4738
- n26_logsTableExtraFields: Vn,
4739
- n27_usersTableNameIndex: Hn,
4740
- n28_usersEmailConstrain: Zn,
4741
- n29_increaseOtpStateLength: ao,
4742
- n30_increaseTicketStateLength: oo,
4743
- n31_branding: lo,
4744
- n32_indexesAndNotNull: mo,
4745
- n33_vendorIdInUniversalLoginSession: fo,
4746
- n34_auth0ClientInUniversalLoginSession: wo,
4747
- n35_increaseUniversalSessionStateLength: No,
4748
- n36_authenticationCodes: xo,
4749
- n37_disableSignUps: Oo,
4750
- n38_otpIpAddress: Io,
4751
- n39_increaseUserAgentLength: jo,
4752
- n40_userId: Mo,
4753
- n41_hooks: Lo,
4754
- n42_userIdIndexes: Ko,
4755
- n43_userIdIndexes: Qo,
4756
- n44_codes: Wo,
4757
- n45_hookProperties: Yo,
4758
- n46_loginAuth0Client: es,
4759
- n47_loginAuth0Client: rs,
4760
- n48_saml: ss,
4761
- n49_removeFields: cs,
4762
- n50_authParamsNonce: ms,
4763
- n51_connectionid: fs,
4764
- n52_cert: ws,
4765
- n53_codes_primary_key: Ns,
4766
- n54_cleanup_tables: xs,
4767
- n55_logs_index: Os,
4768
- n56_application_fields: Is,
4769
- n57_prompt_settings: js,
4770
- n58_connection_client_id: Ms,
4771
- n59_connection_options: Ls,
4772
- n60_users_metadata: Ks,
4773
- n61_userLocales: Qs,
4774
- n62_prompt: Ws,
4775
- n63_connection_cleanup: Ys,
4776
- n64_act_as: ei,
4777
- n65_code_verifier: ri,
4778
- n66_email_providers: si,
4779
- n67_drop_tickets: ci,
4780
- n68_login_useragents: mi,
4781
- n70_refresh_tokens: fi,
4782
- n71_session_new_fields: wi,
4783
- n72_session_primary_key: Ni,
4784
- n73_drop_sessions: xi,
4785
- n74_custom_domains: Oi,
4786
- n75_organizations: Ii,
4787
- n76_authorization_url_length: ji,
4788
- n77_drop_sessions: Mi,
4789
- n78_login_sessions: Li,
4790
- n79_drop_sessions_2: Ki,
4791
- n80_recreate_custom_domains: Qi,
4792
- n81_phone: Wi,
4793
- n82_forms: Yi,
4794
- n83_addFormsIdToHooks: el,
4795
- n84_login_completed: rl,
4796
- n85_add_login_session_id_to_sessions: sl,
4797
- n86_index_sessions_login_session_id: cl,
4798
- n87_code_challenge: ml,
4799
- n88_add_redirect_uri_to_codes: fl,
4800
- n89_add_nonce_and_state_to_codes: wl,
4801
- n90_themes: Nl,
4802
- n91_resource_servers_rules_permissions: xl,
4803
- n92_role_permissions: Ol,
4804
- n93_add_permissions_to_roles: Il,
4805
- n94_keys_connection_and_extend_columns: jl,
4806
- n95_create_organizations_table: Ml
4806
+ down: Rl,
4807
+ up: Ll
4808
+ }, Symbol.toStringTag, { value: "Module" })), Ee = {
4809
+ m1_init: Dr,
4810
+ m2_magicLink: Fr,
4811
+ m3_updateAt: zr,
4812
+ m4_logTable: Lr,
4813
+ m5_userProfile: Ur,
4814
+ m6_sessions: Qr,
4815
+ m7_passwords: Gr,
4816
+ m8_logsTableNewFields: Xr,
4817
+ m9_passwordTableNewField: tn,
4818
+ n01_codesTable: nn,
4819
+ n11_universalLoginSession: ln,
4820
+ n12_userFields: un,
4821
+ n13_userEmailIndex: hn,
4822
+ n14_profileDataField: gn,
4823
+ n15_userEmailIndex: vn,
4824
+ n16_userLocale: bn,
4825
+ n17_signingKeys: Sn,
4826
+ n18_logsFields: $n,
4827
+ n19_connectionsUserinfo: Pn,
4828
+ n20_missingFields: An,
4829
+ n21_sessionDeletedAt: Jn,
4830
+ n22_dropLogsFields: Rn,
4831
+ n23_dropUsersFields: Bn,
4832
+ n24_logsIndexes: Wn,
4833
+ n25_logDescMaxLength: Hn,
4834
+ n26_logsTableExtraFields: Zn,
4835
+ n27_usersTableNameIndex: ao,
4836
+ n28_usersEmailConstrain: oo,
4837
+ n29_increaseOtpStateLength: lo,
4838
+ n30_increaseTicketStateLength: mo,
4839
+ n31_branding: fo,
4840
+ n32_indexesAndNotNull: wo,
4841
+ n33_vendorIdInUniversalLoginSession: No,
4842
+ n34_auth0ClientInUniversalLoginSession: xo,
4843
+ n35_increaseUniversalSessionStateLength: Oo,
4844
+ n36_authenticationCodes: Io,
4845
+ n37_disableSignUps: jo,
4846
+ n38_otpIpAddress: Mo,
4847
+ n39_increaseUserAgentLength: Eo,
4848
+ n40_userId: Ko,
4849
+ n41_hooks: qo,
4850
+ n42_userIdIndexes: Vo,
4851
+ n43_userIdIndexes: Yo,
4852
+ n44_codes: es,
4853
+ n45_hookProperties: rs,
4854
+ n46_loginAuth0Client: ss,
4855
+ n47_loginAuth0Client: cs,
4856
+ n48_saml: ms,
4857
+ n49_removeFields: fs,
4858
+ n50_authParamsNonce: ws,
4859
+ n51_connectionid: Ns,
4860
+ n52_cert: xs,
4861
+ n53_codes_primary_key: Os,
4862
+ n54_cleanup_tables: Is,
4863
+ n55_logs_index: js,
4864
+ n56_application_fields: Ms,
4865
+ n57_prompt_settings: Es,
4866
+ n58_connection_client_id: Ks,
4867
+ n59_connection_options: qs,
4868
+ n60_users_metadata: Vs,
4869
+ n61_userLocales: Ys,
4870
+ n62_prompt: ei,
4871
+ n63_connection_cleanup: ri,
4872
+ n64_act_as: si,
4873
+ n65_code_verifier: ci,
4874
+ n66_email_providers: mi,
4875
+ n67_drop_tickets: fi,
4876
+ n68_login_useragents: wi,
4877
+ n70_refresh_tokens: Ni,
4878
+ n71_session_new_fields: xi,
4879
+ n72_session_primary_key: Oi,
4880
+ n73_drop_sessions: Ii,
4881
+ n74_custom_domains: ji,
4882
+ n75_organizations: Mi,
4883
+ n76_authorization_url_length: Ei,
4884
+ n77_drop_sessions: Ki,
4885
+ n78_login_sessions: qi,
4886
+ n79_drop_sessions_2: Vi,
4887
+ n80_recreate_custom_domains: Yi,
4888
+ n81_phone: el,
4889
+ n82_forms: rl,
4890
+ n83_addFormsIdToHooks: sl,
4891
+ n84_login_completed: cl,
4892
+ n85_add_login_session_id_to_sessions: ml,
4893
+ n86_index_sessions_login_session_id: fl,
4894
+ n87_code_challenge: wl,
4895
+ n88_add_redirect_uri_to_codes: Nl,
4896
+ n89_add_nonce_and_state_to_codes: xl,
4897
+ n90_themes: Ol,
4898
+ n91_resource_servers_rules_permissions: Il,
4899
+ n92_role_permissions: jl,
4900
+ n93_add_permissions_to_roles: Ml,
4901
+ n94_keys_connection_and_extend_columns: El,
4902
+ n95_create_organizations_table: Kl
4807
4903
  };
4808
- async function Rl(t, e = !1) {
4904
+ async function Wl(t, e = !1) {
4809
4905
  e && console.log("migrating...");
4810
- const a = new Je(Le), r = new be({
4906
+ const a = new Je(Ee), r = new be({
4811
4907
  db: t,
4812
4908
  provider: a
4813
4909
  }), { error: n, results: o } = await r.migrateToLatest();
@@ -4818,9 +4914,9 @@ async function Rl(t, e = !1) {
4818
4914
  }), n)
4819
4915
  throw console.error("failed to migrate"), console.error(n), n;
4820
4916
  }
4821
- async function Kl(t) {
4917
+ async function Vl(t) {
4822
4918
  console.log("migrating...");
4823
- const e = new Je(Le), a = new be({
4919
+ const e = new Je(Ee), a = new be({
4824
4920
  db: t,
4825
4921
  provider: e
4826
4922
  }), { error: r, results: n } = await a.migrateDown();
@@ -4829,14 +4925,14 @@ async function Kl(t) {
4829
4925
  }), r)
4830
4926
  throw console.error("failed to migrate"), console.error(r), r;
4831
4927
  }
4832
- function Ul(t) {
4928
+ function Gl(t) {
4833
4929
  return {
4834
4930
  applications: jt(t),
4835
4931
  branding: ea(t),
4836
4932
  cleanup: Ia(t),
4837
- clients: Et(t),
4933
+ clients: Lt(t),
4838
4934
  codes: Ot(t),
4839
- connections: Lt(t),
4935
+ connections: Et(t),
4840
4936
  emailProviders: ba(t),
4841
4937
  customDomains: Yt(t),
4842
4938
  forms: Ma(t),
@@ -4851,16 +4947,17 @@ function Ul(t) {
4851
4947
  rolePermissions: Xa(t),
4852
4948
  userPermissions: ar(t),
4853
4949
  userRoles: sr(t),
4854
- roles: Wa(t),
4950
+ roles: Va(t),
4855
4951
  sessions: gt(t),
4856
4952
  tenants: st(t),
4857
4953
  themes: ua(t),
4858
4954
  users: Ze(t),
4859
- organizations: mr(t)
4955
+ organizations: mr(t),
4956
+ userOrganizations: wr(t)
4860
4957
  };
4861
4958
  }
4862
4959
  export {
4863
- Ul as default,
4864
- Kl as migrateDown,
4865
- Rl as migrateToLatest
4960
+ Gl as default,
4961
+ Vl as migrateDown,
4962
+ Wl as migrateToLatest
4866
4963
  };