@authhero/kysely-adapter 10.20.0 → 10.22.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.
@@ -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: n, ...r } = a, o = {
29
- ...r,
28
+ const { identities: n, ...o } = a, r = {
29
+ ...o,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
@@ -37,16 +37,16 @@ function Qe(t) {
37
37
  user_metadata: JSON.stringify(a.user_metadata)
38
38
  };
39
39
  try {
40
- await t.insertInto("users").values(o).execute();
40
+ await t.insertInto("users").values(r).execute();
41
41
  } catch (s) {
42
42
  throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new V(409, { message: "User already exists" }) : new V(500, { message: `${s.code}, ${s.message}` });
43
43
  }
44
44
  return {
45
- ...o,
45
+ ...r,
46
46
  // TODO: check if this is correct. Should it be optional?
47
- email: o.email || "",
48
- email_verified: o.email_verified === 1,
49
- is_social: o.is_social === 1
47
+ email: r.email || "",
48
+ email_verified: r.email_verified === 1,
49
+ is_social: r.is_social === 1
50
50
  };
51
51
  };
52
52
  }
@@ -77,13 +77,13 @@ function pe(t) {
77
77
  }
78
78
  function qe(t) {
79
79
  return async (e, a) => {
80
- const [n, r] = await Promise.all([
80
+ const [n, o] = 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
84
  if (!n)
85
85
  return null;
86
- const { tenant_id: o, ...s } = n, l = {
86
+ const { tenant_id: r, ...s } = n, l = {
87
87
  ...s,
88
88
  email: n.email || "",
89
89
  email_verified: n.email_verified === 1,
@@ -97,39 +97,39 @@ function qe(t) {
97
97
  user_id: Z(n.user_id).id,
98
98
  isSocial: !!n.is_social
99
99
  },
100
- ...r.map(pe)
100
+ ...o.map(pe)
101
101
  ]
102
102
  };
103
103
  return f(l);
104
104
  };
105
105
  }
106
106
  function T(t, e, a, n) {
107
- return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
108
- let s = o.startsWith("-"), l, c, h, m;
109
- return o.startsWith("-_exists_:") ? (l = o.substring(10), h = !0, s = !0) : o.startsWith("_exists_:") ? (l = o.substring(9), h = !0, s = !1) : o.includes(":") ? (s = o.startsWith("-"), [l, c] = s ? o.substring(1).split(":") : o.split(":"), h = !1, c.startsWith(">=") ? (m = ">=", c = c.substring(2)) : c.startsWith(">") ? (m = ">", c = c.substring(1)) : c.startsWith("<=") ? (m = "<=", c = c.substring(2)) : c.startsWith("<") ? (m = "<", c = c.substring(1)) : m = "=") : (l = null, c = o, h = !1), { key: l, value: c, isNegation: s, isExistsQuery: h, operator: m };
110
- }).forEach(({ key: o, value: s, isNegation: l, isExistsQuery: c, operator: h }) => {
111
- if (o)
107
+ return a.split(/\s+/).map((r) => r.replace(/^([^:]+)=/g, "$1:")).map((r) => {
108
+ let s = r.startsWith("-"), l, c, h, m;
109
+ return r.startsWith("-_exists_:") ? (l = r.substring(10), h = !0, s = !0) : r.startsWith("_exists_:") ? (l = r.substring(9), h = !0, s = !1) : r.includes(":") ? (s = r.startsWith("-"), [l, c] = s ? r.substring(1).split(":") : r.split(":"), h = !1, c.startsWith(">=") ? (m = ">=", c = c.substring(2)) : c.startsWith(">") ? (m = ">", c = c.substring(1)) : c.startsWith("<=") ? (m = "<=", c = c.substring(2)) : c.startsWith("<") ? (m = "<", c = c.substring(1)) : m = "=") : (l = null, c = r, h = !1), { key: l, value: c, isNegation: s, isExistsQuery: h, operator: m };
110
+ }).forEach(({ key: r, value: s, isNegation: l, isExistsQuery: c, operator: h }) => {
111
+ if (r)
112
112
  if (c)
113
- l ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
113
+ l ? e = e.where(r, "is", null) : e = e.where(r, "is not", null);
114
114
  else if (l)
115
115
  switch (h) {
116
116
  case ">":
117
- e = e.where(o, "<=", s);
117
+ e = e.where(r, "<=", s);
118
118
  break;
119
119
  case ">=":
120
- e = e.where(o, "<", s);
120
+ e = e.where(r, "<", s);
121
121
  break;
122
122
  case "<":
123
- e = e.where(o, ">=", s);
123
+ e = e.where(r, ">=", s);
124
124
  break;
125
125
  case "<=":
126
- e = e.where(o, ">", s);
126
+ e = e.where(r, ">", s);
127
127
  break;
128
128
  default:
129
- e = e.where(o, "!=", s);
129
+ e = e.where(r, "!=", s);
130
130
  }
131
131
  else
132
- e = e.where(o, h, s);
132
+ e = e.where(r, h, s);
133
133
  else {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
@@ -154,7 +154,7 @@ function Ve(t) {
154
154
  const { ref: m } = t.dynamic;
155
155
  n = n.orderBy(m(a.sort.sort_by), a.sort.sort_order);
156
156
  }
157
- const o = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], c = o.map((m) => {
157
+ const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = r.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], c = r.map((m) => {
158
158
  const w = l.filter(
159
159
  (x) => x.linked_to === m.user_id
160
160
  );
@@ -189,24 +189,24 @@ function We(t) {
189
189
  function P(t, e = "", a = {}) {
190
190
  for (let n in t)
191
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;
192
+ const o = e ? `${e}_${n}` : n, r = t[n];
193
+ typeof r == "object" && r !== null && !Array.isArray(r) ? P(r, o, a) : typeof r == "boolean" ? a[o] = r ? 1 : 0 : a[o] = r;
194
194
  }
195
195
  return a;
196
196
  }
197
197
  function Ge(t, e) {
198
198
  const a = {};
199
- for (const [n, r] of Object.entries(t)) {
200
- const o = e.find(
199
+ for (const [n, o] of Object.entries(t)) {
200
+ const r = e.find(
201
201
  (s) => n.startsWith(`${s}_`)
202
202
  );
203
- if (!o)
204
- a[n] = r;
203
+ if (!r)
204
+ a[n] = o;
205
205
  else {
206
- const s = n.slice(o.length + 1);
207
- a[o] = {
208
- ...a[o],
209
- [s]: r
206
+ const s = n.slice(r.length + 1);
207
+ a[r] = {
208
+ ...a[r],
209
+ [s]: o
210
210
  };
211
211
  }
212
212
  }
@@ -214,19 +214,19 @@ function Ge(t, e) {
214
214
  }
215
215
  function He(t) {
216
216
  return async (e, a, n) => {
217
- const r = P({
217
+ const o = P({
218
218
  ...n,
219
219
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
220
220
  app_metadata: n.app_metadata ? JSON.stringify(n.app_metadata) : void 0,
221
221
  user_metadata: n.user_metadata ? JSON.stringify(n.user_metadata) : void 0
222
222
  });
223
- return (await t.updateTable("users").set(r).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
223
+ return (await t.updateTable("users").set(o).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, n, r) => {
228
- const o = { linked_to: null };
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;
227
+ return async (e, a, n, o) => {
228
+ const r = { linked_to: null };
229
+ return (await t.updateTable("users").set(r).where("users.tenant_id", "=", e).where("users.user_id", "=", `${n}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
230
230
  };
231
231
  }
232
232
  function Ye(t) {
@@ -276,14 +276,14 @@ function at(t) {
276
276
  a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
277
277
  }
278
278
  e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
279
- const r = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
279
+ const o = 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: r
282
+ tenants: o
283
283
  };
284
- const { count: o } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(o);
284
+ const { count: r } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(r);
285
285
  return {
286
- tenants: r.map(f),
286
+ tenants: o.map(f),
287
287
  start: (e.page - 1) * e.per_page,
288
288
  limit: e.per_page,
289
289
  length: s
@@ -318,7 +318,7 @@ function me(t) {
318
318
  const st = 1024;
319
319
  function it(t) {
320
320
  return async (e, a) => {
321
- var r, o, s;
321
+ var o, r, s;
322
322
  const n = {
323
323
  id: S(),
324
324
  ...a,
@@ -327,10 +327,10 @@ function it(t) {
327
327
  return await t.insertInto("logs").values({
328
328
  ...n,
329
329
  // Truncate long strings to avoid database errors
330
- description: (r = n.description) == null ? void 0 : r.substring(0, 256),
330
+ description: (o = n.description) == null ? void 0 : o.substring(0, 256),
331
331
  isMobile: a.isMobile ? 1 : 0,
332
332
  tenant_id: e,
333
- scope: (o = a.scope) == null ? void 0 : o.join(","),
333
+ scope: (r = a.scope) == null ? void 0 : r.join(","),
334
334
  auth0_client: me(a.auth0_client),
335
335
  details: (s = me(a.details)) == null ? void 0 : s.substring(0, 8192)
336
336
  }).execute(), n;
@@ -366,18 +366,18 @@ function ct(t) {
366
366
  }) => {
367
367
  let n = t.selectFrom("logs").where("logs.tenant_id", "=", e);
368
368
  a.q && (n = T(t, n, a.q, ["user_id", "ip"]));
369
- let r = n;
369
+ let o = n;
370
370
  if (a.sort && a.sort.sort_by) {
371
371
  const { ref: l } = t.dynamic;
372
- r = r.orderBy(
372
+ o = o.orderBy(
373
373
  l(a.sort.sort_by),
374
374
  a.sort.sort_order
375
375
  );
376
376
  }
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((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
377
+ o = o.offset(a.page * a.per_page).limit(a.per_page);
378
+ const r = await o.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
379
379
  return {
380
- logs: o.map(ge),
380
+ logs: r.map(ge),
381
381
  start: a.page * a.per_page,
382
382
  limit: a.per_page,
383
383
  length: b(s)
@@ -402,10 +402,10 @@ function ut(t) {
402
402
  const n = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
403
403
  if (!n)
404
404
  return null;
405
- const { tenant_id: r, device: o, clients: s, ...l } = n;
405
+ const { tenant_id: o, device: r, clients: s, ...l } = n;
406
406
  return {
407
407
  ...l,
408
- device: JSON.parse(o),
408
+ device: JSON.parse(r),
409
409
  clients: JSON.parse(s)
410
410
  };
411
411
  };
@@ -432,13 +432,13 @@ function ht(t) {
432
432
  }
433
433
  function _t(t) {
434
434
  return async (e, a, n) => {
435
- const r = {
435
+ const o = {
436
436
  ...n,
437
437
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
438
438
  device: n.device ? JSON.stringify(n.device) : void 0,
439
439
  clients: n.clients ? JSON.stringify(n.clients) : void 0
440
440
  };
441
- return !!(await t.updateTable("sessions").set(r).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
441
+ return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
442
442
  };
443
443
  }
444
444
  function ft(t) {
@@ -449,18 +449,18 @@ function ft(t) {
449
449
  }) => {
450
450
  let n = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
451
451
  a.q && (n = T(t, n, a.q, ["user_id", "session_id"]));
452
- let r = n;
452
+ let o = n;
453
453
  if (a.sort && a.sort.sort_by) {
454
454
  const { ref: c } = t.dynamic;
455
- r = r.orderBy(
455
+ o = o.orderBy(
456
456
  c(a.sort.sort_by),
457
457
  a.sort.sort_order
458
458
  );
459
459
  }
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((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
460
+ o = o.offset(a.page * a.per_page).limit(a.per_page);
461
+ const r = await o.selectAll().execute(), { count: s } = await n.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
462
462
  return {
463
- sessions: o.map((c) => ({
463
+ sessions: r.map((c) => ({
464
464
  ...c,
465
465
  device: JSON.parse(c.device),
466
466
  clients: JSON.parse(c.clients)
@@ -485,8 +485,8 @@ function gt(t) {
485
485
  const n = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
486
486
  if (!n)
487
487
  return null;
488
- const { tenant_id: r, ...o } = n;
489
- return o;
488
+ const { tenant_id: o, ...r } = n;
489
+ return r;
490
490
  };
491
491
  }
492
492
  function yt(t) {
@@ -523,9 +523,9 @@ function Nt(t) {
523
523
  }) => {
524
524
  let n = t.selectFrom("codes").where("codes.tenant_id", "=", e);
525
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((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
526
+ const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
527
527
  return {
528
- codes: o.map((c) => {
528
+ codes: r.map((c) => {
529
529
  const { tenant_id: h, ...m } = c;
530
530
  return Ke.parse(f(m));
531
531
  }),
@@ -552,10 +552,10 @@ function bt(t) {
552
552
  }
553
553
  function xt(t) {
554
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
- return o ? f(o) : null;
555
+ let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", n);
556
+ e.length && (o = o.where("codes.tenant_id", "=", e));
557
+ const r = await o.selectAll().executeTakeFirst();
558
+ return r ? f(r) : null;
559
559
  };
560
560
  }
561
561
  function Tt(t) {
@@ -576,14 +576,14 @@ function Ot(t) {
576
576
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
577
577
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
578
578
  ...a
579
- }, r = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), c = JSON.stringify(a.allowed_clients);
579
+ }, o = JSON.stringify(a.allowed_origins), r = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), c = JSON.stringify(a.allowed_clients);
580
580
  return await t.insertInto("applications").values({
581
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
- callbacks: o,
586
- allowed_origins: r,
585
+ callbacks: r,
586
+ allowed_origins: o,
587
587
  web_origins: s,
588
588
  allowed_logout_urls: l,
589
589
  allowed_clients: c
@@ -592,15 +592,15 @@ function Ot(t) {
592
592
  }
593
593
  function kt(t) {
594
594
  return async (e) => ({
595
- applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((o) => ({
596
- ...o,
597
- disable_sign_ups: !!o.disable_sign_ups,
598
- addons: o.addons ? JSON.parse(o.addons) : {},
599
- callbacks: o.callbacks ? JSON.parse(o.callbacks) : [],
600
- allowed_origins: o.allowed_origins ? JSON.parse(o.allowed_origins) : [],
601
- web_origins: o.web_origins ? JSON.parse(o.web_origins) : [],
602
- allowed_logout_urls: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : [],
603
- allowed_clients: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : []
595
+ applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((r) => ({
596
+ ...r,
597
+ disable_sign_ups: !!r.disable_sign_ups,
598
+ addons: r.addons ? JSON.parse(r.addons) : {},
599
+ callbacks: r.callbacks ? JSON.parse(r.callbacks) : [],
600
+ allowed_origins: r.allowed_origins ? JSON.parse(r.allowed_origins) : [],
601
+ web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
602
+ allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
603
+ allowed_clients: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : []
604
604
  }))
605
605
  });
606
606
  }
@@ -623,7 +623,7 @@ function Dt(t) {
623
623
  }
624
624
  function It(t) {
625
625
  return async (e, a, n) => {
626
- const r = {
626
+ const o = {
627
627
  ...n,
628
628
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
629
629
  allowed_origins: n.allowed_origins ? JSON.stringify(n.allowed_origins) : void 0,
@@ -634,7 +634,7 @@ function It(t) {
634
634
  addons: n.addons ? JSON.stringify(n.addons) : "{}",
635
635
  disable_sign_ups: n.disable_sign_ups ? 1 : 0
636
636
  };
637
- return await t.updateTable("applications").set(r).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
637
+ return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
638
638
  };
639
639
  }
640
640
  function jt(t) {
@@ -698,13 +698,13 @@ function At(t) {
698
698
  }
699
699
  function Lt(t) {
700
700
  return async (e, a, n) => {
701
- const r = {
701
+ const o = {
702
702
  ...n,
703
703
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
704
704
  };
705
705
  return await t.updateTable("connections").set({
706
- ...r,
707
- options: r.options ? JSON.stringify(r.options) : void 0
706
+ ...o,
707
+ options: o.options ? JSON.stringify(o.options) : void 0
708
708
  }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
709
709
  };
710
710
  }
@@ -726,10 +726,10 @@ function Jt(t) {
726
726
  const n = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
727
727
  if (!n)
728
728
  throw new V(404, { message: "Tenant not found" });
729
- const r = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
729
+ const o = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
730
730
  return {
731
731
  ...a,
732
- connections: r.map(
732
+ connections: o.map(
733
733
  (s) => Re.parse(
734
734
  f({
735
735
  ...s,
@@ -810,12 +810,12 @@ function Vt(t) {
810
810
  }
811
811
  function Wt(t) {
812
812
  return async (e, a, n) => {
813
- const r = {
813
+ const o = {
814
814
  ...n,
815
815
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
816
816
  primary: n.primary ? 1 : 0
817
817
  };
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;
818
+ return (await t.updateTable("custom_domains").set(o).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) {
@@ -844,8 +844,8 @@ function Xt(t) {
844
844
  return null;
845
845
  const {
846
846
  tenant_id: n,
847
- colors_primary: r,
848
- colors_page_background_type: o,
847
+ colors_primary: o,
848
+ colors_page_background_type: r,
849
849
  colors_page_background_start: s,
850
850
  colors_page_background_end: l,
851
851
  colors_page_background_angle_dev: c,
@@ -855,9 +855,9 @@ function Xt(t) {
855
855
  return f({
856
856
  ...m,
857
857
  colors: {
858
- primary: r,
858
+ primary: o,
859
859
  page_background: {
860
- type: o,
860
+ type: r,
861
861
  start: s,
862
862
  end: l,
863
863
  angle_deg: c
@@ -870,10 +870,10 @@ function Xt(t) {
870
870
  function Yt(t) {
871
871
  return async (e, a) => {
872
872
  var s, l, c, h, m, w, x, ee, te, ae, ne, re, oe, se, ie, ce, le, de;
873
- const { colors: n, font: r, ...o } = a;
873
+ const { colors: n, font: o, ...r } = a;
874
874
  try {
875
875
  await t.insertInto("branding").values({
876
- ...o,
876
+ ...r,
877
877
  colors_primary: n == null ? void 0 : n.primary,
878
878
  colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
879
879
  colors_page_background_start: (h = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : h.start,
@@ -884,7 +884,7 @@ function Yt(t) {
884
884
  }).execute();
885
885
  } catch {
886
886
  await t.updateTable("branding").set({
887
- ...o,
887
+ ...r,
888
888
  colors_primary: n == null ? void 0 : n.primary,
889
889
  colors_page_background_type: (ne = (ae = a.colors) == null ? void 0 : ae.page_background) == null ? void 0 : ne.type,
890
890
  colors_page_background_start: (oe = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : oe.start,
@@ -909,9 +909,9 @@ function ea(t) {
909
909
  }) => {
910
910
  let n = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
911
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((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
912
+ const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
913
913
  return {
914
- hooks: o.map((c) => {
914
+ hooks: r.map((c) => {
915
915
  const { tenant_id: h, enabled: m, synchronous: w, ...x } = c;
916
916
  return f({
917
917
  ...x,
@@ -956,13 +956,13 @@ function na(t) {
956
956
  }
957
957
  function ra(t) {
958
958
  return async (e, a, n) => {
959
- const r = {
959
+ const o = {
960
960
  ...n,
961
961
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
962
962
  enabled: n.enabled !== void 0 ? n.enabled ? 1 : 0 : void 0,
963
963
  synchronous: n.enabled !== void 0 ? n.synchronous ? 1 : 0 : void 0
964
964
  };
965
- return await t.updateTable("hooks").set(r).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
965
+ return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
966
966
  };
967
967
  }
968
968
  function oa(t) {
@@ -996,11 +996,11 @@ function ca(t) {
996
996
  }
997
997
  function la(t) {
998
998
  return async (e, a, n) => {
999
- const r = P({
999
+ const o = P({
1000
1000
  ...n,
1001
1001
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1002
1002
  });
1003
- return await t.updateTable("themes").set(r).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1003
+ return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1004
1004
  };
1005
1005
  }
1006
1006
  function da(t) {
@@ -1013,12 +1013,12 @@ function da(t) {
1013
1013
  }
1014
1014
  function ua(t) {
1015
1015
  return async (e, a) => {
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(
1016
+ const n = await t.selectFrom("login_sessions").where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1017
+ return n ? Ue.parse(
1018
1018
  Ge(
1019
1019
  f({
1020
- ...r,
1021
- login_completed: !!r.login_completed
1020
+ ...n,
1021
+ login_completed: !!n.login_completed
1022
1022
  }),
1023
1023
  ["authParams"]
1024
1024
  )
@@ -1027,11 +1027,11 @@ function ua(t) {
1027
1027
  }
1028
1028
  function ma(t) {
1029
1029
  return async (e, a) => {
1030
- var r;
1030
+ var o;
1031
1031
  const n = {
1032
1032
  id: S(),
1033
1033
  ...a,
1034
- authorization_url: (r = a.authorization_url) == null ? void 0 : r.slice(0, 1024),
1034
+ authorization_url: (o = a.authorization_url) == null ? void 0 : o.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
@@ -1106,38 +1106,38 @@ function wa(t) {
1106
1106
  return null;
1107
1107
  const {
1108
1108
  tenant_id: n,
1109
- credentials: r,
1110
- settings: o,
1109
+ credentials: o,
1110
+ settings: r,
1111
1111
  enabled: s,
1112
1112
  ...l
1113
1113
  } = a;
1114
1114
  return f({
1115
1115
  ...l,
1116
- credentials: JSON.parse(r),
1117
- settings: JSON.parse(o),
1116
+ credentials: JSON.parse(o),
1117
+ settings: JSON.parse(r),
1118
1118
  enabled: !!s
1119
1119
  });
1120
1120
  };
1121
1121
  }
1122
1122
  function va(t) {
1123
1123
  return async (e, a) => {
1124
- const { credentials: n, settings: r, enabled: o, ...s } = a;
1124
+ const { credentials: n, settings: o, enabled: r, ...s } = a;
1125
1125
  await t.updateTable("email_providers").set({
1126
1126
  ...s,
1127
1127
  credentials: n ? JSON.stringify(n) : void 0,
1128
- settings: r ? JSON.stringify(r) : void 0,
1129
- enabled: o !== void 0 ? o ? 1 : 0 : void 0
1128
+ settings: o ? JSON.stringify(o) : void 0,
1129
+ enabled: r !== void 0 ? r ? 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: n, settings: r, enabled: o, ...s } = a;
1135
+ const { credentials: n, settings: o, enabled: r, ...s } = a;
1136
1136
  await t.insertInto("email_providers").values({
1137
1137
  ...s,
1138
- enabled: o ? 1 : 0,
1138
+ enabled: r ? 1 : 0,
1139
1139
  credentials: JSON.stringify(n),
1140
- settings: JSON.stringify(r),
1140
+ settings: JSON.stringify(o),
1141
1141
  tenant_id: e,
1142
1142
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1143
1143
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1182,13 +1182,13 @@ function Ta(t) {
1182
1182
  }
1183
1183
  function Sa(t) {
1184
1184
  return async (e, a, n) => {
1185
- const r = {
1185
+ const o = {
1186
1186
  ...n,
1187
1187
  device: n.device ? JSON.stringify(n.device) : void 0,
1188
1188
  resource_servers: n.resource_servers ? JSON.stringify(n.resource_servers) : void 0,
1189
1189
  rotating: n.rotating ? 1 : 0
1190
1190
  };
1191
- return !!(await t.updateTable("refresh_tokens").set(r).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1191
+ return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1192
1192
  };
1193
1193
  }
1194
1194
  function Oa(t) {
@@ -1199,18 +1199,18 @@ function Oa(t) {
1199
1199
  }) => {
1200
1200
  let n = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1201
1201
  a.q && (n = T(t, n, a.q, ["token", "session_id"]));
1202
- let r = n;
1202
+ let o = n;
1203
1203
  if (a.sort && a.sort.sort_by) {
1204
1204
  const { ref: c } = t.dynamic;
1205
- r = r.orderBy(
1205
+ o = o.orderBy(
1206
1206
  c(a.sort.sort_by),
1207
1207
  a.sort.sort_order
1208
1208
  );
1209
1209
  }
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((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
1210
+ o = o.offset(a.page * a.per_page).limit(a.per_page);
1211
+ const r = await o.selectAll().execute(), { count: s } = await n.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
1212
1212
  return {
1213
- refresh_tokens: o.map((c) => ({
1213
+ refresh_tokens: r.map((c) => ({
1214
1214
  ...c,
1215
1215
  rotating: !!c.rotating,
1216
1216
  device: c.device ? JSON.parse(c.device) : {},
@@ -1239,20 +1239,20 @@ function $a(t) {
1239
1239
  Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
1240
1240
  ).toISOString();
1241
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
- (o) => o.or([
1244
- o("expires_at", "<", a),
1245
- o("idle_expires_at", "<", a)
1242
+ const o = await t.selectFrom("sessions").select("id").where(
1243
+ (r) => r.or([
1244
+ r("expires_at", "<", a),
1245
+ r("idle_expires_at", "<", a)
1246
1246
  ])
1247
1247
  ).where(
1248
1248
  "id",
1249
1249
  "not in",
1250
1250
  t.selectFrom("refresh_tokens").select("session_id")
1251
1251
  ).limit(1e5).execute();
1252
- r.length > 0 && await t.deleteFrom("sessions").where(
1252
+ o.length > 0 && await t.deleteFrom("sessions").where(
1253
1253
  "id",
1254
1254
  "in",
1255
- r.map((o) => o.id)
1255
+ o.map((r) => r.id)
1256
1256
  ).execute(), console.log("cleanup complete");
1257
1257
  };
1258
1258
  }
@@ -1319,34 +1319,34 @@ function Pa(t) {
1319
1319
  return async (e, a) => {
1320
1320
  const n = await t.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1321
1321
  if (!n) return null;
1322
- const r = { ...n };
1323
- if (typeof r.nodes == "string")
1322
+ const o = { ...n };
1323
+ if (typeof o.nodes == "string")
1324
1324
  try {
1325
- r.nodes = JSON.parse(r.nodes);
1325
+ o.nodes = JSON.parse(o.nodes);
1326
1326
  } catch {
1327
1327
  }
1328
- if (typeof r.start == "string")
1328
+ if (typeof o.start == "string")
1329
1329
  try {
1330
- r.start = JSON.parse(r.start);
1330
+ o.start = JSON.parse(o.start);
1331
1331
  } catch {
1332
1332
  }
1333
- if (typeof r.ending == "string")
1333
+ if (typeof o.ending == "string")
1334
1334
  try {
1335
- r.ending = JSON.parse(r.ending);
1335
+ o.ending = JSON.parse(o.ending);
1336
1336
  } catch {
1337
1337
  }
1338
- return K.parse(f(r));
1338
+ return K.parse(f(o));
1339
1339
  };
1340
1340
  }
1341
1341
  function Ma(t) {
1342
1342
  return async (e, a, n) => {
1343
- const r = {
1343
+ const o = {
1344
1344
  ...n,
1345
1345
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1346
1346
  };
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
- return o > 0;
1347
+ n.nodes && (o.nodes = JSON.stringify(n.nodes)), n.start && (o.start = JSON.stringify(n.start)), n.ending && (o.ending = JSON.stringify(n.ending));
1348
+ const { numUpdatedRows: r } = await t.updateTable("forms").set(o).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1349
+ return r > 0;
1350
1350
  };
1351
1351
  }
1352
1352
  function Fa(t) {
@@ -2289,15 +2289,15 @@ class Ea extends za {
2289
2289
  const n = u(this, p, ve).call(this, a);
2290
2290
  for (const s of n)
2291
2291
  d(this, k).add(s);
2292
- const r = u(this, p, we).call(this, a);
2293
- for (const s of r)
2292
+ const o = u(this, p, we).call(this, a);
2293
+ for (const s of o)
2294
2294
  d(this, O).add(s);
2295
- const o = super.transformNodeImpl(a);
2296
- for (const s of r)
2295
+ const r = super.transformNodeImpl(a);
2296
+ for (const s of o)
2297
2297
  d(this, O).delete(s);
2298
2298
  for (const s of n)
2299
2299
  d(this, k).delete(s);
2300
- return o;
2300
+ return r;
2301
2301
  }
2302
2302
  transformSchemableIdentifier(a) {
2303
2303
  const n = super.transformSchemableIdentifier(a);
@@ -2319,25 +2319,25 @@ j = new WeakMap(), O = new WeakMap(), k = new WeakMap(), p = new WeakSet(), ye =
2319
2319
  }, we = function(a) {
2320
2320
  const n = /* @__PURE__ */ new Set();
2321
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);
2322
+ for (const o of a.from.froms)
2323
+ u(this, p, $).call(this, o, n);
2324
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);
2325
+ for (const o of a.joins)
2326
+ u(this, p, $).call(this, o.table, n);
2327
2327
  return "using" in a && a.using && u(this, p, $).call(this, a.using, n), n;
2328
2328
  }, ve = function(a) {
2329
2329
  const n = /* @__PURE__ */ new Set();
2330
2330
  return "with" in a && a.with && u(this, p, Ne).call(this, a.with, n), n;
2331
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);
2332
+ const o = B.is(a) ? a : La.is(a) && B.is(a.node) ? a.node : null;
2333
+ o && u(this, p, G).call(this, o.table, n);
2334
2334
  }, G = function(a, n) {
2335
- const r = a.identifier.name;
2336
- !d(this, O).has(r) && !d(this, k).has(r) && n.add(r);
2335
+ const o = a.identifier.name;
2336
+ !d(this, O).has(o) && !d(this, k).has(o) && n.add(o);
2337
2337
  }, Ne = function(a, n) {
2338
- for (const r of a.expressions) {
2339
- const o = r.name.table.table.identifier.name;
2340
- d(this, k).has(o) || n.add(o);
2338
+ for (const o of a.expressions) {
2339
+ const r = o.name.table.table.identifier.name;
2340
+ d(this, k).has(r) || n.add(r);
2341
2341
  }
2342
2342
  };
2343
2343
  var z;
@@ -2377,12 +2377,12 @@ class Ce {
2377
2377
  */
2378
2378
  async getMigrations() {
2379
2379
  const e = await u(this, i, I).call(this, d(this, i, N)) ? await d(this, _).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, N)).select(["name", "timestamp"]).execute() : [];
2380
- return (await u(this, i, Y).call(this)).map(({ name: n, ...r }) => {
2381
- const o = e.find((s) => s.name === n);
2380
+ return (await u(this, i, Y).call(this)).map(({ name: n, ...o }) => {
2381
+ const r = e.find((s) => s.name === n);
2382
2382
  return {
2383
2383
  name: n,
2384
- migration: r,
2385
- executedAt: o ? new Date(o.timestamp) : void 0
2384
+ migration: o,
2385
+ executedAt: r ? new Date(r.timestamp) : void 0
2386
2386
  };
2387
2387
  });
2388
2388
  }
@@ -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: n, pendingMigrations: r }) => {
2463
+ return u(this, i, A).call(this, ({ migrations: a, executedMigrations: n, pendingMigrations: o }) => {
2464
2464
  if (e === Qa)
2465
2465
  return { direction: "Down", step: 1 / 0 };
2466
2466
  if (!a.find((l) => l.name === e))
2467
2467
  throw new Error(`migration "${e}" doesn't exist`);
2468
- const o = n.indexOf(e), s = r.findIndex((l) => l.name === e);
2469
- if (o !== -1)
2468
+ const r = n.indexOf(e), s = o.findIndex((l) => l.name === e);
2469
+ if (r !== -1)
2470
2470
  return {
2471
2471
  direction: "Down",
2472
- step: n.length - o - 1
2472
+ step: n.length - r - 1
2473
2473
  };
2474
2474
  if (s !== -1)
2475
2475
  return { direction: "Up", step: s + 1 };
@@ -2567,7 +2567,7 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
2567
2567
  const a = d(this, i, v);
2568
2568
  return (await d(this, _).db.introspection.getTables({
2569
2569
  withInternalKyselyTables: !0
2570
- })).some((r) => r.name === e && (!a || r.schema === a));
2570
+ })).some((o) => o.name === e && (!a || o.schema === a));
2571
2571
  }, X = async function() {
2572
2572
  return !!await d(this, _).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, D)).where("id", "=", Q).select("id").executeTakeFirst();
2573
2573
  }, $e = async function(e) {
@@ -2575,28 +2575,28 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
2575
2575
  lockTable: d(this, _).migrationLockTableName ?? fe,
2576
2576
  lockRowId: Q,
2577
2577
  lockTableSchema: d(this, _).migrationTableSchema
2578
- }), r = async (o) => {
2578
+ }), o = async (r) => {
2579
2579
  try {
2580
- await a.acquireMigrationLock(o, n);
2581
- const s = await u(this, i, De).call(this, o);
2580
+ await a.acquireMigrationLock(r, n);
2581
+ const s = await u(this, i, De).call(this, r);
2582
2582
  if (s.migrations.length === 0)
2583
2583
  return { results: [] };
2584
2584
  const { direction: l, step: c } = e(s);
2585
- return c <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Fe).call(this, o, s, c) : l === "Up" ? await u(this, i, Ae).call(this, o, s, c) : { results: [] };
2585
+ return c <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Fe).call(this, r, s, c) : l === "Up" ? await u(this, i, Ae).call(this, r, s, c) : { results: [] };
2586
2586
  } finally {
2587
- await a.releaseMigrationLock(o, n);
2587
+ await a.releaseMigrationLock(r, n);
2588
2588
  }
2589
2589
  };
2590
- return a.supportsTransactionalDdl ? d(this, _).db.transaction().execute(r) : d(this, _).db.connection().execute(r);
2590
+ return a.supportsTransactionalDdl ? d(this, _).db.transaction().execute(o) : d(this, _).db.connection().execute(o);
2591
2591
  }, De = async function(e) {
2592
2592
  const a = await u(this, i, Y).call(this), n = await u(this, i, je).call(this, e);
2593
2593
  u(this, i, Pe).call(this, a, n), d(this, i, be) || u(this, i, Me).call(this, a, n);
2594
- const r = u(this, i, Ie).call(this, a, n);
2594
+ const o = u(this, i, Ie).call(this, a, n);
2595
2595
  return g({
2596
2596
  migrations: a,
2597
2597
  executedMigrations: n,
2598
2598
  lastMigration: Aa(n),
2599
- pendingMigrations: r
2599
+ pendingMigrations: o
2600
2600
  });
2601
2601
  }, Ie = function(e, a) {
2602
2602
  return e.filter((n) => !a.includes(n.name));
@@ -2610,67 +2610,67 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
2610
2610
  return (await e.withPlugin(d(this, i, C)).selectFrom(d(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((n) => n.name);
2611
2611
  }, Pe = function(e, a) {
2612
2612
  for (const n of a)
2613
- if (!e.some((r) => r.name === n))
2613
+ if (!e.some((o) => o.name === n))
2614
2614
  throw new Error(`corrupted migrations: previously executed migration ${n} is missing`);
2615
2615
  }, Me = function(e, a) {
2616
2616
  for (let n = 0; n < a.length; ++n)
2617
2617
  if (e[n].name !== a[n])
2618
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
2619
  }, Fe = async function(e, a, n) {
2620
- const r = a.executedMigrations.slice().reverse().slice(0, n).map((s) => a.migrations.find((l) => l.name === s)), o = r.map((s) => ({
2620
+ const o = a.executedMigrations.slice().reverse().slice(0, n).map((s) => a.migrations.find((l) => l.name === s)), r = o.map((s) => ({
2621
2621
  migrationName: s.name,
2622
2622
  direction: "Down",
2623
2623
  status: "NotExecuted"
2624
2624
  }));
2625
- for (let s = 0; s < o.length; ++s) {
2626
- const l = r[s];
2625
+ for (let s = 0; s < r.length; ++s) {
2626
+ const l = o[s];
2627
2627
  try {
2628
- l.down && (await l.down(e), await e.withPlugin(d(this, i, C)).deleteFrom(d(this, i, N)).where("name", "=", l.name).execute(), o[s] = {
2628
+ l.down && (await l.down(e), await e.withPlugin(d(this, i, C)).deleteFrom(d(this, i, N)).where("name", "=", l.name).execute(), r[s] = {
2629
2629
  migrationName: l.name,
2630
2630
  direction: "Down",
2631
2631
  status: "Success"
2632
2632
  });
2633
2633
  } catch (c) {
2634
- throw o[s] = {
2634
+ throw r[s] = {
2635
2635
  migrationName: l.name,
2636
2636
  direction: "Down",
2637
2637
  status: "Error"
2638
2638
  }, new q({
2639
2639
  error: c,
2640
- results: o
2640
+ results: r
2641
2641
  });
2642
2642
  }
2643
2643
  }
2644
- return { results: o };
2644
+ return { results: r };
2645
2645
  }, Ae = async function(e, a, n) {
2646
- const o = a.pendingMigrations.slice(0, n).map((s) => ({
2646
+ const r = a.pendingMigrations.slice(0, n).map((s) => ({
2647
2647
  migrationName: s.name,
2648
2648
  direction: "Up",
2649
2649
  status: "NotExecuted"
2650
2650
  }));
2651
- for (let s = 0; s < o.length; s++) {
2651
+ for (let s = 0; s < r.length; s++) {
2652
2652
  const l = a.pendingMigrations[s];
2653
2653
  try {
2654
2654
  await l.up(e), await e.withPlugin(d(this, i, C)).insertInto(d(this, i, N)).values({
2655
2655
  name: l.name,
2656
2656
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2657
- }).execute(), o[s] = {
2657
+ }).execute(), r[s] = {
2658
2658
  migrationName: l.name,
2659
2659
  direction: "Up",
2660
2660
  status: "Success"
2661
2661
  };
2662
2662
  } catch (c) {
2663
- throw o[s] = {
2663
+ throw r[s] = {
2664
2664
  migrationName: l.name,
2665
2665
  direction: "Up",
2666
2666
  status: "Error"
2667
2667
  }, new q({
2668
2668
  error: c,
2669
- results: o
2669
+ results: r
2670
2670
  });
2671
2671
  }
2672
2672
  }
2673
- return { results: o };
2673
+ return { results: r };
2674
2674
  }, L = async function(e) {
2675
2675
  d(this, _).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2676
2676
  };
@@ -3912,7 +3912,7 @@ const zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3912
3912
  up: Ai
3913
3913
  }, Symbol.toStringTag, { value: "Module" }));
3914
3914
  async function Ji(t) {
3915
- await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(1024)").execute();
3915
+ await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
3916
3916
  }
3917
3917
  async function Ei(t) {
3918
3918
  await t.schema.alterTable("codes").dropColumn("nonce").execute(), await t.schema.alterTable("codes").dropColumn("state").execute();
@@ -4016,22 +4016,22 @@ async function qi(t, e = !1) {
4016
4016
  const a = new Le(ze), n = new Ce({
4017
4017
  db: t,
4018
4018
  provider: a
4019
- }), { error: r, results: o } = await n.migrateToLatest();
4020
- if (o == null || o.forEach((s) => {
4019
+ }), { error: o, results: r } = await n.migrateToLatest();
4020
+ if (r == null || r.forEach((s) => {
4021
4021
  s.status === "Success" ? e && console.log(
4022
4022
  `migration "${s.migrationName}" was executed successfully`
4023
4023
  ) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
4024
- }), r)
4025
- throw console.error("failed to migrate"), console.error(r), r;
4024
+ }), o)
4025
+ throw console.error("failed to migrate"), console.error(o), o;
4026
4026
  }
4027
4027
  async function Vi(t) {
4028
4028
  console.log("migrating...");
4029
4029
  const e = new Le(ze), a = new Ce({
4030
4030
  db: t,
4031
4031
  provider: e
4032
- }), { error: n, results: r } = await a.migrateDown();
4033
- if (r == null || r.forEach((o) => {
4034
- o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
4032
+ }), { error: n, results: o } = await a.migrateDown();
4033
+ if (o == null || o.forEach((r) => {
4034
+ r.status === "Success" ? console.log(`migration "${r.migrationName}" was reverted successfully`) : r.status === "Error" && console.error(`failed to execute migration "${r.migrationName}"`);
4035
4035
  }), n)
4036
4036
  throw console.error("failed to migrate"), console.error(n), n;
4037
4037
  }