@authhero/kysely-adapter 10.16.0 → 10.18.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.
@@ -4,7 +4,7 @@ var ue = (t) => {
4
4
  };
5
5
  var Ee = (t, e, a) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
6
  var M = (t, e, a) => Ee(t, typeof e != "symbol" ? e + "" : e, a), U = (t, e, a) => e.has(t) || ue("Cannot " + a);
7
- var c = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), F = (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);
7
+ var c = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), F = (t, e, a, n) => (U(t, e, "write to private field"), n ? n.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
8
8
  import { parseUserId as Z, codeSchema as Ke, connectionSchema as Re, loginSessionSchema as Ue, promptSettingSchema as Be, formSchema as K } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var V = class extends Error {
@@ -25,8 +25,8 @@ var V = class extends Error {
25
25
  };
26
26
  function Qe(t) {
27
27
  return async (e, a) => {
28
- const { identities: r, ...n } = a, o = {
29
- ...n,
28
+ const { identities: n, ...r } = a, o = {
29
+ ...r,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
@@ -77,41 +77,41 @@ function pe(t) {
77
77
  }
78
78
  function qe(t) {
79
79
  return async (e, a) => {
80
- const [r, n] = await Promise.all([
80
+ const [n, r] = await Promise.all([
81
81
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
82
82
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
83
83
  ]);
84
- if (!r)
84
+ if (!n)
85
85
  return null;
86
- const { tenant_id: o, ...s } = r, l = {
86
+ const { tenant_id: o, ...s } = n, d = {
87
87
  ...s,
88
- email: r.email || "",
89
- email_verified: r.email_verified === 1,
90
- is_social: r.is_social === 1,
91
- app_metadata: JSON.parse(r.app_metadata),
92
- user_metadata: JSON.parse(r.user_metadata),
88
+ email: n.email || "",
89
+ email_verified: n.email_verified === 1,
90
+ is_social: n.is_social === 1,
91
+ app_metadata: JSON.parse(n.app_metadata),
92
+ user_metadata: JSON.parse(n.user_metadata),
93
93
  identities: [
94
94
  {
95
- connection: r.connection,
96
- provider: r.provider,
97
- user_id: Z(r.user_id).id,
98
- isSocial: !!r.is_social
95
+ connection: n.connection,
96
+ provider: n.provider,
97
+ user_id: Z(n.user_id).id,
98
+ isSocial: !!n.is_social
99
99
  },
100
- ...n.map(pe)
100
+ ...r.map(pe)
101
101
  ]
102
102
  };
103
- return f(l);
103
+ return f(d);
104
104
  };
105
105
  }
106
- function T(t, e, a, r) {
106
+ function T(t, e, a, n) {
107
107
  return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
108
- let s = o.startsWith("-"), l, d, h, m;
109
- return o.startsWith("-_exists_:") ? (l = o.substring(10), h = !0, s = !0) : o.startsWith("_exists_:") ? (l = o.substring(9), h = !0, s = !1) : o.includes(":") ? (s = o.startsWith("-"), [l, d] = s ? o.substring(1).split(":") : o.split(":"), h = !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 = o, h = !1), { key: l, value: d, isNegation: s, isExistsQuery: h, operator: m };
110
- }).forEach(({ key: o, value: s, isNegation: l, isExistsQuery: d, operator: h }) => {
108
+ let s = o.startsWith("-"), d, l, h, m;
109
+ return o.startsWith("-_exists_:") ? (d = o.substring(10), h = !0, s = !0) : o.startsWith("_exists_:") ? (d = o.substring(9), h = !0, s = !1) : o.includes(":") ? (s = o.startsWith("-"), [d, l] = s ? o.substring(1).split(":") : o.split(":"), h = !1, l.startsWith(">=") ? (m = ">=", l = l.substring(2)) : l.startsWith(">") ? (m = ">", l = l.substring(1)) : l.startsWith("<=") ? (m = "<=", l = l.substring(2)) : l.startsWith("<") ? (m = "<", l = l.substring(1)) : m = "=") : (d = null, l = o, h = !1), { key: d, value: l, isNegation: s, isExistsQuery: h, operator: m };
110
+ }).forEach(({ key: o, value: s, isNegation: d, isExistsQuery: l, operator: h }) => {
111
111
  if (o)
112
- if (d)
113
- l ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
114
- else if (l)
112
+ if (l)
113
+ d ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
114
+ else if (d)
115
115
  switch (h) {
116
116
  case ">":
117
117
  e = e.where(o, "<=", s);
@@ -134,7 +134,7 @@ function T(t, e, a, r) {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
136
136
  (w) => w.or(
137
- r.map((x) => w(m(x), "like", `%${s}%`))
137
+ n.map((x) => w(m(x), "like", `%${s}%`))
138
138
  )
139
139
  );
140
140
  }
@@ -149,13 +149,13 @@ function Ve(t) {
149
149
  per_page: 50,
150
150
  include_totals: !1
151
151
  }) => {
152
- let r = t.selectFrom("users").where("users.tenant_id", "=", e);
153
- if (a.q && (r = T(t, r, a.q, ["email", "name"])), a.sort && a.sort.sort_by) {
152
+ let n = t.selectFrom("users").where("users.tenant_id", "=", e);
153
+ if (a.q && (n = T(t, n, a.q, ["email", "name"])), a.sort && a.sort.sort_by) {
154
154
  const { ref: m } = t.dynamic;
155
- r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
155
+ n = n.orderBy(m(a.sort.sort_by), a.sort.sort_order);
156
156
  }
157
- const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.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 = o.map((m) => {
158
- const w = l.filter(
157
+ const o = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.map((m) => m.user_id), d = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], l = o.map((m) => {
158
+ const w = d.filter(
159
159
  (x) => x.linked_to === m.user_id
160
160
  );
161
161
  return f({
@@ -174,9 +174,9 @@ function Ve(t) {
174
174
  ...w.map(pe)
175
175
  ]
176
176
  });
177
- }), { count: h } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
177
+ }), { count: h } = await n.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
178
178
  return {
179
- users: d,
179
+ users: l,
180
180
  start: a.page * a.per_page,
181
181
  limit: a.per_page,
182
182
  length: b(h)
@@ -186,47 +186,47 @@ function Ve(t) {
186
186
  function We(t) {
187
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
- function j(t, e = "", a = {}) {
190
- for (let r in t)
191
- if (Object.prototype.hasOwnProperty.call(t, r)) {
192
- const n = e ? `${e}_${r}` : r, o = t[r];
193
- typeof o == "object" && o !== null && !Array.isArray(o) ? j(o, n, a) : typeof o == "boolean" ? a[n] = o ? 1 : 0 : a[n] = o;
189
+ function P(t, e = "", a = {}) {
190
+ for (let n in t)
191
+ if (Object.prototype.hasOwnProperty.call(t, n)) {
192
+ const r = e ? `${e}_${n}` : n, o = t[n];
193
+ typeof o == "object" && o !== null && !Array.isArray(o) ? P(o, r, a) : typeof o == "boolean" ? a[r] = o ? 1 : 0 : a[r] = o;
194
194
  }
195
195
  return a;
196
196
  }
197
197
  function Ge(t, e) {
198
198
  const a = {};
199
- for (const [r, n] of Object.entries(t)) {
199
+ for (const [n, r] of Object.entries(t)) {
200
200
  const o = e.find(
201
- (s) => r.startsWith(`${s}_`)
201
+ (s) => n.startsWith(`${s}_`)
202
202
  );
203
203
  if (!o)
204
- a[r] = n;
204
+ a[n] = r;
205
205
  else {
206
- const s = r.slice(o.length + 1);
206
+ const s = n.slice(o.length + 1);
207
207
  a[o] = {
208
208
  ...a[o],
209
- [s]: n
209
+ [s]: r
210
210
  };
211
211
  }
212
212
  }
213
213
  return a;
214
214
  }
215
215
  function He(t) {
216
- return async (e, a, r) => {
217
- const n = j({
218
- ...r,
216
+ return async (e, a, n) => {
217
+ const r = P({
218
+ ...n,
219
219
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
220
- app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
221
- user_metadata: r.user_metadata ? JSON.stringify(r.user_metadata) : void 0
220
+ app_metadata: n.app_metadata ? JSON.stringify(n.app_metadata) : void 0,
221
+ user_metadata: n.user_metadata ? JSON.stringify(n.user_metadata) : void 0
222
222
  });
223
- return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
223
+ return (await t.updateTable("users").set(r).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
224
224
  };
225
225
  }
226
226
  function Xe(t) {
227
- return async (e, a, r, n) => {
227
+ return async (e, a, n, r) => {
228
228
  const o = { linked_to: null };
229
- return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${n}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
229
+ return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", `${n}|${r}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
230
230
  };
231
231
  }
232
232
  function Ye(t) {
@@ -272,35 +272,35 @@ function at(t) {
272
272
  }) => {
273
273
  let a = t.selectFrom("tenants");
274
274
  if (e.sort && e.sort.sort_by) {
275
- const { ref: l } = t.dynamic;
276
- a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
275
+ const { ref: d } = t.dynamic;
276
+ a = a.orderBy(d(e.sort.sort_by), e.sort.sort_order);
277
277
  }
278
- e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
279
- const n = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
278
+ e.q && (a = a.where((d) => d.or([d("name", "like", `%${e.q}%`)])));
279
+ const r = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
280
280
  if (!e.include_totals)
281
281
  return {
282
- tenants: n
282
+ tenants: r
283
283
  };
284
- const { count: o } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(o);
284
+ const { count: o } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(o);
285
285
  return {
286
- tenants: n.map(f),
286
+ tenants: r.map(f),
287
287
  start: (e.page - 1) * e.per_page,
288
288
  limit: e.per_page,
289
289
  length: s
290
290
  };
291
291
  };
292
292
  }
293
- function rt(t) {
293
+ function nt(t) {
294
294
  return async (e, a) => {
295
- const r = {
295
+ const n = {
296
296
  ...a,
297
297
  id: e,
298
298
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
299
299
  };
300
- await t.updateTable("tenants").set(r).where("id", "=", e).execute();
300
+ await t.updateTable("tenants").set(n).where("id", "=", e).execute();
301
301
  };
302
302
  }
303
- function nt(t) {
303
+ function rt(t) {
304
304
  return async (e) => (await t.deleteFrom("tenants").where("tenants.id", "=", e).execute()).length === 1;
305
305
  }
306
306
  function ot(t) {
@@ -308,8 +308,8 @@ function ot(t) {
308
308
  create: et(t),
309
309
  get: tt(t),
310
310
  list: at(t),
311
- update: rt(t),
312
- remove: nt(t)
311
+ update: nt(t),
312
+ remove: rt(t)
313
313
  };
314
314
  }
315
315
  function me(t) {
@@ -318,22 +318,22 @@ function me(t) {
318
318
  const st = 1024;
319
319
  function it(t) {
320
320
  return async (e, a) => {
321
- var n, o, s;
322
- const r = {
321
+ var r, o, s;
322
+ const n = {
323
323
  id: S(),
324
324
  ...a,
325
325
  user_agent: a.user_agent.slice(0, st)
326
326
  };
327
327
  return await t.insertInto("logs").values({
328
- ...r,
328
+ ...n,
329
329
  // Truncate long strings to avoid database errors
330
- description: (n = r.description) == null ? void 0 : n.substring(0, 256),
330
+ description: (r = n.description) == null ? void 0 : r.substring(0, 256),
331
331
  isMobile: a.isMobile ? 1 : 0,
332
332
  tenant_id: e,
333
333
  scope: (o = a.scope) == null ? void 0 : o.join(","),
334
334
  auth0_client: me(a.auth0_client),
335
335
  details: (s = me(a.details)) == null ? void 0 : s.substring(0, 8192)
336
- }).execute(), r;
336
+ }).execute(), n;
337
337
  };
338
338
  }
339
339
  function he(t) {
@@ -358,24 +358,24 @@ function ge(t) {
358
358
  _id: t.id
359
359
  };
360
360
  }
361
- function dt(t) {
361
+ function lt(t) {
362
362
  return async (e, a = {
363
363
  page: 0,
364
364
  per_page: 50,
365
365
  include_totals: !1
366
366
  }) => {
367
- let r = t.selectFrom("logs").where("logs.tenant_id", "=", e);
368
- a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
369
- let n = r;
367
+ let n = t.selectFrom("logs").where("logs.tenant_id", "=", e);
368
+ a.q && (n = T(t, n, a.q, ["user_id", "ip"]));
369
+ let r = n;
370
370
  if (a.sort && a.sort.sort_by) {
371
- const { ref: l } = t.dynamic;
372
- n = n.orderBy(
373
- l(a.sort.sort_by),
371
+ const { ref: d } = t.dynamic;
372
+ r = r.orderBy(
373
+ d(a.sort.sort_by),
374
374
  a.sort.sort_order
375
375
  );
376
376
  }
377
- n = n.offset(a.page * a.per_page).limit(a.per_page);
378
- const o = await n.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
377
+ r = r.offset(a.page * a.per_page).limit(a.per_page);
378
+ const o = await r.selectAll().execute(), { count: s } = await n.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
379
379
  return {
380
380
  logs: o.map(ge),
381
381
  start: a.page * a.per_page,
@@ -384,27 +384,27 @@ function dt(t) {
384
384
  };
385
385
  };
386
386
  }
387
- function lt(t) {
387
+ function dt(t) {
388
388
  return async (e, a) => {
389
- const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
390
- return r ? ge(r) : null;
389
+ const n = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
390
+ return n ? ge(n) : null;
391
391
  };
392
392
  }
393
393
  function ct(t) {
394
394
  return {
395
395
  create: it(t),
396
- list: dt(t),
397
- get: lt(t)
396
+ list: lt(t),
397
+ get: dt(t)
398
398
  };
399
399
  }
400
400
  function ut(t) {
401
401
  return async (e, a) => {
402
- const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
403
- if (!r)
402
+ const n = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
403
+ if (!n)
404
404
  return null;
405
- const { tenant_id: n, device: o, clients: s, ...l } = r;
405
+ const { tenant_id: r, device: o, clients: s, ...d } = n;
406
406
  return {
407
- ...l,
407
+ ...d,
408
408
  device: JSON.parse(o),
409
409
  clients: JSON.parse(s)
410
410
  };
@@ -412,7 +412,7 @@ function ut(t) {
412
412
  }
413
413
  function mt(t) {
414
414
  return async (e, a) => {
415
- const r = {
415
+ const n = {
416
416
  ...a,
417
417
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
418
418
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -420,25 +420,25 @@ function mt(t) {
420
420
  last_interaction_at: (/* @__PURE__ */ new Date()).toISOString()
421
421
  };
422
422
  return await t.insertInto("sessions").values({
423
- ...r,
423
+ ...n,
424
424
  tenant_id: e,
425
425
  device: JSON.stringify(a.device),
426
426
  clients: JSON.stringify(a.clients)
427
- }).execute(), r;
427
+ }).execute(), n;
428
428
  };
429
429
  }
430
430
  function ht(t) {
431
431
  return async (e, a) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
432
432
  }
433
433
  function _t(t) {
434
- return async (e, a, r) => {
435
- const n = {
436
- ...r,
434
+ return async (e, a, n) => {
435
+ const r = {
436
+ ...n,
437
437
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
438
- device: r.device ? JSON.stringify(r.device) : void 0,
439
- clients: r.clients ? JSON.stringify(r.clients) : void 0
438
+ device: n.device ? JSON.stringify(n.device) : void 0,
439
+ clients: n.clients ? JSON.stringify(n.clients) : void 0
440
440
  };
441
- return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
441
+ return !!(await t.updateTable("sessions").set(r).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
442
442
  };
443
443
  }
444
444
  function ft(t) {
@@ -447,27 +447,27 @@ function ft(t) {
447
447
  per_page: 50,
448
448
  include_totals: !1
449
449
  }) => {
450
- let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
451
- a.q && (r = T(t, r, a.q, ["user_id", "session_id"]));
452
- let n = r;
450
+ let n = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
451
+ a.q && (n = T(t, n, a.q, ["user_id", "session_id"]));
452
+ let r = n;
453
453
  if (a.sort && a.sort.sort_by) {
454
- const { ref: d } = t.dynamic;
455
- n = n.orderBy(
456
- d(a.sort.sort_by),
454
+ const { ref: l } = t.dynamic;
455
+ r = r.orderBy(
456
+ l(a.sort.sort_by),
457
457
  a.sort.sort_order
458
458
  );
459
459
  }
460
- n = n.offset(a.page * a.per_page).limit(a.per_page);
461
- const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
460
+ r = r.offset(a.page * a.per_page).limit(a.per_page);
461
+ const o = await r.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = b(s);
462
462
  return {
463
- sessions: o.map((d) => ({
464
- ...d,
465
- device: JSON.parse(d.device),
466
- clients: JSON.parse(d.clients)
463
+ sessions: o.map((l) => ({
464
+ ...l,
465
+ device: JSON.parse(l.device),
466
+ clients: JSON.parse(l.clients)
467
467
  })),
468
468
  start: a.page * a.per_page,
469
469
  limit: a.per_page,
470
- length: l
470
+ length: d
471
471
  };
472
472
  };
473
473
  }
@@ -482,24 +482,24 @@ function pt(t) {
482
482
  }
483
483
  function gt(t) {
484
484
  return async (e, a) => {
485
- const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
486
- if (!r)
485
+ const n = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
486
+ if (!n)
487
487
  return null;
488
- const { tenant_id: n, ...o } = r;
488
+ const { tenant_id: r, ...o } = n;
489
489
  return o;
490
490
  };
491
491
  }
492
492
  function yt(t) {
493
493
  return async (e, a) => {
494
- const r = {
494
+ const n = {
495
495
  ...a,
496
496
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
497
497
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
498
498
  };
499
499
  return await t.insertInto("passwords").values({
500
- ...r,
500
+ ...n,
501
501
  tenant_id: e
502
- }).execute(), r;
502
+ }).execute(), n;
503
503
  };
504
504
  }
505
505
  function wt(t) {
@@ -521,12 +521,12 @@ function Nt(t) {
521
521
  per_page: 50,
522
522
  include_totals: !1
523
523
  }) => {
524
- let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
525
- a.q && (r = T(t, r, a.q, ["code", "login_id"]));
526
- const o = 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();
524
+ let n = t.selectFrom("codes").where("codes.tenant_id", "=", e);
525
+ a.q && (n = T(t, n, a.q, ["code", "login_id"]));
526
+ const o = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
527
527
  return {
528
- codes: o.map((d) => {
529
- const { tenant_id: h, ...m } = d;
528
+ codes: o.map((l) => {
529
+ const { tenant_id: h, ...m } = l;
530
530
  return Ke.parse(f(m));
531
531
  }),
532
532
  start: a.page * a.per_page,
@@ -537,24 +537,24 @@ function Nt(t) {
537
537
  }
538
538
  function Ct(t) {
539
539
  return async (e, a) => {
540
- const r = {
540
+ const n = {
541
541
  ...a,
542
542
  created_at: (/* @__PURE__ */ new Date()).toISOString()
543
543
  };
544
544
  return await t.insertInto("codes").values({
545
- ...r,
545
+ ...n,
546
546
  tenant_id: e
547
- }).execute(), r;
547
+ }).execute(), n;
548
548
  };
549
549
  }
550
550
  function bt(t) {
551
551
  return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
552
552
  }
553
553
  function xt(t) {
554
- return async (e, a, r) => {
555
- let n = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
556
- e.length && (n = n.where("codes.tenant_id", "=", e));
557
- const o = await n.selectAll().executeTakeFirst();
554
+ return async (e, a, n) => {
555
+ let r = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", n);
556
+ e.length && (r = r.where("codes.tenant_id", "=", e));
557
+ const o = await r.selectAll().executeTakeFirst();
558
558
  return o ? f(o) : null;
559
559
  };
560
560
  }
@@ -572,22 +572,22 @@ function St(t) {
572
572
  }
573
573
  function Ot(t) {
574
574
  return async (e, a) => {
575
- const r = {
575
+ const n = {
576
576
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
577
577
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
578
578
  ...a
579
- }, n = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
579
+ }, r = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), d = JSON.stringify(a.allowed_logout_urls), l = JSON.stringify(a.allowed_clients);
580
580
  return await t.insertInto("applications").values({
581
- ...r,
581
+ ...n,
582
582
  tenant_id: e,
583
583
  disable_sign_ups: a.disable_sign_ups ? 1 : 0,
584
584
  addons: a.addons ? JSON.stringify(a.addons) : "{}",
585
585
  callbacks: o,
586
- allowed_origins: n,
586
+ allowed_origins: r,
587
587
  web_origins: s,
588
- allowed_logout_urls: l,
589
- allowed_clients: d
590
- }).execute(), r;
588
+ allowed_logout_urls: d,
589
+ allowed_clients: l
590
+ }).execute(), n;
591
591
  };
592
592
  }
593
593
  function kt(t) {
@@ -606,15 +606,15 @@ function kt(t) {
606
606
  }
607
607
  function $t(t) {
608
608
  return async (e, a) => {
609
- const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
610
- return r ? f({
611
- ...r,
612
- disable_sign_ups: !!r.disable_sign_ups,
613
- addons: JSON.parse(r.addons),
614
- callbacks: JSON.parse(r.callbacks),
615
- allowed_origins: JSON.parse(r.allowed_origins),
616
- web_origins: JSON.parse(r.web_origins),
617
- allowed_logout_urls: JSON.parse(r.allowed_logout_urls)
609
+ const n = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
610
+ return n ? f({
611
+ ...n,
612
+ disable_sign_ups: !!n.disable_sign_ups,
613
+ addons: JSON.parse(n.addons),
614
+ callbacks: JSON.parse(n.callbacks),
615
+ allowed_origins: JSON.parse(n.allowed_origins),
616
+ web_origins: JSON.parse(n.web_origins),
617
+ allowed_logout_urls: JSON.parse(n.allowed_logout_urls)
618
618
  }) : null;
619
619
  };
620
620
  }
@@ -622,22 +622,22 @@ function Dt(t) {
622
622
  return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
623
623
  }
624
624
  function It(t) {
625
- return async (e, a, r) => {
626
- const n = {
627
- ...r,
625
+ return async (e, a, n) => {
626
+ const r = {
627
+ ...n,
628
628
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
629
- allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
630
- callbacks: r.callbacks ? JSON.stringify(r.callbacks) : void 0,
631
- web_origins: r.web_origins ? JSON.stringify(r.web_origins) : void 0,
632
- allowed_logout_urls: r.allowed_logout_urls ? JSON.stringify(r.allowed_logout_urls) : void 0,
633
- allowed_clients: r.allowed_clients ? JSON.stringify(r.allowed_clients) : void 0,
634
- addons: r.addons ? JSON.stringify(r.addons) : "{}",
635
- disable_sign_ups: r.disable_sign_ups ? 1 : 0
629
+ allowed_origins: n.allowed_origins ? JSON.stringify(n.allowed_origins) : void 0,
630
+ callbacks: n.callbacks ? JSON.stringify(n.callbacks) : void 0,
631
+ web_origins: n.web_origins ? JSON.stringify(n.web_origins) : void 0,
632
+ allowed_logout_urls: n.allowed_logout_urls ? JSON.stringify(n.allowed_logout_urls) : void 0,
633
+ allowed_clients: n.allowed_clients ? JSON.stringify(n.allowed_clients) : void 0,
634
+ addons: n.addons ? JSON.stringify(n.addons) : "{}",
635
+ disable_sign_ups: n.disable_sign_ups ? 1 : 0
636
636
  };
637
- return await t.updateTable("applications").set(n).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
637
+ return await t.updateTable("applications").set(r).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
638
638
  };
639
639
  }
640
- function Pt(t) {
640
+ function jt(t) {
641
641
  return {
642
642
  create: Ot(t),
643
643
  list: kt(t),
@@ -646,20 +646,20 @@ function Pt(t) {
646
646
  update: It(t)
647
647
  };
648
648
  }
649
- function jt(t) {
649
+ function Pt(t) {
650
650
  return async (e, a) => {
651
- const r = {
651
+ const n = {
652
652
  id: S(),
653
653
  ...a,
654
654
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
655
655
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
656
656
  };
657
657
  return await t.insertInto("connections").values({
658
- ...r,
658
+ ...n,
659
659
  // The connection options will have many different properties depending on the strategy
660
- options: JSON.stringify(r.options || {}),
660
+ options: JSON.stringify(n.options || {}),
661
661
  tenant_id: e
662
- }).execute(), r;
662
+ }).execute(), n;
663
663
  };
664
664
  }
665
665
  function Mt(t) {
@@ -668,19 +668,19 @@ function Mt(t) {
668
668
  per_page: 50,
669
669
  include_totals: !1
670
670
  }) => {
671
- let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
672
- a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
673
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
674
- (d) => f({
675
- ...d,
676
- options: JSON.parse(d.options)
671
+ let n = t.selectFrom("connections").where("connections.tenant_id", "=", e);
672
+ a.q && (n = T(t, n, a.q, ["user_id", "ip"]));
673
+ const s = (await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
674
+ (l) => f({
675
+ ...l,
676
+ options: JSON.parse(l.options)
677
677
  })
678
- ), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
678
+ ), { count: d } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
679
679
  return {
680
680
  connections: s,
681
681
  start: a.page * a.per_page,
682
682
  limit: a.per_page,
683
- length: b(l)
683
+ length: b(d)
684
684
  };
685
685
  };
686
686
  }
@@ -689,28 +689,28 @@ function Ft(t) {
689
689
  }
690
690
  function At(t) {
691
691
  return async (e, a) => {
692
- const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
693
- return r ? f({
694
- ...r,
695
- options: JSON.parse(r.options)
692
+ const n = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
693
+ return n ? f({
694
+ ...n,
695
+ options: JSON.parse(n.options)
696
696
  }) : null;
697
697
  };
698
698
  }
699
699
  function Lt(t) {
700
- return async (e, a, r) => {
701
- const n = {
702
- ...r,
700
+ return async (e, a, n) => {
701
+ const r = {
702
+ ...n,
703
703
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
704
704
  };
705
705
  return await t.updateTable("connections").set({
706
- ...n,
707
- options: n.options ? JSON.stringify(n.options) : void 0
706
+ ...r,
707
+ options: r.options ? JSON.stringify(r.options) : void 0
708
708
  }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
709
709
  };
710
710
  }
711
711
  function zt(t) {
712
712
  return {
713
- create: jt(t),
713
+ create: Pt(t),
714
714
  get: At(t),
715
715
  list: Mt(t),
716
716
  remove: Ft(t),
@@ -723,13 +723,13 @@ function Jt(t) {
723
723
  const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
724
724
  if (!a)
725
725
  return null;
726
- const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
727
- if (!r)
726
+ const n = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
727
+ if (!n)
728
728
  throw new V(404, { message: "Tenant not found" });
729
- const n = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
729
+ const r = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
730
730
  return {
731
731
  ...a,
732
- connections: n.map(
732
+ connections: r.map(
733
733
  (s) => Re.parse(
734
734
  f({
735
735
  ...s,
@@ -743,7 +743,7 @@ function Jt(t) {
743
743
  web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
744
744
  allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
745
745
  allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
746
- tenant: f(r),
746
+ tenant: f(n),
747
747
  // this is really an integer in the database
748
748
  disable_sign_ups: !!a.disable_sign_ups
749
749
  };
@@ -775,25 +775,25 @@ function Ut(t) {
775
775
  }
776
776
  function Bt(t) {
777
777
  return async (e, a) => {
778
- const r = {
778
+ const n = {
779
779
  custom_domain_id: S(),
780
780
  status: "pending",
781
781
  primary: !1,
782
782
  ...a
783
783
  };
784
784
  return await t.insertInto("custom_domains").values({
785
- ...r,
785
+ ...n,
786
786
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
787
787
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
788
788
  tenant_id: e,
789
- primary: r.primary ? 1 : 0
790
- }).execute(), r;
789
+ primary: n.primary ? 1 : 0
790
+ }).execute(), n;
791
791
  };
792
792
  }
793
793
  function Qt(t) {
794
- return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((r) => ({
795
- ...r,
796
- primary: r.primary === 1
794
+ return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((n) => ({
795
+ ...n,
796
+ primary: n.primary === 1
797
797
  }));
798
798
  }
799
799
  function qt(t) {
@@ -801,21 +801,21 @@ function qt(t) {
801
801
  }
802
802
  function Vt(t) {
803
803
  return async (e, a) => {
804
- const r = await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).selectAll().executeTakeFirst();
805
- return r ? {
806
- ...r,
807
- primary: r.primary === 1
804
+ const n = await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).selectAll().executeTakeFirst();
805
+ return n ? {
806
+ ...n,
807
+ primary: n.primary === 1
808
808
  } : null;
809
809
  };
810
810
  }
811
811
  function Wt(t) {
812
- return async (e, a, r) => {
813
- const n = {
814
- ...r,
812
+ return async (e, a, n) => {
813
+ const r = {
814
+ ...n,
815
815
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
816
- primary: r.primary ? 1 : 0
816
+ primary: n.primary ? 1 : 0
817
817
  };
818
- return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
818
+ return (await t.updateTable("custom_domains").set(r).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
819
819
  };
820
820
  }
821
821
  function Gt(t) {
@@ -843,24 +843,24 @@ function Xt(t) {
843
843
  if (!a)
844
844
  return null;
845
845
  const {
846
- tenant_id: r,
847
- colors_primary: n,
846
+ tenant_id: n,
847
+ colors_primary: r,
848
848
  colors_page_background_type: o,
849
849
  colors_page_background_start: s,
850
- colors_page_background_end: l,
851
- colors_page_background_angle_dev: d,
850
+ colors_page_background_end: d,
851
+ colors_page_background_angle_dev: l,
852
852
  font_url: h,
853
853
  ...m
854
854
  } = a;
855
855
  return f({
856
856
  ...m,
857
857
  colors: {
858
- primary: n,
858
+ primary: r,
859
859
  page_background: {
860
860
  type: o,
861
861
  start: s,
862
- end: l,
863
- angle_deg: d
862
+ end: d,
863
+ angle_deg: l
864
864
  }
865
865
  },
866
866
  font: h ? { url: h } : void 0
@@ -869,14 +869,14 @@ function Xt(t) {
869
869
  }
870
870
  function Yt(t) {
871
871
  return async (e, a) => {
872
- var s, l, d, h, m, w, x, ee, te, ae, re, ne, oe, se, ie, de, le, ce;
873
- const { colors: r, font: n, ...o } = a;
872
+ var s, d, l, h, m, w, x, ee, te, ae, ne, re, oe, se, ie, le, de, ce;
873
+ const { colors: n, font: r, ...o } = a;
874
874
  try {
875
875
  await t.insertInto("branding").values({
876
876
  ...o,
877
- colors_primary: r == null ? void 0 : r.primary,
878
- colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
879
- colors_page_background_start: (h = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : h.start,
877
+ colors_primary: n == null ? void 0 : n.primary,
878
+ colors_page_background_type: (d = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : d.type,
879
+ colors_page_background_start: (h = (l = a.colors) == null ? void 0 : l.page_background) == null ? void 0 : h.start,
880
880
  colors_page_background_end: (w = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : w.end,
881
881
  colors_page_background_angle_dev: (ee = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : ee.angle_deg,
882
882
  font_url: (te = a.font) == null ? void 0 : te.url,
@@ -885,11 +885,11 @@ function Yt(t) {
885
885
  } catch {
886
886
  await t.updateTable("branding").set({
887
887
  ...o,
888
- colors_primary: r == null ? void 0 : r.primary,
889
- colors_page_background_type: (re = (ae = a.colors) == null ? void 0 : ae.page_background) == null ? void 0 : re.type,
890
- colors_page_background_start: (oe = (ne = a.colors) == null ? void 0 : ne.page_background) == null ? void 0 : oe.start,
888
+ colors_primary: n == null ? void 0 : n.primary,
889
+ colors_page_background_type: (ne = (ae = a.colors) == null ? void 0 : ae.page_background) == null ? void 0 : ne.type,
890
+ colors_page_background_start: (oe = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : oe.start,
891
891
  colors_page_background_end: (ie = (se = a.colors) == null ? void 0 : se.page_background) == null ? void 0 : ie.end,
892
- colors_page_background_angle_dev: (le = (de = a.colors) == null ? void 0 : de.page_background) == null ? void 0 : le.angle_deg,
892
+ colors_page_background_angle_dev: (de = (le = a.colors) == null ? void 0 : le.page_background) == null ? void 0 : de.angle_deg,
893
893
  font_url: (ce = a.font) == null ? void 0 : ce.url
894
894
  }).where("tenant_id", "=", e).execute();
895
895
  }
@@ -907,12 +907,12 @@ function ea(t) {
907
907
  per_page: 50,
908
908
  include_totals: !1
909
909
  }) => {
910
- let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
911
- a.q && (r = T(t, r, a.q, ["url", "form_id"]));
912
- const o = 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();
910
+ let n = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
911
+ a.q && (n = T(t, n, a.q, ["url", "form_id"]));
912
+ const o = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
913
913
  return {
914
- hooks: o.map((d) => {
915
- const { tenant_id: h, enabled: m, synchronous: w, ...x } = d;
914
+ hooks: o.map((l) => {
915
+ const { tenant_id: h, enabled: m, synchronous: w, ...x } = l;
916
916
  return f({
917
917
  ...x,
918
918
  enabled: !!m,
@@ -927,98 +927,98 @@ function ea(t) {
927
927
  }
928
928
  function ta(t) {
929
929
  return async (e, a) => {
930
- const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
931
- return r ? f({
932
- ...r,
933
- enabled: !!r.enabled,
934
- synchronous: !!r.synchronous
930
+ const n = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
931
+ return n ? f({
932
+ ...n,
933
+ enabled: !!n.enabled,
934
+ synchronous: !!n.synchronous
935
935
  }) : null;
936
936
  };
937
937
  }
938
938
  function aa(t) {
939
939
  return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
940
940
  }
941
- function ra(t) {
941
+ function na(t) {
942
942
  return async (e, a) => {
943
- const r = {
943
+ const n = {
944
944
  hook_id: S(),
945
945
  ...a,
946
946
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
947
947
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
948
948
  };
949
949
  return await t.insertInto("hooks").values({
950
- ...r,
950
+ ...n,
951
951
  tenant_id: e,
952
952
  enabled: a.enabled ? 1 : 0,
953
953
  synchronous: a.synchronous ? 1 : 0
954
- }).execute(), r;
954
+ }).execute(), n;
955
955
  };
956
956
  }
957
- function na(t) {
958
- return async (e, a, r) => {
959
- const n = {
960
- ...r,
957
+ function ra(t) {
958
+ return async (e, a, n) => {
959
+ const r = {
960
+ ...n,
961
961
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
962
- enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
963
- synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
962
+ enabled: n.enabled !== void 0 ? n.enabled ? 1 : 0 : void 0,
963
+ synchronous: n.enabled !== void 0 ? n.synchronous ? 1 : 0 : void 0
964
964
  };
965
- return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
965
+ return await t.updateTable("hooks").set(r).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
966
966
  };
967
967
  }
968
968
  function oa(t) {
969
969
  return {
970
- create: ra(t),
970
+ create: na(t),
971
971
  get: ta(t),
972
972
  list: ea(t),
973
- update: na(t),
973
+ update: ra(t),
974
974
  remove: aa(t)
975
975
  };
976
976
  }
977
977
  function sa(t) {
978
978
  return async (e, a) => {
979
- const r = {
979
+ const n = {
980
980
  themeId: S(),
981
981
  ...a,
982
982
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
983
983
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
984
984
  };
985
- return await t.insertInto("themes").values({ ...j(r), tenant_id: e }).execute(), r;
985
+ return await t.insertInto("themes").values({ ...P(n), tenant_id: e }).execute(), n;
986
986
  };
987
987
  }
988
988
  function ia(t) {
989
989
  return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
990
990
  }
991
- function da(t) {
991
+ function la(t) {
992
992
  return async (e, a) => {
993
- const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
994
- return r ? f(r) : null;
993
+ const n = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
994
+ return n ? f(n) : null;
995
995
  };
996
996
  }
997
- function la(t) {
998
- return async (e, a, r) => {
999
- const n = j({
1000
- ...r,
997
+ function da(t) {
998
+ return async (e, a, n) => {
999
+ const r = P({
1000
+ ...n,
1001
1001
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1002
1002
  });
1003
- return await t.updateTable("themes").set(n).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1003
+ return await t.updateTable("themes").set(r).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1004
1004
  };
1005
1005
  }
1006
1006
  function ca(t) {
1007
1007
  return {
1008
1008
  create: sa(t),
1009
- get: da(t),
1009
+ get: la(t),
1010
1010
  remove: ia(t),
1011
- update: la(t)
1011
+ update: da(t)
1012
1012
  };
1013
1013
  }
1014
1014
  function ua(t) {
1015
1015
  return async (e, a) => {
1016
- const r = (/* @__PURE__ */ new Date()).toISOString(), n = await t.selectFrom("login_sessions").where("login_sessions.expires_at", ">", r).where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1017
- return n ? Ue.parse(
1016
+ const n = (/* @__PURE__ */ new Date()).toISOString(), r = await t.selectFrom("login_sessions").where("login_sessions.expires_at", ">", n).where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1017
+ return r ? Ue.parse(
1018
1018
  Ge(
1019
1019
  f({
1020
- ...n,
1021
- login_completed: !!n.login_completed
1020
+ ...r,
1021
+ login_completed: !!r.login_completed
1022
1022
  }),
1023
1023
  ["authParams"]
1024
1024
  )
@@ -1027,25 +1027,25 @@ function ua(t) {
1027
1027
  }
1028
1028
  function ma(t) {
1029
1029
  return async (e, a) => {
1030
- var n;
1031
- const r = {
1030
+ var r;
1031
+ const n = {
1032
1032
  id: S(),
1033
1033
  ...a,
1034
- authorization_url: (n = a.authorization_url) == null ? void 0 : n.slice(0, 1024),
1034
+ authorization_url: (r = a.authorization_url) == null ? void 0 : r.slice(0, 1024),
1035
1035
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1036
1036
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1037
1037
  login_completed: !!a.login_completed
1038
1038
  };
1039
1039
  return await t.insertInto("login_sessions").values({
1040
- ...j(r),
1040
+ ...P(n),
1041
1041
  tenant_id: e
1042
- }).execute(), r;
1042
+ }).execute(), n;
1043
1043
  };
1044
1044
  }
1045
1045
  function ha(t) {
1046
- return async (e, a, r) => (await t.updateTable("login_sessions").set(
1047
- j({
1048
- ...r
1046
+ return async (e, a, n) => (await t.updateTable("login_sessions").set(
1047
+ P({
1048
+ ...n
1049
1049
  })
1050
1050
  ).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
1051
1051
  }
@@ -1083,9 +1083,9 @@ function _e(t) {
1083
1083
  function ga(t) {
1084
1084
  return async (e, a) => {
1085
1085
  try {
1086
- const r = Be.parse(a);
1086
+ const n = Be.parse(a);
1087
1087
  await t.insertInto("prompt_settings").values({
1088
- ..._e(r),
1088
+ ..._e(n),
1089
1089
  tenant_id: e
1090
1090
  }).execute();
1091
1091
  } catch {
@@ -1105,15 +1105,15 @@ function wa(t) {
1105
1105
  if (!a)
1106
1106
  return null;
1107
1107
  const {
1108
- tenant_id: r,
1109
- credentials: n,
1108
+ tenant_id: n,
1109
+ credentials: r,
1110
1110
  settings: o,
1111
1111
  enabled: s,
1112
- ...l
1112
+ ...d
1113
1113
  } = a;
1114
1114
  return f({
1115
- ...l,
1116
- credentials: JSON.parse(n),
1115
+ ...d,
1116
+ credentials: JSON.parse(r),
1117
1117
  settings: JSON.parse(o),
1118
1118
  enabled: !!s
1119
1119
  });
@@ -1121,23 +1121,23 @@ function wa(t) {
1121
1121
  }
1122
1122
  function va(t) {
1123
1123
  return async (e, a) => {
1124
- const { credentials: r, settings: n, enabled: o, ...s } = a;
1124
+ const { credentials: n, settings: r, enabled: o, ...s } = a;
1125
1125
  await t.updateTable("email_providers").set({
1126
1126
  ...s,
1127
- credentials: r ? JSON.stringify(r) : void 0,
1128
- settings: n ? JSON.stringify(n) : void 0,
1127
+ credentials: n ? JSON.stringify(n) : void 0,
1128
+ settings: r ? JSON.stringify(r) : void 0,
1129
1129
  enabled: o !== void 0 ? o ? 1 : 0 : void 0
1130
1130
  }).where("tenant_id", "=", e).execute();
1131
1131
  };
1132
1132
  }
1133
1133
  function Na(t) {
1134
1134
  return async (e, a) => {
1135
- const { credentials: r, settings: n, enabled: o, ...s } = a;
1135
+ const { credentials: n, settings: r, enabled: o, ...s } = a;
1136
1136
  await t.insertInto("email_providers").values({
1137
1137
  ...s,
1138
1138
  enabled: o ? 1 : 0,
1139
- credentials: JSON.stringify(r),
1140
- settings: JSON.stringify(n),
1139
+ credentials: JSON.stringify(n),
1140
+ settings: JSON.stringify(r),
1141
1141
  tenant_id: e,
1142
1142
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1143
1143
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1153,42 +1153,42 @@ function Ca(t) {
1153
1153
  }
1154
1154
  function ba(t) {
1155
1155
  return async (e, a) => {
1156
- const r = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", a).selectAll().executeTakeFirst();
1157
- return r ? {
1158
- ...r,
1159
- rotating: !!r.rotating,
1160
- device: r.device ? JSON.parse(r.device) : {},
1161
- resource_servers: r.resource_servers ? JSON.parse(r.resource_servers) : []
1156
+ const n = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", a).selectAll().executeTakeFirst();
1157
+ return n ? {
1158
+ ...n,
1159
+ rotating: !!n.rotating,
1160
+ device: n.device ? JSON.parse(n.device) : {},
1161
+ resource_servers: n.resource_servers ? JSON.parse(n.resource_servers) : []
1162
1162
  } : null;
1163
1163
  };
1164
1164
  }
1165
1165
  function xa(t) {
1166
1166
  return async (e, a) => {
1167
- const r = {
1167
+ const n = {
1168
1168
  ...a,
1169
1169
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1170
1170
  };
1171
1171
  return await t.insertInto("refresh_tokens").values({
1172
- ...r,
1172
+ ...n,
1173
1173
  tenant_id: e,
1174
1174
  rotating: a.rotating ? 1 : 0,
1175
1175
  device: JSON.stringify(a.device),
1176
1176
  resource_servers: JSON.stringify(a.resource_servers)
1177
- }).execute(), { ...a, ...r };
1177
+ }).execute(), { ...a, ...n };
1178
1178
  };
1179
1179
  }
1180
1180
  function Ta(t) {
1181
1181
  return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1182
1182
  }
1183
1183
  function Sa(t) {
1184
- return async (e, a, r) => {
1185
- const n = {
1186
- ...r,
1187
- device: r.device ? JSON.stringify(r.device) : void 0,
1188
- resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
1189
- rotating: r.rotating ? 1 : 0
1184
+ return async (e, a, n) => {
1185
+ const r = {
1186
+ ...n,
1187
+ device: n.device ? JSON.stringify(n.device) : void 0,
1188
+ resource_servers: n.resource_servers ? JSON.stringify(n.resource_servers) : void 0,
1189
+ rotating: n.rotating ? 1 : 0
1190
1190
  };
1191
- return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1191
+ return !!(await t.updateTable("refresh_tokens").set(r).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1192
1192
  };
1193
1193
  }
1194
1194
  function Oa(t) {
@@ -1197,28 +1197,28 @@ function Oa(t) {
1197
1197
  per_page: 50,
1198
1198
  include_totals: !1
1199
1199
  }) => {
1200
- let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1201
- a.q && (r = T(t, r, a.q, ["token", "session_id"]));
1202
- let n = r;
1200
+ let n = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1201
+ a.q && (n = T(t, n, a.q, ["token", "session_id"]));
1202
+ let r = n;
1203
1203
  if (a.sort && a.sort.sort_by) {
1204
- const { ref: d } = t.dynamic;
1205
- n = n.orderBy(
1206
- d(a.sort.sort_by),
1204
+ const { ref: l } = t.dynamic;
1205
+ r = r.orderBy(
1206
+ l(a.sort.sort_by),
1207
1207
  a.sort.sort_order
1208
1208
  );
1209
1209
  }
1210
- n = n.offset(a.page * a.per_page).limit(a.per_page);
1211
- const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
1212
- return {
1213
- refresh_tokens: o.map((d) => ({
1214
- ...d,
1215
- rotating: !!d.rotating,
1216
- device: d.device ? JSON.parse(d.device) : {},
1217
- resource_servers: d.resource_servers ? JSON.parse(d.resource_servers) : []
1210
+ r = r.offset(a.page * a.per_page).limit(a.per_page);
1211
+ const o = await r.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = b(s);
1212
+ return {
1213
+ refresh_tokens: o.map((l) => ({
1214
+ ...l,
1215
+ rotating: !!l.rotating,
1216
+ device: l.device ? JSON.parse(l.device) : {},
1217
+ resource_servers: l.resource_servers ? JSON.parse(l.resource_servers) : []
1218
1218
  })),
1219
1219
  start: a.page * a.per_page,
1220
1220
  limit: a.per_page,
1221
- length: l
1221
+ length: d
1222
1222
  };
1223
1223
  };
1224
1224
  }
@@ -1235,11 +1235,11 @@ function $a(t) {
1235
1235
  return async () => {
1236
1236
  const e = new Date(Date.now() - 864e5).toISOString(), a = new Date(
1237
1237
  Date.now() - 1e3 * 60 * 60 * 24 * 7
1238
- ).toISOString(), r = new Date(
1238
+ ).toISOString(), n = new Date(
1239
1239
  Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
1240
1240
  ).toISOString();
1241
- console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", r).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where("expires_at", "<", a).limit(1e5).execute(), console.log("delete sessions");
1242
- const n = await t.selectFrom("sessions").select("id").where(
1241
+ console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", n).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where("expires_at", "<", a).limit(1e5).execute(), console.log("delete sessions");
1242
+ const r = await t.selectFrom("sessions").select("id").where(
1243
1243
  (o) => o.or([
1244
1244
  o("expires_at", "<", a),
1245
1245
  o("idle_expires_at", "<", a)
@@ -1249,29 +1249,29 @@ function $a(t) {
1249
1249
  "not in",
1250
1250
  t.selectFrom("refresh_tokens").select("session_id")
1251
1251
  ).limit(1e5).execute();
1252
- n.length > 0 && await t.deleteFrom("sessions").where(
1252
+ r.length > 0 && await t.deleteFrom("sessions").where(
1253
1253
  "id",
1254
1254
  "in",
1255
- n.map((o) => o.id)
1255
+ r.map((o) => o.id)
1256
1256
  ).execute(), console.log("cleanup complete");
1257
1257
  };
1258
1258
  }
1259
1259
  function Da(t) {
1260
1260
  return async (e, a) => {
1261
- const r = K.parse({
1261
+ const n = K.parse({
1262
1262
  id: S(),
1263
1263
  ...a,
1264
1264
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1265
1265
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1266
1266
  });
1267
1267
  return await t.insertInto("forms").values({
1268
- ...r,
1268
+ ...n,
1269
1269
  // Store complex objects as JSON strings
1270
- nodes: JSON.stringify(r.nodes || []),
1271
- start: JSON.stringify(r.start || {}),
1272
- ending: JSON.stringify(r.ending || {}),
1270
+ nodes: JSON.stringify(n.nodes || []),
1271
+ start: JSON.stringify(n.start || {}),
1272
+ ending: JSON.stringify(n.ending || {}),
1273
1273
  tenant_id: e
1274
- }).execute(), K.parse(r);
1274
+ }).execute(), K.parse(n);
1275
1275
  };
1276
1276
  }
1277
1277
  function Ia(t) {
@@ -1280,10 +1280,10 @@ function Ia(t) {
1280
1280
  per_page: 50,
1281
1281
  include_totals: !1
1282
1282
  }) => {
1283
- let r = t.selectFrom("forms").where("tenant_id", "=", e);
1284
- a != null && a.q && (r = T(t, r, a.q, []));
1285
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((d) => {
1286
- const h = { ...d };
1283
+ let n = t.selectFrom("forms").where("tenant_id", "=", e);
1284
+ a != null && a.q && (n = T(t, n, a.q, []));
1285
+ const s = (await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((l) => {
1286
+ const h = { ...l };
1287
1287
  if (typeof h.nodes == "string")
1288
1288
  try {
1289
1289
  h.nodes = JSON.parse(h.nodes);
@@ -1300,61 +1300,61 @@ function Ia(t) {
1300
1300
  } catch {
1301
1301
  }
1302
1302
  return K.parse(f(h));
1303
- }), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
1303
+ }), { count: d } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
1304
1304
  return {
1305
1305
  forms: s,
1306
1306
  start: a.page * a.per_page,
1307
1307
  limit: a.per_page,
1308
- length: b(l)
1308
+ length: b(d)
1309
1309
  };
1310
1310
  };
1311
1311
  }
1312
- function Pa(t) {
1312
+ function ja(t) {
1313
1313
  return async (e, a) => {
1314
- const { numDeletedRows: r } = await t.deleteFrom("forms").where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1315
- return r > 0;
1314
+ const { numDeletedRows: n } = await t.deleteFrom("forms").where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1315
+ return n > 0;
1316
1316
  };
1317
1317
  }
1318
- function ja(t) {
1318
+ function Pa(t) {
1319
1319
  return async (e, a) => {
1320
- const r = await t.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1321
- if (!r) return null;
1322
- const n = { ...r };
1323
- if (typeof n.nodes == "string")
1320
+ const n = await t.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1321
+ if (!n) return null;
1322
+ const r = { ...n };
1323
+ if (typeof r.nodes == "string")
1324
1324
  try {
1325
- n.nodes = JSON.parse(n.nodes);
1325
+ r.nodes = JSON.parse(r.nodes);
1326
1326
  } catch {
1327
1327
  }
1328
- if (typeof n.start == "string")
1328
+ if (typeof r.start == "string")
1329
1329
  try {
1330
- n.start = JSON.parse(n.start);
1330
+ r.start = JSON.parse(r.start);
1331
1331
  } catch {
1332
1332
  }
1333
- if (typeof n.ending == "string")
1333
+ if (typeof r.ending == "string")
1334
1334
  try {
1335
- n.ending = JSON.parse(n.ending);
1335
+ r.ending = JSON.parse(r.ending);
1336
1336
  } catch {
1337
1337
  }
1338
- return K.parse(f(n));
1338
+ return K.parse(f(r));
1339
1339
  };
1340
1340
  }
1341
1341
  function Ma(t) {
1342
- return async (e, a, r) => {
1343
- const n = {
1344
- ...r,
1342
+ return async (e, a, n) => {
1343
+ const r = {
1344
+ ...n,
1345
1345
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1346
1346
  };
1347
- r.nodes && (n.nodes = JSON.stringify(r.nodes)), r.start && (n.start = JSON.stringify(r.start)), r.ending && (n.ending = JSON.stringify(r.ending));
1348
- const { numUpdatedRows: o } = await t.updateTable("forms").set(n).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1347
+ n.nodes && (r.nodes = JSON.stringify(n.nodes)), n.start && (r.start = JSON.stringify(n.start)), n.ending && (r.ending = JSON.stringify(n.ending));
1348
+ const { numUpdatedRows: o } = await t.updateTable("forms").set(r).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1349
1349
  return o > 0;
1350
1350
  };
1351
1351
  }
1352
1352
  function Fa(t) {
1353
1353
  return {
1354
1354
  create: Da(t),
1355
- get: ja(t),
1355
+ get: Pa(t),
1356
1356
  list: Ia(t),
1357
- remove: Pa(t),
1357
+ remove: ja(t),
1358
1358
  update: Ma(t)
1359
1359
  };
1360
1360
  }
@@ -2273,71 +2273,71 @@ const Ja = g({
2273
2273
  UpdateQueryNode: !0,
2274
2274
  MergeQueryNode: !0
2275
2275
  });
2276
- var P, O, k, p, ye, we, ve, $, G, Ne;
2276
+ var j, O, k, p, ye, we, ve, $, G, Ne;
2277
2277
  class Ea extends za {
2278
2278
  constructor(a) {
2279
2279
  super();
2280
2280
  y(this, p);
2281
- y(this, P);
2281
+ y(this, j);
2282
2282
  y(this, O, /* @__PURE__ */ new Set());
2283
2283
  y(this, k, /* @__PURE__ */ new Set());
2284
- F(this, P, a);
2284
+ F(this, j, a);
2285
2285
  }
2286
2286
  transformNodeImpl(a) {
2287
2287
  if (!u(this, p, ye).call(this, a))
2288
2288
  return super.transformNodeImpl(a);
2289
- const r = u(this, p, ve).call(this, a);
2290
- for (const s of r)
2291
- c(this, k).add(s);
2292
- const n = u(this, p, we).call(this, a);
2289
+ const n = u(this, p, ve).call(this, a);
2293
2290
  for (const s of n)
2291
+ c(this, k).add(s);
2292
+ const r = u(this, p, we).call(this, a);
2293
+ for (const s of r)
2294
2294
  c(this, O).add(s);
2295
2295
  const o = super.transformNodeImpl(a);
2296
- for (const s of n)
2297
- c(this, O).delete(s);
2298
2296
  for (const s of r)
2297
+ c(this, O).delete(s);
2298
+ for (const s of n)
2299
2299
  c(this, k).delete(s);
2300
2300
  return o;
2301
2301
  }
2302
2302
  transformSchemableIdentifier(a) {
2303
- const r = super.transformSchemableIdentifier(a);
2304
- return r.schema || !c(this, O).has(a.identifier.name) ? r : {
2305
- ...r,
2306
- schema: E.create(c(this, P))
2303
+ const n = super.transformSchemableIdentifier(a);
2304
+ return n.schema || !c(this, O).has(a.identifier.name) ? n : {
2305
+ ...n,
2306
+ schema: E.create(c(this, j))
2307
2307
  };
2308
2308
  }
2309
2309
  transformReferences(a) {
2310
- const r = super.transformReferences(a);
2311
- return r.table.table.schema ? r : {
2312
- ...r,
2313
- table: B.createWithSchema(c(this, P), r.table.table.identifier.name)
2310
+ const n = super.transformReferences(a);
2311
+ return n.table.table.schema ? n : {
2312
+ ...n,
2313
+ table: B.createWithSchema(c(this, j), n.table.table.identifier.name)
2314
2314
  };
2315
2315
  }
2316
2316
  }
2317
- P = new WeakMap(), O = new WeakMap(), k = new WeakMap(), p = new WeakSet(), ye = function(a) {
2317
+ j = new WeakMap(), O = new WeakMap(), k = new WeakMap(), p = new WeakSet(), ye = function(a) {
2318
2318
  return a.kind in Ja;
2319
2319
  }, we = function(a) {
2320
- const r = /* @__PURE__ */ new Set();
2321
- if ("name" in a && a.name && W.is(a.name) && u(this, p, G).call(this, a.name, r), "from" in a && a.from)
2322
- for (const n of a.from.froms)
2323
- u(this, p, $).call(this, n, r);
2324
- if ("into" in a && a.into && u(this, p, $).call(this, a.into, r), "table" in a && a.table && u(this, p, $).call(this, a.table, r), "joins" in a && a.joins)
2325
- for (const n of a.joins)
2326
- u(this, p, $).call(this, n.table, r);
2327
- return "using" in a && a.using && u(this, p, $).call(this, a.using, r), r;
2320
+ const n = /* @__PURE__ */ new Set();
2321
+ if ("name" in a && a.name && W.is(a.name) && u(this, p, G).call(this, a.name, n), "from" in a && a.from)
2322
+ for (const r of a.from.froms)
2323
+ u(this, p, $).call(this, r, n);
2324
+ if ("into" in a && a.into && u(this, p, $).call(this, a.into, n), "table" in a && a.table && u(this, p, $).call(this, a.table, n), "joins" in a && a.joins)
2325
+ for (const r of a.joins)
2326
+ u(this, p, $).call(this, r.table, n);
2327
+ return "using" in a && a.using && u(this, p, $).call(this, a.using, n), n;
2328
2328
  }, ve = function(a) {
2329
- const r = /* @__PURE__ */ new Set();
2330
- return "with" in a && a.with && u(this, p, Ne).call(this, a.with, r), r;
2331
- }, $ = function(a, r) {
2332
- const n = B.is(a) ? a : La.is(a) && B.is(a.node) ? a.node : null;
2333
- n && u(this, p, G).call(this, n.table, r);
2334
- }, G = function(a, r) {
2335
- const n = a.identifier.name;
2336
- !c(this, O).has(n) && !c(this, k).has(n) && r.add(n);
2337
- }, Ne = function(a, r) {
2338
- for (const n of a.expressions) {
2339
- const o = n.name.table.table.identifier.name;
2340
- c(this, k).has(o) || r.add(o);
2329
+ const n = /* @__PURE__ */ new Set();
2330
+ return "with" in a && a.with && u(this, p, Ne).call(this, a.with, n), n;
2331
+ }, $ = function(a, n) {
2332
+ const r = B.is(a) ? a : La.is(a) && B.is(a.node) ? a.node : null;
2333
+ r && u(this, p, G).call(this, r.table, n);
2334
+ }, G = function(a, n) {
2335
+ const r = a.identifier.name;
2336
+ !c(this, O).has(r) && !c(this, k).has(r) && n.add(r);
2337
+ }, Ne = function(a, n) {
2338
+ for (const r of a.expressions) {
2339
+ const o = r.name.table.table.identifier.name;
2340
+ c(this, k).has(o) || n.add(o);
2341
2341
  }
2342
2342
  };
2343
2343
  var z;
@@ -2363,7 +2363,7 @@ class Ra {
2363
2363
  }
2364
2364
  }
2365
2365
  const Ua = "kysely_migration", fe = "kysely_migration_lock", Ba = !1, Q = "migration_lock", Qa = g({ __noMigrations__: !0 });
2366
- var _, i, A, v, N, D, be, C, xe, Te, Se, Oe, ke, H, I, X, $e, De, Ie, Y, Pe, je, Me, Fe, Ae, L;
2366
+ var _, i, A, v, N, D, be, C, xe, Te, Se, Oe, ke, H, I, X, $e, De, Ie, Y, je, Pe, Me, Fe, Ae, L;
2367
2367
  class Ce {
2368
2368
  constructor(e) {
2369
2369
  y(this, i);
@@ -2377,11 +2377,11 @@ class Ce {
2377
2377
  */
2378
2378
  async getMigrations() {
2379
2379
  const e = await u(this, i, I).call(this, c(this, i, N)) ? await c(this, _).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select(["name", "timestamp"]).execute() : [];
2380
- return (await u(this, i, Y).call(this)).map(({ name: r, ...n }) => {
2381
- const o = e.find((s) => s.name === r);
2380
+ return (await u(this, i, Y).call(this)).map(({ name: n, ...r }) => {
2381
+ const o = e.find((s) => s.name === n);
2382
2382
  return {
2383
- name: r,
2384
- migration: n,
2383
+ name: n,
2384
+ migration: r,
2385
2385
  executedAt: o ? new Date(o.timestamp) : void 0
2386
2386
  };
2387
2387
  });
@@ -2460,16 +2460,16 @@ class Ce {
2460
2460
  * ```
2461
2461
  */
2462
2462
  async migrateTo(e) {
2463
- return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: n }) => {
2463
+ return u(this, i, A).call(this, ({ migrations: a, executedMigrations: n, pendingMigrations: r }) => {
2464
2464
  if (e === Qa)
2465
2465
  return { direction: "Down", step: 1 / 0 };
2466
- if (!a.find((l) => l.name === e))
2466
+ if (!a.find((d) => d.name === e))
2467
2467
  throw new Error(`migration "${e}" doesn't exist`);
2468
- const o = r.indexOf(e), s = n.findIndex((l) => l.name === e);
2468
+ const o = n.indexOf(e), s = r.findIndex((d) => d.name === e);
2469
2469
  if (o !== -1)
2470
2470
  return {
2471
2471
  direction: "Down",
2472
- step: r.length - o - 1
2472
+ step: n.length - o - 1
2473
2473
  };
2474
2474
  if (s !== -1)
2475
2475
  return { direction: "Up", step: s + 1 };
@@ -2567,105 +2567,105 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
2567
2567
  const a = c(this, i, v);
2568
2568
  return (await c(this, _).db.introspection.getTables({
2569
2569
  withInternalKyselyTables: !0
2570
- })).some((n) => n.name === e && (!a || n.schema === a));
2570
+ })).some((r) => r.name === e && (!a || r.schema === a));
2571
2571
  }, X = async function() {
2572
2572
  return !!await c(this, _).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, D)).where("id", "=", Q).select("id").executeTakeFirst();
2573
2573
  }, $e = async function(e) {
2574
- const a = c(this, _).db.getExecutor().adapter, r = g({
2574
+ const a = c(this, _).db.getExecutor().adapter, n = g({
2575
2575
  lockTable: c(this, _).migrationLockTableName ?? fe,
2576
2576
  lockRowId: Q,
2577
2577
  lockTableSchema: c(this, _).migrationTableSchema
2578
- }), n = async (o) => {
2578
+ }), r = async (o) => {
2579
2579
  try {
2580
- await a.acquireMigrationLock(o, r);
2580
+ await a.acquireMigrationLock(o, n);
2581
2581
  const s = await u(this, i, De).call(this, o);
2582
2582
  if (s.migrations.length === 0)
2583
2583
  return { results: [] };
2584
- const { direction: l, step: d } = e(s);
2585
- return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Fe).call(this, o, s, d) : l === "Up" ? await u(this, i, Ae).call(this, o, s, d) : { results: [] };
2584
+ const { direction: d, step: l } = e(s);
2585
+ return l <= 0 ? { results: [] } : d === "Down" ? await u(this, i, Fe).call(this, o, s, l) : d === "Up" ? await u(this, i, Ae).call(this, o, s, l) : { results: [] };
2586
2586
  } finally {
2587
- await a.releaseMigrationLock(o, r);
2587
+ await a.releaseMigrationLock(o, n);
2588
2588
  }
2589
2589
  };
2590
- return a.supportsTransactionalDdl ? c(this, _).db.transaction().execute(n) : c(this, _).db.connection().execute(n);
2590
+ return a.supportsTransactionalDdl ? c(this, _).db.transaction().execute(r) : c(this, _).db.connection().execute(r);
2591
2591
  }, De = async function(e) {
2592
- const a = await u(this, i, Y).call(this), r = await u(this, i, Pe).call(this, e);
2593
- u(this, i, je).call(this, a, r), c(this, i, be) || u(this, i, Me).call(this, a, r);
2594
- const n = u(this, i, Ie).call(this, a, r);
2592
+ const a = await u(this, i, Y).call(this), n = await u(this, i, je).call(this, e);
2593
+ u(this, i, Pe).call(this, a, n), c(this, i, be) || u(this, i, Me).call(this, a, n);
2594
+ const r = u(this, i, Ie).call(this, a, n);
2595
2595
  return g({
2596
2596
  migrations: a,
2597
- executedMigrations: r,
2598
- lastMigration: Aa(r),
2599
- pendingMigrations: n
2597
+ executedMigrations: n,
2598
+ lastMigration: Aa(n),
2599
+ pendingMigrations: r
2600
2600
  });
2601
2601
  }, Ie = function(e, a) {
2602
- return e.filter((r) => !a.includes(r.name));
2602
+ return e.filter((n) => !a.includes(n.name));
2603
2603
  }, Y = async function() {
2604
2604
  const e = await c(this, _).provider.getMigrations();
2605
2605
  return Object.keys(e).sort().map((a) => ({
2606
2606
  ...e[a],
2607
2607
  name: a
2608
2608
  }));
2609
- }, Pe = async function(e) {
2610
- return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2611
- }, je = function(e, a) {
2612
- for (const r of a)
2613
- if (!e.some((n) => n.name === r))
2614
- throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2609
+ }, je = async function(e) {
2610
+ return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((n) => n.name);
2611
+ }, Pe = function(e, a) {
2612
+ for (const n of a)
2613
+ if (!e.some((r) => r.name === n))
2614
+ throw new Error(`corrupted migrations: previously executed migration ${n} is missing`);
2615
2615
  }, Me = function(e, a) {
2616
- for (let r = 0; r < a.length; ++r)
2617
- if (e[r].name !== a[r])
2618
- 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.`);
2619
- }, Fe = async function(e, a, r) {
2620
- const n = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), o = n.map((s) => ({
2616
+ for (let n = 0; n < a.length; ++n)
2617
+ if (e[n].name !== a[n])
2618
+ throw new Error(`corrupted migrations: expected previously executed migration ${a[n]} to be at index ${n} but ${e[n].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2619
+ }, Fe = async function(e, a, n) {
2620
+ const r = a.executedMigrations.slice().reverse().slice(0, n).map((s) => a.migrations.find((d) => d.name === s)), o = r.map((s) => ({
2621
2621
  migrationName: s.name,
2622
2622
  direction: "Down",
2623
2623
  status: "NotExecuted"
2624
2624
  }));
2625
2625
  for (let s = 0; s < o.length; ++s) {
2626
- const l = n[s];
2626
+ const d = r[s];
2627
2627
  try {
2628
- l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, N)).where("name", "=", l.name).execute(), o[s] = {
2629
- migrationName: l.name,
2628
+ d.down && (await d.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, N)).where("name", "=", d.name).execute(), o[s] = {
2629
+ migrationName: d.name,
2630
2630
  direction: "Down",
2631
2631
  status: "Success"
2632
2632
  });
2633
- } catch (d) {
2633
+ } catch (l) {
2634
2634
  throw o[s] = {
2635
- migrationName: l.name,
2635
+ migrationName: d.name,
2636
2636
  direction: "Down",
2637
2637
  status: "Error"
2638
2638
  }, new q({
2639
- error: d,
2639
+ error: l,
2640
2640
  results: o
2641
2641
  });
2642
2642
  }
2643
2643
  }
2644
2644
  return { results: o };
2645
- }, Ae = async function(e, a, r) {
2646
- const o = a.pendingMigrations.slice(0, r).map((s) => ({
2645
+ }, Ae = async function(e, a, n) {
2646
+ const o = a.pendingMigrations.slice(0, n).map((s) => ({
2647
2647
  migrationName: s.name,
2648
2648
  direction: "Up",
2649
2649
  status: "NotExecuted"
2650
2650
  }));
2651
2651
  for (let s = 0; s < o.length; s++) {
2652
- const l = a.pendingMigrations[s];
2652
+ const d = a.pendingMigrations[s];
2653
2653
  try {
2654
- await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, N)).values({
2655
- name: l.name,
2654
+ await d.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, N)).values({
2655
+ name: d.name,
2656
2656
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2657
2657
  }).execute(), o[s] = {
2658
- migrationName: l.name,
2658
+ migrationName: d.name,
2659
2659
  direction: "Up",
2660
2660
  status: "Success"
2661
2661
  };
2662
- } catch (d) {
2662
+ } catch (l) {
2663
2663
  throw o[s] = {
2664
- migrationName: l.name,
2664
+ migrationName: d.name,
2665
2665
  direction: "Up",
2666
2666
  status: "Error"
2667
2667
  }, new q({
2668
- error: d,
2668
+ error: l,
2669
2669
  results: o
2670
2670
  });
2671
2671
  }
@@ -2790,12 +2790,12 @@ async function Ya(t) {
2790
2790
  }
2791
2791
  async function Za(t) {
2792
2792
  }
2793
- const er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2793
+ const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2794
2794
  __proto__: null,
2795
2795
  down: Za,
2796
2796
  up: Ya
2797
2797
  }, Symbol.toStringTag, { value: "Module" }));
2798
- async function tr(t) {
2798
+ async function tn(t) {
2799
2799
  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(
2800
2800
  "tenant_id_constraint",
2801
2801
  ["tenant_id"],
@@ -2804,24 +2804,24 @@ async function tr(t) {
2804
2804
  (e) => e.onDelete("cascade")
2805
2805
  ).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();
2806
2806
  }
2807
- async function ar(t) {
2807
+ async function an(t) {
2808
2808
  await t.schema.dropTable("logs").execute();
2809
2809
  }
2810
- const rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2810
+ const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2811
2811
  __proto__: null,
2812
- down: ar,
2813
- up: tr
2812
+ down: an,
2813
+ up: tn
2814
2814
  }, Symbol.toStringTag, { value: "Module" }));
2815
- async function nr(t) {
2815
+ async function rn(t) {
2816
2816
  }
2817
- async function or(t) {
2817
+ async function on(t) {
2818
2818
  }
2819
- const sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2819
+ const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2820
2820
  __proto__: null,
2821
- down: or,
2822
- up: nr
2821
+ down: on,
2822
+ up: rn
2823
2823
  }, Symbol.toStringTag, { value: "Module" }));
2824
- async function ir(t) {
2824
+ async function ln(t) {
2825
2825
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
2826
2826
  "user_id_constraint",
2827
2827
  ["user_id", "tenant_id"],
@@ -2846,15 +2846,15 @@ async function ir(t) {
2846
2846
  (e) => e.references("applications.id").onDelete("cascade").notNull()
2847
2847
  ).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();
2848
2848
  }
2849
- async function dr(t) {
2849
+ async function dn(t) {
2850
2850
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
2851
2851
  }
2852
- const lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2852
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2853
2853
  __proto__: null,
2854
- down: dr,
2855
- up: ir
2854
+ down: dn,
2855
+ up: ln
2856
2856
  }, Symbol.toStringTag, { value: "Module" }));
2857
- async function cr(t) {
2857
+ async function un(t) {
2858
2858
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
2859
2859
  "user_id_constraint",
2860
2860
  ["user_id", "tenant_id"],
@@ -2869,24 +2869,24 @@ async function cr(t) {
2869
2869
  (e) => e.onDelete("cascade")
2870
2870
  ).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();
2871
2871
  }
2872
- async function ur(t) {
2872
+ async function mn(t) {
2873
2873
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
2874
2874
  }
2875
- const mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2875
+ const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2876
2876
  __proto__: null,
2877
- down: ur,
2878
- up: cr
2877
+ down: mn,
2878
+ up: un
2879
2879
  }, Symbol.toStringTag, { value: "Module" }));
2880
- async function hr(t) {
2880
+ async function _n(t) {
2881
2881
  }
2882
- async function _r(t) {
2882
+ async function fn(t) {
2883
2883
  }
2884
- const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2884
+ const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2885
2885
  __proto__: null,
2886
- down: _r,
2887
- up: hr
2886
+ down: fn,
2887
+ up: _n
2888
2888
  }, Symbol.toStringTag, { value: "Module" }));
2889
- async function pr(t) {
2889
+ async function gn(t) {
2890
2890
  await t.schema.alterTable("passwords").addColumn(
2891
2891
  "password",
2892
2892
  "varchar(255)",
@@ -2894,288 +2894,288 @@ async function pr(t) {
2894
2894
  (e) => e.notNull()
2895
2895
  ).execute();
2896
2896
  }
2897
- async function gr(t) {
2897
+ async function yn(t) {
2898
2898
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2899
2899
  }
2900
- const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2900
+ const wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2901
2901
  __proto__: null,
2902
- down: gr,
2903
- up: pr
2902
+ down: yn,
2903
+ up: gn
2904
2904
  }, Symbol.toStringTag, { value: "Module" }));
2905
- async function wr(t) {
2905
+ async function vn(t) {
2906
2906
  }
2907
- async function vr(t) {
2907
+ async function Nn(t) {
2908
2908
  }
2909
- const Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2909
+ const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2910
2910
  __proto__: null,
2911
- down: vr,
2912
- up: wr
2911
+ down: Nn,
2912
+ up: vn
2913
2913
  }, Symbol.toStringTag, { value: "Module" }));
2914
- async function Cr(t) {
2914
+ async function bn(t) {
2915
2915
  }
2916
- async function br(t) {
2916
+ async function xn(t) {
2917
2917
  }
2918
- const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2918
+ const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2919
2919
  __proto__: null,
2920
- down: br,
2921
- up: Cr
2920
+ down: xn,
2921
+ up: bn
2922
2922
  }, Symbol.toStringTag, { value: "Module" }));
2923
- async function Tr(t) {
2923
+ async function Sn(t) {
2924
2924
  }
2925
- async function Sr(t) {
2925
+ async function On(t) {
2926
2926
  }
2927
- const Or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2927
+ const kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2928
2928
  __proto__: null,
2929
- down: Sr,
2930
- up: Tr
2929
+ down: On,
2930
+ up: Sn
2931
2931
  }, Symbol.toStringTag, { value: "Module" }));
2932
- async function kr(t) {
2932
+ async function $n(t) {
2933
2933
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
2934
2934
  }
2935
- async function $r(t) {
2935
+ async function Dn(t) {
2936
2936
  await t.schema.dropIndex("users_email_index").execute();
2937
2937
  }
2938
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2938
+ const In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2939
2939
  __proto__: null,
2940
- down: $r,
2941
- up: kr
2940
+ down: Dn,
2941
+ up: $n
2942
2942
  }, Symbol.toStringTag, { value: "Module" }));
2943
- async function Ir(t) {
2943
+ async function jn(t) {
2944
2944
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
2945
2945
  }
2946
- async function Pr(t) {
2946
+ async function Pn(t) {
2947
2947
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2948
2948
  }
2949
- const jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2949
+ const Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2950
2950
  __proto__: null,
2951
- down: Pr,
2952
- up: Ir
2951
+ down: Pn,
2952
+ up: jn
2953
2953
  }, Symbol.toStringTag, { value: "Module" }));
2954
- async function Mr(t) {
2954
+ async function Fn(t) {
2955
2955
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
2956
2956
  }
2957
- async function Fr(t) {
2957
+ async function An(t) {
2958
2958
  await t.schema.dropIndex("users_linked_to_index");
2959
2959
  }
2960
- const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2960
+ const Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2961
2961
  __proto__: null,
2962
- down: Fr,
2963
- up: Mr
2962
+ down: An,
2963
+ up: Fn
2964
2964
  }, Symbol.toStringTag, { value: "Module" }));
2965
- async function Lr(t) {
2965
+ async function zn(t) {
2966
2966
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
2967
2967
  }
2968
- async function zr(t) {
2968
+ async function Jn(t) {
2969
2969
  await t.schema.alterTable("users").dropColumn("locale").execute();
2970
2970
  }
2971
- const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2971
+ const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2972
2972
  __proto__: null,
2973
- down: zr,
2974
- up: Lr
2973
+ down: Jn,
2974
+ up: zn
2975
2975
  }, Symbol.toStringTag, { value: "Module" }));
2976
- async function Er(t) {
2976
+ async function Kn(t) {
2977
2977
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2978
2978
  "tenant_id",
2979
2979
  "varchar(255)",
2980
2980
  (e) => e.references("tenants.id").onDelete("cascade")
2981
2981
  ).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();
2982
2982
  }
2983
- async function Kr(t) {
2983
+ async function Rn(t) {
2984
2984
  await t.schema.dropTable("keys").execute();
2985
2985
  }
2986
- const Rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2986
+ const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2987
2987
  __proto__: null,
2988
- down: Kr,
2989
- up: Er
2988
+ down: Rn,
2989
+ up: Kn
2990
2990
  }, Symbol.toStringTag, { value: "Module" }));
2991
- async function Ur(t) {
2991
+ async function Bn(t) {
2992
2992
  }
2993
- async function Br(t) {
2993
+ async function Qn(t) {
2994
2994
  }
2995
- const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2995
+ const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2996
2996
  __proto__: null,
2997
- down: Br,
2998
- up: Ur
2997
+ down: Qn,
2998
+ up: Bn
2999
2999
  }, Symbol.toStringTag, { value: "Module" }));
3000
- async function qr(t) {
3000
+ async function Vn(t) {
3001
3001
  }
3002
- async function Vr(t) {
3002
+ async function Wn(t) {
3003
3003
  }
3004
- const Wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3004
+ const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3005
3005
  __proto__: null,
3006
- down: Vr,
3007
- up: qr
3006
+ down: Wn,
3007
+ up: Vn
3008
3008
  }, Symbol.toStringTag, { value: "Module" }));
3009
- async function Gr(t) {
3009
+ async function Hn(t) {
3010
3010
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3011
3011
  }
3012
- async function Hr(t) {
3012
+ async function Xn(t) {
3013
3013
  await t.schema.alterTable("otps").dropColumn("audience").execute();
3014
3014
  }
3015
- const Xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3015
+ const Yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3016
3016
  __proto__: null,
3017
- down: Hr,
3018
- up: Gr
3017
+ down: Xn,
3018
+ up: Hn
3019
3019
  }, Symbol.toStringTag, { value: "Module" }));
3020
- async function Yr(t) {
3020
+ async function Zn(t) {
3021
3021
  }
3022
- async function Zr(t) {
3022
+ async function er(t) {
3023
3023
  }
3024
- const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3024
+ const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3025
3025
  __proto__: null,
3026
- down: Zr,
3027
- up: Yr
3026
+ down: er,
3027
+ up: Zn
3028
3028
  }, Symbol.toStringTag, { value: "Module" }));
3029
- async function tn(t) {
3029
+ async function ar(t) {
3030
3030
  await t.schema.alterTable("logs").dropColumn("category").execute();
3031
3031
  }
3032
- async function an(t) {
3032
+ async function nr(t) {
3033
3033
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
3034
3034
  }
3035
- const rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3035
+ const rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3036
3036
  __proto__: null,
3037
- down: an,
3038
- up: tn
3037
+ down: nr,
3038
+ up: ar
3039
3039
  }, Symbol.toStringTag, { value: "Module" }));
3040
- async function nn(t) {
3040
+ async function or(t) {
3041
3041
  await t.schema.alterTable("users").dropColumn("tags").execute();
3042
3042
  }
3043
- async function on(t) {
3043
+ async function sr(t) {
3044
3044
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3045
3045
  }
3046
- const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3046
+ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3047
3047
  __proto__: null,
3048
- down: on,
3049
- up: nn
3048
+ down: sr,
3049
+ up: or
3050
3050
  }, Symbol.toStringTag, { value: "Module" }));
3051
- async function dn(t) {
3051
+ async function lr(t) {
3052
3052
  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();
3053
3053
  }
3054
- async function ln(t) {
3054
+ async function dr(t) {
3055
3055
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3056
3056
  }
3057
- const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3057
+ const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3058
3058
  __proto__: null,
3059
- down: ln,
3060
- up: dn
3059
+ down: dr,
3060
+ up: lr
3061
3061
  }, Symbol.toStringTag, { value: "Module" }));
3062
- async function un(t) {
3062
+ async function ur(t) {
3063
3063
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3064
3064
  }
3065
- async function mn(t) {
3065
+ async function mr(t) {
3066
3066
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3067
3067
  }
3068
- const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3068
+ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3069
3069
  __proto__: null,
3070
- down: mn,
3071
- up: un
3070
+ down: mr,
3071
+ up: ur
3072
3072
  }, Symbol.toStringTag, { value: "Module" }));
3073
- async function _n(t) {
3073
+ async function _r(t) {
3074
3074
  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();
3075
3075
  }
3076
- async function fn(t) {
3076
+ async function fr(t) {
3077
3077
  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();
3078
3078
  }
3079
- const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3079
+ const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3080
3080
  __proto__: null,
3081
- down: fn,
3082
- up: _n
3081
+ down: fr,
3082
+ up: _r
3083
3083
  }, Symbol.toStringTag, { value: "Module" }));
3084
- async function gn(t) {
3084
+ async function gr(t) {
3085
3085
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3086
3086
  }
3087
- async function yn(t) {
3087
+ async function yr(t) {
3088
3088
  await t.schema.dropIndex("users_name_index").execute();
3089
3089
  }
3090
- const wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3090
+ const wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3091
3091
  __proto__: null,
3092
- down: yn,
3093
- up: gn
3092
+ down: yr,
3093
+ up: gr
3094
3094
  }, Symbol.toStringTag, { value: "Module" }));
3095
- async function vn(t) {
3095
+ async function vr(t) {
3096
3096
  }
3097
- async function Nn(t) {
3097
+ async function Nr(t) {
3098
3098
  await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3099
3099
  }
3100
- const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3100
+ const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3101
3101
  __proto__: null,
3102
- down: Nn,
3103
- up: vn
3102
+ down: Nr,
3103
+ up: vr
3104
3104
  }, Symbol.toStringTag, { value: "Module" }));
3105
- async function bn(t) {
3105
+ async function br(t) {
3106
3106
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3107
3107
  }
3108
- async function xn(t) {
3108
+ async function xr(t) {
3109
3109
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
3110
3110
  }
3111
- const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3111
+ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3112
3112
  __proto__: null,
3113
- down: xn,
3114
- up: bn
3113
+ down: xr,
3114
+ up: br
3115
3115
  }, Symbol.toStringTag, { value: "Module" }));
3116
- async function Sn(t) {
3116
+ async function Sr(t) {
3117
3117
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3118
3118
  }
3119
- async function On(t) {
3119
+ async function Or(t) {
3120
3120
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3121
3121
  }
3122
- const kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3122
+ const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3123
3123
  __proto__: null,
3124
- down: On,
3125
- up: Sn
3124
+ down: Or,
3125
+ up: Sr
3126
3126
  }, Symbol.toStringTag, { value: "Module" }));
3127
- async function $n(t) {
3127
+ async function $r(t) {
3128
3128
  await t.schema.createTable("branding").addColumn(
3129
3129
  "tenant_id",
3130
3130
  "varchar(255)",
3131
3131
  (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3132
3132
  ).addColumn("logo_url", "varchar(512)").addColumn("favicon_url", "varchar(512)").addColumn("font_url", "varchar(512)").addColumn("colors_primary", "varchar(8)").addColumn("colors_page_background_type", "varchar(32)").addColumn("colors_page_background_start", "varchar(8)").addColumn("colors_page_background_end", "varchar(8)").addColumn("colors_page_background_angle_dev", "integer").execute();
3133
3133
  }
3134
- async function Dn(t) {
3134
+ async function Dr(t) {
3135
3135
  await t.schema.dropTable("branding").execute();
3136
3136
  }
3137
- const In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3137
+ const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3138
3138
  __proto__: null,
3139
- down: Dn,
3140
- up: $n
3139
+ down: Dr,
3140
+ up: $r
3141
3141
  }, Symbol.toStringTag, { value: "Module" }));
3142
- async function Pn(t) {
3142
+ async function jr(t) {
3143
3143
  }
3144
- async function jn(t) {
3144
+ async function Pr(t) {
3145
3145
  }
3146
- const Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3146
+ const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3147
3147
  __proto__: null,
3148
- down: jn,
3149
- up: Pn
3148
+ down: Pr,
3149
+ up: jr
3150
3150
  }, Symbol.toStringTag, { value: "Module" }));
3151
- async function Fn(t) {
3151
+ async function Fr(t) {
3152
3152
  }
3153
- async function An(t) {
3153
+ async function Ar(t) {
3154
3154
  }
3155
- const Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3155
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3156
3156
  __proto__: null,
3157
- down: An,
3158
- up: Fn
3157
+ down: Ar,
3158
+ up: Fr
3159
3159
  }, Symbol.toStringTag, { value: "Module" }));
3160
- async function zn(t) {
3160
+ async function zr(t) {
3161
3161
  }
3162
- async function Jn(t) {
3162
+ async function Jr(t) {
3163
3163
  }
3164
- const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3164
+ const Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3165
3165
  __proto__: null,
3166
- down: Jn,
3167
- up: zn
3166
+ down: Jr,
3167
+ up: zr
3168
3168
  }, Symbol.toStringTag, { value: "Module" }));
3169
- async function Kn(t) {
3169
+ async function Kr(t) {
3170
3170
  }
3171
- async function Rn(t) {
3171
+ async function Rr(t) {
3172
3172
  }
3173
- const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3173
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3174
3174
  __proto__: null,
3175
- down: Rn,
3176
- up: Kn
3175
+ down: Rr,
3176
+ up: Kr
3177
3177
  }, Symbol.toStringTag, { value: "Module" }));
3178
- async function Bn(t) {
3178
+ async function Br(t) {
3179
3179
  await t.schema.createTable("authentication_codes").addColumn(
3180
3180
  "tenant_id",
3181
3181
  "varchar(255)",
@@ -3186,35 +3186,35 @@ async function Bn(t) {
3186
3186
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3187
3187
  ).addColumn("user_id", "varchar(255)", (e) => e.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(8192)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3188
3188
  }
3189
- async function Qn(t) {
3189
+ async function Qr(t) {
3190
3190
  await t.schema.dropTable("authentication_codes").execute();
3191
3191
  }
3192
- const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3192
+ const qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3193
3193
  __proto__: null,
3194
- down: Qn,
3195
- up: Bn
3194
+ down: Qr,
3195
+ up: Br
3196
3196
  }, Symbol.toStringTag, { value: "Module" }));
3197
- async function Vn(t) {
3197
+ async function Vr(t) {
3198
3198
  }
3199
- async function Wn(t) {
3199
+ async function Wr(t) {
3200
3200
  }
3201
- const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3201
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3202
3202
  __proto__: null,
3203
- down: Wn,
3204
- up: Vn
3203
+ down: Wr,
3204
+ up: Vr
3205
3205
  }, Symbol.toStringTag, { value: "Module" }));
3206
- async function Hn(t) {
3206
+ async function Hr(t) {
3207
3207
  await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3208
3208
  }
3209
- async function Xn(t) {
3209
+ async function Xr(t) {
3210
3210
  await t.schema.alterTable("otps").dropColumn("ip").execute();
3211
3211
  }
3212
- const Yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3212
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3213
3213
  __proto__: null,
3214
- down: Xn,
3215
- up: Hn
3214
+ down: Xr,
3215
+ up: Hr
3216
3216
  }, Symbol.toStringTag, { value: "Module" }));
3217
- async function Zn(t) {
3217
+ async function Zr(t) {
3218
3218
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3219
3219
  }
3220
3220
  async function eo(t) {
@@ -3223,15 +3223,15 @@ async function eo(t) {
3223
3223
  const to = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3224
3224
  __proto__: null,
3225
3225
  down: eo,
3226
- up: Zn
3226
+ up: Zr
3227
3227
  }, Symbol.toStringTag, { value: "Module" }));
3228
3228
  async function ao(t) {
3229
3229
  }
3230
- async function ro(t) {
3230
+ async function no(t) {
3231
3231
  }
3232
- const no = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3232
+ const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3233
3233
  __proto__: null,
3234
- down: ro,
3234
+ down: no,
3235
3235
  up: ao
3236
3236
  }, Symbol.toStringTag, { value: "Module" }));
3237
3237
  async function oo(t) {
@@ -3346,12 +3346,12 @@ async function Do(t) {
3346
3346
  }
3347
3347
  async function Io(t) {
3348
3348
  }
3349
- const Po = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3349
+ const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3350
3350
  __proto__: null,
3351
3351
  down: Io,
3352
3352
  up: Do
3353
3353
  }, Symbol.toStringTag, { value: "Module" }));
3354
- async function jo(t) {
3354
+ async function Po(t) {
3355
3355
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3356
3356
  }
3357
3357
  async function Mo(t) {
@@ -3360,7 +3360,7 @@ async function Mo(t) {
3360
3360
  const Fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3361
3361
  __proto__: null,
3362
3362
  down: Mo,
3363
- up: jo
3363
+ up: Po
3364
3364
  }, Symbol.toStringTag, { value: "Module" }));
3365
3365
  async function Ao(t) {
3366
3366
  }
@@ -3488,32 +3488,32 @@ const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3488
3488
  down: ts,
3489
3489
  up: es
3490
3490
  }, Symbol.toStringTag, { value: "Module" }));
3491
- async function rs(t) {
3492
- }
3493
3491
  async function ns(t) {
3494
3492
  }
3493
+ async function rs(t) {
3494
+ }
3495
3495
  const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3496
3496
  __proto__: null,
3497
- down: ns,
3498
- up: rs
3497
+ down: rs,
3498
+ up: ns
3499
3499
  }, Symbol.toStringTag, { value: "Module" }));
3500
3500
  async function ss(t) {
3501
3501
  }
3502
3502
  async function is(t) {
3503
3503
  }
3504
- const ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3504
+ const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3505
3505
  __proto__: null,
3506
3506
  down: is,
3507
3507
  up: ss
3508
3508
  }, Symbol.toStringTag, { value: "Module" }));
3509
- async function ls(t) {
3509
+ async function ds(t) {
3510
3510
  }
3511
3511
  async function cs(t) {
3512
3512
  }
3513
3513
  const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3514
3514
  __proto__: null,
3515
3515
  down: cs,
3516
- up: ls
3516
+ up: ds
3517
3517
  }, Symbol.toStringTag, { value: "Module" }));
3518
3518
  async function ms(t) {
3519
3519
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
@@ -3601,12 +3601,12 @@ async function Is(t) {
3601
3601
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3602
3602
  ).addColumn("email", "varchar(255)", (e) => e.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(1024)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3603
3603
  }
3604
- const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3604
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3605
3605
  __proto__: null,
3606
3606
  down: Is,
3607
3607
  up: Ds
3608
3608
  }, Symbol.toStringTag, { value: "Module" }));
3609
- async function js(t) {
3609
+ async function Ps(t) {
3610
3610
  }
3611
3611
  async function Ms(t) {
3612
3612
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
@@ -3614,7 +3614,7 @@ async function Ms(t) {
3614
3614
  const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3615
3615
  __proto__: null,
3616
3616
  down: Ms,
3617
- up: js
3617
+ up: Ps
3618
3618
  }, Symbol.toStringTag, { value: "Module" }));
3619
3619
  async function As(t) {
3620
3620
  await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
@@ -3744,14 +3744,14 @@ const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3744
3744
  down: ti,
3745
3745
  up: ei
3746
3746
  }, Symbol.toStringTag, { value: "Module" }));
3747
- async function ri(t) {
3748
- }
3749
3747
  async function ni(t) {
3750
3748
  }
3749
+ async function ri(t) {
3750
+ }
3751
3751
  const oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3752
3752
  __proto__: null,
3753
- down: ni,
3754
- up: ri
3753
+ down: ri,
3754
+ up: ni
3755
3755
  }, Symbol.toStringTag, { value: "Module" }));
3756
3756
  async function si(t) {
3757
3757
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
@@ -3783,12 +3783,12 @@ async function si(t) {
3783
3783
  async function ii(t) {
3784
3784
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
3785
3785
  }
3786
- const di = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3786
+ const li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3787
3787
  __proto__: null,
3788
3788
  down: ii,
3789
3789
  up: si
3790
3790
  }, Symbol.toStringTag, { value: "Module" }));
3791
- async function li(t) {
3791
+ async function di(t) {
3792
3792
  await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
3793
3793
  }
3794
3794
  async function ci(t) {
@@ -3796,7 +3796,7 @@ async function ci(t) {
3796
3796
  const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3797
3797
  __proto__: null,
3798
3798
  down: ci,
3799
- up: li
3799
+ up: di
3800
3800
  }, Symbol.toStringTag, { value: "Module" }));
3801
3801
  async function mi(t) {
3802
3802
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
@@ -3862,47 +3862,84 @@ const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3862
3862
  __proto__: null,
3863
3863
  down: Ti,
3864
3864
  up: xi
3865
+ }, Symbol.toStringTag, { value: "Module" }));
3866
+ async function Oi(t) {
3867
+ await t.schema.alterTable("sessions").addColumn(
3868
+ "login_session_id",
3869
+ "varchar(21)",
3870
+ (e) => e.references("login_sessions.id").onDelete("set null")
3871
+ ).execute();
3872
+ }
3873
+ async function ki(t) {
3874
+ await t.schema.alterTable("sessions").dropColumn("login_session_id").execute();
3875
+ }
3876
+ const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3877
+ __proto__: null,
3878
+ down: ki,
3879
+ up: Oi
3880
+ }, Symbol.toStringTag, { value: "Module" }));
3881
+ async function Di(t) {
3882
+ await t.schema.createIndex("IDX_sessions_login_session_id").on("sessions").column("login_session_id").execute();
3883
+ }
3884
+ async function Ii(t) {
3885
+ await t.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
3886
+ }
3887
+ const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3888
+ __proto__: null,
3889
+ down: Ii,
3890
+ up: Di
3891
+ }, Symbol.toStringTag, { value: "Module" }));
3892
+ async function Pi(t) {
3893
+ await t.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await t.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
3894
+ }
3895
+ async function Mi(t) {
3896
+ await t.schema.alterTable("codes").dropColumn("code_challenge").execute(), await t.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
3897
+ }
3898
+ const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3899
+ __proto__: null,
3900
+ down: Mi,
3901
+ up: Pi
3865
3902
  }, Symbol.toStringTag, { value: "Module" })), ze = {
3866
3903
  m1_init: Wa,
3867
3904
  m2_magicLink: Xa,
3868
- m3_updateAt: er,
3869
- m4_logTable: rr,
3870
- m5_userProfile: sr,
3871
- m6_sessions: lr,
3872
- m7_passwords: mr,
3873
- m8_logsTableNewFields: fr,
3874
- m9_passwordTableNewField: yr,
3875
- n01_codesTable: Nr,
3876
- n11_universalLoginSession: xr,
3877
- n12_userFields: Or,
3878
- n13_userEmailIndex: Dr,
3879
- n14_profileDataField: jr,
3880
- n15_userEmailIndex: Ar,
3881
- n16_userLocale: Jr,
3882
- n17_signingKeys: Rr,
3883
- n18_logsFields: Qr,
3884
- n19_connectionsUserinfo: Wr,
3885
- n20_missingFields: Xr,
3886
- n21_sessionDeletedAt: en,
3887
- n22_dropLogsFields: rn,
3888
- n23_dropUsersFields: sn,
3889
- n24_logsIndexes: cn,
3890
- n25_logDescMaxLength: hn,
3891
- n26_logsTableExtraFields: pn,
3892
- n27_usersTableNameIndex: wn,
3893
- n28_usersEmailConstrain: Cn,
3894
- n29_increaseOtpStateLength: Tn,
3895
- n30_increaseTicketStateLength: kn,
3896
- n31_branding: In,
3897
- n32_indexesAndNotNull: Mn,
3898
- n33_vendorIdInUniversalLoginSession: Ln,
3899
- n34_auth0ClientInUniversalLoginSession: En,
3900
- n35_increaseUniversalSessionStateLength: Un,
3901
- n36_authenticationCodes: qn,
3902
- n37_disableSignUps: Gn,
3903
- n38_otpIpAddress: Yn,
3905
+ m3_updateAt: en,
3906
+ m4_logTable: nn,
3907
+ m5_userProfile: sn,
3908
+ m6_sessions: cn,
3909
+ m7_passwords: hn,
3910
+ m8_logsTableNewFields: pn,
3911
+ m9_passwordTableNewField: wn,
3912
+ n01_codesTable: Cn,
3913
+ n11_universalLoginSession: Tn,
3914
+ n12_userFields: kn,
3915
+ n13_userEmailIndex: In,
3916
+ n14_profileDataField: Mn,
3917
+ n15_userEmailIndex: Ln,
3918
+ n16_userLocale: En,
3919
+ n17_signingKeys: Un,
3920
+ n18_logsFields: qn,
3921
+ n19_connectionsUserinfo: Gn,
3922
+ n20_missingFields: Yn,
3923
+ n21_sessionDeletedAt: tr,
3924
+ n22_dropLogsFields: rr,
3925
+ n23_dropUsersFields: ir,
3926
+ n24_logsIndexes: cr,
3927
+ n25_logDescMaxLength: hr,
3928
+ n26_logsTableExtraFields: pr,
3929
+ n27_usersTableNameIndex: wr,
3930
+ n28_usersEmailConstrain: Cr,
3931
+ n29_increaseOtpStateLength: Tr,
3932
+ n30_increaseTicketStateLength: kr,
3933
+ n31_branding: Ir,
3934
+ n32_indexesAndNotNull: Mr,
3935
+ n33_vendorIdInUniversalLoginSession: Lr,
3936
+ n34_auth0ClientInUniversalLoginSession: Er,
3937
+ n35_increaseUniversalSessionStateLength: Ur,
3938
+ n36_authenticationCodes: qr,
3939
+ n37_disableSignUps: Gr,
3940
+ n38_otpIpAddress: Yr,
3904
3941
  n39_increaseUserAgentLength: to,
3905
- n40_userId: no,
3942
+ n40_userId: ro,
3906
3943
  n41_hooks: io,
3907
3944
  n42_userIdIndexes: uo,
3908
3945
  n43_userIdIndexes: _o,
@@ -3911,7 +3948,7 @@ const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3911
3948
  n46_loginAuth0Client: bo,
3912
3949
  n47_loginAuth0Client: So,
3913
3950
  n48_saml: $o,
3914
- n49_removeFields: Po,
3951
+ n49_removeFields: jo,
3915
3952
  n50_authParamsNonce: Fo,
3916
3953
  n51_connectionid: zo,
3917
3954
  n52_cert: Ko,
@@ -3921,7 +3958,7 @@ const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3921
3958
  n56_application_fields: Zo,
3922
3959
  n57_prompt_settings: as,
3923
3960
  n58_connection_client_id: os,
3924
- n59_connection_options: ds,
3961
+ n59_connection_options: ls,
3925
3962
  n60_users_metadata: us,
3926
3963
  n61_userLocales: _s,
3927
3964
  n62_prompt: gs,
@@ -3929,7 +3966,7 @@ const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3929
3966
  n64_act_as: bs,
3930
3967
  n65_code_verifier: Ss,
3931
3968
  n66_email_providers: $s,
3932
- n67_drop_tickets: Ps,
3969
+ n67_drop_tickets: js,
3933
3970
  n68_login_useragents: Fs,
3934
3971
  n70_refresh_tokens: zs,
3935
3972
  n71_session_new_fields: Ks,
@@ -3939,41 +3976,44 @@ const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3939
3976
  n75_organizations: Zs,
3940
3977
  n76_authorization_url_length: ai,
3941
3978
  n77_drop_sessions: oi,
3942
- n78_login_sessions: di,
3979
+ n78_login_sessions: li,
3943
3980
  n79_drop_sessions_2: ui,
3944
3981
  n80_recreate_custom_domains: _i,
3945
3982
  n81_phone: gi,
3946
3983
  n82_forms: vi,
3947
3984
  n83_addFormsIdToHooks: bi,
3948
- n84_login_completed: Si
3985
+ n84_login_completed: Si,
3986
+ n85_add_login_session_id_to_sessions: $i,
3987
+ n86_index_sessions_login_session_id: ji,
3988
+ n87_code_challenge: Fi
3949
3989
  };
3950
- async function Ii(t, e = !1) {
3990
+ async function Ei(t, e = !1) {
3951
3991
  e && console.log("migrating...");
3952
- const a = new Le(ze), r = new Ce({
3992
+ const a = new Le(ze), n = new Ce({
3953
3993
  db: t,
3954
3994
  provider: a
3955
- }), { error: n, results: o } = await r.migrateToLatest();
3995
+ }), { error: r, results: o } = await n.migrateToLatest();
3956
3996
  if (o == null || o.forEach((s) => {
3957
3997
  s.status === "Success" ? e && console.log(
3958
3998
  `migration "${s.migrationName}" was executed successfully`
3959
3999
  ) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
3960
- }), n)
3961
- throw console.error("failed to migrate"), console.error(n), n;
4000
+ }), r)
4001
+ throw console.error("failed to migrate"), console.error(r), r;
3962
4002
  }
3963
- async function Pi(t) {
4003
+ async function Ki(t) {
3964
4004
  console.log("migrating...");
3965
4005
  const e = new Le(ze), a = new Ce({
3966
4006
  db: t,
3967
4007
  provider: e
3968
- }), { error: r, results: n } = await a.migrateDown();
3969
- if (n == null || n.forEach((o) => {
4008
+ }), { error: n, results: r } = await a.migrateDown();
4009
+ if (r == null || r.forEach((o) => {
3970
4010
  o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
3971
- }), r)
3972
- throw console.error("failed to migrate"), console.error(r), r;
4011
+ }), n)
4012
+ throw console.error("failed to migrate"), console.error(n), n;
3973
4013
  }
3974
- function ji(t) {
4014
+ function Ri(t) {
3975
4015
  return {
3976
- applications: Pt(t),
4016
+ applications: jt(t),
3977
4017
  branding: Zt(t),
3978
4018
  cleanup: $a(t),
3979
4019
  clients: Jt(t),
@@ -3996,7 +4036,7 @@ function ji(t) {
3996
4036
  };
3997
4037
  }
3998
4038
  export {
3999
- ji as default,
4000
- Pi as migrateDown,
4001
- Ii as migrateToLatest
4039
+ Ri as default,
4040
+ Ki as migrateDown,
4041
+ Ei as migrateToLatest
4002
4042
  };