@authhero/kysely-adapter 10.29.0 → 10.31.0

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