@authhero/kysely-adapter 10.37.1 → 10.39.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,18 +1,18 @@
1
- var Je = Object.defineProperty;
1
+ var Le = Object.defineProperty;
2
2
  var ue = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var Re = (t, e, r) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
6
- var R = (t, e, r) => Re(t, typeof e != "symbol" ? e + "" : e, r), Y = (t, e, r) => e.has(t) || ue("Cannot " + r);
7
- var d = (t, e, r) => (Y(t, e, "read from private field"), r ? r.call(t) : e.get(t)), S = (t, e, r) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), K = (t, e, r, a) => (Y(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), p = (t, e, r) => (Y(t, e, "access private method"), r);
8
- import { parseUserId as ie, codeSchema as Ke, connectionSchema as Ue, loginSessionSchema as Be, promptSettingSchema as Qe, formSchema as G, resourceServerSchema as qe } from "@authhero/adapter-interfaces";
5
+ var Re = (t, e, a) => e in t ? Le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
+ var R = (t, e, a) => Re(t, typeof e != "symbol" ? e + "" : e, a), X = (t, e, a) => e.has(t) || ue("Cannot " + a);
7
+ var u = (t, e, a) => (X(t, e, "read from private field"), a ? a.call(t) : e.get(t)), O = (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), K = (t, e, a, r) => (X(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), p = (t, e, a) => (X(t, e, "access private method"), a);
8
+ import { parseUserId as ie, codeSchema as Ke, connectionSchema as Ue, loginSessionSchema as Be, promptSettingSchema as qe, formSchema as H, resourceServerSchema as Qe } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
- var te = class extends Error {
11
- constructor(e = 500, r) {
12
- super(r == null ? void 0 : r.message, { cause: r == null ? void 0 : r.cause });
10
+ var q = class extends Error {
11
+ constructor(e = 500, a) {
12
+ super(a == null ? void 0 : a.message, { cause: a == null ? void 0 : a.cause });
13
13
  R(this, "res");
14
14
  R(this, "status");
15
- this.res = r == null ? void 0 : r.res, this.status = e;
15
+ this.res = a == null ? void 0 : a.res, this.status = e;
16
16
  }
17
17
  getResponse() {
18
18
  return this.res ? new Response(this.res.body, {
@@ -23,23 +23,23 @@ var te = class extends Error {
23
23
  });
24
24
  }
25
25
  };
26
- function Ve(t) {
27
- return async (e, r) => {
28
- const { identities: a, ...n } = r, o = {
26
+ function We(t) {
27
+ return async (e, a) => {
28
+ const { identities: r, ...n } = a, o = {
29
29
  ...n,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
33
33
  tenant_id: e,
34
- email_verified: r.email_verified ? 1 : 0,
35
- is_social: r.is_social ? 1 : 0,
36
- app_metadata: JSON.stringify(r.app_metadata),
37
- user_metadata: JSON.stringify(r.user_metadata)
34
+ email_verified: a.email_verified ? 1 : 0,
35
+ is_social: a.is_social ? 1 : 0,
36
+ app_metadata: JSON.stringify(a.app_metadata),
37
+ user_metadata: JSON.stringify(a.user_metadata)
38
38
  };
39
39
  try {
40
40
  await t.insertInto("users").values(o).execute();
41
41
  } catch (s) {
42
- throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new te(409, { message: "User already exists" }) : new te(500, { message: `${s.code}, ${s.message}` });
42
+ throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new q(409, { message: "User already exists" }) : new q(500, { message: `${s.code}, ${s.message}` });
43
43
  }
44
44
  return {
45
45
  ...o,
@@ -55,17 +55,17 @@ function y(t) {
55
55
  return t;
56
56
  if (Array.isArray(t))
57
57
  return t.map(
58
- (r) => (
58
+ (a) => (
59
59
  // Only recurse into objects; leave primitives untouched
60
- r !== null && typeof r == "object" ? y(r) : r
60
+ a !== null && typeof a == "object" ? y(a) : a
61
61
  )
62
62
  );
63
63
  const e = { ...t };
64
- for (const r in e) {
65
- const a = e[r];
66
- a === null ? delete e[r] : a !== null && typeof a == "object" && (Array.isArray(a) ? e[r] = a.map(
64
+ for (const a in e) {
65
+ const r = e[a];
66
+ r === null ? delete e[a] : r !== null && typeof r == "object" && (Array.isArray(r) ? e[a] = r.map(
67
67
  (n) => n !== null && typeof n == "object" ? y(n) : n
68
- ) : e[r] = y(a));
68
+ ) : e[a] = y(r));
69
69
  }
70
70
  return e;
71
71
  }
@@ -73,8 +73,8 @@ function pe(t) {
73
73
  let e = {};
74
74
  try {
75
75
  e = JSON.parse(t.profileData || "{}");
76
- } catch (r) {
77
- console.error("Error parsing profileData", r);
76
+ } catch (a) {
77
+ console.error("Error parsing profileData", a);
78
78
  }
79
79
  return {
80
80
  connection: t.connection,
@@ -88,27 +88,27 @@ function pe(t) {
88
88
  }
89
89
  };
90
90
  }
91
- function We(t) {
92
- return async (e, r) => {
93
- const [a, n] = await Promise.all([
94
- t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", r).selectAll().executeTakeFirst(),
95
- t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", r).selectAll().execute()
91
+ function Ve(t) {
92
+ return async (e, a) => {
93
+ const [r, n] = await Promise.all([
94
+ t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
95
+ t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
96
96
  ]);
97
- if (!a)
97
+ if (!r)
98
98
  return null;
99
- const { tenant_id: o, ...s } = a, i = {
99
+ const { tenant_id: o, ...s } = r, i = {
100
100
  ...s,
101
- email: a.email || "",
102
- email_verified: a.email_verified === 1,
103
- is_social: a.is_social === 1,
104
- app_metadata: JSON.parse(a.app_metadata),
105
- user_metadata: JSON.parse(a.user_metadata),
101
+ email: r.email || "",
102
+ email_verified: r.email_verified === 1,
103
+ is_social: r.is_social === 1,
104
+ app_metadata: JSON.parse(r.app_metadata),
105
+ user_metadata: JSON.parse(r.user_metadata),
106
106
  identities: [
107
107
  {
108
- connection: a.connection,
109
- provider: a.provider,
110
- user_id: ie(a.user_id).id,
111
- isSocial: !!a.is_social
108
+ connection: r.connection,
109
+ provider: r.provider,
110
+ user_id: ie(r.user_id).id,
111
+ isSocial: !!r.is_social
112
112
  },
113
113
  ...n.map(pe)
114
114
  ]
@@ -116,25 +116,25 @@ function We(t) {
116
116
  return y(i);
117
117
  };
118
118
  }
119
- function T(t, e, r, a) {
120
- return r.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
121
- let s = o.startsWith("-"), i = null, c = "", _ = !1, u;
119
+ function S(t, e, a, r) {
120
+ return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
121
+ let s = o.startsWith("-"), i = null, c = "", m = !1, _;
122
122
  if (o.startsWith("-_exists_:"))
123
- i = o.substring(10), _ = !0, s = !0;
123
+ i = o.substring(10), m = !0, s = !0;
124
124
  else if (o.startsWith("_exists_:"))
125
- i = o.substring(9), _ = !0, s = !1;
125
+ i = o.substring(9), m = !0, s = !1;
126
126
  else if (o.includes(":")) {
127
- const m = s ? o.substring(1) : o, h = m.indexOf(":");
128
- i = m.substring(0, h), c = m.substring(h + 1), _ = !1, c.startsWith(">=") ? (u = ">=", c = c.substring(2)) : c.startsWith(">") ? (u = ">", c = c.substring(1)) : c.startsWith("<=") ? (u = "<=", c = c.substring(2)) : c.startsWith("<") ? (u = "<", c = c.substring(1)) : u = "=";
127
+ const d = s ? o.substring(1) : o, h = d.indexOf(":");
128
+ i = d.substring(0, h), c = d.substring(h + 1), m = !1, c.startsWith(">=") ? (_ = ">=", c = c.substring(2)) : c.startsWith(">") ? (_ = ">", c = c.substring(1)) : c.startsWith("<=") ? (_ = "<=", c = c.substring(2)) : c.startsWith("<") ? (_ = "<", c = c.substring(1)) : _ = "=";
129
129
  } else
130
- i = null, c = o, _ = !1;
131
- return { key: i, value: c, isNegation: s, isExistsQuery: _, operator: u };
132
- }).forEach(({ key: o, value: s, isNegation: i, isExistsQuery: c, operator: _ }) => {
130
+ i = null, c = o, m = !1;
131
+ return { key: i, value: c, isNegation: s, isExistsQuery: m, operator: _ };
132
+ }).forEach(({ key: o, value: s, isNegation: i, isExistsQuery: c, operator: m }) => {
133
133
  if (o)
134
134
  if (c)
135
135
  i ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
136
136
  else if (i)
137
- switch (_) {
137
+ switch (m) {
138
138
  case ">":
139
139
  e = e.where(o, "<=", s);
140
140
  break;
@@ -151,12 +151,12 @@ function T(t, e, r, a) {
151
151
  e = e.where(o, "!=", s);
152
152
  }
153
153
  else
154
- e = e.where(o, _, s);
154
+ e = e.where(o, m, s);
155
155
  else if (s) {
156
- const { ref: u } = t.dynamic;
156
+ const { ref: _ } = t.dynamic;
157
157
  e = e.where(
158
- (m) => m.or(
159
- a.map((h) => m(u(h), "like", `%${s}%`))
158
+ (d) => d.or(
159
+ r.map((h) => d(_(h), "like", `%${s}%`))
160
160
  )
161
161
  );
162
162
  }
@@ -166,14 +166,14 @@ function x(t) {
166
166
  return typeof t == "string" ? parseInt(t, 10) : typeof t == "bigint" ? Number(t) : t;
167
167
  }
168
168
  function Ge(t) {
169
- return async (e, r = {}) => {
170
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
169
+ return async (e, a = {}) => {
170
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
171
171
  let c = t.selectFrom("users").where("users.tenant_id", "=", e);
172
- if (i && (c = T(t, c, i, ["email", "name"])), s && s.sort_by) {
172
+ if (i && (c = S(t, c, i, ["email", "name"])), s && s.sort_by) {
173
173
  const { ref: w } = t.dynamic;
174
174
  c = c.orderBy(w(s.sort_by), s.sort_order);
175
175
  }
176
- const u = await c.offset(a * n).limit(n).selectAll().execute(), m = u.map((w) => w.user_id), h = m.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", m).execute() : [], f = u.map((w) => {
176
+ const _ = await c.offset(r * n).limit(n).selectAll().execute(), d = _.map((w) => w.user_id), h = d.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", d).execute() : [], f = _.map((w) => {
177
177
  const b = h.filter(
178
178
  (D) => D.linked_to === w.user_id
179
179
  );
@@ -204,63 +204,63 @@ function Ge(t) {
204
204
  const { count: g } = await c.select((w) => w.fn.countAll().as("count")).executeTakeFirstOrThrow();
205
205
  return {
206
206
  users: f,
207
- start: a * n,
207
+ start: r * n,
208
208
  limit: n,
209
209
  length: x(g)
210
210
  };
211
211
  };
212
212
  }
213
213
  function He(t) {
214
- return async (e, r) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", r).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1);
214
+ 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);
215
215
  }
216
- function J(t, e = "", r = {}) {
217
- for (let a in t)
218
- if (Object.prototype.hasOwnProperty.call(t, a)) {
219
- const n = e ? `${e}_${a}` : a, o = t[a];
220
- typeof o == "object" && o !== null && !Array.isArray(o) ? J(o, n, r) : typeof o == "boolean" ? r[n] = o ? 1 : 0 : r[n] = o;
216
+ function L(t, e = "", a = {}) {
217
+ for (let r in t)
218
+ if (Object.prototype.hasOwnProperty.call(t, r)) {
219
+ const n = e ? `${e}_${r}` : r, o = t[r];
220
+ typeof o == "object" && o !== null && !Array.isArray(o) ? L(o, n, a) : typeof o == "boolean" ? a[n] = o ? 1 : 0 : a[n] = o;
221
221
  }
222
- return r;
222
+ return a;
223
223
  }
224
224
  function ge(t, e) {
225
- const r = {};
226
- for (const [a, n] of Object.entries(t)) {
225
+ const a = {};
226
+ for (const [r, n] of Object.entries(t)) {
227
227
  const o = e.find(
228
- (s) => a.startsWith(`${s}_`)
228
+ (s) => r.startsWith(`${s}_`)
229
229
  );
230
230
  if (!o)
231
- r[a] = n;
231
+ a[r] = n;
232
232
  else {
233
- const s = a.slice(o.length + 1);
234
- r[o] = {
235
- ...r[o],
233
+ const s = r.slice(o.length + 1);
234
+ a[o] = {
235
+ ...a[o],
236
236
  [s]: n
237
237
  };
238
238
  }
239
239
  }
240
- return r;
240
+ return a;
241
241
  }
242
242
  function Ye(t) {
243
- return async (e, r, a) => {
244
- const n = J({
245
- ...a,
243
+ return async (e, a, r) => {
244
+ const n = L({
245
+ ...r,
246
246
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
247
- app_metadata: a.app_metadata ? JSON.stringify(a.app_metadata) : void 0,
248
- user_metadata: a.user_metadata ? JSON.stringify(a.user_metadata) : void 0
247
+ app_metadata: r.app_metadata ? JSON.stringify(r.app_metadata) : void 0,
248
+ user_metadata: r.user_metadata ? JSON.stringify(r.user_metadata) : void 0
249
249
  });
250
- return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", r).execute()).length === 1;
250
+ return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
251
251
  };
252
252
  }
253
253
  function Xe(t) {
254
- return async (e, r, a, n) => {
254
+ return async (e, a, r, n) => {
255
255
  const o = { linked_to: null };
256
- return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", `${a}|${n}`).where("users.linked_to", "=", `${r}`).execute()).length === 1;
256
+ 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;
257
257
  };
258
258
  }
259
259
  function Ze(t) {
260
260
  return {
261
- create: Ve(t),
261
+ create: We(t),
262
262
  remove: He(t),
263
- get: We(t),
263
+ get: Ve(t),
264
264
  list: Ge(t),
265
265
  update: Ye(t),
266
266
  // TODO - think about this more when other issues fixed
@@ -268,60 +268,60 @@ function Ze(t) {
268
268
  };
269
269
  }
270
270
  const et = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
271
- let O = (t = 21) => {
272
- let e = "", r = crypto.getRandomValues(new Uint8Array(t));
271
+ let T = (t = 21) => {
272
+ let e = "", a = crypto.getRandomValues(new Uint8Array(t));
273
273
  for (; t--; )
274
- e += et[r[t] & 63];
274
+ e += et[a[t] & 63];
275
275
  return e;
276
276
  };
277
277
  function tt(t) {
278
278
  return async (e) => {
279
- const r = {
280
- id: e.id || O(),
279
+ const a = {
280
+ id: e.id || T(),
281
281
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
282
282
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
283
283
  ...e
284
284
  };
285
- return await t.insertInto("tenants").values(r).execute(), r;
285
+ return await t.insertInto("tenants").values(a).execute(), a;
286
286
  };
287
287
  }
288
- function rt(t) {
288
+ function at(t) {
289
289
  return async (e) => {
290
- const r = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
291
- return r ? y(r) : null;
290
+ const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
291
+ return a ? y(a) : null;
292
292
  };
293
293
  }
294
- function at(t) {
294
+ function rt(t) {
295
295
  return async (e) => {
296
- let r = t.selectFrom("tenants");
297
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = e;
296
+ let a = t.selectFrom("tenants");
297
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = e;
298
298
  if (s && s.sort_by) {
299
299
  const { ref: f } = t.dynamic;
300
- r = r.orderBy(f(s.sort_by), s.sort_order);
300
+ a = a.orderBy(f(s.sort_by), s.sort_order);
301
301
  }
302
- i && (r = r.where((f) => f.or([f("name", "like", `%${i}%`)])));
303
- const u = (await r.offset(a * n).limit(n).selectAll().execute()).map(y);
302
+ i && (a = a.where((f) => f.or([f("name", "like", `%${i}%`)])));
303
+ const _ = (await a.offset(r * n).limit(n).selectAll().execute()).map(y);
304
304
  if (!o)
305
305
  return {
306
- tenants: u
306
+ tenants: _
307
307
  };
308
- const { count: m } = await r.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow(), h = x(m);
308
+ const { count: d } = await a.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow(), h = x(d);
309
309
  return {
310
- tenants: u,
311
- start: a * n,
310
+ tenants: _,
311
+ start: r * n,
312
312
  limit: n,
313
313
  length: h
314
314
  };
315
315
  };
316
316
  }
317
317
  function nt(t) {
318
- return async (e, r) => {
319
- const a = {
320
- ...r,
318
+ return async (e, a) => {
319
+ const r = {
320
+ ...a,
321
321
  id: e,
322
322
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
323
323
  };
324
- await t.updateTable("tenants").set(a).where("id", "=", e).execute();
324
+ await t.updateTable("tenants").set(r).where("id", "=", e).execute();
325
325
  };
326
326
  }
327
327
  function ot(t) {
@@ -330,8 +330,8 @@ function ot(t) {
330
330
  function st(t) {
331
331
  return {
332
332
  create: tt(t),
333
- get: rt(t),
334
- list: at(t),
333
+ get: at(t),
334
+ list: rt(t),
335
335
  update: nt(t),
336
336
  remove: ot(t)
337
337
  };
@@ -341,23 +341,23 @@ function me(t) {
341
341
  }
342
342
  const it = 1024;
343
343
  function lt(t) {
344
- return async (e, r) => {
344
+ return async (e, a) => {
345
345
  var n, o, s;
346
- const a = {
347
- id: O(),
348
- ...r,
349
- user_agent: r.user_agent.slice(0, it)
346
+ const r = {
347
+ id: T(),
348
+ ...a,
349
+ user_agent: a.user_agent.slice(0, it)
350
350
  };
351
351
  return await t.insertInto("logs").values({
352
- ...a,
352
+ ...r,
353
353
  // Truncate long strings to avoid database errors
354
- description: (n = a.description) == null ? void 0 : n.substring(0, 256),
355
- isMobile: r.isMobile ? 1 : 0,
354
+ description: (n = r.description) == null ? void 0 : n.substring(0, 256),
355
+ isMobile: a.isMobile ? 1 : 0,
356
356
  tenant_id: e,
357
- scope: (o = r.scope) == null ? void 0 : o.join(","),
358
- auth0_client: me(r.auth0_client),
359
- details: (s = me(r.details)) == null ? void 0 : s.substring(0, 8192)
360
- }).execute(), a;
357
+ scope: (o = a.scope) == null ? void 0 : o.join(","),
358
+ auth0_client: me(a.auth0_client),
359
+ details: (s = me(a.details)) == null ? void 0 : s.substring(0, 8192)
360
+ }).execute(), r;
361
361
  };
362
362
  }
363
363
  function _e(t) {
@@ -383,37 +383,37 @@ function we(t) {
383
383
  };
384
384
  }
385
385
  function ct(t) {
386
- return async (e, r = {}) => {
387
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
386
+ return async (e, a = {}) => {
387
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
388
388
  let c = t.selectFrom("logs").where("logs.tenant_id", "=", e);
389
- i && (c = T(t, c, i, ["user_id", "ip"]));
390
- let _ = c;
389
+ i && (c = S(t, c, i, ["user_id", "ip"]));
390
+ let m = c;
391
391
  if (s && s.sort_by) {
392
392
  const { ref: f } = t.dynamic;
393
- _ = _.orderBy(f(s.sort_by), s.sort_order);
393
+ m = m.orderBy(f(s.sort_by), s.sort_order);
394
394
  }
395
- _ = _.offset(a * n).limit(n);
396
- const m = (await _.selectAll().execute()).map(we);
395
+ m = m.offset(r * n).limit(n);
396
+ const d = (await m.selectAll().execute()).map(we);
397
397
  if (!o)
398
398
  return {
399
- logs: m,
399
+ logs: d,
400
400
  start: 0,
401
401
  limit: 0,
402
402
  length: 0
403
403
  };
404
404
  const { count: h } = await c.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
405
405
  return {
406
- logs: m,
407
- start: a * n,
406
+ logs: d,
407
+ start: r * n,
408
408
  limit: n,
409
409
  length: x(h)
410
410
  };
411
411
  };
412
412
  }
413
413
  function dt(t) {
414
- return async (e, r) => {
415
- const a = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", r).selectAll().executeTakeFirst();
416
- return a ? we(a) : null;
414
+ return async (e, a) => {
415
+ const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
416
+ return r ? we(r) : null;
417
417
  };
418
418
  }
419
419
  function ut(t) {
@@ -424,11 +424,11 @@ function ut(t) {
424
424
  };
425
425
  }
426
426
  function mt(t) {
427
- return async (e, r) => {
428
- const a = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", r).selectAll().executeTakeFirst();
429
- if (!a)
427
+ return async (e, a) => {
428
+ const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
429
+ if (!r)
430
430
  return null;
431
- const { tenant_id: n, device: o, clients: s, ...i } = a;
431
+ const { tenant_id: n, device: o, clients: s, ...i } = r;
432
432
  return {
433
433
  ...i,
434
434
  device: JSON.parse(o),
@@ -437,63 +437,63 @@ function mt(t) {
437
437
  };
438
438
  }
439
439
  function _t(t) {
440
- return async (e, r) => {
441
- const a = {
442
- ...r,
440
+ return async (e, a) => {
441
+ const r = {
442
+ ...a,
443
443
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
444
444
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
445
445
  authenticated_at: (/* @__PURE__ */ new Date()).toISOString(),
446
446
  last_interaction_at: (/* @__PURE__ */ new Date()).toISOString()
447
447
  };
448
448
  return await t.insertInto("sessions").values({
449
- ...a,
449
+ ...r,
450
450
  tenant_id: e,
451
- device: JSON.stringify(r.device),
452
- clients: JSON.stringify(r.clients)
453
- }).execute(), a;
451
+ device: JSON.stringify(a.device),
452
+ clients: JSON.stringify(a.clients)
453
+ }).execute(), r;
454
454
  };
455
455
  }
456
456
  function ht(t) {
457
- return async (e, r) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
457
+ return async (e, a) => !!(await t.deleteFrom("sessions").where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
458
458
  }
459
459
  function ft(t) {
460
- return async (e, r, a) => {
460
+ return async (e, a, r) => {
461
461
  const n = {
462
- ...a,
462
+ ...r,
463
463
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
464
- device: a.device ? JSON.stringify(a.device) : void 0,
465
- clients: a.clients ? JSON.stringify(a.clients) : void 0
464
+ device: r.device ? JSON.stringify(r.device) : void 0,
465
+ clients: r.clients ? JSON.stringify(r.clients) : void 0
466
466
  };
467
- return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", r).execute()).length;
467
+ return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
468
468
  };
469
469
  }
470
470
  function pt(t) {
471
- return async (e, r = {}) => {
472
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
471
+ return async (e, a = {}) => {
472
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
473
473
  let c = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
474
- i && (c = T(t, c, i, ["user_id", "session_id"]));
475
- let _ = c;
474
+ i && (c = S(t, c, i, ["user_id", "session_id"]));
475
+ let m = c;
476
476
  if (s && s.sort_by) {
477
477
  const { ref: g } = t.dynamic;
478
- _ = _.orderBy(g(s.sort_by), s.sort_order);
478
+ m = m.orderBy(g(s.sort_by), s.sort_order);
479
479
  }
480
- _ = _.offset(a * n).limit(n);
481
- const m = (await _.selectAll().execute()).map((g) => ({
480
+ m = m.offset(r * n).limit(n);
481
+ const d = (await m.selectAll().execute()).map((g) => ({
482
482
  ...g,
483
483
  device: JSON.parse(g.device),
484
484
  clients: JSON.parse(g.clients)
485
485
  }));
486
486
  if (!o)
487
487
  return {
488
- sessions: m,
488
+ sessions: d,
489
489
  start: 0,
490
490
  limit: 0,
491
491
  length: 0
492
492
  };
493
493
  const { count: h } = await c.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = x(h);
494
494
  return {
495
- sessions: m,
496
- start: a * n,
495
+ sessions: d,
496
+ start: r * n,
497
497
  limit: n,
498
498
  length: f
499
499
  };
@@ -509,32 +509,32 @@ function gt(t) {
509
509
  };
510
510
  }
511
511
  function wt(t) {
512
- return async (e, r) => {
513
- const a = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", r).selectAll().executeTakeFirst();
514
- if (!a)
512
+ return async (e, a) => {
513
+ const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
514
+ if (!r)
515
515
  return null;
516
- const { tenant_id: n, ...o } = a;
516
+ const { tenant_id: n, ...o } = r;
517
517
  return o;
518
518
  };
519
519
  }
520
520
  function yt(t) {
521
- return async (e, r) => {
522
- const a = {
523
- ...r,
521
+ return async (e, a) => {
522
+ const r = {
523
+ ...a,
524
524
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
525
525
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
526
526
  };
527
527
  return await t.insertInto("passwords").values({
528
- ...a,
528
+ ...r,
529
529
  tenant_id: e
530
- }).execute(), a;
530
+ }).execute(), r;
531
531
  };
532
532
  }
533
533
  function vt(t) {
534
- return async (e, r) => (await t.updateTable("passwords").set({
535
- password: r.password,
534
+ return async (e, a) => (await t.updateTable("passwords").set({
535
+ password: a.password,
536
536
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
537
- }).where("tenant_id", "=", e).where("user_id", "=", r.user_id).execute()).length === 1;
537
+ }).where("tenant_id", "=", e).where("user_id", "=", a.user_id).execute()).length === 1;
538
538
  }
539
539
  function Nt(t) {
540
540
  return {
@@ -544,55 +544,55 @@ function Nt(t) {
544
544
  };
545
545
  }
546
546
  function Ct(t) {
547
- return async (e, r = {}) => {
548
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
547
+ return async (e, a = {}) => {
548
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
549
549
  let i = t.selectFrom("codes").where("codes.tenant_id", "=", e);
550
- s && (i = T(t, i, s, ["code", "login_id"]));
551
- const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
550
+ s && (i = S(t, i, s, ["code", "login_id"]));
551
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
552
552
  const { tenant_id: f, ...g } = h;
553
553
  return Ke.parse(y(g));
554
554
  });
555
555
  if (!o)
556
556
  return {
557
- codes: u,
557
+ codes: _,
558
558
  start: 0,
559
559
  limit: 0,
560
560
  length: 0
561
561
  };
562
- const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
562
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
563
563
  return {
564
- codes: u,
565
- start: a * n,
564
+ codes: _,
565
+ start: r * n,
566
566
  limit: n,
567
- length: x(m)
567
+ length: x(d)
568
568
  };
569
569
  };
570
570
  }
571
571
  function bt(t) {
572
- return async (e, r) => {
573
- const a = {
574
- ...r,
572
+ return async (e, a) => {
573
+ const r = {
574
+ ...a,
575
575
  created_at: (/* @__PURE__ */ new Date()).toISOString()
576
576
  };
577
577
  return await t.insertInto("codes").values({
578
- ...a,
578
+ ...r,
579
579
  tenant_id: e
580
- }).execute(), a;
580
+ }).execute(), r;
581
581
  };
582
582
  }
583
583
  function xt(t) {
584
- return async (e, r) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
584
+ return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
585
585
  }
586
586
  function Tt(t) {
587
- return async (e, r, a) => {
588
- let n = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
587
+ return async (e, a, r) => {
588
+ let n = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
589
589
  e.length && (n = n.where("codes.tenant_id", "=", e));
590
590
  const o = await n.selectAll().executeTakeFirst();
591
591
  return o ? y(o) : null;
592
592
  };
593
593
  }
594
594
  function St(t) {
595
- return async (e, r) => (await t.updateTable("codes").set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where("codes.tenant_id", "=", e).where("codes.code_id", "=", r).executeTakeFirst()).numUpdatedRows > 0;
595
+ 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;
596
596
  }
597
597
  function Ot(t) {
598
598
  return {
@@ -604,24 +604,24 @@ function Ot(t) {
604
604
  };
605
605
  }
606
606
  function kt(t) {
607
- return async (e, r) => {
608
- const a = {
607
+ return async (e, a) => {
608
+ const r = {
609
609
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
610
610
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
611
- ...r,
612
- disable_sign_ups: r.disable_sign_ups ?? !1
613
- }, n = JSON.stringify(r.allowed_origins), o = JSON.stringify(r.callbacks), s = JSON.stringify(r.web_origins), i = JSON.stringify(r.allowed_logout_urls), c = JSON.stringify(r.allowed_clients);
614
- return await t.insertInto("applications").values({
615
611
  ...a,
612
+ disable_sign_ups: a.disable_sign_ups ?? !1
613
+ }, n = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), i = JSON.stringify(a.allowed_logout_urls), c = JSON.stringify(a.allowed_clients);
614
+ return await t.insertInto("applications").values({
615
+ ...r,
616
616
  tenant_id: e,
617
- disable_sign_ups: r.disable_sign_ups ? 1 : 0,
618
- addons: r.addons ? JSON.stringify(r.addons) : "{}",
617
+ disable_sign_ups: a.disable_sign_ups ? 1 : 0,
618
+ addons: a.addons ? JSON.stringify(a.addons) : "{}",
619
619
  callbacks: o,
620
620
  allowed_origins: n,
621
621
  web_origins: s,
622
622
  allowed_logout_urls: i,
623
623
  allowed_clients: c
624
- }).execute(), a;
624
+ }).execute(), r;
625
625
  };
626
626
  }
627
627
  function $t(t) {
@@ -639,36 +639,36 @@ function $t(t) {
639
639
  });
640
640
  }
641
641
  function It(t) {
642
- return async (e, r) => {
643
- const a = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).selectAll().executeTakeFirst();
644
- return a ? y({
645
- ...a,
646
- disable_sign_ups: !!a.disable_sign_ups,
647
- addons: JSON.parse(a.addons),
648
- callbacks: JSON.parse(a.callbacks),
649
- allowed_origins: JSON.parse(a.allowed_origins),
650
- web_origins: JSON.parse(a.web_origins),
651
- allowed_logout_urls: JSON.parse(a.allowed_logout_urls)
642
+ return async (e, a) => {
643
+ const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
644
+ return r ? y({
645
+ ...r,
646
+ disable_sign_ups: !!r.disable_sign_ups,
647
+ addons: JSON.parse(r.addons),
648
+ callbacks: JSON.parse(r.callbacks),
649
+ allowed_origins: JSON.parse(r.allowed_origins),
650
+ web_origins: JSON.parse(r.web_origins),
651
+ allowed_logout_urls: JSON.parse(r.allowed_logout_urls)
652
652
  }) : null;
653
653
  };
654
654
  }
655
655
  function Dt(t) {
656
- return async (e, r) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
656
+ return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
657
657
  }
658
658
  function Pt(t) {
659
- return async (e, r, a) => {
659
+ return async (e, a, r) => {
660
660
  const n = {
661
- ...a,
661
+ ...r,
662
662
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
663
- allowed_origins: a.allowed_origins ? JSON.stringify(a.allowed_origins) : void 0,
664
- callbacks: a.callbacks ? JSON.stringify(a.callbacks) : void 0,
665
- web_origins: a.web_origins ? JSON.stringify(a.web_origins) : void 0,
666
- allowed_logout_urls: a.allowed_logout_urls ? JSON.stringify(a.allowed_logout_urls) : void 0,
667
- allowed_clients: a.allowed_clients ? JSON.stringify(a.allowed_clients) : void 0,
668
- addons: a.addons ? JSON.stringify(a.addons) : "{}",
669
- disable_sign_ups: a.disable_sign_ups ? 1 : 0
663
+ allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
664
+ callbacks: r.callbacks ? JSON.stringify(r.callbacks) : void 0,
665
+ web_origins: r.web_origins ? JSON.stringify(r.web_origins) : void 0,
666
+ allowed_logout_urls: r.allowed_logout_urls ? JSON.stringify(r.allowed_logout_urls) : void 0,
667
+ allowed_clients: r.allowed_clients ? JSON.stringify(r.allowed_clients) : void 0,
668
+ addons: r.addons ? JSON.stringify(r.addons) : "{}",
669
+ disable_sign_ups: r.disable_sign_ups ? 1 : 0
670
670
  };
671
- return await t.updateTable("applications").set(n).where("applications.id", "=", r).where("applications.tenant_id", "=", e).execute(), !0;
671
+ return await t.updateTable("applications").set(n).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
672
672
  };
673
673
  }
674
674
  function jt(t) {
@@ -681,27 +681,27 @@ function jt(t) {
681
681
  };
682
682
  }
683
683
  function Ft(t) {
684
- return async (e, r) => {
685
- const a = {
686
- id: O(),
687
- ...r,
684
+ return async (e, a) => {
685
+ const r = {
686
+ id: T(),
687
+ ...a,
688
688
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
689
689
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
690
690
  };
691
691
  return await t.insertInto("connections").values({
692
- ...a,
692
+ ...r,
693
693
  // The connection options will have many different properties depending on the strategy
694
- options: JSON.stringify(a.options || {}),
694
+ options: JSON.stringify(r.options || {}),
695
695
  tenant_id: e
696
- }).execute(), a;
696
+ }).execute(), r;
697
697
  };
698
698
  }
699
- function Mt(t) {
700
- return async (e, r = {}) => {
701
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
699
+ function At(t) {
700
+ return async (e, a = {}) => {
701
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
702
702
  let i = t.selectFrom("connections").where("connections.tenant_id", "=", e);
703
- s && (i = T(t, i, s, ["user_id", "ip"]));
704
- const u = (await i.offset(a * n).limit(n).selectAll().execute()).map(
703
+ s && (i = S(t, i, s, ["user_id", "ip"]));
704
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map(
705
705
  (h) => y({
706
706
  ...h,
707
707
  options: JSON.parse(h.options)
@@ -709,65 +709,65 @@ function Mt(t) {
709
709
  );
710
710
  if (!o)
711
711
  return {
712
- connections: u,
712
+ connections: _,
713
713
  start: 0,
714
714
  limit: 0,
715
715
  length: 0
716
716
  };
717
- const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
717
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
718
718
  return {
719
- connections: u,
720
- start: a * n,
719
+ connections: _,
720
+ start: r * n,
721
721
  limit: n,
722
- length: x(m)
722
+ length: x(d)
723
723
  };
724
724
  };
725
725
  }
726
- function At(t) {
727
- return async (e, r) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).executeTakeFirst()).numDeletedRows > 0;
726
+ function Mt(t) {
727
+ return async (e, a) => (await t.deleteFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
728
728
  }
729
729
  function zt(t) {
730
- return async (e, r) => {
731
- const a = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).selectAll().executeTakeFirst();
732
- return a ? y({
733
- ...a,
734
- options: JSON.parse(a.options)
730
+ return async (e, a) => {
731
+ const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
732
+ return r ? y({
733
+ ...r,
734
+ options: JSON.parse(r.options)
735
735
  }) : null;
736
736
  };
737
737
  }
738
- function Lt(t) {
739
- return async (e, r, a) => {
738
+ function Jt(t) {
739
+ return async (e, a, r) => {
740
740
  const n = {
741
- ...a,
741
+ ...r,
742
742
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
743
743
  };
744
744
  return await t.updateTable("connections").set({
745
745
  ...n,
746
746
  options: n.options ? JSON.stringify(n.options) : void 0
747
- }).where("connections.id", "=", r).where("connections.tenant_id", "=", e).execute(), !0;
747
+ }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
748
748
  };
749
749
  }
750
750
  function Et(t) {
751
751
  return {
752
752
  create: Ft(t),
753
753
  get: zt(t),
754
- list: Mt(t),
755
- remove: At(t),
756
- update: Lt(t)
754
+ list: At(t),
755
+ remove: Mt(t),
756
+ update: Jt(t)
757
757
  };
758
758
  }
759
- function Jt(t) {
759
+ function Lt(t) {
760
760
  return {
761
761
  get: async (e) => {
762
- const r = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
763
- if (!r)
764
- return null;
765
- const a = await t.selectFrom("tenants").selectAll().where("id", "=", r.tenant_id).executeTakeFirst();
762
+ const a = await t.selectFrom("applications").selectAll().where("id", "=", e).executeTakeFirst();
766
763
  if (!a)
767
- throw new te(404, { message: "Tenant not found" });
768
- const n = await t.selectFrom("connections").where("tenant_id", "=", r.tenant_id).selectAll().execute();
764
+ return null;
765
+ const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
766
+ if (!r)
767
+ throw new q(404, { message: "Tenant not found" });
768
+ const n = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
769
769
  return {
770
- ...r,
770
+ ...a,
771
771
  connections: n.map(
772
772
  (s) => Ue.parse(
773
773
  y({
@@ -776,15 +776,15 @@ function Jt(t) {
776
776
  })
777
777
  )
778
778
  ),
779
- addons: r.addons ? JSON.parse(r.addons) : {},
780
- callbacks: r.callbacks ? JSON.parse(r.callbacks) : [],
781
- allowed_origins: r.allowed_origins ? JSON.parse(r.allowed_origins) : [],
782
- web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
783
- allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
784
- allowed_clients: r.allowed_clients ? JSON.parse(r.allowed_clients) : [],
785
- tenant: y(a),
779
+ addons: a.addons ? JSON.parse(a.addons) : {},
780
+ callbacks: a.callbacks ? JSON.parse(a.callbacks) : [],
781
+ allowed_origins: a.allowed_origins ? JSON.parse(a.allowed_origins) : [],
782
+ web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
783
+ allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
784
+ allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
785
+ tenant: y(r),
786
786
  // this is really an integer in the database
787
- disable_sign_ups: !!r.disable_sign_ups
787
+ disable_sign_ups: !!a.disable_sign_ups
788
788
  };
789
789
  }
790
790
  };
@@ -792,8 +792,8 @@ function Jt(t) {
792
792
  function Rt(t) {
793
793
  return async (e = {}) => {
794
794
  const {
795
- page: r = 0,
796
- per_page: a = 100,
795
+ page: a = 0,
796
+ per_page: r = 100,
797
797
  include_totals: n = !1,
798
798
  sort: o,
799
799
  q: s
@@ -804,7 +804,7 @@ function Rt(t) {
804
804
  f("revoked_at", "is", null)
805
805
  ])
806
806
  );
807
- s && (i = T(t, i, s, [
807
+ s && (i = S(t, i, s, [
808
808
  "kid",
809
809
  "connection",
810
810
  "fingerprint",
@@ -812,21 +812,21 @@ function Rt(t) {
812
812
  "type"
813
813
  ]));
814
814
  let c = i.select((f) => f.fn.count("kid").as("count"));
815
- const _ = r * a;
816
- i = i.limit(a).offset(_), o && (i = i.orderBy(o.sort_by, o.sort_order));
817
- const u = await i.selectAll().execute();
815
+ const m = a * r;
816
+ i = i.limit(r).offset(m), o && (i = i.orderBy(o.sort_by, o.sort_order));
817
+ const _ = await i.selectAll().execute();
818
818
  if (!n)
819
819
  return {
820
- signingKeys: u,
820
+ signingKeys: _,
821
821
  start: 0,
822
822
  limit: 0,
823
823
  length: 0
824
824
  };
825
- const m = await c.executeTakeFirst(), h = x((m == null ? void 0 : m.count) ?? 0);
825
+ const d = await c.executeTakeFirst(), h = x((d == null ? void 0 : d.count) ?? 0);
826
826
  return {
827
- signingKeys: u,
828
- start: _,
829
- limit: a,
827
+ signingKeys: _,
828
+ start: m,
829
+ limit: r,
830
830
  length: h
831
831
  };
832
832
  };
@@ -837,7 +837,7 @@ function Kt(t) {
837
837
  };
838
838
  }
839
839
  function Ut(t) {
840
- return async (e, r) => !!(await t.updateTable("keys").set(r).where("kid", "=", e).execute()).length;
840
+ return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
841
841
  }
842
842
  function Bt(t) {
843
843
  return {
@@ -846,87 +846,87 @@ function Bt(t) {
846
846
  update: Ut(t)
847
847
  };
848
848
  }
849
- function Qt(t) {
850
- return async (e, r) => {
851
- const a = {
852
- custom_domain_id: O(),
849
+ function qt(t) {
850
+ return async (e, a) => {
851
+ const r = {
852
+ custom_domain_id: T(),
853
853
  status: "pending",
854
854
  primary: !1,
855
- ...r
855
+ ...a
856
856
  };
857
857
  return await t.insertInto("custom_domains").values({
858
- ...a,
858
+ ...r,
859
859
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
860
860
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
861
861
  tenant_id: e,
862
- primary: a.primary ? 1 : 0
863
- }).execute(), a;
862
+ primary: r.primary ? 1 : 0
863
+ }).execute(), r;
864
864
  };
865
865
  }
866
- function qt(t) {
867
- return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((a) => ({
868
- ...a,
869
- primary: a.primary === 1
866
+ function Qt(t) {
867
+ return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((r) => ({
868
+ ...r,
869
+ primary: r.primary === 1
870
870
  }));
871
871
  }
872
- function Vt(t) {
873
- return async (e, r) => (await t.deleteFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", r).execute()).length > 0;
874
- }
875
872
  function Wt(t) {
876
- return async (e, r) => {
877
- const a = await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", r).selectAll().executeTakeFirst();
878
- return a ? {
879
- ...a,
880
- primary: a.primary === 1
873
+ 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;
874
+ }
875
+ function Vt(t) {
876
+ return async (e, a) => {
877
+ const r = await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).selectAll().executeTakeFirst();
878
+ return r ? {
879
+ ...r,
880
+ primary: r.primary === 1
881
881
  } : null;
882
882
  };
883
883
  }
884
884
  function Gt(t) {
885
- return async (e, r, a) => {
885
+ return async (e, a, r) => {
886
886
  const n = {
887
- ...a,
887
+ ...r,
888
888
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
889
- primary: a.primary ? 1 : 0
889
+ primary: r.primary ? 1 : 0
890
890
  };
891
- return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", r).execute()).length > 0;
891
+ return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
892
892
  };
893
893
  }
894
894
  function Ht(t) {
895
895
  return async (e) => {
896
- const r = await t.selectFrom("custom_domains").where("custom_domains.domain", "=", e).selectAll().executeTakeFirst();
897
- return r ? {
898
- ...r,
899
- primary: r.primary === 1
896
+ const a = await t.selectFrom("custom_domains").where("custom_domains.domain", "=", e).selectAll().executeTakeFirst();
897
+ return a ? {
898
+ ...a,
899
+ primary: a.primary === 1
900
900
  } : null;
901
901
  };
902
902
  }
903
903
  function Yt(t) {
904
904
  return {
905
- create: Qt(t),
906
- get: Wt(t),
905
+ create: qt(t),
906
+ get: Vt(t),
907
907
  getByDomain: Ht(t),
908
- list: qt(t),
909
- remove: Vt(t),
908
+ list: Qt(t),
909
+ remove: Wt(t),
910
910
  update: Gt(t)
911
911
  };
912
912
  }
913
913
  function Xt(t) {
914
914
  return async (e) => {
915
- const [r] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
916
- if (!r)
915
+ const [a] = await t.selectFrom("branding").where("branding.tenant_id", "=", e).selectAll().execute();
916
+ if (!a)
917
917
  return null;
918
918
  const {
919
- tenant_id: a,
919
+ tenant_id: r,
920
920
  colors_primary: n,
921
921
  colors_page_background_type: o,
922
922
  colors_page_background_start: s,
923
923
  colors_page_background_end: i,
924
924
  colors_page_background_angle_dev: c,
925
- font_url: _,
926
- ...u
927
- } = r;
925
+ font_url: m,
926
+ ..._
927
+ } = a;
928
928
  return y({
929
- ...u,
929
+ ..._,
930
930
  colors: {
931
931
  primary: n,
932
932
  page_background: {
@@ -936,50 +936,50 @@ function Xt(t) {
936
936
  angle_deg: c
937
937
  }
938
938
  },
939
- font: _ ? { url: _ } : void 0
939
+ font: m ? { url: m } : void 0
940
940
  });
941
941
  };
942
942
  }
943
943
  function Zt(t) {
944
- return async (e, r) => {
945
- var s, i, c, _, u, m, h, f, g, w, b, D, M, P, V, le, ce, de;
946
- const { colors: a, font: n, ...o } = r;
944
+ return async (e, a) => {
945
+ var s, i, c, m, _, d, h, f, g, w, b, D, A, P, V, le, ce, de;
946
+ const { colors: r, font: n, ...o } = a;
947
947
  try {
948
948
  await t.insertInto("branding").values({
949
949
  ...o,
950
- colors_primary: a == null ? void 0 : a.primary,
951
- colors_page_background_type: (i = (s = r.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
952
- colors_page_background_start: (_ = (c = r.colors) == null ? void 0 : c.page_background) == null ? void 0 : _.start,
953
- colors_page_background_end: (m = (u = r.colors) == null ? void 0 : u.page_background) == null ? void 0 : m.end,
954
- colors_page_background_angle_dev: (f = (h = r.colors) == null ? void 0 : h.page_background) == null ? void 0 : f.angle_deg,
955
- font_url: (g = r.font) == null ? void 0 : g.url,
950
+ colors_primary: r == null ? void 0 : r.primary,
951
+ colors_page_background_type: (i = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
952
+ colors_page_background_start: (m = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : m.start,
953
+ colors_page_background_end: (d = (_ = a.colors) == null ? void 0 : _.page_background) == null ? void 0 : d.end,
954
+ colors_page_background_angle_dev: (f = (h = a.colors) == null ? void 0 : h.page_background) == null ? void 0 : f.angle_deg,
955
+ font_url: (g = a.font) == null ? void 0 : g.url,
956
956
  tenant_id: e
957
957
  }).execute();
958
958
  } catch {
959
959
  await t.updateTable("branding").set({
960
960
  ...o,
961
- colors_primary: a == null ? void 0 : a.primary,
962
- colors_page_background_type: (b = (w = r.colors) == null ? void 0 : w.page_background) == null ? void 0 : b.type,
963
- colors_page_background_start: (M = (D = r.colors) == null ? void 0 : D.page_background) == null ? void 0 : M.start,
964
- colors_page_background_end: (V = (P = r.colors) == null ? void 0 : P.page_background) == null ? void 0 : V.end,
965
- colors_page_background_angle_dev: (ce = (le = r.colors) == null ? void 0 : le.page_background) == null ? void 0 : ce.angle_deg,
966
- font_url: (de = r.font) == null ? void 0 : de.url
961
+ colors_primary: r == null ? void 0 : r.primary,
962
+ colors_page_background_type: (b = (w = a.colors) == null ? void 0 : w.page_background) == null ? void 0 : b.type,
963
+ colors_page_background_start: (A = (D = a.colors) == null ? void 0 : D.page_background) == null ? void 0 : A.start,
964
+ colors_page_background_end: (V = (P = a.colors) == null ? void 0 : P.page_background) == null ? void 0 : V.end,
965
+ colors_page_background_angle_dev: (ce = (le = a.colors) == null ? void 0 : le.page_background) == null ? void 0 : ce.angle_deg,
966
+ font_url: (de = a.font) == null ? void 0 : de.url
967
967
  }).where("tenant_id", "=", e).execute();
968
968
  }
969
969
  };
970
970
  }
971
- function er(t) {
971
+ function ea(t) {
972
972
  return {
973
973
  get: Xt(t),
974
974
  set: Zt(t)
975
975
  };
976
976
  }
977
- function tr(t) {
978
- return async (e, r = {}) => {
979
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
977
+ function ta(t) {
978
+ return async (e, a = {}) => {
979
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
980
980
  let i = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
981
- s && (i = T(t, i, s, ["url", "form_id"]));
982
- const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
981
+ s && (i = S(t, i, s, ["url", "form_id"]));
982
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
983
983
  const { tenant_id: f, enabled: g, synchronous: w, ...b } = h;
984
984
  return y({
985
985
  ...b,
@@ -989,100 +989,100 @@ function tr(t) {
989
989
  });
990
990
  if (!o)
991
991
  return {
992
- hooks: u,
992
+ hooks: _,
993
993
  start: 0,
994
994
  limit: 0,
995
995
  length: 0
996
996
  };
997
- const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
997
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
998
998
  return {
999
- hooks: u,
1000
- start: a * n,
999
+ hooks: _,
1000
+ start: r * n,
1001
1001
  limit: n,
1002
- length: x(m)
1002
+ length: x(d)
1003
1003
  };
1004
1004
  };
1005
1005
  }
1006
- function rr(t) {
1007
- return async (e, r) => {
1008
- const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).selectAll().executeTakeFirst();
1009
- return a ? y({
1010
- ...a,
1011
- enabled: !!a.enabled,
1012
- synchronous: !!a.synchronous
1006
+ function aa(t) {
1007
+ return async (e, a) => {
1008
+ const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
1009
+ return r ? y({
1010
+ ...r,
1011
+ enabled: !!r.enabled,
1012
+ synchronous: !!r.synchronous
1013
1013
  }) : null;
1014
1014
  };
1015
1015
  }
1016
- function ar(t) {
1017
- return async (e, r) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).executeTakeFirst()).numDeletedRows > 0;
1016
+ function ra(t) {
1017
+ return async (e, a) => (await t.deleteFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
1018
1018
  }
1019
- function nr(t) {
1020
- return async (e, r) => {
1021
- const a = {
1022
- hook_id: O(),
1023
- ...r,
1019
+ function na(t) {
1020
+ return async (e, a) => {
1021
+ const r = {
1022
+ hook_id: T(),
1023
+ ...a,
1024
1024
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1025
1025
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1026
1026
  };
1027
1027
  return await t.insertInto("hooks").values({
1028
- ...a,
1028
+ ...r,
1029
1029
  tenant_id: e,
1030
- enabled: r.enabled ? 1 : 0,
1031
- synchronous: r.synchronous ? 1 : 0
1032
- }).execute(), a;
1030
+ enabled: a.enabled ? 1 : 0,
1031
+ synchronous: a.synchronous ? 1 : 0
1032
+ }).execute(), r;
1033
1033
  };
1034
1034
  }
1035
- function or(t) {
1036
- return async (e, r, a) => {
1035
+ function oa(t) {
1036
+ return async (e, a, r) => {
1037
1037
  const n = {
1038
- ...a,
1038
+ ...r,
1039
1039
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1040
- enabled: a.enabled !== void 0 ? a.enabled ? 1 : 0 : void 0,
1041
- synchronous: a.enabled !== void 0 ? a.synchronous ? 1 : 0 : void 0
1040
+ enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
1041
+ synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
1042
1042
  };
1043
- return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", r).where("hooks.tenant_id", "=", e).execute(), !0;
1043
+ return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
1044
1044
  };
1045
1045
  }
1046
- function sr(t) {
1046
+ function sa(t) {
1047
1047
  return {
1048
- create: nr(t),
1049
- get: rr(t),
1050
- list: tr(t),
1051
- update: or(t),
1052
- remove: ar(t)
1048
+ create: na(t),
1049
+ get: aa(t),
1050
+ list: ta(t),
1051
+ update: oa(t),
1052
+ remove: ra(t)
1053
1053
  };
1054
1054
  }
1055
- function ir(t) {
1056
- return async (e, r) => {
1057
- const a = {
1058
- themeId: O(),
1055
+ function ia(t) {
1056
+ return async (e, a) => {
1057
+ const r = {
1058
+ themeId: T(),
1059
1059
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1060
1060
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1061
- ...r
1061
+ ...a
1062
1062
  }, n = {
1063
- ...a,
1063
+ ...r,
1064
1064
  tenant_id: e
1065
1065
  };
1066
- return await t.insertInto("themes").values(J(n)).execute(), a;
1066
+ return await t.insertInto("themes").values(L(n)).execute(), r;
1067
1067
  };
1068
1068
  }
1069
- function lr(t) {
1070
- return async (e, r) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.themeId", "=", r).executeTakeFirst()).numDeletedRows > 0;
1069
+ function la(t) {
1070
+ return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.themeId", "=", a).executeTakeFirst()).numDeletedRows > 0;
1071
1071
  }
1072
- function cr(t) {
1073
- return async (e, r) => {
1074
- const a = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.themeId", "=", r).selectAll().executeTakeFirst();
1075
- if (!a)
1072
+ function ca(t) {
1073
+ return async (e, a) => {
1074
+ const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.themeId", "=", a).selectAll().executeTakeFirst();
1075
+ if (!r)
1076
1076
  return null;
1077
1077
  const n = {
1078
- ...a,
1079
- borders_show_widget_shadow: !!a.borders_show_widget_shadow,
1080
- fonts_body_text_bold: !!a.fonts_body_text_bold,
1081
- fonts_buttons_text_bold: !!a.fonts_buttons_text_bold,
1082
- fonts_input_labels_bold: !!a.fonts_input_labels_bold,
1083
- fonts_links_bold: !!a.fonts_links_bold,
1084
- fonts_subtitle_bold: !!a.fonts_subtitle_bold,
1085
- fonts_title_bold: !!a.fonts_title_bold
1078
+ ...r,
1079
+ borders_show_widget_shadow: !!r.borders_show_widget_shadow,
1080
+ fonts_body_text_bold: !!r.fonts_body_text_bold,
1081
+ fonts_buttons_text_bold: !!r.fonts_buttons_text_bold,
1082
+ fonts_input_labels_bold: !!r.fonts_input_labels_bold,
1083
+ fonts_links_bold: !!r.fonts_links_bold,
1084
+ fonts_subtitle_bold: !!r.fonts_subtitle_bold,
1085
+ fonts_title_bold: !!r.fonts_title_bold
1086
1086
  };
1087
1087
  return y(
1088
1088
  ge(n, [
@@ -1095,80 +1095,80 @@ function cr(t) {
1095
1095
  );
1096
1096
  };
1097
1097
  }
1098
- function dr(t) {
1099
- return async (e, r, a) => {
1100
- const n = J({
1101
- ...a,
1098
+ function da(t) {
1099
+ return async (e, a, r) => {
1100
+ const n = L({
1101
+ ...r,
1102
1102
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1103
1103
  });
1104
- return await t.updateTable("themes").set(n).where("themes.themeId", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
1104
+ return await t.updateTable("themes").set(n).where("themes.themeId", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1105
1105
  };
1106
1106
  }
1107
- function ur(t) {
1107
+ function ua(t) {
1108
1108
  return {
1109
- create: ir(t),
1110
- get: cr(t),
1111
- remove: lr(t),
1112
- update: dr(t)
1109
+ create: ia(t),
1110
+ get: ca(t),
1111
+ remove: la(t),
1112
+ update: da(t)
1113
1113
  };
1114
1114
  }
1115
- function mr(t) {
1116
- return async (e, r) => {
1117
- const a = await t.selectFrom("login_sessions").where("login_sessions.id", "=", r).selectAll().executeTakeFirst();
1118
- return a ? Be.parse(
1115
+ function ma(t) {
1116
+ return async (e, a) => {
1117
+ const r = await t.selectFrom("login_sessions").where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1118
+ return r ? Be.parse(
1119
1119
  ge(
1120
1120
  y({
1121
- ...a,
1122
- login_completed: !!a.login_completed
1121
+ ...r,
1122
+ login_completed: !!r.login_completed
1123
1123
  }),
1124
1124
  ["authParams"]
1125
1125
  )
1126
1126
  ) : null;
1127
1127
  };
1128
1128
  }
1129
- function _r(t) {
1130
- return async (e, r) => {
1129
+ function _a(t) {
1130
+ return async (e, a) => {
1131
1131
  var n;
1132
- const a = {
1133
- id: O(),
1134
- ...r,
1135
- authorization_url: (n = r.authorization_url) == null ? void 0 : n.slice(0, 1024),
1132
+ const r = {
1133
+ id: T(),
1134
+ ...a,
1135
+ authorization_url: (n = a.authorization_url) == null ? void 0 : n.slice(0, 1024),
1136
1136
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1137
1137
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1138
- login_completed: !!r.login_completed
1138
+ login_completed: !!a.login_completed
1139
1139
  };
1140
1140
  return await t.insertInto("login_sessions").values({
1141
- ...J(a),
1141
+ ...L(r),
1142
1142
  tenant_id: e
1143
- }).execute(), a;
1143
+ }).execute(), r;
1144
1144
  };
1145
1145
  }
1146
- function hr(t) {
1147
- return async (e, r, a) => (await t.updateTable("login_sessions").set(
1148
- J({
1149
- ...a
1146
+ function ha(t) {
1147
+ return async (e, a, r) => (await t.updateTable("login_sessions").set(
1148
+ L({
1149
+ ...r
1150
1150
  })
1151
- ).where("login_sessions.id", "=", r).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
1151
+ ).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", e).execute()).length === 1;
1152
1152
  }
1153
- function fr(t) {
1154
- return async (e, r) => (await t.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", e).where("login_sessions.id", "=", r).execute()).length > 0;
1153
+ function fa(t) {
1154
+ return async (e, a) => (await t.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", e).where("login_sessions.id", "=", a).execute()).length > 0;
1155
1155
  }
1156
- function pr(t) {
1156
+ function pa(t) {
1157
1157
  return {
1158
- create: _r(t),
1159
- get: mr(t),
1160
- update: hr(t),
1161
- remove: fr(t)
1158
+ create: _a(t),
1159
+ get: ma(t),
1160
+ update: ha(t),
1161
+ remove: fa(t)
1162
1162
  };
1163
1163
  }
1164
- function gr(t) {
1164
+ function ga(t) {
1165
1165
  return async (e) => {
1166
- const [r] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1166
+ const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1167
1167
  return y({
1168
- identifier_first: !!(r != null && r.identifier_first),
1169
- password_first: !!(r != null && r.password_first),
1170
- webauthn_platform_first_factor: !!(r != null && r.webauthn_platform_first_factor),
1171
- universal_login_experience: (r == null ? void 0 : r.universal_login_experience) || "new"
1168
+ identifier_first: !!(a != null && a.identifier_first),
1169
+ password_first: !!(a != null && a.password_first),
1170
+ webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
1171
+ universal_login_experience: (a == null ? void 0 : a.universal_login_experience) || "new"
1172
1172
  });
1173
1173
  };
1174
1174
  }
@@ -1181,37 +1181,37 @@ function he(t) {
1181
1181
  universal_login_experience: t.universal_login_experience
1182
1182
  });
1183
1183
  }
1184
- function wr(t) {
1185
- return async (e, r) => {
1184
+ function wa(t) {
1185
+ return async (e, a) => {
1186
1186
  try {
1187
- const a = Qe.parse(r);
1187
+ const r = qe.parse(a);
1188
1188
  await t.insertInto("prompt_settings").values({
1189
- ...he(a),
1189
+ ...he(r),
1190
1190
  tenant_id: e
1191
1191
  }).execute();
1192
1192
  } catch {
1193
- await t.updateTable("prompt_settings").set(he(r)).where("tenant_id", "=", e).execute();
1193
+ await t.updateTable("prompt_settings").set(he(a)).where("tenant_id", "=", e).execute();
1194
1194
  }
1195
1195
  };
1196
1196
  }
1197
- function yr(t) {
1197
+ function ya(t) {
1198
1198
  return {
1199
- get: gr(t),
1200
- set: wr(t)
1199
+ get: ga(t),
1200
+ set: wa(t)
1201
1201
  };
1202
1202
  }
1203
- function vr(t) {
1203
+ function va(t) {
1204
1204
  return async (e) => {
1205
- const [r] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1206
- if (!r)
1205
+ const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1206
+ if (!a)
1207
1207
  return null;
1208
1208
  const {
1209
- tenant_id: a,
1209
+ tenant_id: r,
1210
1210
  credentials: n,
1211
1211
  settings: o,
1212
1212
  enabled: s,
1213
1213
  ...i
1214
- } = r;
1214
+ } = a;
1215
1215
  return y({
1216
1216
  ...i,
1217
1217
  credentials: JSON.parse(n),
@@ -1220,24 +1220,24 @@ function vr(t) {
1220
1220
  });
1221
1221
  };
1222
1222
  }
1223
- function Nr(t) {
1224
- return async (e, r) => {
1225
- const { credentials: a, settings: n, enabled: o, ...s } = r;
1223
+ function Na(t) {
1224
+ return async (e, a) => {
1225
+ const { credentials: r, settings: n, enabled: o, ...s } = a;
1226
1226
  await t.updateTable("email_providers").set({
1227
1227
  ...s,
1228
- credentials: a ? JSON.stringify(a) : void 0,
1228
+ credentials: r ? JSON.stringify(r) : void 0,
1229
1229
  settings: n ? JSON.stringify(n) : void 0,
1230
1230
  enabled: o !== void 0 ? o ? 1 : 0 : void 0
1231
1231
  }).where("tenant_id", "=", e).execute();
1232
1232
  };
1233
1233
  }
1234
- function Cr(t) {
1235
- return async (e, r) => {
1236
- const { credentials: a, settings: n, enabled: o, ...s } = r;
1234
+ function Ca(t) {
1235
+ return async (e, a) => {
1236
+ const { credentials: r, settings: n, enabled: o, ...s } = a;
1237
1237
  await t.insertInto("email_providers").values({
1238
1238
  ...s,
1239
1239
  enabled: o ? 1 : 0,
1240
- credentials: JSON.stringify(a),
1240
+ credentials: JSON.stringify(r),
1241
1241
  settings: JSON.stringify(n),
1242
1242
  tenant_id: e,
1243
1243
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1245,65 +1245,65 @@ function Cr(t) {
1245
1245
  }).execute();
1246
1246
  };
1247
1247
  }
1248
- function br(t) {
1248
+ function ba(t) {
1249
1249
  return {
1250
- get: vr(t),
1251
- create: Cr(t),
1252
- update: Nr(t)
1250
+ get: va(t),
1251
+ create: Ca(t),
1252
+ update: Na(t)
1253
1253
  };
1254
1254
  }
1255
- function xr(t) {
1256
- return async (e, r) => {
1257
- const a = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", r).selectAll().executeTakeFirst();
1258
- return a ? {
1259
- ...a,
1260
- rotating: !!a.rotating,
1261
- device: a.device ? JSON.parse(a.device) : {},
1262
- resource_servers: a.resource_servers ? JSON.parse(a.resource_servers) : []
1255
+ function xa(t) {
1256
+ return async (e, a) => {
1257
+ const r = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.id", "=", a).selectAll().executeTakeFirst();
1258
+ return r ? {
1259
+ ...r,
1260
+ rotating: !!r.rotating,
1261
+ device: r.device ? JSON.parse(r.device) : {},
1262
+ resource_servers: r.resource_servers ? JSON.parse(r.resource_servers) : []
1263
1263
  } : null;
1264
1264
  };
1265
1265
  }
1266
- function Tr(t) {
1267
- return async (e, r) => {
1268
- const a = {
1269
- ...r,
1266
+ function Ta(t) {
1267
+ return async (e, a) => {
1268
+ const r = {
1269
+ ...a,
1270
1270
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1271
1271
  };
1272
1272
  return await t.insertInto("refresh_tokens").values({
1273
- ...a,
1273
+ ...r,
1274
1274
  tenant_id: e,
1275
- rotating: r.rotating ? 1 : 0,
1276
- device: JSON.stringify(r.device),
1277
- resource_servers: JSON.stringify(r.resource_servers)
1278
- }).execute(), { ...r, ...a };
1275
+ rotating: a.rotating ? 1 : 0,
1276
+ device: JSON.stringify(a.device),
1277
+ resource_servers: JSON.stringify(a.resource_servers)
1278
+ }).execute(), { ...a, ...r };
1279
1279
  };
1280
1280
  }
1281
- function Sr(t) {
1282
- return async (e, r) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1281
+ function Sa(t) {
1282
+ return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1283
1283
  }
1284
- function Or(t) {
1285
- return async (e, r, a) => {
1284
+ function Oa(t) {
1285
+ return async (e, a, r) => {
1286
1286
  const n = {
1287
- ...a,
1288
- device: a.device ? JSON.stringify(a.device) : void 0,
1289
- resource_servers: a.resource_servers ? JSON.stringify(a.resource_servers) : void 0,
1290
- rotating: a.rotating ? 1 : 0
1287
+ ...r,
1288
+ device: r.device ? JSON.stringify(r.device) : void 0,
1289
+ resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
1290
+ rotating: r.rotating ? 1 : 0
1291
1291
  };
1292
- return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", r).execute()).length;
1292
+ return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1293
1293
  };
1294
1294
  }
1295
- function kr(t) {
1296
- return async (e, r = {}) => {
1297
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = r;
1295
+ function ka(t) {
1296
+ return async (e, a = {}) => {
1297
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, sort: s, q: i } = a;
1298
1298
  let c = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1299
- i && (c = T(t, c, i, ["token", "session_id"]));
1300
- let _ = c;
1299
+ i && (c = S(t, c, i, ["token", "session_id"]));
1300
+ let m = c;
1301
1301
  if (s && s.sort_by) {
1302
1302
  const { ref: g } = t.dynamic;
1303
- _ = _.orderBy(g(s.sort_by), s.sort_order);
1303
+ m = m.orderBy(g(s.sort_by), s.sort_order);
1304
1304
  }
1305
- _ = _.offset(a * n).limit(n);
1306
- const m = (await _.selectAll().execute()).map((g) => ({
1305
+ m = m.offset(r * n).limit(n);
1306
+ const d = (await m.selectAll().execute()).map((g) => ({
1307
1307
  ...g,
1308
1308
  rotating: !!g.rotating,
1309
1309
  device: g.device ? JSON.parse(g.device) : {},
@@ -1311,46 +1311,46 @@ function kr(t) {
1311
1311
  }));
1312
1312
  if (!o)
1313
1313
  return {
1314
- refresh_tokens: m,
1314
+ refresh_tokens: d,
1315
1315
  start: 0,
1316
1316
  limit: 0,
1317
1317
  length: 0
1318
1318
  };
1319
1319
  const { count: h } = await c.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = x(h);
1320
1320
  return {
1321
- refresh_tokens: m,
1322
- start: a * n,
1321
+ refresh_tokens: d,
1322
+ start: r * n,
1323
1323
  limit: n,
1324
1324
  length: f
1325
1325
  };
1326
1326
  };
1327
1327
  }
1328
- function $r(t) {
1328
+ function $a(t) {
1329
1329
  return {
1330
- create: Tr(t),
1331
- get: xr(t),
1332
- list: kr(t),
1333
- remove: Sr(t),
1334
- update: Or(t)
1330
+ create: Ta(t),
1331
+ get: xa(t),
1332
+ list: ka(t),
1333
+ remove: Sa(t),
1334
+ update: Oa(t)
1335
1335
  };
1336
1336
  }
1337
- function Ir(t) {
1337
+ function Ia(t) {
1338
1338
  return async () => {
1339
- const e = new Date(Date.now() - 864e5).toISOString(), r = new Date(
1339
+ const e = new Date(Date.now() - 864e5).toISOString(), a = new Date(
1340
1340
  Date.now() - 1e3 * 60 * 60 * 24 * 7
1341
- ).toISOString(), a = new Date(
1341
+ ).toISOString(), r = new Date(
1342
1342
  Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
1343
1343
  ).toISOString();
1344
- console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", r).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", a).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where(
1344
+ console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", 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(
1345
1345
  (o) => o.or([
1346
- o("expires_at", "<", r),
1347
- o("idle_expires_at", "<", r)
1346
+ o("expires_at", "<", a),
1347
+ o("idle_expires_at", "<", a)
1348
1348
  ])
1349
1349
  ).limit(1e4).execute(), console.log("delete sessions");
1350
1350
  const n = await t.selectFrom("sessions").select("id").where(
1351
1351
  (o) => o.or([
1352
- o("expires_at", "<", r),
1353
- o("idle_expires_at", "<", r)
1352
+ o("expires_at", "<", a),
1353
+ o("idle_expires_at", "<", a)
1354
1354
  ])
1355
1355
  ).where(
1356
1356
  "id",
@@ -1364,30 +1364,30 @@ function Ir(t) {
1364
1364
  ).execute(), console.log("cleanup complete");
1365
1365
  };
1366
1366
  }
1367
- function Dr(t) {
1368
- return async (e, r) => {
1369
- const a = G.parse({
1370
- id: O(),
1371
- ...r,
1367
+ function Da(t) {
1368
+ return async (e, a) => {
1369
+ const r = H.parse({
1370
+ id: T(),
1371
+ ...a,
1372
1372
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1373
1373
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1374
1374
  });
1375
1375
  return await t.insertInto("forms").values({
1376
- ...a,
1376
+ ...r,
1377
1377
  // Store complex objects as JSON strings
1378
- nodes: JSON.stringify(a.nodes || []),
1379
- start: JSON.stringify(a.start || {}),
1380
- ending: JSON.stringify(a.ending || {}),
1378
+ nodes: JSON.stringify(r.nodes || []),
1379
+ start: JSON.stringify(r.start || {}),
1380
+ ending: JSON.stringify(r.ending || {}),
1381
1381
  tenant_id: e
1382
- }).execute(), G.parse(a);
1382
+ }).execute(), H.parse(r);
1383
1383
  };
1384
1384
  }
1385
- function Pr(t) {
1386
- return async (e, r = {}) => {
1387
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
1385
+ function Pa(t) {
1386
+ return async (e, a = {}) => {
1387
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
1388
1388
  let i = t.selectFrom("forms").where("tenant_id", "=", e);
1389
- s && (i = T(t, i, s, []));
1390
- const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
1389
+ s && (i = S(t, i, s, []));
1390
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
1391
1391
  const f = { ...h };
1392
1392
  if (typeof f.nodes == "string")
1393
1393
  try {
@@ -1404,35 +1404,35 @@ function Pr(t) {
1404
1404
  f.ending = JSON.parse(f.ending);
1405
1405
  } catch {
1406
1406
  }
1407
- return G.parse(y(f));
1407
+ return H.parse(y(f));
1408
1408
  });
1409
1409
  if (!o)
1410
1410
  return {
1411
- forms: u,
1411
+ forms: _,
1412
1412
  start: 0,
1413
1413
  limit: 0,
1414
1414
  length: 0
1415
1415
  };
1416
- const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1416
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1417
1417
  return {
1418
- forms: u,
1419
- start: a * n,
1418
+ forms: _,
1419
+ start: r * n,
1420
1420
  limit: n,
1421
- length: x(m)
1421
+ length: x(d)
1422
1422
  };
1423
1423
  };
1424
1424
  }
1425
- function jr(t) {
1426
- return async (e, r) => {
1427
- const { numDeletedRows: a } = await t.deleteFrom("forms").where("id", "=", r).where("tenant_id", "=", e).executeTakeFirst();
1428
- return a > 0;
1425
+ function ja(t) {
1426
+ return async (e, a) => {
1427
+ const { numDeletedRows: r } = await t.deleteFrom("forms").where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1428
+ return r > 0;
1429
1429
  };
1430
1430
  }
1431
- function Fr(t) {
1432
- return async (e, r) => {
1433
- const a = await t.selectFrom("forms").selectAll().where("forms.id", "=", r).where("tenant_id", "=", e).executeTakeFirst();
1434
- if (!a) return null;
1435
- const n = { ...a };
1431
+ function Fa(t) {
1432
+ return async (e, a) => {
1433
+ const r = await t.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1434
+ if (!r) return null;
1435
+ const n = { ...r };
1436
1436
  if (typeof n.nodes == "string")
1437
1437
  try {
1438
1438
  n.nodes = JSON.parse(n.nodes);
@@ -1448,109 +1448,109 @@ function Fr(t) {
1448
1448
  n.ending = JSON.parse(n.ending);
1449
1449
  } catch {
1450
1450
  }
1451
- return G.parse(y(n));
1451
+ return H.parse(y(n));
1452
1452
  };
1453
1453
  }
1454
- function Mr(t) {
1455
- return async (e, r, a) => {
1454
+ function Aa(t) {
1455
+ return async (e, a, r) => {
1456
1456
  const n = {
1457
- ...a,
1457
+ ...r,
1458
1458
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1459
1459
  };
1460
- a.nodes && (n.nodes = JSON.stringify(a.nodes)), a.start && (n.start = JSON.stringify(a.start)), a.ending && (n.ending = JSON.stringify(a.ending));
1461
- const { numUpdatedRows: o } = await t.updateTable("forms").set(n).where("id", "=", r).where("tenant_id", "=", e).executeTakeFirst();
1460
+ r.nodes && (n.nodes = JSON.stringify(r.nodes)), r.start && (n.start = JSON.stringify(r.start)), r.ending && (n.ending = JSON.stringify(r.ending));
1461
+ const { numUpdatedRows: o } = await t.updateTable("forms").set(n).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
1462
1462
  return o > 0;
1463
1463
  };
1464
1464
  }
1465
- function Ar(t) {
1465
+ function Ma(t) {
1466
1466
  return {
1467
- create: Dr(t),
1468
- get: Fr(t),
1469
- list: Pr(t),
1470
- remove: jr(t),
1471
- update: Mr(t)
1467
+ create: Da(t),
1468
+ get: Fa(t),
1469
+ list: Pa(t),
1470
+ remove: ja(t),
1471
+ update: Aa(t)
1472
1472
  };
1473
1473
  }
1474
- function zr(t) {
1475
- return async (e, r) => {
1476
- const a = (/* @__PURE__ */ new Date()).toISOString(), n = {
1477
- id: O(),
1478
- ...r,
1479
- created_at: a,
1480
- updated_at: a
1481
- }, o = qe.parse(n), {
1474
+ function za(t) {
1475
+ return async (e, a) => {
1476
+ const r = (/* @__PURE__ */ new Date()).toISOString(), n = {
1477
+ id: T(),
1478
+ ...a,
1479
+ created_at: r,
1480
+ updated_at: r
1481
+ }, o = Qe.parse(n), {
1482
1482
  verificationKey: s,
1483
1483
  scopes: i,
1484
1484
  options: c,
1485
- skip_consent_for_verifiable_first_party_clients: _,
1486
- allow_offline_access: u,
1487
- ...m
1485
+ skip_consent_for_verifiable_first_party_clients: m,
1486
+ allow_offline_access: _,
1487
+ ...d
1488
1488
  } = o, h = {
1489
- ...m,
1489
+ ...d,
1490
1490
  tenant_id: e,
1491
1491
  scopes: i ? JSON.stringify(i) : "[]",
1492
1492
  options: c ? JSON.stringify(c) : "{}",
1493
- skip_consent_for_verifiable_first_party_clients: _ ? 1 : 0,
1494
- allow_offline_access: u ? 1 : 0,
1493
+ skip_consent_for_verifiable_first_party_clients: m ? 1 : 0,
1494
+ allow_offline_access: _ ? 1 : 0,
1495
1495
  verification_key: s,
1496
- created_at: a,
1497
- updated_at: a
1496
+ created_at: r,
1497
+ updated_at: r
1498
1498
  };
1499
1499
  return await t.insertInto("resource_servers").values(h).execute(), y(o);
1500
1500
  };
1501
1501
  }
1502
- function Lr(t) {
1503
- return async (e, r) => {
1504
- const a = await t.selectFrom("resource_servers").selectAll().where("tenant_id", "=", e).where("id", "=", r).executeTakeFirst();
1505
- if (!a) return null;
1506
- const n = a, {
1502
+ function Ja(t) {
1503
+ return async (e, a) => {
1504
+ const r = await t.selectFrom("resource_servers").selectAll().where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1505
+ if (!r) return null;
1506
+ const n = r, {
1507
1507
  verification_key: o,
1508
1508
  scopes: s,
1509
1509
  options: i,
1510
1510
  skip_consent_for_verifiable_first_party_clients: c,
1511
- allow_offline_access: _,
1512
- ...u
1513
- } = n, m = {
1514
- ...u,
1511
+ allow_offline_access: m,
1512
+ ..._
1513
+ } = n, d = {
1514
+ ..._,
1515
1515
  scopes: s ? JSON.parse(s) : [],
1516
1516
  options: i ? JSON.parse(i) : {},
1517
1517
  skip_consent_for_verifiable_first_party_clients: !!c,
1518
- allow_offline_access: !!_,
1518
+ allow_offline_access: !!m,
1519
1519
  // Convert verification_key back to verificationKey for API
1520
1520
  verificationKey: o
1521
1521
  };
1522
- return y(m);
1522
+ return y(d);
1523
1523
  };
1524
1524
  }
1525
- function Er(t) {
1526
- return async (e, r = {}) => {
1527
- const { page: a = 0, per_page: n = 50, include_totals: o = !1, q: s } = r;
1525
+ function Ea(t) {
1526
+ return async (e, a = {}) => {
1527
+ const { page: r = 0, per_page: n = 50, include_totals: o = !1, q: s } = a;
1528
1528
  let i = t.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", e);
1529
1529
  if (s) {
1530
1530
  const h = s.trim(), f = h.split(/\s+/), g = f.length === 1 ? f[0] : void 0, w = g ? g.match(/^(-)?(name|identifier):(.*)$/) : null, b = w ? w[3] : "", D = /^(>=|>|<=|<)/.test(b || "");
1531
1531
  if (w && !D) {
1532
- const M = !!w[1], P = w[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
1533
- i = M ? i.where(P, "not like", `%${b}%`) : i.where(P, "like", `%${b}%`);
1532
+ const A = !!w[1], P = w[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
1533
+ i = A ? i.where(P, "not like", `%${b}%`) : i.where(P, "like", `%${b}%`);
1534
1534
  } else
1535
- i = T(t, i, h, [
1535
+ i = S(t, i, h, [
1536
1536
  "resource_servers.name",
1537
1537
  "resource_servers.identifier"
1538
1538
  ]);
1539
1539
  }
1540
- const u = (await i.offset(a * n).limit(n).selectAll().execute()).map((h) => {
1540
+ const _ = (await i.offset(r * n).limit(n).selectAll().execute()).map((h) => {
1541
1541
  const f = h, {
1542
1542
  verification_key: g,
1543
1543
  scopes: w,
1544
1544
  options: b,
1545
1545
  skip_consent_for_verifiable_first_party_clients: D,
1546
- allow_offline_access: M,
1546
+ allow_offline_access: A,
1547
1547
  ...P
1548
1548
  } = f, V = {
1549
1549
  ...P,
1550
1550
  scopes: w ? JSON.parse(w) : [],
1551
1551
  options: b ? JSON.parse(b) : {},
1552
1552
  skip_consent_for_verifiable_first_party_clients: !!D,
1553
- allow_offline_access: !!M,
1553
+ allow_offline_access: !!A,
1554
1554
  // Convert verification_key back to verificationKey for API
1555
1555
  verificationKey: g
1556
1556
  };
@@ -1558,84 +1558,84 @@ function Er(t) {
1558
1558
  });
1559
1559
  if (!o)
1560
1560
  return {
1561
- resource_servers: u,
1561
+ resource_servers: _,
1562
1562
  start: 0,
1563
1563
  limit: 0,
1564
1564
  length: 0
1565
1565
  };
1566
- const { count: m } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1566
+ const { count: d } = await i.select((h) => h.fn.countAll().as("count")).executeTakeFirstOrThrow();
1567
1567
  return {
1568
- resource_servers: u,
1569
- start: a * n,
1568
+ resource_servers: _,
1569
+ start: r * n,
1570
1570
  limit: n,
1571
- length: x(m)
1571
+ length: x(d)
1572
1572
  };
1573
1573
  };
1574
1574
  }
1575
- function Jr(t) {
1576
- return async (e, r) => {
1577
- const a = await t.deleteFrom("resource_servers").where("tenant_id", "=", e).where("id", "=", r).executeTakeFirst();
1578
- return Number(a.numDeletedRows) > 0;
1575
+ function La(t) {
1576
+ return async (e, a) => {
1577
+ const r = await t.deleteFrom("resource_servers").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1578
+ return Number(r.numDeletedRows) > 0;
1579
1579
  };
1580
1580
  }
1581
- function Rr(t) {
1582
- return async (e, r, a) => {
1581
+ function Ra(t) {
1582
+ return async (e, a, r) => {
1583
1583
  const {
1584
1584
  verificationKey: n,
1585
1585
  scopes: o,
1586
1586
  options: s,
1587
1587
  skip_consent_for_verifiable_first_party_clients: i,
1588
1588
  allow_offline_access: c,
1589
- ..._
1590
- } = a, u = {
1591
- ..._,
1589
+ ...m
1590
+ } = r, _ = {
1591
+ ...m,
1592
1592
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1593
1593
  };
1594
- n !== void 0 && (u.verification_key = n), o !== void 0 && (u.scopes = JSON.stringify(o)), s !== void 0 && (u.options = JSON.stringify(s)), i !== void 0 && (u.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), c !== void 0 && (u.allow_offline_access = c ? 1 : 0);
1595
- const m = await t.updateTable("resource_servers").set(u).where("tenant_id", "=", e).where("id", "=", r).executeTakeFirst();
1596
- return Number(m.numUpdatedRows) > 0;
1594
+ n !== void 0 && (_.verification_key = n), o !== void 0 && (_.scopes = JSON.stringify(o)), s !== void 0 && (_.options = JSON.stringify(s)), i !== void 0 && (_.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), c !== void 0 && (_.allow_offline_access = c ? 1 : 0);
1595
+ const d = await t.updateTable("resource_servers").set(_).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1596
+ return Number(d.numUpdatedRows) > 0;
1597
1597
  };
1598
1598
  }
1599
- function Kr(t) {
1599
+ function Ka(t) {
1600
1600
  return {
1601
- create: zr(t),
1602
- get: Lr(t),
1603
- list: Er(t),
1604
- remove: Jr(t),
1605
- update: Rr(t)
1601
+ create: za(t),
1602
+ get: Ja(t),
1603
+ list: Ea(t),
1604
+ remove: La(t),
1605
+ update: Ra(t)
1606
1606
  };
1607
1607
  }
1608
- function Ur(t) {
1609
- return async (e, r) => {
1610
- const a = (/* @__PURE__ */ new Date()).toISOString(), n = O(), o = {
1608
+ function Ua(t) {
1609
+ return async (e, a) => {
1610
+ const r = (/* @__PURE__ */ new Date()).toISOString(), n = T(), o = {
1611
1611
  id: n,
1612
- ...r,
1612
+ ...a,
1613
1613
  tenant_id: e,
1614
- created_at: a,
1615
- updated_at: a
1614
+ created_at: r,
1615
+ updated_at: r
1616
1616
  };
1617
1617
  return await t.insertInto("roles").values(o).execute(), {
1618
1618
  id: n,
1619
- ...r,
1620
- created_at: a,
1621
- updated_at: a
1619
+ ...a,
1620
+ created_at: r,
1621
+ updated_at: r
1622
1622
  };
1623
1623
  };
1624
1624
  }
1625
- function Br(t) {
1626
- return async (e, r) => {
1627
- const a = await t.selectFrom("roles").selectAll().where("roles.tenant_id", "=", e).where("roles.id", "=", r).executeTakeFirst();
1628
- return a ? {
1629
- ...a
1625
+ function Ba(t) {
1626
+ return async (e, a) => {
1627
+ const r = await t.selectFrom("roles").selectAll().where("roles.tenant_id", "=", e).where("roles.id", "=", a).executeTakeFirst();
1628
+ return r ? {
1629
+ ...r
1630
1630
  } : null;
1631
1631
  };
1632
1632
  }
1633
- function Qr(t) {
1634
- return async (e, r) => {
1635
- let a = t.selectFrom("roles").where("roles.tenant_id", "=", e);
1636
- const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = r;
1637
- r.q && (a = T(t, a, r.q, ["name"]));
1638
- const c = await a.offset(n * o).limit(o).selectAll().execute();
1633
+ function qa(t) {
1634
+ return async (e, a) => {
1635
+ let r = t.selectFrom("roles").where("roles.tenant_id", "=", e);
1636
+ const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = a;
1637
+ a.q && (r = S(t, r, a.q, ["name"]));
1638
+ const c = await r.offset(n * o).limit(o).selectAll().execute();
1639
1639
  if (!s)
1640
1640
  return {
1641
1641
  roles: c,
@@ -1643,48 +1643,48 @@ function Qr(t) {
1643
1643
  limit: o,
1644
1644
  length: c.length
1645
1645
  };
1646
- const { count: _ } = await a.select((u) => u.fn.countAll().as("count")).executeTakeFirstOrThrow();
1646
+ const { count: m } = await r.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1647
1647
  return {
1648
1648
  roles: c,
1649
1649
  start: n * o,
1650
1650
  limit: o,
1651
- length: x(_)
1651
+ length: x(m)
1652
1652
  };
1653
1653
  };
1654
1654
  }
1655
- function qr(t) {
1656
- return async (e, r, a) => {
1655
+ function Qa(t) {
1656
+ return async (e, a, r) => {
1657
1657
  const n = {
1658
- ...a,
1658
+ ...r,
1659
1659
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1660
- }, o = await t.updateTable("roles").set(n).where("roles.tenant_id", "=", e).where("roles.id", "=", r).executeTakeFirst();
1660
+ }, o = await t.updateTable("roles").set(n).where("roles.tenant_id", "=", e).where("roles.id", "=", a).executeTakeFirst();
1661
1661
  return Number(o.numUpdatedRows) > 0;
1662
1662
  };
1663
1663
  }
1664
- function Vr(t) {
1665
- return async (e, r) => {
1666
- const a = await t.deleteFrom("roles").where("tenant_id", "=", e).where("id", "=", r).executeTakeFirst();
1667
- return Number(a.numDeletedRows) > 0;
1664
+ function Wa(t) {
1665
+ return async (e, a) => {
1666
+ const r = await t.deleteFrom("roles").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1667
+ return Number(r.numDeletedRows) > 0;
1668
1668
  };
1669
1669
  }
1670
- function Wr(t) {
1670
+ function Va(t) {
1671
1671
  return {
1672
- create: Ur(t),
1673
- get: Br(t),
1674
- list: Qr(t),
1675
- update: qr(t),
1676
- remove: Vr(t)
1672
+ create: Ua(t),
1673
+ get: Ba(t),
1674
+ list: qa(t),
1675
+ update: Qa(t),
1676
+ remove: Wa(t)
1677
1677
  };
1678
1678
  }
1679
- function Gr(t) {
1680
- return async (e, r, a) => {
1681
- if (a.length === 0) return !0;
1679
+ function Ga(t) {
1680
+ return async (e, a, r) => {
1681
+ if (r.length === 0) return !0;
1682
1682
  const n = (/* @__PURE__ */ new Date()).toISOString();
1683
1683
  try {
1684
- for (const o of a) {
1685
- if (o.role_id !== r)
1684
+ for (const o of r) {
1685
+ if (o.role_id !== a)
1686
1686
  throw new Error(
1687
- `Permission role_id ${o.role_id} does not match expected role_id ${r}`
1687
+ `Permission role_id ${o.role_id} does not match expected role_id ${a}`
1688
1688
  );
1689
1689
  const s = {
1690
1690
  tenant_id: e,
@@ -1707,13 +1707,13 @@ function Gr(t) {
1707
1707
  }
1708
1708
  };
1709
1709
  }
1710
- function Hr(t) {
1711
- return async (e, r, a) => {
1712
- if (a.length === 0) return !0;
1710
+ function Ha(t) {
1711
+ return async (e, a, r) => {
1712
+ if (r.length === 0) return !0;
1713
1713
  try {
1714
1714
  return (await Promise.all(
1715
- a.map(
1716
- (o) => t.deleteFrom("role_permissions").where("tenant_id", "=", e).where("role_id", "=", r).where(
1715
+ r.map(
1716
+ (o) => t.deleteFrom("role_permissions").where("tenant_id", "=", e).where("role_id", "=", a).where(
1717
1717
  "resource_server_identifier",
1718
1718
  "=",
1719
1719
  o.resource_server_identifier
@@ -1725,12 +1725,12 @@ function Hr(t) {
1725
1725
  }
1726
1726
  };
1727
1727
  }
1728
- function Yr(t) {
1729
- return async (e, r, a = {}) => {
1730
- const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = a;
1728
+ function Ya(t) {
1729
+ return async (e, a, r = {}) => {
1730
+ const { page: n = 0, per_page: o = 50, include_totals: s = !1 } = r;
1731
1731
  let i = t.selectFrom("role_permissions").leftJoin(
1732
1732
  "resource_servers",
1733
- (m) => m.onRef(
1733
+ (d) => d.onRef(
1734
1734
  "role_permissions.tenant_id",
1735
1735
  "=",
1736
1736
  "resource_servers.tenant_id"
@@ -1745,36 +1745,36 @@ function Yr(t) {
1745
1745
  "role_permissions.permission_name",
1746
1746
  "role_permissions.created_at",
1747
1747
  "resource_servers.name as resource_server_name"
1748
- ]).where("role_permissions.tenant_id", "=", e).where("role_permissions.role_id", "=", r);
1749
- const u = (await i.offset(n * o).limit(o).execute()).map((m) => ({
1750
- role_id: m.role_id,
1751
- resource_server_identifier: m.resource_server_identifier,
1752
- resource_server_name: m.resource_server_name || m.resource_server_identifier,
1748
+ ]).where("role_permissions.tenant_id", "=", e).where("role_permissions.role_id", "=", a);
1749
+ const _ = (await i.offset(n * o).limit(o).execute()).map((d) => ({
1750
+ role_id: d.role_id,
1751
+ resource_server_identifier: d.resource_server_identifier,
1752
+ resource_server_name: d.resource_server_name || d.resource_server_identifier,
1753
1753
  // Fallback to identifier if name is null
1754
- permission_name: m.permission_name,
1754
+ permission_name: d.permission_name,
1755
1755
  description: null,
1756
1756
  // No description available from role_permissions directly
1757
- created_at: m.created_at
1757
+ created_at: d.created_at
1758
1758
  }));
1759
- return s && await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow(), u;
1759
+ return s && await i.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), _;
1760
1760
  };
1761
1761
  }
1762
- function Xr(t) {
1762
+ function Xa(t) {
1763
1763
  return {
1764
- assign: Gr(t),
1765
- remove: Hr(t),
1766
- list: Yr(t)
1764
+ assign: Ga(t),
1765
+ remove: Ha(t),
1766
+ list: Ya(t)
1767
1767
  };
1768
1768
  }
1769
- function Zr(t) {
1770
- return async (e, r, a) => {
1771
- if (a.length === 0) return !0;
1769
+ function Za(t) {
1770
+ return async (e, a, r) => {
1771
+ if (r.length === 0) return !0;
1772
1772
  const n = (/* @__PURE__ */ new Date()).toISOString();
1773
1773
  try {
1774
- for (const o of a) {
1774
+ for (const o of r) {
1775
1775
  const s = {
1776
1776
  tenant_id: e,
1777
- user_id: r,
1777
+ user_id: a,
1778
1778
  resource_server_identifier: o.resource_server_identifier,
1779
1779
  permission_name: o.permission_name,
1780
1780
  created_at: n
@@ -1793,12 +1793,12 @@ function Zr(t) {
1793
1793
  }
1794
1794
  };
1795
1795
  }
1796
- function ea(t) {
1797
- return async (e, r, a) => {
1798
- if (a.length === 0) return !0;
1796
+ function er(t) {
1797
+ return async (e, a, r) => {
1798
+ if (r.length === 0) return !0;
1799
1799
  try {
1800
- for (const n of a)
1801
- await t.deleteFrom("user_permissions").where("tenant_id", "=", e).where("user_id", "=", r).where(
1800
+ for (const n of r)
1801
+ await t.deleteFrom("user_permissions").where("tenant_id", "=", e).where("user_id", "=", a).where(
1802
1802
  "resource_server_identifier",
1803
1803
  "=",
1804
1804
  n.resource_server_identifier
@@ -1809,8 +1809,8 @@ function ea(t) {
1809
1809
  }
1810
1810
  };
1811
1811
  }
1812
- function ta(t) {
1813
- return async (e, r, a) => (await t.selectFrom("user_permissions").leftJoin(
1812
+ function tr(t) {
1813
+ return async (e, a, r) => (await t.selectFrom("user_permissions").leftJoin(
1814
1814
  "resource_servers",
1815
1815
  (o) => o.onRef(
1816
1816
  "user_permissions.tenant_id",
@@ -1827,7 +1827,7 @@ function ta(t) {
1827
1827
  "resource_servers.name as resource_server_name",
1828
1828
  "user_permissions.user_id",
1829
1829
  "user_permissions.created_at"
1830
- ]).where("user_permissions.tenant_id", "=", e).where("user_permissions.user_id", "=", r).execute()).map((o) => ({
1830
+ ]).where("user_permissions.tenant_id", "=", e).where("user_permissions.user_id", "=", a).execute()).map((o) => ({
1831
1831
  resource_server_identifier: o.resource_server_identifier,
1832
1832
  permission_name: o.permission_name,
1833
1833
  description: null,
@@ -1838,15 +1838,15 @@ function ta(t) {
1838
1838
  created_at: o.created_at
1839
1839
  }));
1840
1840
  }
1841
- function ra(t) {
1841
+ function ar(t) {
1842
1842
  return {
1843
- assign: Zr(t),
1844
- remove: ea(t),
1845
- list: ta(t)
1843
+ assign: Za(t),
1844
+ remove: er(t),
1845
+ list: tr(t)
1846
1846
  };
1847
1847
  }
1848
- function aa(t) {
1849
- return async (e, r) => await t.selectFrom("user_roles as ur").innerJoin(
1848
+ function rr(t) {
1849
+ return async (e, a) => await t.selectFrom("user_roles as ur").innerJoin(
1850
1850
  "roles as r",
1851
1851
  (n) => n.onRef("ur.role_id", "=", "r.id").onRef("ur.tenant_id", "=", "r.tenant_id")
1852
1852
  ).select([
@@ -1855,16 +1855,16 @@ function aa(t) {
1855
1855
  "r.description",
1856
1856
  "r.created_at",
1857
1857
  "r.updated_at"
1858
- ]).where("ur.tenant_id", "=", e).where("ur.user_id", "=", r).execute();
1858
+ ]).where("ur.tenant_id", "=", e).where("ur.user_id", "=", a).execute();
1859
1859
  }
1860
- function na(t) {
1861
- return async (e, r, a) => {
1862
- if (a.length === 0) return !0;
1860
+ function nr(t) {
1861
+ return async (e, a, r) => {
1862
+ if (r.length === 0) return !0;
1863
1863
  const n = (/* @__PURE__ */ new Date()).toISOString();
1864
1864
  try {
1865
- for (const o of a)
1865
+ for (const o of r)
1866
1866
  try {
1867
- await t.insertInto("user_roles").values({ tenant_id: e, user_id: r, role_id: o, created_at: n }).execute();
1867
+ await t.insertInto("user_roles").values({ tenant_id: e, user_id: a, role_id: o, created_at: n }).execute();
1868
1868
  } catch (s) {
1869
1869
  if (s.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || s.code === "SQLITE_CONSTRAINT_UNIQUE")
1870
1870
  continue;
@@ -1876,29 +1876,212 @@ function na(t) {
1876
1876
  }
1877
1877
  };
1878
1878
  }
1879
- function oa(t) {
1880
- return async (e, r, a) => {
1879
+ function or(t) {
1880
+ return async (e, a, r) => {
1881
1881
  try {
1882
- return a.length && await t.deleteFrom("user_roles").where("tenant_id", "=", e).where("user_id", "=", r).where((n) => n("role_id", "in", a)).execute(), !0;
1882
+ return r.length && await t.deleteFrom("user_roles").where("tenant_id", "=", e).where("user_id", "=", a).where((n) => n("role_id", "in", r)).execute(), !0;
1883
1883
  } catch (n) {
1884
1884
  return console.error("Error removing user roles:", n), !1;
1885
1885
  }
1886
1886
  };
1887
1887
  }
1888
- function sa(t) {
1888
+ function sr(t) {
1889
1889
  return {
1890
- list: aa(t),
1891
- assign: na(t),
1892
- remove: oa(t)
1890
+ list: rr(t),
1891
+ assign: nr(t),
1892
+ remove: or(t)
1893
1893
  };
1894
1894
  }
1895
- function ia(t) {
1896
- return t[t.length - 1];
1895
+ function ir(t) {
1896
+ return async (e, a) => {
1897
+ const r = {
1898
+ ...a,
1899
+ id: a.id || T(),
1900
+ tenant_id: e,
1901
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1902
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1903
+ branding: JSON.stringify(a.branding || {}),
1904
+ metadata: JSON.stringify(a.metadata || {}),
1905
+ enabled_connections: JSON.stringify(
1906
+ a.enabled_connections || []
1907
+ ),
1908
+ token_quota: JSON.stringify(a.token_quota || {})
1909
+ };
1910
+ try {
1911
+ await t.insertInto("organizations").values(r).execute();
1912
+ } catch (n) {
1913
+ throw n.code === "SQLITE_CONSTRAINT_UNIQUE" || n.message.includes("AlreadyExists") ? new q(409, {
1914
+ message: "Organization already exists"
1915
+ }) : n;
1916
+ }
1917
+ return {
1918
+ ...a,
1919
+ id: r.id,
1920
+ created_at: r.created_at,
1921
+ updated_at: r.updated_at
1922
+ };
1923
+ };
1924
+ }
1925
+ function lr(t) {
1926
+ return async (e, a) => {
1927
+ const r = await t.selectFrom("organizations").selectAll().where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1928
+ return r ? y({
1929
+ ...r,
1930
+ branding: r.branding ? JSON.parse(r.branding) : {},
1931
+ metadata: r.metadata ? JSON.parse(r.metadata) : {},
1932
+ enabled_connections: r.enabled_connections ? JSON.parse(r.enabled_connections) : [],
1933
+ token_quota: r.token_quota ? JSON.parse(r.token_quota) : {}
1934
+ }) : null;
1935
+ };
1936
+ }
1937
+ function cr(t) {
1938
+ return async (e, a) => {
1939
+ let r = t.selectFrom("organizations").selectAll().where("tenant_id", "=", e).orderBy("created_at", "desc");
1940
+ if (a != null && a.per_page && (r = r.limit(a.per_page)), a != null && a.page) {
1941
+ const s = (a.page - 1) * (a.per_page || 10);
1942
+ r = r.offset(s);
1943
+ }
1944
+ const o = (await r.execute()).map(
1945
+ (s) => y({
1946
+ ...s,
1947
+ branding: s.branding ? JSON.parse(s.branding) : {},
1948
+ metadata: s.metadata ? JSON.parse(s.metadata) : {},
1949
+ enabled_connections: s.enabled_connections ? JSON.parse(s.enabled_connections) : [],
1950
+ token_quota: s.token_quota ? JSON.parse(s.token_quota) : {}
1951
+ })
1952
+ );
1953
+ return {
1954
+ organizations: o,
1955
+ start: a != null && a.page ? (a.page - 1) * (a.per_page || 10) : 0,
1956
+ limit: (a == null ? void 0 : a.per_page) || o.length,
1957
+ length: o.length
1958
+ };
1959
+ };
1960
+ }
1961
+ function dr(t) {
1962
+ return async (e, a) => (await t.deleteFrom("organizations").where("tenant_id", "=", e).where("id", "=", a).execute()).length > 0;
1963
+ }
1964
+ function ur(t) {
1965
+ return async (e, a, r) => {
1966
+ const { branding: n, metadata: o, enabled_connections: s, token_quota: i, ...c } = r, m = {
1967
+ ...c,
1968
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1969
+ };
1970
+ return n !== void 0 && (m.branding = JSON.stringify(n)), o !== void 0 && (m.metadata = JSON.stringify(o)), s !== void 0 && (m.enabled_connections = JSON.stringify(s)), i !== void 0 && (m.token_quota = JSON.stringify(i)), (await t.updateTable("organizations").set(m).where("tenant_id", "=", e).where("id", "=", a).execute()).length > 0;
1971
+ };
1972
+ }
1973
+ function mr(t) {
1974
+ return {
1975
+ create: ir(t),
1976
+ get: lr(t),
1977
+ list: cr(t),
1978
+ remove: dr(t),
1979
+ update: ur(t)
1980
+ };
1981
+ }
1982
+ function _r(t) {
1983
+ return async (e, a) => {
1984
+ const r = {
1985
+ id: T(),
1986
+ tenant_id: e,
1987
+ user_id: a.user_id,
1988
+ organization_id: a.organization_id,
1989
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1990
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1991
+ };
1992
+ try {
1993
+ await t.insertInto("user_organizations").values(r).execute();
1994
+ } catch (n) {
1995
+ throw n.code === "SQLITE_CONSTRAINT_UNIQUE" || n.code === "ER_DUP_ENTRY" ? new q(409, {
1996
+ message: "User is already a member of this organization"
1997
+ }) : n;
1998
+ }
1999
+ return {
2000
+ ...r
2001
+ };
2002
+ };
2003
+ }
2004
+ function hr(t) {
2005
+ return async (e, a) => {
2006
+ const r = await t.selectFrom("user_organizations").selectAll().where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
2007
+ return r ? {
2008
+ id: r.id,
2009
+ user_id: r.user_id,
2010
+ organization_id: r.organization_id,
2011
+ created_at: r.created_at,
2012
+ updated_at: r.updated_at
2013
+ } : null;
2014
+ };
2015
+ }
2016
+ function fr(t) {
2017
+ return async (e, a) => {
2018
+ const r = (a == null ? void 0 : a.page) || 0, n = (a == null ? void 0 : a.per_page) || 50, o = r * n;
2019
+ let s = t.selectFrom("user_organizations").selectAll().where("tenant_id", "=", e);
2020
+ if (a != null && a.q) {
2021
+ if (a.q.startsWith("user_id:")) {
2022
+ const d = a.q.replace("user_id:", "");
2023
+ s = s.where("user_id", "=", d);
2024
+ } else if (a.q.startsWith("organization_id:")) {
2025
+ const d = a.q.replace("organization_id:", "");
2026
+ s = s.where("organization_id", "=", d);
2027
+ }
2028
+ }
2029
+ s = s.orderBy("created_at", "desc"), n > 0 && (s = s.limit(n).offset(o));
2030
+ const i = await s.execute();
2031
+ let c = t.selectFrom("user_organizations").select(t.fn.count("id").as("count")).where("tenant_id", "=", e);
2032
+ if (a != null && a.q) {
2033
+ if (a.q.startsWith("user_id:")) {
2034
+ const d = a.q.replace("user_id:", "");
2035
+ c = c.where("user_id", "=", d);
2036
+ } else if (a.q.startsWith("organization_id:")) {
2037
+ const d = a.q.replace("organization_id:", "");
2038
+ c = c.where("organization_id", "=", d);
2039
+ }
2040
+ }
2041
+ const m = await c.executeTakeFirst();
2042
+ return {
2043
+ userOrganizations: i.map((d) => ({
2044
+ id: d.id,
2045
+ user_id: d.user_id,
2046
+ organization_id: d.organization_id,
2047
+ created_at: d.created_at,
2048
+ updated_at: d.updated_at
2049
+ })),
2050
+ start: o,
2051
+ limit: n,
2052
+ length: Number((m == null ? void 0 : m.count) || 0)
2053
+ };
2054
+ };
2055
+ }
2056
+ function pr(t) {
2057
+ return async (e, a) => (await t.deleteFrom("user_organizations").where("id", "=", a).where("tenant_id", "=", e).execute()).length > 0;
2058
+ }
2059
+ function gr(t) {
2060
+ return async (e, a, r) => {
2061
+ const n = {
2062
+ ...r,
2063
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
2064
+ };
2065
+ return (await t.updateTable("user_organizations").set(n).where("id", "=", a).where("tenant_id", "=", e).execute()).length > 0;
2066
+ };
2067
+ }
2068
+ function wr(t) {
2069
+ return {
2070
+ // CRUD operations
2071
+ create: _r(t),
2072
+ get: hr(t),
2073
+ list: fr(t),
2074
+ remove: pr(t),
2075
+ update: gr(t)
2076
+ };
2077
+ }
2078
+ function yr(t) {
2079
+ return t[t.length - 1];
1897
2080
  }
1898
2081
  function C(t) {
1899
2082
  return Object.freeze(t);
1900
2083
  }
1901
- const W = C({
2084
+ const G = C({
1902
2085
  is(t) {
1903
2086
  return t.kind === "IdentifierNode";
1904
2087
  },
@@ -1908,24 +2091,24 @@ const W = C({
1908
2091
  name: t
1909
2092
  });
1910
2093
  }
1911
- }), re = C({
2094
+ }), ae = C({
1912
2095
  is(t) {
1913
2096
  return t.kind === "SchemableIdentifierNode";
1914
2097
  },
1915
2098
  create(t) {
1916
2099
  return C({
1917
2100
  kind: "SchemableIdentifierNode",
1918
- identifier: W.create(t)
2101
+ identifier: G.create(t)
1919
2102
  });
1920
2103
  },
1921
2104
  createWithSchema(t, e) {
1922
2105
  return C({
1923
2106
  kind: "SchemableIdentifierNode",
1924
- schema: W.create(t),
1925
- identifier: W.create(e)
2107
+ schema: G.create(t),
2108
+ identifier: G.create(e)
1926
2109
  });
1927
2110
  }
1928
- }), la = C({
2111
+ }), vr = C({
1929
2112
  is(t) {
1930
2113
  return t.kind === "AliasNode";
1931
2114
  },
@@ -1936,28 +2119,28 @@ const W = C({
1936
2119
  alias: e
1937
2120
  });
1938
2121
  }
1939
- }), X = C({
2122
+ }), Z = C({
1940
2123
  is(t) {
1941
2124
  return t.kind === "TableNode";
1942
2125
  },
1943
2126
  create(t) {
1944
2127
  return C({
1945
2128
  kind: "TableNode",
1946
- table: re.create(t)
2129
+ table: ae.create(t)
1947
2130
  });
1948
2131
  },
1949
2132
  createWithSchema(t, e) {
1950
2133
  return C({
1951
2134
  kind: "TableNode",
1952
- table: re.createWithSchema(t, e)
2135
+ table: ae.createWithSchema(t, e)
1953
2136
  });
1954
2137
  }
1955
2138
  });
1956
- var H;
1957
- class ca {
2139
+ var Y;
2140
+ class Nr {
1958
2141
  constructor() {
1959
2142
  R(this, "nodeStack", []);
1960
- S(this, H, C({
2143
+ O(this, Y, C({
1961
2144
  AliasNode: this.transformAlias.bind(this),
1962
2145
  ColumnNode: this.transformColumn.bind(this),
1963
2146
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -2057,14 +2240,14 @@ class ca {
2057
2240
  if (!e)
2058
2241
  return e;
2059
2242
  this.nodeStack.push(e);
2060
- const r = this.transformNodeImpl(e);
2061
- return this.nodeStack.pop(), C(r);
2243
+ const a = this.transformNodeImpl(e);
2244
+ return this.nodeStack.pop(), C(a);
2062
2245
  }
2063
2246
  transformNodeImpl(e) {
2064
- return d(this, H)[e.kind](e);
2247
+ return u(this, Y)[e.kind](e);
2065
2248
  }
2066
2249
  transformNodeList(e) {
2067
- return e && C(e.map((r) => this.transformNode(r)));
2250
+ return e && C(e.map((a) => this.transformNode(a)));
2068
2251
  }
2069
2252
  transformSelectQuery(e) {
2070
2253
  return {
@@ -2787,8 +2970,8 @@ class ca {
2787
2970
  return e;
2788
2971
  }
2789
2972
  }
2790
- H = new WeakMap();
2791
- const da = C({
2973
+ Y = new WeakMap();
2974
+ const Cr = C({
2792
2975
  AlterTableNode: !0,
2793
2976
  CreateIndexNode: !0,
2794
2977
  CreateSchemaNode: !0,
@@ -2807,88 +2990,88 @@ const da = C({
2807
2990
  UpdateQueryNode: !0,
2808
2991
  MergeQueryNode: !0
2809
2992
  });
2810
- var E, j, F, N, ye, ve, Ne, A, ae, Ce;
2811
- class ua extends ca {
2812
- constructor(r) {
2993
+ var E, j, F, N, ye, ve, Ne, M, re, Ce;
2994
+ class br extends Nr {
2995
+ constructor(a) {
2813
2996
  super();
2814
- S(this, N);
2815
- S(this, E);
2816
- S(this, j, /* @__PURE__ */ new Set());
2817
- S(this, F, /* @__PURE__ */ new Set());
2818
- K(this, E, r);
2819
- }
2820
- transformNodeImpl(r) {
2821
- if (!p(this, N, ye).call(this, r))
2822
- return super.transformNodeImpl(r);
2823
- const a = p(this, N, Ne).call(this, r);
2824
- for (const s of a)
2825
- d(this, F).add(s);
2826
- const n = p(this, N, ve).call(this, r);
2997
+ O(this, N);
2998
+ O(this, E);
2999
+ O(this, j, /* @__PURE__ */ new Set());
3000
+ O(this, F, /* @__PURE__ */ new Set());
3001
+ K(this, E, a);
3002
+ }
3003
+ transformNodeImpl(a) {
3004
+ if (!p(this, N, ye).call(this, a))
3005
+ return super.transformNodeImpl(a);
3006
+ const r = p(this, N, Ne).call(this, a);
3007
+ for (const s of r)
3008
+ u(this, F).add(s);
3009
+ const n = p(this, N, ve).call(this, a);
2827
3010
  for (const s of n)
2828
- d(this, j).add(s);
2829
- const o = super.transformNodeImpl(r);
3011
+ u(this, j).add(s);
3012
+ const o = super.transformNodeImpl(a);
2830
3013
  for (const s of n)
2831
- d(this, j).delete(s);
2832
- for (const s of a)
2833
- d(this, F).delete(s);
3014
+ u(this, j).delete(s);
3015
+ for (const s of r)
3016
+ u(this, F).delete(s);
2834
3017
  return o;
2835
3018
  }
2836
- transformSchemableIdentifier(r) {
2837
- const a = super.transformSchemableIdentifier(r);
2838
- return a.schema || !d(this, j).has(r.identifier.name) ? a : {
2839
- ...a,
2840
- schema: W.create(d(this, E))
3019
+ transformSchemableIdentifier(a) {
3020
+ const r = super.transformSchemableIdentifier(a);
3021
+ return r.schema || !u(this, j).has(a.identifier.name) ? r : {
3022
+ ...r,
3023
+ schema: G.create(u(this, E))
2841
3024
  };
2842
3025
  }
2843
- transformReferences(r) {
2844
- const a = super.transformReferences(r);
2845
- return a.table.table.schema ? a : {
2846
- ...a,
2847
- table: X.createWithSchema(d(this, E), a.table.table.identifier.name)
2848
- };
2849
- }
2850
- }
2851
- E = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakSet(), ye = function(r) {
2852
- return r.kind in da;
2853
- }, ve = function(r) {
2854
- const a = /* @__PURE__ */ new Set();
2855
- if ("name" in r && r.name && re.is(r.name) && p(this, N, ae).call(this, r.name, a), "from" in r && r.from)
2856
- for (const n of r.from.froms)
2857
- p(this, N, A).call(this, n, a);
2858
- if ("into" in r && r.into && p(this, N, A).call(this, r.into, a), "table" in r && r.table && p(this, N, A).call(this, r.table, a), "joins" in r && r.joins)
2859
- for (const n of r.joins)
2860
- p(this, N, A).call(this, n.table, a);
2861
- return "using" in r && r.using && p(this, N, A).call(this, r.using, a), a;
2862
- }, Ne = function(r) {
2863
- const a = /* @__PURE__ */ new Set();
2864
- return "with" in r && r.with && p(this, N, Ce).call(this, r.with, a), a;
2865
- }, A = function(r, a) {
2866
- const n = X.is(r) ? r : la.is(r) && X.is(r.node) ? r.node : null;
2867
- n && p(this, N, ae).call(this, n.table, a);
2868
- }, ae = function(r, a) {
2869
- const n = r.identifier.name;
2870
- !d(this, j).has(n) && !d(this, F).has(n) && a.add(n);
2871
- }, Ce = function(r, a) {
2872
- for (const n of r.expressions) {
3026
+ transformReferences(a) {
3027
+ const r = super.transformReferences(a);
3028
+ return r.table.table.schema ? r : {
3029
+ ...r,
3030
+ table: Z.createWithSchema(u(this, E), r.table.table.identifier.name)
3031
+ };
3032
+ }
3033
+ }
3034
+ E = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakSet(), ye = function(a) {
3035
+ return a.kind in Cr;
3036
+ }, ve = function(a) {
3037
+ const r = /* @__PURE__ */ new Set();
3038
+ if ("name" in a && a.name && ae.is(a.name) && p(this, N, re).call(this, a.name, r), "from" in a && a.from)
3039
+ for (const n of a.from.froms)
3040
+ p(this, N, M).call(this, n, r);
3041
+ if ("into" in a && a.into && p(this, N, M).call(this, a.into, r), "table" in a && a.table && p(this, N, M).call(this, a.table, r), "joins" in a && a.joins)
3042
+ for (const n of a.joins)
3043
+ p(this, N, M).call(this, n.table, r);
3044
+ return "using" in a && a.using && p(this, N, M).call(this, a.using, r), r;
3045
+ }, Ne = function(a) {
3046
+ const r = /* @__PURE__ */ new Set();
3047
+ return "with" in a && a.with && p(this, N, Ce).call(this, a.with, r), r;
3048
+ }, M = function(a, r) {
3049
+ const n = Z.is(a) ? a : vr.is(a) && Z.is(a.node) ? a.node : null;
3050
+ n && p(this, N, re).call(this, n.table, r);
3051
+ }, re = function(a, r) {
3052
+ const n = a.identifier.name;
3053
+ !u(this, j).has(n) && !u(this, F).has(n) && r.add(n);
3054
+ }, Ce = function(a, r) {
3055
+ for (const n of a.expressions) {
2873
3056
  const o = n.name.table.table.identifier.name;
2874
- d(this, F).has(o) || a.add(o);
3057
+ u(this, F).has(o) || r.add(o);
2875
3058
  }
2876
3059
  };
2877
3060
  var Q;
2878
- class ma {
3061
+ class xr {
2879
3062
  constructor(e) {
2880
- S(this, Q);
2881
- K(this, Q, new ua(e));
3063
+ O(this, Q);
3064
+ K(this, Q, new br(e));
2882
3065
  }
2883
3066
  transformQuery(e) {
2884
- return d(this, Q).transformNode(e.node);
3067
+ return u(this, Q).transformNode(e.node);
2885
3068
  }
2886
3069
  async transformResult(e) {
2887
3070
  return e.result;
2888
3071
  }
2889
3072
  }
2890
3073
  Q = new WeakMap();
2891
- class _a {
3074
+ class Tr {
2892
3075
  transformQuery(e) {
2893
3076
  return e.node;
2894
3077
  }
@@ -2896,12 +3079,12 @@ class _a {
2896
3079
  return e.result;
2897
3080
  }
2898
3081
  }
2899
- const ha = "kysely_migration", fe = "kysely_migration_lock", fa = !1, Z = "migration_lock", pa = C({ __noMigrations__: !0 });
2900
- var v, l, U, k, $, z, xe, I, Te, Se, Oe, ke, $e, ne, L, oe, Ie, De, Pe, se, je, Fe, Me, Ae, ze, B;
3082
+ const Sr = "kysely_migration", fe = "kysely_migration_lock", Or = !1, ee = "migration_lock", kr = C({ __noMigrations__: !0 });
3083
+ var v, l, U, k, $, z, xe, I, Te, Se, Oe, ke, $e, ne, J, oe, Ie, De, Pe, se, je, Fe, Ae, Me, ze, B;
2901
3084
  class be {
2902
3085
  constructor(e) {
2903
- S(this, l);
2904
- S(this, v);
3086
+ O(this, l);
3087
+ O(this, v);
2905
3088
  K(this, v, C(e));
2906
3089
  }
2907
3090
  /**
@@ -2910,11 +3093,11 @@ class be {
2910
3093
  * The returned array is sorted by migration name.
2911
3094
  */
2912
3095
  async getMigrations() {
2913
- const e = await p(this, l, L).call(this, d(this, l, $)) ? await d(this, v).db.withPlugin(d(this, l, I)).selectFrom(d(this, l, $)).select(["name", "timestamp"]).execute() : [];
2914
- return (await p(this, l, se).call(this)).map(({ name: a, ...n }) => {
2915
- const o = e.find((s) => s.name === a);
3096
+ const e = await p(this, l, J).call(this, u(this, l, $)) ? await u(this, v).db.withPlugin(u(this, l, I)).selectFrom(u(this, l, $)).select(["name", "timestamp"]).execute() : [];
3097
+ return (await p(this, l, se).call(this)).map(({ name: r, ...n }) => {
3098
+ const o = e.find((s) => s.name === r);
2916
3099
  return {
2917
- name: a,
3100
+ name: r,
2918
3101
  migration: n,
2919
3102
  executedAt: o ? new Date(o.timestamp) : void 0
2920
3103
  };
@@ -2994,16 +3177,16 @@ class be {
2994
3177
  * ```
2995
3178
  */
2996
3179
  async migrateTo(e) {
2997
- return p(this, l, U).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: n }) => {
2998
- if (e === pa)
3180
+ return p(this, l, U).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: n }) => {
3181
+ if (e === kr)
2999
3182
  return { direction: "Down", step: 1 / 0 };
3000
- if (!r.find((i) => i.name === e))
3183
+ if (!a.find((i) => i.name === e))
3001
3184
  throw new Error(`migration "${e}" doesn't exist`);
3002
- const o = a.indexOf(e), s = n.findIndex((i) => i.name === e);
3185
+ const o = r.indexOf(e), s = n.findIndex((i) => i.name === e);
3003
3186
  if (o !== -1)
3004
3187
  return {
3005
3188
  direction: "Down",
3006
- step: a.length - o - 1
3189
+ step: r.length - o - 1
3007
3190
  };
3008
3191
  if (s !== -1)
3009
3192
  return { direction: "Up", step: s + 1 };
@@ -3048,110 +3231,110 @@ class be {
3048
3231
  v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3049
3232
  try {
3050
3233
  return await p(this, l, Te).call(this), await p(this, l, Ie).call(this, e);
3051
- } catch (r) {
3052
- return r instanceof ee ? r.resultSet : { error: r };
3234
+ } catch (a) {
3235
+ return a instanceof te ? a.resultSet : { error: a };
3053
3236
  }
3054
3237
  }, k = function() {
3055
- return d(this, v).migrationTableSchema;
3238
+ return u(this, v).migrationTableSchema;
3056
3239
  }, $ = function() {
3057
- return d(this, v).migrationTableName ?? ha;
3240
+ return u(this, v).migrationTableName ?? Sr;
3058
3241
  }, z = function() {
3059
- return d(this, v).migrationLockTableName ?? fe;
3242
+ return u(this, v).migrationLockTableName ?? fe;
3060
3243
  }, xe = function() {
3061
- return d(this, v).allowUnorderedMigrations ?? fa;
3244
+ return u(this, v).allowUnorderedMigrations ?? Or;
3062
3245
  }, I = function() {
3063
- return d(this, l, k) ? new ma(d(this, l, k)) : new _a();
3246
+ return u(this, l, k) ? new xr(u(this, l, k)) : new Tr();
3064
3247
  }, Te = async function() {
3065
3248
  await p(this, l, Se).call(this), await p(this, l, Oe).call(this), await p(this, l, ke).call(this), await p(this, l, $e).call(this);
3066
3249
  }, Se = async function() {
3067
- if (d(this, l, k) && !await p(this, l, ne).call(this))
3250
+ if (u(this, l, k) && !await p(this, l, ne).call(this))
3068
3251
  try {
3069
- await p(this, l, B).call(this, d(this, v).db.schema.createSchema(d(this, l, k)));
3252
+ await p(this, l, B).call(this, u(this, v).db.schema.createSchema(u(this, l, k)));
3070
3253
  } catch (e) {
3071
3254
  if (!await p(this, l, ne).call(this))
3072
3255
  throw e;
3073
3256
  }
3074
3257
  }, Oe = async function() {
3075
- if (!await p(this, l, L).call(this, d(this, l, $)))
3258
+ if (!await p(this, l, J).call(this, u(this, l, $)))
3076
3259
  try {
3077
- d(this, l, k) && await p(this, l, B).call(this, d(this, v).db.schema.createSchema(d(this, l, k))), await p(this, l, B).call(this, d(this, v).db.schema.withPlugin(d(this, l, I)).createTable(d(this, l, $)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
3260
+ u(this, l, k) && await p(this, l, B).call(this, u(this, v).db.schema.createSchema(u(this, l, k))), await p(this, l, B).call(this, u(this, v).db.schema.withPlugin(u(this, l, I)).createTable(u(this, l, $)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
3078
3261
  } catch (e) {
3079
- if (!await p(this, l, L).call(this, d(this, l, $)))
3262
+ if (!await p(this, l, J).call(this, u(this, l, $)))
3080
3263
  throw e;
3081
3264
  }
3082
3265
  }, ke = async function() {
3083
- if (!await p(this, l, L).call(this, d(this, l, z)))
3266
+ if (!await p(this, l, J).call(this, u(this, l, z)))
3084
3267
  try {
3085
- await p(this, l, B).call(this, d(this, v).db.schema.withPlugin(d(this, l, I)).createTable(d(this, l, z)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
3268
+ await p(this, l, B).call(this, u(this, v).db.schema.withPlugin(u(this, l, I)).createTable(u(this, l, z)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
3086
3269
  } catch (e) {
3087
- if (!await p(this, l, L).call(this, d(this, l, z)))
3270
+ if (!await p(this, l, J).call(this, u(this, l, z)))
3088
3271
  throw e;
3089
3272
  }
3090
3273
  }, $e = async function() {
3091
3274
  if (!await p(this, l, oe).call(this))
3092
3275
  try {
3093
- await d(this, v).db.withPlugin(d(this, l, I)).insertInto(d(this, l, z)).values({ id: Z, is_locked: 0 }).execute();
3276
+ await u(this, v).db.withPlugin(u(this, l, I)).insertInto(u(this, l, z)).values({ id: ee, is_locked: 0 }).execute();
3094
3277
  } catch (e) {
3095
3278
  if (!await p(this, l, oe).call(this))
3096
3279
  throw e;
3097
3280
  }
3098
3281
  }, ne = async function() {
3099
- return (await d(this, v).db.introspection.getSchemas()).some((r) => r.name === d(this, l, k));
3100
- }, L = async function(e) {
3101
- const r = d(this, l, k);
3102
- return (await d(this, v).db.introspection.getTables({
3282
+ return (await u(this, v).db.introspection.getSchemas()).some((a) => a.name === u(this, l, k));
3283
+ }, J = async function(e) {
3284
+ const a = u(this, l, k);
3285
+ return (await u(this, v).db.introspection.getTables({
3103
3286
  withInternalKyselyTables: !0
3104
- })).some((n) => n.name === e && (!r || n.schema === r));
3287
+ })).some((n) => n.name === e && (!a || n.schema === a));
3105
3288
  }, oe = async function() {
3106
- return !!await d(this, v).db.withPlugin(d(this, l, I)).selectFrom(d(this, l, z)).where("id", "=", Z).select("id").executeTakeFirst();
3289
+ return !!await u(this, v).db.withPlugin(u(this, l, I)).selectFrom(u(this, l, z)).where("id", "=", ee).select("id").executeTakeFirst();
3107
3290
  }, Ie = async function(e) {
3108
- const r = d(this, v).db.getExecutor().adapter, a = C({
3109
- lockTable: d(this, v).migrationLockTableName ?? fe,
3110
- lockRowId: Z,
3111
- lockTableSchema: d(this, v).migrationTableSchema
3291
+ const a = u(this, v).db.getExecutor().adapter, r = C({
3292
+ lockTable: u(this, v).migrationLockTableName ?? fe,
3293
+ lockRowId: ee,
3294
+ lockTableSchema: u(this, v).migrationTableSchema
3112
3295
  }), n = async (o) => {
3113
3296
  try {
3114
- await r.acquireMigrationLock(o, a);
3297
+ await a.acquireMigrationLock(o, r);
3115
3298
  const s = await p(this, l, De).call(this, o);
3116
3299
  if (s.migrations.length === 0)
3117
3300
  return { results: [] };
3118
3301
  const { direction: i, step: c } = e(s);
3119
- return c <= 0 ? { results: [] } : i === "Down" ? await p(this, l, Ae).call(this, o, s, c) : i === "Up" ? await p(this, l, ze).call(this, o, s, c) : { results: [] };
3302
+ return c <= 0 ? { results: [] } : i === "Down" ? await p(this, l, Me).call(this, o, s, c) : i === "Up" ? await p(this, l, ze).call(this, o, s, c) : { results: [] };
3120
3303
  } finally {
3121
- await r.releaseMigrationLock(o, a);
3304
+ await a.releaseMigrationLock(o, r);
3122
3305
  }
3123
3306
  };
3124
- return r.supportsTransactionalDdl ? d(this, v).db.transaction().execute(n) : d(this, v).db.connection().execute(n);
3307
+ return a.supportsTransactionalDdl ? u(this, v).db.transaction().execute(n) : u(this, v).db.connection().execute(n);
3125
3308
  }, De = async function(e) {
3126
- const r = await p(this, l, se).call(this), a = await p(this, l, je).call(this, e);
3127
- p(this, l, Fe).call(this, r, a), d(this, l, xe) || p(this, l, Me).call(this, r, a);
3128
- const n = p(this, l, Pe).call(this, r, a);
3309
+ const a = await p(this, l, se).call(this), r = await p(this, l, je).call(this, e);
3310
+ p(this, l, Fe).call(this, a, r), u(this, l, xe) || p(this, l, Ae).call(this, a, r);
3311
+ const n = p(this, l, Pe).call(this, a, r);
3129
3312
  return C({
3130
- migrations: r,
3131
- executedMigrations: a,
3132
- lastMigration: ia(a),
3313
+ migrations: a,
3314
+ executedMigrations: r,
3315
+ lastMigration: yr(r),
3133
3316
  pendingMigrations: n
3134
3317
  });
3135
- }, Pe = function(e, r) {
3136
- return e.filter((a) => !r.includes(a.name));
3318
+ }, Pe = function(e, a) {
3319
+ return e.filter((r) => !a.includes(r.name));
3137
3320
  }, se = async function() {
3138
- const e = await d(this, v).provider.getMigrations();
3139
- return Object.keys(e).sort().map((r) => ({
3140
- ...e[r],
3141
- name: r
3321
+ const e = await u(this, v).provider.getMigrations();
3322
+ return Object.keys(e).sort().map((a) => ({
3323
+ ...e[a],
3324
+ name: a
3142
3325
  }));
3143
3326
  }, je = async function(e) {
3144
- return (await e.withPlugin(d(this, l, I)).selectFrom(d(this, l, $)).select("name").orderBy(["timestamp", "name"]).execute()).map((a) => a.name);
3145
- }, Fe = function(e, r) {
3146
- for (const a of r)
3147
- if (!e.some((n) => n.name === a))
3148
- throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
3149
- }, Me = function(e, r) {
3150
- for (let a = 0; a < r.length; ++a)
3151
- if (e[a].name !== r[a])
3152
- throw new Error(`corrupted migrations: expected previously executed migration ${r[a]} to be at index ${a} but ${e[a].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
3153
- }, Ae = async function(e, r, a) {
3154
- const n = r.executedMigrations.slice().reverse().slice(0, a).map((s) => r.migrations.find((i) => i.name === s)), o = n.map((s) => ({
3327
+ return (await e.withPlugin(u(this, l, I)).selectFrom(u(this, l, $)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
3328
+ }, Fe = function(e, a) {
3329
+ for (const r of a)
3330
+ if (!e.some((n) => n.name === r))
3331
+ throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
3332
+ }, Ae = function(e, a) {
3333
+ for (let r = 0; r < a.length; ++r)
3334
+ if (e[r].name !== a[r])
3335
+ 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.`);
3336
+ }, Me = async function(e, a, r) {
3337
+ const n = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((i) => i.name === s)), o = n.map((s) => ({
3155
3338
  migrationName: s.name,
3156
3339
  direction: "Down",
3157
3340
  status: "NotExecuted"
@@ -3159,7 +3342,7 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3159
3342
  for (let s = 0; s < o.length; ++s) {
3160
3343
  const i = n[s];
3161
3344
  try {
3162
- i.down && (await i.down(e), await e.withPlugin(d(this, l, I)).deleteFrom(d(this, l, $)).where("name", "=", i.name).execute(), o[s] = {
3345
+ i.down && (await i.down(e), await e.withPlugin(u(this, l, I)).deleteFrom(u(this, l, $)).where("name", "=", i.name).execute(), o[s] = {
3163
3346
  migrationName: i.name,
3164
3347
  direction: "Down",
3165
3348
  status: "Success"
@@ -3169,23 +3352,23 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3169
3352
  migrationName: i.name,
3170
3353
  direction: "Down",
3171
3354
  status: "Error"
3172
- }, new ee({
3355
+ }, new te({
3173
3356
  error: c,
3174
3357
  results: o
3175
3358
  });
3176
3359
  }
3177
3360
  }
3178
3361
  return { results: o };
3179
- }, ze = async function(e, r, a) {
3180
- const o = r.pendingMigrations.slice(0, a).map((s) => ({
3362
+ }, ze = async function(e, a, r) {
3363
+ const o = a.pendingMigrations.slice(0, r).map((s) => ({
3181
3364
  migrationName: s.name,
3182
3365
  direction: "Up",
3183
3366
  status: "NotExecuted"
3184
3367
  }));
3185
3368
  for (let s = 0; s < o.length; s++) {
3186
- const i = r.pendingMigrations[s];
3369
+ const i = a.pendingMigrations[s];
3187
3370
  try {
3188
- await i.up(e), await e.withPlugin(d(this, l, I)).insertInto(d(this, l, $)).values({
3371
+ await i.up(e), await e.withPlugin(u(this, l, I)).insertInto(u(this, l, $)).values({
3189
3372
  name: i.name,
3190
3373
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3191
3374
  }).execute(), o[s] = {
@@ -3198,7 +3381,7 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3198
3381
  migrationName: i.name,
3199
3382
  direction: "Up",
3200
3383
  status: "Error"
3201
- }, new ee({
3384
+ }, new te({
3202
3385
  error: c,
3203
3386
  results: o
3204
3387
  });
@@ -3206,21 +3389,21 @@ v = new WeakMap(), l = new WeakSet(), U = async function(e) {
3206
3389
  }
3207
3390
  return { results: o };
3208
3391
  }, B = async function(e) {
3209
- d(this, v).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
3392
+ u(this, v).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
3210
3393
  };
3211
- var q;
3212
- class ee extends Error {
3213
- constructor(r) {
3394
+ var W;
3395
+ class te extends Error {
3396
+ constructor(a) {
3214
3397
  super();
3215
- S(this, q);
3216
- K(this, q, r);
3398
+ O(this, W);
3399
+ K(this, W, a);
3217
3400
  }
3218
3401
  get resultSet() {
3219
- return d(this, q);
3402
+ return u(this, W);
3220
3403
  }
3221
3404
  }
3222
- q = new WeakMap();
3223
- class Le {
3405
+ W = new WeakMap();
3406
+ class Je {
3224
3407
  constructor(e) {
3225
3408
  R(this, "migrations");
3226
3409
  this.migrations = e;
@@ -3229,7 +3412,7 @@ class Le {
3229
3412
  return this.migrations;
3230
3413
  }
3231
3414
  }
3232
- async function ga(t) {
3415
+ async function $r(t) {
3233
3416
  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(
3234
3417
  "tenant_id",
3235
3418
  "varchar(255)",
@@ -3301,35 +3484,35 @@ async function ga(t) {
3301
3484
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3302
3485
  ).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();
3303
3486
  }
3304
- async function wa(t) {
3487
+ async function Ir(t) {
3305
3488
  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();
3306
3489
  }
3307
- const ya = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3490
+ const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3308
3491
  __proto__: null,
3309
- down: wa,
3310
- up: ga
3492
+ down: Ir,
3493
+ up: $r
3311
3494
  }, Symbol.toStringTag, { value: "Module" }));
3312
- async function va(t) {
3495
+ async function Pr(t) {
3313
3496
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
3314
3497
  }
3315
- async function Na(t) {
3498
+ async function jr(t) {
3316
3499
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
3317
3500
  }
3318
- const Ca = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3501
+ const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3319
3502
  __proto__: null,
3320
- down: Na,
3321
- up: va
3503
+ down: jr,
3504
+ up: Pr
3322
3505
  }, Symbol.toStringTag, { value: "Module" }));
3323
- async function ba(t) {
3506
+ async function Ar(t) {
3324
3507
  }
3325
- async function xa(t) {
3508
+ async function Mr(t) {
3326
3509
  }
3327
- const Ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3510
+ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3328
3511
  __proto__: null,
3329
- down: xa,
3330
- up: ba
3512
+ down: Mr,
3513
+ up: Ar
3331
3514
  }, Symbol.toStringTag, { value: "Module" }));
3332
- async function Sa(t) {
3515
+ async function Jr(t) {
3333
3516
  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(
3334
3517
  "tenant_id_constraint",
3335
3518
  ["tenant_id"],
@@ -3338,24 +3521,24 @@ async function Sa(t) {
3338
3521
  (e) => e.onDelete("cascade")
3339
3522
  ).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();
3340
3523
  }
3341
- async function Oa(t) {
3524
+ async function Er(t) {
3342
3525
  await t.schema.dropTable("logs").execute();
3343
3526
  }
3344
- const ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3527
+ const Lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3345
3528
  __proto__: null,
3346
- down: Oa,
3347
- up: Sa
3529
+ down: Er,
3530
+ up: Jr
3348
3531
  }, Symbol.toStringTag, { value: "Module" }));
3349
- async function $a(t) {
3532
+ async function Rr(t) {
3350
3533
  }
3351
- async function Ia(t) {
3534
+ async function Kr(t) {
3352
3535
  }
3353
- const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3536
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3354
3537
  __proto__: null,
3355
- down: Ia,
3356
- up: $a
3538
+ down: Kr,
3539
+ up: Rr
3357
3540
  }, Symbol.toStringTag, { value: "Module" }));
3358
- async function Pa(t) {
3541
+ async function Br(t) {
3359
3542
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3360
3543
  "user_id_constraint",
3361
3544
  ["user_id", "tenant_id"],
@@ -3380,15 +3563,15 @@ async function Pa(t) {
3380
3563
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3381
3564
  ).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();
3382
3565
  }
3383
- async function ja(t) {
3566
+ async function qr(t) {
3384
3567
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
3385
3568
  }
3386
- const Fa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3569
+ const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3387
3570
  __proto__: null,
3388
- down: ja,
3389
- up: Pa
3571
+ down: qr,
3572
+ up: Br
3390
3573
  }, Symbol.toStringTag, { value: "Module" }));
3391
- async function Ma(t) {
3574
+ async function Wr(t) {
3392
3575
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
3393
3576
  "user_id_constraint",
3394
3577
  ["user_id", "tenant_id"],
@@ -3403,24 +3586,24 @@ async function Ma(t) {
3403
3586
  (e) => e.onDelete("cascade")
3404
3587
  ).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();
3405
3588
  }
3406
- async function Aa(t) {
3589
+ async function Vr(t) {
3407
3590
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
3408
3591
  }
3409
- const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3592
+ const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3410
3593
  __proto__: null,
3411
- down: Aa,
3412
- up: Ma
3594
+ down: Vr,
3595
+ up: Wr
3413
3596
  }, Symbol.toStringTag, { value: "Module" }));
3414
- async function La(t) {
3597
+ async function Hr(t) {
3415
3598
  }
3416
- async function Ea(t) {
3599
+ async function Yr(t) {
3417
3600
  }
3418
- const Ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3601
+ const Xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3419
3602
  __proto__: null,
3420
- down: Ea,
3421
- up: La
3603
+ down: Yr,
3604
+ up: Hr
3422
3605
  }, Symbol.toStringTag, { value: "Module" }));
3423
- async function Ra(t) {
3606
+ async function Zr(t) {
3424
3607
  await t.schema.alterTable("passwords").addColumn(
3425
3608
  "password",
3426
3609
  "varchar(255)",
@@ -3428,68 +3611,26 @@ async function Ra(t) {
3428
3611
  (e) => e.notNull()
3429
3612
  ).execute();
3430
3613
  }
3431
- async function Ka(t) {
3432
- await t.schema.alterTable("passwords").dropColumn("password").execute();
3433
- }
3434
- const Ua = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3435
- __proto__: null,
3436
- down: Ka,
3437
- up: Ra
3438
- }, Symbol.toStringTag, { value: "Module" }));
3439
- async function Ba(t) {
3440
- }
3441
- async function Qa(t) {
3442
- }
3443
- const qa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3444
- __proto__: null,
3445
- down: Qa,
3446
- up: Ba
3447
- }, Symbol.toStringTag, { value: "Module" }));
3448
- async function Va(t) {
3449
- }
3450
- async function Wa(t) {
3451
- }
3452
- const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3453
- __proto__: null,
3454
- down: Wa,
3455
- up: Va
3456
- }, Symbol.toStringTag, { value: "Module" }));
3457
- async function Ha(t) {
3458
- }
3459
- async function Ya(t) {
3460
- }
3461
- const Xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3462
- __proto__: null,
3463
- down: Ya,
3464
- up: Ha
3465
- }, Symbol.toStringTag, { value: "Module" }));
3466
- async function Za(t) {
3467
- await t.schema.createIndex("users_email_index").on("users").column("email").execute();
3468
- }
3469
3614
  async function en(t) {
3470
- await t.schema.dropIndex("users_email_index").execute();
3615
+ await t.schema.alterTable("passwords").dropColumn("password").execute();
3471
3616
  }
3472
3617
  const tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3473
3618
  __proto__: null,
3474
3619
  down: en,
3475
- up: Za
3620
+ up: Zr
3476
3621
  }, Symbol.toStringTag, { value: "Module" }));
3477
- async function rn(t) {
3478
- await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3479
- }
3480
3622
  async function an(t) {
3481
- await t.schema.alterTable("users").dropColumn("profileData").execute();
3623
+ }
3624
+ async function rn(t) {
3482
3625
  }
3483
3626
  const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3484
3627
  __proto__: null,
3485
- down: an,
3486
- up: rn
3628
+ down: rn,
3629
+ up: an
3487
3630
  }, Symbol.toStringTag, { value: "Module" }));
3488
3631
  async function on(t) {
3489
- await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3490
3632
  }
3491
3633
  async function sn(t) {
3492
- await t.schema.dropIndex("users_linked_to_index");
3493
3634
  }
3494
3635
  const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3495
3636
  __proto__: null,
@@ -3497,10 +3638,8 @@ const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3497
3638
  up: on
3498
3639
  }, Symbol.toStringTag, { value: "Module" }));
3499
3640
  async function cn(t) {
3500
- await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
3501
3641
  }
3502
3642
  async function dn(t) {
3503
- await t.schema.alterTable("users").dropColumn("locale").execute();
3504
3643
  }
3505
3644
  const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3506
3645
  __proto__: null,
@@ -3508,22 +3647,10 @@ const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3508
3647
  up: cn
3509
3648
  }, Symbol.toStringTag, { value: "Module" }));
3510
3649
  async function mn(t) {
3511
- await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
3512
- "tenant_id",
3513
- "varchar(255)",
3514
- (e) => e.references("tenants.id").onDelete("cascade")
3515
- ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn("cert", "varchar(4096)").addColumn("pkcs7", "varchar(4096)").addColumn("fingerprint", "varchar(256)").addColumn("thumbprint", "varchar(256)").addColumn("current_since", "varchar(256)").addColumn("current_until", "varchar(256)").addColumn(
3516
- "type",
3517
- "varchar(50)",
3518
- (e) => e.notNull().defaultTo("jwt_signing")
3519
- ).addColumn(
3520
- "connection",
3521
- "varchar(255)",
3522
- (e) => e.references("connections.id").onDelete("cascade")
3523
- ).execute();
3650
+ await t.schema.createIndex("users_email_index").on("users").column("email").execute();
3524
3651
  }
3525
3652
  async function _n(t) {
3526
- await t.schema.dropTable("keys").execute();
3653
+ await t.schema.dropIndex("users_email_index").execute();
3527
3654
  }
3528
3655
  const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3529
3656
  __proto__: null,
@@ -3531,8 +3658,10 @@ const hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3531
3658
  up: mn
3532
3659
  }, Symbol.toStringTag, { value: "Module" }));
3533
3660
  async function fn(t) {
3661
+ await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3534
3662
  }
3535
3663
  async function pn(t) {
3664
+ await t.schema.alterTable("users").dropColumn("profileData").execute();
3536
3665
  }
3537
3666
  const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3538
3667
  __proto__: null,
@@ -3540,8 +3669,10 @@ const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3540
3669
  up: fn
3541
3670
  }, Symbol.toStringTag, { value: "Module" }));
3542
3671
  async function wn(t) {
3672
+ await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3543
3673
  }
3544
3674
  async function yn(t) {
3675
+ await t.schema.dropIndex("users_linked_to_index");
3545
3676
  }
3546
3677
  const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3547
3678
  __proto__: null,
@@ -3549,10 +3680,10 @@ const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3549
3680
  up: wn
3550
3681
  }, Symbol.toStringTag, { value: "Module" }));
3551
3682
  async function Nn(t) {
3552
- await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3683
+ await t.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
3553
3684
  }
3554
3685
  async function Cn(t) {
3555
- await t.schema.alterTable("otps").dropColumn("audience").execute();
3686
+ await t.schema.alterTable("users").dropColumn("locale").execute();
3556
3687
  }
3557
3688
  const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3558
3689
  __proto__: null,
@@ -3560,8 +3691,22 @@ const bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3560
3691
  up: Nn
3561
3692
  }, Symbol.toStringTag, { value: "Module" }));
3562
3693
  async function xn(t) {
3694
+ await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
3695
+ "tenant_id",
3696
+ "varchar(255)",
3697
+ (e) => e.references("tenants.id").onDelete("cascade")
3698
+ ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn("cert", "varchar(4096)").addColumn("pkcs7", "varchar(4096)").addColumn("fingerprint", "varchar(256)").addColumn("thumbprint", "varchar(256)").addColumn("current_since", "varchar(256)").addColumn("current_until", "varchar(256)").addColumn(
3699
+ "type",
3700
+ "varchar(50)",
3701
+ (e) => e.notNull().defaultTo("jwt_signing")
3702
+ ).addColumn(
3703
+ "connection",
3704
+ "varchar(255)",
3705
+ (e) => e.references("connections.id").onDelete("cascade")
3706
+ ).execute();
3563
3707
  }
3564
3708
  async function Tn(t) {
3709
+ await t.schema.dropTable("keys").execute();
3565
3710
  }
3566
3711
  const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3567
3712
  __proto__: null,
@@ -3569,10 +3714,8 @@ const Sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3569
3714
  up: xn
3570
3715
  }, Symbol.toStringTag, { value: "Module" }));
3571
3716
  async function On(t) {
3572
- await t.schema.alterTable("logs").dropColumn("category").execute();
3573
3717
  }
3574
3718
  async function kn(t) {
3575
- await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
3576
3719
  }
3577
3720
  const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3578
3721
  __proto__: null,
@@ -3580,10 +3723,8 @@ const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3580
3723
  up: On
3581
3724
  }, Symbol.toStringTag, { value: "Module" }));
3582
3725
  async function In(t) {
3583
- await t.schema.alterTable("users").dropColumn("tags").execute();
3584
3726
  }
3585
3727
  async function Dn(t) {
3586
- await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3587
3728
  }
3588
3729
  const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3589
3730
  __proto__: null,
@@ -3591,75 +3732,74 @@ const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3591
3732
  up: In
3592
3733
  }, Symbol.toStringTag, { value: "Module" }));
3593
3734
  async function jn(t) {
3594
- await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(), await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(), await t.schema.createIndex("logs_date").on("logs").column("date").execute();
3735
+ await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
3595
3736
  }
3596
3737
  async function Fn(t) {
3597
- await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3738
+ await t.schema.alterTable("otps").dropColumn("audience").execute();
3598
3739
  }
3599
- const Mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3740
+ const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3600
3741
  __proto__: null,
3601
3742
  down: Fn,
3602
3743
  up: jn
3603
3744
  }, Symbol.toStringTag, { value: "Module" }));
3604
- async function An(t) {
3605
- await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3745
+ async function Mn(t) {
3606
3746
  }
3607
3747
  async function zn(t) {
3608
- await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3609
3748
  }
3610
- const Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3749
+ const Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3611
3750
  __proto__: null,
3612
3751
  down: zn,
3613
- up: An
3752
+ up: Mn
3614
3753
  }, Symbol.toStringTag, { value: "Module" }));
3615
3754
  async function En(t) {
3616
- await t.schema.alterTable("logs").addColumn("user_name", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("auth0_client", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("isMobile", "boolean").execute(), await t.schema.alterTable("logs").addColumn("connection", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("connection_id", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("audience", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("scope", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy_type", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("hostname", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("session_connection", "varchar(255)").execute();
3755
+ await t.schema.alterTable("logs").dropColumn("category").execute();
3617
3756
  }
3618
- async function Jn(t) {
3619
- await t.schema.alterTable("logs").dropColumn("user_name").execute(), await t.schema.alterTable("logs").dropColumn("auth0_client").execute(), await t.schema.alterTable("logs").dropColumn("isMobile").execute(), await t.schema.alterTable("logs").dropColumn("connection").execute(), await t.schema.alterTable("logs").dropColumn("connection_id").execute(), await t.schema.alterTable("logs").dropColumn("audience").execute(), await t.schema.alterTable("logs").dropColumn("scope").execute(), await t.schema.alterTable("logs").dropColumn("strategy").execute(), await t.schema.alterTable("logs").dropColumn("strategy_type").execute(), await t.schema.alterTable("logs").dropColumn("hostname").execute(), await t.schema.alterTable("logs").dropColumn("session_connection").execute();
3757
+ async function Ln(t) {
3758
+ await t.schema.alterTable("logs").addColumn("category", "varchar(255)", (e) => e.notNull()).execute();
3620
3759
  }
3621
3760
  const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3622
3761
  __proto__: null,
3623
- down: Jn,
3762
+ down: Ln,
3624
3763
  up: En
3625
3764
  }, Symbol.toStringTag, { value: "Module" }));
3626
3765
  async function Kn(t) {
3627
- await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3766
+ await t.schema.alterTable("users").dropColumn("tags").execute();
3628
3767
  }
3629
3768
  async function Un(t) {
3630
- await t.schema.dropIndex("users_name_index").execute();
3769
+ await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
3631
3770
  }
3632
3771
  const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3633
3772
  __proto__: null,
3634
3773
  down: Un,
3635
3774
  up: Kn
3636
3775
  }, Symbol.toStringTag, { value: "Module" }));
3637
- async function Qn(t) {
3638
- }
3639
3776
  async function qn(t) {
3640
- await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3777
+ 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();
3778
+ }
3779
+ async function Qn(t) {
3780
+ await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3641
3781
  }
3642
- const Vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3782
+ const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3643
3783
  __proto__: null,
3644
- down: qn,
3645
- up: Qn
3784
+ down: Qn,
3785
+ up: qn
3646
3786
  }, Symbol.toStringTag, { value: "Module" }));
3647
- async function Wn(t) {
3648
- await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3787
+ async function Vn(t) {
3788
+ await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3649
3789
  }
3650
3790
  async function Gn(t) {
3651
- await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
3791
+ await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3652
3792
  }
3653
3793
  const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3654
3794
  __proto__: null,
3655
3795
  down: Gn,
3656
- up: Wn
3796
+ up: Vn
3657
3797
  }, Symbol.toStringTag, { value: "Module" }));
3658
3798
  async function Yn(t) {
3659
- await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3799
+ 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();
3660
3800
  }
3661
3801
  async function Xn(t) {
3662
- await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3802
+ 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();
3663
3803
  }
3664
3804
  const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3665
3805
  __proto__: null,
@@ -3667,32 +3807,31 @@ const Zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3667
3807
  up: Yn
3668
3808
  }, Symbol.toStringTag, { value: "Module" }));
3669
3809
  async function eo(t) {
3670
- await t.schema.createTable("branding").addColumn(
3671
- "tenant_id",
3672
- "varchar(255)",
3673
- (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3674
- ).addColumn("logo_url", "varchar(512)").addColumn("favicon_url", "varchar(512)").addColumn("font_url", "varchar(512)").addColumn("colors_primary", "varchar(8)").addColumn("colors_page_background_type", "varchar(32)").addColumn("colors_page_background_start", "varchar(8)").addColumn("colors_page_background_end", "varchar(8)").addColumn("colors_page_background_angle_dev", "integer").execute();
3810
+ await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3675
3811
  }
3676
3812
  async function to(t) {
3677
- await t.schema.dropTable("branding").execute();
3813
+ await t.schema.dropIndex("users_name_index").execute();
3678
3814
  }
3679
- const ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3815
+ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3680
3816
  __proto__: null,
3681
3817
  down: to,
3682
3818
  up: eo
3683
3819
  }, Symbol.toStringTag, { value: "Module" }));
3684
- async function ao(t) {
3820
+ async function ro(t) {
3685
3821
  }
3686
3822
  async function no(t) {
3823
+ await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3687
3824
  }
3688
3825
  const oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3689
3826
  __proto__: null,
3690
3827
  down: no,
3691
- up: ao
3828
+ up: ro
3692
3829
  }, Symbol.toStringTag, { value: "Module" }));
3693
3830
  async function so(t) {
3831
+ await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3694
3832
  }
3695
3833
  async function io(t) {
3834
+ await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
3696
3835
  }
3697
3836
  const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3698
3837
  __proto__: null,
@@ -3700,8 +3839,10 @@ const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3700
3839
  up: so
3701
3840
  }, Symbol.toStringTag, { value: "Module" }));
3702
3841
  async function co(t) {
3842
+ await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
3703
3843
  }
3704
3844
  async function uo(t) {
3845
+ await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(1024)").execute();
3705
3846
  }
3706
3847
  const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3707
3848
  __proto__: null,
@@ -3709,8 +3850,14 @@ const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3709
3850
  up: co
3710
3851
  }, Symbol.toStringTag, { value: "Module" }));
3711
3852
  async function _o(t) {
3853
+ await t.schema.createTable("branding").addColumn(
3854
+ "tenant_id",
3855
+ "varchar(255)",
3856
+ (e) => e.references("tenants.id").onDelete("cascade").notNull().primaryKey()
3857
+ ).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();
3712
3858
  }
3713
3859
  async function ho(t) {
3860
+ await t.schema.dropTable("branding").execute();
3714
3861
  }
3715
3862
  const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3716
3863
  __proto__: null,
@@ -3718,18 +3865,8 @@ const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3718
3865
  up: _o
3719
3866
  }, Symbol.toStringTag, { value: "Module" }));
3720
3867
  async function po(t) {
3721
- await t.schema.createTable("authentication_codes").addColumn(
3722
- "tenant_id",
3723
- "varchar(255)",
3724
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3725
- ).addColumn("code", "varchar(255)", (e) => e.primaryKey()).addColumn(
3726
- "client_id",
3727
- "varchar(255)",
3728
- (e) => e.references("applications.id").onDelete("cascade").notNull()
3729
- ).addColumn("user_id", "varchar(255)", (e) => e.notNull()).addColumn("nonce", "varchar(255)").addColumn("state", "varchar(8192)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3730
3868
  }
3731
3869
  async function go(t) {
3732
- await t.schema.dropTable("authentication_codes").execute();
3733
3870
  }
3734
3871
  const wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3735
3872
  __proto__: null,
@@ -3746,10 +3883,8 @@ const No = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3746
3883
  up: yo
3747
3884
  }, Symbol.toStringTag, { value: "Module" }));
3748
3885
  async function Co(t) {
3749
- await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3750
3886
  }
3751
3887
  async function bo(t) {
3752
- await t.schema.alterTable("otps").dropColumn("ip").execute();
3753
3888
  }
3754
3889
  const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3755
3890
  __proto__: null,
@@ -3757,10 +3892,8 @@ const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3757
3892
  up: Co
3758
3893
  }, Symbol.toStringTag, { value: "Module" }));
3759
3894
  async function To(t) {
3760
- await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3761
3895
  }
3762
3896
  async function So(t) {
3763
- await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3764
3897
  }
3765
3898
  const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3766
3899
  __proto__: null,
@@ -3768,8 +3901,18 @@ const Oo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3768
3901
  up: To
3769
3902
  }, Symbol.toStringTag, { value: "Module" }));
3770
3903
  async function ko(t) {
3904
+ await t.schema.createTable("authentication_codes").addColumn(
3905
+ "tenant_id",
3906
+ "varchar(255)",
3907
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
3908
+ ).addColumn("code", "varchar(255)", (e) => e.primaryKey()).addColumn(
3909
+ "client_id",
3910
+ "varchar(255)",
3911
+ (e) => e.references("applications.id").onDelete("cascade").notNull()
3912
+ ).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();
3771
3913
  }
3772
3914
  async function $o(t) {
3915
+ await t.schema.dropTable("authentication_codes").execute();
3773
3916
  }
3774
3917
  const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3775
3918
  __proto__: null,
@@ -3777,18 +3920,8 @@ const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3777
3920
  up: ko
3778
3921
  }, Symbol.toStringTag, { value: "Module" }));
3779
3922
  async function Do(t) {
3780
- await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3781
- "tenant_id",
3782
- "varchar(255)",
3783
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3784
- ).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("trigger_id", "varchar(255)", (e) => e.notNull()).addColumn("enabled", "boolean", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addColumn(
3785
- "synchronous",
3786
- "boolean",
3787
- (e) => e.defaultTo(!1).notNull()
3788
- ).addColumn("priority", "integer").execute();
3789
3923
  }
3790
3924
  async function Po(t) {
3791
- await t.schema.dropTable("hooks").execute();
3792
3925
  }
3793
3926
  const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3794
3927
  __proto__: null,
@@ -3796,79 +3929,67 @@ const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3796
3929
  up: Do
3797
3930
  }, Symbol.toStringTag, { value: "Module" }));
3798
3931
  async function Fo(t) {
3932
+ await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
3799
3933
  }
3800
- async function Mo(t) {
3934
+ async function Ao(t) {
3935
+ await t.schema.alterTable("otps").dropColumn("ip").execute();
3801
3936
  }
3802
- const Ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3937
+ const Mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3803
3938
  __proto__: null,
3804
- down: Mo,
3939
+ down: Ao,
3805
3940
  up: Fo
3806
3941
  }, Symbol.toStringTag, { value: "Module" }));
3807
3942
  async function zo(t) {
3943
+ await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3808
3944
  }
3809
- async function Lo(t) {
3945
+ async function Jo(t) {
3946
+ await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3810
3947
  }
3811
3948
  const Eo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3812
3949
  __proto__: null,
3813
- down: Lo,
3950
+ down: Jo,
3814
3951
  up: zo
3815
3952
  }, Symbol.toStringTag, { value: "Module" }));
3816
- async function Jo(t) {
3817
- await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3818
- "tenant_id",
3819
- "varchar(255)",
3820
- (e) => e.references("tenants.id").onDelete("cascade").notNull()
3821
- ).addColumn("authParams_client_id", "varchar(255)", (e) => e.notNull()).addColumn("authParams_vendor_id", "varchar(255)").addColumn("authParams_username", "varchar(255)").addColumn("authParams_response_type", "varchar(255)").addColumn("authParams_response_mode", "varchar(255)").addColumn("authParams_audience", "varchar(255)").addColumn("authParams_scope", "varchar(511)").addColumn("authParams_state", "varchar(511)").addColumn("authParams_code_challenge_method", "varchar(256)").addColumn("authParams_code_challenge", "varchar(256)").addColumn("authParams_redirect_uri", "varchar(256)").addColumn("authParams_organization", "varchar(256)").addColumn("authorization_url", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("ip", "varchar(255)").addColumn("useragent", "varchar(512)").execute(), await t.schema.alterTable("passwords").addColumn("algorithm", "varchar(16)").execute(), await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3953
+ async function Lo(t) {
3954
+ }
3955
+ async function Ro(t) {
3956
+ }
3957
+ const Ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3958
+ __proto__: null,
3959
+ down: Ro,
3960
+ up: Lo
3961
+ }, Symbol.toStringTag, { value: "Module" }));
3962
+ async function Uo(t) {
3963
+ await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3822
3964
  "tenant_id",
3823
3965
  "varchar(255)",
3824
3966
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3825
- ).addColumn("user_id", "varchar(255)").addColumn("login_id", "varchar(255)").addForeignKeyConstraint(
3826
- "codes_user_id_tenant_id_constraint",
3827
- ["user_id", "tenant_id"],
3828
- "users",
3829
- ["user_id", "tenant_id"],
3830
- (e) => e.onDelete("cascade")
3831
- ).addColumn("code_type", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3832
- }
3833
- async function Ro(t) {
3834
- await t.schema.dropTable("logins").execute(), await t.schema.alterTable("passwords").dropColumn("algorithm").execute(), await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("code", "varchar(255)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addColumn("tenant_id", "varchar(255)").addForeignKeyConstraint(
3835
- "codes_user_id_tenant_id_constraint",
3836
- ["user_id", "tenant_id"],
3837
- "users",
3838
- ["user_id", "tenant_id"],
3839
- (e) => e.onDelete("cascade")
3840
- ).addColumn("type", "varchar(255)", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute();
3841
- }
3842
- const Ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3843
- __proto__: null,
3844
- down: Ro,
3845
- up: Jo
3846
- }, Symbol.toStringTag, { value: "Module" }));
3847
- async function Uo(t) {
3967
+ ).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("trigger_id", "varchar(255)", (e) => e.notNull()).addColumn("enabled", "boolean", (e) => e.notNull()).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addColumn(
3968
+ "synchronous",
3969
+ "boolean",
3970
+ (e) => e.defaultTo(!1).notNull()
3971
+ ).addColumn("priority", "integer").execute();
3848
3972
  }
3849
3973
  async function Bo(t) {
3974
+ await t.schema.dropTable("hooks").execute();
3850
3975
  }
3851
- const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3976
+ const qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3852
3977
  __proto__: null,
3853
3978
  down: Bo,
3854
3979
  up: Uo
3855
3980
  }, Symbol.toStringTag, { value: "Module" }));
3856
- async function qo(t) {
3857
- await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3981
+ async function Qo(t) {
3858
3982
  }
3859
- async function Vo(t) {
3860
- await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3983
+ async function Wo(t) {
3861
3984
  }
3862
- const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3985
+ const Vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3863
3986
  __proto__: null,
3864
- down: Vo,
3865
- up: qo
3987
+ down: Wo,
3988
+ up: Qo
3866
3989
  }, Symbol.toStringTag, { value: "Module" }));
3867
3990
  async function Go(t) {
3868
- await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3869
3991
  }
3870
3992
  async function Ho(t) {
3871
- await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3872
3993
  }
3873
3994
  const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3874
3995
  __proto__: null,
@@ -3876,8 +3997,30 @@ const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3876
3997
  up: Go
3877
3998
  }, Symbol.toStringTag, { value: "Module" }));
3878
3999
  async function Xo(t) {
4000
+ await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
4001
+ "tenant_id",
4002
+ "varchar(255)",
4003
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
4004
+ ).addColumn("authParams_client_id", "varchar(255)", (e) => e.notNull()).addColumn("authParams_vendor_id", "varchar(255)").addColumn("authParams_username", "varchar(255)").addColumn("authParams_response_type", "varchar(255)").addColumn("authParams_response_mode", "varchar(255)").addColumn("authParams_audience", "varchar(255)").addColumn("authParams_scope", "varchar(511)").addColumn("authParams_state", "varchar(511)").addColumn("authParams_code_challenge_method", "varchar(256)").addColumn("authParams_code_challenge", "varchar(256)").addColumn("authParams_redirect_uri", "varchar(256)").addColumn("authParams_organization", "varchar(256)").addColumn("authorization_url", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("ip", "varchar(255)").addColumn("useragent", "varchar(512)").execute(), await t.schema.alterTable("passwords").addColumn("algorithm", "varchar(16)").execute(), await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
4005
+ "tenant_id",
4006
+ "varchar(255)",
4007
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
4008
+ ).addColumn("user_id", "varchar(255)").addColumn("login_id", "varchar(255)").addForeignKeyConstraint(
4009
+ "codes_user_id_tenant_id_constraint",
4010
+ ["user_id", "tenant_id"],
4011
+ "users",
4012
+ ["user_id", "tenant_id"],
4013
+ (e) => e.onDelete("cascade")
4014
+ ).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();
3879
4015
  }
3880
4016
  async function Zo(t) {
4017
+ 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(
4018
+ "codes_user_id_tenant_id_constraint",
4019
+ ["user_id", "tenant_id"],
4020
+ "users",
4021
+ ["user_id", "tenant_id"],
4022
+ (e) => e.onDelete("cascade")
4023
+ ).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();
3881
4024
  }
3882
4025
  const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3883
4026
  __proto__: null,
@@ -3886,18 +4029,18 @@ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3886
4029
  }, Symbol.toStringTag, { value: "Module" }));
3887
4030
  async function ts(t) {
3888
4031
  }
3889
- async function rs(t) {
4032
+ async function as(t) {
3890
4033
  }
3891
- const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4034
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3892
4035
  __proto__: null,
3893
- down: rs,
4036
+ down: as,
3894
4037
  up: ts
3895
4038
  }, Symbol.toStringTag, { value: "Module" }));
3896
4039
  async function ns(t) {
3897
- await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
4040
+ await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3898
4041
  }
3899
4042
  async function os(t) {
3900
- await t.schema.alterTable("logins").dropColumn("nonce").execute();
4043
+ await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3901
4044
  }
3902
4045
  const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3903
4046
  __proto__: null,
@@ -3905,8 +4048,10 @@ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3905
4048
  up: ns
3906
4049
  }, Symbol.toStringTag, { value: "Module" }));
3907
4050
  async function is(t) {
4051
+ await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3908
4052
  }
3909
4053
  async function ls(t) {
4054
+ await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3910
4055
  }
3911
4056
  const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3912
4057
  __proto__: null,
@@ -3923,6 +4068,44 @@ const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3923
4068
  up: ds
3924
4069
  }, Symbol.toStringTag, { value: "Module" }));
3925
4070
  async function _s(t) {
4071
+ }
4072
+ async function hs(t) {
4073
+ }
4074
+ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4075
+ __proto__: null,
4076
+ down: hs,
4077
+ up: _s
4078
+ }, Symbol.toStringTag, { value: "Module" }));
4079
+ async function ps(t) {
4080
+ await t.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
4081
+ }
4082
+ async function gs(t) {
4083
+ await t.schema.alterTable("logins").dropColumn("nonce").execute();
4084
+ }
4085
+ const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4086
+ __proto__: null,
4087
+ down: gs,
4088
+ up: ps
4089
+ }, Symbol.toStringTag, { value: "Module" }));
4090
+ async function ys(t) {
4091
+ }
4092
+ async function vs(t) {
4093
+ }
4094
+ const Ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4095
+ __proto__: null,
4096
+ down: vs,
4097
+ up: ys
4098
+ }, Symbol.toStringTag, { value: "Module" }));
4099
+ async function Cs(t) {
4100
+ }
4101
+ async function bs(t) {
4102
+ }
4103
+ const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4104
+ __proto__: null,
4105
+ down: bs,
4106
+ up: Cs
4107
+ }, Symbol.toStringTag, { value: "Module" }));
4108
+ async function Ts(t) {
3926
4109
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
3927
4110
  "tenant_id",
3928
4111
  "varchar(255)",
@@ -3938,7 +4121,7 @@ async function _s(t) {
3938
4121
  "code_type"
3939
4122
  ]).execute();
3940
4123
  }
3941
- async function hs(t) {
4124
+ async function Ss(t) {
3942
4125
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
3943
4126
  "tenant_id",
3944
4127
  "varchar(255)",
@@ -3951,15 +4134,15 @@ async function hs(t) {
3951
4134
  (e) => e.onDelete("cascade")
3952
4135
  ).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();
3953
4136
  }
3954
- const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4137
+ const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3955
4138
  __proto__: null,
3956
- down: hs,
3957
- up: _s
4139
+ down: Ss,
4140
+ up: Ts
3958
4141
  }, Symbol.toStringTag, { value: "Module" }));
3959
- async function ps(t) {
4142
+ async function ks(t) {
3960
4143
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
3961
4144
  }
3962
- async function gs(t) {
4145
+ async function $s(t) {
3963
4146
  await t.schema.alterTable("keys").addColumn("private_key", "varchar(2048)").addColumn("public_key", "varchar(2048)").execute(), await t.schema.createTable("otps").addColumn(
3964
4147
  "tenant_id",
3965
4148
  "varchar(255)",
@@ -3978,32 +4161,32 @@ async function gs(t) {
3978
4161
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3979
4162
  ).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();
3980
4163
  }
3981
- const ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4164
+ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3982
4165
  __proto__: null,
3983
- down: gs,
3984
- up: ps
4166
+ down: $s,
4167
+ up: ks
3985
4168
  }, Symbol.toStringTag, { value: "Module" }));
3986
- async function ys(t) {
4169
+ async function Ds(t) {
3987
4170
  await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id", "date", "type", "user_id"]).execute();
3988
4171
  }
3989
- async function vs(t) {
4172
+ async function Ps(t) {
3990
4173
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
3991
4174
  }
3992
- const Ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4175
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3993
4176
  __proto__: null,
3994
- down: vs,
3995
- up: ys
4177
+ down: Ps,
4178
+ up: Ds
3996
4179
  }, Symbol.toStringTag, { value: "Module" }));
3997
- async function Cs(t) {
4180
+ async function Fs(t) {
3998
4181
  }
3999
- async function bs(t) {
4182
+ async function As(t) {
4000
4183
  }
4001
- const xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4184
+ const Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4002
4185
  __proto__: null,
4003
- down: bs,
4004
- up: Cs
4186
+ down: As,
4187
+ up: Fs
4005
4188
  }, Symbol.toStringTag, { value: "Module" }));
4006
- async function Ts(t) {
4189
+ async function zs(t) {
4007
4190
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
4008
4191
  "universal_login_experience",
4009
4192
  "varchar(16)",
@@ -4022,95 +4205,95 @@ async function Ts(t) {
4022
4205
  (e) => e.defaultTo(!1).notNull()
4023
4206
  ).execute();
4024
4207
  }
4025
- async function Ss(t) {
4208
+ async function Js(t) {
4026
4209
  await t.schema.dropTable("prompt_settings").execute();
4027
4210
  }
4028
- const Os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4211
+ const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4029
4212
  __proto__: null,
4030
- down: Ss,
4031
- up: Ts
4213
+ down: Js,
4214
+ up: zs
4032
4215
  }, Symbol.toStringTag, { value: "Module" }));
4033
- async function ks(t) {
4216
+ async function Ls(t) {
4034
4217
  }
4035
- async function $s(t) {
4218
+ async function Rs(t) {
4036
4219
  }
4037
- const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4220
+ const Ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4038
4221
  __proto__: null,
4039
- down: $s,
4040
- up: ks
4222
+ down: Rs,
4223
+ up: Ls
4041
4224
  }, Symbol.toStringTag, { value: "Module" }));
4042
- async function Ds(t) {
4225
+ async function Us(t) {
4043
4226
  }
4044
- async function Ps(t) {
4227
+ async function Bs(t) {
4045
4228
  }
4046
- const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4229
+ const qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4047
4230
  __proto__: null,
4048
- down: Ps,
4049
- up: Ds
4231
+ down: Bs,
4232
+ up: Us
4050
4233
  }, Symbol.toStringTag, { value: "Module" }));
4051
- async function Fs(t) {
4234
+ async function Qs(t) {
4052
4235
  }
4053
- async function Ms(t) {
4236
+ async function Ws(t) {
4054
4237
  }
4055
- const As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4238
+ const Vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4056
4239
  __proto__: null,
4057
- down: Ms,
4058
- up: Fs
4240
+ down: Ws,
4241
+ up: Qs
4059
4242
  }, Symbol.toStringTag, { value: "Module" }));
4060
- async function zs(t) {
4243
+ async function Gs(t) {
4061
4244
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
4062
4245
  }
4063
- async function Ls(t) {
4246
+ async function Hs(t) {
4064
4247
  await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
4065
4248
  }
4066
- const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4249
+ const Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4067
4250
  __proto__: null,
4068
- down: Ls,
4069
- up: zs
4251
+ down: Hs,
4252
+ up: Gs
4070
4253
  }, Symbol.toStringTag, { value: "Module" }));
4071
- async function Js(t) {
4254
+ async function Xs(t) {
4072
4255
  await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
4073
4256
  }
4074
- async function Rs(t) {
4257
+ async function Zs(t) {
4075
4258
  await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
4076
4259
  }
4077
- const Ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4260
+ const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4078
4261
  __proto__: null,
4079
- down: Rs,
4080
- up: Js
4262
+ down: Zs,
4263
+ up: Xs
4081
4264
  }, Symbol.toStringTag, { value: "Module" }));
4082
- async function Us(t) {
4265
+ async function ti(t) {
4083
4266
  }
4084
- async function Bs(t) {
4267
+ async function ai(t) {
4085
4268
  }
4086
- const Qs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4269
+ const ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4087
4270
  __proto__: null,
4088
- down: Bs,
4089
- up: Us
4271
+ down: ai,
4272
+ up: ti
4090
4273
  }, Symbol.toStringTag, { value: "Module" }));
4091
- async function qs(t) {
4274
+ async function ni(t) {
4092
4275
  await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
4093
4276
  }
4094
- async function Vs(t) {
4277
+ async function oi(t) {
4095
4278
  await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
4096
4279
  }
4097
- const Ws = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4280
+ const si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4098
4281
  __proto__: null,
4099
- down: Vs,
4100
- up: qs
4282
+ down: oi,
4283
+ up: ni
4101
4284
  }, Symbol.toStringTag, { value: "Module" }));
4102
- async function Gs(t) {
4285
+ async function ii(t) {
4103
4286
  await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
4104
4287
  }
4105
- async function Hs(t) {
4288
+ async function li(t) {
4106
4289
  await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
4107
4290
  }
4108
- const Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4291
+ const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4109
4292
  __proto__: null,
4110
- down: Hs,
4111
- up: Gs
4293
+ down: li,
4294
+ up: ii
4112
4295
  }, Symbol.toStringTag, { value: "Module" }));
4113
- async function Xs(t) {
4296
+ async function di(t) {
4114
4297
  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(
4115
4298
  "credentials",
4116
4299
  "varchar(2048)",
@@ -4121,18 +4304,18 @@ async function Xs(t) {
4121
4304
  (e) => e.notNull().defaultTo("{}")
4122
4305
  ).addColumn("created_at", "varchar(29)", (e) => e.notNull()).addColumn("updated_at", "varchar(29)", (e) => e.notNull()).execute();
4123
4306
  }
4124
- async function Zs(t) {
4307
+ async function ui(t) {
4125
4308
  await t.schema.dropTable("email_providers").execute();
4126
4309
  }
4127
- const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4310
+ const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4128
4311
  __proto__: null,
4129
- down: Zs,
4130
- up: Xs
4312
+ down: ui,
4313
+ up: di
4131
4314
  }, Symbol.toStringTag, { value: "Module" }));
4132
- async function ti(t) {
4315
+ async function _i(t) {
4133
4316
  await t.schema.dropTable("tickets").execute();
4134
4317
  }
4135
- async function ri(t) {
4318
+ async function hi(t) {
4136
4319
  await t.schema.createTable("tickets").addColumn(
4137
4320
  "tenant_id",
4138
4321
  "varchar(255)",
@@ -4143,22 +4326,22 @@ async function ri(t) {
4143
4326
  (e) => e.references("applications.id").onDelete("cascade").notNull()
4144
4327
  ).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();
4145
4328
  }
4146
- const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4329
+ const fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4147
4330
  __proto__: null,
4148
- down: ri,
4149
- up: ti
4331
+ down: hi,
4332
+ up: _i
4150
4333
  }, Symbol.toStringTag, { value: "Module" }));
4151
- async function ni(t) {
4334
+ async function pi(t) {
4152
4335
  }
4153
- async function oi(t) {
4336
+ async function gi(t) {
4154
4337
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
4155
4338
  }
4156
- const si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4339
+ const wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4157
4340
  __proto__: null,
4158
- down: oi,
4159
- up: ni
4341
+ down: gi,
4342
+ up: pi
4160
4343
  }, Symbol.toStringTag, { value: "Module" }));
4161
- async function ii(t) {
4344
+ async function yi(t) {
4162
4345
  await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
4163
4346
  "client_id",
4164
4347
  "varchar(21)",
@@ -4171,27 +4354,27 @@ async function ii(t) {
4171
4354
  (e) => e.onDelete("cascade")
4172
4355
  ).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();
4173
4356
  }
4174
- async function li(t) {
4357
+ async function vi(t) {
4175
4358
  await t.schema.dropTable("refresh_tokens").execute();
4176
4359
  }
4177
- const ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4360
+ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4178
4361
  __proto__: null,
4179
- down: li,
4180
- up: ii
4362
+ down: vi,
4363
+ up: yi
4181
4364
  }, Symbol.toStringTag, { value: "Module" }));
4182
- async function di(t) {
4365
+ async function Ci(t) {
4183
4366
  }
4184
- async function ui(t) {
4367
+ async function bi(t) {
4185
4368
  }
4186
- const mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4369
+ const xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4187
4370
  __proto__: null,
4188
- down: ui,
4189
- up: di
4371
+ down: bi,
4372
+ up: Ci
4190
4373
  }, Symbol.toStringTag, { value: "Module" }));
4191
- async function _i(t) {
4374
+ async function Ti(t) {
4192
4375
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
4193
4376
  }
4194
- async function hi(t) {
4377
+ async function Si(t) {
4195
4378
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4196
4379
  "sessions_user_id_constraint",
4197
4380
  ["user_id", "tenant_id"],
@@ -4210,12 +4393,12 @@ async function hi(t) {
4210
4393
  (e) => e.onDelete("cascade")
4211
4394
  ).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();
4212
4395
  }
4213
- const fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4396
+ const Oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4214
4397
  __proto__: null,
4215
- down: hi,
4216
- up: _i
4398
+ down: Si,
4399
+ up: Ti
4217
4400
  }, Symbol.toStringTag, { value: "Module" }));
4218
- async function pi(t) {
4401
+ async function ki(t) {
4219
4402
  await t.schema.createTable("sessions_2").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4220
4403
  "sessions_2_user_id_constraint",
4221
4404
  ["user_id", "tenant_id"],
@@ -4234,15 +4417,15 @@ async function pi(t) {
4234
4417
  (e) => e.onDelete("cascade")
4235
4418
  ).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();
4236
4419
  }
4237
- async function gi(t) {
4420
+ async function $i(t) {
4238
4421
  await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4239
4422
  }
4240
- const wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4423
+ const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4241
4424
  __proto__: null,
4242
- down: gi,
4243
- up: pi
4425
+ down: $i,
4426
+ up: ki
4244
4427
  }, Symbol.toStringTag, { value: "Module" }));
4245
- async function yi(t) {
4428
+ async function Di(t) {
4246
4429
  await t.schema.createTable("custom_domains").addColumn(
4247
4430
  "custom_domain_id",
4248
4431
  "varchar(21)",
@@ -4253,49 +4436,49 @@ async function yi(t) {
4253
4436
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4254
4437
  ).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();
4255
4438
  }
4256
- async function vi(t) {
4439
+ async function Pi(t) {
4257
4440
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("domains").addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
4258
4441
  "tenant_id",
4259
4442
  "varchar(255)",
4260
4443
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4261
4444
  ).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();
4262
4445
  }
4263
- const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4446
+ const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4264
4447
  __proto__: null,
4265
- down: vi,
4266
- up: yi
4448
+ down: Pi,
4449
+ up: Di
4267
4450
  }, Symbol.toStringTag, { value: "Module" }));
4268
- async function Ci(t) {
4451
+ async function Fi(t) {
4269
4452
  }
4270
- async function bi(t) {
4453
+ async function Ai(t) {
4271
4454
  await t.schema.alterTable("logins").dropColumn("authParams_organization").dropColumn("authorization_url").execute();
4272
4455
  }
4273
- const xi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4456
+ const Mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4274
4457
  __proto__: null,
4275
- down: bi,
4276
- up: Ci
4458
+ down: Ai,
4459
+ up: Fi
4277
4460
  }, Symbol.toStringTag, { value: "Module" }));
4278
- async function Ti(t) {
4461
+ async function zi(t) {
4279
4462
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(2048)").execute();
4280
4463
  }
4281
- async function Si(t) {
4464
+ async function Ji(t) {
4282
4465
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(1024)").execute();
4283
4466
  }
4284
- const Oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4467
+ const Ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4285
4468
  __proto__: null,
4286
- down: Si,
4287
- up: Ti
4469
+ down: Ji,
4470
+ up: zi
4288
4471
  }, Symbol.toStringTag, { value: "Module" }));
4289
- async function ki(t) {
4472
+ async function Li(t) {
4290
4473
  }
4291
- async function $i(t) {
4474
+ async function Ri(t) {
4292
4475
  }
4293
- const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4476
+ const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4294
4477
  __proto__: null,
4295
- down: $i,
4296
- up: ki
4478
+ down: Ri,
4479
+ up: Li
4297
4480
  }, Symbol.toStringTag, { value: "Module" }));
4298
- async function Di(t) {
4481
+ async function Ui(t) {
4299
4482
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
4300
4483
  "sessions_user_id_constraint",
4301
4484
  ["user_id", "tenant_id"],
@@ -4322,25 +4505,25 @@ async function Di(t) {
4322
4505
  (e) => e.onDelete("cascade")
4323
4506
  ).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();
4324
4507
  }
4325
- async function Pi(t) {
4508
+ async function Bi(t) {
4326
4509
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
4327
4510
  }
4328
- const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4511
+ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4329
4512
  __proto__: null,
4330
- down: Pi,
4331
- up: Di
4513
+ down: Bi,
4514
+ up: Ui
4332
4515
  }, Symbol.toStringTag, { value: "Module" }));
4333
- async function Fi(t) {
4516
+ async function Qi(t) {
4334
4517
  await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4335
4518
  }
4336
- async function Mi(t) {
4519
+ async function Wi(t) {
4337
4520
  }
4338
- const Ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4521
+ const Vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4339
4522
  __proto__: null,
4340
- down: Mi,
4341
- up: Fi
4523
+ down: Wi,
4524
+ up: Qi
4342
4525
  }, Symbol.toStringTag, { value: "Module" }));
4343
- async function zi(t) {
4526
+ async function Gi(t) {
4344
4527
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
4345
4528
  "custom_domain_id",
4346
4529
  "varchar(256)",
@@ -4351,120 +4534,120 @@ async function zi(t) {
4351
4534
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
4352
4535
  ).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();
4353
4536
  }
4354
- async function Li(t) {
4537
+ async function Hi(t) {
4355
4538
  }
4356
- const Ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4539
+ const Yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4357
4540
  __proto__: null,
4358
- down: Li,
4359
- up: zi
4541
+ down: Hi,
4542
+ up: Gi
4360
4543
  }, Symbol.toStringTag, { value: "Module" }));
4361
- async function Ji(t) {
4544
+ async function Xi(t) {
4362
4545
  }
4363
- async function Ri(t) {
4546
+ async function Zi(t) {
4364
4547
  await t.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
4365
4548
  }
4366
- const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4549
+ const el = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4367
4550
  __proto__: null,
4368
- down: Ri,
4369
- up: Ji
4551
+ down: Zi,
4552
+ up: Xi
4370
4553
  }, Symbol.toStringTag, { value: "Module" }));
4371
- async function Ui(t) {
4554
+ async function tl(t) {
4372
4555
  await t.schema.createTable("forms").addColumn("id", "varchar(255)", (e) => e.primaryKey()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("tenant_id", "varchar(255)", (e) => e.notNull()).addColumn("messages", "varchar(255)").addColumn("languages", "varchar(255)").addColumn("translations", "varchar(4096)").addColumn("nodes", "varchar(4096)").addColumn("start", "varchar(255)").addColumn("ending", "varchar(255)").addColumn("style", "varchar(1042)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("updated_at", "varchar(255)", (e) => e.notNull()).execute(), await t.schema.createIndex("forms_tenant_id_idx").on("forms").column("tenant_id").execute();
4373
4556
  }
4374
- async function Bi(t) {
4557
+ async function al(t) {
4375
4558
  await t.schema.dropTable("forms").execute();
4376
4559
  }
4377
- const Qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4560
+ const rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4378
4561
  __proto__: null,
4379
- down: Bi,
4380
- up: Ui
4562
+ down: al,
4563
+ up: tl
4381
4564
  }, Symbol.toStringTag, { value: "Module" }));
4382
- async function qi(t) {
4565
+ async function nl(t) {
4383
4566
  await t.schema.alterTable("hooks").addColumn("form_id", "text").execute(), await t.schema.alterTable("hooks").addColumn("url_tmp", "varchar(512)").execute(), await t.updateTable("hooks").set((e) => ({ url_tmp: e.ref("url") })).execute(), await t.schema.alterTable("hooks").dropColumn("url").execute(), await t.schema.alterTable("hooks").renameColumn("url_tmp", "url").execute();
4384
4567
  }
4385
- async function Vi(t) {
4568
+ async function ol(t) {
4386
4569
  await t.schema.dropTable("hooks").ifExists().execute(), await t.schema.createTable("hooks").addColumn("hook_id", "text", (e) => e.primaryKey()).addColumn("tenant_id", "text", (e) => e.notNull()).addColumn("trigger_id", "text", (e) => e.notNull()).addColumn("enabled", "integer", (e) => e.notNull().defaultTo(0)).addColumn("url", "varchar(512)", (e) => e.notNull()).addColumn("synchronous", "integer", (e) => e.notNull().defaultTo(0)).addColumn("priority", "integer").addColumn("created_at", "text", (e) => e.notNull()).addColumn("updated_at", "text", (e) => e.notNull()).execute();
4387
4570
  }
4388
- const Wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4571
+ const sl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4389
4572
  __proto__: null,
4390
- down: Vi,
4391
- up: qi
4573
+ down: ol,
4574
+ up: nl
4392
4575
  }, Symbol.toStringTag, { value: "Module" }));
4393
- async function Gi(t) {
4576
+ async function il(t) {
4394
4577
  await t.schema.alterTable("login_sessions").addColumn(
4395
4578
  "login_completed",
4396
4579
  "boolean",
4397
4580
  (e) => e.notNull().defaultTo(0)
4398
4581
  ).execute();
4399
4582
  }
4400
- async function Hi(t) {
4583
+ async function ll(t) {
4401
4584
  await t.schema.alterTable("login_sessions").dropColumn("login_completed").execute();
4402
4585
  }
4403
- const Yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4586
+ const cl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4404
4587
  __proto__: null,
4405
- down: Hi,
4406
- up: Gi
4588
+ down: ll,
4589
+ up: il
4407
4590
  }, Symbol.toStringTag, { value: "Module" }));
4408
- async function Xi(t) {
4591
+ async function dl(t) {
4409
4592
  await t.schema.alterTable("sessions").addColumn(
4410
4593
  "login_session_id",
4411
4594
  "varchar(21)",
4412
4595
  (e) => e.references("login_sessions.id").onDelete("set null")
4413
4596
  ).execute();
4414
4597
  }
4415
- async function Zi(t) {
4598
+ async function ul(t) {
4416
4599
  await t.schema.alterTable("sessions").dropColumn("login_session_id").execute();
4417
4600
  }
4418
- const el = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4601
+ const ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4419
4602
  __proto__: null,
4420
- down: Zi,
4421
- up: Xi
4603
+ down: ul,
4604
+ up: dl
4422
4605
  }, Symbol.toStringTag, { value: "Module" }));
4423
- async function tl(t) {
4606
+ async function _l(t) {
4424
4607
  await t.schema.createIndex("IDX_sessions_login_session_id").on("sessions").column("login_session_id").execute();
4425
4608
  }
4426
- async function rl(t) {
4609
+ async function hl(t) {
4427
4610
  await t.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
4428
4611
  }
4429
- const al = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4612
+ const fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4430
4613
  __proto__: null,
4431
- down: rl,
4432
- up: tl
4614
+ down: hl,
4615
+ up: _l
4433
4616
  }, Symbol.toStringTag, { value: "Module" }));
4434
- async function nl(t) {
4617
+ async function pl(t) {
4435
4618
  await t.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await t.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
4436
4619
  }
4437
- async function ol(t) {
4620
+ async function gl(t) {
4438
4621
  await t.schema.alterTable("codes").dropColumn("code_challenge").execute(), await t.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
4439
4622
  }
4440
- const sl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4623
+ const wl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4441
4624
  __proto__: null,
4442
- down: ol,
4443
- up: nl
4625
+ down: gl,
4626
+ up: pl
4444
4627
  }, Symbol.toStringTag, { value: "Module" }));
4445
- async function il(t) {
4628
+ async function yl(t) {
4446
4629
  await t.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
4447
4630
  }
4448
- async function ll(t) {
4631
+ async function vl(t) {
4449
4632
  await t.schema.alterTable("codes").dropColumn("redirect_uri").execute();
4450
4633
  }
4451
- const cl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4634
+ const Nl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4452
4635
  __proto__: null,
4453
- down: ll,
4454
- up: il
4636
+ down: vl,
4637
+ up: yl
4455
4638
  }, Symbol.toStringTag, { value: "Module" }));
4456
- async function dl(t) {
4639
+ async function Cl(t) {
4457
4640
  await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
4458
4641
  }
4459
- async function ul(t) {
4642
+ async function bl(t) {
4460
4643
  await t.schema.alterTable("codes").dropColumn("nonce").execute(), await t.schema.alterTable("codes").dropColumn("state").execute();
4461
4644
  }
4462
- const ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4645
+ const xl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4463
4646
  __proto__: null,
4464
- down: ul,
4465
- up: dl
4647
+ down: bl,
4648
+ up: Cl
4466
4649
  }, Symbol.toStringTag, { value: "Module" }));
4467
- async function _l(t) {
4650
+ async function Tl(t) {
4468
4651
  await t.schema.createTable("themes").addColumn(
4469
4652
  "tenant_id",
4470
4653
  "varchar(255)",
@@ -4539,26 +4722,26 @@ async function _l(t) {
4539
4722
  (e) => e.notNull()
4540
4723
  ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("themes_pkey", ["tenant_id", "themeId"]).execute(), await t.schema.createIndex("themes_tenant_id_idx").on("themes").column("tenant_id").execute();
4541
4724
  }
4542
- async function hl(t) {
4725
+ async function Sl(t) {
4543
4726
  await t.schema.dropTable("themes").execute();
4544
4727
  }
4545
- const fl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4728
+ const Ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4546
4729
  __proto__: null,
4547
- down: hl,
4548
- up: _l
4730
+ down: Sl,
4731
+ up: Tl
4549
4732
  }, Symbol.toStringTag, { value: "Module" }));
4550
- async function pl(t) {
4733
+ async function kl(t) {
4551
4734
  await t.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("identifier", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("scopes", "varchar(4096)").addColumn("signing_alg", "varchar(64)").addColumn("signing_secret", "varchar(2048)").addColumn("token_lifetime", "integer").addColumn("token_lifetime_for_web", "integer").addColumn("skip_consent_for_verifiable_first_party_clients", "integer").addColumn("allow_offline_access", "integer").addColumn("verification_key", "varchar(4096)").addColumn("options", "varchar(4096)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("resource_servers_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await t.schema.createTable("roles").addColumn("id", "varchar(21)", (e) => e.notNull()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(50)", (e) => e.notNull()).addColumn("description", "varchar(255)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("roles_pk", ["tenant_id", "id"]).execute(), await t.schema.createIndex("roles_tenant_name_uq").on("roles").columns(["tenant_id", "name"]).unique().execute();
4552
4735
  }
4553
- async function gl(t) {
4736
+ async function $l(t) {
4554
4737
  await t.schema.dropTable("roles").execute(), await t.schema.dropTable("resource_servers").execute();
4555
4738
  }
4556
- const wl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4739
+ const Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4557
4740
  __proto__: null,
4558
- down: gl,
4559
- up: pl
4741
+ down: $l,
4742
+ up: kl
4560
4743
  }, Symbol.toStringTag, { value: "Module" }));
4561
- async function yl(t) {
4744
+ async function Dl(t) {
4562
4745
  await t.schema.createTable("role_permissions").addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("role_id", "varchar(21)", (e) => e.notNull()).addColumn(
4563
4746
  "resource_server_identifier",
4564
4747
  "varchar(191)",
@@ -4579,139 +4762,151 @@ async function yl(t) {
4579
4762
  "permission_name"
4580
4763
  ]).execute(), await t.schema.createIndex("user_permissions_user_fk").on("user_permissions").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("user_permissions_permission_fk").on("user_permissions").columns(["tenant_id", "resource_server_identifier", "permission_name"]).execute();
4581
4764
  }
4582
- async function vl(t) {
4765
+ async function Pl(t) {
4583
4766
  await t.schema.dropTable("user_permissions").execute(), await t.schema.dropTable("role_permissions").execute();
4584
4767
  }
4585
- const Nl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4768
+ const jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4586
4769
  __proto__: null,
4587
- down: vl,
4588
- up: yl
4770
+ down: Pl,
4771
+ up: Dl
4589
4772
  }, Symbol.toStringTag, { value: "Module" }));
4590
- async function Cl(t) {
4773
+ async function Fl(t) {
4591
4774
  await t.schema.createTable("user_roles").addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("user_id", "varchar(191)", (e) => e.notNull()).addColumn("role_id", "varchar(21)", (e) => e.notNull()).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("user_roles_pk", [
4592
4775
  "tenant_id",
4593
4776
  "user_id",
4594
4777
  "role_id"
4595
4778
  ]).execute(), await t.schema.createIndex("user_roles_user_fk").on("user_roles").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("user_roles_role_fk").on("user_roles").columns(["tenant_id", "role_id"]).execute();
4596
4779
  }
4597
- async function bl(t) {
4780
+ async function Al(t) {
4598
4781
  await t.schema.dropTable("user_roles").execute();
4599
4782
  }
4600
- const xl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4783
+ const Ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4601
4784
  __proto__: null,
4602
- down: bl,
4603
- up: Cl
4785
+ down: Al,
4786
+ up: Fl
4604
4787
  }, Symbol.toStringTag, { value: "Module" }));
4605
- async function Tl(t) {
4788
+ async function zl(t) {
4606
4789
  }
4607
- async function Sl(t) {
4790
+ async function Jl(t) {
4608
4791
  await t.schema.alterTable("keys").dropColumn("connection").execute(), await t.schema.alterTable("keys").modifyColumn("cert", "varchar(2048)").execute(), await t.schema.alterTable("keys").modifyColumn("pkcs7", "varchar(2048)").execute(), await t.schema.alterTable("keys").dropColumn("type").execute();
4609
4792
  }
4610
- const Ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4793
+ const El = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4611
4794
  __proto__: null,
4612
- down: Sl,
4613
- up: Tl
4795
+ down: Jl,
4796
+ up: zl
4797
+ }, Symbol.toStringTag, { value: "Module" }));
4798
+ async function Ll(t) {
4799
+ await t.schema.createTable("organizations").addColumn("id", "varchar(256)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(256)", (e) => e.notNull()).addColumn("name", "varchar(256)", (e) => e.notNull()).addColumn("display_name", "varchar(256)").addColumn("branding", "text").addColumn("metadata", "text").addColumn("enabled_connections", "text").addColumn("token_quota", "text").addColumn("created_at", "varchar(256)", (e) => e.notNull()).addColumn("updated_at", "varchar(256)", (e) => e.notNull()).execute(), await t.schema.createIndex("idx_organizations_tenant_id").on("organizations").column("tenant_id").execute(), await t.schema.createIndex("idx_organizations_tenant_name_unique").on("organizations").columns(["tenant_id", "name"]).unique().execute();
4800
+ }
4801
+ async function Rl(t) {
4802
+ await t.schema.dropTable("organizations").execute();
4803
+ }
4804
+ const Kl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4805
+ __proto__: null,
4806
+ down: Rl,
4807
+ up: Ll
4614
4808
  }, Symbol.toStringTag, { value: "Module" })), Ee = {
4615
- m1_init: ya,
4616
- m2_magicLink: Ca,
4617
- m3_updateAt: Ta,
4618
- m4_logTable: ka,
4619
- m5_userProfile: Da,
4620
- m6_sessions: Fa,
4621
- m7_passwords: za,
4622
- m8_logsTableNewFields: Ja,
4623
- m9_passwordTableNewField: Ua,
4624
- n01_codesTable: qa,
4625
- n11_universalLoginSession: Ga,
4626
- n12_userFields: Xa,
4627
- n13_userEmailIndex: tn,
4628
- n14_profileDataField: nn,
4629
- n15_userEmailIndex: ln,
4630
- n16_userLocale: un,
4631
- n17_signingKeys: hn,
4632
- n18_logsFields: gn,
4633
- n19_connectionsUserinfo: vn,
4634
- n20_missingFields: bn,
4635
- n21_sessionDeletedAt: Sn,
4636
- n22_dropLogsFields: $n,
4637
- n23_dropUsersFields: Pn,
4638
- n24_logsIndexes: Mn,
4639
- n25_logDescMaxLength: Ln,
4640
- n26_logsTableExtraFields: Rn,
4641
- n27_usersTableNameIndex: Bn,
4642
- n28_usersEmailConstrain: Vn,
4643
- n29_increaseOtpStateLength: Hn,
4644
- n30_increaseTicketStateLength: Zn,
4645
- n31_branding: ro,
4646
- n32_indexesAndNotNull: oo,
4647
- n33_vendorIdInUniversalLoginSession: lo,
4648
- n34_auth0ClientInUniversalLoginSession: mo,
4649
- n35_increaseUniversalSessionStateLength: fo,
4650
- n36_authenticationCodes: wo,
4651
- n37_disableSignUps: No,
4652
- n38_otpIpAddress: xo,
4653
- n39_increaseUserAgentLength: Oo,
4654
- n40_userId: Io,
4655
- n41_hooks: jo,
4656
- n42_userIdIndexes: Ao,
4657
- n43_userIdIndexes: Eo,
4658
- n44_codes: Ko,
4659
- n45_hookProperties: Qo,
4660
- n46_loginAuth0Client: Wo,
4661
- n47_loginAuth0Client: Yo,
4662
- n48_saml: es,
4663
- n49_removeFields: as,
4664
- n50_authParamsNonce: ss,
4665
- n51_connectionid: cs,
4666
- n52_cert: ms,
4667
- n53_codes_primary_key: fs,
4668
- n54_cleanup_tables: ws,
4669
- n55_logs_index: Ns,
4670
- n56_application_fields: xs,
4671
- n57_prompt_settings: Os,
4672
- n58_connection_client_id: Is,
4673
- n59_connection_options: js,
4674
- n60_users_metadata: As,
4675
- n61_userLocales: Es,
4676
- n62_prompt: Ks,
4677
- n63_connection_cleanup: Qs,
4678
- n64_act_as: Ws,
4679
- n65_code_verifier: Ys,
4680
- n66_email_providers: ei,
4681
- n67_drop_tickets: ai,
4682
- n68_login_useragents: si,
4683
- n70_refresh_tokens: ci,
4684
- n71_session_new_fields: mi,
4685
- n72_session_primary_key: fi,
4686
- n73_drop_sessions: wi,
4687
- n74_custom_domains: Ni,
4688
- n75_organizations: xi,
4689
- n76_authorization_url_length: Oi,
4690
- n77_drop_sessions: Ii,
4691
- n78_login_sessions: ji,
4692
- n79_drop_sessions_2: Ai,
4693
- n80_recreate_custom_domains: Ei,
4694
- n81_phone: Ki,
4695
- n82_forms: Qi,
4696
- n83_addFormsIdToHooks: Wi,
4697
- n84_login_completed: Yi,
4698
- n85_add_login_session_id_to_sessions: el,
4699
- n86_index_sessions_login_session_id: al,
4700
- n87_code_challenge: sl,
4701
- n88_add_redirect_uri_to_codes: cl,
4702
- n89_add_nonce_and_state_to_codes: ml,
4703
- n90_themes: fl,
4704
- n91_resource_servers_rules_permissions: wl,
4705
- n92_role_permissions: Nl,
4706
- n93_add_permissions_to_roles: xl,
4707
- n94_keys_connection_and_extend_columns: Ol
4809
+ m1_init: Dr,
4810
+ m2_magicLink: Fr,
4811
+ m3_updateAt: zr,
4812
+ m4_logTable: Lr,
4813
+ m5_userProfile: Ur,
4814
+ m6_sessions: Qr,
4815
+ m7_passwords: Gr,
4816
+ m8_logsTableNewFields: Xr,
4817
+ m9_passwordTableNewField: tn,
4818
+ n01_codesTable: nn,
4819
+ n11_universalLoginSession: ln,
4820
+ n12_userFields: un,
4821
+ n13_userEmailIndex: hn,
4822
+ n14_profileDataField: gn,
4823
+ n15_userEmailIndex: vn,
4824
+ n16_userLocale: bn,
4825
+ n17_signingKeys: Sn,
4826
+ n18_logsFields: $n,
4827
+ n19_connectionsUserinfo: Pn,
4828
+ n20_missingFields: An,
4829
+ n21_sessionDeletedAt: Jn,
4830
+ n22_dropLogsFields: Rn,
4831
+ n23_dropUsersFields: Bn,
4832
+ n24_logsIndexes: Wn,
4833
+ n25_logDescMaxLength: Hn,
4834
+ n26_logsTableExtraFields: Zn,
4835
+ n27_usersTableNameIndex: ao,
4836
+ n28_usersEmailConstrain: oo,
4837
+ n29_increaseOtpStateLength: lo,
4838
+ n30_increaseTicketStateLength: mo,
4839
+ n31_branding: fo,
4840
+ n32_indexesAndNotNull: wo,
4841
+ n33_vendorIdInUniversalLoginSession: No,
4842
+ n34_auth0ClientInUniversalLoginSession: xo,
4843
+ n35_increaseUniversalSessionStateLength: Oo,
4844
+ n36_authenticationCodes: Io,
4845
+ n37_disableSignUps: jo,
4846
+ n38_otpIpAddress: Mo,
4847
+ n39_increaseUserAgentLength: Eo,
4848
+ n40_userId: Ko,
4849
+ n41_hooks: qo,
4850
+ n42_userIdIndexes: Vo,
4851
+ n43_userIdIndexes: Yo,
4852
+ n44_codes: es,
4853
+ n45_hookProperties: rs,
4854
+ n46_loginAuth0Client: ss,
4855
+ n47_loginAuth0Client: cs,
4856
+ n48_saml: ms,
4857
+ n49_removeFields: fs,
4858
+ n50_authParamsNonce: ws,
4859
+ n51_connectionid: Ns,
4860
+ n52_cert: xs,
4861
+ n53_codes_primary_key: Os,
4862
+ n54_cleanup_tables: Is,
4863
+ n55_logs_index: js,
4864
+ n56_application_fields: Ms,
4865
+ n57_prompt_settings: Es,
4866
+ n58_connection_client_id: Ks,
4867
+ n59_connection_options: qs,
4868
+ n60_users_metadata: Vs,
4869
+ n61_userLocales: Ys,
4870
+ n62_prompt: ei,
4871
+ n63_connection_cleanup: ri,
4872
+ n64_act_as: si,
4873
+ n65_code_verifier: ci,
4874
+ n66_email_providers: mi,
4875
+ n67_drop_tickets: fi,
4876
+ n68_login_useragents: wi,
4877
+ n70_refresh_tokens: Ni,
4878
+ n71_session_new_fields: xi,
4879
+ n72_session_primary_key: Oi,
4880
+ n73_drop_sessions: Ii,
4881
+ n74_custom_domains: ji,
4882
+ n75_organizations: Mi,
4883
+ n76_authorization_url_length: Ei,
4884
+ n77_drop_sessions: Ki,
4885
+ n78_login_sessions: qi,
4886
+ n79_drop_sessions_2: Vi,
4887
+ n80_recreate_custom_domains: Yi,
4888
+ n81_phone: el,
4889
+ n82_forms: rl,
4890
+ n83_addFormsIdToHooks: sl,
4891
+ n84_login_completed: cl,
4892
+ n85_add_login_session_id_to_sessions: ml,
4893
+ n86_index_sessions_login_session_id: fl,
4894
+ n87_code_challenge: wl,
4895
+ n88_add_redirect_uri_to_codes: Nl,
4896
+ n89_add_nonce_and_state_to_codes: xl,
4897
+ n90_themes: Ol,
4898
+ n91_resource_servers_rules_permissions: Il,
4899
+ n92_role_permissions: jl,
4900
+ n93_add_permissions_to_roles: Ml,
4901
+ n94_keys_connection_and_extend_columns: El,
4902
+ n95_create_organizations_table: Kl
4708
4903
  };
4709
- async function Pl(t, e = !1) {
4904
+ async function Wl(t, e = !1) {
4710
4905
  e && console.log("migrating...");
4711
- const r = new Le(Ee), a = new be({
4906
+ const a = new Je(Ee), r = new be({
4712
4907
  db: t,
4713
- provider: r
4714
- }), { error: n, results: o } = await a.migrateToLatest();
4908
+ provider: a
4909
+ }), { error: n, results: o } = await r.migrateToLatest();
4715
4910
  if (o == null || o.forEach((s) => {
4716
4911
  s.status === "Success" ? e && console.log(
4717
4912
  `migration "${s.migrationName}" was executed successfully`
@@ -4719,48 +4914,50 @@ async function Pl(t, e = !1) {
4719
4914
  }), n)
4720
4915
  throw console.error("failed to migrate"), console.error(n), n;
4721
4916
  }
4722
- async function jl(t) {
4917
+ async function Vl(t) {
4723
4918
  console.log("migrating...");
4724
- const e = new Le(Ee), r = new be({
4919
+ const e = new Je(Ee), a = new be({
4725
4920
  db: t,
4726
4921
  provider: e
4727
- }), { error: a, results: n } = await r.migrateDown();
4922
+ }), { error: r, results: n } = await a.migrateDown();
4728
4923
  if (n == null || n.forEach((o) => {
4729
4924
  o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
4730
- }), a)
4731
- throw console.error("failed to migrate"), console.error(a), a;
4925
+ }), r)
4926
+ throw console.error("failed to migrate"), console.error(r), r;
4732
4927
  }
4733
- function Fl(t) {
4928
+ function Gl(t) {
4734
4929
  return {
4735
4930
  applications: jt(t),
4736
- branding: er(t),
4737
- cleanup: Ir(t),
4738
- clients: Jt(t),
4931
+ branding: ea(t),
4932
+ cleanup: Ia(t),
4933
+ clients: Lt(t),
4739
4934
  codes: Ot(t),
4740
4935
  connections: Et(t),
4741
- emailProviders: br(t),
4936
+ emailProviders: ba(t),
4742
4937
  customDomains: Yt(t),
4743
- forms: Ar(t),
4744
- hooks: sr(t),
4938
+ forms: Ma(t),
4939
+ hooks: sa(t),
4745
4940
  keys: Bt(t),
4746
- loginSessions: pr(t),
4941
+ loginSessions: pa(t),
4747
4942
  logs: ut(t),
4748
4943
  passwords: Nt(t),
4749
- promptSettings: yr(t),
4750
- refreshTokens: $r(t),
4751
- resourceServers: Kr(t),
4752
- rolePermissions: Xr(t),
4753
- userPermissions: ra(t),
4754
- userRoles: sa(t),
4755
- roles: Wr(t),
4944
+ promptSettings: ya(t),
4945
+ refreshTokens: $a(t),
4946
+ resourceServers: Ka(t),
4947
+ rolePermissions: Xa(t),
4948
+ userPermissions: ar(t),
4949
+ userRoles: sr(t),
4950
+ roles: Va(t),
4756
4951
  sessions: gt(t),
4757
4952
  tenants: st(t),
4758
- themes: ur(t),
4759
- users: Ze(t)
4953
+ themes: ua(t),
4954
+ users: Ze(t),
4955
+ organizations: mr(t),
4956
+ userOrganizations: wr(t)
4760
4957
  };
4761
4958
  }
4762
4959
  export {
4763
- Fl as default,
4764
- jl as migrateDown,
4765
- Pl as migrateToLatest
4960
+ Gl as default,
4961
+ Vl as migrateDown,
4962
+ Wl as migrateToLatest
4766
4963
  };