@authhero/kysely-adapter 10.32.0 → 10.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,10 +2,10 @@ var Ee = Object.defineProperty;
2
2
  var ue = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var Re = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var z = (t, e, a) => Re(t, typeof e != "symbol" ? e + "" : e, a), q = (t, e, a) => e.has(t) || ue("Cannot " + a);
7
- var d = (t, e, a) => (q(t, e, "read from private field"), a ? a.call(t) : e.get(t)), b = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), L = (t, e, a, r) => (q(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), _ = (t, e, a) => (q(t, e, "access private method"), a);
8
- import { parseUserId as ae, codeSchema as Ke, connectionSchema as Be, loginSessionSchema as Ue, promptSettingSchema as Qe, formSchema as U, resourceServerSchema as qe, ruleSchema as Ve, permissionSchema as We } from "@authhero/adapter-interfaces";
5
+ var Ke = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
+ var z = (t, e, a) => Ke(t, typeof e != "symbol" ? e + "" : e, a), Q = (t, e, a) => e.has(t) || ue("Cannot " + a);
7
+ var d = (t, e, a) => (Q(t, e, "read from private field"), a ? a.call(t) : e.get(t)), b = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), L = (t, e, a, r) => (Q(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), _ = (t, e, a) => (Q(t, e, "access private method"), a);
8
+ import { parseUserId as ae, codeSchema as Re, connectionSchema as Be, loginSessionSchema as Ue, promptSettingSchema as qe, formSchema as U, resourceServerSchema as Qe, permissionSchema as Ve } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var H = class extends Error {
11
11
  constructor(e = 500, a) {
@@ -23,10 +23,10 @@ var H = class extends Error {
23
23
  });
24
24
  }
25
25
  };
26
- function Ge(t) {
26
+ function We(t) {
27
27
  return async (e, a) => {
28
- const { identities: r, ...o } = a, n = {
29
- ...o,
28
+ const { identities: r, ...n } = a, 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,16 +37,16 @@ function Ge(t) {
37
37
  user_metadata: JSON.stringify(a.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
42
  throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new H(409, { message: "User already exists" }) : new H(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
  }
@@ -75,15 +75,15 @@ function pe(t) {
75
75
  }
76
76
  };
77
77
  }
78
- function He(t) {
78
+ function Ge(t) {
79
79
  return async (e, a) => {
80
- const [r, o] = await Promise.all([
80
+ const [r, n] = await Promise.all([
81
81
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
82
82
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
83
83
  ]);
84
84
  if (!r)
85
85
  return null;
86
- const { tenant_id: n, ...s } = r, l = {
86
+ const { tenant_id: o, ...s } = r, c = {
87
87
  ...s,
88
88
  email: r.email || "",
89
89
  email_verified: r.email_verified === 1,
@@ -97,53 +97,53 @@ function He(t) {
97
97
  user_id: ae(r.user_id).id,
98
98
  isSocial: !!r.is_social
99
99
  },
100
- ...o.map(pe)
100
+ ...n.map(pe)
101
101
  ]
102
102
  };
103
- return p(l);
103
+ return p(c);
104
104
  };
105
105
  }
106
106
  function N(t, e, a, r) {
107
- return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
- let s = n.startsWith("-"), l = null, i = "", m = !1, u;
109
- if (n.startsWith("-_exists_:"))
110
- l = n.substring(10), m = !0, s = !0;
111
- else if (n.startsWith("_exists_:"))
112
- l = n.substring(9), m = !0, s = !1;
113
- else if (n.includes(":")) {
114
- const h = s ? n.substring(1) : n, y = h.indexOf(":");
115
- l = h.substring(0, y), i = h.substring(y + 1), m = !1, i.startsWith(">=") ? (u = ">=", i = i.substring(2)) : i.startsWith(">") ? (u = ">", i = i.substring(1)) : i.startsWith("<=") ? (u = "<=", i = i.substring(2)) : i.startsWith("<") ? (u = "<", i = i.substring(1)) : u = "=";
107
+ return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
108
+ let s = o.startsWith("-"), c = null, i = "", m = !1, u;
109
+ if (o.startsWith("-_exists_:"))
110
+ c = o.substring(10), m = !0, s = !0;
111
+ else if (o.startsWith("_exists_:"))
112
+ c = o.substring(9), m = !0, s = !1;
113
+ else if (o.includes(":")) {
114
+ const h = s ? o.substring(1) : o, g = h.indexOf(":");
115
+ c = h.substring(0, g), i = h.substring(g + 1), m = !1, i.startsWith(">=") ? (u = ">=", i = i.substring(2)) : i.startsWith(">") ? (u = ">", i = i.substring(1)) : i.startsWith("<=") ? (u = "<=", i = i.substring(2)) : i.startsWith("<") ? (u = "<", i = i.substring(1)) : u = "=";
116
116
  } else
117
- l = null, i = n, m = !1;
118
- return { key: l, value: i, isNegation: s, isExistsQuery: m, operator: u };
119
- }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: i, operator: m }) => {
120
- if (n)
117
+ c = null, i = o, m = !1;
118
+ return { key: c, value: i, isNegation: s, isExistsQuery: m, operator: u };
119
+ }).forEach(({ key: o, value: s, isNegation: c, isExistsQuery: i, operator: m }) => {
120
+ if (o)
121
121
  if (i)
122
- l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
123
- else if (l)
122
+ c ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
123
+ else if (c)
124
124
  switch (m) {
125
125
  case ">":
126
- e = e.where(n, "<=", s);
126
+ e = e.where(o, "<=", s);
127
127
  break;
128
128
  case ">=":
129
- e = e.where(n, "<", s);
129
+ e = e.where(o, "<", s);
130
130
  break;
131
131
  case "<":
132
- e = e.where(n, ">=", s);
132
+ e = e.where(o, ">=", s);
133
133
  break;
134
134
  case "<=":
135
- e = e.where(n, ">", s);
135
+ e = e.where(o, ">", s);
136
136
  break;
137
137
  default:
138
- e = e.where(n, "!=", s);
138
+ e = e.where(o, "!=", s);
139
139
  }
140
140
  else
141
- e = e.where(n, m, s);
141
+ e = e.where(o, m, s);
142
142
  else if (s) {
143
143
  const { ref: u } = t.dynamic;
144
144
  e = e.where(
145
145
  (h) => h.or(
146
- r.map((y) => h(u(y), "like", `%${s}%`))
146
+ r.map((g) => h(u(g), "like", `%${s}%`))
147
147
  )
148
148
  );
149
149
  }
@@ -152,7 +152,7 @@ function N(t, e, a, r) {
152
152
  function v(t) {
153
153
  return typeof t == "string" ? parseInt(t, 10) : typeof t == "bigint" ? Number(t) : t;
154
154
  }
155
- function Xe(t) {
155
+ function He(t) {
156
156
  return async (e, a = {
157
157
  page: 0,
158
158
  per_page: 50,
@@ -163,9 +163,9 @@ function Xe(t) {
163
163
  const { ref: u } = t.dynamic;
164
164
  r = r.orderBy(u(a.sort.sort_by), a.sort.sort_order);
165
165
  }
166
- const n = await r.offset(a.page * a.per_page).limit(a.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() : [], i = n.map((u) => {
167
- const h = l.filter(
168
- (y) => y.linked_to === u.user_id
166
+ const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.map((u) => u.user_id), c = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], i = o.map((u) => {
167
+ const h = c.filter(
168
+ (g) => g.linked_to === u.user_id
169
169
  );
170
170
  return p({
171
171
  ...u,
@@ -192,71 +192,71 @@ function Xe(t) {
192
192
  };
193
193
  };
194
194
  }
195
- function Ye(t) {
195
+ function Xe(t) {
196
196
  return async (e, a) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1);
197
197
  }
198
198
  function A(t, e = "", a = {}) {
199
199
  for (let r in t)
200
200
  if (Object.prototype.hasOwnProperty.call(t, r)) {
201
- const o = e ? `${e}_${r}` : r, n = t[r];
202
- typeof n == "object" && n !== null && !Array.isArray(n) ? A(n, o, a) : typeof n == "boolean" ? a[o] = n ? 1 : 0 : a[o] = n;
201
+ const n = e ? `${e}_${r}` : r, o = t[r];
202
+ typeof o == "object" && o !== null && !Array.isArray(o) ? A(o, n, a) : typeof o == "boolean" ? a[n] = o ? 1 : 0 : a[n] = o;
203
203
  }
204
204
  return a;
205
205
  }
206
206
  function ge(t, e) {
207
207
  const a = {};
208
- for (const [r, o] of Object.entries(t)) {
209
- const n = e.find(
208
+ for (const [r, n] of Object.entries(t)) {
209
+ const o = e.find(
210
210
  (s) => r.startsWith(`${s}_`)
211
211
  );
212
- if (!n)
213
- a[r] = o;
212
+ if (!o)
213
+ a[r] = n;
214
214
  else {
215
- const s = r.slice(n.length + 1);
216
- a[n] = {
217
- ...a[n],
218
- [s]: o
215
+ const s = r.slice(o.length + 1);
216
+ a[o] = {
217
+ ...a[o],
218
+ [s]: n
219
219
  };
220
220
  }
221
221
  }
222
222
  return a;
223
223
  }
224
- function Ze(t) {
224
+ function Ye(t) {
225
225
  return async (e, a, r) => {
226
- const o = A({
226
+ const n = A({
227
227
  ...r,
228
228
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
229
229
  app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
230
230
  user_metadata: r.user_metadata ? JSON.stringify(r.user_metadata) : void 0
231
231
  });
232
- return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
232
+ return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
233
233
  };
234
234
  }
235
- function et(t) {
236
- return async (e, a, r, o) => {
237
- const n = { linked_to: null };
238
- return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
235
+ function Ze(t) {
236
+ return async (e, a, r, n) => {
237
+ const o = { linked_to: null };
238
+ return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${n}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
239
239
  };
240
240
  }
241
- function tt(t) {
241
+ function et(t) {
242
242
  return {
243
- create: Ge(t),
244
- remove: Ye(t),
245
- get: He(t),
246
- list: Xe(t),
247
- update: Ze(t),
243
+ create: We(t),
244
+ remove: Xe(t),
245
+ get: Ge(t),
246
+ list: He(t),
247
+ update: Ye(t),
248
248
  // TODO - think about this more when other issues fixed
249
- unlink: et(t)
249
+ unlink: Ze(t)
250
250
  };
251
251
  }
252
- const at = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
252
+ const tt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
253
253
  let C = (t = 21) => {
254
254
  let e = "", a = crypto.getRandomValues(new Uint8Array(t));
255
255
  for (; t--; )
256
- e += at[a[t] & 63];
256
+ e += tt[a[t] & 63];
257
257
  return e;
258
258
  };
259
- function rt(t) {
259
+ function at(t) {
260
260
  return async (e) => {
261
261
  const a = {
262
262
  id: e.id || C(),
@@ -267,13 +267,13 @@ function rt(t) {
267
267
  return await t.insertInto("tenants").values(a).execute(), a;
268
268
  };
269
269
  }
270
- function nt(t) {
270
+ function rt(t) {
271
271
  return async (e) => {
272
272
  const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
273
273
  return a ? p(a) : null;
274
274
  };
275
275
  }
276
- function ot(t) {
276
+ function nt(t) {
277
277
  return async (e = {
278
278
  page: 0,
279
279
  per_page: 50,
@@ -281,25 +281,25 @@ function ot(t) {
281
281
  }) => {
282
282
  let a = t.selectFrom("tenants");
283
283
  if (e.sort && e.sort.sort_by) {
284
- const { ref: l } = t.dynamic;
285
- a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
284
+ const { ref: c } = t.dynamic;
285
+ a = a.orderBy(c(e.sort.sort_by), e.sort.sort_order);
286
286
  }
287
- e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
288
- const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
287
+ e.q && (a = a.where((c) => c.or([c("name", "like", `%${e.q}%`)])));
288
+ const n = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
289
289
  if (!e.include_totals)
290
290
  return {
291
- tenants: o
291
+ tenants: n
292
292
  };
293
- const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = v(n);
293
+ const { count: o } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = v(o);
294
294
  return {
295
- tenants: o.map(p),
295
+ tenants: n.map(p),
296
296
  start: (e.page - 1) * e.per_page,
297
297
  limit: e.per_page,
298
298
  length: s
299
299
  };
300
300
  };
301
301
  }
302
- function st(t) {
302
+ function ot(t) {
303
303
  return async (e, a) => {
304
304
  const r = {
305
305
  ...a,
@@ -309,37 +309,37 @@ function st(t) {
309
309
  await t.updateTable("tenants").set(r).where("id", "=", e).execute();
310
310
  };
311
311
  }
312
- function it(t) {
312
+ function st(t) {
313
313
  return async (e) => (await t.deleteFrom("tenants").where("tenants.id", "=", e).execute()).length === 1;
314
314
  }
315
- function lt(t) {
315
+ function it(t) {
316
316
  return {
317
- create: rt(t),
318
- get: nt(t),
319
- list: ot(t),
320
- update: st(t),
321
- remove: it(t)
317
+ create: at(t),
318
+ get: rt(t),
319
+ list: nt(t),
320
+ update: ot(t),
321
+ remove: st(t)
322
322
  };
323
323
  }
324
324
  function me(t) {
325
325
  return t ? JSON.stringify(t) : void 0;
326
326
  }
327
- const ct = 1024;
328
- function dt(t) {
327
+ const lt = 1024;
328
+ function ct(t) {
329
329
  return async (e, a) => {
330
- var o, n, s;
330
+ var n, o, s;
331
331
  const r = {
332
332
  id: C(),
333
333
  ...a,
334
- user_agent: a.user_agent.slice(0, ct)
334
+ user_agent: a.user_agent.slice(0, lt)
335
335
  };
336
336
  return await t.insertInto("logs").values({
337
337
  ...r,
338
338
  // Truncate long strings to avoid database errors
339
- description: (o = r.description) == null ? void 0 : o.substring(0, 256),
339
+ description: (n = r.description) == null ? void 0 : n.substring(0, 256),
340
340
  isMobile: a.isMobile ? 1 : 0,
341
341
  tenant_id: e,
342
- scope: (n = a.scope) == null ? void 0 : n.join(","),
342
+ scope: (o = a.scope) == null ? void 0 : o.join(","),
343
343
  auth0_client: me(a.auth0_client),
344
344
  details: (s = me(a.details)) == null ? void 0 : s.substring(0, 8192)
345
345
  }).execute(), r;
@@ -367,7 +367,7 @@ function we(t) {
367
367
  _id: t.id
368
368
  };
369
369
  }
370
- function ut(t) {
370
+ function dt(t) {
371
371
  return async (e, a = {
372
372
  page: 0,
373
373
  per_page: 50,
@@ -375,51 +375,51 @@ function ut(t) {
375
375
  }) => {
376
376
  let r = t.selectFrom("logs").where("logs.tenant_id", "=", e);
377
377
  a.q && (r = N(t, r, a.q, ["user_id", "ip"]));
378
- let o = r;
378
+ let n = r;
379
379
  if (a.sort && a.sort.sort_by) {
380
- const { ref: l } = t.dynamic;
381
- o = o.orderBy(
382
- l(a.sort.sort_by),
380
+ const { ref: c } = t.dynamic;
381
+ n = n.orderBy(
382
+ c(a.sort.sort_by),
383
383
  a.sort.sort_order
384
384
  );
385
385
  }
386
- o = o.offset(a.page * a.per_page).limit(a.per_page);
387
- const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
386
+ n = n.offset(a.page * a.per_page).limit(a.per_page);
387
+ const o = await n.selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
388
388
  return {
389
- logs: n.map(we),
389
+ logs: o.map(we),
390
390
  start: a.page * a.per_page,
391
391
  limit: a.per_page,
392
392
  length: v(s)
393
393
  };
394
394
  };
395
395
  }
396
- function mt(t) {
396
+ function ut(t) {
397
397
  return async (e, a) => {
398
398
  const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
399
399
  return r ? we(r) : null;
400
400
  };
401
401
  }
402
- function _t(t) {
402
+ function mt(t) {
403
403
  return {
404
- create: dt(t),
405
- list: ut(t),
406
- get: mt(t)
404
+ create: ct(t),
405
+ list: dt(t),
406
+ get: ut(t)
407
407
  };
408
408
  }
409
- function ht(t) {
409
+ function _t(t) {
410
410
  return async (e, a) => {
411
411
  const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
412
412
  if (!r)
413
413
  return null;
414
- const { tenant_id: o, device: n, clients: s, ...l } = r;
414
+ const { tenant_id: n, device: o, clients: s, ...c } = r;
415
415
  return {
416
- ...l,
417
- device: JSON.parse(n),
416
+ ...c,
417
+ device: JSON.parse(o),
418
418
  clients: JSON.parse(s)
419
419
  };
420
420
  };
421
421
  }
422
- function ft(t) {
422
+ function ht(t) {
423
423
  return async (e, a) => {
424
424
  const r = {
425
425
  ...a,
@@ -436,21 +436,21 @@ function ft(t) {
436
436
  }).execute(), r;
437
437
  };
438
438
  }
439
- function pt(t) {
439
+ function ft(t) {
440
440
  return async (e, a) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
441
441
  }
442
- function gt(t) {
442
+ function pt(t) {
443
443
  return async (e, a, r) => {
444
- const o = {
444
+ const n = {
445
445
  ...r,
446
446
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
447
447
  device: r.device ? JSON.stringify(r.device) : void 0,
448
448
  clients: r.clients ? JSON.stringify(r.clients) : void 0
449
449
  };
450
- return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
450
+ return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
451
451
  };
452
452
  }
453
- function wt(t) {
453
+ function gt(t) {
454
454
  return async (e, a = {
455
455
  page: 0,
456
456
  per_page: 50,
@@ -458,47 +458,47 @@ function wt(t) {
458
458
  }) => {
459
459
  let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
460
460
  a.q && (r = N(t, r, a.q, ["user_id", "session_id"]));
461
- let o = r;
461
+ let n = r;
462
462
  if (a.sort && a.sort.sort_by) {
463
463
  const { ref: i } = t.dynamic;
464
- o = o.orderBy(
464
+ n = n.orderBy(
465
465
  i(a.sort.sort_by),
466
466
  a.sort.sort_order
467
467
  );
468
468
  }
469
- o = o.offset(a.page * a.per_page).limit(a.per_page);
470
- const n = await o.selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = v(s);
469
+ n = n.offset(a.page * a.per_page).limit(a.per_page);
470
+ const o = await n.selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = v(s);
471
471
  return {
472
- sessions: n.map((i) => ({
472
+ sessions: o.map((i) => ({
473
473
  ...i,
474
474
  device: JSON.parse(i.device),
475
475
  clients: JSON.parse(i.clients)
476
476
  })),
477
477
  start: a.page * a.per_page,
478
478
  limit: a.per_page,
479
- length: l
479
+ length: c
480
480
  };
481
481
  };
482
482
  }
483
- function yt(t) {
483
+ function wt(t) {
484
484
  return {
485
- create: ft(t),
486
- get: ht(t),
487
- list: wt(t),
488
- remove: pt(t),
489
- update: gt(t)
485
+ create: ht(t),
486
+ get: _t(t),
487
+ list: gt(t),
488
+ remove: ft(t),
489
+ update: pt(t)
490
490
  };
491
491
  }
492
- function vt(t) {
492
+ function yt(t) {
493
493
  return async (e, a) => {
494
494
  const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
495
495
  if (!r)
496
496
  return null;
497
- const { tenant_id: o, ...n } = r;
498
- return n;
497
+ const { tenant_id: n, ...o } = r;
498
+ return o;
499
499
  };
500
500
  }
501
- function Nt(t) {
501
+ function vt(t) {
502
502
  return async (e, a) => {
503
503
  const r = {
504
504
  ...a,
@@ -511,20 +511,20 @@ function Nt(t) {
511
511
  }).execute(), r;
512
512
  };
513
513
  }
514
- function Ct(t) {
514
+ function Nt(t) {
515
515
  return async (e, a) => (await t.updateTable("passwords").set({
516
516
  password: a.password,
517
517
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
518
518
  }).where("tenant_id", "=", e).where("user_id", "=", a.user_id).execute()).length === 1;
519
519
  }
520
- function bt(t) {
520
+ function Ct(t) {
521
521
  return {
522
- create: Nt(t),
523
- update: Ct(t),
524
- get: vt(t)
522
+ create: vt(t),
523
+ update: Nt(t),
524
+ get: yt(t)
525
525
  };
526
526
  }
527
- function xt(t) {
527
+ function bt(t) {
528
528
  return async (e, a = {
529
529
  page: 0,
530
530
  per_page: 50,
@@ -532,11 +532,11 @@ function xt(t) {
532
532
  }) => {
533
533
  let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
534
534
  a.q && (r = N(t, r, a.q, ["code", "login_id"]));
535
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
535
+ const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
536
536
  return {
537
- codes: n.map((i) => {
537
+ codes: o.map((i) => {
538
538
  const { tenant_id: m, ...u } = i;
539
- return Ke.parse(p(u));
539
+ return Re.parse(p(u));
540
540
  }),
541
541
  start: a.page * a.per_page,
542
542
  limit: a.per_page,
@@ -544,7 +544,7 @@ function xt(t) {
544
544
  };
545
545
  };
546
546
  }
547
- function Tt(t) {
547
+ function xt(t) {
548
548
  return async (e, a) => {
549
549
  const r = {
550
550
  ...a,
@@ -556,65 +556,65 @@ function Tt(t) {
556
556
  }).execute(), r;
557
557
  };
558
558
  }
559
- function St(t) {
559
+ function Tt(t) {
560
560
  return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
561
561
  }
562
- function Ot(t) {
562
+ function St(t) {
563
563
  return async (e, a, r) => {
564
- let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
565
- e.length && (o = o.where("codes.tenant_id", "=", e));
566
- const n = await o.selectAll().executeTakeFirst();
567
- return n ? p(n) : null;
564
+ let n = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
565
+ e.length && (n = n.where("codes.tenant_id", "=", e));
566
+ const o = await n.selectAll().executeTakeFirst();
567
+ return o ? p(o) : null;
568
568
  };
569
569
  }
570
- function kt(t) {
570
+ function Ot(t) {
571
571
  return async (e, a) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numUpdatedRows > 0;
572
572
  }
573
- function $t(t) {
573
+ function kt(t) {
574
574
  return {
575
- create: Tt(t),
576
- list: xt(t),
577
- remove: St(t),
578
- used: kt(t),
579
- get: Ot(t)
575
+ create: xt(t),
576
+ list: bt(t),
577
+ remove: Tt(t),
578
+ used: Ot(t),
579
+ get: St(t)
580
580
  };
581
581
  }
582
- function Dt(t) {
582
+ function $t(t) {
583
583
  return async (e, a) => {
584
584
  const r = {
585
585
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
586
586
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
587
587
  ...a,
588
588
  disable_sign_ups: a.disable_sign_ups ?? !1
589
- }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), i = JSON.stringify(a.allowed_clients);
589
+ }, n = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), c = JSON.stringify(a.allowed_logout_urls), i = JSON.stringify(a.allowed_clients);
590
590
  return await t.insertInto("applications").values({
591
591
  ...r,
592
592
  tenant_id: e,
593
593
  disable_sign_ups: a.disable_sign_ups ? 1 : 0,
594
594
  addons: a.addons ? JSON.stringify(a.addons) : "{}",
595
- callbacks: n,
596
- allowed_origins: o,
595
+ callbacks: o,
596
+ allowed_origins: n,
597
597
  web_origins: s,
598
- allowed_logout_urls: l,
598
+ allowed_logout_urls: c,
599
599
  allowed_clients: i
600
600
  }).execute(), r;
601
601
  };
602
602
  }
603
- function It(t) {
603
+ function Dt(t) {
604
604
  return async (e) => ({
605
- applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((n) => ({
606
- ...n,
607
- disable_sign_ups: !!n.disable_sign_ups,
608
- addons: n.addons ? JSON.parse(n.addons) : {},
609
- callbacks: n.callbacks ? JSON.parse(n.callbacks) : [],
610
- allowed_origins: n.allowed_origins ? JSON.parse(n.allowed_origins) : [],
611
- web_origins: n.web_origins ? JSON.parse(n.web_origins) : [],
612
- allowed_logout_urls: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : [],
613
- allowed_clients: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : []
605
+ applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((o) => ({
606
+ ...o,
607
+ disable_sign_ups: !!o.disable_sign_ups,
608
+ addons: o.addons ? JSON.parse(o.addons) : {},
609
+ callbacks: o.callbacks ? JSON.parse(o.callbacks) : [],
610
+ allowed_origins: o.allowed_origins ? JSON.parse(o.allowed_origins) : [],
611
+ web_origins: o.web_origins ? JSON.parse(o.web_origins) : [],
612
+ allowed_logout_urls: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : [],
613
+ allowed_clients: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : []
614
614
  }))
615
615
  });
616
616
  }
617
- function jt(t) {
617
+ function It(t) {
618
618
  return async (e, a) => {
619
619
  const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
620
620
  return r ? p({
@@ -628,12 +628,12 @@ function jt(t) {
628
628
  }) : null;
629
629
  };
630
630
  }
631
- function Pt(t) {
631
+ function jt(t) {
632
632
  return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
633
633
  }
634
- function Ft(t) {
634
+ function Pt(t) {
635
635
  return async (e, a, r) => {
636
- const o = {
636
+ const n = {
637
637
  ...r,
638
638
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
639
639
  allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
@@ -644,19 +644,19 @@ function Ft(t) {
644
644
  addons: r.addons ? JSON.stringify(r.addons) : "{}",
645
645
  disable_sign_ups: r.disable_sign_ups ? 1 : 0
646
646
  };
647
- return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
647
+ return await t.updateTable("applications").set(n).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
648
648
  };
649
649
  }
650
- function Mt(t) {
650
+ function Ft(t) {
651
651
  return {
652
- create: Dt(t),
653
- list: It(t),
654
- get: jt(t),
655
- remove: Pt(t),
656
- update: Ft(t)
652
+ create: $t(t),
653
+ list: Dt(t),
654
+ get: It(t),
655
+ remove: jt(t),
656
+ update: Pt(t)
657
657
  };
658
658
  }
659
- function At(t) {
659
+ function Mt(t) {
660
660
  return async (e, a) => {
661
661
  const r = {
662
662
  id: C(),
@@ -672,7 +672,7 @@ function At(t) {
672
672
  }).execute(), r;
673
673
  };
674
674
  }
675
- function zt(t) {
675
+ function At(t) {
676
676
  return async (e, a = {
677
677
  page: 0,
678
678
  per_page: 50,
@@ -685,19 +685,19 @@ function zt(t) {
685
685
  ...i,
686
686
  options: JSON.parse(i.options)
687
687
  })
688
- ), { count: l } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
688
+ ), { count: c } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
689
689
  return {
690
690
  connections: s,
691
691
  start: a.page * a.per_page,
692
692
  limit: a.per_page,
693
- length: v(l)
693
+ length: v(c)
694
694
  };
695
695
  };
696
696
  }
697
- function Lt(t) {
697
+ function zt(t) {
698
698
  return async (e, a) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
699
699
  }
700
- function Jt(t) {
700
+ function Lt(t) {
701
701
  return async (e, a) => {
702
702
  const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
703
703
  return r ? p({
@@ -706,25 +706,25 @@ function Jt(t) {
706
706
  }) : null;
707
707
  };
708
708
  }
709
- function Et(t) {
709
+ function Jt(t) {
710
710
  return async (e, a, r) => {
711
- const o = {
711
+ const n = {
712
712
  ...r,
713
713
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
714
714
  };
715
715
  return await t.updateTable("connections").set({
716
- ...o,
717
- options: o.options ? JSON.stringify(o.options) : void 0
716
+ ...n,
717
+ options: n.options ? JSON.stringify(n.options) : void 0
718
718
  }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
719
719
  };
720
720
  }
721
- function Rt(t) {
721
+ function Et(t) {
722
722
  return {
723
- create: At(t),
724
- get: Jt(t),
725
- list: zt(t),
726
- remove: Lt(t),
727
- update: Et(t)
723
+ create: Mt(t),
724
+ get: Lt(t),
725
+ list: At(t),
726
+ remove: zt(t),
727
+ update: Jt(t)
728
728
  };
729
729
  }
730
730
  function Kt(t) {
@@ -736,10 +736,10 @@ function Kt(t) {
736
736
  const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
737
737
  if (!r)
738
738
  throw new H(404, { message: "Tenant not found" });
739
- const o = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
739
+ const n = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
740
740
  return {
741
741
  ...a,
742
- connections: o.map(
742
+ connections: n.map(
743
743
  (s) => Be.parse(
744
744
  p({
745
745
  ...s,
@@ -760,7 +760,7 @@ function Kt(t) {
760
760
  }
761
761
  };
762
762
  }
763
- function Bt(t) {
763
+ function Rt(t) {
764
764
  return async () => await t.selectFrom("keys").where(
765
765
  (a) => a.or([
766
766
  a("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
@@ -768,22 +768,22 @@ function Bt(t) {
768
768
  ])
769
769
  ).selectAll().execute();
770
770
  }
771
- function Ut(t) {
771
+ function Bt(t) {
772
772
  return async (e) => {
773
773
  await t.insertInto("keys").values({ ...e, created_at: (/* @__PURE__ */ new Date()).toDateString() }).execute();
774
774
  };
775
775
  }
776
- function Qt(t) {
776
+ function Ut(t) {
777
777
  return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
778
778
  }
779
779
  function qt(t) {
780
780
  return {
781
- create: Ut(t),
782
- list: Bt(t),
783
- update: Qt(t)
781
+ create: Bt(t),
782
+ list: Rt(t),
783
+ update: Ut(t)
784
784
  };
785
785
  }
786
- function Vt(t) {
786
+ function Qt(t) {
787
787
  return async (e, a) => {
788
788
  const r = {
789
789
  custom_domain_id: C(),
@@ -800,16 +800,16 @@ function Vt(t) {
800
800
  }).execute(), r;
801
801
  };
802
802
  }
803
- function Wt(t) {
803
+ function Vt(t) {
804
804
  return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((r) => ({
805
805
  ...r,
806
806
  primary: r.primary === 1
807
807
  }));
808
808
  }
809
- function Gt(t) {
809
+ function Wt(t) {
810
810
  return async (e, a) => (await t.deleteFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
811
811
  }
812
- function Ht(t) {
812
+ function Gt(t) {
813
813
  return async (e, a) => {
814
814
  const r = await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).selectAll().executeTakeFirst();
815
815
  return r ? {
@@ -818,17 +818,17 @@ function Ht(t) {
818
818
  } : null;
819
819
  };
820
820
  }
821
- function Xt(t) {
821
+ function Ht(t) {
822
822
  return async (e, a, r) => {
823
- const o = {
823
+ const n = {
824
824
  ...r,
825
825
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
826
826
  primary: r.primary ? 1 : 0
827
827
  };
828
- return (await t.updateTable("custom_domains").set(o).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
828
+ return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
829
829
  };
830
830
  }
831
- function Yt(t) {
831
+ function Xt(t) {
832
832
  return async (e) => {
833
833
  const a = await t.selectFrom("custom_domains").where("custom_domains.domain", "=", e).selectAll().executeTakeFirst();
834
834
  return a ? {
@@ -837,27 +837,27 @@ function Yt(t) {
837
837
  } : null;
838
838
  };
839
839
  }
840
- function Zt(t) {
840
+ function Yt(t) {
841
841
  return {
842
- create: Vt(t),
843
- get: Ht(t),
844
- getByDomain: Yt(t),
845
- list: Wt(t),
846
- remove: Gt(t),
847
- update: Xt(t)
842
+ create: Qt(t),
843
+ get: Gt(t),
844
+ getByDomain: Xt(t),
845
+ list: Vt(t),
846
+ remove: Wt(t),
847
+ update: Ht(t)
848
848
  };
849
849
  }
850
- function ea(t) {
850
+ function Zt(t) {
851
851
  return async (e) => {
852
852
  const [a] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
853
853
  if (!a)
854
854
  return null;
855
855
  const {
856
856
  tenant_id: r,
857
- colors_primary: o,
858
- colors_page_background_type: n,
857
+ colors_primary: n,
858
+ colors_page_background_type: o,
859
859
  colors_page_background_start: s,
860
- colors_page_background_end: l,
860
+ colors_page_background_end: c,
861
861
  colors_page_background_angle_dev: i,
862
862
  font_url: m,
863
863
  ...u
@@ -865,11 +865,11 @@ function ea(t) {
865
865
  return p({
866
866
  ...u,
867
867
  colors: {
868
- primary: o,
868
+ primary: n,
869
869
  page_background: {
870
- type: n,
870
+ type: o,
871
871
  start: s,
872
- end: l,
872
+ end: c,
873
873
  angle_deg: i
874
874
  }
875
875
  },
@@ -877,24 +877,24 @@ function ea(t) {
877
877
  });
878
878
  };
879
879
  }
880
- function ta(t) {
880
+ function ea(t) {
881
881
  return async (e, a) => {
882
- var s, l, i, m, u, h, y, D, I, O, re, ne, oe, se, ie, le, ce, de;
883
- const { colors: r, font: o, ...n } = a;
882
+ var s, c, i, m, u, h, g, D, I, O, re, ne, oe, se, ie, le, ce, de;
883
+ const { colors: r, font: n, ...o } = a;
884
884
  try {
885
885
  await t.insertInto("branding").values({
886
- ...n,
886
+ ...o,
887
887
  colors_primary: r == null ? void 0 : r.primary,
888
- colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
888
+ colors_page_background_type: (c = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
889
889
  colors_page_background_start: (m = (i = a.colors) == null ? void 0 : i.page_background) == null ? void 0 : m.start,
890
890
  colors_page_background_end: (h = (u = a.colors) == null ? void 0 : u.page_background) == null ? void 0 : h.end,
891
- colors_page_background_angle_dev: (D = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : D.angle_deg,
891
+ colors_page_background_angle_dev: (D = (g = a.colors) == null ? void 0 : g.page_background) == null ? void 0 : D.angle_deg,
892
892
  font_url: (I = a.font) == null ? void 0 : I.url,
893
893
  tenant_id: e
894
894
  }).execute();
895
895
  } catch {
896
896
  await t.updateTable("branding").set({
897
- ...n,
897
+ ...o,
898
898
  colors_primary: r == null ? void 0 : r.primary,
899
899
  colors_page_background_type: (re = (O = a.colors) == null ? void 0 : O.page_background) == null ? void 0 : re.type,
900
900
  colors_page_background_start: (oe = (ne = a.colors) == null ? void 0 : ne.page_background) == null ? void 0 : oe.start,
@@ -905,13 +905,13 @@ function ta(t) {
905
905
  }
906
906
  };
907
907
  }
908
- function aa(t) {
908
+ function ta(t) {
909
909
  return {
910
- get: ea(t),
911
- set: ta(t)
910
+ get: Zt(t),
911
+ set: ea(t)
912
912
  };
913
913
  }
914
- function ra(t) {
914
+ function aa(t) {
915
915
  return async (e, a = {
916
916
  page: 0,
917
917
  per_page: 50,
@@ -919,12 +919,12 @@ function ra(t) {
919
919
  }) => {
920
920
  let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
921
921
  a.q && (r = N(t, r, a.q, ["url", "form_id"]));
922
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
922
+ const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
923
923
  return {
924
- hooks: n.map((i) => {
925
- const { tenant_id: m, enabled: u, synchronous: h, ...y } = i;
924
+ hooks: o.map((i) => {
925
+ const { tenant_id: m, enabled: u, synchronous: h, ...g } = i;
926
926
  return p({
927
- ...y,
927
+ ...g,
928
928
  enabled: !!u,
929
929
  synchronous: !!h
930
930
  });
@@ -935,7 +935,7 @@ function ra(t) {
935
935
  };
936
936
  };
937
937
  }
938
- function na(t) {
938
+ function ra(t) {
939
939
  return async (e, a) => {
940
940
  const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
941
941
  return r ? p({
@@ -945,10 +945,10 @@ function na(t) {
945
945
  }) : null;
946
946
  };
947
947
  }
948
- function oa(t) {
948
+ function na(t) {
949
949
  return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
950
950
  }
951
- function sa(t) {
951
+ function oa(t) {
952
952
  return async (e, a) => {
953
953
  const r = {
954
954
  hook_id: C(),
@@ -964,49 +964,49 @@ function sa(t) {
964
964
  }).execute(), r;
965
965
  };
966
966
  }
967
- function ia(t) {
967
+ function sa(t) {
968
968
  return async (e, a, r) => {
969
- const o = {
969
+ const n = {
970
970
  ...r,
971
971
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
972
972
  enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
973
973
  synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
974
974
  };
975
- return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
975
+ return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
976
976
  };
977
977
  }
978
- function la(t) {
978
+ function ia(t) {
979
979
  return {
980
- create: sa(t),
981
- get: na(t),
982
- list: ra(t),
983
- update: ia(t),
984
- remove: oa(t)
980
+ create: oa(t),
981
+ get: ra(t),
982
+ list: aa(t),
983
+ update: sa(t),
984
+ remove: na(t)
985
985
  };
986
986
  }
987
- function ca(t) {
987
+ function la(t) {
988
988
  return async (e, a) => {
989
989
  const r = {
990
990
  themeId: C(),
991
991
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
992
992
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
993
993
  ...a
994
- }, o = {
994
+ }, n = {
995
995
  ...r,
996
996
  tenant_id: e
997
997
  };
998
- return await t.insertInto("themes").values(A(o)).execute(), r;
998
+ return await t.insertInto("themes").values(A(n)).execute(), r;
999
999
  };
1000
1000
  }
1001
- function da(t) {
1001
+ function ca(t) {
1002
1002
  return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.themeId", "=", a).executeTakeFirst()).numDeletedRows > 0;
1003
1003
  }
1004
- function ua(t) {
1004
+ function da(t) {
1005
1005
  return async (e, a) => {
1006
1006
  const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.themeId", "=", a).selectAll().executeTakeFirst();
1007
1007
  if (!r)
1008
1008
  return null;
1009
- const o = {
1009
+ const n = {
1010
1010
  ...r,
1011
1011
  borders_show_widget_shadow: !!r.borders_show_widget_shadow,
1012
1012
  fonts_body_text_bold: !!r.fonts_body_text_bold,
@@ -1017,7 +1017,7 @@ function ua(t) {
1017
1017
  fonts_title_bold: !!r.fonts_title_bold
1018
1018
  };
1019
1019
  return p(
1020
- ge(o, [
1020
+ ge(n, [
1021
1021
  "widget",
1022
1022
  "colors",
1023
1023
  "borders",
@@ -1027,24 +1027,24 @@ function ua(t) {
1027
1027
  );
1028
1028
  };
1029
1029
  }
1030
- function ma(t) {
1030
+ function ua(t) {
1031
1031
  return async (e, a, r) => {
1032
- const o = A({
1032
+ const n = A({
1033
1033
  ...r,
1034
1034
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1035
1035
  });
1036
- return await t.updateTable("themes").set(o).where("themes.themeId", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1036
+ return await t.updateTable("themes").set(n).where("themes.themeId", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1037
1037
  };
1038
1038
  }
1039
- function _a(t) {
1039
+ function ma(t) {
1040
1040
  return {
1041
- create: ca(t),
1042
- get: ua(t),
1043
- remove: da(t),
1044
- update: ma(t)
1041
+ create: la(t),
1042
+ get: da(t),
1043
+ remove: ca(t),
1044
+ update: ua(t)
1045
1045
  };
1046
1046
  }
1047
- function ha(t) {
1047
+ function _a(t) {
1048
1048
  return async (e, a) => {
1049
1049
  const r = await t.selectFrom("login_sessions").where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1050
1050
  return r ? Ue.parse(
@@ -1058,13 +1058,13 @@ function ha(t) {
1058
1058
  ) : null;
1059
1059
  };
1060
1060
  }
1061
- function fa(t) {
1061
+ function ha(t) {
1062
1062
  return async (e, a) => {
1063
- var o;
1063
+ var n;
1064
1064
  const r = {
1065
1065
  id: C(),
1066
1066
  ...a,
1067
- authorization_url: (o = a.authorization_url) == null ? void 0 : o.slice(0, 1024),
1067
+ authorization_url: (n = a.authorization_url) == null ? void 0 : n.slice(0, 1024),
1068
1068
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1069
1069
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1070
1070
  login_completed: !!a.login_completed
@@ -1075,25 +1075,25 @@ function fa(t) {
1075
1075
  }).execute(), r;
1076
1076
  };
1077
1077
  }
1078
- function pa(t) {
1078
+ function fa(t) {
1079
1079
  return async (e, a, r) => (await t.updateTable("login_sessions").set(
1080
1080
  A({
1081
1081
  ...r
1082
1082
  })
1083
1083
  ).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
1084
1084
  }
1085
- function ga(t) {
1085
+ function pa(t) {
1086
1086
  return async (e, a) => (await t.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", e).where("login_sessions.id", "=", a).execute()).length > 0;
1087
1087
  }
1088
- function wa(t) {
1088
+ function ga(t) {
1089
1089
  return {
1090
- create: fa(t),
1091
- get: ha(t),
1092
- update: pa(t),
1093
- remove: ga(t)
1090
+ create: ha(t),
1091
+ get: _a(t),
1092
+ update: fa(t),
1093
+ remove: pa(t)
1094
1094
  };
1095
1095
  }
1096
- function ya(t) {
1096
+ function wa(t) {
1097
1097
  return async (e) => {
1098
1098
  const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1099
1099
  return p({
@@ -1113,10 +1113,10 @@ function he(t) {
1113
1113
  universal_login_experience: t.universal_login_experience
1114
1114
  });
1115
1115
  }
1116
- function va(t) {
1116
+ function ya(t) {
1117
1117
  return async (e, a) => {
1118
1118
  try {
1119
- const r = Qe.parse(a);
1119
+ const r = qe.parse(a);
1120
1120
  await t.insertInto("prompt_settings").values({
1121
1121
  ...he(r),
1122
1122
  tenant_id: e
@@ -1126,65 +1126,65 @@ function va(t) {
1126
1126
  }
1127
1127
  };
1128
1128
  }
1129
- function Na(t) {
1129
+ function va(t) {
1130
1130
  return {
1131
- get: ya(t),
1132
- set: va(t)
1131
+ get: wa(t),
1132
+ set: ya(t)
1133
1133
  };
1134
1134
  }
1135
- function Ca(t) {
1135
+ function Na(t) {
1136
1136
  return async (e) => {
1137
1137
  const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1138
1138
  if (!a)
1139
1139
  return null;
1140
1140
  const {
1141
1141
  tenant_id: r,
1142
- credentials: o,
1143
- settings: n,
1142
+ credentials: n,
1143
+ settings: o,
1144
1144
  enabled: s,
1145
- ...l
1145
+ ...c
1146
1146
  } = a;
1147
1147
  return p({
1148
- ...l,
1149
- credentials: JSON.parse(o),
1150
- settings: JSON.parse(n),
1148
+ ...c,
1149
+ credentials: JSON.parse(n),
1150
+ settings: JSON.parse(o),
1151
1151
  enabled: !!s
1152
1152
  });
1153
1153
  };
1154
1154
  }
1155
- function ba(t) {
1155
+ function Ca(t) {
1156
1156
  return async (e, a) => {
1157
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1157
+ const { credentials: r, settings: n, enabled: o, ...s } = a;
1158
1158
  await t.updateTable("email_providers").set({
1159
1159
  ...s,
1160
1160
  credentials: r ? JSON.stringify(r) : void 0,
1161
- settings: o ? JSON.stringify(o) : void 0,
1162
- enabled: n !== void 0 ? n ? 1 : 0 : void 0
1161
+ settings: n ? JSON.stringify(n) : void 0,
1162
+ enabled: o !== void 0 ? o ? 1 : 0 : void 0
1163
1163
  }).where("tenant_id", "=", e).execute();
1164
1164
  };
1165
1165
  }
1166
- function xa(t) {
1166
+ function ba(t) {
1167
1167
  return async (e, a) => {
1168
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1168
+ const { credentials: r, settings: n, enabled: o, ...s } = a;
1169
1169
  await t.insertInto("email_providers").values({
1170
1170
  ...s,
1171
- enabled: n ? 1 : 0,
1171
+ enabled: o ? 1 : 0,
1172
1172
  credentials: JSON.stringify(r),
1173
- settings: JSON.stringify(o),
1173
+ settings: JSON.stringify(n),
1174
1174
  tenant_id: e,
1175
1175
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1176
1176
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1177
1177
  }).execute();
1178
1178
  };
1179
1179
  }
1180
- function Ta(t) {
1180
+ function xa(t) {
1181
1181
  return {
1182
- get: Ca(t),
1183
- create: xa(t),
1184
- update: ba(t)
1182
+ get: Na(t),
1183
+ create: ba(t),
1184
+ update: Ca(t)
1185
1185
  };
1186
1186
  }
1187
- function Sa(t) {
1187
+ function Ta(t) {
1188
1188
  return async (e, a) => {
1189
1189
  const r = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", a).selectAll().executeTakeFirst();
1190
1190
  return r ? {
@@ -1195,7 +1195,7 @@ function Sa(t) {
1195
1195
  } : null;
1196
1196
  };
1197
1197
  }
1198
- function Oa(t) {
1198
+ function Sa(t) {
1199
1199
  return async (e, a) => {
1200
1200
  const r = {
1201
1201
  ...a,
@@ -1210,21 +1210,21 @@ function Oa(t) {
1210
1210
  }).execute(), { ...a, ...r };
1211
1211
  };
1212
1212
  }
1213
- function ka(t) {
1213
+ function Oa(t) {
1214
1214
  return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1215
1215
  }
1216
- function $a(t) {
1216
+ function ka(t) {
1217
1217
  return async (e, a, r) => {
1218
- const o = {
1218
+ const n = {
1219
1219
  ...r,
1220
1220
  device: r.device ? JSON.stringify(r.device) : void 0,
1221
1221
  resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
1222
1222
  rotating: r.rotating ? 1 : 0
1223
1223
  };
1224
- return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1224
+ return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1225
1225
  };
1226
1226
  }
1227
- function Da(t) {
1227
+ function $a(t) {
1228
1228
  return async (e, a = {
1229
1229
  page: 0,
1230
1230
  per_page: 50,
@@ -1232,18 +1232,18 @@ function Da(t) {
1232
1232
  }) => {
1233
1233
  let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1234
1234
  a.q && (r = N(t, r, a.q, ["token", "session_id"]));
1235
- let o = r;
1235
+ let n = r;
1236
1236
  if (a.sort && a.sort.sort_by) {
1237
1237
  const { ref: i } = t.dynamic;
1238
- o = o.orderBy(
1238
+ n = n.orderBy(
1239
1239
  i(a.sort.sort_by),
1240
1240
  a.sort.sort_order
1241
1241
  );
1242
1242
  }
1243
- o = o.offset(a.page * a.per_page).limit(a.per_page);
1244
- const n = await o.selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = v(s);
1243
+ n = n.offset(a.page * a.per_page).limit(a.per_page);
1244
+ const o = await n.selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = v(s);
1245
1245
  return {
1246
- refresh_tokens: n.map((i) => ({
1246
+ refresh_tokens: o.map((i) => ({
1247
1247
  ...i,
1248
1248
  rotating: !!i.rotating,
1249
1249
  device: i.device ? JSON.parse(i.device) : {},
@@ -1251,20 +1251,20 @@ function Da(t) {
1251
1251
  })),
1252
1252
  start: a.page * a.per_page,
1253
1253
  limit: a.per_page,
1254
- length: l
1254
+ length: c
1255
1255
  };
1256
1256
  };
1257
1257
  }
1258
- function Ia(t) {
1258
+ function Da(t) {
1259
1259
  return {
1260
- create: Oa(t),
1261
- get: Sa(t),
1262
- list: Da(t),
1263
- remove: ka(t),
1264
- update: $a(t)
1260
+ create: Sa(t),
1261
+ get: Ta(t),
1262
+ list: $a(t),
1263
+ remove: Oa(t),
1264
+ update: ka(t)
1265
1265
  };
1266
1266
  }
1267
- function ja(t) {
1267
+ function Ia(t) {
1268
1268
  return async () => {
1269
1269
  const e = new Date(Date.now() - 864e5).toISOString(), a = new Date(
1270
1270
  Date.now() - 1e3 * 60 * 60 * 24 * 7
@@ -1272,29 +1272,29 @@ function ja(t) {
1272
1272
  Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
1273
1273
  ).toISOString();
1274
1274
  console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", r).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where(
1275
- (n) => n.or([
1276
- n("expires_at", "<", a),
1277
- n("idle_expires_at", "<", a)
1275
+ (o) => o.or([
1276
+ o("expires_at", "<", a),
1277
+ o("idle_expires_at", "<", a)
1278
1278
  ])
1279
1279
  ).limit(1e4).execute(), console.log("delete sessions");
1280
- const o = await t.selectFrom("sessions").select("id").where(
1281
- (n) => n.or([
1282
- n("expires_at", "<", a),
1283
- n("idle_expires_at", "<", a)
1280
+ const n = await t.selectFrom("sessions").select("id").where(
1281
+ (o) => o.or([
1282
+ o("expires_at", "<", a),
1283
+ o("idle_expires_at", "<", a)
1284
1284
  ])
1285
1285
  ).where(
1286
1286
  "id",
1287
1287
  "not in",
1288
1288
  t.selectFrom("refresh_tokens").select("session_id")
1289
1289
  ).limit(1e5).execute();
1290
- o.length > 0 && await t.deleteFrom("sessions").where(
1290
+ n.length > 0 && await t.deleteFrom("sessions").where(
1291
1291
  "id",
1292
1292
  "in",
1293
- o.map((n) => n.id)
1293
+ n.map((o) => o.id)
1294
1294
  ).execute(), console.log("cleanup complete");
1295
1295
  };
1296
1296
  }
1297
- function Pa(t) {
1297
+ function ja(t) {
1298
1298
  return async (e, a) => {
1299
1299
  const r = U.parse({
1300
1300
  id: C(),
@@ -1312,7 +1312,7 @@ function Pa(t) {
1312
1312
  }).execute(), U.parse(r);
1313
1313
  };
1314
1314
  }
1315
- function Fa(t) {
1315
+ function Pa(t) {
1316
1316
  return async (e, a = {
1317
1317
  page: 0,
1318
1318
  per_page: 50,
@@ -1338,119 +1338,123 @@ function Fa(t) {
1338
1338
  } catch {
1339
1339
  }
1340
1340
  return U.parse(p(m));
1341
- }), { count: l } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1341
+ }), { count: c } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1342
1342
  return {
1343
1343
  forms: s,
1344
1344
  start: a.page * a.per_page,
1345
1345
  limit: a.per_page,
1346
- length: v(l)
1346
+ length: v(c)
1347
1347
  };
1348
1348
  };
1349
1349
  }
1350
- function Ma(t) {
1350
+ function Fa(t) {
1351
1351
  return async (e, a) => {
1352
1352
  const { numDeletedRows: r } = await t.deleteFrom("forms").where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1353
1353
  return r > 0;
1354
1354
  };
1355
1355
  }
1356
- function Aa(t) {
1356
+ function Ma(t) {
1357
1357
  return async (e, a) => {
1358
1358
  const r = await t.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1359
1359
  if (!r) return null;
1360
- const o = { ...r };
1361
- if (typeof o.nodes == "string")
1360
+ const n = { ...r };
1361
+ if (typeof n.nodes == "string")
1362
1362
  try {
1363
- o.nodes = JSON.parse(o.nodes);
1363
+ n.nodes = JSON.parse(n.nodes);
1364
1364
  } catch {
1365
1365
  }
1366
- if (typeof o.start == "string")
1366
+ if (typeof n.start == "string")
1367
1367
  try {
1368
- o.start = JSON.parse(o.start);
1368
+ n.start = JSON.parse(n.start);
1369
1369
  } catch {
1370
1370
  }
1371
- if (typeof o.ending == "string")
1371
+ if (typeof n.ending == "string")
1372
1372
  try {
1373
- o.ending = JSON.parse(o.ending);
1373
+ n.ending = JSON.parse(n.ending);
1374
1374
  } catch {
1375
1375
  }
1376
- return U.parse(p(o));
1376
+ return U.parse(p(n));
1377
1377
  };
1378
1378
  }
1379
- function za(t) {
1379
+ function Aa(t) {
1380
1380
  return async (e, a, r) => {
1381
- const o = {
1381
+ const n = {
1382
1382
  ...r,
1383
1383
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1384
1384
  };
1385
- r.nodes && (o.nodes = JSON.stringify(r.nodes)), r.start && (o.start = JSON.stringify(r.start)), r.ending && (o.ending = JSON.stringify(r.ending));
1386
- const { numUpdatedRows: n } = await t.updateTable("forms").set(o).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1387
- return n > 0;
1385
+ r.nodes && (n.nodes = JSON.stringify(r.nodes)), r.start && (n.start = JSON.stringify(r.start)), r.ending && (n.ending = JSON.stringify(r.ending));
1386
+ const { numUpdatedRows: o } = await t.updateTable("forms").set(n).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1387
+ return o > 0;
1388
1388
  };
1389
1389
  }
1390
- function La(t) {
1390
+ function za(t) {
1391
1391
  return {
1392
- create: Pa(t),
1393
- get: Aa(t),
1394
- list: Fa(t),
1395
- remove: Ma(t),
1396
- update: za(t)
1392
+ create: ja(t),
1393
+ get: Ma(t),
1394
+ list: Pa(t),
1395
+ remove: Fa(t),
1396
+ update: Aa(t)
1397
1397
  };
1398
1398
  }
1399
- function Ja(t) {
1399
+ function La(t) {
1400
1400
  return async (e, a) => {
1401
- const r = {
1401
+ const r = (/* @__PURE__ */ new Date()).toISOString(), n = {
1402
1402
  id: C(),
1403
- ...a
1404
- }, o = qe.parse(r), {
1405
- verificationKey: n,
1406
- scopes: s,
1407
- options: l,
1408
- skip_consent_for_verifiable_first_party_clients: i,
1409
- allow_offline_access: m,
1410
- ...u
1411
- } = o, h = {
1412
- ...u,
1403
+ ...a,
1404
+ created_at: r,
1405
+ updated_at: r
1406
+ }, o = Qe.parse(n), {
1407
+ verificationKey: s,
1408
+ scopes: c,
1409
+ options: i,
1410
+ skip_consent_for_verifiable_first_party_clients: m,
1411
+ allow_offline_access: u,
1412
+ ...h
1413
+ } = o, g = {
1414
+ ...h,
1413
1415
  tenant_id: e,
1414
- scopes: s ? JSON.stringify(s) : "[]",
1415
- options: l ? JSON.stringify(l) : "{}",
1416
- skip_consent_for_verifiable_first_party_clients: i ? 1 : 0,
1417
- allow_offline_access: m ? 1 : 0,
1418
- verification_key: n
1419
- };
1420
- return await t.insertInto("resource_servers").values(h).execute(), o;
1416
+ scopes: c ? JSON.stringify(c) : "[]",
1417
+ options: i ? JSON.stringify(i) : "{}",
1418
+ skip_consent_for_verifiable_first_party_clients: m ? 1 : 0,
1419
+ allow_offline_access: u ? 1 : 0,
1420
+ verification_key: s,
1421
+ created_at: r,
1422
+ updated_at: r
1423
+ };
1424
+ return await t.insertInto("resource_servers").values(g).execute(), o;
1421
1425
  };
1422
1426
  }
1423
- function Ea(t) {
1427
+ function Ja(t) {
1424
1428
  return async (e, a) => {
1425
1429
  const r = await t.selectFrom("resource_servers").selectAll().where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1426
1430
  if (!r) return null;
1427
- const o = r, {
1428
- verification_key: n,
1431
+ const n = r, {
1432
+ verification_key: o,
1429
1433
  scopes: s,
1430
- options: l,
1434
+ options: c,
1431
1435
  skip_consent_for_verifiable_first_party_clients: i,
1432
1436
  allow_offline_access: m,
1433
1437
  ...u
1434
- } = o;
1438
+ } = n;
1435
1439
  return {
1436
1440
  ...u,
1437
1441
  scopes: s ? JSON.parse(s) : [],
1438
- options: l ? JSON.parse(l) : {},
1442
+ options: c ? JSON.parse(c) : {},
1439
1443
  skip_consent_for_verifiable_first_party_clients: !!i,
1440
1444
  allow_offline_access: !!m,
1441
1445
  // Convert verification_key back to verificationKey for API
1442
- verificationKey: n
1446
+ verificationKey: o
1443
1447
  };
1444
1448
  };
1445
1449
  }
1446
- function Ra(t) {
1450
+ function Ea(t) {
1447
1451
  return async (e, a = { page: 0, per_page: 50, include_totals: !1 }) => {
1448
1452
  let r = t.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", e);
1449
1453
  if (a.q) {
1450
- const i = a.q.trim(), m = i.split(/\s+/), u = m.length === 1 ? m[0] : void 0, h = u ? u.match(/^(-)?(name|identifier):(.*)$/) : null, y = h ? h[3] : "", D = /^(>=|>|<=|<)/.test(y || "");
1454
+ const i = a.q.trim(), m = i.split(/\s+/), u = m.length === 1 ? m[0] : void 0, h = u ? u.match(/^(-)?(name|identifier):(.*)$/) : null, g = h ? h[3] : "", D = /^(>=|>|<=|<)/.test(g || "");
1451
1455
  if (h && !D) {
1452
1456
  const I = !!h[1], O = h[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
1453
- r = I ? r.where(O, "not like", `%${y}%`) : r.where(O, "like", `%${y}%`);
1457
+ r = I ? r.where(O, "not like", `%${g}%`) : r.where(O, "like", `%${g}%`);
1454
1458
  } else
1455
1459
  r = N(t, r, i, [
1456
1460
  "resource_servers.name",
@@ -1461,7 +1465,7 @@ function Ra(t) {
1461
1465
  const m = i, {
1462
1466
  verification_key: u,
1463
1467
  scopes: h,
1464
- options: y,
1468
+ options: g,
1465
1469
  skip_consent_for_verifiable_first_party_clients: D,
1466
1470
  allow_offline_access: I,
1467
1471
  ...O
@@ -1469,18 +1473,18 @@ function Ra(t) {
1469
1473
  return {
1470
1474
  ...O,
1471
1475
  scopes: h ? JSON.parse(h) : [],
1472
- options: y ? JSON.parse(y) : {},
1476
+ options: g ? JSON.parse(g) : {},
1473
1477
  skip_consent_for_verifiable_first_party_clients: !!D,
1474
1478
  allow_offline_access: !!I,
1475
1479
  // Convert verification_key back to verificationKey for API
1476
1480
  verificationKey: u
1477
1481
  };
1478
- }), { count: l } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1482
+ }), { count: c } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1479
1483
  return {
1480
1484
  resource_servers: s,
1481
1485
  start: a.page * a.per_page,
1482
1486
  limit: a.per_page,
1483
- length: v(l)
1487
+ length: v(c)
1484
1488
  };
1485
1489
  };
1486
1490
  }
@@ -1490,227 +1494,236 @@ function Ka(t) {
1490
1494
  return Number(r.numDeletedRows) > 0;
1491
1495
  };
1492
1496
  }
1493
- function Ba(t) {
1497
+ function Ra(t) {
1494
1498
  return async (e, a, r) => {
1495
1499
  const {
1496
- verificationKey: o,
1497
- scopes: n,
1500
+ verificationKey: n,
1501
+ scopes: o,
1498
1502
  options: s,
1499
- skip_consent_for_verifiable_first_party_clients: l,
1503
+ skip_consent_for_verifiable_first_party_clients: c,
1500
1504
  allow_offline_access: i,
1501
1505
  ...m
1502
- } = r, u = { ...m };
1503
- 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), i !== void 0 && (u.allow_offline_access = i ? 1 : 0);
1506
+ } = r, u = {
1507
+ ...m,
1508
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1509
+ };
1510
+ n !== void 0 && (u.verification_key = n), o !== void 0 && (u.scopes = JSON.stringify(o)), s !== void 0 && (u.options = JSON.stringify(s)), c !== void 0 && (u.skip_consent_for_verifiable_first_party_clients = c ? 1 : 0), i !== void 0 && (u.allow_offline_access = i ? 1 : 0);
1504
1511
  const h = await t.updateTable("resource_servers").set(u).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1505
1512
  return Number(h.numUpdatedRows) > 0;
1506
1513
  };
1507
1514
  }
1508
- function Ua(t) {
1515
+ function Ba(t) {
1509
1516
  return {
1510
- create: Ja(t),
1511
- get: Ea(t),
1512
- list: Ra(t),
1517
+ create: La(t),
1518
+ get: Ja(t),
1519
+ list: Ea(t),
1513
1520
  remove: Ka(t),
1514
- update: Ba(t)
1521
+ update: Ra(t)
1515
1522
  };
1516
1523
  }
1517
- function Qa(t) {
1524
+ function Ua(t) {
1518
1525
  return async (e, a) => {
1519
- const r = { id: C(), ...a }, o = Ve.parse(r), { enabled: n, ...s } = o, l = {
1520
- ...s,
1526
+ const r = C(), n = (/* @__PURE__ */ new Date()).toISOString(), o = { id: r, ...a }, s = Ve.parse(o), { sources: c, ...i } = s, m = {
1527
+ id: r,
1528
+ ...i,
1521
1529
  tenant_id: e,
1522
- enabled: n ? 1 : 0
1530
+ sources: c ? JSON.stringify(c) : "[]",
1531
+ created_at: n,
1532
+ updated_at: n
1533
+ };
1534
+ return await t.insertInto("permissions").values(m).execute(), {
1535
+ ...s,
1536
+ created_at: n,
1537
+ updated_at: n
1523
1538
  };
1524
- return await t.insertInto("rules").values(l).execute(), o;
1525
1539
  };
1526
1540
  }
1527
1541
  function qa(t) {
1528
1542
  return async (e, a) => {
1529
- const r = await t.selectFrom("rules").selectAll().where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1543
+ const r = await t.selectFrom("permissions").selectAll().where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1530
1544
  if (!r) return null;
1531
- const o = r, { enabled: n, ...s } = o;
1545
+ const n = r, { sources: o, ...s } = n;
1532
1546
  return {
1533
1547
  ...s,
1534
- enabled: !!n
1548
+ sources: o ? JSON.parse(o) : []
1535
1549
  };
1536
1550
  };
1537
1551
  }
1538
- function Va(t) {
1552
+ function Qa(t) {
1539
1553
  return async (e, a = { page: 0, per_page: 50, include_totals: !1 }) => {
1540
- let r = t.selectFrom("rules").where("rules.tenant_id", "=", e);
1541
- a.q && (r = N(t, r, a.q, ["name", "stage"]));
1554
+ let r = t.selectFrom("permissions").where("permissions.tenant_id", "=", e);
1555
+ a.q && (r = N(t, r, a.q, [
1556
+ "permission_name",
1557
+ "resource_server_identifier",
1558
+ "resource_server_name"
1559
+ ]));
1542
1560
  const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((i) => {
1543
- const m = i, { enabled: u, ...h } = m;
1561
+ const m = i, { sources: u, ...h } = m;
1544
1562
  return {
1545
1563
  ...h,
1546
- enabled: !!u
1564
+ sources: u ? JSON.parse(u) : []
1547
1565
  };
1548
- }), { count: l } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1566
+ }), { count: c } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1549
1567
  return {
1550
- rules: s,
1568
+ permissions: s,
1551
1569
  start: a.page * a.per_page,
1552
1570
  limit: a.per_page,
1553
- length: v(l)
1571
+ length: v(c)
1554
1572
  };
1555
1573
  };
1556
1574
  }
1575
+ function Va(t) {
1576
+ return async (e, a, r) => {
1577
+ const { sources: n, ...o } = r, s = {
1578
+ ...o,
1579
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1580
+ };
1581
+ n !== void 0 && (s.sources = JSON.stringify(n));
1582
+ const c = await t.updateTable("permissions").set(s).where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1583
+ return Number(c.numUpdatedRows) > 0;
1584
+ };
1585
+ }
1557
1586
  function Wa(t) {
1558
1587
  return async (e, a) => {
1559
- const r = await t.deleteFrom("rules").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1588
+ const r = await t.deleteFrom("permissions").where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1560
1589
  return Number(r.numDeletedRows) > 0;
1561
1590
  };
1562
1591
  }
1563
1592
  function Ga(t) {
1564
- return async (e, a, r) => {
1565
- const { enabled: o, ...n } = r, s = { ...n };
1566
- o !== void 0 && (s.enabled = o ? 1 : 0);
1567
- const l = await t.updateTable("rules").set(s).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1568
- return Number(l.numUpdatedRows) > 0;
1569
- };
1570
- }
1571
- function Ha(t) {
1572
1593
  return {
1573
- create: Qa(t),
1594
+ create: Ua(t),
1574
1595
  get: qa(t),
1575
- list: Va(t),
1576
- remove: Wa(t),
1577
- update: Ga(t)
1596
+ list: Qa(t),
1597
+ update: Va(t),
1598
+ remove: Wa(t)
1578
1599
  };
1579
1600
  }
1580
- function Xa(t) {
1601
+ function Ha(t) {
1581
1602
  return async (e, a) => {
1582
- const r = C(), o = { id: r, ...a }, n = We.parse(o), { sources: s, ...l } = n, i = {
1603
+ const r = C(), n = (/* @__PURE__ */ new Date()).toISOString(), o = {
1583
1604
  id: r,
1584
- ...l,
1605
+ ...a,
1585
1606
  tenant_id: e,
1586
- sources: s ? JSON.stringify(s) : "[]"
1607
+ created_at: n,
1608
+ updated_at: n
1609
+ };
1610
+ return await t.insertInto("roles").values(o).execute(), {
1611
+ id: r,
1612
+ ...a,
1613
+ created_at: n,
1614
+ updated_at: n
1587
1615
  };
1588
- return await t.insertInto("permissions").values(i).execute(), n;
1589
1616
  };
1590
1617
  }
1591
- function Ya(t) {
1618
+ function Xa(t) {
1592
1619
  return async (e, a) => {
1593
- const r = await t.selectFrom("permissions").selectAll().where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1594
- if (!r) return null;
1595
- const o = r, { sources: n, ...s } = o;
1596
- return {
1597
- ...s,
1598
- sources: n ? JSON.parse(n) : []
1599
- };
1620
+ const r = await t.selectFrom("roles").selectAll().where("roles.tenant_id", "=", e).where("roles.id", "=", a).executeTakeFirst();
1621
+ return r || null;
1600
1622
  };
1601
1623
  }
1602
- function Za(t) {
1624
+ function Ya(t) {
1603
1625
  return async (e, a = { page: 0, per_page: 50, include_totals: !1 }) => {
1604
- let r = t.selectFrom("permissions").where("permissions.tenant_id", "=", e);
1605
- a.q && (r = N(t, r, a.q, [
1606
- "permission_name",
1607
- "resource_server_identifier",
1608
- "resource_server_name"
1609
- ]));
1610
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((i) => {
1611
- const m = i, { sources: u, ...h } = m;
1612
- return {
1613
- ...h,
1614
- sources: u ? JSON.parse(u) : []
1615
- };
1616
- }), { count: l } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1626
+ let r = t.selectFrom("roles").where("roles.tenant_id", "=", e);
1627
+ a.q && (r = N(t, r, a.q, ["name"]));
1628
+ const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((i) => i), { count: c } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1617
1629
  return {
1618
- permissions: s,
1630
+ roles: s,
1619
1631
  start: a.page * a.per_page,
1620
1632
  limit: a.per_page,
1621
- length: v(l)
1633
+ length: v(c)
1622
1634
  };
1623
1635
  };
1624
1636
  }
1625
- function er(t) {
1637
+ function Za(t) {
1626
1638
  return async (e, a, r) => {
1627
- const { sources: o, ...n } = r, s = { ...n };
1628
- o !== void 0 && (s.sources = JSON.stringify(o));
1629
- const l = await t.updateTable("permissions").set(s).where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1630
- return Number(l.numUpdatedRows) > 0;
1639
+ const n = {
1640
+ ...r,
1641
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1642
+ }, o = await t.updateTable("roles").set(n).where("roles.tenant_id", "=", e).where("roles.id", "=", a).executeTakeFirst();
1643
+ return Number(o.numUpdatedRows) > 0;
1631
1644
  };
1632
1645
  }
1633
- function tr(t) {
1646
+ function er(t) {
1634
1647
  return async (e, a) => {
1635
- const r = await t.deleteFrom("permissions").where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1648
+ const r = await t.deleteFrom("roles").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1636
1649
  return Number(r.numDeletedRows) > 0;
1637
1650
  };
1638
1651
  }
1639
- function ar(t) {
1652
+ function tr(t) {
1640
1653
  return {
1641
- create: Xa(t),
1642
- get: Ya(t),
1643
- list: Za(t),
1644
- update: er(t),
1645
- remove: tr(t)
1654
+ create: Ha(t),
1655
+ get: Xa(t),
1656
+ list: Ya(t),
1657
+ update: Za(t),
1658
+ remove: er(t)
1646
1659
  };
1647
1660
  }
1648
- function rr(t) {
1661
+ function ar(t) {
1649
1662
  return t[t.length - 1];
1650
1663
  }
1651
- function w(t) {
1664
+ function y(t) {
1652
1665
  return Object.freeze(t);
1653
1666
  }
1654
- const B = w({
1667
+ const B = y({
1655
1668
  is(t) {
1656
1669
  return t.kind === "IdentifierNode";
1657
1670
  },
1658
1671
  create(t) {
1659
- return w({
1672
+ return y({
1660
1673
  kind: "IdentifierNode",
1661
1674
  name: t
1662
1675
  });
1663
1676
  }
1664
- }), X = w({
1677
+ }), X = y({
1665
1678
  is(t) {
1666
1679
  return t.kind === "SchemableIdentifierNode";
1667
1680
  },
1668
1681
  create(t) {
1669
- return w({
1682
+ return y({
1670
1683
  kind: "SchemableIdentifierNode",
1671
1684
  identifier: B.create(t)
1672
1685
  });
1673
1686
  },
1674
1687
  createWithSchema(t, e) {
1675
- return w({
1688
+ return y({
1676
1689
  kind: "SchemableIdentifierNode",
1677
1690
  schema: B.create(t),
1678
1691
  identifier: B.create(e)
1679
1692
  });
1680
1693
  }
1681
- }), nr = w({
1694
+ }), rr = y({
1682
1695
  is(t) {
1683
1696
  return t.kind === "AliasNode";
1684
1697
  },
1685
1698
  create(t, e) {
1686
- return w({
1699
+ return y({
1687
1700
  kind: "AliasNode",
1688
1701
  node: t,
1689
1702
  alias: e
1690
1703
  });
1691
1704
  }
1692
- }), V = w({
1705
+ }), V = y({
1693
1706
  is(t) {
1694
1707
  return t.kind === "TableNode";
1695
1708
  },
1696
1709
  create(t) {
1697
- return w({
1710
+ return y({
1698
1711
  kind: "TableNode",
1699
1712
  table: X.create(t)
1700
1713
  });
1701
1714
  },
1702
1715
  createWithSchema(t, e) {
1703
- return w({
1716
+ return y({
1704
1717
  kind: "TableNode",
1705
1718
  table: X.createWithSchema(t, e)
1706
1719
  });
1707
1720
  }
1708
1721
  });
1709
- var Q;
1710
- class or {
1722
+ var q;
1723
+ class nr {
1711
1724
  constructor() {
1712
1725
  z(this, "nodeStack", []);
1713
- b(this, Q, w({
1726
+ b(this, q, y({
1714
1727
  AliasNode: this.transformAlias.bind(this),
1715
1728
  ColumnNode: this.transformColumn.bind(this),
1716
1729
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -1811,13 +1824,13 @@ class or {
1811
1824
  return e;
1812
1825
  this.nodeStack.push(e);
1813
1826
  const a = this.transformNodeImpl(e);
1814
- return this.nodeStack.pop(), w(a);
1827
+ return this.nodeStack.pop(), y(a);
1815
1828
  }
1816
1829
  transformNodeImpl(e) {
1817
- return d(this, Q)[e.kind](e);
1830
+ return d(this, q)[e.kind](e);
1818
1831
  }
1819
1832
  transformNodeList(e) {
1820
- return e && w(e.map((a) => this.transformNode(a)));
1833
+ return e && y(e.map((a) => this.transformNode(a)));
1821
1834
  }
1822
1835
  transformSelectQuery(e) {
1823
1836
  return {
@@ -1916,7 +1929,7 @@ class or {
1916
1929
  transformRaw(e) {
1917
1930
  return {
1918
1931
  kind: "RawNode",
1919
- sqlFragments: w([...e.sqlFragments]),
1932
+ sqlFragments: y([...e.sqlFragments]),
1920
1933
  parameters: this.transformNodeList(e.parameters)
1921
1934
  };
1922
1935
  }
@@ -2540,8 +2553,8 @@ class or {
2540
2553
  return e;
2541
2554
  }
2542
2555
  }
2543
- Q = new WeakMap();
2544
- const sr = w({
2556
+ q = new WeakMap();
2557
+ const or = y({
2545
2558
  AlterTableNode: !0,
2546
2559
  CreateIndexNode: !0,
2547
2560
  CreateSchemaNode: !0,
@@ -2560,31 +2573,31 @@ const sr = w({
2560
2573
  UpdateQueryNode: !0,
2561
2574
  MergeQueryNode: !0
2562
2575
  });
2563
- var M, k, $, g, ye, ve, Ne, j, Y, Ce;
2564
- class ir extends or {
2576
+ var M, k, $, w, ye, ve, Ne, j, Y, Ce;
2577
+ class sr extends nr {
2565
2578
  constructor(a) {
2566
2579
  super();
2567
- b(this, g);
2580
+ b(this, w);
2568
2581
  b(this, M);
2569
2582
  b(this, k, /* @__PURE__ */ new Set());
2570
2583
  b(this, $, /* @__PURE__ */ new Set());
2571
2584
  L(this, M, a);
2572
2585
  }
2573
2586
  transformNodeImpl(a) {
2574
- if (!_(this, g, ye).call(this, a))
2587
+ if (!_(this, w, ye).call(this, a))
2575
2588
  return super.transformNodeImpl(a);
2576
- const r = _(this, g, Ne).call(this, a);
2589
+ const r = _(this, w, Ne).call(this, a);
2577
2590
  for (const s of r)
2578
2591
  d(this, $).add(s);
2579
- const o = _(this, g, ve).call(this, a);
2580
- for (const s of o)
2592
+ const n = _(this, w, ve).call(this, a);
2593
+ for (const s of n)
2581
2594
  d(this, k).add(s);
2582
- const n = super.transformNodeImpl(a);
2583
- for (const s of o)
2595
+ const o = super.transformNodeImpl(a);
2596
+ for (const s of n)
2584
2597
  d(this, k).delete(s);
2585
2598
  for (const s of r)
2586
2599
  d(this, $).delete(s);
2587
- return n;
2600
+ return o;
2588
2601
  }
2589
2602
  transformSchemableIdentifier(a) {
2590
2603
  const r = super.transformSchemableIdentifier(a);
@@ -2601,47 +2614,47 @@ class ir extends or {
2601
2614
  };
2602
2615
  }
2603
2616
  }
2604
- M = new WeakMap(), k = new WeakMap(), $ = new WeakMap(), g = new WeakSet(), ye = function(a) {
2605
- return a.kind in sr;
2617
+ M = new WeakMap(), k = new WeakMap(), $ = new WeakMap(), w = new WeakSet(), ye = function(a) {
2618
+ return a.kind in or;
2606
2619
  }, ve = function(a) {
2607
2620
  const r = /* @__PURE__ */ new Set();
2608
- if ("name" in a && a.name && X.is(a.name) && _(this, g, Y).call(this, a.name, r), "from" in a && a.from)
2609
- for (const o of a.from.froms)
2610
- _(this, g, j).call(this, o, r);
2611
- if ("into" in a && a.into && _(this, g, j).call(this, a.into, r), "table" in a && a.table && _(this, g, j).call(this, a.table, r), "joins" in a && a.joins)
2612
- for (const o of a.joins)
2613
- _(this, g, j).call(this, o.table, r);
2614
- return "using" in a && a.using && _(this, g, j).call(this, a.using, r), r;
2621
+ if ("name" in a && a.name && X.is(a.name) && _(this, w, Y).call(this, a.name, r), "from" in a && a.from)
2622
+ for (const n of a.from.froms)
2623
+ _(this, w, j).call(this, n, r);
2624
+ if ("into" in a && a.into && _(this, w, j).call(this, a.into, r), "table" in a && a.table && _(this, w, j).call(this, a.table, r), "joins" in a && a.joins)
2625
+ for (const n of a.joins)
2626
+ _(this, w, j).call(this, n.table, r);
2627
+ return "using" in a && a.using && _(this, w, j).call(this, a.using, r), r;
2615
2628
  }, Ne = function(a) {
2616
2629
  const r = /* @__PURE__ */ new Set();
2617
- return "with" in a && a.with && _(this, g, Ce).call(this, a.with, r), r;
2630
+ return "with" in a && a.with && _(this, w, Ce).call(this, a.with, r), r;
2618
2631
  }, j = function(a, r) {
2619
- const o = V.is(a) ? a : nr.is(a) && V.is(a.node) ? a.node : null;
2620
- o && _(this, g, Y).call(this, o.table, r);
2632
+ const n = V.is(a) ? a : rr.is(a) && V.is(a.node) ? a.node : null;
2633
+ n && _(this, w, Y).call(this, n.table, r);
2621
2634
  }, Y = function(a, r) {
2622
- const o = a.identifier.name;
2623
- !d(this, k).has(o) && !d(this, $).has(o) && r.add(o);
2635
+ const n = a.identifier.name;
2636
+ !d(this, k).has(n) && !d(this, $).has(n) && r.add(n);
2624
2637
  }, Ce = function(a, r) {
2625
- for (const o of a.expressions) {
2626
- const n = o.name.table.table.identifier.name;
2627
- d(this, $).has(n) || r.add(n);
2638
+ for (const n of a.expressions) {
2639
+ const o = n.name.table.table.identifier.name;
2640
+ d(this, $).has(o) || r.add(o);
2628
2641
  }
2629
2642
  };
2630
- var R;
2631
- class lr {
2643
+ var K;
2644
+ class ir {
2632
2645
  constructor(e) {
2633
- b(this, R);
2634
- L(this, R, new ir(e));
2646
+ b(this, K);
2647
+ L(this, K, new sr(e));
2635
2648
  }
2636
2649
  transformQuery(e) {
2637
- return d(this, R).transformNode(e.node);
2650
+ return d(this, K).transformNode(e.node);
2638
2651
  }
2639
2652
  async transformResult(e) {
2640
2653
  return e.result;
2641
2654
  }
2642
2655
  }
2643
- R = new WeakMap();
2644
- class cr {
2656
+ K = new WeakMap();
2657
+ class lr {
2645
2658
  transformQuery(e) {
2646
2659
  return e.node;
2647
2660
  }
@@ -2649,13 +2662,13 @@ class cr {
2649
2662
  return e.result;
2650
2663
  }
2651
2664
  }
2652
- const dr = "kysely_migration", fe = "kysely_migration_lock", ur = !1, W = "migration_lock", mr = w({ __noMigrations__: !0 });
2653
- var f, c, J, x, T, P, xe, S, Te, Se, Oe, ke, $e, Z, F, ee, De, Ie, je, te, Pe, Fe, Me, Ae, ze, E;
2665
+ const cr = "kysely_migration", fe = "kysely_migration_lock", dr = !1, W = "migration_lock", ur = y({ __noMigrations__: !0 });
2666
+ var f, l, J, x, T, P, xe, S, Te, Se, Oe, ke, $e, Z, F, ee, De, Ie, je, te, Pe, Fe, Me, Ae, ze, E;
2654
2667
  class be {
2655
2668
  constructor(e) {
2656
- b(this, c);
2669
+ b(this, l);
2657
2670
  b(this, f);
2658
- L(this, f, w(e));
2671
+ L(this, f, y(e));
2659
2672
  }
2660
2673
  /**
2661
2674
  * Returns a {@link MigrationInfo} object for each migration.
@@ -2663,13 +2676,13 @@ class be {
2663
2676
  * The returned array is sorted by migration name.
2664
2677
  */
2665
2678
  async getMigrations() {
2666
- const e = await _(this, c, F).call(this, d(this, c, T)) ? await d(this, f).db.withPlugin(d(this, c, S)).selectFrom(d(this, c, T)).select(["name", "timestamp"]).execute() : [];
2667
- return (await _(this, c, te).call(this)).map(({ name: r, ...o }) => {
2668
- const n = e.find((s) => s.name === r);
2679
+ const e = await _(this, l, F).call(this, d(this, l, T)) ? await d(this, f).db.withPlugin(d(this, l, S)).selectFrom(d(this, l, T)).select(["name", "timestamp"]).execute() : [];
2680
+ return (await _(this, l, te).call(this)).map(({ name: r, ...n }) => {
2681
+ const o = e.find((s) => s.name === r);
2669
2682
  return {
2670
2683
  name: r,
2671
- migration: o,
2672
- executedAt: n ? new Date(n.timestamp) : void 0
2684
+ migration: n,
2685
+ executedAt: o ? new Date(o.timestamp) : void 0
2673
2686
  };
2674
2687
  });
2675
2688
  }
@@ -2721,7 +2734,7 @@ class be {
2721
2734
  * ```
2722
2735
  */
2723
2736
  async migrateToLatest() {
2724
- return _(this, c, J).call(this, () => ({ direction: "Up", step: 1 / 0 }));
2737
+ return _(this, l, J).call(this, () => ({ direction: "Up", step: 1 / 0 }));
2725
2738
  }
2726
2739
  /**
2727
2740
  * Migrate up/down to a specific migration.
@@ -2747,16 +2760,16 @@ class be {
2747
2760
  * ```
2748
2761
  */
2749
2762
  async migrateTo(e) {
2750
- return _(this, c, J).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2751
- if (e === mr)
2763
+ return _(this, l, J).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: n }) => {
2764
+ if (e === ur)
2752
2765
  return { direction: "Down", step: 1 / 0 };
2753
- if (!a.find((l) => l.name === e))
2766
+ if (!a.find((c) => c.name === e))
2754
2767
  throw new Error(`migration "${e}" doesn't exist`);
2755
- const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2756
- if (n !== -1)
2768
+ const o = r.indexOf(e), s = n.findIndex((c) => c.name === e);
2769
+ if (o !== -1)
2757
2770
  return {
2758
2771
  direction: "Down",
2759
- step: r.length - n - 1
2772
+ step: r.length - o - 1
2760
2773
  };
2761
2774
  if (s !== -1)
2762
2775
  return { direction: "Up", step: s + 1 };
@@ -2778,7 +2791,7 @@ class be {
2778
2791
  * ```
2779
2792
  */
2780
2793
  async migrateUp() {
2781
- return _(this, c, J).call(this, () => ({ direction: "Up", step: 1 }));
2794
+ return _(this, l, J).call(this, () => ({ direction: "Up", step: 1 }));
2782
2795
  }
2783
2796
  /**
2784
2797
  * Migrate one step down.
@@ -2795,95 +2808,95 @@ class be {
2795
2808
  * ```
2796
2809
  */
2797
2810
  async migrateDown() {
2798
- return _(this, c, J).call(this, () => ({ direction: "Down", step: 1 }));
2811
+ return _(this, l, J).call(this, () => ({ direction: "Down", step: 1 }));
2799
2812
  }
2800
2813
  }
2801
- f = new WeakMap(), c = new WeakSet(), J = async function(e) {
2814
+ f = new WeakMap(), l = new WeakSet(), J = async function(e) {
2802
2815
  try {
2803
- return await _(this, c, Te).call(this), await _(this, c, De).call(this, e);
2816
+ return await _(this, l, Te).call(this), await _(this, l, De).call(this, e);
2804
2817
  } catch (a) {
2805
2818
  return a instanceof G ? a.resultSet : { error: a };
2806
2819
  }
2807
2820
  }, x = function() {
2808
2821
  return d(this, f).migrationTableSchema;
2809
2822
  }, T = function() {
2810
- return d(this, f).migrationTableName ?? dr;
2823
+ return d(this, f).migrationTableName ?? cr;
2811
2824
  }, P = function() {
2812
2825
  return d(this, f).migrationLockTableName ?? fe;
2813
2826
  }, xe = function() {
2814
- return d(this, f).allowUnorderedMigrations ?? ur;
2827
+ return d(this, f).allowUnorderedMigrations ?? dr;
2815
2828
  }, S = function() {
2816
- return d(this, c, x) ? new lr(d(this, c, x)) : new cr();
2829
+ return d(this, l, x) ? new ir(d(this, l, x)) : new lr();
2817
2830
  }, Te = async function() {
2818
- await _(this, c, Se).call(this), await _(this, c, Oe).call(this), await _(this, c, ke).call(this), await _(this, c, $e).call(this);
2831
+ await _(this, l, Se).call(this), await _(this, l, Oe).call(this), await _(this, l, ke).call(this), await _(this, l, $e).call(this);
2819
2832
  }, Se = async function() {
2820
- if (d(this, c, x) && !await _(this, c, Z).call(this))
2833
+ if (d(this, l, x) && !await _(this, l, Z).call(this))
2821
2834
  try {
2822
- await _(this, c, E).call(this, d(this, f).db.schema.createSchema(d(this, c, x)));
2835
+ await _(this, l, E).call(this, d(this, f).db.schema.createSchema(d(this, l, x)));
2823
2836
  } catch (e) {
2824
- if (!await _(this, c, Z).call(this))
2837
+ if (!await _(this, l, Z).call(this))
2825
2838
  throw e;
2826
2839
  }
2827
2840
  }, Oe = async function() {
2828
- if (!await _(this, c, F).call(this, d(this, c, T)))
2841
+ if (!await _(this, l, F).call(this, d(this, l, T)))
2829
2842
  try {
2830
- d(this, c, x) && await _(this, c, E).call(this, d(this, f).db.schema.createSchema(d(this, c, x))), await _(this, c, E).call(this, d(this, f).db.schema.withPlugin(d(this, c, S)).createTable(d(this, c, T)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2843
+ d(this, l, x) && await _(this, l, E).call(this, d(this, f).db.schema.createSchema(d(this, l, x))), await _(this, l, E).call(this, d(this, f).db.schema.withPlugin(d(this, l, S)).createTable(d(this, l, T)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2831
2844
  } catch (e) {
2832
- if (!await _(this, c, F).call(this, d(this, c, T)))
2845
+ if (!await _(this, l, F).call(this, d(this, l, T)))
2833
2846
  throw e;
2834
2847
  }
2835
2848
  }, ke = async function() {
2836
- if (!await _(this, c, F).call(this, d(this, c, P)))
2849
+ if (!await _(this, l, F).call(this, d(this, l, P)))
2837
2850
  try {
2838
- await _(this, c, E).call(this, d(this, f).db.schema.withPlugin(d(this, c, S)).createTable(d(this, c, P)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2851
+ await _(this, l, E).call(this, d(this, f).db.schema.withPlugin(d(this, l, S)).createTable(d(this, l, P)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2839
2852
  } catch (e) {
2840
- if (!await _(this, c, F).call(this, d(this, c, P)))
2853
+ if (!await _(this, l, F).call(this, d(this, l, P)))
2841
2854
  throw e;
2842
2855
  }
2843
2856
  }, $e = async function() {
2844
- if (!await _(this, c, ee).call(this))
2857
+ if (!await _(this, l, ee).call(this))
2845
2858
  try {
2846
- await d(this, f).db.withPlugin(d(this, c, S)).insertInto(d(this, c, P)).values({ id: W, is_locked: 0 }).execute();
2859
+ await d(this, f).db.withPlugin(d(this, l, S)).insertInto(d(this, l, P)).values({ id: W, is_locked: 0 }).execute();
2847
2860
  } catch (e) {
2848
- if (!await _(this, c, ee).call(this))
2861
+ if (!await _(this, l, ee).call(this))
2849
2862
  throw e;
2850
2863
  }
2851
2864
  }, Z = async function() {
2852
- return (await d(this, f).db.introspection.getSchemas()).some((a) => a.name === d(this, c, x));
2865
+ return (await d(this, f).db.introspection.getSchemas()).some((a) => a.name === d(this, l, x));
2853
2866
  }, F = async function(e) {
2854
- const a = d(this, c, x);
2867
+ const a = d(this, l, x);
2855
2868
  return (await d(this, f).db.introspection.getTables({
2856
2869
  withInternalKyselyTables: !0
2857
- })).some((o) => o.name === e && (!a || o.schema === a));
2870
+ })).some((n) => n.name === e && (!a || n.schema === a));
2858
2871
  }, ee = async function() {
2859
- return !!await d(this, f).db.withPlugin(d(this, c, S)).selectFrom(d(this, c, P)).where("id", "=", W).select("id").executeTakeFirst();
2872
+ return !!await d(this, f).db.withPlugin(d(this, l, S)).selectFrom(d(this, l, P)).where("id", "=", W).select("id").executeTakeFirst();
2860
2873
  }, De = async function(e) {
2861
- const a = d(this, f).db.getExecutor().adapter, r = w({
2874
+ const a = d(this, f).db.getExecutor().adapter, r = y({
2862
2875
  lockTable: d(this, f).migrationLockTableName ?? fe,
2863
2876
  lockRowId: W,
2864
2877
  lockTableSchema: d(this, f).migrationTableSchema
2865
- }), o = async (n) => {
2878
+ }), n = async (o) => {
2866
2879
  try {
2867
- await a.acquireMigrationLock(n, r);
2868
- const s = await _(this, c, Ie).call(this, n);
2880
+ await a.acquireMigrationLock(o, r);
2881
+ const s = await _(this, l, Ie).call(this, o);
2869
2882
  if (s.migrations.length === 0)
2870
2883
  return { results: [] };
2871
- const { direction: l, step: i } = e(s);
2872
- return i <= 0 ? { results: [] } : l === "Down" ? await _(this, c, Ae).call(this, n, s, i) : l === "Up" ? await _(this, c, ze).call(this, n, s, i) : { results: [] };
2884
+ const { direction: c, step: i } = e(s);
2885
+ return i <= 0 ? { results: [] } : c === "Down" ? await _(this, l, Ae).call(this, o, s, i) : c === "Up" ? await _(this, l, ze).call(this, o, s, i) : { results: [] };
2873
2886
  } finally {
2874
- await a.releaseMigrationLock(n, r);
2887
+ await a.releaseMigrationLock(o, r);
2875
2888
  }
2876
2889
  };
2877
- return a.supportsTransactionalDdl ? d(this, f).db.transaction().execute(o) : d(this, f).db.connection().execute(o);
2890
+ return a.supportsTransactionalDdl ? d(this, f).db.transaction().execute(n) : d(this, f).db.connection().execute(n);
2878
2891
  }, Ie = async function(e) {
2879
- const a = await _(this, c, te).call(this), r = await _(this, c, Pe).call(this, e);
2880
- _(this, c, Fe).call(this, a, r), d(this, c, xe) || _(this, c, Me).call(this, a, r);
2881
- const o = _(this, c, je).call(this, a, r);
2882
- return w({
2892
+ const a = await _(this, l, te).call(this), r = await _(this, l, Pe).call(this, e);
2893
+ _(this, l, Fe).call(this, a, r), d(this, l, xe) || _(this, l, Me).call(this, a, r);
2894
+ const n = _(this, l, je).call(this, a, r);
2895
+ return y({
2883
2896
  migrations: a,
2884
2897
  executedMigrations: r,
2885
- lastMigration: rr(r),
2886
- pendingMigrations: o
2898
+ lastMigration: ar(r),
2899
+ pendingMigrations: n
2887
2900
  });
2888
2901
  }, je = function(e, a) {
2889
2902
  return e.filter((r) => !a.includes(r.name));
@@ -2894,85 +2907,85 @@ f = new WeakMap(), c = new WeakSet(), J = async function(e) {
2894
2907
  name: a
2895
2908
  }));
2896
2909
  }, Pe = async function(e) {
2897
- return (await e.withPlugin(d(this, c, S)).selectFrom(d(this, c, T)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2910
+ return (await e.withPlugin(d(this, l, S)).selectFrom(d(this, l, T)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2898
2911
  }, Fe = function(e, a) {
2899
2912
  for (const r of a)
2900
- if (!e.some((o) => o.name === r))
2913
+ if (!e.some((n) => n.name === r))
2901
2914
  throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2902
2915
  }, Me = function(e, a) {
2903
2916
  for (let r = 0; r < a.length; ++r)
2904
2917
  if (e[r].name !== a[r])
2905
2918
  throw new Error(`corrupted migrations: expected previously executed migration ${a[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2906
2919
  }, Ae = async function(e, a, r) {
2907
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2920
+ const n = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((c) => c.name === s)), o = n.map((s) => ({
2908
2921
  migrationName: s.name,
2909
2922
  direction: "Down",
2910
2923
  status: "NotExecuted"
2911
2924
  }));
2912
- for (let s = 0; s < n.length; ++s) {
2913
- const l = o[s];
2925
+ for (let s = 0; s < o.length; ++s) {
2926
+ const c = n[s];
2914
2927
  try {
2915
- l.down && (await l.down(e), await e.withPlugin(d(this, c, S)).deleteFrom(d(this, c, T)).where("name", "=", l.name).execute(), n[s] = {
2916
- migrationName: l.name,
2928
+ c.down && (await c.down(e), await e.withPlugin(d(this, l, S)).deleteFrom(d(this, l, T)).where("name", "=", c.name).execute(), o[s] = {
2929
+ migrationName: c.name,
2917
2930
  direction: "Down",
2918
2931
  status: "Success"
2919
2932
  });
2920
2933
  } catch (i) {
2921
- throw n[s] = {
2922
- migrationName: l.name,
2934
+ throw o[s] = {
2935
+ migrationName: c.name,
2923
2936
  direction: "Down",
2924
2937
  status: "Error"
2925
2938
  }, new G({
2926
2939
  error: i,
2927
- results: n
2940
+ results: o
2928
2941
  });
2929
2942
  }
2930
2943
  }
2931
- return { results: n };
2944
+ return { results: o };
2932
2945
  }, ze = async function(e, a, r) {
2933
- const n = a.pendingMigrations.slice(0, r).map((s) => ({
2946
+ const o = a.pendingMigrations.slice(0, r).map((s) => ({
2934
2947
  migrationName: s.name,
2935
2948
  direction: "Up",
2936
2949
  status: "NotExecuted"
2937
2950
  }));
2938
- for (let s = 0; s < n.length; s++) {
2939
- const l = a.pendingMigrations[s];
2951
+ for (let s = 0; s < o.length; s++) {
2952
+ const c = a.pendingMigrations[s];
2940
2953
  try {
2941
- await l.up(e), await e.withPlugin(d(this, c, S)).insertInto(d(this, c, T)).values({
2942
- name: l.name,
2954
+ await c.up(e), await e.withPlugin(d(this, l, S)).insertInto(d(this, l, T)).values({
2955
+ name: c.name,
2943
2956
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2944
- }).execute(), n[s] = {
2945
- migrationName: l.name,
2957
+ }).execute(), o[s] = {
2958
+ migrationName: c.name,
2946
2959
  direction: "Up",
2947
2960
  status: "Success"
2948
2961
  };
2949
2962
  } catch (i) {
2950
- throw n[s] = {
2951
- migrationName: l.name,
2963
+ throw o[s] = {
2964
+ migrationName: c.name,
2952
2965
  direction: "Up",
2953
2966
  status: "Error"
2954
2967
  }, new G({
2955
2968
  error: i,
2956
- results: n
2969
+ results: o
2957
2970
  });
2958
2971
  }
2959
2972
  }
2960
- return { results: n };
2973
+ return { results: o };
2961
2974
  }, E = async function(e) {
2962
2975
  d(this, f).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2963
2976
  };
2964
- var K;
2977
+ var R;
2965
2978
  class G extends Error {
2966
2979
  constructor(a) {
2967
2980
  super();
2968
- b(this, K);
2969
- L(this, K, a);
2981
+ b(this, R);
2982
+ L(this, R, a);
2970
2983
  }
2971
2984
  get resultSet() {
2972
- return d(this, K);
2985
+ return d(this, R);
2973
2986
  }
2974
2987
  }
2975
- K = new WeakMap();
2988
+ R = new WeakMap();
2976
2989
  class Le {
2977
2990
  constructor(e) {
2978
2991
  z(this, "migrations");
@@ -2982,7 +2995,7 @@ class Le {
2982
2995
  return this.migrations;
2983
2996
  }
2984
2997
  }
2985
- async function _r(t) {
2998
+ async function mr(t) {
2986
2999
  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(
2987
3000
  "tenant_id",
2988
3001
  "varchar(255)",
@@ -3054,35 +3067,35 @@ async function _r(t) {
3054
3067
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3055
3068
  ).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();
3056
3069
  }
3057
- async function hr(t) {
3070
+ async function _r(t) {
3058
3071
  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();
3059
3072
  }
3060
- const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3073
+ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3061
3074
  __proto__: null,
3062
- down: hr,
3063
- up: _r
3075
+ down: _r,
3076
+ up: mr
3064
3077
  }, Symbol.toStringTag, { value: "Module" }));
3065
- async function pr(t) {
3078
+ async function fr(t) {
3066
3079
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
3067
3080
  }
3068
- async function gr(t) {
3081
+ async function pr(t) {
3069
3082
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
3070
3083
  }
3071
- const wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3084
+ const gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3072
3085
  __proto__: null,
3073
- down: gr,
3074
- up: pr
3086
+ down: pr,
3087
+ up: fr
3075
3088
  }, Symbol.toStringTag, { value: "Module" }));
3076
- async function yr(t) {
3089
+ async function wr(t) {
3077
3090
  }
3078
- async function vr(t) {
3091
+ async function yr(t) {
3079
3092
  }
3080
- const Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3093
+ const vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3081
3094
  __proto__: null,
3082
- down: vr,
3083
- up: yr
3095
+ down: yr,
3096
+ up: wr
3084
3097
  }, Symbol.toStringTag, { value: "Module" }));
3085
- async function Cr(t) {
3098
+ async function Nr(t) {
3086
3099
  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(
3087
3100
  "tenant_id_constraint",
3088
3101
  ["tenant_id"],
@@ -3091,24 +3104,24 @@ async function Cr(t) {
3091
3104
  (e) => e.onDelete("cascade")
3092
3105
  ).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();
3093
3106
  }
3094
- async function br(t) {
3107
+ async function Cr(t) {
3095
3108
  await t.schema.dropTable("logs").execute();
3096
3109
  }
3097
- const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3110
+ const br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3098
3111
  __proto__: null,
3099
- down: br,
3100
- up: Cr
3112
+ down: Cr,
3113
+ up: Nr
3101
3114
  }, Symbol.toStringTag, { value: "Module" }));
3102
- async function Tr(t) {
3115
+ async function xr(t) {
3103
3116
  }
3104
- async function Sr(t) {
3117
+ async function Tr(t) {
3105
3118
  }
3106
- const Or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3119
+ const Sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3107
3120
  __proto__: null,
3108
- down: Sr,
3109
- up: Tr
3121
+ down: Tr,
3122
+ up: xr
3110
3123
  }, Symbol.toStringTag, { value: "Module" }));
3111
- async function kr(t) {
3124
+ async function Or(t) {
3112
3125
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3113
3126
  "user_id_constraint",
3114
3127
  ["user_id", "tenant_id"],
@@ -3133,15 +3146,15 @@ async function kr(t) {
3133
3146
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3134
3147
  ).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();
3135
3148
  }
3136
- async function $r(t) {
3149
+ async function kr(t) {
3137
3150
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
3138
3151
  }
3139
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3152
+ const $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3140
3153
  __proto__: null,
3141
- down: $r,
3142
- up: kr
3154
+ down: kr,
3155
+ up: Or
3143
3156
  }, Symbol.toStringTag, { value: "Module" }));
3144
- async function Ir(t) {
3157
+ async function Dr(t) {
3145
3158
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
3146
3159
  "user_id_constraint",
3147
3160
  ["user_id", "tenant_id"],
@@ -3156,24 +3169,24 @@ async function Ir(t) {
3156
3169
  (e) => e.onDelete("cascade")
3157
3170
  ).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();
3158
3171
  }
3159
- async function jr(t) {
3172
+ async function Ir(t) {
3160
3173
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
3161
3174
  }
3162
- const Pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3175
+ const jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3163
3176
  __proto__: null,
3164
- down: jr,
3165
- up: Ir
3177
+ down: Ir,
3178
+ up: Dr
3166
3179
  }, Symbol.toStringTag, { value: "Module" }));
3167
- async function Fr(t) {
3180
+ async function Pr(t) {
3168
3181
  }
3169
- async function Mr(t) {
3182
+ async function Fr(t) {
3170
3183
  }
3171
- const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3184
+ const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3172
3185
  __proto__: null,
3173
- down: Mr,
3174
- up: Fr
3186
+ down: Fr,
3187
+ up: Pr
3175
3188
  }, Symbol.toStringTag, { value: "Module" }));
3176
- async function zr(t) {
3189
+ async function Ar(t) {
3177
3190
  await t.schema.alterTable("passwords").addColumn(
3178
3191
  "password",
3179
3192
  "varchar(255)",
@@ -3181,288 +3194,288 @@ async function zr(t) {
3181
3194
  (e) => e.notNull()
3182
3195
  ).execute();
3183
3196
  }
3184
- async function Lr(t) {
3197
+ async function zr(t) {
3185
3198
  await t.schema.alterTable("passwords").dropColumn("password").execute();
3186
3199
  }
3187
- const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3200
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3188
3201
  __proto__: null,
3189
- down: Lr,
3190
- up: zr
3202
+ down: zr,
3203
+ up: Ar
3191
3204
  }, Symbol.toStringTag, { value: "Module" }));
3192
- async function Er(t) {
3205
+ async function Jr(t) {
3193
3206
  }
3194
- async function Rr(t) {
3207
+ async function Er(t) {
3195
3208
  }
3196
3209
  const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3197
3210
  __proto__: null,
3198
- down: Rr,
3199
- up: Er
3211
+ down: Er,
3212
+ up: Jr
3200
3213
  }, Symbol.toStringTag, { value: "Module" }));
3201
- async function Br(t) {
3214
+ async function Rr(t) {
3202
3215
  }
3203
- async function Ur(t) {
3216
+ async function Br(t) {
3204
3217
  }
3205
- const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3218
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3206
3219
  __proto__: null,
3207
- down: Ur,
3208
- up: Br
3220
+ down: Br,
3221
+ up: Rr
3209
3222
  }, Symbol.toStringTag, { value: "Module" }));
3210
3223
  async function qr(t) {
3211
3224
  }
3212
- async function Vr(t) {
3225
+ async function Qr(t) {
3213
3226
  }
3214
- const Wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3227
+ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3215
3228
  __proto__: null,
3216
- down: Vr,
3229
+ down: Qr,
3217
3230
  up: qr
3218
3231
  }, Symbol.toStringTag, { value: "Module" }));
3219
- async function Gr(t) {
3232
+ async function Wr(t) {
3220
3233
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
3221
3234
  }
3222
- async function Hr(t) {
3235
+ async function Gr(t) {
3223
3236
  await t.schema.dropIndex("users_email_index").execute();
3224
3237
  }
3225
- const Xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3238
+ const Hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3226
3239
  __proto__: null,
3227
- down: Hr,
3228
- up: Gr
3240
+ down: Gr,
3241
+ up: Wr
3229
3242
  }, Symbol.toStringTag, { value: "Module" }));
3230
- async function Yr(t) {
3243
+ async function Xr(t) {
3231
3244
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3232
3245
  }
3233
- async function Zr(t) {
3246
+ async function Yr(t) {
3234
3247
  await t.schema.alterTable("users").dropColumn("profileData").execute();
3235
3248
  }
3236
- const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3249
+ const Zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3237
3250
  __proto__: null,
3238
- down: Zr,
3239
- up: Yr
3251
+ down: Yr,
3252
+ up: Xr
3240
3253
  }, Symbol.toStringTag, { value: "Module" }));
3241
- async function tn(t) {
3254
+ async function en(t) {
3242
3255
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3243
3256
  }
3244
- async function an(t) {
3257
+ async function tn(t) {
3245
3258
  await t.schema.dropIndex("users_linked_to_index");
3246
3259
  }
3247
- const rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3260
+ const an = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3248
3261
  __proto__: null,
3249
- down: an,
3250
- up: tn
3262
+ down: tn,
3263
+ up: en
3251
3264
  }, Symbol.toStringTag, { value: "Module" }));
3252
- async function nn(t) {
3265
+ async function rn(t) {
3253
3266
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
3254
3267
  }
3255
- async function on(t) {
3268
+ async function nn(t) {
3256
3269
  await t.schema.alterTable("users").dropColumn("locale").execute();
3257
3270
  }
3258
- const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3271
+ const on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3259
3272
  __proto__: null,
3260
- down: on,
3261
- up: nn
3273
+ down: nn,
3274
+ up: rn
3262
3275
  }, Symbol.toStringTag, { value: "Module" }));
3263
- async function ln(t) {
3276
+ async function sn(t) {
3264
3277
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
3265
3278
  "tenant_id",
3266
3279
  "varchar(255)",
3267
3280
  (e) => e.references("tenants.id").onDelete("cascade")
3268
3281
  ).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();
3269
3282
  }
3270
- async function cn(t) {
3283
+ async function ln(t) {
3271
3284
  await t.schema.dropTable("keys").execute();
3272
3285
  }
3273
- const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3286
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3274
3287
  __proto__: null,
3275
- down: cn,
3276
- up: ln
3288
+ down: ln,
3289
+ up: sn
3277
3290
  }, Symbol.toStringTag, { value: "Module" }));
3278
- async function un(t) {
3291
+ async function dn(t) {
3279
3292
  }
3280
- async function mn(t) {
3293
+ async function un(t) {
3281
3294
  }
3282
- const _n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3295
+ const mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3283
3296
  __proto__: null,
3284
- down: mn,
3285
- up: un
3297
+ down: un,
3298
+ up: dn
3286
3299
  }, Symbol.toStringTag, { value: "Module" }));
3287
- async function hn(t) {
3300
+ async function _n(t) {
3288
3301
  }
3289
- async function fn(t) {
3302
+ async function hn(t) {
3290
3303
  }
3291
- const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3304
+ const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3292
3305
  __proto__: null,
3293
- down: fn,
3294
- up: hn
3306
+ down: hn,
3307
+ up: _n
3295
3308
  }, Symbol.toStringTag, { value: "Module" }));
3296
- async function gn(t) {
3309
+ async function pn(t) {
3297
3310
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3298
3311
  }
3299
- async function wn(t) {
3312
+ async function gn(t) {
3300
3313
  await t.schema.alterTable("otps").dropColumn("audience").execute();
3301
3314
  }
3302
- const yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3315
+ const wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3303
3316
  __proto__: null,
3304
- down: wn,
3305
- up: gn
3317
+ down: gn,
3318
+ up: pn
3306
3319
  }, Symbol.toStringTag, { value: "Module" }));
3307
- async function vn(t) {
3320
+ async function yn(t) {
3308
3321
  }
3309
- async function Nn(t) {
3322
+ async function vn(t) {
3310
3323
  }
3311
- const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3324
+ const Nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3312
3325
  __proto__: null,
3313
- down: Nn,
3314
- up: vn
3326
+ down: vn,
3327
+ up: yn
3315
3328
  }, Symbol.toStringTag, { value: "Module" }));
3316
- async function bn(t) {
3329
+ async function Cn(t) {
3317
3330
  await t.schema.alterTable("logs").dropColumn("category").execute();
3318
3331
  }
3319
- async function xn(t) {
3332
+ async function bn(t) {
3320
3333
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
3321
3334
  }
3322
- const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3335
+ const xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3323
3336
  __proto__: null,
3324
- down: xn,
3325
- up: bn
3337
+ down: bn,
3338
+ up: Cn
3326
3339
  }, Symbol.toStringTag, { value: "Module" }));
3327
- async function Sn(t) {
3340
+ async function Tn(t) {
3328
3341
  await t.schema.alterTable("users").dropColumn("tags").execute();
3329
3342
  }
3330
- async function On(t) {
3343
+ async function Sn(t) {
3331
3344
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3332
3345
  }
3333
- const kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3346
+ const On = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3334
3347
  __proto__: null,
3335
- down: On,
3336
- up: Sn
3348
+ down: Sn,
3349
+ up: Tn
3337
3350
  }, Symbol.toStringTag, { value: "Module" }));
3338
- async function $n(t) {
3351
+ async function kn(t) {
3339
3352
  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();
3340
3353
  }
3341
- async function Dn(t) {
3354
+ async function $n(t) {
3342
3355
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3343
3356
  }
3344
- const In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3357
+ const Dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3345
3358
  __proto__: null,
3346
- down: Dn,
3347
- up: $n
3359
+ down: $n,
3360
+ up: kn
3348
3361
  }, Symbol.toStringTag, { value: "Module" }));
3349
- async function jn(t) {
3362
+ async function In(t) {
3350
3363
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3351
3364
  }
3352
- async function Pn(t) {
3365
+ async function jn(t) {
3353
3366
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3354
3367
  }
3355
- const Fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3368
+ const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3356
3369
  __proto__: null,
3357
- down: Pn,
3358
- up: jn
3370
+ down: jn,
3371
+ up: In
3359
3372
  }, Symbol.toStringTag, { value: "Module" }));
3360
- async function Mn(t) {
3373
+ async function Fn(t) {
3361
3374
  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();
3362
3375
  }
3363
- async function An(t) {
3376
+ async function Mn(t) {
3364
3377
  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();
3365
3378
  }
3366
- const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3379
+ const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3367
3380
  __proto__: null,
3368
- down: An,
3369
- up: Mn
3381
+ down: Mn,
3382
+ up: Fn
3370
3383
  }, Symbol.toStringTag, { value: "Module" }));
3371
- async function Ln(t) {
3384
+ async function zn(t) {
3372
3385
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3373
3386
  }
3374
- async function Jn(t) {
3387
+ async function Ln(t) {
3375
3388
  await t.schema.dropIndex("users_name_index").execute();
3376
3389
  }
3377
- const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3390
+ const Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3378
3391
  __proto__: null,
3379
- down: Jn,
3380
- up: Ln
3392
+ down: Ln,
3393
+ up: zn
3381
3394
  }, Symbol.toStringTag, { value: "Module" }));
3382
- async function Rn(t) {
3395
+ async function En(t) {
3383
3396
  }
3384
3397
  async function Kn(t) {
3385
3398
  await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3386
3399
  }
3387
- const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3400
+ const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3388
3401
  __proto__: null,
3389
3402
  down: Kn,
3390
- up: Rn
3403
+ up: En
3391
3404
  }, Symbol.toStringTag, { value: "Module" }));
3392
- async function Un(t) {
3405
+ async function Bn(t) {
3393
3406
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3394
3407
  }
3395
- async function Qn(t) {
3408
+ async function Un(t) {
3396
3409
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
3397
3410
  }
3398
3411
  const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3399
3412
  __proto__: null,
3400
- down: Qn,
3401
- up: Un
3413
+ down: Un,
3414
+ up: Bn
3402
3415
  }, Symbol.toStringTag, { value: "Module" }));
3403
- async function Vn(t) {
3416
+ async function Qn(t) {
3404
3417
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3405
3418
  }
3406
- async function Wn(t) {
3419
+ async function Vn(t) {
3407
3420
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3408
3421
  }
3409
- const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3422
+ const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3410
3423
  __proto__: null,
3411
- down: Wn,
3412
- up: Vn
3424
+ down: Vn,
3425
+ up: Qn
3413
3426
  }, Symbol.toStringTag, { value: "Module" }));
3414
- async function Hn(t) {
3427
+ async function Gn(t) {
3415
3428
  await t.schema.createTable("branding").addColumn(
3416
3429
  "tenant_id",
3417
3430
  "varchar(255)",
3418
3431
  (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3419
3432
  ).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();
3420
3433
  }
3421
- async function Xn(t) {
3434
+ async function Hn(t) {
3422
3435
  await t.schema.dropTable("branding").execute();
3423
3436
  }
3424
- const Yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3437
+ const Xn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3425
3438
  __proto__: null,
3426
- down: Xn,
3427
- up: Hn
3439
+ down: Hn,
3440
+ up: Gn
3428
3441
  }, Symbol.toStringTag, { value: "Module" }));
3429
- async function Zn(t) {
3442
+ async function Yn(t) {
3430
3443
  }
3431
- async function eo(t) {
3444
+ async function Zn(t) {
3432
3445
  }
3433
- const to = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3446
+ const eo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3434
3447
  __proto__: null,
3435
- down: eo,
3436
- up: Zn
3448
+ down: Zn,
3449
+ up: Yn
3437
3450
  }, Symbol.toStringTag, { value: "Module" }));
3438
- async function ao(t) {
3451
+ async function to(t) {
3439
3452
  }
3440
- async function ro(t) {
3453
+ async function ao(t) {
3441
3454
  }
3442
- const no = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3455
+ const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3443
3456
  __proto__: null,
3444
- down: ro,
3445
- up: ao
3457
+ down: ao,
3458
+ up: to
3446
3459
  }, Symbol.toStringTag, { value: "Module" }));
3447
- async function oo(t) {
3460
+ async function no(t) {
3448
3461
  }
3449
- async function so(t) {
3462
+ async function oo(t) {
3450
3463
  }
3451
- const io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3464
+ const so = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3452
3465
  __proto__: null,
3453
- down: so,
3454
- up: oo
3466
+ down: oo,
3467
+ up: no
3455
3468
  }, Symbol.toStringTag, { value: "Module" }));
3456
- async function lo(t) {
3469
+ async function io(t) {
3457
3470
  }
3458
- async function co(t) {
3471
+ async function lo(t) {
3459
3472
  }
3460
- const uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3473
+ const co = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3461
3474
  __proto__: null,
3462
- down: co,
3463
- up: lo
3475
+ down: lo,
3476
+ up: io
3464
3477
  }, Symbol.toStringTag, { value: "Module" }));
3465
- async function mo(t) {
3478
+ async function uo(t) {
3466
3479
  await t.schema.createTable("authentication_codes").addColumn(
3467
3480
  "tenant_id",
3468
3481
  "varchar(255)",
@@ -3473,55 +3486,55 @@ async function mo(t) {
3473
3486
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3474
3487
  ).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();
3475
3488
  }
3476
- async function _o(t) {
3489
+ async function mo(t) {
3477
3490
  await t.schema.dropTable("authentication_codes").execute();
3478
3491
  }
3479
- const ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3492
+ const _o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3480
3493
  __proto__: null,
3481
- down: _o,
3482
- up: mo
3494
+ down: mo,
3495
+ up: uo
3483
3496
  }, Symbol.toStringTag, { value: "Module" }));
3484
- async function fo(t) {
3497
+ async function ho(t) {
3485
3498
  }
3486
- async function po(t) {
3499
+ async function fo(t) {
3487
3500
  }
3488
- const go = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3501
+ const po = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3489
3502
  __proto__: null,
3490
- down: po,
3491
- up: fo
3503
+ down: fo,
3504
+ up: ho
3492
3505
  }, Symbol.toStringTag, { value: "Module" }));
3493
- async function wo(t) {
3506
+ async function go(t) {
3494
3507
  await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3495
3508
  }
3496
- async function yo(t) {
3509
+ async function wo(t) {
3497
3510
  await t.schema.alterTable("otps").dropColumn("ip").execute();
3498
3511
  }
3499
- const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3512
+ const yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3500
3513
  __proto__: null,
3501
- down: yo,
3502
- up: wo
3514
+ down: wo,
3515
+ up: go
3503
3516
  }, Symbol.toStringTag, { value: "Module" }));
3504
- async function No(t) {
3517
+ async function vo(t) {
3505
3518
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3506
3519
  }
3507
- async function Co(t) {
3520
+ async function No(t) {
3508
3521
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3509
3522
  }
3510
- const bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3523
+ const Co = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3511
3524
  __proto__: null,
3512
- down: Co,
3513
- up: No
3525
+ down: No,
3526
+ up: vo
3514
3527
  }, Symbol.toStringTag, { value: "Module" }));
3515
- async function xo(t) {
3528
+ async function bo(t) {
3516
3529
  }
3517
- async function To(t) {
3530
+ async function xo(t) {
3518
3531
  }
3519
- const So = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3532
+ const To = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3520
3533
  __proto__: null,
3521
- down: To,
3522
- up: xo
3534
+ down: xo,
3535
+ up: bo
3523
3536
  }, Symbol.toStringTag, { value: "Module" }));
3524
- async function Oo(t) {
3537
+ async function So(t) {
3525
3538
  await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3526
3539
  "tenant_id",
3527
3540
  "varchar(255)",
@@ -3532,33 +3545,33 @@ async function Oo(t) {
3532
3545
  (e) => e.defaultTo(!1).notNull()
3533
3546
  ).addColumn("priority", "integer").execute();
3534
3547
  }
3535
- async function ko(t) {
3548
+ async function Oo(t) {
3536
3549
  await t.schema.dropTable("hooks").execute();
3537
3550
  }
3538
- const $o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3551
+ const ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3539
3552
  __proto__: null,
3540
- down: ko,
3541
- up: Oo
3553
+ down: Oo,
3554
+ up: So
3542
3555
  }, Symbol.toStringTag, { value: "Module" }));
3543
- async function Do(t) {
3556
+ async function $o(t) {
3544
3557
  }
3545
- async function Io(t) {
3558
+ async function Do(t) {
3546
3559
  }
3547
- const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3560
+ const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3548
3561
  __proto__: null,
3549
- down: Io,
3550
- up: Do
3562
+ down: Do,
3563
+ up: $o
3551
3564
  }, Symbol.toStringTag, { value: "Module" }));
3552
- async function Po(t) {
3565
+ async function jo(t) {
3553
3566
  }
3554
- async function Fo(t) {
3567
+ async function Po(t) {
3555
3568
  }
3556
- const Mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3569
+ const Fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3557
3570
  __proto__: null,
3558
- down: Fo,
3559
- up: Po
3571
+ down: Po,
3572
+ up: jo
3560
3573
  }, Symbol.toStringTag, { value: "Module" }));
3561
- async function Ao(t) {
3574
+ async function Mo(t) {
3562
3575
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3563
3576
  "tenant_id",
3564
3577
  "varchar(255)",
@@ -3575,7 +3588,7 @@ async function Ao(t) {
3575
3588
  (e) => e.onDelete("cascade")
3576
3589
  ).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();
3577
3590
  }
3578
- async function zo(t) {
3591
+ async function Ao(t) {
3579
3592
  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(
3580
3593
  "codes_user_id_tenant_id_constraint",
3581
3594
  ["user_id", "tenant_id"],
@@ -3584,90 +3597,90 @@ async function zo(t) {
3584
3597
  (e) => e.onDelete("cascade")
3585
3598
  ).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();
3586
3599
  }
3587
- const Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3600
+ const zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3588
3601
  __proto__: null,
3589
- down: zo,
3590
- up: Ao
3602
+ down: Ao,
3603
+ up: Mo
3591
3604
  }, Symbol.toStringTag, { value: "Module" }));
3592
- async function Jo(t) {
3605
+ async function Lo(t) {
3593
3606
  }
3594
- async function Eo(t) {
3607
+ async function Jo(t) {
3595
3608
  }
3596
- const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3609
+ const Eo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3597
3610
  __proto__: null,
3598
- down: Eo,
3599
- up: Jo
3611
+ down: Jo,
3612
+ up: Lo
3600
3613
  }, Symbol.toStringTag, { value: "Module" }));
3601
3614
  async function Ko(t) {
3602
3615
  await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3603
3616
  }
3604
- async function Bo(t) {
3617
+ async function Ro(t) {
3605
3618
  await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3606
3619
  }
3607
- const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3620
+ const Bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3608
3621
  __proto__: null,
3609
- down: Bo,
3622
+ down: Ro,
3610
3623
  up: Ko
3611
3624
  }, Symbol.toStringTag, { value: "Module" }));
3612
- async function Qo(t) {
3625
+ async function Uo(t) {
3613
3626
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3614
3627
  }
3615
3628
  async function qo(t) {
3616
3629
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3617
3630
  }
3618
- const Vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3631
+ const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3619
3632
  __proto__: null,
3620
3633
  down: qo,
3621
- up: Qo
3634
+ up: Uo
3622
3635
  }, Symbol.toStringTag, { value: "Module" }));
3623
- async function Wo(t) {
3636
+ async function Vo(t) {
3624
3637
  }
3625
- async function Go(t) {
3638
+ async function Wo(t) {
3626
3639
  }
3627
- const Ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3640
+ const Go = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3628
3641
  __proto__: null,
3629
- down: Go,
3630
- up: Wo
3642
+ down: Wo,
3643
+ up: Vo
3631
3644
  }, Symbol.toStringTag, { value: "Module" }));
3632
- async function Xo(t) {
3645
+ async function Ho(t) {
3633
3646
  }
3634
- async function Yo(t) {
3647
+ async function Xo(t) {
3635
3648
  }
3636
- const Zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3649
+ const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3637
3650
  __proto__: null,
3638
- down: Yo,
3639
- up: Xo
3651
+ down: Xo,
3652
+ up: Ho
3640
3653
  }, Symbol.toStringTag, { value: "Module" }));
3641
- async function es(t) {
3654
+ async function Zo(t) {
3642
3655
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3643
3656
  }
3644
- async function ts(t) {
3657
+ async function es(t) {
3645
3658
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3646
3659
  }
3647
- const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3660
+ const ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3648
3661
  __proto__: null,
3649
- down: ts,
3650
- up: es
3662
+ down: es,
3663
+ up: Zo
3651
3664
  }, Symbol.toStringTag, { value: "Module" }));
3652
- async function rs(t) {
3665
+ async function as(t) {
3653
3666
  }
3654
- async function ns(t) {
3667
+ async function rs(t) {
3655
3668
  }
3656
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3669
+ const ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3657
3670
  __proto__: null,
3658
- down: ns,
3659
- up: rs
3671
+ down: rs,
3672
+ up: as
3660
3673
  }, Symbol.toStringTag, { value: "Module" }));
3661
- async function ss(t) {
3674
+ async function os(t) {
3662
3675
  }
3663
- async function is(t) {
3676
+ async function ss(t) {
3664
3677
  }
3665
- const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3678
+ const is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3666
3679
  __proto__: null,
3667
- down: is,
3668
- up: ss
3680
+ down: ss,
3681
+ up: os
3669
3682
  }, Symbol.toStringTag, { value: "Module" }));
3670
- async function cs(t) {
3683
+ async function ls(t) {
3671
3684
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
3672
3685
  "tenant_id",
3673
3686
  "varchar(255)",
@@ -3683,7 +3696,7 @@ async function cs(t) {
3683
3696
  "code_type"
3684
3697
  ]).execute();
3685
3698
  }
3686
- async function ds(t) {
3699
+ async function cs(t) {
3687
3700
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3688
3701
  "tenant_id",
3689
3702
  "varchar(255)",
@@ -3696,15 +3709,15 @@ async function ds(t) {
3696
3709
  (e) => e.onDelete("cascade")
3697
3710
  ).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();
3698
3711
  }
3699
- const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3712
+ const ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3700
3713
  __proto__: null,
3701
- down: ds,
3702
- up: cs
3714
+ down: cs,
3715
+ up: ls
3703
3716
  }, Symbol.toStringTag, { value: "Module" }));
3704
- async function ms(t) {
3717
+ async function us(t) {
3705
3718
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
3706
3719
  }
3707
- async function _s(t) {
3720
+ async function ms(t) {
3708
3721
  await t.schema.alterTable("keys").addColumn("private_key", "varchar(2048)").addColumn("public_key", "varchar(2048)").execute(), await t.schema.createTable("otps").addColumn(
3709
3722
  "tenant_id",
3710
3723
  "varchar(255)",
@@ -3723,32 +3736,32 @@ async function _s(t) {
3723
3736
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3724
3737
  ).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();
3725
3738
  }
3726
- const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3739
+ const _s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3727
3740
  __proto__: null,
3728
- down: _s,
3729
- up: ms
3741
+ down: ms,
3742
+ up: us
3730
3743
  }, Symbol.toStringTag, { value: "Module" }));
3731
- async function fs(t) {
3744
+ async function hs(t) {
3732
3745
  await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
3733
3746
  }
3734
- async function ps(t) {
3747
+ async function fs(t) {
3735
3748
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
3736
3749
  }
3737
- const gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3750
+ const ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3738
3751
  __proto__: null,
3739
- down: ps,
3740
- up: fs
3752
+ down: fs,
3753
+ up: hs
3741
3754
  }, Symbol.toStringTag, { value: "Module" }));
3742
- async function ws(t) {
3755
+ async function gs(t) {
3743
3756
  }
3744
- async function ys(t) {
3757
+ async function ws(t) {
3745
3758
  }
3746
- const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3759
+ const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3747
3760
  __proto__: null,
3748
- down: ys,
3749
- up: ws
3761
+ down: ws,
3762
+ up: gs
3750
3763
  }, Symbol.toStringTag, { value: "Module" }));
3751
- async function Ns(t) {
3764
+ async function vs(t) {
3752
3765
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
3753
3766
  "universal_login_experience",
3754
3767
  "varchar(16)",
@@ -3767,95 +3780,95 @@ async function Ns(t) {
3767
3780
  (e) => e.defaultTo(!1).notNull()
3768
3781
  ).execute();
3769
3782
  }
3770
- async function Cs(t) {
3783
+ async function Ns(t) {
3771
3784
  await t.schema.dropTable("prompt_settings").execute();
3772
3785
  }
3773
- const bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3786
+ const Cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3774
3787
  __proto__: null,
3775
- down: Cs,
3776
- up: Ns
3788
+ down: Ns,
3789
+ up: vs
3777
3790
  }, Symbol.toStringTag, { value: "Module" }));
3778
- async function xs(t) {
3791
+ async function bs(t) {
3779
3792
  }
3780
- async function Ts(t) {
3793
+ async function xs(t) {
3781
3794
  }
3782
- const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3795
+ const Ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3783
3796
  __proto__: null,
3784
- down: Ts,
3785
- up: xs
3797
+ down: xs,
3798
+ up: bs
3786
3799
  }, Symbol.toStringTag, { value: "Module" }));
3787
- async function Os(t) {
3800
+ async function Ss(t) {
3788
3801
  }
3789
- async function ks(t) {
3802
+ async function Os(t) {
3790
3803
  }
3791
- const $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3804
+ const ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3792
3805
  __proto__: null,
3793
- down: ks,
3794
- up: Os
3806
+ down: Os,
3807
+ up: Ss
3795
3808
  }, Symbol.toStringTag, { value: "Module" }));
3796
- async function Ds(t) {
3809
+ async function $s(t) {
3797
3810
  }
3798
- async function Is(t) {
3811
+ async function Ds(t) {
3799
3812
  }
3800
- const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3813
+ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3801
3814
  __proto__: null,
3802
- down: Is,
3803
- up: Ds
3815
+ down: Ds,
3816
+ up: $s
3804
3817
  }, Symbol.toStringTag, { value: "Module" }));
3805
- async function Ps(t) {
3818
+ async function js(t) {
3806
3819
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3807
3820
  }
3808
- async function Fs(t) {
3821
+ async function Ps(t) {
3809
3822
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3810
3823
  }
3811
- const Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3824
+ const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3812
3825
  __proto__: null,
3813
- down: Fs,
3814
- up: Ps
3826
+ down: Ps,
3827
+ up: js
3815
3828
  }, Symbol.toStringTag, { value: "Module" }));
3816
- async function As(t) {
3829
+ async function Ms(t) {
3817
3830
  await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
3818
3831
  }
3819
- async function zs(t) {
3832
+ async function As(t) {
3820
3833
  await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
3821
3834
  }
3822
- const Ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3835
+ const zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3823
3836
  __proto__: null,
3824
- down: zs,
3825
- up: As
3837
+ down: As,
3838
+ up: Ms
3826
3839
  }, Symbol.toStringTag, { value: "Module" }));
3827
- async function Js(t) {
3840
+ async function Ls(t) {
3828
3841
  }
3829
- async function Es(t) {
3842
+ async function Js(t) {
3830
3843
  }
3831
- const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3844
+ const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3832
3845
  __proto__: null,
3833
- down: Es,
3834
- up: Js
3846
+ down: Js,
3847
+ up: Ls
3835
3848
  }, Symbol.toStringTag, { value: "Module" }));
3836
3849
  async function Ks(t) {
3837
3850
  await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
3838
3851
  }
3839
- async function Bs(t) {
3852
+ async function Rs(t) {
3840
3853
  await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
3841
3854
  }
3842
- const Us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3855
+ const Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3843
3856
  __proto__: null,
3844
- down: Bs,
3857
+ down: Rs,
3845
3858
  up: Ks
3846
3859
  }, Symbol.toStringTag, { value: "Module" }));
3847
- async function Qs(t) {
3860
+ async function Us(t) {
3848
3861
  await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
3849
3862
  }
3850
3863
  async function qs(t) {
3851
3864
  await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
3852
3865
  }
3853
- const Vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3866
+ const Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3854
3867
  __proto__: null,
3855
3868
  down: qs,
3856
- up: Qs
3869
+ up: Us
3857
3870
  }, Symbol.toStringTag, { value: "Module" }));
3858
- async function Ws(t) {
3871
+ async function Vs(t) {
3859
3872
  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(
3860
3873
  "credentials",
3861
3874
  "varchar(2048)",
@@ -3866,18 +3879,18 @@ async function Ws(t) {
3866
3879
  (e) => e.notNull().defaultTo("{}")
3867
3880
  ).addColumn("created_at", "varchar(29)", (e) => e.notNull()).addColumn("updated_at", "varchar(29)", (e) => e.notNull()).execute();
3868
3881
  }
3869
- async function Gs(t) {
3882
+ async function Ws(t) {
3870
3883
  await t.schema.dropTable("email_providers").execute();
3871
3884
  }
3872
- const Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3885
+ const Gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3873
3886
  __proto__: null,
3874
- down: Gs,
3875
- up: Ws
3887
+ down: Ws,
3888
+ up: Vs
3876
3889
  }, Symbol.toStringTag, { value: "Module" }));
3877
- async function Xs(t) {
3890
+ async function Hs(t) {
3878
3891
  await t.schema.dropTable("tickets").execute();
3879
3892
  }
3880
- async function Ys(t) {
3893
+ async function Xs(t) {
3881
3894
  await t.schema.createTable("tickets").addColumn(
3882
3895
  "tenant_id",
3883
3896
  "varchar(255)",
@@ -3888,22 +3901,22 @@ async function Ys(t) {
3888
3901
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3889
3902
  ).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();
3890
3903
  }
3891
- const Zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3904
+ const Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3892
3905
  __proto__: null,
3893
- down: Ys,
3894
- up: Xs
3906
+ down: Xs,
3907
+ up: Hs
3895
3908
  }, Symbol.toStringTag, { value: "Module" }));
3896
- async function ei(t) {
3909
+ async function Zs(t) {
3897
3910
  }
3898
- async function ti(t) {
3911
+ async function ei(t) {
3899
3912
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3900
3913
  }
3901
- const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3914
+ const ti = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3902
3915
  __proto__: null,
3903
- down: ti,
3904
- up: ei
3916
+ down: ei,
3917
+ up: Zs
3905
3918
  }, Symbol.toStringTag, { value: "Module" }));
3906
- async function ri(t) {
3919
+ async function ai(t) {
3907
3920
  await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3908
3921
  "client_id",
3909
3922
  "varchar(21)",
@@ -3916,27 +3929,27 @@ async function ri(t) {
3916
3929
  (e) => e.onDelete("cascade")
3917
3930
  ).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();
3918
3931
  }
3919
- async function ni(t) {
3932
+ async function ri(t) {
3920
3933
  await t.schema.dropTable("refresh_tokens").execute();
3921
3934
  }
3922
- const oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3935
+ const ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3923
3936
  __proto__: null,
3924
- down: ni,
3925
- up: ri
3937
+ down: ri,
3938
+ up: ai
3926
3939
  }, Symbol.toStringTag, { value: "Module" }));
3927
- async function si(t) {
3940
+ async function oi(t) {
3928
3941
  }
3929
- async function ii(t) {
3942
+ async function si(t) {
3930
3943
  }
3931
- const li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3944
+ const ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3932
3945
  __proto__: null,
3933
- down: ii,
3934
- up: si
3946
+ down: si,
3947
+ up: oi
3935
3948
  }, Symbol.toStringTag, { value: "Module" }));
3936
- async function ci(t) {
3949
+ async function li(t) {
3937
3950
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
3938
3951
  }
3939
- async function di(t) {
3952
+ async function ci(t) {
3940
3953
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3941
3954
  "sessions_user_id_constraint",
3942
3955
  ["user_id", "tenant_id"],
@@ -3955,12 +3968,12 @@ async function di(t) {
3955
3968
  (e) => e.onDelete("cascade")
3956
3969
  ).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();
3957
3970
  }
3958
- const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3971
+ const di = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3959
3972
  __proto__: null,
3960
- down: di,
3961
- up: ci
3973
+ down: ci,
3974
+ up: li
3962
3975
  }, Symbol.toStringTag, { value: "Module" }));
3963
- async function mi(t) {
3976
+ async function ui(t) {
3964
3977
  await t.schema.createTable("sessions_2").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3965
3978
  "sessions_2_user_id_constraint",
3966
3979
  ["user_id", "tenant_id"],
@@ -3979,15 +3992,15 @@ async function mi(t) {
3979
3992
  (e) => e.onDelete("cascade")
3980
3993
  ).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();
3981
3994
  }
3982
- async function _i(t) {
3995
+ async function mi(t) {
3983
3996
  await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
3984
3997
  }
3985
- const hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3998
+ const _i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3986
3999
  __proto__: null,
3987
- down: _i,
3988
- up: mi
4000
+ down: mi,
4001
+ up: ui
3989
4002
  }, Symbol.toStringTag, { value: "Module" }));
3990
- async function fi(t) {
4003
+ async function hi(t) {
3991
4004
  await t.schema.createTable("custom_domains").addColumn(
3992
4005
  "custom_domain_id",
3993
4006
  "varchar(21)",
@@ -3998,49 +4011,49 @@ async function fi(t) {
3998
4011
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3999
4012
  ).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();
4000
4013
  }
4001
- async function pi(t) {
4014
+ async function fi(t) {
4002
4015
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("domains").addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
4003
4016
  "tenant_id",
4004
4017
  "varchar(255)",
4005
4018
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4006
4019
  ).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();
4007
4020
  }
4008
- const gi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4021
+ const pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4009
4022
  __proto__: null,
4010
- down: pi,
4011
- up: fi
4023
+ down: fi,
4024
+ up: hi
4012
4025
  }, Symbol.toStringTag, { value: "Module" }));
4013
- async function wi(t) {
4026
+ async function gi(t) {
4014
4027
  }
4015
- async function yi(t) {
4028
+ async function wi(t) {
4016
4029
  await t.schema.alterTable("logins").dropColumn("authParams_organization").dropColumn("authorization_url").execute();
4017
4030
  }
4018
- const vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4031
+ const yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4019
4032
  __proto__: null,
4020
- down: yi,
4021
- up: wi
4033
+ down: wi,
4034
+ up: gi
4022
4035
  }, Symbol.toStringTag, { value: "Module" }));
4023
- async function Ni(t) {
4036
+ async function vi(t) {
4024
4037
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(2048)").execute();
4025
4038
  }
4026
- async function Ci(t) {
4039
+ async function Ni(t) {
4027
4040
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(1024)").execute();
4028
4041
  }
4029
- const bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4042
+ const Ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4030
4043
  __proto__: null,
4031
- down: Ci,
4032
- up: Ni
4044
+ down: Ni,
4045
+ up: vi
4033
4046
  }, Symbol.toStringTag, { value: "Module" }));
4034
- async function xi(t) {
4047
+ async function bi(t) {
4035
4048
  }
4036
- async function Ti(t) {
4049
+ async function xi(t) {
4037
4050
  }
4038
- const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4051
+ const Ti = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4039
4052
  __proto__: null,
4040
- down: Ti,
4041
- up: xi
4053
+ down: xi,
4054
+ up: bi
4042
4055
  }, Symbol.toStringTag, { value: "Module" }));
4043
- async function Oi(t) {
4056
+ async function Si(t) {
4044
4057
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4045
4058
  "sessions_user_id_constraint",
4046
4059
  ["user_id", "tenant_id"],
@@ -4067,25 +4080,25 @@ async function Oi(t) {
4067
4080
  (e) => e.onDelete("cascade")
4068
4081
  ).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();
4069
4082
  }
4070
- async function ki(t) {
4083
+ async function Oi(t) {
4071
4084
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
4072
4085
  }
4073
- const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4086
+ const ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4074
4087
  __proto__: null,
4075
- down: ki,
4076
- up: Oi
4088
+ down: Oi,
4089
+ up: Si
4077
4090
  }, Symbol.toStringTag, { value: "Module" }));
4078
- async function Di(t) {
4091
+ async function $i(t) {
4079
4092
  await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4080
4093
  }
4081
- async function Ii(t) {
4094
+ async function Di(t) {
4082
4095
  }
4083
- const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4096
+ const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4084
4097
  __proto__: null,
4085
- down: Ii,
4086
- up: Di
4098
+ down: Di,
4099
+ up: $i
4087
4100
  }, Symbol.toStringTag, { value: "Module" }));
4088
- async function Pi(t) {
4101
+ async function ji(t) {
4089
4102
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
4090
4103
  "custom_domain_id",
4091
4104
  "varchar(256)",
@@ -4096,46 +4109,46 @@ async function Pi(t) {
4096
4109
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4097
4110
  ).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();
4098
4111
  }
4099
- async function Fi(t) {
4112
+ async function Pi(t) {
4100
4113
  }
4101
- const Mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4114
+ const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4102
4115
  __proto__: null,
4103
- down: Fi,
4104
- up: Pi
4116
+ down: Pi,
4117
+ up: ji
4105
4118
  }, Symbol.toStringTag, { value: "Module" }));
4106
- async function Ai(t) {
4119
+ async function Mi(t) {
4107
4120
  }
4108
- async function zi(t) {
4121
+ async function Ai(t) {
4109
4122
  await t.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
4110
4123
  }
4111
- const Li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4124
+ const zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4112
4125
  __proto__: null,
4113
- down: zi,
4114
- up: Ai
4126
+ down: Ai,
4127
+ up: Mi
4115
4128
  }, Symbol.toStringTag, { value: "Module" }));
4116
- async function Ji(t) {
4129
+ async function Li(t) {
4117
4130
  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();
4118
4131
  }
4119
- async function Ei(t) {
4132
+ async function Ji(t) {
4120
4133
  await t.schema.dropTable("forms").execute();
4121
4134
  }
4122
- const Ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4135
+ const Ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4123
4136
  __proto__: null,
4124
- down: Ei,
4125
- up: Ji
4137
+ down: Ji,
4138
+ up: Li
4126
4139
  }, Symbol.toStringTag, { value: "Module" }));
4127
4140
  async function Ki(t) {
4128
4141
  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();
4129
4142
  }
4130
- async function Bi(t) {
4143
+ async function Ri(t) {
4131
4144
  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();
4132
4145
  }
4133
- const Ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4146
+ const Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4134
4147
  __proto__: null,
4135
- down: Bi,
4148
+ down: Ri,
4136
4149
  up: Ki
4137
4150
  }, Symbol.toStringTag, { value: "Module" }));
4138
- async function Qi(t) {
4151
+ async function Ui(t) {
4139
4152
  await t.schema.alterTable("login_sessions").addColumn(
4140
4153
  "login_completed",
4141
4154
  "boolean",
@@ -4145,71 +4158,71 @@ async function Qi(t) {
4145
4158
  async function qi(t) {
4146
4159
  await t.schema.alterTable("login_sessions").dropColumn("login_completed").execute();
4147
4160
  }
4148
- const Vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4161
+ const Qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4149
4162
  __proto__: null,
4150
4163
  down: qi,
4151
- up: Qi
4164
+ up: Ui
4152
4165
  }, Symbol.toStringTag, { value: "Module" }));
4153
- async function Wi(t) {
4166
+ async function Vi(t) {
4154
4167
  await t.schema.alterTable("sessions").addColumn(
4155
4168
  "login_session_id",
4156
4169
  "varchar(21)",
4157
4170
  (e) => e.references("login_sessions.id").onDelete("set null")
4158
4171
  ).execute();
4159
4172
  }
4160
- async function Gi(t) {
4173
+ async function Wi(t) {
4161
4174
  await t.schema.alterTable("sessions").dropColumn("login_session_id").execute();
4162
4175
  }
4163
- const Hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4176
+ const Gi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4164
4177
  __proto__: null,
4165
- down: Gi,
4166
- up: Wi
4178
+ down: Wi,
4179
+ up: Vi
4167
4180
  }, Symbol.toStringTag, { value: "Module" }));
4168
- async function Xi(t) {
4181
+ async function Hi(t) {
4169
4182
  await t.schema.createIndex("IDX_sessions_login_session_id").on("sessions").column("login_session_id").execute();
4170
4183
  }
4171
- async function Yi(t) {
4184
+ async function Xi(t) {
4172
4185
  await t.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
4173
4186
  }
4174
- const Zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4187
+ const Yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4175
4188
  __proto__: null,
4176
- down: Yi,
4177
- up: Xi
4189
+ down: Xi,
4190
+ up: Hi
4178
4191
  }, Symbol.toStringTag, { value: "Module" }));
4179
- async function el(t) {
4192
+ async function Zi(t) {
4180
4193
  await t.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await t.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
4181
4194
  }
4182
- async function tl(t) {
4195
+ async function el(t) {
4183
4196
  await t.schema.alterTable("codes").dropColumn("code_challenge").execute(), await t.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
4184
4197
  }
4185
- const al = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4198
+ const tl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4186
4199
  __proto__: null,
4187
- down: tl,
4188
- up: el
4200
+ down: el,
4201
+ up: Zi
4189
4202
  }, Symbol.toStringTag, { value: "Module" }));
4190
- async function rl(t) {
4203
+ async function al(t) {
4191
4204
  await t.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
4192
4205
  }
4193
- async function nl(t) {
4206
+ async function rl(t) {
4194
4207
  await t.schema.alterTable("codes").dropColumn("redirect_uri").execute();
4195
4208
  }
4196
- const ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4209
+ const nl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4197
4210
  __proto__: null,
4198
- down: nl,
4199
- up: rl
4211
+ down: rl,
4212
+ up: al
4200
4213
  }, Symbol.toStringTag, { value: "Module" }));
4201
- async function sl(t) {
4214
+ async function ol(t) {
4202
4215
  await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
4203
4216
  }
4204
- async function il(t) {
4217
+ async function sl(t) {
4205
4218
  await t.schema.alterTable("codes").dropColumn("nonce").execute(), await t.schema.alterTable("codes").dropColumn("state").execute();
4206
4219
  }
4207
- const ll = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4220
+ const il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4208
4221
  __proto__: null,
4209
- down: il,
4210
- up: sl
4222
+ down: sl,
4223
+ up: ol
4211
4224
  }, Symbol.toStringTag, { value: "Module" }));
4212
- async function cl(t) {
4225
+ async function ll(t) {
4213
4226
  await t.schema.createTable("themes").addColumn(
4214
4227
  "tenant_id",
4215
4228
  "varchar(255)",
@@ -4284,173 +4297,173 @@ async function cl(t) {
4284
4297
  (e) => e.notNull()
4285
4298
  ).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();
4286
4299
  }
4287
- async function dl(t) {
4300
+ async function cl(t) {
4288
4301
  await t.schema.dropTable("themes").execute();
4289
4302
  }
4290
- const ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4303
+ const dl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4291
4304
  __proto__: null,
4292
- down: dl,
4293
- up: cl
4305
+ down: cl,
4306
+ up: ll
4294
4307
  }, Symbol.toStringTag, { value: "Module" }));
4295
- async function ml(t) {
4296
- await t.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("identifier", "varchar(191)", (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)").execute(), await t.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await t.schema.createTable("rules").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("script", "varchar(8192)", (e) => e.notNull()).addColumn("order", "integer").addColumn("enabled", "integer").addColumn("stage", "varchar(64)").addColumn("created_at", "varchar(255)").addColumn("updated_at", "varchar(255)").execute(), await t.schema.createIndex("rules_tenant_id_idx").on("rules").column("tenant_id").execute(), await t.schema.createTable("permissions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("permission_name", "varchar(255)", (e) => e.notNull()).addColumn("description", "varchar(1024)").addColumn(
4308
+ async function ul(t) {
4309
+ await t.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("identifier", "varchar(191)", (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()).execute(), await t.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await t.schema.createTable("permissions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("permission_name", "varchar(255)", (e) => e.notNull()).addColumn("description", "varchar(1024)").addColumn(
4297
4310
  "resource_server_identifier",
4298
4311
  "varchar(191)",
4299
4312
  (e) => e.notNull()
4300
- ).addColumn("resource_server_name", "varchar(255)", (e) => e.notNull()).addColumn("sources", "varchar(4096)").execute(), await t.schema.createIndex("permissions_tenant_identifier_name_uq").on("permissions").columns(["tenant_id", "resource_server_identifier", "permission_name"]).unique().execute();
4313
+ ).addColumn("resource_server_name", "varchar(255)", (e) => e.notNull()).addColumn("sources", "varchar(4096)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createIndex("permissions_tenant_identifier_name_uq").on("permissions").columns(["tenant_id", "resource_server_identifier", "permission_name"]).unique().execute(), await t.schema.createTable("roles").addColumn("id", "varchar(21)", (e) => e.primaryKey()).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()).execute(), await t.schema.createIndex("roles_tenant_name_uq").on("roles").columns(["tenant_id", "name"]).unique().execute();
4301
4314
  }
4302
- async function _l(t) {
4303
- await t.schema.dropTable("permissions").execute(), await t.schema.dropTable("rules").execute(), await t.schema.dropTable("resource_servers").execute();
4315
+ async function ml(t) {
4316
+ await t.schema.dropTable("roles").execute(), await t.schema.dropTable("permissions").execute(), await t.schema.dropTable("resource_servers").execute();
4304
4317
  }
4305
- const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4318
+ const _l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4306
4319
  __proto__: null,
4307
- down: _l,
4308
- up: ml
4320
+ down: ml,
4321
+ up: ul
4309
4322
  }, Symbol.toStringTag, { value: "Module" })), Je = {
4310
- m1_init: fr,
4311
- m2_magicLink: wr,
4312
- m3_updateAt: Nr,
4313
- m4_logTable: xr,
4314
- m5_userProfile: Or,
4315
- m6_sessions: Dr,
4316
- m7_passwords: Pr,
4317
- m8_logsTableNewFields: Ar,
4318
- m9_passwordTableNewField: Jr,
4323
+ m1_init: hr,
4324
+ m2_magicLink: gr,
4325
+ m3_updateAt: vr,
4326
+ m4_logTable: br,
4327
+ m5_userProfile: Sr,
4328
+ m6_sessions: $r,
4329
+ m7_passwords: jr,
4330
+ m8_logsTableNewFields: Mr,
4331
+ m9_passwordTableNewField: Lr,
4319
4332
  n01_codesTable: Kr,
4320
- n11_universalLoginSession: Qr,
4321
- n12_userFields: Wr,
4322
- n13_userEmailIndex: Xr,
4323
- n14_profileDataField: en,
4324
- n15_userEmailIndex: rn,
4325
- n16_userLocale: sn,
4326
- n17_signingKeys: dn,
4327
- n18_logsFields: _n,
4328
- n19_connectionsUserinfo: pn,
4329
- n20_missingFields: yn,
4330
- n21_sessionDeletedAt: Cn,
4331
- n22_dropLogsFields: Tn,
4332
- n23_dropUsersFields: kn,
4333
- n24_logsIndexes: In,
4334
- n25_logDescMaxLength: Fn,
4335
- n26_logsTableExtraFields: zn,
4336
- n27_usersTableNameIndex: En,
4337
- n28_usersEmailConstrain: Bn,
4333
+ n11_universalLoginSession: Ur,
4334
+ n12_userFields: Vr,
4335
+ n13_userEmailIndex: Hr,
4336
+ n14_profileDataField: Zr,
4337
+ n15_userEmailIndex: an,
4338
+ n16_userLocale: on,
4339
+ n17_signingKeys: cn,
4340
+ n18_logsFields: mn,
4341
+ n19_connectionsUserinfo: fn,
4342
+ n20_missingFields: wn,
4343
+ n21_sessionDeletedAt: Nn,
4344
+ n22_dropLogsFields: xn,
4345
+ n23_dropUsersFields: On,
4346
+ n24_logsIndexes: Dn,
4347
+ n25_logDescMaxLength: Pn,
4348
+ n26_logsTableExtraFields: An,
4349
+ n27_usersTableNameIndex: Jn,
4350
+ n28_usersEmailConstrain: Rn,
4338
4351
  n29_increaseOtpStateLength: qn,
4339
- n30_increaseTicketStateLength: Gn,
4340
- n31_branding: Yn,
4341
- n32_indexesAndNotNull: to,
4342
- n33_vendorIdInUniversalLoginSession: no,
4343
- n34_auth0ClientInUniversalLoginSession: io,
4344
- n35_increaseUniversalSessionStateLength: uo,
4345
- n36_authenticationCodes: ho,
4346
- n37_disableSignUps: go,
4347
- n38_otpIpAddress: vo,
4348
- n39_increaseUserAgentLength: bo,
4349
- n40_userId: So,
4350
- n41_hooks: $o,
4351
- n42_userIdIndexes: jo,
4352
- n43_userIdIndexes: Mo,
4353
- n44_codes: Lo,
4354
- n45_hookProperties: Ro,
4355
- n46_loginAuth0Client: Uo,
4356
- n47_loginAuth0Client: Vo,
4357
- n48_saml: Ho,
4358
- n49_removeFields: Zo,
4359
- n50_authParamsNonce: as,
4360
- n51_connectionid: os,
4361
- n52_cert: ls,
4362
- n53_codes_primary_key: us,
4363
- n54_cleanup_tables: hs,
4364
- n55_logs_index: gs,
4365
- n56_application_fields: vs,
4366
- n57_prompt_settings: bs,
4367
- n58_connection_client_id: Ss,
4368
- n59_connection_options: $s,
4369
- n60_users_metadata: js,
4370
- n61_userLocales: Ms,
4371
- n62_prompt: Ls,
4372
- n63_connection_cleanup: Rs,
4373
- n64_act_as: Us,
4374
- n65_code_verifier: Vs,
4375
- n66_email_providers: Hs,
4376
- n67_drop_tickets: Zs,
4377
- n68_login_useragents: ai,
4378
- n70_refresh_tokens: oi,
4379
- n71_session_new_fields: li,
4380
- n72_session_primary_key: ui,
4381
- n73_drop_sessions: hi,
4382
- n74_custom_domains: gi,
4383
- n75_organizations: vi,
4384
- n76_authorization_url_length: bi,
4385
- n77_drop_sessions: Si,
4386
- n78_login_sessions: $i,
4387
- n79_drop_sessions_2: ji,
4388
- n80_recreate_custom_domains: Mi,
4389
- n81_phone: Li,
4390
- n82_forms: Ri,
4391
- n83_addFormsIdToHooks: Ui,
4392
- n84_login_completed: Vi,
4393
- n85_add_login_session_id_to_sessions: Hi,
4394
- n86_index_sessions_login_session_id: Zi,
4395
- n87_code_challenge: al,
4396
- n88_add_redirect_uri_to_codes: ol,
4397
- n89_add_nonce_and_state_to_codes: ll,
4398
- n90_themes: ul,
4399
- n91_resource_servers_rules_permissions: hl
4352
+ n30_increaseTicketStateLength: Wn,
4353
+ n31_branding: Xn,
4354
+ n32_indexesAndNotNull: eo,
4355
+ n33_vendorIdInUniversalLoginSession: ro,
4356
+ n34_auth0ClientInUniversalLoginSession: so,
4357
+ n35_increaseUniversalSessionStateLength: co,
4358
+ n36_authenticationCodes: _o,
4359
+ n37_disableSignUps: po,
4360
+ n38_otpIpAddress: yo,
4361
+ n39_increaseUserAgentLength: Co,
4362
+ n40_userId: To,
4363
+ n41_hooks: ko,
4364
+ n42_userIdIndexes: Io,
4365
+ n43_userIdIndexes: Fo,
4366
+ n44_codes: zo,
4367
+ n45_hookProperties: Eo,
4368
+ n46_loginAuth0Client: Bo,
4369
+ n47_loginAuth0Client: Qo,
4370
+ n48_saml: Go,
4371
+ n49_removeFields: Yo,
4372
+ n50_authParamsNonce: ts,
4373
+ n51_connectionid: ns,
4374
+ n52_cert: is,
4375
+ n53_codes_primary_key: ds,
4376
+ n54_cleanup_tables: _s,
4377
+ n55_logs_index: ps,
4378
+ n56_application_fields: ys,
4379
+ n57_prompt_settings: Cs,
4380
+ n58_connection_client_id: Ts,
4381
+ n59_connection_options: ks,
4382
+ n60_users_metadata: Is,
4383
+ n61_userLocales: Fs,
4384
+ n62_prompt: zs,
4385
+ n63_connection_cleanup: Es,
4386
+ n64_act_as: Bs,
4387
+ n65_code_verifier: Qs,
4388
+ n66_email_providers: Gs,
4389
+ n67_drop_tickets: Ys,
4390
+ n68_login_useragents: ti,
4391
+ n70_refresh_tokens: ni,
4392
+ n71_session_new_fields: ii,
4393
+ n72_session_primary_key: di,
4394
+ n73_drop_sessions: _i,
4395
+ n74_custom_domains: pi,
4396
+ n75_organizations: yi,
4397
+ n76_authorization_url_length: Ci,
4398
+ n77_drop_sessions: Ti,
4399
+ n78_login_sessions: ki,
4400
+ n79_drop_sessions_2: Ii,
4401
+ n80_recreate_custom_domains: Fi,
4402
+ n81_phone: zi,
4403
+ n82_forms: Ei,
4404
+ n83_addFormsIdToHooks: Bi,
4405
+ n84_login_completed: Qi,
4406
+ n85_add_login_session_id_to_sessions: Gi,
4407
+ n86_index_sessions_login_session_id: Yi,
4408
+ n87_code_challenge: tl,
4409
+ n88_add_redirect_uri_to_codes: nl,
4410
+ n89_add_nonce_and_state_to_codes: il,
4411
+ n90_themes: dl,
4412
+ n91_resource_servers_rules_permissions: _l
4400
4413
  };
4401
- async function yl(t, e = !1) {
4414
+ async function wl(t, e = !1) {
4402
4415
  e && console.log("migrating...");
4403
4416
  const a = new Le(Je), r = new be({
4404
4417
  db: t,
4405
4418
  provider: a
4406
- }), { error: o, results: n } = await r.migrateToLatest();
4407
- if (n == null || n.forEach((s) => {
4419
+ }), { error: n, results: o } = await r.migrateToLatest();
4420
+ if (o == null || o.forEach((s) => {
4408
4421
  s.status === "Success" ? e && console.log(
4409
4422
  `migration "${s.migrationName}" was executed successfully`
4410
4423
  ) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
4411
- }), o)
4412
- throw console.error("failed to migrate"), console.error(o), o;
4424
+ }), n)
4425
+ throw console.error("failed to migrate"), console.error(n), n;
4413
4426
  }
4414
- async function vl(t) {
4427
+ async function yl(t) {
4415
4428
  console.log("migrating...");
4416
4429
  const e = new Le(Je), a = new be({
4417
4430
  db: t,
4418
4431
  provider: e
4419
- }), { error: r, results: o } = await a.migrateDown();
4420
- if (o == null || o.forEach((n) => {
4421
- n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
4432
+ }), { error: r, results: n } = await a.migrateDown();
4433
+ if (n == null || n.forEach((o) => {
4434
+ o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
4422
4435
  }), r)
4423
4436
  throw console.error("failed to migrate"), console.error(r), r;
4424
4437
  }
4425
- function Nl(t) {
4438
+ function vl(t) {
4426
4439
  return {
4427
- applications: Mt(t),
4428
- branding: aa(t),
4429
- cleanup: ja(t),
4440
+ applications: Ft(t),
4441
+ branding: ta(t),
4442
+ cleanup: Ia(t),
4430
4443
  clients: Kt(t),
4431
- codes: $t(t),
4432
- connections: Rt(t),
4433
- emailProviders: Ta(t),
4434
- customDomains: Zt(t),
4435
- forms: La(t),
4436
- hooks: la(t),
4444
+ codes: kt(t),
4445
+ connections: Et(t),
4446
+ emailProviders: xa(t),
4447
+ customDomains: Yt(t),
4448
+ forms: za(t),
4449
+ hooks: ia(t),
4437
4450
  keys: qt(t),
4438
- loginSessions: wa(t),
4439
- logs: _t(t),
4440
- passwords: bt(t),
4441
- promptSettings: Na(t),
4442
- refreshTokens: Ia(t),
4443
- resourceServers: Ua(t),
4444
- rules: Ha(t),
4445
- permissions: ar(t),
4446
- sessions: yt(t),
4447
- tenants: lt(t),
4448
- themes: _a(t),
4449
- users: tt(t)
4451
+ loginSessions: ga(t),
4452
+ logs: mt(t),
4453
+ passwords: Ct(t),
4454
+ promptSettings: va(t),
4455
+ refreshTokens: Da(t),
4456
+ resourceServers: Ba(t),
4457
+ permissions: Ga(t),
4458
+ roles: tr(t),
4459
+ sessions: wt(t),
4460
+ tenants: it(t),
4461
+ themes: ma(t),
4462
+ users: et(t)
4450
4463
  };
4451
4464
  }
4452
4465
  export {
4453
- Nl as default,
4454
- vl as migrateDown,
4455
- yl as migrateToLatest
4466
+ vl as default,
4467
+ yl as migrateDown,
4468
+ wl as migrateToLatest
4456
4469
  };