@authhero/kysely-adapter 5.1.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,73 +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,
1112
+ function Na(t) {
1113
+ return async (e, a) => {
1114
+ const r = {
1115
+ ...a,
1084
1116
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1085
1117
  };
1086
- 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 };
1087
1119
  };
1088
1120
  }
1089
- function vr(t) {
1090
- 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;
1091
1123
  }
1092
- function br(t) {
1093
- 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;
1094
1126
  }
1095
- function Cr(t) {
1096
- return async (e, r = {
1127
+ function ba(t) {
1128
+ return async (e, a = {
1097
1129
  page: 0,
1098
1130
  per_page: 50,
1099
1131
  include_totals: !1
1100
1132
  }) => {
1101
- let a = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1102
- r.q && (a = T(t, a, r.q, ["token", "session_id"]));
1103
- let o = a;
1104
- 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) {
1105
1137
  const { ref: d } = t.dynamic;
1106
1138
  o = o.orderBy(
1107
- d(r.sort.sort_by),
1108
- r.sort.sort_order
1139
+ d(a.sort.sort_by),
1140
+ a.sort.sort_order
1109
1141
  );
1110
1142
  }
1111
- o = o.offset(r.page * r.per_page).limit(r.per_page);
1112
- 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);
1113
1145
  return {
1114
1146
  refresh_tokens: n,
1115
- start: r.page * r.per_page,
1116
- limit: r.per_page,
1147
+ start: a.page * a.per_page,
1148
+ limit: a.per_page,
1117
1149
  length: l
1118
1150
  };
1119
1151
  };
1120
1152
  }
1121
- function xr(t) {
1153
+ function xa(t) {
1122
1154
  return {
1123
- create: Nr(t),
1124
- get: yr(t),
1125
- list: Cr(t),
1126
- remove: vr(t),
1127
- update: br(t)
1155
+ create: Na(t),
1156
+ get: ya(t),
1157
+ list: ba(t),
1158
+ remove: va(t),
1159
+ update: Ca(t)
1128
1160
  };
1129
1161
  }
1130
- function Tr(t) {
1162
+ function Ta(t) {
1131
1163
  return t[t.length - 1];
1132
1164
  }
1133
1165
  function p(t) {
1134
1166
  return Object.freeze(t);
1135
1167
  }
1136
- const J = p({
1168
+ const z = p({
1137
1169
  is(t) {
1138
1170
  return t.kind === "IdentifierNode";
1139
1171
  },
@@ -1150,17 +1182,17 @@ const J = p({
1150
1182
  create(t) {
1151
1183
  return p({
1152
1184
  kind: "SchemableIdentifierNode",
1153
- identifier: J.create(t)
1185
+ identifier: z.create(t)
1154
1186
  });
1155
1187
  },
1156
1188
  createWithSchema(t, e) {
1157
1189
  return p({
1158
1190
  kind: "SchemableIdentifierNode",
1159
- schema: J.create(t),
1160
- identifier: J.create(e)
1191
+ schema: z.create(t),
1192
+ identifier: z.create(e)
1161
1193
  });
1162
1194
  }
1163
- }), Sr = p({
1195
+ }), Sa = p({
1164
1196
  is(t) {
1165
1197
  return t.kind === "AliasNode";
1166
1198
  },
@@ -1189,7 +1221,7 @@ const J = p({
1189
1221
  }
1190
1222
  });
1191
1223
  var R;
1192
- class Or {
1224
+ class Oa {
1193
1225
  constructor() {
1194
1226
  j(this, "nodeStack", []);
1195
1227
  w(this, R, p({
@@ -1292,14 +1324,14 @@ class Or {
1292
1324
  if (!e)
1293
1325
  return e;
1294
1326
  this.nodeStack.push(e);
1295
- const r = this.transformNodeImpl(e);
1296
- return this.nodeStack.pop(), p(r);
1327
+ const a = this.transformNodeImpl(e);
1328
+ return this.nodeStack.pop(), p(a);
1297
1329
  }
1298
1330
  transformNodeImpl(e) {
1299
1331
  return c(this, R)[e.kind](e);
1300
1332
  }
1301
1333
  transformNodeList(e) {
1302
- return e && p(e.map((r) => this.transformNode(r)));
1334
+ return e && p(e.map((a) => this.transformNode(a)));
1303
1335
  }
1304
1336
  transformSelectQuery(e) {
1305
1337
  return {
@@ -2023,7 +2055,7 @@ class Or {
2023
2055
  }
2024
2056
  }
2025
2057
  R = new WeakMap();
2026
- const kr = p({
2058
+ const ka = p({
2027
2059
  AlterTableNode: !0,
2028
2060
  CreateIndexNode: !0,
2029
2061
  CreateSchemaNode: !0,
@@ -2043,77 +2075,77 @@ const kr = p({
2043
2075
  MergeQueryNode: !0
2044
2076
  });
2045
2077
  var P, S, O, _, ge, we, ye, $, q, Ne;
2046
- class $r extends Or {
2047
- constructor(r) {
2078
+ class $a extends Oa {
2079
+ constructor(a) {
2048
2080
  super();
2049
2081
  w(this, _);
2050
2082
  w(this, P);
2051
2083
  w(this, S, /* @__PURE__ */ new Set());
2052
2084
  w(this, O, /* @__PURE__ */ new Set());
2053
- M(this, P, r);
2085
+ M(this, P, a);
2054
2086
  }
2055
- transformNodeImpl(r) {
2056
- if (!u(this, _, ge).call(this, r))
2057
- return super.transformNodeImpl(r);
2058
- const a = u(this, _, ye).call(this, r);
2059
- 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)
2060
2092
  c(this, O).add(s);
2061
- const o = u(this, _, we).call(this, r);
2093
+ const o = u(this, _, we).call(this, a);
2062
2094
  for (const s of o)
2063
2095
  c(this, S).add(s);
2064
- const n = super.transformNodeImpl(r);
2096
+ const n = super.transformNodeImpl(a);
2065
2097
  for (const s of o)
2066
2098
  c(this, S).delete(s);
2067
- for (const s of a)
2099
+ for (const s of r)
2068
2100
  c(this, O).delete(s);
2069
2101
  return n;
2070
2102
  }
2071
- transformSchemableIdentifier(r) {
2072
- const a = super.transformSchemableIdentifier(r);
2073
- return a.schema || !c(this, S).has(r.identifier.name) ? a : {
2074
- ...a,
2075
- 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))
2076
2108
  };
2077
2109
  }
2078
- transformReferences(r) {
2079
- const a = super.transformReferences(r);
2080
- return a.table.table.schema ? a : {
2081
- ...a,
2082
- table: K.createWithSchema(c(this, P), a.table.table.identifier.name)
2083
- };
2084
- }
2085
- }
2086
- P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(r) {
2087
- return r.kind in kr;
2088
- }, we = function(r) {
2089
- const a = /* @__PURE__ */ new Set();
2090
- if ("name" in r && r.name && W.is(r.name) && u(this, _, q).call(this, r.name, a), "from" in r && r.from)
2091
- for (const o of r.from.froms)
2092
- u(this, _, $).call(this, o, a);
2093
- 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)
2094
- for (const o of r.joins)
2095
- u(this, _, $).call(this, o.table, a);
2096
- return "using" in r && r.using && u(this, _, $).call(this, r.using, a), a;
2097
- }, ye = function(r) {
2098
- const a = /* @__PURE__ */ new Set();
2099
- return "with" in r && r.with && u(this, _, Ne).call(this, r.with, a), a;
2100
- }, $ = function(r, a) {
2101
- const o = K.is(r) ? r : Sr.is(r) && K.is(r.node) ? r.node : null;
2102
- o && u(this, _, q).call(this, o.table, a);
2103
- }, q = function(r, a) {
2104
- const o = r.identifier.name;
2105
- !c(this, S).has(o) && !c(this, O).has(o) && a.add(o);
2106
- }, Ne = function(r, a) {
2107
- 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) {
2108
2140
  const n = o.name.table.table.identifier.name;
2109
- c(this, O).has(n) || a.add(n);
2141
+ c(this, O).has(n) || r.add(n);
2110
2142
  }
2111
2143
  };
2112
2144
  var L;
2113
- class Ir {
2145
+ class Ia {
2114
2146
  constructor(e) {
2115
2147
  w(this, L);
2116
- M(this, L, new $r(e));
2148
+ M(this, L, new $a(e));
2117
2149
  }
2118
2150
  transformQuery(e) {
2119
2151
  return c(this, L).transformNode(e.node);
@@ -2123,7 +2155,7 @@ class Ir {
2123
2155
  }
2124
2156
  }
2125
2157
  L = new WeakMap();
2126
- class Dr {
2158
+ class Da {
2127
2159
  transformQuery(e) {
2128
2160
  return e.node;
2129
2161
  }
@@ -2131,8 +2163,8 @@ class Dr {
2131
2163
  return e.result;
2132
2164
  }
2133
2165
  }
2134
- const Pr = "kysely_migration", fe = "kysely_migration_lock", jr = !1, B = "migration_lock", Mr = p({ __noMigrations__: !0 });
2135
- 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;
2136
2168
  class ve {
2137
2169
  constructor(e) {
2138
2170
  w(this, i);
@@ -2145,11 +2177,11 @@ class ve {
2145
2177
  * The returned array is sorted by migration name.
2146
2178
  */
2147
2179
  async getMigrations() {
2148
- 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() : [];
2149
- return (await u(this, i, X).call(this)).map(({ name: a, ...o }) => {
2150
- 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);
2151
2183
  return {
2152
- name: a,
2184
+ name: r,
2153
2185
  migration: o,
2154
2186
  executedAt: n ? new Date(n.timestamp) : void 0
2155
2187
  };
@@ -2229,16 +2261,16 @@ class ve {
2229
2261
  * ```
2230
2262
  */
2231
2263
  async migrateTo(e) {
2232
- return u(this, i, A).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: o }) => {
2233
- if (e === Mr)
2264
+ return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2265
+ if (e === Ma)
2234
2266
  return { direction: "Down", step: 1 / 0 };
2235
- if (!r.find((l) => l.name === e))
2267
+ if (!a.find((l) => l.name === e))
2236
2268
  throw new Error(`migration "${e}" doesn't exist`);
2237
- 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);
2238
2270
  if (n !== -1)
2239
2271
  return {
2240
2272
  direction: "Down",
2241
- step: a.length - n - 1
2273
+ step: r.length - n - 1
2242
2274
  };
2243
2275
  if (s !== -1)
2244
2276
  return { direction: "Up", step: s + 1 };
@@ -2282,21 +2314,21 @@ class ve {
2282
2314
  }
2283
2315
  h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2284
2316
  try {
2285
- return await u(this, i, Ce).call(this), await u(this, i, ke).call(this, e);
2286
- } catch (r) {
2287
- 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 };
2288
2320
  }
2289
2321
  }, N = function() {
2290
2322
  return c(this, h).migrationTableSchema;
2291
2323
  }, v = function() {
2292
- return c(this, h).migrationTableName ?? Pr;
2324
+ return c(this, h).migrationTableName ?? Pa;
2293
2325
  }, I = function() {
2294
2326
  return c(this, h).migrationLockTableName ?? fe;
2295
- }, be = function() {
2296
- return c(this, h).allowUnorderedMigrations ?? jr;
2297
- }, b = function() {
2298
- return c(this, i, N) ? new Ir(c(this, i, N)) : new Dr();
2299
- }, 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() {
2300
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);
2301
2333
  }, xe = async function() {
2302
2334
  if (c(this, i, N) && !await u(this, i, G).call(this))
@@ -2309,7 +2341,7 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2309
2341
  }, Te = async function() {
2310
2342
  if (!await u(this, i, D).call(this, c(this, i, v)))
2311
2343
  try {
2312
- 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()));
2313
2345
  } catch (e) {
2314
2346
  if (!await u(this, i, D).call(this, c(this, i, v)))
2315
2347
  throw e;
@@ -2317,7 +2349,7 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2317
2349
  }, Se = async function() {
2318
2350
  if (!await u(this, i, D).call(this, c(this, i, I)))
2319
2351
  try {
2320
- 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)));
2321
2353
  } catch (e) {
2322
2354
  if (!await u(this, i, D).call(this, c(this, i, I)))
2323
2355
  throw e;
@@ -2325,68 +2357,68 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2325
2357
  }, Oe = async function() {
2326
2358
  if (!await u(this, i, H).call(this))
2327
2359
  try {
2328
- 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();
2329
2361
  } catch (e) {
2330
2362
  if (!await u(this, i, H).call(this))
2331
2363
  throw e;
2332
2364
  }
2333
2365
  }, G = async function() {
2334
- 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));
2335
2367
  }, D = async function(e) {
2336
- const r = c(this, i, N);
2368
+ const a = c(this, i, N);
2337
2369
  return (await c(this, h).db.introspection.getTables({
2338
2370
  withInternalKyselyTables: !0
2339
- })).some((o) => o.name === e && (!r || o.schema === r));
2371
+ })).some((o) => o.name === e && (!a || o.schema === a));
2340
2372
  }, H = async function() {
2341
- 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();
2342
2374
  }, ke = async function(e) {
2343
- const r = c(this, h).db.getExecutor().adapter, a = p({
2375
+ const a = c(this, h).db.getExecutor().adapter, r = p({
2344
2376
  lockTable: c(this, h).migrationLockTableName ?? fe,
2345
2377
  lockRowId: B,
2346
2378
  lockTableSchema: c(this, h).migrationTableSchema
2347
2379
  }), o = async (n) => {
2348
2380
  try {
2349
- await r.acquireMigrationLock(n, a);
2381
+ await a.acquireMigrationLock(n, r);
2350
2382
  const s = await u(this, i, $e).call(this, n);
2351
2383
  if (s.migrations.length === 0)
2352
2384
  return { results: [] };
2353
2385
  const { direction: l, step: d } = e(s);
2354
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: [] };
2355
2387
  } finally {
2356
- await r.releaseMigrationLock(n, a);
2388
+ await a.releaseMigrationLock(n, r);
2357
2389
  }
2358
2390
  };
2359
- 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);
2360
2392
  }, $e = async function(e) {
2361
- const r = await u(this, i, X).call(this), a = await u(this, i, De).call(this, e);
2362
- u(this, i, Pe).call(this, r, a), c(this, i, be) || u(this, i, je).call(this, r, a);
2363
- 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);
2364
2396
  return p({
2365
- migrations: r,
2366
- executedMigrations: a,
2367
- lastMigration: Tr(a),
2397
+ migrations: a,
2398
+ executedMigrations: r,
2399
+ lastMigration: Ta(r),
2368
2400
  pendingMigrations: o
2369
2401
  });
2370
- }, Ie = function(e, r) {
2371
- return e.filter((a) => !r.includes(a.name));
2402
+ }, Ie = function(e, a) {
2403
+ return e.filter((r) => !a.includes(r.name));
2372
2404
  }, X = async function() {
2373
2405
  const e = await c(this, h).provider.getMigrations();
2374
- return Object.keys(e).sort().map((r) => ({
2375
- ...e[r],
2376
- name: r
2406
+ return Object.keys(e).sort().map((a) => ({
2407
+ ...e[a],
2408
+ name: a
2377
2409
  }));
2378
2410
  }, De = async function(e) {
2379
- return (await e.withPlugin(c(this, i, b)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
2380
- }, Pe = function(e, r) {
2381
- for (const a of r)
2382
- if (!e.some((o) => o.name === a))
2383
- throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
2384
- }, je = function(e, r) {
2385
- for (let a = 0; a < r.length; ++a)
2386
- if (e[a].name !== r[a])
2387
- 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.`);
2388
- }, Me = async function(e, r, a) {
2389
- 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) => ({
2390
2422
  migrationName: s.name,
2391
2423
  direction: "Down",
2392
2424
  status: "NotExecuted"
@@ -2394,7 +2426,7 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2394
2426
  for (let s = 0; s < n.length; ++s) {
2395
2427
  const l = o[s];
2396
2428
  try {
2397
- 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] = {
2398
2430
  migrationName: l.name,
2399
2431
  direction: "Down",
2400
2432
  status: "Success"
@@ -2411,16 +2443,16 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2411
2443
  }
2412
2444
  }
2413
2445
  return { results: n };
2414
- }, Ae = async function(e, r, a) {
2415
- 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) => ({
2416
2448
  migrationName: s.name,
2417
2449
  direction: "Up",
2418
2450
  status: "NotExecuted"
2419
2451
  }));
2420
2452
  for (let s = 0; s < n.length; s++) {
2421
- const l = r.pendingMigrations[s];
2453
+ const l = a.pendingMigrations[s];
2422
2454
  try {
2423
- 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({
2424
2456
  name: l.name,
2425
2457
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2426
2458
  }).execute(), n[s] = {
@@ -2445,10 +2477,10 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2445
2477
  };
2446
2478
  var E;
2447
2479
  class Q extends Error {
2448
- constructor(r) {
2480
+ constructor(a) {
2449
2481
  super();
2450
2482
  w(this, E);
2451
- M(this, E, r);
2483
+ M(this, E, a);
2452
2484
  }
2453
2485
  get resultSet() {
2454
2486
  return c(this, E);
@@ -2464,7 +2496,7 @@ class Fe {
2464
2496
  return this.migrations;
2465
2497
  }
2466
2498
  }
2467
- async function Ar(t) {
2499
+ async function Aa(t) {
2468
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(
2469
2501
  "tenant_id",
2470
2502
  "varchar(255)",
@@ -2532,35 +2564,35 @@ async function Ar(t) {
2532
2564
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
2533
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();
2534
2566
  }
2535
- async function Fr(t) {
2567
+ async function Fa(t) {
2536
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();
2537
2569
  }
2538
- const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2570
+ const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2539
2571
  __proto__: null,
2540
- down: Fr,
2541
- up: Ar
2572
+ down: Fa,
2573
+ up: Aa
2542
2574
  }, Symbol.toStringTag, { value: "Module" }));
2543
- async function Er(t) {
2575
+ async function Ea(t) {
2544
2576
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
2545
2577
  }
2546
- async function zr(t) {
2578
+ async function Ja(t) {
2547
2579
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
2548
2580
  }
2549
- const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2581
+ const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2550
2582
  __proto__: null,
2551
- down: zr,
2552
- up: Er
2583
+ down: Ja,
2584
+ up: Ea
2553
2585
  }, Symbol.toStringTag, { value: "Module" }));
2554
- async function Rr(t) {
2586
+ async function Ra(t) {
2555
2587
  }
2556
- async function Ur(t) {
2588
+ async function Ua(t) {
2557
2589
  }
2558
- const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2590
+ const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2559
2591
  __proto__: null,
2560
- down: Ur,
2561
- up: Rr
2592
+ down: Ua,
2593
+ up: Ra
2562
2594
  }, Symbol.toStringTag, { value: "Module" }));
2563
- async function Br(t) {
2595
+ async function Ba(t) {
2564
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(
2565
2597
  "tenant_id_constraint",
2566
2598
  ["tenant_id"],
@@ -2569,24 +2601,24 @@ async function Br(t) {
2569
2601
  (e) => e.onDelete("cascade")
2570
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();
2571
2603
  }
2572
- async function Qr(t) {
2604
+ async function Qa(t) {
2573
2605
  await t.schema.dropTable("logs").execute();
2574
2606
  }
2575
- const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2607
+ const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2576
2608
  __proto__: null,
2577
- down: Qr,
2578
- up: Br
2609
+ down: Qa,
2610
+ up: Ba
2579
2611
  }, Symbol.toStringTag, { value: "Module" }));
2580
- async function Wr(t) {
2612
+ async function Wa(t) {
2581
2613
  }
2582
- async function qr(t) {
2614
+ async function qa(t) {
2583
2615
  }
2584
- const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2616
+ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2585
2617
  __proto__: null,
2586
- down: qr,
2587
- up: Wr
2618
+ down: qa,
2619
+ up: Wa
2588
2620
  }, Symbol.toStringTag, { value: "Module" }));
2589
- async function Hr(t) {
2621
+ async function Ha(t) {
2590
2622
  await t.schema.createTable("sessions").addColumn("session_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
2591
2623
  "client_id",
2592
2624
  "varchar(255)",
@@ -2615,15 +2647,15 @@ async function Hr(t) {
2615
2647
  (e) => e.references("applications.id").onDelete("cascade").notNull()
2616
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();
2617
2649
  }
2618
- async function Xr(t) {
2650
+ async function Xa(t) {
2619
2651
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
2620
2652
  }
2621
- const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2653
+ const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2622
2654
  __proto__: null,
2623
- down: Xr,
2624
- up: Hr
2655
+ down: Xa,
2656
+ up: Ha
2625
2657
  }, Symbol.toStringTag, { value: "Module" }));
2626
- async function Zr(t) {
2658
+ async function Za(t) {
2627
2659
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
2628
2660
  "user_id_constraint",
2629
2661
  ["user_id", "tenant_id"],
@@ -2638,24 +2670,24 @@ async function Zr(t) {
2638
2670
  (e) => e.onDelete("cascade")
2639
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();
2640
2672
  }
2641
- async function ea(t) {
2673
+ async function er(t) {
2642
2674
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
2643
2675
  }
2644
- const ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2676
+ const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2645
2677
  __proto__: null,
2646
- down: ea,
2647
- up: Zr
2678
+ down: er,
2679
+ up: Za
2648
2680
  }, Symbol.toStringTag, { value: "Module" }));
2649
- async function ra(t) {
2681
+ async function ar(t) {
2650
2682
  }
2651
- async function aa(t) {
2683
+ async function rr(t) {
2652
2684
  }
2653
- const na = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2685
+ const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2654
2686
  __proto__: null,
2655
- down: aa,
2656
- up: ra
2687
+ down: rr,
2688
+ up: ar
2657
2689
  }, Symbol.toStringTag, { value: "Module" }));
2658
- async function oa(t) {
2690
+ async function or(t) {
2659
2691
  await t.schema.alterTable("passwords").addColumn(
2660
2692
  "password",
2661
2693
  "varchar(255)",
@@ -2663,172 +2695,172 @@ async function oa(t) {
2663
2695
  (e) => e.notNull()
2664
2696
  ).execute();
2665
2697
  }
2666
- async function sa(t) {
2698
+ async function sr(t) {
2667
2699
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2668
2700
  }
2669
- const ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2701
+ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2670
2702
  __proto__: null,
2671
- down: sa,
2672
- up: oa
2703
+ down: sr,
2704
+ up: or
2673
2705
  }, Symbol.toStringTag, { value: "Module" }));
2674
- async function la(t) {
2706
+ async function lr(t) {
2675
2707
  }
2676
- async function ca(t) {
2708
+ async function cr(t) {
2677
2709
  }
2678
- const da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2710
+ const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2679
2711
  __proto__: null,
2680
- down: ca,
2681
- up: la
2712
+ down: cr,
2713
+ up: lr
2682
2714
  }, Symbol.toStringTag, { value: "Module" }));
2683
- async function ua(t) {
2715
+ async function ur(t) {
2684
2716
  }
2685
- async function ma(t) {
2717
+ async function mr(t) {
2686
2718
  }
2687
- const ha = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2719
+ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2688
2720
  __proto__: null,
2689
- down: ma,
2690
- up: ua
2721
+ down: mr,
2722
+ up: ur
2691
2723
  }, Symbol.toStringTag, { value: "Module" }));
2692
- async function fa(t) {
2724
+ async function fr(t) {
2693
2725
  }
2694
- async function _a(t) {
2726
+ async function _r(t) {
2695
2727
  }
2696
- const pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2728
+ const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2697
2729
  __proto__: null,
2698
- down: _a,
2699
- up: fa
2730
+ down: _r,
2731
+ up: fr
2700
2732
  }, Symbol.toStringTag, { value: "Module" }));
2701
- async function ga(t) {
2733
+ async function gr(t) {
2702
2734
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
2703
2735
  }
2704
- async function wa(t) {
2736
+ async function wr(t) {
2705
2737
  await t.schema.dropIndex("users_email_index").execute();
2706
2738
  }
2707
- const ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2739
+ const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2708
2740
  __proto__: null,
2709
- down: wa,
2710
- up: ga
2741
+ down: wr,
2742
+ up: gr
2711
2743
  }, Symbol.toStringTag, { value: "Module" }));
2712
- async function Na(t) {
2744
+ async function Nr(t) {
2713
2745
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
2714
2746
  }
2715
- async function va(t) {
2747
+ async function vr(t) {
2716
2748
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2717
2749
  }
2718
- const ba = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2750
+ const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2719
2751
  __proto__: null,
2720
- down: va,
2721
- up: Na
2752
+ down: vr,
2753
+ up: Nr
2722
2754
  }, Symbol.toStringTag, { value: "Module" }));
2723
- async function Ca(t) {
2755
+ async function br(t) {
2724
2756
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
2725
2757
  }
2726
- async function xa(t) {
2758
+ async function xr(t) {
2727
2759
  await t.schema.dropIndex("users_linked_to_index");
2728
2760
  }
2729
- const Ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2761
+ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2730
2762
  __proto__: null,
2731
- down: xa,
2732
- up: Ca
2763
+ down: xr,
2764
+ up: br
2733
2765
  }, Symbol.toStringTag, { value: "Module" }));
2734
- async function Sa(t) {
2766
+ async function Sr(t) {
2735
2767
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
2736
2768
  }
2737
- async function Oa(t) {
2769
+ async function Or(t) {
2738
2770
  await t.schema.alterTable("users").dropColumn("locale").execute();
2739
2771
  }
2740
- const ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2772
+ const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2741
2773
  __proto__: null,
2742
- down: Oa,
2743
- up: Sa
2774
+ down: Or,
2775
+ up: Sr
2744
2776
  }, Symbol.toStringTag, { value: "Module" }));
2745
- async function $a(t) {
2777
+ async function $r(t) {
2746
2778
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2747
2779
  "tenant_id",
2748
2780
  "varchar(255)",
2749
2781
  (e) => e.references("tenants.id").onDelete("cascade")
2750
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();
2751
2783
  }
2752
- async function Ia(t) {
2784
+ async function Ir(t) {
2753
2785
  await t.schema.dropTable("keys").execute();
2754
2786
  }
2755
- const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2787
+ const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2756
2788
  __proto__: null,
2757
- down: Ia,
2758
- up: $a
2789
+ down: Ir,
2790
+ up: $r
2759
2791
  }, Symbol.toStringTag, { value: "Module" }));
2760
- async function Pa(t) {
2792
+ async function Pr(t) {
2761
2793
  }
2762
- async function ja(t) {
2794
+ async function jr(t) {
2763
2795
  }
2764
- const Ma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2796
+ const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2765
2797
  __proto__: null,
2766
- down: ja,
2767
- up: Pa
2798
+ down: jr,
2799
+ up: Pr
2768
2800
  }, Symbol.toStringTag, { value: "Module" }));
2769
- async function Aa(t) {
2801
+ async function Ar(t) {
2770
2802
  }
2771
- async function Fa(t) {
2803
+ async function Fr(t) {
2772
2804
  }
2773
- const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2805
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2774
2806
  __proto__: null,
2775
- down: Fa,
2776
- up: Aa
2807
+ down: Fr,
2808
+ up: Ar
2777
2809
  }, Symbol.toStringTag, { value: "Module" }));
2778
- async function Ea(t) {
2810
+ async function Er(t) {
2779
2811
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
2780
2812
  }
2781
- async function za(t) {
2813
+ async function Jr(t) {
2782
2814
  await t.schema.alterTable("otps").dropColumn("audience").execute();
2783
2815
  }
2784
- const Ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2816
+ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2785
2817
  __proto__: null,
2786
- down: za,
2787
- up: Ea
2818
+ down: Jr,
2819
+ up: Er
2788
2820
  }, Symbol.toStringTag, { value: "Module" }));
2789
- async function Ra(t) {
2821
+ async function Rr(t) {
2790
2822
  }
2791
- async function Ua(t) {
2823
+ async function Ur(t) {
2792
2824
  }
2793
- const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2825
+ const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2794
2826
  __proto__: null,
2795
- down: Ua,
2796
- up: Ra
2827
+ down: Ur,
2828
+ up: Rr
2797
2829
  }, Symbol.toStringTag, { value: "Module" }));
2798
- async function Ba(t) {
2830
+ async function Br(t) {
2799
2831
  await t.schema.alterTable("logs").dropColumn("category").execute();
2800
2832
  }
2801
- async function Qa(t) {
2833
+ async function Qr(t) {
2802
2834
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
2803
2835
  }
2804
- const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2836
+ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2805
2837
  __proto__: null,
2806
- down: Qa,
2807
- up: Ba
2838
+ down: Qr,
2839
+ up: Br
2808
2840
  }, Symbol.toStringTag, { value: "Module" }));
2809
- async function Wa(t) {
2841
+ async function Wr(t) {
2810
2842
  await t.schema.alterTable("users").dropColumn("tags").execute();
2811
2843
  }
2812
- async function qa(t) {
2844
+ async function qr(t) {
2813
2845
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
2814
2846
  }
2815
- const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2847
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2816
2848
  __proto__: null,
2817
- down: qa,
2818
- up: Wa
2849
+ down: qr,
2850
+ up: Wr
2819
2851
  }, Symbol.toStringTag, { value: "Module" }));
2820
- async function Ha(t) {
2852
+ async function Hr(t) {
2821
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();
2822
2854
  }
2823
- async function Xa(t) {
2855
+ async function Xr(t) {
2824
2856
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
2825
2857
  }
2826
- const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2858
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2827
2859
  __proto__: null,
2828
- down: Xa,
2829
- up: Ha
2860
+ down: Xr,
2861
+ up: Hr
2830
2862
  }, Symbol.toStringTag, { value: "Module" }));
2831
- async function Za(t) {
2863
+ async function Zr(t) {
2832
2864
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
2833
2865
  }
2834
2866
  async function en(t) {
@@ -2837,18 +2869,18 @@ async function en(t) {
2837
2869
  const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2838
2870
  __proto__: null,
2839
2871
  down: en,
2840
- up: Za
2872
+ up: Zr
2841
2873
  }, Symbol.toStringTag, { value: "Module" }));
2842
- async function rn(t) {
2874
+ async function an(t) {
2843
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();
2844
2876
  }
2845
- async function an(t) {
2877
+ async function rn(t) {
2846
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();
2847
2879
  }
2848
2880
  const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2849
2881
  __proto__: null,
2850
- down: an,
2851
- up: rn
2882
+ down: rn,
2883
+ up: an
2852
2884
  }, Symbol.toStringTag, { value: "Module" }));
2853
2885
  async function on(t) {
2854
2886
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
@@ -2910,11 +2942,11 @@ const Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2910
2942
  }, Symbol.toStringTag, { value: "Module" }));
2911
2943
  async function vn(t) {
2912
2944
  }
2913
- async function bn(t) {
2945
+ async function Cn(t) {
2914
2946
  }
2915
- const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2947
+ const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2916
2948
  __proto__: null,
2917
- down: bn,
2949
+ down: Cn,
2918
2950
  up: vn
2919
2951
  }, Symbol.toStringTag, { value: "Module" }));
2920
2952
  async function xn(t) {
@@ -2972,16 +3004,16 @@ const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2972
3004
  down: Ln,
2973
3005
  up: Fn
2974
3006
  }, Symbol.toStringTag, { value: "Module" }));
2975
- async function zn(t) {
3007
+ async function Jn(t) {
2976
3008
  await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
2977
3009
  }
2978
- async function Jn(t) {
3010
+ async function zn(t) {
2979
3011
  await t.schema.alterTable("otps").dropColumn("ip").execute();
2980
3012
  }
2981
3013
  const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2982
3014
  __proto__: null,
2983
- down: Jn,
2984
- up: zn
3015
+ down: zn,
3016
+ up: Jn
2985
3017
  }, Symbol.toStringTag, { value: "Module" }));
2986
3018
  async function Un(t) {
2987
3019
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
@@ -3035,12 +3067,12 @@ async function eo(t) {
3035
3067
  }
3036
3068
  async function to(t) {
3037
3069
  }
3038
- const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3070
+ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3039
3071
  __proto__: null,
3040
3072
  down: to,
3041
3073
  up: eo
3042
3074
  }, Symbol.toStringTag, { value: "Module" }));
3043
- async function ao(t) {
3075
+ async function ro(t) {
3044
3076
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3045
3077
  "tenant_id",
3046
3078
  "varchar(255)",
@@ -3069,7 +3101,7 @@ async function no(t) {
3069
3101
  const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3070
3102
  __proto__: null,
3071
3103
  down: no,
3072
- up: ao
3104
+ up: ro
3073
3105
  }, Symbol.toStringTag, { value: "Module" }));
3074
3106
  async function so(t) {
3075
3107
  }
@@ -3120,16 +3152,16 @@ const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3120
3152
  down: No,
3121
3153
  up: yo
3122
3154
  }, Symbol.toStringTag, { value: "Module" }));
3123
- async function bo(t) {
3155
+ async function Co(t) {
3124
3156
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3125
3157
  }
3126
- async function Co(t) {
3158
+ async function bo(t) {
3127
3159
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3128
3160
  }
3129
3161
  const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3130
3162
  __proto__: null,
3131
- down: Co,
3132
- up: bo
3163
+ down: bo,
3164
+ up: Co
3133
3165
  }, Symbol.toStringTag, { value: "Module" }));
3134
3166
  async function To(t) {
3135
3167
  }
@@ -3216,19 +3248,19 @@ async function Lo(t) {
3216
3248
  async function Eo(t) {
3217
3249
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
3218
3250
  }
3219
- const zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3251
+ const Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3220
3252
  __proto__: null,
3221
3253
  down: Eo,
3222
3254
  up: Lo
3223
3255
  }, Symbol.toStringTag, { value: "Module" }));
3224
- async function Jo(t) {
3256
+ async function zo(t) {
3225
3257
  }
3226
3258
  async function Ro(t) {
3227
3259
  }
3228
3260
  const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3229
3261
  __proto__: null,
3230
3262
  down: Ro,
3231
- up: Jo
3263
+ up: zo
3232
3264
  }, Symbol.toStringTag, { value: "Module" }));
3233
3265
  async function Ko(t) {
3234
3266
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
@@ -3287,12 +3319,12 @@ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3287
3319
  async function ts(t) {
3288
3320
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3289
3321
  }
3290
- async function rs(t) {
3322
+ async function as(t) {
3291
3323
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3292
3324
  }
3293
- const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3325
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3294
3326
  __proto__: null,
3295
- down: rs,
3327
+ down: as,
3296
3328
  up: ts
3297
3329
  }, Symbol.toStringTag, { value: "Module" }));
3298
3330
  async function ns(t) {
@@ -3375,15 +3407,15 @@ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3375
3407
  down: Ns,
3376
3408
  up: ys
3377
3409
  }, Symbol.toStringTag, { value: "Module" }));
3378
- async function bs(t) {
3379
- }
3380
3410
  async function Cs(t) {
3411
+ }
3412
+ async function bs(t) {
3381
3413
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3382
3414
  }
3383
3415
  const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3384
3416
  __proto__: null,
3385
- down: Cs,
3386
- up: bs
3417
+ down: bs,
3418
+ up: Cs
3387
3419
  }, Symbol.toStringTag, { value: "Module" }));
3388
3420
  async function Ts(t) {
3389
3421
  await t.schema.createTable("refresh_tokens").addColumn(
@@ -3407,31 +3439,42 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3407
3439
  __proto__: null,
3408
3440
  down: Ss,
3409
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
3410
3453
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3411
- m1_init: Lr,
3412
- m2_magicLink: Jr,
3413
- m3_updateAt: Kr,
3414
- m4_logTable: Vr,
3415
- m5_userProfile: Gr,
3416
- m6_sessions: Yr,
3417
- m7_passwords: ta,
3418
- m8_logsTableNewFields: na,
3419
- m9_passwordTableNewField: ia,
3420
- n01_codesTable: da,
3421
- n11_universalLoginSession: ha,
3422
- n12_userFields: pa,
3423
- n13_userEmailIndex: ya,
3424
- n14_profileDataField: ba,
3425
- n15_userEmailIndex: Ta,
3426
- n16_userLocale: ka,
3427
- n17_signingKeys: Da,
3428
- n18_logsFields: Ma,
3429
- n19_connectionsUserinfo: La,
3430
- n20_missingFields: Ja,
3431
- n21_sessionDeletedAt: Ka,
3432
- n22_dropLogsFields: Va,
3433
- n23_dropUsersFields: Ga,
3434
- 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,
3435
3478
  n25_logDescMaxLength: tn,
3436
3479
  n26_logsTableExtraFields: nn,
3437
3480
  n27_usersTableNameIndex: ln,
@@ -3439,7 +3482,7 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3439
3482
  n29_increaseOtpStateLength: fn,
3440
3483
  n30_increaseTicketStateLength: gn,
3441
3484
  n31_branding: Nn,
3442
- n32_indexesAndNotNull: Cn,
3485
+ n32_indexesAndNotNull: bn,
3443
3486
  n33_vendorIdInUniversalLoginSession: Sn,
3444
3487
  n34_auth0ClientInUniversalLoginSession: $n,
3445
3488
  n35_increaseUniversalSessionStateLength: Pn,
@@ -3450,7 +3493,7 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3450
3493
  n40_userId: Wn,
3451
3494
  n41_hooks: Hn,
3452
3495
  n42_userIdIndexes: Zn,
3453
- n43_userIdIndexes: ro,
3496
+ n43_userIdIndexes: ao,
3454
3497
  n44_codes: oo,
3455
3498
  n45_hookProperties: lo,
3456
3499
  n46_loginAuth0Client: mo,
@@ -3462,13 +3505,13 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3462
3505
  n52_cert: Io,
3463
3506
  n53_codes_primary_key: jo,
3464
3507
  n54_cleanup_tables: Fo,
3465
- n55_logs_index: zo,
3508
+ n55_logs_index: Jo,
3466
3509
  n56_application_fields: Uo,
3467
3510
  n57_prompt_settings: Qo,
3468
3511
  n58_connection_client_id: qo,
3469
3512
  n59_connection_options: Xo,
3470
3513
  n60_users_metadata: es,
3471
- n61_userLocales: as,
3514
+ n61_userLocales: rs,
3472
3515
  n62_prompt: ss,
3473
3516
  n63_connection_cleanup: cs,
3474
3517
  n64_act_as: ms,
@@ -3476,14 +3519,15 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3476
3519
  n66_email_providers: ws,
3477
3520
  n67_drop_tickets: vs,
3478
3521
  n68_login_useragents: xs,
3479
- n70_refresh_tokens: Os
3522
+ n70_refresh_tokens: Os,
3523
+ n71_session_new_fields: Is
3480
3524
  };
3481
- async function Ps(t, e = !1) {
3525
+ async function As(t, e = !1) {
3482
3526
  e && console.log("migrating...");
3483
- const r = new Fe(Le), a = new ve({
3527
+ const a = new Fe(Le), r = new ve({
3484
3528
  db: t,
3485
- provider: r
3486
- }), { error: o, results: n } = await a.migrateToLatest();
3529
+ provider: a
3530
+ }), { error: o, results: n } = await r.migrateToLatest();
3487
3531
  if (n == null || n.forEach((s) => {
3488
3532
  s.status === "Success" ? e && console.log(
3489
3533
  `migration "${s.migrationName}" was executed successfully`
@@ -3491,41 +3535,41 @@ async function Ps(t, e = !1) {
3491
3535
  }), o)
3492
3536
  throw console.error("failed to migrate"), console.error(o), o;
3493
3537
  }
3494
- async function js(t) {
3538
+ async function Fs(t) {
3495
3539
  console.log("migrating...");
3496
- const e = new Fe(Le), r = new ve({
3540
+ const e = new Fe(Le), a = new ve({
3497
3541
  db: t,
3498
3542
  provider: e
3499
- }), { error: a, results: o } = await r.migrateDown();
3543
+ }), { error: r, results: o } = await a.migrateDown();
3500
3544
  if (o == null || o.forEach((n) => {
3501
3545
  n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
3502
- }), a)
3503
- throw console.error("failed to migrate"), console.error(a), a;
3546
+ }), r)
3547
+ throw console.error("failed to migrate"), console.error(r), r;
3504
3548
  }
3505
- function Ms(t) {
3549
+ function Ls(t) {
3506
3550
  return {
3507
3551
  applications: Dt(t),
3508
3552
  branding: qt(t),
3509
3553
  clients: Et(t),
3510
3554
  codes: Tt(t),
3511
3555
  connections: Lt(t),
3512
- emailProviders: wr(t),
3556
+ emailProviders: wa(t),
3513
3557
  domains: Qt(t),
3514
- hooks: er(t),
3558
+ hooks: ea(t),
3515
3559
  keys: Ut(t),
3516
- logins: ur(t),
3560
+ logins: ua(t),
3517
3561
  logs: ct(t),
3518
3562
  passwords: yt(t),
3519
- promptSettings: fr(t),
3520
- refreshTokens: xr(t),
3563
+ promptSettings: fa(t),
3564
+ refreshTokens: xa(t),
3521
3565
  sessions: _t(t),
3522
3566
  tenants: nt(t),
3523
- themes: sr(t),
3567
+ themes: sa(t),
3524
3568
  users: Xe(t)
3525
3569
  };
3526
3570
  }
3527
3571
  export {
3528
- Ms as default,
3529
- js as migrateDown,
3530
- Ps as migrateToLatest
3572
+ Ls as default,
3573
+ Fs as migrateDown,
3574
+ As as migrateToLatest
3531
3575
  };