@authhero/kysely-adapter 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,17 +2,17 @@ var Ee = Object.defineProperty;
2
2
  var de = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var ze = (t, e, r) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
6
- var j = (t, e, r) => ze(t, typeof e != "symbol" ? e + "" : e, r), U = (t, e, r) => e.has(t) || de("Cannot " + r);
7
- var c = (t, e, r) => (U(t, e, "read from private field"), r ? r.call(t) : e.get(t)), w = (t, e, r) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), M = (t, e, r, a) => (U(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), u = (t, e, r) => (U(t, e, "access private method"), r);
8
- import { parseUserId as Y, codeSchema as Je, connectionSchema as Re, loginSchema as Ue, promptSettingSchema as Ke } from "@authhero/adapter-interfaces";
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), U = (t, e, a) => e.has(t) || de("Cannot " + a);
7
+ var c = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), w = (t, e, a) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (U(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
8
+ import { parseUserId as Y, codeSchema as ze, connectionSchema as Re, loginSchema as Ue, promptSettingSchema as Ke } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var V = class extends Error {
11
- constructor(e = 500, r) {
12
- super(r == null ? void 0 : r.message, { cause: r == null ? void 0 : r.cause });
11
+ constructor(e = 500, a) {
12
+ super(a == null ? void 0 : a.message, { cause: a == null ? void 0 : a.cause });
13
13
  j(this, "res");
14
14
  j(this, "status");
15
- this.res = r == null ? void 0 : r.res, this.status = e;
15
+ this.res = a == null ? void 0 : a.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, r) => {
28
- const { identities: a, ...o } = r, n = {
27
+ return async (e, a) => {
28
+ const { identities: r, ...o } = a, 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: 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)
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)
38
38
  };
39
39
  try {
40
40
  await t.insertInto("users").values(n).execute();
@@ -52,16 +52,16 @@ function Be(t) {
52
52
  }
53
53
  function f(t) {
54
54
  const e = { ...t };
55
- for (const 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]));
55
+ for (const a in e)
56
+ e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(f) : e[a] = f(e[a]));
57
57
  return e;
58
58
  }
59
59
  function _e(t) {
60
60
  let e = {};
61
61
  try {
62
62
  e = JSON.parse(t.profileData || "{}");
63
- } catch (r) {
64
- console.error("Error parsing profileData", r);
63
+ } catch (a) {
64
+ console.error("Error parsing profileData", a);
65
65
  }
66
66
  return {
67
67
  connection: t.connection,
@@ -76,26 +76,26 @@ function _e(t) {
76
76
  };
77
77
  }
78
78
  function Qe(t) {
79
- return async (e, 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()
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()
83
83
  ]);
84
- if (!a)
84
+ if (!r)
85
85
  return null;
86
- const { tenant_id: n, ...s } = a, l = {
86
+ const { tenant_id: n, ...s } = r, l = {
87
87
  ...s,
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),
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),
93
93
  identities: [
94
94
  {
95
- connection: a.connection,
96
- provider: a.provider,
97
- user_id: Y(a.user_id).id,
98
- isSocial: !!a.is_social
95
+ connection: r.connection,
96
+ provider: r.provider,
97
+ user_id: Y(r.user_id).id,
98
+ isSocial: !!r.is_social
99
99
  },
100
100
  ...o.map(_e)
101
101
  ]
@@ -103,8 +103,8 @@ function Qe(t) {
103
103
  return f(l);
104
104
  };
105
105
  }
106
- function T(t, e, r, a) {
107
- return r.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
106
+ function T(t, e, a, r) {
107
+ return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
108
  let s = n.startsWith("-"), l, d, g, m;
109
109
  return n.startsWith("-_exists_:") ? (l = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (l = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [l, d] = s ? n.substring(1).split(":") : n.split(":"), g = !1, d.startsWith(">=") ? (m = ">=", d = d.substring(2)) : d.startsWith(">") ? (m = ">", d = d.substring(1)) : d.startsWith("<=") ? (m = "<=", d = d.substring(2)) : d.startsWith("<") ? (m = "<", d = d.substring(1)) : m = "=") : (l = null, d = n, g = !1), { key: l, value: d, isNegation: s, isExistsQuery: g, operator: m };
110
110
  }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: d, operator: g }) => {
@@ -134,27 +134,27 @@ function T(t, e, r, a) {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
136
136
  (y) => y.or(
137
- a.map((x) => y(m(x), "like", `%${s}%`))
137
+ r.map((x) => y(m(x), "like", `%${s}%`))
138
138
  )
139
139
  );
140
140
  }
141
141
  }), e;
142
142
  }
143
- function C(t) {
143
+ function b(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, r = {
147
+ return async (e, a = {
148
148
  page: 0,
149
149
  per_page: 50,
150
150
  include_totals: !1
151
151
  }) => {
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) {
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) {
154
154
  const { ref: m } = t.dynamic;
155
- a = a.orderBy(m(r.sort.sort_by), r.sort.sort_order);
155
+ r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
156
156
  }
157
- const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
157
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
158
158
  const y = l.filter(
159
159
  (x) => x.linked_to === m.user_id
160
160
  );
@@ -174,36 +174,36 @@ function Ve(t) {
174
174
  ...y.map(_e)
175
175
  ]
176
176
  });
177
- }), { count: g } = await a.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
177
+ }), { count: g } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
178
178
  return {
179
179
  users: d,
180
- start: r.page * r.per_page,
181
- limit: r.per_page,
182
- length: C(g)
180
+ start: a.page * a.per_page,
181
+ limit: a.per_page,
182
+ length: b(g)
183
183
  };
184
184
  };
185
185
  }
186
186
  function We(t) {
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);
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);
188
188
  }
189
189
  function qe(t) {
190
190
  if (t.email_verified !== void 0)
191
191
  return t.email_verified ? 1 : 0;
192
192
  }
193
193
  function Ge(t) {
194
- return async (e, r, a) => {
194
+ return async (e, a, r) => {
195
195
  const o = {
196
- ...a,
197
- email_verified: qe(a),
196
+ ...r,
197
+ email_verified: qe(r),
198
198
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
199
199
  };
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;
200
+ return r.app_metadata && (o.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (o.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
201
201
  };
202
202
  }
203
203
  function He(t) {
204
- return async (e, r, a, o) => {
204
+ return async (e, a, r, 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", "=", `${a}|${o}`).where("users.linked_to", "=", `${r}`).execute()).length === 1;
206
+ return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
207
207
  };
208
208
  }
209
209
  function Xe(t) {
@@ -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 = "", r = crypto.getRandomValues(new Uint8Array(t));
222
+ let e = "", a = crypto.getRandomValues(new Uint8Array(t));
223
223
  for (; t--; )
224
- e += Ye[r[t] & 63];
224
+ e += Ye[a[t] & 63];
225
225
  return e;
226
226
  };
227
227
  function Ze(t) {
228
228
  return async (e) => {
229
- const r = {
229
+ const a = {
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(r).execute(), r;
235
+ return await t.insertInto("tenants").values(a).execute(), a;
236
236
  };
237
237
  }
238
238
  function et(t) {
239
239
  return async (e) => {
240
- const r = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
- return r ? f(r) : null;
240
+ const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
+ return a ? f(a) : null;
242
242
  };
243
243
  }
244
244
  function tt(t) {
@@ -247,18 +247,18 @@ function tt(t) {
247
247
  per_page: 50,
248
248
  include_totals: !1
249
249
  }) => {
250
- let r = t.selectFrom("tenants");
250
+ let a = t.selectFrom("tenants");
251
251
  if (e.sort && e.sort.sort_by) {
252
252
  const { ref: l } = t.dynamic;
253
- r = r.orderBy(l(e.sort.sort_by), e.sort.sort_order);
253
+ a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
- e.q && (r = r.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
- const o = await r.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
255
+ e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
+ const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
257
257
  if (!e.include_totals)
258
258
  return {
259
259
  tenants: o
260
260
  };
261
- const { count: n } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = C(n);
261
+ const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(n);
262
262
  return {
263
263
  tenants: o.map(f),
264
264
  start: (e.page - 1) * e.per_page,
@@ -267,17 +267,17 @@ function tt(t) {
267
267
  };
268
268
  };
269
269
  }
270
- function rt(t) {
271
- return async (e, r) => {
272
- const a = {
273
- ...r,
270
+ function at(t) {
271
+ return async (e, a) => {
272
+ const r = {
273
+ ...a,
274
274
  id: e,
275
275
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
276
276
  };
277
- await t.updateTable("tenants").set(a).where("id", "=", e).execute();
277
+ await t.updateTable("tenants").set(r).where("id", "=", e).execute();
278
278
  };
279
279
  }
280
- function at(t) {
280
+ function rt(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: rt(t),
289
- remove: at(t)
288
+ update: at(t),
289
+ remove: rt(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, r) => {
297
+ return async (e, a) => {
298
298
  var o, n, s;
299
- const a = {
299
+ const r = {
300
300
  id: k(),
301
- ...r,
302
- user_agent: r.user_agent.slice(0, ot)
301
+ ...a,
302
+ user_agent: a.user_agent.slice(0, ot)
303
303
  };
304
304
  return await t.insertInto("logs").values({
305
- ...a,
305
+ ...r,
306
306
  // Truncate long strings to avoid database errors
307
- description: (o = a.description) == null ? void 0 : o.substring(0, 256),
308
- isMobile: r.isMobile ? 1 : 0,
307
+ description: (o = r.description) == null ? void 0 : o.substring(0, 256),
308
+ isMobile: a.isMobile ? 1 : 0,
309
309
  tenant_id: e,
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;
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;
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, r = {
339
+ return async (e, a = {
340
340
  page: 0,
341
341
  per_page: 50,
342
342
  include_totals: !1
343
343
  }) => {
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) {
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) {
348
348
  const { ref: l } = t.dynamic;
349
349
  o = o.orderBy(
350
- l(r.sort.sort_by),
351
- r.sort.sort_order
350
+ l(a.sort.sort_by),
351
+ a.sort.sort_order
352
352
  );
353
353
  }
354
- o = o.offset(r.page * r.per_page).limit(r.per_page);
355
- const n = await o.selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
354
+ o = o.offset(a.page * a.per_page).limit(a.per_page);
355
+ const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
356
356
  return {
357
357
  logs: n.map(pe),
358
- start: r.page * r.per_page,
359
- limit: r.per_page,
360
- length: C(s)
358
+ start: a.page * a.per_page,
359
+ limit: a.per_page,
360
+ length: b(s)
361
361
  };
362
362
  };
363
363
  }
364
364
  function lt(t) {
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;
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;
368
368
  };
369
369
  }
370
370
  function ct(t) {
@@ -375,46 +375,78 @@ function ct(t) {
375
375
  };
376
376
  }
377
377
  function dt(t) {
378
- return async (e, r) => await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.session_id", "=", r).where("sessions.deleted_at", "is", null).selectAll().executeTakeFirst() ?? null;
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)
381
+ return null;
382
+ const { tenant_id: o, device: n, clients: s, ...l } = r, d = l.id || l.session_id || "";
383
+ return {
384
+ ...l,
385
+ id: d,
386
+ device: JSON.parse(n),
387
+ clients: JSON.parse(s)
388
+ };
389
+ };
379
390
  }
380
391
  function ut(t) {
381
- return async (e, r) => {
382
- const a = {
383
- ...r,
392
+ return async (e, a) => {
393
+ const r = {
394
+ ...a,
395
+ // fallback untill we changed primary key
396
+ session_id: a.id,
384
397
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
385
- expires_at: (/* @__PURE__ */ new Date()).toISOString()
398
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
399
+ authenticated_at: (/* @__PURE__ */ new Date()).toISOString(),
400
+ last_interaction_at: (/* @__PURE__ */ new Date()).toISOString()
386
401
  };
387
- return await t.insertInto("sessions").values({ ...a, tenant_id: e }).execute(), { ...r, ...a };
402
+ return await t.insertInto("sessions").values({
403
+ ...r,
404
+ tenant_id: e,
405
+ device: JSON.stringify(a.device),
406
+ clients: JSON.stringify(a.clients)
407
+ }).execute(), r;
388
408
  };
389
409
  }
390
410
  function mt(t) {
391
- return async (e, r) => !!(await t.updateTable("sessions").set({ deleted_at: (/* @__PURE__ */ new Date()).toISOString() }).where("tenant_id", "=", e).where("sessions.session_id", "=", r).where("sessions.deleted_at", "is", null).execute()).length;
411
+ return async (e, a) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
392
412
  }
393
413
  function ht(t) {
394
- return async (e, r, a) => !!(await t.updateTable("sessions").set(a).where("tenant_id", "=", e).where("sessions.session_id", "=", r).where("sessions.deleted_at", "is", null).execute()).length;
414
+ return async (e, a, r) => {
415
+ const o = {
416
+ ...r,
417
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
418
+ device: r.device ? JSON.stringify(r.device) : void 0,
419
+ clients: r.clients ? JSON.stringify(r.clients) : void 0
420
+ };
421
+ return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
422
+ };
395
423
  }
396
424
  function ft(t) {
397
- return async (e, r = {
425
+ return async (e, a = {
398
426
  page: 0,
399
427
  per_page: 50,
400
428
  include_totals: !1
401
429
  }) => {
402
- let a = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
403
- r.q && (a = T(t, a, r.q, ["user_id", "session_id"]));
404
- let o = a;
405
- if (r.sort && r.sort.sort_by) {
430
+ let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
431
+ a.q && (r = T(t, r, a.q, ["user_id", "session_id"]));
432
+ let o = r;
433
+ if (a.sort && a.sort.sort_by) {
406
434
  const { ref: d } = t.dynamic;
407
435
  o = o.orderBy(
408
- d(r.sort.sort_by),
409
- r.sort.sort_order
436
+ d(a.sort.sort_by),
437
+ a.sort.sort_order
410
438
  );
411
439
  }
412
- o = o.offset(r.page * r.per_page).limit(r.per_page);
413
- const n = await o.selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = C(s);
440
+ o = o.offset(a.page * a.per_page).limit(a.per_page);
441
+ const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
414
442
  return {
415
- sessions: n,
416
- start: r.page * r.per_page,
417
- limit: r.per_page,
443
+ sessions: n.map((d) => ({
444
+ ...d,
445
+ device: JSON.parse(d.device),
446
+ clients: JSON.parse(d.clients)
447
+ })),
448
+ start: a.page * a.per_page,
449
+ limit: a.per_page,
418
450
  length: l
419
451
  };
420
452
  };
@@ -429,29 +461,29 @@ function _t(t) {
429
461
  };
430
462
  }
431
463
  function pt(t) {
432
- return async (e, r) => {
433
- const a = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", r).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = a;
464
+ return async (e, a) => {
465
+ const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = r;
434
466
  return n;
435
467
  };
436
468
  }
437
469
  function gt(t) {
438
- return async (e, r) => {
439
- const a = {
440
- ...r,
470
+ return async (e, a) => {
471
+ const r = {
472
+ ...a,
441
473
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
442
474
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
443
475
  };
444
476
  return await t.insertInto("passwords").values({
445
- ...a,
477
+ ...r,
446
478
  tenant_id: e
447
- }).execute(), a;
479
+ }).execute(), r;
448
480
  };
449
481
  }
450
482
  function wt(t) {
451
- return async (e, r) => (await t.updateTable("passwords").set({
452
- password: r.password,
483
+ return async (e, a) => (await t.updateTable("passwords").set({
484
+ password: a.password,
453
485
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
454
- }).where("tenant_id", "=", e).where("user_id", "=", r.user_id).execute()).length === 1;
486
+ }).where("tenant_id", "=", e).where("user_id", "=", a.user_id).execute()).length === 1;
455
487
  }
456
488
  function yt(t) {
457
489
  return {
@@ -461,78 +493,78 @@ function yt(t) {
461
493
  };
462
494
  }
463
495
  function Nt(t) {
464
- return async (e, r = {
496
+ return async (e, a = {
465
497
  page: 0,
466
498
  per_page: 50,
467
499
  include_totals: !1
468
500
  }) => {
469
- let a = t.selectFrom("codes").where("codes.tenant_id", "=", e);
470
- r.q && (a = T(t, a, r.q, ["code", "login_id"]));
471
- const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
501
+ let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
502
+ a.q && (r = T(t, r, a.q, ["code", "login_id"]));
503
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
472
504
  return {
473
505
  codes: n.map((d) => {
474
506
  const { tenant_id: g, ...m } = d;
475
- return Je.parse(f(m));
507
+ return ze.parse(f(m));
476
508
  }),
477
- start: r.page * r.per_page,
478
- limit: r.per_page,
479
- length: C(s)
509
+ start: a.page * a.per_page,
510
+ limit: a.per_page,
511
+ length: b(s)
480
512
  };
481
513
  };
482
514
  }
483
515
  function vt(t) {
484
- return async (e, r) => {
485
- const a = {
486
- ...r,
516
+ return async (e, a) => {
517
+ const r = {
518
+ ...a,
487
519
  created_at: (/* @__PURE__ */ new Date()).toISOString()
488
520
  };
489
521
  return await t.insertInto("codes").values({
490
- ...a,
522
+ ...r,
491
523
  tenant_id: e
492
- }).execute(), a;
524
+ }).execute(), r;
493
525
  };
494
526
  }
495
- function bt(t) {
496
- return async (e, r) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
497
- }
498
527
  function Ct(t) {
499
- return async (e, r, a) => {
500
- let o = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
528
+ return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
529
+ }
530
+ function bt(t) {
531
+ return async (e, a, r) => {
532
+ let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
501
533
  e.length && (o = o.where("codes.tenant_id", "=", e));
502
534
  const n = await o.selectAll().executeTakeFirst();
503
535
  return n ? f(n) : null;
504
536
  };
505
537
  }
506
538
  function xt(t) {
507
- return async (e, r) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numUpdatedRows > 0;
539
+ 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;
508
540
  }
509
541
  function Tt(t) {
510
542
  return {
511
543
  create: vt(t),
512
544
  list: Nt(t),
513
- remove: bt(t),
545
+ remove: Ct(t),
514
546
  used: xt(t),
515
- get: Ct(t)
547
+ get: bt(t)
516
548
  };
517
549
  }
518
550
  function St(t) {
519
- return async (e, r) => {
520
- const a = {
551
+ return async (e, a) => {
552
+ const r = {
521
553
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
522
554
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
523
- ...r
524
- }, o = JSON.stringify(r.allowed_origins), n = JSON.stringify(r.callbacks), s = JSON.stringify(r.web_origins), l = JSON.stringify(r.allowed_logout_urls), d = JSON.stringify(r.allowed_clients);
555
+ ...a
556
+ }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
525
557
  return await t.insertInto("applications").values({
526
- ...a,
558
+ ...r,
527
559
  tenant_id: e,
528
- disable_sign_ups: r.disable_sign_ups ? 1 : 0,
529
- addons: r.addons ? JSON.stringify(r.addons) : "{}",
560
+ disable_sign_ups: a.disable_sign_ups ? 1 : 0,
561
+ addons: a.addons ? JSON.stringify(a.addons) : "{}",
530
562
  callbacks: n,
531
563
  allowed_origins: o,
532
564
  web_origins: s,
533
565
  allowed_logout_urls: l,
534
566
  allowed_clients: d
535
- }).execute(), a;
567
+ }).execute(), r;
536
568
  };
537
569
  }
538
570
  function Ot(t) {
@@ -550,36 +582,36 @@ function Ot(t) {
550
582
  });
551
583
  }
552
584
  function kt(t) {
553
- return async (e, r) => {
554
- const a = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).selectAll().executeTakeFirst();
555
- return a ? f({
556
- ...a,
557
- disable_sign_ups: !!a.disable_sign_ups,
558
- addons: JSON.parse(a.addons),
559
- callbacks: JSON.parse(a.callbacks),
560
- allowed_origins: JSON.parse(a.allowed_origins),
561
- web_origins: JSON.parse(a.web_origins),
562
- allowed_logout_urls: JSON.parse(a.allowed_logout_urls)
585
+ return async (e, a) => {
586
+ const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
587
+ return r ? f({
588
+ ...r,
589
+ disable_sign_ups: !!r.disable_sign_ups,
590
+ addons: JSON.parse(r.addons),
591
+ callbacks: JSON.parse(r.callbacks),
592
+ allowed_origins: JSON.parse(r.allowed_origins),
593
+ web_origins: JSON.parse(r.web_origins),
594
+ allowed_logout_urls: JSON.parse(r.allowed_logout_urls)
563
595
  }) : null;
564
596
  };
565
597
  }
566
598
  function $t(t) {
567
- return async (e, r) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
599
+ return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
568
600
  }
569
601
  function It(t) {
570
- return async (e, r, a) => {
602
+ return async (e, a, r) => {
571
603
  const o = {
572
- ...a,
604
+ ...r,
573
605
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
574
- allowed_origins: a.allowed_origins ? JSON.stringify(a.allowed_origins) : void 0,
575
- callbacks: a.callbacks ? JSON.stringify(a.callbacks) : void 0,
576
- web_origins: a.web_origins ? JSON.stringify(a.web_origins) : void 0,
577
- allowed_logout_urls: a.allowed_logout_urls ? JSON.stringify(a.allowed_logout_urls) : void 0,
578
- allowed_clients: a.allowed_clients ? JSON.stringify(a.allowed_clients) : void 0,
579
- addons: a.addons ? JSON.stringify(a.addons) : "{}",
580
- disable_sign_ups: a.disable_sign_ups ? 1 : 0
606
+ allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
607
+ callbacks: r.callbacks ? JSON.stringify(r.callbacks) : void 0,
608
+ web_origins: r.web_origins ? JSON.stringify(r.web_origins) : void 0,
609
+ allowed_logout_urls: r.allowed_logout_urls ? JSON.stringify(r.allowed_logout_urls) : void 0,
610
+ allowed_clients: r.allowed_clients ? JSON.stringify(r.allowed_clients) : void 0,
611
+ addons: r.addons ? JSON.stringify(r.addons) : "{}",
612
+ disable_sign_ups: r.disable_sign_ups ? 1 : 0
581
613
  };
582
- return await t.updateTable("applications").set(o).where("applications.id", "=", r).where("applications.tenant_id", "=", e).execute(), !0;
614
+ return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
583
615
  };
584
616
  }
585
617
  function Dt(t) {
@@ -592,65 +624,65 @@ function Dt(t) {
592
624
  };
593
625
  }
594
626
  function Pt(t) {
595
- return async (e, r) => {
596
- const a = {
627
+ return async (e, a) => {
628
+ const r = {
597
629
  id: k(),
598
- ...r,
630
+ ...a,
599
631
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
600
632
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
601
633
  };
602
634
  return await t.insertInto("connections").values({
603
- ...a,
635
+ ...r,
604
636
  // The connection options will have many different properties depending on the strategy
605
- options: JSON.stringify(a.options || {}),
637
+ options: JSON.stringify(r.options || {}),
606
638
  tenant_id: e
607
- }).execute(), a;
639
+ }).execute(), r;
608
640
  };
609
641
  }
610
642
  function jt(t) {
611
- return async (e, r = {
643
+ return async (e, a = {
612
644
  page: 0,
613
645
  per_page: 50,
614
646
  include_totals: !1
615
647
  }) => {
616
- let a = t.selectFrom("connections").where("connections.tenant_id", "=", e);
617
- r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
618
- const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map(
648
+ let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
649
+ a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
650
+ const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
619
651
  (d) => f({
620
652
  ...d,
621
653
  options: JSON.parse(d.options)
622
654
  })
623
- ), { count: l } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
655
+ ), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
624
656
  return {
625
657
  connections: s,
626
- start: r.page * r.per_page,
627
- limit: r.per_page,
628
- length: C(l)
658
+ start: a.page * a.per_page,
659
+ limit: a.per_page,
660
+ length: b(l)
629
661
  };
630
662
  };
631
663
  }
632
664
  function Mt(t) {
633
- return async (e, r) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
665
+ return async (e, a) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
634
666
  }
635
667
  function At(t) {
636
- return async (e, r) => {
637
- const a = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).selectAll().executeTakeFirst();
638
- return a ? f({
639
- ...a,
640
- options: JSON.parse(a.options)
668
+ return async (e, a) => {
669
+ const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
670
+ return r ? f({
671
+ ...r,
672
+ options: JSON.parse(r.options)
641
673
  }) : null;
642
674
  };
643
675
  }
644
676
  function Ft(t) {
645
- return async (e, r, a) => {
677
+ return async (e, a, r) => {
646
678
  const o = {
647
- ...a,
679
+ ...r,
648
680
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
649
681
  };
650
682
  return await t.updateTable("connections").set({
651
683
  ...o,
652
684
  options: o.options ? JSON.stringify(o.options) : void 0
653
- }).where("connections.id", "=", r).where("connections.tenant_id", "=", e).execute(), !0;
685
+ }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
654
686
  };
655
687
  }
656
688
  function Lt(t) {
@@ -665,15 +697,15 @@ function Lt(t) {
665
697
  function Et(t) {
666
698
  return {
667
699
  get: async (e) => {
668
- const r = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
669
- if (!r)
670
- return null;
671
- const a = await t.selectFrom("tenants").selectAll().where("id", "=", r.tenant_id).executeTakeFirst();
700
+ const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
672
701
  if (!a)
702
+ return null;
703
+ const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
704
+ if (!r)
673
705
  throw new V(404, { message: "Tenant not found" });
674
- const o = await t.selectFrom("connections").where("tenant_id", "=", r.tenant_id).selectAll().execute(), n = await t.selectFrom("domains").where("tenant_id", "=", r.tenant_id).selectAll().execute();
706
+ 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();
675
707
  return {
676
- ...r,
708
+ ...a,
677
709
  connections: o.map(
678
710
  (l) => Re.parse(
679
711
  f({
@@ -683,64 +715,64 @@ function Et(t) {
683
715
  )
684
716
  ),
685
717
  domains: n,
686
- addons: r.addons ? JSON.parse(r.addons) : {},
687
- callbacks: r.callbacks ? JSON.parse(r.callbacks) : [],
688
- allowed_origins: r.allowed_origins ? JSON.parse(r.allowed_origins) : [],
689
- web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
690
- allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
691
- allowed_clients: r.allowed_clients ? JSON.parse(r.allowed_clients) : [],
692
- tenant: f(a),
718
+ addons: a.addons ? JSON.parse(a.addons) : {},
719
+ callbacks: a.callbacks ? JSON.parse(a.callbacks) : [],
720
+ allowed_origins: a.allowed_origins ? JSON.parse(a.allowed_origins) : [],
721
+ web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
722
+ allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
723
+ allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
724
+ tenant: f(r),
693
725
  // this is really an integer in the database
694
- disable_sign_ups: !!r.disable_sign_ups
726
+ disable_sign_ups: !!a.disable_sign_ups
695
727
  };
696
728
  }
697
729
  };
698
730
  }
699
- function zt(t) {
731
+ function Jt(t) {
700
732
  return async () => await t.selectFrom("keys").where(
701
- (r) => r.or([
702
- r("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
703
- r("revoked_at", "is", null)
733
+ (a) => a.or([
734
+ a("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
735
+ a("revoked_at", "is", null)
704
736
  ])
705
737
  ).selectAll().execute();
706
738
  }
707
- function Jt(t) {
739
+ function zt(t) {
708
740
  return async (e) => {
709
741
  await t.insertInto("keys").values({ ...e, created_at: (/* @__PURE__ */ new Date()).toDateString() }).execute();
710
742
  };
711
743
  }
712
744
  function Rt(t) {
713
- return async (e, r) => !!(await t.updateTable("keys").set(r).where("kid", "=", e).execute()).length;
745
+ return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
714
746
  }
715
747
  function Ut(t) {
716
748
  return {
717
- create: Jt(t),
718
- list: zt(t),
749
+ create: zt(t),
750
+ list: Jt(t),
719
751
  update: Rt(t)
720
752
  };
721
753
  }
722
754
  function Kt(t) {
723
- return async (e, r) => {
724
- const a = {
755
+ return async (e, a) => {
756
+ const r = {
725
757
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
726
758
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
727
759
  tenant_id: e,
728
760
  id: k(),
729
- ...r
761
+ ...a
730
762
  };
731
- return await t.insertInto("domains").values(a).execute(), a;
763
+ return await t.insertInto("domains").values(r).execute(), r;
732
764
  };
733
765
  }
734
766
  function Bt(t) {
735
- return async (e, r) => {
736
- let a = t.selectFrom("domains").where("domains.tenant_id", "=", e);
737
- r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
738
- const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
767
+ return async (e, a) => {
768
+ let r = t.selectFrom("domains").where("domains.tenant_id", "=", e);
769
+ a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
770
+ 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();
739
771
  return {
740
772
  domains: n,
741
- start: r.page * r.per_page,
742
- limit: r.per_page,
743
- length: C(s)
773
+ start: a.page * a.per_page,
774
+ limit: a.per_page,
775
+ length: b(s)
744
776
  };
745
777
  };
746
778
  }
@@ -752,11 +784,11 @@ function Qt(t) {
752
784
  }
753
785
  function Vt(t) {
754
786
  return async (e) => {
755
- const [r] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
756
- if (!r)
787
+ const [a] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
788
+ if (!a)
757
789
  return null;
758
790
  const {
759
- tenant_id: a,
791
+ tenant_id: r,
760
792
  colors_primary: o,
761
793
  colors_page_background_type: n,
762
794
  colors_page_background_start: s,
@@ -764,7 +796,7 @@ function Vt(t) {
764
796
  colors_page_background_angle_dev: d,
765
797
  font_url: g,
766
798
  ...m
767
- } = r;
799
+ } = a;
768
800
  return f({
769
801
  ...m,
770
802
  colors: {
@@ -781,29 +813,29 @@ function Vt(t) {
781
813
  };
782
814
  }
783
815
  function Wt(t) {
784
- return async (e, r) => {
785
- var s, l, d, g, m, y, x, Z, ee, te, re, ae, ne, oe, se, ie, le, ce;
786
- const { colors: a, font: o, ...n } = r;
816
+ return async (e, a) => {
817
+ var s, l, d, g, m, y, x, Z, ee, te, ae, re, ne, oe, se, ie, le, ce;
818
+ const { colors: r, font: o, ...n } = a;
787
819
  try {
788
820
  await t.insertInto("branding").values({
789
821
  ...n,
790
- colors_primary: a == null ? void 0 : a.primary,
791
- colors_page_background_type: (l = (s = r.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
792
- colors_page_background_start: (g = (d = r.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
793
- colors_page_background_end: (y = (m = r.colors) == null ? void 0 : m.page_background) == null ? void 0 : y.end,
794
- colors_page_background_angle_dev: (Z = (x = r.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
795
- font_url: (ee = r.font) == null ? void 0 : ee.url,
822
+ colors_primary: r == null ? void 0 : r.primary,
823
+ colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
824
+ colors_page_background_start: (g = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
825
+ colors_page_background_end: (y = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : y.end,
826
+ colors_page_background_angle_dev: (Z = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
827
+ font_url: (ee = a.font) == null ? void 0 : ee.url,
796
828
  tenant_id: e
797
829
  }).execute();
798
830
  } catch {
799
831
  await t.updateTable("branding").set({
800
832
  ...n,
801
- colors_primary: a == null ? void 0 : a.primary,
802
- colors_page_background_type: (re = (te = r.colors) == null ? void 0 : te.page_background) == null ? void 0 : re.type,
803
- colors_page_background_start: (ne = (ae = r.colors) == null ? void 0 : ae.page_background) == null ? void 0 : ne.start,
804
- colors_page_background_end: (se = (oe = r.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
805
- colors_page_background_angle_dev: (le = (ie = r.colors) == null ? void 0 : ie.page_background) == null ? void 0 : le.angle_deg,
806
- font_url: (ce = r.font) == null ? void 0 : ce.url
833
+ colors_primary: r == null ? void 0 : r.primary,
834
+ colors_page_background_type: (ae = (te = a.colors) == null ? void 0 : te.page_background) == null ? void 0 : ae.type,
835
+ colors_page_background_start: (ne = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : ne.start,
836
+ colors_page_background_end: (se = (oe = a.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
837
+ colors_page_background_angle_dev: (le = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : le.angle_deg,
838
+ font_url: (ce = a.font) == null ? void 0 : ce.url
807
839
  }).where("tenant_id", "=", e).execute();
808
840
  }
809
841
  };
@@ -815,14 +847,14 @@ function qt(t) {
815
847
  };
816
848
  }
817
849
  function Gt(t) {
818
- return async (e, r = {
850
+ return async (e, a = {
819
851
  page: 0,
820
852
  per_page: 50,
821
853
  include_totals: !1
822
854
  }) => {
823
- let a = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
824
- r.q && (a = T(t, a, r.q, ["url"]));
825
- const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
855
+ let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
856
+ a.q && (r = T(t, r, a.q, ["url"]));
857
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
826
858
  return {
827
859
  hooks: n.map((d) => {
828
860
  const { tenant_id: g, enabled: m, synchronous: y, ...x } = d;
@@ -832,53 +864,53 @@ function Gt(t) {
832
864
  synchronous: !!y
833
865
  });
834
866
  }),
835
- start: r.page * r.per_page,
836
- limit: r.per_page,
837
- length: C(s)
867
+ start: a.page * a.per_page,
868
+ limit: a.per_page,
869
+ length: b(s)
838
870
  };
839
871
  };
840
872
  }
841
873
  function Ht(t) {
842
- return async (e, r) => {
843
- const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).selectAll().executeTakeFirst();
844
- return a ? f({
845
- ...a,
846
- enabled: !!a.enabled,
847
- synchronous: !!a.synchronous
874
+ return async (e, a) => {
875
+ const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
876
+ return r ? f({
877
+ ...r,
878
+ enabled: !!r.enabled,
879
+ synchronous: !!r.synchronous
848
880
  }) : null;
849
881
  };
850
882
  }
851
883
  function Xt(t) {
852
- return async (e, r) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
884
+ return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
853
885
  }
854
886
  function Yt(t) {
855
- return async (e, r) => {
856
- const a = {
887
+ return async (e, a) => {
888
+ const r = {
857
889
  hook_id: k(),
858
- ...r,
890
+ ...a,
859
891
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
860
892
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
861
893
  };
862
894
  return await t.insertInto("hooks").values({
863
- ...a,
895
+ ...r,
864
896
  tenant_id: e,
865
- enabled: r.enabled ? 1 : 0,
866
- synchronous: r.synchronous ? 1 : 0
867
- }).execute(), a;
897
+ enabled: a.enabled ? 1 : 0,
898
+ synchronous: a.synchronous ? 1 : 0
899
+ }).execute(), r;
868
900
  };
869
901
  }
870
902
  function Zt(t) {
871
- return async (e, r, a) => {
903
+ return async (e, a, r) => {
872
904
  const o = {
873
- ...a,
905
+ ...r,
874
906
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
875
- enabled: a.enabled !== void 0 ? a.enabled ? 1 : 0 : void 0,
876
- synchronous: a.enabled !== void 0 ? a.synchronous ? 1 : 0 : void 0
907
+ enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
908
+ synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
877
909
  };
878
- return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", r).where("hooks.tenant_id", "=", e).execute(), !0;
910
+ return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
879
911
  };
880
912
  }
881
- function er(t) {
913
+ function ea(t) {
882
914
  return {
883
915
  create: Yt(t),
884
916
  get: Ht(t),
@@ -887,110 +919,110 @@ function er(t) {
887
919
  remove: Xt(t)
888
920
  };
889
921
  }
890
- function z(t, e = "", r = {}) {
891
- for (let a in t)
892
- if (Object.prototype.hasOwnProperty.call(t, a)) {
893
- const o = e ? `${e}_${a}` : a;
894
- typeof t[a] == "object" && t[a] !== null && !Array.isArray(t[a]) ? z(t[a], o, r) : r[o] = t[a];
922
+ function J(t, e = "", a = {}) {
923
+ for (let r in t)
924
+ if (Object.prototype.hasOwnProperty.call(t, r)) {
925
+ const o = e ? `${e}_${r}` : r;
926
+ typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? J(t[r], o, a) : a[o] = t[r];
895
927
  }
896
- return r;
928
+ return a;
897
929
  }
898
- function tr(t, e) {
899
- const r = {};
900
- for (const [a, o] of Object.entries(t)) {
930
+ function ta(t, e) {
931
+ const a = {};
932
+ for (const [r, o] of Object.entries(t)) {
901
933
  const n = e.find(
902
- (s) => a.startsWith(`${s}_`)
934
+ (s) => r.startsWith(`${s}_`)
903
935
  );
904
936
  if (!n)
905
- r[a] = o;
937
+ a[r] = o;
906
938
  else {
907
- const s = a.slice(n.length + 1);
908
- r[n] = {
909
- ...r[n],
939
+ const s = r.slice(n.length + 1);
940
+ a[n] = {
941
+ ...a[n],
910
942
  [s]: o
911
943
  };
912
944
  }
913
945
  }
914
- return r;
946
+ return a;
915
947
  }
916
- function rr(t) {
917
- return async (e, r) => {
918
- const a = {
948
+ function aa(t) {
949
+ return async (e, a) => {
950
+ const r = {
919
951
  themeId: k(),
920
- ...r,
952
+ ...a,
921
953
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
922
954
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
923
955
  };
924
- return await t.insertInto("themes").values({ ...z(a), tenant_id: e }).execute(), a;
956
+ return await t.insertInto("themes").values({ ...J(r), tenant_id: e }).execute(), r;
925
957
  };
926
958
  }
927
- function ar(t) {
928
- return async (e, r) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
959
+ function ra(t) {
960
+ return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
929
961
  }
930
- function nr(t) {
931
- return async (e, r) => {
932
- const a = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).selectAll().executeTakeFirst();
933
- return a ? f(a) : null;
962
+ function na(t) {
963
+ return async (e, a) => {
964
+ const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
965
+ return r ? f(r) : null;
934
966
  };
935
967
  }
936
- function or(t) {
937
- return async (e, r, a) => {
938
- const o = z({
939
- ...a,
968
+ function oa(t) {
969
+ return async (e, a, r) => {
970
+ const o = J({
971
+ ...r,
940
972
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
941
973
  });
942
- return await t.updateTable("themes").set(o).where("themes.id", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
974
+ return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
943
975
  };
944
976
  }
945
- function sr(t) {
977
+ function sa(t) {
946
978
  return {
947
- create: rr(t),
948
- get: nr(t),
949
- remove: ar(t),
950
- update: or(t)
979
+ create: aa(t),
980
+ get: na(t),
981
+ remove: ra(t),
982
+ update: oa(t)
951
983
  };
952
984
  }
953
- function ir(t) {
954
- return async (e, r) => {
955
- const a = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", a).where("logins.login_id", "=", r).selectAll().executeTakeFirst();
985
+ function ia(t) {
986
+ return async (e, a) => {
987
+ const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", r).where("logins.login_id", "=", a).selectAll().executeTakeFirst();
956
988
  return o ? Ue.parse(
957
- tr(f(o), ["authParams"])
989
+ ta(f(o), ["authParams"])
958
990
  ) : null;
959
991
  };
960
992
  }
961
- function lr(t) {
962
- return async (e, r) => {
963
- const a = {
993
+ function la(t) {
994
+ return async (e, a) => {
995
+ const r = {
964
996
  login_id: k(),
965
- ...r,
997
+ ...a,
966
998
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
967
999
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
968
1000
  };
969
- return await t.insertInto("logins").values({ ...z(a), tenant_id: e }).execute(), a;
1001
+ return await t.insertInto("logins").values({ ...J(r), tenant_id: e }).execute(), r;
970
1002
  };
971
1003
  }
972
- function cr(t) {
973
- return async (e, r, a) => (await t.updateTable("logins").set(z(a)).where("logins.login_id", "=", r).where("logins.tenant_id", "=", e).execute()).length === 1;
1004
+ function ca(t) {
1005
+ 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;
974
1006
  }
975
- function dr(t) {
976
- return async (e, r) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", r).execute()).length > 0;
1007
+ function da(t) {
1008
+ return async (e, a) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", a).execute()).length > 0;
977
1009
  }
978
- function ur(t) {
1010
+ function ua(t) {
979
1011
  return {
980
- create: lr(t),
981
- get: ir(t),
982
- update: cr(t),
983
- remove: dr(t)
1012
+ create: la(t),
1013
+ get: ia(t),
1014
+ update: ca(t),
1015
+ remove: da(t)
984
1016
  };
985
1017
  }
986
- function mr(t) {
1018
+ function ma(t) {
987
1019
  return async (e) => {
988
- const [r] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1020
+ const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
989
1021
  return f({
990
- identifier_first: !!(r != null && r.identifier_first),
991
- password_first: !!(r != null && r.password_first),
992
- webauthn_platform_first_factor: !!(r != null && r.webauthn_platform_first_factor),
993
- universal_login_experience: (r == null ? void 0 : r.universal_login_experience) || "new"
1022
+ identifier_first: !!(a != null && a.identifier_first),
1023
+ password_first: !!(a != null && a.password_first),
1024
+ webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
1025
+ universal_login_experience: (a == null ? void 0 : a.universal_login_experience) || "new"
994
1026
  });
995
1027
  };
996
1028
  }
@@ -1003,37 +1035,37 @@ function he(t) {
1003
1035
  universal_login_experience: t.universal_login_experience
1004
1036
  });
1005
1037
  }
1006
- function hr(t) {
1007
- return async (e, r) => {
1038
+ function ha(t) {
1039
+ return async (e, a) => {
1008
1040
  try {
1009
- const a = Ke.parse(r);
1041
+ const r = Ke.parse(a);
1010
1042
  await t.insertInto("prompt_settings").values({
1011
- ...he(a),
1043
+ ...he(r),
1012
1044
  tenant_id: e
1013
1045
  }).execute();
1014
1046
  } catch {
1015
- await t.updateTable("prompt_settings").set(he(r)).where("tenant_id", "=", e).execute();
1047
+ await t.updateTable("prompt_settings").set(he(a)).where("tenant_id", "=", e).execute();
1016
1048
  }
1017
1049
  };
1018
1050
  }
1019
- function fr(t) {
1051
+ function fa(t) {
1020
1052
  return {
1021
- get: mr(t),
1022
- set: hr(t)
1053
+ get: ma(t),
1054
+ set: ha(t)
1023
1055
  };
1024
1056
  }
1025
- function _r(t) {
1057
+ function _a(t) {
1026
1058
  return async (e) => {
1027
- const [r] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1028
- if (!r)
1059
+ const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1060
+ if (!a)
1029
1061
  return null;
1030
1062
  const {
1031
- tenant_id: a,
1063
+ tenant_id: r,
1032
1064
  credentials: o,
1033
1065
  settings: n,
1034
1066
  enabled: s,
1035
1067
  ...l
1036
- } = r;
1068
+ } = a;
1037
1069
  return f({
1038
1070
  ...l,
1039
1071
  credentials: JSON.parse(o),
@@ -1042,24 +1074,24 @@ function _r(t) {
1042
1074
  });
1043
1075
  };
1044
1076
  }
1045
- function pr(t) {
1046
- return async (e, r) => {
1047
- const { credentials: a, settings: o, enabled: n, ...s } = r;
1077
+ function pa(t) {
1078
+ return async (e, a) => {
1079
+ const { credentials: r, settings: o, enabled: n, ...s } = a;
1048
1080
  await t.updateTable("email_providers").set({
1049
1081
  ...s,
1050
- credentials: a ? JSON.stringify(a) : void 0,
1082
+ credentials: r ? JSON.stringify(r) : void 0,
1051
1083
  settings: o ? JSON.stringify(o) : void 0,
1052
1084
  enabled: n !== void 0 ? n ? 1 : 0 : void 0
1053
1085
  }).where("tenant_id", "=", e).execute();
1054
1086
  };
1055
1087
  }
1056
- function gr(t) {
1057
- return async (e, r) => {
1058
- const { credentials: a, settings: o, enabled: n, ...s } = r;
1088
+ function ga(t) {
1089
+ return async (e, a) => {
1090
+ const { credentials: r, settings: o, enabled: n, ...s } = a;
1059
1091
  await t.insertInto("email_providers").values({
1060
1092
  ...s,
1061
1093
  enabled: n ? 1 : 0,
1062
- credentials: JSON.stringify(a),
1094
+ credentials: JSON.stringify(r),
1063
1095
  settings: JSON.stringify(o),
1064
1096
  tenant_id: e,
1065
1097
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1067,74 +1099,73 @@ function gr(t) {
1067
1099
  }).execute();
1068
1100
  };
1069
1101
  }
1070
- function wr(t) {
1102
+ function wa(t) {
1071
1103
  return {
1072
- get: _r(t),
1073
- create: gr(t),
1074
- update: pr(t)
1104
+ get: _a(t),
1105
+ create: ga(t),
1106
+ update: pa(t)
1075
1107
  };
1076
1108
  }
1077
- function yr(t) {
1078
- return async (e, r) => await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.token", "=", r).where("refresh_tokens.revoked_at", "is", null).selectAll().executeTakeFirst() ?? null;
1109
+ function ya(t) {
1110
+ return async (e, a) => await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.token", "=", a).where("refresh_tokens.revoked_at", "is", null).selectAll().executeTakeFirst() ?? null;
1079
1111
  }
1080
- function Nr(t) {
1081
- return async (e, r) => {
1082
- const a = {
1083
- ...r,
1084
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
1085
- expires_at: (/* @__PURE__ */ new Date()).toISOString()
1112
+ function Na(t) {
1113
+ return async (e, a) => {
1114
+ const r = {
1115
+ ...a,
1116
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
1086
1117
  };
1087
- return await t.insertInto("refresh_tokens").values({ ...a, tenant_id: e }).execute(), { ...r, ...a };
1118
+ return await t.insertInto("refresh_tokens").values({ ...r, tenant_id: e }).execute(), { ...a, ...r };
1088
1119
  };
1089
1120
  }
1090
- function vr(t) {
1091
- return async (e, r) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.token", "=", r).execute()).length;
1121
+ function va(t) {
1122
+ return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1092
1123
  }
1093
- function br(t) {
1094
- return async (e, r, a) => !!(await t.updateTable("refresh_tokens").set(a).where("tenant_id", "=", e).where("refresh_tokens.token", "=", r).execute()).length;
1124
+ function Ca(t) {
1125
+ return async (e, a, r) => !!(await t.updateTable("refresh_tokens").set(r).where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1095
1126
  }
1096
- function Cr(t) {
1097
- return async (e, r = {
1127
+ function ba(t) {
1128
+ return async (e, a = {
1098
1129
  page: 0,
1099
1130
  per_page: 50,
1100
1131
  include_totals: !1
1101
1132
  }) => {
1102
- let a = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1103
- r.q && (a = T(t, a, r.q, ["token", "session_id"]));
1104
- let o = a;
1105
- if (r.sort && r.sort.sort_by) {
1133
+ let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1134
+ a.q && (r = T(t, r, a.q, ["token", "session_id"]));
1135
+ let o = r;
1136
+ if (a.sort && a.sort.sort_by) {
1106
1137
  const { ref: d } = t.dynamic;
1107
1138
  o = o.orderBy(
1108
- d(r.sort.sort_by),
1109
- r.sort.sort_order
1139
+ d(a.sort.sort_by),
1140
+ a.sort.sort_order
1110
1141
  );
1111
1142
  }
1112
- o = o.offset(r.page * r.per_page).limit(r.per_page);
1113
- const n = await o.selectAll().execute(), { count: s } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = C(s);
1143
+ o = o.offset(a.page * a.per_page).limit(a.per_page);
1144
+ const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
1114
1145
  return {
1115
1146
  refresh_tokens: n,
1116
- start: r.page * r.per_page,
1117
- limit: r.per_page,
1147
+ start: a.page * a.per_page,
1148
+ limit: a.per_page,
1118
1149
  length: l
1119
1150
  };
1120
1151
  };
1121
1152
  }
1122
- function xr(t) {
1153
+ function xa(t) {
1123
1154
  return {
1124
- create: Nr(t),
1125
- get: yr(t),
1126
- list: Cr(t),
1127
- remove: vr(t),
1128
- update: br(t)
1155
+ create: Na(t),
1156
+ get: ya(t),
1157
+ list: ba(t),
1158
+ remove: va(t),
1159
+ update: Ca(t)
1129
1160
  };
1130
1161
  }
1131
- function Tr(t) {
1162
+ function Ta(t) {
1132
1163
  return t[t.length - 1];
1133
1164
  }
1134
1165
  function p(t) {
1135
1166
  return Object.freeze(t);
1136
1167
  }
1137
- const J = p({
1168
+ const z = p({
1138
1169
  is(t) {
1139
1170
  return t.kind === "IdentifierNode";
1140
1171
  },
@@ -1151,17 +1182,17 @@ const J = p({
1151
1182
  create(t) {
1152
1183
  return p({
1153
1184
  kind: "SchemableIdentifierNode",
1154
- identifier: J.create(t)
1185
+ identifier: z.create(t)
1155
1186
  });
1156
1187
  },
1157
1188
  createWithSchema(t, e) {
1158
1189
  return p({
1159
1190
  kind: "SchemableIdentifierNode",
1160
- schema: J.create(t),
1161
- identifier: J.create(e)
1191
+ schema: z.create(t),
1192
+ identifier: z.create(e)
1162
1193
  });
1163
1194
  }
1164
- }), Sr = p({
1195
+ }), Sa = p({
1165
1196
  is(t) {
1166
1197
  return t.kind === "AliasNode";
1167
1198
  },
@@ -1190,7 +1221,7 @@ const J = p({
1190
1221
  }
1191
1222
  });
1192
1223
  var R;
1193
- class Or {
1224
+ class Oa {
1194
1225
  constructor() {
1195
1226
  j(this, "nodeStack", []);
1196
1227
  w(this, R, p({
@@ -1293,14 +1324,14 @@ class Or {
1293
1324
  if (!e)
1294
1325
  return e;
1295
1326
  this.nodeStack.push(e);
1296
- const r = this.transformNodeImpl(e);
1297
- return this.nodeStack.pop(), p(r);
1327
+ const a = this.transformNodeImpl(e);
1328
+ return this.nodeStack.pop(), p(a);
1298
1329
  }
1299
1330
  transformNodeImpl(e) {
1300
1331
  return c(this, R)[e.kind](e);
1301
1332
  }
1302
1333
  transformNodeList(e) {
1303
- return e && p(e.map((r) => this.transformNode(r)));
1334
+ return e && p(e.map((a) => this.transformNode(a)));
1304
1335
  }
1305
1336
  transformSelectQuery(e) {
1306
1337
  return {
@@ -2024,7 +2055,7 @@ class Or {
2024
2055
  }
2025
2056
  }
2026
2057
  R = new WeakMap();
2027
- const kr = p({
2058
+ const ka = p({
2028
2059
  AlterTableNode: !0,
2029
2060
  CreateIndexNode: !0,
2030
2061
  CreateSchemaNode: !0,
@@ -2044,77 +2075,77 @@ const kr = p({
2044
2075
  MergeQueryNode: !0
2045
2076
  });
2046
2077
  var P, S, O, _, ge, we, ye, $, q, Ne;
2047
- class $r extends Or {
2048
- constructor(r) {
2078
+ class $a extends Oa {
2079
+ constructor(a) {
2049
2080
  super();
2050
2081
  w(this, _);
2051
2082
  w(this, P);
2052
2083
  w(this, S, /* @__PURE__ */ new Set());
2053
2084
  w(this, O, /* @__PURE__ */ new Set());
2054
- M(this, P, r);
2085
+ M(this, P, a);
2055
2086
  }
2056
- transformNodeImpl(r) {
2057
- if (!u(this, _, ge).call(this, r))
2058
- return super.transformNodeImpl(r);
2059
- const a = u(this, _, ye).call(this, r);
2060
- for (const s of a)
2087
+ transformNodeImpl(a) {
2088
+ if (!u(this, _, ge).call(this, a))
2089
+ return super.transformNodeImpl(a);
2090
+ const r = u(this, _, ye).call(this, a);
2091
+ for (const s of r)
2061
2092
  c(this, O).add(s);
2062
- const o = u(this, _, we).call(this, r);
2093
+ const o = u(this, _, we).call(this, a);
2063
2094
  for (const s of o)
2064
2095
  c(this, S).add(s);
2065
- const n = super.transformNodeImpl(r);
2096
+ const n = super.transformNodeImpl(a);
2066
2097
  for (const s of o)
2067
2098
  c(this, S).delete(s);
2068
- for (const s of a)
2099
+ for (const s of r)
2069
2100
  c(this, O).delete(s);
2070
2101
  return n;
2071
2102
  }
2072
- transformSchemableIdentifier(r) {
2073
- const a = super.transformSchemableIdentifier(r);
2074
- return a.schema || !c(this, S).has(r.identifier.name) ? a : {
2075
- ...a,
2076
- schema: J.create(c(this, P))
2103
+ transformSchemableIdentifier(a) {
2104
+ const r = super.transformSchemableIdentifier(a);
2105
+ return r.schema || !c(this, S).has(a.identifier.name) ? r : {
2106
+ ...r,
2107
+ schema: z.create(c(this, P))
2077
2108
  };
2078
2109
  }
2079
- transformReferences(r) {
2080
- const a = super.transformReferences(r);
2081
- return a.table.table.schema ? a : {
2082
- ...a,
2083
- table: K.createWithSchema(c(this, P), a.table.table.identifier.name)
2084
- };
2085
- }
2086
- }
2087
- P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(r) {
2088
- return r.kind in kr;
2089
- }, we = function(r) {
2090
- const a = /* @__PURE__ */ new Set();
2091
- if ("name" in r && r.name && W.is(r.name) && u(this, _, q).call(this, r.name, a), "from" in r && r.from)
2092
- for (const o of r.from.froms)
2093
- u(this, _, $).call(this, o, a);
2094
- if ("into" in r && r.into && u(this, _, $).call(this, r.into, a), "table" in r && r.table && u(this, _, $).call(this, r.table, a), "joins" in r && r.joins)
2095
- for (const o of r.joins)
2096
- u(this, _, $).call(this, o.table, a);
2097
- return "using" in r && r.using && u(this, _, $).call(this, r.using, a), a;
2098
- }, ye = function(r) {
2099
- const a = /* @__PURE__ */ new Set();
2100
- return "with" in r && r.with && u(this, _, Ne).call(this, r.with, a), a;
2101
- }, $ = function(r, a) {
2102
- const o = K.is(r) ? r : Sr.is(r) && K.is(r.node) ? r.node : null;
2103
- o && u(this, _, q).call(this, o.table, a);
2104
- }, q = function(r, a) {
2105
- const o = r.identifier.name;
2106
- !c(this, S).has(o) && !c(this, O).has(o) && a.add(o);
2107
- }, Ne = function(r, a) {
2108
- for (const o of r.expressions) {
2110
+ transformReferences(a) {
2111
+ const r = super.transformReferences(a);
2112
+ return r.table.table.schema ? r : {
2113
+ ...r,
2114
+ table: K.createWithSchema(c(this, P), r.table.table.identifier.name)
2115
+ };
2116
+ }
2117
+ }
2118
+ P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(a) {
2119
+ return a.kind in ka;
2120
+ }, we = function(a) {
2121
+ const r = /* @__PURE__ */ new Set();
2122
+ if ("name" in a && a.name && W.is(a.name) && u(this, _, q).call(this, a.name, r), "from" in a && a.from)
2123
+ for (const o of a.from.froms)
2124
+ u(this, _, $).call(this, o, r);
2125
+ if ("into" in a && a.into && u(this, _, $).call(this, a.into, r), "table" in a && a.table && u(this, _, $).call(this, a.table, r), "joins" in a && a.joins)
2126
+ for (const o of a.joins)
2127
+ u(this, _, $).call(this, o.table, r);
2128
+ return "using" in a && a.using && u(this, _, $).call(this, a.using, r), r;
2129
+ }, ye = function(a) {
2130
+ const r = /* @__PURE__ */ new Set();
2131
+ return "with" in a && a.with && u(this, _, Ne).call(this, a.with, r), r;
2132
+ }, $ = function(a, r) {
2133
+ const o = K.is(a) ? a : Sa.is(a) && K.is(a.node) ? a.node : null;
2134
+ o && u(this, _, q).call(this, o.table, r);
2135
+ }, q = function(a, r) {
2136
+ const o = a.identifier.name;
2137
+ !c(this, S).has(o) && !c(this, O).has(o) && r.add(o);
2138
+ }, Ne = function(a, r) {
2139
+ for (const o of a.expressions) {
2109
2140
  const n = o.name.table.table.identifier.name;
2110
- c(this, O).has(n) || a.add(n);
2141
+ c(this, O).has(n) || r.add(n);
2111
2142
  }
2112
2143
  };
2113
2144
  var L;
2114
- class Ir {
2145
+ class Ia {
2115
2146
  constructor(e) {
2116
2147
  w(this, L);
2117
- M(this, L, new $r(e));
2148
+ M(this, L, new $a(e));
2118
2149
  }
2119
2150
  transformQuery(e) {
2120
2151
  return c(this, L).transformNode(e.node);
@@ -2124,7 +2155,7 @@ class Ir {
2124
2155
  }
2125
2156
  }
2126
2157
  L = new WeakMap();
2127
- class Dr {
2158
+ class Da {
2128
2159
  transformQuery(e) {
2129
2160
  return e.node;
2130
2161
  }
@@ -2132,8 +2163,8 @@ class Dr {
2132
2163
  return e.result;
2133
2164
  }
2134
2165
  }
2135
- const Pr = "kysely_migration", fe = "kysely_migration_lock", jr = !1, B = "migration_lock", Mr = p({ __noMigrations__: !0 });
2136
- var h, i, A, N, v, I, be, b, Ce, xe, Te, Se, Oe, G, D, H, ke, $e, Ie, X, De, Pe, je, Me, Ae, F;
2166
+ const Pa = "kysely_migration", fe = "kysely_migration_lock", ja = !1, B = "migration_lock", Ma = p({ __noMigrations__: !0 });
2167
+ var h, i, A, N, v, I, Ce, C, be, xe, Te, Se, Oe, G, D, H, ke, $e, Ie, X, De, Pe, je, Me, Ae, F;
2137
2168
  class ve {
2138
2169
  constructor(e) {
2139
2170
  w(this, i);
@@ -2146,11 +2177,11 @@ class ve {
2146
2177
  * The returned array is sorted by migration name.
2147
2178
  */
2148
2179
  async getMigrations() {
2149
- const e = await u(this, i, D).call(this, c(this, i, v)) ? await c(this, h).db.withPlugin(c(this, i, b)).selectFrom(c(this, i, v)).select(["name", "timestamp"]).execute() : [];
2150
- return (await u(this, i, X).call(this)).map(({ name: a, ...o }) => {
2151
- const n = e.find((s) => s.name === a);
2180
+ const e = await u(this, i, D).call(this, c(this, i, v)) ? await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, v)).select(["name", "timestamp"]).execute() : [];
2181
+ return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2182
+ const n = e.find((s) => s.name === r);
2152
2183
  return {
2153
- name: a,
2184
+ name: r,
2154
2185
  migration: o,
2155
2186
  executedAt: n ? new Date(n.timestamp) : void 0
2156
2187
  };
@@ -2230,16 +2261,16 @@ class ve {
2230
2261
  * ```
2231
2262
  */
2232
2263
  async migrateTo(e) {
2233
- return u(this, i, A).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: o }) => {
2234
- if (e === Mr)
2264
+ return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2265
+ if (e === Ma)
2235
2266
  return { direction: "Down", step: 1 / 0 };
2236
- if (!r.find((l) => l.name === e))
2267
+ if (!a.find((l) => l.name === e))
2237
2268
  throw new Error(`migration "${e}" doesn't exist`);
2238
- const n = a.indexOf(e), s = o.findIndex((l) => l.name === e);
2269
+ const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2239
2270
  if (n !== -1)
2240
2271
  return {
2241
2272
  direction: "Down",
2242
- step: a.length - n - 1
2273
+ step: r.length - n - 1
2243
2274
  };
2244
2275
  if (s !== -1)
2245
2276
  return { direction: "Up", step: s + 1 };
@@ -2283,21 +2314,21 @@ class ve {
2283
2314
  }
2284
2315
  h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2285
2316
  try {
2286
- return await u(this, i, Ce).call(this), await u(this, i, ke).call(this, e);
2287
- } catch (r) {
2288
- return r instanceof Q ? r.resultSet : { error: r };
2317
+ return await u(this, i, be).call(this), await u(this, i, ke).call(this, e);
2318
+ } catch (a) {
2319
+ return a instanceof Q ? a.resultSet : { error: a };
2289
2320
  }
2290
2321
  }, N = function() {
2291
2322
  return c(this, h).migrationTableSchema;
2292
2323
  }, v = function() {
2293
- return c(this, h).migrationTableName ?? Pr;
2324
+ return c(this, h).migrationTableName ?? Pa;
2294
2325
  }, I = function() {
2295
2326
  return c(this, h).migrationLockTableName ?? fe;
2296
- }, be = function() {
2297
- return c(this, h).allowUnorderedMigrations ?? jr;
2298
- }, b = function() {
2299
- return c(this, i, N) ? new Ir(c(this, i, N)) : new Dr();
2300
- }, Ce = async function() {
2327
+ }, Ce = function() {
2328
+ return c(this, h).allowUnorderedMigrations ?? ja;
2329
+ }, C = function() {
2330
+ return c(this, i, N) ? new Ia(c(this, i, N)) : new Da();
2331
+ }, be = async function() {
2301
2332
  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);
2302
2333
  }, xe = async function() {
2303
2334
  if (c(this, i, N) && !await u(this, i, G).call(this))
@@ -2310,7 +2341,7 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2310
2341
  }, Te = async function() {
2311
2342
  if (!await u(this, i, D).call(this, c(this, i, v)))
2312
2343
  try {
2313
- c(this, i, N) && await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N))), await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, b)).createTable(c(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2344
+ c(this, i, N) && await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N))), await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2314
2345
  } catch (e) {
2315
2346
  if (!await u(this, i, D).call(this, c(this, i, v)))
2316
2347
  throw e;
@@ -2318,7 +2349,7 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2318
2349
  }, Se = async function() {
2319
2350
  if (!await u(this, i, D).call(this, c(this, i, I)))
2320
2351
  try {
2321
- await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, b)).createTable(c(this, i, I)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2352
+ await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, I)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2322
2353
  } catch (e) {
2323
2354
  if (!await u(this, i, D).call(this, c(this, i, I)))
2324
2355
  throw e;
@@ -2326,68 +2357,68 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2326
2357
  }, Oe = async function() {
2327
2358
  if (!await u(this, i, H).call(this))
2328
2359
  try {
2329
- await c(this, h).db.withPlugin(c(this, i, b)).insertInto(c(this, i, I)).values({ id: B, is_locked: 0 }).execute();
2360
+ await c(this, h).db.withPlugin(c(this, i, C)).insertInto(c(this, i, I)).values({ id: B, is_locked: 0 }).execute();
2330
2361
  } catch (e) {
2331
2362
  if (!await u(this, i, H).call(this))
2332
2363
  throw e;
2333
2364
  }
2334
2365
  }, G = async function() {
2335
- return (await c(this, h).db.introspection.getSchemas()).some((r) => r.name === c(this, i, N));
2366
+ return (await c(this, h).db.introspection.getSchemas()).some((a) => a.name === c(this, i, N));
2336
2367
  }, D = async function(e) {
2337
- const r = c(this, i, N);
2368
+ const a = c(this, i, N);
2338
2369
  return (await c(this, h).db.introspection.getTables({
2339
2370
  withInternalKyselyTables: !0
2340
- })).some((o) => o.name === e && (!r || o.schema === r));
2371
+ })).some((o) => o.name === e && (!a || o.schema === a));
2341
2372
  }, H = async function() {
2342
- return !!await c(this, h).db.withPlugin(c(this, i, b)).selectFrom(c(this, i, I)).where("id", "=", B).select("id").executeTakeFirst();
2373
+ return !!await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, I)).where("id", "=", B).select("id").executeTakeFirst();
2343
2374
  }, ke = async function(e) {
2344
- const r = c(this, h).db.getExecutor().adapter, a = p({
2375
+ const a = c(this, h).db.getExecutor().adapter, r = p({
2345
2376
  lockTable: c(this, h).migrationLockTableName ?? fe,
2346
2377
  lockRowId: B,
2347
2378
  lockTableSchema: c(this, h).migrationTableSchema
2348
2379
  }), o = async (n) => {
2349
2380
  try {
2350
- await r.acquireMigrationLock(n, a);
2381
+ await a.acquireMigrationLock(n, r);
2351
2382
  const s = await u(this, i, $e).call(this, n);
2352
2383
  if (s.migrations.length === 0)
2353
2384
  return { results: [] };
2354
2385
  const { direction: l, step: d } = e(s);
2355
2386
  return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, d) : l === "Up" ? await u(this, i, Ae).call(this, n, s, d) : { results: [] };
2356
2387
  } finally {
2357
- await r.releaseMigrationLock(n, a);
2388
+ await a.releaseMigrationLock(n, r);
2358
2389
  }
2359
2390
  };
2360
- return r.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2391
+ return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2361
2392
  }, $e = async function(e) {
2362
- const r = await u(this, i, X).call(this), a = await u(this, i, De).call(this, e);
2363
- u(this, i, Pe).call(this, r, a), c(this, i, be) || u(this, i, je).call(this, r, a);
2364
- const o = u(this, i, Ie).call(this, r, a);
2393
+ const a = await u(this, i, X).call(this), r = await u(this, i, De).call(this, e);
2394
+ u(this, i, Pe).call(this, a, r), c(this, i, Ce) || u(this, i, je).call(this, a, r);
2395
+ const o = u(this, i, Ie).call(this, a, r);
2365
2396
  return p({
2366
- migrations: r,
2367
- executedMigrations: a,
2368
- lastMigration: Tr(a),
2397
+ migrations: a,
2398
+ executedMigrations: r,
2399
+ lastMigration: Ta(r),
2369
2400
  pendingMigrations: o
2370
2401
  });
2371
- }, Ie = function(e, r) {
2372
- return e.filter((a) => !r.includes(a.name));
2402
+ }, Ie = function(e, a) {
2403
+ return e.filter((r) => !a.includes(r.name));
2373
2404
  }, X = async function() {
2374
2405
  const e = await c(this, h).provider.getMigrations();
2375
- return Object.keys(e).sort().map((r) => ({
2376
- ...e[r],
2377
- name: r
2406
+ return Object.keys(e).sort().map((a) => ({
2407
+ ...e[a],
2408
+ name: a
2378
2409
  }));
2379
2410
  }, De = async function(e) {
2380
- return (await e.withPlugin(c(this, i, b)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
2381
- }, Pe = function(e, r) {
2382
- for (const a of r)
2383
- if (!e.some((o) => o.name === a))
2384
- throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
2385
- }, je = function(e, r) {
2386
- for (let a = 0; a < r.length; ++a)
2387
- if (e[a].name !== r[a])
2388
- throw new Error(`corrupted migrations: expected previously executed migration ${r[a]} to be at index ${a} but ${e[a].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2389
- }, Me = async function(e, r, a) {
2390
- const o = r.executedMigrations.slice().reverse().slice(0, a).map((s) => r.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2411
+ return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2412
+ }, Pe = function(e, a) {
2413
+ for (const r of a)
2414
+ if (!e.some((o) => o.name === r))
2415
+ throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2416
+ }, je = function(e, a) {
2417
+ for (let r = 0; r < a.length; ++r)
2418
+ if (e[r].name !== a[r])
2419
+ 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.`);
2420
+ }, Me = async function(e, a, r) {
2421
+ const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2391
2422
  migrationName: s.name,
2392
2423
  direction: "Down",
2393
2424
  status: "NotExecuted"
@@ -2395,7 +2426,7 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2395
2426
  for (let s = 0; s < n.length; ++s) {
2396
2427
  const l = o[s];
2397
2428
  try {
2398
- l.down && (await l.down(e), await e.withPlugin(c(this, i, b)).deleteFrom(c(this, i, v)).where("name", "=", l.name).execute(), n[s] = {
2429
+ l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, v)).where("name", "=", l.name).execute(), n[s] = {
2399
2430
  migrationName: l.name,
2400
2431
  direction: "Down",
2401
2432
  status: "Success"
@@ -2412,16 +2443,16 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2412
2443
  }
2413
2444
  }
2414
2445
  return { results: n };
2415
- }, Ae = async function(e, r, a) {
2416
- const n = r.pendingMigrations.slice(0, a).map((s) => ({
2446
+ }, Ae = async function(e, a, r) {
2447
+ const n = a.pendingMigrations.slice(0, r).map((s) => ({
2417
2448
  migrationName: s.name,
2418
2449
  direction: "Up",
2419
2450
  status: "NotExecuted"
2420
2451
  }));
2421
2452
  for (let s = 0; s < n.length; s++) {
2422
- const l = r.pendingMigrations[s];
2453
+ const l = a.pendingMigrations[s];
2423
2454
  try {
2424
- await l.up(e), await e.withPlugin(c(this, i, b)).insertInto(c(this, i, v)).values({
2455
+ await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, v)).values({
2425
2456
  name: l.name,
2426
2457
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2427
2458
  }).execute(), n[s] = {
@@ -2446,10 +2477,10 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2446
2477
  };
2447
2478
  var E;
2448
2479
  class Q extends Error {
2449
- constructor(r) {
2480
+ constructor(a) {
2450
2481
  super();
2451
2482
  w(this, E);
2452
- M(this, E, r);
2483
+ M(this, E, a);
2453
2484
  }
2454
2485
  get resultSet() {
2455
2486
  return c(this, E);
@@ -2465,7 +2496,7 @@ class Fe {
2465
2496
  return this.migrations;
2466
2497
  }
2467
2498
  }
2468
- async function Ar(t) {
2499
+ async function Aa(t) {
2469
2500
  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(
2470
2501
  "tenant_id",
2471
2502
  "varchar(255)",
@@ -2533,35 +2564,35 @@ async function Ar(t) {
2533
2564
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
2534
2565
  ).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();
2535
2566
  }
2536
- async function Fr(t) {
2567
+ async function Fa(t) {
2537
2568
  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();
2538
2569
  }
2539
- const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2570
+ const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2540
2571
  __proto__: null,
2541
- down: Fr,
2542
- up: Ar
2572
+ down: Fa,
2573
+ up: Aa
2543
2574
  }, Symbol.toStringTag, { value: "Module" }));
2544
- async function Er(t) {
2575
+ async function Ea(t) {
2545
2576
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
2546
2577
  }
2547
- async function zr(t) {
2578
+ async function Ja(t) {
2548
2579
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
2549
2580
  }
2550
- const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2581
+ const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2551
2582
  __proto__: null,
2552
- down: zr,
2553
- up: Er
2583
+ down: Ja,
2584
+ up: Ea
2554
2585
  }, Symbol.toStringTag, { value: "Module" }));
2555
- async function Rr(t) {
2586
+ async function Ra(t) {
2556
2587
  }
2557
- async function Ur(t) {
2588
+ async function Ua(t) {
2558
2589
  }
2559
- const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2590
+ const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2560
2591
  __proto__: null,
2561
- down: Ur,
2562
- up: Rr
2592
+ down: Ua,
2593
+ up: Ra
2563
2594
  }, Symbol.toStringTag, { value: "Module" }));
2564
- async function Br(t) {
2595
+ async function Ba(t) {
2565
2596
  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(
2566
2597
  "tenant_id_constraint",
2567
2598
  ["tenant_id"],
@@ -2570,24 +2601,24 @@ async function Br(t) {
2570
2601
  (e) => e.onDelete("cascade")
2571
2602
  ).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();
2572
2603
  }
2573
- async function Qr(t) {
2604
+ async function Qa(t) {
2574
2605
  await t.schema.dropTable("logs").execute();
2575
2606
  }
2576
- const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2607
+ const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2577
2608
  __proto__: null,
2578
- down: Qr,
2579
- up: Br
2609
+ down: Qa,
2610
+ up: Ba
2580
2611
  }, Symbol.toStringTag, { value: "Module" }));
2581
- async function Wr(t) {
2612
+ async function Wa(t) {
2582
2613
  }
2583
- async function qr(t) {
2614
+ async function qa(t) {
2584
2615
  }
2585
- const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2616
+ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2586
2617
  __proto__: null,
2587
- down: qr,
2588
- up: Wr
2618
+ down: qa,
2619
+ up: Wa
2589
2620
  }, Symbol.toStringTag, { value: "Module" }));
2590
- async function Hr(t) {
2621
+ async function Ha(t) {
2591
2622
  await t.schema.createTable("sessions").addColumn("session_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
2592
2623
  "client_id",
2593
2624
  "varchar(255)",
@@ -2616,15 +2647,15 @@ async function Hr(t) {
2616
2647
  (e) => e.references("applications.id").onDelete("cascade").notNull()
2617
2648
  ).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();
2618
2649
  }
2619
- async function Xr(t) {
2650
+ async function Xa(t) {
2620
2651
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
2621
2652
  }
2622
- const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2653
+ const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2623
2654
  __proto__: null,
2624
- down: Xr,
2625
- up: Hr
2655
+ down: Xa,
2656
+ up: Ha
2626
2657
  }, Symbol.toStringTag, { value: "Module" }));
2627
- async function Zr(t) {
2658
+ async function Za(t) {
2628
2659
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
2629
2660
  "user_id_constraint",
2630
2661
  ["user_id", "tenant_id"],
@@ -2639,24 +2670,24 @@ async function Zr(t) {
2639
2670
  (e) => e.onDelete("cascade")
2640
2671
  ).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();
2641
2672
  }
2642
- async function ea(t) {
2673
+ async function er(t) {
2643
2674
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
2644
2675
  }
2645
- const ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2676
+ const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2646
2677
  __proto__: null,
2647
- down: ea,
2648
- up: Zr
2678
+ down: er,
2679
+ up: Za
2649
2680
  }, Symbol.toStringTag, { value: "Module" }));
2650
- async function ra(t) {
2681
+ async function ar(t) {
2651
2682
  }
2652
- async function aa(t) {
2683
+ async function rr(t) {
2653
2684
  }
2654
- const na = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2685
+ const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2655
2686
  __proto__: null,
2656
- down: aa,
2657
- up: ra
2687
+ down: rr,
2688
+ up: ar
2658
2689
  }, Symbol.toStringTag, { value: "Module" }));
2659
- async function oa(t) {
2690
+ async function or(t) {
2660
2691
  await t.schema.alterTable("passwords").addColumn(
2661
2692
  "password",
2662
2693
  "varchar(255)",
@@ -2664,172 +2695,172 @@ async function oa(t) {
2664
2695
  (e) => e.notNull()
2665
2696
  ).execute();
2666
2697
  }
2667
- async function sa(t) {
2698
+ async function sr(t) {
2668
2699
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2669
2700
  }
2670
- const ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2701
+ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2671
2702
  __proto__: null,
2672
- down: sa,
2673
- up: oa
2703
+ down: sr,
2704
+ up: or
2674
2705
  }, Symbol.toStringTag, { value: "Module" }));
2675
- async function la(t) {
2706
+ async function lr(t) {
2676
2707
  }
2677
- async function ca(t) {
2708
+ async function cr(t) {
2678
2709
  }
2679
- const da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2710
+ const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2680
2711
  __proto__: null,
2681
- down: ca,
2682
- up: la
2712
+ down: cr,
2713
+ up: lr
2683
2714
  }, Symbol.toStringTag, { value: "Module" }));
2684
- async function ua(t) {
2715
+ async function ur(t) {
2685
2716
  }
2686
- async function ma(t) {
2717
+ async function mr(t) {
2687
2718
  }
2688
- const ha = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2719
+ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2689
2720
  __proto__: null,
2690
- down: ma,
2691
- up: ua
2721
+ down: mr,
2722
+ up: ur
2692
2723
  }, Symbol.toStringTag, { value: "Module" }));
2693
- async function fa(t) {
2724
+ async function fr(t) {
2694
2725
  }
2695
- async function _a(t) {
2726
+ async function _r(t) {
2696
2727
  }
2697
- const pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2728
+ const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2698
2729
  __proto__: null,
2699
- down: _a,
2700
- up: fa
2730
+ down: _r,
2731
+ up: fr
2701
2732
  }, Symbol.toStringTag, { value: "Module" }));
2702
- async function ga(t) {
2733
+ async function gr(t) {
2703
2734
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
2704
2735
  }
2705
- async function wa(t) {
2736
+ async function wr(t) {
2706
2737
  await t.schema.dropIndex("users_email_index").execute();
2707
2738
  }
2708
- const ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2739
+ const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2709
2740
  __proto__: null,
2710
- down: wa,
2711
- up: ga
2741
+ down: wr,
2742
+ up: gr
2712
2743
  }, Symbol.toStringTag, { value: "Module" }));
2713
- async function Na(t) {
2744
+ async function Nr(t) {
2714
2745
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
2715
2746
  }
2716
- async function va(t) {
2747
+ async function vr(t) {
2717
2748
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2718
2749
  }
2719
- const ba = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2750
+ const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2720
2751
  __proto__: null,
2721
- down: va,
2722
- up: Na
2752
+ down: vr,
2753
+ up: Nr
2723
2754
  }, Symbol.toStringTag, { value: "Module" }));
2724
- async function Ca(t) {
2755
+ async function br(t) {
2725
2756
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
2726
2757
  }
2727
- async function xa(t) {
2758
+ async function xr(t) {
2728
2759
  await t.schema.dropIndex("users_linked_to_index");
2729
2760
  }
2730
- const Ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2761
+ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2731
2762
  __proto__: null,
2732
- down: xa,
2733
- up: Ca
2763
+ down: xr,
2764
+ up: br
2734
2765
  }, Symbol.toStringTag, { value: "Module" }));
2735
- async function Sa(t) {
2766
+ async function Sr(t) {
2736
2767
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
2737
2768
  }
2738
- async function Oa(t) {
2769
+ async function Or(t) {
2739
2770
  await t.schema.alterTable("users").dropColumn("locale").execute();
2740
2771
  }
2741
- const ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2772
+ const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2742
2773
  __proto__: null,
2743
- down: Oa,
2744
- up: Sa
2774
+ down: Or,
2775
+ up: Sr
2745
2776
  }, Symbol.toStringTag, { value: "Module" }));
2746
- async function $a(t) {
2777
+ async function $r(t) {
2747
2778
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2748
2779
  "tenant_id",
2749
2780
  "varchar(255)",
2750
2781
  (e) => e.references("tenants.id").onDelete("cascade")
2751
2782
  ).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();
2752
2783
  }
2753
- async function Ia(t) {
2784
+ async function Ir(t) {
2754
2785
  await t.schema.dropTable("keys").execute();
2755
2786
  }
2756
- const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2787
+ const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2757
2788
  __proto__: null,
2758
- down: Ia,
2759
- up: $a
2789
+ down: Ir,
2790
+ up: $r
2760
2791
  }, Symbol.toStringTag, { value: "Module" }));
2761
- async function Pa(t) {
2792
+ async function Pr(t) {
2762
2793
  }
2763
- async function ja(t) {
2794
+ async function jr(t) {
2764
2795
  }
2765
- const Ma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2796
+ const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2766
2797
  __proto__: null,
2767
- down: ja,
2768
- up: Pa
2798
+ down: jr,
2799
+ up: Pr
2769
2800
  }, Symbol.toStringTag, { value: "Module" }));
2770
- async function Aa(t) {
2801
+ async function Ar(t) {
2771
2802
  }
2772
- async function Fa(t) {
2803
+ async function Fr(t) {
2773
2804
  }
2774
- const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2805
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2775
2806
  __proto__: null,
2776
- down: Fa,
2777
- up: Aa
2807
+ down: Fr,
2808
+ up: Ar
2778
2809
  }, Symbol.toStringTag, { value: "Module" }));
2779
- async function Ea(t) {
2810
+ async function Er(t) {
2780
2811
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
2781
2812
  }
2782
- async function za(t) {
2813
+ async function Jr(t) {
2783
2814
  await t.schema.alterTable("otps").dropColumn("audience").execute();
2784
2815
  }
2785
- const Ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2816
+ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2786
2817
  __proto__: null,
2787
- down: za,
2788
- up: Ea
2818
+ down: Jr,
2819
+ up: Er
2789
2820
  }, Symbol.toStringTag, { value: "Module" }));
2790
- async function Ra(t) {
2821
+ async function Rr(t) {
2791
2822
  }
2792
- async function Ua(t) {
2823
+ async function Ur(t) {
2793
2824
  }
2794
- const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2825
+ const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2795
2826
  __proto__: null,
2796
- down: Ua,
2797
- up: Ra
2827
+ down: Ur,
2828
+ up: Rr
2798
2829
  }, Symbol.toStringTag, { value: "Module" }));
2799
- async function Ba(t) {
2830
+ async function Br(t) {
2800
2831
  await t.schema.alterTable("logs").dropColumn("category").execute();
2801
2832
  }
2802
- async function Qa(t) {
2833
+ async function Qr(t) {
2803
2834
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
2804
2835
  }
2805
- const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2836
+ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2806
2837
  __proto__: null,
2807
- down: Qa,
2808
- up: Ba
2838
+ down: Qr,
2839
+ up: Br
2809
2840
  }, Symbol.toStringTag, { value: "Module" }));
2810
- async function Wa(t) {
2841
+ async function Wr(t) {
2811
2842
  await t.schema.alterTable("users").dropColumn("tags").execute();
2812
2843
  }
2813
- async function qa(t) {
2844
+ async function qr(t) {
2814
2845
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
2815
2846
  }
2816
- const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2847
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2817
2848
  __proto__: null,
2818
- down: qa,
2819
- up: Wa
2849
+ down: qr,
2850
+ up: Wr
2820
2851
  }, Symbol.toStringTag, { value: "Module" }));
2821
- async function Ha(t) {
2852
+ async function Hr(t) {
2822
2853
  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();
2823
2854
  }
2824
- async function Xa(t) {
2855
+ async function Xr(t) {
2825
2856
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
2826
2857
  }
2827
- const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2858
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2828
2859
  __proto__: null,
2829
- down: Xa,
2830
- up: Ha
2860
+ down: Xr,
2861
+ up: Hr
2831
2862
  }, Symbol.toStringTag, { value: "Module" }));
2832
- async function Za(t) {
2863
+ async function Zr(t) {
2833
2864
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
2834
2865
  }
2835
2866
  async function en(t) {
@@ -2838,18 +2869,18 @@ async function en(t) {
2838
2869
  const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2839
2870
  __proto__: null,
2840
2871
  down: en,
2841
- up: Za
2872
+ up: Zr
2842
2873
  }, Symbol.toStringTag, { value: "Module" }));
2843
- async function rn(t) {
2874
+ async function an(t) {
2844
2875
  await t.schema.alterTable("logs").addColumn("user_name", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("auth0_client", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("isMobile", "boolean").execute(), await t.schema.alterTable("logs").addColumn("connection", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("connection_id", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("audience", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("scope", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy_type", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("hostname", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("session_connection", "varchar(255)").execute();
2845
2876
  }
2846
- async function an(t) {
2877
+ async function rn(t) {
2847
2878
  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();
2848
2879
  }
2849
2880
  const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2850
2881
  __proto__: null,
2851
- down: an,
2852
- up: rn
2882
+ down: rn,
2883
+ up: an
2853
2884
  }, Symbol.toStringTag, { value: "Module" }));
2854
2885
  async function on(t) {
2855
2886
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
@@ -2911,11 +2942,11 @@ const Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2911
2942
  }, Symbol.toStringTag, { value: "Module" }));
2912
2943
  async function vn(t) {
2913
2944
  }
2914
- async function bn(t) {
2945
+ async function Cn(t) {
2915
2946
  }
2916
- const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2947
+ const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2917
2948
  __proto__: null,
2918
- down: bn,
2949
+ down: Cn,
2919
2950
  up: vn
2920
2951
  }, Symbol.toStringTag, { value: "Module" }));
2921
2952
  async function xn(t) {
@@ -2973,16 +3004,16 @@ const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2973
3004
  down: Ln,
2974
3005
  up: Fn
2975
3006
  }, Symbol.toStringTag, { value: "Module" }));
2976
- async function zn(t) {
3007
+ async function Jn(t) {
2977
3008
  await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
2978
3009
  }
2979
- async function Jn(t) {
3010
+ async function zn(t) {
2980
3011
  await t.schema.alterTable("otps").dropColumn("ip").execute();
2981
3012
  }
2982
3013
  const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2983
3014
  __proto__: null,
2984
- down: Jn,
2985
- up: zn
3015
+ down: zn,
3016
+ up: Jn
2986
3017
  }, Symbol.toStringTag, { value: "Module" }));
2987
3018
  async function Un(t) {
2988
3019
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
@@ -3036,12 +3067,12 @@ async function eo(t) {
3036
3067
  }
3037
3068
  async function to(t) {
3038
3069
  }
3039
- const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3070
+ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3040
3071
  __proto__: null,
3041
3072
  down: to,
3042
3073
  up: eo
3043
3074
  }, Symbol.toStringTag, { value: "Module" }));
3044
- async function ao(t) {
3075
+ async function ro(t) {
3045
3076
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3046
3077
  "tenant_id",
3047
3078
  "varchar(255)",
@@ -3070,7 +3101,7 @@ async function no(t) {
3070
3101
  const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3071
3102
  __proto__: null,
3072
3103
  down: no,
3073
- up: ao
3104
+ up: ro
3074
3105
  }, Symbol.toStringTag, { value: "Module" }));
3075
3106
  async function so(t) {
3076
3107
  }
@@ -3121,16 +3152,16 @@ const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3121
3152
  down: No,
3122
3153
  up: yo
3123
3154
  }, Symbol.toStringTag, { value: "Module" }));
3124
- async function bo(t) {
3155
+ async function Co(t) {
3125
3156
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3126
3157
  }
3127
- async function Co(t) {
3158
+ async function bo(t) {
3128
3159
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3129
3160
  }
3130
3161
  const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3131
3162
  __proto__: null,
3132
- down: Co,
3133
- up: bo
3163
+ down: bo,
3164
+ up: Co
3134
3165
  }, Symbol.toStringTag, { value: "Module" }));
3135
3166
  async function To(t) {
3136
3167
  }
@@ -3217,19 +3248,19 @@ async function Lo(t) {
3217
3248
  async function Eo(t) {
3218
3249
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
3219
3250
  }
3220
- const zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3251
+ const Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3221
3252
  __proto__: null,
3222
3253
  down: Eo,
3223
3254
  up: Lo
3224
3255
  }, Symbol.toStringTag, { value: "Module" }));
3225
- async function Jo(t) {
3256
+ async function zo(t) {
3226
3257
  }
3227
3258
  async function Ro(t) {
3228
3259
  }
3229
3260
  const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3230
3261
  __proto__: null,
3231
3262
  down: Ro,
3232
- up: Jo
3263
+ up: zo
3233
3264
  }, Symbol.toStringTag, { value: "Module" }));
3234
3265
  async function Ko(t) {
3235
3266
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
@@ -3288,12 +3319,12 @@ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3288
3319
  async function ts(t) {
3289
3320
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3290
3321
  }
3291
- async function rs(t) {
3322
+ async function as(t) {
3292
3323
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3293
3324
  }
3294
- const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3325
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3295
3326
  __proto__: null,
3296
- down: rs,
3327
+ down: as,
3297
3328
  up: ts
3298
3329
  }, Symbol.toStringTag, { value: "Module" }));
3299
3330
  async function ns(t) {
@@ -3376,15 +3407,15 @@ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3376
3407
  down: Ns,
3377
3408
  up: ys
3378
3409
  }, Symbol.toStringTag, { value: "Module" }));
3379
- async function bs(t) {
3380
- }
3381
3410
  async function Cs(t) {
3411
+ }
3412
+ async function bs(t) {
3382
3413
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3383
3414
  }
3384
3415
  const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3385
3416
  __proto__: null,
3386
- down: Cs,
3387
- up: bs
3417
+ down: bs,
3418
+ up: Cs
3388
3419
  }, Symbol.toStringTag, { value: "Module" }));
3389
3420
  async function Ts(t) {
3390
3421
  await t.schema.createTable("refresh_tokens").addColumn(
@@ -3408,31 +3439,42 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3408
3439
  __proto__: null,
3409
3440
  down: Ss,
3410
3441
  up: Ts
3442
+ }, Symbol.toStringTag, { value: "Module" }));
3443
+ async function ks(t) {
3444
+ 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();
3445
+ }
3446
+ async function $s(t) {
3447
+ 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();
3448
+ }
3449
+ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3450
+ __proto__: null,
3451
+ down: $s,
3452
+ up: ks
3411
3453
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3412
- m1_init: Lr,
3413
- m2_magicLink: Jr,
3414
- m3_updateAt: Kr,
3415
- m4_logTable: Vr,
3416
- m5_userProfile: Gr,
3417
- m6_sessions: Yr,
3418
- m7_passwords: ta,
3419
- m8_logsTableNewFields: na,
3420
- m9_passwordTableNewField: ia,
3421
- n01_codesTable: da,
3422
- n11_universalLoginSession: ha,
3423
- n12_userFields: pa,
3424
- n13_userEmailIndex: ya,
3425
- n14_profileDataField: ba,
3426
- n15_userEmailIndex: Ta,
3427
- n16_userLocale: ka,
3428
- n17_signingKeys: Da,
3429
- n18_logsFields: Ma,
3430
- n19_connectionsUserinfo: La,
3431
- n20_missingFields: Ja,
3432
- n21_sessionDeletedAt: Ka,
3433
- n22_dropLogsFields: Va,
3434
- n23_dropUsersFields: Ga,
3435
- n24_logsIndexes: Ya,
3454
+ m1_init: La,
3455
+ m2_magicLink: za,
3456
+ m3_updateAt: Ka,
3457
+ m4_logTable: Va,
3458
+ m5_userProfile: Ga,
3459
+ m6_sessions: Ya,
3460
+ m7_passwords: tr,
3461
+ m8_logsTableNewFields: nr,
3462
+ m9_passwordTableNewField: ir,
3463
+ n01_codesTable: dr,
3464
+ n11_universalLoginSession: hr,
3465
+ n12_userFields: pr,
3466
+ n13_userEmailIndex: yr,
3467
+ n14_profileDataField: Cr,
3468
+ n15_userEmailIndex: Tr,
3469
+ n16_userLocale: kr,
3470
+ n17_signingKeys: Dr,
3471
+ n18_logsFields: Mr,
3472
+ n19_connectionsUserinfo: Lr,
3473
+ n20_missingFields: zr,
3474
+ n21_sessionDeletedAt: Kr,
3475
+ n22_dropLogsFields: Vr,
3476
+ n23_dropUsersFields: Gr,
3477
+ n24_logsIndexes: Yr,
3436
3478
  n25_logDescMaxLength: tn,
3437
3479
  n26_logsTableExtraFields: nn,
3438
3480
  n27_usersTableNameIndex: ln,
@@ -3440,7 +3482,7 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3440
3482
  n29_increaseOtpStateLength: fn,
3441
3483
  n30_increaseTicketStateLength: gn,
3442
3484
  n31_branding: Nn,
3443
- n32_indexesAndNotNull: Cn,
3485
+ n32_indexesAndNotNull: bn,
3444
3486
  n33_vendorIdInUniversalLoginSession: Sn,
3445
3487
  n34_auth0ClientInUniversalLoginSession: $n,
3446
3488
  n35_increaseUniversalSessionStateLength: Pn,
@@ -3451,7 +3493,7 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3451
3493
  n40_userId: Wn,
3452
3494
  n41_hooks: Hn,
3453
3495
  n42_userIdIndexes: Zn,
3454
- n43_userIdIndexes: ro,
3496
+ n43_userIdIndexes: ao,
3455
3497
  n44_codes: oo,
3456
3498
  n45_hookProperties: lo,
3457
3499
  n46_loginAuth0Client: mo,
@@ -3463,13 +3505,13 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3463
3505
  n52_cert: Io,
3464
3506
  n53_codes_primary_key: jo,
3465
3507
  n54_cleanup_tables: Fo,
3466
- n55_logs_index: zo,
3508
+ n55_logs_index: Jo,
3467
3509
  n56_application_fields: Uo,
3468
3510
  n57_prompt_settings: Qo,
3469
3511
  n58_connection_client_id: qo,
3470
3512
  n59_connection_options: Xo,
3471
3513
  n60_users_metadata: es,
3472
- n61_userLocales: as,
3514
+ n61_userLocales: rs,
3473
3515
  n62_prompt: ss,
3474
3516
  n63_connection_cleanup: cs,
3475
3517
  n64_act_as: ms,
@@ -3477,14 +3519,15 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3477
3519
  n66_email_providers: ws,
3478
3520
  n67_drop_tickets: vs,
3479
3521
  n68_login_useragents: xs,
3480
- n70_refresh_tokens: Os
3522
+ n70_refresh_tokens: Os,
3523
+ n71_session_new_fields: Is
3481
3524
  };
3482
- async function Ps(t, e = !1) {
3525
+ async function As(t, e = !1) {
3483
3526
  e && console.log("migrating...");
3484
- const r = new Fe(Le), a = new ve({
3527
+ const a = new Fe(Le), r = new ve({
3485
3528
  db: t,
3486
- provider: r
3487
- }), { error: o, results: n } = await a.migrateToLatest();
3529
+ provider: a
3530
+ }), { error: o, results: n } = await r.migrateToLatest();
3488
3531
  if (n == null || n.forEach((s) => {
3489
3532
  s.status === "Success" ? e && console.log(
3490
3533
  `migration "${s.migrationName}" was executed successfully`
@@ -3492,41 +3535,41 @@ async function Ps(t, e = !1) {
3492
3535
  }), o)
3493
3536
  throw console.error("failed to migrate"), console.error(o), o;
3494
3537
  }
3495
- async function js(t) {
3538
+ async function Fs(t) {
3496
3539
  console.log("migrating...");
3497
- const e = new Fe(Le), r = new ve({
3540
+ const e = new Fe(Le), a = new ve({
3498
3541
  db: t,
3499
3542
  provider: e
3500
- }), { error: a, results: o } = await r.migrateDown();
3543
+ }), { error: r, results: o } = await a.migrateDown();
3501
3544
  if (o == null || o.forEach((n) => {
3502
3545
  n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
3503
- }), a)
3504
- throw console.error("failed to migrate"), console.error(a), a;
3546
+ }), r)
3547
+ throw console.error("failed to migrate"), console.error(r), r;
3505
3548
  }
3506
- function Ms(t) {
3549
+ function Ls(t) {
3507
3550
  return {
3508
3551
  applications: Dt(t),
3509
3552
  branding: qt(t),
3510
3553
  clients: Et(t),
3511
3554
  codes: Tt(t),
3512
3555
  connections: Lt(t),
3513
- emailProviders: wr(t),
3556
+ emailProviders: wa(t),
3514
3557
  domains: Qt(t),
3515
- hooks: er(t),
3558
+ hooks: ea(t),
3516
3559
  keys: Ut(t),
3517
- logins: ur(t),
3560
+ logins: ua(t),
3518
3561
  logs: ct(t),
3519
3562
  passwords: yt(t),
3520
- promptSettings: fr(t),
3521
- refreshTokens: xr(t),
3563
+ promptSettings: fa(t),
3564
+ refreshTokens: xa(t),
3522
3565
  sessions: _t(t),
3523
3566
  tenants: nt(t),
3524
- themes: sr(t),
3567
+ themes: sa(t),
3525
3568
  users: Xe(t)
3526
3569
  };
3527
3570
  }
3528
3571
  export {
3529
- Ms as default,
3530
- js as migrateDown,
3531
- Ps as migrateToLatest
3572
+ Ls as default,
3573
+ Fs as migrateDown,
3574
+ As as migrateToLatest
3532
3575
  };