@authhero/kysely-adapter 10.78.0 → 10.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,9 +3,9 @@ var Sn = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
5
  var Ga = (t, e, n) => e in t ? Va(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var ie = (t, e, n) => Ga(t, typeof e != "symbol" ? e + "" : e, n), Vt = (t, e, n) => e.has(t) || Sn("Cannot " + n);
7
- var s = (t, e, n) => (Vt(t, e, "read from private field"), n ? n.call(t) : e.get(t)), x = (t, e, n) => e.has(t) ? Sn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), b = (t, e, n, a) => (Vt(t, e, "write to private field"), a ? a.call(t, n) : e.set(t, n), n), y = (t, e, n) => (Vt(t, e, "access private method"), n);
8
- import { parseUserId as gn, flowSchema as Jt, codeSchema as Ya, connectionSchema as Ha, loginSessionSchema as Xa, LoginSessionState as Zn, promptSettingSchema as Za, formSchema as bt, resourceServerSchema as er } from "@authhero/adapter-interfaces";
6
+ var ce = (t, e, n) => Ga(t, typeof e != "symbol" ? e + "" : e, n), Vt = (t, e, n) => e.has(t) || Sn("Cannot " + n);
7
+ var s = (t, e, n) => (Vt(t, e, "read from private field"), n ? n.call(t) : e.get(t)), x = (t, e, n) => e.has(t) ? Sn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), b = (t, e, n, a) => (Vt(t, e, "write to private field"), a ? a.call(t, n) : e.set(t, n), n), N = (t, e, n) => (Vt(t, e, "access private method"), n);
8
+ import { parseUserId as gn, flowSchema as Mt, codeSchema as Ya, connectionSchema as Ha, loginSessionSchema as Xa, LoginSessionState as Zn, promptSettingSchema as Za, formSchema as bt, resourceServerSchema as er } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var Ie = class extends Error {
11
11
  /**
@@ -15,8 +15,8 @@ var Ie = class extends Error {
15
15
  */
16
16
  constructor(e = 500, n) {
17
17
  super(n == null ? void 0 : n.message, { cause: n == null ? void 0 : n.cause });
18
- ie(this, "res");
19
- ie(this, "status");
18
+ ce(this, "res");
19
+ ce(this, "status");
20
20
  this.res = n == null ? void 0 : n.res, this.status = e;
21
21
  }
22
22
  /**
@@ -130,65 +130,65 @@ function R(t, e, n, a) {
130
130
  const r = n.split(/ OR /i);
131
131
  if (r.length > 1)
132
132
  return e.where((d) => {
133
- const h = r.map((u) => {
134
- const g = u.trim().match(/^([^:]+):(.+)$/);
135
- if (g) {
136
- const [, f, N] = g;
137
- if (!f || !N) return null;
138
- const C = N.replace(/^"(.*)"$/, "$1");
139
- return d(f.trim(), "=", C.trim());
133
+ const m = r.map((u) => {
134
+ const f = u.trim().match(/^([^:]+):(.+)$/);
135
+ if (f) {
136
+ const [, p, y] = f;
137
+ if (!p || !y) return null;
138
+ const C = y.replace(/^"(.*)"$/, "$1");
139
+ return d(p.trim(), "=", C.trim());
140
140
  }
141
141
  return null;
142
142
  }).filter(Boolean);
143
- return d.or(h);
143
+ return d.or(m);
144
144
  });
145
145
  const o = [];
146
146
  let i = "", l = !1;
147
147
  for (let d = 0; d < n.length; d++) {
148
- const h = n[d];
149
- h === '"' ? (l = !l, i += h) : h === " " && !l ? i.trim() && (o.push(i.trim()), i = "") : i += h;
148
+ const m = n[d];
149
+ m === '"' ? (l = !l, i += m) : m === " " && !l ? i.trim() && (o.push(i.trim()), i = "") : i += m;
150
150
  }
151
151
  return i.trim() && o.push(i.trim()), o.map((d) => d.replace(/^([^:]+)=/g, "$1:")).map((d) => {
152
- let h = d.startsWith("-"), u = null, g = "", f = !1, N;
152
+ let m = d.startsWith("-"), u = null, f = "", p = !1, y;
153
153
  if (d.startsWith("-_exists_:"))
154
- u = d.substring(10), f = !0, h = !0;
154
+ u = d.substring(10), p = !0, m = !0;
155
155
  else if (d.startsWith("_exists_:"))
156
- u = d.substring(9), f = !0, h = !1;
156
+ u = d.substring(9), p = !0, m = !1;
157
157
  else if (d.includes(":")) {
158
- const C = h ? d.substring(1) : d, O = C.indexOf(":");
159
- u = C.substring(0, O), g = C.substring(O + 1), f = !1, g.startsWith(">=") ? (N = ">=", g = g.substring(2)) : g.startsWith(">") ? (N = ">", g = g.substring(1)) : g.startsWith("<=") ? (N = "<=", g = g.substring(2)) : g.startsWith("<") ? (N = "<", g = g.substring(1)) : N = "=", g.startsWith('"') && g.endsWith('"') && g.length > 1 && (g = g.slice(1, -1));
158
+ const C = m ? d.substring(1) : d, O = C.indexOf(":");
159
+ u = C.substring(0, O), f = C.substring(O + 1), p = !1, f.startsWith(">=") ? (y = ">=", f = f.substring(2)) : f.startsWith(">") ? (y = ">", f = f.substring(1)) : f.startsWith("<=") ? (y = "<=", f = f.substring(2)) : f.startsWith("<") ? (y = "<", f = f.substring(1)) : y = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
160
160
  } else
161
- u = null, g = d, f = !1;
162
- return { key: u, value: g, isNegation: h, isExistsQuery: f, operator: N };
163
- }).forEach(({ key: d, value: h, isNegation: u, isExistsQuery: g, operator: f }) => {
161
+ u = null, f = d, p = !1;
162
+ return { key: u, value: f, isNegation: m, isExistsQuery: p, operator: y };
163
+ }).forEach(({ key: d, value: m, isNegation: u, isExistsQuery: f, operator: p }) => {
164
164
  if (d)
165
- if (g)
165
+ if (f)
166
166
  u ? e = e.where(d, "is", null) : e = e.where(d, "is not", null);
167
167
  else if (u)
168
- switch (f) {
168
+ switch (p) {
169
169
  case ">":
170
- e = e.where(d, "<=", h);
170
+ e = e.where(d, "<=", m);
171
171
  break;
172
172
  case ">=":
173
- e = e.where(d, "<", h);
173
+ e = e.where(d, "<", m);
174
174
  break;
175
175
  case "<":
176
- e = e.where(d, ">=", h);
176
+ e = e.where(d, ">=", m);
177
177
  break;
178
178
  case "<=":
179
- e = e.where(d, ">", h);
179
+ e = e.where(d, ">", m);
180
180
  break;
181
181
  default:
182
- e = e.where(d, "!=", h);
182
+ e = e.where(d, "!=", m);
183
183
  }
184
184
  else
185
- e = e.where(d, f, h);
186
- else if (h) {
187
- const { ref: N } = t.dynamic, C = h.includes("|") ? [...a, "user_id"] : a;
185
+ e = e.where(d, p, m);
186
+ else if (m) {
187
+ const { ref: y } = t.dynamic, C = m.includes("|") ? [...a, "user_id"] : a;
188
188
  e = e.where(
189
189
  (O) => O.or(
190
190
  C.map(
191
- (A) => A === "user_id" ? O(N(A), "=", h) : O(N(A), "like", `%${h}%`)
191
+ (A) => A === "user_id" ? O(y(A), "=", m) : O(y(A), "like", `%${m}%`)
192
192
  )
193
193
  )
194
194
  );
@@ -206,8 +206,8 @@ function ar(t) {
206
206
  const { ref: C } = t.dynamic;
207
207
  _ = _.orderBy(C(i.sort_by), i.sort_order);
208
208
  }
209
- const h = await _.offset(a * r).limit(r).selectAll().execute(), u = h.map((C) => C.user_id), g = u.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", u).execute() : [], f = h.map((C) => {
210
- const O = g.filter(
209
+ const m = await _.offset(a * r).limit(r).selectAll().execute(), u = m.map((C) => C.user_id), f = u.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", u).execute() : [], p = m.map((C) => {
210
+ const O = f.filter(
211
211
  (A) => A.linked_to === C.user_id
212
212
  );
213
213
  return T({
@@ -229,17 +229,17 @@ function ar(t) {
229
229
  });
230
230
  if (!o)
231
231
  return {
232
- users: f,
232
+ users: p,
233
233
  start: 0,
234
234
  limit: 0,
235
235
  length: 0
236
236
  };
237
- const { count: N } = await _.select((C) => C.fn.countAll().as("count")).executeTakeFirstOrThrow();
237
+ const { count: y } = await _.select((C) => C.fn.countAll().as("count")).executeTakeFirstOrThrow();
238
238
  return {
239
- users: f,
239
+ users: p,
240
240
  start: a * r,
241
241
  limit: r,
242
- length: F(N)
242
+ length: F(y)
243
243
  };
244
244
  };
245
245
  }
@@ -319,7 +319,7 @@ let lr = (t) => crypto.getRandomValues(new Uint8Array(t)), ur = (t, e, n) => {
319
319
  };
320
320
  function _r(t) {
321
321
  return async (e, n) => {
322
- const a = (/* @__PURE__ */ new Date()).toISOString(), r = Jt.parse({
322
+ const a = (/* @__PURE__ */ new Date()).toISOString(), r = Mt.parse({
323
323
  id: `af_${B()}`,
324
324
  ...n,
325
325
  actions: n.actions || [],
@@ -359,7 +359,7 @@ function mr(t) {
359
359
  ...a,
360
360
  actions: wn(a.actions, [])
361
361
  };
362
- return Jt.parse(T(r));
362
+ return Mt.parse(T(r));
363
363
  };
364
364
  }
365
365
  function hr(t) {
@@ -367,23 +367,23 @@ function hr(t) {
367
367
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, q: i } = n;
368
368
  let l = t.selectFrom("flows").where("tenant_id", "=", e);
369
369
  i && (l = R(t, l, i, []));
370
- const h = (await l.offset(a * r).limit(r).selectAll().execute()).map((g) => {
371
- const f = {
372
- ...g,
373
- actions: wn(g.actions, [])
370
+ const m = (await l.offset(a * r).limit(r).selectAll().execute()).map((f) => {
371
+ const p = {
372
+ ...f,
373
+ actions: wn(f.actions, [])
374
374
  };
375
- return Jt.parse(T(f));
375
+ return Mt.parse(T(p));
376
376
  });
377
377
  if (!o)
378
378
  return {
379
- flows: h,
379
+ flows: m,
380
380
  start: 0,
381
381
  limit: 0,
382
382
  length: 0
383
383
  };
384
- const { count: u } = await l.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow();
384
+ const { count: u } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
385
385
  return {
386
- flows: h,
386
+ flows: m,
387
387
  start: a * r,
388
388
  limit: r,
389
389
  length: F(u)
@@ -400,7 +400,7 @@ function fr(t) {
400
400
  const { numUpdatedRows: o } = await t.updateTable("flows").set(r).where("id", "=", n).where("tenant_id", "=", e).executeTakeFirst();
401
401
  if (o === 0n) return null;
402
402
  const i = await t.selectFrom("flows").selectAll().where("id", "=", n).where("tenant_id", "=", e).executeTakeFirst();
403
- return i ? Jt.parse({
403
+ return i ? Mt.parse({
404
404
  ...i,
405
405
  actions: i.actions ? JSON.parse(i.actions) : []
406
406
  }) : null;
@@ -497,21 +497,21 @@ function vr(t) {
497
497
  let n = t.selectFrom("tenants");
498
498
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, sort: i, q: l } = e;
499
499
  if (i && i.sort_by) {
500
- const { ref: f } = t.dynamic;
501
- n = n.orderBy(f(i.sort_by), i.sort_order);
500
+ const { ref: p } = t.dynamic;
501
+ n = n.orderBy(p(i.sort_by), i.sort_order);
502
502
  }
503
503
  l && (n = R(t, n, l, ["friendly_name"]));
504
- const h = (await n.offset(a * r).limit(r).selectAll().execute()).map(ra);
504
+ const m = (await n.offset(a * r).limit(r).selectAll().execute()).map(ra);
505
505
  if (!o)
506
506
  return {
507
- tenants: h
507
+ tenants: m
508
508
  };
509
- const { count: u } = await n.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow(), g = F(u);
509
+ const { count: u } = await n.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = F(u);
510
510
  return {
511
- tenants: h,
511
+ tenants: m,
512
512
  start: a * r,
513
513
  limit: r,
514
- length: g
514
+ length: f
515
515
  };
516
516
  };
517
517
  }
@@ -606,8 +606,8 @@ function Sr(t) {
606
606
  l && (_ = R(t, _, l, ["user_id", "ip"]));
607
607
  let d = _;
608
608
  if (i && i.sort_by) {
609
- const { ref: f } = t.dynamic;
610
- d = d.orderBy(f(i.sort_by), i.sort_order);
609
+ const { ref: p } = t.dynamic;
610
+ d = d.orderBy(p(i.sort_by), i.sort_order);
611
611
  }
612
612
  d = d.offset(a * r).limit(r);
613
613
  const u = (await d.selectAll().execute()).map(ia);
@@ -618,12 +618,12 @@ function Sr(t) {
618
618
  limit: 0,
619
619
  length: 0
620
620
  };
621
- const { count: g } = await _.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
621
+ const { count: f } = await _.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow();
622
622
  return {
623
623
  logs: u,
624
624
  start: a * r,
625
625
  limit: r,
626
- length: F(g)
626
+ length: F(f)
627
627
  };
628
628
  };
629
629
  }
@@ -691,14 +691,14 @@ function Dr(t) {
691
691
  l && (_ = R(t, _, l, ["user_id", "session_id"]));
692
692
  let d = _;
693
693
  if (i && i.sort_by) {
694
- const { ref: N } = t.dynamic;
695
- d = d.orderBy(N(i.sort_by), i.sort_order);
694
+ const { ref: y } = t.dynamic;
695
+ d = d.orderBy(y(i.sort_by), i.sort_order);
696
696
  }
697
697
  d = d.offset(a * r).limit(r);
698
- const u = (await d.selectAll().execute()).map((N) => ({
699
- ...N,
700
- device: JSON.parse(N.device),
701
- clients: JSON.parse(N.clients)
698
+ const u = (await d.selectAll().execute()).map((y) => ({
699
+ ...y,
700
+ device: JSON.parse(y.device),
701
+ clients: JSON.parse(y.clients)
702
702
  }));
703
703
  if (!o)
704
704
  return {
@@ -707,12 +707,12 @@ function Dr(t) {
707
707
  limit: 0,
708
708
  length: 0
709
709
  };
710
- const { count: g } = await _.select((N) => N.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = F(g);
710
+ const { count: f } = await _.select((y) => y.fn.countAll().as("count")).executeTakeFirstOrThrow(), p = F(f);
711
711
  return {
712
712
  sessions: u,
713
713
  start: a * r,
714
714
  limit: r,
715
- length: f
715
+ length: p
716
716
  };
717
717
  };
718
718
  }
@@ -773,7 +773,7 @@ function Lr(t) {
773
773
  }));
774
774
  };
775
775
  }
776
- function Mr(t) {
776
+ function Jr(t) {
777
777
  return {
778
778
  create: Fr(t),
779
779
  update: jr(t),
@@ -781,25 +781,25 @@ function Mr(t) {
781
781
  list: Lr(t)
782
782
  };
783
783
  }
784
- function Jr(t) {
784
+ function Mr(t) {
785
785
  return async (e, n = {}) => {
786
786
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, q: i } = n;
787
787
  let l = t.selectFrom("codes").where("codes.tenant_id", "=", e);
788
788
  i && (l = R(t, l, i, ["code", "login_id"]));
789
- const h = (await l.offset(a * r).limit(r).selectAll().execute()).map((g) => {
790
- const { tenant_id: f, ...N } = g;
791
- return Ya.parse(T(N));
789
+ const m = (await l.offset(a * r).limit(r).selectAll().execute()).map((f) => {
790
+ const { tenant_id: p, ...y } = f;
791
+ return Ya.parse(T(y));
792
792
  });
793
793
  if (!o)
794
794
  return {
795
- codes: h,
795
+ codes: m,
796
796
  start: 0,
797
797
  limit: 0,
798
798
  length: 0
799
799
  };
800
- const { count: u } = await l.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow();
800
+ const { count: u } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
801
801
  return {
802
- codes: h,
802
+ codes: m,
803
803
  start: a * r,
804
804
  limit: r,
805
805
  length: F(u)
@@ -835,7 +835,7 @@ function Kr(t) {
835
835
  function Ur(t) {
836
836
  return {
837
837
  create: Br(t),
838
- list: Jr(t),
838
+ list: Mr(t),
839
839
  remove: qr(t),
840
840
  used: Kr(t),
841
841
  get: Wr(t)
@@ -893,24 +893,24 @@ function to(t) {
893
893
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, q: i } = n;
894
894
  let l = t.selectFrom("connections").where("connections.tenant_id", "=", e);
895
895
  i && (l = R(t, l, i, ["user_id", "ip"]));
896
- const h = (await l.offset(a * r).limit(r).selectAll().execute()).map((g) => {
897
- const { is_system: f, ...N } = g;
896
+ const m = (await l.offset(a * r).limit(r).selectAll().execute()).map((f) => {
897
+ const { is_system: p, ...y } = f;
898
898
  return T({
899
- ...N,
900
- is_system: f ? !0 : void 0,
901
- options: JSON.parse(g.options)
899
+ ...y,
900
+ is_system: p ? !0 : void 0,
901
+ options: JSON.parse(f.options)
902
902
  });
903
903
  });
904
904
  if (!o)
905
905
  return {
906
- connections: h,
906
+ connections: m,
907
907
  start: 0,
908
908
  limit: 0,
909
909
  length: 0
910
910
  };
911
- const { count: u } = await l.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow();
911
+ const { count: u } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
912
912
  return {
913
- connections: h,
913
+ connections: m,
914
914
  start: a * r,
915
915
  limit: r,
916
916
  length: F(u)
@@ -1294,40 +1294,40 @@ function vo(t) {
1294
1294
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, q: i, sort: l } = n;
1295
1295
  let _ = t.selectFrom("client_grants").where("client_grants.tenant_id", "=", e);
1296
1296
  if (i) {
1297
- const f = i.trim(), N = f.split(/\s+/), C = N.length === 1 ? N[0] : void 0, O = C ? C.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, A = O ? O[3] : "", oe = /^(>=|>|<=|<)/.test(A || "");
1298
- if (O && !oe && A) {
1299
- const Q = !!O[1], ye = O[2], { ref: Pe } = t.dynamic, Ne = Pe(`client_grants.${ye}`);
1300
- if (ye === "allow_any_organization") {
1297
+ const p = i.trim(), y = p.split(/\s+/), C = y.length === 1 ? y[0] : void 0, O = C ? C.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, A = O ? O[3] : "", ie = /^(>=|>|<=|<)/.test(A || "");
1298
+ if (O && !ie && A) {
1299
+ const Q = !!O[1], se = O[2], { ref: Pe } = t.dynamic, H = Pe(`client_grants.${se}`);
1300
+ if (se === "allow_any_organization") {
1301
1301
  const ot = A === "true" ? 1 : 0;
1302
- Q ? _ = _.where(Ne, "!=", ot) : _ = _.where(Ne, "=", ot);
1302
+ Q ? _ = _.where(H, "!=", ot) : _ = _.where(H, "=", ot);
1303
1303
  } else
1304
- Q ? _ = _.where(Ne, "!=", A) : _ = _.where(Ne, "=", A);
1304
+ Q ? _ = _.where(H, "!=", A) : _ = _.where(H, "=", A);
1305
1305
  } else
1306
- _ = R(t, _, f, []);
1306
+ _ = R(t, _, p, []);
1307
1307
  }
1308
1308
  let d = _;
1309
1309
  if (l) {
1310
- const { ref: f } = t.dynamic;
1311
- d = d.orderBy(f(l.sort_by), l.sort_order);
1310
+ const { ref: p } = t.dynamic;
1311
+ d = d.orderBy(p(l.sort_by), l.sort_order);
1312
1312
  } else
1313
1313
  d = d.orderBy("client_grants.created_at", "desc");
1314
1314
  d = d.limit(r).offset(a * r);
1315
- const u = (await d.selectAll().execute()).map((f) => {
1316
- const N = {
1317
- id: f.id,
1318
- client_id: f.client_id,
1319
- audience: f.audience,
1320
- scope: f.scope ? JSON.parse(f.scope) : [],
1321
- organization_usage: f.organization_usage,
1315
+ const u = (await d.selectAll().execute()).map((p) => {
1316
+ const y = {
1317
+ id: p.id,
1318
+ client_id: p.client_id,
1319
+ audience: p.audience,
1320
+ scope: p.scope ? JSON.parse(p.scope) : [],
1321
+ organization_usage: p.organization_usage,
1322
1322
  // Convert integers back to booleans for API response (with defaults)
1323
- allow_any_organization: f.allow_any_organization !== void 0 ? !!f.allow_any_organization : !1,
1324
- is_system: f.is_system !== void 0 ? !!f.is_system : !1,
1325
- subject_type: f.subject_type,
1326
- authorization_details_types: f.authorization_details_types ? JSON.parse(f.authorization_details_types) : [],
1327
- created_at: f.created_at,
1328
- updated_at: f.updated_at
1323
+ allow_any_organization: p.allow_any_organization !== void 0 ? !!p.allow_any_organization : !1,
1324
+ is_system: p.is_system !== void 0 ? !!p.is_system : !1,
1325
+ subject_type: p.subject_type,
1326
+ authorization_details_types: p.authorization_details_types ? JSON.parse(p.authorization_details_types) : [],
1327
+ created_at: p.created_at,
1328
+ updated_at: p.updated_at
1329
1329
  };
1330
- return T(N);
1330
+ return T(y);
1331
1331
  });
1332
1332
  if (!o)
1333
1333
  return {
@@ -1336,12 +1336,12 @@ function vo(t) {
1336
1336
  limit: 0,
1337
1337
  length: 0
1338
1338
  };
1339
- const { count: g } = await _.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
1339
+ const { count: f } = await _.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow();
1340
1340
  return {
1341
1341
  client_grants: u,
1342
1342
  start: a * r,
1343
1343
  limit: r,
1344
- length: F(g)
1344
+ length: F(f)
1345
1345
  };
1346
1346
  };
1347
1347
  }
@@ -1377,7 +1377,25 @@ function bo(t) {
1377
1377
  const a = await t.selectFrom("tenants").selectAll().where("id", "=", n.tenant_id).executeTakeFirst();
1378
1378
  if (!a)
1379
1379
  throw new Ie(404, { message: "Tenant not found" });
1380
- const r = await t.selectFrom("connections").where("tenant_id", "=", n.tenant_id).selectAll().execute(), o = n.client_metadata ? JSON.parse(n.client_metadata) : {};
1380
+ const r = JSON.parse(
1381
+ n.connections || "[]"
1382
+ ), o = await t.selectFrom("connections").where("tenant_id", "=", n.tenant_id).selectAll().execute(), i = n.client_metadata ? JSON.parse(n.client_metadata) : {}, l = new Map(
1383
+ o.map((m) => {
1384
+ const { is_system: u, ...f } = m;
1385
+ return [
1386
+ m.id,
1387
+ Ha.parse(
1388
+ T({
1389
+ ...f,
1390
+ is_system: u ? !0 : void 0,
1391
+ options: m.options ? JSON.parse(m.options) : {}
1392
+ })
1393
+ )
1394
+ ];
1395
+ })
1396
+ ), _ = r.length > 0 ? r.map((m) => l.get(m)).filter(
1397
+ (m) => m != null
1398
+ ) : Array.from(l.values());
1381
1399
  return {
1382
1400
  ...n,
1383
1401
  // Convert integer fields back to booleans
@@ -1390,17 +1408,8 @@ function bo(t) {
1390
1408
  custom_login_page_on: !!n.custom_login_page_on,
1391
1409
  require_pushed_authorization_requests: !!n.require_pushed_authorization_requests,
1392
1410
  require_proof_of_possession: !!n.require_proof_of_possession,
1393
- // Parse JSON string fields back to objects/arrays
1394
- connections: r.map((l) => {
1395
- const { is_system: _, ...d } = l;
1396
- return Ha.parse(
1397
- T({
1398
- ...d,
1399
- is_system: _ ? !0 : void 0,
1400
- options: l.options ? JSON.parse(l.options) : {}
1401
- })
1402
- );
1403
- }),
1411
+ // Use the ordered connections
1412
+ connections: _,
1404
1413
  addons: n.addons ? JSON.parse(n.addons) : {},
1405
1414
  callbacks: n.callbacks ? JSON.parse(n.callbacks) : [],
1406
1415
  allowed_origins: n.allowed_origins ? JSON.parse(n.allowed_origins) : [],
@@ -1414,7 +1423,7 @@ function bo(t) {
1414
1423
  jwt_configuration: n.jwt_configuration ? JSON.parse(n.jwt_configuration) : {},
1415
1424
  signing_keys: n.signing_keys ? JSON.parse(n.signing_keys) : [],
1416
1425
  encryption_key: n.encryption_key ? JSON.parse(n.encryption_key) : {},
1417
- client_metadata: o,
1426
+ client_metadata: i,
1418
1427
  mobile: n.mobile ? JSON.parse(n.mobile) : {},
1419
1428
  native_social_login: n.native_social_login ? JSON.parse(n.native_social_login) : {},
1420
1429
  refresh_token: n.refresh_token ? JSON.parse(n.refresh_token) : {},
@@ -1437,9 +1446,9 @@ function Oo(t) {
1437
1446
  q: i
1438
1447
  } = e;
1439
1448
  let l = t.selectFrom("keys").where(
1440
- (f) => f.or([
1441
- f("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
1442
- f("revoked_at", "is", null)
1449
+ (p) => p.or([
1450
+ p("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
1451
+ p("revoked_at", "is", null)
1443
1452
  ])
1444
1453
  );
1445
1454
  i && (l = R(t, l, i, [
@@ -1449,23 +1458,23 @@ function Oo(t) {
1449
1458
  "thumbprint",
1450
1459
  "type"
1451
1460
  ]));
1452
- let _ = l.select((f) => f.fn.count("kid").as("count"));
1461
+ let _ = l.select((p) => p.fn.count("kid").as("count"));
1453
1462
  const d = n * a;
1454
1463
  l = l.limit(a).offset(d), o && (l = l.orderBy(o.sort_by, o.sort_order));
1455
- const h = await l.selectAll().execute();
1464
+ const m = await l.selectAll().execute();
1456
1465
  if (!r)
1457
1466
  return {
1458
- signingKeys: h,
1467
+ signingKeys: m,
1459
1468
  start: 0,
1460
1469
  limit: 0,
1461
1470
  length: 0
1462
1471
  };
1463
- const u = await _.executeTakeFirst(), g = F((u == null ? void 0 : u.count) ?? 0);
1472
+ const u = await _.executeTakeFirst(), f = F((u == null ? void 0 : u.count) ?? 0);
1464
1473
  return {
1465
- signingKeys: h,
1474
+ signingKeys: m,
1466
1475
  start: d,
1467
1476
  limit: a,
1468
- length: g
1477
+ length: f
1469
1478
  };
1470
1479
  };
1471
1480
  }
@@ -1561,10 +1570,10 @@ function Fo(t) {
1561
1570
  colors_page_background_end: l,
1562
1571
  colors_page_background_angle_dev: _,
1563
1572
  font_url: d,
1564
- ...h
1573
+ ...m
1565
1574
  } = n;
1566
1575
  return T({
1567
- ...h,
1576
+ ...m,
1568
1577
  colors: {
1569
1578
  primary: r,
1570
1579
  page_background: {
@@ -1580,7 +1589,7 @@ function Fo(t) {
1580
1589
  }
1581
1590
  function jo(t) {
1582
1591
  return async (e, n) => {
1583
- var i, l, _, d, h, u, g, f, N, C, O, A, oe, Q, ye, Pe, Ne, ot;
1592
+ var i, l, _, d, m, u, f, p, y, C, O, A, ie, Q, se, Pe, H, ot;
1584
1593
  const { colors: a, font: r, ...o } = n;
1585
1594
  try {
1586
1595
  await t.insertInto("branding").values({
@@ -1588,9 +1597,9 @@ function jo(t) {
1588
1597
  colors_primary: a == null ? void 0 : a.primary,
1589
1598
  colors_page_background_type: (l = (i = n.colors) == null ? void 0 : i.page_background) == null ? void 0 : l.type,
1590
1599
  colors_page_background_start: (d = (_ = n.colors) == null ? void 0 : _.page_background) == null ? void 0 : d.start,
1591
- colors_page_background_end: (u = (h = n.colors) == null ? void 0 : h.page_background) == null ? void 0 : u.end,
1592
- colors_page_background_angle_dev: (f = (g = n.colors) == null ? void 0 : g.page_background) == null ? void 0 : f.angle_deg,
1593
- font_url: (N = n.font) == null ? void 0 : N.url,
1600
+ colors_page_background_end: (u = (m = n.colors) == null ? void 0 : m.page_background) == null ? void 0 : u.end,
1601
+ colors_page_background_angle_dev: (p = (f = n.colors) == null ? void 0 : f.page_background) == null ? void 0 : p.angle_deg,
1602
+ font_url: (y = n.font) == null ? void 0 : y.url,
1594
1603
  tenant_id: e
1595
1604
  }).execute();
1596
1605
  } catch {
@@ -1598,9 +1607,9 @@ function jo(t) {
1598
1607
  ...o,
1599
1608
  colors_primary: a == null ? void 0 : a.primary,
1600
1609
  colors_page_background_type: (O = (C = n.colors) == null ? void 0 : C.page_background) == null ? void 0 : O.type,
1601
- colors_page_background_start: (oe = (A = n.colors) == null ? void 0 : A.page_background) == null ? void 0 : oe.start,
1602
- colors_page_background_end: (ye = (Q = n.colors) == null ? void 0 : Q.page_background) == null ? void 0 : ye.end,
1603
- colors_page_background_angle_dev: (Ne = (Pe = n.colors) == null ? void 0 : Pe.page_background) == null ? void 0 : Ne.angle_deg,
1610
+ colors_page_background_start: (ie = (A = n.colors) == null ? void 0 : A.page_background) == null ? void 0 : ie.start,
1611
+ colors_page_background_end: (se = (Q = n.colors) == null ? void 0 : Q.page_background) == null ? void 0 : se.end,
1612
+ colors_page_background_angle_dev: (H = (Pe = n.colors) == null ? void 0 : Pe.page_background) == null ? void 0 : H.angle_deg,
1604
1613
  font_url: (ot = n.font) == null ? void 0 : ot.url
1605
1614
  }).where("tenant_id", "=", e).execute();
1606
1615
  }
@@ -1612,36 +1621,36 @@ function Lo(t) {
1612
1621
  set: jo(t)
1613
1622
  };
1614
1623
  }
1615
- function Mo(t) {
1624
+ function Jo(t) {
1616
1625
  return async (e, n = {}) => {
1617
1626
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, q: i } = n;
1618
1627
  let l = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
1619
1628
  i && (l = R(t, l, i, ["url", "form_id"]));
1620
- const h = (await l.offset(a * r).limit(r).selectAll().execute()).map((g) => {
1621
- const { tenant_id: f, enabled: N, synchronous: C, ...O } = g;
1629
+ const m = (await l.offset(a * r).limit(r).selectAll().execute()).map((f) => {
1630
+ const { tenant_id: p, enabled: y, synchronous: C, ...O } = f;
1622
1631
  return T({
1623
1632
  ...O,
1624
- enabled: !!N,
1633
+ enabled: !!y,
1625
1634
  synchronous: !!C
1626
1635
  });
1627
1636
  });
1628
1637
  if (!o)
1629
1638
  return {
1630
- hooks: h,
1639
+ hooks: m,
1631
1640
  start: 0,
1632
1641
  limit: 0,
1633
1642
  length: 0
1634
1643
  };
1635
- const { count: u } = await l.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow();
1644
+ const { count: u } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
1636
1645
  return {
1637
- hooks: h,
1646
+ hooks: m,
1638
1647
  start: a * r,
1639
1648
  limit: r,
1640
1649
  length: F(u)
1641
1650
  };
1642
1651
  };
1643
1652
  }
1644
- function Jo(t) {
1653
+ function Mo(t) {
1645
1654
  return async (e, n) => {
1646
1655
  const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", n).selectAll().executeTakeFirst();
1647
1656
  return a ? T({
@@ -1684,8 +1693,8 @@ function Wo(t) {
1684
1693
  function Ko(t) {
1685
1694
  return {
1686
1695
  create: qo(t),
1687
- get: Jo(t),
1688
- list: Mo(t),
1696
+ get: Mo(t),
1697
+ list: Jo(t),
1689
1698
  update: Wo(t),
1690
1699
  remove: Bo(t)
1691
1700
  };
@@ -1941,15 +1950,15 @@ function mi(t) {
1941
1950
  l && (_ = R(t, _, l, ["token", "session_id"]));
1942
1951
  let d = _;
1943
1952
  if (i && i.sort_by) {
1944
- const { ref: N } = t.dynamic;
1945
- d = d.orderBy(N(i.sort_by), i.sort_order);
1953
+ const { ref: y } = t.dynamic;
1954
+ d = d.orderBy(y(i.sort_by), i.sort_order);
1946
1955
  }
1947
1956
  d = d.offset(a * r).limit(r);
1948
- const u = (await d.selectAll().execute()).map((N) => ({
1949
- ...N,
1950
- rotating: !!N.rotating,
1951
- device: N.device ? JSON.parse(N.device) : {},
1952
- resource_servers: N.resource_servers ? JSON.parse(N.resource_servers) : []
1957
+ const u = (await d.selectAll().execute()).map((y) => ({
1958
+ ...y,
1959
+ rotating: !!y.rotating,
1960
+ device: y.device ? JSON.parse(y.device) : {},
1961
+ resource_servers: y.resource_servers ? JSON.parse(y.resource_servers) : []
1953
1962
  }));
1954
1963
  if (!o)
1955
1964
  return {
@@ -1958,12 +1967,12 @@ function mi(t) {
1958
1967
  limit: 0,
1959
1968
  length: 0
1960
1969
  };
1961
- const { count: g } = await _.select((N) => N.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = F(g);
1970
+ const { count: f } = await _.select((y) => y.fn.countAll().as("count")).executeTakeFirstOrThrow(), p = F(f);
1962
1971
  return {
1963
1972
  refresh_tokens: u,
1964
1973
  start: a * r,
1965
1974
  limit: r,
1966
- length: f
1975
+ length: p
1967
1976
  };
1968
1977
  };
1969
1978
  }
@@ -2029,35 +2038,35 @@ function gi(t) {
2029
2038
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, q: i } = n;
2030
2039
  let l = t.selectFrom("forms").where("tenant_id", "=", e);
2031
2040
  i && (l = R(t, l, i, []));
2032
- const h = (await l.offset(a * r).limit(r).selectAll().execute()).map((g) => {
2033
- const f = { ...g };
2034
- if (typeof f.nodes == "string")
2041
+ const m = (await l.offset(a * r).limit(r).selectAll().execute()).map((f) => {
2042
+ const p = { ...f };
2043
+ if (typeof p.nodes == "string")
2035
2044
  try {
2036
- f.nodes = JSON.parse(f.nodes);
2045
+ p.nodes = JSON.parse(p.nodes);
2037
2046
  } catch {
2038
2047
  }
2039
- if (typeof f.start == "string")
2048
+ if (typeof p.start == "string")
2040
2049
  try {
2041
- f.start = JSON.parse(f.start);
2050
+ p.start = JSON.parse(p.start);
2042
2051
  } catch {
2043
2052
  }
2044
- if (typeof f.ending == "string")
2053
+ if (typeof p.ending == "string")
2045
2054
  try {
2046
- f.ending = JSON.parse(f.ending);
2055
+ p.ending = JSON.parse(p.ending);
2047
2056
  } catch {
2048
2057
  }
2049
- return bt.parse(T(f));
2058
+ return bt.parse(T(p));
2050
2059
  });
2051
2060
  if (!o)
2052
2061
  return {
2053
- forms: h,
2062
+ forms: m,
2054
2063
  start: 0,
2055
2064
  limit: 0,
2056
2065
  length: 0
2057
2066
  };
2058
- const { count: u } = await l.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow();
2067
+ const { count: u } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
2059
2068
  return {
2060
- forms: h,
2069
+ forms: m,
2061
2070
  start: a * r,
2062
2071
  limit: r,
2063
2072
  length: F(u)
@@ -2125,22 +2134,24 @@ function Ci(t) {
2125
2134
  scopes: l,
2126
2135
  options: _,
2127
2136
  skip_consent_for_verifiable_first_party_clients: d,
2128
- allow_offline_access: h,
2137
+ allow_offline_access: m,
2129
2138
  is_system: u,
2130
- ...g
2131
- } = o, f = {
2132
- ...g,
2139
+ metadata: f,
2140
+ ...p
2141
+ } = o, y = {
2142
+ ...p,
2133
2143
  tenant_id: e,
2134
2144
  scopes: l ? JSON.stringify(l) : "[]",
2135
2145
  options: _ ? JSON.stringify(_) : "{}",
2136
2146
  skip_consent_for_verifiable_first_party_clients: d ? 1 : 0,
2137
- allow_offline_access: h ? 1 : 0,
2147
+ allow_offline_access: m ? 1 : 0,
2138
2148
  is_system: u ? 1 : 0,
2149
+ metadata: f ? JSON.stringify(f) : void 0,
2139
2150
  verification_key: i,
2140
2151
  created_at: a,
2141
2152
  updated_at: a
2142
2153
  };
2143
- return await t.insertInto("resource_servers").values(f).execute(), T(o);
2154
+ return await t.insertInto("resource_servers").values(y).execute(), T(o);
2144
2155
  };
2145
2156
  }
2146
2157
  function xi(t) {
@@ -2153,19 +2164,21 @@ function xi(t) {
2153
2164
  options: l,
2154
2165
  skip_consent_for_verifiable_first_party_clients: _,
2155
2166
  allow_offline_access: d,
2156
- is_system: h,
2157
- ...u
2158
- } = r, g = {
2159
- ...u,
2167
+ is_system: m,
2168
+ metadata: u,
2169
+ ...f
2170
+ } = r, p = {
2171
+ ...f,
2160
2172
  scopes: i ? JSON.parse(i) : [],
2161
2173
  options: l ? JSON.parse(l) : {},
2162
2174
  skip_consent_for_verifiable_first_party_clients: !!_,
2163
2175
  allow_offline_access: !!d,
2164
- is_system: h ? !0 : void 0,
2176
+ is_system: m ? !0 : void 0,
2177
+ metadata: u ? JSON.parse(u) : void 0,
2165
2178
  // Convert verification_key back to verificationKey for API
2166
2179
  verificationKey: o
2167
2180
  };
2168
- return T(g);
2181
+ return T(p);
2169
2182
  };
2170
2183
  }
2171
2184
  function Ti(t) {
@@ -2173,47 +2186,49 @@ function Ti(t) {
2173
2186
  const { page: a = 0, per_page: r = 50, include_totals: o = !1, q: i } = n;
2174
2187
  let l = t.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", e);
2175
2188
  if (i) {
2176
- const g = i.trim(), f = g.split(/\s+/), N = f.length === 1 ? f[0] : void 0, C = N ? N.match(/^(-)?(name|identifier):(.*)$/) : null, O = C ? C[3] : "", A = /^(>=|>|<=|<)/.test(O || "");
2189
+ const f = i.trim(), p = f.split(/\s+/), y = p.length === 1 ? p[0] : void 0, C = y ? y.match(/^(-)?(name|identifier):(.*)$/) : null, O = C ? C[3] : "", A = /^(>=|>|<=|<)/.test(O || "");
2177
2190
  if (C && !A) {
2178
- const oe = !!C[1], Q = C[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2179
- l = oe ? l.where(Q, "not like", `%${O}%`) : l.where(Q, "like", `%${O}%`);
2191
+ const ie = !!C[1], Q = C[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2192
+ l = ie ? l.where(Q, "not like", `%${O}%`) : l.where(Q, "like", `%${O}%`);
2180
2193
  } else
2181
- l = R(t, l, g, [
2194
+ l = R(t, l, f, [
2182
2195
  "resource_servers.name",
2183
2196
  "resource_servers.identifier"
2184
2197
  ]);
2185
2198
  }
2186
- const h = (await l.offset(a * r).limit(r).selectAll().execute()).map((g) => {
2187
- const f = g, {
2188
- verification_key: N,
2199
+ const m = (await l.offset(a * r).limit(r).selectAll().execute()).map((f) => {
2200
+ const p = f, {
2201
+ verification_key: y,
2189
2202
  scopes: C,
2190
2203
  options: O,
2191
2204
  skip_consent_for_verifiable_first_party_clients: A,
2192
- allow_offline_access: oe,
2205
+ allow_offline_access: ie,
2193
2206
  is_system: Q,
2194
- ...ye
2195
- } = f, Pe = {
2196
- ...ye,
2207
+ metadata: se,
2208
+ ...Pe
2209
+ } = p, H = {
2210
+ ...Pe,
2197
2211
  scopes: C ? JSON.parse(C) : [],
2198
2212
  options: O ? JSON.parse(O) : {},
2199
2213
  skip_consent_for_verifiable_first_party_clients: !!A,
2200
- allow_offline_access: !!oe,
2214
+ allow_offline_access: !!ie,
2201
2215
  is_system: Q ? !0 : void 0,
2216
+ metadata: se ? JSON.parse(se) : void 0,
2202
2217
  // Convert verification_key back to verificationKey for API
2203
- verificationKey: N
2218
+ verificationKey: y
2204
2219
  };
2205
- return T(Pe);
2220
+ return T(H);
2206
2221
  });
2207
2222
  if (!o)
2208
2223
  return {
2209
- resource_servers: h,
2224
+ resource_servers: m,
2210
2225
  start: 0,
2211
2226
  limit: 0,
2212
2227
  length: 0
2213
2228
  };
2214
- const { count: u } = await l.select((g) => g.fn.countAll().as("count")).executeTakeFirstOrThrow();
2229
+ const { count: u } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
2215
2230
  return {
2216
- resource_servers: h,
2231
+ resource_servers: m,
2217
2232
  start: a * r,
2218
2233
  limit: r,
2219
2234
  length: F(u)
@@ -2235,18 +2250,19 @@ function Oi(t) {
2235
2250
  skip_consent_for_verifiable_first_party_clients: l,
2236
2251
  allow_offline_access: _,
2237
2252
  is_system: d,
2238
- ...h
2239
- } = a, u = {
2240
- ...h,
2253
+ metadata: m,
2254
+ ...u
2255
+ } = a, f = {
2256
+ ...u,
2241
2257
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2242
2258
  };
2243
- if (r !== void 0 && (u.verification_key = r), o !== void 0 && (u.scopes = JSON.stringify(o)), i !== void 0) {
2244
- const f = await t.selectFrom("resource_servers").select("options").where("tenant_id", "=", e).where("id", "=", n).executeTakeFirst(), C = { ...f != null && f.options ? JSON.parse(f.options) : {}, ...i };
2245
- u.options = JSON.stringify(C);
2259
+ if (r !== void 0 && (f.verification_key = r), o !== void 0 && (f.scopes = JSON.stringify(o)), i !== void 0) {
2260
+ const y = await t.selectFrom("resource_servers").select("options").where("tenant_id", "=", e).where("id", "=", n).executeTakeFirst(), O = { ...y != null && y.options ? JSON.parse(y.options) : {}, ...i };
2261
+ f.options = JSON.stringify(O);
2246
2262
  }
2247
- l !== void 0 && (u.skip_consent_for_verifiable_first_party_clients = l ? 1 : 0), _ !== void 0 && (u.allow_offline_access = _ ? 1 : 0), d !== void 0 && (u.is_system = d ? 1 : 0);
2248
- const g = await t.updateTable("resource_servers").set(u).where("tenant_id", "=", e).where("id", "=", n).executeTakeFirst();
2249
- return Number(g.numUpdatedRows) > 0;
2263
+ m !== void 0 && (f.metadata = JSON.stringify(m)), l !== void 0 && (f.skip_consent_for_verifiable_first_party_clients = l ? 1 : 0), _ !== void 0 && (f.allow_offline_access = _ ? 1 : 0), d !== void 0 && (f.is_system = d ? 1 : 0);
2264
+ const p = await t.updateTable("resource_servers").set(f).where("tenant_id", "=", e).where("id", "=", n).executeTakeFirst();
2265
+ return Number(p.numUpdatedRows) > 0;
2250
2266
  };
2251
2267
  }
2252
2268
  function Si(t) {
@@ -2260,18 +2276,20 @@ function Si(t) {
2260
2276
  }
2261
2277
  function ki(t) {
2262
2278
  return async (e, n) => {
2263
- const a = (/* @__PURE__ */ new Date()).toISOString(), r = n.id || B(), { is_system: o, id: i, ...l } = n, _ = {
2279
+ const a = (/* @__PURE__ */ new Date()).toISOString(), r = n.id || B(), { is_system: o, id: i, metadata: l, ..._ } = n, d = {
2264
2280
  id: r,
2265
- ...l,
2281
+ ..._,
2266
2282
  tenant_id: e,
2267
2283
  is_system: o ? 1 : 0,
2284
+ metadata: l ? JSON.stringify(l) : void 0,
2268
2285
  created_at: a,
2269
2286
  updated_at: a
2270
2287
  };
2271
- return await t.insertInto("roles").values(_).execute(), {
2288
+ return await t.insertInto("roles").values(d).execute(), {
2272
2289
  id: r,
2273
- ...l,
2290
+ ..._,
2274
2291
  is_system: o ? !0 : void 0,
2292
+ metadata: l,
2275
2293
  created_at: a,
2276
2294
  updated_at: a
2277
2295
  };
@@ -2281,10 +2299,11 @@ function Ii(t) {
2281
2299
  return async (e, n) => {
2282
2300
  const a = await t.selectFrom("roles").selectAll().where("roles.tenant_id", "=", e).where("roles.id", "=", n).executeTakeFirst();
2283
2301
  if (!a) return null;
2284
- const r = a, { is_system: o, tenant_id: i, ...l } = r;
2302
+ const r = a, { is_system: o, tenant_id: i, metadata: l, ..._ } = r;
2285
2303
  return {
2286
- ...l,
2287
- is_system: o ? !0 : void 0
2304
+ ..._,
2305
+ is_system: o ? !0 : void 0,
2306
+ metadata: l ? JSON.parse(l) : void 0
2288
2307
  };
2289
2308
  };
2290
2309
  }
@@ -2294,10 +2313,11 @@ function Ei(t) {
2294
2313
  const { page: r = 0, per_page: o = 50, include_totals: i = !1 } = n;
2295
2314
  n.q && (a = R(t, a, n.q, ["name"]));
2296
2315
  const d = (await a.offset(r * o).limit(o).selectAll().execute()).map((u) => {
2297
- const g = u, { is_system: f, tenant_id: N, ...C } = g;
2316
+ const f = u, { is_system: p, tenant_id: y, metadata: C, ...O } = f;
2298
2317
  return {
2299
- ...C,
2300
- is_system: f ? !0 : void 0
2318
+ ...O,
2319
+ is_system: p ? !0 : void 0,
2320
+ metadata: C ? JSON.parse(C) : void 0
2301
2321
  };
2302
2322
  });
2303
2323
  if (!i)
@@ -2307,23 +2327,24 @@ function Ei(t) {
2307
2327
  limit: o,
2308
2328
  length: d.length
2309
2329
  };
2310
- const { count: h } = await a.select((u) => u.fn.countAll().as("count")).executeTakeFirstOrThrow();
2330
+ const { count: m } = await a.select((u) => u.fn.countAll().as("count")).executeTakeFirstOrThrow();
2311
2331
  return {
2312
2332
  roles: d,
2313
2333
  start: r * o,
2314
2334
  limit: o,
2315
- length: F(h)
2335
+ length: F(m)
2316
2336
  };
2317
2337
  };
2318
2338
  }
2319
2339
  function Ai(t) {
2320
2340
  return async (e, n, a) => {
2321
- const { is_system: r, ...o } = a, i = {
2322
- ...o,
2341
+ const { is_system: r, metadata: o, ...i } = a, l = {
2342
+ ...i,
2323
2343
  is_system: r !== void 0 ? r ? 1 : 0 : void 0,
2344
+ metadata: o !== void 0 ? JSON.stringify(o) : void 0,
2324
2345
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2325
- }, l = await t.updateTable("roles").set(i).where("roles.tenant_id", "=", e).where("roles.id", "=", n).executeTakeFirst();
2326
- return Number(l.numUpdatedRows) > 0;
2346
+ }, _ = await t.updateTable("roles").set(l).where("roles.tenant_id", "=", e).where("roles.id", "=", n).executeTakeFirst();
2347
+ return Number(_.numUpdatedRows) > 0;
2327
2348
  };
2328
2349
  }
2329
2350
  function $i(t) {
@@ -2411,7 +2432,7 @@ function Ri(t) {
2411
2432
  "role_permissions.created_at",
2412
2433
  "resource_servers.name as resource_server_name"
2413
2434
  ]).where("role_permissions.tenant_id", "=", e).where("role_permissions.role_id", "=", n);
2414
- const h = (await l.offset(r * o).limit(o).execute()).map((u) => ({
2435
+ const m = (await l.offset(r * o).limit(o).execute()).map((u) => ({
2415
2436
  role_id: u.role_id,
2416
2437
  resource_server_identifier: u.resource_server_identifier,
2417
2438
  resource_server_name: u.resource_server_name || u.resource_server_identifier,
@@ -2421,7 +2442,7 @@ function Ri(t) {
2421
2442
  // No description available from role_permissions directly
2422
2443
  created_at: u.created_at
2423
2444
  }));
2424
- return i && await l.select((u) => u.fn.countAll().as("count")).executeTakeFirstOrThrow(), h;
2445
+ return i && await l.select((u) => u.fn.countAll().as("count")).executeTakeFirstOrThrow(), m;
2425
2446
  };
2426
2447
  }
2427
2448
  function Fi(t) {
@@ -2463,7 +2484,7 @@ function Li(t) {
2463
2484
  }
2464
2485
  };
2465
2486
  }
2466
- function Mi(t) {
2487
+ function Ji(t) {
2467
2488
  return async (e, n, a, r) => {
2468
2489
  let o = t.selectFrom("user_permissions").leftJoin(
2469
2490
  "resource_servers",
@@ -2501,15 +2522,15 @@ function Mi(t) {
2501
2522
  }));
2502
2523
  };
2503
2524
  }
2504
- function Ji(t) {
2525
+ function Mi(t) {
2505
2526
  return {
2506
2527
  create: ji(t),
2507
2528
  remove: Li(t),
2508
- list: Mi(t)
2529
+ list: Ji(t)
2509
2530
  };
2510
2531
  }
2511
2532
  function Bi(t) {
2512
- const e = Ji(t);
2533
+ const e = Mi(t);
2513
2534
  return {
2514
2535
  create: (n, a, r, o) => e.create(n, a, r, o),
2515
2536
  remove: (n, a, r, o) => e.remove(n, a, r, o),
@@ -2645,9 +2666,9 @@ function c(t) {
2645
2666
  return Object.freeze(t);
2646
2667
  }
2647
2668
  function xt(t) {
2648
- return me(t) ? t : [t];
2669
+ return fe(t) ? t : [t];
2649
2670
  }
2650
- function me(t) {
2671
+ function fe(t) {
2651
2672
  return Array.isArray(t);
2652
2673
  }
2653
2674
  const L = c({
@@ -2677,7 +2698,7 @@ const L = c({
2677
2698
  identifier: L.create(e)
2678
2699
  });
2679
2700
  }
2680
- }), we = c({
2701
+ }), Ne = c({
2681
2702
  is(t) {
2682
2703
  return t.kind === "AliasNode";
2683
2704
  },
@@ -2688,7 +2709,7 @@ const L = c({
2688
2709
  alias: e
2689
2710
  });
2690
2711
  }
2691
- }), _e = c({
2712
+ }), he = c({
2692
2713
  is(t) {
2693
2714
  return t.kind === "TableNode";
2694
2715
  },
@@ -2714,7 +2735,7 @@ function Hi(t) {
2714
2735
  function Xi(t) {
2715
2736
  return Bt(t) && "expression" in t && Y(t.alias) && q(t);
2716
2737
  }
2717
- const H = c({
2738
+ const X = c({
2718
2739
  is(t) {
2719
2740
  return t.kind === "SelectModifierNode";
2720
2741
  },
@@ -2731,7 +2752,7 @@ const H = c({
2731
2752
  rawModifier: t
2732
2753
  });
2733
2754
  }
2734
- }), he = c({
2755
+ }), pe = c({
2735
2756
  is(t) {
2736
2757
  return t.kind === "AndNode";
2737
2758
  },
@@ -2766,7 +2787,7 @@ const H = c({
2766
2787
  cloneWithOperation(t, e, n) {
2767
2788
  return c({
2768
2789
  ...t,
2769
- on: e === "And" ? he.create(t.on, n) : rt.create(t.on, n)
2790
+ on: e === "And" ? pe.create(t.on, n) : rt.create(t.on, n)
2770
2791
  });
2771
2792
  }
2772
2793
  }), ct = c({
@@ -2986,9 +3007,9 @@ function is(t) {
2986
3007
  if (n) {
2987
3008
  if (!os(n))
2988
3009
  throw new Error(`Invalid order by direction: ${n}`);
2989
- return en.create(fe(e), ma(n));
3010
+ return en.create(ge(e), ma(n));
2990
3011
  }
2991
- return fe(t);
3012
+ return ge(t);
2992
3013
  }
2993
3014
  function ma(t) {
2994
3015
  if (t)
@@ -3047,16 +3068,16 @@ const St = c({
3047
3068
  }
3048
3069
  });
3049
3070
  function ss(t) {
3050
- return Y(t) ? fe(t) : t.toOperationNode();
3071
+ return Y(t) ? ge(t) : t.toOperationNode();
3051
3072
  }
3052
3073
  function mt(t) {
3053
- return me(t) ? t.map((e) => M(e)) : [M(t)];
3074
+ return fe(t) ? t.map((e) => J(e)) : [J(t)];
3054
3075
  }
3055
- function M(t) {
3076
+ function J(t) {
3056
3077
  return Qt(t) ? Ut(t) : ss(t);
3057
3078
  }
3058
3079
  function cs(t, e) {
3059
- const n = fe(t);
3080
+ const n = ge(t);
3060
3081
  if (An(e))
3061
3082
  return St.create(n, ha.create(Ee.create(e)));
3062
3083
  const a = e.slice(0, -1);
@@ -3064,7 +3085,7 @@ function cs(t, e) {
3064
3085
  return St.create(n, lt.create(Ee.create(a)));
3065
3086
  throw new Error(`Invalid JSON operator: ${e}`);
3066
3087
  }
3067
- function fe(t) {
3088
+ function ge(t) {
3068
3089
  const e = ".";
3069
3090
  if (!t.includes(e))
3070
3091
  return qt.create(Nn.create(t));
@@ -3079,17 +3100,17 @@ function ls(t) {
3079
3100
  const e = " as ";
3080
3101
  if (t.includes(e)) {
3081
3102
  const [n, a] = t.split(e).map(fa);
3082
- return we.create(fe(n), L.create(a));
3103
+ return Ne.create(ge(n), L.create(a));
3083
3104
  } else
3084
- return fe(t);
3105
+ return ge(t);
3085
3106
  }
3086
3107
  function us(t) {
3087
3108
  const [e, n, a] = t;
3088
- return qt.create(Nn.create(a), _e.createWithSchema(e, n));
3109
+ return qt.create(Nn.create(a), he.createWithSchema(e, n));
3089
3110
  }
3090
3111
  function ds(t) {
3091
3112
  const [e, n] = t;
3092
- return qt.create(Nn.create(n), _e.create(e));
3113
+ return qt.create(Nn.create(n), he.create(e));
3093
3114
  }
3094
3115
  function fa(t) {
3095
3116
  return t.trim();
@@ -3114,7 +3135,7 @@ const _s = c({
3114
3135
  values: c(t)
3115
3136
  });
3116
3137
  }
3117
- }), pe = c({
3138
+ }), we = c({
3118
3139
  is(t) {
3119
3140
  return t.kind === "ValueNode";
3120
3141
  },
@@ -3133,10 +3154,10 @@ const _s = c({
3133
3154
  }
3134
3155
  });
3135
3156
  function hs(t) {
3136
- return me(t) ? fs(t) : z(t);
3157
+ return fe(t) ? fs(t) : z(t);
3137
3158
  }
3138
3159
  function z(t) {
3139
- return Qt(t) ? Ut(t) : pe.create(t);
3160
+ return Qt(t) ? Ut(t) : we.create(t);
3140
3161
  }
3141
3162
  function Cn(t) {
3142
3163
  return yn(t) || sa(t) || ca(t);
@@ -3144,7 +3165,7 @@ function Cn(t) {
3144
3165
  function xn(t) {
3145
3166
  if (!Cn(t))
3146
3167
  throw new Error(`unsafe immediate value ${JSON.stringify(t)}`);
3147
- return pe.createImmediate(t);
3168
+ return we.createImmediate(t);
3148
3169
  }
3149
3170
  function fs(t) {
3150
3171
  return t.some(Qt) ? ms.create(t.map((e) => z(e))) : _s.create(t);
@@ -3168,18 +3189,18 @@ function U(t) {
3168
3189
  throw new Error(`invalid arguments: ${JSON.stringify(t)}`);
3169
3190
  }
3170
3191
  function Tn(t, e, n) {
3171
- return ps(e) && pa(n) ? nt.create(M(t), nn(e), pe.createImmediate(n)) : nt.create(M(t), nn(e), hs(n));
3192
+ return ps(e) && pa(n) ? nt.create(J(t), nn(e), we.createImmediate(n)) : nt.create(J(t), nn(e), hs(n));
3172
3193
  }
3173
3194
  function ft(t, e, n) {
3174
- return nt.create(M(t), nn(e), M(n));
3195
+ return nt.create(J(t), nn(e), J(n));
3175
3196
  }
3176
3197
  function $n(t, e) {
3177
3198
  return tn(Object.entries(t).filter(([, n]) => !Ot(n)).map(([n, a]) => Tn(n, pa(a) ? "is" : "=", a)), e);
3178
3199
  }
3179
3200
  function tn(t, e, n = !0) {
3180
- const a = e === "and" ? he.create : rt.create;
3201
+ const a = e === "and" ? pe.create : rt.create;
3181
3202
  if (t.length === 0)
3182
- return nt.create(pe.createImmediate(1), Ee.create("="), pe.createImmediate(e === "and" ? 1 : 0));
3203
+ return nt.create(we.createImmediate(1), Ee.create("="), we.createImmediate(e === "and" ? 1 : 0));
3183
3204
  let r = Pn(t[0]);
3184
3205
  for (let o = 1; o < t.length; ++o)
3185
3206
  r = a(r, Pn(t[o]));
@@ -3201,7 +3222,7 @@ function nn(t) {
3201
3222
  function Pn(t) {
3202
3223
  return q(t) ? t.toOperationNode() : t;
3203
3224
  }
3204
- const ge = c({
3225
+ const ye = c({
3205
3226
  is(t) {
3206
3227
  return t.kind === "OrderByNode";
3207
3228
  },
@@ -3245,7 +3266,7 @@ const ge = c({
3245
3266
  cloneWithOrderByItems(t, e) {
3246
3267
  return c({
3247
3268
  ...t,
3248
- orderBy: t.orderBy ? ge.cloneWithItems(t.orderBy, e) : ge.create(e)
3269
+ orderBy: t.orderBy ? ye.cloneWithItems(t.orderBy, e) : ye.create(e)
3249
3270
  });
3250
3271
  },
3251
3272
  cloneWithPartitionByItems(t, e) {
@@ -3299,7 +3320,7 @@ const ge = c({
3299
3320
  cloneWithOperation(t, e, n) {
3300
3321
  return c({
3301
3322
  ...t,
3302
- having: e === "And" ? he.create(t.having, n) : rt.create(t.having, n)
3323
+ having: e === "And" ? pe.create(t.having, n) : rt.create(t.having, n)
3303
3324
  });
3304
3325
  }
3305
3326
  }), k = c({
@@ -3340,7 +3361,7 @@ const ge = c({
3340
3361
  cloneWithOrderByItems(t, e) {
3341
3362
  return c({
3342
3363
  ...t,
3343
- orderBy: t.orderBy ? ge.cloneWithItems(t.orderBy, e) : ge.create(e)
3364
+ orderBy: t.orderBy ? ye.cloneWithItems(t.orderBy, e) : ye.create(e)
3344
3365
  });
3345
3366
  },
3346
3367
  cloneWithGroupByItems(t, e) {
@@ -3556,7 +3577,7 @@ const ut = c({
3556
3577
  }
3557
3578
  });
3558
3579
  function ga(t) {
3559
- return Ae(t) ? ga(t(Kt())) : me(t) ? t.map((e) => Fn(e)) : [Fn(t)];
3580
+ return Ae(t) ? ga(t(Kt())) : fe(t) ? t.map((e) => Fn(e)) : [Fn(t)];
3560
3581
  }
3561
3582
  function Fn(t) {
3562
3583
  return Y(t) ? ut.create(ls(t)) : _a(t) ? ut.create(t.toOperationNode()) : ut.create(Sa(t));
@@ -3656,7 +3677,7 @@ const ys = c({
3656
3677
  cloneWithOrderByItems(t, e) {
3657
3678
  return c({
3658
3679
  ...t,
3659
- orderBy: t.orderBy ? ge.cloneWithItems(t.orderBy, e) : ge.create(e)
3680
+ orderBy: t.orderBy ? ye.cloneWithItems(t.orderBy, e) : ye.create(e)
3660
3681
  });
3661
3682
  },
3662
3683
  cloneWithoutOrderBy(t) {
@@ -3696,10 +3717,10 @@ const ys = c({
3696
3717
  cloneWithOperation(t, e, n) {
3697
3718
  return c({
3698
3719
  ...t,
3699
- where: e === "And" ? he.create(t.where, n) : rt.create(t.where, n)
3720
+ where: e === "And" ? pe.create(t.where, n) : rt.create(t.where, n)
3700
3721
  });
3701
3722
  }
3702
- }), Mn = c({
3723
+ }), Jn = c({
3703
3724
  is(t) {
3704
3725
  return t.kind === "ReturningNode";
3705
3726
  },
@@ -3774,7 +3795,7 @@ const ys = c({
3774
3795
  ]) : void 0
3775
3796
  });
3776
3797
  }
3777
- }), Jn = c({
3798
+ }), Mn = c({
3778
3799
  is(t) {
3779
3800
  return t.kind === "OutputNode";
3780
3801
  },
@@ -3815,7 +3836,7 @@ const ys = c({
3815
3836
  cloneWithReturning(t, e) {
3816
3837
  return c({
3817
3838
  ...t,
3818
- returning: t.returning ? Mn.cloneWithSelections(t.returning, e) : Mn.create(e)
3839
+ returning: t.returning ? Jn.cloneWithSelections(t.returning, e) : Jn.create(e)
3819
3840
  });
3820
3841
  },
3821
3842
  cloneWithoutReturning(t) {
@@ -3845,7 +3866,7 @@ const ys = c({
3845
3866
  cloneWithOutput(t, e) {
3846
3867
  return c({
3847
3868
  ...t,
3848
- output: t.output ? Jn.cloneWithSelections(t.output, e) : Jn.create(e)
3869
+ output: t.output ? Mn.cloneWithSelections(t.output, e) : Mn.create(e)
3849
3870
  });
3850
3871
  }
3851
3872
  });
@@ -3855,7 +3876,7 @@ class Ts extends Error {
3855
3876
  /**
3856
3877
  * The operation node tree of the query that was executed.
3857
3878
  */
3858
- ie(this, "node");
3879
+ ce(this, "node");
3859
3880
  this.node = n;
3860
3881
  }
3861
3882
  }
@@ -3967,7 +3988,7 @@ function Es(t) {
3967
3988
  function As() {
3968
3989
  return Bn[~~(Math.random() * Bn.length)];
3969
3990
  }
3970
- function X() {
3991
+ function Z() {
3971
3992
  return new $s();
3972
3993
  }
3973
3994
  var qe;
@@ -3983,7 +4004,7 @@ qe = new WeakMap();
3983
4004
  var Rt;
3984
4005
  class Ps {
3985
4006
  constructor() {
3986
- ie(this, "nodeStack", []);
4007
+ ce(this, "nodeStack", []);
3987
4008
  x(this, Rt, c({
3988
4009
  AliasNode: this.transformAlias.bind(this),
3989
4010
  ColumnNode: this.transformColumn.bind(this),
@@ -4853,12 +4874,12 @@ class Rs extends Ps {
4853
4874
  b(this, We, n);
4854
4875
  }
4855
4876
  transformNodeImpl(n) {
4856
- if (!y(this, E, ya).call(this, n))
4877
+ if (!N(this, E, ya).call(this, n))
4857
4878
  return super.transformNodeImpl(n);
4858
- const a = y(this, E, va).call(this, n);
4879
+ const a = N(this, E, va).call(this, n);
4859
4880
  for (const i of a)
4860
4881
  s(this, xe).add(i);
4861
- const r = y(this, E, Na).call(this, n);
4882
+ const r = N(this, E, Na).call(this, n);
4862
4883
  for (const i of r)
4863
4884
  s(this, Ce).add(i);
4864
4885
  const o = super.transformNodeImpl(n);
@@ -4879,24 +4900,24 @@ class Rs extends Ps {
4879
4900
  const a = super.transformReferences(n);
4880
4901
  return a.table.table.schema ? a : {
4881
4902
  ...a,
4882
- table: _e.createWithSchema(s(this, We), a.table.table.identifier.name)
4903
+ table: he.createWithSchema(s(this, We), a.table.table.identifier.name)
4883
4904
  };
4884
4905
  }
4885
4906
  transformAggregateFunction(n) {
4886
4907
  return {
4887
4908
  ...super.transformAggregateFunction({ ...n, aggregated: [] }),
4888
- aggregated: y(this, E, rn).call(this, n, "aggregated")
4909
+ aggregated: N(this, E, rn).call(this, n, "aggregated")
4889
4910
  };
4890
4911
  }
4891
4912
  transformFunction(n) {
4892
4913
  return {
4893
4914
  ...super.transformFunction({ ...n, arguments: [] }),
4894
- arguments: y(this, E, rn).call(this, n, "arguments")
4915
+ arguments: N(this, E, rn).call(this, n, "arguments")
4895
4916
  };
4896
4917
  }
4897
4918
  }
4898
4919
  We = new WeakMap(), Ce = new WeakMap(), xe = new WeakMap(), E = new WeakSet(), rn = function(n, a) {
4899
- return zs[n.func] ? n[a].map((r) => !_e.is(r) || r.table.schema ? this.transformNode(r) : {
4920
+ return zs[n.func] ? n[a].map((r) => !he.is(r) || r.table.schema ? this.transformNode(r) : {
4900
4921
  ...r,
4901
4922
  table: this.transformIdentifier(r.table.identifier)
4902
4923
  }) : this.transformNodeList(n[a]);
@@ -4904,19 +4925,19 @@ We = new WeakMap(), Ce = new WeakMap(), xe = new WeakMap(), E = new WeakSet(), r
4904
4925
  return n.kind in Ds;
4905
4926
  }, Na = function(n) {
4906
4927
  const a = /* @__PURE__ */ new Set();
4907
- if ("name" in n && n.name && Zt.is(n.name) && y(this, E, on).call(this, n.name, a), "from" in n && n.from)
4928
+ if ("name" in n && n.name && Zt.is(n.name) && N(this, E, on).call(this, n.name, a), "from" in n && n.from)
4908
4929
  for (const r of n.from.froms)
4909
- y(this, E, Re).call(this, r, a);
4910
- if ("into" in n && n.into && y(this, E, Re).call(this, n.into, a), "table" in n && n.table && y(this, E, Re).call(this, n.table, a), "joins" in n && n.joins)
4930
+ N(this, E, Re).call(this, r, a);
4931
+ if ("into" in n && n.into && N(this, E, Re).call(this, n.into, a), "table" in n && n.table && N(this, E, Re).call(this, n.table, a), "joins" in n && n.joins)
4911
4932
  for (const r of n.joins)
4912
- y(this, E, Re).call(this, r.table, a);
4913
- return "using" in n && n.using && y(this, E, Re).call(this, n.using, a), a;
4933
+ N(this, E, Re).call(this, r.table, a);
4934
+ return "using" in n && n.using && N(this, E, Re).call(this, n.using, a), a;
4914
4935
  }, va = function(n) {
4915
4936
  const a = /* @__PURE__ */ new Set();
4916
- return "with" in n && n.with && y(this, E, Ca).call(this, n.with, a), a;
4937
+ return "with" in n && n.with && N(this, E, Ca).call(this, n.with, a), a;
4917
4938
  }, Re = function(n, a) {
4918
- const r = _e.is(n) ? n : we.is(n) && _e.is(n.node) ? n.node : null;
4919
- r && y(this, E, on).call(this, r.table, a);
4939
+ const r = he.is(n) ? n : Ne.is(n) && he.is(n.node) ? n.node : null;
4940
+ r && N(this, E, on).call(this, r.table, a);
4920
4941
  }, on = function(n, a) {
4921
4942
  const r = n.identifier.name;
4922
4943
  !s(this, Ce).has(r) && !s(this, xe).has(r) && a.add(r);
@@ -4946,10 +4967,10 @@ class qn {
4946
4967
  x(this, gt);
4947
4968
  x(this, Ke);
4948
4969
  x(this, Ue);
4949
- ie(this, "resolve", (e) => {
4970
+ ce(this, "resolve", (e) => {
4950
4971
  s(this, Ke) && s(this, Ke).call(this, e);
4951
4972
  });
4952
- ie(this, "reject", (e) => {
4973
+ ce(this, "reject", (e) => {
4953
4974
  s(this, Ue) && s(this, Ue).call(this, e);
4954
4975
  });
4955
4976
  b(this, gt, new Promise((e, n) => {
@@ -4993,8 +5014,8 @@ class Ls {
4993
5014
  }
4994
5015
  async executeQuery(e, n) {
4995
5016
  return await this.provideConnection(async (a) => {
4996
- const r = await a.executeQuery(e), o = await y(this, wt, sn).call(this, r, n);
4997
- return Ms(r, o), o;
5017
+ const r = await a.executeQuery(e), o = await N(this, wt, sn).call(this, r, n);
5018
+ return Js(r, o), o;
4998
5019
  });
4999
5020
  }
5000
5021
  async *stream(e, n, a) {
@@ -5003,7 +5024,7 @@ class Ls {
5003
5024
  const i = await r.promise;
5004
5025
  try {
5005
5026
  for await (const l of i.streamQuery(e, n))
5006
- yield await y(this, wt, sn).call(this, l, a);
5027
+ yield await N(this, wt, sn).call(this, l, a);
5007
5028
  } finally {
5008
5029
  o.resolve();
5009
5030
  }
@@ -5014,11 +5035,11 @@ Te = new WeakMap(), wt = new WeakSet(), sn = async function(e, n) {
5014
5035
  e = await a.transformResult({ result: e, queryId: n });
5015
5036
  return e;
5016
5037
  };
5017
- function Ms(t, e) {
5038
+ function Js(t, e) {
5018
5039
  const { numAffectedRows: n } = t;
5019
5040
  n === void 0 && t.numUpdatedOrDeletedRows === void 0 || n !== void 0 && e.numAffectedRows !== void 0 || Fs("kysely:warning: outdated driver/plugin detected! QueryResult.numUpdatedOrDeletedRows is deprecated and will be removed in a future release.");
5020
5041
  }
5021
- class Me extends Ls {
5042
+ class Je extends Ls {
5022
5043
  get adapter() {
5023
5044
  throw new Error("this query cannot be compiled to SQL");
5024
5045
  }
@@ -5032,20 +5053,20 @@ class Me extends Ls {
5032
5053
  throw new Error("this query cannot have a connection provider");
5033
5054
  }
5034
5055
  withPlugin(e) {
5035
- return new Me([...this.plugins, e]);
5056
+ return new Je([...this.plugins, e]);
5036
5057
  }
5037
5058
  withPlugins(e) {
5038
- return new Me([...this.plugins, ...e]);
5059
+ return new Je([...this.plugins, ...e]);
5039
5060
  }
5040
5061
  withPluginAtFront(e) {
5041
- return new Me([e, ...this.plugins]);
5062
+ return new Je([e, ...this.plugins]);
5042
5063
  }
5043
5064
  withoutPlugins() {
5044
- return new Me([]);
5065
+ return new Je([]);
5045
5066
  }
5046
5067
  }
5047
- const Ta = new Me();
5048
- function Js(t, e) {
5068
+ const Ta = new Je();
5069
+ function Ms(t, e) {
5049
5070
  return new It({
5050
5071
  joinNode: ct.create(t, Pt(e))
5051
5072
  });
@@ -5063,7 +5084,7 @@ function De(t, e) {
5063
5084
  throw new Error("not implemented");
5064
5085
  }
5065
5086
  function qs(t, e, n) {
5066
- return n(Js(t, e)).toOperationNode();
5087
+ return n(Ms(t, e)).toOperationNode();
5067
5088
  }
5068
5089
  function Ws(t, e, n, a) {
5069
5090
  return ct.createWithOn(t, Pt(e), ft(n, "=", a));
@@ -5106,13 +5127,13 @@ const Vs = c({
5106
5127
  }
5107
5128
  });
5108
5129
  function ze(t, e, n) {
5109
- return Ae(e) && (e = e(On())), me(e) || (e = [e]), e.map((a) => Vs.create(t, Ut(a), n));
5130
+ return Ae(e) && (e = e(On())), fe(e) || (e = [e]), e.map((a) => Vs.create(t, Ut(a), n));
5110
5131
  }
5111
- var ae;
5132
+ var re;
5112
5133
  const Ft = class Ft {
5113
5134
  constructor(e) {
5114
- x(this, ae);
5115
- b(this, ae, e);
5135
+ x(this, re);
5136
+ b(this, re, e);
5116
5137
  }
5117
5138
  /** @private */
5118
5139
  get expressionType() {
@@ -5121,10 +5142,10 @@ const Ft = class Ft {
5121
5142
  return new bn(this, e);
5122
5143
  }
5123
5144
  or(...e) {
5124
- return new cn(rt.create(s(this, ae), U(e)));
5145
+ return new cn(rt.create(s(this, re), U(e)));
5125
5146
  }
5126
5147
  and(...e) {
5127
- return new ln(he.create(s(this, ae), U(e)));
5148
+ return new ln(pe.create(s(this, re), U(e)));
5128
5149
  }
5129
5150
  /**
5130
5151
  * Change the output type of the expression.
@@ -5133,7 +5154,7 @@ const Ft = class Ft {
5133
5154
  * returns a copy of this `ExpressionWrapper` with a new output type.
5134
5155
  */
5135
5156
  $castTo() {
5136
- return new Ft(s(this, ae));
5157
+ return new Ft(s(this, re));
5137
5158
  }
5138
5159
  /**
5139
5160
  * Omit null from the expression's type.
@@ -5145,20 +5166,20 @@ const Ft = class Ft {
5145
5166
  * returns a copy of `this` with a new output type.
5146
5167
  */
5147
5168
  $notNull() {
5148
- return new Ft(s(this, ae));
5169
+ return new Ft(s(this, re));
5149
5170
  }
5150
5171
  toOperationNode() {
5151
- return s(this, ae);
5172
+ return s(this, re);
5152
5173
  }
5153
5174
  };
5154
- ae = new WeakMap();
5175
+ re = new WeakMap();
5155
5176
  let S = Ft;
5156
- var Qe, le;
5177
+ var Qe, de;
5157
5178
  class bn {
5158
5179
  constructor(e, n) {
5159
5180
  x(this, Qe);
5160
- x(this, le);
5161
- b(this, Qe, e), b(this, le, n);
5181
+ x(this, de);
5182
+ b(this, Qe, e), b(this, de, n);
5162
5183
  }
5163
5184
  /** @private */
5164
5185
  get expression() {
@@ -5166,13 +5187,13 @@ class bn {
5166
5187
  }
5167
5188
  /** @private */
5168
5189
  get alias() {
5169
- return s(this, le);
5190
+ return s(this, de);
5170
5191
  }
5171
5192
  toOperationNode() {
5172
- return we.create(s(this, Qe).toOperationNode(), q(s(this, le)) ? s(this, le).toOperationNode() : L.create(s(this, le)));
5193
+ return Ne.create(s(this, Qe).toOperationNode(), q(s(this, de)) ? s(this, de).toOperationNode() : L.create(s(this, de)));
5173
5194
  }
5174
5195
  }
5175
- Qe = new WeakMap(), le = new WeakMap();
5196
+ Qe = new WeakMap(), de = new WeakMap();
5176
5197
  var be;
5177
5198
  const jt = class jt {
5178
5199
  constructor(e) {
@@ -5216,7 +5237,7 @@ const Lt = class Lt {
5216
5237
  return new bn(this, e);
5217
5238
  }
5218
5239
  and(...e) {
5219
- return new Lt(he.create(s(this, Oe), U(e)));
5240
+ return new Lt(pe.create(s(this, Oe), U(e)));
5220
5241
  }
5221
5242
  /**
5222
5243
  * Change the output type of the expression.
@@ -5240,7 +5261,7 @@ const Gs = {
5240
5261
  create(t, e) {
5241
5262
  return {
5242
5263
  kind: "FetchNode",
5243
- rowCount: pe.create(t),
5264
+ rowCount: we.create(t),
5244
5265
  modifier: e
5245
5266
  };
5246
5267
  }
@@ -5255,11 +5276,11 @@ function Ys(t, e) {
5255
5276
  function Hs(t) {
5256
5277
  return t === "only" || t === "with ties";
5257
5278
  }
5258
- var m;
5279
+ var h;
5259
5280
  const v = class v {
5260
5281
  constructor(e) {
5261
- x(this, m);
5262
- b(this, m, c(e));
5282
+ x(this, h);
5283
+ b(this, h, c(e));
5263
5284
  }
5264
5285
  get expressionType() {
5265
5286
  }
@@ -5268,206 +5289,206 @@ const v = class v {
5268
5289
  }
5269
5290
  where(...e) {
5270
5291
  return new v({
5271
- ...s(this, m),
5272
- queryNode: $.cloneWithWhere(s(this, m).queryNode, U(e))
5292
+ ...s(this, h),
5293
+ queryNode: $.cloneWithWhere(s(this, h).queryNode, U(e))
5273
5294
  });
5274
5295
  }
5275
5296
  whereRef(e, n, a) {
5276
5297
  return new v({
5277
- ...s(this, m),
5278
- queryNode: $.cloneWithWhere(s(this, m).queryNode, ft(e, n, a))
5298
+ ...s(this, h),
5299
+ queryNode: $.cloneWithWhere(s(this, h).queryNode, ft(e, n, a))
5279
5300
  });
5280
5301
  }
5281
5302
  having(...e) {
5282
5303
  return new v({
5283
- ...s(this, m),
5284
- queryNode: k.cloneWithHaving(s(this, m).queryNode, U(e))
5304
+ ...s(this, h),
5305
+ queryNode: k.cloneWithHaving(s(this, h).queryNode, U(e))
5285
5306
  });
5286
5307
  }
5287
5308
  havingRef(e, n, a) {
5288
5309
  return new v({
5289
- ...s(this, m),
5290
- queryNode: k.cloneWithHaving(s(this, m).queryNode, ft(e, n, a))
5310
+ ...s(this, h),
5311
+ queryNode: k.cloneWithHaving(s(this, h).queryNode, ft(e, n, a))
5291
5312
  });
5292
5313
  }
5293
5314
  select(e) {
5294
5315
  return new v({
5295
- ...s(this, m),
5296
- queryNode: k.cloneWithSelections(s(this, m).queryNode, ga(e))
5316
+ ...s(this, h),
5317
+ queryNode: k.cloneWithSelections(s(this, h).queryNode, ga(e))
5297
5318
  });
5298
5319
  }
5299
5320
  distinctOn(e) {
5300
5321
  return new v({
5301
- ...s(this, m),
5302
- queryNode: k.cloneWithDistinctOn(s(this, m).queryNode, mt(e))
5322
+ ...s(this, h),
5323
+ queryNode: k.cloneWithDistinctOn(s(this, h).queryNode, mt(e))
5303
5324
  });
5304
5325
  }
5305
5326
  modifyFront(e) {
5306
5327
  return new v({
5307
- ...s(this, m),
5308
- queryNode: k.cloneWithFrontModifier(s(this, m).queryNode, H.createWithExpression(e.toOperationNode()))
5328
+ ...s(this, h),
5329
+ queryNode: k.cloneWithFrontModifier(s(this, h).queryNode, X.createWithExpression(e.toOperationNode()))
5309
5330
  });
5310
5331
  }
5311
5332
  modifyEnd(e) {
5312
5333
  return new v({
5313
- ...s(this, m),
5314
- queryNode: $.cloneWithEndModifier(s(this, m).queryNode, H.createWithExpression(e.toOperationNode()))
5334
+ ...s(this, h),
5335
+ queryNode: $.cloneWithEndModifier(s(this, h).queryNode, X.createWithExpression(e.toOperationNode()))
5315
5336
  });
5316
5337
  }
5317
5338
  distinct() {
5318
5339
  return new v({
5319
- ...s(this, m),
5320
- queryNode: k.cloneWithFrontModifier(s(this, m).queryNode, H.create("Distinct"))
5340
+ ...s(this, h),
5341
+ queryNode: k.cloneWithFrontModifier(s(this, h).queryNode, X.create("Distinct"))
5321
5342
  });
5322
5343
  }
5323
5344
  forUpdate(e) {
5324
5345
  return new v({
5325
- ...s(this, m),
5326
- queryNode: $.cloneWithEndModifier(s(this, m).queryNode, H.create("ForUpdate", e ? xt(e).map(K) : void 0))
5346
+ ...s(this, h),
5347
+ queryNode: $.cloneWithEndModifier(s(this, h).queryNode, X.create("ForUpdate", e ? xt(e).map(K) : void 0))
5327
5348
  });
5328
5349
  }
5329
5350
  forShare(e) {
5330
5351
  return new v({
5331
- ...s(this, m),
5332
- queryNode: $.cloneWithEndModifier(s(this, m).queryNode, H.create("ForShare", e ? xt(e).map(K) : void 0))
5352
+ ...s(this, h),
5353
+ queryNode: $.cloneWithEndModifier(s(this, h).queryNode, X.create("ForShare", e ? xt(e).map(K) : void 0))
5333
5354
  });
5334
5355
  }
5335
5356
  forKeyShare(e) {
5336
5357
  return new v({
5337
- ...s(this, m),
5338
- queryNode: $.cloneWithEndModifier(s(this, m).queryNode, H.create("ForKeyShare", e ? xt(e).map(K) : void 0))
5358
+ ...s(this, h),
5359
+ queryNode: $.cloneWithEndModifier(s(this, h).queryNode, X.create("ForKeyShare", e ? xt(e).map(K) : void 0))
5339
5360
  });
5340
5361
  }
5341
5362
  forNoKeyUpdate(e) {
5342
5363
  return new v({
5343
- ...s(this, m),
5344
- queryNode: $.cloneWithEndModifier(s(this, m).queryNode, H.create("ForNoKeyUpdate", e ? xt(e).map(K) : void 0))
5364
+ ...s(this, h),
5365
+ queryNode: $.cloneWithEndModifier(s(this, h).queryNode, X.create("ForNoKeyUpdate", e ? xt(e).map(K) : void 0))
5345
5366
  });
5346
5367
  }
5347
5368
  skipLocked() {
5348
5369
  return new v({
5349
- ...s(this, m),
5350
- queryNode: $.cloneWithEndModifier(s(this, m).queryNode, H.create("SkipLocked"))
5370
+ ...s(this, h),
5371
+ queryNode: $.cloneWithEndModifier(s(this, h).queryNode, X.create("SkipLocked"))
5351
5372
  });
5352
5373
  }
5353
5374
  noWait() {
5354
5375
  return new v({
5355
- ...s(this, m),
5356
- queryNode: $.cloneWithEndModifier(s(this, m).queryNode, H.create("NoWait"))
5376
+ ...s(this, h),
5377
+ queryNode: $.cloneWithEndModifier(s(this, h).queryNode, X.create("NoWait"))
5357
5378
  });
5358
5379
  }
5359
5380
  selectAll(e) {
5360
5381
  return new v({
5361
- ...s(this, m),
5362
- queryNode: k.cloneWithSelections(s(this, m).queryNode, wa(e))
5382
+ ...s(this, h),
5383
+ queryNode: k.cloneWithSelections(s(this, h).queryNode, wa(e))
5363
5384
  });
5364
5385
  }
5365
5386
  innerJoin(...e) {
5366
5387
  return new v({
5367
- ...s(this, m),
5368
- queryNode: $.cloneWithJoin(s(this, m).queryNode, De("InnerJoin", e))
5388
+ ...s(this, h),
5389
+ queryNode: $.cloneWithJoin(s(this, h).queryNode, De("InnerJoin", e))
5369
5390
  });
5370
5391
  }
5371
5392
  leftJoin(...e) {
5372
5393
  return new v({
5373
- ...s(this, m),
5374
- queryNode: $.cloneWithJoin(s(this, m).queryNode, De("LeftJoin", e))
5394
+ ...s(this, h),
5395
+ queryNode: $.cloneWithJoin(s(this, h).queryNode, De("LeftJoin", e))
5375
5396
  });
5376
5397
  }
5377
5398
  rightJoin(...e) {
5378
5399
  return new v({
5379
- ...s(this, m),
5380
- queryNode: $.cloneWithJoin(s(this, m).queryNode, De("RightJoin", e))
5400
+ ...s(this, h),
5401
+ queryNode: $.cloneWithJoin(s(this, h).queryNode, De("RightJoin", e))
5381
5402
  });
5382
5403
  }
5383
5404
  fullJoin(...e) {
5384
5405
  return new v({
5385
- ...s(this, m),
5386
- queryNode: $.cloneWithJoin(s(this, m).queryNode, De("FullJoin", e))
5406
+ ...s(this, h),
5407
+ queryNode: $.cloneWithJoin(s(this, h).queryNode, De("FullJoin", e))
5387
5408
  });
5388
5409
  }
5389
5410
  innerJoinLateral(...e) {
5390
5411
  return new v({
5391
- ...s(this, m),
5392
- queryNode: $.cloneWithJoin(s(this, m).queryNode, De("LateralInnerJoin", e))
5412
+ ...s(this, h),
5413
+ queryNode: $.cloneWithJoin(s(this, h).queryNode, De("LateralInnerJoin", e))
5393
5414
  });
5394
5415
  }
5395
5416
  leftJoinLateral(...e) {
5396
5417
  return new v({
5397
- ...s(this, m),
5398
- queryNode: $.cloneWithJoin(s(this, m).queryNode, De("LateralLeftJoin", e))
5418
+ ...s(this, h),
5419
+ queryNode: $.cloneWithJoin(s(this, h).queryNode, De("LateralLeftJoin", e))
5399
5420
  });
5400
5421
  }
5401
5422
  orderBy(...e) {
5402
5423
  return new v({
5403
- ...s(this, m),
5404
- queryNode: k.cloneWithOrderByItems(s(this, m).queryNode, vn(e))
5424
+ ...s(this, h),
5425
+ queryNode: k.cloneWithOrderByItems(s(this, h).queryNode, vn(e))
5405
5426
  });
5406
5427
  }
5407
5428
  groupBy(e) {
5408
5429
  return new v({
5409
- ...s(this, m),
5410
- queryNode: k.cloneWithGroupByItems(s(this, m).queryNode, Qs(e))
5430
+ ...s(this, h),
5431
+ queryNode: k.cloneWithGroupByItems(s(this, h).queryNode, Qs(e))
5411
5432
  });
5412
5433
  }
5413
5434
  limit(e) {
5414
5435
  return new v({
5415
- ...s(this, m),
5416
- queryNode: k.cloneWithLimit(s(this, m).queryNode, Is.create(z(e)))
5436
+ ...s(this, h),
5437
+ queryNode: k.cloneWithLimit(s(this, h).queryNode, Is.create(z(e)))
5417
5438
  });
5418
5439
  }
5419
5440
  offset(e) {
5420
5441
  return new v({
5421
- ...s(this, m),
5422
- queryNode: k.cloneWithOffset(s(this, m).queryNode, Ks.create(z(e)))
5442
+ ...s(this, h),
5443
+ queryNode: k.cloneWithOffset(s(this, h).queryNode, Ks.create(z(e)))
5423
5444
  });
5424
5445
  }
5425
5446
  fetch(e, n = "only") {
5426
5447
  return new v({
5427
- ...s(this, m),
5428
- queryNode: k.cloneWithFetch(s(this, m).queryNode, Ys(e, n))
5448
+ ...s(this, h),
5449
+ queryNode: k.cloneWithFetch(s(this, h).queryNode, Ys(e, n))
5429
5450
  });
5430
5451
  }
5431
5452
  top(e, n) {
5432
5453
  return new v({
5433
- ...s(this, m),
5434
- queryNode: $.cloneWithTop(s(this, m).queryNode, Ss(e, n))
5454
+ ...s(this, h),
5455
+ queryNode: $.cloneWithTop(s(this, h).queryNode, Ss(e, n))
5435
5456
  });
5436
5457
  }
5437
5458
  union(e) {
5438
5459
  return new v({
5439
- ...s(this, m),
5440
- queryNode: k.cloneWithSetOperations(s(this, m).queryNode, ze("union", e, !1))
5460
+ ...s(this, h),
5461
+ queryNode: k.cloneWithSetOperations(s(this, h).queryNode, ze("union", e, !1))
5441
5462
  });
5442
5463
  }
5443
5464
  unionAll(e) {
5444
5465
  return new v({
5445
- ...s(this, m),
5446
- queryNode: k.cloneWithSetOperations(s(this, m).queryNode, ze("union", e, !0))
5466
+ ...s(this, h),
5467
+ queryNode: k.cloneWithSetOperations(s(this, h).queryNode, ze("union", e, !0))
5447
5468
  });
5448
5469
  }
5449
5470
  intersect(e) {
5450
5471
  return new v({
5451
- ...s(this, m),
5452
- queryNode: k.cloneWithSetOperations(s(this, m).queryNode, ze("intersect", e, !1))
5472
+ ...s(this, h),
5473
+ queryNode: k.cloneWithSetOperations(s(this, h).queryNode, ze("intersect", e, !1))
5453
5474
  });
5454
5475
  }
5455
5476
  intersectAll(e) {
5456
5477
  return new v({
5457
- ...s(this, m),
5458
- queryNode: k.cloneWithSetOperations(s(this, m).queryNode, ze("intersect", e, !0))
5478
+ ...s(this, h),
5479
+ queryNode: k.cloneWithSetOperations(s(this, h).queryNode, ze("intersect", e, !0))
5459
5480
  });
5460
5481
  }
5461
5482
  except(e) {
5462
5483
  return new v({
5463
- ...s(this, m),
5464
- queryNode: k.cloneWithSetOperations(s(this, m).queryNode, ze("except", e, !1))
5484
+ ...s(this, h),
5485
+ queryNode: k.cloneWithSetOperations(s(this, h).queryNode, ze("except", e, !1))
5465
5486
  });
5466
5487
  }
5467
5488
  exceptAll(e) {
5468
5489
  return new v({
5469
- ...s(this, m),
5470
- queryNode: k.cloneWithSetOperations(s(this, m).queryNode, ze("except", e, !0))
5490
+ ...s(this, h),
5491
+ queryNode: k.cloneWithSetOperations(s(this, h).queryNode, ze("except", e, !0))
5471
5492
  });
5472
5493
  }
5473
5494
  as(e) {
@@ -5475,38 +5496,38 @@ const v = class v {
5475
5496
  }
5476
5497
  clearSelect() {
5477
5498
  return new v({
5478
- ...s(this, m),
5479
- queryNode: k.cloneWithoutSelections(s(this, m).queryNode)
5499
+ ...s(this, h),
5500
+ queryNode: k.cloneWithoutSelections(s(this, h).queryNode)
5480
5501
  });
5481
5502
  }
5482
5503
  clearWhere() {
5483
5504
  return new v({
5484
- ...s(this, m),
5485
- queryNode: $.cloneWithoutWhere(s(this, m).queryNode)
5505
+ ...s(this, h),
5506
+ queryNode: $.cloneWithoutWhere(s(this, h).queryNode)
5486
5507
  });
5487
5508
  }
5488
5509
  clearLimit() {
5489
5510
  return new v({
5490
- ...s(this, m),
5491
- queryNode: k.cloneWithoutLimit(s(this, m).queryNode)
5511
+ ...s(this, h),
5512
+ queryNode: k.cloneWithoutLimit(s(this, h).queryNode)
5492
5513
  });
5493
5514
  }
5494
5515
  clearOffset() {
5495
5516
  return new v({
5496
- ...s(this, m),
5497
- queryNode: k.cloneWithoutOffset(s(this, m).queryNode)
5517
+ ...s(this, h),
5518
+ queryNode: k.cloneWithoutOffset(s(this, h).queryNode)
5498
5519
  });
5499
5520
  }
5500
5521
  clearOrderBy() {
5501
5522
  return new v({
5502
- ...s(this, m),
5503
- queryNode: k.cloneWithoutOrderBy(s(this, m).queryNode)
5523
+ ...s(this, h),
5524
+ queryNode: k.cloneWithoutOrderBy(s(this, h).queryNode)
5504
5525
  });
5505
5526
  }
5506
5527
  clearGroupBy() {
5507
5528
  return new v({
5508
- ...s(this, m),
5509
- queryNode: k.cloneWithoutGroupBy(s(this, m).queryNode)
5529
+ ...s(this, h),
5530
+ queryNode: k.cloneWithoutGroupBy(s(this, h).queryNode)
5510
5531
  });
5511
5532
  }
5512
5533
  $call(e) {
@@ -5514,36 +5535,36 @@ const v = class v {
5514
5535
  }
5515
5536
  $if(e, n) {
5516
5537
  return e ? n(this) : new v({
5517
- ...s(this, m)
5538
+ ...s(this, h)
5518
5539
  });
5519
5540
  }
5520
5541
  $castTo() {
5521
- return new v(s(this, m));
5542
+ return new v(s(this, h));
5522
5543
  }
5523
5544
  $narrowType() {
5524
- return new v(s(this, m));
5545
+ return new v(s(this, h));
5525
5546
  }
5526
5547
  $assertType() {
5527
- return new v(s(this, m));
5548
+ return new v(s(this, h));
5528
5549
  }
5529
5550
  $asTuple() {
5530
5551
  return new S(this.toOperationNode());
5531
5552
  }
5532
5553
  withPlugin(e) {
5533
5554
  return new v({
5534
- ...s(this, m),
5535
- executor: s(this, m).executor.withPlugin(e)
5555
+ ...s(this, h),
5556
+ executor: s(this, h).executor.withPlugin(e)
5536
5557
  });
5537
5558
  }
5538
5559
  toOperationNode() {
5539
- return s(this, m).executor.transformQuery(s(this, m).queryNode, s(this, m).queryId);
5560
+ return s(this, h).executor.transformQuery(s(this, h).queryNode, s(this, h).queryId);
5540
5561
  }
5541
5562
  compile() {
5542
- return s(this, m).executor.compileQuery(this.toOperationNode(), s(this, m).queryId);
5563
+ return s(this, h).executor.compileQuery(this.toOperationNode(), s(this, h).queryId);
5543
5564
  }
5544
5565
  async execute() {
5545
5566
  const e = this.compile();
5546
- return (await s(this, m).executor.executeQuery(e, s(this, m).queryId)).rows;
5567
+ return (await s(this, h).executor.executeQuery(e, s(this, h).queryId)).rows;
5547
5568
  }
5548
5569
  async executeTakeFirst() {
5549
5570
  const [e] = await this.execute();
@@ -5556,18 +5577,18 @@ const v = class v {
5556
5577
  return n;
5557
5578
  }
5558
5579
  async *stream(e = 100) {
5559
- const n = this.compile(), a = s(this, m).executor.stream(n, e, s(this, m).queryId);
5580
+ const n = this.compile(), a = s(this, h).executor.stream(n, e, s(this, h).queryId);
5560
5581
  for await (const r of a)
5561
5582
  yield* r.rows;
5562
5583
  }
5563
5584
  async explain(e, n) {
5564
5585
  return await new v({
5565
- ...s(this, m),
5566
- queryNode: $.cloneWithExplain(s(this, m).queryNode, e, n)
5586
+ ...s(this, h),
5587
+ queryNode: $.cloneWithExplain(s(this, h).queryNode, e, n)
5567
5588
  }).execute();
5568
5589
  }
5569
5590
  };
5570
- m = new WeakMap();
5591
+ h = new WeakMap();
5571
5592
  let At = v;
5572
5593
  $e(At, "don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");
5573
5594
  function Xs(t) {
@@ -5590,12 +5611,12 @@ class ba {
5590
5611
  return !0;
5591
5612
  }
5592
5613
  toOperationNode() {
5593
- return we.create(s(this, Ve).toOperationNode(), L.create(s(this, Ge)));
5614
+ return Ne.create(s(this, Ve).toOperationNode(), L.create(s(this, Ge)));
5594
5615
  }
5595
5616
  }
5596
5617
  Ve = new WeakMap(), Ge = new WeakMap();
5597
5618
  $e(ba, "don't await AliasedSelectQueryBuilder instances directly. AliasedSelectQueryBuilder should never be executed directly since it's always a part of another query.");
5598
- const ce = c({
5619
+ const ue = c({
5599
5620
  is(t) {
5600
5621
  return t.kind === "AggregateFunctionNode";
5601
5622
  },
@@ -5615,7 +5636,7 @@ const ce = c({
5615
5636
  cloneWithOrderBy(t, e) {
5616
5637
  return c({
5617
5638
  ...t,
5618
- orderBy: t.orderBy ? ge.cloneWithItems(t.orderBy, e) : ge.create(e)
5639
+ orderBy: t.orderBy ? ye.cloneWithItems(t.orderBy, e) : ye.create(e)
5619
5640
  });
5620
5641
  },
5621
5642
  cloneWithFilter(t, e) {
@@ -5649,7 +5670,7 @@ const ce = c({
5649
5670
  }
5650
5671
  });
5651
5672
  var P;
5652
- const ne = class ne {
5673
+ const ae = class ae {
5653
5674
  constructor(e) {
5654
5675
  x(this, P);
5655
5676
  b(this, P, c(e));
@@ -5707,9 +5728,9 @@ const ne = class ne {
5707
5728
  * ```
5708
5729
  */
5709
5730
  distinct() {
5710
- return new ne({
5731
+ return new ae({
5711
5732
  ...s(this, P),
5712
- aggregateFunctionNode: ce.cloneWithDistinct(s(this, P).aggregateFunctionNode)
5733
+ aggregateFunctionNode: ue.cloneWithDistinct(s(this, P).aggregateFunctionNode)
5713
5734
  });
5714
5735
  }
5715
5736
  /**
@@ -5736,15 +5757,15 @@ const ne = class ne {
5736
5757
  * ```
5737
5758
  */
5738
5759
  orderBy(e, n) {
5739
- return new ne({
5760
+ return new ae({
5740
5761
  ...s(this, P),
5741
- aggregateFunctionNode: ce.cloneWithOrderBy(s(this, P).aggregateFunctionNode, vn([e, n]))
5762
+ aggregateFunctionNode: ue.cloneWithOrderBy(s(this, P).aggregateFunctionNode, vn([e, n]))
5742
5763
  });
5743
5764
  }
5744
5765
  filterWhere(...e) {
5745
- return new ne({
5766
+ return new ae({
5746
5767
  ...s(this, P),
5747
- aggregateFunctionNode: ce.cloneWithFilter(s(this, P).aggregateFunctionNode, U(e))
5768
+ aggregateFunctionNode: ue.cloneWithFilter(s(this, P).aggregateFunctionNode, U(e))
5748
5769
  });
5749
5770
  }
5750
5771
  /**
@@ -5780,9 +5801,9 @@ const ne = class ne {
5780
5801
  * ```
5781
5802
  */
5782
5803
  filterWhereRef(e, n, a) {
5783
- return new ne({
5804
+ return new ae({
5784
5805
  ...s(this, P),
5785
- aggregateFunctionNode: ce.cloneWithFilter(s(this, P).aggregateFunctionNode, ft(e, n, a))
5806
+ aggregateFunctionNode: ue.cloneWithFilter(s(this, P).aggregateFunctionNode, ft(e, n, a))
5786
5807
  });
5787
5808
  }
5788
5809
  /**
@@ -5829,9 +5850,9 @@ const ne = class ne {
5829
5850
  */
5830
5851
  over(e) {
5831
5852
  const n = Bs();
5832
- return new ne({
5853
+ return new ae({
5833
5854
  ...s(this, P),
5834
- aggregateFunctionNode: ce.cloneWithOver(s(this, P).aggregateFunctionNode, (e ? e(n) : n).toOperationNode())
5855
+ aggregateFunctionNode: ue.cloneWithOver(s(this, P).aggregateFunctionNode, (e ? e(n) : n).toOperationNode())
5835
5856
  });
5836
5857
  }
5837
5858
  /**
@@ -5848,7 +5869,7 @@ const ne = class ne {
5848
5869
  * returns a copy of this `AggregateFunctionBuilder` with a new output type.
5849
5870
  */
5850
5871
  $castTo() {
5851
- return new ne(s(this, P));
5872
+ return new ae(s(this, P));
5852
5873
  }
5853
5874
  /**
5854
5875
  * Omit null from the expression's type.
@@ -5860,15 +5881,15 @@ const ne = class ne {
5860
5881
  * returns a copy of `this` with a new output type.
5861
5882
  */
5862
5883
  $notNull() {
5863
- return new ne(s(this, P));
5884
+ return new ae(s(this, P));
5864
5885
  }
5865
5886
  toOperationNode() {
5866
5887
  return s(this, P).aggregateFunctionNode;
5867
5888
  }
5868
5889
  };
5869
5890
  P = new WeakMap();
5870
- let Je = ne;
5871
- $e(Je, "don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");
5891
+ let Me = ae;
5892
+ $e(Me, "don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.");
5872
5893
  var Ye, He;
5873
5894
  class Zs {
5874
5895
  constructor(e, n) {
@@ -5885,13 +5906,13 @@ class Zs {
5885
5906
  return s(this, He);
5886
5907
  }
5887
5908
  toOperationNode() {
5888
- return we.create(s(this, Ye).toOperationNode(), L.create(s(this, He)));
5909
+ return Ne.create(s(this, Ye).toOperationNode(), L.create(s(this, He)));
5889
5910
  }
5890
5911
  }
5891
5912
  Ye = new WeakMap(), He = new WeakMap();
5892
5913
  function ec() {
5893
- const t = (n, a) => new S(Kn.create(n, mt(a ?? []))), e = (n, a) => new Je({
5894
- aggregateFunctionNode: ce.create(n, a ? mt(a) : void 0)
5914
+ const t = (n, a) => new S(Kn.create(n, mt(a ?? []))), e = (n, a) => new Me({
5915
+ aggregateFunctionNode: ue.create(n, a ? mt(a) : void 0)
5895
5916
  });
5896
5917
  return Object.assign(t, {
5897
5918
  agg: e,
@@ -5905,8 +5926,8 @@ function ec() {
5905
5926
  return e("count", [n]);
5906
5927
  },
5907
5928
  countAll(n) {
5908
- return new Je({
5909
- aggregateFunctionNode: ce.create("count", wa(n))
5929
+ return new Me({
5930
+ aggregateFunctionNode: ue.create("count", wa(n))
5910
5931
  });
5911
5932
  },
5912
5933
  max(n) {
@@ -5922,8 +5943,8 @@ function ec() {
5922
5943
  return t("any", [n]);
5923
5944
  },
5924
5945
  jsonAgg(n) {
5925
- return new Je({
5926
- aggregateFunctionNode: ce.create("json_agg", [
5946
+ return new Me({
5947
+ aggregateFunctionNode: ue.create("json_agg", [
5927
5948
  Y(n) ? K(n) : n.toOperationNode()
5928
5949
  ])
5929
5950
  });
@@ -5948,9 +5969,9 @@ const tc = c({
5948
5969
  }
5949
5970
  });
5950
5971
  function nc(t, e) {
5951
- return tc.create(Ee.create(t), M(e));
5972
+ return tc.create(Ee.create(t), J(e));
5952
5973
  }
5953
- const re = c({
5974
+ const oe = c({
5954
5975
  is(t) {
5955
5976
  return t.kind === "CaseNode";
5956
5977
  },
@@ -5991,7 +6012,7 @@ class ac {
5991
6012
  when(...e) {
5992
6013
  return new Oa({
5993
6014
  ...s(this, Xe),
5994
- node: re.cloneWithWhen(s(this, Xe).node, Wt.create(U(e)))
6015
+ node: oe.cloneWithWhen(s(this, Xe).node, Wt.create(U(e)))
5995
6016
  });
5996
6017
  }
5997
6018
  }
@@ -6005,7 +6026,7 @@ class Oa {
6005
6026
  then(e) {
6006
6027
  return new rc({
6007
6028
  ...s(this, Ze),
6008
- node: re.cloneWithThen(s(this, Ze).node, Cn(e) ? xn(e) : z(e))
6029
+ node: oe.cloneWithThen(s(this, Ze).node, Cn(e) ? xn(e) : z(e))
6009
6030
  });
6010
6031
  }
6011
6032
  }
@@ -6019,22 +6040,22 @@ class rc {
6019
6040
  when(...e) {
6020
6041
  return new Oa({
6021
6042
  ...s(this, V),
6022
- node: re.cloneWithWhen(s(this, V).node, Wt.create(U(e)))
6043
+ node: oe.cloneWithWhen(s(this, V).node, Wt.create(U(e)))
6023
6044
  });
6024
6045
  }
6025
6046
  else(e) {
6026
6047
  return new oc({
6027
6048
  ...s(this, V),
6028
- node: re.cloneWith(s(this, V).node, {
6049
+ node: oe.cloneWith(s(this, V).node, {
6029
6050
  else: Cn(e) ? xn(e) : z(e)
6030
6051
  })
6031
6052
  });
6032
6053
  }
6033
6054
  end() {
6034
- return new S(re.cloneWith(s(this, V).node, { isStatement: !1 }));
6055
+ return new S(oe.cloneWith(s(this, V).node, { isStatement: !1 }));
6035
6056
  }
6036
6057
  endCase() {
6037
- return new S(re.cloneWith(s(this, V).node, { isStatement: !0 }));
6058
+ return new S(oe.cloneWith(s(this, V).node, { isStatement: !0 }));
6038
6059
  }
6039
6060
  }
6040
6061
  V = new WeakMap();
@@ -6045,10 +6066,10 @@ class oc {
6045
6066
  b(this, et, c(e));
6046
6067
  }
6047
6068
  end() {
6048
- return new S(re.cloneWith(s(this, et).node, { isStatement: !1 }));
6069
+ return new S(oe.cloneWith(s(this, et).node, { isStatement: !1 }));
6049
6070
  }
6050
6071
  endCase() {
6051
- return new S(re.cloneWith(s(this, et).node, { isStatement: !0 }));
6072
+ return new S(oe.cloneWith(s(this, et).node, { isStatement: !0 }));
6052
6073
  }
6053
6074
  }
6054
6075
  et = new WeakMap();
@@ -6139,7 +6160,7 @@ class un {
6139
6160
  * ```
6140
6161
  */
6141
6162
  at(e) {
6142
- return y(this, yt, dn).call(this, "ArrayLocation", e);
6163
+ return N(this, yt, dn).call(this, "ArrayLocation", e);
6143
6164
  }
6144
6165
  /**
6145
6166
  * Access a property of a JSON object.
@@ -6191,14 +6212,14 @@ class un {
6191
6212
  * ```
6192
6213
  */
6193
6214
  key(e) {
6194
- return y(this, yt, dn).call(this, "Member", e);
6215
+ return N(this, yt, dn).call(this, "Member", e);
6195
6216
  }
6196
6217
  }
6197
6218
  G = new WeakMap(), yt = new WeakSet(), dn = function(e, n) {
6198
- return St.is(s(this, G)) ? new $t(St.cloneWithTraversal(s(this, G), lt.is(s(this, G).traversal) ? lt.cloneWithLeg(s(this, G).traversal, Un.create(e, n)) : ha.cloneWithValue(s(this, G).traversal, pe.createImmediate(n)))) : new $t(lt.cloneWithLeg(s(this, G), Un.create(e, n)));
6219
+ return St.is(s(this, G)) ? new $t(St.cloneWithTraversal(s(this, G), lt.is(s(this, G).traversal) ? lt.cloneWithLeg(s(this, G).traversal, Un.create(e, n)) : ha.cloneWithValue(s(this, G).traversal, we.createImmediate(n)))) : new $t(lt.cloneWithLeg(s(this, G), Un.create(e, n)));
6199
6220
  };
6200
6221
  var Se;
6201
- const Mt = class Mt extends un {
6222
+ const Jt = class Jt extends un {
6202
6223
  constructor(n) {
6203
6224
  super(n);
6204
6225
  x(this, Se);
@@ -6217,23 +6238,23 @@ const Mt = class Mt extends un {
6217
6238
  * returns a copy of this `JSONPathBuilder` with a new output type.
6218
6239
  */
6219
6240
  $castTo() {
6220
- return new Mt(s(this, Se));
6241
+ return new Jt(s(this, Se));
6221
6242
  }
6222
6243
  $notNull() {
6223
- return new Mt(s(this, Se));
6244
+ return new Jt(s(this, Se));
6224
6245
  }
6225
6246
  toOperationNode() {
6226
6247
  return s(this, Se);
6227
6248
  }
6228
6249
  };
6229
6250
  Se = new WeakMap();
6230
- let $t = Mt;
6231
- var tt, ue;
6251
+ let $t = Jt;
6252
+ var tt, _e;
6232
6253
  class ic {
6233
6254
  constructor(e, n) {
6234
6255
  x(this, tt);
6235
- x(this, ue);
6236
- b(this, tt, e), b(this, ue, n);
6256
+ x(this, _e);
6257
+ b(this, tt, e), b(this, _e, n);
6237
6258
  }
6238
6259
  /** @private */
6239
6260
  get expression() {
@@ -6241,13 +6262,13 @@ class ic {
6241
6262
  }
6242
6263
  /** @private */
6243
6264
  get alias() {
6244
- return s(this, ue);
6265
+ return s(this, _e);
6245
6266
  }
6246
6267
  toOperationNode() {
6247
- return we.create(s(this, tt).toOperationNode(), q(s(this, ue)) ? s(this, ue).toOperationNode() : L.create(s(this, ue)));
6268
+ return Ne.create(s(this, tt).toOperationNode(), q(s(this, _e)) ? s(this, _e).toOperationNode() : L.create(s(this, _e)));
6248
6269
  }
6249
6270
  }
6250
- tt = new WeakMap(), ue = new WeakMap();
6271
+ tt = new WeakMap(), _e = new WeakMap();
6251
6272
  const Qn = c({
6252
6273
  is(t) {
6253
6274
  return t.kind === "TupleNode";
@@ -6359,18 +6380,18 @@ function On(t = Ta) {
6359
6380
  eb: void 0,
6360
6381
  selectFrom(r) {
6361
6382
  return Xs({
6362
- queryId: X(),
6383
+ queryId: Z(),
6363
6384
  executor: t,
6364
6385
  queryNode: k.createFrom(mc(r))
6365
6386
  });
6366
6387
  },
6367
6388
  case(r) {
6368
6389
  return new ac({
6369
- node: re.create(Ot(r) ? void 0 : M(r))
6390
+ node: oe.create(Ot(r) ? void 0 : J(r))
6370
6391
  });
6371
6392
  },
6372
6393
  ref(r, o) {
6373
- return Ot(o) ? new S(fe(r)) : new un(cs(r, o));
6394
+ return Ot(o) ? new S(ge(r)) : new un(cs(r, o));
6374
6395
  },
6375
6396
  jsonPath() {
6376
6397
  return new un(lt.create());
@@ -6382,7 +6403,7 @@ function On(t = Ta) {
6382
6403
  return new S(z(r));
6383
6404
  },
6384
6405
  refTuple(...r) {
6385
- return new S(Qn.create(r.map(M)));
6406
+ return new S(Qn.create(r.map(J)));
6386
6407
  },
6387
6408
  tuple(...r) {
6388
6409
  return new S(Qn.create(r.map(z)));
@@ -6401,23 +6422,23 @@ function On(t = Ta) {
6401
6422
  return n("-", r);
6402
6423
  },
6403
6424
  between(r, o, i) {
6404
- return new S(nt.create(M(r), Ee.create("between"), he.create(z(o), z(i))));
6425
+ return new S(nt.create(J(r), Ee.create("between"), pe.create(z(o), z(i))));
6405
6426
  },
6406
6427
  betweenSymmetric(r, o, i) {
6407
- return new S(nt.create(M(r), Ee.create("between symmetric"), he.create(z(o), z(i))));
6428
+ return new S(nt.create(J(r), Ee.create("between symmetric"), pe.create(z(o), z(i))));
6408
6429
  },
6409
6430
  and(r) {
6410
- return me(r) ? new S(tn(r, "and")) : new S($n(r, "and"));
6431
+ return fe(r) ? new S(tn(r, "and")) : new S($n(r, "and"));
6411
6432
  },
6412
6433
  or(r) {
6413
- return me(r) ? new S(tn(r, "or")) : new S($n(r, "or"));
6434
+ return fe(r) ? new S(tn(r, "or")) : new S($n(r, "or"));
6414
6435
  },
6415
6436
  parens(...r) {
6416
6437
  const o = U(r);
6417
6438
  return ht.is(o) ? new S(o) : new S(ht.create(o));
6418
6439
  },
6419
6440
  cast(r, o) {
6420
- return new S(_c.create(M(r), dc(o)));
6441
+ return new S(_c.create(J(r), dc(o)));
6421
6442
  },
6422
6443
  withSchema(r) {
6423
6444
  return On(t.withPluginAtFront(new xa(r)));
@@ -6446,7 +6467,7 @@ function Qt(t) {
6446
6467
  return Hi(t) || Xi(t) || Ae(t);
6447
6468
  }
6448
6469
  function mc(t) {
6449
- return me(t) ? t.map((e) => Pt(e)) : [Pt(t)];
6470
+ return fe(t) ? t.map((e) => Pt(e)) : [Pt(t)];
6450
6471
  }
6451
6472
  function Pt(t) {
6452
6473
  return Y(t) ? hc(t) : Sa(t);
@@ -6455,7 +6476,7 @@ function hc(t) {
6455
6476
  const e = " as ";
6456
6477
  if (t.includes(e)) {
6457
6478
  const [n, a] = t.split(e).map(ka);
6458
- return we.create(K(n), L.create(a));
6479
+ return Ne.create(K(n), L.create(a));
6459
6480
  } else
6460
6481
  return K(t);
6461
6482
  }
@@ -6463,17 +6484,17 @@ function K(t) {
6463
6484
  const e = ".";
6464
6485
  if (t.includes(e)) {
6465
6486
  const [n, a] = t.split(e).map(ka);
6466
- return _e.createWithSchema(n, a);
6487
+ return he.createWithSchema(n, a);
6467
6488
  } else
6468
- return _e.create(t);
6489
+ return he.create(t);
6469
6490
  }
6470
6491
  function ka(t) {
6471
6492
  return t.trim();
6472
6493
  }
6473
- var D, J, Tt, _n, mn;
6494
+ var D, M, Tt, _n, mn;
6474
6495
  const _t = class _t {
6475
6496
  constructor(e) {
6476
- x(this, J);
6497
+ x(this, M);
6477
6498
  x(this, D);
6478
6499
  b(this, D, c(e));
6479
6500
  }
@@ -6498,64 +6519,64 @@ const _t = class _t {
6498
6519
  });
6499
6520
  }
6500
6521
  toOperationNode() {
6501
- return y(this, J, _n).call(this, y(this, J, Tt).call(this));
6522
+ return N(this, M, _n).call(this, N(this, M, Tt).call(this));
6502
6523
  }
6503
6524
  compile(e) {
6504
- return y(this, J, mn).call(this, y(this, J, Tt).call(this, e));
6525
+ return N(this, M, mn).call(this, N(this, M, Tt).call(this, e));
6505
6526
  }
6506
6527
  async execute(e) {
6507
- const n = y(this, J, Tt).call(this, e);
6508
- return n.executeQuery(y(this, J, mn).call(this, n), s(this, D).queryId);
6528
+ const n = N(this, M, Tt).call(this, e);
6529
+ return n.executeQuery(N(this, M, mn).call(this, n), s(this, D).queryId);
6509
6530
  }
6510
6531
  };
6511
- D = new WeakMap(), J = new WeakSet(), Tt = function(e) {
6532
+ D = new WeakMap(), M = new WeakSet(), Tt = function(e) {
6512
6533
  const n = e !== void 0 ? e.getExecutor() : Ta;
6513
6534
  return s(this, D).plugins !== void 0 ? n.withPlugins(s(this, D).plugins) : n;
6514
6535
  }, _n = function(e) {
6515
6536
  return e.transformQuery(s(this, D).rawNode, s(this, D).queryId);
6516
6537
  }, mn = function(e) {
6517
- return e.compileQuery(y(this, J, _n).call(this, e), s(this, D).queryId);
6538
+ return e.compileQuery(N(this, M, _n).call(this, e), s(this, D).queryId);
6518
6539
  };
6519
6540
  let Dt = _t;
6520
- function se(t) {
6541
+ function le(t) {
6521
6542
  return new Dt(t);
6522
6543
  }
6523
6544
  $e(Dt, "don't await RawBuilder instances directly. To execute the query you need to call `execute`");
6524
- var ke, de;
6545
+ var ke, me;
6525
6546
  class Ia {
6526
6547
  constructor(e, n) {
6527
6548
  x(this, ke);
6528
- x(this, de);
6529
- b(this, ke, e), b(this, de, n);
6549
+ x(this, me);
6550
+ b(this, ke, e), b(this, me, n);
6530
6551
  }
6531
6552
  get expression() {
6532
6553
  return s(this, ke);
6533
6554
  }
6534
6555
  get alias() {
6535
- return s(this, de);
6556
+ return s(this, me);
6536
6557
  }
6537
6558
  get rawBuilder() {
6538
6559
  return s(this, ke);
6539
6560
  }
6540
6561
  toOperationNode() {
6541
- return we.create(s(this, ke).toOperationNode(), q(s(this, de)) ? s(this, de).toOperationNode() : L.create(s(this, de)));
6562
+ return Ne.create(s(this, ke).toOperationNode(), q(s(this, me)) ? s(this, me).toOperationNode() : L.create(s(this, me)));
6542
6563
  }
6543
6564
  }
6544
- ke = new WeakMap(), de = new WeakMap();
6565
+ ke = new WeakMap(), me = new WeakMap();
6545
6566
  $e(Ia, "don't await AliasedRawBuilder instances directly. AliasedRawBuilder should never be executed directly since it's always a part of another query.");
6546
- const w = Object.assign((t, ...e) => se({
6547
- queryId: X(),
6567
+ const w = Object.assign((t, ...e) => le({
6568
+ queryId: Z(),
6548
6569
  rawNode: j.create(t, (e == null ? void 0 : e.map(Vn)) ?? [])
6549
6570
  }), {
6550
6571
  ref(t) {
6551
- return se({
6552
- queryId: X(),
6553
- rawNode: j.createWithChild(fe(t))
6572
+ return le({
6573
+ queryId: Z(),
6574
+ rawNode: j.createWithChild(ge(t))
6554
6575
  });
6555
6576
  },
6556
6577
  val(t) {
6557
- return se({
6558
- queryId: X(),
6578
+ return le({
6579
+ queryId: Z(),
6559
6580
  rawNode: j.createWithChild(z(t))
6560
6581
  });
6561
6582
  },
@@ -6563,30 +6584,30 @@ const w = Object.assign((t, ...e) => se({
6563
6584
  return this.val(t);
6564
6585
  },
6565
6586
  table(t) {
6566
- return se({
6567
- queryId: X(),
6587
+ return le({
6588
+ queryId: Z(),
6568
6589
  rawNode: j.createWithChild(K(t))
6569
6590
  });
6570
6591
  },
6571
6592
  id(...t) {
6572
6593
  const e = new Array(t.length + 1).fill(".");
6573
- return e[0] = "", e[e.length - 1] = "", se({
6574
- queryId: X(),
6594
+ return e[0] = "", e[e.length - 1] = "", le({
6595
+ queryId: Z(),
6575
6596
  rawNode: j.create(e, t.map(L.create))
6576
6597
  });
6577
6598
  },
6578
6599
  lit(t) {
6579
- return se({
6580
- queryId: X(),
6581
- rawNode: j.createWithChild(pe.createImmediate(t))
6600
+ return le({
6601
+ queryId: Z(),
6602
+ rawNode: j.createWithChild(we.createImmediate(t))
6582
6603
  });
6583
6604
  },
6584
6605
  literal(t) {
6585
6606
  return this.lit(t);
6586
6607
  },
6587
6608
  raw(t) {
6588
- return se({
6589
- queryId: X(),
6609
+ return le({
6610
+ queryId: Z(),
6590
6611
  rawNode: j.createWithSql(t)
6591
6612
  });
6592
6613
  },
@@ -6594,8 +6615,8 @@ const w = Object.assign((t, ...e) => se({
6594
6615
  const n = new Array(2 * t.length - 1), a = e.toOperationNode();
6595
6616
  for (let r = 0; r < t.length; ++r)
6596
6617
  n[2 * r] = Vn(t[r]), r !== t.length - 1 && (n[2 * r + 1] = a);
6597
- return se({
6598
- queryId: X(),
6618
+ return le({
6619
+ queryId: Z(),
6599
6620
  rawNode: j.createWithChildren(n)
6600
6621
  });
6601
6622
  }
@@ -6612,10 +6633,10 @@ class fc {
6612
6633
  }
6613
6634
  }
6614
6635
  const pc = "kysely_migration", Gn = "kysely_migration_lock", gc = !1, Ht = "migration_lock", wc = c({ __noMigrations__: !0 });
6615
- var I, p, it, Z, ee, Fe, Aa, te, $a, Pa, Da, za, Ra, hn, je, fn, Fa, ja, La, pn, Ma, Ja, Ba, qa, Wa, st;
6636
+ var I, g, it, ee, te, Fe, Aa, ne, $a, Pa, Da, za, Ra, hn, je, fn, Fa, ja, La, pn, Ja, Ma, Ba, qa, Wa, st;
6616
6637
  class Ea {
6617
6638
  constructor(e) {
6618
- x(this, p);
6639
+ x(this, g);
6619
6640
  x(this, I);
6620
6641
  b(this, I, c(e));
6621
6642
  }
@@ -6625,8 +6646,8 @@ class Ea {
6625
6646
  * The returned array is sorted by migration name.
6626
6647
  */
6627
6648
  async getMigrations() {
6628
- const e = await y(this, p, je).call(this, s(this, p, ee)) ? await s(this, I).db.withPlugin(s(this, p, te)).selectFrom(s(this, p, ee)).select(["name", "timestamp"]).$narrowType().execute() : [];
6629
- return (await y(this, p, pn).call(this)).map(({ name: a, ...r }) => {
6649
+ const e = await N(this, g, je).call(this, s(this, g, te)) ? await s(this, I).db.withPlugin(s(this, g, ne)).selectFrom(s(this, g, te)).select(["name", "timestamp"]).$narrowType().execute() : [];
6650
+ return (await N(this, g, pn).call(this)).map(({ name: a, ...r }) => {
6630
6651
  const o = e.find((i) => i.name === a);
6631
6652
  return {
6632
6653
  name: a,
@@ -6682,7 +6703,7 @@ class Ea {
6682
6703
  * ```
6683
6704
  */
6684
6705
  async migrateToLatest() {
6685
- return y(this, p, it).call(this, () => ({ direction: "Up", step: 1 / 0 }));
6706
+ return N(this, g, it).call(this, () => ({ direction: "Up", step: 1 / 0 }));
6686
6707
  }
6687
6708
  /**
6688
6709
  * Migrate up/down to a specific migration.
@@ -6736,7 +6757,7 @@ class Ea {
6736
6757
  * ```
6737
6758
  */
6738
6759
  async migrateTo(e) {
6739
- return y(this, p, it).call(this, ({ migrations: n, executedMigrations: a, pendingMigrations: r }) => {
6760
+ return N(this, g, it).call(this, ({ migrations: n, executedMigrations: a, pendingMigrations: r }) => {
6740
6761
  if (e === wc)
6741
6762
  return { direction: "Down", step: 1 / 0 };
6742
6763
  if (!n.find((l) => l.name === e))
@@ -6781,7 +6802,7 @@ class Ea {
6781
6802
  * ```
6782
6803
  */
6783
6804
  async migrateUp() {
6784
- return y(this, p, it).call(this, () => ({ direction: "Up", step: 1 }));
6805
+ return N(this, g, it).call(this, () => ({ direction: "Up", step: 1 }));
6785
6806
  }
6786
6807
  /**
6787
6808
  * Migrate one step down.
@@ -6812,68 +6833,68 @@ class Ea {
6812
6833
  * ```
6813
6834
  */
6814
6835
  async migrateDown() {
6815
- return y(this, p, it).call(this, () => ({ direction: "Down", step: 1 }));
6836
+ return N(this, g, it).call(this, () => ({ direction: "Down", step: 1 }));
6816
6837
  }
6817
6838
  }
6818
- I = new WeakMap(), p = new WeakSet(), it = async function(e) {
6839
+ I = new WeakMap(), g = new WeakSet(), it = async function(e) {
6819
6840
  try {
6820
- return await y(this, p, $a).call(this), await y(this, p, Fa).call(this, e);
6841
+ return await N(this, g, $a).call(this), await N(this, g, Fa).call(this, e);
6821
6842
  } catch (n) {
6822
6843
  return n instanceof Xt ? n.resultSet : { error: n };
6823
6844
  }
6824
- }, Z = function() {
6825
- return s(this, I).migrationTableSchema;
6826
6845
  }, ee = function() {
6846
+ return s(this, I).migrationTableSchema;
6847
+ }, te = function() {
6827
6848
  return s(this, I).migrationTableName ?? pc;
6828
6849
  }, Fe = function() {
6829
6850
  return s(this, I).migrationLockTableName ?? Gn;
6830
6851
  }, Aa = function() {
6831
6852
  return s(this, I).allowUnorderedMigrations ?? gc;
6832
- }, te = function() {
6833
- return s(this, p, Z) ? new xa(s(this, p, Z)) : new fc();
6853
+ }, ne = function() {
6854
+ return s(this, g, ee) ? new xa(s(this, g, ee)) : new fc();
6834
6855
  }, $a = async function() {
6835
- await y(this, p, Pa).call(this), await y(this, p, Da).call(this), await y(this, p, za).call(this), await y(this, p, Ra).call(this);
6856
+ await N(this, g, Pa).call(this), await N(this, g, Da).call(this), await N(this, g, za).call(this), await N(this, g, Ra).call(this);
6836
6857
  }, Pa = async function() {
6837
- if (s(this, p, Z) && !await y(this, p, hn).call(this))
6858
+ if (s(this, g, ee) && !await N(this, g, hn).call(this))
6838
6859
  try {
6839
- await y(this, p, st).call(this, s(this, I).db.schema.createSchema(s(this, p, Z)));
6860
+ await N(this, g, st).call(this, s(this, I).db.schema.createSchema(s(this, g, ee)));
6840
6861
  } catch (e) {
6841
- if (!await y(this, p, hn).call(this))
6862
+ if (!await N(this, g, hn).call(this))
6842
6863
  throw e;
6843
6864
  }
6844
6865
  }, Da = async function() {
6845
- if (!await y(this, p, je).call(this, s(this, p, ee)))
6866
+ if (!await N(this, g, je).call(this, s(this, g, te)))
6846
6867
  try {
6847
- s(this, p, Z) && await y(this, p, st).call(this, s(this, I).db.schema.createSchema(s(this, p, Z))), await y(this, p, st).call(this, s(this, I).db.schema.withPlugin(s(this, p, te)).createTable(s(this, p, ee)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
6868
+ s(this, g, ee) && await N(this, g, st).call(this, s(this, I).db.schema.createSchema(s(this, g, ee))), await N(this, g, st).call(this, s(this, I).db.schema.withPlugin(s(this, g, ne)).createTable(s(this, g, te)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
6848
6869
  } catch (e) {
6849
- if (!await y(this, p, je).call(this, s(this, p, ee)))
6870
+ if (!await N(this, g, je).call(this, s(this, g, te)))
6850
6871
  throw e;
6851
6872
  }
6852
6873
  }, za = async function() {
6853
- if (!await y(this, p, je).call(this, s(this, p, Fe)))
6874
+ if (!await N(this, g, je).call(this, s(this, g, Fe)))
6854
6875
  try {
6855
- await y(this, p, st).call(this, s(this, I).db.schema.withPlugin(s(this, p, te)).createTable(s(this, p, Fe)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
6876
+ await N(this, g, st).call(this, s(this, I).db.schema.withPlugin(s(this, g, ne)).createTable(s(this, g, Fe)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
6856
6877
  } catch (e) {
6857
- if (!await y(this, p, je).call(this, s(this, p, Fe)))
6878
+ if (!await N(this, g, je).call(this, s(this, g, Fe)))
6858
6879
  throw e;
6859
6880
  }
6860
6881
  }, Ra = async function() {
6861
- if (!await y(this, p, fn).call(this))
6882
+ if (!await N(this, g, fn).call(this))
6862
6883
  try {
6863
- await s(this, I).db.withPlugin(s(this, p, te)).insertInto(s(this, p, Fe)).values({ id: Ht, is_locked: 0 }).execute();
6884
+ await s(this, I).db.withPlugin(s(this, g, ne)).insertInto(s(this, g, Fe)).values({ id: Ht, is_locked: 0 }).execute();
6864
6885
  } catch (e) {
6865
- if (!await y(this, p, fn).call(this))
6886
+ if (!await N(this, g, fn).call(this))
6866
6887
  throw e;
6867
6888
  }
6868
6889
  }, hn = async function() {
6869
- return (await s(this, I).db.introspection.getSchemas()).some((n) => n.name === s(this, p, Z));
6890
+ return (await s(this, I).db.introspection.getSchemas()).some((n) => n.name === s(this, g, ee));
6870
6891
  }, je = async function(e) {
6871
- const n = s(this, p, Z);
6892
+ const n = s(this, g, ee);
6872
6893
  return (await s(this, I).db.introspection.getTables({
6873
6894
  withInternalKyselyTables: !0
6874
6895
  })).some((r) => r.name === e && (!n || r.schema === n));
6875
6896
  }, fn = async function() {
6876
- return !!await s(this, I).db.withPlugin(s(this, p, te)).selectFrom(s(this, p, Fe)).where("id", "=", Ht).select("id").executeTakeFirst();
6897
+ return !!await s(this, I).db.withPlugin(s(this, g, ne)).selectFrom(s(this, g, Fe)).where("id", "=", Ht).select("id").executeTakeFirst();
6877
6898
  }, Fa = async function(e) {
6878
6899
  const n = s(this, I).db.getExecutor().adapter, a = c({
6879
6900
  lockTable: s(this, I).migrationLockTableName ?? Gn,
@@ -6882,20 +6903,20 @@ I = new WeakMap(), p = new WeakSet(), it = async function(e) {
6882
6903
  }), r = async (o) => {
6883
6904
  try {
6884
6905
  await n.acquireMigrationLock(o, a);
6885
- const i = await y(this, p, ja).call(this, o);
6906
+ const i = await N(this, g, ja).call(this, o);
6886
6907
  if (i.migrations.length === 0)
6887
6908
  return { results: [] };
6888
6909
  const { direction: l, step: _ } = e(i);
6889
- return _ <= 0 ? { results: [] } : l === "Down" ? await y(this, p, qa).call(this, o, i, _) : l === "Up" ? await y(this, p, Wa).call(this, o, i, _) : { results: [] };
6910
+ return _ <= 0 ? { results: [] } : l === "Down" ? await N(this, g, qa).call(this, o, i, _) : l === "Up" ? await N(this, g, Wa).call(this, o, i, _) : { results: [] };
6890
6911
  } finally {
6891
6912
  await n.releaseMigrationLock(o, a);
6892
6913
  }
6893
6914
  };
6894
6915
  return n.supportsTransactionalDdl ? s(this, I).db.transaction().execute(r) : s(this, I).db.connection().execute(r);
6895
6916
  }, ja = async function(e) {
6896
- const n = await y(this, p, pn).call(this), a = await y(this, p, Ma).call(this, e);
6897
- y(this, p, Ja).call(this, n, a), s(this, p, Aa) || y(this, p, Ba).call(this, n, a);
6898
- const r = y(this, p, La).call(this, n, a);
6917
+ const n = await N(this, g, pn).call(this), a = await N(this, g, Ja).call(this, e);
6918
+ N(this, g, Ma).call(this, n, a), s(this, g, Aa) || N(this, g, Ba).call(this, n, a);
6919
+ const r = N(this, g, La).call(this, n, a);
6899
6920
  return c({
6900
6921
  migrations: n,
6901
6922
  executedMigrations: a,
@@ -6910,10 +6931,10 @@ I = new WeakMap(), p = new WeakSet(), it = async function(e) {
6910
6931
  ...e[n],
6911
6932
  name: n
6912
6933
  }));
6913
- }, Ma = async function(e) {
6914
- const n = await e.withPlugin(s(this, p, te)).selectFrom(s(this, p, ee)).select(["name", "timestamp"]).$narrowType().execute(), a = s(this, I).nameComparator || ((r, o) => r.localeCompare(o));
6934
+ }, Ja = async function(e) {
6935
+ const n = await e.withPlugin(s(this, g, ne)).selectFrom(s(this, g, te)).select(["name", "timestamp"]).$narrowType().execute(), a = s(this, I).nameComparator || ((r, o) => r.localeCompare(o));
6915
6936
  return n.sort((r, o) => r.timestamp === o.timestamp ? a(r.name, o.name) : new Date(r.timestamp).getTime() - new Date(o.timestamp).getTime()).map((r) => r.name);
6916
- }, Ja = function(e, n) {
6937
+ }, Ma = function(e, n) {
6917
6938
  for (const a of n)
6918
6939
  if (!e.some((r) => r.name === a))
6919
6940
  throw new Error(`corrupted migrations: previously executed migration ${a} is missing`);
@@ -6930,7 +6951,7 @@ I = new WeakMap(), p = new WeakSet(), it = async function(e) {
6930
6951
  for (let i = 0; i < o.length; ++i) {
6931
6952
  const l = r[i];
6932
6953
  try {
6933
- l.down && (await l.down(e), await e.withPlugin(s(this, p, te)).deleteFrom(s(this, p, ee)).where("name", "=", l.name).execute(), o[i] = {
6954
+ l.down && (await l.down(e), await e.withPlugin(s(this, g, ne)).deleteFrom(s(this, g, te)).where("name", "=", l.name).execute(), o[i] = {
6934
6955
  migrationName: l.name,
6935
6956
  direction: "Down",
6936
6957
  status: "Success"
@@ -6956,7 +6977,7 @@ I = new WeakMap(), p = new WeakSet(), it = async function(e) {
6956
6977
  for (let i = 0; i < o.length; i++) {
6957
6978
  const l = n.pendingMigrations[i];
6958
6979
  try {
6959
- await l.up(e), await e.withPlugin(s(this, p, te)).insertInto(s(this, p, ee)).values({
6980
+ await l.up(e), await e.withPlugin(s(this, g, ne)).insertInto(s(this, g, te)).values({
6960
6981
  name: l.name,
6961
6982
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
6962
6983
  }).execute(), o[i] = {
@@ -6995,20 +7016,20 @@ function yc(t) {
6995
7016
  return async (e, n) => {
6996
7017
  let a = t.selectFrom("organizations").selectAll().where("tenant_id", "=", e);
6997
7018
  if (n != null && n.q && (a = a.where(
6998
- (h) => h.or([
6999
- h("name", "like", `%${n.q}%`),
7000
- h("display_name", "like", `%${n.q}%`)
7019
+ (m) => m.or([
7020
+ m("name", "like", `%${n.q}%`),
7021
+ m("display_name", "like", `%${n.q}%`)
7001
7022
  ])
7002
7023
  )), n != null && n.sort) {
7003
- const h = n.sort.sort_order === "asc" ? "asc" : "desc", u = n.sort.sort_by;
7004
- ["name", "display_name", "created_at"].includes(u) ? a = a.orderBy(u, h) : a = a.orderBy("created_at", "desc");
7024
+ const m = n.sort.sort_order === "asc" ? "asc" : "desc", u = n.sort.sort_by;
7025
+ ["name", "display_name", "created_at"].includes(u) ? a = a.orderBy(u, m) : a = a.orderBy("created_at", "desc");
7005
7026
  } else
7006
7027
  a = a.orderBy("created_at", "desc");
7007
7028
  if ((n == null ? void 0 : n.from) !== void 0) {
7008
- const h = parseInt(n.from, 10);
7009
- isNaN(h) || (a = a.offset(h));
7029
+ const m = parseInt(n.from, 10);
7030
+ isNaN(m) || (a = a.offset(m));
7010
7031
  } else if ((n == null ? void 0 : n.page) !== void 0) {
7011
- const h = (n == null ? void 0 : n.per_page) || (n == null ? void 0 : n.take) || 10, u = n.page * h;
7032
+ const m = (n == null ? void 0 : n.per_page) || (n == null ? void 0 : n.take) || 10, u = n.page * m;
7012
7033
  a = a.offset(u);
7013
7034
  }
7014
7035
  const r = (n == null ? void 0 : n.take) || (n == null ? void 0 : n.per_page) || 10;
@@ -7016,23 +7037,23 @@ function yc(t) {
7016
7037
  const o = await a.execute();
7017
7038
  let i = o.length;
7018
7039
  if (n != null && n.include_totals) {
7019
- let h = t.selectFrom("organizations").select(w`count(*)`.as("count")).where("tenant_id", "=", e);
7020
- n != null && n.q && (h = h.where(
7021
- (g) => g.or([
7022
- g("name", "like", `%${n.q}%`),
7023
- g("display_name", "like", `%${n.q}%`)
7040
+ let m = t.selectFrom("organizations").select(w`count(*)`.as("count")).where("tenant_id", "=", e);
7041
+ n != null && n.q && (m = m.where(
7042
+ (f) => f.or([
7043
+ f("name", "like", `%${n.q}%`),
7044
+ f("display_name", "like", `%${n.q}%`)
7024
7045
  ])
7025
7046
  ));
7026
- const u = await h.executeTakeFirst();
7047
+ const u = await m.executeTakeFirst();
7027
7048
  i = Number((u == null ? void 0 : u.count) || 0);
7028
7049
  }
7029
7050
  const l = o.map(
7030
- (h) => T({
7031
- ...h,
7032
- branding: h.branding ? JSON.parse(h.branding) : {},
7033
- metadata: h.metadata ? JSON.parse(h.metadata) : {},
7034
- enabled_connections: h.enabled_connections ? JSON.parse(h.enabled_connections) : [],
7035
- token_quota: h.token_quota ? JSON.parse(h.token_quota) : {}
7051
+ (m) => T({
7052
+ ...m,
7053
+ branding: m.branding ? JSON.parse(m.branding) : {},
7054
+ metadata: m.metadata ? JSON.parse(m.metadata) : {},
7055
+ enabled_connections: m.enabled_connections ? JSON.parse(m.enabled_connections) : [],
7056
+ token_quota: m.token_quota ? JSON.parse(m.token_quota) : {}
7036
7057
  })
7037
7058
  ), _ = (n == null ? void 0 : n.take) || (n == null ? void 0 : n.per_page) || 10, d = n != null && n.from ? parseInt(n.from, 10) : n != null && n.page ? n.page * _ : 0;
7038
7059
  return {
@@ -7386,7 +7407,7 @@ function Fc(t) {
7386
7407
  }
7387
7408
  class Ka {
7388
7409
  constructor(e) {
7389
- ie(this, "migrations");
7410
+ ce(this, "migrations");
7390
7411
  this.migrations = e;
7391
7412
  }
7392
7413
  async getMigrations() {
@@ -7468,12 +7489,12 @@ async function jc(t) {
7468
7489
  async function Lc(t) {
7469
7490
  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();
7470
7491
  }
7471
- const Mc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7492
+ const Jc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7472
7493
  __proto__: null,
7473
7494
  down: Lc,
7474
7495
  up: jc
7475
7496
  }, Symbol.toStringTag, { value: "Module" }));
7476
- async function Jc(t) {
7497
+ async function Mc(t) {
7477
7498
  await t.schema.alterTable("tenants").addColumn("support_url", "varchar(255)").execute();
7478
7499
  }
7479
7500
  async function Bc(t) {
@@ -7482,7 +7503,7 @@ async function Bc(t) {
7482
7503
  const qc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7483
7504
  __proto__: null,
7484
7505
  down: Bc,
7485
- up: Jc
7506
+ up: Mc
7486
7507
  }, Symbol.toStringTag, { value: "Module" }));
7487
7508
  async function Wc(t) {
7488
7509
  }
@@ -7707,12 +7728,12 @@ async function jl(t) {
7707
7728
  }
7708
7729
  async function Ll(t) {
7709
7730
  }
7710
- const Ml = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7731
+ const Jl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7711
7732
  __proto__: null,
7712
7733
  down: Ll,
7713
7734
  up: jl
7714
7735
  }, Symbol.toStringTag, { value: "Module" }));
7715
- async function Jl(t) {
7736
+ async function Ml(t) {
7716
7737
  await t.schema.alterTable("otps").addColumn("audience", "varchar(255)").execute();
7717
7738
  }
7718
7739
  async function Bl(t) {
@@ -7721,7 +7742,7 @@ async function Bl(t) {
7721
7742
  const ql = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7722
7743
  __proto__: null,
7723
7744
  down: Bl,
7724
- up: Jl
7745
+ up: Ml
7725
7746
  }, Symbol.toStringTag, { value: "Module" }));
7726
7747
  async function Wl(t) {
7727
7748
  }
@@ -7904,12 +7925,12 @@ async function ju(t) {
7904
7925
  }
7905
7926
  async function Lu(t) {
7906
7927
  }
7907
- const Mu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7928
+ const Ju = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7908
7929
  __proto__: null,
7909
7930
  down: Lu,
7910
7931
  up: ju
7911
7932
  }, Symbol.toStringTag, { value: "Module" }));
7912
- async function Ju(t) {
7933
+ async function Mu(t) {
7913
7934
  await t.schema.alterTable("otps").addColumn("ip", "varchar(64)").execute();
7914
7935
  }
7915
7936
  async function Bu(t) {
@@ -7918,7 +7939,7 @@ async function Bu(t) {
7918
7939
  const qu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7919
7940
  __proto__: null,
7920
7941
  down: Bu,
7921
- up: Ju
7942
+ up: Mu
7922
7943
  }, Symbol.toStringTag, { value: "Module" }));
7923
7944
  async function Wu(t) {
7924
7945
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
@@ -8153,19 +8174,19 @@ async function jd(t) {
8153
8174
  async function Ld(t) {
8154
8175
  await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute();
8155
8176
  }
8156
- const Md = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8177
+ const Jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8157
8178
  __proto__: null,
8158
8179
  down: Ld,
8159
8180
  up: jd
8160
8181
  }, Symbol.toStringTag, { value: "Module" }));
8161
- async function Jd(t) {
8182
+ async function Md(t) {
8162
8183
  }
8163
8184
  async function Bd(t) {
8164
8185
  }
8165
8186
  const qd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8166
8187
  __proto__: null,
8167
8188
  down: Bd,
8168
- up: Jd
8189
+ up: Md
8169
8190
  }, Symbol.toStringTag, { value: "Module" }));
8170
8191
  async function Wd(t) {
8171
8192
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
@@ -8424,12 +8445,12 @@ async function L_(t) {
8424
8445
  (e) => e.references("tenants.id").onDelete("cascade").notNull()
8425
8446
  ).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();
8426
8447
  }
8427
- const M_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8448
+ const J_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8428
8449
  __proto__: null,
8429
8450
  down: L_,
8430
8451
  up: j_
8431
8452
  }, Symbol.toStringTag, { value: "Module" }));
8432
- async function J_(t) {
8453
+ async function M_(t) {
8433
8454
  }
8434
8455
  async function B_(t) {
8435
8456
  await t.schema.alterTable("logins").dropColumn("authParams_organization").dropColumn("authorization_url").execute();
@@ -8437,7 +8458,7 @@ async function B_(t) {
8437
8458
  const q_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8438
8459
  __proto__: null,
8439
8460
  down: B_,
8440
- up: J_
8461
+ up: M_
8441
8462
  }, Symbol.toStringTag, { value: "Module" }));
8442
8463
  async function W_(t) {
8443
8464
  await t.schema.alterTable("logins").dropColumn("authorization_url").execute(), await t.schema.alterTable("logins").addColumn("authorization_url", "varchar(2048)").execute();
@@ -8746,12 +8767,12 @@ async function jm(t) {
8746
8767
  async function Lm(t) {
8747
8768
  await t.schema.dropTable("user_permissions").execute(), await t.schema.dropTable("role_permissions").execute();
8748
8769
  }
8749
- const Mm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8770
+ const Jm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8750
8771
  __proto__: null,
8751
8772
  down: Lm,
8752
8773
  up: jm
8753
8774
  }, Symbol.toStringTag, { value: "Module" }));
8754
- async function Jm(t) {
8775
+ async function Mm(t) {
8755
8776
  await t.schema.createTable("user_roles").addColumn("tenant_id", "varchar(191)", (e) => e.notNull()).addColumn("user_id", "varchar(191)", (e) => e.notNull()).addColumn("role_id", "varchar(21)", (e) => e.notNull()).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addPrimaryKeyConstraint("user_roles_pk", [
8756
8777
  "tenant_id",
8757
8778
  "user_id",
@@ -8764,7 +8785,7 @@ async function Bm(t) {
8764
8785
  const qm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8765
8786
  __proto__: null,
8766
8787
  down: Bm,
8767
- up: Jm
8788
+ up: Mm
8768
8789
  }, Symbol.toStringTag, { value: "Module" }));
8769
8790
  async function Wm(t) {
8770
8791
  }
@@ -9317,12 +9338,12 @@ const jh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9317
9338
  async function Lh(t) {
9318
9339
  await t.schema.dropTable("logs").ifExists().execute(), await t.schema.createTable("logs").addColumn("log_id", "varchar(21)", (e) => e.primaryKey().notNull()).addColumn("category", "varchar(255)").addColumn("tenant_id", "varchar(64)").addColumn("user_id", "varchar(64)").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)").addColumn("isMobile", "integer").addColumn("user_name", "varchar(255)").addColumn("connection", "varchar(255)").addColumn("connection_id", "varchar(255)").addColumn("audience", "varchar(255)").addColumn("scope", "varchar(255)").addColumn("strategy", "varchar(255)").addColumn("strategy_type", "varchar(255)").addColumn("hostname", "varchar(255)").addColumn("auth0_client", "varchar(8192)").addColumn("session_connection", "varchar(255)").execute();
9319
9340
  }
9320
- async function Mh(t) {
9341
+ async function Jh(t) {
9321
9342
  await t.schema.dropTable("logs").ifExists().execute(), await t.schema.createTable("logs").addColumn("id", "varchar(255)", (e) => e.primaryKey().notNull()).addColumn("category", "varchar(255)", (e) => e.notNull()).addColumn("tenant_id", "varchar(64)").addColumn("user_id", "varchar(64)").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();
9322
9343
  }
9323
- const Jh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9344
+ const Mh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9324
9345
  __proto__: null,
9325
- down: Mh,
9346
+ down: Jh,
9326
9347
  up: Lh
9327
9348
  }, Symbol.toStringTag, { value: "Module" }));
9328
9349
  async function Bh(t) {
@@ -9571,8 +9592,19 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9571
9592
  __proto__: null,
9572
9593
  down: df,
9573
9594
  up: uf
9595
+ }, Symbol.toStringTag, { value: "Module" }));
9596
+ async function mf(t) {
9597
+ await t.schema.alterTable("roles").addColumn("metadata", "varchar(4096)").execute(), await t.schema.alterTable("resource_servers").addColumn("metadata", "varchar(4096)").execute();
9598
+ }
9599
+ async function hf(t) {
9600
+ await t.schema.alterTable("roles").dropColumn("metadata").execute(), await t.schema.alterTable("resource_servers").dropColumn("metadata").execute();
9601
+ }
9602
+ const ff = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9603
+ __proto__: null,
9604
+ down: hf,
9605
+ up: mf
9574
9606
  }, Symbol.toStringTag, { value: "Module" })), Qa = {
9575
- m1_init: Mc,
9607
+ m1_init: Jc,
9576
9608
  m2_magicLink: qc,
9577
9609
  m3_updateAt: Uc,
9578
9610
  m4_logTable: Gc,
@@ -9590,7 +9622,7 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9590
9622
  n16_userLocale: Al,
9591
9623
  n17_signingKeys: Dl,
9592
9624
  n18_logsFields: Fl,
9593
- n19_connectionsUserinfo: Ml,
9625
+ n19_connectionsUserinfo: Jl,
9594
9626
  n20_missingFields: ql,
9595
9627
  n21_sessionDeletedAt: Ul,
9596
9628
  n22_dropLogsFields: Gl,
@@ -9608,7 +9640,7 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9608
9640
  n34_auth0ClientInUniversalLoginSession: Au,
9609
9641
  n35_increaseUniversalSessionStateLength: Du,
9610
9642
  n36_authenticationCodes: Fu,
9611
- n37_disableSignUps: Mu,
9643
+ n37_disableSignUps: Ju,
9612
9644
  n38_otpIpAddress: qu,
9613
9645
  n39_increaseUserAgentLength: Uu,
9614
9646
  n40_userId: Gu,
@@ -9626,7 +9658,7 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9626
9658
  n52_cert: Ad,
9627
9659
  n53_codes_primary_key: Dd,
9628
9660
  n54_cleanup_tables: Fd,
9629
- n55_logs_index: Md,
9661
+ n55_logs_index: Jd,
9630
9662
  n56_application_fields: qd,
9631
9663
  n57_prompt_settings: Ud,
9632
9664
  n58_connection_client_id: Gd,
@@ -9644,7 +9676,7 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9644
9676
  n71_session_new_fields: A_,
9645
9677
  n72_session_primary_key: D_,
9646
9678
  n73_drop_sessions: F_,
9647
- n74_custom_domains: M_,
9679
+ n74_custom_domains: J_,
9648
9680
  n75_organizations: q_,
9649
9681
  n76_authorization_url_length: U_,
9650
9682
  n77_drop_sessions: G_,
@@ -9662,7 +9694,7 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9662
9694
  n89_add_nonce_and_state_to_codes: Am,
9663
9695
  n90_themes: Dm,
9664
9696
  n91_resource_servers_rules_permissions: Fm,
9665
- n92_role_permissions: Mm,
9697
+ n92_role_permissions: Jm,
9666
9698
  n93_add_permissions_to_roles: qm,
9667
9699
  n94_keys_connection_and_extend_columns: Um,
9668
9700
  n95_create_organizations_table: Gm,
@@ -9679,7 +9711,7 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9679
9711
  o007_tenant_settings: $h,
9680
9712
  o008_merge_tenant_settings_into_tenants: zh,
9681
9713
  o009_create_invites_table: jh,
9682
- o010_add_log_id_to_logs: Jh,
9714
+ o010_add_log_id_to_logs: Mh,
9683
9715
  o011_add_location_info_to_logs: Wh,
9684
9716
  o012_add_password_history: Qh,
9685
9717
  o013_connection_display_name: Yh,
@@ -9687,9 +9719,10 @@ const _f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9687
9719
  o015_flows: nf,
9688
9720
  o016_add_is_system_column: of,
9689
9721
  o017_connections_composite_key: lf,
9690
- o018_login_session_state: _f
9722
+ o018_login_session_state: _f,
9723
+ o019_roles_resource_servers_metadata: ff
9691
9724
  };
9692
- async function gf(t, e = !1) {
9725
+ async function Nf(t, e = !1) {
9693
9726
  e && console.log("migrating...");
9694
9727
  const n = new Ka(Qa), a = new Ea({
9695
9728
  db: t,
@@ -9702,7 +9735,7 @@ async function gf(t, e = !1) {
9702
9735
  }), r)
9703
9736
  throw console.error("failed to migrate"), console.error(r), r;
9704
9737
  }
9705
- async function wf(t) {
9738
+ async function vf(t) {
9706
9739
  console.log("migrating...");
9707
9740
  const e = new Ka(Qa), n = new Ea({
9708
9741
  db: t,
@@ -9713,7 +9746,7 @@ async function wf(t) {
9713
9746
  }), a)
9714
9747
  throw console.error("failed to migrate"), console.error(a), a;
9715
9748
  }
9716
- function yf(t) {
9749
+ function Cf(t) {
9717
9750
  return {
9718
9751
  branding: Lo(t),
9719
9752
  cleanup: fi(t),
@@ -9732,7 +9765,7 @@ function yf(t) {
9732
9765
  keys: Io(t),
9733
9766
  loginSessions: ti(t),
9734
9767
  logs: Ir(t),
9735
- passwords: Mr(t),
9768
+ passwords: Jr(t),
9736
9769
  promptSettings: ri(t),
9737
9770
  refreshTokens: hi(t),
9738
9771
  resourceServers: Si(t),
@@ -9750,7 +9783,7 @@ function yf(t) {
9750
9783
  };
9751
9784
  }
9752
9785
  export {
9753
- yf as default,
9754
- wf as migrateDown,
9755
- gf as migrateToLatest
9786
+ Cf as default,
9787
+ vf as migrateDown,
9788
+ Nf as migrateToLatest
9756
9789
  };