@authhero/kysely-adapter 10.99.0 → 10.101.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 ja = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
5
  var pr = (t, e, a) => e in t ? fr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var me = (t, e, a) => pr(t, typeof e != "symbol" ? e + "" : e, a), na = (t, e, a) => e.has(t) || ja("Cannot " + a);
7
- var i = (t, e, a) => (na(t, e, "read from private field"), a ? a.call(t) : e.get(t)), x = (t, e, a) => e.has(t) ? ja("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), S = (t, e, a, n) => (na(t, e, "write to private field"), n ? n.call(t, a) : e.set(t, a), a), v = (t, e, a) => (na(t, e, "access private method"), a);
8
- import { parseUserId as gr, flowSchema as Ht, codeSchema as wr, loginSessionSchema as yr, LoginSessionState as fn, promptSettingSchema as vr, formSchema as Dt, resourceServerSchema as Nr } from "@authhero/adapter-interfaces";
6
+ var me = (t, e, a) => pr(t, typeof e != "symbol" ? e + "" : e, a), ra = (t, e, a) => e.has(t) || ja("Cannot " + a);
7
+ var i = (t, e, a) => (ra(t, e, "read from private field"), a ? a.call(t) : e.get(t)), x = (t, e, a) => e.has(t) ? ja("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), S = (t, e, a, n) => (ra(t, e, "write to private field"), n ? n.call(t, a) : e.set(t, a), a), v = (t, e, a) => (ra(t, e, "access private method"), a);
8
+ import { parseUserId as gr, flowSchema as Yt, codeSchema as wr, loginSessionSchema as yr, LoginSessionState as fn, promptSettingSchema as vr, formSchema as Pt, resourceServerSchema as Nr } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var ct = class extends Error {
11
11
  /**
@@ -137,7 +137,7 @@ const br = [
137
137
  "phone_verified",
138
138
  "username"
139
139
  ];
140
- function Pt(t, e = !1) {
140
+ function Rt(t, e = !1) {
141
141
  const a = {
142
142
  connection: t.connection,
143
143
  provider: t.provider,
@@ -179,8 +179,8 @@ function kr(t) {
179
179
  user_metadata: JSON.parse(n.user_metadata),
180
180
  address: n.address ? JSON.parse(n.address) : void 0,
181
181
  identities: [
182
- Pt(n, !0),
183
- ...r.map((u) => Pt(u))
182
+ Rt(n, !0),
183
+ ...r.map((u) => Rt(u))
184
184
  ]
185
185
  };
186
186
  return O(l);
@@ -279,8 +279,8 @@ function Er(t) {
279
279
  user_metadata: JSON.parse(N.user_metadata),
280
280
  address: N.address ? JSON.parse(N.address) : void 0,
281
281
  identities: [
282
- Pt(N, !0),
283
- ...T.map((b) => Pt(b))
282
+ Rt(N, !0),
283
+ ...T.map((b) => Rt(b))
284
284
  ]
285
285
  });
286
286
  });
@@ -361,7 +361,7 @@ function Dr(t, e) {
361
361
  }
362
362
  function Pr(t) {
363
363
  return async (e, a) => {
364
- const n = (/* @__PURE__ */ new Date()).toISOString(), r = Ht.parse({
364
+ const n = (/* @__PURE__ */ new Date()).toISOString(), r = Yt.parse({
365
365
  id: `af_${K()}`,
366
366
  ...a,
367
367
  actions: a.actions || [],
@@ -376,7 +376,7 @@ function Pr(t) {
376
376
  }).execute(), r;
377
377
  };
378
378
  }
379
- function ba(t, e) {
379
+ function dt(t, e) {
380
380
  if (!t)
381
381
  return e;
382
382
  try {
@@ -387,7 +387,7 @@ function ba(t, e) {
387
387
  }
388
388
  function gn(t, e, a = { ...t }) {
389
389
  for (const n in e)
390
- n in t && (a[n] = ba(
390
+ n in t && (a[n] = dt(
391
391
  t[n],
392
392
  e[n]
393
393
  ));
@@ -399,9 +399,9 @@ function Rr(t) {
399
399
  if (!n) return null;
400
400
  const r = {
401
401
  ...n,
402
- actions: ba(n.actions, [])
402
+ actions: dt(n.actions, [])
403
403
  };
404
- return Ht.parse(O(r));
404
+ return Yt.parse(O(r));
405
405
  };
406
406
  }
407
407
  function zr(t) {
@@ -412,9 +412,9 @@ function zr(t) {
412
412
  const d = (await l.offset(n * r).limit(r).selectAll().execute()).map((f) => {
413
413
  const p = {
414
414
  ...f,
415
- actions: ba(f.actions, [])
415
+ actions: dt(f.actions, [])
416
416
  };
417
- return Ht.parse(O(p));
417
+ return Yt.parse(O(p));
418
418
  });
419
419
  if (!o)
420
420
  return {
@@ -442,7 +442,7 @@ function Fr(t) {
442
442
  const { numUpdatedRows: o } = await t.updateTable("flows").set(r).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
443
443
  if (o === 0n) return null;
444
444
  const s = await t.selectFrom("flows").selectAll().where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
445
- return s ? Ht.parse({
445
+ return s ? Yt.parse({
446
446
  ...s,
447
447
  actions: s.actions ? JSON.parse(s.actions) : []
448
448
  }) : null;
@@ -463,7 +463,7 @@ function Mr(t) {
463
463
  remove: Lr(t)
464
464
  };
465
465
  }
466
- function kt(t, e, a = { ...t }) {
466
+ function Et(t, e, a = { ...t }) {
467
467
  for (const n of e)
468
468
  t[n] !== void 0 && (a[n] = JSON.stringify(t[n]));
469
469
  return a;
@@ -488,7 +488,7 @@ function yn(t) {
488
488
  }
489
489
  function vn(t) {
490
490
  const e = { ...t };
491
- return kt(
491
+ return Et(
492
492
  t,
493
493
  [
494
494
  "session_cookie",
@@ -984,24 +984,24 @@ const go = 17, wo = {
984
984
  guardian_factor: "gfa_",
985
985
  invite: "inv_"
986
986
  };
987
- function Et(t) {
987
+ function It(t) {
988
988
  const n = Sr("0123456789abcdefghijklmnopqrstuvwxyz", go)();
989
989
  return `${wo[t]}${n}`;
990
990
  }
991
991
  function yo() {
992
- return Et("organization");
992
+ return It("organization");
993
993
  }
994
994
  function vo() {
995
- return Et("connection");
995
+ return It("connection");
996
996
  }
997
997
  function No() {
998
- return Et("hook");
998
+ return It("hook");
999
999
  }
1000
1000
  function Co() {
1001
- return Et("resource_server");
1001
+ return It("resource_server");
1002
1002
  }
1003
1003
  function xo() {
1004
- return Et("invite");
1004
+ return It("invite");
1005
1005
  }
1006
1006
  function To(t) {
1007
1007
  return async (e, a) => {
@@ -1312,7 +1312,7 @@ function zo(t) {
1312
1312
  "require_proof_of_possession"
1313
1313
  ],
1314
1314
  r
1315
- ), kt(
1315
+ ), Et(
1316
1316
  n,
1317
1317
  [
1318
1318
  "callbacks",
@@ -1612,14 +1612,16 @@ function es(t) {
1612
1612
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1613
1613
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1614
1614
  tenant_id: e,
1615
- primary: n.primary ? 1 : 0
1615
+ primary: n.primary ? 1 : 0,
1616
+ domain_metadata: n.domain_metadata ? JSON.stringify(n.domain_metadata) : void 0
1616
1617
  }).execute(), n;
1617
1618
  };
1618
1619
  }
1619
1620
  function ts(t) {
1620
1621
  return async (e) => (await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).selectAll().execute()).map((n) => ({
1621
1622
  ...n,
1622
- primary: n.primary === 1
1623
+ primary: n.primary === 1,
1624
+ domain_metadata: dt(n.domain_metadata, void 0)
1623
1625
  }));
1624
1626
  }
1625
1627
  function as(t) {
@@ -1630,7 +1632,8 @@ function ns(t) {
1630
1632
  const n = await t.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).selectAll().executeTakeFirst();
1631
1633
  return n ? {
1632
1634
  ...n,
1633
- primary: n.primary === 1
1635
+ primary: n.primary === 1,
1636
+ domain_metadata: dt(n.domain_metadata, void 0)
1634
1637
  } : null;
1635
1638
  };
1636
1639
  }
@@ -1639,7 +1642,8 @@ function rs(t) {
1639
1642
  const r = {
1640
1643
  ...n,
1641
1644
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
1642
- primary: n.primary ? 1 : 0
1645
+ primary: n.primary ? 1 : 0,
1646
+ domain_metadata: n.domain_metadata ? JSON.stringify(n.domain_metadata) : void 0
1643
1647
  };
1644
1648
  return (await t.updateTable("custom_domains").set(r).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
1645
1649
  };
@@ -1649,7 +1653,8 @@ function os(t) {
1649
1653
  const a = await t.selectFrom("custom_domains").where("custom_domains.domain", "=", e).selectAll().executeTakeFirst();
1650
1654
  return a ? {
1651
1655
  ...a,
1652
- primary: a.primary === 1
1656
+ primary: a.primary === 1,
1657
+ domain_metadata: dt(a.domain_metadata, void 0)
1653
1658
  } : null;
1654
1659
  };
1655
1660
  }
@@ -1948,27 +1953,27 @@ function Ss(t) {
1948
1953
  );
1949
1954
  };
1950
1955
  }
1951
- function $t(t) {
1956
+ function At(t) {
1952
1957
  const e = new Error(t);
1953
1958
  return e.source = "ulid", e;
1954
1959
  }
1955
- const Ia = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ht = Ia.length, Wa = Math.pow(2, 48) - 1, Os = 10, bs = 16;
1960
+ const Ia = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ft = Ia.length, Wa = Math.pow(2, 48) - 1, Os = 10, bs = 16;
1956
1961
  function ks(t) {
1957
- let e = Math.floor(t() * ht);
1958
- return e === ht && (e = ht - 1), Ia.charAt(e);
1962
+ let e = Math.floor(t() * ft);
1963
+ return e === ft && (e = ft - 1), Ia.charAt(e);
1959
1964
  }
1960
1965
  function Es(t, e) {
1961
1966
  if (isNaN(t))
1962
1967
  throw new Error(t + " must be a number");
1963
1968
  if (t > Wa)
1964
- throw $t("cannot encode time greater than " + Wa);
1969
+ throw At("cannot encode time greater than " + Wa);
1965
1970
  if (t < 0)
1966
- throw $t("time must be positive");
1971
+ throw At("time must be positive");
1967
1972
  if (Number.isInteger(Number(t)) === !1)
1968
- throw $t("time must be an integer");
1973
+ throw At("time must be an integer");
1969
1974
  let a, n = "";
1970
1975
  for (; e > 0; e--)
1971
- a = t % ht, n = Ia.charAt(a) + n, t = (t - a) / ht;
1976
+ a = t % ft, n = Ia.charAt(a) + n, t = (t - a) / ft;
1972
1977
  return n;
1973
1978
  }
1974
1979
  function Is(t, e) {
@@ -1997,7 +2002,7 @@ function $s(t = !1, e) {
1997
2002
  }
1998
2003
  return () => Math.random();
1999
2004
  }
2000
- throw $t("secure crypto unusable, insecure Math.random not allowed");
2005
+ throw At("secure crypto unusable, insecure Math.random not allowed");
2001
2006
  }
2002
2007
  function As(t) {
2003
2008
  return t || (t = $s()), function(a) {
@@ -2231,7 +2236,7 @@ function Hs(t) {
2231
2236
  return async (e, a = {}) => {
2232
2237
  const { page: n = 0, per_page: r = 50, include_totals: o = !1, sort: s, q: l } = a;
2233
2238
  let u = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
2234
- l && (u = q(t, u, l, ["token", "session_id"]));
2239
+ l && (u = q(t, u, l, ["token", "session_id", "login_id"]));
2235
2240
  let _ = u;
2236
2241
  if (s && s.sort_by) {
2237
2242
  const { ref: y } = t.dynamic;
@@ -2361,7 +2366,7 @@ function Xs(t) {
2361
2366
  }
2362
2367
  function Zs(t) {
2363
2368
  return async (e, a) => {
2364
- const n = Dt.parse({
2369
+ const n = Pt.parse({
2365
2370
  id: K(),
2366
2371
  ...a,
2367
2372
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -2374,7 +2379,7 @@ function Zs(t) {
2374
2379
  start: JSON.stringify(n.start || {}),
2375
2380
  ending: JSON.stringify(n.ending || {}),
2376
2381
  tenant_id: e
2377
- }).execute(), Dt.parse(n);
2382
+ }).execute(), Pt.parse(n);
2378
2383
  };
2379
2384
  }
2380
2385
  function ei(t) {
@@ -2399,7 +2404,7 @@ function ei(t) {
2399
2404
  p.ending = JSON.parse(p.ending);
2400
2405
  } catch {
2401
2406
  }
2402
- return Dt.parse(O(p));
2407
+ return Pt.parse(O(p));
2403
2408
  });
2404
2409
  if (!o)
2405
2410
  return {
@@ -2443,7 +2448,7 @@ function ai(t) {
2443
2448
  r.ending = JSON.parse(r.ending);
2444
2449
  } catch {
2445
2450
  }
2446
- return Dt.parse(O(r));
2451
+ return Pt.parse(O(r));
2447
2452
  };
2448
2453
  }
2449
2454
  function ni(t) {
@@ -2452,7 +2457,7 @@ function ni(t) {
2452
2457
  ...n,
2453
2458
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2454
2459
  };
2455
- kt(n, ["nodes", "start", "ending"], r);
2460
+ Et(n, ["nodes", "start", "ending"], r);
2456
2461
  const { numUpdatedRows: o } = await t.updateTable("forms").set(r).where("id", "=", a).where("tenant_id", "=", e).executeTakeFirst();
2457
2462
  return o > 0;
2458
2463
  };
@@ -2979,7 +2984,7 @@ function Ai(t) {
2979
2984
  }) : null;
2980
2985
  };
2981
2986
  }
2982
- function Rt(t) {
2987
+ function zt(t) {
2983
2988
  return typeof t > "u" || t === void 0;
2984
2989
  }
2985
2990
  function re(t) {
@@ -3000,7 +3005,7 @@ function Sn(t) {
3000
3005
  function Fe(t) {
3001
3006
  return typeof t == "function";
3002
3007
  }
3003
- function Yt(t) {
3008
+ function Xt(t) {
3004
3009
  return typeof t == "object" && t !== null;
3005
3010
  }
3006
3011
  function Di(t) {
@@ -3009,7 +3014,7 @@ function Di(t) {
3009
3014
  function c(t) {
3010
3015
  return Object.freeze(t);
3011
3016
  }
3012
- function It(t) {
3017
+ function $t(t) {
3013
3018
  return ve(t) ? t : [t];
3014
3019
  }
3015
3020
  function ve(t) {
@@ -3025,7 +3030,7 @@ const U = c({
3025
3030
  name: t
3026
3031
  });
3027
3032
  }
3028
- }), ua = c({
3033
+ }), da = c({
3029
3034
  is(t) {
3030
3035
  return t.kind === "SchemableIdentifierNode";
3031
3036
  },
@@ -3060,24 +3065,24 @@ const U = c({
3060
3065
  create(t) {
3061
3066
  return c({
3062
3067
  kind: "TableNode",
3063
- table: ua.create(t)
3068
+ table: da.create(t)
3064
3069
  });
3065
3070
  },
3066
3071
  createWithSchema(t, e) {
3067
3072
  return c({
3068
3073
  kind: "TableNode",
3069
- table: ua.createWithSchema(t, e)
3074
+ table: da.createWithSchema(t, e)
3070
3075
  });
3071
3076
  }
3072
3077
  });
3073
3078
  function H(t) {
3074
- return Yt(t) && Fe(t.toOperationNode);
3079
+ return Xt(t) && Fe(t.toOperationNode);
3075
3080
  }
3076
3081
  function Pi(t) {
3077
- return Yt(t) && "expressionType" in t && H(t);
3082
+ return Xt(t) && "expressionType" in t && H(t);
3078
3083
  }
3079
3084
  function Ri(t) {
3080
- return Yt(t) && "expression" in t && re(t.alias) && H(t);
3085
+ return Xt(t) && "expression" in t && re(t.alias) && H(t);
3081
3086
  }
3082
3087
  const oe = c({
3083
3088
  is(t) {
@@ -3107,7 +3112,7 @@ const oe = c({
3107
3112
  right: e
3108
3113
  });
3109
3114
  }
3110
- }), dt = c({
3115
+ }), _t = c({
3111
3116
  is(t) {
3112
3117
  return t.kind === "OrNode";
3113
3118
  },
@@ -3118,7 +3123,7 @@ const oe = c({
3118
3123
  right: e
3119
3124
  });
3120
3125
  }
3121
- }), ra = c({
3126
+ }), oa = c({
3122
3127
  is(t) {
3123
3128
  return t.kind === "OnNode";
3124
3129
  },
@@ -3131,10 +3136,10 @@ const oe = c({
3131
3136
  cloneWithOperation(t, e, a) {
3132
3137
  return c({
3133
3138
  ...t,
3134
- on: e === "And" ? Ne.create(t.on, a) : dt.create(t.on, a)
3139
+ on: e === "And" ? Ne.create(t.on, a) : _t.create(t.on, a)
3135
3140
  });
3136
3141
  }
3137
- }), ft = c({
3142
+ }), pt = c({
3138
3143
  is(t) {
3139
3144
  return t.kind === "JoinNode";
3140
3145
  },
@@ -3151,13 +3156,13 @@ const oe = c({
3151
3156
  kind: "JoinNode",
3152
3157
  joinType: t,
3153
3158
  table: e,
3154
- on: ra.create(a)
3159
+ on: oa.create(a)
3155
3160
  });
3156
3161
  },
3157
3162
  cloneWithOn(t, e) {
3158
3163
  return c({
3159
3164
  ...t,
3160
- on: t.on ? ra.cloneWithOperation(t.on, "And", e) : ra.create(e)
3165
+ on: t.on ? oa.cloneWithOperation(t.on, "And", e) : oa.create(e)
3161
3166
  });
3162
3167
  }
3163
3168
  }), lt = c({
@@ -3267,7 +3272,7 @@ const Aa = c({
3267
3272
  kind: "SelectAllNode"
3268
3273
  });
3269
3274
  }
3270
- }), Xt = c({
3275
+ }), Zt = c({
3271
3276
  is(t) {
3272
3277
  return t.kind === "ReferenceNode";
3273
3278
  },
@@ -3287,9 +3292,9 @@ const Aa = c({
3287
3292
  }
3288
3293
  });
3289
3294
  function kn(t) {
3290
- return Yt(t) && H(t) && re(t.dynamicReference);
3295
+ return Xt(t) && H(t) && re(t.dynamicReference);
3291
3296
  }
3292
- const da = c({
3297
+ const _a = c({
3293
3298
  is(t) {
3294
3299
  return t.kind === "OrderByItemNode";
3295
3300
  },
@@ -3326,32 +3331,32 @@ function qi(t) {
3326
3331
  }
3327
3332
  function Da(t) {
3328
3333
  if (t.length === 2)
3329
- return [oa(t[0], t[1])];
3334
+ return [sa(t[0], t[1])];
3330
3335
  if (t.length === 1) {
3331
3336
  const [e] = t;
3332
- return Array.isArray(e) ? e.map((a) => oa(a)) : [oa(e)];
3337
+ return Array.isArray(e) ? e.map((a) => sa(a)) : [sa(e)];
3333
3338
  }
3334
3339
  throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${t.length}`);
3335
3340
  }
3336
- function oa(t, e) {
3341
+ function sa(t, e) {
3337
3342
  const a = Wi(t);
3338
- if (da.is(a)) {
3343
+ if (_a.is(a)) {
3339
3344
  if (e)
3340
3345
  throw new Error("Cannot specify direction twice!");
3341
3346
  return a;
3342
3347
  }
3343
- return da.create(a, En(e));
3348
+ return _a.create(a, En(e));
3344
3349
  }
3345
3350
  function Wi(t) {
3346
- if (aa(t))
3347
- return ta(t);
3351
+ if (na(t))
3352
+ return aa(t);
3348
3353
  if (kn(t))
3349
3354
  return t.toOperationNode();
3350
3355
  const [e, a] = t.split(" ");
3351
3356
  if (a) {
3352
3357
  if (!qi(a))
3353
3358
  throw new Error(`Invalid order by direction: ${a}`);
3354
- return da.create(Ce(e), En(a));
3359
+ return _a.create(Ce(e), En(a));
3355
3360
  }
3356
3361
  return Ce(t);
3357
3362
  }
@@ -3359,7 +3364,7 @@ function En(t) {
3359
3364
  if (t)
3360
3365
  return t === "asc" || t === "desc" ? B.createWithSql(t) : t.toOperationNode();
3361
3366
  }
3362
- const zt = c({
3367
+ const Ft = c({
3363
3368
  is(t) {
3364
3369
  return t.kind === "JSONReferenceNode";
3365
3370
  },
@@ -3393,7 +3398,7 @@ const zt = c({
3393
3398
  values: c([...t.values, e])
3394
3399
  });
3395
3400
  }
3396
- }), pt = c({
3401
+ }), gt = c({
3397
3402
  is(t) {
3398
3403
  return t.kind === "JSONPathNode";
3399
3404
  },
@@ -3414,25 +3419,25 @@ const zt = c({
3414
3419
  function Bi(t) {
3415
3420
  return re(t) ? Ce(t) : t.toOperationNode();
3416
3421
  }
3417
- function vt(t) {
3422
+ function Nt(t) {
3418
3423
  return ve(t) ? t.map((e) => V(e)) : [V(t)];
3419
3424
  }
3420
3425
  function V(t) {
3421
- return aa(t) ? ta(t) : Bi(t);
3426
+ return na(t) ? aa(t) : Bi(t);
3422
3427
  }
3423
3428
  function Ui(t, e) {
3424
3429
  const a = Ce(t);
3425
3430
  if (Ua(e))
3426
- return zt.create(a, In.create(Re.create(e)));
3431
+ return Ft.create(a, In.create(Re.create(e)));
3427
3432
  const n = e.slice(0, -1);
3428
3433
  if (Ua(n))
3429
- return zt.create(a, pt.create(Re.create(n)));
3434
+ return Ft.create(a, gt.create(Re.create(n)));
3430
3435
  throw new Error(`Invalid JSON operator: ${e}`);
3431
3436
  }
3432
3437
  function Ce(t) {
3433
3438
  const e = ".";
3434
3439
  if (!t.includes(e))
3435
- return Xt.create(Aa.create(t));
3440
+ return Zt.create(Aa.create(t));
3436
3441
  const a = t.split(e).map($n);
3437
3442
  if (a.length === 3)
3438
3443
  return Qi(a);
@@ -3450,11 +3455,11 @@ function Ki(t) {
3450
3455
  }
3451
3456
  function Qi(t) {
3452
3457
  const [e, a, n] = t;
3453
- return Xt.create(Aa.create(n), ye.createWithSchema(e, a));
3458
+ return Zt.create(Aa.create(n), ye.createWithSchema(e, a));
3454
3459
  }
3455
3460
  function Vi(t) {
3456
3461
  const [e, a] = t;
3457
- return Xt.create(Aa.create(a), ye.create(e));
3462
+ return Zt.create(Aa.create(a), ye.create(e));
3458
3463
  }
3459
3464
  function $n(t) {
3460
3465
  return t.trim();
@@ -3501,7 +3506,7 @@ function Yi(t) {
3501
3506
  return ve(t) ? Xi(t) : j(t);
3502
3507
  }
3503
3508
  function j(t) {
3504
- return aa(t) ? ta(t) : xe.create(t);
3509
+ return na(t) ? aa(t) : xe.create(t);
3505
3510
  }
3506
3511
  function Pa(t) {
3507
3512
  return $a(t) || xn(t) || Tn(t);
@@ -3512,9 +3517,9 @@ function Ra(t) {
3512
3517
  return xe.createImmediate(t);
3513
3518
  }
3514
3519
  function Xi(t) {
3515
- return t.some(aa) ? Hi.create(t.map((e) => j(e))) : Gi.create(t);
3520
+ return t.some(na) ? Hi.create(t.map((e) => j(e))) : Gi.create(t);
3516
3521
  }
3517
- const Nt = c({
3522
+ const Ct = c({
3518
3523
  is(t) {
3519
3524
  return t.kind === "ParensNode";
3520
3525
  },
@@ -3533,22 +3538,22 @@ function ee(t) {
3533
3538
  throw new Error(`invalid arguments: ${JSON.stringify(t)}`);
3534
3539
  }
3535
3540
  function za(t, e, a) {
3536
- return Zi(e) && An(a) ? lt.create(V(t), ma(e), xe.createImmediate(a)) : lt.create(V(t), ma(e), Yi(a));
3541
+ return Zi(e) && An(a) ? lt.create(V(t), ha(e), xe.createImmediate(a)) : lt.create(V(t), ha(e), Yi(a));
3537
3542
  }
3538
- function Ct(t, e, a) {
3539
- return lt.create(V(t), ma(e), V(a));
3543
+ function xt(t, e, a) {
3544
+ return lt.create(V(t), ha(e), V(a));
3540
3545
  }
3541
3546
  function Ka(t, e) {
3542
- return _a(Object.entries(t).filter(([, a]) => !Rt(a)).map(([a, n]) => za(a, An(n) ? "is" : "=", n)), e);
3547
+ return ma(Object.entries(t).filter(([, a]) => !zt(a)).map(([a, n]) => za(a, An(n) ? "is" : "=", n)), e);
3543
3548
  }
3544
- function _a(t, e, a = !0) {
3545
- const n = e === "and" ? Ne.create : dt.create;
3549
+ function ma(t, e, a = !0) {
3550
+ const n = e === "and" ? Ne.create : _t.create;
3546
3551
  if (t.length === 0)
3547
3552
  return lt.create(xe.createImmediate(1), Re.create("="), xe.createImmediate(e === "and" ? 1 : 0));
3548
3553
  let r = Qa(t[0]);
3549
3554
  for (let o = 1; o < t.length; ++o)
3550
3555
  r = n(r, Qa(t[o]));
3551
- return t.length > 1 && a ? Nt.create(r) : r;
3556
+ return t.length > 1 && a ? Ct.create(r) : r;
3552
3557
  }
3553
3558
  function Zi(t) {
3554
3559
  return t === "is" || t === "is not";
@@ -3556,7 +3561,7 @@ function Zi(t) {
3556
3561
  function An(t) {
3557
3562
  return Tn(t) || xn(t);
3558
3563
  }
3559
- function ma(t) {
3564
+ function ha(t) {
3560
3565
  if (re(t) && Ji.includes(t))
3561
3566
  return Re.create(t);
3562
3567
  if (H(t))
@@ -3598,7 +3603,7 @@ const Te = c({
3598
3603
  items: c([...t.items, ...e])
3599
3604
  });
3600
3605
  }
3601
- }), ha = c({
3606
+ }), fa = c({
3602
3607
  is(t) {
3603
3608
  return t.kind === "OverNode";
3604
3609
  },
@@ -3619,7 +3624,7 @@ const Te = c({
3619
3624
  partitionBy: t.partitionBy ? Va.cloneWithItems(t.partitionBy, e) : Va.create(e)
3620
3625
  });
3621
3626
  }
3622
- }), Ft = c({
3627
+ }), Lt = c({
3623
3628
  is(t) {
3624
3629
  return t.kind === "FromNode";
3625
3630
  },
@@ -3664,7 +3669,7 @@ const Te = c({
3664
3669
  cloneWithOperation(t, e, a) {
3665
3670
  return c({
3666
3671
  ...t,
3667
- having: e === "And" ? Ne.create(t.having, a) : dt.create(t.having, a)
3672
+ having: e === "And" ? Ne.create(t.having, a) : _t.create(t.having, a)
3668
3673
  });
3669
3674
  }
3670
3675
  }), E = c({
@@ -3680,7 +3685,7 @@ const Te = c({
3680
3685
  createFrom(t, e) {
3681
3686
  return c({
3682
3687
  kind: "SelectQueryNode",
3683
- from: Ft.create(t),
3688
+ from: Lt.create(t),
3684
3689
  ...e && { with: e }
3685
3690
  });
3686
3691
  },
@@ -3786,15 +3791,15 @@ function Le(t, e) {
3786
3791
  });
3787
3792
  }
3788
3793
  var X;
3789
- const wt = class wt {
3794
+ const yt = class yt {
3790
3795
  constructor(e) {
3791
3796
  x(this, X);
3792
3797
  S(this, X, c(e));
3793
3798
  }
3794
3799
  on(...e) {
3795
- return new wt({
3800
+ return new yt({
3796
3801
  ...i(this, X),
3797
- joinNode: ft.cloneWithOn(i(this, X).joinNode, ee(e))
3802
+ joinNode: pt.cloneWithOn(i(this, X).joinNode, ee(e))
3798
3803
  });
3799
3804
  }
3800
3805
  /**
@@ -3804,18 +3809,18 @@ const wt = class wt {
3804
3809
  * See {@link WhereInterface.whereRef} for documentation and examples.
3805
3810
  */
3806
3811
  onRef(e, a, n) {
3807
- return new wt({
3812
+ return new yt({
3808
3813
  ...i(this, X),
3809
- joinNode: ft.cloneWithOn(i(this, X).joinNode, Ct(e, a, n))
3814
+ joinNode: pt.cloneWithOn(i(this, X).joinNode, xt(e, a, n))
3810
3815
  });
3811
3816
  }
3812
3817
  /**
3813
3818
  * Adds `on true`.
3814
3819
  */
3815
3820
  onTrue() {
3816
- return new wt({
3821
+ return new yt({
3817
3822
  ...i(this, X),
3818
- joinNode: ft.cloneWithOn(i(this, X).joinNode, B.createWithSql("true"))
3823
+ joinNode: pt.cloneWithOn(i(this, X).joinNode, B.createWithSql("true"))
3819
3824
  });
3820
3825
  }
3821
3826
  /**
@@ -3830,8 +3835,8 @@ const wt = class wt {
3830
3835
  }
3831
3836
  };
3832
3837
  X = new WeakMap();
3833
- let Lt = wt;
3834
- Le(Lt, "don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");
3838
+ let Mt = yt;
3839
+ Le(Mt, "don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.");
3835
3840
  const ec = c({
3836
3841
  is(t) {
3837
3842
  return t.kind === "PartitionByItemNode";
@@ -3844,10 +3849,10 @@ const ec = c({
3844
3849
  }
3845
3850
  });
3846
3851
  function tc(t) {
3847
- return vt(t).map(ec.create);
3852
+ return Nt(t).map(ec.create);
3848
3853
  }
3849
3854
  var be;
3850
- const Bt = class Bt {
3855
+ const Ut = class Ut {
3851
3856
  constructor(e) {
3852
3857
  x(this, be);
3853
3858
  S(this, be, c(e));
@@ -3874,13 +3879,13 @@ const Bt = class Bt {
3874
3879
  * ```
3875
3880
  */
3876
3881
  orderBy(e, a) {
3877
- return new Bt({
3878
- overNode: ha.cloneWithOrderByItems(i(this, be).overNode, Da([e, a]))
3882
+ return new Ut({
3883
+ overNode: fa.cloneWithOrderByItems(i(this, be).overNode, Da([e, a]))
3879
3884
  });
3880
3885
  }
3881
3886
  partitionBy(e) {
3882
- return new Bt({
3883
- overNode: ha.cloneWithPartitionByItems(i(this, be).overNode, tc(e))
3887
+ return new Ut({
3888
+ overNode: fa.cloneWithPartitionByItems(i(this, be).overNode, tc(e))
3884
3889
  });
3885
3890
  }
3886
3891
  /**
@@ -3895,9 +3900,9 @@ const Bt = class Bt {
3895
3900
  }
3896
3901
  };
3897
3902
  be = new WeakMap();
3898
- let Mt = Bt;
3899
- Le(Mt, "don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");
3900
- const gt = c({
3903
+ let jt = Ut;
3904
+ Le(jt, "don't await OverBuilder instances. They are never executed directly and are always just a part of a query.");
3905
+ const wt = c({
3901
3906
  is(t) {
3902
3907
  return t.kind === "SelectionNode";
3903
3908
  },
@@ -3916,22 +3921,22 @@ const gt = c({
3916
3921
  createSelectAllFromTable(t) {
3917
3922
  return c({
3918
3923
  kind: "SelectionNode",
3919
- selection: Xt.createSelectAll(t)
3924
+ selection: Zt.createSelectAll(t)
3920
3925
  });
3921
3926
  }
3922
3927
  });
3923
3928
  function Dn(t) {
3924
- return Fe(t) ? Dn(t(ea())) : ve(t) ? t.map((e) => Ya(e)) : [Ya(t)];
3929
+ return Fe(t) ? Dn(t(ta())) : ve(t) ? t.map((e) => Ya(e)) : [Ya(t)];
3925
3930
  }
3926
3931
  function Ya(t) {
3927
- return re(t) ? gt.create(Ki(t)) : kn(t) ? gt.create(t.toOperationNode()) : gt.create(Wn(t));
3932
+ return re(t) ? wt.create(Ki(t)) : kn(t) ? wt.create(t.toOperationNode()) : wt.create(Wn(t));
3928
3933
  }
3929
3934
  function Pn(t) {
3930
- return t ? Array.isArray(t) ? t.map(Xa) : [Xa(t)] : [gt.createSelectAll()];
3935
+ return t ? Array.isArray(t) ? t.map(Xa) : [Xa(t)] : [wt.createSelectAll()];
3931
3936
  }
3932
3937
  function Xa(t) {
3933
3938
  if (re(t))
3934
- return gt.createSelectAllFromTable(Z(t));
3939
+ return wt.createSelectAllFromTable(Z(t));
3935
3940
  throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`);
3936
3941
  }
3937
3942
  const ac = c({
@@ -3976,7 +3981,7 @@ const ac = c({
3976
3981
  cloneWithFromItems(t, e) {
3977
3982
  return c({
3978
3983
  ...t,
3979
- from: t.from ? Ft.cloneWithFroms(t.from, e) : Ft.create(e)
3984
+ from: t.from ? Lt.cloneWithFroms(t.from, e) : Lt.create(e)
3980
3985
  });
3981
3986
  },
3982
3987
  cloneWithUpdates(t, e) {
@@ -4014,7 +4019,7 @@ const ac = c({
4014
4019
  create(t, e) {
4015
4020
  return c({
4016
4021
  kind: "DeleteQueryNode",
4017
- from: Ft.create(t),
4022
+ from: Lt.create(t),
4018
4023
  ...e && { with: e }
4019
4024
  });
4020
4025
  },
@@ -4061,7 +4066,7 @@ const ac = c({
4061
4066
  cloneWithOperation(t, e, a) {
4062
4067
  return c({
4063
4068
  ...t,
4064
- where: e === "And" ? Ne.create(t.where, a) : dt.create(t.where, a)
4069
+ where: e === "And" ? Ne.create(t.where, a) : _t.create(t.where, a)
4065
4070
  });
4066
4071
  }
4067
4072
  }), en = c({
@@ -4091,7 +4096,7 @@ const ac = c({
4091
4096
  options: e
4092
4097
  });
4093
4098
  }
4094
- }), Zt = c({
4099
+ }), ea = c({
4095
4100
  is(t) {
4096
4101
  return t.kind === "WhenNode";
4097
4102
  },
@@ -4135,7 +4140,7 @@ const ac = c({
4135
4140
  ...t,
4136
4141
  whens: t.whens ? c([
4137
4142
  ...t.whens.slice(0, -1),
4138
- Zt.cloneWithResult(t.whens[t.whens.length - 1], e)
4143
+ ea.cloneWithResult(t.whens[t.whens.length - 1], e)
4139
4144
  ]) : void 0
4140
4145
  });
4141
4146
  }
@@ -4242,7 +4247,7 @@ const lc = c({
4242
4247
  function uc(t, e) {
4243
4248
  if (!$a(t) && !Sn(t))
4244
4249
  throw new Error(`Invalid top expression: ${t}`);
4245
- if (!Rt(e) && !dc(e))
4250
+ if (!zt(e) && !dc(e))
4246
4251
  throw new Error(`Invalid top modifiers: ${e}`);
4247
4252
  return lc.create(t, e);
4248
4253
  }
@@ -4345,11 +4350,11 @@ class fc {
4345
4350
  }
4346
4351
  }
4347
4352
  Ge = new WeakMap();
4348
- var Ut;
4353
+ var Kt;
4349
4354
  class pc {
4350
4355
  constructor() {
4351
4356
  me(this, "nodeStack", []);
4352
- x(this, Ut, c({
4357
+ x(this, Kt, c({
4353
4358
  AliasNode: this.transformAlias.bind(this),
4354
4359
  ColumnNode: this.transformColumn.bind(this),
4355
4360
  IdentifierNode: this.transformIdentifier.bind(this),
@@ -4453,7 +4458,7 @@ class pc {
4453
4458
  return this.nodeStack.pop(), c(a);
4454
4459
  }
4455
4460
  transformNodeImpl(e) {
4456
- return i(this, Ut)[e.kind](e);
4461
+ return i(this, Kt)[e.kind](e);
4457
4462
  }
4458
4463
  transformNodeList(e) {
4459
4464
  return e && c(e.map((a) => this.transformNode(a)));
@@ -5184,7 +5189,7 @@ class pc {
5184
5189
  return e;
5185
5190
  }
5186
5191
  }
5187
- Ut = new WeakMap();
5192
+ Kt = new WeakMap();
5188
5193
  const gc = c({
5189
5194
  AlterTableNode: !0,
5190
5195
  CreateIndexNode: !0,
@@ -5207,7 +5212,7 @@ const gc = c({
5207
5212
  json_agg: !0,
5208
5213
  to_json: !0
5209
5214
  };
5210
- var He, ke, Ee, $, fa, Rn, zn, Fn, qe, pa, Ln;
5215
+ var He, ke, Ee, $, pa, Rn, zn, Fn, qe, ga, Ln;
5211
5216
  class yc extends pc {
5212
5217
  constructor(a) {
5213
5218
  super();
@@ -5250,17 +5255,17 @@ class yc extends pc {
5250
5255
  transformAggregateFunction(a) {
5251
5256
  return {
5252
5257
  ...super.transformAggregateFunction({ ...a, aggregated: [] }),
5253
- aggregated: v(this, $, fa).call(this, a, "aggregated")
5258
+ aggregated: v(this, $, pa).call(this, a, "aggregated")
5254
5259
  };
5255
5260
  }
5256
5261
  transformFunction(a) {
5257
5262
  return {
5258
5263
  ...super.transformFunction({ ...a, arguments: [] }),
5259
- arguments: v(this, $, fa).call(this, a, "arguments")
5264
+ arguments: v(this, $, pa).call(this, a, "arguments")
5260
5265
  };
5261
5266
  }
5262
5267
  }
5263
- He = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), $ = new WeakSet(), fa = function(a, n) {
5268
+ He = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), $ = new WeakSet(), pa = function(a, n) {
5264
5269
  return wc[a.func] ? a[n].map((r) => !ye.is(r) || r.table.schema ? this.transformNode(r) : {
5265
5270
  ...r,
5266
5271
  table: this.transformIdentifier(r.table.identifier)
@@ -5269,7 +5274,7 @@ He = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), $ = new WeakSet(), f
5269
5274
  return a.kind in gc;
5270
5275
  }, zn = function(a) {
5271
5276
  const n = /* @__PURE__ */ new Set();
5272
- if ("name" in a && a.name && ua.is(a.name) && v(this, $, pa).call(this, a.name, n), "from" in a && a.from)
5277
+ if ("name" in a && a.name && da.is(a.name) && v(this, $, ga).call(this, a.name, n), "from" in a && a.from)
5273
5278
  for (const r of a.from.froms)
5274
5279
  v(this, $, qe).call(this, r, n);
5275
5280
  if ("into" in a && a.into && v(this, $, qe).call(this, a.into, n), "table" in a && a.table && v(this, $, qe).call(this, a.table, n), "joins" in a && a.joins)
@@ -5281,8 +5286,8 @@ He = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), $ = new WeakSet(), f
5281
5286
  return "with" in a && a.with && v(this, $, Ln).call(this, a.with, n), n;
5282
5287
  }, qe = function(a, n) {
5283
5288
  const r = ye.is(a) ? a : Se.is(a) && ye.is(a.node) ? a.node : null;
5284
- r && v(this, $, pa).call(this, r.table, n);
5285
- }, pa = function(a, n) {
5289
+ r && v(this, $, ga).call(this, r.table, n);
5290
+ }, ga = function(a, n) {
5286
5291
  const r = a.identifier.name;
5287
5292
  !i(this, ke).has(r) && !i(this, Ee).has(r) && n.add(r);
5288
5293
  }, Ln = function(a, n) {
@@ -5291,24 +5296,24 @@ He = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), $ = new WeakSet(), f
5291
5296
  i(this, Ee).has(o) || n.add(o);
5292
5297
  }
5293
5298
  };
5294
- var xt;
5299
+ var Tt;
5295
5300
  class Mn {
5296
5301
  constructor(e) {
5297
- x(this, xt);
5298
- S(this, xt, new yc(e));
5302
+ x(this, Tt);
5303
+ S(this, Tt, new yc(e));
5299
5304
  }
5300
5305
  transformQuery(e) {
5301
- return i(this, xt).transformNode(e.node);
5306
+ return i(this, Tt).transformNode(e.node);
5302
5307
  }
5303
5308
  async transformResult(e) {
5304
5309
  return e.result;
5305
5310
  }
5306
5311
  }
5307
- xt = new WeakMap();
5308
- var Tt, Ye, Xe;
5312
+ Tt = new WeakMap();
5313
+ var St, Ye, Xe;
5309
5314
  class nn {
5310
5315
  constructor() {
5311
- x(this, Tt);
5316
+ x(this, St);
5312
5317
  x(this, Ye);
5313
5318
  x(this, Xe);
5314
5319
  me(this, "resolve", (e) => {
@@ -5317,24 +5322,24 @@ class nn {
5317
5322
  me(this, "reject", (e) => {
5318
5323
  i(this, Xe) && i(this, Xe).call(this, e);
5319
5324
  });
5320
- S(this, Tt, new Promise((e, a) => {
5325
+ S(this, St, new Promise((e, a) => {
5321
5326
  S(this, Xe, a), S(this, Ye, e);
5322
5327
  }));
5323
5328
  }
5324
5329
  get promise() {
5325
- return i(this, Tt);
5330
+ return i(this, St);
5326
5331
  }
5327
5332
  }
5328
- Tt = new WeakMap(), Ye = new WeakMap(), Xe = new WeakMap();
5333
+ St = new WeakMap(), Ye = new WeakMap(), Xe = new WeakMap();
5329
5334
  const rn = /* @__PURE__ */ new Set();
5330
5335
  function vc(t) {
5331
5336
  rn.has(t) || (rn.add(t), console.log(t));
5332
5337
  }
5333
5338
  const Nc = c([]);
5334
- var Ie, St, ga;
5339
+ var Ie, Ot, wa;
5335
5340
  class Cc {
5336
5341
  constructor(e = Nc) {
5337
- x(this, St);
5342
+ x(this, Ot);
5338
5343
  x(this, Ie);
5339
5344
  S(this, Ie, e);
5340
5345
  }
@@ -5358,7 +5363,7 @@ class Cc {
5358
5363
  }
5359
5364
  async executeQuery(e, a) {
5360
5365
  return await this.provideConnection(async (n) => {
5361
- const r = await n.executeQuery(e), o = await v(this, St, ga).call(this, r, a);
5366
+ const r = await n.executeQuery(e), o = await v(this, Ot, wa).call(this, r, a);
5362
5367
  return xc(r, o), o;
5363
5368
  });
5364
5369
  }
@@ -5368,13 +5373,13 @@ class Cc {
5368
5373
  const s = await r.promise;
5369
5374
  try {
5370
5375
  for await (const l of s.streamQuery(e, a))
5371
- yield await v(this, St, ga).call(this, l, n);
5376
+ yield await v(this, Ot, wa).call(this, l, n);
5372
5377
  } finally {
5373
5378
  o.resolve();
5374
5379
  }
5375
5380
  }
5376
5381
  }
5377
- Ie = new WeakMap(), St = new WeakSet(), ga = async function(e, a) {
5382
+ Ie = new WeakMap(), Ot = new WeakSet(), wa = async function(e, a) {
5378
5383
  for (const n of i(this, Ie))
5379
5384
  e = await n.transformResult({ result: e, queryId: a });
5380
5385
  return e;
@@ -5411,13 +5416,13 @@ class Ke extends Cc {
5411
5416
  }
5412
5417
  const jn = new Ke();
5413
5418
  function Tc(t, e) {
5414
- return new Lt({
5415
- joinNode: ft.create(t, qt(e))
5419
+ return new Mt({
5420
+ joinNode: pt.create(t, Wt(e))
5416
5421
  });
5417
5422
  }
5418
5423
  function Sc() {
5419
- return new Mt({
5420
- overNode: ha.create()
5424
+ return new jt({
5425
+ overNode: fa.create()
5421
5426
  });
5422
5427
  }
5423
5428
  function Me(t, e) {
@@ -5431,7 +5436,7 @@ function Oc(t, e, a) {
5431
5436
  return a(Tc(t, e)).toOperationNode();
5432
5437
  }
5433
5438
  function bc(t, e, a, n) {
5434
- return ft.createWithOn(t, qt(e), Ct(a, "=", n));
5439
+ return pt.createWithOn(t, Wt(e), xt(a, "=", n));
5435
5440
  }
5436
5441
  const kc = c({
5437
5442
  is(t) {
@@ -5455,7 +5460,7 @@ const kc = c({
5455
5460
  }
5456
5461
  });
5457
5462
  function Ic(t) {
5458
- return t = Fe(t) ? t(ea()) : t, vt(t).map(Ec.create);
5463
+ return t = Fe(t) ? t(ta()) : t, Nt(t).map(Ec.create);
5459
5464
  }
5460
5465
  const $c = c({
5461
5466
  is(t) {
@@ -5471,10 +5476,10 @@ const $c = c({
5471
5476
  }
5472
5477
  });
5473
5478
  function je(t, e, a) {
5474
- return Fe(e) && (e = e(La())), ve(e) || (e = [e]), e.map((n) => $c.create(t, ta(n), a));
5479
+ return Fe(e) && (e = e(La())), ve(e) || (e = [e]), e.map((n) => $c.create(t, aa(n), a));
5475
5480
  }
5476
5481
  var de;
5477
- const Kt = class Kt {
5482
+ const Qt = class Qt {
5478
5483
  constructor(e) {
5479
5484
  x(this, de);
5480
5485
  S(this, de, e);
@@ -5486,10 +5491,10 @@ const Kt = class Kt {
5486
5491
  return new Fa(this, e);
5487
5492
  }
5488
5493
  or(...e) {
5489
- return new wa(dt.create(i(this, de), ee(e)));
5494
+ return new ya(_t.create(i(this, de), ee(e)));
5490
5495
  }
5491
5496
  and(...e) {
5492
- return new ya(Ne.create(i(this, de), ee(e)));
5497
+ return new va(Ne.create(i(this, de), ee(e)));
5493
5498
  }
5494
5499
  /**
5495
5500
  * Change the output type of the expression.
@@ -5498,7 +5503,7 @@ const Kt = class Kt {
5498
5503
  * returns a copy of this `ExpressionWrapper` with a new output type.
5499
5504
  */
5500
5505
  $castTo() {
5501
- return new Kt(i(this, de));
5506
+ return new Qt(i(this, de));
5502
5507
  }
5503
5508
  /**
5504
5509
  * Omit null from the expression's type.
@@ -5510,14 +5515,14 @@ const Kt = class Kt {
5510
5515
  * returns a copy of `this` with a new output type.
5511
5516
  */
5512
5517
  $notNull() {
5513
- return new Kt(i(this, de));
5518
+ return new Qt(i(this, de));
5514
5519
  }
5515
5520
  toOperationNode() {
5516
5521
  return i(this, de);
5517
5522
  }
5518
5523
  };
5519
5524
  de = new WeakMap();
5520
- let k = Kt;
5525
+ let k = Qt;
5521
5526
  var Ze, pe;
5522
5527
  class Fa {
5523
5528
  constructor(e, a) {
@@ -5539,7 +5544,7 @@ class Fa {
5539
5544
  }
5540
5545
  Ze = new WeakMap(), pe = new WeakMap();
5541
5546
  var $e;
5542
- const Qt = class Qt {
5547
+ const Vt = class Vt {
5543
5548
  constructor(e) {
5544
5549
  x(this, $e);
5545
5550
  S(this, $e, e);
@@ -5551,7 +5556,7 @@ const Qt = class Qt {
5551
5556
  return new Fa(this, e);
5552
5557
  }
5553
5558
  or(...e) {
5554
- return new Qt(dt.create(i(this, $e), ee(e)));
5559
+ return new Vt(_t.create(i(this, $e), ee(e)));
5555
5560
  }
5556
5561
  /**
5557
5562
  * Change the output type of the expression.
@@ -5560,16 +5565,16 @@ const Qt = class Qt {
5560
5565
  * returns a copy of this `OrWrapper` with a new output type.
5561
5566
  */
5562
5567
  $castTo() {
5563
- return new Qt(i(this, $e));
5568
+ return new Vt(i(this, $e));
5564
5569
  }
5565
5570
  toOperationNode() {
5566
- return Nt.create(i(this, $e));
5571
+ return Ct.create(i(this, $e));
5567
5572
  }
5568
5573
  };
5569
5574
  $e = new WeakMap();
5570
- let wa = Qt;
5575
+ let ya = Vt;
5571
5576
  var Ae;
5572
- const Vt = class Vt {
5577
+ const Gt = class Gt {
5573
5578
  constructor(e) {
5574
5579
  x(this, Ae);
5575
5580
  S(this, Ae, e);
@@ -5581,7 +5586,7 @@ const Vt = class Vt {
5581
5586
  return new Fa(this, e);
5582
5587
  }
5583
5588
  and(...e) {
5584
- return new Vt(Ne.create(i(this, Ae), ee(e)));
5589
+ return new Gt(Ne.create(i(this, Ae), ee(e)));
5585
5590
  }
5586
5591
  /**
5587
5592
  * Change the output type of the expression.
@@ -5590,14 +5595,14 @@ const Vt = class Vt {
5590
5595
  * returns a copy of this `AndWrapper` with a new output type.
5591
5596
  */
5592
5597
  $castTo() {
5593
- return new Vt(i(this, Ae));
5598
+ return new Gt(i(this, Ae));
5594
5599
  }
5595
5600
  toOperationNode() {
5596
- return Nt.create(i(this, Ae));
5601
+ return Ct.create(i(this, Ae));
5597
5602
  }
5598
5603
  };
5599
5604
  Ae = new WeakMap();
5600
- let ya = Vt;
5605
+ let va = Gt;
5601
5606
  const Ac = {
5602
5607
  is(t) {
5603
5608
  return t.kind === "FetchNode";
@@ -5640,7 +5645,7 @@ const C = class C {
5640
5645
  whereRef(e, a, n) {
5641
5646
  return new C({
5642
5647
  ...i(this, h),
5643
- queryNode: A.cloneWithWhere(i(this, h).queryNode, Ct(e, a, n))
5648
+ queryNode: A.cloneWithWhere(i(this, h).queryNode, xt(e, a, n))
5644
5649
  });
5645
5650
  }
5646
5651
  having(...e) {
@@ -5652,7 +5657,7 @@ const C = class C {
5652
5657
  havingRef(e, a, n) {
5653
5658
  return new C({
5654
5659
  ...i(this, h),
5655
- queryNode: E.cloneWithHaving(i(this, h).queryNode, Ct(e, a, n))
5660
+ queryNode: E.cloneWithHaving(i(this, h).queryNode, xt(e, a, n))
5656
5661
  });
5657
5662
  }
5658
5663
  select(e) {
@@ -5664,7 +5669,7 @@ const C = class C {
5664
5669
  distinctOn(e) {
5665
5670
  return new C({
5666
5671
  ...i(this, h),
5667
- queryNode: E.cloneWithDistinctOn(i(this, h).queryNode, vt(e))
5672
+ queryNode: E.cloneWithDistinctOn(i(this, h).queryNode, Nt(e))
5668
5673
  });
5669
5674
  }
5670
5675
  modifyFront(e) {
@@ -5688,25 +5693,25 @@ const C = class C {
5688
5693
  forUpdate(e) {
5689
5694
  return new C({
5690
5695
  ...i(this, h),
5691
- queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForUpdate", e ? It(e).map(Z) : void 0))
5696
+ queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForUpdate", e ? $t(e).map(Z) : void 0))
5692
5697
  });
5693
5698
  }
5694
5699
  forShare(e) {
5695
5700
  return new C({
5696
5701
  ...i(this, h),
5697
- queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForShare", e ? It(e).map(Z) : void 0))
5702
+ queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForShare", e ? $t(e).map(Z) : void 0))
5698
5703
  });
5699
5704
  }
5700
5705
  forKeyShare(e) {
5701
5706
  return new C({
5702
5707
  ...i(this, h),
5703
- queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForKeyShare", e ? It(e).map(Z) : void 0))
5708
+ queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForKeyShare", e ? $t(e).map(Z) : void 0))
5704
5709
  });
5705
5710
  }
5706
5711
  forNoKeyUpdate(e) {
5707
5712
  return new C({
5708
5713
  ...i(this, h),
5709
- queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForNoKeyUpdate", e ? It(e).map(Z) : void 0))
5714
+ queryNode: A.cloneWithEndModifier(i(this, h).queryNode, oe.create("ForNoKeyUpdate", e ? $t(e).map(Z) : void 0))
5710
5715
  });
5711
5716
  }
5712
5717
  skipLocked() {
@@ -5933,10 +5938,10 @@ const C = class C {
5933
5938
  }
5934
5939
  };
5935
5940
  h = new WeakMap();
5936
- let jt = C;
5937
- Le(jt, "don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");
5941
+ let Jt = C;
5942
+ Le(Jt, "don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.");
5938
5943
  function Rc(t) {
5939
- return new jt(t);
5944
+ return new Jt(t);
5940
5945
  }
5941
5946
  var et, tt;
5942
5947
  class Jn {
@@ -6147,7 +6152,7 @@ const ue = class ue {
6147
6152
  filterWhereRef(e, a, n) {
6148
6153
  return new ue({
6149
6154
  ...i(this, D),
6150
- aggregateFunctionNode: fe.cloneWithFilter(i(this, D).aggregateFunctionNode, Ct(e, a, n))
6155
+ aggregateFunctionNode: fe.cloneWithFilter(i(this, D).aggregateFunctionNode, xt(e, a, n))
6151
6156
  });
6152
6157
  }
6153
6158
  /**
@@ -6255,8 +6260,8 @@ class zc {
6255
6260
  }
6256
6261
  at = new WeakMap(), nt = new WeakMap();
6257
6262
  function Fc() {
6258
- const t = (a, n) => new k(on.create(a, vt(n ?? []))), e = (a, n) => new Qe({
6259
- aggregateFunctionNode: fe.create(a, n ? vt(n) : void 0)
6263
+ const t = (a, n) => new k(on.create(a, Nt(n ?? []))), e = (a, n) => new Qe({
6264
+ aggregateFunctionNode: fe.create(a, n ? Nt(n) : void 0)
6260
6265
  });
6261
6266
  return Object.assign(t, {
6262
6267
  agg: e,
@@ -6336,7 +6341,7 @@ const _e = c({
6336
6341
  ...t,
6337
6342
  when: t.when ? c([
6338
6343
  ...t.when.slice(0, -1),
6339
- Zt.cloneWithResult(t.when[t.when.length - 1], e)
6344
+ ea.cloneWithResult(t.when[t.when.length - 1], e)
6340
6345
  ]) : void 0
6341
6346
  });
6342
6347
  },
@@ -6356,7 +6361,7 @@ class jc {
6356
6361
  when(...e) {
6357
6362
  return new qn({
6358
6363
  ...i(this, rt),
6359
- node: _e.cloneWithWhen(i(this, rt).node, Zt.create(ee(e)))
6364
+ node: _e.cloneWithWhen(i(this, rt).node, ea.create(ee(e)))
6360
6365
  });
6361
6366
  }
6362
6367
  }
@@ -6384,7 +6389,7 @@ class Jc {
6384
6389
  when(...e) {
6385
6390
  return new qn({
6386
6391
  ...i(this, ae),
6387
- node: _e.cloneWithWhen(i(this, ae).node, Zt.create(ee(e)))
6392
+ node: _e.cloneWithWhen(i(this, ae).node, ea.create(ee(e)))
6388
6393
  });
6389
6394
  }
6390
6395
  else(e) {
@@ -6429,10 +6434,10 @@ const sn = c({
6429
6434
  });
6430
6435
  }
6431
6436
  });
6432
- var ne, Ot, Na;
6433
- class va {
6437
+ var ne, bt, Ca;
6438
+ class Na {
6434
6439
  constructor(e) {
6435
- x(this, Ot);
6440
+ x(this, bt);
6436
6441
  x(this, ne);
6437
6442
  S(this, ne, e);
6438
6443
  }
@@ -6504,7 +6509,7 @@ class va {
6504
6509
  * ```
6505
6510
  */
6506
6511
  at(e) {
6507
- return v(this, Ot, Na).call(this, "ArrayLocation", e);
6512
+ return v(this, bt, Ca).call(this, "ArrayLocation", e);
6508
6513
  }
6509
6514
  /**
6510
6515
  * Access a property of a JSON object.
@@ -6556,14 +6561,14 @@ class va {
6556
6561
  * ```
6557
6562
  */
6558
6563
  key(e) {
6559
- return v(this, Ot, Na).call(this, "Member", e);
6564
+ return v(this, bt, Ca).call(this, "Member", e);
6560
6565
  }
6561
6566
  }
6562
- ne = new WeakMap(), Ot = new WeakSet(), Na = function(e, a) {
6563
- return zt.is(i(this, ne)) ? new Jt(zt.cloneWithTraversal(i(this, ne), pt.is(i(this, ne).traversal) ? pt.cloneWithLeg(i(this, ne).traversal, sn.create(e, a)) : In.cloneWithValue(i(this, ne).traversal, xe.createImmediate(a)))) : new Jt(pt.cloneWithLeg(i(this, ne), sn.create(e, a)));
6567
+ ne = new WeakMap(), bt = new WeakSet(), Ca = function(e, a) {
6568
+ return Ft.is(i(this, ne)) ? new qt(Ft.cloneWithTraversal(i(this, ne), gt.is(i(this, ne).traversal) ? gt.cloneWithLeg(i(this, ne).traversal, sn.create(e, a)) : In.cloneWithValue(i(this, ne).traversal, xe.createImmediate(a)))) : new qt(gt.cloneWithLeg(i(this, ne), sn.create(e, a)));
6564
6569
  };
6565
6570
  var De;
6566
- const Gt = class Gt extends va {
6571
+ const Ht = class Ht extends Na {
6567
6572
  constructor(a) {
6568
6573
  super(a);
6569
6574
  x(this, De);
@@ -6582,17 +6587,17 @@ const Gt = class Gt extends va {
6582
6587
  * returns a copy of this `JSONPathBuilder` with a new output type.
6583
6588
  */
6584
6589
  $castTo() {
6585
- return new Gt(i(this, De));
6590
+ return new Ht(i(this, De));
6586
6591
  }
6587
6592
  $notNull() {
6588
- return new Gt(i(this, De));
6593
+ return new Ht(i(this, De));
6589
6594
  }
6590
6595
  toOperationNode() {
6591
6596
  return i(this, De);
6592
6597
  }
6593
6598
  };
6594
6599
  De = new WeakMap();
6595
- let Jt = Gt;
6600
+ let qt = Ht;
6596
6601
  var it, ge;
6597
6602
  class Wc {
6598
6603
  constructor(e, a) {
@@ -6731,14 +6736,14 @@ function La(t = jn) {
6731
6736
  },
6732
6737
  case(r) {
6733
6738
  return new jc({
6734
- node: _e.create(Rt(r) ? void 0 : V(r))
6739
+ node: _e.create(zt(r) ? void 0 : V(r))
6735
6740
  });
6736
6741
  },
6737
6742
  ref(r, o) {
6738
- return Rt(o) ? new k(Ce(r)) : new va(Ui(r, o));
6743
+ return zt(o) ? new k(Ce(r)) : new Na(Ui(r, o));
6739
6744
  },
6740
6745
  jsonPath() {
6741
- return new va(pt.create());
6746
+ return new Na(gt.create());
6742
6747
  },
6743
6748
  table(r) {
6744
6749
  return new k(Z(r));
@@ -6772,14 +6777,14 @@ function La(t = jn) {
6772
6777
  return new k(lt.create(V(r), Re.create("between symmetric"), Ne.create(j(o), j(s))));
6773
6778
  },
6774
6779
  and(r) {
6775
- return ve(r) ? new k(_a(r, "and")) : new k(Ka(r, "and"));
6780
+ return ve(r) ? new k(ma(r, "and")) : new k(Ka(r, "and"));
6776
6781
  },
6777
6782
  or(r) {
6778
- return ve(r) ? new k(_a(r, "or")) : new k(Ka(r, "or"));
6783
+ return ve(r) ? new k(ma(r, "or")) : new k(Ka(r, "or"));
6779
6784
  },
6780
6785
  parens(...r) {
6781
6786
  const o = ee(r);
6782
- return Nt.is(o) ? new k(o) : new k(Nt.create(o));
6787
+ return Ct.is(o) ? new k(o) : new k(Ct.create(o));
6783
6788
  },
6784
6789
  cast(r, o) {
6785
6790
  return new k(Gc.create(V(r), Vc(o)));
@@ -6790,30 +6795,30 @@ function La(t = jn) {
6790
6795
  });
6791
6796
  return n.fn = Fc(), n.eb = n, n;
6792
6797
  }
6793
- function ea(t) {
6798
+ function ta(t) {
6794
6799
  return La();
6795
6800
  }
6796
- function ta(t) {
6801
+ function aa(t) {
6797
6802
  if (H(t))
6798
6803
  return t.toOperationNode();
6799
6804
  if (Fe(t))
6800
- return t(ea()).toOperationNode();
6805
+ return t(ta()).toOperationNode();
6801
6806
  throw new Error(`invalid expression: ${JSON.stringify(t)}`);
6802
6807
  }
6803
6808
  function Wn(t) {
6804
6809
  if (H(t))
6805
6810
  return t.toOperationNode();
6806
6811
  if (Fe(t))
6807
- return t(ea()).toOperationNode();
6812
+ return t(ta()).toOperationNode();
6808
6813
  throw new Error(`invalid aliased expression: ${JSON.stringify(t)}`);
6809
6814
  }
6810
- function aa(t) {
6815
+ function na(t) {
6811
6816
  return Pi(t) || Ri(t) || Fe(t);
6812
6817
  }
6813
6818
  function Hc(t) {
6814
- return ve(t) ? t.map((e) => qt(e)) : [qt(t)];
6819
+ return ve(t) ? t.map((e) => Wt(e)) : [Wt(t)];
6815
6820
  }
6816
- function qt(t) {
6821
+ function Wt(t) {
6817
6822
  return re(t) ? Yc(t) : Wn(t);
6818
6823
  }
6819
6824
  function Yc(t) {
@@ -6835,8 +6840,8 @@ function Z(t) {
6835
6840
  function Bn(t) {
6836
6841
  return t.trim();
6837
6842
  }
6838
- var M, G, At, Ca, xa;
6839
- const yt = class yt {
6843
+ var M, G, Dt, xa, Ta;
6844
+ const vt = class vt {
6840
6845
  constructor(e) {
6841
6846
  x(this, G);
6842
6847
  x(this, M);
@@ -6851,41 +6856,41 @@ const yt = class yt {
6851
6856
  return new Un(this, e);
6852
6857
  }
6853
6858
  $castTo() {
6854
- return new yt({ ...i(this, M) });
6859
+ return new vt({ ...i(this, M) });
6855
6860
  }
6856
6861
  $notNull() {
6857
- return new yt(i(this, M));
6862
+ return new vt(i(this, M));
6858
6863
  }
6859
6864
  withPlugin(e) {
6860
- return new yt({
6865
+ return new vt({
6861
6866
  ...i(this, M),
6862
6867
  plugins: i(this, M).plugins !== void 0 ? c([...i(this, M).plugins, e]) : c([e])
6863
6868
  });
6864
6869
  }
6865
6870
  toOperationNode() {
6866
- return v(this, G, Ca).call(this, v(this, G, At).call(this));
6871
+ return v(this, G, xa).call(this, v(this, G, Dt).call(this));
6867
6872
  }
6868
6873
  compile(e) {
6869
- return v(this, G, xa).call(this, v(this, G, At).call(this, e));
6874
+ return v(this, G, Ta).call(this, v(this, G, Dt).call(this, e));
6870
6875
  }
6871
6876
  async execute(e) {
6872
- const a = v(this, G, At).call(this, e);
6873
- return a.executeQuery(v(this, G, xa).call(this, a), i(this, M).queryId);
6877
+ const a = v(this, G, Dt).call(this, e);
6878
+ return a.executeQuery(v(this, G, Ta).call(this, a), i(this, M).queryId);
6874
6879
  }
6875
6880
  };
6876
- M = new WeakMap(), G = new WeakSet(), At = function(e) {
6881
+ M = new WeakMap(), G = new WeakSet(), Dt = function(e) {
6877
6882
  const a = e !== void 0 ? e.getExecutor() : jn;
6878
6883
  return i(this, M).plugins !== void 0 ? a.withPlugins(i(this, M).plugins) : a;
6879
- }, Ca = function(e) {
6880
- return e.transformQuery(i(this, M).rawNode, i(this, M).queryId);
6881
6884
  }, xa = function(e) {
6882
- return e.compileQuery(v(this, G, Ca).call(this, e), i(this, M).queryId);
6885
+ return e.transformQuery(i(this, M).rawNode, i(this, M).queryId);
6886
+ }, Ta = function(e) {
6887
+ return e.compileQuery(v(this, G, xa).call(this, e), i(this, M).queryId);
6883
6888
  };
6884
- let Wt = yt;
6889
+ let Bt = vt;
6885
6890
  function he(t) {
6886
- return new Wt(t);
6891
+ return new Bt(t);
6887
6892
  }
6888
- Le(Wt, "don't await RawBuilder instances directly. To execute the query you need to call `execute`");
6893
+ Le(Bt, "don't await RawBuilder instances directly. To execute the query you need to call `execute`");
6889
6894
  var Pe, we;
6890
6895
  class Un {
6891
6896
  constructor(e, a) {
@@ -6976,8 +6981,8 @@ class Xc {
6976
6981
  return e.result;
6977
6982
  }
6978
6983
  }
6979
- const Zc = "kysely_migration", un = "kysely_migration_lock", el = !1, sa = "migration_lock", tl = c({ __noMigrations__: !0 });
6980
- var I, g, _t, ie, ce, We, Qn, le, Vn, Gn, Hn, Yn, Xn, Ta, Be, Sa, Zn, er, tr, Oa, ar, nr, rr, or, sr, mt;
6984
+ const Zc = "kysely_migration", un = "kysely_migration_lock", el = !1, ia = "migration_lock", tl = c({ __noMigrations__: !0 });
6985
+ var I, g, mt, ie, ce, We, Qn, le, Vn, Gn, Hn, Yn, Xn, Sa, Be, Oa, Zn, er, tr, ba, ar, nr, rr, or, sr, ht;
6981
6986
  class Kn {
6982
6987
  constructor(e) {
6983
6988
  x(this, g);
@@ -6991,7 +6996,7 @@ class Kn {
6991
6996
  */
6992
6997
  async getMigrations() {
6993
6998
  const e = await v(this, g, Be).call(this, i(this, g, ce)) ? await i(this, I).db.withPlugin(i(this, g, le)).selectFrom(i(this, g, ce)).select(["name", "timestamp"]).$narrowType().execute() : [];
6994
- return (await v(this, g, Oa).call(this)).map(({ name: n, ...r }) => {
6999
+ return (await v(this, g, ba).call(this)).map(({ name: n, ...r }) => {
6995
7000
  const o = e.find((s) => s.name === n);
6996
7001
  return {
6997
7002
  name: n,
@@ -7047,7 +7052,7 @@ class Kn {
7047
7052
  * ```
7048
7053
  */
7049
7054
  async migrateToLatest() {
7050
- return v(this, g, _t).call(this, () => ({ direction: "Up", step: 1 / 0 }));
7055
+ return v(this, g, mt).call(this, () => ({ direction: "Up", step: 1 / 0 }));
7051
7056
  }
7052
7057
  /**
7053
7058
  * Migrate up/down to a specific migration.
@@ -7101,7 +7106,7 @@ class Kn {
7101
7106
  * ```
7102
7107
  */
7103
7108
  async migrateTo(e) {
7104
- return v(this, g, _t).call(this, ({ migrations: a, executedMigrations: n, pendingMigrations: r }) => {
7109
+ return v(this, g, mt).call(this, ({ migrations: a, executedMigrations: n, pendingMigrations: r }) => {
7105
7110
  if (e === tl)
7106
7111
  return { direction: "Down", step: 1 / 0 };
7107
7112
  if (!a.find((l) => l.name === e))
@@ -7146,7 +7151,7 @@ class Kn {
7146
7151
  * ```
7147
7152
  */
7148
7153
  async migrateUp() {
7149
- return v(this, g, _t).call(this, () => ({ direction: "Up", step: 1 }));
7154
+ return v(this, g, mt).call(this, () => ({ direction: "Up", step: 1 }));
7150
7155
  }
7151
7156
  /**
7152
7157
  * Migrate one step down.
@@ -7177,14 +7182,14 @@ class Kn {
7177
7182
  * ```
7178
7183
  */
7179
7184
  async migrateDown() {
7180
- return v(this, g, _t).call(this, () => ({ direction: "Down", step: 1 }));
7185
+ return v(this, g, mt).call(this, () => ({ direction: "Down", step: 1 }));
7181
7186
  }
7182
7187
  }
7183
- I = new WeakMap(), g = new WeakSet(), _t = async function(e) {
7188
+ I = new WeakMap(), g = new WeakSet(), mt = async function(e) {
7184
7189
  try {
7185
7190
  return await v(this, g, Vn).call(this), await v(this, g, Zn).call(this, e);
7186
7191
  } catch (a) {
7187
- return a instanceof ia ? a.resultSet : { error: a };
7192
+ return a instanceof ca ? a.resultSet : { error: a };
7188
7193
  }
7189
7194
  }, ie = function() {
7190
7195
  return i(this, I).migrationTableSchema;
@@ -7199,17 +7204,17 @@ I = new WeakMap(), g = new WeakSet(), _t = async function(e) {
7199
7204
  }, Vn = async function() {
7200
7205
  await v(this, g, Gn).call(this), await v(this, g, Hn).call(this), await v(this, g, Yn).call(this), await v(this, g, Xn).call(this);
7201
7206
  }, Gn = async function() {
7202
- if (i(this, g, ie) && !await v(this, g, Ta).call(this))
7207
+ if (i(this, g, ie) && !await v(this, g, Sa).call(this))
7203
7208
  try {
7204
- await v(this, g, mt).call(this, i(this, I).db.schema.createSchema(i(this, g, ie)));
7209
+ await v(this, g, ht).call(this, i(this, I).db.schema.createSchema(i(this, g, ie)));
7205
7210
  } catch (e) {
7206
- if (!await v(this, g, Ta).call(this))
7211
+ if (!await v(this, g, Sa).call(this))
7207
7212
  throw e;
7208
7213
  }
7209
7214
  }, Hn = async function() {
7210
7215
  if (!await v(this, g, Be).call(this, i(this, g, ce)))
7211
7216
  try {
7212
- i(this, g, ie) && await v(this, g, mt).call(this, i(this, I).db.schema.createSchema(i(this, g, ie))), await v(this, g, mt).call(this, i(this, I).db.schema.withPlugin(i(this, g, le)).createTable(i(this, g, ce)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
7217
+ i(this, g, ie) && await v(this, g, ht).call(this, i(this, I).db.schema.createSchema(i(this, g, ie))), await v(this, g, ht).call(this, i(this, I).db.schema.withPlugin(i(this, g, le)).createTable(i(this, g, ce)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
7213
7218
  } catch (e) {
7214
7219
  if (!await v(this, g, Be).call(this, i(this, g, ce)))
7215
7220
  throw e;
@@ -7217,32 +7222,32 @@ I = new WeakMap(), g = new WeakSet(), _t = async function(e) {
7217
7222
  }, Yn = async function() {
7218
7223
  if (!await v(this, g, Be).call(this, i(this, g, We)))
7219
7224
  try {
7220
- await v(this, g, mt).call(this, i(this, I).db.schema.withPlugin(i(this, g, le)).createTable(i(this, g, We)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
7225
+ await v(this, g, ht).call(this, i(this, I).db.schema.withPlugin(i(this, g, le)).createTable(i(this, g, We)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
7221
7226
  } catch (e) {
7222
7227
  if (!await v(this, g, Be).call(this, i(this, g, We)))
7223
7228
  throw e;
7224
7229
  }
7225
7230
  }, Xn = async function() {
7226
- if (!await v(this, g, Sa).call(this))
7231
+ if (!await v(this, g, Oa).call(this))
7227
7232
  try {
7228
- await i(this, I).db.withPlugin(i(this, g, le)).insertInto(i(this, g, We)).values({ id: sa, is_locked: 0 }).execute();
7233
+ await i(this, I).db.withPlugin(i(this, g, le)).insertInto(i(this, g, We)).values({ id: ia, is_locked: 0 }).execute();
7229
7234
  } catch (e) {
7230
- if (!await v(this, g, Sa).call(this))
7235
+ if (!await v(this, g, Oa).call(this))
7231
7236
  throw e;
7232
7237
  }
7233
- }, Ta = async function() {
7238
+ }, Sa = async function() {
7234
7239
  return (await i(this, I).db.introspection.getSchemas()).some((a) => a.name === i(this, g, ie));
7235
7240
  }, Be = async function(e) {
7236
7241
  const a = i(this, g, ie);
7237
7242
  return (await i(this, I).db.introspection.getTables({
7238
7243
  withInternalKyselyTables: !0
7239
7244
  })).some((r) => r.name === e && (!a || r.schema === a));
7240
- }, Sa = async function() {
7241
- return !!await i(this, I).db.withPlugin(i(this, g, le)).selectFrom(i(this, g, We)).where("id", "=", sa).select("id").executeTakeFirst();
7245
+ }, Oa = async function() {
7246
+ return !!await i(this, I).db.withPlugin(i(this, g, le)).selectFrom(i(this, g, We)).where("id", "=", ia).select("id").executeTakeFirst();
7242
7247
  }, Zn = async function(e) {
7243
7248
  const a = i(this, I).db.getExecutor().adapter, n = c({
7244
7249
  lockTable: i(this, I).migrationLockTableName ?? un,
7245
- lockRowId: sa,
7250
+ lockRowId: ia,
7246
7251
  lockTableSchema: i(this, I).migrationTableSchema
7247
7252
  }), r = async (o) => {
7248
7253
  try {
@@ -7258,7 +7263,7 @@ I = new WeakMap(), g = new WeakSet(), _t = async function(e) {
7258
7263
  };
7259
7264
  return a.supportsTransactionalDdl ? i(this, I).db.transaction().execute(r) : i(this, I).db.connection().execute(r);
7260
7265
  }, er = async function(e) {
7261
- const a = await v(this, g, Oa).call(this), n = await v(this, g, ar).call(this, e);
7266
+ const a = await v(this, g, ba).call(this), n = await v(this, g, ar).call(this, e);
7262
7267
  v(this, g, nr).call(this, a, n), i(this, g, Qn) || v(this, g, rr).call(this, a, n);
7263
7268
  const r = v(this, g, tr).call(this, a, n);
7264
7269
  return c({
@@ -7269,7 +7274,7 @@ I = new WeakMap(), g = new WeakSet(), _t = async function(e) {
7269
7274
  });
7270
7275
  }, tr = function(e, a) {
7271
7276
  return e.filter((n) => !a.includes(n.name));
7272
- }, Oa = async function() {
7277
+ }, ba = async function() {
7273
7278
  const e = await i(this, I).provider.getMigrations();
7274
7279
  return Object.keys(e).sort().map((a) => ({
7275
7280
  ...e[a],
@@ -7305,7 +7310,7 @@ I = new WeakMap(), g = new WeakSet(), _t = async function(e) {
7305
7310
  migrationName: l.name,
7306
7311
  direction: "Down",
7307
7312
  status: "Error"
7308
- }, new ia({
7313
+ }, new ca({
7309
7314
  error: u,
7310
7315
  results: o
7311
7316
  });
@@ -7334,28 +7339,28 @@ I = new WeakMap(), g = new WeakSet(), _t = async function(e) {
7334
7339
  migrationName: l.name,
7335
7340
  direction: "Up",
7336
7341
  status: "Error"
7337
- }, new ia({
7342
+ }, new ca({
7338
7343
  error: u,
7339
7344
  results: o
7340
7345
  });
7341
7346
  }
7342
7347
  }
7343
7348
  return { results: o };
7344
- }, mt = async function(e) {
7349
+ }, ht = async function(e) {
7345
7350
  i(this, I).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
7346
7351
  };
7347
- var bt;
7348
- class ia extends Error {
7352
+ var kt;
7353
+ class ca extends Error {
7349
7354
  constructor(a) {
7350
7355
  super();
7351
- x(this, bt);
7352
- S(this, bt, a);
7356
+ x(this, kt);
7357
+ S(this, kt, a);
7353
7358
  }
7354
7359
  get resultSet() {
7355
- return i(this, bt);
7360
+ return i(this, kt);
7356
7361
  }
7357
7362
  }
7358
- bt = new WeakMap();
7363
+ kt = new WeakMap();
7359
7364
  function al(t) {
7360
7365
  return async (e, a) => {
7361
7366
  let n = t.selectFrom("organizations").selectAll().where("tenant_id", "=", e);
@@ -7418,7 +7423,7 @@ function rl(t) {
7418
7423
  ...u,
7419
7424
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
7420
7425
  };
7421
- return kt(
7426
+ return Et(
7422
7427
  n,
7423
7428
  ["branding", "metadata", "enabled_connections", "token_quota"],
7424
7429
  _
@@ -7576,7 +7581,7 @@ function _l(t) {
7576
7581
  }
7577
7582
  function ml(t) {
7578
7583
  return async (e, a) => {
7579
- const n = xo(), r = (/* @__PURE__ */ new Date()).toISOString(), o = a.ttl_sec || 604800, s = new Date(Date.now() + o * 1e3).toISOString(), l = kt(
7584
+ const n = xo(), r = (/* @__PURE__ */ new Date()).toISOString(), o = a.ttl_sec || 604800, s = new Date(Date.now() + o * 1e3).toISOString(), l = Et(
7580
7585
  {
7581
7586
  id: n,
7582
7587
  tenant_id: e,
@@ -10211,7 +10216,7 @@ async function $p(t) {
10211
10216
  return "sqlite";
10212
10217
  }
10213
10218
  }
10214
- async function ca(t, e, a, n) {
10219
+ async function la(t, e, a, n) {
10215
10220
  try {
10216
10221
  await t.schema.alterTable(e).addColumn(a, w.raw(n)).execute();
10217
10222
  } catch (r) {
@@ -10226,7 +10231,7 @@ async function ca(t, e, a, n) {
10226
10231
  }
10227
10232
  async function Ap(t) {
10228
10233
  const e = await $p(t);
10229
- await ca(t, "hooks", "template_id", "text"), await ca(t, "hooks", "created_at_ts", "bigint"), await ca(t, "hooks", "updated_at_ts", "bigint"), e === "mysql" ? await w`
10234
+ await la(t, "hooks", "template_id", "text"), await la(t, "hooks", "created_at_ts", "bigint"), await la(t, "hooks", "updated_at_ts", "bigint"), e === "mysql" ? await w`
10230
10235
  UPDATE hooks
10231
10236
  SET created_at_ts = UNIX_TIMESTAMP(created_at) * 1000,
10232
10237
  updated_at_ts = UNIX_TIMESTAMP(updated_at) * 1000
@@ -10238,7 +10243,7 @@ async function Ap(t) {
10238
10243
  WHERE created_at_ts IS NULL AND created_at IS NOT NULL
10239
10244
  `.execute(t), e === "mysql" && (await t.schema.alterTable("hooks").modifyColumn("created_at", "varchar(255)").execute(), await t.schema.alterTable("hooks").modifyColumn("updated_at", "varchar(255)").execute());
10240
10245
  }
10241
- async function la(t, e, a) {
10246
+ async function ua(t, e, a) {
10242
10247
  try {
10243
10248
  await t.schema.alterTable(e).dropColumn(a).execute();
10244
10249
  } catch (n) {
@@ -10248,7 +10253,7 @@ async function la(t, e, a) {
10248
10253
  }
10249
10254
  }
10250
10255
  async function Dp(t) {
10251
- await la(t, "hooks", "template_id"), await la(t, "hooks", "created_at_ts"), await la(t, "hooks", "updated_at_ts");
10256
+ await ua(t, "hooks", "template_id"), await ua(t, "hooks", "created_at_ts"), await ua(t, "hooks", "updated_at_ts");
10252
10257
  }
10253
10258
  const Pp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10254
10259
  __proto__: null,
@@ -10381,6 +10386,17 @@ const jp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10381
10386
  __proto__: null,
10382
10387
  down: Mp,
10383
10388
  up: Lp
10389
+ }, Symbol.toStringTag, { value: "Module" }));
10390
+ async function Jp(t) {
10391
+ await t.schema.alterTable("refresh_tokens").addColumn("login_id", "varchar(26)").execute(), await t.schema.createIndex("idx_refresh_tokens_login_id").on("refresh_tokens").column("login_id").execute();
10392
+ }
10393
+ async function qp(t) {
10394
+ await t.schema.dropIndex("idx_refresh_tokens_login_id").execute(), await t.schema.alterTable("refresh_tokens").dropColumn("login_id").execute();
10395
+ }
10396
+ const Wp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10397
+ __proto__: null,
10398
+ down: qp,
10399
+ up: Jp
10384
10400
  }, Symbol.toStringTag, { value: "Module" })), dr = {
10385
10401
  m1_init: Tl,
10386
10402
  m2_magicLink: bl,
@@ -10511,9 +10527,10 @@ const jp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10511
10527
  o029_guardian_mfa: Ip,
10512
10528
  o030_add_template_id_to_hooks: Pp,
10513
10529
  o031_hooks_cleanup: Fp,
10514
- o032_unique_username_provider: jp
10530
+ o032_unique_username_provider: jp,
10531
+ o033_add_login_id_to_refresh_tokens: Wp
10515
10532
  };
10516
- async function Bp(t, e = !1) {
10533
+ async function Qp(t, e = !1) {
10517
10534
  e && console.log("migrating...");
10518
10535
  const a = new ir(dr), n = new Kn({
10519
10536
  db: t,
@@ -10526,7 +10543,7 @@ async function Bp(t, e = !1) {
10526
10543
  }), r)
10527
10544
  throw console.error("failed to migrate"), console.error(r), r;
10528
10545
  }
10529
- async function Up(t) {
10546
+ async function Vp(t) {
10530
10547
  console.log("migrating...");
10531
10548
  const e = new ir(dr), a = new Kn({
10532
10549
  db: t,
@@ -10537,7 +10554,7 @@ async function Up(t) {
10537
10554
  }), n)
10538
10555
  throw console.error("failed to migrate"), console.error(n), n;
10539
10556
  }
10540
- function Kp(t, e = { useTransactions: !0 }) {
10557
+ function Gp(t, e = { useTransactions: !0 }) {
10541
10558
  return {
10542
10559
  branding: ls(t),
10543
10560
  clients: Fo(t),
@@ -10575,7 +10592,7 @@ function Kp(t, e = { useTransactions: !0 }) {
10575
10592
  };
10576
10593
  }
10577
10594
  export {
10578
- Kp as default,
10579
- Up as migrateDown,
10580
- Bp as migrateToLatest
10595
+ Gp as default,
10596
+ Vp as migrateDown,
10597
+ Qp as migrateToLatest
10581
10598
  };