@authhero/kysely-adapter 10.32.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 Re = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var z = (t, e, a) => Re(t, typeof e != "symbol" ? e + "" : e, a), q = (t, e, a) => e.has(t) || ue("Cannot " + a);
7
- var d = (t, e, a) => (q(t, e, "read from private field"), a ? a.call(t) : e.get(t)), b = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), L = (t, e, a, r) => (q(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), _ = (t, e, a) => (q(t, e, "access private method"), a);
8
- import { parseUserId as ae, codeSchema as Ke, connectionSchema as Be, loginSessionSchema as Ue, promptSettingSchema as Qe, formSchema as U, resourceServerSchema as qe, ruleSchema as Ve, permissionSchema as We } from "@authhero/adapter-interfaces";
5
+ var 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,18 +23,18 @@ var H = class extends Error {
23
23
  });
24
24
  }
25
25
  };
26
- function Ge(t) {
27
- return async (e, a) => {
28
- const { identities: r, ...o } = a, n = {
26
+ function Ve(t) {
27
+ return async (e, r) => {
28
+ const { identities: a, ...o } = r, n = {
29
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
40
  await t.insertInto("users").values(n).execute();
@@ -52,21 +52,21 @@ function Ge(t) {
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,27 +75,27 @@ function pe(t) {
75
75
  }
76
76
  };
77
77
  }
78
- function He(t) {
79
- return async (e, a) => {
80
- const [r, o] = 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: n, ...s } = r, l = {
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
100
  ...o.map(pe)
101
101
  ]
@@ -103,25 +103,25 @@ function He(t) {
103
103
  return p(l);
104
104
  };
105
105
  }
106
- function N(t, e, a, r) {
107
- return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
- let s = n.startsWith("-"), l = null, i = "", m = !1, u;
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
109
  if (n.startsWith("-_exists_:"))
110
- l = n.substring(10), m = !0, s = !0;
110
+ l = n.substring(10), _ = !0, s = !0;
111
111
  else if (n.startsWith("_exists_:"))
112
- l = n.substring(9), m = !0, s = !1;
112
+ l = n.substring(9), _ = !0, s = !1;
113
113
  else if (n.includes(":")) {
114
- const h = s ? n.substring(1) : n, y = h.indexOf(":");
115
- l = h.substring(0, y), i = h.substring(y + 1), m = !1, i.startsWith(">=") ? (u = ">=", i = i.substring(2)) : i.startsWith(">") ? (u = ">", i = i.substring(1)) : i.startsWith("<=") ? (u = "<=", i = i.substring(2)) : i.startsWith("<") ? (u = "<", i = i.substring(1)) : u = "=";
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
- l = null, i = n, m = !1;
118
- return { key: l, value: i, isNegation: s, isExistsQuery: m, operator: u };
119
- }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: i, operator: m }) => {
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
120
  if (n)
121
- if (i)
121
+ if (c)
122
122
  l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
123
123
  else if (l)
124
- switch (m) {
124
+ switch (_) {
125
125
  case ">":
126
126
  e = e.where(n, "<=", s);
127
127
  break;
@@ -138,12 +138,12 @@ function N(t, e, a, r) {
138
138
  e = e.where(n, "!=", s);
139
139
  }
140
140
  else
141
- e = e.where(n, 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((y) => h(u(y), "like", `%${s}%`))
146
+ a.map((g) => h(u(g), "like", `%${s}%`))
147
147
  )
148
148
  );
149
149
  }
@@ -152,20 +152,20 @@ function N(t, e, a, r) {
152
152
  function v(t) {
153
153
  return typeof t == "string" ? parseInt(t, 10) : typeof t == "bigint" ? Number(t) : t;
154
154
  }
155
- function Xe(t) {
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 n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((u) => u.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], i = n.map((u) => {
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
167
  const h = l.filter(
168
- (y) => y.linked_to === u.user_id
168
+ (g) => g.linked_to === u.user_id
169
169
  );
170
170
  return p({
171
171
  ...u,
@@ -177,120 +177,120 @@ function Xe(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 Ye(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 o = e ? `${e}_${r}` : r, n = t[r];
202
- typeof n == "object" && n !== null && !Array.isArray(n) ? A(n, o, a) : typeof n == "boolean" ? a[o] = n ? 1 : 0 : a[o] = n;
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, o] of Object.entries(t)) {
207
+ const r = {};
208
+ for (const [a, o] of Object.entries(t)) {
209
209
  const n = e.find(
210
- (s) => r.startsWith(`${s}_`)
210
+ (s) => a.startsWith(`${s}_`)
211
211
  );
212
212
  if (!n)
213
- a[r] = o;
213
+ r[a] = o;
214
214
  else {
215
- const s = r.slice(n.length + 1);
216
- a[n] = {
217
- ...a[n],
215
+ const s = a.slice(n.length + 1);
216
+ r[n] = {
217
+ ...r[n],
218
218
  [s]: o
219
219
  };
220
220
  }
221
221
  }
222
- return a;
222
+ return r;
223
223
  }
224
- function Ze(t) {
225
- return async (e, a, r) => {
224
+ function Xe(t) {
225
+ return async (e, r, a) => {
226
226
  const o = A({
227
- ...r,
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(o).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 et(t) {
236
- return async (e, a, r, o) => {
235
+ function Ye(t) {
236
+ return async (e, r, a, o) => {
237
237
  const n = { linked_to: null };
238
- return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
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 tt(t) {
241
+ function Ze(t) {
242
242
  return {
243
- create: Ge(t),
244
- remove: Ye(t),
245
- get: He(t),
246
- list: Xe(t),
247
- update: Ze(t),
243
+ create: 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: et(t)
249
+ unlink: Ye(t)
250
250
  };
251
251
  }
252
- const at = "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 += at[a[t] & 63];
256
+ e += et[r[t] & 63];
257
257
  return e;
258
258
  };
259
- function rt(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
- function nt(t) {
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 ot(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
284
  const { ref: l } = t.dynamic;
285
- a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
285
+ r = r.orderBy(l(e.sort.sort_by), e.sort.sort_order);
286
286
  }
287
- e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
288
- const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
287
+ e.q && (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
291
  tenants: o
292
292
  };
293
- const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = v(n);
293
+ const { count: n } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = v(n);
294
294
  return {
295
295
  tenants: o.map(p),
296
296
  start: (e.page - 1) * e.per_page,
@@ -299,50 +299,50 @@ function ot(t) {
299
299
  };
300
300
  };
301
301
  }
302
- function st(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 it(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 lt(t) {
315
+ function st(t) {
316
316
  return {
317
- create: rt(t),
318
- get: nt(t),
319
- list: ot(t),
320
- update: st(t),
321
- remove: it(t)
317
+ create: tt(t),
318
+ get: rt(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 ct = 1024;
328
- function dt(t) {
329
- return async (e, a) => {
327
+ const it = 1024;
328
+ function lt(t) {
329
+ return async (e, r) => {
330
330
  var o, n, s;
331
- const r = {
332
- id: C(),
333
- ...a,
334
- user_agent: a.user_agent.slice(0, ct)
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: (o = r.description) == null ? void 0 : o.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: (n = a.scope) == null ? void 0 : n.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,51 +367,51 @@ function we(t) {
367
367
  _id: t.id
368
368
  };
369
369
  }
370
- function ut(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 o = r;
379
- if (a.sort && a.sort.sort_by) {
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
380
  const { ref: l } = t.dynamic;
381
381
  o = o.orderBy(
382
- l(a.sort.sort_by),
383
- a.sort.sort_order
382
+ l(r.sort.sort_by),
383
+ r.sort.sort_order
384
384
  );
385
385
  }
386
- o = o.offset(a.page * a.per_page).limit(a.per_page);
387
- const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
386
+ 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
389
  logs: n.map(we),
390
- start: a.page * a.per_page,
391
- limit: a.per_page,
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 mt(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 _t(t) {
402
+ function ut(t) {
403
403
  return {
404
- create: dt(t),
405
- list: ut(t),
406
- get: mt(t)
404
+ create: lt(t),
405
+ list: ct(t),
406
+ get: dt(t)
407
407
  };
408
408
  }
409
- function ht(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: o, device: n, clients: s, ...l } = r;
414
+ const { tenant_id: o, device: n, clients: s, ...l } = a;
415
415
  return {
416
416
  ...l,
417
417
  device: JSON.parse(n),
@@ -419,188 +419,188 @@ function ht(t) {
419
419
  };
420
420
  };
421
421
  }
422
- function ft(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 pt(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 gt(t) {
443
- return async (e, a, r) => {
442
+ function ft(t) {
443
+ return async (e, r, a) => {
444
444
  const o = {
445
- ...r,
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(o).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 wt(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 o = r;
462
- if (a.sort && a.sort.sort_by) {
463
- const { ref: i } = t.dynamic;
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
464
  o = o.orderBy(
465
- i(a.sort.sort_by),
466
- a.sort.sort_order
465
+ c(r.sort.sort_by),
466
+ r.sort.sort_order
467
467
  );
468
468
  }
469
- o = o.offset(a.page * a.per_page).limit(a.per_page);
470
- const n = await o.selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = v(s);
469
+ 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: n.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,
477
+ start: r.page * r.per_page,
478
+ limit: r.per_page,
479
479
  length: l
480
480
  };
481
481
  };
482
482
  }
483
- function yt(t) {
483
+ function gt(t) {
484
484
  return {
485
- create: ft(t),
486
- get: ht(t),
487
- list: wt(t),
488
- remove: pt(t),
489
- update: gt(t)
485
+ create: _t(t),
486
+ get: mt(t),
487
+ list: pt(t),
488
+ remove: ht(t),
489
+ update: ft(t)
490
490
  };
491
491
  }
492
- function vt(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: o, ...n } = r;
497
+ const { tenant_id: o, ...n } = a;
498
498
  return n;
499
499
  };
500
500
  }
501
- function Nt(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 Ct(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 bt(t) {
520
+ function Nt(t) {
521
521
  return {
522
- create: Nt(t),
523
- update: Ct(t),
524
- get: vt(t)
522
+ create: yt(t),
523
+ update: vt(t),
524
+ get: wt(t)
525
525
  };
526
526
  }
527
- function xt(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 n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
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: n.map((i) => {
538
- const { tenant_id: m, ...u } = i;
537
+ codes: n.map((c) => {
538
+ const { tenant_id: _, ...u } = c;
539
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 Tt(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 St(t) {
560
- return async (e, a) => (await t.deleteFrom("codes").where("codes.tenant_id", "=", e).where("codes.code_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
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
561
  }
562
- function Ot(t) {
563
- return async (e, a, r) => {
564
- let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
562
+ function Tt(t) {
563
+ return async (e, r, a) => {
564
+ let o = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
565
565
  e.length && (o = o.where("codes.tenant_id", "=", e));
566
566
  const n = await o.selectAll().executeTakeFirst();
567
567
  return n ? p(n) : null;
568
568
  };
569
569
  }
570
- function kt(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;
570
+ function St(t) {
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;
572
572
  }
573
- function $t(t) {
573
+ function Ot(t) {
574
574
  return {
575
- create: Tt(t),
576
- list: xt(t),
577
- remove: St(t),
578
- used: kt(t),
579
- get: Ot(t)
575
+ create: bt(t),
576
+ list: Ct(t),
577
+ remove: xt(t),
578
+ used: St(t),
579
+ get: Tt(t)
580
580
  };
581
581
  }
582
- function Dt(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
- }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), i = JSON.stringify(a.allowed_clients);
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) : "{}",
593
+ disable_sign_ups: r.disable_sign_ups ? 1 : 0,
594
+ addons: r.addons ? JSON.stringify(r.addons) : "{}",
595
595
  callbacks: n,
596
596
  allowed_origins: o,
597
597
  web_origins: s,
598
598
  allowed_logout_urls: l,
599
- allowed_clients: i
600
- }).execute(), r;
599
+ allowed_clients: c
600
+ }).execute(), a;
601
601
  };
602
602
  }
603
- function It(t) {
603
+ function $t(t) {
604
604
  return async (e) => ({
605
605
  applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((n) => ({
606
606
  ...n,
@@ -614,254 +614,254 @@ function It(t) {
614
614
  }))
615
615
  });
616
616
  }
617
- function jt(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)
617
+ function It(t) {
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 Pt(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
- function Ft(t) {
635
- return async (e, a, r) => {
634
+ function Pt(t) {
635
+ return async (e, r, a) => {
636
636
  const o = {
637
- ...r,
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(o).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 Mt(t) {
650
+ function jt(t) {
651
651
  return {
652
- create: Dt(t),
653
- list: It(t),
654
- get: jt(t),
655
- remove: Pt(t),
656
- update: Ft(t)
652
+ create: kt(t),
653
+ list: $t(t),
654
+ get: It(t),
655
+ remove: Dt(t),
656
+ update: Pt(t)
657
657
  };
658
658
  }
659
- function At(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 zt(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: l } = 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,
691
+ start: r.page * r.per_page,
692
+ limit: r.per_page,
693
693
  length: v(l)
694
694
  };
695
695
  };
696
696
  }
697
- function Lt(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 Jt(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 Et(t) {
710
- return async (e, a, r) => {
709
+ function Lt(t) {
710
+ return async (e, r, a) => {
711
711
  const o = {
712
- ...r,
712
+ ...a,
713
713
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
714
714
  };
715
715
  return await t.updateTable("connections").set({
716
716
  ...o,
717
717
  options: o.options ? JSON.stringify(o.options) : void 0
718
- }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
718
+ }).where("connections.id", "=", r).where("connections.tenant_id", "=", e).execute(), !0;
719
719
  };
720
720
  }
721
- function Rt(t) {
721
+ function Et(t) {
722
722
  return {
723
- create: At(t),
724
- get: Jt(t),
725
- list: zt(t),
726
- remove: Lt(t),
727
- update: Et(t)
723
+ create: 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 o = 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,
741
+ ...r,
742
742
  connections: o.map(
743
- (s) => Be.parse(
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
- function Bt(t) {
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 Ut(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
- function Qt(t) {
777
- return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
776
+ function Ut(t) {
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: Ut(t),
782
- list: Bt(t),
783
- update: Qt(t)
781
+ create: Kt(t),
782
+ list: Rt(t),
783
+ update: Ut(t)
784
784
  };
785
785
  }
786
- function Vt(t) {
787
- return async (e, a) => {
788
- const r = {
789
- custom_domain_id: C(),
786
+ function Qt(t) {
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 Wt(t) {
804
- return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((r) => ({
805
- ...r,
806
- primary: r.primary === 1
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 Gt(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 Ht(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 Xt(t) {
822
- return async (e, a, r) => {
821
+ function Gt(t) {
822
+ return async (e, r, a) => {
823
823
  const o = {
824
- ...r,
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(o).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
828
+ return (await t.updateTable("custom_domains").set(o).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", r).execute()).length > 0;
829
829
  };
830
830
  }
831
- function Yt(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 Zt(t) {
840
+ function Xt(t) {
841
841
  return {
842
- create: Vt(t),
843
- get: Ht(t),
844
- getByDomain: Yt(t),
845
- list: Wt(t),
846
- remove: Gt(t),
847
- update: Xt(t)
842
+ create: Qt(t),
843
+ get: Wt(t),
844
+ getByDomain: Ht(t),
845
+ list: qt(t),
846
+ remove: Vt(t),
847
+ update: Gt(t)
848
848
  };
849
849
  }
850
- function ea(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,
856
+ tenant_id: a,
857
857
  colors_primary: o,
858
858
  colors_page_background_type: n,
859
859
  colors_page_background_start: s,
860
860
  colors_page_background_end: l,
861
- colors_page_background_angle_dev: i,
862
- font_url: m,
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: {
@@ -870,151 +870,151 @@ function ea(t) {
870
870
  type: n,
871
871
  start: s,
872
872
  end: l,
873
- angle_deg: i
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 ta(t) {
881
- return async (e, a) => {
882
- var s, l, i, m, u, h, y, D, I, O, re, ne, oe, se, ie, le, ce, de;
883
- const { colors: r, font: o, ...n } = a;
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
886
  ...n,
887
- colors_primary: r == null ? void 0 : r.primary,
888
- colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
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 = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : D.angle_deg,
892
- font_url: (I = a.font) == null ? void 0 : I.url,
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
897
  ...n,
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
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 aa(t) {
908
+ function er(t) {
909
909
  return {
910
- get: ea(t),
911
- set: ta(t)
910
+ get: Yt(t),
911
+ set: Zt(t)
912
912
  };
913
913
  }
914
- function ra(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 n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
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: n.map((i) => {
925
- const { tenant_id: m, enabled: u, synchronous: h, ...y } = i;
924
+ hooks: n.map((c) => {
925
+ const { tenant_id: _, enabled: u, synchronous: h, ...g } = c;
926
926
  return p({
927
- ...y,
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 na(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 oa(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 sa(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 ia(t) {
968
- return async (e, a, r) => {
967
+ function or(t) {
968
+ return async (e, r, a) => {
969
969
  const o = {
970
- ...r,
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(o).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 la(t) {
978
+ function sr(t) {
979
979
  return {
980
- create: sa(t),
981
- get: na(t),
982
- list: ra(t),
983
- update: ia(t),
984
- remove: oa(t)
980
+ create: nr(t),
981
+ get: rr(t),
982
+ list: tr(t),
983
+ update: or(t),
984
+ remove: ar(t)
985
985
  };
986
986
  }
987
- function ca(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
993
+ ...r
994
994
  }, o = {
995
- ...r,
995
+ ...a,
996
996
  tenant_id: e
997
997
  };
998
- return await t.insertInto("themes").values(A(o)).execute(), r;
998
+ return await t.insertInto("themes").values(A(o)).execute(), a;
999
999
  };
1000
1000
  }
1001
- function da(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 ua(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
1009
  const o = {
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
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
1020
  ge(o, [
@@ -1027,80 +1027,80 @@ function ua(t) {
1027
1027
  );
1028
1028
  };
1029
1029
  }
1030
- function ma(t) {
1031
- return async (e, a, r) => {
1030
+ function dr(t) {
1031
+ return async (e, r, a) => {
1032
1032
  const o = A({
1033
- ...r,
1033
+ ...a,
1034
1034
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1035
1035
  });
1036
- return await t.updateTable("themes").set(o).where("themes.themeId", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
1036
+ return await t.updateTable("themes").set(o).where("themes.themeId", "=", r).where("themes.tenant_id", "=", e).execute(), !0;
1037
1037
  };
1038
1038
  }
1039
- function _a(t) {
1039
+ function ur(t) {
1040
1040
  return {
1041
- create: ca(t),
1042
- get: ua(t),
1043
- remove: da(t),
1044
- update: ma(t)
1041
+ create: ir(t),
1042
+ get: cr(t),
1043
+ remove: lr(t),
1044
+ update: dr(t)
1045
1045
  };
1046
1046
  }
1047
- function ha(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 fa(t) {
1062
- return async (e, a) => {
1061
+ function _r(t) {
1062
+ return async (e, r) => {
1063
1063
  var o;
1064
- const r = {
1065
- id: C(),
1066
- ...a,
1067
- authorization_url: (o = a.authorization_url) == null ? void 0 : o.slice(0, 1024),
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 pa(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 ga(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 wa(t) {
1088
+ function pr(t) {
1089
1089
  return {
1090
- create: fa(t),
1091
- get: ha(t),
1092
- update: pa(t),
1093
- remove: ga(t)
1090
+ create: _r(t),
1091
+ get: mr(t),
1092
+ update: hr(t),
1093
+ remove: fr(t)
1094
1094
  };
1095
1095
  }
1096
- function ya(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,37 +1113,37 @@ function he(t) {
1113
1113
  universal_login_experience: t.universal_login_experience
1114
1114
  });
1115
1115
  }
1116
- function va(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 Na(t) {
1129
+ function yr(t) {
1130
1130
  return {
1131
- get: ya(t),
1132
- set: va(t)
1131
+ get: gr(t),
1132
+ set: wr(t)
1133
1133
  };
1134
1134
  }
1135
- function Ca(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,
1141
+ tenant_id: a,
1142
1142
  credentials: o,
1143
1143
  settings: n,
1144
1144
  enabled: s,
1145
1145
  ...l
1146
- } = a;
1146
+ } = r;
1147
1147
  return p({
1148
1148
  ...l,
1149
1149
  credentials: JSON.parse(o),
@@ -1152,24 +1152,24 @@ function Ca(t) {
1152
1152
  });
1153
1153
  };
1154
1154
  }
1155
- function ba(t) {
1156
- return async (e, a) => {
1157
- const { credentials: r, settings: o, enabled: n, ...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,
1160
+ credentials: a ? JSON.stringify(a) : void 0,
1161
1161
  settings: o ? JSON.stringify(o) : void 0,
1162
1162
  enabled: n !== void 0 ? n ? 1 : 0 : void 0
1163
1163
  }).where("tenant_id", "=", e).execute();
1164
1164
  };
1165
1165
  }
1166
- function xa(t) {
1167
- return async (e, a) => {
1168
- const { credentials: r, settings: o, enabled: n, ...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
1171
  enabled: n ? 1 : 0,
1172
- credentials: JSON.stringify(r),
1172
+ credentials: JSON.stringify(a),
1173
1173
  settings: JSON.stringify(o),
1174
1174
  tenant_id: e,
1175
1175
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1177,110 +1177,110 @@ function xa(t) {
1177
1177
  }).execute();
1178
1178
  };
1179
1179
  }
1180
- function Ta(t) {
1180
+ function br(t) {
1181
1181
  return {
1182
- get: Ca(t),
1183
- create: xa(t),
1184
- update: ba(t)
1182
+ get: vr(t),
1183
+ create: Cr(t),
1184
+ update: Nr(t)
1185
1185
  };
1186
1186
  }
1187
- function Sa(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 Oa(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 ka(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 $a(t) {
1217
- return async (e, a, r) => {
1216
+ function Or(t) {
1217
+ return async (e, r, a) => {
1218
1218
  const o = {
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
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(o).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 Da(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 o = r;
1236
- if (a.sort && a.sort.sort_by) {
1237
- const { ref: i } = t.dynamic;
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
1238
  o = o.orderBy(
1239
- i(a.sort.sort_by),
1240
- a.sort.sort_order
1239
+ c(r.sort.sort_by),
1240
+ r.sort.sort_order
1241
1241
  );
1242
1242
  }
1243
- o = o.offset(a.page * a.per_page).limit(a.per_page);
1244
- const n = await o.selectAll().execute(), { count: s } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = v(s);
1243
+ 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: n.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,
1252
+ start: r.page * r.per_page,
1253
+ limit: r.per_page,
1254
1254
  length: l
1255
1255
  };
1256
1256
  };
1257
1257
  }
1258
- function Ia(t) {
1258
+ function $r(t) {
1259
1259
  return {
1260
- create: Oa(t),
1261
- get: Sa(t),
1262
- list: Da(t),
1263
- remove: ka(t),
1264
- update: $a(t)
1260
+ create: Tr(t),
1261
+ get: xr(t),
1262
+ list: kr(t),
1263
+ remove: Sr(t),
1264
+ update: Or(t)
1265
1265
  };
1266
1266
  }
1267
- function ja(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(
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
1275
  (n) => n.or([
1276
- n("expires_at", "<", a),
1277
- n("idle_expires_at", "<", a)
1276
+ n("expires_at", "<", r),
1277
+ n("idle_expires_at", "<", r)
1278
1278
  ])
1279
1279
  ).limit(1e4).execute(), console.log("delete sessions");
1280
1280
  const o = await t.selectFrom("sessions").select("id").where(
1281
1281
  (n) => n.or([
1282
- n("expires_at", "<", a),
1283
- n("idle_expires_at", "<", a)
1282
+ n("expires_at", "<", r),
1283
+ n("idle_expires_at", "<", r)
1284
1284
  ])
1285
1285
  ).where(
1286
1286
  "id",
@@ -1294,70 +1294,70 @@ function ja(t) {
1294
1294
  ).execute(), console.log("cleanup complete");
1295
1295
  };
1296
1296
  }
1297
- function Pa(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 Fa(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: l } = 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,
1344
+ start: r.page * r.per_page,
1345
+ limit: r.per_page,
1346
1346
  length: v(l)
1347
1347
  };
1348
1348
  };
1349
1349
  }
1350
- function Ma(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 Aa(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 o = { ...r };
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
1361
  if (typeof o.nodes == "string")
1362
1362
  try {
1363
1363
  o.nodes = JSON.parse(o.nodes);
@@ -1373,344 +1373,446 @@ function Aa(t) {
1373
1373
  o.ending = JSON.parse(o.ending);
1374
1374
  } catch {
1375
1375
  }
1376
- return U.parse(p(o));
1376
+ return B.parse(p(o));
1377
1377
  };
1378
1378
  }
1379
- function za(t) {
1380
- return async (e, a, r) => {
1379
+ function Mr(t) {
1380
+ return async (e, r, a) => {
1381
1381
  const o = {
1382
- ...r,
1382
+ ...a,
1383
1383
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1384
1384
  };
1385
- r.nodes && (o.nodes = JSON.stringify(r.nodes)), r.start && (o.start = JSON.stringify(r.start)), r.ending && (o.ending = JSON.stringify(r.ending));
1386
- const { numUpdatedRows: n } = await t.updateTable("forms").set(o).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
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
1387
  return n > 0;
1388
1388
  };
1389
1389
  }
1390
- function La(t) {
1390
+ function Ar(t) {
1391
1391
  return {
1392
- create: Pa(t),
1393
- get: Aa(t),
1394
- list: Fa(t),
1395
- remove: Ma(t),
1396
- update: za(t)
1392
+ create: Dr(t),
1393
+ get: Fr(t),
1394
+ list: Pr(t),
1395
+ remove: jr(t),
1396
+ update: Mr(t)
1397
1397
  };
1398
1398
  }
1399
- function Ja(t) {
1400
- return async (e, a) => {
1401
- const r = {
1402
- id: C(),
1403
- ...a
1404
- }, o = qe.parse(r), {
1405
- verificationKey: n,
1406
- scopes: s,
1407
- options: l,
1408
- skip_consent_for_verifiable_first_party_clients: i,
1409
- allow_offline_access: m,
1410
- ...u
1411
- } = o, h = {
1412
- ...u,
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
+ verificationKey: s,
1408
+ scopes: l,
1409
+ options: c,
1410
+ skip_consent_for_verifiable_first_party_clients: _,
1411
+ allow_offline_access: u,
1412
+ ...h
1413
+ } = n, g = {
1414
+ ...h,
1413
1415
  tenant_id: e,
1414
- scopes: s ? JSON.stringify(s) : "[]",
1415
- options: l ? JSON.stringify(l) : "{}",
1416
- skip_consent_for_verifiable_first_party_clients: i ? 1 : 0,
1417
- allow_offline_access: m ? 1 : 0,
1418
- verification_key: n
1419
- };
1420
- return await t.insertInto("resource_servers").values(h).execute(), o;
1416
+ scopes: l ? JSON.stringify(l) : "[]",
1417
+ options: c ? JSON.stringify(c) : "{}",
1418
+ skip_consent_for_verifiable_first_party_clients: _ ? 1 : 0,
1419
+ allow_offline_access: u ? 1 : 0,
1420
+ verification_key: s,
1421
+ created_at: a,
1422
+ updated_at: a
1423
+ };
1424
+ return await t.insertInto("resource_servers").values(g).execute(), n;
1421
1425
  };
1422
1426
  }
1423
- function Ea(t) {
1424
- return async (e, a) => {
1425
- const r = await t.selectFrom("resource_servers").selectAll().where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1426
- if (!r) return null;
1427
- const o = r, {
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, {
1428
1432
  verification_key: n,
1429
1433
  scopes: s,
1430
1434
  options: l,
1431
- skip_consent_for_verifiable_first_party_clients: i,
1432
- allow_offline_access: m,
1435
+ skip_consent_for_verifiable_first_party_clients: c,
1436
+ allow_offline_access: _,
1433
1437
  ...u
1434
1438
  } = o;
1435
1439
  return {
1436
1440
  ...u,
1437
1441
  scopes: s ? JSON.parse(s) : [],
1438
1442
  options: l ? JSON.parse(l) : {},
1439
- skip_consent_for_verifiable_first_party_clients: !!i,
1440
- allow_offline_access: !!m,
1443
+ skip_consent_for_verifiable_first_party_clients: !!c,
1444
+ allow_offline_access: !!_,
1441
1445
  // Convert verification_key back to verificationKey for API
1442
1446
  verificationKey: n
1443
1447
  };
1444
1448
  };
1445
1449
  }
1446
- function Ra(t) {
1447
- return async (e, a = { page: 0, per_page: 50, include_totals: !1 }) => {
1448
- let r = t.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", e);
1449
- if (a.q) {
1450
- const i = a.q.trim(), m = i.split(/\s+/), u = m.length === 1 ? m[0] : void 0, h = u ? u.match(/^(-)?(name|identifier):(.*)$/) : null, y = h ? h[3] : "", D = /^(>=|>|<=|<)/.test(y || "");
1451
- if (h && !D) {
1452
- const I = !!h[1], O = h[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
1453
- r = I ? r.where(O, "not like", `%${y}%`) : r.where(O, "like", `%${y}%`);
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}%`);
1454
1458
  } else
1455
- r = N(t, r, i, [
1459
+ a = C(t, a, c, [
1456
1460
  "resource_servers.name",
1457
1461
  "resource_servers.identifier"
1458
1462
  ]);
1459
1463
  }
1460
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((i) => {
1461
- 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, {
1462
1466
  verification_key: u,
1463
1467
  scopes: h,
1464
- options: y,
1465
- skip_consent_for_verifiable_first_party_clients: D,
1466
- allow_offline_access: I,
1468
+ options: g,
1469
+ skip_consent_for_verifiable_first_party_clients: I,
1470
+ allow_offline_access: D,
1467
1471
  ...O
1468
- } = m;
1472
+ } = _;
1469
1473
  return {
1470
1474
  ...O,
1471
1475
  scopes: h ? JSON.parse(h) : [],
1472
- options: y ? JSON.parse(y) : {},
1473
- skip_consent_for_verifiable_first_party_clients: !!D,
1474
- allow_offline_access: !!I,
1476
+ options: g ? JSON.parse(g) : {},
1477
+ skip_consent_for_verifiable_first_party_clients: !!I,
1478
+ allow_offline_access: !!D,
1475
1479
  // Convert verification_key back to verificationKey for API
1476
1480
  verificationKey: u
1477
1481
  };
1478
- }), { count: l } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1482
+ }), { count: l } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
1479
1483
  return {
1480
1484
  resource_servers: s,
1481
- start: a.page * a.per_page,
1482
- limit: a.per_page,
1485
+ start: r.page * r.per_page,
1486
+ limit: r.per_page,
1483
1487
  length: v(l)
1484
1488
  };
1485
1489
  };
1486
1490
  }
1487
- function Ka(t) {
1488
- return async (e, a) => {
1489
- const r = await t.deleteFrom("resource_servers").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1490
- 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;
1491
1495
  };
1492
1496
  }
1493
- function Ba(t) {
1494
- return async (e, a, r) => {
1497
+ function Rr(t) {
1498
+ return async (e, r, a) => {
1495
1499
  const {
1496
1500
  verificationKey: o,
1497
1501
  scopes: n,
1498
1502
  options: s,
1499
1503
  skip_consent_for_verifiable_first_party_clients: l,
1500
- allow_offline_access: i,
1501
- ...m
1502
- } = r, u = { ...m };
1503
- o !== void 0 && (u.verification_key = o), n !== void 0 && (u.scopes = JSON.stringify(n)), s !== void 0 && (u.options = JSON.stringify(s)), l !== void 0 && (u.skip_consent_for_verifiable_first_party_clients = l ? 1 : 0), i !== void 0 && (u.allow_offline_access = i ? 1 : 0);
1504
- const h = await t.updateTable("resource_servers").set(u).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1504
+ allow_offline_access: c,
1505
+ ..._
1506
+ } = a, u = {
1507
+ ..._,
1508
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1509
+ };
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();
1505
1512
  return Number(h.numUpdatedRows) > 0;
1506
1513
  };
1507
1514
  }
1508
- function Ua(t) {
1515
+ function Kr(t) {
1509
1516
  return {
1510
- create: Ja(t),
1511
- get: Ea(t),
1512
- list: Ra(t),
1513
- remove: Ka(t),
1514
- update: Ba(t)
1517
+ create: zr(t),
1518
+ get: Lr(t),
1519
+ list: Er(t),
1520
+ remove: Jr(t),
1521
+ update: Rr(t)
1515
1522
  };
1516
1523
  }
1517
- function Qa(t) {
1518
- return async (e, a) => {
1519
- const r = { id: C(), ...a }, o = Ve.parse(r), { enabled: n, ...s } = o, l = {
1520
- ...s,
1524
+ function Ur(t) {
1525
+ return async (e, r) => {
1526
+ const a = (/* @__PURE__ */ new Date()).toISOString(), o = b(), n = {
1527
+ id: o,
1528
+ ...r,
1521
1529
  tenant_id: e,
1522
- enabled: n ? 1 : 0
1530
+ created_at: a,
1531
+ updated_at: a
1532
+ };
1533
+ return await t.insertInto("roles").values(n).execute(), {
1534
+ id: o,
1535
+ ...r,
1536
+ created_at: a,
1537
+ updated_at: a
1523
1538
  };
1524
- return await t.insertInto("rules").values(l).execute(), o;
1525
1539
  };
1526
1540
  }
1527
- function qa(t) {
1528
- return async (e, a) => {
1529
- const r = await t.selectFrom("rules").selectAll().where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1530
- if (!r) return null;
1531
- const o = r, { enabled: n, ...s } = o;
1532
- return {
1533
- ...s,
1534
- enabled: !!n
1535
- };
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;
1536
1547
  };
1537
1548
  }
1538
- function Va(t) {
1539
- return async (e, a = { page: 0, per_page: 50, include_totals: !1 }) => {
1540
- let r = t.selectFrom("rules").where("rules.tenant_id", "=", e);
1541
- a.q && (r = N(t, r, a.q, ["name", "stage"]));
1542
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((i) => {
1543
- const m = i, { enabled: u, ...h } = m;
1544
- return {
1545
- ...h,
1546
- enabled: !!u
1547
- };
1548
- }), { count: l } = 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();
1549
1554
  return {
1550
- rules: s,
1551
- start: a.page * a.per_page,
1552
- limit: a.per_page,
1553
- length: v(l)
1555
+ roles: n,
1556
+ start: r.page * r.per_page,
1557
+ limit: r.per_page,
1558
+ length: v(s)
1554
1559
  };
1555
1560
  };
1556
1561
  }
1557
- function Wa(t) {
1558
- return async (e, a) => {
1559
- const r = await t.deleteFrom("rules").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1560
- return Number(r.numDeletedRows) > 0;
1562
+ function qr(t) {
1563
+ return async (e, r, a) => {
1564
+ const o = {
1565
+ ...a,
1566
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
1567
+ }, n = await t.updateTable("roles").set(o).where("roles.tenant_id", "=", e).where("roles.id", "=", r).executeTakeFirst();
1568
+ return Number(n.numUpdatedRows) > 0;
1561
1569
  };
1562
1570
  }
1563
- function Ga(t) {
1564
- return async (e, a, r) => {
1565
- const { enabled: o, ...n } = r, s = { ...n };
1566
- o !== void 0 && (s.enabled = o ? 1 : 0);
1567
- const l = await t.updateTable("rules").set(s).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
1568
- return Number(l.numUpdatedRows) > 0;
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;
1569
1575
  };
1570
1576
  }
1571
- function Ha(t) {
1577
+ function Wr(t) {
1572
1578
  return {
1573
- create: Qa(t),
1574
- get: qa(t),
1575
- list: Va(t),
1576
- remove: Wa(t),
1577
- update: Ga(t)
1579
+ create: Ur(t),
1580
+ get: Br(t),
1581
+ list: Qr(t),
1582
+ update: qr(t),
1583
+ remove: Vr(t)
1578
1584
  };
1579
1585
  }
1580
- function Xa(t) {
1581
- return async (e, a) => {
1582
- const r = C(), o = { id: r, ...a }, n = We.parse(o), { sources: s, ...l } = n, i = {
1583
- id: r,
1584
- ...l,
1585
- tenant_id: e,
1586
- sources: s ? JSON.stringify(s) : "[]"
1587
- };
1588
- return await t.insertInto("permissions").values(i).execute(), n;
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
+ }
1589
1615
  };
1590
1616
  }
1591
- function Ya(t) {
1592
- return async (e, a) => {
1593
- const r = await t.selectFrom("permissions").selectAll().where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1594
- if (!r) return null;
1595
- const o = r, { sources: n, ...s } = o;
1596
- return {
1597
- ...s,
1598
- sources: n ? JSON.parse(n) : []
1599
- };
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
+ }
1600
1633
  };
1601
1634
  }
1602
- function Za(t) {
1603
- return async (e, a = { page: 0, per_page: 50, include_totals: !1 }) => {
1604
- let r = t.selectFrom("permissions").where("permissions.tenant_id", "=", e);
1605
- a.q && (r = N(t, r, a.q, [
1606
- "permission_name",
1607
- "resource_server_identifier",
1608
- "resource_server_name"
1609
- ]));
1610
- const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((i) => {
1611
- const m = i, { sources: u, ...h } = m;
1612
- return {
1613
- ...h,
1614
- sources: u ? JSON.parse(u) : []
1615
- };
1616
- }), { count: l } = await r.select((i) => i.fn.countAll().as("count")).executeTakeFirstOrThrow();
1617
- return {
1618
- permissions: s,
1619
- start: a.page * a.per_page,
1620
- limit: a.per_page,
1621
- length: v(l)
1622
- };
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)
1623
1669
  };
1624
1670
  }
1625
- function er(t) {
1626
- return async (e, a, r) => {
1627
- const { sources: o, ...n } = r, s = { ...n };
1628
- o !== void 0 && (s.sources = JSON.stringify(o));
1629
- const l = await t.updateTable("permissions").set(s).where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1630
- return Number(l.numUpdatedRows) > 0;
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
+ }
1631
1696
  };
1632
1697
  }
1633
- function tr(t) {
1634
- return async (e, a) => {
1635
- const r = await t.deleteFrom("permissions").where("permissions.tenant_id", "=", e).where("permissions.id", "=", a).executeTakeFirst();
1636
- 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
+ }
1637
1712
  };
1638
1713
  }
1639
- function ar(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) {
1640
1744
  return {
1641
- create: Xa(t),
1642
- get: Ya(t),
1643
- list: Za(t),
1644
- update: er(t),
1645
- remove: tr(t)
1745
+ assign: Zr(t),
1746
+ remove: ea(t),
1747
+ list: ta(t)
1646
1748
  };
1647
1749
  }
1648
- function rr(t) {
1750
+ function aa(t) {
1649
1751
  return t[t.length - 1];
1650
1752
  }
1651
- function w(t) {
1753
+ function y(t) {
1652
1754
  return Object.freeze(t);
1653
1755
  }
1654
- const B = w({
1756
+ const U = y({
1655
1757
  is(t) {
1656
1758
  return t.kind === "IdentifierNode";
1657
1759
  },
1658
1760
  create(t) {
1659
- return w({
1761
+ return y({
1660
1762
  kind: "IdentifierNode",
1661
1763
  name: t
1662
1764
  });
1663
1765
  }
1664
- }), X = w({
1766
+ }), X = y({
1665
1767
  is(t) {
1666
1768
  return t.kind === "SchemableIdentifierNode";
1667
1769
  },
1668
1770
  create(t) {
1669
- return w({
1771
+ return y({
1670
1772
  kind: "SchemableIdentifierNode",
1671
- identifier: B.create(t)
1773
+ identifier: U.create(t)
1672
1774
  });
1673
1775
  },
1674
1776
  createWithSchema(t, e) {
1675
- return w({
1777
+ return y({
1676
1778
  kind: "SchemableIdentifierNode",
1677
- schema: B.create(t),
1678
- identifier: B.create(e)
1779
+ schema: U.create(t),
1780
+ identifier: U.create(e)
1679
1781
  });
1680
1782
  }
1681
- }), nr = w({
1783
+ }), na = y({
1682
1784
  is(t) {
1683
1785
  return t.kind === "AliasNode";
1684
1786
  },
1685
1787
  create(t, e) {
1686
- return w({
1788
+ return y({
1687
1789
  kind: "AliasNode",
1688
1790
  node: t,
1689
1791
  alias: e
1690
1792
  });
1691
1793
  }
1692
- }), V = w({
1794
+ }), V = y({
1693
1795
  is(t) {
1694
1796
  return t.kind === "TableNode";
1695
1797
  },
1696
1798
  create(t) {
1697
- return w({
1799
+ return y({
1698
1800
  kind: "TableNode",
1699
1801
  table: X.create(t)
1700
1802
  });
1701
1803
  },
1702
1804
  createWithSchema(t, e) {
1703
- return w({
1805
+ return y({
1704
1806
  kind: "TableNode",
1705
1807
  table: X.createWithSchema(t, e)
1706
1808
  });
1707
1809
  }
1708
1810
  });
1709
1811
  var Q;
1710
- class or {
1812
+ class oa {
1711
1813
  constructor() {
1712
1814
  z(this, "nodeStack", []);
1713
- b(this, Q, w({
1815
+ N(this, Q, y({
1714
1816
  AliasNode: this.transformAlias.bind(this),
1715
1817
  ColumnNode: this.transformColumn.bind(this),
1716
1818
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -1810,14 +1912,14 @@ class or {
1810
1912
  if (!e)
1811
1913
  return e;
1812
1914
  this.nodeStack.push(e);
1813
- const a = this.transformNodeImpl(e);
1814
- return this.nodeStack.pop(), w(a);
1915
+ const r = this.transformNodeImpl(e);
1916
+ return this.nodeStack.pop(), y(r);
1815
1917
  }
1816
1918
  transformNodeImpl(e) {
1817
1919
  return d(this, Q)[e.kind](e);
1818
1920
  }
1819
1921
  transformNodeList(e) {
1820
- return e && w(e.map((a) => this.transformNode(a)));
1922
+ return e && y(e.map((r) => this.transformNode(r)));
1821
1923
  }
1822
1924
  transformSelectQuery(e) {
1823
1925
  return {
@@ -1916,7 +2018,7 @@ class or {
1916
2018
  transformRaw(e) {
1917
2019
  return {
1918
2020
  kind: "RawNode",
1919
- sqlFragments: w([...e.sqlFragments]),
2021
+ sqlFragments: y([...e.sqlFragments]),
1920
2022
  parameters: this.transformNodeList(e.parameters)
1921
2023
  };
1922
2024
  }
@@ -2541,7 +2643,7 @@ class or {
2541
2643
  }
2542
2644
  }
2543
2645
  Q = new WeakMap();
2544
- const sr = w({
2646
+ const sa = y({
2545
2647
  AlterTableNode: !0,
2546
2648
  CreateIndexNode: !0,
2547
2649
  CreateSchemaNode: !0,
@@ -2560,78 +2662,78 @@ const sr = w({
2560
2662
  UpdateQueryNode: !0,
2561
2663
  MergeQueryNode: !0
2562
2664
  });
2563
- var M, k, $, g, ye, ve, Ne, j, Y, Ce;
2564
- class ir extends or {
2565
- constructor(a) {
2665
+ var M, k, $, w, ye, ve, Ne, P, Y, Ce;
2666
+ class ia extends oa {
2667
+ constructor(r) {
2566
2668
  super();
2567
- b(this, g);
2568
- b(this, M);
2569
- b(this, k, /* @__PURE__ */ new Set());
2570
- b(this, $, /* @__PURE__ */ new Set());
2571
- L(this, M, a);
2572
- }
2573
- transformNodeImpl(a) {
2574
- if (!_(this, g, ye).call(this, a))
2575
- return super.transformNodeImpl(a);
2576
- const r = _(this, g, Ne).call(this, a);
2577
- 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)
2578
2680
  d(this, $).add(s);
2579
- const o = _(this, g, ve).call(this, a);
2681
+ const o = m(this, w, ve).call(this, r);
2580
2682
  for (const s of o)
2581
2683
  d(this, k).add(s);
2582
- const n = super.transformNodeImpl(a);
2684
+ const n = super.transformNodeImpl(r);
2583
2685
  for (const s of o)
2584
2686
  d(this, k).delete(s);
2585
- for (const s of r)
2687
+ for (const s of a)
2586
2688
  d(this, $).delete(s);
2587
2689
  return n;
2588
2690
  }
2589
- transformSchemableIdentifier(a) {
2590
- const r = super.transformSchemableIdentifier(a);
2591
- return r.schema || !d(this, k).has(a.identifier.name) ? r : {
2592
- ...r,
2593
- 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))
2594
2696
  };
2595
2697
  }
2596
- transformReferences(a) {
2597
- const r = super.transformReferences(a);
2598
- return r.table.table.schema ? r : {
2599
- ...r,
2600
- table: V.createWithSchema(d(this, M), r.table.table.identifier.name)
2601
- };
2602
- }
2603
- }
2604
- M = new WeakMap(), k = new WeakMap(), $ = new WeakMap(), g = new WeakSet(), ye = function(a) {
2605
- return a.kind in sr;
2606
- }, ve = function(a) {
2607
- const r = /* @__PURE__ */ new Set();
2608
- if ("name" in a && a.name && X.is(a.name) && _(this, g, Y).call(this, a.name, r), "from" in a && a.from)
2609
- for (const o of a.from.froms)
2610
- _(this, g, j).call(this, o, r);
2611
- if ("into" in a && a.into && _(this, g, j).call(this, a.into, r), "table" in a && a.table && _(this, g, j).call(this, a.table, r), "joins" in a && a.joins)
2612
- for (const o of a.joins)
2613
- _(this, g, j).call(this, o.table, r);
2614
- return "using" in a && a.using && _(this, g, j).call(this, a.using, r), r;
2615
- }, Ne = function(a) {
2616
- const r = /* @__PURE__ */ new Set();
2617
- return "with" in a && a.with && _(this, g, Ce).call(this, a.with, r), r;
2618
- }, j = function(a, r) {
2619
- const o = V.is(a) ? a : nr.is(a) && V.is(a.node) ? a.node : null;
2620
- o && _(this, g, Y).call(this, o.table, r);
2621
- }, Y = function(a, r) {
2622
- const o = a.identifier.name;
2623
- !d(this, k).has(o) && !d(this, $).has(o) && r.add(o);
2624
- }, Ce = function(a, r) {
2625
- for (const o of a.expressions) {
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) {
2626
2728
  const n = o.name.table.table.identifier.name;
2627
- d(this, $).has(n) || r.add(n);
2729
+ d(this, $).has(n) || a.add(n);
2628
2730
  }
2629
2731
  };
2630
2732
  var R;
2631
- class lr {
2733
+ class la {
2632
2734
  constructor(e) {
2633
- b(this, R);
2634
- L(this, R, new ir(e));
2735
+ N(this, R);
2736
+ L(this, R, new ia(e));
2635
2737
  }
2636
2738
  transformQuery(e) {
2637
2739
  return d(this, R).transformNode(e.node);
@@ -2641,7 +2743,7 @@ class lr {
2641
2743
  }
2642
2744
  }
2643
2745
  R = new WeakMap();
2644
- class cr {
2746
+ class ca {
2645
2747
  transformQuery(e) {
2646
2748
  return e.node;
2647
2749
  }
@@ -2649,13 +2751,13 @@ class cr {
2649
2751
  return e.result;
2650
2752
  }
2651
2753
  }
2652
- const dr = "kysely_migration", fe = "kysely_migration_lock", ur = !1, W = "migration_lock", mr = w({ __noMigrations__: !0 });
2653
- var f, c, J, x, T, P, xe, S, Te, Se, Oe, ke, $e, Z, F, ee, De, Ie, je, te, Pe, Fe, Me, Ae, ze, E;
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;
2654
2756
  class be {
2655
2757
  constructor(e) {
2656
- b(this, c);
2657
- b(this, f);
2658
- L(this, f, w(e));
2758
+ N(this, i);
2759
+ N(this, f);
2760
+ L(this, f, y(e));
2659
2761
  }
2660
2762
  /**
2661
2763
  * Returns a {@link MigrationInfo} object for each migration.
@@ -2663,11 +2765,11 @@ class be {
2663
2765
  * The returned array is sorted by migration name.
2664
2766
  */
2665
2767
  async getMigrations() {
2666
- const e = await _(this, c, F).call(this, d(this, c, T)) ? await d(this, f).db.withPlugin(d(this, c, S)).selectFrom(d(this, c, T)).select(["name", "timestamp"]).execute() : [];
2667
- return (await _(this, c, te).call(this)).map(({ name: r, ...o }) => {
2668
- const n = e.find((s) => s.name === r);
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);
2669
2771
  return {
2670
- name: r,
2772
+ name: a,
2671
2773
  migration: o,
2672
2774
  executedAt: n ? new Date(n.timestamp) : void 0
2673
2775
  };
@@ -2721,7 +2823,7 @@ class be {
2721
2823
  * ```
2722
2824
  */
2723
2825
  async migrateToLatest() {
2724
- return _(this, c, J).call(this, () => ({ direction: "Up", step: 1 / 0 }));
2826
+ return m(this, i, E).call(this, () => ({ direction: "Up", step: 1 / 0 }));
2725
2827
  }
2726
2828
  /**
2727
2829
  * Migrate up/down to a specific migration.
@@ -2747,16 +2849,16 @@ class be {
2747
2849
  * ```
2748
2850
  */
2749
2851
  async migrateTo(e) {
2750
- return _(this, c, J).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2751
- if (e === mr)
2852
+ return m(this, i, E).call(this, ({ migrations: r, executedMigrations: a, pendingMigrations: o }) => {
2853
+ if (e === ma)
2752
2854
  return { direction: "Down", step: 1 / 0 };
2753
- if (!a.find((l) => l.name === e))
2855
+ if (!r.find((l) => l.name === e))
2754
2856
  throw new Error(`migration "${e}" doesn't exist`);
2755
- const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2857
+ const n = a.indexOf(e), s = o.findIndex((l) => l.name === e);
2756
2858
  if (n !== -1)
2757
2859
  return {
2758
2860
  direction: "Down",
2759
- step: r.length - n - 1
2861
+ step: a.length - n - 1
2760
2862
  };
2761
2863
  if (s !== -1)
2762
2864
  return { direction: "Up", step: s + 1 };
@@ -2778,7 +2880,7 @@ class be {
2778
2880
  * ```
2779
2881
  */
2780
2882
  async migrateUp() {
2781
- return _(this, c, J).call(this, () => ({ direction: "Up", step: 1 }));
2883
+ return m(this, i, E).call(this, () => ({ direction: "Up", step: 1 }));
2782
2884
  }
2783
2885
  /**
2784
2886
  * Migrate one step down.
@@ -2795,116 +2897,116 @@ class be {
2795
2897
  * ```
2796
2898
  */
2797
2899
  async migrateDown() {
2798
- return _(this, c, J).call(this, () => ({ direction: "Down", step: 1 }));
2900
+ return m(this, i, E).call(this, () => ({ direction: "Down", step: 1 }));
2799
2901
  }
2800
2902
  }
2801
- f = new WeakMap(), c = new WeakSet(), J = async function(e) {
2903
+ f = new WeakMap(), i = new WeakSet(), E = async function(e) {
2802
2904
  try {
2803
- return await _(this, c, Te).call(this), await _(this, c, De).call(this, e);
2804
- } catch (a) {
2805
- 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 };
2806
2908
  }
2807
2909
  }, x = function() {
2808
2910
  return d(this, f).migrationTableSchema;
2809
2911
  }, T = function() {
2810
- return d(this, f).migrationTableName ?? dr;
2811
- }, P = function() {
2912
+ return d(this, f).migrationTableName ?? da;
2913
+ }, j = function() {
2812
2914
  return d(this, f).migrationLockTableName ?? fe;
2813
2915
  }, xe = function() {
2814
- return d(this, f).allowUnorderedMigrations ?? ur;
2916
+ return d(this, f).allowUnorderedMigrations ?? ua;
2815
2917
  }, S = function() {
2816
- return d(this, c, x) ? new lr(d(this, c, x)) : new cr();
2918
+ return d(this, i, x) ? new la(d(this, i, x)) : new ca();
2817
2919
  }, Te = async function() {
2818
- await _(this, c, Se).call(this), await _(this, c, Oe).call(this), await _(this, c, ke).call(this), await _(this, c, $e).call(this);
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);
2819
2921
  }, Se = async function() {
2820
- if (d(this, c, x) && !await _(this, c, Z).call(this))
2922
+ if (d(this, i, x) && !await m(this, i, Z).call(this))
2821
2923
  try {
2822
- await _(this, c, E).call(this, d(this, f).db.schema.createSchema(d(this, c, x)));
2924
+ await m(this, i, J).call(this, d(this, f).db.schema.createSchema(d(this, i, x)));
2823
2925
  } catch (e) {
2824
- if (!await _(this, c, Z).call(this))
2926
+ if (!await m(this, i, Z).call(this))
2825
2927
  throw e;
2826
2928
  }
2827
2929
  }, Oe = async function() {
2828
- if (!await _(this, c, F).call(this, d(this, c, T)))
2930
+ if (!await m(this, i, F).call(this, d(this, i, T)))
2829
2931
  try {
2830
- d(this, c, x) && await _(this, c, E).call(this, d(this, f).db.schema.createSchema(d(this, c, x))), await _(this, c, E).call(this, d(this, f).db.schema.withPlugin(d(this, c, S)).createTable(d(this, c, T)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
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()));
2831
2933
  } catch (e) {
2832
- if (!await _(this, c, F).call(this, d(this, c, T)))
2934
+ if (!await m(this, i, F).call(this, d(this, i, T)))
2833
2935
  throw e;
2834
2936
  }
2835
2937
  }, ke = async function() {
2836
- if (!await _(this, c, F).call(this, d(this, c, P)))
2938
+ if (!await m(this, i, F).call(this, d(this, i, j)))
2837
2939
  try {
2838
- await _(this, c, E).call(this, d(this, f).db.schema.withPlugin(d(this, c, S)).createTable(d(this, c, P)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
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)));
2839
2941
  } catch (e) {
2840
- if (!await _(this, c, F).call(this, d(this, c, P)))
2942
+ if (!await m(this, i, F).call(this, d(this, i, j)))
2841
2943
  throw e;
2842
2944
  }
2843
2945
  }, $e = async function() {
2844
- if (!await _(this, c, ee).call(this))
2946
+ if (!await m(this, i, ee).call(this))
2845
2947
  try {
2846
- await d(this, f).db.withPlugin(d(this, c, S)).insertInto(d(this, c, 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();
2847
2949
  } catch (e) {
2848
- if (!await _(this, c, ee).call(this))
2950
+ if (!await m(this, i, ee).call(this))
2849
2951
  throw e;
2850
2952
  }
2851
2953
  }, Z = async function() {
2852
- return (await d(this, f).db.introspection.getSchemas()).some((a) => a.name === d(this, c, x));
2954
+ return (await d(this, f).db.introspection.getSchemas()).some((r) => r.name === d(this, i, x));
2853
2955
  }, F = async function(e) {
2854
- const a = d(this, c, x);
2956
+ const r = d(this, i, x);
2855
2957
  return (await d(this, f).db.introspection.getTables({
2856
2958
  withInternalKyselyTables: !0
2857
- })).some((o) => o.name === e && (!a || o.schema === a));
2959
+ })).some((o) => o.name === e && (!r || o.schema === r));
2858
2960
  }, ee = async function() {
2859
- return !!await d(this, f).db.withPlugin(d(this, c, S)).selectFrom(d(this, c, P)).where("id", "=", W).select("id").executeTakeFirst();
2860
- }, De = async function(e) {
2861
- const a = d(this, f).db.getExecutor().adapter, r = w({
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({
2862
2964
  lockTable: d(this, f).migrationLockTableName ?? fe,
2863
2965
  lockRowId: W,
2864
2966
  lockTableSchema: d(this, f).migrationTableSchema
2865
2967
  }), o = async (n) => {
2866
2968
  try {
2867
- await a.acquireMigrationLock(n, r);
2868
- const s = await _(this, c, Ie).call(this, n);
2969
+ await r.acquireMigrationLock(n, a);
2970
+ const s = await m(this, i, De).call(this, n);
2869
2971
  if (s.migrations.length === 0)
2870
2972
  return { results: [] };
2871
- const { direction: l, step: i } = e(s);
2872
- return i <= 0 ? { results: [] } : l === "Down" ? await _(this, c, Ae).call(this, n, s, i) : l === "Up" ? await _(this, c, ze).call(this, n, s, i) : { results: [] };
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: [] };
2873
2975
  } finally {
2874
- await a.releaseMigrationLock(n, r);
2976
+ await r.releaseMigrationLock(n, a);
2875
2977
  }
2876
2978
  };
2877
- return a.supportsTransactionalDdl ? d(this, f).db.transaction().execute(o) : d(this, f).db.connection().execute(o);
2878
- }, Ie = async function(e) {
2879
- const a = await _(this, c, te).call(this), r = await _(this, c, Pe).call(this, e);
2880
- _(this, c, Fe).call(this, a, r), d(this, c, xe) || _(this, c, Me).call(this, a, r);
2881
- const o = _(this, c, je).call(this, a, r);
2882
- return w({
2883
- migrations: a,
2884
- executedMigrations: r,
2885
- lastMigration: rr(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);
2984
+ return y({
2985
+ migrations: r,
2986
+ executedMigrations: a,
2987
+ lastMigration: aa(a),
2886
2988
  pendingMigrations: o
2887
2989
  });
2888
- }, je = function(e, a) {
2889
- return e.filter((r) => !a.includes(r.name));
2990
+ }, Pe = function(e, r) {
2991
+ return e.filter((a) => !r.includes(a.name));
2890
2992
  }, te = async function() {
2891
2993
  const e = await d(this, f).provider.getMigrations();
2892
- return Object.keys(e).sort().map((a) => ({
2893
- ...e[a],
2894
- name: a
2994
+ return Object.keys(e).sort().map((r) => ({
2995
+ ...e[r],
2996
+ name: r
2895
2997
  }));
2896
- }, Pe = async function(e) {
2897
- return (await e.withPlugin(d(this, c, S)).selectFrom(d(this, c, T)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2898
- }, Fe = function(e, a) {
2899
- for (const r of a)
2900
- if (!e.some((o) => o.name === r))
2901
- throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2902
- }, Me = function(e, a) {
2903
- for (let r = 0; r < a.length; ++r)
2904
- if (e[r].name !== a[r])
2905
- throw new Error(`corrupted migrations: expected previously executed migration ${a[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2906
- }, Ae = async function(e, a, r) {
2907
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
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) => ({
2908
3010
  migrationName: s.name,
2909
3011
  direction: "Down",
2910
3012
  status: "NotExecuted"
@@ -2912,33 +3014,33 @@ f = new WeakMap(), c = new WeakSet(), J = async function(e) {
2912
3014
  for (let s = 0; s < n.length; ++s) {
2913
3015
  const l = o[s];
2914
3016
  try {
2915
- l.down && (await l.down(e), await e.withPlugin(d(this, c, S)).deleteFrom(d(this, c, T)).where("name", "=", l.name).execute(), n[s] = {
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] = {
2916
3018
  migrationName: l.name,
2917
3019
  direction: "Down",
2918
3020
  status: "Success"
2919
3021
  });
2920
- } catch (i) {
3022
+ } catch (c) {
2921
3023
  throw n[s] = {
2922
3024
  migrationName: l.name,
2923
3025
  direction: "Down",
2924
3026
  status: "Error"
2925
3027
  }, new G({
2926
- error: i,
3028
+ error: c,
2927
3029
  results: n
2928
3030
  });
2929
3031
  }
2930
3032
  }
2931
3033
  return { results: n };
2932
- }, ze = async function(e, a, r) {
2933
- const n = a.pendingMigrations.slice(0, r).map((s) => ({
3034
+ }, ze = async function(e, r, a) {
3035
+ const n = r.pendingMigrations.slice(0, a).map((s) => ({
2934
3036
  migrationName: s.name,
2935
3037
  direction: "Up",
2936
3038
  status: "NotExecuted"
2937
3039
  }));
2938
3040
  for (let s = 0; s < n.length; s++) {
2939
- const l = a.pendingMigrations[s];
3041
+ const l = r.pendingMigrations[s];
2940
3042
  try {
2941
- await l.up(e), await e.withPlugin(d(this, c, S)).insertInto(d(this, c, T)).values({
3043
+ await l.up(e), await e.withPlugin(d(this, i, S)).insertInto(d(this, i, T)).values({
2942
3044
  name: l.name,
2943
3045
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2944
3046
  }).execute(), n[s] = {
@@ -2946,27 +3048,27 @@ f = new WeakMap(), c = new WeakSet(), J = async function(e) {
2946
3048
  direction: "Up",
2947
3049
  status: "Success"
2948
3050
  };
2949
- } catch (i) {
3051
+ } catch (c) {
2950
3052
  throw n[s] = {
2951
3053
  migrationName: l.name,
2952
3054
  direction: "Up",
2953
3055
  status: "Error"
2954
3056
  }, new G({
2955
- error: i,
3057
+ error: c,
2956
3058
  results: n
2957
3059
  });
2958
3060
  }
2959
3061
  }
2960
3062
  return { results: n };
2961
- }, E = async function(e) {
3063
+ }, J = async function(e) {
2962
3064
  d(this, f).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2963
3065
  };
2964
3066
  var K;
2965
3067
  class G extends Error {
2966
- constructor(a) {
3068
+ constructor(r) {
2967
3069
  super();
2968
- b(this, K);
2969
- L(this, K, a);
3070
+ N(this, K);
3071
+ L(this, K, r);
2970
3072
  }
2971
3073
  get resultSet() {
2972
3074
  return d(this, K);
@@ -2982,7 +3084,7 @@ class Le {
2982
3084
  return this.migrations;
2983
3085
  }
2984
3086
  }
2985
- async function _r(t) {
3087
+ async function _a(t) {
2986
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(
2987
3089
  "tenant_id",
2988
3090
  "varchar(255)",
@@ -3054,35 +3156,35 @@ async function _r(t) {
3054
3156
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
3055
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();
3056
3158
  }
3057
- async function hr(t) {
3159
+ async function ha(t) {
3058
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();
3059
3161
  }
3060
- const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3162
+ const fa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3061
3163
  __proto__: null,
3062
- down: hr,
3063
- up: _r
3164
+ down: ha,
3165
+ up: _a
3064
3166
  }, Symbol.toStringTag, { value: "Module" }));
3065
- async function pr(t) {
3167
+ async function pa(t) {
3066
3168
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
3067
3169
  }
3068
- async function gr(t) {
3170
+ async function ga(t) {
3069
3171
  await t.schema.alterTable("tenants").dropColumn("support_url").execute();
3070
3172
  }
3071
- const wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3173
+ const wa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3072
3174
  __proto__: null,
3073
- down: gr,
3074
- up: pr
3175
+ down: ga,
3176
+ up: pa
3075
3177
  }, Symbol.toStringTag, { value: "Module" }));
3076
- async function yr(t) {
3178
+ async function ya(t) {
3077
3179
  }
3078
- async function vr(t) {
3180
+ async function va(t) {
3079
3181
  }
3080
- const Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3182
+ const Na = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3081
3183
  __proto__: null,
3082
- down: vr,
3083
- up: yr
3184
+ down: va,
3185
+ up: ya
3084
3186
  }, Symbol.toStringTag, { value: "Module" }));
3085
- async function Cr(t) {
3187
+ async function Ca(t) {
3086
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(
3087
3189
  "tenant_id_constraint",
3088
3190
  ["tenant_id"],
@@ -3091,24 +3193,24 @@ async function Cr(t) {
3091
3193
  (e) => e.onDelete("cascade")
3092
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();
3093
3195
  }
3094
- async function br(t) {
3196
+ async function ba(t) {
3095
3197
  await t.schema.dropTable("logs").execute();
3096
3198
  }
3097
- const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3199
+ const xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3098
3200
  __proto__: null,
3099
- down: br,
3100
- up: Cr
3201
+ down: ba,
3202
+ up: Ca
3101
3203
  }, Symbol.toStringTag, { value: "Module" }));
3102
- async function Tr(t) {
3204
+ async function Ta(t) {
3103
3205
  }
3104
- async function Sr(t) {
3206
+ async function Sa(t) {
3105
3207
  }
3106
- const Or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3208
+ const Oa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3107
3209
  __proto__: null,
3108
- down: Sr,
3109
- up: Tr
3210
+ down: Sa,
3211
+ up: Ta
3110
3212
  }, Symbol.toStringTag, { value: "Module" }));
3111
- async function kr(t) {
3213
+ async function ka(t) {
3112
3214
  await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3113
3215
  "user_id_constraint",
3114
3216
  ["user_id", "tenant_id"],
@@ -3133,15 +3235,15 @@ async function kr(t) {
3133
3235
  (e) => e.references("applications.id").onDelete("cascade").notNull()
3134
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();
3135
3237
  }
3136
- async function $r(t) {
3238
+ async function $a(t) {
3137
3239
  await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
3138
3240
  }
3139
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3241
+ const Ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3140
3242
  __proto__: null,
3141
- down: $r,
3142
- up: kr
3243
+ down: $a,
3244
+ up: ka
3143
3245
  }, Symbol.toStringTag, { value: "Module" }));
3144
- async function Ir(t) {
3246
+ async function Da(t) {
3145
3247
  await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
3146
3248
  "user_id_constraint",
3147
3249
  ["user_id", "tenant_id"],
@@ -3156,24 +3258,24 @@ async function Ir(t) {
3156
3258
  (e) => e.onDelete("cascade")
3157
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();
3158
3260
  }
3159
- async function jr(t) {
3261
+ async function Pa(t) {
3160
3262
  await t.schema.dropTable("passwords").execute(), await t.schema.dropTable("codes").execute();
3161
3263
  }
3162
- const Pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3264
+ const ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3163
3265
  __proto__: null,
3164
- down: jr,
3165
- up: Ir
3266
+ down: Pa,
3267
+ up: Da
3166
3268
  }, Symbol.toStringTag, { value: "Module" }));
3167
- async function Fr(t) {
3269
+ async function Fa(t) {
3168
3270
  }
3169
- async function Mr(t) {
3271
+ async function Ma(t) {
3170
3272
  }
3171
- const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3273
+ const Aa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3172
3274
  __proto__: null,
3173
- down: Mr,
3174
- up: Fr
3275
+ down: Ma,
3276
+ up: Fa
3175
3277
  }, Symbol.toStringTag, { value: "Module" }));
3176
- async function zr(t) {
3278
+ async function za(t) {
3177
3279
  await t.schema.alterTable("passwords").addColumn(
3178
3280
  "password",
3179
3281
  "varchar(255)",
@@ -3181,72 +3283,72 @@ async function zr(t) {
3181
3283
  (e) => e.notNull()
3182
3284
  ).execute();
3183
3285
  }
3184
- async function Lr(t) {
3286
+ async function La(t) {
3185
3287
  await t.schema.alterTable("passwords").dropColumn("password").execute();
3186
3288
  }
3187
- const Jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3289
+ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3188
3290
  __proto__: null,
3189
- down: Lr,
3190
- up: zr
3291
+ down: La,
3292
+ up: za
3191
3293
  }, Symbol.toStringTag, { value: "Module" }));
3192
- async function Er(t) {
3294
+ async function Ja(t) {
3193
3295
  }
3194
- async function Rr(t) {
3296
+ async function Ra(t) {
3195
3297
  }
3196
- const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3298
+ const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3197
3299
  __proto__: null,
3198
- down: Rr,
3199
- up: Er
3300
+ down: Ra,
3301
+ up: Ja
3200
3302
  }, Symbol.toStringTag, { value: "Module" }));
3201
- async function Br(t) {
3303
+ async function Ua(t) {
3202
3304
  }
3203
- async function Ur(t) {
3305
+ async function Ba(t) {
3204
3306
  }
3205
- const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3307
+ const Qa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3206
3308
  __proto__: null,
3207
- down: Ur,
3208
- up: Br
3309
+ down: Ba,
3310
+ up: Ua
3209
3311
  }, Symbol.toStringTag, { value: "Module" }));
3210
- async function qr(t) {
3312
+ async function qa(t) {
3211
3313
  }
3212
- async function Vr(t) {
3314
+ async function Va(t) {
3213
3315
  }
3214
- const Wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3316
+ const Wa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3215
3317
  __proto__: null,
3216
- down: Vr,
3217
- up: qr
3318
+ down: Va,
3319
+ up: qa
3218
3320
  }, Symbol.toStringTag, { value: "Module" }));
3219
- async function Gr(t) {
3321
+ async function Ga(t) {
3220
3322
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
3221
3323
  }
3222
- async function Hr(t) {
3324
+ async function Ha(t) {
3223
3325
  await t.schema.dropIndex("users_email_index").execute();
3224
3326
  }
3225
- const Xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3327
+ const Xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3226
3328
  __proto__: null,
3227
- down: Hr,
3228
- up: Gr
3329
+ down: Ha,
3330
+ up: Ga
3229
3331
  }, Symbol.toStringTag, { value: "Module" }));
3230
- async function Yr(t) {
3332
+ async function Ya(t) {
3231
3333
  await t.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
3232
3334
  }
3233
- async function Zr(t) {
3335
+ async function Za(t) {
3234
3336
  await t.schema.alterTable("users").dropColumn("profileData").execute();
3235
3337
  }
3236
3338
  const en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3237
3339
  __proto__: null,
3238
- down: Zr,
3239
- up: Yr
3340
+ down: Za,
3341
+ up: Ya
3240
3342
  }, Symbol.toStringTag, { value: "Module" }));
3241
3343
  async function tn(t) {
3242
3344
  await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
3243
3345
  }
3244
- async function an(t) {
3346
+ async function rn(t) {
3245
3347
  await t.schema.dropIndex("users_linked_to_index");
3246
3348
  }
3247
- const rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3349
+ const an = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3248
3350
  __proto__: null,
3249
- down: an,
3351
+ down: rn,
3250
3352
  up: tn
3251
3353
  }, Symbol.toStringTag, { value: "Module" }));
3252
3354
  async function nn(t) {
@@ -3338,24 +3440,24 @@ const kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3338
3440
  async function $n(t) {
3339
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();
3340
3442
  }
3341
- async function Dn(t) {
3443
+ async function In(t) {
3342
3444
  await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
3343
3445
  }
3344
- const In = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3446
+ const Dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3345
3447
  __proto__: null,
3346
- down: Dn,
3448
+ down: In,
3347
3449
  up: $n
3348
3450
  }, Symbol.toStringTag, { value: "Module" }));
3349
- async function jn(t) {
3451
+ async function Pn(t) {
3350
3452
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
3351
3453
  }
3352
- async function Pn(t) {
3454
+ async function jn(t) {
3353
3455
  await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
3354
3456
  }
3355
3457
  const Fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3356
3458
  __proto__: null,
3357
- down: Pn,
3358
- up: jn
3459
+ down: jn,
3460
+ up: Pn
3359
3461
  }, Symbol.toStringTag, { value: "Module" }));
3360
3462
  async function Mn(t) {
3361
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();
@@ -3371,12 +3473,12 @@ const zn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3371
3473
  async function Ln(t) {
3372
3474
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
3373
3475
  }
3374
- async function Jn(t) {
3476
+ async function En(t) {
3375
3477
  await t.schema.dropIndex("users_name_index").execute();
3376
3478
  }
3377
- const En = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3479
+ const Jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3378
3480
  __proto__: null,
3379
- down: Jn,
3481
+ down: En,
3380
3482
  up: Ln
3381
3483
  }, Symbol.toStringTag, { value: "Module" }));
3382
3484
  async function Rn(t) {
@@ -3384,12 +3486,12 @@ async function Rn(t) {
3384
3486
  async function Kn(t) {
3385
3487
  await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
3386
3488
  }
3387
- const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3489
+ const Un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3388
3490
  __proto__: null,
3389
3491
  down: Kn,
3390
3492
  up: Rn
3391
3493
  }, Symbol.toStringTag, { value: "Module" }));
3392
- async function Un(t) {
3494
+ async function Bn(t) {
3393
3495
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
3394
3496
  }
3395
3497
  async function Qn(t) {
@@ -3398,7 +3500,7 @@ async function Qn(t) {
3398
3500
  const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3399
3501
  __proto__: null,
3400
3502
  down: Qn,
3401
- up: Un
3503
+ up: Bn
3402
3504
  }, Symbol.toStringTag, { value: "Module" }));
3403
3505
  async function Vn(t) {
3404
3506
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
@@ -3435,14 +3537,14 @@ const to = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3435
3537
  down: eo,
3436
3538
  up: Zn
3437
3539
  }, Symbol.toStringTag, { value: "Module" }));
3438
- async function ao(t) {
3439
- }
3440
3540
  async function ro(t) {
3441
3541
  }
3542
+ async function ao(t) {
3543
+ }
3442
3544
  const no = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3443
3545
  __proto__: null,
3444
- down: ro,
3445
- up: ao
3546
+ down: ao,
3547
+ up: ro
3446
3548
  }, Symbol.toStringTag, { value: "Module" }));
3447
3549
  async function oo(t) {
3448
3550
  }
@@ -3540,23 +3642,23 @@ const $o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3540
3642
  down: ko,
3541
3643
  up: Oo
3542
3644
  }, Symbol.toStringTag, { value: "Module" }));
3543
- async function Do(t) {
3544
- }
3545
3645
  async function Io(t) {
3546
3646
  }
3547
- const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3647
+ async function Do(t) {
3648
+ }
3649
+ const Po = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3548
3650
  __proto__: null,
3549
- down: Io,
3550
- up: Do
3651
+ down: Do,
3652
+ up: Io
3551
3653
  }, Symbol.toStringTag, { value: "Module" }));
3552
- async function Po(t) {
3654
+ async function jo(t) {
3553
3655
  }
3554
3656
  async function Fo(t) {
3555
3657
  }
3556
3658
  const Mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3557
3659
  __proto__: null,
3558
3660
  down: Fo,
3559
- up: Po
3661
+ up: jo
3560
3662
  }, Symbol.toStringTag, { value: "Module" }));
3561
3663
  async function Ao(t) {
3562
3664
  await t.schema.createTable("logins").addColumn("login_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
@@ -3589,24 +3691,24 @@ const Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3589
3691
  down: zo,
3590
3692
  up: Ao
3591
3693
  }, Symbol.toStringTag, { value: "Module" }));
3592
- async function Jo(t) {
3593
- }
3594
3694
  async function Eo(t) {
3595
3695
  }
3696
+ async function Jo(t) {
3697
+ }
3596
3698
  const Ro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3597
3699
  __proto__: null,
3598
- down: Eo,
3599
- up: Jo
3700
+ down: Jo,
3701
+ up: Eo
3600
3702
  }, Symbol.toStringTag, { value: "Module" }));
3601
3703
  async function Ko(t) {
3602
3704
  await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3603
3705
  }
3604
- async function Bo(t) {
3706
+ async function Uo(t) {
3605
3707
  await t.schema.alterTable("logins").dropColumn("auth0Client").execute();
3606
3708
  }
3607
- const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3709
+ const Bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3608
3710
  __proto__: null,
3609
- down: Bo,
3711
+ down: Uo,
3610
3712
  up: Ko
3611
3713
  }, Symbol.toStringTag, { value: "Module" }));
3612
3714
  async function Qo(t) {
@@ -3644,19 +3746,19 @@ async function es(t) {
3644
3746
  async function ts(t) {
3645
3747
  await t.schema.alterTable("logins").dropColumn("nonce").execute();
3646
3748
  }
3647
- const as = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3749
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3648
3750
  __proto__: null,
3649
3751
  down: ts,
3650
3752
  up: es
3651
3753
  }, Symbol.toStringTag, { value: "Module" }));
3652
- async function rs(t) {
3754
+ async function as(t) {
3653
3755
  }
3654
3756
  async function ns(t) {
3655
3757
  }
3656
3758
  const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3657
3759
  __proto__: null,
3658
3760
  down: ns,
3659
- up: rs
3761
+ up: as
3660
3762
  }, Symbol.toStringTag, { value: "Module" }));
3661
3763
  async function ss(t) {
3662
3764
  }
@@ -3793,16 +3895,16 @@ const $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3793
3895
  down: ks,
3794
3896
  up: Os
3795
3897
  }, Symbol.toStringTag, { value: "Module" }));
3796
- async function Ds(t) {
3797
- }
3798
3898
  async function Is(t) {
3799
3899
  }
3800
- const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3900
+ async function Ds(t) {
3901
+ }
3902
+ const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3801
3903
  __proto__: null,
3802
- down: Is,
3803
- up: Ds
3904
+ down: Ds,
3905
+ up: Is
3804
3906
  }, Symbol.toStringTag, { value: "Module" }));
3805
- async function Ps(t) {
3907
+ async function js(t) {
3806
3908
  await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
3807
3909
  }
3808
3910
  async function Fs(t) {
@@ -3811,7 +3913,7 @@ async function Fs(t) {
3811
3913
  const Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3812
3914
  __proto__: null,
3813
3915
  down: Fs,
3814
- up: Ps
3916
+ up: js
3815
3917
  }, Symbol.toStringTag, { value: "Module" }));
3816
3918
  async function As(t) {
3817
3919
  await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
@@ -3824,24 +3926,24 @@ const Ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3824
3926
  down: zs,
3825
3927
  up: As
3826
3928
  }, Symbol.toStringTag, { value: "Module" }));
3827
- async function Js(t) {
3828
- }
3829
3929
  async function Es(t) {
3830
3930
  }
3931
+ async function Js(t) {
3932
+ }
3831
3933
  const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3832
3934
  __proto__: null,
3833
- down: Es,
3834
- up: Js
3935
+ down: Js,
3936
+ up: Es
3835
3937
  }, Symbol.toStringTag, { value: "Module" }));
3836
3938
  async function Ks(t) {
3837
3939
  await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
3838
3940
  }
3839
- async function Bs(t) {
3941
+ async function Us(t) {
3840
3942
  await t.schema.alterTable("logins").dropColumn("authParam_act_as").execute();
3841
3943
  }
3842
- const Us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3944
+ const Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3843
3945
  __proto__: null,
3844
- down: Bs,
3946
+ down: Us,
3845
3947
  up: Ks
3846
3948
  }, Symbol.toStringTag, { value: "Module" }));
3847
3949
  async function Qs(t) {
@@ -3898,12 +4000,12 @@ async function ei(t) {
3898
4000
  async function ti(t) {
3899
4001
  await t.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
3900
4002
  }
3901
- const ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4003
+ const ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3902
4004
  __proto__: null,
3903
4005
  down: ti,
3904
4006
  up: ei
3905
4007
  }, Symbol.toStringTag, { value: "Module" }));
3906
- async function ri(t) {
4008
+ async function ai(t) {
3907
4009
  await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3908
4010
  "client_id",
3909
4011
  "varchar(21)",
@@ -3922,7 +4024,7 @@ async function ni(t) {
3922
4024
  const oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3923
4025
  __proto__: null,
3924
4026
  down: ni,
3925
- up: ri
4027
+ up: ai
3926
4028
  }, Symbol.toStringTag, { value: "Module" }));
3927
4029
  async function si(t) {
3928
4030
  }
@@ -4075,17 +4177,17 @@ const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4075
4177
  down: ki,
4076
4178
  up: Oi
4077
4179
  }, Symbol.toStringTag, { value: "Module" }));
4078
- async function Di(t) {
4180
+ async function Ii(t) {
4079
4181
  await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
4080
4182
  }
4081
- async function Ii(t) {
4183
+ async function Di(t) {
4082
4184
  }
4083
- const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4185
+ const Pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4084
4186
  __proto__: null,
4085
- down: Ii,
4086
- up: Di
4187
+ down: Di,
4188
+ up: Ii
4087
4189
  }, Symbol.toStringTag, { value: "Module" }));
4088
- async function Pi(t) {
4190
+ async function ji(t) {
4089
4191
  await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
4090
4192
  "custom_domain_id",
4091
4193
  "varchar(256)",
@@ -4101,7 +4203,7 @@ async function Fi(t) {
4101
4203
  const Mi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4102
4204
  __proto__: null,
4103
4205
  down: Fi,
4104
- up: Pi
4206
+ up: ji
4105
4207
  }, Symbol.toStringTag, { value: "Module" }));
4106
4208
  async function Ai(t) {
4107
4209
  }
@@ -4113,26 +4215,26 @@ const Li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4113
4215
  down: zi,
4114
4216
  up: Ai
4115
4217
  }, Symbol.toStringTag, { value: "Module" }));
4116
- async function Ji(t) {
4218
+ async function Ei(t) {
4117
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();
4118
4220
  }
4119
- async function Ei(t) {
4221
+ async function Ji(t) {
4120
4222
  await t.schema.dropTable("forms").execute();
4121
4223
  }
4122
4224
  const Ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4123
4225
  __proto__: null,
4124
- down: Ei,
4125
- up: Ji
4226
+ down: Ji,
4227
+ up: Ei
4126
4228
  }, Symbol.toStringTag, { value: "Module" }));
4127
4229
  async function Ki(t) {
4128
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();
4129
4231
  }
4130
- async function Bi(t) {
4232
+ async function Ui(t) {
4131
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();
4132
4234
  }
4133
- const Ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4235
+ const Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4134
4236
  __proto__: null,
4135
- down: Bi,
4237
+ down: Ui,
4136
4238
  up: Ki
4137
4239
  }, Symbol.toStringTag, { value: "Module" }));
4138
4240
  async function Qi(t) {
@@ -4182,12 +4284,12 @@ async function el(t) {
4182
4284
  async function tl(t) {
4183
4285
  await t.schema.alterTable("codes").dropColumn("code_challenge").execute(), await t.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
4184
4286
  }
4185
- const al = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4287
+ const rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4186
4288
  __proto__: null,
4187
4289
  down: tl,
4188
4290
  up: el
4189
4291
  }, Symbol.toStringTag, { value: "Module" }));
4190
- async function rl(t) {
4292
+ async function al(t) {
4191
4293
  await t.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
4192
4294
  }
4193
4295
  async function nl(t) {
@@ -4196,7 +4298,7 @@ async function nl(t) {
4196
4298
  const ol = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4197
4299
  __proto__: null,
4198
4300
  down: nl,
4199
- up: rl
4301
+ up: al
4200
4302
  }, Symbol.toStringTag, { value: "Module" }));
4201
4303
  async function sl(t) {
4202
4304
  await t.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await t.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
@@ -4293,35 +4395,60 @@ const ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4293
4395
  up: cl
4294
4396
  }, Symbol.toStringTag, { value: "Module" }));
4295
4397
  async function ml(t) {
4296
- await t.schema.createTable("resource_servers").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("identifier", "varchar(191)", (e) => e.notNull()).addColumn("scopes", "varchar(4096)").addColumn("signing_alg", "varchar(64)").addColumn("signing_secret", "varchar(2048)").addColumn("token_lifetime", "integer").addColumn("token_lifetime_for_web", "integer").addColumn("skip_consent_for_verifiable_first_party_clients", "integer").addColumn("allow_offline_access", "integer").addColumn("verification_key", "varchar(4096)").addColumn("options", "varchar(4096)").execute(), await t.schema.createIndex("resource_servers_tenant_identifier_uq").on("resource_servers").columns(["tenant_id", "identifier"]).unique().execute(), await t.schema.createTable("rules").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("name", "varchar(255)", (e) => e.notNull()).addColumn("script", "varchar(8192)", (e) => e.notNull()).addColumn("order", "integer").addColumn("enabled", "integer").addColumn("stage", "varchar(64)").addColumn("created_at", "varchar(255)").addColumn("updated_at", "varchar(255)").execute(), await t.schema.createIndex("rules_tenant_id_idx").on("rules").column("tenant_id").execute(), await t.schema.createTable("permissions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("permission_name", "varchar(255)", (e) => e.notNull()).addColumn("description", "varchar(1024)").addColumn(
4297
- "resource_server_identifier",
4298
- "varchar(191)",
4299
- (e) => e.notNull()
4300
- ).addColumn("resource_server_name", "varchar(255)", (e) => e.notNull()).addColumn("sources", "varchar(4096)").execute(), await t.schema.createIndex("permissions_tenant_identifier_name_uq").on("permissions").columns(["tenant_id", "resource_server_identifier", "permission_name"]).unique().execute();
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();
4301
4399
  }
4302
4400
  async function _l(t) {
4303
- await t.schema.dropTable("permissions").execute(), await t.schema.dropTable("rules").execute(), await t.schema.dropTable("resource_servers").execute();
4401
+ await t.schema.dropTable("roles").execute(), await t.schema.dropTable("resource_servers").execute();
4304
4402
  }
4305
4403
  const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4306
4404
  __proto__: null,
4307
4405
  down: _l,
4308
4406
  up: ml
4309
- }, Symbol.toStringTag, { value: "Module" })), Je = {
4310
- m1_init: fr,
4311
- m2_magicLink: wr,
4312
- m3_updateAt: Nr,
4313
- m4_logTable: xr,
4314
- m5_userProfile: Or,
4315
- m6_sessions: Dr,
4316
- m7_passwords: Pr,
4317
- m8_logsTableNewFields: Ar,
4318
- m9_passwordTableNewField: Jr,
4319
- n01_codesTable: Kr,
4320
- n11_universalLoginSession: Qr,
4321
- n12_userFields: Wr,
4322
- n13_userEmailIndex: Xr,
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(
4419
+ "resource_server_identifier",
4420
+ "varchar(191)",
4421
+ (e) => e.notNull()
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();
4428
+ }
4429
+ async function pl(t) {
4430
+ await t.schema.dropTable("user_permissions").execute(), await t.schema.dropTable("role_permissions").execute();
4431
+ }
4432
+ const gl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4433
+ __proto__: null,
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,
4323
4450
  n14_profileDataField: en,
4324
- n15_userEmailIndex: rn,
4451
+ n15_userEmailIndex: an,
4325
4452
  n16_userLocale: sn,
4326
4453
  n17_signingKeys: dn,
4327
4454
  n18_logsFields: _n,
@@ -4330,11 +4457,11 @@ const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4330
4457
  n21_sessionDeletedAt: Cn,
4331
4458
  n22_dropLogsFields: Tn,
4332
4459
  n23_dropUsersFields: kn,
4333
- n24_logsIndexes: In,
4460
+ n24_logsIndexes: Dn,
4334
4461
  n25_logDescMaxLength: Fn,
4335
4462
  n26_logsTableExtraFields: zn,
4336
- n27_usersTableNameIndex: En,
4337
- n28_usersEmailConstrain: Bn,
4463
+ n27_usersTableNameIndex: Jn,
4464
+ n28_usersEmailConstrain: Un,
4338
4465
  n29_increaseOtpStateLength: qn,
4339
4466
  n30_increaseTicketStateLength: Gn,
4340
4467
  n31_branding: Yn,
@@ -4348,15 +4475,15 @@ const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4348
4475
  n39_increaseUserAgentLength: bo,
4349
4476
  n40_userId: So,
4350
4477
  n41_hooks: $o,
4351
- n42_userIdIndexes: jo,
4478
+ n42_userIdIndexes: Po,
4352
4479
  n43_userIdIndexes: Mo,
4353
4480
  n44_codes: Lo,
4354
4481
  n45_hookProperties: Ro,
4355
- n46_loginAuth0Client: Uo,
4482
+ n46_loginAuth0Client: Bo,
4356
4483
  n47_loginAuth0Client: Vo,
4357
4484
  n48_saml: Ho,
4358
4485
  n49_removeFields: Zo,
4359
- n50_authParamsNonce: as,
4486
+ n50_authParamsNonce: rs,
4360
4487
  n51_connectionid: os,
4361
4488
  n52_cert: ls,
4362
4489
  n53_codes_primary_key: us,
@@ -4366,15 +4493,15 @@ const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4366
4493
  n57_prompt_settings: bs,
4367
4494
  n58_connection_client_id: Ss,
4368
4495
  n59_connection_options: $s,
4369
- n60_users_metadata: js,
4496
+ n60_users_metadata: Ps,
4370
4497
  n61_userLocales: Ms,
4371
4498
  n62_prompt: Ls,
4372
4499
  n63_connection_cleanup: Rs,
4373
- n64_act_as: Us,
4500
+ n64_act_as: Bs,
4374
4501
  n65_code_verifier: Vs,
4375
4502
  n66_email_providers: Hs,
4376
4503
  n67_drop_tickets: Zs,
4377
- n68_login_useragents: ai,
4504
+ n68_login_useragents: ri,
4378
4505
  n70_refresh_tokens: oi,
4379
4506
  n71_session_new_fields: li,
4380
4507
  n72_session_primary_key: ui,
@@ -4384,26 +4511,27 @@ const hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4384
4511
  n76_authorization_url_length: bi,
4385
4512
  n77_drop_sessions: Si,
4386
4513
  n78_login_sessions: $i,
4387
- n79_drop_sessions_2: ji,
4514
+ n79_drop_sessions_2: Pi,
4388
4515
  n80_recreate_custom_domains: Mi,
4389
4516
  n81_phone: Li,
4390
4517
  n82_forms: Ri,
4391
- n83_addFormsIdToHooks: Ui,
4518
+ n83_addFormsIdToHooks: Bi,
4392
4519
  n84_login_completed: Vi,
4393
4520
  n85_add_login_session_id_to_sessions: Hi,
4394
4521
  n86_index_sessions_login_session_id: Zi,
4395
- n87_code_challenge: al,
4522
+ n87_code_challenge: rl,
4396
4523
  n88_add_redirect_uri_to_codes: ol,
4397
4524
  n89_add_nonce_and_state_to_codes: ll,
4398
4525
  n90_themes: ul,
4399
- n91_resource_servers_rules_permissions: hl
4526
+ n91_resource_servers_rules_permissions: hl,
4527
+ n92_role_permissions: gl
4400
4528
  };
4401
- async function yl(t, e = !1) {
4529
+ async function Cl(t, e = !1) {
4402
4530
  e && console.log("migrating...");
4403
- const a = new Le(Je), r = new be({
4531
+ const r = new Le(Ee), a = new be({
4404
4532
  db: t,
4405
- provider: a
4406
- }), { error: o, results: n } = await r.migrateToLatest();
4533
+ provider: r
4534
+ }), { error: o, results: n } = await a.migrateToLatest();
4407
4535
  if (n == null || n.forEach((s) => {
4408
4536
  s.status === "Success" ? e && console.log(
4409
4537
  `migration "${s.migrationName}" was executed successfully`
@@ -4411,46 +4539,47 @@ async function yl(t, e = !1) {
4411
4539
  }), o)
4412
4540
  throw console.error("failed to migrate"), console.error(o), o;
4413
4541
  }
4414
- async function vl(t) {
4542
+ async function bl(t) {
4415
4543
  console.log("migrating...");
4416
- const e = new Le(Je), a = new be({
4544
+ const e = new Le(Ee), r = new be({
4417
4545
  db: t,
4418
4546
  provider: e
4419
- }), { error: r, results: o } = await a.migrateDown();
4547
+ }), { error: a, results: o } = await r.migrateDown();
4420
4548
  if (o == null || o.forEach((n) => {
4421
4549
  n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
4422
- }), r)
4423
- throw console.error("failed to migrate"), console.error(r), r;
4550
+ }), a)
4551
+ throw console.error("failed to migrate"), console.error(a), a;
4424
4552
  }
4425
- function Nl(t) {
4553
+ function xl(t) {
4426
4554
  return {
4427
- applications: Mt(t),
4428
- branding: aa(t),
4429
- cleanup: ja(t),
4430
- clients: Kt(t),
4431
- codes: $t(t),
4432
- connections: Rt(t),
4433
- emailProviders: Ta(t),
4434
- customDomains: Zt(t),
4435
- forms: La(t),
4436
- hooks: la(t),
4437
- keys: qt(t),
4438
- loginSessions: wa(t),
4439
- logs: _t(t),
4440
- passwords: bt(t),
4441
- promptSettings: Na(t),
4442
- refreshTokens: Ia(t),
4443
- resourceServers: Ua(t),
4444
- rules: Ha(t),
4445
- permissions: ar(t),
4446
- sessions: yt(t),
4447
- tenants: lt(t),
4448
- themes: _a(t),
4449
- users: tt(t)
4555
+ applications: jt(t),
4556
+ branding: er(t),
4557
+ cleanup: Ir(t),
4558
+ clients: Jt(t),
4559
+ codes: Ot(t),
4560
+ connections: 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)
4450
4579
  };
4451
4580
  }
4452
4581
  export {
4453
- Nl as default,
4454
- vl as migrateDown,
4455
- yl as migrateToLatest
4582
+ xl as default,
4583
+ bl as migrateDown,
4584
+ Cl as migrateToLatest
4456
4585
  };