@authhero/kysely-adapter 10.35.0 → 10.37.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.
@@ -3,15 +3,15 @@ var ue = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
5
  var Re = (t, e, r) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
6
- var z = (t, e, r) => Re(t, typeof e != "symbol" ? e + "" : e, r), V = (t, e, r) => e.has(t) || ue("Cannot " + r);
7
- var d = (t, e, r) => (V(t, e, "read from private field"), r ? r.call(t) : e.get(t)), N = (t, e, r) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), L = (t, e, r, a) => (V(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), m = (t, e, r) => (V(t, e, "access private method"), r);
8
- import { parseUserId as ae, codeSchema as Ke, connectionSchema as Ue, loginSessionSchema as Be, promptSettingSchema as Qe, formSchema as Q, resourceServerSchema as qe } from "@authhero/adapter-interfaces";
6
+ var R = (t, e, r) => Re(t, typeof e != "symbol" ? e + "" : e, r), Y = (t, e, r) => e.has(t) || ue("Cannot " + r);
7
+ var d = (t, e, r) => (Y(t, e, "read from private field"), r ? r.call(t) : e.get(t)), S = (t, e, r) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), K = (t, e, r, a) => (Y(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), p = (t, e, r) => (Y(t, e, "access private method"), r);
8
+ import { parseUserId as ie, codeSchema as Ke, connectionSchema as Ue, loginSessionSchema as Be, promptSettingSchema as Qe, formSchema as G, resourceServerSchema as qe } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
- var X = class extends Error {
10
+ var te = class extends Error {
11
11
  constructor(e = 500, r) {
12
12
  super(r == null ? void 0 : r.message, { cause: r == null ? void 0 : r.cause });
13
- z(this, "res");
14
- z(this, "status");
13
+ R(this, "res");
14
+ R(this, "status");
15
15
  this.res = r == null ? void 0 : r.res, this.status = e;
16
16
  }
17
17
  getResponse() {
@@ -25,8 +25,8 @@ var X = class extends Error {
25
25
  };
26
26
  function Ve(t) {
27
27
  return async (e, r) => {
28
- const { identities: a, ...o } = r, n = {
29
- ...o,
28
+ const { identities: a, ...n } = r, o = {
29
+ ...n,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
@@ -37,35 +37,35 @@ function Ve(t) {
37
37
  user_metadata: JSON.stringify(r.user_metadata)
38
38
  };
39
39
  try {
40
- await t.insertInto("users").values(n).execute();
40
+ await t.insertInto("users").values(o).execute();
41
41
  } catch (s) {
42
- throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new X(409, { message: "User already exists" }) : new X(500, { message: `${s.code}, ${s.message}` });
42
+ throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new te(409, { message: "User already exists" }) : new te(500, { message: `${s.code}, ${s.message}` });
43
43
  }
44
44
  return {
45
- ...n,
45
+ ...o,
46
46
  // TODO: check if this is correct. Should it be optional?
47
- email: n.email || "",
48
- email_verified: n.email_verified === 1,
49
- is_social: n.is_social === 1
47
+ email: o.email || "",
48
+ email_verified: o.email_verified === 1,
49
+ is_social: o.is_social === 1
50
50
  };
51
51
  };
52
52
  }
53
- function f(t) {
53
+ function y(t) {
54
54
  if (t == null || typeof t != "object")
55
55
  return t;
56
56
  if (Array.isArray(t))
57
57
  return t.map(
58
58
  (r) => (
59
59
  // Only recurse into objects; leave primitives untouched
60
- r !== null && typeof r == "object" ? f(r) : r
60
+ r !== null && typeof r == "object" ? y(r) : r
61
61
  )
62
62
  );
63
63
  const e = { ...t };
64
64
  for (const r in e) {
65
65
  const a = e[r];
66
66
  a === null ? delete e[r] : a !== null && typeof a == "object" && (Array.isArray(a) ? e[r] = a.map(
67
- (o) => o !== null && typeof o == "object" ? f(o) : o
68
- ) : e[r] = f(a));
67
+ (n) => n !== null && typeof n == "object" ? y(n) : n
68
+ ) : e[r] = y(a));
69
69
  }
70
70
  return e;
71
71
  }
@@ -79,7 +79,7 @@ function pe(t) {
79
79
  return {
80
80
  connection: t.connection,
81
81
  provider: t.provider,
82
- user_id: ae(t.user_id).id,
82
+ user_id: ie(t.user_id).id,
83
83
  isSocial: !!t.is_social,
84
84
  profileData: {
85
85
  email: t.email,
@@ -90,13 +90,13 @@ function pe(t) {
90
90
  }
91
91
  function We(t) {
92
92
  return async (e, r) => {
93
- const [a, o] = await Promise.all([
93
+ const [a, n] = await Promise.all([
94
94
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", r).selectAll().executeTakeFirst(),
95
95
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", r).selectAll().execute()
96
96
  ]);
97
97
  if (!a)
98
98
  return null;
99
- const { tenant_id: n, ...s } = a, l = {
99
+ const { tenant_id: o, ...s } = a, i = {
100
100
  ...s,
101
101
  email: a.email || "",
102
102
  email_verified: a.email_verified === 1,
@@ -107,148 +107,153 @@ function We(t) {
107
107
  {
108
108
  connection: a.connection,
109
109
  provider: a.provider,
110
- user_id: ae(a.user_id).id,
110
+ user_id: ie(a.user_id).id,
111
111
  isSocial: !!a.is_social
112
112
  },
113
- ...o.map(pe)
113
+ ...n.map(pe)
114
114
  ]
115
115
  };
116
- return f(l);
116
+ return y(i);
117
117
  };
118
118
  }
119
- function C(t, e, r, a) {
120
- return r.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
121
- let s = n.startsWith("-"), l = null, c = "", _ = !1, u;
122
- if (n.startsWith("-_exists_:"))
123
- l = n.substring(10), _ = !0, s = !0;
124
- else if (n.startsWith("_exists_:"))
125
- l = n.substring(9), _ = !0, s = !1;
126
- else if (n.includes(":")) {
127
- const h = s ? n.substring(1) : n, g = h.indexOf(":");
128
- l = h.substring(0, g), c = h.substring(g + 1), _ = !1, c.startsWith(">=") ? (u = ">=", c = c.substring(2)) : c.startsWith(">") ? (u = ">", c = c.substring(1)) : c.startsWith("<=") ? (u = "<=", c = c.substring(2)) : c.startsWith("<") ? (u = "<", c = c.substring(1)) : u = "=";
119
+ function T(t, e, r, a) {
120
+ return r.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
121
+ let s = o.startsWith("-"), i = null, c = "", _ = !1, u;
122
+ if (o.startsWith("-_exists_:"))
123
+ i = o.substring(10), _ = !0, s = !0;
124
+ else if (o.startsWith("_exists_:"))
125
+ i = o.substring(9), _ = !0, s = !1;
126
+ else if (o.includes(":")) {
127
+ const m = s ? o.substring(1) : o, h = m.indexOf(":");
128
+ i = m.substring(0, h), c = m.substring(h + 1), _ = !1, c.startsWith(">=") ? (u = ">=", c = c.substring(2)) : c.startsWith(">") ? (u = ">", c = c.substring(1)) : c.startsWith("<=") ? (u = "<=", c = c.substring(2)) : c.startsWith("<") ? (u = "<", c = c.substring(1)) : u = "=";
129
129
  } else
130
- l = null, c = n, _ = !1;
131
- return { key: l, value: c, isNegation: s, isExistsQuery: _, operator: u };
132
- }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: c, operator: _ }) => {
133
- if (n)
130
+ i = null, c = o, _ = !1;
131
+ return { key: i, value: c, isNegation: s, isExistsQuery: _, operator: u };
132
+ }).forEach(({ key: o, value: s, isNegation: i, isExistsQuery: c, operator: _ }) => {
133
+ if (o)
134
134
  if (c)
135
- l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
136
- else if (l)
135
+ i ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
136
+ else if (i)
137
137
  switch (_) {
138
138
  case ">":
139
- e = e.where(n, "<=", s);
139
+ e = e.where(o, "<=", s);
140
140
  break;
141
141
  case ">=":
142
- e = e.where(n, "<", s);
142
+ e = e.where(o, "<", s);
143
143
  break;
144
144
  case "<":
145
- e = e.where(n, ">=", s);
145
+ e = e.where(o, ">=", s);
146
146
  break;
147
147
  case "<=":
148
- e = e.where(n, ">", s);
148
+ e = e.where(o, ">", s);
149
149
  break;
150
150
  default:
151
- e = e.where(n, "!=", s);
151
+ e = e.where(o, "!=", s);
152
152
  }
153
153
  else
154
- e = e.where(n, _, s);
154
+ e = e.where(o, _, s);
155
155
  else if (s) {
156
156
  const { ref: u } = t.dynamic;
157
157
  e = e.where(
158
- (h) => h.or(
159
- a.map((g) => h(u(g), "like", `%${s}%`))
158
+ (m) => m.or(
159
+ a.map((h) => m(u(h), "like", `%${s}%`))
160
160
  )
161
161
  );
162
162
  }
163
163
  }), e;
164
164
  }
165
- function v(t) {
165
+ function x(t) {
166
166
  return typeof t == "string" ? parseInt(t, 10) : typeof t == "bigint" ? Number(t) : t;
167
167
  }
168
168
  function Ge(t) {
169
- return async (e, r = {
170
- page: 0,
171
- per_page: 50,
172
- include_totals: !1
173
- }) => {
174
- let a = t.selectFrom("users").where("users.tenant_id", "=", e);
175
- if (r.q && (a = C(t, a, r.q, ["email", "name"])), r.sort && r.sort.sort_by) {
176
- const { ref: u } = t.dynamic;
177
- a = a.orderBy(u(r.sort.sort_by), r.sort.sort_order);
169
+ return async (e, r = {}) => {
170
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
171
+ let c = t.selectFrom("users").where("users.tenant_id", "=", e);
172
+ if (i && (c = T(t, c, i, ["email", "name"])), s && s.sort_by) {
173
+ const { ref: w } = t.dynamic;
174
+ c = c.orderBy(w(s.sort_by), s.sort_order);
178
175
  }
179
- const n = await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute(), s = n.map((u) => u.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], c = n.map((u) => {
180
- const h = l.filter(
181
- (g) => g.linked_to === u.user_id
176
+ const u = await c.offset(a * n).limit(n).selectAll().execute(), m = u.map((w) => w.user_id), h = m.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", m).execute() : [], f = u.map((w) => {
177
+ const b = h.filter(
178
+ (D) => D.linked_to === w.user_id
182
179
  );
183
- return f({
184
- ...u,
185
- email_verified: u.email_verified === 1,
186
- is_social: u.is_social === 1,
187
- app_metadata: JSON.parse(u.app_metadata),
188
- user_metadata: JSON.parse(u.user_metadata),
180
+ return y({
181
+ ...w,
182
+ email_verified: w.email_verified === 1,
183
+ is_social: w.is_social === 1,
184
+ app_metadata: JSON.parse(w.app_metadata),
185
+ user_metadata: JSON.parse(w.user_metadata),
189
186
  identities: [
190
187
  {
191
- connection: u.connection,
192
- provider: u.provider,
193
- user_id: ae(u.user_id).id,
194
- isSocial: !!u.is_social
188
+ connection: w.connection,
189
+ provider: w.provider,
190
+ user_id: ie(w.user_id).id,
191
+ isSocial: !!w.is_social
195
192
  },
196
- ...h.map(pe)
193
+ ...b.map(pe)
197
194
  ]
198
195
  });
199
- }), { count: _ } = await a.select((u) => u.fn.countAll().as("count")).executeTakeFirstOrThrow();
196
+ });
197
+ if (!o)
198
+ return {
199
+ users: f,
200
+ start: 0,
201
+ limit: 0,
202
+ length: 0
203
+ };
204
+ const { count: g } = await c.select((w) => w.fn.countAll().as("count")).executeTakeFirstOrThrow();
200
205
  return {
201
- users: c,
202
- start: r.page * r.per_page,
203
- limit: r.per_page,
204
- length: v(_)
206
+ users: f,
207
+ start: a * n,
208
+ limit: n,
209
+ length: x(g)
205
210
  };
206
211
  };
207
212
  }
208
213
  function He(t) {
209
214
  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);
210
215
  }
211
- function A(t, e = "", r = {}) {
216
+ function J(t, e = "", r = {}) {
212
217
  for (let a in t)
213
218
  if (Object.prototype.hasOwnProperty.call(t, a)) {
214
- const o = e ? `${e}_${a}` : a, n = t[a];
215
- typeof n == "object" && n !== null && !Array.isArray(n) ? A(n, o, r) : typeof n == "boolean" ? r[o] = n ? 1 : 0 : r[o] = n;
219
+ const n = e ? `${e}_${a}` : a, o = t[a];
220
+ typeof o == "object" && o !== null && !Array.isArray(o) ? J(o, n, r) : typeof o == "boolean" ? r[n] = o ? 1 : 0 : r[n] = o;
216
221
  }
217
222
  return r;
218
223
  }
219
224
  function ge(t, e) {
220
225
  const r = {};
221
- for (const [a, o] of Object.entries(t)) {
222
- const n = e.find(
226
+ for (const [a, n] of Object.entries(t)) {
227
+ const o = e.find(
223
228
  (s) => a.startsWith(`${s}_`)
224
229
  );
225
- if (!n)
226
- r[a] = o;
230
+ if (!o)
231
+ r[a] = n;
227
232
  else {
228
- const s = a.slice(n.length + 1);
229
- r[n] = {
230
- ...r[n],
231
- [s]: o
233
+ const s = a.slice(o.length + 1);
234
+ r[o] = {
235
+ ...r[o],
236
+ [s]: n
232
237
  };
233
238
  }
234
239
  }
235
240
  return r;
236
241
  }
237
- function Xe(t) {
242
+ function Ye(t) {
238
243
  return async (e, r, a) => {
239
- const o = A({
244
+ const n = J({
240
245
  ...a,
241
246
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
242
247
  app_metadata: a.app_metadata ? JSON.stringify(a.app_metadata) : void 0,
243
248
  user_metadata: a.user_metadata ? JSON.stringify(a.user_metadata) : void 0
244
249
  });
245
- return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1;
250
+ return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1;
246
251
  };
247
252
  }
248
- function Ye(t) {
249
- return async (e, r, a, o) => {
250
- const n = { linked_to: null };
251
- 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;
253
+ function Xe(t) {
254
+ return async (e, r, a, n) => {
255
+ const o = { linked_to: null };
256
+ return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", `${a}|${n}`).where("users.linked_to", "=", `${r}`).execute()).length === 1;
252
257
  };
253
258
  }
254
259
  function Ze(t) {
@@ -257,13 +262,13 @@ function Ze(t) {
257
262
  remove: He(t),
258
263
  get: We(t),
259
264
  list: Ge(t),
260
- update: Xe(t),
265
+ update: Ye(t),
261
266
  // TODO - think about this more when other issues fixed
262
- unlink: Ye(t)
267
+ unlink: Xe(t)
263
268
  };
264
269
  }
265
270
  const et = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
266
- let b = (t = 21) => {
271
+ let O = (t = 21) => {
267
272
  let e = "", r = crypto.getRandomValues(new Uint8Array(t));
268
273
  for (; t--; )
269
274
  e += et[r[t] & 63];
@@ -272,7 +277,7 @@ let b = (t = 21) => {
272
277
  function tt(t) {
273
278
  return async (e) => {
274
279
  const r = {
275
- id: e.id || b(),
280
+ id: e.id || O(),
276
281
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
277
282
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
278
283
  ...e
@@ -283,32 +288,29 @@ function tt(t) {
283
288
  function rt(t) {
284
289
  return async (e) => {
285
290
  const r = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
286
- return r ? f(r) : null;
291
+ return r ? y(r) : null;
287
292
  };
288
293
  }
289
294
  function at(t) {
290
- return async (e = {
291
- page: 0,
292
- per_page: 50,
293
- include_totals: !1
294
- }) => {
295
+ return async (e) => {
295
296
  let r = t.selectFrom("tenants");
296
- if (e.sort && e.sort.sort_by) {
297
- const { ref: l } = t.dynamic;
298
- r = r.orderBy(l(e.sort.sort_by), e.sort.sort_order);
297
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = e;
298
+ if (s && s.sort_by) {
299
+ const { ref: f } = t.dynamic;
300
+ r = r.orderBy(f(s.sort_by), s.sort_order);
299
301
  }
300
- e.q && (r = r.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
301
- const o = await r.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
302
- if (!e.include_totals)
302
+ i && (r = r.where((f) => f.or([f("name", "like", `%${i}%`)])));
303
+ const u = (await r.offset(a * n).limit(n).selectAll().execute()).map(y);
304
+ if (!o)
303
305
  return {
304
- tenants: o
306
+ tenants: u
305
307
  };
306
- const { count: n } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = v(n);
308
+ const { count: m } = await r.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow(), h = x(m);
307
309
  return {
308
- tenants: o.map(f),
309
- start: (e.page - 1) * e.per_page,
310
- limit: e.per_page,
311
- length: s
310
+ tenants: u,
311
+ start: a * n,
312
+ limit: n,
313
+ length: h
312
314
  };
313
315
  };
314
316
  }
@@ -340,19 +342,19 @@ function me(t) {
340
342
  const it = 1024;
341
343
  function lt(t) {
342
344
  return async (e, r) => {
343
- var o, n, s;
345
+ var n, o, s;
344
346
  const a = {
345
- id: b(),
347
+ id: O(),
346
348
  ...r,
347
349
  user_agent: r.user_agent.slice(0, it)
348
350
  };
349
351
  return await t.insertInto("logs").values({
350
352
  ...a,
351
353
  // Truncate long strings to avoid database errors
352
- description: (o = a.description) == null ? void 0 : o.substring(0, 256),
354
+ description: (n = a.description) == null ? void 0 : n.substring(0, 256),
353
355
  isMobile: r.isMobile ? 1 : 0,
354
356
  tenant_id: e,
355
- scope: (n = r.scope) == null ? void 0 : n.join(","),
357
+ scope: (o = r.scope) == null ? void 0 : o.join(","),
356
358
  auth0_client: me(r.auth0_client),
357
359
  details: (s = me(r.details)) == null ? void 0 : s.substring(0, 8192)
358
360
  }).execute(), a;
@@ -381,28 +383,30 @@ function we(t) {
381
383
  };
382
384
  }
383
385
  function ct(t) {
384
- return async (e, r = {
385
- page: 0,
386
- per_page: 50,
387
- include_totals: !1
388
- }) => {
389
- let a = t.selectFrom("logs").where("logs.tenant_id", "=", e);
390
- r.q && (a = C(t, a, r.q, ["user_id", "ip"]));
391
- let o = a;
392
- if (r.sort && r.sort.sort_by) {
393
- const { ref: l } = t.dynamic;
394
- o = o.orderBy(
395
- l(r.sort.sort_by),
396
- r.sort.sort_order
397
- );
386
+ return async (e, r = {}) => {
387
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
388
+ let c = t.selectFrom("logs").where("logs.tenant_id", "=", e);
389
+ i && (c = T(t, c, i, ["user_id", "ip"]));
390
+ let _ = c;
391
+ if (s && s.sort_by) {
392
+ const { ref: f } = t.dynamic;
393
+ _ = _.orderBy(f(s.sort_by), s.sort_order);
398
394
  }
399
- o = o.offset(r.page * r.per_page).limit(r.per_page);
400
- const n = await o.selectAll().execute(), { count: s } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
395
+ _ = _.offset(a * n).limit(n);
396
+ const m = (await _.selectAll().execute()).map(we);
397
+ if (!o)
398
+ return {
399
+ logs: m,
400
+ start: 0,
401
+ limit: 0,
402
+ length: 0
403
+ };
404
+ const { count: h } = await c.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
401
405
  return {
402
- logs: n.map(we),
403
- start: r.page * r.per_page,
404
- limit: r.per_page,
405
- length: v(s)
406
+ logs: m,
407
+ start: a * n,
408
+ limit: n,
409
+ length: x(h)
406
410
  };
407
411
  };
408
412
  }
@@ -424,10 +428,10 @@ function mt(t) {
424
428
  const a = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", r).selectAll().executeTakeFirst();
425
429
  if (!a)
426
430
  return null;
427
- const { tenant_id: o, device: n, clients: s, ...l } = a;
431
+ const { tenant_id: n, device: o, clients: s, ...i } = a;
428
432
  return {
429
- ...l,
430
- device: JSON.parse(n),
433
+ ...i,
434
+ device: JSON.parse(o),
431
435
  clients: JSON.parse(s)
432
436
  };
433
437
  };
@@ -454,42 +458,44 @@ function ht(t) {
454
458
  }
455
459
  function ft(t) {
456
460
  return async (e, r, a) => {
457
- const o = {
461
+ const n = {
458
462
  ...a,
459
463
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
460
464
  device: a.device ? JSON.stringify(a.device) : void 0,
461
465
  clients: a.clients ? JSON.stringify(a.clients) : void 0
462
466
  };
463
- return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
467
+ return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
464
468
  };
465
469
  }
466
470
  function pt(t) {
467
- return async (e, r = {
468
- page: 0,
469
- per_page: 50,
470
- include_totals: !1
471
- }) => {
472
- let a = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
473
- r.q && (a = C(t, a, r.q, ["user_id", "session_id"]));
474
- let o = a;
475
- if (r.sort && r.sort.sort_by) {
476
- const { ref: c } = t.dynamic;
477
- o = o.orderBy(
478
- c(r.sort.sort_by),
479
- r.sort.sort_order
480
- );
471
+ return async (e, r = {}) => {
472
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
473
+ let c = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
474
+ i && (c = T(t, c, i, ["user_id", "session_id"]));
475
+ let _ = c;
476
+ if (s && s.sort_by) {
477
+ const { ref: g } = t.dynamic;
478
+ _ = _.orderBy(g(s.sort_by), s.sort_order);
481
479
  }
482
- o = o.offset(r.page * r.per_page).limit(r.per_page);
483
- const n = await o.selectAll().execute(), { count: s } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = v(s);
480
+ _ = _.offset(a * n).limit(n);
481
+ const m = (await _.selectAll().execute()).map((g) => ({
482
+ ...g,
483
+ device: JSON.parse(g.device),
484
+ clients: JSON.parse(g.clients)
485
+ }));
486
+ if (!o)
487
+ return {
488
+ sessions: m,
489
+ start: 0,
490
+ limit: 0,
491
+ length: 0
492
+ };
493
+ const { count: h } = await c.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = x(h);
484
494
  return {
485
- sessions: n.map((c) => ({
486
- ...c,
487
- device: JSON.parse(c.device),
488
- clients: JSON.parse(c.clients)
489
- })),
490
- start: r.page * r.per_page,
491
- limit: r.per_page,
492
- length: l
495
+ sessions: m,
496
+ start: a * n,
497
+ limit: n,
498
+ length: f
493
499
  };
494
500
  };
495
501
  }
@@ -507,8 +513,8 @@ function wt(t) {
507
513
  const a = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", r).selectAll().executeTakeFirst();
508
514
  if (!a)
509
515
  return null;
510
- const { tenant_id: o, ...n } = a;
511
- return n;
516
+ const { tenant_id: n, ...o } = a;
517
+ return o;
512
518
  };
513
519
  }
514
520
  function yt(t) {
@@ -538,22 +544,27 @@ function Nt(t) {
538
544
  };
539
545
  }
540
546
  function Ct(t) {
541
- return async (e, r = {
542
- page: 0,
543
- per_page: 50,
544
- include_totals: !1
545
- }) => {
546
- let a = t.selectFrom("codes").where("codes.tenant_id", "=", e);
547
- r.q && (a = C(t, a, r.q, ["code", "login_id"]));
548
- 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();
547
+ return async (e, r = {}) => {
548
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
549
+ let i = t.selectFrom("codes").where("codes.tenant_id", "=", e);
550
+ s && (i = T(t, i, s, ["code", "login_id"]));
551
+ const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
552
+ const { tenant_id: f, ...g } = h;
553
+ return Ke.parse(y(g));
554
+ });
555
+ if (!o)
556
+ return {
557
+ codes: u,
558
+ start: 0,
559
+ limit: 0,
560
+ length: 0
561
+ };
562
+ const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
549
563
  return {
550
- codes: n.map((c) => {
551
- const { tenant_id: _, ...u } = c;
552
- return Ke.parse(f(u));
553
- }),
554
- start: r.page * r.per_page,
555
- limit: r.per_page,
556
- length: v(s)
564
+ codes: u,
565
+ start: a * n,
566
+ limit: n,
567
+ length: x(m)
557
568
  };
558
569
  };
559
570
  }
@@ -574,10 +585,10 @@ function xt(t) {
574
585
  }
575
586
  function Tt(t) {
576
587
  return async (e, r, a) => {
577
- let o = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
578
- e.length && (o = o.where("codes.tenant_id", "=", e));
579
- const n = await o.selectAll().executeTakeFirst();
580
- return n ? f(n) : null;
588
+ let n = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
589
+ e.length && (n = n.where("codes.tenant_id", "=", e));
590
+ const o = await n.selectAll().executeTakeFirst();
591
+ return o ? y(o) : null;
581
592
  };
582
593
  }
583
594
  function St(t) {
@@ -599,38 +610,38 @@ function kt(t) {
599
610
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
600
611
  ...r,
601
612
  disable_sign_ups: r.disable_sign_ups ?? !1
602
- }, o = JSON.stringify(r.allowed_origins), n = JSON.stringify(r.callbacks), s = JSON.stringify(r.web_origins), l = JSON.stringify(r.allowed_logout_urls), c = JSON.stringify(r.allowed_clients);
613
+ }, n = JSON.stringify(r.allowed_origins), o = JSON.stringify(r.callbacks), s = JSON.stringify(r.web_origins), i = JSON.stringify(r.allowed_logout_urls), c = JSON.stringify(r.allowed_clients);
603
614
  return await t.insertInto("applications").values({
604
615
  ...a,
605
616
  tenant_id: e,
606
617
  disable_sign_ups: r.disable_sign_ups ? 1 : 0,
607
618
  addons: r.addons ? JSON.stringify(r.addons) : "{}",
608
- callbacks: n,
609
- allowed_origins: o,
619
+ callbacks: o,
620
+ allowed_origins: n,
610
621
  web_origins: s,
611
- allowed_logout_urls: l,
622
+ allowed_logout_urls: i,
612
623
  allowed_clients: c
613
624
  }).execute(), a;
614
625
  };
615
626
  }
616
627
  function $t(t) {
617
628
  return async (e) => ({
618
- applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((n) => ({
619
- ...n,
620
- disable_sign_ups: !!n.disable_sign_ups,
621
- addons: n.addons ? JSON.parse(n.addons) : {},
622
- callbacks: n.callbacks ? JSON.parse(n.callbacks) : [],
623
- allowed_origins: n.allowed_origins ? JSON.parse(n.allowed_origins) : [],
624
- web_origins: n.web_origins ? JSON.parse(n.web_origins) : [],
625
- allowed_logout_urls: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : [],
626
- allowed_clients: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : []
629
+ applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((o) => ({
630
+ ...o,
631
+ disable_sign_ups: !!o.disable_sign_ups,
632
+ addons: o.addons ? JSON.parse(o.addons) : {},
633
+ callbacks: o.callbacks ? JSON.parse(o.callbacks) : [],
634
+ allowed_origins: o.allowed_origins ? JSON.parse(o.allowed_origins) : [],
635
+ web_origins: o.web_origins ? JSON.parse(o.web_origins) : [],
636
+ allowed_logout_urls: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : [],
637
+ allowed_clients: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : []
627
638
  }))
628
639
  });
629
640
  }
630
641
  function It(t) {
631
642
  return async (e, r) => {
632
643
  const a = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).selectAll().executeTakeFirst();
633
- return a ? f({
644
+ return a ? y({
634
645
  ...a,
635
646
  disable_sign_ups: !!a.disable_sign_ups,
636
647
  addons: JSON.parse(a.addons),
@@ -646,7 +657,7 @@ function Dt(t) {
646
657
  }
647
658
  function Pt(t) {
648
659
  return async (e, r, a) => {
649
- const o = {
660
+ const n = {
650
661
  ...a,
651
662
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
652
663
  allowed_origins: a.allowed_origins ? JSON.stringify(a.allowed_origins) : void 0,
@@ -657,7 +668,7 @@ function Pt(t) {
657
668
  addons: a.addons ? JSON.stringify(a.addons) : "{}",
658
669
  disable_sign_ups: a.disable_sign_ups ? 1 : 0
659
670
  };
660
- return await t.updateTable("applications").set(o).where("applications.id", "=", r).where("applications.tenant_id", "=", e).execute(), !0;
671
+ return await t.updateTable("applications").set(n).where("applications.id", "=", r).where("applications.tenant_id", "=", e).execute(), !0;
661
672
  };
662
673
  }
663
674
  function jt(t) {
@@ -672,7 +683,7 @@ function jt(t) {
672
683
  function Ft(t) {
673
684
  return async (e, r) => {
674
685
  const a = {
675
- id: b(),
686
+ id: O(),
676
687
  ...r,
677
688
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
678
689
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -686,24 +697,29 @@ function Ft(t) {
686
697
  };
687
698
  }
688
699
  function Mt(t) {
689
- return async (e, r = {
690
- page: 0,
691
- per_page: 50,
692
- include_totals: !1
693
- }) => {
694
- let a = t.selectFrom("connections").where("connections.tenant_id", "=", e);
695
- r.q && (a = C(t, a, r.q, ["user_id", "ip"]));
696
- const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map(
697
- (c) => f({
698
- ...c,
699
- options: JSON.parse(c.options)
700
+ return async (e, r = {}) => {
701
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
702
+ let i = t.selectFrom("connections").where("connections.tenant_id", "=", e);
703
+ s && (i = T(t, i, s, ["user_id", "ip"]));
704
+ const u = (await i.offset(a * n).limit(n).selectAll().execute()).map(
705
+ (h) => y({
706
+ ...h,
707
+ options: JSON.parse(h.options)
700
708
  })
701
- ), { count: l } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
709
+ );
710
+ if (!o)
711
+ return {
712
+ connections: u,
713
+ start: 0,
714
+ limit: 0,
715
+ length: 0
716
+ };
717
+ const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
702
718
  return {
703
- connections: s,
704
- start: r.page * r.per_page,
705
- limit: r.per_page,
706
- length: v(l)
719
+ connections: u,
720
+ start: a * n,
721
+ limit: n,
722
+ length: x(m)
707
723
  };
708
724
  };
709
725
  }
@@ -713,7 +729,7 @@ function At(t) {
713
729
  function zt(t) {
714
730
  return async (e, r) => {
715
731
  const a = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).selectAll().executeTakeFirst();
716
- return a ? f({
732
+ return a ? y({
717
733
  ...a,
718
734
  options: JSON.parse(a.options)
719
735
  }) : null;
@@ -721,13 +737,13 @@ function zt(t) {
721
737
  }
722
738
  function Lt(t) {
723
739
  return async (e, r, a) => {
724
- const o = {
740
+ const n = {
725
741
  ...a,
726
742
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
727
743
  };
728
744
  return await t.updateTable("connections").set({
729
- ...o,
730
- options: o.options ? JSON.stringify(o.options) : void 0
745
+ ...n,
746
+ options: n.options ? JSON.stringify(n.options) : void 0
731
747
  }).where("connections.id", "=", r).where("connections.tenant_id", "=", e).execute(), !0;
732
748
  };
733
749
  }
@@ -748,13 +764,13 @@ function Jt(t) {
748
764
  return null;
749
765
  const a = await t.selectFrom("tenants").selectAll().where("id", "=", r.tenant_id).executeTakeFirst();
750
766
  if (!a)
751
- throw new X(404, { message: "Tenant not found" });
752
- const o = await t.selectFrom("connections").where("tenant_id", "=", r.tenant_id).selectAll().execute();
767
+ throw new te(404, { message: "Tenant not found" });
768
+ const n = await t.selectFrom("connections").where("tenant_id", "=", r.tenant_id).selectAll().execute();
753
769
  return {
754
770
  ...r,
755
- connections: o.map(
771
+ connections: n.map(
756
772
  (s) => Ue.parse(
757
- f({
773
+ y({
758
774
  ...s,
759
775
  options: s.options ? JSON.parse(s.options) : {}
760
776
  })
@@ -766,7 +782,7 @@ function Jt(t) {
766
782
  web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
767
783
  allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
768
784
  allowed_clients: r.allowed_clients ? JSON.parse(r.allowed_clients) : [],
769
- tenant: f(a),
785
+ tenant: y(a),
770
786
  // this is really an integer in the database
771
787
  disable_sign_ups: !!r.disable_sign_ups
772
788
  };
@@ -774,12 +790,46 @@ function Jt(t) {
774
790
  };
775
791
  }
776
792
  function Rt(t) {
777
- return async () => await t.selectFrom("keys").where(
778
- (r) => r.or([
779
- r("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
780
- r("revoked_at", "is", null)
781
- ])
782
- ).selectAll().execute();
793
+ return async (e = {}) => {
794
+ const {
795
+ page: r = 0,
796
+ per_page: a = 100,
797
+ include_totals: n = !1,
798
+ sort: o,
799
+ q: s
800
+ } = e;
801
+ let i = t.selectFrom("keys").where(
802
+ (f) => f.or([
803
+ f("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
804
+ f("revoked_at", "is", null)
805
+ ])
806
+ );
807
+ s && (i = T(t, i, s, [
808
+ "kid",
809
+ "connection",
810
+ "fingerprint",
811
+ "thumbprint",
812
+ "type"
813
+ ]));
814
+ let c = i.select((f) => f.fn.count("kid").as("count"));
815
+ const _ = r * a;
816
+ i = i.limit(a).offset(_), o && (i = i.orderBy(o.sort_by, o.sort_order));
817
+ const u = await i.selectAll().execute();
818
+ if (!n)
819
+ return {
820
+ signingKeys: u,
821
+ start: 0,
822
+ limit: 0,
823
+ length: 0
824
+ };
825
+ const m = await c.executeTakeFirst(), h = x((m == null ? void 0 : m.count) ?? 0);
826
+ return {
827
+ signingKeys: u,
828
+ start: _,
829
+ limit: a,
830
+ length: h
831
+ };
832
+ };
783
833
  }
784
834
  function Kt(t) {
785
835
  return async (e) => {
@@ -799,7 +849,7 @@ function Bt(t) {
799
849
  function Qt(t) {
800
850
  return async (e, r) => {
801
851
  const a = {
802
- custom_domain_id: b(),
852
+ custom_domain_id: O(),
803
853
  status: "pending",
804
854
  primary: !1,
805
855
  ...r
@@ -833,12 +883,12 @@ function Wt(t) {
833
883
  }
834
884
  function Gt(t) {
835
885
  return async (e, r, a) => {
836
- const o = {
886
+ const n = {
837
887
  ...a,
838
888
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
839
889
  primary: a.primary ? 1 : 0
840
890
  };
841
- return (await t.updateTable("custom_domains").set(o).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", r).execute()).length > 0;
891
+ return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", r).execute()).length > 0;
842
892
  };
843
893
  }
844
894
  function Ht(t) {
@@ -850,7 +900,7 @@ function Ht(t) {
850
900
  } : null;
851
901
  };
852
902
  }
853
- function Xt(t) {
903
+ function Yt(t) {
854
904
  return {
855
905
  create: Qt(t),
856
906
  get: Wt(t),
@@ -860,29 +910,29 @@ function Xt(t) {
860
910
  update: Gt(t)
861
911
  };
862
912
  }
863
- function Yt(t) {
913
+ function Xt(t) {
864
914
  return async (e) => {
865
915
  const [r] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
866
916
  if (!r)
867
917
  return null;
868
918
  const {
869
919
  tenant_id: a,
870
- colors_primary: o,
871
- colors_page_background_type: n,
920
+ colors_primary: n,
921
+ colors_page_background_type: o,
872
922
  colors_page_background_start: s,
873
- colors_page_background_end: l,
923
+ colors_page_background_end: i,
874
924
  colors_page_background_angle_dev: c,
875
925
  font_url: _,
876
926
  ...u
877
927
  } = r;
878
- return f({
928
+ return y({
879
929
  ...u,
880
930
  colors: {
881
- primary: o,
931
+ primary: n,
882
932
  page_background: {
883
- type: n,
933
+ type: o,
884
934
  start: s,
885
- end: l,
935
+ end: i,
886
936
  angle_deg: c
887
937
  }
888
938
  },
@@ -892,26 +942,26 @@ function Yt(t) {
892
942
  }
893
943
  function Zt(t) {
894
944
  return async (e, r) => {
895
- var s, l, c, _, u, h, g, I, D, O, U, ne, oe, se, ie, le, ce, de;
896
- const { colors: a, font: o, ...n } = r;
945
+ var s, i, c, _, u, m, h, f, g, w, b, D, M, P, V, le, ce, de;
946
+ const { colors: a, font: n, ...o } = r;
897
947
  try {
898
948
  await t.insertInto("branding").values({
899
- ...n,
949
+ ...o,
900
950
  colors_primary: a == null ? void 0 : a.primary,
901
- colors_page_background_type: (l = (s = r.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
951
+ colors_page_background_type: (i = (s = r.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
902
952
  colors_page_background_start: (_ = (c = r.colors) == null ? void 0 : c.page_background) == null ? void 0 : _.start,
903
- colors_page_background_end: (h = (u = r.colors) == null ? void 0 : u.page_background) == null ? void 0 : h.end,
904
- colors_page_background_angle_dev: (I = (g = r.colors) == null ? void 0 : g.page_background) == null ? void 0 : I.angle_deg,
905
- font_url: (D = r.font) == null ? void 0 : D.url,
953
+ colors_page_background_end: (m = (u = r.colors) == null ? void 0 : u.page_background) == null ? void 0 : m.end,
954
+ colors_page_background_angle_dev: (f = (h = r.colors) == null ? void 0 : h.page_background) == null ? void 0 : f.angle_deg,
955
+ font_url: (g = r.font) == null ? void 0 : g.url,
906
956
  tenant_id: e
907
957
  }).execute();
908
958
  } catch {
909
959
  await t.updateTable("branding").set({
910
- ...n,
960
+ ...o,
911
961
  colors_primary: a == null ? void 0 : a.primary,
912
- colors_page_background_type: (U = (O = r.colors) == null ? void 0 : O.page_background) == null ? void 0 : U.type,
913
- colors_page_background_start: (oe = (ne = r.colors) == null ? void 0 : ne.page_background) == null ? void 0 : oe.start,
914
- colors_page_background_end: (ie = (se = r.colors) == null ? void 0 : se.page_background) == null ? void 0 : ie.end,
962
+ colors_page_background_type: (b = (w = r.colors) == null ? void 0 : w.page_background) == null ? void 0 : b.type,
963
+ colors_page_background_start: (M = (D = r.colors) == null ? void 0 : D.page_background) == null ? void 0 : M.start,
964
+ colors_page_background_end: (V = (P = r.colors) == null ? void 0 : P.page_background) == null ? void 0 : V.end,
915
965
  colors_page_background_angle_dev: (ce = (le = r.colors) == null ? void 0 : le.page_background) == null ? void 0 : ce.angle_deg,
916
966
  font_url: (de = r.font) == null ? void 0 : de.url
917
967
  }).where("tenant_id", "=", e).execute();
@@ -920,38 +970,43 @@ function Zt(t) {
920
970
  }
921
971
  function er(t) {
922
972
  return {
923
- get: Yt(t),
973
+ get: Xt(t),
924
974
  set: Zt(t)
925
975
  };
926
976
  }
927
977
  function tr(t) {
928
- return async (e, r = {
929
- page: 0,
930
- per_page: 50,
931
- include_totals: !1
932
- }) => {
933
- let a = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
934
- r.q && (a = C(t, a, r.q, ["url", "form_id"]));
935
- 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();
978
+ return async (e, r = {}) => {
979
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
980
+ let i = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
981
+ s && (i = T(t, i, s, ["url", "form_id"]));
982
+ const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
983
+ const { tenant_id: f, enabled: g, synchronous: w, ...b } = h;
984
+ return y({
985
+ ...b,
986
+ enabled: !!g,
987
+ synchronous: !!w
988
+ });
989
+ });
990
+ if (!o)
991
+ return {
992
+ hooks: u,
993
+ start: 0,
994
+ limit: 0,
995
+ length: 0
996
+ };
997
+ const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
936
998
  return {
937
- hooks: n.map((c) => {
938
- const { tenant_id: _, enabled: u, synchronous: h, ...g } = c;
939
- return f({
940
- ...g,
941
- enabled: !!u,
942
- synchronous: !!h
943
- });
944
- }),
945
- start: r.page * r.per_page,
946
- limit: r.per_page,
947
- length: v(s)
999
+ hooks: u,
1000
+ start: a * n,
1001
+ limit: n,
1002
+ length: x(m)
948
1003
  };
949
1004
  };
950
1005
  }
951
1006
  function rr(t) {
952
1007
  return async (e, r) => {
953
1008
  const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).selectAll().executeTakeFirst();
954
- return a ? f({
1009
+ return a ? y({
955
1010
  ...a,
956
1011
  enabled: !!a.enabled,
957
1012
  synchronous: !!a.synchronous
@@ -964,7 +1019,7 @@ function ar(t) {
964
1019
  function nr(t) {
965
1020
  return async (e, r) => {
966
1021
  const a = {
967
- hook_id: b(),
1022
+ hook_id: O(),
968
1023
  ...r,
969
1024
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
970
1025
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -979,13 +1034,13 @@ function nr(t) {
979
1034
  }
980
1035
  function or(t) {
981
1036
  return async (e, r, a) => {
982
- const o = {
1037
+ const n = {
983
1038
  ...a,
984
1039
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
985
1040
  enabled: a.enabled !== void 0 ? a.enabled ? 1 : 0 : void 0,
986
1041
  synchronous: a.enabled !== void 0 ? a.synchronous ? 1 : 0 : void 0
987
1042
  };
988
- return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", r).where("hooks.tenant_id", "=", e).execute(), !0;
1043
+ return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", r).where("hooks.tenant_id", "=", e).execute(), !0;
989
1044
  };
990
1045
  }
991
1046
  function sr(t) {
@@ -1000,15 +1055,15 @@ function sr(t) {
1000
1055
  function ir(t) {
1001
1056
  return async (e, r) => {
1002
1057
  const a = {
1003
- themeId: b(),
1058
+ themeId: O(),
1004
1059
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1005
1060
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1006
1061
  ...r
1007
- }, o = {
1062
+ }, n = {
1008
1063
  ...a,
1009
1064
  tenant_id: e
1010
1065
  };
1011
- return await t.insertInto("themes").values(A(o)).execute(), a;
1066
+ return await t.insertInto("themes").values(J(n)).execute(), a;
1012
1067
  };
1013
1068
  }
1014
1069
  function lr(t) {
@@ -1019,7 +1074,7 @@ function cr(t) {
1019
1074
  const a = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.themeId", "=", r).selectAll().executeTakeFirst();
1020
1075
  if (!a)
1021
1076
  return null;
1022
- const o = {
1077
+ const n = {
1023
1078
  ...a,
1024
1079
  borders_show_widget_shadow: !!a.borders_show_widget_shadow,
1025
1080
  fonts_body_text_bold: !!a.fonts_body_text_bold,
@@ -1029,8 +1084,8 @@ function cr(t) {
1029
1084
  fonts_subtitle_bold: !!a.fonts_subtitle_bold,
1030
1085
  fonts_title_bold: !!a.fonts_title_bold
1031
1086
  };
1032
- return f(
1033
- ge(o, [
1087
+ return y(
1088
+ ge(n, [
1034
1089
  "widget",
1035
1090
  "colors",
1036
1091
  "borders",
@@ -1042,11 +1097,11 @@ function cr(t) {
1042
1097
  }
1043
1098
  function dr(t) {
1044
1099
  return async (e, r, a) => {
1045
- const o = A({
1100
+ const n = J({
1046
1101
  ...a,
1047
1102
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1048
1103
  });
1049
- return await t.updateTable("themes").set(o).where("themes.themeId", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
1104
+ return await t.updateTable("themes").set(n).where("themes.themeId", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
1050
1105
  };
1051
1106
  }
1052
1107
  function ur(t) {
@@ -1062,7 +1117,7 @@ function mr(t) {
1062
1117
  const a = await t.selectFrom("login_sessions").where("login_sessions.id", "=", r).selectAll().executeTakeFirst();
1063
1118
  return a ? Be.parse(
1064
1119
  ge(
1065
- f({
1120
+ y({
1066
1121
  ...a,
1067
1122
  login_completed: !!a.login_completed
1068
1123
  }),
@@ -1073,24 +1128,24 @@ function mr(t) {
1073
1128
  }
1074
1129
  function _r(t) {
1075
1130
  return async (e, r) => {
1076
- var o;
1131
+ var n;
1077
1132
  const a = {
1078
- id: b(),
1133
+ id: O(),
1079
1134
  ...r,
1080
- authorization_url: (o = r.authorization_url) == null ? void 0 : o.slice(0, 1024),
1135
+ authorization_url: (n = r.authorization_url) == null ? void 0 : n.slice(0, 1024),
1081
1136
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1082
1137
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1083
1138
  login_completed: !!r.login_completed
1084
1139
  };
1085
1140
  return await t.insertInto("login_sessions").values({
1086
- ...A(a),
1141
+ ...J(a),
1087
1142
  tenant_id: e
1088
1143
  }).execute(), a;
1089
1144
  };
1090
1145
  }
1091
1146
  function hr(t) {
1092
1147
  return async (e, r, a) => (await t.updateTable("login_sessions").set(
1093
- A({
1148
+ J({
1094
1149
  ...a
1095
1150
  })
1096
1151
  ).where("login_sessions.id", "=", r).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
@@ -1109,7 +1164,7 @@ function pr(t) {
1109
1164
  function gr(t) {
1110
1165
  return async (e) => {
1111
1166
  const [r] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1112
- return f({
1167
+ return y({
1113
1168
  identifier_first: !!(r != null && r.identifier_first),
1114
1169
  password_first: !!(r != null && r.password_first),
1115
1170
  webauthn_platform_first_factor: !!(r != null && r.webauthn_platform_first_factor),
@@ -1118,7 +1173,7 @@ function gr(t) {
1118
1173
  };
1119
1174
  }
1120
1175
  function he(t) {
1121
- return f({
1176
+ return y({
1122
1177
  ...t,
1123
1178
  webauthn_platform_first_factor: t.webauthn_platform_first_factor ? !!t.webauthn_platform_first_factor : void 0,
1124
1179
  identifier_first: t.identifier_first ? !!t.identifier_first : void 0,
@@ -1152,38 +1207,38 @@ function vr(t) {
1152
1207
  return null;
1153
1208
  const {
1154
1209
  tenant_id: a,
1155
- credentials: o,
1156
- settings: n,
1210
+ credentials: n,
1211
+ settings: o,
1157
1212
  enabled: s,
1158
- ...l
1213
+ ...i
1159
1214
  } = r;
1160
- return f({
1161
- ...l,
1162
- credentials: JSON.parse(o),
1163
- settings: JSON.parse(n),
1215
+ return y({
1216
+ ...i,
1217
+ credentials: JSON.parse(n),
1218
+ settings: JSON.parse(o),
1164
1219
  enabled: !!s
1165
1220
  });
1166
1221
  };
1167
1222
  }
1168
1223
  function Nr(t) {
1169
1224
  return async (e, r) => {
1170
- const { credentials: a, settings: o, enabled: n, ...s } = r;
1225
+ const { credentials: a, settings: n, enabled: o, ...s } = r;
1171
1226
  await t.updateTable("email_providers").set({
1172
1227
  ...s,
1173
1228
  credentials: a ? JSON.stringify(a) : void 0,
1174
- settings: o ? JSON.stringify(o) : void 0,
1175
- enabled: n !== void 0 ? n ? 1 : 0 : void 0
1229
+ settings: n ? JSON.stringify(n) : void 0,
1230
+ enabled: o !== void 0 ? o ? 1 : 0 : void 0
1176
1231
  }).where("tenant_id", "=", e).execute();
1177
1232
  };
1178
1233
  }
1179
1234
  function Cr(t) {
1180
1235
  return async (e, r) => {
1181
- const { credentials: a, settings: o, enabled: n, ...s } = r;
1236
+ const { credentials: a, settings: n, enabled: o, ...s } = r;
1182
1237
  await t.insertInto("email_providers").values({
1183
1238
  ...s,
1184
- enabled: n ? 1 : 0,
1239
+ enabled: o ? 1 : 0,
1185
1240
  credentials: JSON.stringify(a),
1186
- settings: JSON.stringify(o),
1241
+ settings: JSON.stringify(n),
1187
1242
  tenant_id: e,
1188
1243
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1189
1244
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1228,43 +1283,45 @@ function Sr(t) {
1228
1283
  }
1229
1284
  function Or(t) {
1230
1285
  return async (e, r, a) => {
1231
- const o = {
1286
+ const n = {
1232
1287
  ...a,
1233
1288
  device: a.device ? JSON.stringify(a.device) : void 0,
1234
1289
  resource_servers: a.resource_servers ? JSON.stringify(a.resource_servers) : void 0,
1235
1290
  rotating: a.rotating ? 1 : 0
1236
1291
  };
1237
- return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1292
+ return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1238
1293
  };
1239
1294
  }
1240
1295
  function kr(t) {
1241
- return async (e, r = {
1242
- page: 0,
1243
- per_page: 50,
1244
- include_totals: !1
1245
- }) => {
1246
- let a = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1247
- r.q && (a = C(t, a, r.q, ["token", "session_id"]));
1248
- let o = a;
1249
- if (r.sort && r.sort.sort_by) {
1250
- const { ref: c } = t.dynamic;
1251
- o = o.orderBy(
1252
- c(r.sort.sort_by),
1253
- r.sort.sort_order
1254
- );
1296
+ return async (e, r = {}) => {
1297
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
1298
+ let c = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1299
+ i && (c = T(t, c, i, ["token", "session_id"]));
1300
+ let _ = c;
1301
+ if (s && s.sort_by) {
1302
+ const { ref: g } = t.dynamic;
1303
+ _ = _.orderBy(g(s.sort_by), s.sort_order);
1255
1304
  }
1256
- o = o.offset(r.page * r.per_page).limit(r.per_page);
1257
- const n = await o.selectAll().execute(), { count: s } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = v(s);
1305
+ _ = _.offset(a * n).limit(n);
1306
+ const m = (await _.selectAll().execute()).map((g) => ({
1307
+ ...g,
1308
+ rotating: !!g.rotating,
1309
+ device: g.device ? JSON.parse(g.device) : {},
1310
+ resource_servers: g.resource_servers ? JSON.parse(g.resource_servers) : []
1311
+ }));
1312
+ if (!o)
1313
+ return {
1314
+ refresh_tokens: m,
1315
+ start: 0,
1316
+ limit: 0,
1317
+ length: 0
1318
+ };
1319
+ const { count: h } = await c.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = x(h);
1258
1320
  return {
1259
- refresh_tokens: n.map((c) => ({
1260
- ...c,
1261
- rotating: !!c.rotating,
1262
- device: c.device ? JSON.parse(c.device) : {},
1263
- resource_servers: c.resource_servers ? JSON.parse(c.resource_servers) : []
1264
- })),
1265
- start: r.page * r.per_page,
1266
- limit: r.per_page,
1267
- length: l
1321
+ refresh_tokens: m,
1322
+ start: a * n,
1323
+ limit: n,
1324
+ length: f
1268
1325
  };
1269
1326
  };
1270
1327
  }
@@ -1285,32 +1342,32 @@ function Ir(t) {
1285
1342
  Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
1286
1343
  ).toISOString();
1287
1344
  console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", r).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", a).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where(
1288
- (n) => n.or([
1289
- n("expires_at", "<", r),
1290
- n("idle_expires_at", "<", r)
1345
+ (o) => o.or([
1346
+ o("expires_at", "<", r),
1347
+ o("idle_expires_at", "<", r)
1291
1348
  ])
1292
1349
  ).limit(1e4).execute(), console.log("delete sessions");
1293
- const o = await t.selectFrom("sessions").select("id").where(
1294
- (n) => n.or([
1295
- n("expires_at", "<", r),
1296
- n("idle_expires_at", "<", r)
1350
+ const n = await t.selectFrom("sessions").select("id").where(
1351
+ (o) => o.or([
1352
+ o("expires_at", "<", r),
1353
+ o("idle_expires_at", "<", r)
1297
1354
  ])
1298
1355
  ).where(
1299
1356
  "id",
1300
1357
  "not in",
1301
1358
  t.selectFrom("refresh_tokens").select("session_id")
1302
1359
  ).limit(1e5).execute();
1303
- o.length > 0 && await t.deleteFrom("sessions").where(
1360
+ n.length > 0 && await t.deleteFrom("sessions").where(
1304
1361
  "id",
1305
1362
  "in",
1306
- o.map((n) => n.id)
1363
+ n.map((o) => o.id)
1307
1364
  ).execute(), console.log("cleanup complete");
1308
1365
  };
1309
1366
  }
1310
1367
  function Dr(t) {
1311
1368
  return async (e, r) => {
1312
- const a = Q.parse({
1313
- id: b(),
1369
+ const a = G.parse({
1370
+ id: O(),
1314
1371
  ...r,
1315
1372
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1316
1373
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1322,41 +1379,46 @@ function Dr(t) {
1322
1379
  start: JSON.stringify(a.start || {}),
1323
1380
  ending: JSON.stringify(a.ending || {}),
1324
1381
  tenant_id: e
1325
- }).execute(), Q.parse(a);
1382
+ }).execute(), G.parse(a);
1326
1383
  };
1327
1384
  }
1328
1385
  function Pr(t) {
1329
- return async (e, r = {
1330
- page: 0,
1331
- per_page: 50,
1332
- include_totals: !1
1333
- }) => {
1334
- let a = t.selectFrom("forms").where("tenant_id", "=", e);
1335
- r != null && r.q && (a = C(t, a, r.q, []));
1336
- const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map((c) => {
1337
- const _ = { ...c };
1338
- if (typeof _.nodes == "string")
1386
+ return async (e, r = {}) => {
1387
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
1388
+ let i = t.selectFrom("forms").where("tenant_id", "=", e);
1389
+ s && (i = T(t, i, s, []));
1390
+ const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
1391
+ const f = { ...h };
1392
+ if (typeof f.nodes == "string")
1339
1393
  try {
1340
- _.nodes = JSON.parse(_.nodes);
1394
+ f.nodes = JSON.parse(f.nodes);
1341
1395
  } catch {
1342
1396
  }
1343
- if (typeof _.start == "string")
1397
+ if (typeof f.start == "string")
1344
1398
  try {
1345
- _.start = JSON.parse(_.start);
1399
+ f.start = JSON.parse(f.start);
1346
1400
  } catch {
1347
1401
  }
1348
- if (typeof _.ending == "string")
1402
+ if (typeof f.ending == "string")
1349
1403
  try {
1350
- _.ending = JSON.parse(_.ending);
1404
+ f.ending = JSON.parse(f.ending);
1351
1405
  } catch {
1352
1406
  }
1353
- return Q.parse(f(_));
1354
- }), { count: l } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
1407
+ return G.parse(y(f));
1408
+ });
1409
+ if (!o)
1410
+ return {
1411
+ forms: u,
1412
+ start: 0,
1413
+ limit: 0,
1414
+ length: 0
1415
+ };
1416
+ const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1355
1417
  return {
1356
- forms: s,
1357
- start: r.page * r.per_page,
1358
- limit: r.per_page,
1359
- length: v(l)
1418
+ forms: u,
1419
+ start: a * n,
1420
+ limit: n,
1421
+ length: x(m)
1360
1422
  };
1361
1423
  };
1362
1424
  }
@@ -1370,34 +1432,34 @@ function Fr(t) {
1370
1432
  return async (e, r) => {
1371
1433
  const a = await t.selectFrom("forms").selectAll().where("forms.id", "=", r).where("tenant_id", "=", e).executeTakeFirst();
1372
1434
  if (!a) return null;
1373
- const o = { ...a };
1374
- if (typeof o.nodes == "string")
1435
+ const n = { ...a };
1436
+ if (typeof n.nodes == "string")
1375
1437
  try {
1376
- o.nodes = JSON.parse(o.nodes);
1438
+ n.nodes = JSON.parse(n.nodes);
1377
1439
  } catch {
1378
1440
  }
1379
- if (typeof o.start == "string")
1441
+ if (typeof n.start == "string")
1380
1442
  try {
1381
- o.start = JSON.parse(o.start);
1443
+ n.start = JSON.parse(n.start);
1382
1444
  } catch {
1383
1445
  }
1384
- if (typeof o.ending == "string")
1446
+ if (typeof n.ending == "string")
1385
1447
  try {
1386
- o.ending = JSON.parse(o.ending);
1448
+ n.ending = JSON.parse(n.ending);
1387
1449
  } catch {
1388
1450
  }
1389
- return Q.parse(f(o));
1451
+ return G.parse(y(n));
1390
1452
  };
1391
1453
  }
1392
1454
  function Mr(t) {
1393
1455
  return async (e, r, a) => {
1394
- const o = {
1456
+ const n = {
1395
1457
  ...a,
1396
1458
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1397
1459
  };
1398
- a.nodes && (o.nodes = JSON.stringify(a.nodes)), a.start && (o.start = JSON.stringify(a.start)), a.ending && (o.ending = JSON.stringify(a.ending));
1399
- const { numUpdatedRows: n } = await t.updateTable("forms").set(o).where("id", "=", r).where("tenant_id", "=", e).executeTakeFirst();
1400
- return n > 0;
1460
+ a.nodes && (n.nodes = JSON.stringify(a.nodes)), a.start && (n.start = JSON.stringify(a.start)), a.ending && (n.ending = JSON.stringify(a.ending));
1461
+ const { numUpdatedRows: o } = await t.updateTable("forms").set(n).where("id", "=", r).where("tenant_id", "=", e).executeTakeFirst();
1462
+ return o > 0;
1401
1463
  };
1402
1464
  }
1403
1465
  function Ar(t) {
@@ -1411,22 +1473,22 @@ function Ar(t) {
1411
1473
  }
1412
1474
  function zr(t) {
1413
1475
  return async (e, r) => {
1414
- const a = (/* @__PURE__ */ new Date()).toISOString(), o = {
1415
- id: b(),
1476
+ const a = (/* @__PURE__ */ new Date()).toISOString(), n = {
1477
+ id: O(),
1416
1478
  ...r,
1417
1479
  created_at: a,
1418
1480
  updated_at: a
1419
- }, n = qe.parse(o), {
1481
+ }, o = qe.parse(n), {
1420
1482
  verificationKey: s,
1421
- scopes: l,
1483
+ scopes: i,
1422
1484
  options: c,
1423
1485
  skip_consent_for_verifiable_first_party_clients: _,
1424
1486
  allow_offline_access: u,
1425
- ...h
1426
- } = n, g = {
1427
- ...h,
1487
+ ...m
1488
+ } = o, h = {
1489
+ ...m,
1428
1490
  tenant_id: e,
1429
- scopes: l ? JSON.stringify(l) : "[]",
1491
+ scopes: i ? JSON.stringify(i) : "[]",
1430
1492
  options: c ? JSON.stringify(c) : "{}",
1431
1493
  skip_consent_for_verifiable_first_party_clients: _ ? 1 : 0,
1432
1494
  allow_offline_access: u ? 1 : 0,
@@ -1434,70 +1496,79 @@ function zr(t) {
1434
1496
  created_at: a,
1435
1497
  updated_at: a
1436
1498
  };
1437
- return await t.insertInto("resource_servers").values(g).execute(), f(n);
1499
+ return await t.insertInto("resource_servers").values(h).execute(), y(o);
1438
1500
  };
1439
1501
  }
1440
1502
  function Lr(t) {
1441
1503
  return async (e, r) => {
1442
1504
  const a = await t.selectFrom("resource_servers").selectAll().where("tenant_id", "=", e).where("id", "=", r).executeTakeFirst();
1443
1505
  if (!a) return null;
1444
- const o = a, {
1445
- verification_key: n,
1506
+ const n = a, {
1507
+ verification_key: o,
1446
1508
  scopes: s,
1447
- options: l,
1509
+ options: i,
1448
1510
  skip_consent_for_verifiable_first_party_clients: c,
1449
1511
  allow_offline_access: _,
1450
1512
  ...u
1451
- } = o, h = {
1513
+ } = n, m = {
1452
1514
  ...u,
1453
1515
  scopes: s ? JSON.parse(s) : [],
1454
- options: l ? JSON.parse(l) : {},
1516
+ options: i ? JSON.parse(i) : {},
1455
1517
  skip_consent_for_verifiable_first_party_clients: !!c,
1456
1518
  allow_offline_access: !!_,
1457
1519
  // Convert verification_key back to verificationKey for API
1458
- verificationKey: n
1520
+ verificationKey: o
1459
1521
  };
1460
- return f(h);
1522
+ return y(m);
1461
1523
  };
1462
1524
  }
1463
1525
  function Er(t) {
1464
- return async (e, r = { page: 0, per_page: 50, include_totals: !1 }) => {
1465
- let a = t.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", e);
1466
- if (r.q) {
1467
- const c = r.q.trim(), _ = c.split(/\s+/), u = _.length === 1 ? _[0] : void 0, h = u ? u.match(/^(-)?(name|identifier):(.*)$/) : null, g = h ? h[3] : "", I = /^(>=|>|<=|<)/.test(g || "");
1468
- if (h && !I) {
1469
- const D = !!h[1], O = h[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
1470
- a = D ? a.where(O, "not like", `%${g}%`) : a.where(O, "like", `%${g}%`);
1526
+ return async (e, r = {}) => {
1527
+ const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
1528
+ let i = t.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", e);
1529
+ if (s) {
1530
+ const h = s.trim(), f = h.split(/\s+/), g = f.length === 1 ? f[0] : void 0, w = g ? g.match(/^(-)?(name|identifier):(.*)$/) : null, b = w ? w[3] : "", D = /^(>=|>|<=|<)/.test(b || "");
1531
+ if (w && !D) {
1532
+ const M = !!w[1], P = w[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
1533
+ i = M ? i.where(P, "not like", `%${b}%`) : i.where(P, "like", `%${b}%`);
1471
1534
  } else
1472
- a = C(t, a, c, [
1535
+ i = T(t, i, h, [
1473
1536
  "resource_servers.name",
1474
1537
  "resource_servers.identifier"
1475
1538
  ]);
1476
1539
  }
1477
- const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map((c) => {
1478
- const _ = c, {
1479
- verification_key: u,
1480
- scopes: h,
1481
- options: g,
1482
- skip_consent_for_verifiable_first_party_clients: I,
1483
- allow_offline_access: D,
1484
- ...O
1485
- } = _, U = {
1486
- ...O,
1487
- scopes: h ? JSON.parse(h) : [],
1488
- options: g ? JSON.parse(g) : {},
1489
- skip_consent_for_verifiable_first_party_clients: !!I,
1490
- allow_offline_access: !!D,
1540
+ const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
1541
+ const f = h, {
1542
+ verification_key: g,
1543
+ scopes: w,
1544
+ options: b,
1545
+ skip_consent_for_verifiable_first_party_clients: D,
1546
+ allow_offline_access: M,
1547
+ ...P
1548
+ } = f, V = {
1549
+ ...P,
1550
+ scopes: w ? JSON.parse(w) : [],
1551
+ options: b ? JSON.parse(b) : {},
1552
+ skip_consent_for_verifiable_first_party_clients: !!D,
1553
+ allow_offline_access: !!M,
1491
1554
  // Convert verification_key back to verificationKey for API
1492
- verificationKey: u
1555
+ verificationKey: g
1556
+ };
1557
+ return y(V);
1558
+ });
1559
+ if (!o)
1560
+ return {
1561
+ resource_servers: u,
1562
+ start: 0,
1563
+ limit: 0,
1564
+ length: 0
1493
1565
  };
1494
- return f(U);
1495
- }), { count: l } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
1566
+ const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1496
1567
  return {
1497
- resource_servers: s,
1498
- start: r.page * r.per_page,
1499
- limit: r.per_page,
1500
- length: v(l)
1568
+ resource_servers: u,
1569
+ start: a * n,
1570
+ limit: n,
1571
+ length: x(m)
1501
1572
  };
1502
1573
  };
1503
1574
  }
@@ -1510,19 +1581,19 @@ function Jr(t) {
1510
1581
  function Rr(t) {
1511
1582
  return async (e, r, a) => {
1512
1583
  const {
1513
- verificationKey: o,
1514
- scopes: n,
1584
+ verificationKey: n,
1585
+ scopes: o,
1515
1586
  options: s,
1516
- skip_consent_for_verifiable_first_party_clients: l,
1587
+ skip_consent_for_verifiable_first_party_clients: i,
1517
1588
  allow_offline_access: c,
1518
1589
  ..._
1519
1590
  } = a, u = {
1520
1591
  ..._,
1521
1592
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1522
1593
  };
1523
- o !== void 0 && (u.verification_key = o), n !== void 0 && (u.scopes = JSON.stringify(n)), s !== void 0 && (u.options = JSON.stringify(s)), l !== void 0 && (u.skip_consent_for_verifiable_first_party_clients = l ? 1 : 0), c !== void 0 && (u.allow_offline_access = c ? 1 : 0);
1524
- const h = await t.updateTable("resource_servers").set(u).where("tenant_id", "=", e).where("id", "=", r).executeTakeFirst();
1525
- return Number(h.numUpdatedRows) > 0;
1594
+ n !== void 0 && (u.verification_key = n), o !== void 0 && (u.scopes = JSON.stringify(o)), s !== void 0 && (u.options = JSON.stringify(s)), i !== void 0 && (u.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), c !== void 0 && (u.allow_offline_access = c ? 1 : 0);
1595
+ const m = await t.updateTable("resource_servers").set(u).where("tenant_id", "=", e).where("id", "=", r).executeTakeFirst();
1596
+ return Number(m.numUpdatedRows) > 0;
1526
1597
  };
1527
1598
  }
1528
1599
  function Kr(t) {
@@ -1536,15 +1607,15 @@ function Kr(t) {
1536
1607
  }
1537
1608
  function Ur(t) {
1538
1609
  return async (e, r) => {
1539
- const a = (/* @__PURE__ */ new Date()).toISOString(), o = b(), n = {
1540
- id: o,
1610
+ const a = (/* @__PURE__ */ new Date()).toISOString(), n = O(), o = {
1611
+ id: n,
1541
1612
  ...r,
1542
1613
  tenant_id: e,
1543
1614
  created_at: a,
1544
1615
  updated_at: a
1545
1616
  };
1546
- return await t.insertInto("roles").values(n).execute(), {
1547
- id: o,
1617
+ return await t.insertInto("roles").values(o).execute(), {
1618
+ id: n,
1548
1619
  ...r,
1549
1620
  created_at: a,
1550
1621
  updated_at: a
@@ -1560,25 +1631,34 @@ function Br(t) {
1560
1631
  };
1561
1632
  }
1562
1633
  function Qr(t) {
1563
- return async (e, r = { page: 0, per_page: 50, include_totals: !1 }) => {
1634
+ return async (e, r) => {
1564
1635
  let a = t.selectFrom("roles").where("roles.tenant_id", "=", e);
1565
- r.q && (a = C(t, a, r.q, ["name"]));
1566
- 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();
1636
+ const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = r;
1637
+ r.q && (a = T(t, a, r.q, ["name"]));
1638
+ const c = await a.offset(n * o).limit(o).selectAll().execute();
1639
+ if (!s)
1640
+ return {
1641
+ roles: c,
1642
+ start: n * o,
1643
+ limit: o,
1644
+ length: c.length
1645
+ };
1646
+ const { count: _ } = await a.select((u) => u.fn.countAll().as("count")).executeTakeFirstOrThrow();
1567
1647
  return {
1568
- roles: n,
1569
- start: r.page * r.per_page,
1570
- limit: r.per_page,
1571
- length: v(s)
1648
+ roles: c,
1649
+ start: n * o,
1650
+ limit: o,
1651
+ length: x(_)
1572
1652
  };
1573
1653
  };
1574
1654
  }
1575
1655
  function qr(t) {
1576
1656
  return async (e, r, a) => {
1577
- const o = {
1657
+ const n = {
1578
1658
  ...a,
1579
1659
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1580
- }, n = await t.updateTable("roles").set(o).where("roles.tenant_id", "=", e).where("roles.id", "=", r).executeTakeFirst();
1581
- return Number(n.numUpdatedRows) > 0;
1660
+ }, o = await t.updateTable("roles").set(n).where("roles.tenant_id", "=", e).where("roles.id", "=", r).executeTakeFirst();
1661
+ return Number(o.numUpdatedRows) > 0;
1582
1662
  };
1583
1663
  }
1584
1664
  function Vr(t) {
@@ -1599,31 +1679,31 @@ function Wr(t) {
1599
1679
  function Gr(t) {
1600
1680
  return async (e, r, a) => {
1601
1681
  if (a.length === 0) return !0;
1602
- const o = (/* @__PURE__ */ new Date()).toISOString();
1682
+ const n = (/* @__PURE__ */ new Date()).toISOString();
1603
1683
  try {
1604
- for (const n of a) {
1605
- if (n.role_id !== r)
1684
+ for (const o of a) {
1685
+ if (o.role_id !== r)
1606
1686
  throw new Error(
1607
- `Permission role_id ${n.role_id} does not match expected role_id ${r}`
1687
+ `Permission role_id ${o.role_id} does not match expected role_id ${r}`
1608
1688
  );
1609
1689
  const s = {
1610
1690
  tenant_id: e,
1611
- role_id: n.role_id,
1612
- resource_server_identifier: n.resource_server_identifier,
1613
- permission_name: n.permission_name,
1614
- created_at: o
1691
+ role_id: o.role_id,
1692
+ resource_server_identifier: o.resource_server_identifier,
1693
+ permission_name: o.permission_name,
1694
+ created_at: n
1615
1695
  };
1616
1696
  try {
1617
1697
  await t.insertInto("role_permissions").values(s).execute();
1618
- } catch (l) {
1619
- if (l.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || l.code === "SQLITE_CONSTRAINT_UNIQUE")
1698
+ } catch (i) {
1699
+ if (i.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || i.code === "SQLITE_CONSTRAINT_UNIQUE")
1620
1700
  continue;
1621
- throw l;
1701
+ throw i;
1622
1702
  }
1623
1703
  }
1624
1704
  return !0;
1625
- } catch (n) {
1626
- return console.error("Error assigning role permissions:", n), !1;
1705
+ } catch (o) {
1706
+ return console.error("Error assigning role permissions:", o), !1;
1627
1707
  }
1628
1708
  };
1629
1709
  }
@@ -1633,78 +1713,83 @@ function Hr(t) {
1633
1713
  try {
1634
1714
  return (await Promise.all(
1635
1715
  a.map(
1636
- (n) => t.deleteFrom("role_permissions").where("tenant_id", "=", e).where("role_id", "=", r).where(
1716
+ (o) => t.deleteFrom("role_permissions").where("tenant_id", "=", e).where("role_id", "=", r).where(
1637
1717
  "resource_server_identifier",
1638
1718
  "=",
1639
- n.resource_server_identifier
1640
- ).where("permission_name", "=", n.permission_name).executeTakeFirst()
1719
+ o.resource_server_identifier
1720
+ ).where("permission_name", "=", o.permission_name).executeTakeFirst()
1641
1721
  )
1642
- )).some((n) => Number(n.numDeletedRows) > 0);
1643
- } catch (o) {
1644
- return console.error("Error removing role permissions:", o), !1;
1722
+ )).some((o) => Number(o.numDeletedRows) > 0);
1723
+ } catch (n) {
1724
+ return console.error("Error removing role permissions:", n), !1;
1645
1725
  }
1646
1726
  };
1647
1727
  }
1648
- function Xr(t) {
1649
- return async (e, r, a = { page: 0, per_page: 50, include_totals: !1 }) => (await t.selectFrom("role_permissions").leftJoin(
1650
- "resource_servers",
1651
- (s) => s.onRef(
1652
- "role_permissions.tenant_id",
1653
- "=",
1654
- "resource_servers.tenant_id"
1655
- ).onRef(
1728
+ function Yr(t) {
1729
+ return async (e, r, a = {}) => {
1730
+ const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = a;
1731
+ let i = t.selectFrom("role_permissions").leftJoin(
1732
+ "resource_servers",
1733
+ (m) => m.onRef(
1734
+ "role_permissions.tenant_id",
1735
+ "=",
1736
+ "resource_servers.tenant_id"
1737
+ ).onRef(
1738
+ "role_permissions.resource_server_identifier",
1739
+ "=",
1740
+ "resource_servers.id"
1741
+ )
1742
+ ).select([
1743
+ "role_permissions.role_id",
1656
1744
  "role_permissions.resource_server_identifier",
1657
- "=",
1658
- "resource_servers.id"
1659
- )
1660
- ).select([
1661
- "role_permissions.role_id",
1662
- "role_permissions.resource_server_identifier",
1663
- "role_permissions.permission_name",
1664
- "role_permissions.created_at",
1665
- "resource_servers.name as resource_server_name"
1666
- ]).where("role_permissions.tenant_id", "=", e).where("role_permissions.role_id", "=", r).offset(a.page * a.per_page).limit(a.per_page).execute()).map((s) => ({
1667
- role_id: s.role_id,
1668
- resource_server_identifier: s.resource_server_identifier,
1669
- resource_server_name: s.resource_server_name || s.resource_server_identifier,
1670
- // Fallback to identifier if name is null
1671
- permission_name: s.permission_name,
1672
- description: null,
1673
- // No description available from role_permissions directly
1674
- created_at: s.created_at
1675
- }));
1745
+ "role_permissions.permission_name",
1746
+ "role_permissions.created_at",
1747
+ "resource_servers.name as resource_server_name"
1748
+ ]).where("role_permissions.tenant_id", "=", e).where("role_permissions.role_id", "=", r);
1749
+ const u = (await i.offset(n * o).limit(o).execute()).map((m) => ({
1750
+ role_id: m.role_id,
1751
+ resource_server_identifier: m.resource_server_identifier,
1752
+ resource_server_name: m.resource_server_name || m.resource_server_identifier,
1753
+ // Fallback to identifier if name is null
1754
+ permission_name: m.permission_name,
1755
+ description: null,
1756
+ // No description available from role_permissions directly
1757
+ created_at: m.created_at
1758
+ }));
1759
+ return s && await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow(), u;
1760
+ };
1676
1761
  }
1677
- function Yr(t) {
1762
+ function Xr(t) {
1678
1763
  return {
1679
1764
  assign: Gr(t),
1680
1765
  remove: Hr(t),
1681
- list: Xr(t)
1766
+ list: Yr(t)
1682
1767
  };
1683
1768
  }
1684
1769
  function Zr(t) {
1685
1770
  return async (e, r, a) => {
1686
1771
  if (a.length === 0) return !0;
1687
- const o = (/* @__PURE__ */ new Date()).toISOString();
1772
+ const n = (/* @__PURE__ */ new Date()).toISOString();
1688
1773
  try {
1689
- for (const n of a) {
1774
+ for (const o of a) {
1690
1775
  const s = {
1691
1776
  tenant_id: e,
1692
1777
  user_id: r,
1693
- resource_server_identifier: n.resource_server_identifier,
1694
- permission_name: n.permission_name,
1695
- created_at: o
1778
+ resource_server_identifier: o.resource_server_identifier,
1779
+ permission_name: o.permission_name,
1780
+ created_at: n
1696
1781
  };
1697
1782
  try {
1698
1783
  await t.insertInto("user_permissions").values(s).execute();
1699
- } catch (l) {
1700
- if (l.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || l.code === "SQLITE_CONSTRAINT_UNIQUE")
1784
+ } catch (i) {
1785
+ if (i.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || i.code === "SQLITE_CONSTRAINT_UNIQUE")
1701
1786
  continue;
1702
- throw l;
1787
+ throw i;
1703
1788
  }
1704
1789
  }
1705
1790
  return !0;
1706
- } catch (n) {
1707
- return console.error("Error assigning user permissions:", n), !1;
1791
+ } catch (o) {
1792
+ return console.error("Error assigning user permissions:", o), !1;
1708
1793
  }
1709
1794
  };
1710
1795
  }
@@ -1712,22 +1797,22 @@ function ea(t) {
1712
1797
  return async (e, r, a) => {
1713
1798
  if (a.length === 0) return !0;
1714
1799
  try {
1715
- for (const o of a)
1800
+ for (const n of a)
1716
1801
  await t.deleteFrom("user_permissions").where("tenant_id", "=", e).where("user_id", "=", r).where(
1717
1802
  "resource_server_identifier",
1718
1803
  "=",
1719
- o.resource_server_identifier
1720
- ).where("permission_name", "=", o.permission_name).execute();
1804
+ n.resource_server_identifier
1805
+ ).where("permission_name", "=", n.permission_name).execute();
1721
1806
  return !0;
1722
- } catch (o) {
1723
- return console.error("Error removing user permissions:", o), !1;
1807
+ } catch (n) {
1808
+ return console.error("Error removing user permissions:", n), !1;
1724
1809
  }
1725
1810
  };
1726
1811
  }
1727
1812
  function ta(t) {
1728
1813
  return async (e, r, a) => (await t.selectFrom("user_permissions").leftJoin(
1729
1814
  "resource_servers",
1730
- (n) => n.onRef(
1815
+ (o) => o.onRef(
1731
1816
  "user_permissions.tenant_id",
1732
1817
  "=",
1733
1818
  "resource_servers.tenant_id"
@@ -1742,15 +1827,15 @@ function ta(t) {
1742
1827
  "resource_servers.name as resource_server_name",
1743
1828
  "user_permissions.user_id",
1744
1829
  "user_permissions.created_at"
1745
- ]).where("user_permissions.tenant_id", "=", e).where("user_permissions.user_id", "=", r).execute()).map((n) => ({
1746
- resource_server_identifier: n.resource_server_identifier,
1747
- permission_name: n.permission_name,
1830
+ ]).where("user_permissions.tenant_id", "=", e).where("user_permissions.user_id", "=", r).execute()).map((o) => ({
1831
+ resource_server_identifier: o.resource_server_identifier,
1832
+ permission_name: o.permission_name,
1748
1833
  description: null,
1749
1834
  // No description available from user_permissions directly
1750
- resource_server_name: n.resource_server_name || n.resource_server_identifier,
1835
+ resource_server_name: o.resource_server_name || o.resource_server_identifier,
1751
1836
  // Fallback to identifier if name is null
1752
- user_id: n.user_id,
1753
- created_at: n.created_at
1837
+ user_id: o.user_id,
1838
+ created_at: o.created_at
1754
1839
  }));
1755
1840
  }
1756
1841
  function ra(t) {
@@ -1761,71 +1846,118 @@ function ra(t) {
1761
1846
  };
1762
1847
  }
1763
1848
  function aa(t) {
1849
+ return async (e, r) => await t.selectFrom("user_roles as ur").innerJoin(
1850
+ "roles as r",
1851
+ (n) => n.onRef("ur.role_id", "=", "r.id").onRef("ur.tenant_id", "=", "r.tenant_id")
1852
+ ).select([
1853
+ "r.id",
1854
+ "r.name",
1855
+ "r.description",
1856
+ "r.created_at",
1857
+ "r.updated_at"
1858
+ ]).where("ur.tenant_id", "=", e).where("ur.user_id", "=", r).execute();
1859
+ }
1860
+ function na(t) {
1861
+ return async (e, r, a) => {
1862
+ if (a.length === 0) return !0;
1863
+ const n = (/* @__PURE__ */ new Date()).toISOString();
1864
+ try {
1865
+ for (const o of a)
1866
+ try {
1867
+ await t.insertInto("user_roles").values({ tenant_id: e, user_id: r, role_id: o, created_at: n }).execute();
1868
+ } catch (s) {
1869
+ if (s.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || s.code === "SQLITE_CONSTRAINT_UNIQUE")
1870
+ continue;
1871
+ throw s;
1872
+ }
1873
+ return !0;
1874
+ } catch (o) {
1875
+ return console.error("Error assigning user roles:", o), !1;
1876
+ }
1877
+ };
1878
+ }
1879
+ function oa(t) {
1880
+ return async (e, r, a) => {
1881
+ try {
1882
+ return a.length && await t.deleteFrom("user_roles").where("tenant_id", "=", e).where("user_id", "=", r).where((n) => n("role_id", "in", a)).execute(), !0;
1883
+ } catch (n) {
1884
+ return console.error("Error removing user roles:", n), !1;
1885
+ }
1886
+ };
1887
+ }
1888
+ function sa(t) {
1889
+ return {
1890
+ list: aa(t),
1891
+ assign: na(t),
1892
+ remove: oa(t)
1893
+ };
1894
+ }
1895
+ function ia(t) {
1764
1896
  return t[t.length - 1];
1765
1897
  }
1766
- function y(t) {
1898
+ function C(t) {
1767
1899
  return Object.freeze(t);
1768
1900
  }
1769
- const B = y({
1901
+ const W = C({
1770
1902
  is(t) {
1771
1903
  return t.kind === "IdentifierNode";
1772
1904
  },
1773
1905
  create(t) {
1774
- return y({
1906
+ return C({
1775
1907
  kind: "IdentifierNode",
1776
1908
  name: t
1777
1909
  });
1778
1910
  }
1779
- }), Y = y({
1911
+ }), re = C({
1780
1912
  is(t) {
1781
1913
  return t.kind === "SchemableIdentifierNode";
1782
1914
  },
1783
1915
  create(t) {
1784
- return y({
1916
+ return C({
1785
1917
  kind: "SchemableIdentifierNode",
1786
- identifier: B.create(t)
1918
+ identifier: W.create(t)
1787
1919
  });
1788
1920
  },
1789
1921
  createWithSchema(t, e) {
1790
- return y({
1922
+ return C({
1791
1923
  kind: "SchemableIdentifierNode",
1792
- schema: B.create(t),
1793
- identifier: B.create(e)
1924
+ schema: W.create(t),
1925
+ identifier: W.create(e)
1794
1926
  });
1795
1927
  }
1796
- }), na = y({
1928
+ }), la = C({
1797
1929
  is(t) {
1798
1930
  return t.kind === "AliasNode";
1799
1931
  },
1800
1932
  create(t, e) {
1801
- return y({
1933
+ return C({
1802
1934
  kind: "AliasNode",
1803
1935
  node: t,
1804
1936
  alias: e
1805
1937
  });
1806
1938
  }
1807
- }), W = y({
1939
+ }), X = C({
1808
1940
  is(t) {
1809
1941
  return t.kind === "TableNode";
1810
1942
  },
1811
1943
  create(t) {
1812
- return y({
1944
+ return C({
1813
1945
  kind: "TableNode",
1814
- table: Y.create(t)
1946
+ table: re.create(t)
1815
1947
  });
1816
1948
  },
1817
1949
  createWithSchema(t, e) {
1818
- return y({
1950
+ return C({
1819
1951
  kind: "TableNode",
1820
- table: Y.createWithSchema(t, e)
1952
+ table: re.createWithSchema(t, e)
1821
1953
  });
1822
1954
  }
1823
1955
  });
1824
- var q;
1825
- class oa {
1956
+ var H;
1957
+ class ca {
1826
1958
  constructor() {
1827
- z(this, "nodeStack", []);
1828
- N(this, q, y({
1959
+ R(this, "nodeStack", []);
1960
+ S(this, H, C({
1829
1961
  AliasNode: this.transformAlias.bind(this),
1830
1962
  ColumnNode: this.transformColumn.bind(this),
1831
1963
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -1926,13 +2058,13 @@ class oa {
1926
2058
  return e;
1927
2059
  this.nodeStack.push(e);
1928
2060
  const r = this.transformNodeImpl(e);
1929
- return this.nodeStack.pop(), y(r);
2061
+ return this.nodeStack.pop(), C(r);
1930
2062
  }
1931
2063
  transformNodeImpl(e) {
1932
- return d(this, q)[e.kind](e);
2064
+ return d(this, H)[e.kind](e);
1933
2065
  }
1934
2066
  transformNodeList(e) {
1935
- return e && y(e.map((r) => this.transformNode(r)));
2067
+ return e && C(e.map((r) => this.transformNode(r)));
1936
2068
  }
1937
2069
  transformSelectQuery(e) {
1938
2070
  return {
@@ -2031,7 +2163,7 @@ class oa {
2031
2163
  transformRaw(e) {
2032
2164
  return {
2033
2165
  kind: "RawNode",
2034
- sqlFragments: y([...e.sqlFragments]),
2166
+ sqlFragments: C([...e.sqlFragments]),
2035
2167
  parameters: this.transformNodeList(e.parameters)
2036
2168
  };
2037
2169
  }
@@ -2655,8 +2787,8 @@ class oa {
2655
2787
  return e;
2656
2788
  }
2657
2789
  }
2658
- q = new WeakMap();
2659
- const sa = y({
2790
+ H = new WeakMap();
2791
+ const da = C({
2660
2792
  AlterTableNode: !0,
2661
2793
  CreateIndexNode: !0,
2662
2794
  CreateSchemaNode: !0,
@@ -2675,88 +2807,88 @@ const sa = y({
2675
2807
  UpdateQueryNode: !0,
2676
2808
  MergeQueryNode: !0
2677
2809
  });
2678
- var M, k, $, w, ye, ve, Ne, P, Z, Ce;
2679
- class ia extends oa {
2810
+ var E, j, F, N, ye, ve, Ne, A, ae, Ce;
2811
+ class ua extends ca {
2680
2812
  constructor(r) {
2681
2813
  super();
2682
- N(this, w);
2683
- N(this, M);
2684
- N(this, k, /* @__PURE__ */ new Set());
2685
- N(this, $, /* @__PURE__ */ new Set());
2686
- L(this, M, r);
2814
+ S(this, N);
2815
+ S(this, E);
2816
+ S(this, j, /* @__PURE__ */ new Set());
2817
+ S(this, F, /* @__PURE__ */ new Set());
2818
+ K(this, E, r);
2687
2819
  }
2688
2820
  transformNodeImpl(r) {
2689
- if (!m(this, w, ye).call(this, r))
2821
+ if (!p(this, N, ye).call(this, r))
2690
2822
  return super.transformNodeImpl(r);
2691
- const a = m(this, w, Ne).call(this, r);
2823
+ const a = p(this, N, Ne).call(this, r);
2692
2824
  for (const s of a)
2693
- d(this, $).add(s);
2694
- const o = m(this, w, ve).call(this, r);
2695
- for (const s of o)
2696
- d(this, k).add(s);
2697
- const n = super.transformNodeImpl(r);
2698
- for (const s of o)
2699
- d(this, k).delete(s);
2825
+ d(this, F).add(s);
2826
+ const n = p(this, N, ve).call(this, r);
2827
+ for (const s of n)
2828
+ d(this, j).add(s);
2829
+ const o = super.transformNodeImpl(r);
2830
+ for (const s of n)
2831
+ d(this, j).delete(s);
2700
2832
  for (const s of a)
2701
- d(this, $).delete(s);
2702
- return n;
2833
+ d(this, F).delete(s);
2834
+ return o;
2703
2835
  }
2704
2836
  transformSchemableIdentifier(r) {
2705
2837
  const a = super.transformSchemableIdentifier(r);
2706
- return a.schema || !d(this, k).has(r.identifier.name) ? a : {
2838
+ return a.schema || !d(this, j).has(r.identifier.name) ? a : {
2707
2839
  ...a,
2708
- schema: B.create(d(this, M))
2840
+ schema: W.create(d(this, E))
2709
2841
  };
2710
2842
  }
2711
2843
  transformReferences(r) {
2712
2844
  const a = super.transformReferences(r);
2713
2845
  return a.table.table.schema ? a : {
2714
2846
  ...a,
2715
- table: W.createWithSchema(d(this, M), a.table.table.identifier.name)
2847
+ table: X.createWithSchema(d(this, E), a.table.table.identifier.name)
2716
2848
  };
2717
2849
  }
2718
2850
  }
2719
- M = new WeakMap(), k = new WeakMap(), $ = new WeakMap(), w = new WeakSet(), ye = function(r) {
2720
- return r.kind in sa;
2851
+ E = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakSet(), ye = function(r) {
2852
+ return r.kind in da;
2721
2853
  }, ve = function(r) {
2722
2854
  const a = /* @__PURE__ */ new Set();
2723
- if ("name" in r && r.name && Y.is(r.name) && m(this, w, Z).call(this, r.name, a), "from" in r && r.from)
2724
- for (const o of r.from.froms)
2725
- m(this, w, P).call(this, o, a);
2726
- if ("into" in r && r.into && m(this, w, P).call(this, r.into, a), "table" in r && r.table && m(this, w, P).call(this, r.table, a), "joins" in r && r.joins)
2727
- for (const o of r.joins)
2728
- m(this, w, P).call(this, o.table, a);
2729
- return "using" in r && r.using && m(this, w, P).call(this, r.using, a), a;
2855
+ if ("name" in r && r.name && re.is(r.name) && p(this, N, ae).call(this, r.name, a), "from" in r && r.from)
2856
+ for (const n of r.from.froms)
2857
+ p(this, N, A).call(this, n, a);
2858
+ if ("into" in r && r.into && p(this, N, A).call(this, r.into, a), "table" in r && r.table && p(this, N, A).call(this, r.table, a), "joins" in r && r.joins)
2859
+ for (const n of r.joins)
2860
+ p(this, N, A).call(this, n.table, a);
2861
+ return "using" in r && r.using && p(this, N, A).call(this, r.using, a), a;
2730
2862
  }, Ne = function(r) {
2731
2863
  const a = /* @__PURE__ */ new Set();
2732
- return "with" in r && r.with && m(this, w, Ce).call(this, r.with, a), a;
2733
- }, P = function(r, a) {
2734
- const o = W.is(r) ? r : na.is(r) && W.is(r.node) ? r.node : null;
2735
- o && m(this, w, Z).call(this, o.table, a);
2736
- }, Z = function(r, a) {
2737
- const o = r.identifier.name;
2738
- !d(this, k).has(o) && !d(this, $).has(o) && a.add(o);
2864
+ return "with" in r && r.with && p(this, N, Ce).call(this, r.with, a), a;
2865
+ }, A = function(r, a) {
2866
+ const n = X.is(r) ? r : la.is(r) && X.is(r.node) ? r.node : null;
2867
+ n && p(this, N, ae).call(this, n.table, a);
2868
+ }, ae = function(r, a) {
2869
+ const n = r.identifier.name;
2870
+ !d(this, j).has(n) && !d(this, F).has(n) && a.add(n);
2739
2871
  }, Ce = function(r, a) {
2740
- for (const o of r.expressions) {
2741
- const n = o.name.table.table.identifier.name;
2742
- d(this, $).has(n) || a.add(n);
2872
+ for (const n of r.expressions) {
2873
+ const o = n.name.table.table.identifier.name;
2874
+ d(this, F).has(o) || a.add(o);
2743
2875
  }
2744
2876
  };
2745
- var R;
2746
- class la {
2877
+ var Q;
2878
+ class ma {
2747
2879
  constructor(e) {
2748
- N(this, R);
2749
- L(this, R, new ia(e));
2880
+ S(this, Q);
2881
+ K(this, Q, new ua(e));
2750
2882
  }
2751
2883
  transformQuery(e) {
2752
- return d(this, R).transformNode(e.node);
2884
+ return d(this, Q).transformNode(e.node);
2753
2885
  }
2754
2886
  async transformResult(e) {
2755
2887
  return e.result;
2756
2888
  }
2757
2889
  }
2758
- R = new WeakMap();
2759
- class ca {
2890
+ Q = new WeakMap();
2891
+ class _a {
2760
2892
  transformQuery(e) {
2761
2893
  return e.node;
2762
2894
  }
@@ -2764,13 +2896,13 @@ class ca {
2764
2896
  return e.result;
2765
2897
  }
2766
2898
  }
2767
- const da = "kysely_migration", fe = "kysely_migration_lock", ua = !1, G = "migration_lock", ma = y({ __noMigrations__: !0 });
2768
- var p, i, E, x, T, j, xe, S, Te, Se, Oe, ke, $e, ee, F, te, Ie, De, Pe, re, je, Fe, Me, Ae, ze, J;
2899
+ const ha = "kysely_migration", fe = "kysely_migration_lock", fa = !1, Z = "migration_lock", pa = C({ __noMigrations__: !0 });
2900
+ var v, l, U, k, $, z, xe, I, Te, Se, Oe, ke, $e, ne, L, oe, Ie, De, Pe, se, je, Fe, Me, Ae, ze, B;
2769
2901
  class be {
2770
2902
  constructor(e) {
2771
- N(this, i);
2772
- N(this, p);
2773
- L(this, p, y(e));
2903
+ S(this, l);
2904
+ S(this, v);
2905
+ K(this, v, C(e));
2774
2906
  }
2775
2907
  /**
2776
2908
  * Returns a {@link MigrationInfo} object for each migration.
@@ -2778,13 +2910,13 @@ class be {
2778
2910
  * The returned array is sorted by migration name.
2779
2911
  */
2780
2912
  async getMigrations() {
2781
- const e = await m(this, i, F).call(this, d(this, i, T)) ? await d(this, p).db.withPlugin(d(this, i, S)).selectFrom(d(this, i, T)).select(["name", "timestamp"]).execute() : [];
2782
- return (await m(this, i, re).call(this)).map(({ name: a, ...o }) => {
2783
- const n = e.find((s) => s.name === a);
2913
+ const e = await p(this, l, L).call(this, d(this, l, $)) ? await d(this, v).db.withPlugin(d(this, l, I)).selectFrom(d(this, l, $)).select(["name", "timestamp"]).execute() : [];
2914
+ return (await p(this, l, se).call(this)).map(({ name: a, ...n }) => {
2915
+ const o = e.find((s) => s.name === a);
2784
2916
  return {
2785
2917
  name: a,
2786
- migration: o,
2787
- executedAt: n ? new Date(n.timestamp) : void 0
2918
+ migration: n,
2919
+ executedAt: o ? new Date(o.timestamp) : void 0
2788
2920
  };
2789
2921
  });
2790
2922
  }
@@ -2836,7 +2968,7 @@ class be {
2836
2968
  * ```
2837
2969
  */
2838
2970
  async migrateToLatest() {
2839
- return m(this, i, E).call(this, () => ({ direction: "Up", step: 1 / 0 }));
2971
+ return p(this, l, U).call(this, () => ({ direction: "Up", step: 1 / 0 }));
2840
2972
  }
2841
2973
  /**
2842
2974
  * Migrate up/down to a specific migration.
@@ -2862,16 +2994,16 @@ class be {
2862
2994
  * ```
2863
2995
  */
2864
2996
  async migrateTo(e) {
2865
- return m(this, i, E).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: o }) => {
2866
- if (e === ma)
2997
+ return p(this, l, U).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: n }) => {
2998
+ if (e === pa)
2867
2999
  return { direction: "Down", step: 1 / 0 };
2868
- if (!r.find((l) => l.name === e))
3000
+ if (!r.find((i) => i.name === e))
2869
3001
  throw new Error(`migration "${e}" doesn't exist`);
2870
- const n = a.indexOf(e), s = o.findIndex((l) => l.name === e);
2871
- if (n !== -1)
3002
+ const o = a.indexOf(e), s = n.findIndex((i) => i.name === e);
3003
+ if (o !== -1)
2872
3004
  return {
2873
3005
  direction: "Down",
2874
- step: a.length - n - 1
3006
+ step: a.length - o - 1
2875
3007
  };
2876
3008
  if (s !== -1)
2877
3009
  return { direction: "Up", step: s + 1 };
@@ -2893,7 +3025,7 @@ class be {
2893
3025
  * ```
2894
3026
  */
2895
3027
  async migrateUp() {
2896
- return m(this, i, E).call(this, () => ({ direction: "Up", step: 1 }));
3028
+ return p(this, l, U).call(this, () => ({ direction: "Up", step: 1 }));
2897
3029
  }
2898
3030
  /**
2899
3031
  * Migrate one step down.
@@ -2910,194 +3042,194 @@ class be {
2910
3042
  * ```
2911
3043
  */
2912
3044
  async migrateDown() {
2913
- return m(this, i, E).call(this, () => ({ direction: "Down", step: 1 }));
3045
+ return p(this, l, U).call(this, () => ({ direction: "Down", step: 1 }));
2914
3046
  }
2915
3047
  }
2916
- p = new WeakMap(), i = new WeakSet(), E = async function(e) {
3048
+ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
2917
3049
  try {
2918
- return await m(this, i, Te).call(this), await m(this, i, Ie).call(this, e);
3050
+ return await p(this, l, Te).call(this), await p(this, l, Ie).call(this, e);
2919
3051
  } catch (r) {
2920
- return r instanceof H ? r.resultSet : { error: r };
2921
- }
2922
- }, x = function() {
2923
- return d(this, p).migrationTableSchema;
2924
- }, T = function() {
2925
- return d(this, p).migrationTableName ?? da;
2926
- }, j = function() {
2927
- return d(this, p).migrationLockTableName ?? fe;
3052
+ return r instanceof ee ? r.resultSet : { error: r };
3053
+ }
3054
+ }, k = function() {
3055
+ return d(this, v).migrationTableSchema;
3056
+ }, $ = function() {
3057
+ return d(this, v).migrationTableName ?? ha;
3058
+ }, z = function() {
3059
+ return d(this, v).migrationLockTableName ?? fe;
2928
3060
  }, xe = function() {
2929
- return d(this, p).allowUnorderedMigrations ?? ua;
2930
- }, S = function() {
2931
- return d(this, i, x) ? new la(d(this, i, x)) : new ca();
3061
+ return d(this, v).allowUnorderedMigrations ?? fa;
3062
+ }, I = function() {
3063
+ return d(this, l, k) ? new ma(d(this, l, k)) : new _a();
2932
3064
  }, Te = async function() {
2933
- await m(this, i, Se).call(this), await m(this, i, Oe).call(this), await m(this, i, ke).call(this), await m(this, i, $e).call(this);
3065
+ await p(this, l, Se).call(this), await p(this, l, Oe).call(this), await p(this, l, ke).call(this), await p(this, l, $e).call(this);
2934
3066
  }, Se = async function() {
2935
- if (d(this, i, x) && !await m(this, i, ee).call(this))
3067
+ if (d(this, l, k) && !await p(this, l, ne).call(this))
2936
3068
  try {
2937
- await m(this, i, J).call(this, d(this, p).db.schema.createSchema(d(this, i, x)));
3069
+ await p(this, l, B).call(this, d(this, v).db.schema.createSchema(d(this, l, k)));
2938
3070
  } catch (e) {
2939
- if (!await m(this, i, ee).call(this))
3071
+ if (!await p(this, l, ne).call(this))
2940
3072
  throw e;
2941
3073
  }
2942
3074
  }, Oe = async function() {
2943
- if (!await m(this, i, F).call(this, d(this, i, T)))
3075
+ if (!await p(this, l, L).call(this, d(this, l, $)))
2944
3076
  try {
2945
- d(this, i, x) && await m(this, i, J).call(this, d(this, p).db.schema.createSchema(d(this, i, x))), await m(this, i, J).call(this, d(this, p).db.schema.withPlugin(d(this, i, S)).createTable(d(this, i, T)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
3077
+ d(this, l, k) && await p(this, l, B).call(this, d(this, v).db.schema.createSchema(d(this, l, k))), await p(this, l, B).call(this, d(this, v).db.schema.withPlugin(d(this, l, I)).createTable(d(this, l, $)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2946
3078
  } catch (e) {
2947
- if (!await m(this, i, F).call(this, d(this, i, T)))
3079
+ if (!await p(this, l, L).call(this, d(this, l, $)))
2948
3080
  throw e;
2949
3081
  }
2950
3082
  }, ke = async function() {
2951
- if (!await m(this, i, F).call(this, d(this, i, j)))
3083
+ if (!await p(this, l, L).call(this, d(this, l, z)))
2952
3084
  try {
2953
- await m(this, i, J).call(this, d(this, p).db.schema.withPlugin(d(this, i, S)).createTable(d(this, i, j)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
3085
+ await p(this, l, B).call(this, d(this, v).db.schema.withPlugin(d(this, l, I)).createTable(d(this, l, z)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2954
3086
  } catch (e) {
2955
- if (!await m(this, i, F).call(this, d(this, i, j)))
3087
+ if (!await p(this, l, L).call(this, d(this, l, z)))
2956
3088
  throw e;
2957
3089
  }
2958
3090
  }, $e = async function() {
2959
- if (!await m(this, i, te).call(this))
3091
+ if (!await p(this, l, oe).call(this))
2960
3092
  try {
2961
- await d(this, p).db.withPlugin(d(this, i, S)).insertInto(d(this, i, j)).values({ id: G, is_locked: 0 }).execute();
3093
+ await d(this, v).db.withPlugin(d(this, l, I)).insertInto(d(this, l, z)).values({ id: Z, is_locked: 0 }).execute();
2962
3094
  } catch (e) {
2963
- if (!await m(this, i, te).call(this))
3095
+ if (!await p(this, l, oe).call(this))
2964
3096
  throw e;
2965
3097
  }
2966
- }, ee = async function() {
2967
- return (await d(this, p).db.introspection.getSchemas()).some((r) => r.name === d(this, i, x));
2968
- }, F = async function(e) {
2969
- const r = d(this, i, x);
2970
- return (await d(this, p).db.introspection.getTables({
3098
+ }, ne = async function() {
3099
+ return (await d(this, v).db.introspection.getSchemas()).some((r) => r.name === d(this, l, k));
3100
+ }, L = async function(e) {
3101
+ const r = d(this, l, k);
3102
+ return (await d(this, v).db.introspection.getTables({
2971
3103
  withInternalKyselyTables: !0
2972
- })).some((o) => o.name === e && (!r || o.schema === r));
2973
- }, te = async function() {
2974
- return !!await d(this, p).db.withPlugin(d(this, i, S)).selectFrom(d(this, i, j)).where("id", "=", G).select("id").executeTakeFirst();
3104
+ })).some((n) => n.name === e && (!r || n.schema === r));
3105
+ }, oe = async function() {
3106
+ return !!await d(this, v).db.withPlugin(d(this, l, I)).selectFrom(d(this, l, z)).where("id", "=", Z).select("id").executeTakeFirst();
2975
3107
  }, Ie = async function(e) {
2976
- const r = d(this, p).db.getExecutor().adapter, a = y({
2977
- lockTable: d(this, p).migrationLockTableName ?? fe,
2978
- lockRowId: G,
2979
- lockTableSchema: d(this, p).migrationTableSchema
2980
- }), o = async (n) => {
3108
+ const r = d(this, v).db.getExecutor().adapter, a = C({
3109
+ lockTable: d(this, v).migrationLockTableName ?? fe,
3110
+ lockRowId: Z,
3111
+ lockTableSchema: d(this, v).migrationTableSchema
3112
+ }), n = async (o) => {
2981
3113
  try {
2982
- await r.acquireMigrationLock(n, a);
2983
- const s = await m(this, i, De).call(this, n);
3114
+ await r.acquireMigrationLock(o, a);
3115
+ const s = await p(this, l, De).call(this, o);
2984
3116
  if (s.migrations.length === 0)
2985
3117
  return { results: [] };
2986
- const { direction: l, step: c } = e(s);
2987
- return c <= 0 ? { results: [] } : l === "Down" ? await m(this, i, Ae).call(this, n, s, c) : l === "Up" ? await m(this, i, ze).call(this, n, s, c) : { results: [] };
3118
+ const { direction: i, step: c } = e(s);
3119
+ return c <= 0 ? { results: [] } : i === "Down" ? await p(this, l, Ae).call(this, o, s, c) : i === "Up" ? await p(this, l, ze).call(this, o, s, c) : { results: [] };
2988
3120
  } finally {
2989
- await r.releaseMigrationLock(n, a);
3121
+ await r.releaseMigrationLock(o, a);
2990
3122
  }
2991
3123
  };
2992
- return r.supportsTransactionalDdl ? d(this, p).db.transaction().execute(o) : d(this, p).db.connection().execute(o);
3124
+ return r.supportsTransactionalDdl ? d(this, v).db.transaction().execute(n) : d(this, v).db.connection().execute(n);
2993
3125
  }, De = async function(e) {
2994
- const r = await m(this, i, re).call(this), a = await m(this, i, je).call(this, e);
2995
- m(this, i, Fe).call(this, r, a), d(this, i, xe) || m(this, i, Me).call(this, r, a);
2996
- const o = m(this, i, Pe).call(this, r, a);
2997
- return y({
3126
+ const r = await p(this, l, se).call(this), a = await p(this, l, je).call(this, e);
3127
+ p(this, l, Fe).call(this, r, a), d(this, l, xe) || p(this, l, Me).call(this, r, a);
3128
+ const n = p(this, l, Pe).call(this, r, a);
3129
+ return C({
2998
3130
  migrations: r,
2999
3131
  executedMigrations: a,
3000
- lastMigration: aa(a),
3001
- pendingMigrations: o
3132
+ lastMigration: ia(a),
3133
+ pendingMigrations: n
3002
3134
  });
3003
3135
  }, Pe = function(e, r) {
3004
3136
  return e.filter((a) => !r.includes(a.name));
3005
- }, re = async function() {
3006
- const e = await d(this, p).provider.getMigrations();
3137
+ }, se = async function() {
3138
+ const e = await d(this, v).provider.getMigrations();
3007
3139
  return Object.keys(e).sort().map((r) => ({
3008
3140
  ...e[r],
3009
3141
  name: r
3010
3142
  }));
3011
3143
  }, je = async function(e) {
3012
- return (await e.withPlugin(d(this, i, S)).selectFrom(d(this, i, T)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
3144
+ return (await e.withPlugin(d(this, l, I)).selectFrom(d(this, l, $)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
3013
3145
  }, Fe = function(e, r) {
3014
3146
  for (const a of r)
3015
- if (!e.some((o) => o.name === a))
3147
+ if (!e.some((n) => n.name === a))
3016
3148
  throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
3017
3149
  }, Me = function(e, r) {
3018
3150
  for (let a = 0; a < r.length; ++a)
3019
3151
  if (e[a].name !== r[a])
3020
3152
  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.`);
3021
3153
  }, Ae = async function(e, r, a) {
3022
- const o = r.executedMigrations.slice().reverse().slice(0, a).map((s) => r.migrations.find((l) => l.name === s)), n = o.map((s) => ({
3154
+ const n = r.executedMigrations.slice().reverse().slice(0, a).map((s) => r.migrations.find((i) => i.name === s)), o = n.map((s) => ({
3023
3155
  migrationName: s.name,
3024
3156
  direction: "Down",
3025
3157
  status: "NotExecuted"
3026
3158
  }));
3027
- for (let s = 0; s < n.length; ++s) {
3028
- const l = o[s];
3159
+ for (let s = 0; s < o.length; ++s) {
3160
+ const i = n[s];
3029
3161
  try {
3030
- l.down && (await l.down(e), await e.withPlugin(d(this, i, S)).deleteFrom(d(this, i, T)).where("name", "=", l.name).execute(), n[s] = {
3031
- migrationName: l.name,
3162
+ i.down && (await i.down(e), await e.withPlugin(d(this, l, I)).deleteFrom(d(this, l, $)).where("name", "=", i.name).execute(), o[s] = {
3163
+ migrationName: i.name,
3032
3164
  direction: "Down",
3033
3165
  status: "Success"
3034
3166
  });
3035
3167
  } catch (c) {
3036
- throw n[s] = {
3037
- migrationName: l.name,
3168
+ throw o[s] = {
3169
+ migrationName: i.name,
3038
3170
  direction: "Down",
3039
3171
  status: "Error"
3040
- }, new H({
3172
+ }, new ee({
3041
3173
  error: c,
3042
- results: n
3174
+ results: o
3043
3175
  });
3044
3176
  }
3045
3177
  }
3046
- return { results: n };
3178
+ return { results: o };
3047
3179
  }, ze = async function(e, r, a) {
3048
- const n = r.pendingMigrations.slice(0, a).map((s) => ({
3180
+ const o = r.pendingMigrations.slice(0, a).map((s) => ({
3049
3181
  migrationName: s.name,
3050
3182
  direction: "Up",
3051
3183
  status: "NotExecuted"
3052
3184
  }));
3053
- for (let s = 0; s < n.length; s++) {
3054
- const l = r.pendingMigrations[s];
3185
+ for (let s = 0; s < o.length; s++) {
3186
+ const i = r.pendingMigrations[s];
3055
3187
  try {
3056
- await l.up(e), await e.withPlugin(d(this, i, S)).insertInto(d(this, i, T)).values({
3057
- name: l.name,
3188
+ await i.up(e), await e.withPlugin(d(this, l, I)).insertInto(d(this, l, $)).values({
3189
+ name: i.name,
3058
3190
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3059
- }).execute(), n[s] = {
3060
- migrationName: l.name,
3191
+ }).execute(), o[s] = {
3192
+ migrationName: i.name,
3061
3193
  direction: "Up",
3062
3194
  status: "Success"
3063
3195
  };
3064
3196
  } catch (c) {
3065
- throw n[s] = {
3066
- migrationName: l.name,
3197
+ throw o[s] = {
3198
+ migrationName: i.name,
3067
3199
  direction: "Up",
3068
3200
  status: "Error"
3069
- }, new H({
3201
+ }, new ee({
3070
3202
  error: c,
3071
- results: n
3203
+ results: o
3072
3204
  });
3073
3205
  }
3074
3206
  }
3075
- return { results: n };
3076
- }, J = async function(e) {
3077
- d(this, p).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
3207
+ return { results: o };
3208
+ }, B = async function(e) {
3209
+ d(this, v).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
3078
3210
  };
3079
- var K;
3080
- class H extends Error {
3211
+ var q;
3212
+ class ee extends Error {
3081
3213
  constructor(r) {
3082
3214
  super();
3083
- N(this, K);
3084
- L(this, K, r);
3215
+ S(this, q);
3216
+ K(this, q, r);
3085
3217
  }
3086
3218
  get resultSet() {
3087
- return d(this, K);
3219
+ return d(this, q);
3088
3220
  }
3089
3221
  }
3090
- K = new WeakMap();
3222
+ q = new WeakMap();
3091
3223
  class Le {
3092
3224
  constructor(e) {
3093
- z(this, "migrations");
3225
+ R(this, "migrations");
3094
3226
  this.migrations = e;
3095
3227
  }
3096
3228
  async getMigrations() {
3097
3229
  return this.migrations;
3098
3230
  }
3099
3231
  }
3100
- async function _a(t) {
3232
+ async function ga(t) {
3101
3233
  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(
3102
3234
  "tenant_id",
3103
3235
  "varchar(255)",
@@ -3169,35 +3301,35 @@ async function _a(t) {
3169
3301
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3170
3302
  ).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();
3171
3303
  }
3172
- async function ha(t) {
3304
+ async function wa(t) {
3173
3305
  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();
3174
3306
  }
3175
- const fa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3307
+ const ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3176
3308
  __proto__: null,
3177
- down: ha,
3178
- up: _a
3309
+ down: wa,
3310
+ up: ga
3179
3311
  }, Symbol.toStringTag, { value: "Module" }));
3180
- async function pa(t) {
3312
+ async function va(t) {
3181
3313
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
3182
3314
  }
3183
- async function ga(t) {
3315
+ async function Na(t) {
3184
3316
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
3185
3317
  }
3186
- const wa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3318
+ const Ca = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3187
3319
  __proto__: null,
3188
- down: ga,
3189
- up: pa
3320
+ down: Na,
3321
+ up: va
3190
3322
  }, Symbol.toStringTag, { value: "Module" }));
3191
- async function ya(t) {
3323
+ async function ba(t) {
3192
3324
  }
3193
- async function va(t) {
3325
+ async function xa(t) {
3194
3326
  }
3195
- const Na = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3327
+ const Ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3196
3328
  __proto__: null,
3197
- down: va,
3198
- up: ya
3329
+ down: xa,
3330
+ up: ba
3199
3331
  }, Symbol.toStringTag, { value: "Module" }));
3200
- async function Ca(t) {
3332
+ async function Sa(t) {
3201
3333
  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(
3202
3334
  "tenant_id_constraint",
3203
3335
  ["tenant_id"],
@@ -3206,24 +3338,24 @@ async function Ca(t) {
3206
3338
  (e) => e.onDelete("cascade")
3207
3339
  ).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();
3208
3340
  }
3209
- async function ba(t) {
3341
+ async function Oa(t) {
3210
3342
  await t.schema.dropTable("logs").execute();
3211
3343
  }
3212
- const xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3344
+ const ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3213
3345
  __proto__: null,
3214
- down: ba,
3215
- up: Ca
3346
+ down: Oa,
3347
+ up: Sa
3216
3348
  }, Symbol.toStringTag, { value: "Module" }));
3217
- async function Ta(t) {
3349
+ async function $a(t) {
3218
3350
  }
3219
- async function Sa(t) {
3351
+ async function Ia(t) {
3220
3352
  }
3221
- const Oa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3353
+ const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3222
3354
  __proto__: null,
3223
- down: Sa,
3224
- up: Ta
3355
+ down: Ia,
3356
+ up: $a
3225
3357
  }, Symbol.toStringTag, { value: "Module" }));
3226
- async function ka(t) {
3358
+ async function Pa(t) {
3227
3359
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3228
3360
  "user_id_constraint",
3229
3361
  ["user_id", "tenant_id"],
@@ -3248,15 +3380,15 @@ async function ka(t) {
3248
3380
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3249
3381
  ).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();
3250
3382
  }
3251
- async function $a(t) {
3383
+ async function ja(t) {
3252
3384
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
3253
3385
  }
3254
- const Ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3386
+ const Fa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3255
3387
  __proto__: null,
3256
- down: $a,
3257
- up: ka
3388
+ down: ja,
3389
+ up: Pa
3258
3390
  }, Symbol.toStringTag, { value: "Module" }));
3259
- async function Da(t) {
3391
+ async function Ma(t) {
3260
3392
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
3261
3393
  "user_id_constraint",
3262
3394
  ["user_id", "tenant_id"],
@@ -3271,24 +3403,24 @@ async function Da(t) {
3271
3403
  (e) => e.onDelete("cascade")
3272
3404
  ).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();
3273
3405
  }
3274
- async function Pa(t) {
3406
+ async function Aa(t) {
3275
3407
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
3276
3408
  }
3277
- const ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3409
+ const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3278
3410
  __proto__: null,
3279
- down: Pa,
3280
- up: Da
3411
+ down: Aa,
3412
+ up: Ma
3281
3413
  }, Symbol.toStringTag, { value: "Module" }));
3282
- async function Fa(t) {
3414
+ async function La(t) {
3283
3415
  }
3284
- async function Ma(t) {
3416
+ async function Ea(t) {
3285
3417
  }
3286
- const Aa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3418
+ const Ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3287
3419
  __proto__: null,
3288
- down: Ma,
3289
- up: Fa
3420
+ down: Ea,
3421
+ up: La
3290
3422
  }, Symbol.toStringTag, { value: "Module" }));
3291
- async function za(t) {
3423
+ async function Ra(t) {
3292
3424
  await t.schema.alterTable("passwords").addColumn(
3293
3425
  "password",
3294
3426
  "varchar(255)",
@@ -3296,288 +3428,296 @@ async function za(t) {
3296
3428
  (e) => e.notNull()
3297
3429
  ).execute();
3298
3430
  }
3299
- async function La(t) {
3431
+ async function Ka(t) {
3300
3432
  await t.schema.alterTable("passwords").dropColumn("password").execute();
3301
3433
  }
3302
- const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3434
+ const Ua = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3303
3435
  __proto__: null,
3304
- down: La,
3305
- up: za
3436
+ down: Ka,
3437
+ up: Ra
3306
3438
  }, Symbol.toStringTag, { value: "Module" }));
3307
- async function Ja(t) {
3439
+ async function Ba(t) {
3308
3440
  }
3309
- async function Ra(t) {
3441
+ async function Qa(t) {
3310
3442
  }
3311
- const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3443
+ const qa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3312
3444
  __proto__: null,
3313
- down: Ra,
3314
- up: Ja
3445
+ down: Qa,
3446
+ up: Ba
3315
3447
  }, Symbol.toStringTag, { value: "Module" }));
3316
- async function Ua(t) {
3448
+ async function Va(t) {
3317
3449
  }
3318
- async function Ba(t) {
3450
+ async function Wa(t) {
3319
3451
  }
3320
- const Qa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3452
+ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3321
3453
  __proto__: null,
3322
- down: Ba,
3323
- up: Ua
3454
+ down: Wa,
3455
+ up: Va
3324
3456
  }, Symbol.toStringTag, { value: "Module" }));
3325
- async function qa(t) {
3457
+ async function Ha(t) {
3326
3458
  }
3327
- async function Va(t) {
3459
+ async function Ya(t) {
3328
3460
  }
3329
- const Wa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3461
+ const Xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3330
3462
  __proto__: null,
3331
- down: Va,
3332
- up: qa
3463
+ down: Ya,
3464
+ up: Ha
3333
3465
  }, Symbol.toStringTag, { value: "Module" }));
3334
- async function Ga(t) {
3466
+ async function Za(t) {
3335
3467
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
3336
3468
  }
3337
- async function Ha(t) {
3469
+ async function en(t) {
3338
3470
  await t.schema.dropIndex("users_email_index").execute();
3339
3471
  }
3340
- const Xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3472
+ const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3341
3473
  __proto__: null,
3342
- down: Ha,
3343
- up: Ga
3474
+ down: en,
3475
+ up: Za
3344
3476
  }, Symbol.toStringTag, { value: "Module" }));
3345
- async function Ya(t) {
3477
+ async function rn(t) {
3346
3478
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3347
3479
  }
3348
- async function Za(t) {
3480
+ async function an(t) {
3349
3481
  await t.schema.alterTable("users").dropColumn("profileData").execute();
3350
3482
  }
3351
- const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3483
+ const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3352
3484
  __proto__: null,
3353
- down: Za,
3354
- up: Ya
3485
+ down: an,
3486
+ up: rn
3355
3487
  }, Symbol.toStringTag, { value: "Module" }));
3356
- async function tn(t) {
3488
+ async function on(t) {
3357
3489
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3358
3490
  }
3359
- async function rn(t) {
3491
+ async function sn(t) {
3360
3492
  await t.schema.dropIndex("users_linked_to_index");
3361
3493
  }
3362
- const an = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3494
+ const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3363
3495
  __proto__: null,
3364
- down: rn,
3365
- up: tn
3496
+ down: sn,
3497
+ up: on
3366
3498
  }, Symbol.toStringTag, { value: "Module" }));
3367
- async function nn(t) {
3499
+ async function cn(t) {
3368
3500
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
3369
3501
  }
3370
- async function on(t) {
3502
+ async function dn(t) {
3371
3503
  await t.schema.alterTable("users").dropColumn("locale").execute();
3372
3504
  }
3373
- const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3505
+ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3374
3506
  __proto__: null,
3375
- down: on,
3376
- up: nn
3507
+ down: dn,
3508
+ up: cn
3377
3509
  }, Symbol.toStringTag, { value: "Module" }));
3378
- async function ln(t) {
3510
+ async function mn(t) {
3379
3511
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
3380
3512
  "tenant_id",
3381
3513
  "varchar(255)",
3382
3514
  (e) => e.references("tenants.id").onDelete("cascade")
3383
- ).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();
3515
+ ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn("cert", "varchar(4096)").addColumn("pkcs7", "varchar(4096)").addColumn("fingerprint", "varchar(256)").addColumn("thumbprint", "varchar(256)").addColumn("current_since", "varchar(256)").addColumn("current_until", "varchar(256)").addColumn(
3516
+ "type",
3517
+ "varchar(50)",
3518
+ (e) => e.notNull().defaultTo("jwt_signing")
3519
+ ).addColumn(
3520
+ "connection",
3521
+ "varchar(255)",
3522
+ (e) => e.references("connections.id").onDelete("cascade")
3523
+ ).execute();
3384
3524
  }
3385
- async function cn(t) {
3525
+ async function _n(t) {
3386
3526
  await t.schema.dropTable("keys").execute();
3387
3527
  }
3388
- const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3528
+ const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3389
3529
  __proto__: null,
3390
- down: cn,
3391
- up: ln
3530
+ down: _n,
3531
+ up: mn
3392
3532
  }, Symbol.toStringTag, { value: "Module" }));
3393
- async function un(t) {
3533
+ async function fn(t) {
3394
3534
  }
3395
- async function mn(t) {
3535
+ async function pn(t) {
3396
3536
  }
3397
- const _n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3537
+ const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3398
3538
  __proto__: null,
3399
- down: mn,
3400
- up: un
3539
+ down: pn,
3540
+ up: fn
3401
3541
  }, Symbol.toStringTag, { value: "Module" }));
3402
- async function hn(t) {
3542
+ async function wn(t) {
3403
3543
  }
3404
- async function fn(t) {
3544
+ async function yn(t) {
3405
3545
  }
3406
- const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3546
+ const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3407
3547
  __proto__: null,
3408
- down: fn,
3409
- up: hn
3548
+ down: yn,
3549
+ up: wn
3410
3550
  }, Symbol.toStringTag, { value: "Module" }));
3411
- async function gn(t) {
3551
+ async function Nn(t) {
3412
3552
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3413
3553
  }
3414
- async function wn(t) {
3554
+ async function Cn(t) {
3415
3555
  await t.schema.alterTable("otps").dropColumn("audience").execute();
3416
3556
  }
3417
- const yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3557
+ const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3418
3558
  __proto__: null,
3419
- down: wn,
3420
- up: gn
3559
+ down: Cn,
3560
+ up: Nn
3421
3561
  }, Symbol.toStringTag, { value: "Module" }));
3422
- async function vn(t) {
3562
+ async function xn(t) {
3423
3563
  }
3424
- async function Nn(t) {
3564
+ async function Tn(t) {
3425
3565
  }
3426
- const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3566
+ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3427
3567
  __proto__: null,
3428
- down: Nn,
3429
- up: vn
3568
+ down: Tn,
3569
+ up: xn
3430
3570
  }, Symbol.toStringTag, { value: "Module" }));
3431
- async function bn(t) {
3571
+ async function On(t) {
3432
3572
  await t.schema.alterTable("logs").dropColumn("category").execute();
3433
3573
  }
3434
- async function xn(t) {
3574
+ async function kn(t) {
3435
3575
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
3436
3576
  }
3437
- const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3577
+ const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3438
3578
  __proto__: null,
3439
- down: xn,
3440
- up: bn
3579
+ down: kn,
3580
+ up: On
3441
3581
  }, Symbol.toStringTag, { value: "Module" }));
3442
- async function Sn(t) {
3582
+ async function In(t) {
3443
3583
  await t.schema.alterTable("users").dropColumn("tags").execute();
3444
3584
  }
3445
- async function On(t) {
3585
+ async function Dn(t) {
3446
3586
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3447
3587
  }
3448
- const kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3588
+ const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3449
3589
  __proto__: null,
3450
- down: On,
3451
- up: Sn
3590
+ down: Dn,
3591
+ up: In
3452
3592
  }, Symbol.toStringTag, { value: "Module" }));
3453
- async function $n(t) {
3593
+ async function jn(t) {
3454
3594
  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();
3455
3595
  }
3456
- async function In(t) {
3596
+ async function Fn(t) {
3457
3597
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3458
3598
  }
3459
- const Dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3599
+ const Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3460
3600
  __proto__: null,
3461
- down: In,
3462
- up: $n
3601
+ down: Fn,
3602
+ up: jn
3463
3603
  }, Symbol.toStringTag, { value: "Module" }));
3464
- async function Pn(t) {
3604
+ async function An(t) {
3465
3605
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3466
3606
  }
3467
- async function jn(t) {
3607
+ async function zn(t) {
3468
3608
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3469
3609
  }
3470
- const Fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3610
+ const Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3471
3611
  __proto__: null,
3472
- down: jn,
3473
- up: Pn
3612
+ down: zn,
3613
+ up: An
3474
3614
  }, Symbol.toStringTag, { value: "Module" }));
3475
- async function Mn(t) {
3615
+ async function En(t) {
3476
3616
  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();
3477
3617
  }
3478
- async function An(t) {
3618
+ async function Jn(t) {
3479
3619
  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();
3480
3620
  }
3481
- const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3621
+ const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3482
3622
  __proto__: null,
3483
- down: An,
3484
- up: Mn
3623
+ down: Jn,
3624
+ up: En
3485
3625
  }, Symbol.toStringTag, { value: "Module" }));
3486
- async function Ln(t) {
3626
+ async function Kn(t) {
3487
3627
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3488
3628
  }
3489
- async function En(t) {
3629
+ async function Un(t) {
3490
3630
  await t.schema.dropIndex("users_name_index").execute();
3491
3631
  }
3492
- const Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3632
+ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3493
3633
  __proto__: null,
3494
- down: En,
3495
- up: Ln
3634
+ down: Un,
3635
+ up: Kn
3496
3636
  }, Symbol.toStringTag, { value: "Module" }));
3497
- async function Rn(t) {
3637
+ async function Qn(t) {
3498
3638
  }
3499
- async function Kn(t) {
3639
+ async function qn(t) {
3500
3640
  await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3501
3641
  }
3502
- const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3642
+ const Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3503
3643
  __proto__: null,
3504
- down: Kn,
3505
- up: Rn
3644
+ down: qn,
3645
+ up: Qn
3506
3646
  }, Symbol.toStringTag, { value: "Module" }));
3507
- async function Bn(t) {
3647
+ async function Wn(t) {
3508
3648
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3509
3649
  }
3510
- async function Qn(t) {
3650
+ async function Gn(t) {
3511
3651
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
3512
3652
  }
3513
- const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3653
+ const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3514
3654
  __proto__: null,
3515
- down: Qn,
3516
- up: Bn
3655
+ down: Gn,
3656
+ up: Wn
3517
3657
  }, Symbol.toStringTag, { value: "Module" }));
3518
- async function Vn(t) {
3658
+ async function Yn(t) {
3519
3659
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3520
3660
  }
3521
- async function Wn(t) {
3661
+ async function Xn(t) {
3522
3662
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3523
3663
  }
3524
- const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3664
+ const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3525
3665
  __proto__: null,
3526
- down: Wn,
3527
- up: Vn
3666
+ down: Xn,
3667
+ up: Yn
3528
3668
  }, Symbol.toStringTag, { value: "Module" }));
3529
- async function Hn(t) {
3669
+ async function eo(t) {
3530
3670
  await t.schema.createTable("branding").addColumn(
3531
3671
  "tenant_id",
3532
3672
  "varchar(255)",
3533
3673
  (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3534
3674
  ).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();
3535
3675
  }
3536
- async function Xn(t) {
3676
+ async function to(t) {
3537
3677
  await t.schema.dropTable("branding").execute();
3538
3678
  }
3539
- const Yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3679
+ const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3540
3680
  __proto__: null,
3541
- down: Xn,
3542
- up: Hn
3681
+ down: to,
3682
+ up: eo
3543
3683
  }, Symbol.toStringTag, { value: "Module" }));
3544
- async function Zn(t) {
3684
+ async function ao(t) {
3545
3685
  }
3546
- async function eo(t) {
3686
+ async function no(t) {
3547
3687
  }
3548
- const to = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3688
+ const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3549
3689
  __proto__: null,
3550
- down: eo,
3551
- up: Zn
3690
+ down: no,
3691
+ up: ao
3552
3692
  }, Symbol.toStringTag, { value: "Module" }));
3553
- async function ro(t) {
3693
+ async function so(t) {
3554
3694
  }
3555
- async function ao(t) {
3695
+ async function io(t) {
3556
3696
  }
3557
- const no = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3697
+ const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3558
3698
  __proto__: null,
3559
- down: ao,
3560
- up: ro
3699
+ down: io,
3700
+ up: so
3561
3701
  }, Symbol.toStringTag, { value: "Module" }));
3562
- async function oo(t) {
3702
+ async function co(t) {
3563
3703
  }
3564
- async function so(t) {
3704
+ async function uo(t) {
3565
3705
  }
3566
- const io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3706
+ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3567
3707
  __proto__: null,
3568
- down: so,
3569
- up: oo
3708
+ down: uo,
3709
+ up: co
3570
3710
  }, Symbol.toStringTag, { value: "Module" }));
3571
- async function lo(t) {
3711
+ async function _o(t) {
3572
3712
  }
3573
- async function co(t) {
3713
+ async function ho(t) {
3574
3714
  }
3575
- const uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3715
+ const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3576
3716
  __proto__: null,
3577
- down: co,
3578
- up: lo
3717
+ down: ho,
3718
+ up: _o
3579
3719
  }, Symbol.toStringTag, { value: "Module" }));
3580
- async function mo(t) {
3720
+ async function po(t) {
3581
3721
  await t.schema.createTable("authentication_codes").addColumn(
3582
3722
  "tenant_id",
3583
3723
  "varchar(255)",
@@ -3588,55 +3728,55 @@ async function mo(t) {
3588
3728
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3589
3729
  ).addColumn("user_id", "varchar(255)", (e) => e.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(8192)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3590
3730
  }
3591
- async function _o(t) {
3731
+ async function go(t) {
3592
3732
  await t.schema.dropTable("authentication_codes").execute();
3593
3733
  }
3594
- const ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3734
+ const wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3595
3735
  __proto__: null,
3596
- down: _o,
3597
- up: mo
3736
+ down: go,
3737
+ up: po
3598
3738
  }, Symbol.toStringTag, { value: "Module" }));
3599
- async function fo(t) {
3739
+ async function yo(t) {
3600
3740
  }
3601
- async function po(t) {
3741
+ async function vo(t) {
3602
3742
  }
3603
- const go = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3743
+ const No = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3604
3744
  __proto__: null,
3605
- down: po,
3606
- up: fo
3745
+ down: vo,
3746
+ up: yo
3607
3747
  }, Symbol.toStringTag, { value: "Module" }));
3608
- async function wo(t) {
3748
+ async function Co(t) {
3609
3749
  await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3610
3750
  }
3611
- async function yo(t) {
3751
+ async function bo(t) {
3612
3752
  await t.schema.alterTable("otps").dropColumn("ip").execute();
3613
3753
  }
3614
- const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3754
+ const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3615
3755
  __proto__: null,
3616
- down: yo,
3617
- up: wo
3756
+ down: bo,
3757
+ up: Co
3618
3758
  }, Symbol.toStringTag, { value: "Module" }));
3619
- async function No(t) {
3759
+ async function To(t) {
3620
3760
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3621
3761
  }
3622
- async function Co(t) {
3762
+ async function So(t) {
3623
3763
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3624
3764
  }
3625
- const bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3765
+ const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3626
3766
  __proto__: null,
3627
- down: Co,
3628
- up: No
3767
+ down: So,
3768
+ up: To
3629
3769
  }, Symbol.toStringTag, { value: "Module" }));
3630
- async function xo(t) {
3770
+ async function ko(t) {
3631
3771
  }
3632
- async function To(t) {
3772
+ async function $o(t) {
3633
3773
  }
3634
- const So = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3774
+ const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3635
3775
  __proto__: null,
3636
- down: To,
3637
- up: xo
3776
+ down: $o,
3777
+ up: ko
3638
3778
  }, Symbol.toStringTag, { value: "Module" }));
3639
- async function Oo(t) {
3779
+ async function Do(t) {
3640
3780
  await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3641
3781
  "tenant_id",
3642
3782
  "varchar(255)",
@@ -3647,33 +3787,33 @@ async function Oo(t) {
3647
3787
  (e) => e.defaultTo(!1).notNull()
3648
3788
  ).addColumn("priority", "integer").execute();
3649
3789
  }
3650
- async function ko(t) {
3790
+ async function Po(t) {
3651
3791
  await t.schema.dropTable("hooks").execute();
3652
3792
  }
3653
- const $o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3793
+ const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3654
3794
  __proto__: null,
3655
- down: ko,
3656
- up: Oo
3795
+ down: Po,
3796
+ up: Do
3657
3797
  }, Symbol.toStringTag, { value: "Module" }));
3658
- async function Io(t) {
3798
+ async function Fo(t) {
3659
3799
  }
3660
- async function Do(t) {
3800
+ async function Mo(t) {
3661
3801
  }
3662
- const Po = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3802
+ const Ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3663
3803
  __proto__: null,
3664
- down: Do,
3665
- up: Io
3804
+ down: Mo,
3805
+ up: Fo
3666
3806
  }, Symbol.toStringTag, { value: "Module" }));
3667
- async function jo(t) {
3807
+ async function zo(t) {
3668
3808
  }
3669
- async function Fo(t) {
3809
+ async function Lo(t) {
3670
3810
  }
3671
- const Mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3811
+ const Eo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3672
3812
  __proto__: null,
3673
- down: Fo,
3674
- up: jo
3813
+ down: Lo,
3814
+ up: zo
3675
3815
  }, Symbol.toStringTag, { value: "Module" }));
3676
- async function Ao(t) {
3816
+ async function Jo(t) {
3677
3817
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3678
3818
  "tenant_id",
3679
3819
  "varchar(255)",
@@ -3690,7 +3830,7 @@ async function Ao(t) {
3690
3830
  (e) => e.onDelete("cascade")
3691
3831
  ).addColumn("code_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();
3692
3832
  }
3693
- async function zo(t) {
3833
+ async function Ro(t) {
3694
3834
  await t.schema.dropTable("logins").execute(), await t.schema.alterTable("passwords").dropColumn("algorithm").execute(), await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("code", "varchar(255)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addColumn("tenant_id", "varchar(255)").addForeignKeyConstraint(
3695
3835
  "codes_user_id_tenant_id_constraint",
3696
3836
  ["user_id", "tenant_id"],
@@ -3699,90 +3839,90 @@ async function zo(t) {
3699
3839
  (e) => e.onDelete("cascade")
3700
3840
  ).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();
3701
3841
  }
3702
- const Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3842
+ const Ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3703
3843
  __proto__: null,
3704
- down: zo,
3705
- up: Ao
3844
+ down: Ro,
3845
+ up: Jo
3706
3846
  }, Symbol.toStringTag, { value: "Module" }));
3707
- async function Eo(t) {
3847
+ async function Uo(t) {
3708
3848
  }
3709
- async function Jo(t) {
3849
+ async function Bo(t) {
3710
3850
  }
3711
- const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3851
+ const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3712
3852
  __proto__: null,
3713
- down: Jo,
3714
- up: Eo
3853
+ down: Bo,
3854
+ up: Uo
3715
3855
  }, Symbol.toStringTag, { value: "Module" }));
3716
- async function Ko(t) {
3856
+ async function qo(t) {
3717
3857
  await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3718
3858
  }
3719
- async function Uo(t) {
3859
+ async function Vo(t) {
3720
3860
  await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3721
3861
  }
3722
- const Bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3862
+ const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3723
3863
  __proto__: null,
3724
- down: Uo,
3725
- up: Ko
3864
+ down: Vo,
3865
+ up: qo
3726
3866
  }, Symbol.toStringTag, { value: "Module" }));
3727
- async function Qo(t) {
3867
+ async function Go(t) {
3728
3868
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3729
3869
  }
3730
- async function qo(t) {
3870
+ async function Ho(t) {
3731
3871
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3732
3872
  }
3733
- const Vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3873
+ const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3734
3874
  __proto__: null,
3735
- down: qo,
3736
- up: Qo
3875
+ down: Ho,
3876
+ up: Go
3737
3877
  }, Symbol.toStringTag, { value: "Module" }));
3738
- async function Wo(t) {
3878
+ async function Xo(t) {
3739
3879
  }
3740
- async function Go(t) {
3880
+ async function Zo(t) {
3741
3881
  }
3742
- const Ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3882
+ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3743
3883
  __proto__: null,
3744
- down: Go,
3745
- up: Wo
3884
+ down: Zo,
3885
+ up: Xo
3746
3886
  }, Symbol.toStringTag, { value: "Module" }));
3747
- async function Xo(t) {
3887
+ async function ts(t) {
3748
3888
  }
3749
- async function Yo(t) {
3889
+ async function rs(t) {
3750
3890
  }
3751
- const Zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3891
+ const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3752
3892
  __proto__: null,
3753
- down: Yo,
3754
- up: Xo
3893
+ down: rs,
3894
+ up: ts
3755
3895
  }, Symbol.toStringTag, { value: "Module" }));
3756
- async function es(t) {
3896
+ async function ns(t) {
3757
3897
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3758
3898
  }
3759
- async function ts(t) {
3899
+ async function os(t) {
3760
3900
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3761
3901
  }
3762
- const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3902
+ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3763
3903
  __proto__: null,
3764
- down: ts,
3765
- up: es
3904
+ down: os,
3905
+ up: ns
3766
3906
  }, Symbol.toStringTag, { value: "Module" }));
3767
- async function as(t) {
3907
+ async function is(t) {
3768
3908
  }
3769
- async function ns(t) {
3909
+ async function ls(t) {
3770
3910
  }
3771
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3911
+ const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3772
3912
  __proto__: null,
3773
- down: ns,
3774
- up: as
3913
+ down: ls,
3914
+ up: is
3775
3915
  }, Symbol.toStringTag, { value: "Module" }));
3776
- async function ss(t) {
3916
+ async function ds(t) {
3777
3917
  }
3778
- async function is(t) {
3918
+ async function us(t) {
3779
3919
  }
3780
- const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3920
+ const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3781
3921
  __proto__: null,
3782
- down: is,
3783
- up: ss
3922
+ down: us,
3923
+ up: ds
3784
3924
  }, Symbol.toStringTag, { value: "Module" }));
3785
- async function cs(t) {
3925
+ async function _s(t) {
3786
3926
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
3787
3927
  "tenant_id",
3788
3928
  "varchar(255)",
@@ -3798,7 +3938,7 @@ async function cs(t) {
3798
3938
  "code_type"
3799
3939
  ]).execute();
3800
3940
  }
3801
- async function ds(t) {
3941
+ async function hs(t) {
3802
3942
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3803
3943
  "tenant_id",
3804
3944
  "varchar(255)",
@@ -3811,15 +3951,15 @@ async function ds(t) {
3811
3951
  (e) => e.onDelete("cascade")
3812
3952
  ).addColumn("code_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();
3813
3953
  }
3814
- const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3954
+ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3815
3955
  __proto__: null,
3816
- down: ds,
3817
- up: cs
3956
+ down: hs,
3957
+ up: _s
3818
3958
  }, Symbol.toStringTag, { value: "Module" }));
3819
- async function ms(t) {
3959
+ async function ps(t) {
3820
3960
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
3821
3961
  }
3822
- async function _s(t) {
3962
+ async function gs(t) {
3823
3963
  await t.schema.alterTable("keys").addColumn("private_key", "varchar(2048)").addColumn("public_key", "varchar(2048)").execute(), await t.schema.createTable("otps").addColumn(
3824
3964
  "tenant_id",
3825
3965
  "varchar(255)",
@@ -3838,32 +3978,32 @@ async function _s(t) {
3838
3978
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3839
3979
  ).addColumn("user_id", "varchar(255)", (e) => e.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(8192)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3840
3980
  }
3841
- const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3981
+ const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3842
3982
  __proto__: null,
3843
- down: _s,
3844
- up: ms
3983
+ down: gs,
3984
+ up: ps
3845
3985
  }, Symbol.toStringTag, { value: "Module" }));
3846
- async function fs(t) {
3986
+ async function ys(t) {
3847
3987
  await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
3848
3988
  }
3849
- async function ps(t) {
3989
+ async function vs(t) {
3850
3990
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
3851
3991
  }
3852
- const gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3992
+ const Ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3853
3993
  __proto__: null,
3854
- down: ps,
3855
- up: fs
3994
+ down: vs,
3995
+ up: ys
3856
3996
  }, Symbol.toStringTag, { value: "Module" }));
3857
- async function ws(t) {
3997
+ async function Cs(t) {
3858
3998
  }
3859
- async function ys(t) {
3999
+ async function bs(t) {
3860
4000
  }
3861
- const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4001
+ const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3862
4002
  __proto__: null,
3863
- down: ys,
3864
- up: ws
4003
+ down: bs,
4004
+ up: Cs
3865
4005
  }, Symbol.toStringTag, { value: "Module" }));
3866
- async function Ns(t) {
4006
+ async function Ts(t) {
3867
4007
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
3868
4008
  "universal_login_experience",
3869
4009
  "varchar(16)",
@@ -3882,95 +4022,95 @@ async function Ns(t) {
3882
4022
  (e) => e.defaultTo(!1).notNull()
3883
4023
  ).execute();
3884
4024
  }
3885
- async function Cs(t) {
4025
+ async function Ss(t) {
3886
4026
  await t.schema.dropTable("prompt_settings").execute();
3887
4027
  }
3888
- const bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4028
+ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3889
4029
  __proto__: null,
3890
- down: Cs,
3891
- up: Ns
4030
+ down: Ss,
4031
+ up: Ts
3892
4032
  }, Symbol.toStringTag, { value: "Module" }));
3893
- async function xs(t) {
4033
+ async function ks(t) {
3894
4034
  }
3895
- async function Ts(t) {
4035
+ async function $s(t) {
3896
4036
  }
3897
- const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4037
+ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3898
4038
  __proto__: null,
3899
- down: Ts,
3900
- up: xs
4039
+ down: $s,
4040
+ up: ks
3901
4041
  }, Symbol.toStringTag, { value: "Module" }));
3902
- async function Os(t) {
4042
+ async function Ds(t) {
3903
4043
  }
3904
- async function ks(t) {
4044
+ async function Ps(t) {
3905
4045
  }
3906
- const $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4046
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3907
4047
  __proto__: null,
3908
- down: ks,
3909
- up: Os
4048
+ down: Ps,
4049
+ up: Ds
3910
4050
  }, Symbol.toStringTag, { value: "Module" }));
3911
- async function Is(t) {
4051
+ async function Fs(t) {
3912
4052
  }
3913
- async function Ds(t) {
4053
+ async function Ms(t) {
3914
4054
  }
3915
- const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4055
+ const As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3916
4056
  __proto__: null,
3917
- down: Ds,
3918
- up: Is
4057
+ down: Ms,
4058
+ up: Fs
3919
4059
  }, Symbol.toStringTag, { value: "Module" }));
3920
- async function js(t) {
4060
+ async function zs(t) {
3921
4061
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3922
4062
  }
3923
- async function Fs(t) {
4063
+ async function Ls(t) {
3924
4064
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3925
4065
  }
3926
- const Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4066
+ const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3927
4067
  __proto__: null,
3928
- down: Fs,
3929
- up: js
4068
+ down: Ls,
4069
+ up: zs
3930
4070
  }, Symbol.toStringTag, { value: "Module" }));
3931
- async function As(t) {
4071
+ async function Js(t) {
3932
4072
  await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
3933
4073
  }
3934
- async function zs(t) {
4074
+ async function Rs(t) {
3935
4075
  await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
3936
4076
  }
3937
- const Ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4077
+ const Ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3938
4078
  __proto__: null,
3939
- down: zs,
3940
- up: As
4079
+ down: Rs,
4080
+ up: Js
3941
4081
  }, Symbol.toStringTag, { value: "Module" }));
3942
- async function Es(t) {
4082
+ async function Us(t) {
3943
4083
  }
3944
- async function Js(t) {
4084
+ async function Bs(t) {
3945
4085
  }
3946
- const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4086
+ const Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3947
4087
  __proto__: null,
3948
- down: Js,
3949
- up: Es
4088
+ down: Bs,
4089
+ up: Us
3950
4090
  }, Symbol.toStringTag, { value: "Module" }));
3951
- async function Ks(t) {
4091
+ async function qs(t) {
3952
4092
  await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
3953
4093
  }
3954
- async function Us(t) {
4094
+ async function Vs(t) {
3955
4095
  await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
3956
4096
  }
3957
- const Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4097
+ const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3958
4098
  __proto__: null,
3959
- down: Us,
3960
- up: Ks
4099
+ down: Vs,
4100
+ up: qs
3961
4101
  }, Symbol.toStringTag, { value: "Module" }));
3962
- async function Qs(t) {
4102
+ async function Gs(t) {
3963
4103
  await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
3964
4104
  }
3965
- async function qs(t) {
4105
+ async function Hs(t) {
3966
4106
  await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
3967
4107
  }
3968
- const Vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4108
+ const Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3969
4109
  __proto__: null,
3970
- down: qs,
3971
- up: Qs
4110
+ down: Hs,
4111
+ up: Gs
3972
4112
  }, Symbol.toStringTag, { value: "Module" }));
3973
- async function Ws(t) {
4113
+ async function Xs(t) {
3974
4114
  await t.schema.createTable("email_providers").addColumn("tenant_id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("enabled", "boolean", (e) => e.notNull()).addColumn("default_from_address", "varchar(255)").addColumn(
3975
4115
  "credentials",
3976
4116
  "varchar(2048)",
@@ -3981,18 +4121,18 @@ async function Ws(t) {
3981
4121
  (e) => e.notNull().defaultTo("{}")
3982
4122
  ).addColumn("created_at", "varchar(29)", (e) => e.notNull()).addColumn("updated_at", "varchar(29)", (e) => e.notNull()).execute();
3983
4123
  }
3984
- async function Gs(t) {
4124
+ async function Zs(t) {
3985
4125
  await t.schema.dropTable("email_providers").execute();
3986
4126
  }
3987
- const Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4127
+ const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3988
4128
  __proto__: null,
3989
- down: Gs,
3990
- up: Ws
4129
+ down: Zs,
4130
+ up: Xs
3991
4131
  }, Symbol.toStringTag, { value: "Module" }));
3992
- async function Xs(t) {
4132
+ async function ti(t) {
3993
4133
  await t.schema.dropTable("tickets").execute();
3994
4134
  }
3995
- async function Ys(t) {
4135
+ async function ri(t) {
3996
4136
  await t.schema.createTable("tickets").addColumn(
3997
4137
  "tenant_id",
3998
4138
  "varchar(255)",
@@ -4003,22 +4143,22 @@ async function Ys(t) {
4003
4143
  (e) => e.references("applications.id").onDelete("cascade").notNull()
4004
4144
  ).addColumn("email", "varchar(255)", (e) => e.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(1024)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
4005
4145
  }
4006
- const Zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4146
+ const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4007
4147
  __proto__: null,
4008
- down: Ys,
4009
- up: Xs
4148
+ down: ri,
4149
+ up: ti
4010
4150
  }, Symbol.toStringTag, { value: "Module" }));
4011
- async function ei(t) {
4151
+ async function ni(t) {
4012
4152
  }
4013
- async function ti(t) {
4153
+ async function oi(t) {
4014
4154
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
4015
4155
  }
4016
- const ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4156
+ const si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4017
4157
  __proto__: null,
4018
- down: ti,
4019
- up: ei
4158
+ down: oi,
4159
+ up: ni
4020
4160
  }, Symbol.toStringTag, { value: "Module" }));
4021
- async function ai(t) {
4161
+ async function ii(t) {
4022
4162
  await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
4023
4163
  "client_id",
4024
4164
  "varchar(21)",
@@ -4031,27 +4171,27 @@ async function ai(t) {
4031
4171
  (e) => e.onDelete("cascade")
4032
4172
  ).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();
4033
4173
  }
4034
- async function ni(t) {
4174
+ async function li(t) {
4035
4175
  await t.schema.dropTable("refresh_tokens").execute();
4036
4176
  }
4037
- const oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4177
+ const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4038
4178
  __proto__: null,
4039
- down: ni,
4040
- up: ai
4179
+ down: li,
4180
+ up: ii
4041
4181
  }, Symbol.toStringTag, { value: "Module" }));
4042
- async function si(t) {
4182
+ async function di(t) {
4043
4183
  }
4044
- async function ii(t) {
4184
+ async function ui(t) {
4045
4185
  }
4046
- const li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4186
+ const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4047
4187
  __proto__: null,
4048
- down: ii,
4049
- up: si
4188
+ down: ui,
4189
+ up: di
4050
4190
  }, Symbol.toStringTag, { value: "Module" }));
4051
- async function ci(t) {
4191
+ async function _i(t) {
4052
4192
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
4053
4193
  }
4054
- async function di(t) {
4194
+ async function hi(t) {
4055
4195
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4056
4196
  "sessions_user_id_constraint",
4057
4197
  ["user_id", "tenant_id"],
@@ -4070,12 +4210,12 @@ async function di(t) {
4070
4210
  (e) => e.onDelete("cascade")
4071
4211
  ).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();
4072
4212
  }
4073
- const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4213
+ const fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4074
4214
  __proto__: null,
4075
- down: di,
4076
- up: ci
4215
+ down: hi,
4216
+ up: _i
4077
4217
  }, Symbol.toStringTag, { value: "Module" }));
4078
- async function mi(t) {
4218
+ async function pi(t) {
4079
4219
  await t.schema.createTable("sessions_2").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4080
4220
  "sessions_2_user_id_constraint",
4081
4221
  ["user_id", "tenant_id"],
@@ -4094,15 +4234,15 @@ async function mi(t) {
4094
4234
  (e) => e.onDelete("cascade")
4095
4235
  ).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();
4096
4236
  }
4097
- async function _i(t) {
4237
+ async function gi(t) {
4098
4238
  await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4099
4239
  }
4100
- const hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4240
+ const wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4101
4241
  __proto__: null,
4102
- down: _i,
4103
- up: mi
4242
+ down: gi,
4243
+ up: pi
4104
4244
  }, Symbol.toStringTag, { value: "Module" }));
4105
- async function fi(t) {
4245
+ async function yi(t) {
4106
4246
  await t.schema.createTable("custom_domains").addColumn(
4107
4247
  "custom_domain_id",
4108
4248
  "varchar(21)",
@@ -4113,49 +4253,49 @@ async function fi(t) {
4113
4253
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4114
4254
  ).addColumn("domain", "varchar(255)", (e) => e.notNull()).addColumn("primary", "boolean", (e) => e.notNull()).addColumn("status", "varchar(50)", (e) => e.notNull()).addColumn("type", "varchar(50)", (e) => e.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).execute(), await t.schema.dropTable("domains").execute();
4115
4255
  }
4116
- async function pi(t) {
4256
+ async function vi(t) {
4117
4257
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("domains").addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
4118
4258
  "tenant_id",
4119
4259
  "varchar(255)",
4120
4260
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4121
4261
  ).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();
4122
4262
  }
4123
- const gi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4263
+ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4124
4264
  __proto__: null,
4125
- down: pi,
4126
- up: fi
4265
+ down: vi,
4266
+ up: yi
4127
4267
  }, Symbol.toStringTag, { value: "Module" }));
4128
- async function wi(t) {
4268
+ async function Ci(t) {
4129
4269
  }
4130
- async function yi(t) {
4270
+ async function bi(t) {
4131
4271
  await t.schema.alterTable("logins").dropColumn("authParams_organization").dropColumn("authorization_url").execute();
4132
4272
  }
4133
- const vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4273
+ const xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4134
4274
  __proto__: null,
4135
- down: yi,
4136
- up: wi
4275
+ down: bi,
4276
+ up: Ci
4137
4277
  }, Symbol.toStringTag, { value: "Module" }));
4138
- async function Ni(t) {
4278
+ async function Ti(t) {
4139
4279
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(2048)").execute();
4140
4280
  }
4141
- async function Ci(t) {
4281
+ async function Si(t) {
4142
4282
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(1024)").execute();
4143
4283
  }
4144
- const bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4284
+ const Oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4145
4285
  __proto__: null,
4146
- down: Ci,
4147
- up: Ni
4286
+ down: Si,
4287
+ up: Ti
4148
4288
  }, Symbol.toStringTag, { value: "Module" }));
4149
- async function xi(t) {
4289
+ async function ki(t) {
4150
4290
  }
4151
- async function Ti(t) {
4291
+ async function $i(t) {
4152
4292
  }
4153
- const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4293
+ const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4154
4294
  __proto__: null,
4155
- down: Ti,
4156
- up: xi
4295
+ down: $i,
4296
+ up: ki
4157
4297
  }, Symbol.toStringTag, { value: "Module" }));
4158
- async function Oi(t) {
4298
+ async function Di(t) {
4159
4299
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4160
4300
  "sessions_user_id_constraint",
4161
4301
  ["user_id", "tenant_id"],
@@ -4182,25 +4322,25 @@ async function Oi(t) {
4182
4322
  (e) => e.onDelete("cascade")
4183
4323
  ).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();
4184
4324
  }
4185
- async function ki(t) {
4325
+ async function Pi(t) {
4186
4326
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
4187
4327
  }
4188
- const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4328
+ const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4189
4329
  __proto__: null,
4190
- down: ki,
4191
- up: Oi
4330
+ down: Pi,
4331
+ up: Di
4192
4332
  }, Symbol.toStringTag, { value: "Module" }));
4193
- async function Ii(t) {
4333
+ async function Fi(t) {
4194
4334
  await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4195
4335
  }
4196
- async function Di(t) {
4336
+ async function Mi(t) {
4197
4337
  }
4198
- const Pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4338
+ const Ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4199
4339
  __proto__: null,
4200
- down: Di,
4201
- up: Ii
4340
+ down: Mi,
4341
+ up: Fi
4202
4342
  }, Symbol.toStringTag, { value: "Module" }));
4203
- async function ji(t) {
4343
+ async function zi(t) {
4204
4344
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
4205
4345
  "custom_domain_id",
4206
4346
  "varchar(256)",
@@ -4211,120 +4351,120 @@ async function ji(t) {
4211
4351
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4212
4352
  ).addColumn("domain", "varchar(255)", (e) => e.notNull()).addColumn("primary", "boolean", (e) => e.notNull()).addColumn("status", "varchar(50)", (e) => e.notNull()).addColumn("type", "varchar(50)", (e) => e.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).execute();
4213
4353
  }
4214
- async function Fi(t) {
4354
+ async function Li(t) {
4215
4355
  }
4216
- const Mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4356
+ const Ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4217
4357
  __proto__: null,
4218
- down: Fi,
4219
- up: ji
4358
+ down: Li,
4359
+ up: zi
4220
4360
  }, Symbol.toStringTag, { value: "Module" }));
4221
- async function Ai(t) {
4361
+ async function Ji(t) {
4222
4362
  }
4223
- async function zi(t) {
4363
+ async function Ri(t) {
4224
4364
  await t.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
4225
4365
  }
4226
- const Li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4366
+ const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4227
4367
  __proto__: null,
4228
- down: zi,
4229
- up: Ai
4368
+ down: Ri,
4369
+ up: Ji
4230
4370
  }, Symbol.toStringTag, { value: "Module" }));
4231
- async function Ei(t) {
4371
+ async function Ui(t) {
4232
4372
  await t.schema.createTable("forms").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("tenant_id", "varchar(255)", (e) => e.notNull()).addColumn("messages", "varchar(255)").addColumn("languages", "varchar(255)").addColumn("translations", "varchar(4096)").addColumn("nodes", "varchar(4096)").addColumn("start", "varchar(255)").addColumn("ending", "varchar(255)").addColumn("style", "varchar(1042)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createIndex("forms_tenant_id_idx").on("forms").column("tenant_id").execute();
4233
4373
  }
4234
- async function Ji(t) {
4374
+ async function Bi(t) {
4235
4375
  await t.schema.dropTable("forms").execute();
4236
4376
  }
4237
- const Ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4377
+ const Qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4238
4378
  __proto__: null,
4239
- down: Ji,
4240
- up: Ei
4379
+ down: Bi,
4380
+ up: Ui
4241
4381
  }, Symbol.toStringTag, { value: "Module" }));
4242
- async function Ki(t) {
4382
+ async function qi(t) {
4243
4383
  await t.schema.alterTable("hooks").addColumn("form_id", "text").execute(), await t.schema.alterTable("hooks").addColumn("url_tmp", "varchar(512)").execute(), await t.updateTable("hooks").set((e) => ({ url_tmp: e.ref("url") })).execute(), await t.schema.alterTable("hooks").dropColumn("url").execute(), await t.schema.alterTable("hooks").renameColumn("url_tmp", "url").execute();
4244
4384
  }
4245
- async function Ui(t) {
4385
+ async function Vi(t) {
4246
4386
  await t.schema.dropTable("hooks").ifExists().execute(), await t.schema.createTable("hooks").addColumn("hook_id", "text", (e) => e.primaryKey()).addColumn("tenant_id", "text", (e) => e.notNull()).addColumn("trigger_id", "text", (e) => e.notNull()).addColumn("enabled", "integer", (e) => e.notNull().defaultTo(0)).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("synchronous", "integer", (e) => e.notNull().defaultTo(0)).addColumn("priority", "integer").addColumn("created_at", "text", (e) => e.notNull()).addColumn("updated_at", "text", (e) => e.notNull()).execute();
4247
4387
  }
4248
- const Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4388
+ const Wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4249
4389
  __proto__: null,
4250
- down: Ui,
4251
- up: Ki
4390
+ down: Vi,
4391
+ up: qi
4252
4392
  }, Symbol.toStringTag, { value: "Module" }));
4253
- async function Qi(t) {
4393
+ async function Gi(t) {
4254
4394
  await t.schema.alterTable("login_sessions").addColumn(
4255
4395
  "login_completed",
4256
4396
  "boolean",
4257
4397
  (e) => e.notNull().defaultTo(0)
4258
4398
  ).execute();
4259
4399
  }
4260
- async function qi(t) {
4400
+ async function Hi(t) {
4261
4401
  await t.schema.alterTable("login_sessions").dropColumn("login_completed").execute();
4262
4402
  }
4263
- const Vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4403
+ const Yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4264
4404
  __proto__: null,
4265
- down: qi,
4266
- up: Qi
4405
+ down: Hi,
4406
+ up: Gi
4267
4407
  }, Symbol.toStringTag, { value: "Module" }));
4268
- async function Wi(t) {
4408
+ async function Xi(t) {
4269
4409
  await t.schema.alterTable("sessions").addColumn(
4270
4410
  "login_session_id",
4271
4411
  "varchar(21)",
4272
4412
  (e) => e.references("login_sessions.id").onDelete("set null")
4273
4413
  ).execute();
4274
4414
  }
4275
- async function Gi(t) {
4415
+ async function Zi(t) {
4276
4416
  await t.schema.alterTable("sessions").dropColumn("login_session_id").execute();
4277
4417
  }
4278
- const Hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4418
+ const el = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4279
4419
  __proto__: null,
4280
- down: Gi,
4281
- up: Wi
4420
+ down: Zi,
4421
+ up: Xi
4282
4422
  }, Symbol.toStringTag, { value: "Module" }));
4283
- async function Xi(t) {
4423
+ async function tl(t) {
4284
4424
  await t.schema.createIndex("IDX_sessions_login_session_id").on("sessions").column("login_session_id").execute();
4285
4425
  }
4286
- async function Yi(t) {
4426
+ async function rl(t) {
4287
4427
  await t.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
4288
4428
  }
4289
- const Zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4429
+ const al = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4290
4430
  __proto__: null,
4291
- down: Yi,
4292
- up: Xi
4431
+ down: rl,
4432
+ up: tl
4293
4433
  }, Symbol.toStringTag, { value: "Module" }));
4294
- async function el(t) {
4434
+ async function nl(t) {
4295
4435
  await t.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await t.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
4296
4436
  }
4297
- async function tl(t) {
4437
+ async function ol(t) {
4298
4438
  await t.schema.alterTable("codes").dropColumn("code_challenge").execute(), await t.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
4299
4439
  }
4300
- const rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4440
+ const sl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4301
4441
  __proto__: null,
4302
- down: tl,
4303
- up: el
4442
+ down: ol,
4443
+ up: nl
4304
4444
  }, Symbol.toStringTag, { value: "Module" }));
4305
- async function al(t) {
4445
+ async function il(t) {
4306
4446
  await t.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
4307
4447
  }
4308
- async function nl(t) {
4448
+ async function ll(t) {
4309
4449
  await t.schema.alterTable("codes").dropColumn("redirect_uri").execute();
4310
4450
  }
4311
- const ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4451
+ const cl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4312
4452
  __proto__: null,
4313
- down: nl,
4314
- up: al
4453
+ down: ll,
4454
+ up: il
4315
4455
  }, Symbol.toStringTag, { value: "Module" }));
4316
- async function sl(t) {
4456
+ async function dl(t) {
4317
4457
  await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
4318
4458
  }
4319
- async function il(t) {
4459
+ async function ul(t) {
4320
4460
  await t.schema.alterTable("codes").dropColumn("nonce").execute(), await t.schema.alterTable("codes").dropColumn("state").execute();
4321
4461
  }
4322
- const ll = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4462
+ const ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4323
4463
  __proto__: null,
4324
- down: il,
4325
- up: sl
4464
+ down: ul,
4465
+ up: dl
4326
4466
  }, Symbol.toStringTag, { value: "Module" }));
4327
- async function cl(t) {
4467
+ async function _l(t) {
4328
4468
  await t.schema.createTable("themes").addColumn(
4329
4469
  "tenant_id",
4330
4470
  "varchar(255)",
@@ -4399,31 +4539,31 @@ async function cl(t) {
4399
4539
  (e) => e.notNull()
4400
4540
  ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("themes_pkey", ["tenant_id", "themeId"]).execute(), await t.schema.createIndex("themes_tenant_id_idx").on("themes").column("tenant_id").execute();
4401
4541
  }
4402
- async function dl(t) {
4542
+ async function hl(t) {
4403
4543
  await t.schema.dropTable("themes").execute();
4404
4544
  }
4405
- const ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4545
+ const fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4406
4546
  __proto__: null,
4407
- down: dl,
4408
- up: cl
4547
+ down: hl,
4548
+ up: _l
4409
4549
  }, Symbol.toStringTag, { value: "Module" }));
4410
- async function ml(t) {
4411
- await t.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("identifier", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("scopes", "varchar(4096)").addColumn("signing_alg", "varchar(64)").addColumn("signing_secret", "varchar(2048)").addColumn("token_lifetime", "integer").addColumn("token_lifetime_for_web", "integer").addColumn("skip_consent_for_verifiable_first_party_clients", "integer").addColumn("allow_offline_access", "integer").addColumn("verification_key", "varchar(4096)").addColumn("options", "varchar(4096)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addPrimaryKeyConstraint("resource_servers_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await t.schema.createTable("roles").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(50)", (e) => e.notNull()).addColumn("description", "varchar(255)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addPrimaryKeyConstraint("roles_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("roles_tenant_name_uq").on("roles").columns(["tenant_id", "name"]).unique().execute();
4550
+ async function pl(t) {
4551
+ await t.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("identifier", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("scopes", "varchar(4096)").addColumn("signing_alg", "varchar(64)").addColumn("signing_secret", "varchar(2048)").addColumn("token_lifetime", "integer").addColumn("token_lifetime_for_web", "integer").addColumn("skip_consent_for_verifiable_first_party_clients", "integer").addColumn("allow_offline_access", "integer").addColumn("verification_key", "varchar(4096)").addColumn("options", "varchar(4096)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("resource_servers_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await t.schema.createTable("roles").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(50)", (e) => e.notNull()).addColumn("description", "varchar(255)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("roles_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("roles_tenant_name_uq").on("roles").columns(["tenant_id", "name"]).unique().execute();
4412
4552
  }
4413
- async function _l(t) {
4553
+ async function gl(t) {
4414
4554
  await t.schema.dropTable("roles").execute(), await t.schema.dropTable("resource_servers").execute();
4415
4555
  }
4416
- const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4556
+ const wl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4417
4557
  __proto__: null,
4418
- down: _l,
4419
- up: ml
4558
+ down: gl,
4559
+ up: pl
4420
4560
  }, Symbol.toStringTag, { value: "Module" }));
4421
- async function fl(t) {
4561
+ async function yl(t) {
4422
4562
  await t.schema.createTable("role_permissions").addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("role_id", "varchar(21)", (e) => e.notNull()).addColumn(
4423
4563
  "resource_server_identifier",
4424
4564
  "varchar(191)",
4425
4565
  (e) => e.notNull()
4426
- ).addColumn("permission_name", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addPrimaryKeyConstraint("role_permissions_pk", [
4566
+ ).addColumn("permission_name", "varchar(191)", (e) => e.notNull()).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("role_permissions_pk", [
4427
4567
  "tenant_id",
4428
4568
  "role_id",
4429
4569
  "resource_server_identifier",
@@ -4432,138 +4572,165 @@ async function fl(t) {
4432
4572
  "resource_server_identifier",
4433
4573
  "varchar(191)",
4434
4574
  (e) => e.notNull()
4435
- ).addColumn("permission_name", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addPrimaryKeyConstraint("user_permissions_pk", [
4575
+ ).addColumn("permission_name", "varchar(191)", (e) => e.notNull()).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("user_permissions_pk", [
4436
4576
  "tenant_id",
4437
4577
  "user_id",
4438
4578
  "resource_server_identifier",
4439
4579
  "permission_name"
4440
4580
  ]).execute(), await t.schema.createIndex("user_permissions_user_fk").on("user_permissions").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("user_permissions_permission_fk").on("user_permissions").columns(["tenant_id", "resource_server_identifier", "permission_name"]).execute();
4441
4581
  }
4442
- async function pl(t) {
4582
+ async function vl(t) {
4443
4583
  await t.schema.dropTable("user_permissions").execute(), await t.schema.dropTable("role_permissions").execute();
4444
4584
  }
4445
- const gl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4585
+ const Nl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4446
4586
  __proto__: null,
4447
- down: pl,
4448
- up: fl
4587
+ down: vl,
4588
+ up: yl
4589
+ }, Symbol.toStringTag, { value: "Module" }));
4590
+ async function Cl(t) {
4591
+ await t.schema.createTable("user_roles").addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("user_id", "varchar(191)", (e) => e.notNull()).addColumn("role_id", "varchar(21)", (e) => e.notNull()).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("user_roles_pk", [
4592
+ "tenant_id",
4593
+ "user_id",
4594
+ "role_id"
4595
+ ]).execute(), await t.schema.createIndex("user_roles_user_fk").on("user_roles").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("user_roles_role_fk").on("user_roles").columns(["tenant_id", "role_id"]).execute();
4596
+ }
4597
+ async function bl(t) {
4598
+ await t.schema.dropTable("user_roles").execute();
4599
+ }
4600
+ const xl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4601
+ __proto__: null,
4602
+ down: bl,
4603
+ up: Cl
4604
+ }, Symbol.toStringTag, { value: "Module" }));
4605
+ async function Tl(t) {
4606
+ }
4607
+ async function Sl(t) {
4608
+ await t.schema.alterTable("keys").dropColumn("connection").execute(), await t.schema.alterTable("keys").alterColumn("cert", (e) => e.setDataType("varchar(2048)")).execute(), await t.schema.alterTable("keys").alterColumn("pkcs7", (e) => e.setDataType("varchar(2048)")).execute(), await t.schema.alterTable("keys").dropColumn("type").execute();
4609
+ }
4610
+ const Ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4611
+ __proto__: null,
4612
+ down: Sl,
4613
+ up: Tl
4449
4614
  }, Symbol.toStringTag, { value: "Module" })), Ee = {
4450
- m1_init: fa,
4451
- m2_magicLink: wa,
4452
- m3_updateAt: Na,
4453
- m4_logTable: xa,
4454
- m5_userProfile: Oa,
4455
- m6_sessions: Ia,
4456
- m7_passwords: ja,
4457
- m8_logsTableNewFields: Aa,
4458
- m9_passwordTableNewField: Ea,
4459
- n01_codesTable: Ka,
4460
- n11_universalLoginSession: Qa,
4461
- n12_userFields: Wa,
4462
- n13_userEmailIndex: Xa,
4463
- n14_profileDataField: en,
4464
- n15_userEmailIndex: an,
4465
- n16_userLocale: sn,
4466
- n17_signingKeys: dn,
4467
- n18_logsFields: _n,
4468
- n19_connectionsUserinfo: pn,
4469
- n20_missingFields: yn,
4470
- n21_sessionDeletedAt: Cn,
4471
- n22_dropLogsFields: Tn,
4472
- n23_dropUsersFields: kn,
4473
- n24_logsIndexes: Dn,
4474
- n25_logDescMaxLength: Fn,
4475
- n26_logsTableExtraFields: zn,
4476
- n27_usersTableNameIndex: Jn,
4477
- n28_usersEmailConstrain: Un,
4478
- n29_increaseOtpStateLength: qn,
4479
- n30_increaseTicketStateLength: Gn,
4480
- n31_branding: Yn,
4481
- n32_indexesAndNotNull: to,
4482
- n33_vendorIdInUniversalLoginSession: no,
4483
- n34_auth0ClientInUniversalLoginSession: io,
4484
- n35_increaseUniversalSessionStateLength: uo,
4485
- n36_authenticationCodes: ho,
4486
- n37_disableSignUps: go,
4487
- n38_otpIpAddress: vo,
4488
- n39_increaseUserAgentLength: bo,
4489
- n40_userId: So,
4490
- n41_hooks: $o,
4491
- n42_userIdIndexes: Po,
4492
- n43_userIdIndexes: Mo,
4493
- n44_codes: Lo,
4494
- n45_hookProperties: Ro,
4495
- n46_loginAuth0Client: Bo,
4496
- n47_loginAuth0Client: Vo,
4497
- n48_saml: Ho,
4498
- n49_removeFields: Zo,
4499
- n50_authParamsNonce: rs,
4500
- n51_connectionid: os,
4501
- n52_cert: ls,
4502
- n53_codes_primary_key: us,
4503
- n54_cleanup_tables: hs,
4504
- n55_logs_index: gs,
4505
- n56_application_fields: vs,
4506
- n57_prompt_settings: bs,
4507
- n58_connection_client_id: Ss,
4508
- n59_connection_options: $s,
4509
- n60_users_metadata: Ps,
4510
- n61_userLocales: Ms,
4511
- n62_prompt: Ls,
4512
- n63_connection_cleanup: Rs,
4513
- n64_act_as: Bs,
4514
- n65_code_verifier: Vs,
4515
- n66_email_providers: Hs,
4516
- n67_drop_tickets: Zs,
4517
- n68_login_useragents: ri,
4518
- n70_refresh_tokens: oi,
4519
- n71_session_new_fields: li,
4520
- n72_session_primary_key: ui,
4521
- n73_drop_sessions: hi,
4522
- n74_custom_domains: gi,
4523
- n75_organizations: vi,
4524
- n76_authorization_url_length: bi,
4525
- n77_drop_sessions: Si,
4526
- n78_login_sessions: $i,
4527
- n79_drop_sessions_2: Pi,
4528
- n80_recreate_custom_domains: Mi,
4529
- n81_phone: Li,
4530
- n82_forms: Ri,
4531
- n83_addFormsIdToHooks: Bi,
4532
- n84_login_completed: Vi,
4533
- n85_add_login_session_id_to_sessions: Hi,
4534
- n86_index_sessions_login_session_id: Zi,
4535
- n87_code_challenge: rl,
4536
- n88_add_redirect_uri_to_codes: ol,
4537
- n89_add_nonce_and_state_to_codes: ll,
4538
- n90_themes: ul,
4539
- n91_resource_servers_rules_permissions: hl,
4540
- n92_role_permissions: gl
4615
+ m1_init: ya,
4616
+ m2_magicLink: Ca,
4617
+ m3_updateAt: Ta,
4618
+ m4_logTable: ka,
4619
+ m5_userProfile: Da,
4620
+ m6_sessions: Fa,
4621
+ m7_passwords: za,
4622
+ m8_logsTableNewFields: Ja,
4623
+ m9_passwordTableNewField: Ua,
4624
+ n01_codesTable: qa,
4625
+ n11_universalLoginSession: Ga,
4626
+ n12_userFields: Xa,
4627
+ n13_userEmailIndex: tn,
4628
+ n14_profileDataField: nn,
4629
+ n15_userEmailIndex: ln,
4630
+ n16_userLocale: un,
4631
+ n17_signingKeys: hn,
4632
+ n18_logsFields: gn,
4633
+ n19_connectionsUserinfo: vn,
4634
+ n20_missingFields: bn,
4635
+ n21_sessionDeletedAt: Sn,
4636
+ n22_dropLogsFields: $n,
4637
+ n23_dropUsersFields: Pn,
4638
+ n24_logsIndexes: Mn,
4639
+ n25_logDescMaxLength: Ln,
4640
+ n26_logsTableExtraFields: Rn,
4641
+ n27_usersTableNameIndex: Bn,
4642
+ n28_usersEmailConstrain: Vn,
4643
+ n29_increaseOtpStateLength: Hn,
4644
+ n30_increaseTicketStateLength: Zn,
4645
+ n31_branding: ro,
4646
+ n32_indexesAndNotNull: oo,
4647
+ n33_vendorIdInUniversalLoginSession: lo,
4648
+ n34_auth0ClientInUniversalLoginSession: mo,
4649
+ n35_increaseUniversalSessionStateLength: fo,
4650
+ n36_authenticationCodes: wo,
4651
+ n37_disableSignUps: No,
4652
+ n38_otpIpAddress: xo,
4653
+ n39_increaseUserAgentLength: Oo,
4654
+ n40_userId: Io,
4655
+ n41_hooks: jo,
4656
+ n42_userIdIndexes: Ao,
4657
+ n43_userIdIndexes: Eo,
4658
+ n44_codes: Ko,
4659
+ n45_hookProperties: Qo,
4660
+ n46_loginAuth0Client: Wo,
4661
+ n47_loginAuth0Client: Yo,
4662
+ n48_saml: es,
4663
+ n49_removeFields: as,
4664
+ n50_authParamsNonce: ss,
4665
+ n51_connectionid: cs,
4666
+ n52_cert: ms,
4667
+ n53_codes_primary_key: fs,
4668
+ n54_cleanup_tables: ws,
4669
+ n55_logs_index: Ns,
4670
+ n56_application_fields: xs,
4671
+ n57_prompt_settings: Os,
4672
+ n58_connection_client_id: Is,
4673
+ n59_connection_options: js,
4674
+ n60_users_metadata: As,
4675
+ n61_userLocales: Es,
4676
+ n62_prompt: Ks,
4677
+ n63_connection_cleanup: Qs,
4678
+ n64_act_as: Ws,
4679
+ n65_code_verifier: Ys,
4680
+ n66_email_providers: ei,
4681
+ n67_drop_tickets: ai,
4682
+ n68_login_useragents: si,
4683
+ n70_refresh_tokens: ci,
4684
+ n71_session_new_fields: mi,
4685
+ n72_session_primary_key: fi,
4686
+ n73_drop_sessions: wi,
4687
+ n74_custom_domains: Ni,
4688
+ n75_organizations: xi,
4689
+ n76_authorization_url_length: Oi,
4690
+ n77_drop_sessions: Ii,
4691
+ n78_login_sessions: ji,
4692
+ n79_drop_sessions_2: Ai,
4693
+ n80_recreate_custom_domains: Ei,
4694
+ n81_phone: Ki,
4695
+ n82_forms: Qi,
4696
+ n83_addFormsIdToHooks: Wi,
4697
+ n84_login_completed: Yi,
4698
+ n85_add_login_session_id_to_sessions: el,
4699
+ n86_index_sessions_login_session_id: al,
4700
+ n87_code_challenge: sl,
4701
+ n88_add_redirect_uri_to_codes: cl,
4702
+ n89_add_nonce_and_state_to_codes: ml,
4703
+ n90_themes: fl,
4704
+ n91_resource_servers_rules_permissions: wl,
4705
+ n92_role_permissions: Nl,
4706
+ n93_add_permissions_to_roles: xl,
4707
+ n94_keys_connection_and_extend_columns: Ol
4541
4708
  };
4542
- async function Cl(t, e = !1) {
4709
+ async function Pl(t, e = !1) {
4543
4710
  e && console.log("migrating...");
4544
4711
  const r = new Le(Ee), a = new be({
4545
4712
  db: t,
4546
4713
  provider: r
4547
- }), { error: o, results: n } = await a.migrateToLatest();
4548
- if (n == null || n.forEach((s) => {
4714
+ }), { error: n, results: o } = await a.migrateToLatest();
4715
+ if (o == null || o.forEach((s) => {
4549
4716
  s.status === "Success" ? e && console.log(
4550
4717
  `migration "${s.migrationName}" was executed successfully`
4551
4718
  ) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
4552
- }), o)
4553
- throw console.error("failed to migrate"), console.error(o), o;
4719
+ }), n)
4720
+ throw console.error("failed to migrate"), console.error(n), n;
4554
4721
  }
4555
- async function bl(t) {
4722
+ async function jl(t) {
4556
4723
  console.log("migrating...");
4557
4724
  const e = new Le(Ee), r = new be({
4558
4725
  db: t,
4559
4726
  provider: e
4560
- }), { error: a, results: o } = await r.migrateDown();
4561
- if (o == null || o.forEach((n) => {
4562
- n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
4727
+ }), { error: a, results: n } = await r.migrateDown();
4728
+ if (n == null || n.forEach((o) => {
4729
+ o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
4563
4730
  }), a)
4564
4731
  throw console.error("failed to migrate"), console.error(a), a;
4565
4732
  }
4566
- function xl(t) {
4733
+ function Fl(t) {
4567
4734
  return {
4568
4735
  applications: jt(t),
4569
4736
  branding: er(t),
@@ -4572,7 +4739,7 @@ function xl(t) {
4572
4739
  codes: Ot(t),
4573
4740
  connections: Et(t),
4574
4741
  emailProviders: br(t),
4575
- customDomains: Xt(t),
4742
+ customDomains: Yt(t),
4576
4743
  forms: Ar(t),
4577
4744
  hooks: sr(t),
4578
4745
  keys: Bt(t),
@@ -4582,8 +4749,9 @@ function xl(t) {
4582
4749
  promptSettings: yr(t),
4583
4750
  refreshTokens: $r(t),
4584
4751
  resourceServers: Kr(t),
4585
- rolePermissions: Yr(t),
4752
+ rolePermissions: Xr(t),
4586
4753
  userPermissions: ra(t),
4754
+ userRoles: sa(t),
4587
4755
  roles: Wr(t),
4588
4756
  sessions: gt(t),
4589
4757
  tenants: st(t),
@@ -4592,7 +4760,7 @@ function xl(t) {
4592
4760
  };
4593
4761
  }
4594
4762
  export {
4595
- xl as default,
4596
- bl as migrateDown,
4597
- Cl as migrateToLatest
4763
+ Fl as default,
4764
+ jl as migrateDown,
4765
+ Pl as migrateToLatest
4598
4766
  };