@authhero/kysely-adapter 7.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,17 +2,17 @@ var Ee = Object.defineProperty;
2
2
  var de = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var Je = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var j = (t, e, a) => Je(t, typeof e != "symbol" ? e + "" : e, a), U = (t, e, a) => e.has(t) || de("Cannot " + a);
7
- var c = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), w = (t, e, a) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (U(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
8
- import { parseUserId as Y, codeSchema as ze, connectionSchema as Re, loginSchema as Ue, promptSettingSchema as Ke } from "@authhero/adapter-interfaces";
5
+ var Je = (t, e, r) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
6
+ var j = (t, e, r) => Je(t, typeof e != "symbol" ? e + "" : e, r), K = (t, e, r) => e.has(t) || de("Cannot " + r);
7
+ var d = (t, e, r) => (K(t, e, "read from private field"), r ? r.call(t) : e.get(t)), y = (t, e, r) => e.has(t) ? de("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), M = (t, e, r, a) => (K(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), u = (t, e, r) => (K(t, e, "access private method"), r);
8
+ import { parseUserId as Y, codeSchema as ze, connectionSchema as Re, loginSchema as Ke, promptSettingSchema as Ue } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var V = class extends Error {
11
- constructor(e = 500, a) {
12
- super(a == null ? void 0 : a.message, { cause: a == null ? void 0 : a.cause });
11
+ constructor(e = 500, r) {
12
+ super(r == null ? void 0 : r.message, { cause: r == null ? void 0 : r.cause });
13
13
  j(this, "res");
14
14
  j(this, "status");
15
- this.res = a == null ? void 0 : a.res, this.status = e;
15
+ this.res = r == null ? void 0 : r.res, this.status = e;
16
16
  }
17
17
  getResponse() {
18
18
  return this.res ? new Response(this.res.body, {
@@ -24,17 +24,17 @@ var V = class extends Error {
24
24
  }
25
25
  };
26
26
  function Be(t) {
27
- return async (e, a) => {
28
- const { identities: r, ...o } = a, n = {
27
+ return async (e, r) => {
28
+ const { identities: a, ...o } = r, n = {
29
29
  ...o,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
33
33
  tenant_id: e,
34
- email_verified: a.email_verified ? 1 : 0,
35
- is_social: a.is_social ? 1 : 0,
36
- app_metadata: JSON.stringify(a.app_metadata),
37
- user_metadata: JSON.stringify(a.user_metadata)
34
+ email_verified: r.email_verified ? 1 : 0,
35
+ is_social: r.is_social ? 1 : 0,
36
+ app_metadata: JSON.stringify(r.app_metadata),
37
+ user_metadata: JSON.stringify(r.user_metadata)
38
38
  };
39
39
  try {
40
40
  await t.insertInto("users").values(n).execute();
@@ -52,16 +52,16 @@ function Be(t) {
52
52
  }
53
53
  function f(t) {
54
54
  const e = { ...t };
55
- for (const a in e)
56
- e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(f) : e[a] = f(e[a]));
55
+ for (const r in e)
56
+ e[r] === null ? delete e[r] : typeof e[r] == "object" && (Array.isArray(e[r]) ? e[r] = e[r].map(f) : e[r] = f(e[r]));
57
57
  return e;
58
58
  }
59
59
  function _e(t) {
60
60
  let e = {};
61
61
  try {
62
62
  e = JSON.parse(t.profileData || "{}");
63
- } catch (a) {
64
- console.error("Error parsing profileData", a);
63
+ } catch (r) {
64
+ console.error("Error parsing profileData", r);
65
65
  }
66
66
  return {
67
67
  connection: t.connection,
@@ -76,42 +76,42 @@ function _e(t) {
76
76
  };
77
77
  }
78
78
  function Qe(t) {
79
- return async (e, a) => {
80
- const [r, o] = await Promise.all([
81
- t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
82
- t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
79
+ return async (e, r) => {
80
+ const [a, o] = await Promise.all([
81
+ t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", r).selectAll().executeTakeFirst(),
82
+ t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", r).selectAll().execute()
83
83
  ]);
84
- if (!r)
84
+ if (!a)
85
85
  return null;
86
- const { tenant_id: n, ...s } = r, l = {
86
+ const { tenant_id: n, ...s } = a, c = {
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: a.email || "",
89
+ email_verified: a.email_verified === 1,
90
+ is_social: a.is_social === 1,
91
+ app_metadata: JSON.parse(a.app_metadata),
92
+ user_metadata: JSON.parse(a.user_metadata),
93
93
  identities: [
94
94
  {
95
- connection: r.connection,
96
- provider: r.provider,
97
- user_id: Y(r.user_id).id,
98
- isSocial: !!r.is_social
95
+ connection: a.connection,
96
+ provider: a.provider,
97
+ user_id: Y(a.user_id).id,
98
+ isSocial: !!a.is_social
99
99
  },
100
100
  ...o.map(_e)
101
101
  ]
102
102
  };
103
- return f(l);
103
+ return f(c);
104
104
  };
105
105
  }
106
- function T(t, e, a, r) {
107
- return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
- let s = n.startsWith("-"), l, d, g, m;
109
- return n.startsWith("-_exists_:") ? (l = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (l = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [l, d] = s ? n.substring(1).split(":") : n.split(":"), g = !1, d.startsWith(">=") ? (m = ">=", d = d.substring(2)) : d.startsWith(">") ? (m = ">", d = d.substring(1)) : d.startsWith("<=") ? (m = "<=", d = d.substring(2)) : d.startsWith("<") ? (m = "<", d = d.substring(1)) : m = "=") : (l = null, d = n, g = !1), { key: l, value: d, isNegation: s, isExistsQuery: g, operator: m };
110
- }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: d, operator: g }) => {
106
+ function T(t, e, r, a) {
107
+ return r.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
+ let s = n.startsWith("-"), c, l, g, m;
109
+ return n.startsWith("-_exists_:") ? (c = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (c = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [c, l] = s ? n.substring(1).split(":") : n.split(":"), g = !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 = "=") : (c = null, l = n, g = !1), { key: c, value: l, isNegation: s, isExistsQuery: g, operator: m };
110
+ }).forEach(({ key: n, value: s, isNegation: c, isExistsQuery: l, operator: g }) => {
111
111
  if (n)
112
- if (d)
113
- l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
- else if (l)
112
+ if (l)
113
+ c ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
+ else if (c)
115
115
  switch (g) {
116
116
  case ">":
117
117
  e = e.where(n, "<=", s);
@@ -133,29 +133,29 @@ function T(t, e, a, r) {
133
133
  else {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
136
- (y) => y.or(
137
- r.map((x) => y(m(x), "like", `%${s}%`))
136
+ (w) => w.or(
137
+ a.map((x) => w(m(x), "like", `%${s}%`))
138
138
  )
139
139
  );
140
140
  }
141
141
  }), e;
142
142
  }
143
- function b(t) {
143
+ function C(t) {
144
144
  return typeof t == "string" ? parseInt(t, 10) : typeof t == "bigint" ? Number(t) : t;
145
145
  }
146
146
  function Ve(t) {
147
- return async (e, a = {
147
+ return async (e, r = {
148
148
  page: 0,
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 a = t.selectFrom("users").where("users.tenant_id", "=", e);
153
+ if (r.q && (a = T(t, a, r.q, ["email", "name"])), r.sort && r.sort.sort_by) {
154
154
  const { ref: m } = t.dynamic;
155
- r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
155
+ a = a.orderBy(m(r.sort.sort_by), r.sort.sort_order);
156
156
  }
157
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
158
- const y = l.filter(
157
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), s = n.map((m) => m.user_id), c = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], l = n.map((m) => {
158
+ const w = c.filter(
159
159
  (x) => x.linked_to === m.user_id
160
160
  );
161
161
  return f({
@@ -171,45 +171,45 @@ function Ve(t) {
171
171
  user_id: Y(m.user_id).id,
172
172
  isSocial: !!m.is_social
173
173
  },
174
- ...y.map(_e)
174
+ ...w.map(_e)
175
175
  ]
176
176
  });
177
- }), { count: g } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
177
+ }), { count: g } = await a.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
178
178
  return {
179
- users: d,
180
- start: a.page * a.per_page,
181
- limit: a.per_page,
182
- length: b(g)
179
+ users: l,
180
+ start: r.page * r.per_page,
181
+ limit: r.per_page,
182
+ length: C(g)
183
183
  };
184
184
  };
185
185
  }
186
- function We(t) {
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
- }
189
186
  function qe(t) {
187
+ return async (e, r) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", r).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1);
188
+ }
189
+ function We(t) {
190
190
  if (t.email_verified !== void 0)
191
191
  return t.email_verified ? 1 : 0;
192
192
  }
193
193
  function Ge(t) {
194
- return async (e, a, r) => {
194
+ return async (e, r, a) => {
195
195
  const o = {
196
- ...r,
197
- email_verified: qe(r),
196
+ ...a,
197
+ email_verified: We(a),
198
198
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
199
199
  };
200
- return r.app_metadata && (o.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (o.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
200
+ return a.app_metadata && (o.app_metadata = JSON.stringify(a.app_metadata)), a.user_metadata && (o.user_metadata = JSON.stringify(a.user_metadata)), (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1;
201
201
  };
202
202
  }
203
203
  function He(t) {
204
- return async (e, a, r, o) => {
204
+ return async (e, r, a, o) => {
205
205
  const n = { linked_to: null };
206
- return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
206
+ return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${a}|${o}`).where("users.linked_to", "=", `${r}`).execute()).length === 1;
207
207
  };
208
208
  }
209
209
  function Xe(t) {
210
210
  return {
211
211
  create: Be(t),
212
- remove: We(t),
212
+ remove: qe(t),
213
213
  get: Qe(t),
214
214
  list: Ve(t),
215
215
  update: Ge(t),
@@ -219,26 +219,26 @@ function Xe(t) {
219
219
  }
220
220
  const Ye = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
221
221
  let k = (t = 21) => {
222
- let e = "", a = crypto.getRandomValues(new Uint8Array(t));
222
+ let e = "", r = crypto.getRandomValues(new Uint8Array(t));
223
223
  for (; t--; )
224
- e += Ye[a[t] & 63];
224
+ e += Ye[r[t] & 63];
225
225
  return e;
226
226
  };
227
227
  function Ze(t) {
228
228
  return async (e) => {
229
- const a = {
229
+ const r = {
230
230
  id: e.id || k(),
231
231
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
232
232
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
233
233
  ...e
234
234
  };
235
- return await t.insertInto("tenants").values(a).execute(), a;
235
+ return await t.insertInto("tenants").values(r).execute(), r;
236
236
  };
237
237
  }
238
238
  function et(t) {
239
239
  return async (e) => {
240
- const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
- return a ? f(a) : null;
240
+ const r = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
+ return r ? f(r) : null;
242
242
  };
243
243
  }
244
244
  function tt(t) {
@@ -247,18 +247,18 @@ function tt(t) {
247
247
  per_page: 50,
248
248
  include_totals: !1
249
249
  }) => {
250
- let a = t.selectFrom("tenants");
250
+ let r = t.selectFrom("tenants");
251
251
  if (e.sort && e.sort.sort_by) {
252
- const { ref: l } = t.dynamic;
253
- a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
252
+ const { ref: c } = t.dynamic;
253
+ r = r.orderBy(c(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
- e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
- const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
255
+ e.q && (r = r.where((c) => c.or([c("name", "like", `%${e.q}%`)])));
256
+ const o = await r.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
257
257
  if (!e.include_totals)
258
258
  return {
259
259
  tenants: o
260
260
  };
261
- const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(n);
261
+ const { count: n } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = C(n);
262
262
  return {
263
263
  tenants: o.map(f),
264
264
  start: (e.page - 1) * e.per_page,
@@ -267,17 +267,17 @@ function tt(t) {
267
267
  };
268
268
  };
269
269
  }
270
- function at(t) {
271
- return async (e, a) => {
272
- const r = {
273
- ...a,
270
+ function rt(t) {
271
+ return async (e, r) => {
272
+ const a = {
273
+ ...r,
274
274
  id: e,
275
275
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
276
276
  };
277
- await t.updateTable("tenants").set(r).where("id", "=", e).execute();
277
+ await t.updateTable("tenants").set(a).where("id", "=", e).execute();
278
278
  };
279
279
  }
280
- function rt(t) {
280
+ function at(t) {
281
281
  return async (e) => (await t.deleteFrom("tenants").where("tenants.id", "=", e).execute()).length === 1;
282
282
  }
283
283
  function nt(t) {
@@ -285,8 +285,8 @@ function nt(t) {
285
285
  create: Ze(t),
286
286
  get: et(t),
287
287
  list: tt(t),
288
- update: at(t),
289
- remove: rt(t)
288
+ update: rt(t),
289
+ remove: at(t)
290
290
  };
291
291
  }
292
292
  function ue(t) {
@@ -294,23 +294,23 @@ function ue(t) {
294
294
  }
295
295
  const ot = 1024;
296
296
  function st(t) {
297
- return async (e, a) => {
297
+ return async (e, r) => {
298
298
  var o, n, s;
299
- const r = {
299
+ const a = {
300
300
  id: k(),
301
- ...a,
302
- user_agent: a.user_agent.slice(0, ot)
301
+ ...r,
302
+ user_agent: r.user_agent.slice(0, ot)
303
303
  };
304
304
  return await t.insertInto("logs").values({
305
- ...r,
305
+ ...a,
306
306
  // Truncate long strings to avoid database errors
307
- description: (o = r.description) == null ? void 0 : o.substring(0, 256),
308
- isMobile: a.isMobile ? 1 : 0,
307
+ description: (o = a.description) == null ? void 0 : o.substring(0, 256),
308
+ isMobile: r.isMobile ? 1 : 0,
309
309
  tenant_id: e,
310
- scope: (n = a.scope) == null ? void 0 : n.join(","),
311
- auth0_client: ue(a.auth0_client),
312
- details: (s = ue(a.details)) == null ? void 0 : s.substring(0, 8192)
313
- }).execute(), r;
310
+ scope: (n = r.scope) == null ? void 0 : n.join(","),
311
+ auth0_client: ue(r.auth0_client),
312
+ details: (s = ue(r.details)) == null ? void 0 : s.substring(0, 8192)
313
+ }).execute(), a;
314
314
  };
315
315
  }
316
316
  function me(t) {
@@ -336,118 +336,115 @@ function pe(t) {
336
336
  };
337
337
  }
338
338
  function it(t) {
339
- return async (e, a = {
339
+ return async (e, r = {
340
340
  page: 0,
341
341
  per_page: 50,
342
342
  include_totals: !1
343
343
  }) => {
344
- let r = t.selectFrom("logs").where("logs.tenant_id", "=", e);
345
- a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
346
- let o = r;
347
- if (a.sort && a.sort.sort_by) {
348
- const { ref: l } = t.dynamic;
344
+ let a = t.selectFrom("logs").where("logs.tenant_id", "=", e);
345
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
346
+ let o = a;
347
+ if (r.sort && r.sort.sort_by) {
348
+ const { ref: c } = t.dynamic;
349
349
  o = o.orderBy(
350
- l(a.sort.sort_by),
351
- a.sort.sort_order
350
+ c(r.sort.sort_by),
351
+ r.sort.sort_order
352
352
  );
353
353
  }
354
- o = o.offset(a.page * a.per_page).limit(a.per_page);
355
- const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
354
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
355
+ const n = await o.selectAll().execute(), { count: s } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
356
356
  return {
357
357
  logs: n.map(pe),
358
- start: a.page * a.per_page,
359
- limit: a.per_page,
360
- length: b(s)
358
+ start: r.page * r.per_page,
359
+ limit: r.per_page,
360
+ length: C(s)
361
361
  };
362
362
  };
363
363
  }
364
- function lt(t) {
365
- return async (e, a) => {
366
- const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
367
- return r ? pe(r) : null;
364
+ function ct(t) {
365
+ return async (e, r) => {
366
+ const a = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", r).selectAll().executeTakeFirst();
367
+ return a ? pe(a) : null;
368
368
  };
369
369
  }
370
- function ct(t) {
370
+ function lt(t) {
371
371
  return {
372
372
  create: st(t),
373
373
  list: it(t),
374
- get: lt(t)
374
+ get: ct(t)
375
375
  };
376
376
  }
377
377
  function dt(t) {
378
- return async (e, a) => {
379
- const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).where("sessions.revoked_at", "is", null).selectAll().executeTakeFirst();
380
- if (!r)
378
+ return async (e, r) => {
379
+ const a = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", r).where("sessions.revoked_at", "is", null).selectAll().executeTakeFirst();
380
+ if (!a)
381
381
  return null;
382
- const { tenant_id: o, device: n, clients: s, ...l } = r, d = l.id || l.session_id || "";
382
+ const { tenant_id: o, device: n, clients: s, ...c } = a;
383
383
  return {
384
- ...l,
385
- id: d,
384
+ ...c,
386
385
  device: JSON.parse(n),
387
386
  clients: JSON.parse(s)
388
387
  };
389
388
  };
390
389
  }
391
390
  function ut(t) {
392
- return async (e, a) => {
393
- const r = {
394
- ...a,
395
- // fallback untill we changed primary key
396
- session_id: a.id,
391
+ return async (e, r) => {
392
+ const a = {
393
+ ...r,
397
394
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
398
395
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
399
396
  authenticated_at: (/* @__PURE__ */ new Date()).toISOString(),
400
397
  last_interaction_at: (/* @__PURE__ */ new Date()).toISOString()
401
398
  };
402
399
  return await t.insertInto("sessions").values({
403
- ...r,
400
+ ...a,
404
401
  tenant_id: e,
405
- device: JSON.stringify(a.device),
406
- clients: JSON.stringify(a.clients)
407
- }).execute(), r;
402
+ device: JSON.stringify(r.device),
403
+ clients: JSON.stringify(r.clients)
404
+ }).execute(), a;
408
405
  };
409
406
  }
410
407
  function mt(t) {
411
- return async (e, a) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
408
+ return async (e, r) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
412
409
  }
413
410
  function ht(t) {
414
- return async (e, a, r) => {
411
+ return async (e, r, a) => {
415
412
  const o = {
416
- ...r,
413
+ ...a,
417
414
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
418
- device: r.device ? JSON.stringify(r.device) : void 0,
419
- clients: r.clients ? JSON.stringify(r.clients) : void 0
415
+ device: a.device ? JSON.stringify(a.device) : void 0,
416
+ clients: a.clients ? JSON.stringify(a.clients) : void 0
420
417
  };
421
- return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
418
+ return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
422
419
  };
423
420
  }
424
421
  function ft(t) {
425
- return async (e, a = {
422
+ return async (e, r = {
426
423
  page: 0,
427
424
  per_page: 50,
428
425
  include_totals: !1
429
426
  }) => {
430
- let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
431
- a.q && (r = T(t, r, a.q, ["user_id", "session_id"]));
432
- let o = r;
433
- if (a.sort && a.sort.sort_by) {
434
- const { ref: d } = t.dynamic;
427
+ let a = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
428
+ r.q && (a = T(t, a, r.q, ["user_id", "session_id"]));
429
+ let o = a;
430
+ if (r.sort && r.sort.sort_by) {
431
+ const { ref: l } = t.dynamic;
435
432
  o = o.orderBy(
436
- d(a.sort.sort_by),
437
- a.sort.sort_order
433
+ l(r.sort.sort_by),
434
+ r.sort.sort_order
438
435
  );
439
436
  }
440
- o = o.offset(a.page * a.per_page).limit(a.per_page);
441
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
437
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
438
+ const n = await o.selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = C(s);
442
439
  return {
443
- sessions: n.map((d) => ({
444
- ...d,
445
- device: JSON.parse(d.device),
446
- clients: JSON.parse(d.clients)
440
+ sessions: n.map((l) => ({
441
+ ...l,
442
+ device: JSON.parse(l.device),
443
+ clients: JSON.parse(l.clients)
447
444
  })),
448
- start: a.page * a.per_page,
449
- limit: a.per_page,
450
- length: l
445
+ start: r.page * r.per_page,
446
+ limit: r.per_page,
447
+ length: c
451
448
  };
452
449
  };
453
450
  }
@@ -461,110 +458,110 @@ function _t(t) {
461
458
  };
462
459
  }
463
460
  function pt(t) {
464
- return async (e, a) => {
465
- const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = r;
461
+ return async (e, r) => {
462
+ const a = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", r).selectAll().executeTakeFirstOrThrow(), { tenant_id: o, ...n } = a;
466
463
  return n;
467
464
  };
468
465
  }
469
466
  function gt(t) {
470
- return async (e, a) => {
471
- const r = {
472
- ...a,
467
+ return async (e, r) => {
468
+ const a = {
469
+ ...r,
473
470
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
474
471
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
475
472
  };
476
473
  return await t.insertInto("passwords").values({
477
- ...r,
474
+ ...a,
478
475
  tenant_id: e
479
- }).execute(), r;
476
+ }).execute(), a;
480
477
  };
481
478
  }
482
- function wt(t) {
483
- return async (e, a) => (await t.updateTable("passwords").set({
484
- password: a.password,
479
+ function yt(t) {
480
+ return async (e, r) => (await t.updateTable("passwords").set({
481
+ password: r.password,
485
482
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
486
- }).where("tenant_id", "=", e).where("user_id", "=", a.user_id).execute()).length === 1;
483
+ }).where("tenant_id", "=", e).where("user_id", "=", r.user_id).execute()).length === 1;
487
484
  }
488
- function yt(t) {
485
+ function wt(t) {
489
486
  return {
490
487
  create: gt(t),
491
- update: wt(t),
488
+ update: yt(t),
492
489
  get: pt(t)
493
490
  };
494
491
  }
495
492
  function Nt(t) {
496
- return async (e, a = {
493
+ return async (e, r = {
497
494
  page: 0,
498
495
  per_page: 50,
499
496
  include_totals: !1
500
497
  }) => {
501
- let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
502
- a.q && (r = T(t, r, a.q, ["code", "login_id"]));
503
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
498
+ let a = t.selectFrom("codes").where("codes.tenant_id", "=", e);
499
+ r.q && (a = T(t, a, r.q, ["code", "login_id"]));
500
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
504
501
  return {
505
- codes: n.map((d) => {
506
- const { tenant_id: g, ...m } = d;
502
+ codes: n.map((l) => {
503
+ const { tenant_id: g, ...m } = l;
507
504
  return ze.parse(f(m));
508
505
  }),
509
- start: a.page * a.per_page,
510
- limit: a.per_page,
511
- length: b(s)
506
+ start: r.page * r.per_page,
507
+ limit: r.per_page,
508
+ length: C(s)
512
509
  };
513
510
  };
514
511
  }
515
512
  function vt(t) {
516
- return async (e, a) => {
517
- const r = {
518
- ...a,
513
+ return async (e, r) => {
514
+ const a = {
515
+ ...r,
519
516
  created_at: (/* @__PURE__ */ new Date()).toISOString()
520
517
  };
521
518
  return await t.insertInto("codes").values({
522
- ...r,
519
+ ...a,
523
520
  tenant_id: e
524
- }).execute(), r;
521
+ }).execute(), a;
525
522
  };
526
523
  }
527
- function Ct(t) {
528
- return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
529
- }
530
524
  function bt(t) {
531
- return async (e, a, r) => {
532
- let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
525
+ return async (e, r) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
526
+ }
527
+ function Ct(t) {
528
+ return async (e, r, a) => {
529
+ let o = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
533
530
  e.length && (o = o.where("codes.tenant_id", "=", e));
534
531
  const n = await o.selectAll().executeTakeFirst();
535
532
  return n ? f(n) : null;
536
533
  };
537
534
  }
538
535
  function xt(t) {
539
- return async (e, a) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numUpdatedRows > 0;
536
+ return async (e, r) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numUpdatedRows > 0;
540
537
  }
541
538
  function Tt(t) {
542
539
  return {
543
540
  create: vt(t),
544
541
  list: Nt(t),
545
- remove: Ct(t),
542
+ remove: bt(t),
546
543
  used: xt(t),
547
- get: bt(t)
544
+ get: Ct(t)
548
545
  };
549
546
  }
550
547
  function St(t) {
551
- return async (e, a) => {
552
- const r = {
548
+ return async (e, r) => {
549
+ const a = {
553
550
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
554
551
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
555
- ...a
556
- }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
552
+ ...r
553
+ }, o = JSON.stringify(r.allowed_origins), n = JSON.stringify(r.callbacks), s = JSON.stringify(r.web_origins), c = JSON.stringify(r.allowed_logout_urls), l = JSON.stringify(r.allowed_clients);
557
554
  return await t.insertInto("applications").values({
558
- ...r,
555
+ ...a,
559
556
  tenant_id: e,
560
- disable_sign_ups: a.disable_sign_ups ? 1 : 0,
561
- addons: a.addons ? JSON.stringify(a.addons) : "{}",
557
+ disable_sign_ups: r.disable_sign_ups ? 1 : 0,
558
+ addons: r.addons ? JSON.stringify(r.addons) : "{}",
562
559
  callbacks: n,
563
560
  allowed_origins: o,
564
561
  web_origins: s,
565
- allowed_logout_urls: l,
566
- allowed_clients: d
567
- }).execute(), r;
562
+ allowed_logout_urls: c,
563
+ allowed_clients: l
564
+ }).execute(), a;
568
565
  };
569
566
  }
570
567
  function Ot(t) {
@@ -582,36 +579,36 @@ function Ot(t) {
582
579
  });
583
580
  }
584
581
  function kt(t) {
585
- return async (e, a) => {
586
- const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
587
- return r ? f({
588
- ...r,
589
- disable_sign_ups: !!r.disable_sign_ups,
590
- addons: JSON.parse(r.addons),
591
- callbacks: JSON.parse(r.callbacks),
592
- allowed_origins: JSON.parse(r.allowed_origins),
593
- web_origins: JSON.parse(r.web_origins),
594
- allowed_logout_urls: JSON.parse(r.allowed_logout_urls)
582
+ return async (e, r) => {
583
+ const a = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).selectAll().executeTakeFirst();
584
+ return a ? f({
585
+ ...a,
586
+ disable_sign_ups: !!a.disable_sign_ups,
587
+ addons: JSON.parse(a.addons),
588
+ callbacks: JSON.parse(a.callbacks),
589
+ allowed_origins: JSON.parse(a.allowed_origins),
590
+ web_origins: JSON.parse(a.web_origins),
591
+ allowed_logout_urls: JSON.parse(a.allowed_logout_urls)
595
592
  }) : null;
596
593
  };
597
594
  }
598
595
  function $t(t) {
599
- return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
596
+ return async (e, r) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
600
597
  }
601
598
  function It(t) {
602
- return async (e, a, r) => {
599
+ return async (e, r, a) => {
603
600
  const o = {
604
- ...r,
601
+ ...a,
605
602
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
606
- allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
607
- callbacks: r.callbacks ? JSON.stringify(r.callbacks) : void 0,
608
- web_origins: r.web_origins ? JSON.stringify(r.web_origins) : void 0,
609
- allowed_logout_urls: r.allowed_logout_urls ? JSON.stringify(r.allowed_logout_urls) : void 0,
610
- allowed_clients: r.allowed_clients ? JSON.stringify(r.allowed_clients) : void 0,
611
- addons: r.addons ? JSON.stringify(r.addons) : "{}",
612
- disable_sign_ups: r.disable_sign_ups ? 1 : 0
603
+ allowed_origins: a.allowed_origins ? JSON.stringify(a.allowed_origins) : void 0,
604
+ callbacks: a.callbacks ? JSON.stringify(a.callbacks) : void 0,
605
+ web_origins: a.web_origins ? JSON.stringify(a.web_origins) : void 0,
606
+ allowed_logout_urls: a.allowed_logout_urls ? JSON.stringify(a.allowed_logout_urls) : void 0,
607
+ allowed_clients: a.allowed_clients ? JSON.stringify(a.allowed_clients) : void 0,
608
+ addons: a.addons ? JSON.stringify(a.addons) : "{}",
609
+ disable_sign_ups: a.disable_sign_ups ? 1 : 0
613
610
  };
614
- return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
611
+ return await t.updateTable("applications").set(o).where("applications.id", "=", r).where("applications.tenant_id", "=", e).execute(), !0;
615
612
  };
616
613
  }
617
614
  function Dt(t) {
@@ -624,65 +621,65 @@ function Dt(t) {
624
621
  };
625
622
  }
626
623
  function Pt(t) {
627
- return async (e, a) => {
628
- const r = {
624
+ return async (e, r) => {
625
+ const a = {
629
626
  id: k(),
630
- ...a,
627
+ ...r,
631
628
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
632
629
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
633
630
  };
634
631
  return await t.insertInto("connections").values({
635
- ...r,
632
+ ...a,
636
633
  // The connection options will have many different properties depending on the strategy
637
- options: JSON.stringify(r.options || {}),
634
+ options: JSON.stringify(a.options || {}),
638
635
  tenant_id: e
639
- }).execute(), r;
636
+ }).execute(), a;
640
637
  };
641
638
  }
642
639
  function jt(t) {
643
- return async (e, a = {
640
+ return async (e, r = {
644
641
  page: 0,
645
642
  per_page: 50,
646
643
  include_totals: !1
647
644
  }) => {
648
- let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
649
- a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
650
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
651
- (d) => f({
652
- ...d,
653
- options: JSON.parse(d.options)
645
+ let a = t.selectFrom("connections").where("connections.tenant_id", "=", e);
646
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
647
+ const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map(
648
+ (l) => f({
649
+ ...l,
650
+ options: JSON.parse(l.options)
654
651
  })
655
- ), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
652
+ ), { count: c } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
656
653
  return {
657
654
  connections: s,
658
- start: a.page * a.per_page,
659
- limit: a.per_page,
660
- length: b(l)
655
+ start: r.page * r.per_page,
656
+ limit: r.per_page,
657
+ length: C(c)
661
658
  };
662
659
  };
663
660
  }
664
661
  function Mt(t) {
665
- return async (e, a) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
662
+ return async (e, r) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
666
663
  }
667
664
  function At(t) {
668
- return async (e, a) => {
669
- const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
670
- return r ? f({
671
- ...r,
672
- options: JSON.parse(r.options)
665
+ return async (e, r) => {
666
+ const a = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).selectAll().executeTakeFirst();
667
+ return a ? f({
668
+ ...a,
669
+ options: JSON.parse(a.options)
673
670
  }) : null;
674
671
  };
675
672
  }
676
673
  function Ft(t) {
677
- return async (e, a, r) => {
674
+ return async (e, r, a) => {
678
675
  const o = {
679
- ...r,
676
+ ...a,
680
677
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
681
678
  };
682
679
  return await t.updateTable("connections").set({
683
680
  ...o,
684
681
  options: o.options ? JSON.stringify(o.options) : void 0
685
- }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
682
+ }).where("connections.id", "=", r).where("connections.tenant_id", "=", e).execute(), !0;
686
683
  };
687
684
  }
688
685
  function Lt(t) {
@@ -697,42 +694,42 @@ function Lt(t) {
697
694
  function Et(t) {
698
695
  return {
699
696
  get: async (e) => {
700
- const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
701
- if (!a)
702
- return null;
703
- const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
697
+ const r = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
704
698
  if (!r)
699
+ return null;
700
+ const a = await t.selectFrom("tenants").selectAll().where("id", "=", r.tenant_id).executeTakeFirst();
701
+ if (!a)
705
702
  throw new V(404, { message: "Tenant not found" });
706
- const o = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute(), n = await t.selectFrom("domains").where("tenant_id", "=", a.tenant_id).selectAll().execute();
703
+ const o = await t.selectFrom("connections").where("tenant_id", "=", r.tenant_id).selectAll().execute(), n = await t.selectFrom("domains").where("tenant_id", "=", r.tenant_id).selectAll().execute();
707
704
  return {
708
- ...a,
705
+ ...r,
709
706
  connections: o.map(
710
- (l) => Re.parse(
707
+ (c) => Re.parse(
711
708
  f({
712
- ...l,
713
- options: l.options ? JSON.parse(l.options) : {}
709
+ ...c,
710
+ options: c.options ? JSON.parse(c.options) : {}
714
711
  })
715
712
  )
716
713
  ),
717
714
  domains: n,
718
- addons: a.addons ? JSON.parse(a.addons) : {},
719
- callbacks: a.callbacks ? JSON.parse(a.callbacks) : [],
720
- allowed_origins: a.allowed_origins ? JSON.parse(a.allowed_origins) : [],
721
- web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
722
- allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
723
- allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
724
- tenant: f(r),
715
+ addons: r.addons ? JSON.parse(r.addons) : {},
716
+ callbacks: r.callbacks ? JSON.parse(r.callbacks) : [],
717
+ allowed_origins: r.allowed_origins ? JSON.parse(r.allowed_origins) : [],
718
+ web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
719
+ allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
720
+ allowed_clients: r.allowed_clients ? JSON.parse(r.allowed_clients) : [],
721
+ tenant: f(a),
725
722
  // this is really an integer in the database
726
- disable_sign_ups: !!a.disable_sign_ups
723
+ disable_sign_ups: !!r.disable_sign_ups
727
724
  };
728
725
  }
729
726
  };
730
727
  }
731
728
  function Jt(t) {
732
729
  return async () => await t.selectFrom("keys").where(
733
- (a) => a.or([
734
- a("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
735
- a("revoked_at", "is", null)
730
+ (r) => r.or([
731
+ r("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
732
+ r("revoked_at", "is", null)
736
733
  ])
737
734
  ).selectAll().execute();
738
735
  }
@@ -742,61 +739,61 @@ function zt(t) {
742
739
  };
743
740
  }
744
741
  function Rt(t) {
745
- return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
742
+ return async (e, r) => !!(await t.updateTable("keys").set(r).where("kid", "=", e).execute()).length;
746
743
  }
747
- function Ut(t) {
744
+ function Kt(t) {
748
745
  return {
749
746
  create: zt(t),
750
747
  list: Jt(t),
751
748
  update: Rt(t)
752
749
  };
753
750
  }
754
- function Kt(t) {
755
- return async (e, a) => {
756
- const r = {
751
+ function Ut(t) {
752
+ return async (e, r) => {
753
+ const a = {
757
754
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
758
755
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
759
756
  tenant_id: e,
760
757
  id: k(),
761
- ...a
758
+ ...r
762
759
  };
763
- return await t.insertInto("domains").values(r).execute(), r;
760
+ return await t.insertInto("domains").values(a).execute(), a;
764
761
  };
765
762
  }
766
763
  function Bt(t) {
767
- return async (e, a) => {
768
- let r = t.selectFrom("domains").where("domains.tenant_id", "=", e);
769
- a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
770
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
764
+ return async (e, r) => {
765
+ let a = t.selectFrom("domains").where("domains.tenant_id", "=", e);
766
+ r.q && (a = T(t, a, r.q, ["user_id", "ip"]));
767
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
771
768
  return {
772
769
  domains: n,
773
- start: a.page * a.per_page,
774
- limit: a.per_page,
775
- length: b(s)
770
+ start: r.page * r.per_page,
771
+ limit: r.per_page,
772
+ length: C(s)
776
773
  };
777
774
  };
778
775
  }
779
776
  function Qt(t) {
780
777
  return {
781
- create: Kt(t),
778
+ create: Ut(t),
782
779
  list: Bt(t)
783
780
  };
784
781
  }
785
782
  function Vt(t) {
786
783
  return async (e) => {
787
- const [a] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
788
- if (!a)
784
+ const [r] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
785
+ if (!r)
789
786
  return null;
790
787
  const {
791
- tenant_id: r,
788
+ tenant_id: a,
792
789
  colors_primary: o,
793
790
  colors_page_background_type: n,
794
791
  colors_page_background_start: s,
795
- colors_page_background_end: l,
796
- colors_page_background_angle_dev: d,
792
+ colors_page_background_end: c,
793
+ colors_page_background_angle_dev: l,
797
794
  font_url: g,
798
795
  ...m
799
- } = a;
796
+ } = r;
800
797
  return f({
801
798
  ...m,
802
799
  colors: {
@@ -804,113 +801,113 @@ function Vt(t) {
804
801
  page_background: {
805
802
  type: n,
806
803
  start: s,
807
- end: l,
808
- angle_deg: d
804
+ end: c,
805
+ angle_deg: l
809
806
  }
810
807
  },
811
808
  font: g ? { url: g } : void 0
812
809
  });
813
810
  };
814
811
  }
815
- function Wt(t) {
816
- return async (e, a) => {
817
- var s, l, d, g, m, y, x, Z, ee, te, ae, re, ne, oe, se, ie, le, ce;
818
- const { colors: r, font: o, ...n } = a;
812
+ function qt(t) {
813
+ return async (e, r) => {
814
+ var s, c, l, g, m, w, x, Z, ee, te, re, ae, ne, oe, se, ie, ce, le;
815
+ const { colors: a, font: o, ...n } = r;
819
816
  try {
820
817
  await t.insertInto("branding").values({
821
818
  ...n,
822
- colors_primary: r == null ? void 0 : r.primary,
823
- colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
824
- colors_page_background_start: (g = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
825
- colors_page_background_end: (y = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : y.end,
826
- colors_page_background_angle_dev: (Z = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
827
- font_url: (ee = a.font) == null ? void 0 : ee.url,
819
+ colors_primary: a == null ? void 0 : a.primary,
820
+ colors_page_background_type: (c = (s = r.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
821
+ colors_page_background_start: (g = (l = r.colors) == null ? void 0 : l.page_background) == null ? void 0 : g.start,
822
+ colors_page_background_end: (w = (m = r.colors) == null ? void 0 : m.page_background) == null ? void 0 : w.end,
823
+ colors_page_background_angle_dev: (Z = (x = r.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
824
+ font_url: (ee = r.font) == null ? void 0 : ee.url,
828
825
  tenant_id: e
829
826
  }).execute();
830
827
  } catch {
831
828
  await t.updateTable("branding").set({
832
829
  ...n,
833
- colors_primary: r == null ? void 0 : r.primary,
834
- colors_page_background_type: (ae = (te = a.colors) == null ? void 0 : te.page_background) == null ? void 0 : ae.type,
835
- colors_page_background_start: (ne = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : ne.start,
836
- colors_page_background_end: (se = (oe = a.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
837
- colors_page_background_angle_dev: (le = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : le.angle_deg,
838
- font_url: (ce = a.font) == null ? void 0 : ce.url
830
+ colors_primary: a == null ? void 0 : a.primary,
831
+ colors_page_background_type: (re = (te = r.colors) == null ? void 0 : te.page_background) == null ? void 0 : re.type,
832
+ colors_page_background_start: (ne = (ae = r.colors) == null ? void 0 : ae.page_background) == null ? void 0 : ne.start,
833
+ colors_page_background_end: (se = (oe = r.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
834
+ colors_page_background_angle_dev: (ce = (ie = r.colors) == null ? void 0 : ie.page_background) == null ? void 0 : ce.angle_deg,
835
+ font_url: (le = r.font) == null ? void 0 : le.url
839
836
  }).where("tenant_id", "=", e).execute();
840
837
  }
841
838
  };
842
839
  }
843
- function qt(t) {
840
+ function Wt(t) {
844
841
  return {
845
842
  get: Vt(t),
846
- set: Wt(t)
843
+ set: qt(t)
847
844
  };
848
845
  }
849
846
  function Gt(t) {
850
- return async (e, a = {
847
+ return async (e, r = {
851
848
  page: 0,
852
849
  per_page: 50,
853
850
  include_totals: !1
854
851
  }) => {
855
- let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
856
- a.q && (r = T(t, r, a.q, ["url"]));
857
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
852
+ let a = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
853
+ r.q && (a = T(t, a, r.q, ["url"]));
854
+ const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
858
855
  return {
859
- hooks: n.map((d) => {
860
- const { tenant_id: g, enabled: m, synchronous: y, ...x } = d;
856
+ hooks: n.map((l) => {
857
+ const { tenant_id: g, enabled: m, synchronous: w, ...x } = l;
861
858
  return f({
862
859
  ...x,
863
860
  enabled: !!m,
864
- synchronous: !!y
861
+ synchronous: !!w
865
862
  });
866
863
  }),
867
- start: a.page * a.per_page,
868
- limit: a.per_page,
869
- length: b(s)
864
+ start: r.page * r.per_page,
865
+ limit: r.per_page,
866
+ length: C(s)
870
867
  };
871
868
  };
872
869
  }
873
870
  function Ht(t) {
874
- return async (e, a) => {
875
- const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
876
- return r ? f({
877
- ...r,
878
- enabled: !!r.enabled,
879
- synchronous: !!r.synchronous
871
+ return async (e, r) => {
872
+ const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).selectAll().executeTakeFirst();
873
+ return a ? f({
874
+ ...a,
875
+ enabled: !!a.enabled,
876
+ synchronous: !!a.synchronous
880
877
  }) : null;
881
878
  };
882
879
  }
883
880
  function Xt(t) {
884
- return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
881
+ return async (e, r) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
885
882
  }
886
883
  function Yt(t) {
887
- return async (e, a) => {
888
- const r = {
884
+ return async (e, r) => {
885
+ const a = {
889
886
  hook_id: k(),
890
- ...a,
887
+ ...r,
891
888
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
892
889
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
893
890
  };
894
891
  return await t.insertInto("hooks").values({
895
- ...r,
892
+ ...a,
896
893
  tenant_id: e,
897
- enabled: a.enabled ? 1 : 0,
898
- synchronous: a.synchronous ? 1 : 0
899
- }).execute(), r;
894
+ enabled: r.enabled ? 1 : 0,
895
+ synchronous: r.synchronous ? 1 : 0
896
+ }).execute(), a;
900
897
  };
901
898
  }
902
899
  function Zt(t) {
903
- return async (e, a, r) => {
900
+ return async (e, r, a) => {
904
901
  const o = {
905
- ...r,
902
+ ...a,
906
903
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
907
- enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
908
- synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
904
+ enabled: a.enabled !== void 0 ? a.enabled ? 1 : 0 : void 0,
905
+ synchronous: a.enabled !== void 0 ? a.synchronous ? 1 : 0 : void 0
909
906
  };
910
- return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
907
+ return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", r).where("hooks.tenant_id", "=", e).execute(), !0;
911
908
  };
912
909
  }
913
- function ea(t) {
910
+ function er(t) {
914
911
  return {
915
912
  create: Yt(t),
916
913
  get: Ht(t),
@@ -919,110 +916,110 @@ function ea(t) {
919
916
  remove: Xt(t)
920
917
  };
921
918
  }
922
- function J(t, e = "", a = {}) {
923
- for (let r in t)
924
- if (Object.prototype.hasOwnProperty.call(t, r)) {
925
- const o = e ? `${e}_${r}` : r;
926
- typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? J(t[r], o, a) : a[o] = t[r];
919
+ function J(t, e = "", r = {}) {
920
+ for (let a in t)
921
+ if (Object.prototype.hasOwnProperty.call(t, a)) {
922
+ const o = e ? `${e}_${a}` : a;
923
+ typeof t[a] == "object" && t[a] !== null && !Array.isArray(t[a]) ? J(t[a], o, r) : r[o] = t[a];
927
924
  }
928
- return a;
925
+ return r;
929
926
  }
930
- function ta(t, e) {
931
- const a = {};
932
- for (const [r, o] of Object.entries(t)) {
927
+ function tr(t, e) {
928
+ const r = {};
929
+ for (const [a, o] of Object.entries(t)) {
933
930
  const n = e.find(
934
- (s) => r.startsWith(`${s}_`)
931
+ (s) => a.startsWith(`${s}_`)
935
932
  );
936
933
  if (!n)
937
- a[r] = o;
934
+ r[a] = o;
938
935
  else {
939
- const s = r.slice(n.length + 1);
940
- a[n] = {
941
- ...a[n],
936
+ const s = a.slice(n.length + 1);
937
+ r[n] = {
938
+ ...r[n],
942
939
  [s]: o
943
940
  };
944
941
  }
945
942
  }
946
- return a;
943
+ return r;
947
944
  }
948
- function aa(t) {
949
- return async (e, a) => {
950
- const r = {
945
+ function rr(t) {
946
+ return async (e, r) => {
947
+ const a = {
951
948
  themeId: k(),
952
- ...a,
949
+ ...r,
953
950
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
954
951
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
955
952
  };
956
- return await t.insertInto("themes").values({ ...J(r), tenant_id: e }).execute(), r;
953
+ return await t.insertInto("themes").values({ ...J(a), tenant_id: e }).execute(), a;
957
954
  };
958
955
  }
959
- function ra(t) {
960
- return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
956
+ function ar(t) {
957
+ return async (e, r) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
961
958
  }
962
- function na(t) {
963
- return async (e, a) => {
964
- const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
965
- return r ? f(r) : null;
959
+ function nr(t) {
960
+ return async (e, r) => {
961
+ const a = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", r).selectAll().executeTakeFirst();
962
+ return a ? f(a) : null;
966
963
  };
967
964
  }
968
- function oa(t) {
969
- return async (e, a, r) => {
965
+ function or(t) {
966
+ return async (e, r, a) => {
970
967
  const o = J({
971
- ...r,
968
+ ...a,
972
969
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
973
970
  });
974
- return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
971
+ return await t.updateTable("themes").set(o).where("themes.id", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
975
972
  };
976
973
  }
977
- function sa(t) {
974
+ function sr(t) {
978
975
  return {
979
- create: aa(t),
980
- get: na(t),
981
- remove: ra(t),
982
- update: oa(t)
976
+ create: rr(t),
977
+ get: nr(t),
978
+ remove: ar(t),
979
+ update: or(t)
983
980
  };
984
981
  }
985
- function ia(t) {
986
- return async (e, a) => {
987
- const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", r).where("logins.login_id", "=", a).selectAll().executeTakeFirst();
988
- return o ? Ue.parse(
989
- ta(f(o), ["authParams"])
982
+ function ir(t) {
983
+ return async (e, r) => {
984
+ const a = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", a).where("logins.login_id", "=", r).selectAll().executeTakeFirst();
985
+ return o ? Ke.parse(
986
+ tr(f(o), ["authParams"])
990
987
  ) : null;
991
988
  };
992
989
  }
993
- function la(t) {
994
- return async (e, a) => {
995
- const r = {
990
+ function cr(t) {
991
+ return async (e, r) => {
992
+ const a = {
996
993
  login_id: k(),
997
- ...a,
994
+ ...r,
998
995
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
999
996
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1000
997
  };
1001
- return await t.insertInto("logins").values({ ...J(r), tenant_id: e }).execute(), r;
998
+ return await t.insertInto("logins").values({ ...J(a), tenant_id: e }).execute(), a;
1002
999
  };
1003
1000
  }
1004
- function ca(t) {
1005
- return async (e, a, r) => (await t.updateTable("logins").set(J(r)).where("logins.login_id", "=", a).where("logins.tenant_id", "=", e).execute()).length === 1;
1001
+ function lr(t) {
1002
+ return async (e, r, a) => (await t.updateTable("logins").set(J(a)).where("logins.login_id", "=", r).where("logins.tenant_id", "=", e).execute()).length === 1;
1006
1003
  }
1007
- function da(t) {
1008
- return async (e, a) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", a).execute()).length > 0;
1004
+ function dr(t) {
1005
+ return async (e, r) => (await t.deleteFrom("logins").where("logins.tenant_id", "=", e).where("logins.login_id", "=", r).execute()).length > 0;
1009
1006
  }
1010
- function ua(t) {
1007
+ function ur(t) {
1011
1008
  return {
1012
- create: la(t),
1013
- get: ia(t),
1014
- update: ca(t),
1015
- remove: da(t)
1009
+ create: cr(t),
1010
+ get: ir(t),
1011
+ update: lr(t),
1012
+ remove: dr(t)
1016
1013
  };
1017
1014
  }
1018
- function ma(t) {
1015
+ function mr(t) {
1019
1016
  return async (e) => {
1020
- const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1017
+ const [r] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1021
1018
  return f({
1022
- identifier_first: !!(a != null && a.identifier_first),
1023
- password_first: !!(a != null && a.password_first),
1024
- webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
1025
- universal_login_experience: (a == null ? void 0 : a.universal_login_experience) || "new"
1019
+ identifier_first: !!(r != null && r.identifier_first),
1020
+ password_first: !!(r != null && r.password_first),
1021
+ webauthn_platform_first_factor: !!(r != null && r.webauthn_platform_first_factor),
1022
+ universal_login_experience: (r == null ? void 0 : r.universal_login_experience) || "new"
1026
1023
  });
1027
1024
  };
1028
1025
  }
@@ -1035,63 +1032,63 @@ function he(t) {
1035
1032
  universal_login_experience: t.universal_login_experience
1036
1033
  });
1037
1034
  }
1038
- function ha(t) {
1039
- return async (e, a) => {
1035
+ function hr(t) {
1036
+ return async (e, r) => {
1040
1037
  try {
1041
- const r = Ke.parse(a);
1038
+ const a = Ue.parse(r);
1042
1039
  await t.insertInto("prompt_settings").values({
1043
- ...he(r),
1040
+ ...he(a),
1044
1041
  tenant_id: e
1045
1042
  }).execute();
1046
1043
  } catch {
1047
- await t.updateTable("prompt_settings").set(he(a)).where("tenant_id", "=", e).execute();
1044
+ await t.updateTable("prompt_settings").set(he(r)).where("tenant_id", "=", e).execute();
1048
1045
  }
1049
1046
  };
1050
1047
  }
1051
- function fa(t) {
1048
+ function fr(t) {
1052
1049
  return {
1053
- get: ma(t),
1054
- set: ha(t)
1050
+ get: mr(t),
1051
+ set: hr(t)
1055
1052
  };
1056
1053
  }
1057
- function _a(t) {
1054
+ function _r(t) {
1058
1055
  return async (e) => {
1059
- const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1060
- if (!a)
1056
+ const [r] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1057
+ if (!r)
1061
1058
  return null;
1062
1059
  const {
1063
- tenant_id: r,
1060
+ tenant_id: a,
1064
1061
  credentials: o,
1065
1062
  settings: n,
1066
1063
  enabled: s,
1067
- ...l
1068
- } = a;
1064
+ ...c
1065
+ } = r;
1069
1066
  return f({
1070
- ...l,
1067
+ ...c,
1071
1068
  credentials: JSON.parse(o),
1072
1069
  settings: JSON.parse(n),
1073
1070
  enabled: !!s
1074
1071
  });
1075
1072
  };
1076
1073
  }
1077
- function pa(t) {
1078
- return async (e, a) => {
1079
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1074
+ function pr(t) {
1075
+ return async (e, r) => {
1076
+ const { credentials: a, settings: o, enabled: n, ...s } = r;
1080
1077
  await t.updateTable("email_providers").set({
1081
1078
  ...s,
1082
- credentials: r ? JSON.stringify(r) : void 0,
1079
+ credentials: a ? JSON.stringify(a) : void 0,
1083
1080
  settings: o ? JSON.stringify(o) : void 0,
1084
1081
  enabled: n !== void 0 ? n ? 1 : 0 : void 0
1085
1082
  }).where("tenant_id", "=", e).execute();
1086
1083
  };
1087
1084
  }
1088
- function ga(t) {
1089
- return async (e, a) => {
1090
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1085
+ function gr(t) {
1086
+ return async (e, r) => {
1087
+ const { credentials: a, settings: o, enabled: n, ...s } = r;
1091
1088
  await t.insertInto("email_providers").values({
1092
1089
  ...s,
1093
1090
  enabled: n ? 1 : 0,
1094
- credentials: JSON.stringify(r),
1091
+ credentials: JSON.stringify(a),
1095
1092
  settings: JSON.stringify(o),
1096
1093
  tenant_id: e,
1097
1094
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1099,67 +1096,94 @@ function ga(t) {
1099
1096
  }).execute();
1100
1097
  };
1101
1098
  }
1102
- function wa(t) {
1099
+ function yr(t) {
1103
1100
  return {
1104
- get: _a(t),
1105
- create: ga(t),
1106
- update: pa(t)
1101
+ get: _r(t),
1102
+ create: gr(t),
1103
+ update: pr(t)
1107
1104
  };
1108
1105
  }
1109
- function ya(t) {
1110
- return async (e, a) => await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.token", "=", a).where("refresh_tokens.revoked_at", "is", null).selectAll().executeTakeFirst() ?? null;
1111
- }
1112
- function Na(t) {
1113
- return async (e, a) => {
1114
- const r = {
1106
+ function wr(t) {
1107
+ return async (e, r) => {
1108
+ const a = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", r).selectAll().executeTakeFirst();
1109
+ return a ? {
1115
1110
  ...a,
1111
+ rotating: !!a.rotating,
1112
+ device: a.device ? JSON.parse(a.device) : {},
1113
+ resource_servers: a.resource_servers ? JSON.parse(a.resource_servers) : []
1114
+ } : null;
1115
+ };
1116
+ }
1117
+ function Nr(t) {
1118
+ return async (e, r) => {
1119
+ const a = {
1120
+ ...r,
1116
1121
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1117
1122
  };
1118
- return await t.insertInto("refresh_tokens").values({ ...r, tenant_id: e }).execute(), { ...a, ...r };
1123
+ return await t.insertInto("refresh_tokens").values({
1124
+ ...a,
1125
+ tenant_id: e,
1126
+ rotating: r.rotating ? 1 : 0,
1127
+ device: JSON.stringify(r.device),
1128
+ resource_servers: JSON.stringify(r.resource_servers)
1129
+ }).execute(), { ...r, ...a };
1119
1130
  };
1120
1131
  }
1121
- function va(t) {
1122
- return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1132
+ function vr(t) {
1133
+ return async (e, r) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1123
1134
  }
1124
- function Ca(t) {
1125
- return async (e, a, r) => !!(await t.updateTable("refresh_tokens").set(r).where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1135
+ function br(t) {
1136
+ return async (e, r, a) => {
1137
+ const o = {
1138
+ ...a,
1139
+ device: a.device ? JSON.stringify(a.device) : void 0,
1140
+ resource_servers: a.resource_servers ? JSON.stringify(a.resource_servers) : void 0,
1141
+ rotating: a.rotating ? 1 : 0
1142
+ };
1143
+ return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1144
+ };
1126
1145
  }
1127
- function ba(t) {
1128
- return async (e, a = {
1146
+ function Cr(t) {
1147
+ return async (e, r = {
1129
1148
  page: 0,
1130
1149
  per_page: 50,
1131
1150
  include_totals: !1
1132
1151
  }) => {
1133
- let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1134
- a.q && (r = T(t, r, a.q, ["token", "session_id"]));
1135
- let o = r;
1136
- if (a.sort && a.sort.sort_by) {
1137
- const { ref: d } = t.dynamic;
1152
+ let a = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1153
+ r.q && (a = T(t, a, r.q, ["token", "session_id"]));
1154
+ let o = a;
1155
+ if (r.sort && r.sort.sort_by) {
1156
+ const { ref: l } = t.dynamic;
1138
1157
  o = o.orderBy(
1139
- d(a.sort.sort_by),
1140
- a.sort.sort_order
1158
+ l(r.sort.sort_by),
1159
+ r.sort.sort_order
1141
1160
  );
1142
1161
  }
1143
- o = o.offset(a.page * a.per_page).limit(a.per_page);
1144
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
1145
- return {
1146
- refresh_tokens: n,
1147
- start: a.page * a.per_page,
1148
- limit: a.per_page,
1149
- length: l
1162
+ o = o.offset(r.page * r.per_page).limit(r.per_page);
1163
+ const n = await o.selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = C(s);
1164
+ return {
1165
+ refresh_tokens: n.map((l) => ({
1166
+ ...l,
1167
+ rotating: !!l.rotating,
1168
+ device: l.device ? JSON.parse(l.device) : {},
1169
+ resource_servers: l.resource_servers ? JSON.parse(l.resource_servers) : []
1170
+ })),
1171
+ start: r.page * r.per_page,
1172
+ limit: r.per_page,
1173
+ length: c
1150
1174
  };
1151
1175
  };
1152
1176
  }
1153
- function xa(t) {
1177
+ function xr(t) {
1154
1178
  return {
1155
- create: Na(t),
1156
- get: ya(t),
1157
- list: ba(t),
1158
- remove: va(t),
1159
- update: Ca(t)
1179
+ create: Nr(t),
1180
+ get: wr(t),
1181
+ list: Cr(t),
1182
+ remove: vr(t),
1183
+ update: br(t)
1160
1184
  };
1161
1185
  }
1162
- function Ta(t) {
1186
+ function Tr(t) {
1163
1187
  return t[t.length - 1];
1164
1188
  }
1165
1189
  function p(t) {
@@ -1175,7 +1199,7 @@ const z = p({
1175
1199
  name: t
1176
1200
  });
1177
1201
  }
1178
- }), W = p({
1202
+ }), q = p({
1179
1203
  is(t) {
1180
1204
  return t.kind === "SchemableIdentifierNode";
1181
1205
  },
@@ -1192,7 +1216,7 @@ const z = p({
1192
1216
  identifier: z.create(e)
1193
1217
  });
1194
1218
  }
1195
- }), Sa = p({
1219
+ }), Sr = p({
1196
1220
  is(t) {
1197
1221
  return t.kind === "AliasNode";
1198
1222
  },
@@ -1203,28 +1227,28 @@ const z = p({
1203
1227
  alias: e
1204
1228
  });
1205
1229
  }
1206
- }), K = p({
1230
+ }), U = p({
1207
1231
  is(t) {
1208
1232
  return t.kind === "TableNode";
1209
1233
  },
1210
1234
  create(t) {
1211
1235
  return p({
1212
1236
  kind: "TableNode",
1213
- table: W.create(t)
1237
+ table: q.create(t)
1214
1238
  });
1215
1239
  },
1216
1240
  createWithSchema(t, e) {
1217
1241
  return p({
1218
1242
  kind: "TableNode",
1219
- table: W.createWithSchema(t, e)
1243
+ table: q.createWithSchema(t, e)
1220
1244
  });
1221
1245
  }
1222
1246
  });
1223
1247
  var R;
1224
- class Oa {
1248
+ class Or {
1225
1249
  constructor() {
1226
1250
  j(this, "nodeStack", []);
1227
- w(this, R, p({
1251
+ y(this, R, p({
1228
1252
  AliasNode: this.transformAlias.bind(this),
1229
1253
  ColumnNode: this.transformColumn.bind(this),
1230
1254
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -1324,14 +1348,14 @@ class Oa {
1324
1348
  if (!e)
1325
1349
  return e;
1326
1350
  this.nodeStack.push(e);
1327
- const a = this.transformNodeImpl(e);
1328
- return this.nodeStack.pop(), p(a);
1351
+ const r = this.transformNodeImpl(e);
1352
+ return this.nodeStack.pop(), p(r);
1329
1353
  }
1330
1354
  transformNodeImpl(e) {
1331
- return c(this, R)[e.kind](e);
1355
+ return d(this, R)[e.kind](e);
1332
1356
  }
1333
1357
  transformNodeList(e) {
1334
- return e && p(e.map((a) => this.transformNode(a)));
1358
+ return e && p(e.map((r) => this.transformNode(r)));
1335
1359
  }
1336
1360
  transformSelectQuery(e) {
1337
1361
  return {
@@ -2055,7 +2079,7 @@ class Oa {
2055
2079
  }
2056
2080
  }
2057
2081
  R = new WeakMap();
2058
- const ka = p({
2082
+ const kr = p({
2059
2083
  AlterTableNode: !0,
2060
2084
  CreateIndexNode: !0,
2061
2085
  CreateSchemaNode: !0,
@@ -2074,88 +2098,88 @@ const ka = p({
2074
2098
  UpdateQueryNode: !0,
2075
2099
  MergeQueryNode: !0
2076
2100
  });
2077
- var P, S, O, _, ge, we, ye, $, q, Ne;
2078
- class $a extends Oa {
2079
- constructor(a) {
2101
+ var P, S, O, _, ge, ye, we, $, W, Ne;
2102
+ class $r extends Or {
2103
+ constructor(r) {
2080
2104
  super();
2081
- w(this, _);
2082
- w(this, P);
2083
- w(this, S, /* @__PURE__ */ new Set());
2084
- w(this, O, /* @__PURE__ */ new Set());
2085
- M(this, P, a);
2086
- }
2087
- transformNodeImpl(a) {
2088
- if (!u(this, _, ge).call(this, a))
2089
- return super.transformNodeImpl(a);
2090
- const r = u(this, _, ye).call(this, a);
2091
- for (const s of r)
2092
- c(this, O).add(s);
2093
- const o = u(this, _, we).call(this, a);
2105
+ y(this, _);
2106
+ y(this, P);
2107
+ y(this, S, /* @__PURE__ */ new Set());
2108
+ y(this, O, /* @__PURE__ */ new Set());
2109
+ M(this, P, r);
2110
+ }
2111
+ transformNodeImpl(r) {
2112
+ if (!u(this, _, ge).call(this, r))
2113
+ return super.transformNodeImpl(r);
2114
+ const a = u(this, _, we).call(this, r);
2115
+ for (const s of a)
2116
+ d(this, O).add(s);
2117
+ const o = u(this, _, ye).call(this, r);
2094
2118
  for (const s of o)
2095
- c(this, S).add(s);
2096
- const n = super.transformNodeImpl(a);
2119
+ d(this, S).add(s);
2120
+ const n = super.transformNodeImpl(r);
2097
2121
  for (const s of o)
2098
- c(this, S).delete(s);
2099
- for (const s of r)
2100
- c(this, O).delete(s);
2122
+ d(this, S).delete(s);
2123
+ for (const s of a)
2124
+ d(this, O).delete(s);
2101
2125
  return n;
2102
2126
  }
2103
- transformSchemableIdentifier(a) {
2104
- const r = super.transformSchemableIdentifier(a);
2105
- return r.schema || !c(this, S).has(a.identifier.name) ? r : {
2106
- ...r,
2107
- schema: z.create(c(this, P))
2127
+ transformSchemableIdentifier(r) {
2128
+ const a = super.transformSchemableIdentifier(r);
2129
+ return a.schema || !d(this, S).has(r.identifier.name) ? a : {
2130
+ ...a,
2131
+ schema: z.create(d(this, P))
2108
2132
  };
2109
2133
  }
2110
- transformReferences(a) {
2111
- const r = super.transformReferences(a);
2112
- return r.table.table.schema ? r : {
2113
- ...r,
2114
- table: K.createWithSchema(c(this, P), r.table.table.identifier.name)
2115
- };
2116
- }
2117
- }
2118
- P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(a) {
2119
- return a.kind in ka;
2120
- }, we = function(a) {
2121
- const r = /* @__PURE__ */ new Set();
2122
- if ("name" in a && a.name && W.is(a.name) && u(this, _, q).call(this, a.name, r), "from" in a && a.from)
2123
- for (const o of a.from.froms)
2124
- u(this, _, $).call(this, o, r);
2125
- if ("into" in a && a.into && u(this, _, $).call(this, a.into, r), "table" in a && a.table && u(this, _, $).call(this, a.table, r), "joins" in a && a.joins)
2126
- for (const o of a.joins)
2127
- u(this, _, $).call(this, o.table, r);
2128
- return "using" in a && a.using && u(this, _, $).call(this, a.using, r), r;
2129
- }, ye = function(a) {
2130
- const r = /* @__PURE__ */ new Set();
2131
- return "with" in a && a.with && u(this, _, Ne).call(this, a.with, r), r;
2132
- }, $ = function(a, r) {
2133
- const o = K.is(a) ? a : Sa.is(a) && K.is(a.node) ? a.node : null;
2134
- o && u(this, _, q).call(this, o.table, r);
2135
- }, q = function(a, r) {
2136
- const o = a.identifier.name;
2137
- !c(this, S).has(o) && !c(this, O).has(o) && r.add(o);
2138
- }, Ne = function(a, r) {
2139
- for (const o of a.expressions) {
2134
+ transformReferences(r) {
2135
+ const a = super.transformReferences(r);
2136
+ return a.table.table.schema ? a : {
2137
+ ...a,
2138
+ table: U.createWithSchema(d(this, P), a.table.table.identifier.name)
2139
+ };
2140
+ }
2141
+ }
2142
+ P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(r) {
2143
+ return r.kind in kr;
2144
+ }, ye = function(r) {
2145
+ const a = /* @__PURE__ */ new Set();
2146
+ if ("name" in r && r.name && q.is(r.name) && u(this, _, W).call(this, r.name, a), "from" in r && r.from)
2147
+ for (const o of r.from.froms)
2148
+ u(this, _, $).call(this, o, a);
2149
+ if ("into" in r && r.into && u(this, _, $).call(this, r.into, a), "table" in r && r.table && u(this, _, $).call(this, r.table, a), "joins" in r && r.joins)
2150
+ for (const o of r.joins)
2151
+ u(this, _, $).call(this, o.table, a);
2152
+ return "using" in r && r.using && u(this, _, $).call(this, r.using, a), a;
2153
+ }, we = function(r) {
2154
+ const a = /* @__PURE__ */ new Set();
2155
+ return "with" in r && r.with && u(this, _, Ne).call(this, r.with, a), a;
2156
+ }, $ = function(r, a) {
2157
+ const o = U.is(r) ? r : Sr.is(r) && U.is(r.node) ? r.node : null;
2158
+ o && u(this, _, W).call(this, o.table, a);
2159
+ }, W = function(r, a) {
2160
+ const o = r.identifier.name;
2161
+ !d(this, S).has(o) && !d(this, O).has(o) && a.add(o);
2162
+ }, Ne = function(r, a) {
2163
+ for (const o of r.expressions) {
2140
2164
  const n = o.name.table.table.identifier.name;
2141
- c(this, O).has(n) || r.add(n);
2165
+ d(this, O).has(n) || a.add(n);
2142
2166
  }
2143
2167
  };
2144
2168
  var L;
2145
- class Ia {
2169
+ class Ir {
2146
2170
  constructor(e) {
2147
- w(this, L);
2148
- M(this, L, new $a(e));
2171
+ y(this, L);
2172
+ M(this, L, new $r(e));
2149
2173
  }
2150
2174
  transformQuery(e) {
2151
- return c(this, L).transformNode(e.node);
2175
+ return d(this, L).transformNode(e.node);
2152
2176
  }
2153
2177
  async transformResult(e) {
2154
2178
  return e.result;
2155
2179
  }
2156
2180
  }
2157
2181
  L = new WeakMap();
2158
- class Da {
2182
+ class Dr {
2159
2183
  transformQuery(e) {
2160
2184
  return e.node;
2161
2185
  }
@@ -2163,12 +2187,12 @@ class Da {
2163
2187
  return e.result;
2164
2188
  }
2165
2189
  }
2166
- const Pa = "kysely_migration", fe = "kysely_migration_lock", ja = !1, B = "migration_lock", Ma = p({ __noMigrations__: !0 });
2167
- var h, i, A, N, v, I, Ce, C, be, xe, Te, Se, Oe, G, D, H, ke, $e, Ie, X, De, Pe, je, Me, Ae, F;
2190
+ const Pr = "kysely_migration", fe = "kysely_migration_lock", jr = !1, B = "migration_lock", Mr = p({ __noMigrations__: !0 });
2191
+ var h, i, A, N, v, I, be, b, Ce, xe, Te, Se, Oe, G, D, H, ke, $e, Ie, X, De, Pe, je, Me, Ae, F;
2168
2192
  class ve {
2169
2193
  constructor(e) {
2170
- w(this, i);
2171
- w(this, h);
2194
+ y(this, i);
2195
+ y(this, h);
2172
2196
  M(this, h, p(e));
2173
2197
  }
2174
2198
  /**
@@ -2177,11 +2201,11 @@ class ve {
2177
2201
  * The returned array is sorted by migration name.
2178
2202
  */
2179
2203
  async getMigrations() {
2180
- const e = await u(this, i, D).call(this, c(this, i, v)) ? await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, v)).select(["name", "timestamp"]).execute() : [];
2181
- return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2182
- const n = e.find((s) => s.name === r);
2204
+ const e = await u(this, i, D).call(this, d(this, i, v)) ? await d(this, h).db.withPlugin(d(this, i, b)).selectFrom(d(this, i, v)).select(["name", "timestamp"]).execute() : [];
2205
+ return (await u(this, i, X).call(this)).map(({ name: a, ...o }) => {
2206
+ const n = e.find((s) => s.name === a);
2183
2207
  return {
2184
- name: r,
2208
+ name: a,
2185
2209
  migration: o,
2186
2210
  executedAt: n ? new Date(n.timestamp) : void 0
2187
2211
  };
@@ -2261,16 +2285,16 @@ class ve {
2261
2285
  * ```
2262
2286
  */
2263
2287
  async migrateTo(e) {
2264
- return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2265
- if (e === Ma)
2288
+ return u(this, i, A).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: o }) => {
2289
+ if (e === Mr)
2266
2290
  return { direction: "Down", step: 1 / 0 };
2267
- if (!a.find((l) => l.name === e))
2291
+ if (!r.find((c) => c.name === e))
2268
2292
  throw new Error(`migration "${e}" doesn't exist`);
2269
- const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2293
+ const n = a.indexOf(e), s = o.findIndex((c) => c.name === e);
2270
2294
  if (n !== -1)
2271
2295
  return {
2272
2296
  direction: "Down",
2273
- step: r.length - n - 1
2297
+ step: a.length - n - 1
2274
2298
  };
2275
2299
  if (s !== -1)
2276
2300
  return { direction: "Up", step: s + 1 };
@@ -2314,176 +2338,176 @@ class ve {
2314
2338
  }
2315
2339
  h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2316
2340
  try {
2317
- return await u(this, i, be).call(this), await u(this, i, ke).call(this, e);
2318
- } catch (a) {
2319
- return a instanceof Q ? a.resultSet : { error: a };
2341
+ return await u(this, i, Ce).call(this), await u(this, i, ke).call(this, e);
2342
+ } catch (r) {
2343
+ return r instanceof Q ? r.resultSet : { error: r };
2320
2344
  }
2321
2345
  }, N = function() {
2322
- return c(this, h).migrationTableSchema;
2346
+ return d(this, h).migrationTableSchema;
2323
2347
  }, v = function() {
2324
- return c(this, h).migrationTableName ?? Pa;
2348
+ return d(this, h).migrationTableName ?? Pr;
2325
2349
  }, I = function() {
2326
- return c(this, h).migrationLockTableName ?? fe;
2327
- }, Ce = function() {
2328
- return c(this, h).allowUnorderedMigrations ?? ja;
2329
- }, C = function() {
2330
- return c(this, i, N) ? new Ia(c(this, i, N)) : new Da();
2331
- }, be = async function() {
2350
+ return d(this, h).migrationLockTableName ?? fe;
2351
+ }, be = function() {
2352
+ return d(this, h).allowUnorderedMigrations ?? jr;
2353
+ }, b = function() {
2354
+ return d(this, i, N) ? new Ir(d(this, i, N)) : new Dr();
2355
+ }, Ce = async function() {
2332
2356
  await u(this, i, xe).call(this), await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this);
2333
2357
  }, xe = async function() {
2334
- if (c(this, i, N) && !await u(this, i, G).call(this))
2358
+ if (d(this, i, N) && !await u(this, i, G).call(this))
2335
2359
  try {
2336
- await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N)));
2360
+ await u(this, i, F).call(this, d(this, h).db.schema.createSchema(d(this, i, N)));
2337
2361
  } catch (e) {
2338
2362
  if (!await u(this, i, G).call(this))
2339
2363
  throw e;
2340
2364
  }
2341
2365
  }, Te = async function() {
2342
- if (!await u(this, i, D).call(this, c(this, i, v)))
2366
+ if (!await u(this, i, D).call(this, d(this, i, v)))
2343
2367
  try {
2344
- c(this, i, N) && await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N))), await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2368
+ d(this, i, N) && await u(this, i, F).call(this, d(this, h).db.schema.createSchema(d(this, i, N))), await u(this, i, F).call(this, d(this, h).db.schema.withPlugin(d(this, i, b)).createTable(d(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2345
2369
  } catch (e) {
2346
- if (!await u(this, i, D).call(this, c(this, i, v)))
2370
+ if (!await u(this, i, D).call(this, d(this, i, v)))
2347
2371
  throw e;
2348
2372
  }
2349
2373
  }, Se = async function() {
2350
- if (!await u(this, i, D).call(this, c(this, i, I)))
2374
+ if (!await u(this, i, D).call(this, d(this, i, I)))
2351
2375
  try {
2352
- await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, I)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2376
+ await u(this, i, F).call(this, d(this, h).db.schema.withPlugin(d(this, i, b)).createTable(d(this, i, I)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2353
2377
  } catch (e) {
2354
- if (!await u(this, i, D).call(this, c(this, i, I)))
2378
+ if (!await u(this, i, D).call(this, d(this, i, I)))
2355
2379
  throw e;
2356
2380
  }
2357
2381
  }, Oe = async function() {
2358
2382
  if (!await u(this, i, H).call(this))
2359
2383
  try {
2360
- await c(this, h).db.withPlugin(c(this, i, C)).insertInto(c(this, i, I)).values({ id: B, is_locked: 0 }).execute();
2384
+ await d(this, h).db.withPlugin(d(this, i, b)).insertInto(d(this, i, I)).values({ id: B, is_locked: 0 }).execute();
2361
2385
  } catch (e) {
2362
2386
  if (!await u(this, i, H).call(this))
2363
2387
  throw e;
2364
2388
  }
2365
2389
  }, G = async function() {
2366
- return (await c(this, h).db.introspection.getSchemas()).some((a) => a.name === c(this, i, N));
2390
+ return (await d(this, h).db.introspection.getSchemas()).some((r) => r.name === d(this, i, N));
2367
2391
  }, D = async function(e) {
2368
- const a = c(this, i, N);
2369
- return (await c(this, h).db.introspection.getTables({
2392
+ const r = d(this, i, N);
2393
+ return (await d(this, h).db.introspection.getTables({
2370
2394
  withInternalKyselyTables: !0
2371
- })).some((o) => o.name === e && (!a || o.schema === a));
2395
+ })).some((o) => o.name === e && (!r || o.schema === r));
2372
2396
  }, H = async function() {
2373
- return !!await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, I)).where("id", "=", B).select("id").executeTakeFirst();
2397
+ return !!await d(this, h).db.withPlugin(d(this, i, b)).selectFrom(d(this, i, I)).where("id", "=", B).select("id").executeTakeFirst();
2374
2398
  }, ke = async function(e) {
2375
- const a = c(this, h).db.getExecutor().adapter, r = p({
2376
- lockTable: c(this, h).migrationLockTableName ?? fe,
2399
+ const r = d(this, h).db.getExecutor().adapter, a = p({
2400
+ lockTable: d(this, h).migrationLockTableName ?? fe,
2377
2401
  lockRowId: B,
2378
- lockTableSchema: c(this, h).migrationTableSchema
2402
+ lockTableSchema: d(this, h).migrationTableSchema
2379
2403
  }), o = async (n) => {
2380
2404
  try {
2381
- await a.acquireMigrationLock(n, r);
2405
+ await r.acquireMigrationLock(n, a);
2382
2406
  const s = await u(this, i, $e).call(this, n);
2383
2407
  if (s.migrations.length === 0)
2384
2408
  return { results: [] };
2385
- const { direction: l, step: d } = e(s);
2386
- return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, d) : l === "Up" ? await u(this, i, Ae).call(this, n, s, d) : { results: [] };
2409
+ const { direction: c, step: l } = e(s);
2410
+ return l <= 0 ? { results: [] } : c === "Down" ? await u(this, i, Me).call(this, n, s, l) : c === "Up" ? await u(this, i, Ae).call(this, n, s, l) : { results: [] };
2387
2411
  } finally {
2388
- await a.releaseMigrationLock(n, r);
2412
+ await r.releaseMigrationLock(n, a);
2389
2413
  }
2390
2414
  };
2391
- return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2415
+ return r.supportsTransactionalDdl ? d(this, h).db.transaction().execute(o) : d(this, h).db.connection().execute(o);
2392
2416
  }, $e = async function(e) {
2393
- const a = await u(this, i, X).call(this), r = await u(this, i, De).call(this, e);
2394
- u(this, i, Pe).call(this, a, r), c(this, i, Ce) || u(this, i, je).call(this, a, r);
2395
- const o = u(this, i, Ie).call(this, a, r);
2417
+ const r = await u(this, i, X).call(this), a = await u(this, i, De).call(this, e);
2418
+ u(this, i, Pe).call(this, r, a), d(this, i, be) || u(this, i, je).call(this, r, a);
2419
+ const o = u(this, i, Ie).call(this, r, a);
2396
2420
  return p({
2397
- migrations: a,
2398
- executedMigrations: r,
2399
- lastMigration: Ta(r),
2421
+ migrations: r,
2422
+ executedMigrations: a,
2423
+ lastMigration: Tr(a),
2400
2424
  pendingMigrations: o
2401
2425
  });
2402
- }, Ie = function(e, a) {
2403
- return e.filter((r) => !a.includes(r.name));
2426
+ }, Ie = function(e, r) {
2427
+ return e.filter((a) => !r.includes(a.name));
2404
2428
  }, X = async function() {
2405
- const e = await c(this, h).provider.getMigrations();
2406
- return Object.keys(e).sort().map((a) => ({
2407
- ...e[a],
2408
- name: a
2429
+ const e = await d(this, h).provider.getMigrations();
2430
+ return Object.keys(e).sort().map((r) => ({
2431
+ ...e[r],
2432
+ name: r
2409
2433
  }));
2410
2434
  }, De = async function(e) {
2411
- return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2412
- }, Pe = function(e, a) {
2413
- for (const r of a)
2414
- if (!e.some((o) => o.name === r))
2415
- throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2416
- }, je = function(e, a) {
2417
- for (let r = 0; r < a.length; ++r)
2418
- if (e[r].name !== a[r])
2419
- throw new Error(`corrupted migrations: expected previously executed migration ${a[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2420
- }, Me = async function(e, a, r) {
2421
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2435
+ return (await e.withPlugin(d(this, i, b)).selectFrom(d(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
2436
+ }, Pe = function(e, r) {
2437
+ for (const a of r)
2438
+ if (!e.some((o) => o.name === a))
2439
+ throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
2440
+ }, je = function(e, r) {
2441
+ for (let a = 0; a < r.length; ++a)
2442
+ if (e[a].name !== r[a])
2443
+ throw new Error(`corrupted migrations: expected previously executed migration ${r[a]} to be at index ${a} but ${e[a].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2444
+ }, Me = async function(e, r, a) {
2445
+ const o = r.executedMigrations.slice().reverse().slice(0, a).map((s) => r.migrations.find((c) => c.name === s)), n = o.map((s) => ({
2422
2446
  migrationName: s.name,
2423
2447
  direction: "Down",
2424
2448
  status: "NotExecuted"
2425
2449
  }));
2426
2450
  for (let s = 0; s < n.length; ++s) {
2427
- const l = o[s];
2451
+ const c = o[s];
2428
2452
  try {
2429
- l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, v)).where("name", "=", l.name).execute(), n[s] = {
2430
- migrationName: l.name,
2453
+ c.down && (await c.down(e), await e.withPlugin(d(this, i, b)).deleteFrom(d(this, i, v)).where("name", "=", c.name).execute(), n[s] = {
2454
+ migrationName: c.name,
2431
2455
  direction: "Down",
2432
2456
  status: "Success"
2433
2457
  });
2434
- } catch (d) {
2458
+ } catch (l) {
2435
2459
  throw n[s] = {
2436
- migrationName: l.name,
2460
+ migrationName: c.name,
2437
2461
  direction: "Down",
2438
2462
  status: "Error"
2439
2463
  }, new Q({
2440
- error: d,
2464
+ error: l,
2441
2465
  results: n
2442
2466
  });
2443
2467
  }
2444
2468
  }
2445
2469
  return { results: n };
2446
- }, Ae = async function(e, a, r) {
2447
- const n = a.pendingMigrations.slice(0, r).map((s) => ({
2470
+ }, Ae = async function(e, r, a) {
2471
+ const n = r.pendingMigrations.slice(0, a).map((s) => ({
2448
2472
  migrationName: s.name,
2449
2473
  direction: "Up",
2450
2474
  status: "NotExecuted"
2451
2475
  }));
2452
2476
  for (let s = 0; s < n.length; s++) {
2453
- const l = a.pendingMigrations[s];
2477
+ const c = r.pendingMigrations[s];
2454
2478
  try {
2455
- await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, v)).values({
2456
- name: l.name,
2479
+ await c.up(e), await e.withPlugin(d(this, i, b)).insertInto(d(this, i, v)).values({
2480
+ name: c.name,
2457
2481
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2458
2482
  }).execute(), n[s] = {
2459
- migrationName: l.name,
2483
+ migrationName: c.name,
2460
2484
  direction: "Up",
2461
2485
  status: "Success"
2462
2486
  };
2463
- } catch (d) {
2487
+ } catch (l) {
2464
2488
  throw n[s] = {
2465
- migrationName: l.name,
2489
+ migrationName: c.name,
2466
2490
  direction: "Up",
2467
2491
  status: "Error"
2468
2492
  }, new Q({
2469
- error: d,
2493
+ error: l,
2470
2494
  results: n
2471
2495
  });
2472
2496
  }
2473
2497
  }
2474
2498
  return { results: n };
2475
2499
  }, F = async function(e) {
2476
- c(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2500
+ d(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2477
2501
  };
2478
2502
  var E;
2479
2503
  class Q extends Error {
2480
- constructor(a) {
2504
+ constructor(r) {
2481
2505
  super();
2482
- w(this, E);
2483
- M(this, E, a);
2506
+ y(this, E);
2507
+ M(this, E, r);
2484
2508
  }
2485
2509
  get resultSet() {
2486
- return c(this, E);
2510
+ return d(this, E);
2487
2511
  }
2488
2512
  }
2489
2513
  E = new WeakMap();
@@ -2496,7 +2520,7 @@ class Fe {
2496
2520
  return this.migrations;
2497
2521
  }
2498
2522
  }
2499
- async function Aa(t) {
2523
+ async function Ar(t) {
2500
2524
  await t.schema.createTable("tenants").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)").addColumn("audience", "varchar(255)").addColumn("sender_email", "varchar(255)").addColumn("sender_name", "varchar(255)").addColumn("language", "varchar(255)").addColumn("logo", "varchar(255)").addColumn("primary_color", "varchar(255)").addColumn("secondary_color", "varchar(255)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createTable("users").addColumn("user_id", "varchar(255)", (e) => e.notNull()).addColumn(
2501
2525
  "tenant_id",
2502
2526
  "varchar(255)",
@@ -2564,35 +2588,35 @@ async function Aa(t) {
2564
2588
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
2565
2589
  ).addColumn("domain", "varchar(255)", (e) => e.notNull()).addColumn("email_service", "varchar(255)").addColumn("email_api_key", "varchar(255)").addColumn("dkim_private_key", "varchar(2048)").addColumn("dkim_public_key", "varchar(2048)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute();
2566
2590
  }
2567
- async function Fa(t) {
2591
+ async function Fr(t) {
2568
2592
  await t.schema.dropTable("domains").execute(), await t.schema.dropTable("members").execute(), await t.schema.dropTable("users").execute(), await t.schema.dropTable("connections").execute(), await t.schema.dropTable("applications").execute(), await t.schema.dropTable("migrations").execute(), await t.schema.dropTable("tenants").execute();
2569
2593
  }
2570
- const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2594
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2571
2595
  __proto__: null,
2572
- down: Fa,
2573
- up: Aa
2596
+ down: Fr,
2597
+ up: Ar
2574
2598
  }, Symbol.toStringTag, { value: "Module" }));
2575
- async function Ea(t) {
2599
+ async function Er(t) {
2576
2600
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
2577
2601
  }
2578
- async function Ja(t) {
2602
+ async function Jr(t) {
2579
2603
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
2580
2604
  }
2581
- const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2605
+ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2582
2606
  __proto__: null,
2583
- down: Ja,
2584
- up: Ea
2607
+ down: Jr,
2608
+ up: Er
2585
2609
  }, Symbol.toStringTag, { value: "Module" }));
2586
- async function Ra(t) {
2610
+ async function Rr(t) {
2587
2611
  }
2588
- async function Ua(t) {
2612
+ async function Kr(t) {
2589
2613
  }
2590
- const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2614
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2591
2615
  __proto__: null,
2592
- down: Ua,
2593
- up: Ra
2616
+ down: Kr,
2617
+ up: Rr
2594
2618
  }, Symbol.toStringTag, { value: "Module" }));
2595
- async function Ba(t) {
2619
+ async function Br(t) {
2596
2620
  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(
2597
2621
  "tenant_id_constraint",
2598
2622
  ["tenant_id"],
@@ -2601,35 +2625,31 @@ async function Ba(t) {
2601
2625
  (e) => e.onDelete("cascade")
2602
2626
  ).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();
2603
2627
  }
2604
- async function Qa(t) {
2628
+ async function Qr(t) {
2605
2629
  await t.schema.dropTable("logs").execute();
2606
2630
  }
2607
- const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2631
+ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2608
2632
  __proto__: null,
2609
- down: Qa,
2610
- up: Ba
2633
+ down: Qr,
2634
+ up: Br
2611
2635
  }, Symbol.toStringTag, { value: "Module" }));
2612
- async function Wa(t) {
2636
+ async function qr(t) {
2613
2637
  }
2614
- async function qa(t) {
2638
+ async function Wr(t) {
2615
2639
  }
2616
- const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2640
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2617
2641
  __proto__: null,
2618
- down: qa,
2619
- up: Wa
2642
+ down: Wr,
2643
+ up: qr
2620
2644
  }, Symbol.toStringTag, { value: "Module" }));
2621
- async function Ha(t) {
2622
- await t.schema.createTable("sessions").addColumn("session_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
2623
- "client_id",
2624
- "varchar(255)",
2625
- (e) => e.references("applications.id").onDelete("cascade").notNull()
2626
- ).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
2645
+ async function Hr(t) {
2646
+ await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
2627
2647
  "user_id_constraint",
2628
2648
  ["user_id", "tenant_id"],
2629
2649
  "users",
2630
2650
  ["user_id", "tenant_id"],
2631
2651
  (e) => e.onDelete("cascade")
2632
- ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").addColumn("deleted_at", "varchar(255)").execute(), await t.schema.createTable("tickets").addColumn(
2652
+ ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("authenticated_at", "varchar(35)").addColumn("last_interaction_at", "varchar(35)").addColumn("used_at", "varchar(35)").addColumn("revoked_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("clients", "varchar(1024)", (e) => e.notNull()).execute(), await t.schema.createTable("tickets").addColumn(
2633
2653
  "tenant_id",
2634
2654
  "varchar(255)",
2635
2655
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
@@ -2647,15 +2667,15 @@ async function Ha(t) {
2647
2667
  (e) => e.references("applications.id").onDelete("cascade").notNull()
2648
2668
  ).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();
2649
2669
  }
2650
- async function Xa(t) {
2670
+ async function Xr(t) {
2651
2671
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
2652
2672
  }
2653
- const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2673
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2654
2674
  __proto__: null,
2655
- down: Xa,
2656
- up: Ha
2675
+ down: Xr,
2676
+ up: Hr
2657
2677
  }, Symbol.toStringTag, { value: "Module" }));
2658
- async function Za(t) {
2678
+ async function Zr(t) {
2659
2679
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
2660
2680
  "user_id_constraint",
2661
2681
  ["user_id", "tenant_id"],
@@ -2670,24 +2690,24 @@ async function Za(t) {
2670
2690
  (e) => e.onDelete("cascade")
2671
2691
  ).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();
2672
2692
  }
2673
- async function er(t) {
2693
+ async function ea(t) {
2674
2694
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
2675
2695
  }
2676
- const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2696
+ const ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2677
2697
  __proto__: null,
2678
- down: er,
2679
- up: Za
2698
+ down: ea,
2699
+ up: Zr
2680
2700
  }, Symbol.toStringTag, { value: "Module" }));
2681
- async function ar(t) {
2701
+ async function ra(t) {
2682
2702
  }
2683
- async function rr(t) {
2703
+ async function aa(t) {
2684
2704
  }
2685
- const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2705
+ const na = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2686
2706
  __proto__: null,
2687
- down: rr,
2688
- up: ar
2707
+ down: aa,
2708
+ up: ra
2689
2709
  }, Symbol.toStringTag, { value: "Module" }));
2690
- async function or(t) {
2710
+ async function oa(t) {
2691
2711
  await t.schema.alterTable("passwords").addColumn(
2692
2712
  "password",
2693
2713
  "varchar(255)",
@@ -2695,172 +2715,172 @@ async function or(t) {
2695
2715
  (e) => e.notNull()
2696
2716
  ).execute();
2697
2717
  }
2698
- async function sr(t) {
2718
+ async function sa(t) {
2699
2719
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2700
2720
  }
2701
- const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2721
+ const ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2702
2722
  __proto__: null,
2703
- down: sr,
2704
- up: or
2723
+ down: sa,
2724
+ up: oa
2705
2725
  }, Symbol.toStringTag, { value: "Module" }));
2706
- async function lr(t) {
2726
+ async function ca(t) {
2707
2727
  }
2708
- async function cr(t) {
2728
+ async function la(t) {
2709
2729
  }
2710
- const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2730
+ const da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2711
2731
  __proto__: null,
2712
- down: cr,
2713
- up: lr
2732
+ down: la,
2733
+ up: ca
2714
2734
  }, Symbol.toStringTag, { value: "Module" }));
2715
- async function ur(t) {
2735
+ async function ua(t) {
2716
2736
  }
2717
- async function mr(t) {
2737
+ async function ma(t) {
2718
2738
  }
2719
- const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2739
+ const ha = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2720
2740
  __proto__: null,
2721
- down: mr,
2722
- up: ur
2741
+ down: ma,
2742
+ up: ua
2723
2743
  }, Symbol.toStringTag, { value: "Module" }));
2724
- async function fr(t) {
2744
+ async function fa(t) {
2725
2745
  }
2726
- async function _r(t) {
2746
+ async function _a(t) {
2727
2747
  }
2728
- const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2748
+ const pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2729
2749
  __proto__: null,
2730
- down: _r,
2731
- up: fr
2750
+ down: _a,
2751
+ up: fa
2732
2752
  }, Symbol.toStringTag, { value: "Module" }));
2733
- async function gr(t) {
2753
+ async function ga(t) {
2734
2754
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
2735
2755
  }
2736
- async function wr(t) {
2756
+ async function ya(t) {
2737
2757
  await t.schema.dropIndex("users_email_index").execute();
2738
2758
  }
2739
- const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2759
+ const wa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2740
2760
  __proto__: null,
2741
- down: wr,
2742
- up: gr
2761
+ down: ya,
2762
+ up: ga
2743
2763
  }, Symbol.toStringTag, { value: "Module" }));
2744
- async function Nr(t) {
2764
+ async function Na(t) {
2745
2765
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
2746
2766
  }
2747
- async function vr(t) {
2767
+ async function va(t) {
2748
2768
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2749
2769
  }
2750
- const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2770
+ const ba = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2751
2771
  __proto__: null,
2752
- down: vr,
2753
- up: Nr
2772
+ down: va,
2773
+ up: Na
2754
2774
  }, Symbol.toStringTag, { value: "Module" }));
2755
- async function br(t) {
2775
+ async function Ca(t) {
2756
2776
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
2757
2777
  }
2758
- async function xr(t) {
2778
+ async function xa(t) {
2759
2779
  await t.schema.dropIndex("users_linked_to_index");
2760
2780
  }
2761
- const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2781
+ const Ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2762
2782
  __proto__: null,
2763
- down: xr,
2764
- up: br
2783
+ down: xa,
2784
+ up: Ca
2765
2785
  }, Symbol.toStringTag, { value: "Module" }));
2766
- async function Sr(t) {
2786
+ async function Sa(t) {
2767
2787
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
2768
2788
  }
2769
- async function Or(t) {
2789
+ async function Oa(t) {
2770
2790
  await t.schema.alterTable("users").dropColumn("locale").execute();
2771
2791
  }
2772
- const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2792
+ const ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2773
2793
  __proto__: null,
2774
- down: Or,
2775
- up: Sr
2794
+ down: Oa,
2795
+ up: Sa
2776
2796
  }, Symbol.toStringTag, { value: "Module" }));
2777
- async function $r(t) {
2797
+ async function $a(t) {
2778
2798
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2779
2799
  "tenant_id",
2780
2800
  "varchar(255)",
2781
2801
  (e) => e.references("tenants.id").onDelete("cascade")
2782
2802
  ).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();
2783
2803
  }
2784
- async function Ir(t) {
2804
+ async function Ia(t) {
2785
2805
  await t.schema.dropTable("keys").execute();
2786
2806
  }
2787
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2807
+ const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2788
2808
  __proto__: null,
2789
- down: Ir,
2790
- up: $r
2809
+ down: Ia,
2810
+ up: $a
2791
2811
  }, Symbol.toStringTag, { value: "Module" }));
2792
- async function Pr(t) {
2812
+ async function Pa(t) {
2793
2813
  }
2794
- async function jr(t) {
2814
+ async function ja(t) {
2795
2815
  }
2796
- const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2816
+ const Ma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2797
2817
  __proto__: null,
2798
- down: jr,
2799
- up: Pr
2818
+ down: ja,
2819
+ up: Pa
2800
2820
  }, Symbol.toStringTag, { value: "Module" }));
2801
- async function Ar(t) {
2821
+ async function Aa(t) {
2802
2822
  }
2803
- async function Fr(t) {
2823
+ async function Fa(t) {
2804
2824
  }
2805
- const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2825
+ const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2806
2826
  __proto__: null,
2807
- down: Fr,
2808
- up: Ar
2827
+ down: Fa,
2828
+ up: Aa
2809
2829
  }, Symbol.toStringTag, { value: "Module" }));
2810
- async function Er(t) {
2830
+ async function Ea(t) {
2811
2831
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
2812
2832
  }
2813
- async function Jr(t) {
2833
+ async function Ja(t) {
2814
2834
  await t.schema.alterTable("otps").dropColumn("audience").execute();
2815
2835
  }
2816
- const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2836
+ const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2817
2837
  __proto__: null,
2818
- down: Jr,
2819
- up: Er
2838
+ down: Ja,
2839
+ up: Ea
2820
2840
  }, Symbol.toStringTag, { value: "Module" }));
2821
- async function Rr(t) {
2841
+ async function Ra(t) {
2822
2842
  }
2823
- async function Ur(t) {
2843
+ async function Ka(t) {
2824
2844
  }
2825
- const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2845
+ const Ua = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2826
2846
  __proto__: null,
2827
- down: Ur,
2828
- up: Rr
2847
+ down: Ka,
2848
+ up: Ra
2829
2849
  }, Symbol.toStringTag, { value: "Module" }));
2830
- async function Br(t) {
2850
+ async function Ba(t) {
2831
2851
  await t.schema.alterTable("logs").dropColumn("category").execute();
2832
2852
  }
2833
- async function Qr(t) {
2853
+ async function Qa(t) {
2834
2854
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
2835
2855
  }
2836
- const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2856
+ const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2837
2857
  __proto__: null,
2838
- down: Qr,
2839
- up: Br
2858
+ down: Qa,
2859
+ up: Ba
2840
2860
  }, Symbol.toStringTag, { value: "Module" }));
2841
- async function Wr(t) {
2861
+ async function qa(t) {
2842
2862
  await t.schema.alterTable("users").dropColumn("tags").execute();
2843
2863
  }
2844
- async function qr(t) {
2864
+ async function Wa(t) {
2845
2865
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
2846
2866
  }
2847
- const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2867
+ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2848
2868
  __proto__: null,
2849
- down: qr,
2850
- up: Wr
2869
+ down: Wa,
2870
+ up: qa
2851
2871
  }, Symbol.toStringTag, { value: "Module" }));
2852
- async function Hr(t) {
2872
+ async function Ha(t) {
2853
2873
  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();
2854
2874
  }
2855
- async function Xr(t) {
2875
+ async function Xa(t) {
2856
2876
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
2857
2877
  }
2858
- const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2878
+ const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2859
2879
  __proto__: null,
2860
- down: Xr,
2861
- up: Hr
2880
+ down: Xa,
2881
+ up: Ha
2862
2882
  }, Symbol.toStringTag, { value: "Module" }));
2863
- async function Zr(t) {
2883
+ async function Za(t) {
2864
2884
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
2865
2885
  }
2866
2886
  async function en(t) {
@@ -2869,18 +2889,18 @@ async function en(t) {
2869
2889
  const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2870
2890
  __proto__: null,
2871
2891
  down: en,
2872
- up: Zr
2892
+ up: Za
2873
2893
  }, Symbol.toStringTag, { value: "Module" }));
2874
- async function an(t) {
2894
+ async function rn(t) {
2875
2895
  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();
2876
2896
  }
2877
- async function rn(t) {
2897
+ async function an(t) {
2878
2898
  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();
2879
2899
  }
2880
2900
  const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2881
2901
  __proto__: null,
2882
- down: rn,
2883
- up: an
2902
+ down: an,
2903
+ up: rn
2884
2904
  }, Symbol.toStringTag, { value: "Module" }));
2885
2905
  async function on(t) {
2886
2906
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
@@ -2888,12 +2908,12 @@ async function on(t) {
2888
2908
  async function sn(t) {
2889
2909
  await t.schema.dropIndex("users_name_index").execute();
2890
2910
  }
2891
- const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2911
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2892
2912
  __proto__: null,
2893
2913
  down: sn,
2894
2914
  up: on
2895
2915
  }, Symbol.toStringTag, { value: "Module" }));
2896
- async function cn(t) {
2916
+ async function ln(t) {
2897
2917
  }
2898
2918
  async function dn(t) {
2899
2919
  await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
@@ -2901,7 +2921,7 @@ async function dn(t) {
2901
2921
  const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2902
2922
  __proto__: null,
2903
2923
  down: dn,
2904
- up: cn
2924
+ up: ln
2905
2925
  }, Symbol.toStringTag, { value: "Module" }));
2906
2926
  async function mn(t) {
2907
2927
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
@@ -2925,28 +2945,28 @@ const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2925
2945
  down: pn,
2926
2946
  up: _n
2927
2947
  }, Symbol.toStringTag, { value: "Module" }));
2928
- async function wn(t) {
2948
+ async function yn(t) {
2929
2949
  await t.schema.createTable("branding").addColumn(
2930
2950
  "tenant_id",
2931
2951
  "varchar(255)",
2932
2952
  (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
2933
2953
  ).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();
2934
2954
  }
2935
- async function yn(t) {
2955
+ async function wn(t) {
2936
2956
  await t.schema.dropTable("branding").execute();
2937
2957
  }
2938
2958
  const Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2939
2959
  __proto__: null,
2940
- down: yn,
2941
- up: wn
2960
+ down: wn,
2961
+ up: yn
2942
2962
  }, Symbol.toStringTag, { value: "Module" }));
2943
2963
  async function vn(t) {
2944
2964
  }
2945
- async function Cn(t) {
2965
+ async function bn(t) {
2946
2966
  }
2947
- const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2967
+ const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2948
2968
  __proto__: null,
2949
- down: Cn,
2969
+ down: bn,
2950
2970
  up: vn
2951
2971
  }, Symbol.toStringTag, { value: "Module" }));
2952
2972
  async function xn(t) {
@@ -3015,27 +3035,27 @@ const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3015
3035
  down: zn,
3016
3036
  up: Jn
3017
3037
  }, Symbol.toStringTag, { value: "Module" }));
3018
- async function Un(t) {
3038
+ async function Kn(t) {
3019
3039
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3020
3040
  }
3021
- async function Kn(t) {
3041
+ async function Un(t) {
3022
3042
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3023
3043
  }
3024
3044
  const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3025
3045
  __proto__: null,
3026
- down: Kn,
3027
- up: Un
3046
+ down: Un,
3047
+ up: Kn
3028
3048
  }, Symbol.toStringTag, { value: "Module" }));
3029
3049
  async function Qn(t) {
3030
3050
  }
3031
3051
  async function Vn(t) {
3032
3052
  }
3033
- const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3053
+ const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3034
3054
  __proto__: null,
3035
3055
  down: Vn,
3036
3056
  up: Qn
3037
3057
  }, Symbol.toStringTag, { value: "Module" }));
3038
- async function qn(t) {
3058
+ async function Wn(t) {
3039
3059
  await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3040
3060
  "tenant_id",
3041
3061
  "varchar(255)",
@@ -3052,7 +3072,7 @@ async function Gn(t) {
3052
3072
  const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3053
3073
  __proto__: null,
3054
3074
  down: Gn,
3055
- up: qn
3075
+ up: Wn
3056
3076
  }, Symbol.toStringTag, { value: "Module" }));
3057
3077
  async function Xn(t) {
3058
3078
  }
@@ -3067,12 +3087,12 @@ async function eo(t) {
3067
3087
  }
3068
3088
  async function to(t) {
3069
3089
  }
3070
- const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3090
+ const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3071
3091
  __proto__: null,
3072
3092
  down: to,
3073
3093
  up: eo
3074
3094
  }, Symbol.toStringTag, { value: "Module" }));
3075
- async function ro(t) {
3095
+ async function ao(t) {
3076
3096
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3077
3097
  "tenant_id",
3078
3098
  "varchar(255)",
@@ -3101,18 +3121,18 @@ async function no(t) {
3101
3121
  const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3102
3122
  __proto__: null,
3103
3123
  down: no,
3104
- up: ro
3124
+ up: ao
3105
3125
  }, Symbol.toStringTag, { value: "Module" }));
3106
3126
  async function so(t) {
3107
3127
  }
3108
3128
  async function io(t) {
3109
3129
  }
3110
- const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3130
+ const co = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3111
3131
  __proto__: null,
3112
3132
  down: io,
3113
3133
  up: so
3114
3134
  }, Symbol.toStringTag, { value: "Module" }));
3115
- async function co(t) {
3135
+ async function lo(t) {
3116
3136
  await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3117
3137
  }
3118
3138
  async function uo(t) {
@@ -3121,7 +3141,7 @@ async function uo(t) {
3121
3141
  const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3122
3142
  __proto__: null,
3123
3143
  down: uo,
3124
- up: co
3144
+ up: lo
3125
3145
  }, Symbol.toStringTag, { value: "Module" }));
3126
3146
  async function ho(t) {
3127
3147
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
@@ -3138,30 +3158,30 @@ async function po(t) {
3138
3158
  }
3139
3159
  async function go(t) {
3140
3160
  }
3141
- const wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3161
+ const yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3142
3162
  __proto__: null,
3143
3163
  down: go,
3144
3164
  up: po
3145
3165
  }, Symbol.toStringTag, { value: "Module" }));
3146
- async function yo(t) {
3166
+ async function wo(t) {
3147
3167
  }
3148
3168
  async function No(t) {
3149
3169
  }
3150
3170
  const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3151
3171
  __proto__: null,
3152
3172
  down: No,
3153
- up: yo
3173
+ up: wo
3154
3174
  }, Symbol.toStringTag, { value: "Module" }));
3155
- async function Co(t) {
3175
+ async function bo(t) {
3156
3176
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3157
3177
  }
3158
- async function bo(t) {
3178
+ async function Co(t) {
3159
3179
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3160
3180
  }
3161
3181
  const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3162
3182
  __proto__: null,
3163
- down: bo,
3164
- up: Co
3183
+ down: Co,
3184
+ up: bo
3165
3185
  }, Symbol.toStringTag, { value: "Module" }));
3166
3186
  async function To(t) {
3167
3187
  }
@@ -3257,12 +3277,12 @@ async function zo(t) {
3257
3277
  }
3258
3278
  async function Ro(t) {
3259
3279
  }
3260
- const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3280
+ const Ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3261
3281
  __proto__: null,
3262
3282
  down: Ro,
3263
3283
  up: zo
3264
3284
  }, Symbol.toStringTag, { value: "Module" }));
3265
- async function Ko(t) {
3285
+ async function Uo(t) {
3266
3286
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
3267
3287
  "universal_login_experience",
3268
3288
  "varchar(16)",
@@ -3287,15 +3307,15 @@ async function Bo(t) {
3287
3307
  const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3288
3308
  __proto__: null,
3289
3309
  down: Bo,
3290
- up: Ko
3310
+ up: Uo
3291
3311
  }, Symbol.toStringTag, { value: "Module" }));
3292
3312
  async function Vo(t) {
3293
3313
  }
3294
- async function Wo(t) {
3314
+ async function qo(t) {
3295
3315
  }
3296
- const qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3316
+ const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3297
3317
  __proto__: null,
3298
- down: Wo,
3318
+ down: qo,
3299
3319
  up: Vo
3300
3320
  }, Symbol.toStringTag, { value: "Module" }));
3301
3321
  async function Go(t) {
@@ -3319,12 +3339,12 @@ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3319
3339
  async function ts(t) {
3320
3340
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3321
3341
  }
3322
- async function as(t) {
3342
+ async function rs(t) {
3323
3343
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3324
3344
  }
3325
- const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3345
+ const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3326
3346
  __proto__: null,
3327
- down: as,
3347
+ down: rs,
3328
3348
  up: ts
3329
3349
  }, Symbol.toStringTag, { value: "Module" }));
3330
3350
  async function ns(t) {
@@ -3340,11 +3360,11 @@ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3340
3360
  }, Symbol.toStringTag, { value: "Module" }));
3341
3361
  async function is(t) {
3342
3362
  }
3343
- async function ls(t) {
3363
+ async function cs(t) {
3344
3364
  }
3345
- const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3365
+ const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3346
3366
  __proto__: null,
3347
- down: ls,
3367
+ down: cs,
3348
3368
  up: is
3349
3369
  }, Symbol.toStringTag, { value: "Module" }));
3350
3370
  async function ds(t) {
@@ -3383,12 +3403,12 @@ async function ps(t) {
3383
3403
  async function gs(t) {
3384
3404
  await t.schema.dropTable("email_providers").execute();
3385
3405
  }
3386
- const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3406
+ const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3387
3407
  __proto__: null,
3388
3408
  down: gs,
3389
3409
  up: ps
3390
3410
  }, Symbol.toStringTag, { value: "Module" }));
3391
- async function ys(t) {
3411
+ async function ws(t) {
3392
3412
  await t.schema.dropTable("tickets").execute();
3393
3413
  }
3394
3414
  async function Ns(t) {
@@ -3405,32 +3425,30 @@ async function Ns(t) {
3405
3425
  const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3406
3426
  __proto__: null,
3407
3427
  down: Ns,
3408
- up: ys
3428
+ up: ws
3409
3429
  }, Symbol.toStringTag, { value: "Module" }));
3410
- async function Cs(t) {
3411
- }
3412
3430
  async function bs(t) {
3431
+ }
3432
+ async function Cs(t) {
3413
3433
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3414
3434
  }
3415
3435
  const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3416
3436
  __proto__: null,
3417
- down: bs,
3418
- up: Cs
3437
+ down: Cs,
3438
+ up: bs
3419
3439
  }, Symbol.toStringTag, { value: "Module" }));
3420
3440
  async function Ts(t) {
3421
- await t.schema.createTable("refresh_tokens").addColumn(
3422
- "tenant_id",
3423
- "varchar(255)",
3424
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3425
- ).addColumn("token", "varchar(255)", (e) => e.notNull()).addColumn(
3426
- "session_id",
3427
- "varchar(255)",
3428
- (e) => e.references("sessions.session_id").onDelete("cascade").notNull()
3429
- ).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").addColumn("scope", "varchar(512)", (e) => e.notNull()).addColumn("audience", "varchar(512)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn(
3430
- "created_at",
3431
- "varchar(255)",
3432
- (e) => e.notNull().defaultTo((/* @__PURE__ */ new Date()).toISOString())
3433
- ).addPrimaryKeyConstraint("refresh_tokens_pkey", ["tenant_id", "token"]).execute();
3441
+ await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3442
+ "client_id",
3443
+ "varchar(21)",
3444
+ (e) => e.references("applications.id").onDelete("cascade").notNull()
3445
+ ).addColumn("tenant_id", "varchar(255)").addColumn("session_id", "varchar(21)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3446
+ "user_id_constraint",
3447
+ ["user_id", "tenant_id"],
3448
+ "users",
3449
+ ["user_id", "tenant_id"],
3450
+ (e) => e.onDelete("cascade")
3451
+ ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
3434
3452
  }
3435
3453
  async function Ss(t) {
3436
3454
  await t.schema.dropTable("refresh_tokens").execute();
@@ -3441,48 +3459,55 @@ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3441
3459
  up: Ts
3442
3460
  }, Symbol.toStringTag, { value: "Module" }));
3443
3461
  async function ks(t) {
3444
- await t.schema.alterTable("sessions").addColumn("id", "varchar(21)").execute(), await t.schema.alterTable("sessions").addColumn("idle_expires_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("updated_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("authenticated_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("revoked_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("last_interaction_at", "varchar(35)").execute(), await t.schema.alterTable("sessions").addColumn("device", "varchar(2048)").execute(), await t.schema.alterTable("sessions").addColumn("clients", "varchar(1024)").execute(), await t.schema.alterTable("sessions").dropColumn("expires_at").execute(), await t.schema.alterTable("sessions").addColumn("expires_at", "varchar(35)").execute();
3445
3462
  }
3446
3463
  async function $s(t) {
3447
- await t.schema.alterTable("sessions").dropColumn("id").dropColumn("idle_expires_at").dropColumn("updated_at").dropColumn("revoked_at").dropColumn("authenticated_at").dropColumn("last_interaction_at").dropColumn("device").dropColumn("clients").execute();
3448
3464
  }
3449
3465
  const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3450
3466
  __proto__: null,
3451
3467
  down: $s,
3452
3468
  up: ks
3469
+ }, Symbol.toStringTag, { value: "Module" }));
3470
+ async function Ds(t) {
3471
+ }
3472
+ async function Ps(t) {
3473
+ }
3474
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3475
+ __proto__: null,
3476
+ down: Ps,
3477
+ up: Ds
3453
3478
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3454
- m1_init: La,
3455
- m2_magicLink: za,
3456
- m3_updateAt: Ka,
3457
- m4_logTable: Va,
3458
- m5_userProfile: Ga,
3459
- m6_sessions: Ya,
3460
- m7_passwords: tr,
3461
- m8_logsTableNewFields: nr,
3462
- m9_passwordTableNewField: ir,
3463
- n01_codesTable: dr,
3464
- n11_universalLoginSession: hr,
3465
- n12_userFields: pr,
3466
- n13_userEmailIndex: yr,
3467
- n14_profileDataField: Cr,
3468
- n15_userEmailIndex: Tr,
3469
- n16_userLocale: kr,
3470
- n17_signingKeys: Dr,
3471
- n18_logsFields: Mr,
3472
- n19_connectionsUserinfo: Lr,
3473
- n20_missingFields: zr,
3474
- n21_sessionDeletedAt: Kr,
3475
- n22_dropLogsFields: Vr,
3476
- n23_dropUsersFields: Gr,
3477
- n24_logsIndexes: Yr,
3479
+ m1_init: Lr,
3480
+ m2_magicLink: zr,
3481
+ m3_updateAt: Ur,
3482
+ m4_logTable: Vr,
3483
+ m5_userProfile: Gr,
3484
+ m6_sessions: Yr,
3485
+ m7_passwords: ta,
3486
+ m8_logsTableNewFields: na,
3487
+ m9_passwordTableNewField: ia,
3488
+ n01_codesTable: da,
3489
+ n11_universalLoginSession: ha,
3490
+ n12_userFields: pa,
3491
+ n13_userEmailIndex: wa,
3492
+ n14_profileDataField: ba,
3493
+ n15_userEmailIndex: Ta,
3494
+ n16_userLocale: ka,
3495
+ n17_signingKeys: Da,
3496
+ n18_logsFields: Ma,
3497
+ n19_connectionsUserinfo: La,
3498
+ n20_missingFields: za,
3499
+ n21_sessionDeletedAt: Ua,
3500
+ n22_dropLogsFields: Va,
3501
+ n23_dropUsersFields: Ga,
3502
+ n24_logsIndexes: Ya,
3478
3503
  n25_logDescMaxLength: tn,
3479
3504
  n26_logsTableExtraFields: nn,
3480
- n27_usersTableNameIndex: ln,
3505
+ n27_usersTableNameIndex: cn,
3481
3506
  n28_usersEmailConstrain: un,
3482
3507
  n29_increaseOtpStateLength: fn,
3483
3508
  n30_increaseTicketStateLength: gn,
3484
3509
  n31_branding: Nn,
3485
- n32_indexesAndNotNull: bn,
3510
+ n32_indexesAndNotNull: Cn,
3486
3511
  n33_vendorIdInUniversalLoginSession: Sn,
3487
3512
  n34_auth0ClientInUniversalLoginSession: $n,
3488
3513
  n35_increaseUniversalSessionStateLength: Pn,
@@ -3490,15 +3515,15 @@ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3490
3515
  n37_disableSignUps: En,
3491
3516
  n38_otpIpAddress: Rn,
3492
3517
  n39_increaseUserAgentLength: Bn,
3493
- n40_userId: Wn,
3518
+ n40_userId: qn,
3494
3519
  n41_hooks: Hn,
3495
3520
  n42_userIdIndexes: Zn,
3496
- n43_userIdIndexes: ao,
3521
+ n43_userIdIndexes: ro,
3497
3522
  n44_codes: oo,
3498
- n45_hookProperties: lo,
3523
+ n45_hookProperties: co,
3499
3524
  n46_loginAuth0Client: mo,
3500
3525
  n47_loginAuth0Client: _o,
3501
- n48_saml: wo,
3526
+ n48_saml: yo,
3502
3527
  n49_removeFields: vo,
3503
3528
  n50_authParamsNonce: xo,
3504
3529
  n51_connectionid: Oo,
@@ -3506,28 +3531,29 @@ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3506
3531
  n53_codes_primary_key: jo,
3507
3532
  n54_cleanup_tables: Fo,
3508
3533
  n55_logs_index: Jo,
3509
- n56_application_fields: Uo,
3534
+ n56_application_fields: Ko,
3510
3535
  n57_prompt_settings: Qo,
3511
- n58_connection_client_id: qo,
3536
+ n58_connection_client_id: Wo,
3512
3537
  n59_connection_options: Xo,
3513
3538
  n60_users_metadata: es,
3514
- n61_userLocales: rs,
3539
+ n61_userLocales: as,
3515
3540
  n62_prompt: ss,
3516
- n63_connection_cleanup: cs,
3541
+ n63_connection_cleanup: ls,
3517
3542
  n64_act_as: ms,
3518
3543
  n65_code_verifier: _s,
3519
- n66_email_providers: ws,
3544
+ n66_email_providers: ys,
3520
3545
  n67_drop_tickets: vs,
3521
3546
  n68_login_useragents: xs,
3522
3547
  n70_refresh_tokens: Os,
3523
- n71_session_new_fields: Is
3548
+ n71_session_new_fields: Is,
3549
+ n72_session_primary_key: js
3524
3550
  };
3525
- async function As(t, e = !1) {
3551
+ async function Es(t, e = !1) {
3526
3552
  e && console.log("migrating...");
3527
- const a = new Fe(Le), r = new ve({
3553
+ const r = new Fe(Le), a = new ve({
3528
3554
  db: t,
3529
- provider: a
3530
- }), { error: o, results: n } = await r.migrateToLatest();
3555
+ provider: r
3556
+ }), { error: o, results: n } = await a.migrateToLatest();
3531
3557
  if (n == null || n.forEach((s) => {
3532
3558
  s.status === "Success" ? e && console.log(
3533
3559
  `migration "${s.migrationName}" was executed successfully`
@@ -3535,41 +3561,41 @@ async function As(t, e = !1) {
3535
3561
  }), o)
3536
3562
  throw console.error("failed to migrate"), console.error(o), o;
3537
3563
  }
3538
- async function Fs(t) {
3564
+ async function Js(t) {
3539
3565
  console.log("migrating...");
3540
- const e = new Fe(Le), a = new ve({
3566
+ const e = new Fe(Le), r = new ve({
3541
3567
  db: t,
3542
3568
  provider: e
3543
- }), { error: r, results: o } = await a.migrateDown();
3569
+ }), { error: a, results: o } = await r.migrateDown();
3544
3570
  if (o == null || o.forEach((n) => {
3545
3571
  n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
3546
- }), r)
3547
- throw console.error("failed to migrate"), console.error(r), r;
3572
+ }), a)
3573
+ throw console.error("failed to migrate"), console.error(a), a;
3548
3574
  }
3549
- function Ls(t) {
3575
+ function zs(t) {
3550
3576
  return {
3551
3577
  applications: Dt(t),
3552
- branding: qt(t),
3578
+ branding: Wt(t),
3553
3579
  clients: Et(t),
3554
3580
  codes: Tt(t),
3555
3581
  connections: Lt(t),
3556
- emailProviders: wa(t),
3582
+ emailProviders: yr(t),
3557
3583
  domains: Qt(t),
3558
- hooks: ea(t),
3559
- keys: Ut(t),
3560
- logins: ua(t),
3561
- logs: ct(t),
3562
- passwords: yt(t),
3563
- promptSettings: fa(t),
3564
- refreshTokens: xa(t),
3584
+ hooks: er(t),
3585
+ keys: Kt(t),
3586
+ logins: ur(t),
3587
+ logs: lt(t),
3588
+ passwords: wt(t),
3589
+ promptSettings: fr(t),
3590
+ refreshTokens: xr(t),
3565
3591
  sessions: _t(t),
3566
3592
  tenants: nt(t),
3567
- themes: sa(t),
3593
+ themes: sr(t),
3568
3594
  users: Xe(t)
3569
3595
  };
3570
3596
  }
3571
3597
  export {
3572
- Ls as default,
3573
- Fs as migrateDown,
3574
- As as migrateToLatest
3598
+ zs as default,
3599
+ Js as migrateDown,
3600
+ Es as migrateToLatest
3575
3601
  };