@authhero/kysely-adapter 8.0.0 → 8.1.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 Je = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var j = (t, e, a) => Je(t, typeof e != "symbol" ? e + "" : e, a), K = (t, e, a) => e.has(t) || de("Cannot " + a);
7
- var d = (t, e, a) => (K(t, e, "read from private field"), a ? a.call(t) : e.get(t)), w = (t, e, a) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (K(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (K(t, e, "access private method"), a);
5
+ var Je = (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) => Je(t, typeof e != "symbol" ? e + "" : e, r), K = (t, e, r) => e.has(t) || de("Cannot " + r);
7
+ var d = (t, e, r) => (K(t, e, "read from private field"), r ? r.call(t) : e.get(t)), y = (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) => (K(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), u = (t, e, r) => (K(t, e, "access private method"), r);
8
8
  import { parseUserId as Y, codeSchema as ze, connectionSchema as Re, loginSchema as Ke, promptSettingSchema as Ue } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var V = class extends Error {
11
- 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();
@@ -50,18 +50,18 @@ function Be(t) {
50
50
  };
51
51
  };
52
52
  }
53
- function _(t) {
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(_) : e[a] = _(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
- function fe(t) {
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,35 +76,35 @@ function fe(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, c = {
86
+ const { tenant_id: n, ...s } = a, c = {
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
- ...o.map(fe)
100
+ ...o.map(_e)
101
101
  ]
102
102
  };
103
- return _(c);
103
+ return f(c);
104
104
  };
105
105
  }
106
- function T(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("-"), c, l, g, m;
109
109
  return n.startsWith("-_exists_:") ? (c = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (c = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [c, l] = s ? n.substring(1).split(":") : n.split(":"), g = !1, l.startsWith(">=") ? (m = ">=", l = l.substring(2)) : l.startsWith(">") ? (m = ">", l = l.substring(1)) : l.startsWith("<=") ? (m = "<=", l = l.substring(2)) : l.startsWith("<") ? (m = "<", l = l.substring(1)) : m = "=") : (c = null, l = n, g = !1), { key: c, value: l, isNegation: s, isExistsQuery: g, operator: m };
110
110
  }).forEach(({ key: n, value: s, isNegation: c, isExistsQuery: l, operator: g }) => {
@@ -133,32 +133,32 @@ function T(t, e, a, r) {
133
133
  else {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
136
- (y) => y.or(
137
- r.map((x) => y(m(x), "like", `%${s}%`))
136
+ (w) => w.or(
137
+ a.map((x) => w(m(x), "like", `%${s}%`))
138
138
  )
139
139
  );
140
140
  }
141
141
  }), e;
142
142
  }
143
- function b(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 = T(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), c = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], l = n.map((m) => {
158
- const y = c.filter(
157
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), s = n.map((m) => m.user_id), c = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], l = n.map((m) => {
158
+ const w = c.filter(
159
159
  (x) => x.linked_to === m.user_id
160
160
  );
161
- return _({
161
+ return f({
162
162
  ...m,
163
163
  email_verified: m.email_verified === 1,
164
164
  is_social: m.is_social === 1,
@@ -171,39 +171,39 @@ function Ve(t) {
171
171
  user_id: Y(m.user_id).id,
172
172
  isSocial: !!m.is_social
173
173
  },
174
- ...y.map(fe)
174
+ ...w.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: l,
180
- start: a.page * a.per_page,
181
- limit: a.per_page,
182
- length: b(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 qe(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 We(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: We(r),
196
+ ...a,
197
+ email_verified: We(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 ? _(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,37 +247,37 @@ 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: c } = t.dynamic;
253
- a = a.orderBy(c(e.sort.sort_by), e.sort.sort_order);
253
+ r = r.orderBy(c(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
- e.q && (a = a.where((c) => c.or([c("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((c) => c.or([c("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((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(n);
261
+ const { count: n } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = C(n);
262
262
  return {
263
- tenants: o.map(_),
263
+ tenants: o.map(f),
264
264
  start: (e.page - 1) * e.per_page,
265
265
  limit: e.per_page,
266
266
  length: s
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 = T(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: c } = t.dynamic;
349
349
  o = o.orderBy(
350
- c(a.sort.sort_by),
351
- a.sort.sort_order
350
+ c(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((c) => c.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((c) => c.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: b(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 ct(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 lt(t) {
@@ -375,11 +375,11 @@ function lt(t) {
375
375
  };
376
376
  }
377
377
  function dt(t) {
378
- return async (e, a) => {
379
- const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).where("sessions.revoked_at", "is", null).selectAll().executeTakeFirst();
380
- if (!r)
378
+ return async (e, r) => {
379
+ const a = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", r).where("sessions.revoked_at", "is", null).selectAll().executeTakeFirst();
380
+ if (!a)
381
381
  return null;
382
- const { tenant_id: o, device: n, clients: s, ...c } = r;
382
+ const { tenant_id: o, device: n, clients: s, ...c } = a;
383
383
  return {
384
384
  ...c,
385
385
  device: JSON.parse(n),
@@ -388,180 +388,180 @@ function dt(t) {
388
388
  };
389
389
  }
390
390
  function ut(t) {
391
- return async (e, a) => {
392
- const r = {
393
- ...a,
391
+ return async (e, r) => {
392
+ const a = {
393
+ ...r,
394
394
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
395
395
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
396
396
  authenticated_at: (/* @__PURE__ */ new Date()).toISOString(),
397
397
  last_interaction_at: (/* @__PURE__ */ new Date()).toISOString()
398
398
  };
399
399
  return await t.insertInto("sessions").values({
400
- ...r,
400
+ ...a,
401
401
  tenant_id: e,
402
- device: JSON.stringify(a.device),
403
- clients: JSON.stringify(a.clients)
404
- }).execute(), r;
402
+ device: JSON.stringify(r.device),
403
+ clients: JSON.stringify(r.clients)
404
+ }).execute(), a;
405
405
  };
406
406
  }
407
407
  function mt(t) {
408
- return async (e, a) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
408
+ return async (e, r) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
409
409
  }
410
410
  function ht(t) {
411
- return async (e, a, r) => {
411
+ return async (e, r, a) => {
412
412
  const o = {
413
- ...r,
413
+ ...a,
414
414
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
415
- device: r.device ? JSON.stringify(r.device) : void 0,
416
- clients: r.clients ? JSON.stringify(r.clients) : void 0
415
+ device: a.device ? JSON.stringify(a.device) : void 0,
416
+ clients: a.clients ? JSON.stringify(a.clients) : void 0
417
417
  };
418
- return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
418
+ return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
419
419
  };
420
420
  }
421
- function _t(t) {
422
- return async (e, a = {
421
+ function ft(t) {
422
+ return async (e, r = {
423
423
  page: 0,
424
424
  per_page: 50,
425
425
  include_totals: !1
426
426
  }) => {
427
- let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
428
- a.q && (r = T(t, r, a.q, ["user_id", "session_id"]));
429
- let o = r;
430
- if (a.sort && a.sort.sort_by) {
427
+ let a = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
428
+ r.q && (a = T(t, a, r.q, ["user_id", "session_id"]));
429
+ let o = a;
430
+ if (r.sort && r.sort.sort_by) {
431
431
  const { ref: l } = t.dynamic;
432
432
  o = o.orderBy(
433
- l(a.sort.sort_by),
434
- a.sort.sort_order
433
+ l(r.sort.sort_by),
434
+ r.sort.sort_order
435
435
  );
436
436
  }
437
- o = o.offset(a.page * a.per_page).limit(a.per_page);
438
- const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
437
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
438
+ const n = await o.selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = C(s);
439
439
  return {
440
440
  sessions: n.map((l) => ({
441
441
  ...l,
442
442
  device: JSON.parse(l.device),
443
443
  clients: JSON.parse(l.clients)
444
444
  })),
445
- start: a.page * a.per_page,
446
- limit: a.per_page,
445
+ start: r.page * r.per_page,
446
+ limit: r.per_page,
447
447
  length: c
448
448
  };
449
449
  };
450
450
  }
451
- function ft(t) {
451
+ function _t(t) {
452
452
  return {
453
453
  create: ut(t),
454
454
  get: dt(t),
455
- list: _t(t),
455
+ list: ft(t),
456
456
  remove: mt(t),
457
457
  update: ht(t)
458
458
  };
459
459
  }
460
460
  function pt(t) {
461
- return async (e, a) => {
462
- const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = r;
461
+ return async (e, r) => {
462
+ const a = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", r).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = a;
463
463
  return n;
464
464
  };
465
465
  }
466
466
  function gt(t) {
467
- return async (e, a) => {
468
- const r = {
469
- ...a,
467
+ return async (e, r) => {
468
+ const a = {
469
+ ...r,
470
470
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
471
471
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
472
472
  };
473
473
  return await t.insertInto("passwords").values({
474
- ...r,
474
+ ...a,
475
475
  tenant_id: e
476
- }).execute(), r;
476
+ }).execute(), a;
477
477
  };
478
478
  }
479
- function wt(t) {
480
- return async (e, a) => (await t.updateTable("passwords").set({
481
- password: a.password,
479
+ function yt(t) {
480
+ return async (e, r) => (await t.updateTable("passwords").set({
481
+ password: r.password,
482
482
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
483
- }).where("tenant_id", "=", e).where("user_id", "=", a.user_id).execute()).length === 1;
483
+ }).where("tenant_id", "=", e).where("user_id", "=", r.user_id).execute()).length === 1;
484
484
  }
485
- function yt(t) {
485
+ function wt(t) {
486
486
  return {
487
487
  create: gt(t),
488
- update: wt(t),
488
+ update: yt(t),
489
489
  get: pt(t)
490
490
  };
491
491
  }
492
492
  function Nt(t) {
493
- return async (e, a = {
493
+ return async (e, r = {
494
494
  page: 0,
495
495
  per_page: 50,
496
496
  include_totals: !1
497
497
  }) => {
498
- let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
499
- a.q && (r = T(t, r, a.q, ["code", "login_id"]));
500
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
498
+ let a = t.selectFrom("codes").where("codes.tenant_id", "=", e);
499
+ r.q && (a = T(t, a, r.q, ["code", "login_id"]));
500
+ 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();
501
501
  return {
502
502
  codes: n.map((l) => {
503
503
  const { tenant_id: g, ...m } = l;
504
- return ze.parse(_(m));
504
+ return ze.parse(f(m));
505
505
  }),
506
- start: a.page * a.per_page,
507
- limit: a.per_page,
508
- length: b(s)
506
+ start: r.page * r.per_page,
507
+ limit: r.per_page,
508
+ length: C(s)
509
509
  };
510
510
  };
511
511
  }
512
512
  function vt(t) {
513
- return async (e, a) => {
514
- const r = {
515
- ...a,
513
+ return async (e, r) => {
514
+ const a = {
515
+ ...r,
516
516
  created_at: (/* @__PURE__ */ new Date()).toISOString()
517
517
  };
518
518
  return await t.insertInto("codes").values({
519
- ...r,
519
+ ...a,
520
520
  tenant_id: e
521
- }).execute(), r;
521
+ }).execute(), a;
522
522
  };
523
523
  }
524
- function Ct(t) {
525
- return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
526
- }
527
524
  function bt(t) {
528
- return async (e, a, r) => {
529
- let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
525
+ return async (e, r) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
526
+ }
527
+ function Ct(t) {
528
+ return async (e, r, a) => {
529
+ let o = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
530
530
  e.length && (o = o.where("codes.tenant_id", "=", e));
531
531
  const n = await o.selectAll().executeTakeFirst();
532
- return n ? _(n) : null;
532
+ return n ? f(n) : null;
533
533
  };
534
534
  }
535
535
  function xt(t) {
536
- 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;
536
+ 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;
537
537
  }
538
538
  function Tt(t) {
539
539
  return {
540
540
  create: vt(t),
541
541
  list: Nt(t),
542
- remove: Ct(t),
542
+ remove: bt(t),
543
543
  used: xt(t),
544
- get: bt(t)
544
+ get: Ct(t)
545
545
  };
546
546
  }
547
547
  function St(t) {
548
- return async (e, a) => {
549
- const r = {
548
+ return async (e, r) => {
549
+ const a = {
550
550
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
551
551
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
552
- ...a
553
- }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), c = JSON.stringify(a.allowed_logout_urls), l = JSON.stringify(a.allowed_clients);
552
+ ...r
553
+ }, o = JSON.stringify(r.allowed_origins), n = JSON.stringify(r.callbacks), s = JSON.stringify(r.web_origins), c = JSON.stringify(r.allowed_logout_urls), l = JSON.stringify(r.allowed_clients);
554
554
  return await t.insertInto("applications").values({
555
- ...r,
555
+ ...a,
556
556
  tenant_id: e,
557
- disable_sign_ups: a.disable_sign_ups ? 1 : 0,
558
- addons: a.addons ? JSON.stringify(a.addons) : "{}",
557
+ disable_sign_ups: r.disable_sign_ups ? 1 : 0,
558
+ addons: r.addons ? JSON.stringify(r.addons) : "{}",
559
559
  callbacks: n,
560
560
  allowed_origins: o,
561
561
  web_origins: s,
562
562
  allowed_logout_urls: c,
563
563
  allowed_clients: l
564
- }).execute(), r;
564
+ }).execute(), a;
565
565
  };
566
566
  }
567
567
  function Ot(t) {
@@ -579,107 +579,107 @@ function Ot(t) {
579
579
  });
580
580
  }
581
581
  function kt(t) {
582
- return async (e, a) => {
583
- const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
584
- return r ? _({
585
- ...r,
586
- disable_sign_ups: !!r.disable_sign_ups,
587
- addons: JSON.parse(r.addons),
588
- callbacks: JSON.parse(r.callbacks),
589
- allowed_origins: JSON.parse(r.allowed_origins),
590
- web_origins: JSON.parse(r.web_origins),
591
- allowed_logout_urls: JSON.parse(r.allowed_logout_urls)
582
+ return async (e, r) => {
583
+ const a = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).selectAll().executeTakeFirst();
584
+ return a ? f({
585
+ ...a,
586
+ disable_sign_ups: !!a.disable_sign_ups,
587
+ addons: JSON.parse(a.addons),
588
+ callbacks: JSON.parse(a.callbacks),
589
+ allowed_origins: JSON.parse(a.allowed_origins),
590
+ web_origins: JSON.parse(a.web_origins),
591
+ allowed_logout_urls: JSON.parse(a.allowed_logout_urls)
592
592
  }) : null;
593
593
  };
594
594
  }
595
595
  function $t(t) {
596
- return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
596
+ return async (e, r) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
597
597
  }
598
- function Dt(t) {
599
- return async (e, a, r) => {
598
+ function It(t) {
599
+ return async (e, r, a) => {
600
600
  const o = {
601
- ...r,
601
+ ...a,
602
602
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
603
- allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
604
- callbacks: r.callbacks ? JSON.stringify(r.callbacks) : void 0,
605
- web_origins: r.web_origins ? JSON.stringify(r.web_origins) : void 0,
606
- allowed_logout_urls: r.allowed_logout_urls ? JSON.stringify(r.allowed_logout_urls) : void 0,
607
- allowed_clients: r.allowed_clients ? JSON.stringify(r.allowed_clients) : void 0,
608
- addons: r.addons ? JSON.stringify(r.addons) : "{}",
609
- disable_sign_ups: r.disable_sign_ups ? 1 : 0
603
+ allowed_origins: a.allowed_origins ? JSON.stringify(a.allowed_origins) : void 0,
604
+ callbacks: a.callbacks ? JSON.stringify(a.callbacks) : void 0,
605
+ web_origins: a.web_origins ? JSON.stringify(a.web_origins) : void 0,
606
+ allowed_logout_urls: a.allowed_logout_urls ? JSON.stringify(a.allowed_logout_urls) : void 0,
607
+ allowed_clients: a.allowed_clients ? JSON.stringify(a.allowed_clients) : void 0,
608
+ addons: a.addons ? JSON.stringify(a.addons) : "{}",
609
+ disable_sign_ups: a.disable_sign_ups ? 1 : 0
610
610
  };
611
- return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
611
+ return await t.updateTable("applications").set(o).where("applications.id", "=", r).where("applications.tenant_id", "=", e).execute(), !0;
612
612
  };
613
613
  }
614
- function It(t) {
614
+ function Dt(t) {
615
615
  return {
616
616
  create: St(t),
617
617
  list: Ot(t),
618
618
  get: kt(t),
619
619
  remove: $t(t),
620
- update: Dt(t)
620
+ update: It(t)
621
621
  };
622
622
  }
623
623
  function Pt(t) {
624
- return async (e, a) => {
625
- const r = {
624
+ return async (e, r) => {
625
+ const a = {
626
626
  id: k(),
627
- ...a,
627
+ ...r,
628
628
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
629
629
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
630
630
  };
631
631
  return await t.insertInto("connections").values({
632
- ...r,
632
+ ...a,
633
633
  // The connection options will have many different properties depending on the strategy
634
- options: JSON.stringify(r.options || {}),
634
+ options: JSON.stringify(a.options || {}),
635
635
  tenant_id: e
636
- }).execute(), r;
636
+ }).execute(), a;
637
637
  };
638
638
  }
639
639
  function jt(t) {
640
- return async (e, a = {
640
+ return async (e, r = {
641
641
  page: 0,
642
642
  per_page: 50,
643
643
  include_totals: !1
644
644
  }) => {
645
- let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
646
- a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
647
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
648
- (l) => _({
645
+ let a = t.selectFrom("connections").where("connections.tenant_id", "=", e);
646
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
647
+ const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map(
648
+ (l) => f({
649
649
  ...l,
650
650
  options: JSON.parse(l.options)
651
651
  })
652
- ), { count: c } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
652
+ ), { count: c } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
653
653
  return {
654
654
  connections: s,
655
- start: a.page * a.per_page,
656
- limit: a.per_page,
657
- length: b(c)
655
+ start: r.page * r.per_page,
656
+ limit: r.per_page,
657
+ length: C(c)
658
658
  };
659
659
  };
660
660
  }
661
661
  function Mt(t) {
662
- return async (e, a) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
662
+ return async (e, r) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
663
663
  }
664
664
  function At(t) {
665
- return async (e, a) => {
666
- const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
667
- return r ? _({
668
- ...r,
669
- options: JSON.parse(r.options)
665
+ return async (e, r) => {
666
+ const a = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).selectAll().executeTakeFirst();
667
+ return a ? f({
668
+ ...a,
669
+ options: JSON.parse(a.options)
670
670
  }) : null;
671
671
  };
672
672
  }
673
673
  function Ft(t) {
674
- return async (e, a, r) => {
674
+ return async (e, r, a) => {
675
675
  const o = {
676
- ...r,
676
+ ...a,
677
677
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
678
678
  };
679
679
  return await t.updateTable("connections").set({
680
680
  ...o,
681
681
  options: o.options ? JSON.stringify(o.options) : void 0
682
- }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
682
+ }).where("connections.id", "=", r).where("connections.tenant_id", "=", e).execute(), !0;
683
683
  };
684
684
  }
685
685
  function Lt(t) {
@@ -694,42 +694,42 @@ function Lt(t) {
694
694
  function Et(t) {
695
695
  return {
696
696
  get: async (e) => {
697
- const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
698
- if (!a)
699
- return null;
700
- const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
697
+ const r = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
701
698
  if (!r)
699
+ return null;
700
+ const a = await t.selectFrom("tenants").selectAll().where("id", "=", r.tenant_id).executeTakeFirst();
701
+ if (!a)
702
702
  throw new V(404, { message: "Tenant not found" });
703
- 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();
703
+ 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();
704
704
  return {
705
- ...a,
705
+ ...r,
706
706
  connections: o.map(
707
707
  (c) => Re.parse(
708
- _({
708
+ f({
709
709
  ...c,
710
710
  options: c.options ? JSON.parse(c.options) : {}
711
711
  })
712
712
  )
713
713
  ),
714
714
  domains: n,
715
- addons: a.addons ? JSON.parse(a.addons) : {},
716
- callbacks: a.callbacks ? JSON.parse(a.callbacks) : [],
717
- allowed_origins: a.allowed_origins ? JSON.parse(a.allowed_origins) : [],
718
- web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
719
- allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
720
- allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
721
- tenant: _(r),
715
+ addons: r.addons ? JSON.parse(r.addons) : {},
716
+ callbacks: r.callbacks ? JSON.parse(r.callbacks) : [],
717
+ allowed_origins: r.allowed_origins ? JSON.parse(r.allowed_origins) : [],
718
+ web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
719
+ allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
720
+ allowed_clients: r.allowed_clients ? JSON.parse(r.allowed_clients) : [],
721
+ tenant: f(a),
722
722
  // this is really an integer in the database
723
- disable_sign_ups: !!a.disable_sign_ups
723
+ disable_sign_ups: !!r.disable_sign_ups
724
724
  };
725
725
  }
726
726
  };
727
727
  }
728
728
  function Jt(t) {
729
729
  return async () => await t.selectFrom("keys").where(
730
- (a) => a.or([
731
- a("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
732
- a("revoked_at", "is", null)
730
+ (r) => r.or([
731
+ r("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
732
+ r("revoked_at", "is", null)
733
733
  ])
734
734
  ).selectAll().execute();
735
735
  }
@@ -739,7 +739,7 @@ function zt(t) {
739
739
  };
740
740
  }
741
741
  function Rt(t) {
742
- return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
742
+ return async (e, r) => !!(await t.updateTable("keys").set(r).where("kid", "=", e).execute()).length;
743
743
  }
744
744
  function Kt(t) {
745
745
  return {
@@ -749,27 +749,27 @@ function Kt(t) {
749
749
  };
750
750
  }
751
751
  function Ut(t) {
752
- return async (e, a) => {
753
- const r = {
752
+ return async (e, r) => {
753
+ const a = {
754
754
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
755
755
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
756
756
  tenant_id: e,
757
757
  id: k(),
758
- ...a
758
+ ...r
759
759
  };
760
- return await t.insertInto("domains").values(r).execute(), r;
760
+ return await t.insertInto("domains").values(a).execute(), a;
761
761
  };
762
762
  }
763
763
  function Bt(t) {
764
- return async (e, a) => {
765
- let r = t.selectFrom("domains").where("domains.tenant_id", "=", e);
766
- a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
767
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
764
+ return async (e, r) => {
765
+ let a = t.selectFrom("domains").where("domains.tenant_id", "=", e);
766
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
767
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
768
768
  return {
769
769
  domains: n,
770
- start: a.page * a.per_page,
771
- limit: a.per_page,
772
- length: b(s)
770
+ start: r.page * r.per_page,
771
+ limit: r.per_page,
772
+ length: C(s)
773
773
  };
774
774
  };
775
775
  }
@@ -781,11 +781,11 @@ function Qt(t) {
781
781
  }
782
782
  function Vt(t) {
783
783
  return async (e) => {
784
- const [a] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
785
- if (!a)
784
+ const [r] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
785
+ if (!r)
786
786
  return null;
787
787
  const {
788
- tenant_id: r,
788
+ tenant_id: a,
789
789
  colors_primary: o,
790
790
  colors_page_background_type: n,
791
791
  colors_page_background_start: s,
@@ -793,8 +793,8 @@ function Vt(t) {
793
793
  colors_page_background_angle_dev: l,
794
794
  font_url: g,
795
795
  ...m
796
- } = a;
797
- return _({
796
+ } = r;
797
+ return f({
798
798
  ...m,
799
799
  colors: {
800
800
  primary: o,
@@ -810,29 +810,29 @@ function Vt(t) {
810
810
  };
811
811
  }
812
812
  function qt(t) {
813
- return async (e, a) => {
814
- var s, c, l, g, m, y, x, Z, ee, te, ae, re, ne, oe, se, ie, ce, le;
815
- const { colors: r, font: o, ...n } = a;
813
+ return async (e, r) => {
814
+ var s, c, l, g, m, w, x, Z, ee, te, re, ae, ne, oe, se, ie, ce, le;
815
+ const { colors: a, font: o, ...n } = r;
816
816
  try {
817
817
  await t.insertInto("branding").values({
818
818
  ...n,
819
- colors_primary: r == null ? void 0 : r.primary,
820
- colors_page_background_type: (c = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
821
- colors_page_background_start: (g = (l = a.colors) == null ? void 0 : l.page_background) == null ? void 0 : g.start,
822
- colors_page_background_end: (y = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : y.end,
823
- colors_page_background_angle_dev: (Z = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
824
- font_url: (ee = a.font) == null ? void 0 : ee.url,
819
+ colors_primary: a == null ? void 0 : a.primary,
820
+ colors_page_background_type: (c = (s = r.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
821
+ colors_page_background_start: (g = (l = r.colors) == null ? void 0 : l.page_background) == null ? void 0 : g.start,
822
+ colors_page_background_end: (w = (m = r.colors) == null ? void 0 : m.page_background) == null ? void 0 : w.end,
823
+ colors_page_background_angle_dev: (Z = (x = r.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
824
+ font_url: (ee = r.font) == null ? void 0 : ee.url,
825
825
  tenant_id: e
826
826
  }).execute();
827
827
  } catch {
828
828
  await t.updateTable("branding").set({
829
829
  ...n,
830
- colors_primary: r == null ? void 0 : r.primary,
831
- colors_page_background_type: (ae = (te = a.colors) == null ? void 0 : te.page_background) == null ? void 0 : ae.type,
832
- colors_page_background_start: (ne = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : ne.start,
833
- colors_page_background_end: (se = (oe = a.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
834
- colors_page_background_angle_dev: (ce = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : ce.angle_deg,
835
- font_url: (le = a.font) == null ? void 0 : le.url
830
+ colors_primary: a == null ? void 0 : a.primary,
831
+ colors_page_background_type: (re = (te = r.colors) == null ? void 0 : te.page_background) == null ? void 0 : re.type,
832
+ colors_page_background_start: (ne = (ae = r.colors) == null ? void 0 : ae.page_background) == null ? void 0 : ne.start,
833
+ colors_page_background_end: (se = (oe = r.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
834
+ colors_page_background_angle_dev: (ce = (ie = r.colors) == null ? void 0 : ie.page_background) == null ? void 0 : ce.angle_deg,
835
+ font_url: (le = r.font) == null ? void 0 : le.url
836
836
  }).where("tenant_id", "=", e).execute();
837
837
  }
838
838
  };
@@ -844,70 +844,70 @@ function Wt(t) {
844
844
  };
845
845
  }
846
846
  function Gt(t) {
847
- return async (e, a = {
847
+ return async (e, r = {
848
848
  page: 0,
849
849
  per_page: 50,
850
850
  include_totals: !1
851
851
  }) => {
852
- let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
853
- a.q && (r = T(t, r, a.q, ["url"]));
854
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
852
+ let a = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
853
+ r.q && (a = T(t, a, r.q, ["url"]));
854
+ 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();
855
855
  return {
856
856
  hooks: n.map((l) => {
857
- const { tenant_id: g, enabled: m, synchronous: y, ...x } = l;
858
- return _({
857
+ const { tenant_id: g, enabled: m, synchronous: w, ...x } = l;
858
+ return f({
859
859
  ...x,
860
860
  enabled: !!m,
861
- synchronous: !!y
861
+ synchronous: !!w
862
862
  });
863
863
  }),
864
- start: a.page * a.per_page,
865
- limit: a.per_page,
866
- length: b(s)
864
+ start: r.page * r.per_page,
865
+ limit: r.per_page,
866
+ length: C(s)
867
867
  };
868
868
  };
869
869
  }
870
870
  function Ht(t) {
871
- return async (e, a) => {
872
- const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
873
- return r ? _({
874
- ...r,
875
- enabled: !!r.enabled,
876
- synchronous: !!r.synchronous
871
+ return async (e, r) => {
872
+ const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).selectAll().executeTakeFirst();
873
+ return a ? f({
874
+ ...a,
875
+ enabled: !!a.enabled,
876
+ synchronous: !!a.synchronous
877
877
  }) : null;
878
878
  };
879
879
  }
880
880
  function Xt(t) {
881
- return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
881
+ return async (e, r) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
882
882
  }
883
883
  function Yt(t) {
884
- return async (e, a) => {
885
- const r = {
884
+ return async (e, r) => {
885
+ const a = {
886
886
  hook_id: k(),
887
- ...a,
887
+ ...r,
888
888
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
889
889
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
890
890
  };
891
891
  return await t.insertInto("hooks").values({
892
- ...r,
892
+ ...a,
893
893
  tenant_id: e,
894
- enabled: a.enabled ? 1 : 0,
895
- synchronous: a.synchronous ? 1 : 0
896
- }).execute(), r;
894
+ enabled: r.enabled ? 1 : 0,
895
+ synchronous: r.synchronous ? 1 : 0
896
+ }).execute(), a;
897
897
  };
898
898
  }
899
899
  function Zt(t) {
900
- return async (e, a, r) => {
900
+ return async (e, r, a) => {
901
901
  const o = {
902
- ...r,
902
+ ...a,
903
903
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
904
- enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
905
- synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
904
+ enabled: a.enabled !== void 0 ? a.enabled ? 1 : 0 : void 0,
905
+ synchronous: a.enabled !== void 0 ? a.synchronous ? 1 : 0 : void 0
906
906
  };
907
- return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
907
+ return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", r).where("hooks.tenant_id", "=", e).execute(), !0;
908
908
  };
909
909
  }
910
- function ea(t) {
910
+ function er(t) {
911
911
  return {
912
912
  create: Yt(t),
913
913
  get: Ht(t),
@@ -916,115 +916,115 @@ function ea(t) {
916
916
  remove: Xt(t)
917
917
  };
918
918
  }
919
- function J(t, e = "", a = {}) {
920
- for (let r in t)
921
- if (Object.prototype.hasOwnProperty.call(t, r)) {
922
- const o = e ? `${e}_${r}` : r;
923
- typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? J(t[r], o, a) : a[o] = t[r];
919
+ function J(t, e = "", r = {}) {
920
+ for (let a in t)
921
+ if (Object.prototype.hasOwnProperty.call(t, a)) {
922
+ const o = e ? `${e}_${a}` : a;
923
+ typeof t[a] == "object" && t[a] !== null && !Array.isArray(t[a]) ? J(t[a], o, r) : r[o] = t[a];
924
924
  }
925
- return a;
925
+ return r;
926
926
  }
927
- function ta(t, e) {
928
- const a = {};
929
- for (const [r, o] of Object.entries(t)) {
927
+ function tr(t, e) {
928
+ const r = {};
929
+ for (const [a, o] of Object.entries(t)) {
930
930
  const n = e.find(
931
- (s) => r.startsWith(`${s}_`)
931
+ (s) => a.startsWith(`${s}_`)
932
932
  );
933
933
  if (!n)
934
- a[r] = o;
934
+ r[a] = o;
935
935
  else {
936
- const s = r.slice(n.length + 1);
937
- a[n] = {
938
- ...a[n],
936
+ const s = a.slice(n.length + 1);
937
+ r[n] = {
938
+ ...r[n],
939
939
  [s]: o
940
940
  };
941
941
  }
942
942
  }
943
- return a;
943
+ return r;
944
944
  }
945
- function aa(t) {
946
- return async (e, a) => {
947
- const r = {
945
+ function rr(t) {
946
+ return async (e, r) => {
947
+ const a = {
948
948
  themeId: k(),
949
- ...a,
949
+ ...r,
950
950
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
951
951
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
952
952
  };
953
- return await t.insertInto("themes").values({ ...J(r), tenant_id: e }).execute(), r;
953
+ return await t.insertInto("themes").values({ ...J(a), tenant_id: e }).execute(), a;
954
954
  };
955
955
  }
956
- function ra(t) {
957
- return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
956
+ function ar(t) {
957
+ return async (e, r) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
958
958
  }
959
- function na(t) {
960
- return async (e, a) => {
961
- const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
962
- return r ? _(r) : null;
959
+ function nr(t) {
960
+ return async (e, r) => {
961
+ const a = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).selectAll().executeTakeFirst();
962
+ return a ? f(a) : null;
963
963
  };
964
964
  }
965
- function oa(t) {
966
- return async (e, a, r) => {
965
+ function or(t) {
966
+ return async (e, r, a) => {
967
967
  const o = J({
968
- ...r,
968
+ ...a,
969
969
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
970
970
  });
971
- return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
971
+ return await t.updateTable("themes").set(o).where("themes.id", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
972
972
  };
973
973
  }
974
- function sa(t) {
974
+ function sr(t) {
975
975
  return {
976
- create: aa(t),
977
- get: na(t),
978
- remove: ra(t),
979
- update: oa(t)
976
+ create: rr(t),
977
+ get: nr(t),
978
+ remove: ar(t),
979
+ update: or(t)
980
980
  };
981
981
  }
982
- function ia(t) {
983
- return async (e, a) => {
984
- const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", r).where("logins.login_id", "=", a).selectAll().executeTakeFirst();
982
+ function ir(t) {
983
+ return async (e, r) => {
984
+ const a = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", a).where("logins.login_id", "=", r).selectAll().executeTakeFirst();
985
985
  return o ? Ke.parse(
986
- ta(_(o), ["authParams"])
986
+ tr(f(o), ["authParams"])
987
987
  ) : null;
988
988
  };
989
989
  }
990
- function ca(t) {
991
- return async (e, a) => {
992
- const r = {
990
+ function cr(t) {
991
+ return async (e, r) => {
992
+ const a = {
993
993
  login_id: k(),
994
- ...a,
994
+ ...r,
995
995
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
996
996
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
997
997
  };
998
- return await t.insertInto("logins").values({ ...J(r), tenant_id: e }).execute(), r;
998
+ return await t.insertInto("logins").values({ ...J(a), tenant_id: e }).execute(), a;
999
999
  };
1000
1000
  }
1001
- function la(t) {
1002
- return async (e, a, r) => (await t.updateTable("logins").set(J(r)).where("logins.login_id", "=", a).where("logins.tenant_id", "=", e).execute()).length === 1;
1001
+ function lr(t) {
1002
+ return async (e, r, a) => (await t.updateTable("logins").set(J(a)).where("logins.login_id", "=", r).where("logins.tenant_id", "=", e).execute()).length === 1;
1003
1003
  }
1004
- function da(t) {
1005
- return async (e, a) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", a).execute()).length > 0;
1004
+ function dr(t) {
1005
+ return async (e, r) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", r).execute()).length > 0;
1006
1006
  }
1007
- function ua(t) {
1007
+ function ur(t) {
1008
1008
  return {
1009
- create: ca(t),
1010
- get: ia(t),
1011
- update: la(t),
1012
- remove: da(t)
1009
+ create: cr(t),
1010
+ get: ir(t),
1011
+ update: lr(t),
1012
+ remove: dr(t)
1013
1013
  };
1014
1014
  }
1015
- function ma(t) {
1015
+ function mr(t) {
1016
1016
  return async (e) => {
1017
- const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1018
- return _({
1019
- identifier_first: !!(a != null && a.identifier_first),
1020
- password_first: !!(a != null && a.password_first),
1021
- webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
1022
- universal_login_experience: (a == null ? void 0 : a.universal_login_experience) || "new"
1017
+ const [r] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1018
+ return f({
1019
+ identifier_first: !!(r != null && r.identifier_first),
1020
+ password_first: !!(r != null && r.password_first),
1021
+ webauthn_platform_first_factor: !!(r != null && r.webauthn_platform_first_factor),
1022
+ universal_login_experience: (r == null ? void 0 : r.universal_login_experience) || "new"
1023
1023
  });
1024
1024
  };
1025
1025
  }
1026
1026
  function he(t) {
1027
- return _({
1027
+ return f({
1028
1028
  ...t,
1029
1029
  webauthn_platform_first_factor: t.webauthn_platform_first_factor ? !!t.webauthn_platform_first_factor : void 0,
1030
1030
  identifier_first: t.identifier_first ? !!t.identifier_first : void 0,
@@ -1032,38 +1032,38 @@ function he(t) {
1032
1032
  universal_login_experience: t.universal_login_experience
1033
1033
  });
1034
1034
  }
1035
- function ha(t) {
1036
- return async (e, a) => {
1035
+ function hr(t) {
1036
+ return async (e, r) => {
1037
1037
  try {
1038
- const r = Ue.parse(a);
1038
+ const a = Ue.parse(r);
1039
1039
  await t.insertInto("prompt_settings").values({
1040
- ...he(r),
1040
+ ...he(a),
1041
1041
  tenant_id: e
1042
1042
  }).execute();
1043
1043
  } catch {
1044
- await t.updateTable("prompt_settings").set(he(a)).where("tenant_id", "=", e).execute();
1044
+ await t.updateTable("prompt_settings").set(he(r)).where("tenant_id", "=", e).execute();
1045
1045
  }
1046
1046
  };
1047
1047
  }
1048
- function _a(t) {
1048
+ function fr(t) {
1049
1049
  return {
1050
- get: ma(t),
1051
- set: ha(t)
1050
+ get: mr(t),
1051
+ set: hr(t)
1052
1052
  };
1053
1053
  }
1054
- function fa(t) {
1054
+ function _r(t) {
1055
1055
  return async (e) => {
1056
- const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1057
- if (!a)
1056
+ const [r] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1057
+ if (!r)
1058
1058
  return null;
1059
1059
  const {
1060
- tenant_id: r,
1060
+ tenant_id: a,
1061
1061
  credentials: o,
1062
1062
  settings: n,
1063
1063
  enabled: s,
1064
1064
  ...c
1065
- } = a;
1066
- return _({
1065
+ } = r;
1066
+ return f({
1067
1067
  ...c,
1068
1068
  credentials: JSON.parse(o),
1069
1069
  settings: JSON.parse(n),
@@ -1071,24 +1071,24 @@ function fa(t) {
1071
1071
  });
1072
1072
  };
1073
1073
  }
1074
- function pa(t) {
1075
- return async (e, a) => {
1076
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1074
+ function pr(t) {
1075
+ return async (e, r) => {
1076
+ const { credentials: a, settings: o, enabled: n, ...s } = r;
1077
1077
  await t.updateTable("email_providers").set({
1078
1078
  ...s,
1079
- credentials: r ? JSON.stringify(r) : void 0,
1079
+ credentials: a ? JSON.stringify(a) : void 0,
1080
1080
  settings: o ? JSON.stringify(o) : void 0,
1081
1081
  enabled: n !== void 0 ? n ? 1 : 0 : void 0
1082
1082
  }).where("tenant_id", "=", e).execute();
1083
1083
  };
1084
1084
  }
1085
- function ga(t) {
1086
- return async (e, a) => {
1087
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1085
+ function gr(t) {
1086
+ return async (e, r) => {
1087
+ const { credentials: a, settings: o, enabled: n, ...s } = r;
1088
1088
  await t.insertInto("email_providers").values({
1089
1089
  ...s,
1090
1090
  enabled: n ? 1 : 0,
1091
- credentials: JSON.stringify(r),
1091
+ credentials: JSON.stringify(a),
1092
1092
  settings: JSON.stringify(o),
1093
1093
  tenant_id: e,
1094
1094
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1096,71 +1096,71 @@ function ga(t) {
1096
1096
  }).execute();
1097
1097
  };
1098
1098
  }
1099
- function wa(t) {
1099
+ function yr(t) {
1100
1100
  return {
1101
- get: fa(t),
1102
- create: ga(t),
1103
- update: pa(t)
1101
+ get: _r(t),
1102
+ create: gr(t),
1103
+ update: pr(t)
1104
1104
  };
1105
1105
  }
1106
- function ya(t) {
1107
- return async (e, a) => {
1108
- const r = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.token", "=", a).selectAll().executeTakeFirst();
1109
- return r ? {
1110
- ...r,
1111
- rotating: !!r.rotating,
1112
- device: r.device ? JSON.parse(r.device) : {},
1113
- resource_servers: r.resource_servers ? JSON.parse(r.resource_servers) : []
1106
+ function wr(t) {
1107
+ return async (e, r) => {
1108
+ const a = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", r).selectAll().executeTakeFirst();
1109
+ return a ? {
1110
+ ...a,
1111
+ rotating: !!a.rotating,
1112
+ device: a.device ? JSON.parse(a.device) : {},
1113
+ resource_servers: a.resource_servers ? JSON.parse(a.resource_servers) : []
1114
1114
  } : null;
1115
1115
  };
1116
1116
  }
1117
- function Na(t) {
1118
- return async (e, a) => {
1119
- const r = {
1120
- ...a,
1117
+ function Nr(t) {
1118
+ return async (e, r) => {
1119
+ const a = {
1120
+ ...r,
1121
1121
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1122
1122
  };
1123
1123
  return await t.insertInto("refresh_tokens").values({
1124
- ...r,
1124
+ ...a,
1125
1125
  tenant_id: e,
1126
- rotating: a.rotating ? 1 : 0,
1127
- device: JSON.stringify(a.device),
1128
- resource_servers: JSON.stringify(a.resource_servers)
1129
- }).execute(), { ...a, ...r };
1126
+ rotating: r.rotating ? 1 : 0,
1127
+ device: JSON.stringify(r.device),
1128
+ resource_servers: JSON.stringify(r.resource_servers)
1129
+ }).execute(), { ...r, ...a };
1130
1130
  };
1131
1131
  }
1132
- function va(t) {
1133
- return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1132
+ function vr(t) {
1133
+ return async (e, r) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1134
1134
  }
1135
- function Ca(t) {
1136
- return async (e, a, r) => {
1135
+ function br(t) {
1136
+ return async (e, r, a) => {
1137
1137
  const o = {
1138
- ...r,
1139
- device: r.device ? JSON.stringify(r.device) : void 0,
1140
- resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
1141
- rotating: r.rotating ? 1 : 0
1138
+ ...a,
1139
+ device: a.device ? JSON.stringify(a.device) : void 0,
1140
+ resource_servers: a.resource_servers ? JSON.stringify(a.resource_servers) : void 0,
1141
+ rotating: a.rotating ? 1 : 0
1142
1142
  };
1143
- return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1143
+ return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1144
1144
  };
1145
1145
  }
1146
- function ba(t) {
1147
- return async (e, a = {
1146
+ function Cr(t) {
1147
+ return async (e, r = {
1148
1148
  page: 0,
1149
1149
  per_page: 50,
1150
1150
  include_totals: !1
1151
1151
  }) => {
1152
- let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1153
- a.q && (r = T(t, r, a.q, ["token", "session_id"]));
1154
- let o = r;
1155
- if (a.sort && a.sort.sort_by) {
1152
+ let a = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1153
+ r.q && (a = T(t, a, r.q, ["token", "session_id"]));
1154
+ let o = a;
1155
+ if (r.sort && r.sort.sort_by) {
1156
1156
  const { ref: l } = t.dynamic;
1157
1157
  o = o.orderBy(
1158
- l(a.sort.sort_by),
1159
- a.sort.sort_order
1158
+ l(r.sort.sort_by),
1159
+ r.sort.sort_order
1160
1160
  );
1161
1161
  }
1162
- o = o.offset(a.page * a.per_page).limit(a.per_page);
1163
- const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
1162
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
1163
+ const n = await o.selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = C(s);
1164
1164
  return {
1165
1165
  refresh_tokens: n.map((l) => ({
1166
1166
  ...l,
@@ -1168,22 +1168,22 @@ function ba(t) {
1168
1168
  device: l.device ? JSON.parse(l.device) : {},
1169
1169
  resource_servers: l.resource_servers ? JSON.parse(l.resource_servers) : []
1170
1170
  })),
1171
- start: a.page * a.per_page,
1172
- limit: a.per_page,
1171
+ start: r.page * r.per_page,
1172
+ limit: r.per_page,
1173
1173
  length: c
1174
1174
  };
1175
1175
  };
1176
1176
  }
1177
- function xa(t) {
1177
+ function xr(t) {
1178
1178
  return {
1179
- create: Na(t),
1180
- get: ya(t),
1181
- list: ba(t),
1182
- remove: va(t),
1183
- update: Ca(t)
1179
+ create: Nr(t),
1180
+ get: wr(t),
1181
+ list: Cr(t),
1182
+ remove: vr(t),
1183
+ update: br(t)
1184
1184
  };
1185
1185
  }
1186
- function Ta(t) {
1186
+ function Tr(t) {
1187
1187
  return t[t.length - 1];
1188
1188
  }
1189
1189
  function p(t) {
@@ -1216,7 +1216,7 @@ const z = p({
1216
1216
  identifier: z.create(e)
1217
1217
  });
1218
1218
  }
1219
- }), Sa = p({
1219
+ }), Sr = p({
1220
1220
  is(t) {
1221
1221
  return t.kind === "AliasNode";
1222
1222
  },
@@ -1245,10 +1245,10 @@ const z = p({
1245
1245
  }
1246
1246
  });
1247
1247
  var R;
1248
- class Oa {
1248
+ class Or {
1249
1249
  constructor() {
1250
1250
  j(this, "nodeStack", []);
1251
- w(this, R, p({
1251
+ y(this, R, p({
1252
1252
  AliasNode: this.transformAlias.bind(this),
1253
1253
  ColumnNode: this.transformColumn.bind(this),
1254
1254
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -1348,14 +1348,14 @@ class Oa {
1348
1348
  if (!e)
1349
1349
  return e;
1350
1350
  this.nodeStack.push(e);
1351
- const a = this.transformNodeImpl(e);
1352
- return this.nodeStack.pop(), p(a);
1351
+ const r = this.transformNodeImpl(e);
1352
+ return this.nodeStack.pop(), p(r);
1353
1353
  }
1354
1354
  transformNodeImpl(e) {
1355
1355
  return d(this, R)[e.kind](e);
1356
1356
  }
1357
1357
  transformNodeList(e) {
1358
- return e && p(e.map((a) => this.transformNode(a)));
1358
+ return e && p(e.map((r) => this.transformNode(r)));
1359
1359
  }
1360
1360
  transformSelectQuery(e) {
1361
1361
  return {
@@ -2079,7 +2079,7 @@ class Oa {
2079
2079
  }
2080
2080
  }
2081
2081
  R = new WeakMap();
2082
- const ka = p({
2082
+ const kr = p({
2083
2083
  AlterTableNode: !0,
2084
2084
  CreateIndexNode: !0,
2085
2085
  CreateSchemaNode: !0,
@@ -2098,78 +2098,78 @@ const ka = p({
2098
2098
  UpdateQueryNode: !0,
2099
2099
  MergeQueryNode: !0
2100
2100
  });
2101
- var P, S, O, f, ge, we, ye, $, W, Ne;
2102
- class $a extends Oa {
2103
- constructor(a) {
2101
+ var P, S, O, _, ge, ye, we, $, W, Ne;
2102
+ class $r extends Or {
2103
+ constructor(r) {
2104
2104
  super();
2105
- w(this, f);
2106
- w(this, P);
2107
- w(this, S, /* @__PURE__ */ new Set());
2108
- w(this, O, /* @__PURE__ */ new Set());
2109
- M(this, P, a);
2110
- }
2111
- transformNodeImpl(a) {
2112
- if (!u(this, f, ge).call(this, a))
2113
- return super.transformNodeImpl(a);
2114
- const r = u(this, f, ye).call(this, a);
2115
- for (const s of r)
2105
+ y(this, _);
2106
+ y(this, P);
2107
+ y(this, S, /* @__PURE__ */ new Set());
2108
+ y(this, O, /* @__PURE__ */ new Set());
2109
+ M(this, P, r);
2110
+ }
2111
+ transformNodeImpl(r) {
2112
+ if (!u(this, _, ge).call(this, r))
2113
+ return super.transformNodeImpl(r);
2114
+ const a = u(this, _, we).call(this, r);
2115
+ for (const s of a)
2116
2116
  d(this, O).add(s);
2117
- const o = u(this, f, we).call(this, a);
2117
+ const o = u(this, _, ye).call(this, r);
2118
2118
  for (const s of o)
2119
2119
  d(this, S).add(s);
2120
- const n = super.transformNodeImpl(a);
2120
+ const n = super.transformNodeImpl(r);
2121
2121
  for (const s of o)
2122
2122
  d(this, S).delete(s);
2123
- for (const s of r)
2123
+ for (const s of a)
2124
2124
  d(this, O).delete(s);
2125
2125
  return n;
2126
2126
  }
2127
- transformSchemableIdentifier(a) {
2128
- const r = super.transformSchemableIdentifier(a);
2129
- return r.schema || !d(this, S).has(a.identifier.name) ? r : {
2130
- ...r,
2127
+ transformSchemableIdentifier(r) {
2128
+ const a = super.transformSchemableIdentifier(r);
2129
+ return a.schema || !d(this, S).has(r.identifier.name) ? a : {
2130
+ ...a,
2131
2131
  schema: z.create(d(this, P))
2132
2132
  };
2133
2133
  }
2134
- transformReferences(a) {
2135
- const r = super.transformReferences(a);
2136
- return r.table.table.schema ? r : {
2137
- ...r,
2138
- table: U.createWithSchema(d(this, P), r.table.table.identifier.name)
2139
- };
2140
- }
2141
- }
2142
- P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), f = new WeakSet(), ge = function(a) {
2143
- return a.kind in ka;
2144
- }, we = function(a) {
2145
- const r = /* @__PURE__ */ new Set();
2146
- if ("name" in a && a.name && q.is(a.name) && u(this, f, W).call(this, a.name, r), "from" in a && a.from)
2147
- for (const o of a.from.froms)
2148
- u(this, f, $).call(this, o, r);
2149
- if ("into" in a && a.into && u(this, f, $).call(this, a.into, r), "table" in a && a.table && u(this, f, $).call(this, a.table, r), "joins" in a && a.joins)
2150
- for (const o of a.joins)
2151
- u(this, f, $).call(this, o.table, r);
2152
- return "using" in a && a.using && u(this, f, $).call(this, a.using, r), r;
2153
- }, ye = function(a) {
2154
- const r = /* @__PURE__ */ new Set();
2155
- return "with" in a && a.with && u(this, f, Ne).call(this, a.with, r), r;
2156
- }, $ = function(a, r) {
2157
- const o = U.is(a) ? a : Sa.is(a) && U.is(a.node) ? a.node : null;
2158
- o && u(this, f, W).call(this, o.table, r);
2159
- }, W = function(a, r) {
2160
- const o = a.identifier.name;
2161
- !d(this, S).has(o) && !d(this, O).has(o) && r.add(o);
2162
- }, Ne = function(a, r) {
2163
- for (const o of a.expressions) {
2134
+ transformReferences(r) {
2135
+ const a = super.transformReferences(r);
2136
+ return a.table.table.schema ? a : {
2137
+ ...a,
2138
+ table: U.createWithSchema(d(this, P), a.table.table.identifier.name)
2139
+ };
2140
+ }
2141
+ }
2142
+ P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(r) {
2143
+ return r.kind in kr;
2144
+ }, ye = function(r) {
2145
+ const a = /* @__PURE__ */ new Set();
2146
+ if ("name" in r && r.name && q.is(r.name) && u(this, _, W).call(this, r.name, a), "from" in r && r.from)
2147
+ for (const o of r.from.froms)
2148
+ u(this, _, $).call(this, o, a);
2149
+ 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)
2150
+ for (const o of r.joins)
2151
+ u(this, _, $).call(this, o.table, a);
2152
+ return "using" in r && r.using && u(this, _, $).call(this, r.using, a), a;
2153
+ }, we = function(r) {
2154
+ const a = /* @__PURE__ */ new Set();
2155
+ return "with" in r && r.with && u(this, _, Ne).call(this, r.with, a), a;
2156
+ }, $ = function(r, a) {
2157
+ const o = U.is(r) ? r : Sr.is(r) && U.is(r.node) ? r.node : null;
2158
+ o && u(this, _, W).call(this, o.table, a);
2159
+ }, W = function(r, a) {
2160
+ const o = r.identifier.name;
2161
+ !d(this, S).has(o) && !d(this, O).has(o) && a.add(o);
2162
+ }, Ne = function(r, a) {
2163
+ for (const o of r.expressions) {
2164
2164
  const n = o.name.table.table.identifier.name;
2165
- d(this, O).has(n) || r.add(n);
2165
+ d(this, O).has(n) || a.add(n);
2166
2166
  }
2167
2167
  };
2168
2168
  var L;
2169
- class Da {
2169
+ class Ir {
2170
2170
  constructor(e) {
2171
- w(this, L);
2172
- M(this, L, new $a(e));
2171
+ y(this, L);
2172
+ M(this, L, new $r(e));
2173
2173
  }
2174
2174
  transformQuery(e) {
2175
2175
  return d(this, L).transformNode(e.node);
@@ -2179,7 +2179,7 @@ class Da {
2179
2179
  }
2180
2180
  }
2181
2181
  L = new WeakMap();
2182
- class Ia {
2182
+ class Dr {
2183
2183
  transformQuery(e) {
2184
2184
  return e.node;
2185
2185
  }
@@ -2187,12 +2187,12 @@ class Ia {
2187
2187
  return e.result;
2188
2188
  }
2189
2189
  }
2190
- const Pa = "kysely_migration", _e = "kysely_migration_lock", ja = !1, B = "migration_lock", Ma = p({ __noMigrations__: !0 });
2191
- var h, i, A, N, v, D, Ce, C, be, xe, Te, Se, Oe, G, I, H, ke, $e, De, X, Ie, Pe, je, Me, Ae, F;
2190
+ const Pr = "kysely_migration", fe = "kysely_migration_lock", jr = !1, B = "migration_lock", Mr = p({ __noMigrations__: !0 });
2191
+ 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;
2192
2192
  class ve {
2193
2193
  constructor(e) {
2194
- w(this, i);
2195
- w(this, h);
2194
+ y(this, i);
2195
+ y(this, h);
2196
2196
  M(this, h, p(e));
2197
2197
  }
2198
2198
  /**
@@ -2201,11 +2201,11 @@ class ve {
2201
2201
  * The returned array is sorted by migration name.
2202
2202
  */
2203
2203
  async getMigrations() {
2204
- const e = await u(this, i, I).call(this, d(this, i, v)) ? await d(this, h).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, v)).select(["name", "timestamp"]).execute() : [];
2205
- return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2206
- const n = e.find((s) => s.name === r);
2204
+ const e = await u(this, i, D).call(this, d(this, i, v)) ? await d(this, h).db.withPlugin(d(this, i, b)).selectFrom(d(this, i, v)).select(["name", "timestamp"]).execute() : [];
2205
+ return (await u(this, i, X).call(this)).map(({ name: a, ...o }) => {
2206
+ const n = e.find((s) => s.name === a);
2207
2207
  return {
2208
- name: r,
2208
+ name: a,
2209
2209
  migration: o,
2210
2210
  executedAt: n ? new Date(n.timestamp) : void 0
2211
2211
  };
@@ -2285,16 +2285,16 @@ class ve {
2285
2285
  * ```
2286
2286
  */
2287
2287
  async migrateTo(e) {
2288
- return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2289
- if (e === Ma)
2288
+ return u(this, i, A).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: o }) => {
2289
+ if (e === Mr)
2290
2290
  return { direction: "Down", step: 1 / 0 };
2291
- if (!a.find((c) => c.name === e))
2291
+ if (!r.find((c) => c.name === e))
2292
2292
  throw new Error(`migration "${e}" doesn't exist`);
2293
- const n = r.indexOf(e), s = o.findIndex((c) => c.name === e);
2293
+ const n = a.indexOf(e), s = o.findIndex((c) => c.name === e);
2294
2294
  if (n !== -1)
2295
2295
  return {
2296
2296
  direction: "Down",
2297
- step: r.length - n - 1
2297
+ step: a.length - n - 1
2298
2298
  };
2299
2299
  if (s !== -1)
2300
2300
  return { direction: "Up", step: s + 1 };
@@ -2338,21 +2338,21 @@ class ve {
2338
2338
  }
2339
2339
  h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2340
2340
  try {
2341
- return await u(this, i, be).call(this), await u(this, i, ke).call(this, e);
2342
- } catch (a) {
2343
- return a instanceof Q ? a.resultSet : { error: a };
2341
+ return await u(this, i, Ce).call(this), await u(this, i, ke).call(this, e);
2342
+ } catch (r) {
2343
+ return r instanceof Q ? r.resultSet : { error: r };
2344
2344
  }
2345
2345
  }, N = function() {
2346
2346
  return d(this, h).migrationTableSchema;
2347
2347
  }, v = function() {
2348
- return d(this, h).migrationTableName ?? Pa;
2349
- }, D = function() {
2350
- return d(this, h).migrationLockTableName ?? _e;
2351
- }, Ce = function() {
2352
- return d(this, h).allowUnorderedMigrations ?? ja;
2353
- }, C = function() {
2354
- return d(this, i, N) ? new Da(d(this, i, N)) : new Ia();
2355
- }, be = async function() {
2348
+ return d(this, h).migrationTableName ?? Pr;
2349
+ }, I = function() {
2350
+ return d(this, h).migrationLockTableName ?? fe;
2351
+ }, be = function() {
2352
+ return d(this, h).allowUnorderedMigrations ?? jr;
2353
+ }, b = function() {
2354
+ return d(this, i, N) ? new Ir(d(this, i, N)) : new Dr();
2355
+ }, Ce = async function() {
2356
2356
  await u(this, i, xe).call(this), await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this);
2357
2357
  }, xe = async function() {
2358
2358
  if (d(this, i, N) && !await u(this, i, G).call(this))
@@ -2363,86 +2363,86 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2363
2363
  throw e;
2364
2364
  }
2365
2365
  }, Te = async function() {
2366
- if (!await u(this, i, I).call(this, d(this, i, v)))
2366
+ if (!await u(this, i, D).call(this, d(this, i, v)))
2367
2367
  try {
2368
- d(this, i, N) && await u(this, i, F).call(this, d(this, h).db.schema.createSchema(d(this, i, N))), await u(this, i, F).call(this, d(this, h).db.schema.withPlugin(d(this, i, C)).createTable(d(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2368
+ d(this, i, N) && await u(this, i, F).call(this, d(this, h).db.schema.createSchema(d(this, i, N))), await u(this, i, F).call(this, d(this, h).db.schema.withPlugin(d(this, i, b)).createTable(d(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2369
2369
  } catch (e) {
2370
- if (!await u(this, i, I).call(this, d(this, i, v)))
2370
+ if (!await u(this, i, D).call(this, d(this, i, v)))
2371
2371
  throw e;
2372
2372
  }
2373
2373
  }, Se = async function() {
2374
- if (!await u(this, i, I).call(this, d(this, i, D)))
2374
+ if (!await u(this, i, D).call(this, d(this, i, I)))
2375
2375
  try {
2376
- await u(this, i, F).call(this, d(this, h).db.schema.withPlugin(d(this, i, C)).createTable(d(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2376
+ await u(this, i, F).call(this, d(this, h).db.schema.withPlugin(d(this, i, b)).createTable(d(this, i, I)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2377
2377
  } catch (e) {
2378
- if (!await u(this, i, I).call(this, d(this, i, D)))
2378
+ if (!await u(this, i, D).call(this, d(this, i, I)))
2379
2379
  throw e;
2380
2380
  }
2381
2381
  }, Oe = async function() {
2382
2382
  if (!await u(this, i, H).call(this))
2383
2383
  try {
2384
- await d(this, h).db.withPlugin(d(this, i, C)).insertInto(d(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2384
+ await d(this, h).db.withPlugin(d(this, i, b)).insertInto(d(this, i, I)).values({ id: B, is_locked: 0 }).execute();
2385
2385
  } catch (e) {
2386
2386
  if (!await u(this, i, H).call(this))
2387
2387
  throw e;
2388
2388
  }
2389
2389
  }, G = async function() {
2390
- return (await d(this, h).db.introspection.getSchemas()).some((a) => a.name === d(this, i, N));
2391
- }, I = async function(e) {
2392
- const a = d(this, i, N);
2390
+ return (await d(this, h).db.introspection.getSchemas()).some((r) => r.name === d(this, i, N));
2391
+ }, D = async function(e) {
2392
+ const r = d(this, i, N);
2393
2393
  return (await d(this, h).db.introspection.getTables({
2394
2394
  withInternalKyselyTables: !0
2395
- })).some((o) => o.name === e && (!a || o.schema === a));
2395
+ })).some((o) => o.name === e && (!r || o.schema === r));
2396
2396
  }, H = async function() {
2397
- return !!await d(this, h).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2397
+ return !!await d(this, h).db.withPlugin(d(this, i, b)).selectFrom(d(this, i, I)).where("id", "=", B).select("id").executeTakeFirst();
2398
2398
  }, ke = async function(e) {
2399
- const a = d(this, h).db.getExecutor().adapter, r = p({
2400
- lockTable: d(this, h).migrationLockTableName ?? _e,
2399
+ const r = d(this, h).db.getExecutor().adapter, a = p({
2400
+ lockTable: d(this, h).migrationLockTableName ?? fe,
2401
2401
  lockRowId: B,
2402
2402
  lockTableSchema: d(this, h).migrationTableSchema
2403
2403
  }), o = async (n) => {
2404
2404
  try {
2405
- await a.acquireMigrationLock(n, r);
2405
+ await r.acquireMigrationLock(n, a);
2406
2406
  const s = await u(this, i, $e).call(this, n);
2407
2407
  if (s.migrations.length === 0)
2408
2408
  return { results: [] };
2409
2409
  const { direction: c, step: l } = e(s);
2410
2410
  return l <= 0 ? { results: [] } : c === "Down" ? await u(this, i, Me).call(this, n, s, l) : c === "Up" ? await u(this, i, Ae).call(this, n, s, l) : { results: [] };
2411
2411
  } finally {
2412
- await a.releaseMigrationLock(n, r);
2412
+ await r.releaseMigrationLock(n, a);
2413
2413
  }
2414
2414
  };
2415
- return a.supportsTransactionalDdl ? d(this, h).db.transaction().execute(o) : d(this, h).db.connection().execute(o);
2415
+ return r.supportsTransactionalDdl ? d(this, h).db.transaction().execute(o) : d(this, h).db.connection().execute(o);
2416
2416
  }, $e = async function(e) {
2417
- const a = await u(this, i, X).call(this), r = await u(this, i, Ie).call(this, e);
2418
- u(this, i, Pe).call(this, a, r), d(this, i, Ce) || u(this, i, je).call(this, a, r);
2419
- const o = u(this, i, De).call(this, a, r);
2417
+ const r = await u(this, i, X).call(this), a = await u(this, i, De).call(this, e);
2418
+ u(this, i, Pe).call(this, r, a), d(this, i, be) || u(this, i, je).call(this, r, a);
2419
+ const o = u(this, i, Ie).call(this, r, a);
2420
2420
  return p({
2421
- migrations: a,
2422
- executedMigrations: r,
2423
- lastMigration: Ta(r),
2421
+ migrations: r,
2422
+ executedMigrations: a,
2423
+ lastMigration: Tr(a),
2424
2424
  pendingMigrations: o
2425
2425
  });
2426
- }, De = function(e, a) {
2427
- return e.filter((r) => !a.includes(r.name));
2426
+ }, Ie = function(e, r) {
2427
+ return e.filter((a) => !r.includes(a.name));
2428
2428
  }, X = async function() {
2429
2429
  const e = await d(this, h).provider.getMigrations();
2430
- return Object.keys(e).sort().map((a) => ({
2431
- ...e[a],
2432
- name: a
2430
+ return Object.keys(e).sort().map((r) => ({
2431
+ ...e[r],
2432
+ name: r
2433
2433
  }));
2434
- }, Ie = async function(e) {
2435
- return (await e.withPlugin(d(this, i, C)).selectFrom(d(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2436
- }, Pe = function(e, a) {
2437
- for (const r of a)
2438
- if (!e.some((o) => o.name === r))
2439
- throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2440
- }, je = function(e, a) {
2441
- for (let r = 0; r < a.length; ++r)
2442
- if (e[r].name !== a[r])
2443
- throw new Error(`corrupted migrations: expected previously executed migration ${a[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2444
- }, Me = async function(e, a, r) {
2445
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((c) => c.name === s)), n = o.map((s) => ({
2434
+ }, De = async function(e) {
2435
+ return (await e.withPlugin(d(this, i, b)).selectFrom(d(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
2436
+ }, Pe = function(e, r) {
2437
+ for (const a of r)
2438
+ if (!e.some((o) => o.name === a))
2439
+ throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
2440
+ }, je = function(e, r) {
2441
+ for (let a = 0; a < r.length; ++a)
2442
+ if (e[a].name !== r[a])
2443
+ 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.`);
2444
+ }, Me = async function(e, r, a) {
2445
+ const o = r.executedMigrations.slice().reverse().slice(0, a).map((s) => r.migrations.find((c) => c.name === s)), n = o.map((s) => ({
2446
2446
  migrationName: s.name,
2447
2447
  direction: "Down",
2448
2448
  status: "NotExecuted"
@@ -2450,7 +2450,7 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2450
2450
  for (let s = 0; s < n.length; ++s) {
2451
2451
  const c = o[s];
2452
2452
  try {
2453
- c.down && (await c.down(e), await e.withPlugin(d(this, i, C)).deleteFrom(d(this, i, v)).where("name", "=", c.name).execute(), n[s] = {
2453
+ c.down && (await c.down(e), await e.withPlugin(d(this, i, b)).deleteFrom(d(this, i, v)).where("name", "=", c.name).execute(), n[s] = {
2454
2454
  migrationName: c.name,
2455
2455
  direction: "Down",
2456
2456
  status: "Success"
@@ -2467,16 +2467,16 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2467
2467
  }
2468
2468
  }
2469
2469
  return { results: n };
2470
- }, Ae = async function(e, a, r) {
2471
- const n = a.pendingMigrations.slice(0, r).map((s) => ({
2470
+ }, Ae = async function(e, r, a) {
2471
+ const n = r.pendingMigrations.slice(0, a).map((s) => ({
2472
2472
  migrationName: s.name,
2473
2473
  direction: "Up",
2474
2474
  status: "NotExecuted"
2475
2475
  }));
2476
2476
  for (let s = 0; s < n.length; s++) {
2477
- const c = a.pendingMigrations[s];
2477
+ const c = r.pendingMigrations[s];
2478
2478
  try {
2479
- await c.up(e), await e.withPlugin(d(this, i, C)).insertInto(d(this, i, v)).values({
2479
+ await c.up(e), await e.withPlugin(d(this, i, b)).insertInto(d(this, i, v)).values({
2480
2480
  name: c.name,
2481
2481
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2482
2482
  }).execute(), n[s] = {
@@ -2501,10 +2501,10 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2501
2501
  };
2502
2502
  var E;
2503
2503
  class Q extends Error {
2504
- constructor(a) {
2504
+ constructor(r) {
2505
2505
  super();
2506
- w(this, E);
2507
- M(this, E, a);
2506
+ y(this, E);
2507
+ M(this, E, r);
2508
2508
  }
2509
2509
  get resultSet() {
2510
2510
  return d(this, E);
@@ -2520,7 +2520,7 @@ class Fe {
2520
2520
  return this.migrations;
2521
2521
  }
2522
2522
  }
2523
- async function Aa(t) {
2523
+ async function Ar(t) {
2524
2524
  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(
2525
2525
  "tenant_id",
2526
2526
  "varchar(255)",
@@ -2588,35 +2588,35 @@ async function Aa(t) {
2588
2588
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
2589
2589
  ).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();
2590
2590
  }
2591
- async function Fa(t) {
2591
+ async function Fr(t) {
2592
2592
  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();
2593
2593
  }
2594
- const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2594
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2595
2595
  __proto__: null,
2596
- down: Fa,
2597
- up: Aa
2596
+ down: Fr,
2597
+ up: Ar
2598
2598
  }, Symbol.toStringTag, { value: "Module" }));
2599
- async function Ea(t) {
2599
+ async function Er(t) {
2600
2600
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
2601
2601
  }
2602
- async function Ja(t) {
2602
+ async function Jr(t) {
2603
2603
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
2604
2604
  }
2605
- const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2605
+ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2606
2606
  __proto__: null,
2607
- down: Ja,
2608
- up: Ea
2607
+ down: Jr,
2608
+ up: Er
2609
2609
  }, Symbol.toStringTag, { value: "Module" }));
2610
- async function Ra(t) {
2610
+ async function Rr(t) {
2611
2611
  }
2612
- async function Ka(t) {
2612
+ async function Kr(t) {
2613
2613
  }
2614
- const Ua = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2614
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2615
2615
  __proto__: null,
2616
- down: Ka,
2617
- up: Ra
2616
+ down: Kr,
2617
+ up: Rr
2618
2618
  }, Symbol.toStringTag, { value: "Module" }));
2619
- async function Ba(t) {
2619
+ async function Br(t) {
2620
2620
  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(
2621
2621
  "tenant_id_constraint",
2622
2622
  ["tenant_id"],
@@ -2625,35 +2625,31 @@ async function Ba(t) {
2625
2625
  (e) => e.onDelete("cascade")
2626
2626
  ).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();
2627
2627
  }
2628
- async function Qa(t) {
2628
+ async function Qr(t) {
2629
2629
  await t.schema.dropTable("logs").execute();
2630
2630
  }
2631
- const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2631
+ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2632
2632
  __proto__: null,
2633
- down: Qa,
2634
- up: Ba
2633
+ down: Qr,
2634
+ up: Br
2635
2635
  }, Symbol.toStringTag, { value: "Module" }));
2636
- async function qa(t) {
2636
+ async function qr(t) {
2637
2637
  }
2638
- async function Wa(t) {
2638
+ async function Wr(t) {
2639
2639
  }
2640
- const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2640
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2641
2641
  __proto__: null,
2642
- down: Wa,
2643
- up: qa
2642
+ down: Wr,
2643
+ up: qr
2644
2644
  }, Symbol.toStringTag, { value: "Module" }));
2645
- async function Ha(t) {
2646
- await t.schema.createTable("sessions").addColumn("session_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
2647
- "client_id",
2648
- "varchar(255)",
2649
- (e) => e.references("applications.id").onDelete("cascade").notNull()
2650
- ).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
2645
+ async function Hr(t) {
2646
+ await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
2651
2647
  "user_id_constraint",
2652
2648
  ["user_id", "tenant_id"],
2653
2649
  "users",
2654
2650
  ["user_id", "tenant_id"],
2655
2651
  (e) => e.onDelete("cascade")
2656
- ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").addColumn("deleted_at", "varchar(255)").execute(), await t.schema.createTable("tickets").addColumn(
2652
+ ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("authenticated_at", "varchar(35)").addColumn("last_interaction_at", "varchar(35)").addColumn("used_at", "varchar(35)").addColumn("revoked_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("clients", "varchar(1024)", (e) => e.notNull()).execute(), await t.schema.createTable("tickets").addColumn(
2657
2653
  "tenant_id",
2658
2654
  "varchar(255)",
2659
2655
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
@@ -2671,15 +2667,15 @@ async function Ha(t) {
2671
2667
  (e) => e.references("applications.id").onDelete("cascade").notNull()
2672
2668
  ).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();
2673
2669
  }
2674
- async function Xa(t) {
2670
+ async function Xr(t) {
2675
2671
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
2676
2672
  }
2677
- const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2673
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2678
2674
  __proto__: null,
2679
- down: Xa,
2680
- up: Ha
2675
+ down: Xr,
2676
+ up: Hr
2681
2677
  }, Symbol.toStringTag, { value: "Module" }));
2682
- async function Za(t) {
2678
+ async function Zr(t) {
2683
2679
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
2684
2680
  "user_id_constraint",
2685
2681
  ["user_id", "tenant_id"],
@@ -2694,24 +2690,24 @@ async function Za(t) {
2694
2690
  (e) => e.onDelete("cascade")
2695
2691
  ).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();
2696
2692
  }
2697
- async function er(t) {
2693
+ async function ea(t) {
2698
2694
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
2699
2695
  }
2700
- const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2696
+ const ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2701
2697
  __proto__: null,
2702
- down: er,
2703
- up: Za
2698
+ down: ea,
2699
+ up: Zr
2704
2700
  }, Symbol.toStringTag, { value: "Module" }));
2705
- async function ar(t) {
2701
+ async function ra(t) {
2706
2702
  }
2707
- async function rr(t) {
2703
+ async function aa(t) {
2708
2704
  }
2709
- const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2705
+ const na = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2710
2706
  __proto__: null,
2711
- down: rr,
2712
- up: ar
2707
+ down: aa,
2708
+ up: ra
2713
2709
  }, Symbol.toStringTag, { value: "Module" }));
2714
- async function or(t) {
2710
+ async function oa(t) {
2715
2711
  await t.schema.alterTable("passwords").addColumn(
2716
2712
  "password",
2717
2713
  "varchar(255)",
@@ -2719,172 +2715,172 @@ async function or(t) {
2719
2715
  (e) => e.notNull()
2720
2716
  ).execute();
2721
2717
  }
2722
- async function sr(t) {
2718
+ async function sa(t) {
2723
2719
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2724
2720
  }
2725
- const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2721
+ const ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2726
2722
  __proto__: null,
2727
- down: sr,
2728
- up: or
2723
+ down: sa,
2724
+ up: oa
2729
2725
  }, Symbol.toStringTag, { value: "Module" }));
2730
- async function cr(t) {
2726
+ async function ca(t) {
2731
2727
  }
2732
- async function lr(t) {
2728
+ async function la(t) {
2733
2729
  }
2734
- const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2730
+ const da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2735
2731
  __proto__: null,
2736
- down: lr,
2737
- up: cr
2732
+ down: la,
2733
+ up: ca
2738
2734
  }, Symbol.toStringTag, { value: "Module" }));
2739
- async function ur(t) {
2735
+ async function ua(t) {
2740
2736
  }
2741
- async function mr(t) {
2737
+ async function ma(t) {
2742
2738
  }
2743
- const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2739
+ const ha = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2744
2740
  __proto__: null,
2745
- down: mr,
2746
- up: ur
2741
+ down: ma,
2742
+ up: ua
2747
2743
  }, Symbol.toStringTag, { value: "Module" }));
2748
- async function _r(t) {
2744
+ async function fa(t) {
2749
2745
  }
2750
- async function fr(t) {
2746
+ async function _a(t) {
2751
2747
  }
2752
- const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2748
+ const pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2753
2749
  __proto__: null,
2754
- down: fr,
2755
- up: _r
2750
+ down: _a,
2751
+ up: fa
2756
2752
  }, Symbol.toStringTag, { value: "Module" }));
2757
- async function gr(t) {
2753
+ async function ga(t) {
2758
2754
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
2759
2755
  }
2760
- async function wr(t) {
2756
+ async function ya(t) {
2761
2757
  await t.schema.dropIndex("users_email_index").execute();
2762
2758
  }
2763
- const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2759
+ const wa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2764
2760
  __proto__: null,
2765
- down: wr,
2766
- up: gr
2761
+ down: ya,
2762
+ up: ga
2767
2763
  }, Symbol.toStringTag, { value: "Module" }));
2768
- async function Nr(t) {
2764
+ async function Na(t) {
2769
2765
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
2770
2766
  }
2771
- async function vr(t) {
2767
+ async function va(t) {
2772
2768
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2773
2769
  }
2774
- const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2770
+ const ba = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2775
2771
  __proto__: null,
2776
- down: vr,
2777
- up: Nr
2772
+ down: va,
2773
+ up: Na
2778
2774
  }, Symbol.toStringTag, { value: "Module" }));
2779
- async function br(t) {
2775
+ async function Ca(t) {
2780
2776
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
2781
2777
  }
2782
- async function xr(t) {
2778
+ async function xa(t) {
2783
2779
  await t.schema.dropIndex("users_linked_to_index");
2784
2780
  }
2785
- const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2781
+ const Ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2786
2782
  __proto__: null,
2787
- down: xr,
2788
- up: br
2783
+ down: xa,
2784
+ up: Ca
2789
2785
  }, Symbol.toStringTag, { value: "Module" }));
2790
- async function Sr(t) {
2786
+ async function Sa(t) {
2791
2787
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
2792
2788
  }
2793
- async function Or(t) {
2789
+ async function Oa(t) {
2794
2790
  await t.schema.alterTable("users").dropColumn("locale").execute();
2795
2791
  }
2796
- const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2792
+ const ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2797
2793
  __proto__: null,
2798
- down: Or,
2799
- up: Sr
2794
+ down: Oa,
2795
+ up: Sa
2800
2796
  }, Symbol.toStringTag, { value: "Module" }));
2801
- async function $r(t) {
2797
+ async function $a(t) {
2802
2798
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2803
2799
  "tenant_id",
2804
2800
  "varchar(255)",
2805
2801
  (e) => e.references("tenants.id").onDelete("cascade")
2806
2802
  ).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();
2807
2803
  }
2808
- async function Dr(t) {
2804
+ async function Ia(t) {
2809
2805
  await t.schema.dropTable("keys").execute();
2810
2806
  }
2811
- const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2807
+ const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2812
2808
  __proto__: null,
2813
- down: Dr,
2814
- up: $r
2809
+ down: Ia,
2810
+ up: $a
2815
2811
  }, Symbol.toStringTag, { value: "Module" }));
2816
- async function Pr(t) {
2812
+ async function Pa(t) {
2817
2813
  }
2818
- async function jr(t) {
2814
+ async function ja(t) {
2819
2815
  }
2820
- const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2816
+ const Ma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2821
2817
  __proto__: null,
2822
- down: jr,
2823
- up: Pr
2818
+ down: ja,
2819
+ up: Pa
2824
2820
  }, Symbol.toStringTag, { value: "Module" }));
2825
- async function Ar(t) {
2821
+ async function Aa(t) {
2826
2822
  }
2827
- async function Fr(t) {
2823
+ async function Fa(t) {
2828
2824
  }
2829
- const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2825
+ const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2830
2826
  __proto__: null,
2831
- down: Fr,
2832
- up: Ar
2827
+ down: Fa,
2828
+ up: Aa
2833
2829
  }, Symbol.toStringTag, { value: "Module" }));
2834
- async function Er(t) {
2830
+ async function Ea(t) {
2835
2831
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
2836
2832
  }
2837
- async function Jr(t) {
2833
+ async function Ja(t) {
2838
2834
  await t.schema.alterTable("otps").dropColumn("audience").execute();
2839
2835
  }
2840
- const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2836
+ const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2841
2837
  __proto__: null,
2842
- down: Jr,
2843
- up: Er
2838
+ down: Ja,
2839
+ up: Ea
2844
2840
  }, Symbol.toStringTag, { value: "Module" }));
2845
- async function Rr(t) {
2841
+ async function Ra(t) {
2846
2842
  }
2847
- async function Kr(t) {
2843
+ async function Ka(t) {
2848
2844
  }
2849
- const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2845
+ const Ua = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2850
2846
  __proto__: null,
2851
- down: Kr,
2852
- up: Rr
2847
+ down: Ka,
2848
+ up: Ra
2853
2849
  }, Symbol.toStringTag, { value: "Module" }));
2854
- async function Br(t) {
2850
+ async function Ba(t) {
2855
2851
  await t.schema.alterTable("logs").dropColumn("category").execute();
2856
2852
  }
2857
- async function Qr(t) {
2853
+ async function Qa(t) {
2858
2854
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
2859
2855
  }
2860
- const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2856
+ const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2861
2857
  __proto__: null,
2862
- down: Qr,
2863
- up: Br
2858
+ down: Qa,
2859
+ up: Ba
2864
2860
  }, Symbol.toStringTag, { value: "Module" }));
2865
- async function qr(t) {
2861
+ async function qa(t) {
2866
2862
  await t.schema.alterTable("users").dropColumn("tags").execute();
2867
2863
  }
2868
- async function Wr(t) {
2864
+ async function Wa(t) {
2869
2865
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
2870
2866
  }
2871
- const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2867
+ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2872
2868
  __proto__: null,
2873
- down: Wr,
2874
- up: qr
2869
+ down: Wa,
2870
+ up: qa
2875
2871
  }, Symbol.toStringTag, { value: "Module" }));
2876
- async function Hr(t) {
2872
+ async function Ha(t) {
2877
2873
  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();
2878
2874
  }
2879
- async function Xr(t) {
2875
+ async function Xa(t) {
2880
2876
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
2881
2877
  }
2882
- const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2878
+ const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2883
2879
  __proto__: null,
2884
- down: Xr,
2885
- up: Hr
2880
+ down: Xa,
2881
+ up: Ha
2886
2882
  }, Symbol.toStringTag, { value: "Module" }));
2887
- async function Zr(t) {
2883
+ async function Za(t) {
2888
2884
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
2889
2885
  }
2890
2886
  async function en(t) {
@@ -2893,18 +2889,18 @@ async function en(t) {
2893
2889
  const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2894
2890
  __proto__: null,
2895
2891
  down: en,
2896
- up: Zr
2892
+ up: Za
2897
2893
  }, Symbol.toStringTag, { value: "Module" }));
2898
- async function an(t) {
2894
+ async function rn(t) {
2899
2895
  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();
2900
2896
  }
2901
- async function rn(t) {
2897
+ async function an(t) {
2902
2898
  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();
2903
2899
  }
2904
2900
  const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2905
2901
  __proto__: null,
2906
- down: rn,
2907
- up: an
2902
+ down: an,
2903
+ up: rn
2908
2904
  }, Symbol.toStringTag, { value: "Module" }));
2909
2905
  async function on(t) {
2910
2906
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
@@ -2933,12 +2929,12 @@ async function mn(t) {
2933
2929
  async function hn(t) {
2934
2930
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
2935
2931
  }
2936
- const _n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2932
+ const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2937
2933
  __proto__: null,
2938
2934
  down: hn,
2939
2935
  up: mn
2940
2936
  }, Symbol.toStringTag, { value: "Module" }));
2941
- async function fn(t) {
2937
+ async function _n(t) {
2942
2938
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
2943
2939
  }
2944
2940
  async function pn(t) {
@@ -2947,30 +2943,30 @@ async function pn(t) {
2947
2943
  const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2948
2944
  __proto__: null,
2949
2945
  down: pn,
2950
- up: fn
2946
+ up: _n
2951
2947
  }, Symbol.toStringTag, { value: "Module" }));
2952
- async function wn(t) {
2948
+ async function yn(t) {
2953
2949
  await t.schema.createTable("branding").addColumn(
2954
2950
  "tenant_id",
2955
2951
  "varchar(255)",
2956
2952
  (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
2957
2953
  ).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();
2958
2954
  }
2959
- async function yn(t) {
2955
+ async function wn(t) {
2960
2956
  await t.schema.dropTable("branding").execute();
2961
2957
  }
2962
2958
  const Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2963
2959
  __proto__: null,
2964
- down: yn,
2965
- up: wn
2960
+ down: wn,
2961
+ up: yn
2966
2962
  }, Symbol.toStringTag, { value: "Module" }));
2967
2963
  async function vn(t) {
2968
2964
  }
2969
- async function Cn(t) {
2965
+ async function bn(t) {
2970
2966
  }
2971
- const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2967
+ const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2972
2968
  __proto__: null,
2973
- down: Cn,
2969
+ down: bn,
2974
2970
  up: vn
2975
2971
  }, Symbol.toStringTag, { value: "Module" }));
2976
2972
  async function xn(t) {
@@ -2991,14 +2987,14 @@ const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2991
2987
  down: kn,
2992
2988
  up: On
2993
2989
  }, Symbol.toStringTag, { value: "Module" }));
2994
- async function Dn(t) {
2995
- }
2996
2990
  async function In(t) {
2997
2991
  }
2992
+ async function Dn(t) {
2993
+ }
2998
2994
  const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2999
2995
  __proto__: null,
3000
- down: In,
3001
- up: Dn
2996
+ down: Dn,
2997
+ up: In
3002
2998
  }, Symbol.toStringTag, { value: "Module" }));
3003
2999
  async function jn(t) {
3004
3000
  await t.schema.createTable("authentication_codes").addColumn(
@@ -3091,12 +3087,12 @@ async function eo(t) {
3091
3087
  }
3092
3088
  async function to(t) {
3093
3089
  }
3094
- const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3090
+ const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3095
3091
  __proto__: null,
3096
3092
  down: to,
3097
3093
  up: eo
3098
3094
  }, Symbol.toStringTag, { value: "Module" }));
3099
- async function ro(t) {
3095
+ async function ao(t) {
3100
3096
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3101
3097
  "tenant_id",
3102
3098
  "varchar(255)",
@@ -3125,7 +3121,7 @@ async function no(t) {
3125
3121
  const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3126
3122
  __proto__: null,
3127
3123
  down: no,
3128
- up: ro
3124
+ up: ao
3129
3125
  }, Symbol.toStringTag, { value: "Module" }));
3130
3126
  async function so(t) {
3131
3127
  }
@@ -3150,42 +3146,42 @@ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3150
3146
  async function ho(t) {
3151
3147
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3152
3148
  }
3153
- async function _o(t) {
3149
+ async function fo(t) {
3154
3150
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3155
3151
  }
3156
- const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3152
+ const _o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3157
3153
  __proto__: null,
3158
- down: _o,
3154
+ down: fo,
3159
3155
  up: ho
3160
3156
  }, Symbol.toStringTag, { value: "Module" }));
3161
3157
  async function po(t) {
3162
3158
  }
3163
3159
  async function go(t) {
3164
3160
  }
3165
- const wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3161
+ const yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3166
3162
  __proto__: null,
3167
3163
  down: go,
3168
3164
  up: po
3169
3165
  }, Symbol.toStringTag, { value: "Module" }));
3170
- async function yo(t) {
3166
+ async function wo(t) {
3171
3167
  }
3172
3168
  async function No(t) {
3173
3169
  }
3174
3170
  const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3175
3171
  __proto__: null,
3176
3172
  down: No,
3177
- up: yo
3173
+ up: wo
3178
3174
  }, Symbol.toStringTag, { value: "Module" }));
3179
- async function Co(t) {
3175
+ async function bo(t) {
3180
3176
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3181
3177
  }
3182
- async function bo(t) {
3178
+ async function Co(t) {
3183
3179
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3184
3180
  }
3185
3181
  const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3186
3182
  __proto__: null,
3187
- down: bo,
3188
- up: Co
3183
+ down: Co,
3184
+ up: bo
3189
3185
  }, Symbol.toStringTag, { value: "Module" }));
3190
3186
  async function To(t) {
3191
3187
  }
@@ -3200,12 +3196,12 @@ async function ko(t) {
3200
3196
  }
3201
3197
  async function $o(t) {
3202
3198
  }
3203
- const Do = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3199
+ const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3204
3200
  __proto__: null,
3205
3201
  down: $o,
3206
3202
  up: ko
3207
3203
  }, Symbol.toStringTag, { value: "Module" }));
3208
- async function Io(t) {
3204
+ async function Do(t) {
3209
3205
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
3210
3206
  "tenant_id",
3211
3207
  "varchar(255)",
@@ -3237,7 +3233,7 @@ async function Po(t) {
3237
3233
  const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3238
3234
  __proto__: null,
3239
3235
  down: Po,
3240
- up: Io
3236
+ up: Do
3241
3237
  }, Symbol.toStringTag, { value: "Module" }));
3242
3238
  async function Mo(t) {
3243
3239
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
@@ -3343,12 +3339,12 @@ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3343
3339
  async function ts(t) {
3344
3340
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3345
3341
  }
3346
- async function as(t) {
3342
+ async function rs(t) {
3347
3343
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3348
3344
  }
3349
- const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3345
+ const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3350
3346
  __proto__: null,
3351
- down: as,
3347
+ down: rs,
3352
3348
  up: ts
3353
3349
  }, Symbol.toStringTag, { value: "Module" }));
3354
3350
  async function ns(t) {
@@ -3385,12 +3381,12 @@ const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3385
3381
  async function hs(t) {
3386
3382
  await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
3387
3383
  }
3388
- async function _s(t) {
3384
+ async function fs(t) {
3389
3385
  await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
3390
3386
  }
3391
- const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3387
+ const _s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3392
3388
  __proto__: null,
3393
- down: _s,
3389
+ down: fs,
3394
3390
  up: hs
3395
3391
  }, Symbol.toStringTag, { value: "Module" }));
3396
3392
  async function ps(t) {
@@ -3407,12 +3403,12 @@ async function ps(t) {
3407
3403
  async function gs(t) {
3408
3404
  await t.schema.dropTable("email_providers").execute();
3409
3405
  }
3410
- const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3406
+ const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3411
3407
  __proto__: null,
3412
3408
  down: gs,
3413
3409
  up: ps
3414
3410
  }, Symbol.toStringTag, { value: "Module" }));
3415
- async function ys(t) {
3411
+ async function ws(t) {
3416
3412
  await t.schema.dropTable("tickets").execute();
3417
3413
  }
3418
3414
  async function Ns(t) {
@@ -3429,32 +3425,30 @@ async function Ns(t) {
3429
3425
  const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3430
3426
  __proto__: null,
3431
3427
  down: Ns,
3432
- up: ys
3428
+ up: ws
3433
3429
  }, Symbol.toStringTag, { value: "Module" }));
3434
- async function Cs(t) {
3435
- }
3436
3430
  async function bs(t) {
3431
+ }
3432
+ async function Cs(t) {
3437
3433
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3438
3434
  }
3439
3435
  const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3440
3436
  __proto__: null,
3441
- down: bs,
3442
- up: Cs
3437
+ down: Cs,
3438
+ up: bs
3443
3439
  }, Symbol.toStringTag, { value: "Module" }));
3444
3440
  async function Ts(t) {
3445
- await t.schema.createTable("refresh_tokens").addColumn(
3446
- "tenant_id",
3447
- "varchar(255)",
3448
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3449
- ).addColumn("token", "varchar(255)", (e) => e.notNull()).addColumn(
3450
- "session_id",
3451
- "varchar(255)",
3452
- (e) => e.references("sessions.session_id").onDelete("cascade").notNull()
3453
- ).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(
3454
- "created_at",
3455
- "varchar(255)",
3456
- (e) => e.notNull().defaultTo((/* @__PURE__ */ new Date()).toISOString())
3457
- ).addPrimaryKeyConstraint("refresh_tokens_pkey", ["tenant_id", "token"]).execute();
3441
+ await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3442
+ "client_id",
3443
+ "varchar(21)",
3444
+ (e) => e.references("applications.id").onDelete("cascade").notNull()
3445
+ ).addColumn("tenant_id", "varchar(255)").addColumn("session_id", "varchar(21)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3446
+ "user_id_constraint",
3447
+ ["user_id", "tenant_id"],
3448
+ "users",
3449
+ ["user_id", "tenant_id"],
3450
+ (e) => e.onDelete("cascade")
3451
+ ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
3458
3452
  }
3459
3453
  async function Ss(t) {
3460
3454
  await t.schema.dropTable("refresh_tokens").execute();
@@ -3465,75 +3459,55 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3465
3459
  up: Ts
3466
3460
  }, Symbol.toStringTag, { value: "Module" }));
3467
3461
  async function ks(t) {
3468
- await t.schema.alterTable("sessions").addColumn("id", "varchar(21)").execute(), await t.schema.alterTable("sessions").addColumn("idle_expires_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("updated_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("authenticated_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("revoked_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("last_interaction_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("device", "varchar(2048)").execute(), await t.schema.alterTable("sessions").addColumn("clients", "varchar(1024)").execute(), await t.schema.alterTable("sessions").dropColumn("expires_at").execute(), await t.schema.alterTable("sessions").addColumn("expires_at", "varchar(35)").execute();
3469
3462
  }
3470
3463
  async function $s(t) {
3471
- await t.schema.alterTable("sessions").dropColumn("id").dropColumn("idle_expires_at").dropColumn("updated_at").dropColumn("revoked_at").dropColumn("authenticated_at").dropColumn("last_interaction_at").dropColumn("device").dropColumn("clients").execute();
3472
3464
  }
3473
- const Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3465
+ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3474
3466
  __proto__: null,
3475
3467
  down: $s,
3476
3468
  up: ks
3477
3469
  }, Symbol.toStringTag, { value: "Module" }));
3478
- async function Is(t) {
3479
- await t.schema.alterTable("refresh_tokens").addColumn("rotating", "boolean").execute(), await t.schema.alterTable("refresh_tokens").addColumn("device", "varchar(1024)").execute(), await t.schema.alterTable("refresh_tokens").addColumn("resource_servers", "varchar(1024)").execute(), await t.schema.alterTable("refresh_tokens").addColumn("user_id", "varchar(255)").execute(), await t.schema.alterTable("refresh_tokens").dropColumn("scope").execute(), await t.schema.alterTable("refresh_tokens").addColumn("scope", "varchar(255)").execute(), await t.schema.alterTable("refresh_tokens").dropColumn("audience").execute(), await t.schema.alterTable("refresh_tokens").addColumn("audience", "varchar(255)").execute(), await t.schema.alterTable("refresh_tokens").dropColumn("session_id").execute(), await t.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(255)").execute(), await t.schema.createTable("sessions_new").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3480
- "user_id_constraint",
3481
- ["user_id", "tenant_id"],
3482
- "users",
3483
- ["user_id", "tenant_id"],
3484
- (e) => e.onDelete("cascade")
3485
- ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("authenticated_at", "varchar(35)").addColumn("last_interaction_at", "varchar(35)").addColumn("used_at", "varchar(35)").addColumn("revoked_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("clients", "varchar(1024)", (e) => e.notNull()).execute(), await t.schema.createTable("refresh_tokens_new").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3486
- "client_id",
3487
- "varchar(21)",
3488
- (e) => e.references("applications.id").onDelete("cascade").notNull()
3489
- ).addColumn("tenant_id", "varchar(255)").addColumn("session_id", "varchar(21)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3490
- "user_id_constraint",
3491
- ["user_id", "tenant_id"],
3492
- "users",
3493
- ["user_id", "tenant_id"],
3494
- (e) => e.onDelete("cascade")
3495
- ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
3470
+ async function Ds(t) {
3496
3471
  }
3497
3472
  async function Ps(t) {
3498
- await t.schema.dropTable("sessions_new").execute(), await t.schema.dropTable("refresh_tokens_new").execute();
3499
3473
  }
3500
3474
  const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3501
3475
  __proto__: null,
3502
3476
  down: Ps,
3503
- up: Is
3477
+ up: Ds
3504
3478
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3505
- m1_init: La,
3506
- m2_magicLink: za,
3507
- m3_updateAt: Ua,
3508
- m4_logTable: Va,
3509
- m5_userProfile: Ga,
3510
- m6_sessions: Ya,
3511
- m7_passwords: tr,
3512
- m8_logsTableNewFields: nr,
3513
- m9_passwordTableNewField: ir,
3514
- n01_codesTable: dr,
3515
- n11_universalLoginSession: hr,
3516
- n12_userFields: pr,
3517
- n13_userEmailIndex: yr,
3518
- n14_profileDataField: Cr,
3519
- n15_userEmailIndex: Tr,
3520
- n16_userLocale: kr,
3521
- n17_signingKeys: Ir,
3522
- n18_logsFields: Mr,
3523
- n19_connectionsUserinfo: Lr,
3524
- n20_missingFields: zr,
3525
- n21_sessionDeletedAt: Ur,
3526
- n22_dropLogsFields: Vr,
3527
- n23_dropUsersFields: Gr,
3528
- n24_logsIndexes: Yr,
3479
+ m1_init: Lr,
3480
+ m2_magicLink: zr,
3481
+ m3_updateAt: Ur,
3482
+ m4_logTable: Vr,
3483
+ m5_userProfile: Gr,
3484
+ m6_sessions: Yr,
3485
+ m7_passwords: ta,
3486
+ m8_logsTableNewFields: na,
3487
+ m9_passwordTableNewField: ia,
3488
+ n01_codesTable: da,
3489
+ n11_universalLoginSession: ha,
3490
+ n12_userFields: pa,
3491
+ n13_userEmailIndex: wa,
3492
+ n14_profileDataField: ba,
3493
+ n15_userEmailIndex: Ta,
3494
+ n16_userLocale: ka,
3495
+ n17_signingKeys: Da,
3496
+ n18_logsFields: Ma,
3497
+ n19_connectionsUserinfo: La,
3498
+ n20_missingFields: za,
3499
+ n21_sessionDeletedAt: Ua,
3500
+ n22_dropLogsFields: Va,
3501
+ n23_dropUsersFields: Ga,
3502
+ n24_logsIndexes: Ya,
3529
3503
  n25_logDescMaxLength: tn,
3530
3504
  n26_logsTableExtraFields: nn,
3531
3505
  n27_usersTableNameIndex: cn,
3532
3506
  n28_usersEmailConstrain: un,
3533
- n29_increaseOtpStateLength: _n,
3507
+ n29_increaseOtpStateLength: fn,
3534
3508
  n30_increaseTicketStateLength: gn,
3535
3509
  n31_branding: Nn,
3536
- n32_indexesAndNotNull: bn,
3510
+ n32_indexesAndNotNull: Cn,
3537
3511
  n33_vendorIdInUniversalLoginSession: Sn,
3538
3512
  n34_auth0ClientInUniversalLoginSession: $n,
3539
3513
  n35_increaseUniversalSessionStateLength: Pn,
@@ -3544,16 +3518,16 @@ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3544
3518
  n40_userId: qn,
3545
3519
  n41_hooks: Hn,
3546
3520
  n42_userIdIndexes: Zn,
3547
- n43_userIdIndexes: ao,
3521
+ n43_userIdIndexes: ro,
3548
3522
  n44_codes: oo,
3549
3523
  n45_hookProperties: co,
3550
3524
  n46_loginAuth0Client: mo,
3551
- n47_loginAuth0Client: fo,
3552
- n48_saml: wo,
3525
+ n47_loginAuth0Client: _o,
3526
+ n48_saml: yo,
3553
3527
  n49_removeFields: vo,
3554
3528
  n50_authParamsNonce: xo,
3555
3529
  n51_connectionid: Oo,
3556
- n52_cert: Do,
3530
+ n52_cert: Io,
3557
3531
  n53_codes_primary_key: jo,
3558
3532
  n54_cleanup_tables: Fo,
3559
3533
  n55_logs_index: Jo,
@@ -3562,24 +3536,24 @@ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3562
3536
  n58_connection_client_id: Wo,
3563
3537
  n59_connection_options: Xo,
3564
3538
  n60_users_metadata: es,
3565
- n61_userLocales: rs,
3539
+ n61_userLocales: as,
3566
3540
  n62_prompt: ss,
3567
3541
  n63_connection_cleanup: ls,
3568
3542
  n64_act_as: ms,
3569
- n65_code_verifier: fs,
3570
- n66_email_providers: ws,
3543
+ n65_code_verifier: _s,
3544
+ n66_email_providers: ys,
3571
3545
  n67_drop_tickets: vs,
3572
3546
  n68_login_useragents: xs,
3573
3547
  n70_refresh_tokens: Os,
3574
- n71_session_new_fields: Ds,
3548
+ n71_session_new_fields: Is,
3575
3549
  n72_session_primary_key: js
3576
3550
  };
3577
3551
  async function Es(t, e = !1) {
3578
3552
  e && console.log("migrating...");
3579
- const a = new Fe(Le), r = new ve({
3553
+ const r = new Fe(Le), a = new ve({
3580
3554
  db: t,
3581
- provider: a
3582
- }), { error: o, results: n } = await r.migrateToLatest();
3555
+ provider: r
3556
+ }), { error: o, results: n } = await a.migrateToLatest();
3583
3557
  if (n == null || n.forEach((s) => {
3584
3558
  s.status === "Success" ? e && console.log(
3585
3559
  `migration "${s.migrationName}" was executed successfully`
@@ -3589,34 +3563,34 @@ async function Es(t, e = !1) {
3589
3563
  }
3590
3564
  async function Js(t) {
3591
3565
  console.log("migrating...");
3592
- const e = new Fe(Le), a = new ve({
3566
+ const e = new Fe(Le), r = new ve({
3593
3567
  db: t,
3594
3568
  provider: e
3595
- }), { error: r, results: o } = await a.migrateDown();
3569
+ }), { error: a, results: o } = await r.migrateDown();
3596
3570
  if (o == null || o.forEach((n) => {
3597
3571
  n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
3598
- }), r)
3599
- throw console.error("failed to migrate"), console.error(r), r;
3572
+ }), a)
3573
+ throw console.error("failed to migrate"), console.error(a), a;
3600
3574
  }
3601
3575
  function zs(t) {
3602
3576
  return {
3603
- applications: It(t),
3577
+ applications: Dt(t),
3604
3578
  branding: Wt(t),
3605
3579
  clients: Et(t),
3606
3580
  codes: Tt(t),
3607
3581
  connections: Lt(t),
3608
- emailProviders: wa(t),
3582
+ emailProviders: yr(t),
3609
3583
  domains: Qt(t),
3610
- hooks: ea(t),
3584
+ hooks: er(t),
3611
3585
  keys: Kt(t),
3612
- logins: ua(t),
3586
+ logins: ur(t),
3613
3587
  logs: lt(t),
3614
- passwords: yt(t),
3615
- promptSettings: _a(t),
3616
- refreshTokens: xa(t),
3617
- sessions: ft(t),
3588
+ passwords: wt(t),
3589
+ promptSettings: fr(t),
3590
+ refreshTokens: xr(t),
3591
+ sessions: _t(t),
3618
3592
  tenants: nt(t),
3619
- themes: sa(t),
3593
+ themes: sr(t),
3620
3594
  users: Xe(t)
3621
3595
  };
3622
3596
  }