@authhero/kysely-adapter 10.17.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,33 +77,33 @@ 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, d = {
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
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
108
  let s = o.startsWith("-"), d, l, h, m;
109
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 };
@@ -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,12 +149,12 @@ 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), d = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], l = o.map((m) => {
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
158
  const w = d.filter(
159
159
  (x) => x.linked_to === m.user_id
160
160
  );
@@ -174,7 +174,7 @@ 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
179
  users: l,
180
180
  start: a.page * a.per_page,
@@ -187,46 +187,46 @@ 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
189
  function P(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) ? P(o, n, a) : typeof o == "boolean" ? a[n] = o ? 1 : 0 : a[n] = o;
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 = P({
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) {
@@ -276,31 +276,31 @@ function at(t) {
276
276
  a = a.orderBy(d(e.sort.sort_by), e.sort.sort_order);
277
277
  }
278
278
  e.q && (a = a.where((d) => d.or([d("name", "like", `%${e.q}%`)])));
279
- const n = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
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
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) {
@@ -364,18 +364,18 @@ function lt(t) {
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
371
  const { ref: d } = t.dynamic;
372
- n = n.orderBy(
372
+ r = r.orderBy(
373
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((d) => d.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,
@@ -386,8 +386,8 @@ function lt(t) {
386
386
  }
387
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) {
@@ -399,10 +399,10 @@ function ct(t) {
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, ...d } = r;
405
+ const { tenant_id: r, device: o, clients: s, ...d } = n;
406
406
  return {
407
407
  ...d,
408
408
  device: JSON.parse(o),
@@ -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,18 +447,18 @@ 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
454
  const { ref: l } = t.dynamic;
455
- n = n.orderBy(
455
+ r = r.orderBy(
456
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((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = 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
463
  sessions: o.map((l) => ({
464
464
  ...l,
@@ -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,9 +521,9 @@ 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((l) => l.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
528
  codes: o.map((l) => {
529
529
  const { tenant_id: h, ...m } = l;
@@ -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), d = JSON.stringify(a.allowed_logout_urls), l = 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
588
  allowed_logout_urls: d,
589
589
  allowed_clients: l
590
- }).execute(), r;
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,19 +622,19 @@ 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
640
  function jt(t) {
@@ -648,18 +648,18 @@ function jt(t) {
648
648
  }
649
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,14 +668,14 @@ 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(
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
674
  (l) => f({
675
675
  ...l,
676
676
  options: JSON.parse(l.options)
677
677
  })
678
- ), { count: d } = await r.select((l) => l.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,
@@ -689,22 +689,22 @@ 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
  }
@@ -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,8 +843,8 @@ 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
850
  colors_page_background_end: d,
@@ -855,7 +855,7 @@ function Xt(t) {
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,
@@ -869,12 +869,12 @@ function Xt(t) {
869
869
  }
870
870
  function Yt(t) {
871
871
  return async (e, a) => {
872
- var s, d, l, h, m, w, x, ee, te, ae, re, ne, oe, se, ie, le, de, 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,
877
+ colors_primary: n == null ? void 0 : n.primary,
878
878
  colors_page_background_type: (d = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : d.type,
879
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,
@@ -885,9 +885,9 @@ 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
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
@@ -907,9 +907,9 @@ 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((l) => l.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
914
  hooks: o.map((l) => {
915
915
  const { tenant_id: h, enabled: m, synchronous: w, ...x } = l;
@@ -927,62 +927,62 @@ 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({ ...P(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) {
@@ -990,17 +990,17 @@ function ia(t) {
990
990
  }
991
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
997
  function da(t) {
998
- return async (e, a, r) => {
999
- const n = P({
1000
- ...r,
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) {
@@ -1013,12 +1013,12 @@ function ca(t) {
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
- ...P(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(
1046
+ return async (e, a, n) => (await t.updateTable("login_sessions").set(
1047
1047
  P({
1048
- ...r
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
1112
  ...d
1113
1113
  } = a;
1114
1114
  return f({
1115
1115
  ...d,
1116
- credentials: JSON.parse(n),
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,18 +1197,18 @@ 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
1204
  const { ref: l } = t.dynamic;
1205
- n = n.orderBy(
1205
+ r = r.orderBy(
1206
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((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = b(s);
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
1212
  return {
1213
1213
  refresh_tokens: o.map((l) => ({
1214
1214
  ...l,
@@ -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,9 +1280,9 @@ 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((l) => {
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
1286
  const h = { ...l };
1287
1287
  if (typeof h.nodes == "string")
1288
1288
  try {
@@ -1300,7 +1300,7 @@ function Ia(t) {
1300
1300
  } catch {
1301
1301
  }
1302
1302
  return K.parse(f(h));
1303
- }), { count: d } = await r.select((l) => l.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,
@@ -1311,41 +1311,41 @@ function Ia(t) {
1311
1311
  }
1312
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
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
  }
@@ -2286,58 +2286,58 @@ class Ea extends za {
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,
2303
+ const n = super.transformSchemableIdentifier(a);
2304
+ return n.schema || !c(this, O).has(a.identifier.name) ? n : {
2305
+ ...n,
2306
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, j), 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
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;
@@ -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
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((d) => d.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,39 +2567,39 @@ _ = 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
2584
  const { direction: d, step: l } = e(s);
2585
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, je).call(this, e);
2593
- u(this, i, Pe).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) => ({
@@ -2607,23 +2607,23 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
2607
2607
  name: a
2608
2608
  }));
2609
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((r) => r.name);
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
2611
  }, Pe = 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`);
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((d) => d.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 d = n[s];
2626
+ const d = r[s];
2627
2627
  try {
2628
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
2629
  migrationName: d.name,
@@ -2642,8 +2642,8 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
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"
@@ -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 lr(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 dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2852
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2853
2853
  __proto__: null,
2854
- down: lr,
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 jr(t) {
2946
+ async function Pn(t) {
2947
2947
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2948
2948
  }
2949
- const Pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2949
+ const Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2950
2950
  __proto__: null,
2951
- down: jr,
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 ln(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 dn(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: dn,
3060
- up: ln
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 jn(t) {
3142
+ async function jr(t) {
3143
3143
  }
3144
- async function Pn(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: Pn,
3149
- up: jn
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) {
@@ -3488,14 +3488,14 @@ 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
  }
@@ -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(
@@ -3877,47 +3877,69 @@ const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3877
3877
  __proto__: null,
3878
3878
  down: ki,
3879
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
3880
3902
  }, Symbol.toStringTag, { value: "Module" })), ze = {
3881
3903
  m1_init: Wa,
3882
3904
  m2_magicLink: Xa,
3883
- m3_updateAt: er,
3884
- m4_logTable: rr,
3885
- m5_userProfile: sr,
3886
- m6_sessions: dr,
3887
- m7_passwords: mr,
3888
- m8_logsTableNewFields: fr,
3889
- m9_passwordTableNewField: yr,
3890
- n01_codesTable: Nr,
3891
- n11_universalLoginSession: xr,
3892
- n12_userFields: Or,
3893
- n13_userEmailIndex: Dr,
3894
- n14_profileDataField: Pr,
3895
- n15_userEmailIndex: Ar,
3896
- n16_userLocale: Jr,
3897
- n17_signingKeys: Rr,
3898
- n18_logsFields: Qr,
3899
- n19_connectionsUserinfo: Wr,
3900
- n20_missingFields: Xr,
3901
- n21_sessionDeletedAt: en,
3902
- n22_dropLogsFields: rn,
3903
- n23_dropUsersFields: sn,
3904
- n24_logsIndexes: cn,
3905
- n25_logDescMaxLength: hn,
3906
- n26_logsTableExtraFields: pn,
3907
- n27_usersTableNameIndex: wn,
3908
- n28_usersEmailConstrain: Cn,
3909
- n29_increaseOtpStateLength: Tn,
3910
- n30_increaseTicketStateLength: kn,
3911
- n31_branding: In,
3912
- n32_indexesAndNotNull: Mn,
3913
- n33_vendorIdInUniversalLoginSession: Ln,
3914
- n34_auth0ClientInUniversalLoginSession: En,
3915
- n35_increaseUniversalSessionStateLength: Un,
3916
- n36_authenticationCodes: qn,
3917
- n37_disableSignUps: Gn,
3918
- 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,
3919
3941
  n39_increaseUserAgentLength: to,
3920
- n40_userId: no,
3942
+ n40_userId: ro,
3921
3943
  n41_hooks: io,
3922
3944
  n42_userIdIndexes: uo,
3923
3945
  n43_userIdIndexes: _o,
@@ -3961,33 +3983,35 @@ const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3961
3983
  n82_forms: vi,
3962
3984
  n83_addFormsIdToHooks: bi,
3963
3985
  n84_login_completed: Si,
3964
- n85_add_login_session_id_to_sessions: $i
3986
+ n85_add_login_session_id_to_sessions: $i,
3987
+ n86_index_sessions_login_session_id: ji,
3988
+ n87_code_challenge: Fi
3965
3989
  };
3966
- async function Mi(t, e = !1) {
3990
+ async function Ei(t, e = !1) {
3967
3991
  e && console.log("migrating...");
3968
- const a = new Le(ze), r = new Ce({
3992
+ const a = new Le(ze), n = new Ce({
3969
3993
  db: t,
3970
3994
  provider: a
3971
- }), { error: n, results: o } = await r.migrateToLatest();
3995
+ }), { error: r, results: o } = await n.migrateToLatest();
3972
3996
  if (o == null || o.forEach((s) => {
3973
3997
  s.status === "Success" ? e && console.log(
3974
3998
  `migration "${s.migrationName}" was executed successfully`
3975
3999
  ) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
3976
- }), n)
3977
- throw console.error("failed to migrate"), console.error(n), n;
4000
+ }), r)
4001
+ throw console.error("failed to migrate"), console.error(r), r;
3978
4002
  }
3979
- async function Fi(t) {
4003
+ async function Ki(t) {
3980
4004
  console.log("migrating...");
3981
4005
  const e = new Le(ze), a = new Ce({
3982
4006
  db: t,
3983
4007
  provider: e
3984
- }), { error: r, results: n } = await a.migrateDown();
3985
- if (n == null || n.forEach((o) => {
4008
+ }), { error: n, results: r } = await a.migrateDown();
4009
+ if (r == null || r.forEach((o) => {
3986
4010
  o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
3987
- }), r)
3988
- throw console.error("failed to migrate"), console.error(r), r;
4011
+ }), n)
4012
+ throw console.error("failed to migrate"), console.error(n), n;
3989
4013
  }
3990
- function Ai(t) {
4014
+ function Ri(t) {
3991
4015
  return {
3992
4016
  applications: jt(t),
3993
4017
  branding: Zt(t),
@@ -4012,7 +4036,7 @@ function Ai(t) {
4012
4036
  };
4013
4037
  }
4014
4038
  export {
4015
- Ai as default,
4016
- Fi as migrateDown,
4017
- Mi as migrateToLatest
4039
+ Ri as default,
4040
+ Ki as migrateDown,
4041
+ Ei as migrateToLatest
4018
4042
  };