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