@authhero/kysely-adapter 2.1.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,17 +2,17 @@ var Ee = Object.defineProperty;
2
2
  var de = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var ze = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var j = (t, e, a) => ze(t, typeof e != "symbol" ? e + "" : e, a), U = (t, e, a) => e.has(t) || de("Cannot " + a);
7
- var c = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), w = (t, e, a) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (U(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
5
+ var ze = (t, e, r) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
6
+ var j = (t, e, r) => ze(t, typeof e != "symbol" ? e + "" : e, r), U = (t, e, r) => e.has(t) || de("Cannot " + r);
7
+ var c = (t, e, r) => (U(t, e, "read from private field"), r ? r.call(t) : e.get(t)), w = (t, e, r) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), M = (t, e, r, a) => (U(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), u = (t, e, r) => (U(t, e, "access private method"), r);
8
8
  import { parseUserId as Y, codeSchema as Je, connectionSchema as Re, loginSchema as Ue, promptSettingSchema as Ke } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var V = class extends Error {
11
- constructor(e = 500, a) {
12
- super(a == null ? void 0 : a.message, { cause: a == null ? void 0 : a.cause });
11
+ constructor(e = 500, r) {
12
+ super(r == null ? void 0 : r.message, { cause: r == null ? void 0 : r.cause });
13
13
  j(this, "res");
14
14
  j(this, "status");
15
- this.res = a == null ? void 0 : a.res, this.status = e;
15
+ this.res = r == null ? void 0 : r.res, this.status = e;
16
16
  }
17
17
  getResponse() {
18
18
  return this.res ? new Response(this.res.body, {
@@ -24,17 +24,17 @@ var V = class extends Error {
24
24
  }
25
25
  };
26
26
  function Be(t) {
27
- return async (e, a) => {
28
- const { identities: r, ...o } = a, n = {
27
+ return async (e, r) => {
28
+ const { identities: a, ...o } = r, n = {
29
29
  ...o,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
33
33
  tenant_id: e,
34
- email_verified: a.email_verified ? 1 : 0,
35
- is_social: a.is_social ? 1 : 0,
36
- app_metadata: JSON.stringify(a.app_metadata),
37
- user_metadata: JSON.stringify(a.user_metadata)
34
+ email_verified: r.email_verified ? 1 : 0,
35
+ is_social: r.is_social ? 1 : 0,
36
+ app_metadata: JSON.stringify(r.app_metadata),
37
+ user_metadata: JSON.stringify(r.user_metadata)
38
38
  };
39
39
  try {
40
40
  await t.insertInto("users").values(n).execute();
@@ -52,16 +52,16 @@ function Be(t) {
52
52
  }
53
53
  function f(t) {
54
54
  const e = { ...t };
55
- for (const a in e)
56
- e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(f) : e[a] = f(e[a]));
55
+ for (const r in e)
56
+ e[r] === null ? delete e[r] : typeof e[r] == "object" && (Array.isArray(e[r]) ? e[r] = e[r].map(f) : e[r] = f(e[r]));
57
57
  return e;
58
58
  }
59
59
  function _e(t) {
60
60
  let e = {};
61
61
  try {
62
62
  e = JSON.parse(t.profileData || "{}");
63
- } catch (a) {
64
- console.error("Error parsing profileData", a);
63
+ } catch (r) {
64
+ console.error("Error parsing profileData", r);
65
65
  }
66
66
  return {
67
67
  connection: t.connection,
@@ -76,26 +76,26 @@ function _e(t) {
76
76
  };
77
77
  }
78
78
  function Qe(t) {
79
- return async (e, a) => {
80
- const [r, o] = await Promise.all([
81
- t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
82
- t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
79
+ return async (e, r) => {
80
+ const [a, o] = await Promise.all([
81
+ t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", r).selectAll().executeTakeFirst(),
82
+ t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", r).selectAll().execute()
83
83
  ]);
84
- if (!r)
84
+ if (!a)
85
85
  return null;
86
- const { tenant_id: n, ...s } = r, l = {
86
+ const { tenant_id: n, ...s } = a, l = {
87
87
  ...s,
88
- email: r.email || "",
89
- email_verified: r.email_verified === 1,
90
- is_social: r.is_social === 1,
91
- app_metadata: JSON.parse(r.app_metadata),
92
- user_metadata: JSON.parse(r.user_metadata),
88
+ email: a.email || "",
89
+ email_verified: a.email_verified === 1,
90
+ is_social: a.is_social === 1,
91
+ app_metadata: JSON.parse(a.app_metadata),
92
+ user_metadata: JSON.parse(a.user_metadata),
93
93
  identities: [
94
94
  {
95
- connection: r.connection,
96
- provider: r.provider,
97
- user_id: Y(r.user_id).id,
98
- isSocial: !!r.is_social
95
+ connection: a.connection,
96
+ provider: a.provider,
97
+ user_id: Y(a.user_id).id,
98
+ isSocial: !!a.is_social
99
99
  },
100
100
  ...o.map(_e)
101
101
  ]
@@ -103,8 +103,8 @@ function Qe(t) {
103
103
  return f(l);
104
104
  };
105
105
  }
106
- function O(t, e, a, r) {
107
- return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
106
+ function T(t, e, r, a) {
107
+ return r.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
108
  let s = n.startsWith("-"), l, d, g, m;
109
109
  return n.startsWith("-_exists_:") ? (l = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (l = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [l, d] = s ? n.substring(1).split(":") : n.split(":"), g = !1, d.startsWith(">=") ? (m = ">=", d = d.substring(2)) : d.startsWith(">") ? (m = ">", d = d.substring(1)) : d.startsWith("<=") ? (m = "<=", d = d.substring(2)) : d.startsWith("<") ? (m = "<", d = d.substring(1)) : m = "=") : (l = null, d = n, g = !1), { key: l, value: d, isNegation: s, isExistsQuery: g, operator: m };
110
110
  }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: d, operator: g }) => {
@@ -134,29 +134,29 @@ function O(t, e, a, r) {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
136
136
  (y) => y.or(
137
- r.map((C) => y(m(C), "like", `%${s}%`))
137
+ a.map((x) => y(m(x), "like", `%${s}%`))
138
138
  )
139
139
  );
140
140
  }
141
141
  }), e;
142
142
  }
143
- function x(t) {
143
+ function C(t) {
144
144
  return typeof t == "string" ? parseInt(t, 10) : typeof t == "bigint" ? Number(t) : t;
145
145
  }
146
146
  function Ve(t) {
147
- return async (e, a = {
147
+ return async (e, r = {
148
148
  page: 0,
149
149
  per_page: 50,
150
150
  include_totals: !1
151
151
  }) => {
152
- let r = t.selectFrom("users").where("users.tenant_id", "=", e);
153
- if (a.q && (r = O(t, r, a.q, ["email", "name"])), a.sort && a.sort.sort_by) {
152
+ let a = t.selectFrom("users").where("users.tenant_id", "=", e);
153
+ if (r.q && (a = T(t, a, r.q, ["email", "name"])), r.sort && r.sort.sort_by) {
154
154
  const { ref: m } = t.dynamic;
155
- r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
155
+ a = a.orderBy(m(r.sort.sort_by), r.sort.sort_order);
156
156
  }
157
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
157
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
158
158
  const y = l.filter(
159
- (C) => C.linked_to === m.user_id
159
+ (x) => x.linked_to === m.user_id
160
160
  );
161
161
  return f({
162
162
  ...m,
@@ -174,36 +174,36 @@ function Ve(t) {
174
174
  ...y.map(_e)
175
175
  ]
176
176
  });
177
- }), { count: g } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
177
+ }), { count: g } = await a.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
178
178
  return {
179
179
  users: d,
180
- start: a.page * a.per_page,
181
- limit: a.per_page,
182
- length: x(g)
180
+ start: r.page * r.per_page,
181
+ limit: r.per_page,
182
+ length: C(g)
183
183
  };
184
184
  };
185
185
  }
186
186
  function We(t) {
187
- return async (e, a) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1);
187
+ return async (e, r) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", r).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1);
188
188
  }
189
189
  function qe(t) {
190
190
  if (t.email_verified !== void 0)
191
191
  return t.email_verified ? 1 : 0;
192
192
  }
193
193
  function Ge(t) {
194
- return async (e, a, r) => {
194
+ return async (e, r, a) => {
195
195
  const o = {
196
- ...r,
197
- email_verified: qe(r),
196
+ ...a,
197
+ email_verified: qe(a),
198
198
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
199
199
  };
200
- return r.app_metadata && (o.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (o.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
200
+ return a.app_metadata && (o.app_metadata = JSON.stringify(a.app_metadata)), a.user_metadata && (o.user_metadata = JSON.stringify(a.user_metadata)), (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1;
201
201
  };
202
202
  }
203
203
  function He(t) {
204
- return async (e, a, r, o) => {
204
+ return async (e, r, a, o) => {
205
205
  const n = { linked_to: null };
206
- return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
206
+ return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${a}|${o}`).where("users.linked_to", "=", `${r}`).execute()).length === 1;
207
207
  };
208
208
  }
209
209
  function Xe(t) {
@@ -219,26 +219,26 @@ function Xe(t) {
219
219
  }
220
220
  const Ye = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
221
221
  let k = (t = 21) => {
222
- let e = "", a = crypto.getRandomValues(new Uint8Array(t));
222
+ let e = "", r = crypto.getRandomValues(new Uint8Array(t));
223
223
  for (; t--; )
224
- e += Ye[a[t] & 63];
224
+ e += Ye[r[t] & 63];
225
225
  return e;
226
226
  };
227
227
  function Ze(t) {
228
228
  return async (e) => {
229
- const a = {
229
+ const r = {
230
230
  id: e.id || k(),
231
231
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
232
232
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
233
233
  ...e
234
234
  };
235
- return await t.insertInto("tenants").values(a).execute(), a;
235
+ return await t.insertInto("tenants").values(r).execute(), r;
236
236
  };
237
237
  }
238
238
  function et(t) {
239
239
  return async (e) => {
240
- const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
- return a ? f(a) : null;
240
+ const r = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
+ return r ? f(r) : null;
242
242
  };
243
243
  }
244
244
  function tt(t) {
@@ -247,18 +247,18 @@ function tt(t) {
247
247
  per_page: 50,
248
248
  include_totals: !1
249
249
  }) => {
250
- let a = t.selectFrom("tenants");
250
+ let r = t.selectFrom("tenants");
251
251
  if (e.sort && e.sort.sort_by) {
252
252
  const { ref: l } = t.dynamic;
253
- a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
253
+ r = r.orderBy(l(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
- e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
- const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
255
+ e.q && (r = r.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
+ const o = await r.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
257
257
  if (!e.include_totals)
258
258
  return {
259
259
  tenants: o
260
260
  };
261
- const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = x(n);
261
+ const { count: n } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = C(n);
262
262
  return {
263
263
  tenants: o.map(f),
264
264
  start: (e.page - 1) * e.per_page,
@@ -267,17 +267,17 @@ function tt(t) {
267
267
  };
268
268
  };
269
269
  }
270
- function at(t) {
271
- return async (e, a) => {
272
- const r = {
273
- ...a,
270
+ function rt(t) {
271
+ return async (e, r) => {
272
+ const a = {
273
+ ...r,
274
274
  id: e,
275
275
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
276
276
  };
277
- await t.updateTable("tenants").set(r).where("id", "=", e).execute();
277
+ await t.updateTable("tenants").set(a).where("id", "=", e).execute();
278
278
  };
279
279
  }
280
- function rt(t) {
280
+ function at(t) {
281
281
  return async (e) => (await t.deleteFrom("tenants").where("tenants.id", "=", e).execute()).length === 1;
282
282
  }
283
283
  function nt(t) {
@@ -285,8 +285,8 @@ function nt(t) {
285
285
  create: Ze(t),
286
286
  get: et(t),
287
287
  list: tt(t),
288
- update: at(t),
289
- remove: rt(t)
288
+ update: rt(t),
289
+ remove: at(t)
290
290
  };
291
291
  }
292
292
  function ue(t) {
@@ -294,23 +294,23 @@ function ue(t) {
294
294
  }
295
295
  const ot = 1024;
296
296
  function st(t) {
297
- return async (e, a) => {
297
+ return async (e, r) => {
298
298
  var o, n, s;
299
- const r = {
299
+ const a = {
300
300
  id: k(),
301
- ...a,
302
- user_agent: a.user_agent.slice(0, ot)
301
+ ...r,
302
+ user_agent: r.user_agent.slice(0, ot)
303
303
  };
304
304
  return await t.insertInto("logs").values({
305
- ...r,
305
+ ...a,
306
306
  // Truncate long strings to avoid database errors
307
- description: (o = r.description) == null ? void 0 : o.substring(0, 256),
308
- isMobile: a.isMobile ? 1 : 0,
307
+ description: (o = a.description) == null ? void 0 : o.substring(0, 256),
308
+ isMobile: r.isMobile ? 1 : 0,
309
309
  tenant_id: e,
310
- scope: (n = a.scope) == null ? void 0 : n.join(","),
311
- auth0_client: ue(a.auth0_client),
312
- details: (s = ue(a.details)) == null ? void 0 : s.substring(0, 8192)
313
- }).execute(), r;
310
+ scope: (n = r.scope) == null ? void 0 : n.join(","),
311
+ auth0_client: ue(r.auth0_client),
312
+ details: (s = ue(r.details)) == null ? void 0 : s.substring(0, 8192)
313
+ }).execute(), a;
314
314
  };
315
315
  }
316
316
  function me(t) {
@@ -336,35 +336,35 @@ function pe(t) {
336
336
  };
337
337
  }
338
338
  function it(t) {
339
- return async (e, a = {
339
+ return async (e, r = {
340
340
  page: 0,
341
341
  per_page: 50,
342
342
  include_totals: !1
343
343
  }) => {
344
- let r = t.selectFrom("logs").where("logs.tenant_id", "=", e);
345
- a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
346
- let o = r;
347
- if (a.sort && a.sort.sort_by) {
344
+ let a = t.selectFrom("logs").where("logs.tenant_id", "=", e);
345
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
346
+ let o = a;
347
+ if (r.sort && r.sort.sort_by) {
348
348
  const { ref: l } = t.dynamic;
349
349
  o = o.orderBy(
350
- l(a.sort.sort_by),
351
- a.sort.sort_order
350
+ l(r.sort.sort_by),
351
+ r.sort.sort_order
352
352
  );
353
353
  }
354
- o = o.offset(a.page * a.per_page).limit(a.per_page);
355
- const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
354
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
355
+ const n = await o.selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
356
356
  return {
357
357
  logs: n.map(pe),
358
- start: a.page * a.per_page,
359
- limit: a.per_page,
360
- length: x(s)
358
+ start: r.page * r.per_page,
359
+ limit: r.per_page,
360
+ length: C(s)
361
361
  };
362
362
  };
363
363
  }
364
364
  function lt(t) {
365
- return async (e, a) => {
366
- const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
367
- return r ? pe(r) : null;
365
+ return async (e, r) => {
366
+ const a = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", r).selectAll().executeTakeFirst();
367
+ return a ? pe(a) : null;
368
368
  };
369
369
  }
370
370
  function ct(t) {
@@ -375,46 +375,46 @@ function ct(t) {
375
375
  };
376
376
  }
377
377
  function dt(t) {
378
- return async (e, a) => await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.session_id", "=", a).where("sessions.deleted_at", "is", null).selectAll().executeTakeFirst() ?? null;
378
+ return async (e, r) => await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.session_id", "=", r).where("sessions.deleted_at", "is", null).selectAll().executeTakeFirst() ?? null;
379
379
  }
380
380
  function ut(t) {
381
- return async (e, a) => {
382
- const r = {
383
- ...a,
381
+ return async (e, r) => {
382
+ const a = {
383
+ ...r,
384
384
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
385
385
  expires_at: (/* @__PURE__ */ new Date()).toISOString()
386
386
  };
387
- return await t.insertInto("sessions").values({ ...r, tenant_id: e }).execute(), { ...a, ...r };
387
+ return await t.insertInto("sessions").values({ ...a, tenant_id: e }).execute(), { ...r, ...a };
388
388
  };
389
389
  }
390
390
  function mt(t) {
391
- return async (e, a) => !!(await t.updateTable("sessions").set({ deleted_at: (/* @__PURE__ */ new Date()).toISOString() }).where("tenant_id", "=", e).where("sessions.session_id", "=", a).where("sessions.deleted_at", "is", null).execute()).length;
391
+ return async (e, r) => !!(await t.updateTable("sessions").set({ deleted_at: (/* @__PURE__ */ new Date()).toISOString() }).where("tenant_id", "=", e).where("sessions.session_id", "=", r).where("sessions.deleted_at", "is", null).execute()).length;
392
392
  }
393
393
  function ht(t) {
394
- return async (e, a, r) => !!(await t.updateTable("sessions").set(r).where("tenant_id", "=", e).where("sessions.session_id", "=", a).where("sessions.deleted_at", "is", null).execute()).length;
394
+ return async (e, r, a) => !!(await t.updateTable("sessions").set(a).where("tenant_id", "=", e).where("sessions.session_id", "=", r).where("sessions.deleted_at", "is", null).execute()).length;
395
395
  }
396
396
  function ft(t) {
397
- return async (e, a = {
397
+ return async (e, r = {
398
398
  page: 0,
399
399
  per_page: 50,
400
400
  include_totals: !1
401
401
  }) => {
402
- let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
403
- a.q && (r = O(t, r, a.q, ["user_id", "session_id"]));
404
- let o = r;
405
- if (a.sort && a.sort.sort_by) {
402
+ let a = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
403
+ r.q && (a = T(t, a, r.q, ["user_id", "session_id"]));
404
+ let o = a;
405
+ if (r.sort && r.sort.sort_by) {
406
406
  const { ref: d } = t.dynamic;
407
407
  o = o.orderBy(
408
- d(a.sort.sort_by),
409
- a.sort.sort_order
408
+ d(r.sort.sort_by),
409
+ r.sort.sort_order
410
410
  );
411
411
  }
412
- o = o.offset(a.page * a.per_page).limit(a.per_page);
413
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
412
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
413
+ const n = await o.selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = C(s);
414
414
  return {
415
415
  sessions: n,
416
- start: a.page * a.per_page,
417
- limit: a.per_page,
416
+ start: r.page * r.per_page,
417
+ limit: r.per_page,
418
418
  length: l
419
419
  };
420
420
  };
@@ -429,29 +429,29 @@ function _t(t) {
429
429
  };
430
430
  }
431
431
  function pt(t) {
432
- return async (e, a) => {
433
- const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = r;
432
+ return async (e, r) => {
433
+ const a = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", r).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = a;
434
434
  return n;
435
435
  };
436
436
  }
437
437
  function gt(t) {
438
- return async (e, a) => {
439
- const r = {
440
- ...a,
438
+ return async (e, r) => {
439
+ const a = {
440
+ ...r,
441
441
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
442
442
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
443
443
  };
444
444
  return await t.insertInto("passwords").values({
445
- ...r,
445
+ ...a,
446
446
  tenant_id: e
447
- }).execute(), r;
447
+ }).execute(), a;
448
448
  };
449
449
  }
450
450
  function wt(t) {
451
- return async (e, a) => (await t.updateTable("passwords").set({
452
- password: a.password,
451
+ return async (e, r) => (await t.updateTable("passwords").set({
452
+ password: r.password,
453
453
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
454
- }).where("tenant_id", "=", e).where("user_id", "=", a.user_id).execute()).length === 1;
454
+ }).where("tenant_id", "=", e).where("user_id", "=", r.user_id).execute()).length === 1;
455
455
  }
456
456
  function yt(t) {
457
457
  return {
@@ -461,50 +461,50 @@ function yt(t) {
461
461
  };
462
462
  }
463
463
  function Nt(t) {
464
- return async (e, a = {
464
+ return async (e, r = {
465
465
  page: 0,
466
466
  per_page: 50,
467
467
  include_totals: !1
468
468
  }) => {
469
- let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
470
- a.q && (r = O(t, r, a.q, ["code", "login_id"]));
471
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
469
+ let a = t.selectFrom("codes").where("codes.tenant_id", "=", e);
470
+ r.q && (a = T(t, a, r.q, ["code", "login_id"]));
471
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
472
472
  return {
473
473
  codes: n.map((d) => {
474
474
  const { tenant_id: g, ...m } = d;
475
475
  return Je.parse(f(m));
476
476
  }),
477
- start: a.page * a.per_page,
478
- limit: a.per_page,
479
- length: x(s)
477
+ start: r.page * r.per_page,
478
+ limit: r.per_page,
479
+ length: C(s)
480
480
  };
481
481
  };
482
482
  }
483
483
  function vt(t) {
484
- return async (e, a) => {
485
- const r = {
486
- ...a,
484
+ return async (e, r) => {
485
+ const a = {
486
+ ...r,
487
487
  created_at: (/* @__PURE__ */ new Date()).toISOString()
488
488
  };
489
489
  return await t.insertInto("codes").values({
490
- ...r,
490
+ ...a,
491
491
  tenant_id: e
492
- }).execute(), r;
492
+ }).execute(), a;
493
493
  };
494
494
  }
495
495
  function bt(t) {
496
- return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
496
+ return async (e, r) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
497
497
  }
498
498
  function Ct(t) {
499
- return async (e, a, r) => {
500
- let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
499
+ return async (e, r, a) => {
500
+ let o = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
501
501
  e.length && (o = o.where("codes.tenant_id", "=", e));
502
502
  const n = await o.selectAll().executeTakeFirst();
503
503
  return n ? f(n) : null;
504
504
  };
505
505
  }
506
506
  function xt(t) {
507
- return async (e, a) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numUpdatedRows > 0;
507
+ return async (e, r) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numUpdatedRows > 0;
508
508
  }
509
509
  function Tt(t) {
510
510
  return {
@@ -516,23 +516,23 @@ function Tt(t) {
516
516
  };
517
517
  }
518
518
  function St(t) {
519
- return async (e, a) => {
520
- const r = {
519
+ return async (e, r) => {
520
+ const a = {
521
521
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
522
522
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
523
- ...a
524
- }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
523
+ ...r
524
+ }, o = JSON.stringify(r.allowed_origins), n = JSON.stringify(r.callbacks), s = JSON.stringify(r.web_origins), l = JSON.stringify(r.allowed_logout_urls), d = JSON.stringify(r.allowed_clients);
525
525
  return await t.insertInto("applications").values({
526
- ...r,
526
+ ...a,
527
527
  tenant_id: e,
528
- disable_sign_ups: a.disable_sign_ups ? 1 : 0,
529
- addons: a.addons ? JSON.stringify(a.addons) : "{}",
528
+ disable_sign_ups: r.disable_sign_ups ? 1 : 0,
529
+ addons: r.addons ? JSON.stringify(r.addons) : "{}",
530
530
  callbacks: n,
531
531
  allowed_origins: o,
532
532
  web_origins: s,
533
533
  allowed_logout_urls: l,
534
534
  allowed_clients: d
535
- }).execute(), r;
535
+ }).execute(), a;
536
536
  };
537
537
  }
538
538
  function Ot(t) {
@@ -550,107 +550,107 @@ function Ot(t) {
550
550
  });
551
551
  }
552
552
  function kt(t) {
553
- return async (e, a) => {
554
- const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
555
- return r ? f({
556
- ...r,
557
- disable_sign_ups: !!r.disable_sign_ups,
558
- addons: JSON.parse(r.addons),
559
- callbacks: JSON.parse(r.callbacks),
560
- allowed_origins: JSON.parse(r.allowed_origins),
561
- web_origins: JSON.parse(r.web_origins),
562
- allowed_logout_urls: JSON.parse(r.allowed_logout_urls)
553
+ return async (e, r) => {
554
+ const a = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).selectAll().executeTakeFirst();
555
+ return a ? f({
556
+ ...a,
557
+ disable_sign_ups: !!a.disable_sign_ups,
558
+ addons: JSON.parse(a.addons),
559
+ callbacks: JSON.parse(a.callbacks),
560
+ allowed_origins: JSON.parse(a.allowed_origins),
561
+ web_origins: JSON.parse(a.web_origins),
562
+ allowed_logout_urls: JSON.parse(a.allowed_logout_urls)
563
563
  }) : null;
564
564
  };
565
565
  }
566
566
  function $t(t) {
567
- return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
567
+ return async (e, r) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
568
568
  }
569
- function Dt(t) {
570
- return async (e, a, r) => {
569
+ function It(t) {
570
+ return async (e, r, a) => {
571
571
  const o = {
572
- ...r,
572
+ ...a,
573
573
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
574
- allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
575
- callbacks: r.callbacks ? JSON.stringify(r.callbacks) : void 0,
576
- web_origins: r.web_origins ? JSON.stringify(r.web_origins) : void 0,
577
- allowed_logout_urls: r.allowed_logout_urls ? JSON.stringify(r.allowed_logout_urls) : void 0,
578
- allowed_clients: r.allowed_clients ? JSON.stringify(r.allowed_clients) : void 0,
579
- addons: r.addons ? JSON.stringify(r.addons) : "{}",
580
- disable_sign_ups: r.disable_sign_ups ? 1 : 0
574
+ allowed_origins: a.allowed_origins ? JSON.stringify(a.allowed_origins) : void 0,
575
+ callbacks: a.callbacks ? JSON.stringify(a.callbacks) : void 0,
576
+ web_origins: a.web_origins ? JSON.stringify(a.web_origins) : void 0,
577
+ allowed_logout_urls: a.allowed_logout_urls ? JSON.stringify(a.allowed_logout_urls) : void 0,
578
+ allowed_clients: a.allowed_clients ? JSON.stringify(a.allowed_clients) : void 0,
579
+ addons: a.addons ? JSON.stringify(a.addons) : "{}",
580
+ disable_sign_ups: a.disable_sign_ups ? 1 : 0
581
581
  };
582
- return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
582
+ return await t.updateTable("applications").set(o).where("applications.id", "=", r).where("applications.tenant_id", "=", e).execute(), !0;
583
583
  };
584
584
  }
585
- function It(t) {
585
+ function Dt(t) {
586
586
  return {
587
587
  create: St(t),
588
588
  list: Ot(t),
589
589
  get: kt(t),
590
590
  remove: $t(t),
591
- update: Dt(t)
591
+ update: It(t)
592
592
  };
593
593
  }
594
594
  function Pt(t) {
595
- return async (e, a) => {
596
- const r = {
595
+ return async (e, r) => {
596
+ const a = {
597
597
  id: k(),
598
- ...a,
598
+ ...r,
599
599
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
600
600
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
601
601
  };
602
602
  return await t.insertInto("connections").values({
603
- ...r,
603
+ ...a,
604
604
  // The connection options will have many different properties depending on the strategy
605
- options: JSON.stringify(r.options || {}),
605
+ options: JSON.stringify(a.options || {}),
606
606
  tenant_id: e
607
- }).execute(), r;
607
+ }).execute(), a;
608
608
  };
609
609
  }
610
610
  function jt(t) {
611
- return async (e, a = {
611
+ return async (e, r = {
612
612
  page: 0,
613
613
  per_page: 50,
614
614
  include_totals: !1
615
615
  }) => {
616
- let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
617
- a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
618
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
616
+ let a = t.selectFrom("connections").where("connections.tenant_id", "=", e);
617
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
618
+ const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map(
619
619
  (d) => f({
620
620
  ...d,
621
621
  options: JSON.parse(d.options)
622
622
  })
623
- ), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
623
+ ), { count: l } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
624
624
  return {
625
625
  connections: s,
626
- start: a.page * a.per_page,
627
- limit: a.per_page,
628
- length: x(l)
626
+ start: r.page * r.per_page,
627
+ limit: r.per_page,
628
+ length: C(l)
629
629
  };
630
630
  };
631
631
  }
632
632
  function Mt(t) {
633
- return async (e, a) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
633
+ return async (e, r) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
634
634
  }
635
635
  function At(t) {
636
- return async (e, a) => {
637
- const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
638
- return r ? f({
639
- ...r,
640
- options: JSON.parse(r.options)
636
+ return async (e, r) => {
637
+ const a = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).selectAll().executeTakeFirst();
638
+ return a ? f({
639
+ ...a,
640
+ options: JSON.parse(a.options)
641
641
  }) : null;
642
642
  };
643
643
  }
644
644
  function Ft(t) {
645
- return async (e, a, r) => {
645
+ return async (e, r, a) => {
646
646
  const o = {
647
- ...r,
647
+ ...a,
648
648
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
649
649
  };
650
650
  return await t.updateTable("connections").set({
651
651
  ...o,
652
652
  options: o.options ? JSON.stringify(o.options) : void 0
653
- }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
653
+ }).where("connections.id", "=", r).where("connections.tenant_id", "=", e).execute(), !0;
654
654
  };
655
655
  }
656
656
  function Lt(t) {
@@ -665,15 +665,15 @@ function Lt(t) {
665
665
  function Et(t) {
666
666
  return {
667
667
  get: async (e) => {
668
- const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
669
- if (!a)
670
- return null;
671
- const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
668
+ const r = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
672
669
  if (!r)
670
+ return null;
671
+ const a = await t.selectFrom("tenants").selectAll().where("id", "=", r.tenant_id).executeTakeFirst();
672
+ if (!a)
673
673
  throw new V(404, { message: "Tenant not found" });
674
- const o = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute(), n = await t.selectFrom("domains").where("tenant_id", "=", a.tenant_id).selectAll().execute();
674
+ const o = await t.selectFrom("connections").where("tenant_id", "=", r.tenant_id).selectAll().execute(), n = await t.selectFrom("domains").where("tenant_id", "=", r.tenant_id).selectAll().execute();
675
675
  return {
676
- ...a,
676
+ ...r,
677
677
  connections: o.map(
678
678
  (l) => Re.parse(
679
679
  f({
@@ -683,24 +683,24 @@ function Et(t) {
683
683
  )
684
684
  ),
685
685
  domains: n,
686
- addons: a.addons ? JSON.parse(a.addons) : {},
687
- callbacks: a.callbacks ? JSON.parse(a.callbacks) : [],
688
- allowed_origins: a.allowed_origins ? JSON.parse(a.allowed_origins) : [],
689
- web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
690
- allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
691
- allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
692
- tenant: f(r),
686
+ addons: r.addons ? JSON.parse(r.addons) : {},
687
+ callbacks: r.callbacks ? JSON.parse(r.callbacks) : [],
688
+ allowed_origins: r.allowed_origins ? JSON.parse(r.allowed_origins) : [],
689
+ web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
690
+ allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
691
+ allowed_clients: r.allowed_clients ? JSON.parse(r.allowed_clients) : [],
692
+ tenant: f(a),
693
693
  // this is really an integer in the database
694
- disable_sign_ups: !!a.disable_sign_ups
694
+ disable_sign_ups: !!r.disable_sign_ups
695
695
  };
696
696
  }
697
697
  };
698
698
  }
699
699
  function zt(t) {
700
700
  return async () => await t.selectFrom("keys").where(
701
- (a) => a.or([
702
- a("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
703
- a("revoked_at", "is", null)
701
+ (r) => r.or([
702
+ r("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
703
+ r("revoked_at", "is", null)
704
704
  ])
705
705
  ).selectAll().execute();
706
706
  }
@@ -710,7 +710,7 @@ function Jt(t) {
710
710
  };
711
711
  }
712
712
  function Rt(t) {
713
- return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
713
+ return async (e, r) => !!(await t.updateTable("keys").set(r).where("kid", "=", e).execute()).length;
714
714
  }
715
715
  function Ut(t) {
716
716
  return {
@@ -720,27 +720,27 @@ function Ut(t) {
720
720
  };
721
721
  }
722
722
  function Kt(t) {
723
- return async (e, a) => {
724
- const r = {
723
+ return async (e, r) => {
724
+ const a = {
725
725
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
726
726
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
727
727
  tenant_id: e,
728
728
  id: k(),
729
- ...a
729
+ ...r
730
730
  };
731
- return await t.insertInto("domains").values(r).execute(), r;
731
+ return await t.insertInto("domains").values(a).execute(), a;
732
732
  };
733
733
  }
734
734
  function Bt(t) {
735
- return async (e, a) => {
736
- let r = t.selectFrom("domains").where("domains.tenant_id", "=", e);
737
- a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
738
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
735
+ return async (e, r) => {
736
+ let a = t.selectFrom("domains").where("domains.tenant_id", "=", e);
737
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
738
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
739
739
  return {
740
740
  domains: n,
741
- start: a.page * a.per_page,
742
- limit: a.per_page,
743
- length: x(s)
741
+ start: r.page * r.per_page,
742
+ limit: r.per_page,
743
+ length: C(s)
744
744
  };
745
745
  };
746
746
  }
@@ -752,11 +752,11 @@ function Qt(t) {
752
752
  }
753
753
  function Vt(t) {
754
754
  return async (e) => {
755
- const [a] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
756
- if (!a)
755
+ const [r] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
756
+ if (!r)
757
757
  return null;
758
758
  const {
759
- tenant_id: r,
759
+ tenant_id: a,
760
760
  colors_primary: o,
761
761
  colors_page_background_type: n,
762
762
  colors_page_background_start: s,
@@ -764,7 +764,7 @@ function Vt(t) {
764
764
  colors_page_background_angle_dev: d,
765
765
  font_url: g,
766
766
  ...m
767
- } = a;
767
+ } = r;
768
768
  return f({
769
769
  ...m,
770
770
  colors: {
@@ -781,29 +781,29 @@ function Vt(t) {
781
781
  };
782
782
  }
783
783
  function Wt(t) {
784
- return async (e, a) => {
785
- var s, l, d, g, m, y, C, Z, ee, te, ae, re, ne, oe, se, ie, le, ce;
786
- const { colors: r, font: o, ...n } = a;
784
+ return async (e, r) => {
785
+ var s, l, d, g, m, y, x, Z, ee, te, re, ae, ne, oe, se, ie, le, ce;
786
+ const { colors: a, font: o, ...n } = r;
787
787
  try {
788
788
  await t.insertInto("branding").values({
789
789
  ...n,
790
- colors_primary: r == null ? void 0 : r.primary,
791
- colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
792
- colors_page_background_start: (g = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
793
- colors_page_background_end: (y = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : y.end,
794
- colors_page_background_angle_dev: (Z = (C = a.colors) == null ? void 0 : C.page_background) == null ? void 0 : Z.angle_deg,
795
- font_url: (ee = a.font) == null ? void 0 : ee.url,
790
+ colors_primary: a == null ? void 0 : a.primary,
791
+ colors_page_background_type: (l = (s = r.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
792
+ colors_page_background_start: (g = (d = r.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
793
+ colors_page_background_end: (y = (m = r.colors) == null ? void 0 : m.page_background) == null ? void 0 : y.end,
794
+ colors_page_background_angle_dev: (Z = (x = r.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
795
+ font_url: (ee = r.font) == null ? void 0 : ee.url,
796
796
  tenant_id: e
797
797
  }).execute();
798
798
  } catch {
799
799
  await t.updateTable("branding").set({
800
800
  ...n,
801
- colors_primary: r == null ? void 0 : r.primary,
802
- colors_page_background_type: (ae = (te = a.colors) == null ? void 0 : te.page_background) == null ? void 0 : ae.type,
803
- colors_page_background_start: (ne = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : ne.start,
804
- colors_page_background_end: (se = (oe = a.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
805
- colors_page_background_angle_dev: (le = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : le.angle_deg,
806
- font_url: (ce = a.font) == null ? void 0 : ce.url
801
+ colors_primary: a == null ? void 0 : a.primary,
802
+ colors_page_background_type: (re = (te = r.colors) == null ? void 0 : te.page_background) == null ? void 0 : re.type,
803
+ colors_page_background_start: (ne = (ae = r.colors) == null ? void 0 : ae.page_background) == null ? void 0 : ne.start,
804
+ colors_page_background_end: (se = (oe = r.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
805
+ colors_page_background_angle_dev: (le = (ie = r.colors) == null ? void 0 : ie.page_background) == null ? void 0 : le.angle_deg,
806
+ font_url: (ce = r.font) == null ? void 0 : ce.url
807
807
  }).where("tenant_id", "=", e).execute();
808
808
  }
809
809
  };
@@ -815,70 +815,70 @@ function qt(t) {
815
815
  };
816
816
  }
817
817
  function Gt(t) {
818
- return async (e, a = {
818
+ return async (e, r = {
819
819
  page: 0,
820
820
  per_page: 50,
821
821
  include_totals: !1
822
822
  }) => {
823
- let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
824
- a.q && (r = O(t, r, a.q, ["url"]));
825
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
823
+ let a = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
824
+ r.q && (a = T(t, a, r.q, ["url"]));
825
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
826
826
  return {
827
827
  hooks: n.map((d) => {
828
- const { tenant_id: g, enabled: m, synchronous: y, ...C } = d;
828
+ const { tenant_id: g, enabled: m, synchronous: y, ...x } = d;
829
829
  return f({
830
- ...C,
830
+ ...x,
831
831
  enabled: !!m,
832
832
  synchronous: !!y
833
833
  });
834
834
  }),
835
- start: a.page * a.per_page,
836
- limit: a.per_page,
837
- length: x(s)
835
+ start: r.page * r.per_page,
836
+ limit: r.per_page,
837
+ length: C(s)
838
838
  };
839
839
  };
840
840
  }
841
841
  function Ht(t) {
842
- return async (e, a) => {
843
- const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
844
- return r ? f({
845
- ...r,
846
- enabled: !!r.enabled,
847
- synchronous: !!r.synchronous
842
+ return async (e, r) => {
843
+ const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).selectAll().executeTakeFirst();
844
+ return a ? f({
845
+ ...a,
846
+ enabled: !!a.enabled,
847
+ synchronous: !!a.synchronous
848
848
  }) : null;
849
849
  };
850
850
  }
851
851
  function Xt(t) {
852
- return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
852
+ return async (e, r) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
853
853
  }
854
854
  function Yt(t) {
855
- return async (e, a) => {
856
- const r = {
855
+ return async (e, r) => {
856
+ const a = {
857
857
  hook_id: k(),
858
- ...a,
858
+ ...r,
859
859
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
860
860
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
861
861
  };
862
862
  return await t.insertInto("hooks").values({
863
- ...r,
863
+ ...a,
864
864
  tenant_id: e,
865
- enabled: a.enabled ? 1 : 0,
866
- synchronous: a.synchronous ? 1 : 0
867
- }).execute(), r;
865
+ enabled: r.enabled ? 1 : 0,
866
+ synchronous: r.synchronous ? 1 : 0
867
+ }).execute(), a;
868
868
  };
869
869
  }
870
870
  function Zt(t) {
871
- return async (e, a, r) => {
871
+ return async (e, r, a) => {
872
872
  const o = {
873
- ...r,
873
+ ...a,
874
874
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
875
- enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
876
- synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
875
+ enabled: a.enabled !== void 0 ? a.enabled ? 1 : 0 : void 0,
876
+ synchronous: a.enabled !== void 0 ? a.synchronous ? 1 : 0 : void 0
877
877
  };
878
- return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
878
+ return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", r).where("hooks.tenant_id", "=", e).execute(), !0;
879
879
  };
880
880
  }
881
- function ea(t) {
881
+ function er(t) {
882
882
  return {
883
883
  create: Yt(t),
884
884
  get: Ht(t),
@@ -887,110 +887,110 @@ function ea(t) {
887
887
  remove: Xt(t)
888
888
  };
889
889
  }
890
- function z(t, e = "", a = {}) {
891
- for (let r in t)
892
- if (Object.prototype.hasOwnProperty.call(t, r)) {
893
- const o = e ? `${e}_${r}` : r;
894
- typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? z(t[r], o, a) : a[o] = t[r];
890
+ function z(t, e = "", r = {}) {
891
+ for (let a in t)
892
+ if (Object.prototype.hasOwnProperty.call(t, a)) {
893
+ const o = e ? `${e}_${a}` : a;
894
+ typeof t[a] == "object" && t[a] !== null && !Array.isArray(t[a]) ? z(t[a], o, r) : r[o] = t[a];
895
895
  }
896
- return a;
896
+ return r;
897
897
  }
898
- function ta(t, e) {
899
- const a = {};
900
- for (const [r, o] of Object.entries(t)) {
898
+ function tr(t, e) {
899
+ const r = {};
900
+ for (const [a, o] of Object.entries(t)) {
901
901
  const n = e.find(
902
- (s) => r.startsWith(`${s}_`)
902
+ (s) => a.startsWith(`${s}_`)
903
903
  );
904
904
  if (!n)
905
- a[r] = o;
905
+ r[a] = o;
906
906
  else {
907
- const s = r.slice(n.length + 1);
908
- a[n] = {
909
- ...a[n],
907
+ const s = a.slice(n.length + 1);
908
+ r[n] = {
909
+ ...r[n],
910
910
  [s]: o
911
911
  };
912
912
  }
913
913
  }
914
- return a;
914
+ return r;
915
915
  }
916
- function aa(t) {
917
- return async (e, a) => {
918
- const r = {
916
+ function rr(t) {
917
+ return async (e, r) => {
918
+ const a = {
919
919
  themeId: k(),
920
- ...a,
920
+ ...r,
921
921
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
922
922
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
923
923
  };
924
- return await t.insertInto("themes").values({ ...z(r), tenant_id: e }).execute(), r;
924
+ return await t.insertInto("themes").values({ ...z(a), tenant_id: e }).execute(), a;
925
925
  };
926
926
  }
927
- function ra(t) {
928
- return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
927
+ function ar(t) {
928
+ return async (e, r) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
929
929
  }
930
- function na(t) {
931
- return async (e, a) => {
932
- const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
933
- return r ? f(r) : null;
930
+ function nr(t) {
931
+ return async (e, r) => {
932
+ const a = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).selectAll().executeTakeFirst();
933
+ return a ? f(a) : null;
934
934
  };
935
935
  }
936
- function oa(t) {
937
- return async (e, a, r) => {
936
+ function or(t) {
937
+ return async (e, r, a) => {
938
938
  const o = z({
939
- ...r,
939
+ ...a,
940
940
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
941
941
  });
942
- return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
942
+ return await t.updateTable("themes").set(o).where("themes.id", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
943
943
  };
944
944
  }
945
- function sa(t) {
945
+ function sr(t) {
946
946
  return {
947
- create: aa(t),
948
- get: na(t),
949
- remove: ra(t),
950
- update: oa(t)
947
+ create: rr(t),
948
+ get: nr(t),
949
+ remove: ar(t),
950
+ update: or(t)
951
951
  };
952
952
  }
953
- function ia(t) {
954
- return async (e, a) => {
955
- const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", r).where("logins.login_id", "=", a).selectAll().executeTakeFirst();
953
+ function ir(t) {
954
+ return async (e, r) => {
955
+ const a = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", a).where("logins.login_id", "=", r).selectAll().executeTakeFirst();
956
956
  return o ? Ue.parse(
957
- ta(f(o), ["authParams"])
957
+ tr(f(o), ["authParams"])
958
958
  ) : null;
959
959
  };
960
960
  }
961
- function la(t) {
962
- return async (e, a) => {
963
- const r = {
961
+ function lr(t) {
962
+ return async (e, r) => {
963
+ const a = {
964
964
  login_id: k(),
965
- ...a,
965
+ ...r,
966
966
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
967
967
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
968
968
  };
969
- return await t.insertInto("logins").values({ ...z(r), tenant_id: e }).execute(), r;
969
+ return await t.insertInto("logins").values({ ...z(a), tenant_id: e }).execute(), a;
970
970
  };
971
971
  }
972
- function ca(t) {
973
- return async (e, a, r) => (await t.updateTable("logins").set(z(r)).where("logins.login_id", "=", a).where("logins.tenant_id", "=", e).execute()).length === 1;
972
+ function cr(t) {
973
+ return async (e, r, a) => (await t.updateTable("logins").set(z(a)).where("logins.login_id", "=", r).where("logins.tenant_id", "=", e).execute()).length === 1;
974
974
  }
975
- function da(t) {
976
- return async (e, a) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", a).execute()).length > 0;
975
+ function dr(t) {
976
+ return async (e, r) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", r).execute()).length > 0;
977
977
  }
978
- function ua(t) {
978
+ function ur(t) {
979
979
  return {
980
- create: la(t),
981
- get: ia(t),
982
- update: ca(t),
983
- remove: da(t)
980
+ create: lr(t),
981
+ get: ir(t),
982
+ update: cr(t),
983
+ remove: dr(t)
984
984
  };
985
985
  }
986
- function ma(t) {
986
+ function mr(t) {
987
987
  return async (e) => {
988
- const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
988
+ const [r] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
989
989
  return f({
990
- identifier_first: !!(a != null && a.identifier_first),
991
- password_first: !!(a != null && a.password_first),
992
- webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
993
- universal_login_experience: (a == null ? void 0 : a.universal_login_experience) || "new"
990
+ identifier_first: !!(r != null && r.identifier_first),
991
+ password_first: !!(r != null && r.password_first),
992
+ webauthn_platform_first_factor: !!(r != null && r.webauthn_platform_first_factor),
993
+ universal_login_experience: (r == null ? void 0 : r.universal_login_experience) || "new"
994
994
  });
995
995
  };
996
996
  }
@@ -1003,37 +1003,37 @@ function he(t) {
1003
1003
  universal_login_experience: t.universal_login_experience
1004
1004
  });
1005
1005
  }
1006
- function ha(t) {
1007
- return async (e, a) => {
1006
+ function hr(t) {
1007
+ return async (e, r) => {
1008
1008
  try {
1009
- const r = Ke.parse(a);
1009
+ const a = Ke.parse(r);
1010
1010
  await t.insertInto("prompt_settings").values({
1011
- ...he(r),
1011
+ ...he(a),
1012
1012
  tenant_id: e
1013
1013
  }).execute();
1014
1014
  } catch {
1015
- await t.updateTable("prompt_settings").set(he(a)).where("tenant_id", "=", e).execute();
1015
+ await t.updateTable("prompt_settings").set(he(r)).where("tenant_id", "=", e).execute();
1016
1016
  }
1017
1017
  };
1018
1018
  }
1019
- function fa(t) {
1019
+ function fr(t) {
1020
1020
  return {
1021
- get: ma(t),
1022
- set: ha(t)
1021
+ get: mr(t),
1022
+ set: hr(t)
1023
1023
  };
1024
1024
  }
1025
- function _a(t) {
1025
+ function _r(t) {
1026
1026
  return async (e) => {
1027
- const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1028
- if (!a)
1027
+ const [r] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1028
+ if (!r)
1029
1029
  return null;
1030
1030
  const {
1031
- tenant_id: r,
1031
+ tenant_id: a,
1032
1032
  credentials: o,
1033
1033
  settings: n,
1034
1034
  enabled: s,
1035
1035
  ...l
1036
- } = a;
1036
+ } = r;
1037
1037
  return f({
1038
1038
  ...l,
1039
1039
  credentials: JSON.parse(o),
@@ -1042,24 +1042,24 @@ function _a(t) {
1042
1042
  });
1043
1043
  };
1044
1044
  }
1045
- function pa(t) {
1046
- return async (e, a) => {
1047
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1045
+ function pr(t) {
1046
+ return async (e, r) => {
1047
+ const { credentials: a, settings: o, enabled: n, ...s } = r;
1048
1048
  await t.updateTable("email_providers").set({
1049
1049
  ...s,
1050
- credentials: r ? JSON.stringify(r) : void 0,
1050
+ credentials: a ? JSON.stringify(a) : void 0,
1051
1051
  settings: o ? JSON.stringify(o) : void 0,
1052
1052
  enabled: n !== void 0 ? n ? 1 : 0 : void 0
1053
1053
  }).where("tenant_id", "=", e).execute();
1054
1054
  };
1055
1055
  }
1056
- function ga(t) {
1057
- return async (e, a) => {
1058
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1056
+ function gr(t) {
1057
+ return async (e, r) => {
1058
+ const { credentials: a, settings: o, enabled: n, ...s } = r;
1059
1059
  await t.insertInto("email_providers").values({
1060
1060
  ...s,
1061
1061
  enabled: n ? 1 : 0,
1062
- credentials: JSON.stringify(r),
1062
+ credentials: JSON.stringify(a),
1063
1063
  settings: JSON.stringify(o),
1064
1064
  tenant_id: e,
1065
1065
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1067,14 +1067,68 @@ function ga(t) {
1067
1067
  }).execute();
1068
1068
  };
1069
1069
  }
1070
- function wa(t) {
1070
+ function wr(t) {
1071
1071
  return {
1072
- get: _a(t),
1073
- create: ga(t),
1074
- update: pa(t)
1072
+ get: _r(t),
1073
+ create: gr(t),
1074
+ update: pr(t)
1075
1075
  };
1076
1076
  }
1077
- function ya(t) {
1077
+ function yr(t) {
1078
+ return async (e, r) => await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.token", "=", r).where("refresh_tokens.revoked_at", "is", null).selectAll().executeTakeFirst() ?? null;
1079
+ }
1080
+ function Nr(t) {
1081
+ return async (e, r) => {
1082
+ const a = {
1083
+ ...r,
1084
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1085
+ expires_at: (/* @__PURE__ */ new Date()).toISOString()
1086
+ };
1087
+ return await t.insertInto("refresh_tokens").values({ ...a, tenant_id: e }).execute(), { ...r, ...a };
1088
+ };
1089
+ }
1090
+ function vr(t) {
1091
+ return async (e, r) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.token", "=", r).execute()).length;
1092
+ }
1093
+ function br(t) {
1094
+ return async (e, r, a) => !!(await t.updateTable("refresh_tokens").set(a).where("tenant_id", "=", e).where("refresh_tokens.token", "=", r).execute()).length;
1095
+ }
1096
+ function Cr(t) {
1097
+ return async (e, r = {
1098
+ page: 0,
1099
+ per_page: 50,
1100
+ include_totals: !1
1101
+ }) => {
1102
+ let a = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1103
+ r.q && (a = T(t, a, r.q, ["token", "session_id"]));
1104
+ let o = a;
1105
+ if (r.sort && r.sort.sort_by) {
1106
+ const { ref: d } = t.dynamic;
1107
+ o = o.orderBy(
1108
+ d(r.sort.sort_by),
1109
+ r.sort.sort_order
1110
+ );
1111
+ }
1112
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
1113
+ const n = await o.selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = C(s);
1114
+ return {
1115
+ refresh_tokens: n,
1116
+ start: r.page * r.per_page,
1117
+ limit: r.per_page,
1118
+ length: l
1119
+ };
1120
+ };
1121
+ }
1122
+ function xr(t) {
1123
+ return {
1124
+ create: Nr(t),
1125
+ get: yr(t),
1126
+ list: Cr(t),
1127
+ remove: vr(t),
1128
+ update: br(t)
1129
+ };
1130
+ }
1131
+ function Tr(t) {
1078
1132
  return t[t.length - 1];
1079
1133
  }
1080
1134
  function p(t) {
@@ -1107,7 +1161,7 @@ const J = p({
1107
1161
  identifier: J.create(e)
1108
1162
  });
1109
1163
  }
1110
- }), Na = p({
1164
+ }), Sr = p({
1111
1165
  is(t) {
1112
1166
  return t.kind === "AliasNode";
1113
1167
  },
@@ -1136,7 +1190,7 @@ const J = p({
1136
1190
  }
1137
1191
  });
1138
1192
  var R;
1139
- class va {
1193
+ class Or {
1140
1194
  constructor() {
1141
1195
  j(this, "nodeStack", []);
1142
1196
  w(this, R, p({
@@ -1239,14 +1293,14 @@ class va {
1239
1293
  if (!e)
1240
1294
  return e;
1241
1295
  this.nodeStack.push(e);
1242
- const a = this.transformNodeImpl(e);
1243
- return this.nodeStack.pop(), p(a);
1296
+ const r = this.transformNodeImpl(e);
1297
+ return this.nodeStack.pop(), p(r);
1244
1298
  }
1245
1299
  transformNodeImpl(e) {
1246
1300
  return c(this, R)[e.kind](e);
1247
1301
  }
1248
1302
  transformNodeList(e) {
1249
- return e && p(e.map((a) => this.transformNode(a)));
1303
+ return e && p(e.map((r) => this.transformNode(r)));
1250
1304
  }
1251
1305
  transformSelectQuery(e) {
1252
1306
  return {
@@ -1970,7 +2024,7 @@ class va {
1970
2024
  }
1971
2025
  }
1972
2026
  R = new WeakMap();
1973
- const ba = p({
2027
+ const kr = p({
1974
2028
  AlterTableNode: !0,
1975
2029
  CreateIndexNode: !0,
1976
2030
  CreateSchemaNode: !0,
@@ -1989,78 +2043,78 @@ const ba = p({
1989
2043
  UpdateQueryNode: !0,
1990
2044
  MergeQueryNode: !0
1991
2045
  });
1992
- var P, T, S, _, ge, we, ye, $, q, Ne;
1993
- class Ca extends va {
1994
- constructor(a) {
2046
+ var P, S, O, _, ge, we, ye, $, q, Ne;
2047
+ class $r extends Or {
2048
+ constructor(r) {
1995
2049
  super();
1996
2050
  w(this, _);
1997
2051
  w(this, P);
1998
- w(this, T, /* @__PURE__ */ new Set());
1999
2052
  w(this, S, /* @__PURE__ */ new Set());
2000
- M(this, P, a);
2001
- }
2002
- transformNodeImpl(a) {
2003
- if (!u(this, _, ge).call(this, a))
2004
- return super.transformNodeImpl(a);
2005
- const r = u(this, _, ye).call(this, a);
2006
- for (const s of r)
2007
- c(this, S).add(s);
2008
- const o = u(this, _, we).call(this, a);
2053
+ w(this, O, /* @__PURE__ */ new Set());
2054
+ M(this, P, r);
2055
+ }
2056
+ transformNodeImpl(r) {
2057
+ if (!u(this, _, ge).call(this, r))
2058
+ return super.transformNodeImpl(r);
2059
+ const a = u(this, _, ye).call(this, r);
2060
+ for (const s of a)
2061
+ c(this, O).add(s);
2062
+ const o = u(this, _, we).call(this, r);
2009
2063
  for (const s of o)
2010
- c(this, T).add(s);
2011
- const n = super.transformNodeImpl(a);
2064
+ c(this, S).add(s);
2065
+ const n = super.transformNodeImpl(r);
2012
2066
  for (const s of o)
2013
- c(this, T).delete(s);
2014
- for (const s of r)
2015
2067
  c(this, S).delete(s);
2068
+ for (const s of a)
2069
+ c(this, O).delete(s);
2016
2070
  return n;
2017
2071
  }
2018
- transformSchemableIdentifier(a) {
2019
- const r = super.transformSchemableIdentifier(a);
2020
- return r.schema || !c(this, T).has(a.identifier.name) ? r : {
2021
- ...r,
2072
+ transformSchemableIdentifier(r) {
2073
+ const a = super.transformSchemableIdentifier(r);
2074
+ return a.schema || !c(this, S).has(r.identifier.name) ? a : {
2075
+ ...a,
2022
2076
  schema: J.create(c(this, P))
2023
2077
  };
2024
2078
  }
2025
- transformReferences(a) {
2026
- const r = super.transformReferences(a);
2027
- return r.table.table.schema ? r : {
2028
- ...r,
2029
- table: K.createWithSchema(c(this, P), r.table.table.identifier.name)
2030
- };
2031
- }
2032
- }
2033
- P = new WeakMap(), T = new WeakMap(), S = new WeakMap(), _ = new WeakSet(), ge = function(a) {
2034
- return a.kind in ba;
2035
- }, we = function(a) {
2036
- const r = /* @__PURE__ */ new Set();
2037
- if ("name" in a && a.name && W.is(a.name) && u(this, _, q).call(this, a.name, r), "from" in a && a.from)
2038
- for (const o of a.from.froms)
2039
- u(this, _, $).call(this, o, r);
2040
- if ("into" in a && a.into && u(this, _, $).call(this, a.into, r), "table" in a && a.table && u(this, _, $).call(this, a.table, r), "joins" in a && a.joins)
2041
- for (const o of a.joins)
2042
- u(this, _, $).call(this, o.table, r);
2043
- return "using" in a && a.using && u(this, _, $).call(this, a.using, r), r;
2044
- }, ye = function(a) {
2045
- const r = /* @__PURE__ */ new Set();
2046
- return "with" in a && a.with && u(this, _, Ne).call(this, a.with, r), r;
2047
- }, $ = function(a, r) {
2048
- const o = K.is(a) ? a : Na.is(a) && K.is(a.node) ? a.node : null;
2049
- o && u(this, _, q).call(this, o.table, r);
2050
- }, q = function(a, r) {
2051
- const o = a.identifier.name;
2052
- !c(this, T).has(o) && !c(this, S).has(o) && r.add(o);
2053
- }, Ne = function(a, r) {
2054
- for (const o of a.expressions) {
2079
+ transformReferences(r) {
2080
+ const a = super.transformReferences(r);
2081
+ return a.table.table.schema ? a : {
2082
+ ...a,
2083
+ table: K.createWithSchema(c(this, P), a.table.table.identifier.name)
2084
+ };
2085
+ }
2086
+ }
2087
+ P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(r) {
2088
+ return r.kind in kr;
2089
+ }, we = function(r) {
2090
+ const a = /* @__PURE__ */ new Set();
2091
+ if ("name" in r && r.name && W.is(r.name) && u(this, _, q).call(this, r.name, a), "from" in r && r.from)
2092
+ for (const o of r.from.froms)
2093
+ u(this, _, $).call(this, o, a);
2094
+ if ("into" in r && r.into && u(this, _, $).call(this, r.into, a), "table" in r && r.table && u(this, _, $).call(this, r.table, a), "joins" in r && r.joins)
2095
+ for (const o of r.joins)
2096
+ u(this, _, $).call(this, o.table, a);
2097
+ return "using" in r && r.using && u(this, _, $).call(this, r.using, a), a;
2098
+ }, ye = function(r) {
2099
+ const a = /* @__PURE__ */ new Set();
2100
+ return "with" in r && r.with && u(this, _, Ne).call(this, r.with, a), a;
2101
+ }, $ = function(r, a) {
2102
+ const o = K.is(r) ? r : Sr.is(r) && K.is(r.node) ? r.node : null;
2103
+ o && u(this, _, q).call(this, o.table, a);
2104
+ }, q = function(r, a) {
2105
+ const o = r.identifier.name;
2106
+ !c(this, S).has(o) && !c(this, O).has(o) && a.add(o);
2107
+ }, Ne = function(r, a) {
2108
+ for (const o of r.expressions) {
2055
2109
  const n = o.name.table.table.identifier.name;
2056
- c(this, S).has(n) || r.add(n);
2110
+ c(this, O).has(n) || a.add(n);
2057
2111
  }
2058
2112
  };
2059
2113
  var L;
2060
- class xa {
2114
+ class Ir {
2061
2115
  constructor(e) {
2062
2116
  w(this, L);
2063
- M(this, L, new Ca(e));
2117
+ M(this, L, new $r(e));
2064
2118
  }
2065
2119
  transformQuery(e) {
2066
2120
  return c(this, L).transformNode(e.node);
@@ -2070,7 +2124,7 @@ class xa {
2070
2124
  }
2071
2125
  }
2072
2126
  L = new WeakMap();
2073
- class Ta {
2127
+ class Dr {
2074
2128
  transformQuery(e) {
2075
2129
  return e.node;
2076
2130
  }
@@ -2078,8 +2132,8 @@ class Ta {
2078
2132
  return e.result;
2079
2133
  }
2080
2134
  }
2081
- const Sa = "kysely_migration", fe = "kysely_migration_lock", Oa = !1, B = "migration_lock", ka = p({ __noMigrations__: !0 });
2082
- var h, i, A, N, v, D, be, b, Ce, xe, Te, Se, Oe, G, I, H, ke, $e, De, X, Ie, Pe, je, Me, Ae, F;
2135
+ const Pr = "kysely_migration", fe = "kysely_migration_lock", jr = !1, B = "migration_lock", Mr = p({ __noMigrations__: !0 });
2136
+ var h, i, A, N, v, I, be, b, Ce, xe, Te, Se, Oe, G, D, H, ke, $e, Ie, X, De, Pe, je, Me, Ae, F;
2083
2137
  class ve {
2084
2138
  constructor(e) {
2085
2139
  w(this, i);
@@ -2092,11 +2146,11 @@ class ve {
2092
2146
  * The returned array is sorted by migration name.
2093
2147
  */
2094
2148
  async getMigrations() {
2095
- const e = await u(this, i, I).call(this, c(this, i, v)) ? await c(this, h).db.withPlugin(c(this, i, b)).selectFrom(c(this, i, v)).select(["name", "timestamp"]).execute() : [];
2096
- return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2097
- const n = e.find((s) => s.name === r);
2149
+ const e = await u(this, i, D).call(this, c(this, i, v)) ? await c(this, h).db.withPlugin(c(this, i, b)).selectFrom(c(this, i, v)).select(["name", "timestamp"]).execute() : [];
2150
+ return (await u(this, i, X).call(this)).map(({ name: a, ...o }) => {
2151
+ const n = e.find((s) => s.name === a);
2098
2152
  return {
2099
- name: r,
2153
+ name: a,
2100
2154
  migration: o,
2101
2155
  executedAt: n ? new Date(n.timestamp) : void 0
2102
2156
  };
@@ -2176,16 +2230,16 @@ class ve {
2176
2230
  * ```
2177
2231
  */
2178
2232
  async migrateTo(e) {
2179
- return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2180
- if (e === ka)
2233
+ return u(this, i, A).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: o }) => {
2234
+ if (e === Mr)
2181
2235
  return { direction: "Down", step: 1 / 0 };
2182
- if (!a.find((l) => l.name === e))
2236
+ if (!r.find((l) => l.name === e))
2183
2237
  throw new Error(`migration "${e}" doesn't exist`);
2184
- const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2238
+ const n = a.indexOf(e), s = o.findIndex((l) => l.name === e);
2185
2239
  if (n !== -1)
2186
2240
  return {
2187
2241
  direction: "Down",
2188
- step: r.length - n - 1
2242
+ step: a.length - n - 1
2189
2243
  };
2190
2244
  if (s !== -1)
2191
2245
  return { direction: "Up", step: s + 1 };
@@ -2230,19 +2284,19 @@ class ve {
2230
2284
  h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2231
2285
  try {
2232
2286
  return await u(this, i, Ce).call(this), await u(this, i, ke).call(this, e);
2233
- } catch (a) {
2234
- return a instanceof Q ? a.resultSet : { error: a };
2287
+ } catch (r) {
2288
+ return r instanceof Q ? r.resultSet : { error: r };
2235
2289
  }
2236
2290
  }, N = function() {
2237
2291
  return c(this, h).migrationTableSchema;
2238
2292
  }, v = function() {
2239
- return c(this, h).migrationTableName ?? Sa;
2240
- }, D = function() {
2293
+ return c(this, h).migrationTableName ?? Pr;
2294
+ }, I = function() {
2241
2295
  return c(this, h).migrationLockTableName ?? fe;
2242
2296
  }, be = function() {
2243
- return c(this, h).allowUnorderedMigrations ?? Oa;
2297
+ return c(this, h).allowUnorderedMigrations ?? jr;
2244
2298
  }, b = function() {
2245
- return c(this, i, N) ? new xa(c(this, i, N)) : new Ta();
2299
+ return c(this, i, N) ? new Ir(c(this, i, N)) : new Dr();
2246
2300
  }, Ce = async function() {
2247
2301
  await u(this, i, xe).call(this), await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this);
2248
2302
  }, xe = async function() {
@@ -2254,86 +2308,86 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2254
2308
  throw e;
2255
2309
  }
2256
2310
  }, Te = async function() {
2257
- if (!await u(this, i, I).call(this, c(this, i, v)))
2311
+ if (!await u(this, i, D).call(this, c(this, i, v)))
2258
2312
  try {
2259
2313
  c(this, i, N) && await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N))), await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, b)).createTable(c(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2260
2314
  } catch (e) {
2261
- if (!await u(this, i, I).call(this, c(this, i, v)))
2315
+ if (!await u(this, i, D).call(this, c(this, i, v)))
2262
2316
  throw e;
2263
2317
  }
2264
2318
  }, Se = async function() {
2265
- if (!await u(this, i, I).call(this, c(this, i, D)))
2319
+ if (!await u(this, i, D).call(this, c(this, i, I)))
2266
2320
  try {
2267
- await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, b)).createTable(c(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2321
+ await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, b)).createTable(c(this, i, I)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2268
2322
  } catch (e) {
2269
- if (!await u(this, i, I).call(this, c(this, i, D)))
2323
+ if (!await u(this, i, D).call(this, c(this, i, I)))
2270
2324
  throw e;
2271
2325
  }
2272
2326
  }, Oe = async function() {
2273
2327
  if (!await u(this, i, H).call(this))
2274
2328
  try {
2275
- await c(this, h).db.withPlugin(c(this, i, b)).insertInto(c(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2329
+ await c(this, h).db.withPlugin(c(this, i, b)).insertInto(c(this, i, I)).values({ id: B, is_locked: 0 }).execute();
2276
2330
  } catch (e) {
2277
2331
  if (!await u(this, i, H).call(this))
2278
2332
  throw e;
2279
2333
  }
2280
2334
  }, G = async function() {
2281
- return (await c(this, h).db.introspection.getSchemas()).some((a) => a.name === c(this, i, N));
2282
- }, I = async function(e) {
2283
- const a = c(this, i, N);
2335
+ return (await c(this, h).db.introspection.getSchemas()).some((r) => r.name === c(this, i, N));
2336
+ }, D = async function(e) {
2337
+ const r = c(this, i, N);
2284
2338
  return (await c(this, h).db.introspection.getTables({
2285
2339
  withInternalKyselyTables: !0
2286
- })).some((o) => o.name === e && (!a || o.schema === a));
2340
+ })).some((o) => o.name === e && (!r || o.schema === r));
2287
2341
  }, H = async function() {
2288
- return !!await c(this, h).db.withPlugin(c(this, i, b)).selectFrom(c(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2342
+ return !!await c(this, h).db.withPlugin(c(this, i, b)).selectFrom(c(this, i, I)).where("id", "=", B).select("id").executeTakeFirst();
2289
2343
  }, ke = async function(e) {
2290
- const a = c(this, h).db.getExecutor().adapter, r = p({
2344
+ const r = c(this, h).db.getExecutor().adapter, a = p({
2291
2345
  lockTable: c(this, h).migrationLockTableName ?? fe,
2292
2346
  lockRowId: B,
2293
2347
  lockTableSchema: c(this, h).migrationTableSchema
2294
2348
  }), o = async (n) => {
2295
2349
  try {
2296
- await a.acquireMigrationLock(n, r);
2350
+ await r.acquireMigrationLock(n, a);
2297
2351
  const s = await u(this, i, $e).call(this, n);
2298
2352
  if (s.migrations.length === 0)
2299
2353
  return { results: [] };
2300
2354
  const { direction: l, step: d } = e(s);
2301
2355
  return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, d) : l === "Up" ? await u(this, i, Ae).call(this, n, s, d) : { results: [] };
2302
2356
  } finally {
2303
- await a.releaseMigrationLock(n, r);
2357
+ await r.releaseMigrationLock(n, a);
2304
2358
  }
2305
2359
  };
2306
- return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2360
+ return r.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2307
2361
  }, $e = async function(e) {
2308
- const a = await u(this, i, X).call(this), r = await u(this, i, Ie).call(this, e);
2309
- u(this, i, Pe).call(this, a, r), c(this, i, be) || u(this, i, je).call(this, a, r);
2310
- const o = u(this, i, De).call(this, a, r);
2362
+ const r = await u(this, i, X).call(this), a = await u(this, i, De).call(this, e);
2363
+ u(this, i, Pe).call(this, r, a), c(this, i, be) || u(this, i, je).call(this, r, a);
2364
+ const o = u(this, i, Ie).call(this, r, a);
2311
2365
  return p({
2312
- migrations: a,
2313
- executedMigrations: r,
2314
- lastMigration: ya(r),
2366
+ migrations: r,
2367
+ executedMigrations: a,
2368
+ lastMigration: Tr(a),
2315
2369
  pendingMigrations: o
2316
2370
  });
2317
- }, De = function(e, a) {
2318
- return e.filter((r) => !a.includes(r.name));
2371
+ }, Ie = function(e, r) {
2372
+ return e.filter((a) => !r.includes(a.name));
2319
2373
  }, X = async function() {
2320
2374
  const e = await c(this, h).provider.getMigrations();
2321
- return Object.keys(e).sort().map((a) => ({
2322
- ...e[a],
2323
- name: a
2375
+ return Object.keys(e).sort().map((r) => ({
2376
+ ...e[r],
2377
+ name: r
2324
2378
  }));
2325
- }, Ie = async function(e) {
2326
- return (await e.withPlugin(c(this, i, b)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2327
- }, Pe = function(e, a) {
2328
- for (const r of a)
2329
- if (!e.some((o) => o.name === r))
2330
- throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2331
- }, je = function(e, a) {
2332
- for (let r = 0; r < a.length; ++r)
2333
- if (e[r].name !== a[r])
2334
- throw new Error(`corrupted migrations: expected previously executed migration ${a[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2335
- }, Me = async function(e, a, r) {
2336
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2379
+ }, De = async function(e) {
2380
+ return (await e.withPlugin(c(this, i, b)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
2381
+ }, Pe = function(e, r) {
2382
+ for (const a of r)
2383
+ if (!e.some((o) => o.name === a))
2384
+ throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
2385
+ }, je = function(e, r) {
2386
+ for (let a = 0; a < r.length; ++a)
2387
+ if (e[a].name !== r[a])
2388
+ throw new Error(`corrupted migrations: expected previously executed migration ${r[a]} to be at index ${a} but ${e[a].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2389
+ }, Me = async function(e, r, a) {
2390
+ const o = r.executedMigrations.slice().reverse().slice(0, a).map((s) => r.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2337
2391
  migrationName: s.name,
2338
2392
  direction: "Down",
2339
2393
  status: "NotExecuted"
@@ -2358,14 +2412,14 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2358
2412
  }
2359
2413
  }
2360
2414
  return { results: n };
2361
- }, Ae = async function(e, a, r) {
2362
- const n = a.pendingMigrations.slice(0, r).map((s) => ({
2415
+ }, Ae = async function(e, r, a) {
2416
+ const n = r.pendingMigrations.slice(0, a).map((s) => ({
2363
2417
  migrationName: s.name,
2364
2418
  direction: "Up",
2365
2419
  status: "NotExecuted"
2366
2420
  }));
2367
2421
  for (let s = 0; s < n.length; s++) {
2368
- const l = a.pendingMigrations[s];
2422
+ const l = r.pendingMigrations[s];
2369
2423
  try {
2370
2424
  await l.up(e), await e.withPlugin(c(this, i, b)).insertInto(c(this, i, v)).values({
2371
2425
  name: l.name,
@@ -2392,10 +2446,10 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2392
2446
  };
2393
2447
  var E;
2394
2448
  class Q extends Error {
2395
- constructor(a) {
2449
+ constructor(r) {
2396
2450
  super();
2397
2451
  w(this, E);
2398
- M(this, E, a);
2452
+ M(this, E, r);
2399
2453
  }
2400
2454
  get resultSet() {
2401
2455
  return c(this, E);
@@ -2411,7 +2465,7 @@ class Fe {
2411
2465
  return this.migrations;
2412
2466
  }
2413
2467
  }
2414
- async function $a(t) {
2468
+ async function Ar(t) {
2415
2469
  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(
2416
2470
  "tenant_id",
2417
2471
  "varchar(255)",
@@ -2479,35 +2533,35 @@ async function $a(t) {
2479
2533
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
2480
2534
  ).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();
2481
2535
  }
2482
- async function Da(t) {
2536
+ async function Fr(t) {
2483
2537
  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();
2484
2538
  }
2485
- const Ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2539
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2486
2540
  __proto__: null,
2487
- down: Da,
2488
- up: $a
2541
+ down: Fr,
2542
+ up: Ar
2489
2543
  }, Symbol.toStringTag, { value: "Module" }));
2490
- async function Pa(t) {
2544
+ async function Er(t) {
2491
2545
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
2492
2546
  }
2493
- async function ja(t) {
2547
+ async function zr(t) {
2494
2548
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
2495
2549
  }
2496
- const Ma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2550
+ const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2497
2551
  __proto__: null,
2498
- down: ja,
2499
- up: Pa
2552
+ down: zr,
2553
+ up: Er
2500
2554
  }, Symbol.toStringTag, { value: "Module" }));
2501
- async function Aa(t) {
2555
+ async function Rr(t) {
2502
2556
  }
2503
- async function Fa(t) {
2557
+ async function Ur(t) {
2504
2558
  }
2505
- const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2559
+ const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2506
2560
  __proto__: null,
2507
- down: Fa,
2508
- up: Aa
2561
+ down: Ur,
2562
+ up: Rr
2509
2563
  }, Symbol.toStringTag, { value: "Module" }));
2510
- async function Ea(t) {
2564
+ async function Br(t) {
2511
2565
  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(
2512
2566
  "tenant_id_constraint",
2513
2567
  ["tenant_id"],
@@ -2516,24 +2570,24 @@ async function Ea(t) {
2516
2570
  (e) => e.onDelete("cascade")
2517
2571
  ).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();
2518
2572
  }
2519
- async function za(t) {
2573
+ async function Qr(t) {
2520
2574
  await t.schema.dropTable("logs").execute();
2521
2575
  }
2522
- const Ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2576
+ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2523
2577
  __proto__: null,
2524
- down: za,
2525
- up: Ea
2578
+ down: Qr,
2579
+ up: Br
2526
2580
  }, Symbol.toStringTag, { value: "Module" }));
2527
- async function Ra(t) {
2581
+ async function Wr(t) {
2528
2582
  }
2529
- async function Ua(t) {
2583
+ async function qr(t) {
2530
2584
  }
2531
- const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2585
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2532
2586
  __proto__: null,
2533
- down: Ua,
2534
- up: Ra
2587
+ down: qr,
2588
+ up: Wr
2535
2589
  }, Symbol.toStringTag, { value: "Module" }));
2536
- async function Ba(t) {
2590
+ async function Hr(t) {
2537
2591
  await t.schema.createTable("sessions").addColumn("session_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
2538
2592
  "client_id",
2539
2593
  "varchar(255)",
@@ -2562,15 +2616,15 @@ async function Ba(t) {
2562
2616
  (e) => e.references("applications.id").onDelete("cascade").notNull()
2563
2617
  ).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();
2564
2618
  }
2565
- async function Qa(t) {
2619
+ async function Xr(t) {
2566
2620
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
2567
2621
  }
2568
- const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2622
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2569
2623
  __proto__: null,
2570
- down: Qa,
2571
- up: Ba
2624
+ down: Xr,
2625
+ up: Hr
2572
2626
  }, Symbol.toStringTag, { value: "Module" }));
2573
- async function Wa(t) {
2627
+ async function Zr(t) {
2574
2628
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
2575
2629
  "user_id_constraint",
2576
2630
  ["user_id", "tenant_id"],
@@ -2585,24 +2639,24 @@ async function Wa(t) {
2585
2639
  (e) => e.onDelete("cascade")
2586
2640
  ).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();
2587
2641
  }
2588
- async function qa(t) {
2642
+ async function ea(t) {
2589
2643
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
2590
2644
  }
2591
- const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2645
+ const ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2592
2646
  __proto__: null,
2593
- down: qa,
2594
- up: Wa
2647
+ down: ea,
2648
+ up: Zr
2595
2649
  }, Symbol.toStringTag, { value: "Module" }));
2596
- async function Ha(t) {
2650
+ async function ra(t) {
2597
2651
  }
2598
- async function Xa(t) {
2652
+ async function aa(t) {
2599
2653
  }
2600
- const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2654
+ const na = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2601
2655
  __proto__: null,
2602
- down: Xa,
2603
- up: Ha
2656
+ down: aa,
2657
+ up: ra
2604
2658
  }, Symbol.toStringTag, { value: "Module" }));
2605
- async function Za(t) {
2659
+ async function oa(t) {
2606
2660
  await t.schema.alterTable("passwords").addColumn(
2607
2661
  "password",
2608
2662
  "varchar(255)",
@@ -2610,219 +2664,198 @@ async function Za(t) {
2610
2664
  (e) => e.notNull()
2611
2665
  ).execute();
2612
2666
  }
2613
- async function er(t) {
2667
+ async function sa(t) {
2614
2668
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2615
2669
  }
2616
- const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2670
+ const ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2617
2671
  __proto__: null,
2618
- down: er,
2619
- up: Za
2672
+ down: sa,
2673
+ up: oa
2620
2674
  }, Symbol.toStringTag, { value: "Module" }));
2621
- async function ar(t) {
2675
+ async function la(t) {
2622
2676
  }
2623
- async function rr(t) {
2677
+ async function ca(t) {
2624
2678
  }
2625
- const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2679
+ const da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2626
2680
  __proto__: null,
2627
- down: rr,
2628
- up: ar
2681
+ down: ca,
2682
+ up: la
2629
2683
  }, Symbol.toStringTag, { value: "Module" }));
2630
- async function or(t) {
2684
+ async function ua(t) {
2631
2685
  }
2632
- async function sr(t) {
2686
+ async function ma(t) {
2633
2687
  }
2634
- const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2688
+ const ha = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2635
2689
  __proto__: null,
2636
- down: sr,
2637
- up: or
2690
+ down: ma,
2691
+ up: ua
2638
2692
  }, Symbol.toStringTag, { value: "Module" }));
2639
- async function lr(t) {
2693
+ async function fa(t) {
2640
2694
  }
2641
- async function cr(t) {
2695
+ async function _a(t) {
2642
2696
  }
2643
- const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2697
+ const pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2644
2698
  __proto__: null,
2645
- down: cr,
2646
- up: lr
2699
+ down: _a,
2700
+ up: fa
2647
2701
  }, Symbol.toStringTag, { value: "Module" }));
2648
- async function ur(t) {
2702
+ async function ga(t) {
2649
2703
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
2650
2704
  }
2651
- async function mr(t) {
2705
+ async function wa(t) {
2652
2706
  await t.schema.dropIndex("users_email_index").execute();
2653
2707
  }
2654
- const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2708
+ const ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2655
2709
  __proto__: null,
2656
- down: mr,
2657
- up: ur
2710
+ down: wa,
2711
+ up: ga
2658
2712
  }, Symbol.toStringTag, { value: "Module" }));
2659
- async function fr(t) {
2713
+ async function Na(t) {
2660
2714
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
2661
2715
  }
2662
- async function _r(t) {
2716
+ async function va(t) {
2663
2717
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2664
2718
  }
2665
- const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2719
+ const ba = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2666
2720
  __proto__: null,
2667
- down: _r,
2668
- up: fr
2721
+ down: va,
2722
+ up: Na
2669
2723
  }, Symbol.toStringTag, { value: "Module" }));
2670
- async function gr(t) {
2724
+ async function Ca(t) {
2671
2725
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
2672
2726
  }
2673
- async function wr(t) {
2727
+ async function xa(t) {
2674
2728
  await t.schema.dropIndex("users_linked_to_index");
2675
2729
  }
2676
- const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2730
+ const Ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2677
2731
  __proto__: null,
2678
- down: wr,
2679
- up: gr
2732
+ down: xa,
2733
+ up: Ca
2680
2734
  }, Symbol.toStringTag, { value: "Module" }));
2681
- async function Nr(t) {
2735
+ async function Sa(t) {
2682
2736
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
2683
2737
  }
2684
- async function vr(t) {
2738
+ async function Oa(t) {
2685
2739
  await t.schema.alterTable("users").dropColumn("locale").execute();
2686
2740
  }
2687
- const br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2741
+ const ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2688
2742
  __proto__: null,
2689
- down: vr,
2690
- up: Nr
2743
+ down: Oa,
2744
+ up: Sa
2691
2745
  }, Symbol.toStringTag, { value: "Module" }));
2692
- async function Cr(t) {
2746
+ async function $a(t) {
2693
2747
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2694
2748
  "tenant_id",
2695
2749
  "varchar(255)",
2696
2750
  (e) => e.references("tenants.id").onDelete("cascade")
2697
2751
  ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn("cert", "varchar(2048)").addColumn("pkcs7", "varchar(2048)").addColumn("fingerprint", "varchar(256)").addColumn("thumbprint", "varchar(256)").addColumn("current_since", "varchar(256)").addColumn("current_until", "varchar(256)").execute();
2698
2752
  }
2699
- async function xr(t) {
2753
+ async function Ia(t) {
2700
2754
  await t.schema.dropTable("keys").execute();
2701
2755
  }
2702
- const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2756
+ const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2703
2757
  __proto__: null,
2704
- down: xr,
2705
- up: Cr
2758
+ down: Ia,
2759
+ up: $a
2706
2760
  }, Symbol.toStringTag, { value: "Module" }));
2707
- async function Sr(t) {
2761
+ async function Pa(t) {
2708
2762
  }
2709
- async function Or(t) {
2763
+ async function ja(t) {
2710
2764
  }
2711
- const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2765
+ const Ma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2712
2766
  __proto__: null,
2713
- down: Or,
2714
- up: Sr
2767
+ down: ja,
2768
+ up: Pa
2715
2769
  }, Symbol.toStringTag, { value: "Module" }));
2716
- async function $r(t) {
2770
+ async function Aa(t) {
2717
2771
  }
2718
- async function Dr(t) {
2772
+ async function Fa(t) {
2719
2773
  }
2720
- const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2774
+ const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2721
2775
  __proto__: null,
2722
- down: Dr,
2723
- up: $r
2776
+ down: Fa,
2777
+ up: Aa
2724
2778
  }, Symbol.toStringTag, { value: "Module" }));
2725
- async function Pr(t) {
2779
+ async function Ea(t) {
2726
2780
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
2727
2781
  }
2728
- async function jr(t) {
2782
+ async function za(t) {
2729
2783
  await t.schema.alterTable("otps").dropColumn("audience").execute();
2730
2784
  }
2731
- const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2785
+ const Ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2732
2786
  __proto__: null,
2733
- down: jr,
2734
- up: Pr
2787
+ down: za,
2788
+ up: Ea
2735
2789
  }, Symbol.toStringTag, { value: "Module" }));
2736
- async function Ar(t) {
2790
+ async function Ra(t) {
2737
2791
  }
2738
- async function Fr(t) {
2792
+ async function Ua(t) {
2739
2793
  }
2740
- const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2794
+ const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2741
2795
  __proto__: null,
2742
- down: Fr,
2743
- up: Ar
2796
+ down: Ua,
2797
+ up: Ra
2744
2798
  }, Symbol.toStringTag, { value: "Module" }));
2745
- async function Er(t) {
2799
+ async function Ba(t) {
2746
2800
  await t.schema.alterTable("logs").dropColumn("category").execute();
2747
2801
  }
2748
- async function zr(t) {
2802
+ async function Qa(t) {
2749
2803
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
2750
2804
  }
2751
- const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2805
+ const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2752
2806
  __proto__: null,
2753
- down: zr,
2754
- up: Er
2807
+ down: Qa,
2808
+ up: Ba
2755
2809
  }, Symbol.toStringTag, { value: "Module" }));
2756
- async function Rr(t) {
2810
+ async function Wa(t) {
2757
2811
  await t.schema.alterTable("users").dropColumn("tags").execute();
2758
2812
  }
2759
- async function Ur(t) {
2813
+ async function qa(t) {
2760
2814
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
2761
2815
  }
2762
- const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2816
+ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2763
2817
  __proto__: null,
2764
- down: Ur,
2765
- up: Rr
2818
+ down: qa,
2819
+ up: Wa
2766
2820
  }, Symbol.toStringTag, { value: "Module" }));
2767
- async function Br(t) {
2821
+ async function Ha(t) {
2768
2822
  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();
2769
2823
  }
2770
- async function Qr(t) {
2824
+ async function Xa(t) {
2771
2825
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
2772
2826
  }
2773
- const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2827
+ const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2774
2828
  __proto__: null,
2775
- down: Qr,
2776
- up: Br
2777
- }, Symbol.toStringTag, { value: "Module" }));
2778
- async function Wr(t) {
2779
- await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
2780
- }
2781
- async function qr(t) {
2782
- await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
2783
- }
2784
- const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2785
- __proto__: null,
2786
- down: qr,
2787
- up: Wr
2788
- }, Symbol.toStringTag, { value: "Module" }));
2789
- async function Hr(t) {
2790
- 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();
2791
- }
2792
- async function Xr(t) {
2793
- 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();
2794
- }
2795
- const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2796
- __proto__: null,
2797
- down: Xr,
2798
- up: Hr
2829
+ down: Xa,
2830
+ up: Ha
2799
2831
  }, Symbol.toStringTag, { value: "Module" }));
2800
- async function Zr(t) {
2801
- await t.schema.createIndex("users_name_index").on("users").column("name").execute();
2832
+ async function Za(t) {
2833
+ await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
2802
2834
  }
2803
2835
  async function en(t) {
2804
- await t.schema.dropIndex("users_name_index").execute();
2836
+ await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
2805
2837
  }
2806
2838
  const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2807
2839
  __proto__: null,
2808
2840
  down: en,
2809
- up: Zr
2841
+ up: Za
2810
2842
  }, Symbol.toStringTag, { value: "Module" }));
2811
- async function an(t) {
2812
- }
2813
2843
  async function rn(t) {
2814
- await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
2844
+ 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();
2845
+ }
2846
+ async function an(t) {
2847
+ 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();
2815
2848
  }
2816
2849
  const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2817
2850
  __proto__: null,
2818
- down: rn,
2819
- up: an
2851
+ down: an,
2852
+ up: rn
2820
2853
  }, Symbol.toStringTag, { value: "Module" }));
2821
2854
  async function on(t) {
2822
- await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
2855
+ await t.schema.createIndex("users_name_index").on("users").column("name").execute();
2823
2856
  }
2824
2857
  async function sn(t) {
2825
- await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
2858
+ await t.schema.dropIndex("users_name_index").execute();
2826
2859
  }
2827
2860
  const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2828
2861
  __proto__: null,
@@ -2830,10 +2863,9 @@ const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2830
2863
  up: on
2831
2864
  }, Symbol.toStringTag, { value: "Module" }));
2832
2865
  async function cn(t) {
2833
- await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
2834
2866
  }
2835
2867
  async function dn(t) {
2836
- await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
2868
+ await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
2837
2869
  }
2838
2870
  const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2839
2871
  __proto__: null,
@@ -2841,14 +2873,10 @@ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2841
2873
  up: cn
2842
2874
  }, Symbol.toStringTag, { value: "Module" }));
2843
2875
  async function mn(t) {
2844
- await t.schema.createTable("branding").addColumn(
2845
- "tenant_id",
2846
- "varchar(255)",
2847
- (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
2848
- ).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();
2876
+ await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
2849
2877
  }
2850
2878
  async function hn(t) {
2851
- await t.schema.dropTable("branding").execute();
2879
+ await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
2852
2880
  }
2853
2881
  const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2854
2882
  __proto__: null,
@@ -2856,8 +2884,10 @@ const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2856
2884
  up: mn
2857
2885
  }, Symbol.toStringTag, { value: "Module" }));
2858
2886
  async function _n(t) {
2887
+ await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
2859
2888
  }
2860
2889
  async function pn(t) {
2890
+ await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
2861
2891
  }
2862
2892
  const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2863
2893
  __proto__: null,
@@ -2865,8 +2895,14 @@ const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2865
2895
  up: _n
2866
2896
  }, Symbol.toStringTag, { value: "Module" }));
2867
2897
  async function wn(t) {
2898
+ await t.schema.createTable("branding").addColumn(
2899
+ "tenant_id",
2900
+ "varchar(255)",
2901
+ (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
2902
+ ).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();
2868
2903
  }
2869
2904
  async function yn(t) {
2905
+ await t.schema.dropTable("branding").execute();
2870
2906
  }
2871
2907
  const Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2872
2908
  __proto__: null,
@@ -2892,38 +2928,36 @@ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2892
2928
  up: xn
2893
2929
  }, Symbol.toStringTag, { value: "Module" }));
2894
2930
  async function On(t) {
2895
- await t.schema.createTable("authentication_codes").addColumn(
2896
- "tenant_id",
2897
- "varchar(255)",
2898
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
2899
- ).addColumn("code", "varchar(255)", (e) => e.primaryKey()).addColumn(
2900
- "client_id",
2901
- "varchar(255)",
2902
- (e) => e.references("applications.id").onDelete("cascade").notNull()
2903
- ).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();
2904
2931
  }
2905
2932
  async function kn(t) {
2906
- await t.schema.dropTable("authentication_codes").execute();
2907
2933
  }
2908
2934
  const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2909
2935
  __proto__: null,
2910
2936
  down: kn,
2911
2937
  up: On
2912
2938
  }, Symbol.toStringTag, { value: "Module" }));
2913
- async function Dn(t) {
2914
- }
2915
2939
  async function In(t) {
2916
2940
  }
2941
+ async function Dn(t) {
2942
+ }
2917
2943
  const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2918
2944
  __proto__: null,
2919
- down: In,
2920
- up: Dn
2945
+ down: Dn,
2946
+ up: In
2921
2947
  }, Symbol.toStringTag, { value: "Module" }));
2922
2948
  async function jn(t) {
2923
- await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
2949
+ await t.schema.createTable("authentication_codes").addColumn(
2950
+ "tenant_id",
2951
+ "varchar(255)",
2952
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
2953
+ ).addColumn("code", "varchar(255)", (e) => e.primaryKey()).addColumn(
2954
+ "client_id",
2955
+ "varchar(255)",
2956
+ (e) => e.references("applications.id").onDelete("cascade").notNull()
2957
+ ).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();
2924
2958
  }
2925
2959
  async function Mn(t) {
2926
- await t.schema.alterTable("otps").dropColumn("ip").execute();
2960
+ await t.schema.dropTable("authentication_codes").execute();
2927
2961
  }
2928
2962
  const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2929
2963
  __proto__: null,
@@ -2931,10 +2965,8 @@ const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2931
2965
  up: jn
2932
2966
  }, Symbol.toStringTag, { value: "Module" }));
2933
2967
  async function Fn(t) {
2934
- await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
2935
2968
  }
2936
2969
  async function Ln(t) {
2937
- await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
2938
2970
  }
2939
2971
  const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2940
2972
  __proto__: null,
@@ -2942,8 +2974,10 @@ const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2942
2974
  up: Fn
2943
2975
  }, Symbol.toStringTag, { value: "Module" }));
2944
2976
  async function zn(t) {
2977
+ await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
2945
2978
  }
2946
2979
  async function Jn(t) {
2980
+ await t.schema.alterTable("otps").dropColumn("ip").execute();
2947
2981
  }
2948
2982
  const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2949
2983
  __proto__: null,
@@ -2951,18 +2985,10 @@ const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2951
2985
  up: zn
2952
2986
  }, Symbol.toStringTag, { value: "Module" }));
2953
2987
  async function Un(t) {
2954
- await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
2955
- "tenant_id",
2956
- "varchar(255)",
2957
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
2958
- ).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(
2959
- "synchronous",
2960
- "boolean",
2961
- (e) => e.defaultTo(!1).notNull()
2962
- ).addColumn("priority", "integer").execute();
2988
+ await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
2963
2989
  }
2964
2990
  async function Kn(t) {
2965
- await t.schema.dropTable("hooks").execute();
2991
+ await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
2966
2992
  }
2967
2993
  const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2968
2994
  __proto__: null,
@@ -2979,8 +3005,18 @@ const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2979
3005
  up: Qn
2980
3006
  }, Symbol.toStringTag, { value: "Module" }));
2981
3007
  async function qn(t) {
3008
+ await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3009
+ "tenant_id",
3010
+ "varchar(255)",
3011
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
3012
+ ).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(
3013
+ "synchronous",
3014
+ "boolean",
3015
+ (e) => e.defaultTo(!1).notNull()
3016
+ ).addColumn("priority", "integer").execute();
2982
3017
  }
2983
3018
  async function Gn(t) {
3019
+ await t.schema.dropTable("hooks").execute();
2984
3020
  }
2985
3021
  const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2986
3022
  __proto__: null,
@@ -2988,6 +3024,24 @@ const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2988
3024
  up: qn
2989
3025
  }, Symbol.toStringTag, { value: "Module" }));
2990
3026
  async function Xn(t) {
3027
+ }
3028
+ async function Yn(t) {
3029
+ }
3030
+ const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3031
+ __proto__: null,
3032
+ down: Yn,
3033
+ up: Xn
3034
+ }, Symbol.toStringTag, { value: "Module" }));
3035
+ async function eo(t) {
3036
+ }
3037
+ async function to(t) {
3038
+ }
3039
+ const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3040
+ __proto__: null,
3041
+ down: to,
3042
+ up: eo
3043
+ }, Symbol.toStringTag, { value: "Module" }));
3044
+ async function ao(t) {
2991
3045
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
2992
3046
  "tenant_id",
2993
3047
  "varchar(255)",
@@ -3004,7 +3058,7 @@ async function Xn(t) {
3004
3058
  (e) => e.onDelete("cascade")
3005
3059
  ).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();
3006
3060
  }
3007
- async function Yn(t) {
3061
+ async function no(t) {
3008
3062
  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(
3009
3063
  "codes_user_id_tenant_id_constraint",
3010
3064
  ["user_id", "tenant_id"],
@@ -3013,36 +3067,14 @@ async function Yn(t) {
3013
3067
  (e) => e.onDelete("cascade")
3014
3068
  ).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();
3015
3069
  }
3016
- const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3017
- __proto__: null,
3018
- down: Yn,
3019
- up: Xn
3020
- }, Symbol.toStringTag, { value: "Module" }));
3021
- async function eo(t) {
3022
- }
3023
- async function to(t) {
3024
- }
3025
- const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3026
- __proto__: null,
3027
- down: to,
3028
- up: eo
3029
- }, Symbol.toStringTag, { value: "Module" }));
3030
- async function ro(t) {
3031
- await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3032
- }
3033
- async function no(t) {
3034
- await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3035
- }
3036
3070
  const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3037
3071
  __proto__: null,
3038
3072
  down: no,
3039
- up: ro
3073
+ up: ao
3040
3074
  }, Symbol.toStringTag, { value: "Module" }));
3041
3075
  async function so(t) {
3042
- await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3043
3076
  }
3044
3077
  async function io(t) {
3045
- await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3046
3078
  }
3047
3079
  const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3048
3080
  __proto__: null,
@@ -3050,8 +3082,10 @@ const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3050
3082
  up: so
3051
3083
  }, Symbol.toStringTag, { value: "Module" }));
3052
3084
  async function co(t) {
3085
+ await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3053
3086
  }
3054
3087
  async function uo(t) {
3088
+ await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3055
3089
  }
3056
3090
  const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3057
3091
  __proto__: null,
@@ -3059,8 +3093,10 @@ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3059
3093
  up: co
3060
3094
  }, Symbol.toStringTag, { value: "Module" }));
3061
3095
  async function ho(t) {
3096
+ await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3062
3097
  }
3063
3098
  async function fo(t) {
3099
+ await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3064
3100
  }
3065
3101
  const _o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3066
3102
  __proto__: null,
@@ -3068,10 +3104,8 @@ const _o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3068
3104
  up: ho
3069
3105
  }, Symbol.toStringTag, { value: "Module" }));
3070
3106
  async function po(t) {
3071
- await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3072
3107
  }
3073
3108
  async function go(t) {
3074
- await t.schema.alterTable("logins").dropColumn("nonce").execute();
3075
3109
  }
3076
3110
  const wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3077
3111
  __proto__: null,
@@ -3088,8 +3122,10 @@ const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3088
3122
  up: yo
3089
3123
  }, Symbol.toStringTag, { value: "Module" }));
3090
3124
  async function bo(t) {
3125
+ await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3091
3126
  }
3092
3127
  async function Co(t) {
3128
+ await t.schema.alterTable("logins").dropColumn("nonce").execute();
3093
3129
  }
3094
3130
  const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3095
3131
  __proto__: null,
@@ -3097,6 +3133,24 @@ const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3097
3133
  up: bo
3098
3134
  }, Symbol.toStringTag, { value: "Module" }));
3099
3135
  async function To(t) {
3136
+ }
3137
+ async function So(t) {
3138
+ }
3139
+ const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3140
+ __proto__: null,
3141
+ down: So,
3142
+ up: To
3143
+ }, Symbol.toStringTag, { value: "Module" }));
3144
+ async function ko(t) {
3145
+ }
3146
+ async function $o(t) {
3147
+ }
3148
+ const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3149
+ __proto__: null,
3150
+ down: $o,
3151
+ up: ko
3152
+ }, Symbol.toStringTag, { value: "Module" }));
3153
+ async function Do(t) {
3100
3154
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
3101
3155
  "tenant_id",
3102
3156
  "varchar(255)",
@@ -3112,7 +3166,7 @@ async function To(t) {
3112
3166
  "code_type"
3113
3167
  ]).execute();
3114
3168
  }
3115
- async function So(t) {
3169
+ async function Po(t) {
3116
3170
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3117
3171
  "tenant_id",
3118
3172
  "varchar(255)",
@@ -3125,15 +3179,15 @@ async function So(t) {
3125
3179
  (e) => e.onDelete("cascade")
3126
3180
  ).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();
3127
3181
  }
3128
- const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3182
+ const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3129
3183
  __proto__: null,
3130
- down: So,
3131
- up: To
3184
+ down: Po,
3185
+ up: Do
3132
3186
  }, Symbol.toStringTag, { value: "Module" }));
3133
- async function ko(t) {
3187
+ async function Mo(t) {
3134
3188
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
3135
3189
  }
3136
- async function $o(t) {
3190
+ async function Ao(t) {
3137
3191
  await t.schema.alterTable("keys").addColumn("private_key", "varchar(2048)").addColumn("public_key", "varchar(2048)").execute(), await t.schema.createTable("otps").addColumn(
3138
3192
  "tenant_id",
3139
3193
  "varchar(255)",
@@ -3152,32 +3206,32 @@ async function $o(t) {
3152
3206
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3153
3207
  ).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();
3154
3208
  }
3155
- const Do = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3209
+ const Fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3156
3210
  __proto__: null,
3157
- down: $o,
3158
- up: ko
3211
+ down: Ao,
3212
+ up: Mo
3159
3213
  }, Symbol.toStringTag, { value: "Module" }));
3160
- async function Io(t) {
3214
+ async function Lo(t) {
3161
3215
  await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
3162
3216
  }
3163
- async function Po(t) {
3217
+ async function Eo(t) {
3164
3218
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
3165
3219
  }
3166
- const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3220
+ const zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3167
3221
  __proto__: null,
3168
- down: Po,
3169
- up: Io
3222
+ down: Eo,
3223
+ up: Lo
3170
3224
  }, Symbol.toStringTag, { value: "Module" }));
3171
- async function Mo(t) {
3225
+ async function Jo(t) {
3172
3226
  }
3173
- async function Ao(t) {
3227
+ async function Ro(t) {
3174
3228
  }
3175
- const Fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3229
+ const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3176
3230
  __proto__: null,
3177
- down: Ao,
3178
- up: Mo
3231
+ down: Ro,
3232
+ up: Jo
3179
3233
  }, Symbol.toStringTag, { value: "Module" }));
3180
- async function Lo(t) {
3234
+ async function Ko(t) {
3181
3235
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
3182
3236
  "universal_login_experience",
3183
3237
  "varchar(16)",
@@ -3196,26 +3250,8 @@ async function Lo(t) {
3196
3250
  (e) => e.defaultTo(!1).notNull()
3197
3251
  ).execute();
3198
3252
  }
3199
- async function Eo(t) {
3200
- await t.schema.dropTable("prompt_settings").execute();
3201
- }
3202
- const zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3203
- __proto__: null,
3204
- down: Eo,
3205
- up: Lo
3206
- }, Symbol.toStringTag, { value: "Module" }));
3207
- async function Jo(t) {
3208
- }
3209
- async function Ro(t) {
3210
- }
3211
- const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3212
- __proto__: null,
3213
- down: Ro,
3214
- up: Jo
3215
- }, Symbol.toStringTag, { value: "Module" }));
3216
- async function Ko(t) {
3217
- }
3218
3253
  async function Bo(t) {
3254
+ await t.schema.dropTable("prompt_settings").execute();
3219
3255
  }
3220
3256
  const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3221
3257
  __proto__: null,
@@ -3232,10 +3268,8 @@ const qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3232
3268
  up: Vo
3233
3269
  }, Symbol.toStringTag, { value: "Module" }));
3234
3270
  async function Go(t) {
3235
- await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3236
3271
  }
3237
3272
  async function Ho(t) {
3238
- await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3239
3273
  }
3240
3274
  const Xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3241
3275
  __proto__: null,
@@ -3243,10 +3277,8 @@ const Xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3243
3277
  up: Go
3244
3278
  }, Symbol.toStringTag, { value: "Module" }));
3245
3279
  async function Yo(t) {
3246
- await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
3247
3280
  }
3248
3281
  async function Zo(t) {
3249
- await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
3250
3282
  }
3251
3283
  const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3252
3284
  __proto__: null,
@@ -3254,19 +3286,21 @@ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3254
3286
  up: Yo
3255
3287
  }, Symbol.toStringTag, { value: "Module" }));
3256
3288
  async function ts(t) {
3289
+ await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3257
3290
  }
3258
- async function as(t) {
3291
+ async function rs(t) {
3292
+ await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3259
3293
  }
3260
- const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3294
+ const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3261
3295
  __proto__: null,
3262
- down: as,
3296
+ down: rs,
3263
3297
  up: ts
3264
3298
  }, Symbol.toStringTag, { value: "Module" }));
3265
3299
  async function ns(t) {
3266
- await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
3300
+ await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
3267
3301
  }
3268
3302
  async function os(t) {
3269
- await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
3303
+ await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
3270
3304
  }
3271
3305
  const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3272
3306
  __proto__: null,
@@ -3274,10 +3308,8 @@ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3274
3308
  up: ns
3275
3309
  }, Symbol.toStringTag, { value: "Module" }));
3276
3310
  async function is(t) {
3277
- await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
3278
3311
  }
3279
3312
  async function ls(t) {
3280
- await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
3281
3313
  }
3282
3314
  const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3283
3315
  __proto__: null,
@@ -3285,6 +3317,28 @@ const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3285
3317
  up: is
3286
3318
  }, Symbol.toStringTag, { value: "Module" }));
3287
3319
  async function ds(t) {
3320
+ await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
3321
+ }
3322
+ async function us(t) {
3323
+ await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
3324
+ }
3325
+ const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3326
+ __proto__: null,
3327
+ down: us,
3328
+ up: ds
3329
+ }, Symbol.toStringTag, { value: "Module" }));
3330
+ async function hs(t) {
3331
+ await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
3332
+ }
3333
+ async function fs(t) {
3334
+ await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
3335
+ }
3336
+ const _s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3337
+ __proto__: null,
3338
+ down: fs,
3339
+ up: hs
3340
+ }, Symbol.toStringTag, { value: "Module" }));
3341
+ async function ps(t) {
3288
3342
  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(
3289
3343
  "credentials",
3290
3344
  "varchar(2048)",
@@ -3295,18 +3349,18 @@ async function ds(t) {
3295
3349
  (e) => e.notNull().defaultTo("{}")
3296
3350
  ).addColumn("created_at", "varchar(29)", (e) => e.notNull()).addColumn("updated_at", "varchar(29)", (e) => e.notNull()).execute();
3297
3351
  }
3298
- async function us(t) {
3352
+ async function gs(t) {
3299
3353
  await t.schema.dropTable("email_providers").execute();
3300
3354
  }
3301
- const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3355
+ const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3302
3356
  __proto__: null,
3303
- down: us,
3304
- up: ds
3357
+ down: gs,
3358
+ up: ps
3305
3359
  }, Symbol.toStringTag, { value: "Module" }));
3306
- async function hs(t) {
3360
+ async function ys(t) {
3307
3361
  await t.schema.dropTable("tickets").execute();
3308
3362
  }
3309
- async function fs(t) {
3363
+ async function Ns(t) {
3310
3364
  await t.schema.createTable("tickets").addColumn(
3311
3365
  "tenant_id",
3312
3366
  "varchar(255)",
@@ -3317,123 +3371,120 @@ async function fs(t) {
3317
3371
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3318
3372
  ).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();
3319
3373
  }
3320
- const _s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3374
+ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3321
3375
  __proto__: null,
3322
- down: fs,
3323
- up: hs
3376
+ down: Ns,
3377
+ up: ys
3324
3378
  }, Symbol.toStringTag, { value: "Module" }));
3325
- async function ps(t) {
3379
+ async function bs(t) {
3326
3380
  }
3327
- async function gs(t) {
3381
+ async function Cs(t) {
3328
3382
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3329
3383
  }
3330
- const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3384
+ const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3331
3385
  __proto__: null,
3332
- down: gs,
3333
- up: ps
3386
+ down: Cs,
3387
+ up: bs
3334
3388
  }, Symbol.toStringTag, { value: "Module" }));
3335
- async function ys(t) {
3389
+ async function Ts(t) {
3336
3390
  await t.schema.createTable("refresh_tokens").addColumn(
3337
3391
  "tenant_id",
3338
3392
  "varchar(255)",
3339
3393
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3340
- ).addColumn("refresh_token", "varchar(255)", (e) => e.notNull()).addColumn(
3394
+ ).addColumn("token", "varchar(255)", (e) => e.notNull()).addColumn(
3341
3395
  "session_id",
3342
3396
  "varchar(255)",
3343
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3344
- ).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").addColumn("revoked_at", "varchar(255)").addColumn(
3397
+ (e) => e.references("sessions.session_id").onDelete("cascade").notNull()
3398
+ ).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").addColumn("scope", "varchar(512)", (e) => e.notNull()).addColumn("audience", "varchar(512)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn(
3345
3399
  "created_at",
3346
3400
  "varchar(255)",
3347
3401
  (e) => e.notNull().defaultTo((/* @__PURE__ */ new Date()).toISOString())
3348
- ).addPrimaryKeyConstraint("refresh_tokens_pkey", [
3349
- "tenant_id",
3350
- "refresh_token"
3351
- ]).execute();
3402
+ ).addPrimaryKeyConstraint("refresh_tokens_pkey", ["tenant_id", "token"]).execute();
3352
3403
  }
3353
- async function Ns(t) {
3404
+ async function Ss(t) {
3354
3405
  await t.schema.dropTable("refresh_tokens").execute();
3355
3406
  }
3356
- const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3407
+ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3357
3408
  __proto__: null,
3358
- down: Ns,
3359
- up: ys
3409
+ down: Ss,
3410
+ up: Ts
3360
3411
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3361
- m1_init: Ia,
3362
- m2_magicLink: Ma,
3363
- m3_updateAt: La,
3364
- m4_logTable: Ja,
3365
- m5_userProfile: Ka,
3366
- m6_sessions: Va,
3367
- m7_passwords: Ga,
3368
- m8_logsTableNewFields: Ya,
3369
- m9_passwordTableNewField: tr,
3370
- n01_codesTable: nr,
3371
- n11_universalLoginSession: ir,
3372
- n12_userFields: dr,
3373
- n13_userEmailIndex: hr,
3374
- n14_profileDataField: pr,
3375
- n15_userEmailIndex: yr,
3376
- n16_userLocale: br,
3377
- n17_signingKeys: Tr,
3378
- n18_logsFields: kr,
3379
- n19_connectionsUserinfo: Ir,
3380
- n20_missingFields: Mr,
3381
- n21_sessionDeletedAt: Lr,
3382
- n22_dropLogsFields: Jr,
3383
- n23_dropUsersFields: Kr,
3384
- n24_logsIndexes: Vr,
3385
- n25_logDescMaxLength: Gr,
3386
- n26_logsTableExtraFields: Yr,
3387
- n27_usersTableNameIndex: tn,
3388
- n28_usersEmailConstrain: nn,
3389
- n29_increaseOtpStateLength: ln,
3390
- n30_increaseTicketStateLength: un,
3391
- n31_branding: fn,
3392
- n32_indexesAndNotNull: gn,
3393
- n33_vendorIdInUniversalLoginSession: Nn,
3394
- n34_auth0ClientInUniversalLoginSession: Cn,
3395
- n35_increaseUniversalSessionStateLength: Sn,
3396
- n36_authenticationCodes: $n,
3397
- n37_disableSignUps: Pn,
3398
- n38_otpIpAddress: An,
3399
- n39_increaseUserAgentLength: En,
3400
- n40_userId: Rn,
3401
- n41_hooks: Bn,
3402
- n42_userIdIndexes: Wn,
3403
- n43_userIdIndexes: Hn,
3404
- n44_codes: Zn,
3405
- n45_hookProperties: ao,
3406
- n46_loginAuth0Client: oo,
3407
- n47_loginAuth0Client: lo,
3408
- n48_saml: mo,
3409
- n49_removeFields: _o,
3410
- n50_authParamsNonce: wo,
3411
- n51_connectionid: vo,
3412
- n52_cert: xo,
3413
- n53_codes_primary_key: Oo,
3414
- n54_cleanup_tables: Do,
3415
- n55_logs_index: jo,
3416
- n56_application_fields: Fo,
3417
- n57_prompt_settings: zo,
3418
- n58_connection_client_id: Uo,
3419
- n59_connection_options: Qo,
3420
- n60_users_metadata: qo,
3421
- n61_userLocales: Xo,
3422
- n62_prompt: es,
3423
- n63_connection_cleanup: rs,
3424
- n64_act_as: ss,
3425
- n65_code_verifier: cs,
3426
- n66_email_providers: ms,
3427
- n67_drop_tickets: _s,
3428
- n68_login_useragents: ws,
3429
- n70_refresh_tokens: vs
3412
+ m1_init: Lr,
3413
+ m2_magicLink: Jr,
3414
+ m3_updateAt: Kr,
3415
+ m4_logTable: Vr,
3416
+ m5_userProfile: Gr,
3417
+ m6_sessions: Yr,
3418
+ m7_passwords: ta,
3419
+ m8_logsTableNewFields: na,
3420
+ m9_passwordTableNewField: ia,
3421
+ n01_codesTable: da,
3422
+ n11_universalLoginSession: ha,
3423
+ n12_userFields: pa,
3424
+ n13_userEmailIndex: ya,
3425
+ n14_profileDataField: ba,
3426
+ n15_userEmailIndex: Ta,
3427
+ n16_userLocale: ka,
3428
+ n17_signingKeys: Da,
3429
+ n18_logsFields: Ma,
3430
+ n19_connectionsUserinfo: La,
3431
+ n20_missingFields: Ja,
3432
+ n21_sessionDeletedAt: Ka,
3433
+ n22_dropLogsFields: Va,
3434
+ n23_dropUsersFields: Ga,
3435
+ n24_logsIndexes: Ya,
3436
+ n25_logDescMaxLength: tn,
3437
+ n26_logsTableExtraFields: nn,
3438
+ n27_usersTableNameIndex: ln,
3439
+ n28_usersEmailConstrain: un,
3440
+ n29_increaseOtpStateLength: fn,
3441
+ n30_increaseTicketStateLength: gn,
3442
+ n31_branding: Nn,
3443
+ n32_indexesAndNotNull: Cn,
3444
+ n33_vendorIdInUniversalLoginSession: Sn,
3445
+ n34_auth0ClientInUniversalLoginSession: $n,
3446
+ n35_increaseUniversalSessionStateLength: Pn,
3447
+ n36_authenticationCodes: An,
3448
+ n37_disableSignUps: En,
3449
+ n38_otpIpAddress: Rn,
3450
+ n39_increaseUserAgentLength: Bn,
3451
+ n40_userId: Wn,
3452
+ n41_hooks: Hn,
3453
+ n42_userIdIndexes: Zn,
3454
+ n43_userIdIndexes: ro,
3455
+ n44_codes: oo,
3456
+ n45_hookProperties: lo,
3457
+ n46_loginAuth0Client: mo,
3458
+ n47_loginAuth0Client: _o,
3459
+ n48_saml: wo,
3460
+ n49_removeFields: vo,
3461
+ n50_authParamsNonce: xo,
3462
+ n51_connectionid: Oo,
3463
+ n52_cert: Io,
3464
+ n53_codes_primary_key: jo,
3465
+ n54_cleanup_tables: Fo,
3466
+ n55_logs_index: zo,
3467
+ n56_application_fields: Uo,
3468
+ n57_prompt_settings: Qo,
3469
+ n58_connection_client_id: qo,
3470
+ n59_connection_options: Xo,
3471
+ n60_users_metadata: es,
3472
+ n61_userLocales: as,
3473
+ n62_prompt: ss,
3474
+ n63_connection_cleanup: cs,
3475
+ n64_act_as: ms,
3476
+ n65_code_verifier: _s,
3477
+ n66_email_providers: ws,
3478
+ n67_drop_tickets: vs,
3479
+ n68_login_useragents: xs,
3480
+ n70_refresh_tokens: Os
3430
3481
  };
3431
- async function Ss(t, e = !1) {
3482
+ async function Ps(t, e = !1) {
3432
3483
  e && console.log("migrating...");
3433
- const a = new Fe(Le), r = new ve({
3484
+ const r = new Fe(Le), a = new ve({
3434
3485
  db: t,
3435
- provider: a
3436
- }), { error: o, results: n } = await r.migrateToLatest();
3486
+ provider: r
3487
+ }), { error: o, results: n } = await a.migrateToLatest();
3437
3488
  if (n == null || n.forEach((s) => {
3438
3489
  s.status === "Success" ? e && console.log(
3439
3490
  `migration "${s.migrationName}" was executed successfully`
@@ -3441,40 +3492,41 @@ async function Ss(t, e = !1) {
3441
3492
  }), o)
3442
3493
  throw console.error("failed to migrate"), console.error(o), o;
3443
3494
  }
3444
- async function Os(t) {
3495
+ async function js(t) {
3445
3496
  console.log("migrating...");
3446
- const e = new Fe(Le), a = new ve({
3497
+ const e = new Fe(Le), r = new ve({
3447
3498
  db: t,
3448
3499
  provider: e
3449
- }), { error: r, results: o } = await a.migrateDown();
3500
+ }), { error: a, results: o } = await r.migrateDown();
3450
3501
  if (o == null || o.forEach((n) => {
3451
3502
  n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
3452
- }), r)
3453
- throw console.error("failed to migrate"), console.error(r), r;
3503
+ }), a)
3504
+ throw console.error("failed to migrate"), console.error(a), a;
3454
3505
  }
3455
- function ks(t) {
3506
+ function Ms(t) {
3456
3507
  return {
3457
- applications: It(t),
3508
+ applications: Dt(t),
3458
3509
  branding: qt(t),
3459
3510
  clients: Et(t),
3460
3511
  codes: Tt(t),
3461
3512
  connections: Lt(t),
3462
- emailProviders: wa(t),
3513
+ emailProviders: wr(t),
3463
3514
  domains: Qt(t),
3464
- hooks: ea(t),
3515
+ hooks: er(t),
3465
3516
  keys: Ut(t),
3466
- logins: ua(t),
3517
+ logins: ur(t),
3467
3518
  logs: ct(t),
3468
3519
  passwords: yt(t),
3469
- promptSettings: fa(t),
3470
- users: Xe(t),
3520
+ promptSettings: fr(t),
3521
+ refreshTokens: xr(t),
3471
3522
  sessions: _t(t),
3472
3523
  tenants: nt(t),
3473
- themes: sa(t)
3524
+ themes: sr(t),
3525
+ users: Xe(t)
3474
3526
  };
3475
3527
  }
3476
3528
  export {
3477
- ks as default,
3478
- Os as migrateDown,
3479
- Ss as migrateToLatest
3529
+ Ms as default,
3530
+ js as migrateDown,
3531
+ Ps as migrateToLatest
3480
3532
  };