@authhero/kysely-adapter 10.10.0 → 10.12.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.
@@ -1,11 +1,11 @@
1
- var ze = Object.defineProperty;
2
- var le = (t) => {
1
+ var Je = Object.defineProperty;
2
+ var ue = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var Ee = (t, e, a) => e in t ? ze(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var j = (t, e, a) => Ee(t, typeof e != "symbol" ? e + "" : e, a), R = (t, e, a) => e.has(t) || le("Cannot " + a);
7
- var c = (t, e, a) => (R(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? le("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (R(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (R(t, e, "access private method"), a);
8
- import { parseUserId as Y, codeSchema as Je, connectionSchema as Ke, loginSessionSchema as Re, promptSettingSchema as Ue } from "@authhero/adapter-interfaces";
5
+ var Ee = (t, e, a) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
+ var j = (t, e, a) => Ee(t, typeof e != "symbol" ? e + "" : e, a), U = (t, e, a) => e.has(t) || ue("Cannot " + a);
7
+ var l = (t, e, a) => (U(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), M = (t, e, a, r) => (U(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
8
+ import { parseUserId as Z, codeSchema as Ke, connectionSchema as Re, loginSessionSchema as Ue, promptSettingSchema as Be, formSchema as K } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var V = class extends Error {
11
11
  constructor(e = 500, a) {
@@ -23,10 +23,10 @@ var V = class extends Error {
23
23
  });
24
24
  }
25
25
  };
26
- function Be(t) {
26
+ function Qe(t) {
27
27
  return async (e, a) => {
28
- const { identities: r, ...o } = a, n = {
29
- ...o,
28
+ const { identities: r, ...n } = a, o = {
29
+ ...n,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
@@ -37,26 +37,26 @@ function Be(t) {
37
37
  user_metadata: JSON.stringify(a.user_metadata)
38
38
  };
39
39
  try {
40
- await t.insertInto("users").values(n).execute();
40
+ await t.insertInto("users").values(o).execute();
41
41
  } catch (s) {
42
42
  throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new V(409, { message: "User already exists" }) : new V(500, { message: `${s.code}, ${s.message}` });
43
43
  }
44
44
  return {
45
- ...n,
45
+ ...o,
46
46
  // TODO: check if this is correct. Should it be optional?
47
- email: n.email || "",
48
- email_verified: n.email_verified === 1,
49
- is_social: n.is_social === 1
47
+ email: o.email || "",
48
+ email_verified: o.email_verified === 1,
49
+ is_social: o.is_social === 1
50
50
  };
51
51
  };
52
52
  }
53
- function _(t) {
53
+ function f(t) {
54
54
  const e = { ...t };
55
55
  for (const a in e)
56
- e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(_) : e[a] = _(e[a]));
56
+ e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(f) : e[a] = f(e[a]));
57
57
  return e;
58
58
  }
59
- function fe(t) {
59
+ function pe(t) {
60
60
  let e = {};
61
61
  try {
62
62
  e = JSON.parse(t.profileData || "{}");
@@ -66,7 +66,7 @@ function fe(t) {
66
66
  return {
67
67
  connection: t.connection,
68
68
  provider: t.provider,
69
- user_id: Y(t.user_id).id,
69
+ user_id: Z(t.user_id).id,
70
70
  isSocial: !!t.is_social,
71
71
  profileData: {
72
72
  email: t.email,
@@ -75,15 +75,15 @@ function fe(t) {
75
75
  }
76
76
  };
77
77
  }
78
- function Qe(t) {
78
+ function qe(t) {
79
79
  return async (e, a) => {
80
- const [r, o] = await Promise.all([
80
+ const [r, n] = await Promise.all([
81
81
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
82
82
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
83
83
  ]);
84
84
  if (!r)
85
85
  return null;
86
- const { tenant_id: n, ...s } = r, l = {
86
+ const { tenant_id: o, ...s } = r, c = {
87
87
  ...s,
88
88
  email: r.email || "",
89
89
  email_verified: r.email_verified === 1,
@@ -94,53 +94,53 @@ function Qe(t) {
94
94
  {
95
95
  connection: r.connection,
96
96
  provider: r.provider,
97
- user_id: Y(r.user_id).id,
97
+ user_id: Z(r.user_id).id,
98
98
  isSocial: !!r.is_social
99
99
  },
100
- ...o.map(fe)
100
+ ...n.map(pe)
101
101
  ]
102
102
  };
103
- return _(l);
103
+ return f(c);
104
104
  };
105
105
  }
106
- function O(t, e, a, r) {
107
- return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
- let s = n.startsWith("-"), l, d, g, m;
109
- return n.startsWith("-_exists_:") ? (l = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (l = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [l, d] = s ? n.substring(1).split(":") : n.split(":"), g = !1, d.startsWith(">=") ? (m = ">=", d = d.substring(2)) : d.startsWith(">") ? (m = ">", d = d.substring(1)) : d.startsWith("<=") ? (m = "<=", d = d.substring(2)) : d.startsWith("<") ? (m = "<", d = d.substring(1)) : m = "=") : (l = null, d = n, g = !1), { key: l, value: d, isNegation: s, isExistsQuery: g, operator: m };
110
- }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: d, operator: g }) => {
111
- if (n)
106
+ function T(t, e, a, r) {
107
+ return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
108
+ let s = o.startsWith("-"), c, d, h, m;
109
+ return o.startsWith("-_exists_:") ? (c = o.substring(10), h = !0, s = !0) : o.startsWith("_exists_:") ? (c = o.substring(9), h = !0, s = !1) : o.includes(":") ? (s = o.startsWith("-"), [c, d] = s ? o.substring(1).split(":") : o.split(":"), h = !1, d.startsWith(">=") ? (m = ">=", d = d.substring(2)) : d.startsWith(">") ? (m = ">", d = d.substring(1)) : d.startsWith("<=") ? (m = "<=", d = d.substring(2)) : d.startsWith("<") ? (m = "<", d = d.substring(1)) : m = "=") : (c = null, d = o, h = !1), { key: c, value: d, isNegation: s, isExistsQuery: h, operator: m };
110
+ }).forEach(({ key: o, value: s, isNegation: c, isExistsQuery: d, operator: h }) => {
111
+ if (o)
112
112
  if (d)
113
- l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
- else if (l)
115
- switch (g) {
113
+ c ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
114
+ else if (c)
115
+ switch (h) {
116
116
  case ">":
117
- e = e.where(n, "<=", s);
117
+ e = e.where(o, "<=", s);
118
118
  break;
119
119
  case ">=":
120
- e = e.where(n, "<", s);
120
+ e = e.where(o, "<", s);
121
121
  break;
122
122
  case "<":
123
- e = e.where(n, ">=", s);
123
+ e = e.where(o, ">=", s);
124
124
  break;
125
125
  case "<=":
126
- e = e.where(n, ">", s);
126
+ e = e.where(o, ">", s);
127
127
  break;
128
128
  default:
129
- e = e.where(n, "!=", s);
129
+ e = e.where(o, "!=", s);
130
130
  }
131
131
  else
132
- e = e.where(n, g, s);
132
+ e = e.where(o, h, s);
133
133
  else {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
136
136
  (w) => w.or(
137
- r.map((b) => w(m(b), "like", `%${s}%`))
137
+ r.map((x) => w(m(x), "like", `%${s}%`))
138
138
  )
139
139
  );
140
140
  }
141
141
  }), e;
142
142
  }
143
- function x(t) {
143
+ function b(t) {
144
144
  return typeof t == "string" ? parseInt(t, 10) : typeof t == "bigint" ? Number(t) : t;
145
145
  }
146
146
  function Ve(t) {
@@ -150,15 +150,15 @@ function Ve(t) {
150
150
  include_totals: !1
151
151
  }) => {
152
152
  let r = t.selectFrom("users").where("users.tenant_id", "=", e);
153
- if (a.q && (r = O(t, r, a.q, ["email", "name"])), a.sort && a.sort.sort_by) {
153
+ if (a.q && (r = T(t, r, a.q, ["email", "name"])), a.sort && a.sort.sort_by) {
154
154
  const { ref: m } = t.dynamic;
155
155
  r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
156
156
  }
157
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
158
- const w = l.filter(
159
- (b) => b.linked_to === m.user_id
157
+ 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() : [], d = o.map((m) => {
158
+ const w = c.filter(
159
+ (x) => x.linked_to === m.user_id
160
160
  );
161
- return _({
161
+ return f({
162
162
  ...m,
163
163
  email_verified: m.email_verified === 1,
164
164
  is_social: m.is_social === 1,
@@ -168,66 +168,66 @@ function Ve(t) {
168
168
  {
169
169
  connection: m.connection,
170
170
  provider: m.provider,
171
- user_id: Y(m.user_id).id,
171
+ user_id: Z(m.user_id).id,
172
172
  isSocial: !!m.is_social
173
173
  },
174
- ...w.map(fe)
174
+ ...w.map(pe)
175
175
  ]
176
176
  });
177
- }), { count: g } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
177
+ }), { count: h } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
178
178
  return {
179
179
  users: d,
180
180
  start: a.page * a.per_page,
181
181
  limit: a.per_page,
182
- length: x(g)
182
+ length: b(h)
183
183
  };
184
184
  };
185
185
  }
186
186
  function We(t) {
187
187
  return async (e, a) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1);
188
188
  }
189
- function qe(t) {
189
+ function Ge(t) {
190
190
  if (t.email_verified !== void 0)
191
191
  return t.email_verified ? 1 : 0;
192
192
  }
193
- function Ge(t) {
193
+ function He(t) {
194
194
  return async (e, a, r) => {
195
- const o = {
195
+ const n = {
196
196
  ...r,
197
- email_verified: qe(r),
197
+ email_verified: Ge(r),
198
198
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
199
199
  };
200
- return r.app_metadata && (o.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (o.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
200
+ return r.app_metadata && (n.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (n.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
201
201
  };
202
202
  }
203
- function He(t) {
204
- return async (e, a, r, o) => {
205
- const n = { linked_to: null };
206
- return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
203
+ function Xe(t) {
204
+ return async (e, a, r, n) => {
205
+ const o = { linked_to: null };
206
+ 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;
207
207
  };
208
208
  }
209
- function Xe(t) {
209
+ function Ye(t) {
210
210
  return {
211
- create: Be(t),
211
+ create: Qe(t),
212
212
  remove: We(t),
213
- get: Qe(t),
213
+ get: qe(t),
214
214
  list: Ve(t),
215
- update: Ge(t),
215
+ update: He(t),
216
216
  // TODO - think about this more when other issues fixed
217
- unlink: He(t)
217
+ unlink: Xe(t)
218
218
  };
219
219
  }
220
- const Ye = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
221
- let k = (t = 21) => {
220
+ const Ze = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
221
+ let S = (t = 21) => {
222
222
  let e = "", a = crypto.getRandomValues(new Uint8Array(t));
223
223
  for (; t--; )
224
- e += Ye[a[t] & 63];
224
+ e += Ze[a[t] & 63];
225
225
  return e;
226
226
  };
227
- function Ze(t) {
227
+ function et(t) {
228
228
  return async (e) => {
229
229
  const a = {
230
- id: e.id || k(),
230
+ id: e.id || S(),
231
231
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
232
232
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
233
233
  ...e
@@ -235,13 +235,13 @@ function Ze(t) {
235
235
  return await t.insertInto("tenants").values(a).execute(), a;
236
236
  };
237
237
  }
238
- function et(t) {
238
+ function tt(t) {
239
239
  return async (e) => {
240
240
  const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
- return a ? _(a) : null;
241
+ return a ? f(a) : null;
242
242
  };
243
243
  }
244
- function tt(t) {
244
+ function at(t) {
245
245
  return async (e = {
246
246
  page: 0,
247
247
  per_page: 50,
@@ -249,25 +249,25 @@ function tt(t) {
249
249
  }) => {
250
250
  let a = t.selectFrom("tenants");
251
251
  if (e.sort && e.sort.sort_by) {
252
- const { ref: l } = t.dynamic;
253
- a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
252
+ const { ref: c } = t.dynamic;
253
+ a = a.orderBy(c(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
- e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
- const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
255
+ e.q && (a = a.where((c) => c.or([c("name", "like", `%${e.q}%`)])));
256
+ const n = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
257
257
  if (!e.include_totals)
258
258
  return {
259
- tenants: o
259
+ tenants: n
260
260
  };
261
- const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = x(n);
261
+ const { count: o } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(o);
262
262
  return {
263
- tenants: o.map(_),
263
+ tenants: n.map(f),
264
264
  start: (e.page - 1) * e.per_page,
265
265
  limit: e.per_page,
266
266
  length: s
267
267
  };
268
268
  };
269
269
  }
270
- function at(t) {
270
+ function rt(t) {
271
271
  return async (e, a) => {
272
272
  const r = {
273
273
  ...a,
@@ -277,43 +277,43 @@ function at(t) {
277
277
  await t.updateTable("tenants").set(r).where("id", "=", e).execute();
278
278
  };
279
279
  }
280
- function rt(t) {
280
+ function nt(t) {
281
281
  return async (e) => (await t.deleteFrom("tenants").where("tenants.id", "=", e).execute()).length === 1;
282
282
  }
283
- function nt(t) {
283
+ function ot(t) {
284
284
  return {
285
- create: Ze(t),
286
- get: et(t),
287
- list: tt(t),
288
- update: at(t),
289
- remove: rt(t)
285
+ create: et(t),
286
+ get: tt(t),
287
+ list: at(t),
288
+ update: rt(t),
289
+ remove: nt(t)
290
290
  };
291
291
  }
292
- function ue(t) {
292
+ function me(t) {
293
293
  return t ? JSON.stringify(t) : void 0;
294
294
  }
295
- const ot = 1024;
296
- function st(t) {
295
+ const st = 1024;
296
+ function it(t) {
297
297
  return async (e, a) => {
298
- var o, n, s;
298
+ var n, o, s;
299
299
  const r = {
300
- id: k(),
300
+ id: S(),
301
301
  ...a,
302
- user_agent: a.user_agent.slice(0, ot)
302
+ user_agent: a.user_agent.slice(0, st)
303
303
  };
304
304
  return await t.insertInto("logs").values({
305
305
  ...r,
306
306
  // Truncate long strings to avoid database errors
307
- description: (o = r.description) == null ? void 0 : o.substring(0, 256),
307
+ description: (n = r.description) == null ? void 0 : n.substring(0, 256),
308
308
  isMobile: a.isMobile ? 1 : 0,
309
309
  tenant_id: e,
310
- scope: (n = a.scope) == null ? void 0 : n.join(","),
311
- auth0_client: ue(a.auth0_client),
312
- details: (s = ue(a.details)) == null ? void 0 : s.substring(0, 8192)
310
+ scope: (o = a.scope) == null ? void 0 : o.join(","),
311
+ auth0_client: me(a.auth0_client),
312
+ details: (s = me(a.details)) == null ? void 0 : s.substring(0, 8192)
313
313
  }).execute(), r;
314
314
  };
315
315
  }
316
- function me(t) {
316
+ function he(t) {
317
317
  if (!t)
318
318
  return "";
319
319
  try {
@@ -322,72 +322,72 @@ function me(t) {
322
322
  return t;
323
323
  }
324
324
  }
325
- function pe(t) {
325
+ function ge(t) {
326
326
  return {
327
327
  ...t,
328
328
  client_id: t.client_id,
329
329
  client_name: "",
330
- auth0_client: me(t.auth0_client),
331
- details: me(t.details),
330
+ auth0_client: he(t.auth0_client),
331
+ details: he(t.details),
332
332
  isMobile: !!t.isMobile,
333
333
  scope: t.scope ? t.scope.split(",") : void 0,
334
334
  log_id: t.id,
335
335
  _id: t.id
336
336
  };
337
337
  }
338
- function it(t) {
338
+ function dt(t) {
339
339
  return async (e, a = {
340
340
  page: 0,
341
341
  per_page: 50,
342
342
  include_totals: !1
343
343
  }) => {
344
344
  let r = t.selectFrom("logs").where("logs.tenant_id", "=", e);
345
- a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
346
- let o = r;
345
+ a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
346
+ let n = r;
347
347
  if (a.sort && a.sort.sort_by) {
348
- const { ref: l } = t.dynamic;
349
- o = o.orderBy(
350
- l(a.sort.sort_by),
348
+ const { ref: c } = t.dynamic;
349
+ n = n.orderBy(
350
+ c(a.sort.sort_by),
351
351
  a.sort.sort_order
352
352
  );
353
353
  }
354
- o = o.offset(a.page * a.per_page).limit(a.per_page);
355
- const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
354
+ n = n.offset(a.page * a.per_page).limit(a.per_page);
355
+ const o = await n.selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
356
356
  return {
357
- logs: n.map(pe),
357
+ logs: o.map(ge),
358
358
  start: a.page * a.per_page,
359
359
  limit: a.per_page,
360
- length: x(s)
360
+ length: b(s)
361
361
  };
362
362
  };
363
363
  }
364
- function dt(t) {
364
+ function ct(t) {
365
365
  return async (e, a) => {
366
366
  const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
367
- return r ? pe(r) : null;
367
+ return r ? ge(r) : null;
368
368
  };
369
369
  }
370
- function ct(t) {
370
+ function lt(t) {
371
371
  return {
372
- create: st(t),
373
- list: it(t),
374
- get: dt(t)
372
+ create: it(t),
373
+ list: dt(t),
374
+ get: ct(t)
375
375
  };
376
376
  }
377
- function lt(t) {
377
+ function ut(t) {
378
378
  return async (e, a) => {
379
379
  const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
380
380
  if (!r)
381
381
  return null;
382
- const { tenant_id: o, device: n, clients: s, ...l } = r;
382
+ const { tenant_id: n, device: o, clients: s, ...c } = r;
383
383
  return {
384
- ...l,
385
- device: JSON.parse(n),
384
+ ...c,
385
+ device: JSON.parse(o),
386
386
  clients: JSON.parse(s)
387
387
  };
388
388
  };
389
389
  }
390
- function ut(t) {
390
+ function mt(t) {
391
391
  return async (e, a) => {
392
392
  const r = {
393
393
  ...a,
@@ -404,69 +404,69 @@ function ut(t) {
404
404
  }).execute(), r;
405
405
  };
406
406
  }
407
- function mt(t) {
407
+ function ht(t) {
408
408
  return async (e, a) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
409
409
  }
410
- function ht(t) {
410
+ function _t(t) {
411
411
  return async (e, a, r) => {
412
- const o = {
412
+ const n = {
413
413
  ...r,
414
414
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
415
415
  device: r.device ? JSON.stringify(r.device) : void 0,
416
416
  clients: r.clients ? JSON.stringify(r.clients) : void 0
417
417
  };
418
- return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
418
+ return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
419
419
  };
420
420
  }
421
- function _t(t) {
421
+ function ft(t) {
422
422
  return async (e, a = {
423
423
  page: 0,
424
424
  per_page: 50,
425
425
  include_totals: !1
426
426
  }) => {
427
427
  let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
428
- a.q && (r = O(t, r, a.q, ["user_id", "session_id"]));
429
- let o = r;
428
+ a.q && (r = T(t, r, a.q, ["user_id", "session_id"]));
429
+ let n = r;
430
430
  if (a.sort && a.sort.sort_by) {
431
431
  const { ref: d } = t.dynamic;
432
- o = o.orderBy(
432
+ n = n.orderBy(
433
433
  d(a.sort.sort_by),
434
434
  a.sort.sort_order
435
435
  );
436
436
  }
437
- o = o.offset(a.page * a.per_page).limit(a.per_page);
438
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
437
+ n = n.offset(a.page * a.per_page).limit(a.per_page);
438
+ const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
439
439
  return {
440
- sessions: n.map((d) => ({
440
+ sessions: o.map((d) => ({
441
441
  ...d,
442
442
  device: JSON.parse(d.device),
443
443
  clients: JSON.parse(d.clients)
444
444
  })),
445
445
  start: a.page * a.per_page,
446
446
  limit: a.per_page,
447
- length: l
447
+ length: c
448
448
  };
449
449
  };
450
450
  }
451
- function ft(t) {
451
+ function pt(t) {
452
452
  return {
453
- create: ut(t),
454
- get: lt(t),
455
- list: _t(t),
456
- remove: mt(t),
457
- update: ht(t)
453
+ create: mt(t),
454
+ get: ut(t),
455
+ list: ft(t),
456
+ remove: ht(t),
457
+ update: _t(t)
458
458
  };
459
459
  }
460
- function pt(t) {
460
+ function gt(t) {
461
461
  return async (e, a) => {
462
462
  const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
463
463
  if (!r)
464
464
  return null;
465
- const { tenant_id: o, ...n } = r;
466
- return n;
465
+ const { tenant_id: n, ...o } = r;
466
+ return o;
467
467
  };
468
468
  }
469
- function gt(t) {
469
+ function yt(t) {
470
470
  return async (e, a) => {
471
471
  const r = {
472
472
  ...a,
@@ -479,40 +479,40 @@ function gt(t) {
479
479
  }).execute(), r;
480
480
  };
481
481
  }
482
- function yt(t) {
482
+ function wt(t) {
483
483
  return async (e, a) => (await t.updateTable("passwords").set({
484
484
  password: a.password,
485
485
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
486
486
  }).where("tenant_id", "=", e).where("user_id", "=", a.user_id).execute()).length === 1;
487
487
  }
488
- function wt(t) {
488
+ function vt(t) {
489
489
  return {
490
- create: gt(t),
491
- update: yt(t),
492
- get: pt(t)
490
+ create: yt(t),
491
+ update: wt(t),
492
+ get: gt(t)
493
493
  };
494
494
  }
495
- function vt(t) {
495
+ function Nt(t) {
496
496
  return async (e, a = {
497
497
  page: 0,
498
498
  per_page: 50,
499
499
  include_totals: !1
500
500
  }) => {
501
501
  let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
502
- a.q && (r = O(t, r, a.q, ["code", "login_id"]));
503
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
502
+ a.q && (r = T(t, r, a.q, ["code", "login_id"]));
503
+ const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
504
504
  return {
505
- codes: n.map((d) => {
506
- const { tenant_id: g, ...m } = d;
507
- return Je.parse(_(m));
505
+ codes: o.map((d) => {
506
+ const { tenant_id: h, ...m } = d;
507
+ return Ke.parse(f(m));
508
508
  }),
509
509
  start: a.page * a.per_page,
510
510
  limit: a.per_page,
511
- length: x(s)
511
+ length: b(s)
512
512
  };
513
513
  };
514
514
  }
515
- function Nt(t) {
515
+ function Ct(t) {
516
516
  return async (e, a) => {
517
517
  const r = {
518
518
  ...a,
@@ -524,67 +524,67 @@ function Nt(t) {
524
524
  }).execute(), r;
525
525
  };
526
526
  }
527
- function Ct(t) {
527
+ function bt(t) {
528
528
  return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
529
529
  }
530
- function bt(t) {
530
+ function xt(t) {
531
531
  return async (e, a, r) => {
532
- let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
533
- e.length && (o = o.where("codes.tenant_id", "=", e));
534
- const n = await o.selectAll().executeTakeFirst();
535
- return n ? _(n) : null;
532
+ let n = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
533
+ e.length && (n = n.where("codes.tenant_id", "=", e));
534
+ const o = await n.selectAll().executeTakeFirst();
535
+ return o ? f(o) : null;
536
536
  };
537
537
  }
538
- function xt(t) {
538
+ function Tt(t) {
539
539
  return async (e, a) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numUpdatedRows > 0;
540
540
  }
541
- function Tt(t) {
541
+ function St(t) {
542
542
  return {
543
- create: Nt(t),
544
- list: vt(t),
545
- remove: Ct(t),
546
- used: xt(t),
547
- get: bt(t)
543
+ create: Ct(t),
544
+ list: Nt(t),
545
+ remove: bt(t),
546
+ used: Tt(t),
547
+ get: xt(t)
548
548
  };
549
549
  }
550
- function St(t) {
550
+ function Ot(t) {
551
551
  return async (e, a) => {
552
552
  const r = {
553
553
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
554
554
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
555
555
  ...a
556
- }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
556
+ }, n = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), c = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
557
557
  return await t.insertInto("applications").values({
558
558
  ...r,
559
559
  tenant_id: e,
560
560
  disable_sign_ups: a.disable_sign_ups ? 1 : 0,
561
561
  addons: a.addons ? JSON.stringify(a.addons) : "{}",
562
- callbacks: n,
563
- allowed_origins: o,
562
+ callbacks: o,
563
+ allowed_origins: n,
564
564
  web_origins: s,
565
- allowed_logout_urls: l,
565
+ allowed_logout_urls: c,
566
566
  allowed_clients: d
567
567
  }).execute(), r;
568
568
  };
569
569
  }
570
- function Ot(t) {
570
+ function kt(t) {
571
571
  return async (e) => ({
572
- applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((n) => ({
573
- ...n,
574
- disable_sign_ups: !!n.disable_sign_ups,
575
- addons: n.addons ? JSON.parse(n.addons) : {},
576
- callbacks: n.callbacks ? JSON.parse(n.callbacks) : [],
577
- allowed_origins: n.allowed_origins ? JSON.parse(n.allowed_origins) : [],
578
- web_origins: n.web_origins ? JSON.parse(n.web_origins) : [],
579
- allowed_logout_urls: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : [],
580
- allowed_clients: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : []
572
+ applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((o) => ({
573
+ ...o,
574
+ disable_sign_ups: !!o.disable_sign_ups,
575
+ addons: o.addons ? JSON.parse(o.addons) : {},
576
+ callbacks: o.callbacks ? JSON.parse(o.callbacks) : [],
577
+ allowed_origins: o.allowed_origins ? JSON.parse(o.allowed_origins) : [],
578
+ web_origins: o.web_origins ? JSON.parse(o.web_origins) : [],
579
+ allowed_logout_urls: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : [],
580
+ allowed_clients: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : []
581
581
  }))
582
582
  });
583
583
  }
584
- function kt(t) {
584
+ function $t(t) {
585
585
  return async (e, a) => {
586
586
  const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
587
- return r ? _({
587
+ return r ? f({
588
588
  ...r,
589
589
  disable_sign_ups: !!r.disable_sign_ups,
590
590
  addons: JSON.parse(r.addons),
@@ -595,12 +595,12 @@ function kt(t) {
595
595
  }) : null;
596
596
  };
597
597
  }
598
- function $t(t) {
598
+ function Dt(t) {
599
599
  return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
600
600
  }
601
- function Dt(t) {
601
+ function It(t) {
602
602
  return async (e, a, r) => {
603
- const o = {
603
+ const n = {
604
604
  ...r,
605
605
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
606
606
  allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
@@ -611,22 +611,22 @@ function Dt(t) {
611
611
  addons: r.addons ? JSON.stringify(r.addons) : "{}",
612
612
  disable_sign_ups: r.disable_sign_ups ? 1 : 0
613
613
  };
614
- return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
614
+ return await t.updateTable("applications").set(n).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
615
615
  };
616
616
  }
617
- function It(t) {
617
+ function Pt(t) {
618
618
  return {
619
- create: St(t),
620
- list: Ot(t),
621
- get: kt(t),
622
- remove: $t(t),
623
- update: Dt(t)
619
+ create: Ot(t),
620
+ list: kt(t),
621
+ get: $t(t),
622
+ remove: Dt(t),
623
+ update: It(t)
624
624
  };
625
625
  }
626
- function Pt(t) {
626
+ function jt(t) {
627
627
  return async (e, a) => {
628
628
  const r = {
629
- id: k(),
629
+ id: S(),
630
630
  ...a,
631
631
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
632
632
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -639,62 +639,62 @@ function Pt(t) {
639
639
  }).execute(), r;
640
640
  };
641
641
  }
642
- function jt(t) {
642
+ function Mt(t) {
643
643
  return async (e, a = {
644
644
  page: 0,
645
645
  per_page: 50,
646
646
  include_totals: !1
647
647
  }) => {
648
648
  let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
649
- a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
649
+ a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
650
650
  const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
651
- (d) => _({
651
+ (d) => f({
652
652
  ...d,
653
653
  options: JSON.parse(d.options)
654
654
  })
655
- ), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
655
+ ), { count: c } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
656
656
  return {
657
657
  connections: s,
658
658
  start: a.page * a.per_page,
659
659
  limit: a.per_page,
660
- length: x(l)
660
+ length: b(c)
661
661
  };
662
662
  };
663
663
  }
664
- function Mt(t) {
664
+ function Ft(t) {
665
665
  return async (e, a) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
666
666
  }
667
- function Ft(t) {
667
+ function At(t) {
668
668
  return async (e, a) => {
669
669
  const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
670
- return r ? _({
670
+ return r ? f({
671
671
  ...r,
672
672
  options: JSON.parse(r.options)
673
673
  }) : null;
674
674
  };
675
675
  }
676
- function At(t) {
676
+ function Lt(t) {
677
677
  return async (e, a, r) => {
678
- const o = {
678
+ const n = {
679
679
  ...r,
680
680
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
681
681
  };
682
682
  return await t.updateTable("connections").set({
683
- ...o,
684
- options: o.options ? JSON.stringify(o.options) : void 0
683
+ ...n,
684
+ options: n.options ? JSON.stringify(n.options) : void 0
685
685
  }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
686
686
  };
687
687
  }
688
- function Lt(t) {
688
+ function zt(t) {
689
689
  return {
690
- create: Pt(t),
691
- get: Ft(t),
692
- list: jt(t),
693
- remove: Mt(t),
694
- update: At(t)
690
+ create: jt(t),
691
+ get: At(t),
692
+ list: Mt(t),
693
+ remove: Ft(t),
694
+ update: Lt(t)
695
695
  };
696
696
  }
697
- function zt(t) {
697
+ function Jt(t) {
698
698
  return {
699
699
  get: async (e) => {
700
700
  const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
@@ -703,12 +703,12 @@ function zt(t) {
703
703
  const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
704
704
  if (!r)
705
705
  throw new V(404, { message: "Tenant not found" });
706
- const o = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
706
+ const n = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
707
707
  return {
708
708
  ...a,
709
- connections: o.map(
710
- (s) => Ke.parse(
711
- _({
709
+ connections: n.map(
710
+ (s) => Re.parse(
711
+ f({
712
712
  ...s,
713
713
  options: s.options ? JSON.parse(s.options) : {}
714
714
  })
@@ -720,7 +720,7 @@ function zt(t) {
720
720
  web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
721
721
  allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
722
722
  allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
723
- tenant: _(r),
723
+ tenant: f(r),
724
724
  // this is really an integer in the database
725
725
  disable_sign_ups: !!a.disable_sign_ups
726
726
  };
@@ -735,25 +735,25 @@ function Et(t) {
735
735
  ])
736
736
  ).selectAll().execute();
737
737
  }
738
- function Jt(t) {
738
+ function Kt(t) {
739
739
  return async (e) => {
740
740
  await t.insertInto("keys").values({ ...e, created_at: (/* @__PURE__ */ new Date()).toDateString() }).execute();
741
741
  };
742
742
  }
743
- function Kt(t) {
743
+ function Rt(t) {
744
744
  return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
745
745
  }
746
- function Rt(t) {
746
+ function Ut(t) {
747
747
  return {
748
- create: Jt(t),
748
+ create: Kt(t),
749
749
  list: Et(t),
750
- update: Kt(t)
750
+ update: Rt(t)
751
751
  };
752
752
  }
753
- function Ut(t) {
753
+ function Bt(t) {
754
754
  return async (e, a) => {
755
755
  const r = {
756
- custom_domain_id: k(),
756
+ custom_domain_id: S(),
757
757
  status: "pending",
758
758
  primary: !1,
759
759
  ...a
@@ -767,13 +767,13 @@ function Ut(t) {
767
767
  }).execute(), r;
768
768
  };
769
769
  }
770
- function Bt(t) {
770
+ function Qt(t) {
771
771
  return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((r) => ({
772
772
  ...r,
773
773
  primary: r.primary === 1
774
774
  }));
775
775
  }
776
- function Qt(t) {
776
+ function qt(t) {
777
777
  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;
778
778
  }
779
779
  function Vt(t) {
@@ -787,15 +787,15 @@ function Vt(t) {
787
787
  }
788
788
  function Wt(t) {
789
789
  return async (e, a, r) => {
790
- const o = {
790
+ const n = {
791
791
  ...r,
792
792
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
793
793
  primary: r.primary ? 1 : 0
794
794
  };
795
- return (await t.updateTable("custom_domains").set(o).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
795
+ return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
796
796
  };
797
797
  }
798
- function qt(t) {
798
+ function Gt(t) {
799
799
  return async (e) => {
800
800
  const a = await t.selectFrom("custom_domains").where("custom_domains.domain", "=", e).selectAll().executeTakeFirst();
801
801
  return a ? {
@@ -804,121 +804,121 @@ function qt(t) {
804
804
  } : null;
805
805
  };
806
806
  }
807
- function Gt(t) {
807
+ function Ht(t) {
808
808
  return {
809
- create: Ut(t),
809
+ create: Bt(t),
810
810
  get: Vt(t),
811
- getByDomain: qt(t),
812
- list: Bt(t),
813
- remove: Qt(t),
811
+ getByDomain: Gt(t),
812
+ list: Qt(t),
813
+ remove: qt(t),
814
814
  update: Wt(t)
815
815
  };
816
816
  }
817
- function Ht(t) {
817
+ function Xt(t) {
818
818
  return async (e) => {
819
819
  const [a] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
820
820
  if (!a)
821
821
  return null;
822
822
  const {
823
823
  tenant_id: r,
824
- colors_primary: o,
825
- colors_page_background_type: n,
824
+ colors_primary: n,
825
+ colors_page_background_type: o,
826
826
  colors_page_background_start: s,
827
- colors_page_background_end: l,
827
+ colors_page_background_end: c,
828
828
  colors_page_background_angle_dev: d,
829
- font_url: g,
829
+ font_url: h,
830
830
  ...m
831
831
  } = a;
832
- return _({
832
+ return f({
833
833
  ...m,
834
834
  colors: {
835
- primary: o,
835
+ primary: n,
836
836
  page_background: {
837
- type: n,
837
+ type: o,
838
838
  start: s,
839
- end: l,
839
+ end: c,
840
840
  angle_deg: d
841
841
  }
842
842
  },
843
- font: g ? { url: g } : void 0
843
+ font: h ? { url: h } : void 0
844
844
  });
845
845
  };
846
846
  }
847
- function Xt(t) {
847
+ function Yt(t) {
848
848
  return async (e, a) => {
849
- var s, l, d, g, m, w, b, Z, ee, te, ae, re, ne, oe, se, ie, de, ce;
850
- const { colors: r, font: o, ...n } = a;
849
+ var s, c, d, h, m, w, x, ee, te, ae, re, ne, oe, se, ie, de, ce, le;
850
+ const { colors: r, font: n, ...o } = a;
851
851
  try {
852
852
  await t.insertInto("branding").values({
853
- ...n,
853
+ ...o,
854
854
  colors_primary: r == null ? void 0 : r.primary,
855
- colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
856
- colors_page_background_start: (g = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
855
+ colors_page_background_type: (c = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
856
+ colors_page_background_start: (h = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : h.start,
857
857
  colors_page_background_end: (w = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : w.end,
858
- colors_page_background_angle_dev: (Z = (b = a.colors) == null ? void 0 : b.page_background) == null ? void 0 : Z.angle_deg,
859
- font_url: (ee = a.font) == null ? void 0 : ee.url,
858
+ colors_page_background_angle_dev: (ee = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : ee.angle_deg,
859
+ font_url: (te = a.font) == null ? void 0 : te.url,
860
860
  tenant_id: e
861
861
  }).execute();
862
862
  } catch {
863
863
  await t.updateTable("branding").set({
864
- ...n,
864
+ ...o,
865
865
  colors_primary: r == null ? void 0 : r.primary,
866
- colors_page_background_type: (ae = (te = a.colors) == null ? void 0 : te.page_background) == null ? void 0 : ae.type,
867
- colors_page_background_start: (ne = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : ne.start,
868
- colors_page_background_end: (se = (oe = a.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
869
- colors_page_background_angle_dev: (de = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : de.angle_deg,
870
- font_url: (ce = a.font) == null ? void 0 : ce.url
866
+ colors_page_background_type: (re = (ae = a.colors) == null ? void 0 : ae.page_background) == null ? void 0 : re.type,
867
+ colors_page_background_start: (oe = (ne = a.colors) == null ? void 0 : ne.page_background) == null ? void 0 : oe.start,
868
+ colors_page_background_end: (ie = (se = a.colors) == null ? void 0 : se.page_background) == null ? void 0 : ie.end,
869
+ colors_page_background_angle_dev: (ce = (de = a.colors) == null ? void 0 : de.page_background) == null ? void 0 : ce.angle_deg,
870
+ font_url: (le = a.font) == null ? void 0 : le.url
871
871
  }).where("tenant_id", "=", e).execute();
872
872
  }
873
873
  };
874
874
  }
875
- function Yt(t) {
875
+ function Zt(t) {
876
876
  return {
877
- get: Ht(t),
878
- set: Xt(t)
877
+ get: Xt(t),
878
+ set: Yt(t)
879
879
  };
880
880
  }
881
- function Zt(t) {
881
+ function ea(t) {
882
882
  return async (e, a = {
883
883
  page: 0,
884
884
  per_page: 50,
885
885
  include_totals: !1
886
886
  }) => {
887
887
  let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
888
- a.q && (r = O(t, r, a.q, ["url"]));
889
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
888
+ a.q && (r = T(t, r, a.q, ["url"]));
889
+ const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
890
890
  return {
891
- hooks: n.map((d) => {
892
- const { tenant_id: g, enabled: m, synchronous: w, ...b } = d;
893
- return _({
894
- ...b,
891
+ hooks: o.map((d) => {
892
+ const { tenant_id: h, enabled: m, synchronous: w, ...x } = d;
893
+ return f({
894
+ ...x,
895
895
  enabled: !!m,
896
896
  synchronous: !!w
897
897
  });
898
898
  }),
899
899
  start: a.page * a.per_page,
900
900
  limit: a.per_page,
901
- length: x(s)
901
+ length: b(s)
902
902
  };
903
903
  };
904
904
  }
905
- function ea(t) {
905
+ function ta(t) {
906
906
  return async (e, a) => {
907
907
  const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
908
- return r ? _({
908
+ return r ? f({
909
909
  ...r,
910
910
  enabled: !!r.enabled,
911
911
  synchronous: !!r.synchronous
912
912
  }) : null;
913
913
  };
914
914
  }
915
- function ta(t) {
915
+ function aa(t) {
916
916
  return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
917
917
  }
918
- function aa(t) {
918
+ function ra(t) {
919
919
  return async (e, a) => {
920
920
  const r = {
921
- hook_id: k(),
921
+ hook_id: S(),
922
922
  ...a,
923
923
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
924
924
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -931,128 +931,128 @@ function aa(t) {
931
931
  }).execute(), r;
932
932
  };
933
933
  }
934
- function ra(t) {
934
+ function na(t) {
935
935
  return async (e, a, r) => {
936
- const o = {
936
+ const n = {
937
937
  ...r,
938
938
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
939
939
  enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
940
940
  synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
941
941
  };
942
- return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
942
+ return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
943
943
  };
944
944
  }
945
- function na(t) {
945
+ function oa(t) {
946
946
  return {
947
- create: aa(t),
948
- get: ea(t),
949
- list: Zt(t),
950
- update: ra(t),
951
- remove: ta(t)
947
+ create: ra(t),
948
+ get: ta(t),
949
+ list: ea(t),
950
+ update: na(t),
951
+ remove: aa(t)
952
952
  };
953
953
  }
954
- function E(t, e = "", a = {}) {
954
+ function J(t, e = "", a = {}) {
955
955
  for (let r in t)
956
956
  if (Object.prototype.hasOwnProperty.call(t, r)) {
957
- const o = e ? `${e}_${r}` : r;
958
- typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? E(t[r], o, a) : a[o] = t[r];
957
+ const n = e ? `${e}_${r}` : r;
958
+ typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? J(t[r], n, a) : a[n] = t[r];
959
959
  }
960
960
  return a;
961
961
  }
962
- function oa(t, e) {
962
+ function sa(t, e) {
963
963
  const a = {};
964
- for (const [r, o] of Object.entries(t)) {
965
- const n = e.find(
964
+ for (const [r, n] of Object.entries(t)) {
965
+ const o = e.find(
966
966
  (s) => r.startsWith(`${s}_`)
967
967
  );
968
- if (!n)
969
- a[r] = o;
968
+ if (!o)
969
+ a[r] = n;
970
970
  else {
971
- const s = r.slice(n.length + 1);
972
- a[n] = {
973
- ...a[n],
974
- [s]: o
971
+ const s = r.slice(o.length + 1);
972
+ a[o] = {
973
+ ...a[o],
974
+ [s]: n
975
975
  };
976
976
  }
977
977
  }
978
978
  return a;
979
979
  }
980
- function sa(t) {
980
+ function ia(t) {
981
981
  return async (e, a) => {
982
982
  const r = {
983
- themeId: k(),
983
+ themeId: S(),
984
984
  ...a,
985
985
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
986
986
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
987
987
  };
988
- return await t.insertInto("themes").values({ ...E(r), tenant_id: e }).execute(), r;
988
+ return await t.insertInto("themes").values({ ...J(r), tenant_id: e }).execute(), r;
989
989
  };
990
990
  }
991
- function ia(t) {
991
+ function da(t) {
992
992
  return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
993
993
  }
994
- function da(t) {
994
+ function ca(t) {
995
995
  return async (e, a) => {
996
996
  const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
997
- return r ? _(r) : null;
997
+ return r ? f(r) : null;
998
998
  };
999
999
  }
1000
- function ca(t) {
1000
+ function la(t) {
1001
1001
  return async (e, a, r) => {
1002
- const o = E({
1002
+ const n = J({
1003
1003
  ...r,
1004
1004
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1005
1005
  });
1006
- return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1006
+ return await t.updateTable("themes").set(n).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1007
1007
  };
1008
1008
  }
1009
- function la(t) {
1009
+ function ua(t) {
1010
1010
  return {
1011
- create: sa(t),
1012
- get: da(t),
1013
- remove: ia(t),
1014
- update: ca(t)
1011
+ create: ia(t),
1012
+ get: ca(t),
1013
+ remove: da(t),
1014
+ update: la(t)
1015
1015
  };
1016
1016
  }
1017
- function ua(t) {
1017
+ function ma(t) {
1018
1018
  return async (e, a) => {
1019
- const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("login_sessions").where("login_sessions.expires_at", ">", r).where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1020
- return o ? Re.parse(
1021
- oa(_(o), ["authParams"])
1019
+ const r = (/* @__PURE__ */ new Date()).toISOString(), n = await t.selectFrom("login_sessions").where("login_sessions.expires_at", ">", r).where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1020
+ return n ? Ue.parse(
1021
+ sa(f(n), ["authParams"])
1022
1022
  ) : null;
1023
1023
  };
1024
1024
  }
1025
- function ma(t) {
1025
+ function ha(t) {
1026
1026
  return async (e, a) => {
1027
- var o;
1027
+ var n;
1028
1028
  const r = {
1029
- id: k(),
1029
+ id: S(),
1030
1030
  ...a,
1031
- authorization_url: (o = a.authorization_url) == null ? void 0 : o.slice(0, 1024),
1031
+ authorization_url: (n = a.authorization_url) == null ? void 0 : n.slice(0, 1024),
1032
1032
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1033
1033
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1034
1034
  };
1035
- return await t.insertInto("login_sessions").values({ ...E(r), tenant_id: e }).execute(), r;
1035
+ return await t.insertInto("login_sessions").values({ ...J(r), tenant_id: e }).execute(), r;
1036
1036
  };
1037
1037
  }
1038
- function ha(t) {
1039
- return async (e, a, r) => (await t.updateTable("login_sessions").set(E(r)).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
1040
- }
1041
1038
  function _a(t) {
1042
- return async (e, a) => (await t.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", e).where("login_sessions.id", "=", a).execute()).length > 0;
1039
+ return async (e, a, r) => (await t.updateTable("login_sessions").set(J(r)).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
1043
1040
  }
1044
1041
  function fa(t) {
1042
+ return async (e, a) => (await t.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", e).where("login_sessions.id", "=", a).execute()).length > 0;
1043
+ }
1044
+ function pa(t) {
1045
1045
  return {
1046
- create: ma(t),
1047
- get: ua(t),
1048
- update: ha(t),
1049
- remove: _a(t)
1046
+ create: ha(t),
1047
+ get: ma(t),
1048
+ update: _a(t),
1049
+ remove: fa(t)
1050
1050
  };
1051
1051
  }
1052
- function pa(t) {
1052
+ function ga(t) {
1053
1053
  return async (e) => {
1054
1054
  const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1055
- return _({
1055
+ return f({
1056
1056
  identifier_first: !!(a != null && a.identifier_first),
1057
1057
  password_first: !!(a != null && a.password_first),
1058
1058
  webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
@@ -1060,8 +1060,8 @@ function pa(t) {
1060
1060
  });
1061
1061
  };
1062
1062
  }
1063
- function he(t) {
1064
- return _({
1063
+ function _e(t) {
1064
+ return f({
1065
1065
  ...t,
1066
1066
  webauthn_platform_first_factor: t.webauthn_platform_first_factor ? !!t.webauthn_platform_first_factor : void 0,
1067
1067
  identifier_first: t.identifier_first ? !!t.identifier_first : void 0,
@@ -1069,78 +1069,78 @@ function he(t) {
1069
1069
  universal_login_experience: t.universal_login_experience
1070
1070
  });
1071
1071
  }
1072
- function ga(t) {
1072
+ function ya(t) {
1073
1073
  return async (e, a) => {
1074
1074
  try {
1075
- const r = Ue.parse(a);
1075
+ const r = Be.parse(a);
1076
1076
  await t.insertInto("prompt_settings").values({
1077
- ...he(r),
1077
+ ..._e(r),
1078
1078
  tenant_id: e
1079
1079
  }).execute();
1080
1080
  } catch {
1081
- await t.updateTable("prompt_settings").set(he(a)).where("tenant_id", "=", e).execute();
1081
+ await t.updateTable("prompt_settings").set(_e(a)).where("tenant_id", "=", e).execute();
1082
1082
  }
1083
1083
  };
1084
1084
  }
1085
- function ya(t) {
1085
+ function wa(t) {
1086
1086
  return {
1087
- get: pa(t),
1088
- set: ga(t)
1087
+ get: ga(t),
1088
+ set: ya(t)
1089
1089
  };
1090
1090
  }
1091
- function wa(t) {
1091
+ function va(t) {
1092
1092
  return async (e) => {
1093
1093
  const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1094
1094
  if (!a)
1095
1095
  return null;
1096
1096
  const {
1097
1097
  tenant_id: r,
1098
- credentials: o,
1099
- settings: n,
1098
+ credentials: n,
1099
+ settings: o,
1100
1100
  enabled: s,
1101
- ...l
1101
+ ...c
1102
1102
  } = a;
1103
- return _({
1104
- ...l,
1105
- credentials: JSON.parse(o),
1106
- settings: JSON.parse(n),
1103
+ return f({
1104
+ ...c,
1105
+ credentials: JSON.parse(n),
1106
+ settings: JSON.parse(o),
1107
1107
  enabled: !!s
1108
1108
  });
1109
1109
  };
1110
1110
  }
1111
- function va(t) {
1111
+ function Na(t) {
1112
1112
  return async (e, a) => {
1113
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1113
+ const { credentials: r, settings: n, enabled: o, ...s } = a;
1114
1114
  await t.updateTable("email_providers").set({
1115
1115
  ...s,
1116
1116
  credentials: r ? JSON.stringify(r) : void 0,
1117
- settings: o ? JSON.stringify(o) : void 0,
1118
- enabled: n !== void 0 ? n ? 1 : 0 : void 0
1117
+ settings: n ? JSON.stringify(n) : void 0,
1118
+ enabled: o !== void 0 ? o ? 1 : 0 : void 0
1119
1119
  }).where("tenant_id", "=", e).execute();
1120
1120
  };
1121
1121
  }
1122
- function Na(t) {
1122
+ function Ca(t) {
1123
1123
  return async (e, a) => {
1124
- const { credentials: r, settings: o, enabled: n, ...s } = a;
1124
+ const { credentials: r, settings: n, enabled: o, ...s } = a;
1125
1125
  await t.insertInto("email_providers").values({
1126
1126
  ...s,
1127
- enabled: n ? 1 : 0,
1127
+ enabled: o ? 1 : 0,
1128
1128
  credentials: JSON.stringify(r),
1129
- settings: JSON.stringify(o),
1129
+ settings: JSON.stringify(n),
1130
1130
  tenant_id: e,
1131
1131
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1132
1132
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1133
1133
  }).execute();
1134
1134
  };
1135
1135
  }
1136
- function Ca(t) {
1136
+ function ba(t) {
1137
1137
  return {
1138
- get: wa(t),
1139
- create: Na(t),
1140
- update: va(t)
1138
+ get: va(t),
1139
+ create: Ca(t),
1140
+ update: Na(t)
1141
1141
  };
1142
1142
  }
1143
- function ba(t) {
1143
+ function xa(t) {
1144
1144
  return async (e, a) => {
1145
1145
  const r = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", a).selectAll().executeTakeFirst();
1146
1146
  return r ? {
@@ -1151,7 +1151,7 @@ function ba(t) {
1151
1151
  } : null;
1152
1152
  };
1153
1153
  }
1154
- function xa(t) {
1154
+ function Ta(t) {
1155
1155
  return async (e, a) => {
1156
1156
  const r = {
1157
1157
  ...a,
@@ -1166,40 +1166,40 @@ function xa(t) {
1166
1166
  }).execute(), { ...a, ...r };
1167
1167
  };
1168
1168
  }
1169
- function Ta(t) {
1169
+ function Sa(t) {
1170
1170
  return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1171
1171
  }
1172
- function Sa(t) {
1172
+ function Oa(t) {
1173
1173
  return async (e, a, r) => {
1174
- const o = {
1174
+ const n = {
1175
1175
  ...r,
1176
1176
  device: r.device ? JSON.stringify(r.device) : void 0,
1177
1177
  resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
1178
1178
  rotating: r.rotating ? 1 : 0
1179
1179
  };
1180
- return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1180
+ return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1181
1181
  };
1182
1182
  }
1183
- function Oa(t) {
1183
+ function ka(t) {
1184
1184
  return async (e, a = {
1185
1185
  page: 0,
1186
1186
  per_page: 50,
1187
1187
  include_totals: !1
1188
1188
  }) => {
1189
1189
  let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1190
- a.q && (r = O(t, r, a.q, ["token", "session_id"]));
1191
- let o = r;
1190
+ a.q && (r = T(t, r, a.q, ["token", "session_id"]));
1191
+ let n = r;
1192
1192
  if (a.sort && a.sort.sort_by) {
1193
1193
  const { ref: d } = t.dynamic;
1194
- o = o.orderBy(
1194
+ n = n.orderBy(
1195
1195
  d(a.sort.sort_by),
1196
1196
  a.sort.sort_order
1197
1197
  );
1198
1198
  }
1199
- o = o.offset(a.page * a.per_page).limit(a.per_page);
1200
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
1199
+ n = n.offset(a.page * a.per_page).limit(a.per_page);
1200
+ const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
1201
1201
  return {
1202
- refresh_tokens: n.map((d) => ({
1202
+ refresh_tokens: o.map((d) => ({
1203
1203
  ...d,
1204
1204
  rotating: !!d.rotating,
1205
1205
  device: d.device ? JSON.parse(d.device) : {},
@@ -1207,20 +1207,20 @@ function Oa(t) {
1207
1207
  })),
1208
1208
  start: a.page * a.per_page,
1209
1209
  limit: a.per_page,
1210
- length: l
1210
+ length: c
1211
1211
  };
1212
1212
  };
1213
1213
  }
1214
- function ka(t) {
1214
+ function $a(t) {
1215
1215
  return {
1216
- create: xa(t),
1217
- get: ba(t),
1218
- list: Oa(t),
1219
- remove: Ta(t),
1220
- update: Sa(t)
1216
+ create: Ta(t),
1217
+ get: xa(t),
1218
+ list: ka(t),
1219
+ remove: Sa(t),
1220
+ update: Oa(t)
1221
1221
  };
1222
1222
  }
1223
- function $a(t) {
1223
+ function Da(t) {
1224
1224
  return async () => {
1225
1225
  const e = new Date(Date.now() - 864e5).toISOString(), a = new Date(
1226
1226
  Date.now() - 1e3 * 60 * 60 * 24 * 7
@@ -1228,89 +1228,191 @@ function $a(t) {
1228
1228
  Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
1229
1229
  ).toISOString();
1230
1230
  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("expires_at", "<", a).limit(1e5).execute(), console.log("delete sessions");
1231
- const o = await t.selectFrom("sessions").select("id").where(
1232
- (n) => n.or([
1233
- n("expires_at", "<", a),
1234
- n("idle_expires_at", "<", a)
1231
+ const n = await t.selectFrom("sessions").select("id").where(
1232
+ (o) => o.or([
1233
+ o("expires_at", "<", a),
1234
+ o("idle_expires_at", "<", a)
1235
1235
  ])
1236
1236
  ).where(
1237
1237
  "id",
1238
1238
  "not in",
1239
1239
  t.selectFrom("refresh_tokens").select("session_id")
1240
1240
  ).limit(1e5).execute();
1241
- o.length > 0 && await t.deleteFrom("sessions").where(
1241
+ n.length > 0 && await t.deleteFrom("sessions").where(
1242
1242
  "id",
1243
1243
  "in",
1244
- o.map((n) => n.id)
1244
+ n.map((o) => o.id)
1245
1245
  ).execute(), console.log("cleanup complete");
1246
1246
  };
1247
1247
  }
1248
- function Da(t) {
1248
+ function Ia(t) {
1249
+ return async (e, a) => {
1250
+ const r = K.parse({
1251
+ id: S(),
1252
+ ...a,
1253
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1254
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1255
+ });
1256
+ return await t.insertInto("forms").values({
1257
+ ...r,
1258
+ // Store complex objects as JSON strings
1259
+ nodes: JSON.stringify(r.nodes || []),
1260
+ start: JSON.stringify(r.start || {}),
1261
+ ending: JSON.stringify(r.ending || {}),
1262
+ tenant_id: e
1263
+ }).execute(), K.parse(r);
1264
+ };
1265
+ }
1266
+ function Pa(t) {
1267
+ return async (e, a = {
1268
+ page: 0,
1269
+ per_page: 50,
1270
+ include_totals: !1
1271
+ }) => {
1272
+ let r = t.selectFrom("forms").where("tenant_id", "=", e);
1273
+ a != null && a.q && (r = T(t, r, a.q, []));
1274
+ const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((d) => {
1275
+ const h = { ...d };
1276
+ if (typeof h.nodes == "string")
1277
+ try {
1278
+ h.nodes = JSON.parse(h.nodes);
1279
+ } catch {
1280
+ }
1281
+ if (typeof h.start == "string")
1282
+ try {
1283
+ h.start = JSON.parse(h.start);
1284
+ } catch {
1285
+ }
1286
+ if (typeof h.ending == "string")
1287
+ try {
1288
+ h.ending = JSON.parse(h.ending);
1289
+ } catch {
1290
+ }
1291
+ return K.parse(f(h));
1292
+ }), { count: c } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
1293
+ return {
1294
+ forms: s,
1295
+ start: a.page * a.per_page,
1296
+ limit: a.per_page,
1297
+ length: b(c)
1298
+ };
1299
+ };
1300
+ }
1301
+ function ja(t) {
1302
+ return async (e, a) => {
1303
+ const { numDeletedRows: r } = await t.deleteFrom("forms").where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1304
+ return r > 0;
1305
+ };
1306
+ }
1307
+ function Ma(t) {
1308
+ return async (e, a) => {
1309
+ const r = await t.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1310
+ if (!r) return null;
1311
+ const n = { ...r };
1312
+ if (typeof n.nodes == "string")
1313
+ try {
1314
+ n.nodes = JSON.parse(n.nodes);
1315
+ } catch {
1316
+ }
1317
+ if (typeof n.start == "string")
1318
+ try {
1319
+ n.start = JSON.parse(n.start);
1320
+ } catch {
1321
+ }
1322
+ if (typeof n.ending == "string")
1323
+ try {
1324
+ n.ending = JSON.parse(n.ending);
1325
+ } catch {
1326
+ }
1327
+ return K.parse(f(n));
1328
+ };
1329
+ }
1330
+ function Fa(t) {
1331
+ return async (e, a, r) => {
1332
+ const n = {
1333
+ ...r,
1334
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1335
+ };
1336
+ r.nodes && (n.fields = JSON.stringify(r.nodes)), r.start && (n.controls = JSON.stringify(r.start)), r.ending && (n.layout = JSON.stringify(r.ending));
1337
+ const { numUpdatedRows: o } = await t.updateTable("forms").set(n).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1338
+ return o > 0;
1339
+ };
1340
+ }
1341
+ function Aa(t) {
1342
+ return {
1343
+ create: Ia(t),
1344
+ get: Ma(t),
1345
+ list: Pa(t),
1346
+ remove: ja(t),
1347
+ update: Fa(t)
1348
+ };
1349
+ }
1350
+ function La(t) {
1249
1351
  return t[t.length - 1];
1250
1352
  }
1251
- function p(t) {
1353
+ function g(t) {
1252
1354
  return Object.freeze(t);
1253
1355
  }
1254
- const J = p({
1356
+ const E = g({
1255
1357
  is(t) {
1256
1358
  return t.kind === "IdentifierNode";
1257
1359
  },
1258
1360
  create(t) {
1259
- return p({
1361
+ return g({
1260
1362
  kind: "IdentifierNode",
1261
1363
  name: t
1262
1364
  });
1263
1365
  }
1264
- }), W = p({
1366
+ }), W = g({
1265
1367
  is(t) {
1266
1368
  return t.kind === "SchemableIdentifierNode";
1267
1369
  },
1268
1370
  create(t) {
1269
- return p({
1371
+ return g({
1270
1372
  kind: "SchemableIdentifierNode",
1271
- identifier: J.create(t)
1373
+ identifier: E.create(t)
1272
1374
  });
1273
1375
  },
1274
1376
  createWithSchema(t, e) {
1275
- return p({
1377
+ return g({
1276
1378
  kind: "SchemableIdentifierNode",
1277
- schema: J.create(t),
1278
- identifier: J.create(e)
1379
+ schema: E.create(t),
1380
+ identifier: E.create(e)
1279
1381
  });
1280
1382
  }
1281
- }), Ia = p({
1383
+ }), za = g({
1282
1384
  is(t) {
1283
1385
  return t.kind === "AliasNode";
1284
1386
  },
1285
1387
  create(t, e) {
1286
- return p({
1388
+ return g({
1287
1389
  kind: "AliasNode",
1288
1390
  node: t,
1289
1391
  alias: e
1290
1392
  });
1291
1393
  }
1292
- }), U = p({
1394
+ }), B = g({
1293
1395
  is(t) {
1294
1396
  return t.kind === "TableNode";
1295
1397
  },
1296
1398
  create(t) {
1297
- return p({
1399
+ return g({
1298
1400
  kind: "TableNode",
1299
1401
  table: W.create(t)
1300
1402
  });
1301
1403
  },
1302
1404
  createWithSchema(t, e) {
1303
- return p({
1405
+ return g({
1304
1406
  kind: "TableNode",
1305
1407
  table: W.createWithSchema(t, e)
1306
1408
  });
1307
1409
  }
1308
1410
  });
1309
- var K;
1310
- class Pa {
1411
+ var R;
1412
+ class Ja {
1311
1413
  constructor() {
1312
1414
  j(this, "nodeStack", []);
1313
- y(this, K, p({
1415
+ y(this, R, g({
1314
1416
  AliasNode: this.transformAlias.bind(this),
1315
1417
  ColumnNode: this.transformColumn.bind(this),
1316
1418
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -1411,13 +1513,13 @@ class Pa {
1411
1513
  return e;
1412
1514
  this.nodeStack.push(e);
1413
1515
  const a = this.transformNodeImpl(e);
1414
- return this.nodeStack.pop(), p(a);
1516
+ return this.nodeStack.pop(), g(a);
1415
1517
  }
1416
1518
  transformNodeImpl(e) {
1417
- return c(this, K)[e.kind](e);
1519
+ return l(this, R)[e.kind](e);
1418
1520
  }
1419
1521
  transformNodeList(e) {
1420
- return e && p(e.map((a) => this.transformNode(a)));
1522
+ return e && g(e.map((a) => this.transformNode(a)));
1421
1523
  }
1422
1524
  transformSelectQuery(e) {
1423
1525
  return {
@@ -1516,7 +1618,7 @@ class Pa {
1516
1618
  transformRaw(e) {
1517
1619
  return {
1518
1620
  kind: "RawNode",
1519
- sqlFragments: p([...e.sqlFragments]),
1621
+ sqlFragments: g([...e.sqlFragments]),
1520
1622
  parameters: this.transformNodeList(e.parameters)
1521
1623
  };
1522
1624
  }
@@ -2140,8 +2242,8 @@ class Pa {
2140
2242
  return e;
2141
2243
  }
2142
2244
  }
2143
- K = new WeakMap();
2144
- const ja = p({
2245
+ R = new WeakMap();
2246
+ const Ea = g({
2145
2247
  AlterTableNode: !0,
2146
2248
  CreateIndexNode: !0,
2147
2249
  CreateSchemaNode: !0,
@@ -2160,88 +2262,88 @@ const ja = p({
2160
2262
  UpdateQueryNode: !0,
2161
2263
  MergeQueryNode: !0
2162
2264
  });
2163
- var P, T, S, f, ge, ye, we, $, q, ve;
2164
- class Ma extends Pa {
2265
+ var P, O, k, p, ye, we, ve, $, G, Ne;
2266
+ class Ka extends Ja {
2165
2267
  constructor(a) {
2166
2268
  super();
2167
- y(this, f);
2269
+ y(this, p);
2168
2270
  y(this, P);
2169
- y(this, T, /* @__PURE__ */ new Set());
2170
- y(this, S, /* @__PURE__ */ new Set());
2271
+ y(this, O, /* @__PURE__ */ new Set());
2272
+ y(this, k, /* @__PURE__ */ new Set());
2171
2273
  M(this, P, a);
2172
2274
  }
2173
2275
  transformNodeImpl(a) {
2174
- if (!u(this, f, ge).call(this, a))
2276
+ if (!u(this, p, ye).call(this, a))
2175
2277
  return super.transformNodeImpl(a);
2176
- const r = u(this, f, we).call(this, a);
2278
+ const r = u(this, p, ve).call(this, a);
2177
2279
  for (const s of r)
2178
- c(this, S).add(s);
2179
- const o = u(this, f, ye).call(this, a);
2180
- for (const s of o)
2181
- c(this, T).add(s);
2182
- const n = super.transformNodeImpl(a);
2183
- for (const s of o)
2184
- c(this, T).delete(s);
2280
+ l(this, k).add(s);
2281
+ const n = u(this, p, we).call(this, a);
2282
+ for (const s of n)
2283
+ l(this, O).add(s);
2284
+ const o = super.transformNodeImpl(a);
2285
+ for (const s of n)
2286
+ l(this, O).delete(s);
2185
2287
  for (const s of r)
2186
- c(this, S).delete(s);
2187
- return n;
2288
+ l(this, k).delete(s);
2289
+ return o;
2188
2290
  }
2189
2291
  transformSchemableIdentifier(a) {
2190
2292
  const r = super.transformSchemableIdentifier(a);
2191
- return r.schema || !c(this, T).has(a.identifier.name) ? r : {
2293
+ return r.schema || !l(this, O).has(a.identifier.name) ? r : {
2192
2294
  ...r,
2193
- schema: J.create(c(this, P))
2295
+ schema: E.create(l(this, P))
2194
2296
  };
2195
2297
  }
2196
2298
  transformReferences(a) {
2197
2299
  const r = super.transformReferences(a);
2198
2300
  return r.table.table.schema ? r : {
2199
2301
  ...r,
2200
- table: U.createWithSchema(c(this, P), r.table.table.identifier.name)
2302
+ table: B.createWithSchema(l(this, P), r.table.table.identifier.name)
2201
2303
  };
2202
2304
  }
2203
2305
  }
2204
- P = new WeakMap(), T = new WeakMap(), S = new WeakMap(), f = new WeakSet(), ge = function(a) {
2205
- return a.kind in ja;
2206
- }, ye = function(a) {
2207
- const r = /* @__PURE__ */ new Set();
2208
- if ("name" in a && a.name && W.is(a.name) && u(this, f, q).call(this, a.name, r), "from" in a && a.from)
2209
- for (const o of a.from.froms)
2210
- u(this, f, $).call(this, o, r);
2211
- if ("into" in a && a.into && u(this, f, $).call(this, a.into, r), "table" in a && a.table && u(this, f, $).call(this, a.table, r), "joins" in a && a.joins)
2212
- for (const o of a.joins)
2213
- u(this, f, $).call(this, o.table, r);
2214
- return "using" in a && a.using && u(this, f, $).call(this, a.using, r), r;
2306
+ P = new WeakMap(), O = new WeakMap(), k = new WeakMap(), p = new WeakSet(), ye = function(a) {
2307
+ return a.kind in Ea;
2215
2308
  }, we = function(a) {
2216
2309
  const r = /* @__PURE__ */ new Set();
2217
- return "with" in a && a.with && u(this, f, ve).call(this, a.with, r), r;
2310
+ if ("name" in a && a.name && W.is(a.name) && u(this, p, G).call(this, a.name, r), "from" in a && a.from)
2311
+ for (const n of a.from.froms)
2312
+ u(this, p, $).call(this, n, r);
2313
+ if ("into" in a && a.into && u(this, p, $).call(this, a.into, r), "table" in a && a.table && u(this, p, $).call(this, a.table, r), "joins" in a && a.joins)
2314
+ for (const n of a.joins)
2315
+ u(this, p, $).call(this, n.table, r);
2316
+ return "using" in a && a.using && u(this, p, $).call(this, a.using, r), r;
2317
+ }, ve = function(a) {
2318
+ const r = /* @__PURE__ */ new Set();
2319
+ return "with" in a && a.with && u(this, p, Ne).call(this, a.with, r), r;
2218
2320
  }, $ = function(a, r) {
2219
- const o = U.is(a) ? a : Ia.is(a) && U.is(a.node) ? a.node : null;
2220
- o && u(this, f, q).call(this, o.table, r);
2221
- }, q = function(a, r) {
2222
- const o = a.identifier.name;
2223
- !c(this, T).has(o) && !c(this, S).has(o) && r.add(o);
2224
- }, ve = function(a, r) {
2225
- for (const o of a.expressions) {
2226
- const n = o.name.table.table.identifier.name;
2227
- c(this, S).has(n) || r.add(n);
2321
+ const n = B.is(a) ? a : za.is(a) && B.is(a.node) ? a.node : null;
2322
+ n && u(this, p, G).call(this, n.table, r);
2323
+ }, G = function(a, r) {
2324
+ const n = a.identifier.name;
2325
+ !l(this, O).has(n) && !l(this, k).has(n) && r.add(n);
2326
+ }, Ne = function(a, r) {
2327
+ for (const n of a.expressions) {
2328
+ const o = n.name.table.table.identifier.name;
2329
+ l(this, k).has(o) || r.add(o);
2228
2330
  }
2229
2331
  };
2230
2332
  var L;
2231
- class Fa {
2333
+ class Ra {
2232
2334
  constructor(e) {
2233
2335
  y(this, L);
2234
- M(this, L, new Ma(e));
2336
+ M(this, L, new Ka(e));
2235
2337
  }
2236
2338
  transformQuery(e) {
2237
- return c(this, L).transformNode(e.node);
2339
+ return l(this, L).transformNode(e.node);
2238
2340
  }
2239
2341
  async transformResult(e) {
2240
2342
  return e.result;
2241
2343
  }
2242
2344
  }
2243
2345
  L = new WeakMap();
2244
- class Aa {
2346
+ class Ua {
2245
2347
  transformQuery(e) {
2246
2348
  return e.node;
2247
2349
  }
@@ -2249,13 +2351,13 @@ class Aa {
2249
2351
  return e.result;
2250
2352
  }
2251
2353
  }
2252
- const La = "kysely_migration", _e = "kysely_migration_lock", za = !1, B = "migration_lock", Ea = p({ __noMigrations__: !0 });
2253
- var h, i, F, v, N, D, Ce, C, be, xe, Te, Se, Oe, G, I, H, ke, $e, De, X, Ie, Pe, je, Me, Fe, A;
2254
- class Ne {
2354
+ const Ba = "kysely_migration", fe = "kysely_migration_lock", Qa = !1, Q = "migration_lock", qa = g({ __noMigrations__: !0 });
2355
+ var _, i, F, v, N, D, be, C, xe, Te, Se, Oe, ke, H, I, X, $e, De, Ie, Y, Pe, je, Me, Fe, Ae, A;
2356
+ class Ce {
2255
2357
  constructor(e) {
2256
2358
  y(this, i);
2257
- y(this, h);
2258
- M(this, h, p(e));
2359
+ y(this, _);
2360
+ M(this, _, g(e));
2259
2361
  }
2260
2362
  /**
2261
2363
  * Returns a {@link MigrationInfo} object for each migration.
@@ -2263,13 +2365,13 @@ class Ne {
2263
2365
  * The returned array is sorted by migration name.
2264
2366
  */
2265
2367
  async getMigrations() {
2266
- 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() : [];
2267
- return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2268
- const n = e.find((s) => s.name === r);
2368
+ const e = await u(this, i, I).call(this, l(this, i, N)) ? await l(this, _).db.withPlugin(l(this, i, C)).selectFrom(l(this, i, N)).select(["name", "timestamp"]).execute() : [];
2369
+ return (await u(this, i, Y).call(this)).map(({ name: r, ...n }) => {
2370
+ const o = e.find((s) => s.name === r);
2269
2371
  return {
2270
2372
  name: r,
2271
- migration: o,
2272
- executedAt: n ? new Date(n.timestamp) : void 0
2373
+ migration: n,
2374
+ executedAt: o ? new Date(o.timestamp) : void 0
2273
2375
  };
2274
2376
  });
2275
2377
  }
@@ -2347,16 +2449,16 @@ class Ne {
2347
2449
  * ```
2348
2450
  */
2349
2451
  async migrateTo(e) {
2350
- return u(this, i, F).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2351
- if (e === Ea)
2452
+ return u(this, i, F).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: n }) => {
2453
+ if (e === qa)
2352
2454
  return { direction: "Down", step: 1 / 0 };
2353
- if (!a.find((l) => l.name === e))
2455
+ if (!a.find((c) => c.name === e))
2354
2456
  throw new Error(`migration "${e}" doesn't exist`);
2355
- const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2356
- if (n !== -1)
2457
+ const o = r.indexOf(e), s = n.findIndex((c) => c.name === e);
2458
+ if (o !== -1)
2357
2459
  return {
2358
2460
  direction: "Down",
2359
- step: r.length - n - 1
2461
+ step: r.length - o - 1
2360
2462
  };
2361
2463
  if (s !== -1)
2362
2464
  return { direction: "Up", step: s + 1 };
@@ -2398,182 +2500,182 @@ class Ne {
2398
2500
  return u(this, i, F).call(this, () => ({ direction: "Down", step: 1 }));
2399
2501
  }
2400
2502
  }
2401
- h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2503
+ _ = new WeakMap(), i = new WeakSet(), F = async function(e) {
2402
2504
  try {
2403
- return await u(this, i, be).call(this), await u(this, i, ke).call(this, e);
2505
+ return await u(this, i, xe).call(this), await u(this, i, $e).call(this, e);
2404
2506
  } catch (a) {
2405
- return a instanceof Q ? a.resultSet : { error: a };
2507
+ return a instanceof q ? a.resultSet : { error: a };
2406
2508
  }
2407
2509
  }, v = function() {
2408
- return c(this, h).migrationTableSchema;
2510
+ return l(this, _).migrationTableSchema;
2409
2511
  }, N = function() {
2410
- return c(this, h).migrationTableName ?? La;
2512
+ return l(this, _).migrationTableName ?? Ba;
2411
2513
  }, D = function() {
2412
- return c(this, h).migrationLockTableName ?? _e;
2413
- }, Ce = function() {
2414
- return c(this, h).allowUnorderedMigrations ?? za;
2514
+ return l(this, _).migrationLockTableName ?? fe;
2515
+ }, be = function() {
2516
+ return l(this, _).allowUnorderedMigrations ?? Qa;
2415
2517
  }, C = function() {
2416
- return c(this, i, v) ? new Fa(c(this, i, v)) : new Aa();
2417
- }, be = async function() {
2418
- await u(this, i, xe).call(this), await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this);
2518
+ return l(this, i, v) ? new Ra(l(this, i, v)) : new Ua();
2419
2519
  }, xe = async function() {
2420
- if (c(this, i, v) && !await u(this, i, G).call(this))
2520
+ await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this), await u(this, i, ke).call(this);
2521
+ }, Te = async function() {
2522
+ if (l(this, i, v) && !await u(this, i, H).call(this))
2421
2523
  try {
2422
- await u(this, i, A).call(this, c(this, h).db.schema.createSchema(c(this, i, v)));
2524
+ await u(this, i, A).call(this, l(this, _).db.schema.createSchema(l(this, i, v)));
2423
2525
  } catch (e) {
2424
- if (!await u(this, i, G).call(this))
2526
+ if (!await u(this, i, H).call(this))
2425
2527
  throw e;
2426
2528
  }
2427
- }, Te = async function() {
2428
- if (!await u(this, i, I).call(this, c(this, i, N)))
2529
+ }, Se = async function() {
2530
+ if (!await u(this, i, I).call(this, l(this, i, N)))
2429
2531
  try {
2430
- c(this, i, v) && await u(this, i, A).call(this, c(this, h).db.schema.createSchema(c(this, i, v))), await u(this, i, A).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()));
2532
+ l(this, i, v) && await u(this, i, A).call(this, l(this, _).db.schema.createSchema(l(this, i, v))), await u(this, i, A).call(this, l(this, _).db.schema.withPlugin(l(this, i, C)).createTable(l(this, i, N)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2431
2533
  } catch (e) {
2432
- if (!await u(this, i, I).call(this, c(this, i, N)))
2534
+ if (!await u(this, i, I).call(this, l(this, i, N)))
2433
2535
  throw e;
2434
2536
  }
2435
- }, Se = async function() {
2436
- if (!await u(this, i, I).call(this, c(this, i, D)))
2537
+ }, Oe = async function() {
2538
+ if (!await u(this, i, I).call(this, l(this, i, D)))
2437
2539
  try {
2438
- await u(this, i, A).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)));
2540
+ await u(this, i, A).call(this, l(this, _).db.schema.withPlugin(l(this, i, C)).createTable(l(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2439
2541
  } catch (e) {
2440
- if (!await u(this, i, I).call(this, c(this, i, D)))
2542
+ if (!await u(this, i, I).call(this, l(this, i, D)))
2441
2543
  throw e;
2442
2544
  }
2443
- }, Oe = async function() {
2444
- if (!await u(this, i, H).call(this))
2545
+ }, ke = async function() {
2546
+ if (!await u(this, i, X).call(this))
2445
2547
  try {
2446
- await c(this, h).db.withPlugin(c(this, i, C)).insertInto(c(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2548
+ await l(this, _).db.withPlugin(l(this, i, C)).insertInto(l(this, i, D)).values({ id: Q, is_locked: 0 }).execute();
2447
2549
  } catch (e) {
2448
- if (!await u(this, i, H).call(this))
2550
+ if (!await u(this, i, X).call(this))
2449
2551
  throw e;
2450
2552
  }
2451
- }, G = async function() {
2452
- return (await c(this, h).db.introspection.getSchemas()).some((a) => a.name === c(this, i, v));
2553
+ }, H = async function() {
2554
+ return (await l(this, _).db.introspection.getSchemas()).some((a) => a.name === l(this, i, v));
2453
2555
  }, I = async function(e) {
2454
- const a = c(this, i, v);
2455
- return (await c(this, h).db.introspection.getTables({
2556
+ const a = l(this, i, v);
2557
+ return (await l(this, _).db.introspection.getTables({
2456
2558
  withInternalKyselyTables: !0
2457
- })).some((o) => o.name === e && (!a || o.schema === a));
2458
- }, H = async function() {
2459
- return !!await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2460
- }, ke = async function(e) {
2461
- const a = c(this, h).db.getExecutor().adapter, r = p({
2462
- lockTable: c(this, h).migrationLockTableName ?? _e,
2463
- lockRowId: B,
2464
- lockTableSchema: c(this, h).migrationTableSchema
2465
- }), o = async (n) => {
2559
+ })).some((n) => n.name === e && (!a || n.schema === a));
2560
+ }, X = async function() {
2561
+ return !!await l(this, _).db.withPlugin(l(this, i, C)).selectFrom(l(this, i, D)).where("id", "=", Q).select("id").executeTakeFirst();
2562
+ }, $e = async function(e) {
2563
+ const a = l(this, _).db.getExecutor().adapter, r = g({
2564
+ lockTable: l(this, _).migrationLockTableName ?? fe,
2565
+ lockRowId: Q,
2566
+ lockTableSchema: l(this, _).migrationTableSchema
2567
+ }), n = async (o) => {
2466
2568
  try {
2467
- await a.acquireMigrationLock(n, r);
2468
- const s = await u(this, i, $e).call(this, n);
2569
+ await a.acquireMigrationLock(o, r);
2570
+ const s = await u(this, i, De).call(this, o);
2469
2571
  if (s.migrations.length === 0)
2470
2572
  return { results: [] };
2471
- const { direction: l, step: d } = e(s);
2472
- return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, d) : l === "Up" ? await u(this, i, Fe).call(this, n, s, d) : { results: [] };
2573
+ const { direction: c, step: d } = e(s);
2574
+ return d <= 0 ? { results: [] } : c === "Down" ? await u(this, i, Fe).call(this, o, s, d) : c === "Up" ? await u(this, i, Ae).call(this, o, s, d) : { results: [] };
2473
2575
  } finally {
2474
- await a.releaseMigrationLock(n, r);
2576
+ await a.releaseMigrationLock(o, r);
2475
2577
  }
2476
2578
  };
2477
- return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2478
- }, $e = async function(e) {
2479
- const a = await u(this, i, X).call(this), r = await u(this, i, Ie).call(this, e);
2480
- u(this, i, Pe).call(this, a, r), c(this, i, Ce) || u(this, i, je).call(this, a, r);
2481
- const o = u(this, i, De).call(this, a, r);
2482
- return p({
2579
+ return a.supportsTransactionalDdl ? l(this, _).db.transaction().execute(n) : l(this, _).db.connection().execute(n);
2580
+ }, De = async function(e) {
2581
+ const a = await u(this, i, Y).call(this), r = await u(this, i, Pe).call(this, e);
2582
+ u(this, i, je).call(this, a, r), l(this, i, be) || u(this, i, Me).call(this, a, r);
2583
+ const n = u(this, i, Ie).call(this, a, r);
2584
+ return g({
2483
2585
  migrations: a,
2484
2586
  executedMigrations: r,
2485
- lastMigration: Da(r),
2486
- pendingMigrations: o
2587
+ lastMigration: La(r),
2588
+ pendingMigrations: n
2487
2589
  });
2488
- }, De = function(e, a) {
2590
+ }, Ie = function(e, a) {
2489
2591
  return e.filter((r) => !a.includes(r.name));
2490
- }, X = async function() {
2491
- const e = await c(this, h).provider.getMigrations();
2592
+ }, Y = async function() {
2593
+ const e = await l(this, _).provider.getMigrations();
2492
2594
  return Object.keys(e).sort().map((a) => ({
2493
2595
  ...e[a],
2494
2596
  name: a
2495
2597
  }));
2496
- }, Ie = async function(e) {
2497
- return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2498
- }, Pe = function(e, a) {
2598
+ }, Pe = async function(e) {
2599
+ return (await e.withPlugin(l(this, i, C)).selectFrom(l(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2600
+ }, je = function(e, a) {
2499
2601
  for (const r of a)
2500
- if (!e.some((o) => o.name === r))
2602
+ if (!e.some((n) => n.name === r))
2501
2603
  throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2502
- }, je = function(e, a) {
2604
+ }, Me = function(e, a) {
2503
2605
  for (let r = 0; r < a.length; ++r)
2504
2606
  if (e[r].name !== a[r])
2505
2607
  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.`);
2506
- }, Me = async function(e, a, r) {
2507
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2608
+ }, Fe = async function(e, a, r) {
2609
+ const n = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((c) => c.name === s)), o = n.map((s) => ({
2508
2610
  migrationName: s.name,
2509
2611
  direction: "Down",
2510
2612
  status: "NotExecuted"
2511
2613
  }));
2512
- for (let s = 0; s < n.length; ++s) {
2513
- const l = o[s];
2614
+ for (let s = 0; s < o.length; ++s) {
2615
+ const c = n[s];
2514
2616
  try {
2515
- l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, N)).where("name", "=", l.name).execute(), n[s] = {
2516
- migrationName: l.name,
2617
+ c.down && (await c.down(e), await e.withPlugin(l(this, i, C)).deleteFrom(l(this, i, N)).where("name", "=", c.name).execute(), o[s] = {
2618
+ migrationName: c.name,
2517
2619
  direction: "Down",
2518
2620
  status: "Success"
2519
2621
  });
2520
2622
  } catch (d) {
2521
- throw n[s] = {
2522
- migrationName: l.name,
2623
+ throw o[s] = {
2624
+ migrationName: c.name,
2523
2625
  direction: "Down",
2524
2626
  status: "Error"
2525
- }, new Q({
2627
+ }, new q({
2526
2628
  error: d,
2527
- results: n
2629
+ results: o
2528
2630
  });
2529
2631
  }
2530
2632
  }
2531
- return { results: n };
2532
- }, Fe = async function(e, a, r) {
2533
- const n = a.pendingMigrations.slice(0, r).map((s) => ({
2633
+ return { results: o };
2634
+ }, Ae = async function(e, a, r) {
2635
+ const o = a.pendingMigrations.slice(0, r).map((s) => ({
2534
2636
  migrationName: s.name,
2535
2637
  direction: "Up",
2536
2638
  status: "NotExecuted"
2537
2639
  }));
2538
- for (let s = 0; s < n.length; s++) {
2539
- const l = a.pendingMigrations[s];
2640
+ for (let s = 0; s < o.length; s++) {
2641
+ const c = a.pendingMigrations[s];
2540
2642
  try {
2541
- await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, N)).values({
2542
- name: l.name,
2643
+ await c.up(e), await e.withPlugin(l(this, i, C)).insertInto(l(this, i, N)).values({
2644
+ name: c.name,
2543
2645
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2544
- }).execute(), n[s] = {
2545
- migrationName: l.name,
2646
+ }).execute(), o[s] = {
2647
+ migrationName: c.name,
2546
2648
  direction: "Up",
2547
2649
  status: "Success"
2548
2650
  };
2549
2651
  } catch (d) {
2550
- throw n[s] = {
2551
- migrationName: l.name,
2652
+ throw o[s] = {
2653
+ migrationName: c.name,
2552
2654
  direction: "Up",
2553
2655
  status: "Error"
2554
- }, new Q({
2656
+ }, new q({
2555
2657
  error: d,
2556
- results: n
2658
+ results: o
2557
2659
  });
2558
2660
  }
2559
2661
  }
2560
- return { results: n };
2662
+ return { results: o };
2561
2663
  }, A = async function(e) {
2562
- c(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2664
+ l(this, _).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2563
2665
  };
2564
2666
  var z;
2565
- class Q extends Error {
2667
+ class q extends Error {
2566
2668
  constructor(a) {
2567
2669
  super();
2568
2670
  y(this, z);
2569
2671
  M(this, z, a);
2570
2672
  }
2571
2673
  get resultSet() {
2572
- return c(this, z);
2674
+ return l(this, z);
2573
2675
  }
2574
2676
  }
2575
2677
  z = new WeakMap();
2576
- class Ae {
2678
+ class Le {
2577
2679
  constructor(e) {
2578
2680
  j(this, "migrations");
2579
2681
  this.migrations = e;
@@ -2582,7 +2684,7 @@ class Ae {
2582
2684
  return this.migrations;
2583
2685
  }
2584
2686
  }
2585
- async function Ja(t) {
2687
+ async function Va(t) {
2586
2688
  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(
2587
2689
  "tenant_id",
2588
2690
  "varchar(255)",
@@ -2654,35 +2756,35 @@ async function Ja(t) {
2654
2756
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
2655
2757
  ).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();
2656
2758
  }
2657
- async function Ka(t) {
2759
+ async function Wa(t) {
2658
2760
  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();
2659
2761
  }
2660
- const Ra = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2762
+ const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2661
2763
  __proto__: null,
2662
- down: Ka,
2663
- up: Ja
2764
+ down: Wa,
2765
+ up: Va
2664
2766
  }, Symbol.toStringTag, { value: "Module" }));
2665
- async function Ua(t) {
2767
+ async function Ha(t) {
2666
2768
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
2667
2769
  }
2668
- async function Ba(t) {
2770
+ async function Xa(t) {
2669
2771
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
2670
2772
  }
2671
- const Qa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2773
+ const Ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2672
2774
  __proto__: null,
2673
- down: Ba,
2674
- up: Ua
2775
+ down: Xa,
2776
+ up: Ha
2675
2777
  }, Symbol.toStringTag, { value: "Module" }));
2676
- async function Va(t) {
2778
+ async function Za(t) {
2677
2779
  }
2678
- async function Wa(t) {
2780
+ async function er(t) {
2679
2781
  }
2680
- const qa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2782
+ const tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2681
2783
  __proto__: null,
2682
- down: Wa,
2683
- up: Va
2784
+ down: er,
2785
+ up: Za
2684
2786
  }, Symbol.toStringTag, { value: "Module" }));
2685
- async function Ga(t) {
2787
+ async function ar(t) {
2686
2788
  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(
2687
2789
  "tenant_id_constraint",
2688
2790
  ["tenant_id"],
@@ -2691,24 +2793,24 @@ async function Ga(t) {
2691
2793
  (e) => e.onDelete("cascade")
2692
2794
  ).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();
2693
2795
  }
2694
- async function Ha(t) {
2796
+ async function rr(t) {
2695
2797
  await t.schema.dropTable("logs").execute();
2696
2798
  }
2697
- const Xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2799
+ const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2698
2800
  __proto__: null,
2699
- down: Ha,
2700
- up: Ga
2801
+ down: rr,
2802
+ up: ar
2701
2803
  }, Symbol.toStringTag, { value: "Module" }));
2702
- async function Ya(t) {
2804
+ async function or(t) {
2703
2805
  }
2704
- async function Za(t) {
2806
+ async function sr(t) {
2705
2807
  }
2706
- const er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2808
+ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2707
2809
  __proto__: null,
2708
- down: Za,
2709
- up: Ya
2810
+ down: sr,
2811
+ up: or
2710
2812
  }, Symbol.toStringTag, { value: "Module" }));
2711
- async function tr(t) {
2813
+ async function dr(t) {
2712
2814
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
2713
2815
  "user_id_constraint",
2714
2816
  ["user_id", "tenant_id"],
@@ -2733,15 +2835,15 @@ async function tr(t) {
2733
2835
  (e) => e.references("applications.id").onDelete("cascade").notNull()
2734
2836
  ).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();
2735
2837
  }
2736
- async function ar(t) {
2838
+ async function cr(t) {
2737
2839
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
2738
2840
  }
2739
- const rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2841
+ const lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2740
2842
  __proto__: null,
2741
- down: ar,
2742
- up: tr
2843
+ down: cr,
2844
+ up: dr
2743
2845
  }, Symbol.toStringTag, { value: "Module" }));
2744
- async function nr(t) {
2846
+ async function ur(t) {
2745
2847
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
2746
2848
  "user_id_constraint",
2747
2849
  ["user_id", "tenant_id"],
@@ -2756,24 +2858,24 @@ async function nr(t) {
2756
2858
  (e) => e.onDelete("cascade")
2757
2859
  ).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();
2758
2860
  }
2759
- async function or(t) {
2861
+ async function mr(t) {
2760
2862
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
2761
2863
  }
2762
- const sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2864
+ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2763
2865
  __proto__: null,
2764
- down: or,
2765
- up: nr
2866
+ down: mr,
2867
+ up: ur
2766
2868
  }, Symbol.toStringTag, { value: "Module" }));
2767
- async function ir(t) {
2869
+ async function _r(t) {
2768
2870
  }
2769
- async function dr(t) {
2871
+ async function fr(t) {
2770
2872
  }
2771
- const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2873
+ const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2772
2874
  __proto__: null,
2773
- down: dr,
2774
- up: ir
2875
+ down: fr,
2876
+ up: _r
2775
2877
  }, Symbol.toStringTag, { value: "Module" }));
2776
- async function lr(t) {
2878
+ async function gr(t) {
2777
2879
  await t.schema.alterTable("passwords").addColumn(
2778
2880
  "password",
2779
2881
  "varchar(255)",
@@ -2781,288 +2883,288 @@ async function lr(t) {
2781
2883
  (e) => e.notNull()
2782
2884
  ).execute();
2783
2885
  }
2784
- async function ur(t) {
2886
+ async function yr(t) {
2785
2887
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2786
2888
  }
2787
- const mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2889
+ const wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2788
2890
  __proto__: null,
2789
- down: ur,
2790
- up: lr
2891
+ down: yr,
2892
+ up: gr
2791
2893
  }, Symbol.toStringTag, { value: "Module" }));
2792
- async function hr(t) {
2894
+ async function vr(t) {
2793
2895
  }
2794
- async function _r(t) {
2896
+ async function Nr(t) {
2795
2897
  }
2796
- const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2898
+ const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2797
2899
  __proto__: null,
2798
- down: _r,
2799
- up: hr
2900
+ down: Nr,
2901
+ up: vr
2800
2902
  }, Symbol.toStringTag, { value: "Module" }));
2801
- async function pr(t) {
2903
+ async function br(t) {
2802
2904
  }
2803
- async function gr(t) {
2905
+ async function xr(t) {
2804
2906
  }
2805
- const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2907
+ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2806
2908
  __proto__: null,
2807
- down: gr,
2808
- up: pr
2909
+ down: xr,
2910
+ up: br
2809
2911
  }, Symbol.toStringTag, { value: "Module" }));
2810
- async function wr(t) {
2912
+ async function Sr(t) {
2811
2913
  }
2812
- async function vr(t) {
2914
+ async function Or(t) {
2813
2915
  }
2814
- const Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2916
+ const kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2815
2917
  __proto__: null,
2816
- down: vr,
2817
- up: wr
2918
+ down: Or,
2919
+ up: Sr
2818
2920
  }, Symbol.toStringTag, { value: "Module" }));
2819
- async function Cr(t) {
2921
+ async function $r(t) {
2820
2922
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
2821
2923
  }
2822
- async function br(t) {
2924
+ async function Dr(t) {
2823
2925
  await t.schema.dropIndex("users_email_index").execute();
2824
2926
  }
2825
- const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2927
+ const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2826
2928
  __proto__: null,
2827
- down: br,
2828
- up: Cr
2929
+ down: Dr,
2930
+ up: $r
2829
2931
  }, Symbol.toStringTag, { value: "Module" }));
2830
- async function Tr(t) {
2932
+ async function Pr(t) {
2831
2933
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
2832
2934
  }
2833
- async function Sr(t) {
2935
+ async function jr(t) {
2834
2936
  await t.schema.alterTable("users").dropColumn("profileData").execute();
2835
2937
  }
2836
- const Or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2938
+ const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2837
2939
  __proto__: null,
2838
- down: Sr,
2839
- up: Tr
2940
+ down: jr,
2941
+ up: Pr
2840
2942
  }, Symbol.toStringTag, { value: "Module" }));
2841
- async function kr(t) {
2943
+ async function Fr(t) {
2842
2944
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
2843
2945
  }
2844
- async function $r(t) {
2946
+ async function Ar(t) {
2845
2947
  await t.schema.dropIndex("users_linked_to_index");
2846
2948
  }
2847
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2949
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2848
2950
  __proto__: null,
2849
- down: $r,
2850
- up: kr
2951
+ down: Ar,
2952
+ up: Fr
2851
2953
  }, Symbol.toStringTag, { value: "Module" }));
2852
- async function Ir(t) {
2954
+ async function zr(t) {
2853
2955
  await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
2854
2956
  }
2855
- async function Pr(t) {
2957
+ async function Jr(t) {
2856
2958
  await t.schema.alterTable("users").dropColumn("locale").execute();
2857
2959
  }
2858
- const jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2960
+ const Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2859
2961
  __proto__: null,
2860
- down: Pr,
2861
- up: Ir
2962
+ down: Jr,
2963
+ up: zr
2862
2964
  }, Symbol.toStringTag, { value: "Module" }));
2863
- async function Mr(t) {
2965
+ async function Kr(t) {
2864
2966
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2865
2967
  "tenant_id",
2866
2968
  "varchar(255)",
2867
2969
  (e) => e.references("tenants.id").onDelete("cascade")
2868
2970
  ).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();
2869
2971
  }
2870
- async function Fr(t) {
2972
+ async function Rr(t) {
2871
2973
  await t.schema.dropTable("keys").execute();
2872
2974
  }
2873
- const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2975
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2874
2976
  __proto__: null,
2875
- down: Fr,
2876
- up: Mr
2977
+ down: Rr,
2978
+ up: Kr
2877
2979
  }, Symbol.toStringTag, { value: "Module" }));
2878
- async function Lr(t) {
2980
+ async function Br(t) {
2879
2981
  }
2880
- async function zr(t) {
2982
+ async function Qr(t) {
2881
2983
  }
2882
- const Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2984
+ const qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2883
2985
  __proto__: null,
2884
- down: zr,
2885
- up: Lr
2986
+ down: Qr,
2987
+ up: Br
2886
2988
  }, Symbol.toStringTag, { value: "Module" }));
2887
- async function Jr(t) {
2989
+ async function Vr(t) {
2888
2990
  }
2889
- async function Kr(t) {
2991
+ async function Wr(t) {
2890
2992
  }
2891
- const Rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2993
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2892
2994
  __proto__: null,
2893
- down: Kr,
2894
- up: Jr
2995
+ down: Wr,
2996
+ up: Vr
2895
2997
  }, Symbol.toStringTag, { value: "Module" }));
2896
- async function Ur(t) {
2998
+ async function Hr(t) {
2897
2999
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
2898
3000
  }
2899
- async function Br(t) {
3001
+ async function Xr(t) {
2900
3002
  await t.schema.alterTable("otps").dropColumn("audience").execute();
2901
3003
  }
2902
- const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3004
+ const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2903
3005
  __proto__: null,
2904
- down: Br,
2905
- up: Ur
3006
+ down: Xr,
3007
+ up: Hr
2906
3008
  }, Symbol.toStringTag, { value: "Module" }));
2907
- async function Vr(t) {
3009
+ async function Zr(t) {
2908
3010
  }
2909
- async function Wr(t) {
3011
+ async function en(t) {
2910
3012
  }
2911
- const qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3013
+ const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2912
3014
  __proto__: null,
2913
- down: Wr,
2914
- up: Vr
3015
+ down: en,
3016
+ up: Zr
2915
3017
  }, Symbol.toStringTag, { value: "Module" }));
2916
- async function Gr(t) {
3018
+ async function an(t) {
2917
3019
  await t.schema.alterTable("logs").dropColumn("category").execute();
2918
3020
  }
2919
- async function Hr(t) {
3021
+ async function rn(t) {
2920
3022
  await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
2921
3023
  }
2922
- const Xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3024
+ const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2923
3025
  __proto__: null,
2924
- down: Hr,
2925
- up: Gr
3026
+ down: rn,
3027
+ up: an
2926
3028
  }, Symbol.toStringTag, { value: "Module" }));
2927
- async function Yr(t) {
3029
+ async function on(t) {
2928
3030
  await t.schema.alterTable("users").dropColumn("tags").execute();
2929
3031
  }
2930
- async function Zr(t) {
3032
+ async function sn(t) {
2931
3033
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
2932
3034
  }
2933
- const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3035
+ const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2934
3036
  __proto__: null,
2935
- down: Zr,
2936
- up: Yr
3037
+ down: sn,
3038
+ up: on
2937
3039
  }, Symbol.toStringTag, { value: "Module" }));
2938
- async function tn(t) {
3040
+ async function cn(t) {
2939
3041
  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();
2940
3042
  }
2941
- async function an(t) {
3043
+ async function ln(t) {
2942
3044
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
2943
3045
  }
2944
- const rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3046
+ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2945
3047
  __proto__: null,
2946
- down: an,
2947
- up: tn
3048
+ down: ln,
3049
+ up: cn
2948
3050
  }, Symbol.toStringTag, { value: "Module" }));
2949
- async function nn(t) {
3051
+ async function mn(t) {
2950
3052
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
2951
3053
  }
2952
- async function on(t) {
3054
+ async function hn(t) {
2953
3055
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
2954
3056
  }
2955
- const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3057
+ const _n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2956
3058
  __proto__: null,
2957
- down: on,
2958
- up: nn
3059
+ down: hn,
3060
+ up: mn
2959
3061
  }, Symbol.toStringTag, { value: "Module" }));
2960
- async function dn(t) {
3062
+ async function fn(t) {
2961
3063
  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();
2962
3064
  }
2963
- async function cn(t) {
3065
+ async function pn(t) {
2964
3066
  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();
2965
3067
  }
2966
- const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3068
+ const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2967
3069
  __proto__: null,
2968
- down: cn,
2969
- up: dn
3070
+ down: pn,
3071
+ up: fn
2970
3072
  }, Symbol.toStringTag, { value: "Module" }));
2971
- async function un(t) {
3073
+ async function yn(t) {
2972
3074
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
2973
3075
  }
2974
- async function mn(t) {
3076
+ async function wn(t) {
2975
3077
  await t.schema.dropIndex("users_name_index").execute();
2976
3078
  }
2977
- const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3079
+ const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2978
3080
  __proto__: null,
2979
- down: mn,
2980
- up: un
3081
+ down: wn,
3082
+ up: yn
2981
3083
  }, Symbol.toStringTag, { value: "Module" }));
2982
- async function _n(t) {
3084
+ async function Nn(t) {
2983
3085
  }
2984
- async function fn(t) {
3086
+ async function Cn(t) {
2985
3087
  await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
2986
3088
  }
2987
- const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3089
+ const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2988
3090
  __proto__: null,
2989
- down: fn,
2990
- up: _n
3091
+ down: Cn,
3092
+ up: Nn
2991
3093
  }, Symbol.toStringTag, { value: "Module" }));
2992
- async function gn(t) {
3094
+ async function xn(t) {
2993
3095
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
2994
3096
  }
2995
- async function yn(t) {
3097
+ async function Tn(t) {
2996
3098
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
2997
3099
  }
2998
- const wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3100
+ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2999
3101
  __proto__: null,
3000
- down: yn,
3001
- up: gn
3102
+ down: Tn,
3103
+ up: xn
3002
3104
  }, Symbol.toStringTag, { value: "Module" }));
3003
- async function vn(t) {
3105
+ async function On(t) {
3004
3106
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3005
3107
  }
3006
- async function Nn(t) {
3108
+ async function kn(t) {
3007
3109
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3008
3110
  }
3009
- const Cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3111
+ const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3010
3112
  __proto__: null,
3011
- down: Nn,
3012
- up: vn
3113
+ down: kn,
3114
+ up: On
3013
3115
  }, Symbol.toStringTag, { value: "Module" }));
3014
- async function bn(t) {
3116
+ async function Dn(t) {
3015
3117
  await t.schema.createTable("branding").addColumn(
3016
3118
  "tenant_id",
3017
3119
  "varchar(255)",
3018
3120
  (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3019
3121
  ).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();
3020
3122
  }
3021
- async function xn(t) {
3123
+ async function In(t) {
3022
3124
  await t.schema.dropTable("branding").execute();
3023
3125
  }
3024
- const Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3126
+ const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3025
3127
  __proto__: null,
3026
- down: xn,
3027
- up: bn
3128
+ down: In,
3129
+ up: Dn
3028
3130
  }, Symbol.toStringTag, { value: "Module" }));
3029
- async function Sn(t) {
3131
+ async function jn(t) {
3030
3132
  }
3031
- async function On(t) {
3133
+ async function Mn(t) {
3032
3134
  }
3033
- const kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3135
+ const Fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3034
3136
  __proto__: null,
3035
- down: On,
3036
- up: Sn
3137
+ down: Mn,
3138
+ up: jn
3037
3139
  }, Symbol.toStringTag, { value: "Module" }));
3038
- async function $n(t) {
3140
+ async function An(t) {
3039
3141
  }
3040
- async function Dn(t) {
3142
+ async function Ln(t) {
3041
3143
  }
3042
- const In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3144
+ const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3043
3145
  __proto__: null,
3044
- down: Dn,
3045
- up: $n
3146
+ down: Ln,
3147
+ up: An
3046
3148
  }, Symbol.toStringTag, { value: "Module" }));
3047
- async function Pn(t) {
3149
+ async function Jn(t) {
3048
3150
  }
3049
- async function jn(t) {
3151
+ async function En(t) {
3050
3152
  }
3051
- const Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3153
+ const Kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3052
3154
  __proto__: null,
3053
- down: jn,
3054
- up: Pn
3155
+ down: En,
3156
+ up: Jn
3055
3157
  }, Symbol.toStringTag, { value: "Module" }));
3056
- async function Fn(t) {
3158
+ async function Rn(t) {
3057
3159
  }
3058
- async function An(t) {
3160
+ async function Un(t) {
3059
3161
  }
3060
- const Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3162
+ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3061
3163
  __proto__: null,
3062
- down: An,
3063
- up: Fn
3164
+ down: Un,
3165
+ up: Rn
3064
3166
  }, Symbol.toStringTag, { value: "Module" }));
3065
- async function zn(t) {
3167
+ async function Qn(t) {
3066
3168
  await t.schema.createTable("authentication_codes").addColumn(
3067
3169
  "tenant_id",
3068
3170
  "varchar(255)",
@@ -3073,55 +3175,55 @@ async function zn(t) {
3073
3175
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3074
3176
  ).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();
3075
3177
  }
3076
- async function En(t) {
3178
+ async function qn(t) {
3077
3179
  await t.schema.dropTable("authentication_codes").execute();
3078
3180
  }
3079
- const Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3181
+ const Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3080
3182
  __proto__: null,
3081
- down: En,
3082
- up: zn
3183
+ down: qn,
3184
+ up: Qn
3083
3185
  }, Symbol.toStringTag, { value: "Module" }));
3084
- async function Kn(t) {
3186
+ async function Wn(t) {
3085
3187
  }
3086
- async function Rn(t) {
3188
+ async function Gn(t) {
3087
3189
  }
3088
- const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3190
+ const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3089
3191
  __proto__: null,
3090
- down: Rn,
3091
- up: Kn
3192
+ down: Gn,
3193
+ up: Wn
3092
3194
  }, Symbol.toStringTag, { value: "Module" }));
3093
- async function Bn(t) {
3195
+ async function Xn(t) {
3094
3196
  await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3095
3197
  }
3096
- async function Qn(t) {
3198
+ async function Yn(t) {
3097
3199
  await t.schema.alterTable("otps").dropColumn("ip").execute();
3098
3200
  }
3099
- const Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3201
+ const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3100
3202
  __proto__: null,
3101
- down: Qn,
3102
- up: Bn
3203
+ down: Yn,
3204
+ up: Xn
3103
3205
  }, Symbol.toStringTag, { value: "Module" }));
3104
- async function Wn(t) {
3206
+ async function eo(t) {
3105
3207
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3106
3208
  }
3107
- async function qn(t) {
3209
+ async function to(t) {
3108
3210
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3109
3211
  }
3110
- const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3212
+ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3111
3213
  __proto__: null,
3112
- down: qn,
3113
- up: Wn
3214
+ down: to,
3215
+ up: eo
3114
3216
  }, Symbol.toStringTag, { value: "Module" }));
3115
- async function Hn(t) {
3217
+ async function ro(t) {
3116
3218
  }
3117
- async function Xn(t) {
3219
+ async function no(t) {
3118
3220
  }
3119
- const Yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3221
+ const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3120
3222
  __proto__: null,
3121
- down: Xn,
3122
- up: Hn
3223
+ down: no,
3224
+ up: ro
3123
3225
  }, Symbol.toStringTag, { value: "Module" }));
3124
- async function Zn(t) {
3226
+ async function so(t) {
3125
3227
  await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3126
3228
  "tenant_id",
3127
3229
  "varchar(255)",
@@ -3132,33 +3234,33 @@ async function Zn(t) {
3132
3234
  (e) => e.defaultTo(!1).notNull()
3133
3235
  ).addColumn("priority", "integer").execute();
3134
3236
  }
3135
- async function eo(t) {
3237
+ async function io(t) {
3136
3238
  await t.schema.dropTable("hooks").execute();
3137
3239
  }
3138
- const to = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3240
+ const co = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3139
3241
  __proto__: null,
3140
- down: eo,
3141
- up: Zn
3242
+ down: io,
3243
+ up: so
3142
3244
  }, Symbol.toStringTag, { value: "Module" }));
3143
- async function ao(t) {
3245
+ async function lo(t) {
3144
3246
  }
3145
- async function ro(t) {
3247
+ async function uo(t) {
3146
3248
  }
3147
- const no = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3249
+ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3148
3250
  __proto__: null,
3149
- down: ro,
3150
- up: ao
3251
+ down: uo,
3252
+ up: lo
3151
3253
  }, Symbol.toStringTag, { value: "Module" }));
3152
- async function oo(t) {
3254
+ async function ho(t) {
3153
3255
  }
3154
- async function so(t) {
3256
+ async function _o(t) {
3155
3257
  }
3156
- const io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3258
+ const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3157
3259
  __proto__: null,
3158
- down: so,
3159
- up: oo
3260
+ down: _o,
3261
+ up: ho
3160
3262
  }, Symbol.toStringTag, { value: "Module" }));
3161
- async function co(t) {
3263
+ async function po(t) {
3162
3264
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3163
3265
  "tenant_id",
3164
3266
  "varchar(255)",
@@ -3175,7 +3277,7 @@ async function co(t) {
3175
3277
  (e) => e.onDelete("cascade")
3176
3278
  ).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();
3177
3279
  }
3178
- async function lo(t) {
3280
+ async function go(t) {
3179
3281
  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(
3180
3282
  "codes_user_id_tenant_id_constraint",
3181
3283
  ["user_id", "tenant_id"],
@@ -3184,90 +3286,90 @@ async function lo(t) {
3184
3286
  (e) => e.onDelete("cascade")
3185
3287
  ).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();
3186
3288
  }
3187
- const uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3289
+ const yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3188
3290
  __proto__: null,
3189
- down: lo,
3190
- up: co
3291
+ down: go,
3292
+ up: po
3191
3293
  }, Symbol.toStringTag, { value: "Module" }));
3192
- async function mo(t) {
3294
+ async function wo(t) {
3193
3295
  }
3194
- async function ho(t) {
3296
+ async function vo(t) {
3195
3297
  }
3196
- const _o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3298
+ const No = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3197
3299
  __proto__: null,
3198
- down: ho,
3199
- up: mo
3300
+ down: vo,
3301
+ up: wo
3200
3302
  }, Symbol.toStringTag, { value: "Module" }));
3201
- async function fo(t) {
3303
+ async function Co(t) {
3202
3304
  await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3203
3305
  }
3204
- async function po(t) {
3306
+ async function bo(t) {
3205
3307
  await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3206
3308
  }
3207
- const go = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3309
+ const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3208
3310
  __proto__: null,
3209
- down: po,
3210
- up: fo
3311
+ down: bo,
3312
+ up: Co
3211
3313
  }, Symbol.toStringTag, { value: "Module" }));
3212
- async function yo(t) {
3314
+ async function To(t) {
3213
3315
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3214
3316
  }
3215
- async function wo(t) {
3317
+ async function So(t) {
3216
3318
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3217
3319
  }
3218
- const vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3320
+ const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3219
3321
  __proto__: null,
3220
- down: wo,
3221
- up: yo
3322
+ down: So,
3323
+ up: To
3222
3324
  }, Symbol.toStringTag, { value: "Module" }));
3223
- async function No(t) {
3325
+ async function ko(t) {
3224
3326
  }
3225
- async function Co(t) {
3327
+ async function $o(t) {
3226
3328
  }
3227
- const bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3329
+ const Do = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3228
3330
  __proto__: null,
3229
- down: Co,
3230
- up: No
3331
+ down: $o,
3332
+ up: ko
3231
3333
  }, Symbol.toStringTag, { value: "Module" }));
3232
- async function xo(t) {
3334
+ async function Io(t) {
3233
3335
  }
3234
- async function To(t) {
3336
+ async function Po(t) {
3235
3337
  }
3236
- const So = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3338
+ const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3237
3339
  __proto__: null,
3238
- down: To,
3239
- up: xo
3340
+ down: Po,
3341
+ up: Io
3240
3342
  }, Symbol.toStringTag, { value: "Module" }));
3241
- async function Oo(t) {
3343
+ async function Mo(t) {
3242
3344
  await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
3243
3345
  }
3244
- async function ko(t) {
3346
+ async function Fo(t) {
3245
3347
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3246
3348
  }
3247
- const $o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3349
+ const Ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3248
3350
  __proto__: null,
3249
- down: ko,
3250
- up: Oo
3351
+ down: Fo,
3352
+ up: Mo
3251
3353
  }, Symbol.toStringTag, { value: "Module" }));
3252
- async function Do(t) {
3354
+ async function Lo(t) {
3253
3355
  }
3254
- async function Io(t) {
3356
+ async function zo(t) {
3255
3357
  }
3256
- const Po = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3358
+ const Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3257
3359
  __proto__: null,
3258
- down: Io,
3259
- up: Do
3360
+ down: zo,
3361
+ up: Lo
3260
3362
  }, Symbol.toStringTag, { value: "Module" }));
3261
- async function jo(t) {
3363
+ async function Eo(t) {
3262
3364
  }
3263
- async function Mo(t) {
3365
+ async function Ko(t) {
3264
3366
  }
3265
- const Fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3367
+ const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3266
3368
  __proto__: null,
3267
- down: Mo,
3268
- up: jo
3369
+ down: Ko,
3370
+ up: Eo
3269
3371
  }, Symbol.toStringTag, { value: "Module" }));
3270
- async function Ao(t) {
3372
+ async function Uo(t) {
3271
3373
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
3272
3374
  "tenant_id",
3273
3375
  "varchar(255)",
@@ -3283,7 +3385,7 @@ async function Ao(t) {
3283
3385
  "code_type"
3284
3386
  ]).execute();
3285
3387
  }
3286
- async function Lo(t) {
3388
+ async function Bo(t) {
3287
3389
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3288
3390
  "tenant_id",
3289
3391
  "varchar(255)",
@@ -3296,15 +3398,15 @@ async function Lo(t) {
3296
3398
  (e) => e.onDelete("cascade")
3297
3399
  ).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();
3298
3400
  }
3299
- const zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3401
+ const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3300
3402
  __proto__: null,
3301
- down: Lo,
3302
- up: Ao
3403
+ down: Bo,
3404
+ up: Uo
3303
3405
  }, Symbol.toStringTag, { value: "Module" }));
3304
- async function Eo(t) {
3406
+ async function qo(t) {
3305
3407
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
3306
3408
  }
3307
- async function Jo(t) {
3409
+ async function Vo(t) {
3308
3410
  await t.schema.alterTable("keys").addColumn("private_key", "varchar(2048)").addColumn("public_key", "varchar(2048)").execute(), await t.schema.createTable("otps").addColumn(
3309
3411
  "tenant_id",
3310
3412
  "varchar(255)",
@@ -3323,32 +3425,32 @@ async function Jo(t) {
3323
3425
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3324
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();
3325
3427
  }
3326
- const Ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3428
+ const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3327
3429
  __proto__: null,
3328
- down: Jo,
3329
- up: Eo
3430
+ down: Vo,
3431
+ up: qo
3330
3432
  }, Symbol.toStringTag, { value: "Module" }));
3331
- async function Ro(t) {
3433
+ async function Go(t) {
3332
3434
  await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
3333
3435
  }
3334
- async function Uo(t) {
3436
+ async function Ho(t) {
3335
3437
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
3336
3438
  }
3337
- const Bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3439
+ const Xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3338
3440
  __proto__: null,
3339
- down: Uo,
3340
- up: Ro
3441
+ down: Ho,
3442
+ up: Go
3341
3443
  }, Symbol.toStringTag, { value: "Module" }));
3342
- async function Qo(t) {
3444
+ async function Yo(t) {
3343
3445
  }
3344
- async function Vo(t) {
3446
+ async function Zo(t) {
3345
3447
  }
3346
- const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3448
+ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3347
3449
  __proto__: null,
3348
- down: Vo,
3349
- up: Qo
3450
+ down: Zo,
3451
+ up: Yo
3350
3452
  }, Symbol.toStringTag, { value: "Module" }));
3351
- async function qo(t) {
3453
+ async function ts(t) {
3352
3454
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
3353
3455
  "universal_login_experience",
3354
3456
  "varchar(16)",
@@ -3367,95 +3469,95 @@ async function qo(t) {
3367
3469
  (e) => e.defaultTo(!1).notNull()
3368
3470
  ).execute();
3369
3471
  }
3370
- async function Go(t) {
3472
+ async function as(t) {
3371
3473
  await t.schema.dropTable("prompt_settings").execute();
3372
3474
  }
3373
- const Ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3475
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3374
3476
  __proto__: null,
3375
- down: Go,
3376
- up: qo
3477
+ down: as,
3478
+ up: ts
3377
3479
  }, Symbol.toStringTag, { value: "Module" }));
3378
- async function Xo(t) {
3480
+ async function ns(t) {
3379
3481
  }
3380
- async function Yo(t) {
3482
+ async function os(t) {
3381
3483
  }
3382
- const Zo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3484
+ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3383
3485
  __proto__: null,
3384
- down: Yo,
3385
- up: Xo
3486
+ down: os,
3487
+ up: ns
3386
3488
  }, Symbol.toStringTag, { value: "Module" }));
3387
- async function es(t) {
3489
+ async function is(t) {
3388
3490
  }
3389
- async function ts(t) {
3491
+ async function ds(t) {
3390
3492
  }
3391
- const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3493
+ const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3392
3494
  __proto__: null,
3393
- down: ts,
3394
- up: es
3495
+ down: ds,
3496
+ up: is
3395
3497
  }, Symbol.toStringTag, { value: "Module" }));
3396
- async function rs(t) {
3498
+ async function ls(t) {
3397
3499
  }
3398
- async function ns(t) {
3500
+ async function us(t) {
3399
3501
  }
3400
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3502
+ const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3401
3503
  __proto__: null,
3402
- down: ns,
3403
- up: rs
3504
+ down: us,
3505
+ up: ls
3404
3506
  }, Symbol.toStringTag, { value: "Module" }));
3405
- async function ss(t) {
3507
+ async function hs(t) {
3406
3508
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3407
3509
  }
3408
- async function is(t) {
3510
+ async function _s(t) {
3409
3511
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
3410
3512
  }
3411
- const ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3513
+ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3412
3514
  __proto__: null,
3413
- down: is,
3414
- up: ss
3515
+ down: _s,
3516
+ up: hs
3415
3517
  }, Symbol.toStringTag, { value: "Module" }));
3416
- async function cs(t) {
3518
+ async function ps(t) {
3417
3519
  await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
3418
3520
  }
3419
- async function ls(t) {
3521
+ async function gs(t) {
3420
3522
  await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
3421
3523
  }
3422
- const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3524
+ const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3423
3525
  __proto__: null,
3424
- down: ls,
3425
- up: cs
3526
+ down: gs,
3527
+ up: ps
3426
3528
  }, Symbol.toStringTag, { value: "Module" }));
3427
- async function ms(t) {
3529
+ async function ws(t) {
3428
3530
  }
3429
- async function hs(t) {
3531
+ async function vs(t) {
3430
3532
  }
3431
- const _s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3533
+ const Ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3432
3534
  __proto__: null,
3433
- down: hs,
3434
- up: ms
3535
+ down: vs,
3536
+ up: ws
3435
3537
  }, Symbol.toStringTag, { value: "Module" }));
3436
- async function fs(t) {
3538
+ async function Cs(t) {
3437
3539
  await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
3438
3540
  }
3439
- async function ps(t) {
3541
+ async function bs(t) {
3440
3542
  await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
3441
3543
  }
3442
- const gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3544
+ const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3443
3545
  __proto__: null,
3444
- down: ps,
3445
- up: fs
3546
+ down: bs,
3547
+ up: Cs
3446
3548
  }, Symbol.toStringTag, { value: "Module" }));
3447
- async function ys(t) {
3549
+ async function Ts(t) {
3448
3550
  await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
3449
3551
  }
3450
- async function ws(t) {
3552
+ async function Ss(t) {
3451
3553
  await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
3452
3554
  }
3453
- const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3555
+ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3454
3556
  __proto__: null,
3455
- down: ws,
3456
- up: ys
3557
+ down: Ss,
3558
+ up: Ts
3457
3559
  }, Symbol.toStringTag, { value: "Module" }));
3458
- async function Ns(t) {
3560
+ async function ks(t) {
3459
3561
  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(
3460
3562
  "credentials",
3461
3563
  "varchar(2048)",
@@ -3466,18 +3568,18 @@ async function Ns(t) {
3466
3568
  (e) => e.notNull().defaultTo("{}")
3467
3569
  ).addColumn("created_at", "varchar(29)", (e) => e.notNull()).addColumn("updated_at", "varchar(29)", (e) => e.notNull()).execute();
3468
3570
  }
3469
- async function Cs(t) {
3571
+ async function $s(t) {
3470
3572
  await t.schema.dropTable("email_providers").execute();
3471
3573
  }
3472
- const bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3574
+ const Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3473
3575
  __proto__: null,
3474
- down: Cs,
3475
- up: Ns
3576
+ down: $s,
3577
+ up: ks
3476
3578
  }, Symbol.toStringTag, { value: "Module" }));
3477
- async function xs(t) {
3579
+ async function Is(t) {
3478
3580
  await t.schema.dropTable("tickets").execute();
3479
3581
  }
3480
- async function Ts(t) {
3582
+ async function Ps(t) {
3481
3583
  await t.schema.createTable("tickets").addColumn(
3482
3584
  "tenant_id",
3483
3585
  "varchar(255)",
@@ -3488,22 +3590,22 @@ async function Ts(t) {
3488
3590
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3489
3591
  ).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();
3490
3592
  }
3491
- const Ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3593
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3492
3594
  __proto__: null,
3493
- down: Ts,
3494
- up: xs
3595
+ down: Ps,
3596
+ up: Is
3495
3597
  }, Symbol.toStringTag, { value: "Module" }));
3496
- async function Os(t) {
3598
+ async function Ms(t) {
3497
3599
  }
3498
- async function ks(t) {
3600
+ async function Fs(t) {
3499
3601
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3500
3602
  }
3501
- const $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3603
+ const As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3502
3604
  __proto__: null,
3503
- down: ks,
3504
- up: Os
3605
+ down: Fs,
3606
+ up: Ms
3505
3607
  }, Symbol.toStringTag, { value: "Module" }));
3506
- async function Ds(t) {
3608
+ async function Ls(t) {
3507
3609
  await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3508
3610
  "client_id",
3509
3611
  "varchar(21)",
@@ -3516,27 +3618,27 @@ async function Ds(t) {
3516
3618
  (e) => e.onDelete("cascade")
3517
3619
  ).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();
3518
3620
  }
3519
- async function Is(t) {
3621
+ async function zs(t) {
3520
3622
  await t.schema.dropTable("refresh_tokens").execute();
3521
3623
  }
3522
- const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3624
+ const Js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3523
3625
  __proto__: null,
3524
- down: Is,
3525
- up: Ds
3626
+ down: zs,
3627
+ up: Ls
3526
3628
  }, Symbol.toStringTag, { value: "Module" }));
3527
- async function js(t) {
3629
+ async function Es(t) {
3528
3630
  }
3529
- async function Ms(t) {
3631
+ async function Ks(t) {
3530
3632
  }
3531
- const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3633
+ const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3532
3634
  __proto__: null,
3533
- down: Ms,
3534
- up: js
3635
+ down: Ks,
3636
+ up: Es
3535
3637
  }, Symbol.toStringTag, { value: "Module" }));
3536
- async function As(t) {
3638
+ async function Us(t) {
3537
3639
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
3538
3640
  }
3539
- async function Ls(t) {
3641
+ async function Bs(t) {
3540
3642
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3541
3643
  "sessions_user_id_constraint",
3542
3644
  ["user_id", "tenant_id"],
@@ -3555,12 +3657,12 @@ async function Ls(t) {
3555
3657
  (e) => e.onDelete("cascade")
3556
3658
  ).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();
3557
3659
  }
3558
- const zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3660
+ const Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3559
3661
  __proto__: null,
3560
- down: Ls,
3561
- up: As
3662
+ down: Bs,
3663
+ up: Us
3562
3664
  }, Symbol.toStringTag, { value: "Module" }));
3563
- async function Es(t) {
3665
+ async function qs(t) {
3564
3666
  await t.schema.createTable("sessions_2").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3565
3667
  "sessions_2_user_id_constraint",
3566
3668
  ["user_id", "tenant_id"],
@@ -3579,15 +3681,15 @@ async function Es(t) {
3579
3681
  (e) => e.onDelete("cascade")
3580
3682
  ).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();
3581
3683
  }
3582
- async function Js(t) {
3684
+ async function Vs(t) {
3583
3685
  await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
3584
3686
  }
3585
- const Ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3687
+ const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3586
3688
  __proto__: null,
3587
- down: Js,
3588
- up: Es
3689
+ down: Vs,
3690
+ up: qs
3589
3691
  }, Symbol.toStringTag, { value: "Module" }));
3590
- async function Rs(t) {
3692
+ async function Gs(t) {
3591
3693
  await t.schema.createTable("custom_domains").addColumn(
3592
3694
  "custom_domain_id",
3593
3695
  "varchar(21)",
@@ -3598,49 +3700,49 @@ async function Rs(t) {
3598
3700
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3599
3701
  ).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();
3600
3702
  }
3601
- async function Us(t) {
3703
+ async function Hs(t) {
3602
3704
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("domains").addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3603
3705
  "tenant_id",
3604
3706
  "varchar(255)",
3605
3707
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3606
3708
  ).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();
3607
3709
  }
3608
- const Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3710
+ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3609
3711
  __proto__: null,
3610
- down: Us,
3611
- up: Rs
3712
+ down: Hs,
3713
+ up: Gs
3612
3714
  }, Symbol.toStringTag, { value: "Module" }));
3613
- async function Qs(t) {
3715
+ async function Ys(t) {
3614
3716
  }
3615
- async function Vs(t) {
3717
+ async function Zs(t) {
3616
3718
  await t.schema.alterTable("logins").dropColumn("authParams_organization").dropColumn("authorization_url").execute();
3617
3719
  }
3618
- const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3720
+ const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3619
3721
  __proto__: null,
3620
- down: Vs,
3621
- up: Qs
3722
+ down: Zs,
3723
+ up: Ys
3622
3724
  }, Symbol.toStringTag, { value: "Module" }));
3623
- async function qs(t) {
3725
+ async function ti(t) {
3624
3726
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(2048)").execute();
3625
3727
  }
3626
- async function Gs(t) {
3728
+ async function ai(t) {
3627
3729
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(1024)").execute();
3628
3730
  }
3629
- const Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3731
+ const ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3630
3732
  __proto__: null,
3631
- down: Gs,
3632
- up: qs
3733
+ down: ai,
3734
+ up: ti
3633
3735
  }, Symbol.toStringTag, { value: "Module" }));
3634
- async function Xs(t) {
3736
+ async function ni(t) {
3635
3737
  }
3636
- async function Ys(t) {
3738
+ async function oi(t) {
3637
3739
  }
3638
- const Zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3740
+ const si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3639
3741
  __proto__: null,
3640
- down: Ys,
3641
- up: Xs
3742
+ down: oi,
3743
+ up: ni
3642
3744
  }, Symbol.toStringTag, { value: "Module" }));
3643
- async function ei(t) {
3745
+ async function ii(t) {
3644
3746
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3645
3747
  "sessions_user_id_constraint",
3646
3748
  ["user_id", "tenant_id"],
@@ -3667,25 +3769,25 @@ async function ei(t) {
3667
3769
  (e) => e.onDelete("cascade")
3668
3770
  ).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();
3669
3771
  }
3670
- async function ti(t) {
3772
+ async function di(t) {
3671
3773
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
3672
3774
  }
3673
- const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3775
+ const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3674
3776
  __proto__: null,
3675
- down: ti,
3676
- up: ei
3777
+ down: di,
3778
+ up: ii
3677
3779
  }, Symbol.toStringTag, { value: "Module" }));
3678
- async function ri(t) {
3780
+ async function li(t) {
3679
3781
  await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
3680
3782
  }
3681
- async function ni(t) {
3783
+ async function ui(t) {
3682
3784
  }
3683
- const oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3785
+ const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3684
3786
  __proto__: null,
3685
- down: ni,
3686
- up: ri
3787
+ down: ui,
3788
+ up: li
3687
3789
  }, Symbol.toStringTag, { value: "Module" }));
3688
- async function si(t) {
3790
+ async function hi(t) {
3689
3791
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
3690
3792
  "custom_domain_id",
3691
3793
  "varchar(256)",
@@ -3696,153 +3798,166 @@ async function si(t) {
3696
3798
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3697
3799
  ).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();
3698
3800
  }
3699
- async function ii(t) {
3801
+ async function _i(t) {
3700
3802
  }
3701
- const di = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3803
+ const fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3702
3804
  __proto__: null,
3703
- down: ii,
3704
- up: si
3805
+ down: _i,
3806
+ up: hi
3705
3807
  }, Symbol.toStringTag, { value: "Module" }));
3706
- async function ci(t) {
3808
+ async function pi(t) {
3707
3809
  }
3708
- async function li(t) {
3810
+ async function gi(t) {
3709
3811
  await t.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
3710
3812
  }
3711
- const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3712
- __proto__: null,
3713
- down: li,
3714
- up: ci
3715
- }, Symbol.toStringTag, { value: "Module" })), Le = {
3716
- m1_init: Ra,
3717
- m2_magicLink: Qa,
3718
- m3_updateAt: qa,
3719
- m4_logTable: Xa,
3720
- m5_userProfile: er,
3721
- m6_sessions: rr,
3722
- m7_passwords: sr,
3723
- m8_logsTableNewFields: cr,
3724
- m9_passwordTableNewField: mr,
3725
- n01_codesTable: fr,
3726
- n11_universalLoginSession: yr,
3727
- n12_userFields: Nr,
3728
- n13_userEmailIndex: xr,
3729
- n14_profileDataField: Or,
3730
- n15_userEmailIndex: Dr,
3731
- n16_userLocale: jr,
3732
- n17_signingKeys: Ar,
3733
- n18_logsFields: Er,
3734
- n19_connectionsUserinfo: Rr,
3735
- n20_missingFields: Qr,
3736
- n21_sessionDeletedAt: qr,
3737
- n22_dropLogsFields: Xr,
3738
- n23_dropUsersFields: en,
3739
- n24_logsIndexes: rn,
3740
- n25_logDescMaxLength: sn,
3741
- n26_logsTableExtraFields: ln,
3742
- n27_usersTableNameIndex: hn,
3743
- n28_usersEmailConstrain: pn,
3744
- n29_increaseOtpStateLength: wn,
3745
- n30_increaseTicketStateLength: Cn,
3746
- n31_branding: Tn,
3747
- n32_indexesAndNotNull: kn,
3748
- n33_vendorIdInUniversalLoginSession: In,
3749
- n34_auth0ClientInUniversalLoginSession: Mn,
3750
- n35_increaseUniversalSessionStateLength: Ln,
3751
- n36_authenticationCodes: Jn,
3752
- n37_disableSignUps: Un,
3753
- n38_otpIpAddress: Vn,
3754
- n39_increaseUserAgentLength: Gn,
3755
- n40_userId: Yn,
3756
- n41_hooks: to,
3757
- n42_userIdIndexes: no,
3758
- n43_userIdIndexes: io,
3759
- n44_codes: uo,
3760
- n45_hookProperties: _o,
3761
- n46_loginAuth0Client: go,
3762
- n47_loginAuth0Client: vo,
3763
- n48_saml: bo,
3764
- n49_removeFields: So,
3765
- n50_authParamsNonce: $o,
3766
- n51_connectionid: Po,
3767
- n52_cert: Fo,
3768
- n53_codes_primary_key: zo,
3769
- n54_cleanup_tables: Ko,
3770
- n55_logs_index: Bo,
3771
- n56_application_fields: Wo,
3772
- n57_prompt_settings: Ho,
3773
- n58_connection_client_id: Zo,
3774
- n59_connection_options: as,
3775
- n60_users_metadata: os,
3776
- n61_userLocales: ds,
3777
- n62_prompt: us,
3778
- n63_connection_cleanup: _s,
3779
- n64_act_as: gs,
3780
- n65_code_verifier: vs,
3781
- n66_email_providers: bs,
3782
- n67_drop_tickets: Ss,
3783
- n68_login_useragents: $s,
3784
- n70_refresh_tokens: Ps,
3785
- n71_session_new_fields: Fs,
3786
- n72_session_primary_key: zs,
3787
- n73_drop_sessions: Ks,
3788
- n74_custom_domains: Bs,
3789
- n75_organizations: Ws,
3790
- n76_authorization_url_length: Hs,
3791
- n77_drop_sessions: Zs,
3792
- n78_login_sessions: ai,
3793
- n79_drop_sessions_2: oi,
3794
- n80_recreate_custom_domains: di,
3795
- n81_phone: ui
3813
+ const yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3814
+ __proto__: null,
3815
+ down: gi,
3816
+ up: pi
3817
+ }, Symbol.toStringTag, { value: "Module" }));
3818
+ async function wi(t) {
3819
+ 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", "jsonb").addColumn("languages", "jsonb").addColumn("translations", "jsonb").addColumn("nodes", "jsonb").addColumn("start", "jsonb").addColumn("ending", "jsonb").addColumn("style", "jsonb").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();
3820
+ }
3821
+ async function vi(t) {
3822
+ await t.schema.dropTable("forms").execute();
3823
+ }
3824
+ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3825
+ __proto__: null,
3826
+ down: vi,
3827
+ up: wi
3828
+ }, Symbol.toStringTag, { value: "Module" })), ze = {
3829
+ m1_init: Ga,
3830
+ m2_magicLink: Ya,
3831
+ m3_updateAt: tr,
3832
+ m4_logTable: nr,
3833
+ m5_userProfile: ir,
3834
+ m6_sessions: lr,
3835
+ m7_passwords: hr,
3836
+ m8_logsTableNewFields: pr,
3837
+ m9_passwordTableNewField: wr,
3838
+ n01_codesTable: Cr,
3839
+ n11_universalLoginSession: Tr,
3840
+ n12_userFields: kr,
3841
+ n13_userEmailIndex: Ir,
3842
+ n14_profileDataField: Mr,
3843
+ n15_userEmailIndex: Lr,
3844
+ n16_userLocale: Er,
3845
+ n17_signingKeys: Ur,
3846
+ n18_logsFields: qr,
3847
+ n19_connectionsUserinfo: Gr,
3848
+ n20_missingFields: Yr,
3849
+ n21_sessionDeletedAt: tn,
3850
+ n22_dropLogsFields: nn,
3851
+ n23_dropUsersFields: dn,
3852
+ n24_logsIndexes: un,
3853
+ n25_logDescMaxLength: _n,
3854
+ n26_logsTableExtraFields: gn,
3855
+ n27_usersTableNameIndex: vn,
3856
+ n28_usersEmailConstrain: bn,
3857
+ n29_increaseOtpStateLength: Sn,
3858
+ n30_increaseTicketStateLength: $n,
3859
+ n31_branding: Pn,
3860
+ n32_indexesAndNotNull: Fn,
3861
+ n33_vendorIdInUniversalLoginSession: zn,
3862
+ n34_auth0ClientInUniversalLoginSession: Kn,
3863
+ n35_increaseUniversalSessionStateLength: Bn,
3864
+ n36_authenticationCodes: Vn,
3865
+ n37_disableSignUps: Hn,
3866
+ n38_otpIpAddress: Zn,
3867
+ n39_increaseUserAgentLength: ao,
3868
+ n40_userId: oo,
3869
+ n41_hooks: co,
3870
+ n42_userIdIndexes: mo,
3871
+ n43_userIdIndexes: fo,
3872
+ n44_codes: yo,
3873
+ n45_hookProperties: No,
3874
+ n46_loginAuth0Client: xo,
3875
+ n47_loginAuth0Client: Oo,
3876
+ n48_saml: Do,
3877
+ n49_removeFields: jo,
3878
+ n50_authParamsNonce: Ao,
3879
+ n51_connectionid: Jo,
3880
+ n52_cert: Ro,
3881
+ n53_codes_primary_key: Qo,
3882
+ n54_cleanup_tables: Wo,
3883
+ n55_logs_index: Xo,
3884
+ n56_application_fields: es,
3885
+ n57_prompt_settings: rs,
3886
+ n58_connection_client_id: ss,
3887
+ n59_connection_options: cs,
3888
+ n60_users_metadata: ms,
3889
+ n61_userLocales: fs,
3890
+ n62_prompt: ys,
3891
+ n63_connection_cleanup: Ns,
3892
+ n64_act_as: xs,
3893
+ n65_code_verifier: Os,
3894
+ n66_email_providers: Ds,
3895
+ n67_drop_tickets: js,
3896
+ n68_login_useragents: As,
3897
+ n70_refresh_tokens: Js,
3898
+ n71_session_new_fields: Rs,
3899
+ n72_session_primary_key: Qs,
3900
+ n73_drop_sessions: Ws,
3901
+ n74_custom_domains: Xs,
3902
+ n75_organizations: ei,
3903
+ n76_authorization_url_length: ri,
3904
+ n77_drop_sessions: si,
3905
+ n78_login_sessions: ci,
3906
+ n79_drop_sessions_2: mi,
3907
+ n80_recreate_custom_domains: fi,
3908
+ n81_phone: yi,
3909
+ n82_forms: Ni
3796
3910
  };
3797
- async function pi(t, e = !1) {
3911
+ async function Si(t, e = !1) {
3798
3912
  e && console.log("migrating...");
3799
- const a = new Ae(Le), r = new Ne({
3913
+ const a = new Le(ze), r = new Ce({
3800
3914
  db: t,
3801
3915
  provider: a
3802
- }), { error: o, results: n } = await r.migrateToLatest();
3803
- if (n == null || n.forEach((s) => {
3916
+ }), { error: n, results: o } = await r.migrateToLatest();
3917
+ if (o == null || o.forEach((s) => {
3804
3918
  s.status === "Success" ? e && console.log(
3805
3919
  `migration "${s.migrationName}" was executed successfully`
3806
3920
  ) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
3807
- }), o)
3808
- throw console.error("failed to migrate"), console.error(o), o;
3921
+ }), n)
3922
+ throw console.error("failed to migrate"), console.error(n), n;
3809
3923
  }
3810
- async function gi(t) {
3924
+ async function Oi(t) {
3811
3925
  console.log("migrating...");
3812
- const e = new Ae(Le), a = new Ne({
3926
+ const e = new Le(ze), a = new Ce({
3813
3927
  db: t,
3814
3928
  provider: e
3815
- }), { error: r, results: o } = await a.migrateDown();
3816
- if (o == null || o.forEach((n) => {
3817
- n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
3929
+ }), { error: r, results: n } = await a.migrateDown();
3930
+ if (n == null || n.forEach((o) => {
3931
+ o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
3818
3932
  }), r)
3819
3933
  throw console.error("failed to migrate"), console.error(r), r;
3820
3934
  }
3821
- function yi(t) {
3935
+ function ki(t) {
3822
3936
  return {
3823
- applications: It(t),
3824
- branding: Yt(t),
3825
- cleanup: $a(t),
3826
- clients: zt(t),
3827
- codes: Tt(t),
3828
- connections: Lt(t),
3829
- emailProviders: Ca(t),
3830
- customDomains: Gt(t),
3831
- hooks: na(t),
3832
- keys: Rt(t),
3833
- loginSessions: fa(t),
3834
- logs: ct(t),
3835
- passwords: wt(t),
3836
- promptSettings: ya(t),
3837
- refreshTokens: ka(t),
3838
- sessions: ft(t),
3839
- tenants: nt(t),
3840
- themes: la(t),
3841
- users: Xe(t)
3937
+ applications: Pt(t),
3938
+ branding: Zt(t),
3939
+ cleanup: Da(t),
3940
+ clients: Jt(t),
3941
+ codes: St(t),
3942
+ connections: zt(t),
3943
+ emailProviders: ba(t),
3944
+ customDomains: Ht(t),
3945
+ forms: Aa(t),
3946
+ hooks: oa(t),
3947
+ keys: Ut(t),
3948
+ loginSessions: pa(t),
3949
+ logs: lt(t),
3950
+ passwords: vt(t),
3951
+ promptSettings: wa(t),
3952
+ refreshTokens: $a(t),
3953
+ sessions: pt(t),
3954
+ tenants: ot(t),
3955
+ themes: ua(t),
3956
+ users: Ye(t)
3842
3957
  };
3843
3958
  }
3844
3959
  export {
3845
- yi as default,
3846
- gi as migrateDown,
3847
- pi as migrateToLatest
3960
+ ki as default,
3961
+ Oi as migrateDown,
3962
+ Si as migrateToLatest
3848
3963
  };