@authhero/drizzle 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  var wr = Object.defineProperty;
2
2
  var Nr = (n, i, e) => i in n ? wr(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var h = (n, i, e) => Nr(n, typeof i != "symbol" ? i + "" : i, e);
3
+ var p = (n, i, e) => Nr(n, typeof i != "symbol" ? i + "" : i, e);
4
4
  const v = Symbol.for("drizzle:entityKind");
5
5
  function X(n, i) {
6
6
  if (!n || typeof n != "object")
@@ -24,23 +24,23 @@ var Mt;
24
24
  Mt = v;
25
25
  class Qe {
26
26
  constructor(i, e) {
27
- h(this, "name");
28
- h(this, "keyAsName");
29
- h(this, "primary");
30
- h(this, "notNull");
31
- h(this, "default");
32
- h(this, "defaultFn");
33
- h(this, "onUpdateFn");
34
- h(this, "hasDefault");
35
- h(this, "isUnique");
36
- h(this, "uniqueName");
37
- h(this, "uniqueType");
38
- h(this, "dataType");
39
- h(this, "columnType");
40
- h(this, "enumValues");
41
- h(this, "generated");
42
- h(this, "generatedIdentity");
43
- h(this, "config");
27
+ p(this, "name");
28
+ p(this, "keyAsName");
29
+ p(this, "primary");
30
+ p(this, "notNull");
31
+ p(this, "default");
32
+ p(this, "defaultFn");
33
+ p(this, "onUpdateFn");
34
+ p(this, "hasDefault");
35
+ p(this, "isUnique");
36
+ p(this, "uniqueName");
37
+ p(this, "uniqueType");
38
+ p(this, "dataType");
39
+ p(this, "columnType");
40
+ p(this, "enumValues");
41
+ p(this, "generated");
42
+ p(this, "generatedIdentity");
43
+ p(this, "config");
44
44
  this.table = i, this.config = e, this.name = e.name, this.keyAsName = e.keyAsName, this.notNull = e.notNull, this.default = e.default, this.defaultFn = e.defaultFn, this.onUpdateFn = e.onUpdateFn, this.hasDefault = e.hasDefault, this.primary = e.primaryKey, this.isUnique = e.isUnique, this.uniqueName = e.uniqueName, this.uniqueType = e.uniqueType, this.dataType = e.dataType, this.columnType = e.columnType, this.generated = e.generated, this.generatedIdentity = e.generatedIdentity;
45
45
  }
46
46
  mapFromDriverValue(i) {
@@ -54,20 +54,20 @@ class Qe {
54
54
  return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
55
55
  }
56
56
  }
57
- h(Qe, Mt, "Column");
57
+ p(Qe, Mt, "Column");
58
58
  var Vt;
59
59
  Vt = v;
60
60
  class qi {
61
61
  constructor(i, e, t) {
62
- h(this, "config");
62
+ p(this, "config");
63
63
  /**
64
64
  * Alias for {@link $defaultFn}.
65
65
  */
66
- h(this, "$default", this.$defaultFn);
66
+ p(this, "$default", this.$defaultFn);
67
67
  /**
68
68
  * Alias for {@link $onUpdateFn}.
69
69
  */
70
- h(this, "$onUpdate", this.$onUpdateFn);
70
+ p(this, "$onUpdate", this.$onUpdateFn);
71
71
  this.config = {
72
72
  name: i,
73
73
  keyAsName: i === "",
@@ -147,7 +147,7 @@ class qi {
147
147
  this.config.name === "" && (this.config.name = i);
148
148
  }
149
149
  }
150
- h(qi, Vt, "ColumnBuilder");
150
+ p(qi, Vt, "ColumnBuilder");
151
151
  const ze = Symbol.for("drizzle:Name"), Tt = Symbol.for("drizzle:isPgEnum");
152
152
  function vr(n) {
153
153
  return !!n && typeof n == "function" && Tt in n && n[Tt] === !0;
@@ -169,55 +169,55 @@ class bt {
169
169
  // return new SQL([this]);
170
170
  // }
171
171
  }
172
- h(bt, Rt, "Subquery");
172
+ p(bt, Rt, "Subquery");
173
173
  const Sr = {
174
174
  startActiveSpan(n, i) {
175
175
  return i();
176
176
  }
177
- }, Ce = Symbol.for("drizzle:ViewBaseConfig"), Ze = Symbol.for("drizzle:Schema"), qt = Symbol.for("drizzle:Columns"), Lt = Symbol.for("drizzle:ExtraConfigColumns"), et = Symbol.for("drizzle:OriginalName"), tt = Symbol.for("drizzle:BaseName"), Re = Symbol.for("drizzle:IsAlias"), Et = Symbol.for("drizzle:ExtraConfigBuilder"), xr = Symbol.for("drizzle:IsDrizzleTable");
177
+ }, Ce = Symbol.for("drizzle:ViewBaseConfig"), Xe = Symbol.for("drizzle:Schema"), qt = Symbol.for("drizzle:Columns"), Lt = Symbol.for("drizzle:ExtraConfigColumns"), Ze = Symbol.for("drizzle:OriginalName"), et = Symbol.for("drizzle:BaseName"), Ve = Symbol.for("drizzle:IsAlias"), Et = Symbol.for("drizzle:ExtraConfigBuilder"), xr = Symbol.for("drizzle:IsDrizzleTable");
178
178
  var Wt, Ht, Gt, Yt, Xt, Zt, en, tn, nn, rn;
179
- rn = v, nn = ze, tn = et, en = Ze, Zt = qt, Xt = Lt, Yt = tt, Gt = Re, Ht = xr, Wt = Et;
179
+ rn = v, nn = ze, tn = Ze, en = Xe, Zt = qt, Xt = Lt, Yt = et, Gt = Ve, Ht = xr, Wt = Et;
180
180
  class M {
181
181
  constructor(i, e, t) {
182
182
  /**
183
183
  * @internal
184
184
  * Can be changed if the table is aliased.
185
185
  */
186
- h(this, nn);
186
+ p(this, nn);
187
187
  /**
188
188
  * @internal
189
189
  * Used to store the original name of the table, before any aliasing.
190
190
  */
191
- h(this, tn);
191
+ p(this, tn);
192
192
  /** @internal */
193
- h(this, en);
193
+ p(this, en);
194
194
  /** @internal */
195
- h(this, Zt);
195
+ p(this, Zt);
196
196
  /** @internal */
197
- h(this, Xt);
197
+ p(this, Xt);
198
198
  /**
199
199
  * @internal
200
200
  * Used to store the table name before the transformation via the `tableCreator` functions.
201
201
  */
202
- h(this, Yt);
202
+ p(this, Yt);
203
203
  /** @internal */
204
- h(this, Gt, !1);
204
+ p(this, Gt, !1);
205
205
  /** @internal */
206
- h(this, Ht, !0);
206
+ p(this, Ht, !0);
207
207
  /** @internal */
208
- h(this, Wt);
209
- this[ze] = this[et] = i, this[Ze] = e, this[tt] = t;
208
+ p(this, Wt);
209
+ this[ze] = this[Ze] = i, this[Xe] = e, this[et] = t;
210
210
  }
211
211
  }
212
- h(M, rn, "Table"), /** @internal */
213
- h(M, "Symbol", {
212
+ p(M, rn, "Table"), /** @internal */
213
+ p(M, "Symbol", {
214
214
  Name: ze,
215
- Schema: Ze,
216
- OriginalName: et,
215
+ Schema: Xe,
216
+ OriginalName: Ze,
217
217
  Columns: qt,
218
218
  ExtraConfigColumns: Lt,
219
- BaseName: tt,
220
- IsAlias: Re,
219
+ BaseName: et,
220
+ IsAlias: Ve,
221
221
  ExtraConfigBuilder: Et
222
222
  });
223
223
  function Li(n) {
@@ -234,23 +234,23 @@ var sn;
234
234
  sn = v;
235
235
  class Z {
236
236
  constructor(i) {
237
- h(this, "value");
237
+ p(this, "value");
238
238
  this.value = Array.isArray(i) ? i : [i];
239
239
  }
240
240
  getSQL() {
241
- return new J([this]);
241
+ return new P([this]);
242
242
  }
243
243
  }
244
- h(Z, sn, "StringChunk");
244
+ p(Z, sn, "StringChunk");
245
245
  var on;
246
246
  on = v;
247
247
  const De = class De {
248
248
  constructor(i) {
249
249
  /** @internal */
250
- h(this, "decoder", Ei);
251
- h(this, "shouldInlineParams", !1);
250
+ p(this, "decoder", Ei);
251
+ p(this, "shouldInlineParams", !1);
252
252
  /** @internal */
253
- h(this, "usedTables", []);
253
+ p(this, "usedTables", []);
254
254
  this.queryChunks = i;
255
255
  for (const e of i)
256
256
  if (X(e, M)) {
@@ -285,10 +285,10 @@ const De = class De {
285
285
  paramStartIndex: c
286
286
  } = t;
287
287
  return br(i.map((d) => {
288
- var m;
288
+ var h;
289
289
  if (X(d, Z))
290
290
  return { sql: d.value.join(""), params: [] };
291
- if (X(d, We))
291
+ if (X(d, Re))
292
292
  return { sql: o(d.value), params: [] };
293
293
  if (d === void 0)
294
294
  return { sql: "", params: [] };
@@ -306,7 +306,7 @@ const De = class De {
306
306
  if (X(d, M)) {
307
307
  const f = d[M.Symbol.Schema], y = d[M.Symbol.Name];
308
308
  return {
309
- sql: f === void 0 || d[Re] ? o(y) : o(f) + "." + o(y),
309
+ sql: f === void 0 || d[Ve] ? o(y) : o(f) + "." + o(y),
310
310
  params: []
311
311
  };
312
312
  }
@@ -316,7 +316,7 @@ const De = class De {
316
316
  return { sql: o(f), params: [] };
317
317
  const y = d.table[M.Symbol.Schema];
318
318
  return {
319
- sql: d.table[Re] || y === void 0 ? o(d.table[M.Symbol.Name]) + "." + o(f) : o(y) + "." + o(d.table[M.Symbol.Name]) + "." + o(f),
319
+ sql: d.table[Ve] || y === void 0 ? o(d.table[M.Symbol.Name]) + "." + o(f) : o(y) + "." + o(d.table[M.Symbol.Name]) + "." + o(f),
320
320
  params: []
321
321
  };
322
322
  }
@@ -342,8 +342,8 @@ const De = class De {
342
342
  new Z("("),
343
343
  d._.sql,
344
344
  new Z(") "),
345
- new We(d._.alias)
346
- ], t) : vr(d) ? d.schema ? { sql: o(d.schema) + "." + o(d.enumName), params: [] } : { sql: o(d.enumName), params: [] } : Li(d) ? (m = d.shouldOmitSQLParens) != null && m.call(d) ? this.buildQueryFromSourceParams([d.getSQL()], t) : this.buildQueryFromSourceParams([
345
+ new Re(d._.alias)
346
+ ], t) : vr(d) ? d.schema ? { sql: o(d.schema) + "." + o(d.enumName), params: [] } : { sql: o(d.enumName), params: [] } : Li(d) ? (h = d.shouldOmitSQLParens) != null && h.call(d) ? this.buildQueryFromSourceParams([d.getSQL()], t) : this.buildQueryFromSourceParams([
347
347
  new Z("("),
348
348
  d.getSQL(),
349
349
  new Z(")")
@@ -385,20 +385,20 @@ const De = class De {
385
385
  return i ? this : void 0;
386
386
  }
387
387
  };
388
- h(De, on, "SQL");
389
- let J = De;
388
+ p(De, on, "SQL");
389
+ let P = De;
390
390
  var an;
391
391
  an = v;
392
- class We {
392
+ class Re {
393
393
  constructor(i) {
394
- h(this, "brand");
394
+ p(this, "brand");
395
395
  this.value = i;
396
396
  }
397
397
  getSQL() {
398
- return new J([this]);
398
+ return new P([this]);
399
399
  }
400
400
  }
401
- h(We, an, "Name");
401
+ p(Re, an, "Name");
402
402
  function Dr(n) {
403
403
  return typeof n == "object" && n !== null && "mapToDriverValue" in n && typeof n.mapToDriverValue == "function";
404
404
  }
@@ -419,43 +419,43 @@ class Ae {
419
419
  * @param encoder - Encoder to convert the value to a driver parameter
420
420
  */
421
421
  constructor(i, e = Ci) {
422
- h(this, "brand");
422
+ p(this, "brand");
423
423
  this.value = i, this.encoder = e;
424
424
  }
425
425
  getSQL() {
426
- return new J([this]);
426
+ return new P([this]);
427
427
  }
428
428
  }
429
- h(Ae, ln, "Param");
429
+ p(Ae, ln, "Param");
430
430
  function w(n, ...i) {
431
431
  const e = [];
432
432
  (i.length > 0 || n.length > 0 && n[0] !== "") && e.push(new Z(n[0]));
433
433
  for (const [t, r] of i.entries())
434
434
  e.push(r, new Z(n[t + 1]));
435
- return new J(e);
435
+ return new P(e);
436
436
  }
437
437
  ((n) => {
438
438
  function i() {
439
- return new J([]);
439
+ return new P([]);
440
440
  }
441
441
  n.empty = i;
442
442
  function e(u) {
443
- return new J(u);
443
+ return new P(u);
444
444
  }
445
445
  n.fromList = e;
446
446
  function t(u) {
447
- return new J([new Z(u)]);
447
+ return new P([new Z(u)]);
448
448
  }
449
449
  n.raw = t;
450
450
  function r(u, c) {
451
451
  const d = [];
452
- for (const [m, f] of u.entries())
453
- m > 0 && c !== void 0 && d.push(c), d.push(f);
454
- return new J(d);
452
+ for (const [h, f] of u.entries())
453
+ h > 0 && c !== void 0 && d.push(c), d.push(f);
454
+ return new P(d);
455
455
  }
456
456
  n.join = r;
457
457
  function o(u) {
458
- return new We(u);
458
+ return new Re(u);
459
459
  }
460
460
  n.identifier = o;
461
461
  function l(u) {
@@ -473,7 +473,7 @@ function w(n, ...i) {
473
473
  const t = class t {
474
474
  constructor(o, l) {
475
475
  /** @internal */
476
- h(this, "isSelectionField", !1);
476
+ p(this, "isSelectionField", !1);
477
477
  this.sql = o, this.fieldAlias = l;
478
478
  }
479
479
  getSQL() {
@@ -484,10 +484,10 @@ function w(n, ...i) {
484
484
  return new t(this.sql, this.fieldAlias);
485
485
  }
486
486
  };
487
- h(t, e, "SQL.Aliased");
487
+ p(t, e, "SQL.Aliased");
488
488
  let i = t;
489
489
  n.Aliased = i;
490
- })(J || (J = {}));
490
+ })(P || (P = {}));
491
491
  var _n;
492
492
  _n = v;
493
493
  class Be {
@@ -495,19 +495,19 @@ class Be {
495
495
  this.name = i;
496
496
  }
497
497
  getSQL() {
498
- return new J([this]);
498
+ return new P([this]);
499
499
  }
500
500
  }
501
- h(Be, _n, "Placeholder");
501
+ p(Be, _n, "Placeholder");
502
502
  const Or = Symbol.for("drizzle:IsDrizzleView");
503
503
  var un, dn, cn;
504
504
  cn = v, dn = Ce, un = Or;
505
505
  class Dt {
506
506
  constructor({ name: i, schema: e, selectedFields: t, query: r }) {
507
507
  /** @internal */
508
- h(this, dn);
508
+ p(this, dn);
509
509
  /** @internal */
510
- h(this, un, !0);
510
+ p(this, un, !0);
511
511
  this[Ce] = {
512
512
  name: i,
513
513
  originalName: i,
@@ -519,18 +519,18 @@ class Dt {
519
519
  };
520
520
  }
521
521
  getSQL() {
522
- return new J([this]);
522
+ return new P([this]);
523
523
  }
524
524
  }
525
- h(Dt, cn, "View");
525
+ p(Dt, cn, "View");
526
526
  Qe.prototype.getSQL = function() {
527
- return new J([this]);
527
+ return new P([this]);
528
528
  };
529
529
  M.prototype.getSQL = function() {
530
- return new J([this]);
530
+ return new P([this]);
531
531
  };
532
532
  bt.prototype.getSQL = function() {
533
- return new J([this]);
533
+ return new P([this]);
534
534
  };
535
535
  function Je(n, i) {
536
536
  return {
@@ -548,7 +548,7 @@ function g(...n) {
548
548
  (e) => e !== void 0
549
549
  );
550
550
  if (i.length !== 0)
551
- return i.length === 1 ? new J(i) : new J([
551
+ return i.length === 1 ? new P(i) : new P([
552
552
  new Z("("),
553
553
  w.join(i, new Z(" and ")),
554
554
  new Z(")")
@@ -559,20 +559,20 @@ function de(...n) {
559
559
  (e) => e !== void 0
560
560
  );
561
561
  if (i.length !== 0)
562
- return i.length === 1 ? new J(i) : new J([
562
+ return i.length === 1 ? new P(i) : new P([
563
563
  new Z("("),
564
564
  w.join(i, new Z(" or ")),
565
565
  new Z(")")
566
566
  ]);
567
567
  }
568
- const He = (n, i) => w`${n} > ${xe(i, n)}`, Ge = (n, i) => w`${n} >= ${xe(i, n)}`, we = (n, i) => w`${n} < ${xe(i, n)}`, Oe = (n, i) => w`${n} <= ${xe(i, n)}`;
568
+ const We = (n, i) => w`${n} > ${xe(i, n)}`, He = (n, i) => w`${n} >= ${xe(i, n)}`, we = (n, i) => w`${n} < ${xe(i, n)}`, Oe = (n, i) => w`${n} <= ${xe(i, n)}`;
569
569
  function Ne(n, i) {
570
570
  return Array.isArray(i) ? i.length === 0 ? w`false` : w`${n} in ${i.map((e) => xe(e, n))}` : w`${n} in ${xe(i, n)}`;
571
571
  }
572
572
  function ye(n) {
573
573
  return w`${n} is null`;
574
574
  }
575
- function Ve(n) {
575
+ function Me(n) {
576
576
  return w`${n} is not null`;
577
577
  }
578
578
  function Ie(n, i) {
@@ -606,11 +606,11 @@ gn = v;
606
606
  class Bi {
607
607
  constructor(i, e) {
608
608
  /** @internal */
609
- h(this, "reference");
609
+ p(this, "reference");
610
610
  /** @internal */
611
- h(this, "_onUpdate");
611
+ p(this, "_onUpdate");
612
612
  /** @internal */
613
- h(this, "_onDelete");
613
+ p(this, "_onDelete");
614
614
  this.reference = () => {
615
615
  const { name: t, columns: r, foreignColumns: o } = i();
616
616
  return { name: t, columns: r, foreignTable: o[0].table, foreignColumns: o };
@@ -627,14 +627,14 @@ class Bi {
627
627
  return new $i(i, this);
628
628
  }
629
629
  }
630
- h(Bi, gn, "SQLiteForeignKeyBuilder");
630
+ p(Bi, gn, "SQLiteForeignKeyBuilder");
631
631
  var fn;
632
632
  fn = v;
633
633
  class $i {
634
634
  constructor(i, e) {
635
- h(this, "reference");
636
- h(this, "onUpdate");
637
- h(this, "onDelete");
635
+ p(this, "reference");
636
+ p(this, "onUpdate");
637
+ p(this, "onDelete");
638
638
  this.table = i, this.reference = e.reference, this.onUpdate = e._onUpdate, this.onDelete = e._onDelete;
639
639
  }
640
640
  getName() {
@@ -647,15 +647,15 @@ class $i {
647
647
  return i ?? `${l.join("_")}_fk`;
648
648
  }
649
649
  }
650
- h($i, fn, "SQLiteForeignKey");
650
+ p($i, fn, "SQLiteForeignKey");
651
651
  function zr(n, i) {
652
652
  return `${n[ze]}_${i.join("_")}_unique`;
653
653
  }
654
- var hn, mn;
655
- class ce extends (mn = qi, hn = v, mn) {
654
+ var pn, hn;
655
+ class ce extends (hn = qi, pn = v, hn) {
656
656
  constructor() {
657
657
  super(...arguments);
658
- h(this, "foreignKeyConfigs", []);
658
+ p(this, "foreignKeyConfigs", []);
659
659
  }
660
660
  references(e, t = {}) {
661
661
  return this.foreignKeyConfigs.push({ ref: e, actions: t }), this;
@@ -681,27 +681,27 @@ class ce extends (mn = qi, hn = v, mn) {
681
681
  })(r, o));
682
682
  }
683
683
  }
684
- h(ce, hn, "SQLiteColumnBuilder");
685
- var pn, yn;
686
- class ge extends (yn = Qe, pn = v, yn) {
684
+ p(ce, pn, "SQLiteColumnBuilder");
685
+ var mn, yn;
686
+ class ge extends (yn = Qe, mn = v, yn) {
687
687
  constructor(i, e) {
688
688
  e.uniqueName || (e.uniqueName = zr(i, [e.name])), super(i, e), this.table = i;
689
689
  }
690
690
  }
691
- h(ge, pn, "SQLiteColumn");
691
+ p(ge, mn, "SQLiteColumn");
692
692
  var wn, Nn;
693
- class Pi extends (Nn = ce, wn = v, Nn) {
693
+ class Qi extends (Nn = ce, wn = v, Nn) {
694
694
  constructor(i) {
695
695
  super(i, "bigint", "SQLiteBigInt");
696
696
  }
697
697
  /** @internal */
698
698
  build(i) {
699
- return new Qi(i, this.config);
699
+ return new Ji(i, this.config);
700
700
  }
701
701
  }
702
- h(Pi, wn, "SQLiteBigIntBuilder");
702
+ p(Qi, wn, "SQLiteBigIntBuilder");
703
703
  var vn, Sn;
704
- class Qi extends (Sn = ge, vn = v, Sn) {
704
+ class Ji extends (Sn = ge, vn = v, Sn) {
705
705
  getSQLType() {
706
706
  return "blob";
707
707
  }
@@ -716,9 +716,9 @@ class Qi extends (Sn = ge, vn = v, Sn) {
716
716
  return Buffer.from(i.toString());
717
717
  }
718
718
  }
719
- h(Qi, vn, "SQLiteBigInt");
719
+ p(Ji, vn, "SQLiteBigInt");
720
720
  var xn, bn;
721
- class Ji extends (bn = ce, xn = v, bn) {
721
+ class Pi extends (bn = ce, xn = v, bn) {
722
722
  constructor(i) {
723
723
  super(i, "json", "SQLiteBlobJson");
724
724
  }
@@ -730,7 +730,7 @@ class Ji extends (bn = ce, xn = v, bn) {
730
730
  );
731
731
  }
732
732
  }
733
- h(Ji, xn, "SQLiteBlobJsonBuilder");
733
+ p(Pi, xn, "SQLiteBlobJsonBuilder");
734
734
  var Dn, On;
735
735
  class Fi extends (On = ge, Dn = v, On) {
736
736
  getSQLType() {
@@ -747,7 +747,7 @@ class Fi extends (On = ge, Dn = v, On) {
747
747
  return Buffer.from(JSON.stringify(i));
748
748
  }
749
749
  }
750
- h(Fi, Dn, "SQLiteBlobJson");
750
+ p(Fi, Dn, "SQLiteBlobJson");
751
751
  var kn, In;
752
752
  class Ui extends (In = ce, kn = v, In) {
753
753
  constructor(i) {
@@ -758,7 +758,7 @@ class Ui extends (In = ce, kn = v, In) {
758
758
  return new Ki(i, this.config);
759
759
  }
760
760
  }
761
- h(Ui, kn, "SQLiteBlobBufferBuilder");
761
+ p(Ui, kn, "SQLiteBlobBufferBuilder");
762
762
  var zn, Tn;
763
763
  class Ki extends (Tn = ge, zn = v, Tn) {
764
764
  mapFromDriverValue(i) {
@@ -768,10 +768,10 @@ class Ki extends (Tn = ge, zn = v, Tn) {
768
768
  return "blob";
769
769
  }
770
770
  }
771
- h(Ki, zn, "SQLiteBlobBuffer");
771
+ p(Ki, zn, "SQLiteBlobBuffer");
772
772
  function Tr(n, i) {
773
773
  const { name: e, config: t } = Je(n, i);
774
- return (t == null ? void 0 : t.mode) === "json" ? new Ji(e) : (t == null ? void 0 : t.mode) === "bigint" ? new Pi(e) : new Ui(e);
774
+ return (t == null ? void 0 : t.mode) === "json" ? new Pi(e) : (t == null ? void 0 : t.mode) === "bigint" ? new Qi(e) : new Ui(e);
775
775
  }
776
776
  var qn, Ln;
777
777
  class ji extends (Ln = ce, qn = v, Ln) {
@@ -786,14 +786,14 @@ class ji extends (Ln = ce, qn = v, Ln) {
786
786
  );
787
787
  }
788
788
  }
789
- h(ji, qn, "SQLiteCustomColumnBuilder");
789
+ p(ji, qn, "SQLiteCustomColumnBuilder");
790
790
  var En, Cn;
791
791
  class Mi extends (Cn = ge, En = v, Cn) {
792
792
  constructor(e, t) {
793
793
  super(e, t);
794
- h(this, "sqlName");
795
- h(this, "mapTo");
796
- h(this, "mapFrom");
794
+ p(this, "sqlName");
795
+ p(this, "mapTo");
796
+ p(this, "mapFrom");
797
797
  this.sqlName = t.customTypeParams.dataType(t.fieldConfig), this.mapTo = t.customTypeParams.toDriver, this.mapFrom = t.customTypeParams.fromDriver;
798
798
  }
799
799
  getSQLType() {
@@ -806,7 +806,7 @@ class Mi extends (Cn = ge, En = v, Cn) {
806
806
  return typeof this.mapTo == "function" ? this.mapTo(e) : e;
807
807
  }
808
808
  }
809
- h(Mi, En, "SQLiteCustomColumn");
809
+ p(Mi, En, "SQLiteCustomColumn");
810
810
  function qr(n) {
811
811
  return (i, e) => {
812
812
  const { name: t, config: r } = Je(i, e);
@@ -818,7 +818,7 @@ function qr(n) {
818
818
  };
819
819
  }
820
820
  var An, Bn;
821
- class Ye extends (Bn = ce, An = v, Bn) {
821
+ class Ge extends (Bn = ce, An = v, Bn) {
822
822
  constructor(i, e, t) {
823
823
  super(i, e, t), this.config.autoIncrement = !1;
824
824
  }
@@ -826,20 +826,20 @@ class Ye extends (Bn = ce, An = v, Bn) {
826
826
  return i != null && i.autoIncrement && (this.config.autoIncrement = !0), this.config.hasDefault = !0, super.primaryKey();
827
827
  }
828
828
  }
829
- h(Ye, An, "SQLiteBaseIntegerBuilder");
830
- var $n, Pn;
831
- class Xe extends (Pn = ge, $n = v, Pn) {
829
+ p(Ge, An, "SQLiteBaseIntegerBuilder");
830
+ var $n, Qn;
831
+ class Ye extends (Qn = ge, $n = v, Qn) {
832
832
  constructor() {
833
833
  super(...arguments);
834
- h(this, "autoIncrement", this.config.autoIncrement);
834
+ p(this, "autoIncrement", this.config.autoIncrement);
835
835
  }
836
836
  getSQLType() {
837
837
  return "integer";
838
838
  }
839
839
  }
840
- h(Xe, $n, "SQLiteBaseInteger");
841
- var Qn, Jn;
842
- class Vi extends (Jn = Ye, Qn = v, Jn) {
840
+ p(Ye, $n, "SQLiteBaseInteger");
841
+ var Jn, Pn;
842
+ class Vi extends (Pn = Ge, Jn = v, Pn) {
843
843
  constructor(i) {
844
844
  super(i, "number", "SQLiteInteger");
845
845
  }
@@ -850,13 +850,13 @@ class Vi extends (Jn = Ye, Qn = v, Jn) {
850
850
  );
851
851
  }
852
852
  }
853
- h(Vi, Qn, "SQLiteIntegerBuilder");
853
+ p(Vi, Jn, "SQLiteIntegerBuilder");
854
854
  var Fn, Un;
855
- class Ri extends (Un = Xe, Fn = v, Un) {
855
+ class Ri extends (Un = Ye, Fn = v, Un) {
856
856
  }
857
- h(Ri, Fn, "SQLiteInteger");
857
+ p(Ri, Fn, "SQLiteInteger");
858
858
  var Kn, jn;
859
- class Wi extends (jn = Ye, Kn = v, jn) {
859
+ class Wi extends (jn = Ge, Kn = v, jn) {
860
860
  constructor(i, e) {
861
861
  super(i, "date", "SQLiteTimestamp"), this.config.mode = e;
862
862
  }
@@ -875,12 +875,12 @@ class Wi extends (jn = Ye, Kn = v, jn) {
875
875
  );
876
876
  }
877
877
  }
878
- h(Wi, Kn, "SQLiteTimestampBuilder");
878
+ p(Wi, Kn, "SQLiteTimestampBuilder");
879
879
  var Mn, Vn;
880
- class Hi extends (Vn = Xe, Mn = v, Vn) {
880
+ class Hi extends (Vn = Ye, Mn = v, Vn) {
881
881
  constructor() {
882
882
  super(...arguments);
883
- h(this, "mode", this.config.mode);
883
+ p(this, "mode", this.config.mode);
884
884
  }
885
885
  mapFromDriverValue(e) {
886
886
  return this.config.mode === "timestamp" ? new Date(e * 1e3) : new Date(e);
@@ -890,9 +890,9 @@ class Hi extends (Vn = Xe, Mn = v, Vn) {
890
890
  return this.config.mode === "timestamp" ? Math.floor(t / 1e3) : t;
891
891
  }
892
892
  }
893
- h(Hi, Mn, "SQLiteTimestamp");
893
+ p(Hi, Mn, "SQLiteTimestamp");
894
894
  var Rn, Wn;
895
- class Gi extends (Wn = Ye, Rn = v, Wn) {
895
+ class Gi extends (Wn = Ge, Rn = v, Wn) {
896
896
  constructor(i, e) {
897
897
  super(i, "boolean", "SQLiteBoolean"), this.config.mode = e;
898
898
  }
@@ -903,12 +903,12 @@ class Gi extends (Wn = Ye, Rn = v, Wn) {
903
903
  );
904
904
  }
905
905
  }
906
- h(Gi, Rn, "SQLiteBooleanBuilder");
906
+ p(Gi, Rn, "SQLiteBooleanBuilder");
907
907
  var Hn, Gn;
908
- class Yi extends (Gn = Xe, Hn = v, Gn) {
908
+ class Yi extends (Gn = Ye, Hn = v, Gn) {
909
909
  constructor() {
910
910
  super(...arguments);
911
- h(this, "mode", this.config.mode);
911
+ p(this, "mode", this.config.mode);
912
912
  }
913
913
  mapFromDriverValue(e) {
914
914
  return Number(e) === 1;
@@ -917,8 +917,8 @@ class Yi extends (Gn = Xe, Hn = v, Gn) {
917
917
  return e ? 1 : 0;
918
918
  }
919
919
  }
920
- h(Yi, Hn, "SQLiteBoolean");
921
- function p(n, i) {
920
+ p(Yi, Hn, "SQLiteBoolean");
921
+ function m(n, i) {
922
922
  const { name: e, config: t } = Je(n, i);
923
923
  return (t == null ? void 0 : t.mode) === "timestamp" || (t == null ? void 0 : t.mode) === "timestamp_ms" ? new Wi(e, t.mode) : (t == null ? void 0 : t.mode) === "boolean" ? new Gi(e, t.mode) : new Vi(e);
924
924
  }
@@ -935,7 +935,7 @@ class Xi extends (Xn = ce, Yn = v, Xn) {
935
935
  );
936
936
  }
937
937
  }
938
- h(Xi, Yn, "SQLiteNumericBuilder");
938
+ p(Xi, Yn, "SQLiteNumericBuilder");
939
939
  var Zn, ei;
940
940
  class Zi extends (ei = ge, Zn = v, ei) {
941
941
  mapFromDriverValue(i) {
@@ -945,7 +945,7 @@ class Zi extends (ei = ge, Zn = v, ei) {
945
945
  return "numeric";
946
946
  }
947
947
  }
948
- h(Zi, Zn, "SQLiteNumeric");
948
+ p(Zi, Zn, "SQLiteNumeric");
949
949
  var ti, ni;
950
950
  class er extends (ni = ce, ti = v, ni) {
951
951
  constructor(i) {
@@ -959,12 +959,12 @@ class er extends (ni = ce, ti = v, ni) {
959
959
  );
960
960
  }
961
961
  }
962
- h(er, ti, "SQLiteNumericNumberBuilder");
962
+ p(er, ti, "SQLiteNumericNumberBuilder");
963
963
  var ii, ri;
964
964
  class tr extends (ri = ge, ii = v, ri) {
965
965
  constructor() {
966
966
  super(...arguments);
967
- h(this, "mapToDriverValue", String);
967
+ p(this, "mapToDriverValue", String);
968
968
  }
969
969
  mapFromDriverValue(e) {
970
970
  return typeof e == "number" ? e : Number(e);
@@ -973,7 +973,7 @@ class tr extends (ri = ge, ii = v, ri) {
973
973
  return "numeric";
974
974
  }
975
975
  }
976
- h(tr, ii, "SQLiteNumericNumber");
976
+ p(tr, ii, "SQLiteNumericNumber");
977
977
  var si, oi;
978
978
  class nr extends (oi = ce, si = v, oi) {
979
979
  constructor(i) {
@@ -987,19 +987,19 @@ class nr extends (oi = ce, si = v, oi) {
987
987
  );
988
988
  }
989
989
  }
990
- h(nr, si, "SQLiteNumericBigIntBuilder");
990
+ p(nr, si, "SQLiteNumericBigIntBuilder");
991
991
  var ai, li;
992
992
  class ir extends (li = ge, ai = v, li) {
993
993
  constructor() {
994
994
  super(...arguments);
995
- h(this, "mapFromDriverValue", BigInt);
996
- h(this, "mapToDriverValue", String);
995
+ p(this, "mapFromDriverValue", BigInt);
996
+ p(this, "mapToDriverValue", String);
997
997
  }
998
998
  getSQLType() {
999
999
  return "numeric";
1000
1000
  }
1001
1001
  }
1002
- h(ir, ai, "SQLiteNumericBigInt");
1002
+ p(ir, ai, "SQLiteNumericBigInt");
1003
1003
  function Lr(n, i) {
1004
1004
  const { name: e, config: t } = Je(n, i), r = t == null ? void 0 : t.mode;
1005
1005
  return r === "number" ? new er(e) : r === "bigint" ? new nr(e) : new Xi(e);
@@ -1014,14 +1014,14 @@ class rr extends (ui = ce, _i = v, ui) {
1014
1014
  return new sr(i, this.config);
1015
1015
  }
1016
1016
  }
1017
- h(rr, _i, "SQLiteRealBuilder");
1017
+ p(rr, _i, "SQLiteRealBuilder");
1018
1018
  var di, ci;
1019
1019
  class sr extends (ci = ge, di = v, ci) {
1020
1020
  getSQLType() {
1021
1021
  return "real";
1022
1022
  }
1023
1023
  }
1024
- h(sr, di, "SQLiteReal");
1024
+ p(sr, di, "SQLiteReal");
1025
1025
  function Er(n) {
1026
1026
  return new rr(n ?? "");
1027
1027
  }
@@ -1038,21 +1038,21 @@ class or extends (fi = ce, gi = v, fi) {
1038
1038
  );
1039
1039
  }
1040
1040
  }
1041
- h(or, gi, "SQLiteTextBuilder");
1042
- var hi, mi;
1043
- class ar extends (mi = ge, hi = v, mi) {
1041
+ p(or, gi, "SQLiteTextBuilder");
1042
+ var pi, hi;
1043
+ class ar extends (hi = ge, pi = v, hi) {
1044
1044
  constructor(e, t) {
1045
1045
  super(e, t);
1046
- h(this, "enumValues", this.config.enumValues);
1047
- h(this, "length", this.config.length);
1046
+ p(this, "enumValues", this.config.enumValues);
1047
+ p(this, "length", this.config.length);
1048
1048
  }
1049
1049
  getSQLType() {
1050
1050
  return `text${this.config.length ? `(${this.config.length})` : ""}`;
1051
1051
  }
1052
1052
  }
1053
- h(ar, hi, "SQLiteText");
1054
- var pi, yi;
1055
- class lr extends (yi = ce, pi = v, yi) {
1053
+ p(ar, pi, "SQLiteText");
1054
+ var mi, yi;
1055
+ class lr extends (yi = ce, mi = v, yi) {
1056
1056
  constructor(i) {
1057
1057
  super(i, "json", "SQLiteTextJson");
1058
1058
  }
@@ -1064,7 +1064,7 @@ class lr extends (yi = ce, pi = v, yi) {
1064
1064
  );
1065
1065
  }
1066
1066
  }
1067
- h(lr, pi, "SQLiteTextJsonBuilder");
1067
+ p(lr, mi, "SQLiteTextJsonBuilder");
1068
1068
  var wi, Ni;
1069
1069
  class _r extends (Ni = ge, wi = v, Ni) {
1070
1070
  getSQLType() {
@@ -1077,7 +1077,7 @@ class _r extends (Ni = ge, wi = v, Ni) {
1077
1077
  return JSON.stringify(i);
1078
1078
  }
1079
1079
  }
1080
- h(_r, wi, "SQLiteTextJson");
1080
+ p(_r, wi, "SQLiteTextJson");
1081
1081
  function s(n, i = {}) {
1082
1082
  const { name: e, config: t } = Je(n, i);
1083
1083
  return t.mode === "json" ? new lr(e) : new or(e, t);
@@ -1086,36 +1086,36 @@ function Cr() {
1086
1086
  return {
1087
1087
  blob: Tr,
1088
1088
  customType: qr,
1089
- integer: p,
1089
+ integer: m,
1090
1090
  numeric: Lr,
1091
1091
  real: Er,
1092
1092
  text: s
1093
1093
  };
1094
1094
  }
1095
- const pt = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1095
+ const ht = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1096
1096
  var vi, Si, xi, bi, Di;
1097
- class $e extends (Di = M, bi = v, xi = M.Symbol.Columns, Si = pt, vi = M.Symbol.ExtraConfigBuilder, Di) {
1097
+ class $e extends (Di = M, bi = v, xi = M.Symbol.Columns, Si = ht, vi = M.Symbol.ExtraConfigBuilder, Di) {
1098
1098
  constructor() {
1099
1099
  super(...arguments);
1100
1100
  /** @internal */
1101
- h(this, xi);
1101
+ p(this, xi);
1102
1102
  /** @internal */
1103
- h(this, Si, []);
1103
+ p(this, Si, []);
1104
1104
  /** @internal */
1105
- h(this, vi);
1105
+ p(this, vi);
1106
1106
  }
1107
1107
  }
1108
- h($e, bi, "SQLiteTable"), /** @internal */
1109
- h($e, "Symbol", Object.assign({}, M.Symbol, {
1110
- InlineForeignKeys: pt
1108
+ p($e, bi, "SQLiteTable"), /** @internal */
1109
+ p($e, "Symbol", Object.assign({}, M.Symbol, {
1110
+ InlineForeignKeys: ht
1111
1111
  }));
1112
1112
  function Ar(n, i, e, t, r = n) {
1113
1113
  const o = new $e(n, t, r), l = typeof i == "function" ? i(Cr()) : i, _ = Object.fromEntries(
1114
1114
  Object.entries(l).map(([c, d]) => {
1115
- const m = d;
1116
- m.setName(c);
1117
- const f = m.build(o);
1118
- return o[pt].push(...m.buildForeignKeys(f, o)), [c, f];
1115
+ const h = d;
1116
+ h.setName(c);
1117
+ const f = h.build(o);
1118
+ return o[ht].push(...h.buildForeignKeys(f, o)), [c, f];
1119
1119
  })
1120
1120
  ), u = Object.assign(o, _);
1121
1121
  return u[M.Symbol.Columns] = _, u[M.Symbol.ExtraConfigColumns] = _, e && (u[$e.Symbol.ExtraConfigBuilder] = e), u;
@@ -1131,13 +1131,13 @@ class Ot {
1131
1131
  return new ur(this.name, i, this.unique);
1132
1132
  }
1133
1133
  }
1134
- h(Ot, Oi, "SQLiteIndexBuilderOn");
1134
+ p(Ot, Oi, "SQLiteIndexBuilderOn");
1135
1135
  var ki;
1136
1136
  ki = v;
1137
1137
  class ur {
1138
1138
  constructor(i, e, t) {
1139
1139
  /** @internal */
1140
- h(this, "config");
1140
+ p(this, "config");
1141
1141
  this.config = {
1142
1142
  name: i,
1143
1143
  columns: e,
@@ -1156,16 +1156,16 @@ class ur {
1156
1156
  return new dr(this.config, i);
1157
1157
  }
1158
1158
  }
1159
- h(ur, ki, "SQLiteIndexBuilder");
1159
+ p(ur, ki, "SQLiteIndexBuilder");
1160
1160
  var Ii;
1161
1161
  Ii = v;
1162
1162
  class dr {
1163
1163
  constructor(i, e) {
1164
- h(this, "config");
1164
+ p(this, "config");
1165
1165
  this.config = { ...i, table: e };
1166
1166
  }
1167
1167
  }
1168
- h(dr, Ii, "SQLiteIndex");
1168
+ p(dr, Ii, "SQLiteIndex");
1169
1169
  function S(n) {
1170
1170
  return new Ot(n, !1);
1171
1171
  }
@@ -1173,16 +1173,16 @@ function Te(n) {
1173
1173
  return new Ot(n, !0);
1174
1174
  }
1175
1175
  function oe(...n) {
1176
- return n[0].columns ? new yt(n[0].columns, n[0].name) : new yt(n);
1176
+ return n[0].columns ? new mt(n[0].columns, n[0].name) : new mt(n);
1177
1177
  }
1178
1178
  var zi;
1179
1179
  zi = v;
1180
- class yt {
1180
+ class mt {
1181
1181
  constructor(i, e) {
1182
1182
  /** @internal */
1183
- h(this, "columns");
1183
+ p(this, "columns");
1184
1184
  /** @internal */
1185
- h(this, "name");
1185
+ p(this, "name");
1186
1186
  this.columns = i, this.name = e;
1187
1187
  }
1188
1188
  /** @internal */
@@ -1190,20 +1190,20 @@ class yt {
1190
1190
  return new cr(i, this.columns, this.name);
1191
1191
  }
1192
1192
  }
1193
- h(yt, zi, "SQLitePrimaryKeyBuilder");
1193
+ p(mt, zi, "SQLitePrimaryKeyBuilder");
1194
1194
  var Ti;
1195
1195
  Ti = v;
1196
1196
  class cr {
1197
1197
  constructor(i, e, t) {
1198
- h(this, "columns");
1199
- h(this, "name");
1198
+ p(this, "columns");
1199
+ p(this, "name");
1200
1200
  this.table = i, this.columns = e, this.name = t;
1201
1201
  }
1202
1202
  getName() {
1203
1203
  return this.name ?? `${this.table[$e.Symbol.Name]}_${this.columns.map((i) => i.name).join("_")}_pk`;
1204
1204
  }
1205
1205
  }
1206
- h(cr, Ti, "SQLitePrimaryKey");
1206
+ p(cr, Ti, "SQLitePrimaryKey");
1207
1207
  const D = O("tenants", {
1208
1208
  id: s("id", { length: 191 }).primaryKey(),
1209
1209
  name: s("name", { length: 255 }),
@@ -1217,12 +1217,12 @@ const D = O("tenants", {
1217
1217
  created_at: s("created_at", { length: 35 }).notNull(),
1218
1218
  updated_at: s("updated_at", { length: 35 }).notNull(),
1219
1219
  support_url: s("support_url", { length: 255 }),
1220
- idle_session_lifetime: p("idle_session_lifetime"),
1221
- session_lifetime: p("session_lifetime"),
1220
+ idle_session_lifetime: m("idle_session_lifetime"),
1221
+ session_lifetime: m("session_lifetime"),
1222
1222
  session_cookie: s("session_cookie"),
1223
1223
  allowed_logout_urls: s("allowed_logout_urls"),
1224
- ephemeral_session_lifetime: p("ephemeral_session_lifetime"),
1225
- idle_ephemeral_session_lifetime: p("idle_ephemeral_session_lifetime"),
1224
+ ephemeral_session_lifetime: m("ephemeral_session_lifetime"),
1225
+ idle_ephemeral_session_lifetime: m("idle_ephemeral_session_lifetime"),
1226
1226
  default_redirection_uri: s("default_redirection_uri"),
1227
1227
  enabled_locales: s("enabled_locales"),
1228
1228
  default_directory: s("default_directory", { length: 255 }),
@@ -1242,18 +1242,18 @@ const D = O("tenants", {
1242
1242
  default_organization: s("default_organization", { length: 255 }),
1243
1243
  sessions: s("sessions"),
1244
1244
  oidc_logout: s("oidc_logout"),
1245
- allow_organization_name_in_authentication_api: p(
1245
+ allow_organization_name_in_authentication_api: m(
1246
1246
  "allow_organization_name_in_authentication_api"
1247
1247
  ),
1248
- customize_mfa_in_postlogin_action: p(
1248
+ customize_mfa_in_postlogin_action: m(
1249
1249
  "customize_mfa_in_postlogin_action"
1250
1250
  ),
1251
1251
  acr_values_supported: s("acr_values_supported"),
1252
1252
  mtls: s("mtls"),
1253
- pushed_authorization_requests_supported: p(
1253
+ pushed_authorization_requests_supported: m(
1254
1254
  "pushed_authorization_requests_supported"
1255
1255
  ),
1256
- authorization_response_iss_parameter_supported: p(
1256
+ authorization_response_iss_parameter_supported: m(
1257
1257
  "authorization_response_iss_parameter_supported"
1258
1258
  )
1259
1259
  }), k = O(
@@ -1269,21 +1269,21 @@ const D = O("tenants", {
1269
1269
  picture: s("picture", { length: 2083 }),
1270
1270
  tags: s("tags", { length: 255 }),
1271
1271
  phone_number: s("phone_number", { length: 17 }),
1272
- phone_verified: p("phone_verified", { mode: "boolean" }),
1272
+ phone_verified: m("phone_verified", { mode: "boolean" }),
1273
1273
  username: s("username", { length: 128 }),
1274
1274
  created_at: s("created_at", { length: 35 }).notNull(),
1275
1275
  updated_at: s("updated_at", { length: 35 }).notNull(),
1276
1276
  linked_to: s("linked_to", { length: 255 }),
1277
1277
  last_ip: s("last_ip", { length: 255 }),
1278
- login_count: p("login_count").notNull(),
1278
+ login_count: m("login_count").notNull(),
1279
1279
  last_login: s("last_login", { length: 255 }),
1280
1280
  registration_completed_at: s("registration_completed_at", {
1281
1281
  length: 35
1282
1282
  }),
1283
1283
  provider: s("provider", { length: 255 }).notNull(),
1284
1284
  connection: s("connection", { length: 255 }),
1285
- email_verified: p("email_verified", { mode: "boolean" }).notNull(),
1286
- is_social: p("is_social", { mode: "boolean" }).notNull(),
1285
+ email_verified: m("email_verified", { mode: "boolean" }).notNull(),
1286
+ is_social: m("is_social", { mode: "boolean" }).notNull(),
1287
1287
  app_metadata: s("app_metadata", { length: 4096 }).notNull().default("{}"),
1288
1288
  user_metadata: s("user_metadata").notNull().default("{}"),
1289
1289
  profileData: s("profileData", { length: 2048 }),
@@ -1332,7 +1332,7 @@ const D = O("tenants", {
1332
1332
  n.provider
1333
1333
  )
1334
1334
  ]
1335
- ), C = O("passwords", {
1335
+ ), A = O("passwords", {
1336
1336
  id: s("id", { length: 21 }).primaryKey(),
1337
1337
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1338
1338
  user_id: s("user_id", { length: 255 }).notNull(),
@@ -1340,21 +1340,21 @@ const D = O("tenants", {
1340
1340
  updated_at: s("updated_at", { length: 35 }).notNull(),
1341
1341
  password: s("password", { length: 255 }).notNull(),
1342
1342
  algorithm: s("algorithm", { length: 16 }).notNull().default("bcrypt"),
1343
- is_current: p("is_current").notNull().default(1)
1343
+ is_current: m("is_current").notNull().default(1)
1344
1344
  }), $ = O(
1345
1345
  "sessions",
1346
1346
  {
1347
1347
  id: s("id", { length: 21 }).notNull(),
1348
1348
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1349
1349
  user_id: s("user_id", { length: 255 }),
1350
- created_at_ts: p("created_at_ts").notNull(),
1351
- updated_at_ts: p("updated_at_ts").notNull(),
1352
- expires_at_ts: p("expires_at_ts"),
1353
- idle_expires_at_ts: p("idle_expires_at_ts"),
1354
- authenticated_at_ts: p("authenticated_at_ts"),
1355
- last_interaction_at_ts: p("last_interaction_at_ts"),
1356
- used_at_ts: p("used_at_ts"),
1357
- revoked_at_ts: p("revoked_at_ts"),
1350
+ created_at_ts: m("created_at_ts").notNull(),
1351
+ updated_at_ts: m("updated_at_ts").notNull(),
1352
+ expires_at_ts: m("expires_at_ts"),
1353
+ idle_expires_at_ts: m("idle_expires_at_ts"),
1354
+ authenticated_at_ts: m("authenticated_at_ts"),
1355
+ last_interaction_at_ts: m("last_interaction_at_ts"),
1356
+ used_at_ts: m("used_at_ts"),
1357
+ revoked_at_ts: m("revoked_at_ts"),
1358
1358
  device: s("device").notNull(),
1359
1359
  clients: s("clients").notNull(),
1360
1360
  login_session_id: s("login_session_id", { length: 21 })
@@ -1375,11 +1375,11 @@ const D = O("tenants", {
1375
1375
  user_id: s("user_id", { length: 255 }),
1376
1376
  resource_servers: s("resource_servers").notNull(),
1377
1377
  device: s("device").notNull(),
1378
- rotating: p("rotating", { mode: "boolean" }).notNull(),
1379
- created_at_ts: p("created_at_ts").notNull(),
1380
- expires_at_ts: p("expires_at_ts"),
1381
- idle_expires_at_ts: p("idle_expires_at_ts"),
1382
- last_exchanged_at_ts: p("last_exchanged_at_ts")
1378
+ rotating: m("rotating", { mode: "boolean" }).notNull(),
1379
+ created_at_ts: m("created_at_ts").notNull(),
1380
+ expires_at_ts: m("expires_at_ts"),
1381
+ idle_expires_at_ts: m("idle_expires_at_ts"),
1382
+ last_exchanged_at_ts: m("last_exchanged_at_ts")
1383
1383
  },
1384
1384
  (n) => [
1385
1385
  oe({
@@ -1390,39 +1390,20 @@ const D = O("tenants", {
1390
1390
  S("idx_refresh_tokens_login_id").on(n.login_id),
1391
1391
  S("idx_refresh_tokens_expires_at_ts").on(n.expires_at_ts)
1392
1392
  ]
1393
- ), B = O(
1393
+ ), L = O(
1394
1394
  "login_sessions",
1395
1395
  {
1396
1396
  id: s("id", { length: 21 }).notNull(),
1397
1397
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1398
1398
  session_id: s("session_id", { length: 21 }),
1399
1399
  csrf_token: s("csrf_token", { length: 21 }).notNull(),
1400
- authParams_client_id: s("authParams_client_id", {
1401
- length: 191
1402
- }).notNull(),
1403
- authParams_vendor_id: s("authParams_vendor_id", { length: 255 }),
1404
- authParams_username: s("authParams_username", { length: 255 }),
1405
- authParams_response_type: s("authParams_response_type", { length: 255 }),
1406
- authParams_response_mode: s("authParams_response_mode", { length: 255 }),
1407
- authParams_audience: s("authParams_audience", { length: 255 }),
1408
- authParams_scope: s("authParams_scope"),
1409
- authParams_state: s("authParams_state"),
1410
- authParams_nonce: s("authParams_nonce", { length: 255 }),
1411
- authParams_code_challenge_method: s("authParams_code_challenge_method", {
1412
- length: 255
1413
- }),
1414
- authParams_code_challenge: s("authParams_code_challenge", {
1415
- length: 255
1416
- }),
1417
- authParams_redirect_uri: s("authParams_redirect_uri"),
1418
- authParams_organization: s("authParams_organization", { length: 255 }),
1419
- authParams_prompt: s("authParams_prompt", { length: 32 }),
1420
- authParams_act_as: s("authParams_act_as", { length: 256 }),
1421
- authParams_ui_locales: s("authParams_ui_locales", { length: 32 }),
1400
+ // JSON-serialized authParams. Canonical source of truth. Replaces the
1401
+ // legacy hoisted authParams_* columns, which were dropped.
1402
+ auth_params: s("auth_params"),
1422
1403
  authorization_url: s("authorization_url"),
1423
- created_at_ts: p("created_at_ts").notNull(),
1424
- updated_at_ts: p("updated_at_ts").notNull(),
1425
- expires_at_ts: p("expires_at_ts").notNull(),
1404
+ created_at_ts: m("created_at_ts").notNull(),
1405
+ updated_at_ts: m("updated_at_ts").notNull(),
1406
+ expires_at_ts: m("expires_at_ts").notNull(),
1426
1407
  ip: s("ip", { length: 39 }),
1427
1408
  useragent: s("useragent"),
1428
1409
  auth0Client: s("auth0Client", { length: 255 }),
@@ -1452,7 +1433,7 @@ const D = O("tenants", {
1452
1433
  S("login_sessions_tenant_user_idx").on(n.tenant_id, n.user_id),
1453
1434
  S("idx_login_sessions_expires_at_ts").on(n.expires_at_ts)
1454
1435
  ]
1455
- ), P = O(
1436
+ ), Q = O(
1456
1437
  "codes",
1457
1438
  {
1458
1439
  code_id: s("code_id", { length: 191 }).notNull(),
@@ -1518,7 +1499,7 @@ const D = O("tenants", {
1518
1499
  S("otps_email_index").on(n.email),
1519
1500
  S("otps_expires_at_index").on(n.expires_at)
1520
1501
  ]
1521
- ), Pr = O("tickets", {
1502
+ ), Qr = O("tickets", {
1522
1503
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1523
1504
  id: s("id", { length: 255 }).primaryKey(),
1524
1505
  client_id: s("client_id", { length: 255 }).notNull(),
@@ -1539,13 +1520,13 @@ const D = O("tenants", {
1539
1520
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1540
1521
  name: s("name", { length: 255 }).notNull(),
1541
1522
  description: s("description", { length: 140 }),
1542
- global: p("global").notNull().default(0),
1523
+ global: m("global").notNull().default(0),
1543
1524
  client_secret: s("client_secret", { length: 255 }),
1544
1525
  app_type: s("app_type", { length: 64 }).default("regular_web"),
1545
1526
  logo_uri: s("logo_uri", { length: 2083 }),
1546
- is_first_party: p("is_first_party").notNull().default(0),
1547
- oidc_conformant: p("oidc_conformant").notNull().default(1),
1548
- auth0_conformant: p("auth0_conformant").notNull().default(1),
1527
+ is_first_party: m("is_first_party").notNull().default(0),
1528
+ oidc_conformant: m("oidc_conformant").notNull().default(1),
1529
+ auth0_conformant: m("auth0_conformant").notNull().default(1),
1549
1530
  callbacks: s("callbacks").notNull(),
1550
1531
  allowed_origins: s("allowed_origins").notNull(),
1551
1532
  web_origins: s("web_origins").notNull(),
@@ -1558,11 +1539,11 @@ const D = O("tenants", {
1558
1539
  jwt_configuration: s("jwt_configuration").notNull(),
1559
1540
  signing_keys: s("signing_keys").notNull(),
1560
1541
  encryption_key: s("encryption_key").notNull(),
1561
- sso: p("sso").notNull().default(0),
1562
- sso_disabled: p("sso_disabled").notNull().default(1),
1563
- cross_origin_authentication: p("cross_origin_authentication").notNull().default(0),
1542
+ sso: m("sso").notNull().default(0),
1543
+ sso_disabled: m("sso_disabled").notNull().default(1),
1544
+ cross_origin_authentication: m("cross_origin_authentication").notNull().default(0),
1564
1545
  cross_origin_loc: s("cross_origin_loc", { length: 2083 }),
1565
- custom_login_page_on: p("custom_login_page_on").notNull().default(0),
1546
+ custom_login_page_on: m("custom_login_page_on").notNull().default(0),
1566
1547
  custom_login_page: s("custom_login_page"),
1567
1548
  custom_login_page_preview: s("custom_login_page_preview"),
1568
1549
  form_template: s("form_template"),
@@ -1585,13 +1566,13 @@ const D = O("tenants", {
1585
1566
  client_authentication_methods: s(
1586
1567
  "client_authentication_methods"
1587
1568
  ).notNull(),
1588
- require_pushed_authorization_requests: p(
1569
+ require_pushed_authorization_requests: m(
1589
1570
  "require_pushed_authorization_requests"
1590
1571
  ).notNull().default(0),
1591
- require_proof_of_possession: p("require_proof_of_possession").notNull().default(0),
1572
+ require_proof_of_possession: m("require_proof_of_possession").notNull().default(0),
1592
1573
  signed_request_object: s("signed_request_object").notNull(),
1593
1574
  compliance_level: s("compliance_level", { length: 64 }),
1594
- par_request_expiry: p("par_request_expiry"),
1575
+ par_request_expiry: m("par_request_expiry"),
1595
1576
  token_quota: s("token_quota").notNull(),
1596
1577
  created_at: s("created_at", { length: 35 }).notNull(),
1597
1578
  updated_at: s("updated_at", { length: 35 }).notNull(),
@@ -1612,8 +1593,8 @@ const D = O("tenants", {
1612
1593
  audience: s("audience", { length: 191 }).notNull(),
1613
1594
  scope: s("scope").default("[]"),
1614
1595
  organization_usage: s("organization_usage", { length: 32 }),
1615
- allow_any_organization: p("allow_any_organization").default(0),
1616
- is_system: p("is_system").default(0),
1596
+ allow_any_organization: m("allow_any_organization").default(0),
1597
+ is_system: m("is_system").default(0),
1617
1598
  subject_type: s("subject_type", { length: 32 }),
1618
1599
  authorization_details_types: s("authorization_details_types").default(
1619
1600
  "[]"
@@ -1641,9 +1622,9 @@ const D = O("tenants", {
1641
1622
  created_at: s("created_at", { length: 35 }).notNull(),
1642
1623
  updated_at: s("updated_at", { length: 35 }).notNull(),
1643
1624
  display_name: s("display_name", { length: 255 }),
1644
- is_domain_connection: p("is_domain_connection"),
1645
- show_as_button: p("show_as_button"),
1646
- is_system: p("is_system").notNull().default(0),
1625
+ is_domain_connection: m("is_domain_connection"),
1626
+ show_as_button: m("show_as_button"),
1627
+ is_system: m("is_system").notNull().default(0),
1647
1628
  metadata: s("metadata", { length: 4096 })
1648
1629
  },
1649
1630
  (n) => [
@@ -1658,7 +1639,7 @@ const D = O("tenants", {
1658
1639
  custom_domain_id: s("custom_domain_id", { length: 256 }).primaryKey(),
1659
1640
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1660
1641
  domain: s("domain", { length: 255 }).notNull(),
1661
- primary: p("primary", { mode: "boolean" }).notNull(),
1642
+ primary: m("primary", { mode: "boolean" }).notNull(),
1662
1643
  status: s("status", { length: 50 }).notNull(),
1663
1644
  type: s("type", { length: 50 }).notNull(),
1664
1645
  origin_domain_name: s("origin_domain_name", { length: 255 }),
@@ -1670,7 +1651,7 @@ const D = O("tenants", {
1670
1651
  updated_at: s("updated_at", { length: 35 }).notNull()
1671
1652
  },
1672
1653
  (n) => [Te("custom_domains_domain_unique").on(n.domain)]
1673
- ), Qr = O("domains", {
1654
+ ), Jr = O("domains", {
1674
1655
  id: s("id", { length: 255 }).primaryKey(),
1675
1656
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1676
1657
  domain: s("domain", { length: 255 }).notNull(),
@@ -1680,7 +1661,7 @@ const D = O("tenants", {
1680
1661
  dkim_public_key: s("dkim_public_key", { length: 2048 }),
1681
1662
  created_at: s("created_at", { length: 35 }).notNull(),
1682
1663
  updated_at: s("updated_at", { length: 35 }).notNull()
1683
- }), L = O(
1664
+ }), E = O(
1684
1665
  "organizations",
1685
1666
  {
1686
1667
  id: s("id", { length: 21 }).primaryKey(),
@@ -1695,7 +1676,7 @@ const D = O("tenants", {
1695
1676
  updated_at: s("updated_at", { length: 35 }).notNull()
1696
1677
  },
1697
1678
  (n) => [S("idx_organizations_tenant_id").on(n.tenant_id)]
1698
- ), Q = O(
1679
+ ), J = O(
1699
1680
  "user_organizations",
1700
1681
  {
1701
1682
  id: s("id", { length: 21 }).primaryKey(),
@@ -1732,8 +1713,8 @@ const D = O("tenants", {
1732
1713
  user_metadata: s("user_metadata"),
1733
1714
  roles: s("roles"),
1734
1715
  ticket_id: s("ticket_id", { length: 191 }),
1735
- ttl_sec: p("ttl_sec"),
1736
- send_invitation_email: p("send_invitation_email")
1716
+ ttl_sec: m("ttl_sec"),
1717
+ send_invitation_email: m("send_invitation_email")
1737
1718
  },
1738
1719
  (n) => [
1739
1720
  S("idx_invites_tenant_id").on(n.tenant_id),
@@ -1748,7 +1729,7 @@ const D = O("tenants", {
1748
1729
  tenant_id: s("tenant_id", { length: 191 }).notNull(),
1749
1730
  name: s("name", { length: 50 }).notNull(),
1750
1731
  description: s("description", { length: 255 }),
1751
- is_system: p("is_system").notNull().default(0),
1732
+ is_system: m("is_system").notNull().default(0),
1752
1733
  metadata: s("metadata", { length: 4096 }),
1753
1734
  created_at: s("created_at", { length: 35 }).notNull(),
1754
1735
  updated_at: s("updated_at", { length: 35 }).notNull()
@@ -1838,7 +1819,7 @@ const D = O("tenants", {
1838
1819
  S("user_roles_role_fk").on(n.tenant_id, n.role_id),
1839
1820
  S("user_roles_organization_fk").on(n.organization_id)
1840
1821
  ]
1841
- ), E = O(
1822
+ ), C = O(
1842
1823
  "resource_servers",
1843
1824
  {
1844
1825
  id: s("id", { length: 21 }).notNull(),
@@ -1848,15 +1829,15 @@ const D = O("tenants", {
1848
1829
  scopes: s("scopes", { length: 4096 }),
1849
1830
  signing_alg: s("signing_alg", { length: 64 }),
1850
1831
  signing_secret: s("signing_secret", { length: 2048 }),
1851
- token_lifetime: p("token_lifetime"),
1852
- token_lifetime_for_web: p("token_lifetime_for_web"),
1853
- skip_consent_for_verifiable_first_party_clients: p(
1832
+ token_lifetime: m("token_lifetime"),
1833
+ token_lifetime_for_web: m("token_lifetime_for_web"),
1834
+ skip_consent_for_verifiable_first_party_clients: m(
1854
1835
  "skip_consent_for_verifiable_first_party_clients"
1855
1836
  ),
1856
- allow_offline_access: p("allow_offline_access"),
1837
+ allow_offline_access: m("allow_offline_access"),
1857
1838
  verification_key: s("verification_key", { length: 4096 }),
1858
1839
  options: s("options", { length: 4096 }),
1859
- is_system: p("is_system").notNull().default(0),
1840
+ is_system: m("is_system").notNull().default(0),
1860
1841
  metadata: s("metadata", { length: 4096 }),
1861
1842
  created_at: s("created_at", { length: 35 }).notNull(),
1862
1843
  updated_at: s("updated_at", { length: 35 }).notNull()
@@ -1880,14 +1861,14 @@ const D = O("tenants", {
1880
1861
  length: 8
1881
1862
  }),
1882
1863
  colors_page_background_end: s("colors_page_background_end", { length: 8 }),
1883
- colors_page_background_angle_dev: p("colors_page_background_angle_dev")
1864
+ colors_page_background_angle_dev: m("colors_page_background_angle_dev")
1884
1865
  }), ve = O(
1885
1866
  "universal_login_templates",
1886
1867
  {
1887
1868
  tenant_id: s("tenant_id", { length: 191 }).primaryKey().references(() => D.id, { onDelete: "cascade" }),
1888
1869
  body: s("body").notNull(),
1889
- created_at_ts: p("created_at_ts").notNull(),
1890
- updated_at_ts: p("updated_at_ts").notNull()
1870
+ created_at_ts: m("created_at_ts").notNull(),
1871
+ updated_at_ts: m("updated_at_ts").notNull()
1891
1872
  }
1892
1873
  ), fe = O(
1893
1874
  "themes",
@@ -1940,54 +1921,54 @@ const D = O("tenants", {
1940
1921
  colors_widget_border: s("colors_widget_border", {
1941
1922
  length: 24
1942
1923
  }).notNull(),
1943
- borders_button_border_radius: p(
1924
+ borders_button_border_radius: m(
1944
1925
  "borders_button_border_radius"
1945
1926
  ).notNull(),
1946
- borders_button_border_weight: p(
1927
+ borders_button_border_weight: m(
1947
1928
  "borders_button_border_weight"
1948
1929
  ).notNull(),
1949
1930
  borders_buttons_style: s("borders_buttons_style", {
1950
1931
  length: 24
1951
1932
  }).notNull(),
1952
- borders_input_border_radius: p(
1933
+ borders_input_border_radius: m(
1953
1934
  "borders_input_border_radius"
1954
1935
  ).notNull(),
1955
- borders_input_border_weight: p(
1936
+ borders_input_border_weight: m(
1956
1937
  "borders_input_border_weight"
1957
1938
  ).notNull(),
1958
1939
  borders_inputs_style: s("borders_inputs_style", {
1959
1940
  length: 24
1960
1941
  }).notNull(),
1961
- borders_show_widget_shadow: p("borders_show_widget_shadow", {
1942
+ borders_show_widget_shadow: m("borders_show_widget_shadow", {
1962
1943
  mode: "boolean"
1963
1944
  }).notNull(),
1964
- borders_widget_border_weight: p(
1945
+ borders_widget_border_weight: m(
1965
1946
  "borders_widget_border_weight"
1966
1947
  ).notNull(),
1967
- borders_widget_corner_radius: p(
1948
+ borders_widget_corner_radius: m(
1968
1949
  "borders_widget_corner_radius"
1969
1950
  ).notNull(),
1970
- fonts_body_text_bold: p("fonts_body_text_bold").notNull(),
1971
- fonts_body_text_size: p("fonts_body_text_size").notNull(),
1972
- fonts_buttons_text_bold: p("fonts_buttons_text_bold").notNull(),
1973
- fonts_buttons_text_size: p("fonts_buttons_text_size").notNull(),
1951
+ fonts_body_text_bold: m("fonts_body_text_bold").notNull(),
1952
+ fonts_body_text_size: m("fonts_body_text_size").notNull(),
1953
+ fonts_buttons_text_bold: m("fonts_buttons_text_bold").notNull(),
1954
+ fonts_buttons_text_size: m("fonts_buttons_text_size").notNull(),
1974
1955
  fonts_font_url: s("fonts_font_url", { length: 255 }).notNull(),
1975
- fonts_input_labels_bold: p("fonts_input_labels_bold").notNull(),
1976
- fonts_input_labels_size: p("fonts_input_labels_size").notNull(),
1977
- fonts_links_bold: p("fonts_links_bold", {
1956
+ fonts_input_labels_bold: m("fonts_input_labels_bold").notNull(),
1957
+ fonts_input_labels_size: m("fonts_input_labels_size").notNull(),
1958
+ fonts_links_bold: m("fonts_links_bold", {
1978
1959
  mode: "boolean"
1979
1960
  }).notNull(),
1980
- fonts_links_size: p("fonts_links_size").notNull(),
1961
+ fonts_links_size: m("fonts_links_size").notNull(),
1981
1962
  fonts_links_style: s("fonts_links_style", { length: 24 }).notNull(),
1982
- fonts_reference_text_size: p("fonts_reference_text_size").notNull(),
1983
- fonts_subtitle_bold: p("fonts_subtitle_bold", {
1963
+ fonts_reference_text_size: m("fonts_reference_text_size").notNull(),
1964
+ fonts_subtitle_bold: m("fonts_subtitle_bold", {
1984
1965
  mode: "boolean"
1985
1966
  }).notNull(),
1986
- fonts_subtitle_size: p("fonts_subtitle_size").notNull(),
1987
- fonts_title_bold: p("fonts_title_bold", {
1967
+ fonts_subtitle_size: m("fonts_subtitle_size").notNull(),
1968
+ fonts_title_bold: m("fonts_title_bold", {
1988
1969
  mode: "boolean"
1989
1970
  }).notNull(),
1990
- fonts_title_size: p("fonts_title_size").notNull(),
1971
+ fonts_title_size: m("fonts_title_size").notNull(),
1991
1972
  page_background_background_color: s("page_background_background_color", {
1992
1973
  length: 24
1993
1974
  }).notNull(),
@@ -2001,7 +1982,7 @@ const D = O("tenants", {
2001
1982
  widget_header_text_alignment: s("widget_header_text_alignment", {
2002
1983
  length: 24
2003
1984
  }).notNull(),
2004
- widget_logo_height: p("widget_logo_height").notNull(),
1985
+ widget_logo_height: m("widget_logo_height").notNull(),
2005
1986
  widget_logo_position: s("widget_logo_position", {
2006
1987
  length: 24
2007
1988
  }).notNull(),
@@ -2050,15 +2031,15 @@ const D = O("tenants", {
2050
2031
  ), Ee = O("prompt_settings", {
2051
2032
  tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
2052
2033
  universal_login_experience: s("universal_login_experience", { length: 16 }).notNull().default("new"),
2053
- identifier_first: p("identifier_first", { mode: "boolean" }).notNull().default(!0),
2054
- password_first: p("password_first", { mode: "boolean" }).notNull().default(!1),
2055
- webauthn_platform_first_factor: p("webauthn_platform_first_factor", {
2034
+ identifier_first: m("identifier_first", { mode: "boolean" }).notNull().default(!0),
2035
+ password_first: m("password_first", { mode: "boolean" }).notNull().default(!1),
2036
+ webauthn_platform_first_factor: m("webauthn_platform_first_factor", {
2056
2037
  mode: "boolean"
2057
2038
  }).notNull().default(!1)
2058
2039
  }), Se = O("email_providers", {
2059
2040
  tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
2060
2041
  name: s("name", { length: 255 }).notNull(),
2061
- enabled: p("enabled", { mode: "boolean" }).notNull(),
2042
+ enabled: m("enabled", { mode: "boolean" }).notNull(),
2062
2043
  default_from_address: s("default_from_address", { length: 255 }),
2063
2044
  credentials: s("credentials", { length: 2048 }).notNull().default("{}"),
2064
2045
  settings: s("settings", { length: 2048 }).notNull().default("{}"),
@@ -2072,11 +2053,11 @@ const D = O("tenants", {
2072
2053
  url: s("url", { length: 512 }),
2073
2054
  // nullable - only required for webhook type hooks
2074
2055
  trigger_id: s("trigger_id", { length: 255 }).notNull(),
2075
- enabled: p("enabled", { mode: "boolean" }).notNull(),
2076
- created_at_ts: p("created_at_ts").notNull(),
2077
- updated_at_ts: p("updated_at_ts").notNull(),
2078
- synchronous: p("synchronous", { mode: "boolean" }).notNull().default(!1),
2079
- priority: p("priority"),
2056
+ enabled: m("enabled", { mode: "boolean" }).notNull(),
2057
+ created_at_ts: m("created_at_ts").notNull(),
2058
+ updated_at_ts: m("updated_at_ts").notNull(),
2059
+ synchronous: m("synchronous", { mode: "boolean" }).notNull().default(!1),
2060
+ priority: m("priority"),
2080
2061
  form_id: s("form_id", { length: 128 }),
2081
2062
  // only required for form type hooks
2082
2063
  template_id: s("template_id", { length: 64 }),
@@ -2085,18 +2066,18 @@ const D = O("tenants", {
2085
2066
  // only required for code type hooks
2086
2067
  },
2087
2068
  (n) => [S("hooks_tenant_id_idx").on(n.tenant_id)]
2088
- ), he = O(
2069
+ ), pe = O(
2089
2070
  "hook_code",
2090
2071
  {
2091
2072
  id: s("id", { length: 21 }).primaryKey(),
2092
2073
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
2093
2074
  code: s("code").notNull(),
2094
2075
  secrets: s("secrets"),
2095
- created_at_ts: p("created_at_ts").notNull(),
2096
- updated_at_ts: p("updated_at_ts").notNull()
2076
+ created_at_ts: m("created_at_ts").notNull(),
2077
+ updated_at_ts: m("updated_at_ts").notNull()
2097
2078
  },
2098
2079
  (n) => [S("hook_code_tenant_id_idx").on(n.tenant_id)]
2099
- ), me = O("keys", {
2080
+ ), he = O("keys", {
2100
2081
  kid: s("kid", { length: 255 }).primaryKey(),
2101
2082
  tenant_id: s("tenant_id", { length: 191 }).references(() => D.id, {
2102
2083
  onDelete: "cascade"
@@ -2121,8 +2102,8 @@ const D = O("tenants", {
2121
2102
  prompt: s("prompt", { length: 64 }).notNull(),
2122
2103
  language: s("language", { length: 16 }).notNull(),
2123
2104
  custom_text: s("custom_text").notNull(),
2124
- created_at_ts: p("created_at_ts").notNull(),
2125
- updated_at_ts: p("updated_at_ts").notNull()
2105
+ created_at_ts: m("created_at_ts").notNull(),
2106
+ updated_at_ts: m("updated_at_ts").notNull()
2126
2107
  },
2127
2108
  (n) => [
2128
2109
  oe({ columns: [n.tenant_id, n.prompt, n.language] })
@@ -2138,13 +2119,13 @@ const D = O("tenants", {
2138
2119
  totp_secret: s("totp_secret", { length: 255 }),
2139
2120
  credential_id: s("credential_id", { length: 512 }),
2140
2121
  public_key: s("public_key"),
2141
- sign_count: p("sign_count"),
2142
- credential_backed_up: p("credential_backed_up"),
2122
+ sign_count: m("sign_count"),
2123
+ credential_backed_up: m("credential_backed_up"),
2143
2124
  transports: s("transports", { length: 512 }),
2144
2125
  friendly_name: s("friendly_name", { length: 255 }),
2145
- confirmed: p("confirmed").notNull().default(0),
2146
- created_at_ts: p("created_at_ts").notNull(),
2147
- updated_at_ts: p("updated_at_ts").notNull()
2126
+ confirmed: m("confirmed").notNull().default(0),
2127
+ created_at_ts: m("created_at_ts").notNull(),
2128
+ updated_at_ts: m("updated_at_ts").notNull()
2148
2129
  },
2149
2130
  (n) => [
2150
2131
  S("authentication_methods_tenant_user_idx").on(
@@ -2168,7 +2149,7 @@ const D = O("tenants", {
2168
2149
  user_agent: s("user_agent", { length: 255 }),
2169
2150
  description: s("description", { length: 255 }),
2170
2151
  details: s("details", { length: 2048 }),
2171
- isMobile: p("isMobile"),
2152
+ isMobile: m("isMobile"),
2172
2153
  user_name: s("user_name", { length: 255 }),
2173
2154
  connection: s("connection", { length: 255 }),
2174
2155
  connection_id: s("connection_id", { length: 255 }),
@@ -2209,7 +2190,7 @@ const D = O("tenants", {
2209
2190
  payload: s("payload").notNull(),
2210
2191
  created_at: s("created_at", { length: 35 }).notNull(),
2211
2192
  processed_at: s("processed_at", { length: 35 }),
2212
- retry_count: p("retry_count").notNull().default(0),
2193
+ retry_count: m("retry_count").notNull().default(0),
2213
2194
  next_retry_at: s("next_retry_at", { length: 35 }),
2214
2195
  error: s("error"),
2215
2196
  claimed_by: s("claimed_by", { length: 255 }),
@@ -2237,35 +2218,35 @@ const D = O("tenants", {
2237
2218
  branding: Le,
2238
2219
  clientGrants: Y,
2239
2220
  clients: I,
2240
- codes: P,
2221
+ codes: Q,
2241
2222
  connections: K,
2242
2223
  customDomains: se,
2243
2224
  customText: te,
2244
- domains: Qr,
2225
+ domains: Jr,
2245
2226
  emailProviders: Se,
2246
2227
  flows: re,
2247
2228
  forms: ie,
2248
- hookCode: he,
2229
+ hookCode: pe,
2249
2230
  hooks: ee,
2250
2231
  invites: ne,
2251
- keys: me,
2252
- loginSessions: B,
2232
+ keys: he,
2233
+ loginSessions: L,
2253
2234
  logs: q,
2254
- organizations: L,
2235
+ organizations: E,
2255
2236
  otps: $r,
2256
2237
  outboxEvents: b,
2257
- passwords: C,
2238
+ passwords: A,
2258
2239
  promptSettings: Ee,
2259
2240
  refreshTokens: T,
2260
- resourceServers: E,
2241
+ resourceServers: C,
2261
2242
  rolePermissions: le,
2262
2243
  roles: F,
2263
2244
  sessions: $,
2264
2245
  tenants: D,
2265
2246
  themes: fe,
2266
- tickets: Pr,
2247
+ tickets: Qr,
2267
2248
  universalLoginTemplates: ve,
2268
- userOrganizations: Q,
2249
+ userOrganizations: J,
2269
2250
  userPermissions: _e,
2270
2251
  userRoles: ue,
2271
2252
  users: k
@@ -2286,7 +2267,7 @@ function z(n) {
2286
2267
  }
2287
2268
  return i;
2288
2269
  }
2289
- function Jr(n, i, e = { ...n }) {
2270
+ function Pr(n, i, e = { ...n }) {
2290
2271
  for (const t of i)
2291
2272
  n[t] !== void 0 && (e[t] = JSON.stringify(n[t]));
2292
2273
  return e;
@@ -2312,11 +2293,11 @@ function x(n, i) {
2312
2293
  }
2313
2294
  return n;
2314
2295
  }
2315
- function Pe(n, i = "", e = {}) {
2296
+ function yt(n, i = "", e = {}) {
2316
2297
  for (const t in n)
2317
2298
  if (Object.prototype.hasOwnProperty.call(n, t)) {
2318
2299
  const r = i ? `${i}_${t}` : t, o = n[t];
2319
- typeof o == "object" && o !== null && !Array.isArray(o) ? Pe(o, r, e) : typeof o == "boolean" ? e[r] = o ? 1 : 0 : e[r] = o;
2300
+ typeof o == "object" && o !== null && !Array.isArray(o) ? yt(o, r, e) : typeof o == "boolean" ? e[r] = o ? 1 : 0 : e[r] = o;
2320
2301
  }
2321
2302
  return e;
2322
2303
  }
@@ -2371,7 +2352,7 @@ function Kr(n) {
2371
2352
  });
2372
2353
  },
2373
2354
  async set(i, e) {
2374
- var _, u, c, d, m, f, y, N;
2355
+ var _, u, c, d, h, f, y, N;
2375
2356
  const { colors: t, font: r, ...o } = e, l = {
2376
2357
  ...o,
2377
2358
  tenant_id: i,
@@ -2387,7 +2368,7 @@ function Kr(n) {
2387
2368
  set: {
2388
2369
  ...o,
2389
2370
  colors_primary: t == null ? void 0 : t.primary,
2390
- colors_page_background_type: (m = t == null ? void 0 : t.page_background) == null ? void 0 : m.type,
2371
+ colors_page_background_type: (h = t == null ? void 0 : t.page_background) == null ? void 0 : h.type,
2391
2372
  colors_page_background_start: (f = t == null ? void 0 : t.page_background) == null ? void 0 : f.start,
2392
2373
  colors_page_background_end: (y = t == null ? void 0 : t.page_background) == null ? void 0 : y.end,
2393
2374
  colors_page_background_angle_dev: (N = t == null ? void 0 : t.page_background) == null ? void 0 : N.angle_deg,
@@ -2405,8 +2386,8 @@ var be = class extends Error {
2405
2386
  */
2406
2387
  constructor(i = 500, e) {
2407
2388
  super(e == null ? void 0 : e.message, { cause: e == null ? void 0 : e.cause });
2408
- h(this, "res");
2409
- h(this, "status");
2389
+ p(this, "res");
2390
+ p(this, "status");
2410
2391
  this.res = e == null ? void 0 : e.res, this.status = i;
2411
2392
  }
2412
2393
  /**
@@ -2423,16 +2404,16 @@ var be = class extends Error {
2423
2404
  });
2424
2405
  }
2425
2406
  };
2426
- function pe(n, i, e) {
2407
+ function me(n, i, e) {
2427
2408
  const t = i.split(/ OR /i);
2428
2409
  if (t.length > 1) {
2429
2410
  const c = t.map((d) => {
2430
- const m = d.trim().match(/^([^:]+):(.+)$/);
2431
- if (m) {
2432
- const [, f, y] = m;
2411
+ const h = d.trim().match(/^([^:]+):(.+)$/);
2412
+ if (h) {
2413
+ const [, f, y] = h;
2433
2414
  if (!f || !y) return null;
2434
- const N = y.replace(/^"(.*)"$/, "$1"), A = n[f.trim()];
2435
- return A ? a(A, N.trim()) : null;
2415
+ const N = y.replace(/^"(.*)"$/, "$1"), B = n[f.trim()];
2416
+ return B ? a(B, N.trim()) : null;
2436
2417
  }
2437
2418
  return null;
2438
2419
  }).filter(Boolean);
@@ -2446,32 +2427,32 @@ function pe(n, i, e) {
2446
2427
  }
2447
2428
  o.trim() && r.push(o.trim());
2448
2429
  const _ = r.map((c) => c.replace(/^([^:]+)=/g, "$1:")).map((c) => {
2449
- let d = c.startsWith("-"), m = null, f = "", y = !1, N;
2430
+ let d = c.startsWith("-"), h = null, f = "", y = !1, N;
2450
2431
  if (c.startsWith("-_exists_:"))
2451
- m = c.substring(10), y = !0, d = !0;
2432
+ h = c.substring(10), y = !0, d = !0;
2452
2433
  else if (c.startsWith("_exists_:"))
2453
- m = c.substring(9), y = !0, d = !1;
2434
+ h = c.substring(9), y = !0, d = !1;
2454
2435
  else if (c.includes(":")) {
2455
- const A = d ? c.substring(1) : c, W = A.indexOf(":");
2456
- m = A.substring(0, W), f = A.substring(W + 1), y = !1, f.startsWith(">=") ? (N = ">=", f = f.substring(2)) : f.startsWith(">") ? (N = ">", f = f.substring(1)) : f.startsWith("<=") ? (N = "<=", f = f.substring(2)) : f.startsWith("<") ? (N = "<", f = f.substring(1)) : N = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
2436
+ const B = d ? c.substring(1) : c, W = B.indexOf(":");
2437
+ h = B.substring(0, W), f = B.substring(W + 1), y = !1, f.startsWith(">=") ? (N = ">=", f = f.substring(2)) : f.startsWith(">") ? (N = ">", f = f.substring(1)) : f.startsWith("<=") ? (N = "<=", f = f.substring(2)) : f.startsWith("<") ? (N = "<", f = f.substring(1)) : N = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
2457
2438
  } else
2458
- m = null, f = c, y = !1;
2459
- return { key: m, value: f, isNegation: d, isExistsQuery: y, operator: N };
2439
+ h = null, f = c, y = !1;
2440
+ return { key: h, value: f, isNegation: d, isExistsQuery: y, operator: N };
2460
2441
  }), u = [];
2461
- for (const { key: c, value: d, isNegation: m, isExistsQuery: f, operator: y } of _)
2442
+ for (const { key: c, value: d, isNegation: h, isExistsQuery: f, operator: y } of _)
2462
2443
  if (c) {
2463
2444
  const N = n[c];
2464
2445
  if (!N) {
2465
2446
  f ? u.push(
2466
- m ? w`${w.identifier(c)} IS NULL` : w`${w.identifier(c)} IS NOT NULL`
2447
+ h ? w`${w.identifier(c)} IS NULL` : w`${w.identifier(c)} IS NOT NULL`
2467
2448
  ) : u.push(
2468
- w`${w.identifier(c)} ${w.raw(m ? "!=" : y ?? "=")} ${d}`
2449
+ w`${w.identifier(c)} ${w.raw(h ? "!=" : y ?? "=")} ${d}`
2469
2450
  );
2470
2451
  continue;
2471
2452
  }
2472
2453
  if (f)
2473
- u.push(m ? ye(N) : Ve(N));
2474
- else if (m)
2454
+ u.push(h ? ye(N) : Me(N));
2455
+ else if (h)
2475
2456
  switch (y) {
2476
2457
  case ">":
2477
2458
  u.push(Oe(N, d));
@@ -2480,10 +2461,10 @@ function pe(n, i, e) {
2480
2461
  u.push(we(N, d));
2481
2462
  break;
2482
2463
  case "<":
2483
- u.push(Ge(N, d));
2464
+ u.push(He(N, d));
2484
2465
  break;
2485
2466
  case "<=":
2486
- u.push(He(N, d));
2467
+ u.push(We(N, d));
2487
2468
  break;
2488
2469
  default:
2489
2470
  u.push(kr(N, d));
@@ -2491,10 +2472,10 @@ function pe(n, i, e) {
2491
2472
  else
2492
2473
  switch (y) {
2493
2474
  case ">":
2494
- u.push(He(N, d));
2475
+ u.push(We(N, d));
2495
2476
  break;
2496
2477
  case ">=":
2497
- u.push(Ge(N, d));
2478
+ u.push(He(N, d));
2498
2479
  break;
2499
2480
  case "<":
2500
2481
  u.push(we(N, d));
@@ -2506,11 +2487,11 @@ function pe(n, i, e) {
2506
2487
  u.push(a(N, d));
2507
2488
  }
2508
2489
  } else if (d) {
2509
- const A = (d.includes("|") ? [...e, "user_id"] : e).map((W) => {
2490
+ const B = (d.includes("|") ? [...e, "user_id"] : e).map((W) => {
2510
2491
  const H = n[W];
2511
2492
  return H ? W === "user_id" ? a(H, d) : Ie(H, `%${d}%`) : null;
2512
2493
  }).filter(Boolean);
2513
- A.length > 0 && u.push(de(...A));
2494
+ B.length > 0 && u.push(de(...B));
2514
2495
  }
2515
2496
  if (u.length !== 0)
2516
2497
  return u.length === 1 ? u[0] : g(...u);
@@ -2550,7 +2531,7 @@ const kt = [
2550
2531
  "signed_request_object",
2551
2532
  "token_quota"
2552
2533
  ];
2553
- function Ue(n) {
2534
+ function Fe(n) {
2554
2535
  const { tenant_id: i, connections: e, ...t } = n, r = { ...t };
2555
2536
  for (const o of kt)
2556
2537
  r[o] = !!t[o];
@@ -2614,7 +2595,7 @@ function jr(n) {
2614
2595
  message: "Client already exists"
2615
2596
  }) : u;
2616
2597
  }
2617
- return Ue({ ...o, tenant_id: i });
2598
+ return Fe({ ...o, tenant_id: i });
2618
2599
  },
2619
2600
  async get(i, e) {
2620
2601
  const t = await n.select().from(I).where(
@@ -2623,12 +2604,12 @@ function jr(n) {
2623
2604
  a(I.client_id, e)
2624
2605
  )
2625
2606
  ).get();
2626
- return t ? Ue(t) : null;
2607
+ return t ? Fe(t) : null;
2627
2608
  },
2628
2609
  async getByClientId(i) {
2629
2610
  const e = await n.select().from(I).where(a(I.client_id, i)).get();
2630
2611
  return e ? {
2631
- ...Ue(e),
2612
+ ...Fe(e),
2632
2613
  tenant_id: e.tenant_id
2633
2614
  } : null;
2634
2615
  },
@@ -2654,7 +2635,7 @@ function jr(n) {
2654
2635
  } = e || {};
2655
2636
  let u = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
2656
2637
  if (_) {
2657
- const f = pe(I, _, ["name", "client_id"]);
2638
+ const f = me(I, _, ["name", "client_id"]);
2658
2639
  f && (u = u.where(g(a(I.tenant_id, i), f)));
2659
2640
  }
2660
2641
  if (l != null && l.sort_by) {
@@ -2663,15 +2644,15 @@ function jr(n) {
2663
2644
  l.sort_order === "desc" ? V(f) : G(f)
2664
2645
  ));
2665
2646
  }
2666
- const d = (await u.offset(t * r).limit(r)).map(Ue);
2647
+ const d = (await u.offset(t * r).limit(r)).map(Fe);
2667
2648
  if (!o)
2668
2649
  return { clients: d };
2669
- const [m] = await n.select({ count: R() }).from(I).where(a(I.tenant_id, i));
2650
+ const [h] = await n.select({ count: R() }).from(I).where(a(I.tenant_id, i));
2670
2651
  return {
2671
2652
  clients: d,
2672
2653
  start: t * r,
2673
2654
  limit: r,
2674
- length: Number((m == null ? void 0 : m.count) ?? 0)
2655
+ length: Number((h == null ? void 0 : h.count) ?? 0)
2675
2656
  };
2676
2657
  },
2677
2658
  async remove(i, e) {
@@ -2792,7 +2773,7 @@ let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr
2792
2773
  i += Rr[e[n] & 63];
2793
2774
  return i;
2794
2775
  };
2795
- function nt(n) {
2776
+ function tt(n) {
2796
2777
  const {
2797
2778
  tenant_id: i,
2798
2779
  scope: e,
@@ -2831,13 +2812,13 @@ function Yr(n) {
2831
2812
  created_at: t,
2832
2813
  updated_at: t
2833
2814
  };
2834
- return await n.insert(Y).values(o), nt({ ...o, tenant_id: i });
2815
+ return await n.insert(Y).values(o), tt({ ...o, tenant_id: i });
2835
2816
  },
2836
2817
  async get(i, e) {
2837
2818
  const t = await n.select().from(Y).where(
2838
2819
  g(a(Y.tenant_id, i), a(Y.id, e))
2839
2820
  ).get();
2840
- return t ? nt(t) : null;
2821
+ return t ? tt(t) : null;
2841
2822
  },
2842
2823
  async update(i, e, t) {
2843
2824
  const {
@@ -2863,7 +2844,7 @@ function Yr(n) {
2863
2844
  include_totals: o = !1,
2864
2845
  sort: l,
2865
2846
  q: _
2866
- } = e || {}, u = _ ? pe(Y, _, ["client_id", "audience"]) : void 0, c = u ? g(a(Y.tenant_id, i), u) : a(Y.tenant_id, i);
2847
+ } = e || {}, u = _ ? me(Y, _, ["client_id", "audience"]) : void 0, c = u ? g(a(Y.tenant_id, i), u) : a(Y.tenant_id, i);
2867
2848
  let d = n.select().from(Y).where(c).$dynamic();
2868
2849
  if (l != null && l.sort_by) {
2869
2850
  const N = Y[l.sort_by];
@@ -2872,7 +2853,7 @@ function Yr(n) {
2872
2853
  ));
2873
2854
  } else
2874
2855
  d = d.orderBy(G(Y.created_at));
2875
- const f = (await d.offset(t * r).limit(r)).map(nt);
2856
+ const f = (await d.offset(t * r).limit(r)).map(tt);
2876
2857
  if (!o)
2877
2858
  return { client_grants: f };
2878
2859
  const [y] = await n.select({ count: R() }).from(Y).where(c);
@@ -2890,7 +2871,7 @@ function Yr(n) {
2890
2871
  }
2891
2872
  };
2892
2873
  }
2893
- function it(n) {
2874
+ function nt(n) {
2894
2875
  const { tenant_id: i, ...e } = n;
2895
2876
  return z(e);
2896
2877
  }
@@ -2903,19 +2884,19 @@ function Xr(n) {
2903
2884
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
2904
2885
  expires_at: e.expires_at
2905
2886
  };
2906
- return await n.insert(P).values(t), it(t);
2887
+ return await n.insert(Q).values(t), nt(t);
2907
2888
  },
2908
2889
  async get(i, e, t) {
2909
2890
  if (!i)
2910
2891
  throw new Error("tenant_id is required");
2911
- const r = await n.select().from(P).where(
2892
+ const r = await n.select().from(Q).where(
2912
2893
  g(
2913
- a(P.tenant_id, i),
2914
- a(P.code_id, e),
2915
- a(P.code_type, t)
2894
+ a(Q.tenant_id, i),
2895
+ a(Q.code_id, e),
2896
+ a(Q.code_type, t)
2916
2897
  )
2917
2898
  ).get();
2918
- return r ? it(r) : null;
2899
+ return r ? nt(r) : null;
2919
2900
  },
2920
2901
  async list(i, e) {
2921
2902
  const {
@@ -2924,17 +2905,17 @@ function Xr(n) {
2924
2905
  include_totals: o = !1,
2925
2906
  sort: l
2926
2907
  } = e || {};
2927
- let _ = n.select().from(P).where(a(P.tenant_id, i)).$dynamic();
2908
+ let _ = n.select().from(Q).where(a(Q.tenant_id, i)).$dynamic();
2928
2909
  if (l != null && l.sort_by) {
2929
- const m = P[l.sort_by];
2930
- m && (_ = _.orderBy(
2931
- l.sort_order === "desc" ? V(m) : G(m)
2910
+ const h = Q[l.sort_by];
2911
+ h && (_ = _.orderBy(
2912
+ l.sort_order === "desc" ? V(h) : G(h)
2932
2913
  ));
2933
2914
  }
2934
- const c = (await _.offset(t * r).limit(r)).map(it);
2915
+ const c = (await _.offset(t * r).limit(r)).map(nt);
2935
2916
  if (!o)
2936
2917
  return { codes: c };
2937
- const [d] = await n.select({ count: R() }).from(P).where(a(P.tenant_id, i));
2918
+ const [d] = await n.select({ count: R() }).from(Q).where(a(Q.tenant_id, i));
2938
2919
  return {
2939
2920
  codes: c,
2940
2921
  start: t * r,
@@ -2943,19 +2924,19 @@ function Xr(n) {
2943
2924
  };
2944
2925
  },
2945
2926
  async used(i, e) {
2946
- return (await n.update(P).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(g(a(P.tenant_id, i), a(P.code_id, e))).returning()).length > 0;
2927
+ return (await n.update(Q).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(g(a(Q.tenant_id, i), a(Q.code_id, e))).returning()).length > 0;
2947
2928
  },
2948
2929
  async consume(i, e) {
2949
- return (await n.update(P).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
2930
+ return (await n.update(Q).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
2950
2931
  g(
2951
- a(P.tenant_id, i),
2952
- a(P.code_id, e),
2953
- ye(P.used_at)
2932
+ a(Q.tenant_id, i),
2933
+ a(Q.code_id, e),
2934
+ ye(Q.used_at)
2954
2935
  )
2955
2936
  ).returning()).length > 0;
2956
2937
  },
2957
2938
  async remove(i, e) {
2958
- return (await n.delete(P).where(g(a(P.tenant_id, i), a(P.code_id, e))).returning()).length > 0;
2939
+ return (await n.delete(Q).where(g(a(Q.tenant_id, i), a(Q.code_id, e))).returning()).length > 0;
2959
2940
  }
2960
2941
  };
2961
2942
  }
@@ -2963,7 +2944,7 @@ function Zr() {
2963
2944
  const { customAlphabet: n } = require("nanoid");
2964
2945
  return `con_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
2965
2946
  }
2966
- function rt(n) {
2947
+ function it(n) {
2967
2948
  const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
2968
2949
  return z({
2969
2950
  ...o,
@@ -2993,7 +2974,7 @@ function es(n) {
2993
2974
  message: "Connection already exists"
2994
2975
  }) : _;
2995
2976
  }
2996
- return rt(r);
2977
+ return it(r);
2997
2978
  },
2998
2979
  async get(i, e) {
2999
2980
  const t = await n.select().from(K).where(
@@ -3002,7 +2983,7 @@ function es(n) {
3002
2983
  a(K.id, e)
3003
2984
  )
3004
2985
  ).get();
3005
- return t ? rt(t) : null;
2986
+ return t ? it(t) : null;
3006
2987
  },
3007
2988
  async update(i, e, t) {
3008
2989
  const r = {
@@ -3025,7 +3006,7 @@ function es(n) {
3025
3006
  } = e || {};
3026
3007
  let u = a(K.tenant_id, i);
3027
3008
  if (_) {
3028
- const y = pe(K, _, ["name"]);
3009
+ const y = me(K, _, ["name"]);
3029
3010
  y && (u = g(u, y));
3030
3011
  }
3031
3012
  let c = n.select().from(K).where(u).$dynamic();
@@ -3035,12 +3016,12 @@ function es(n) {
3035
3016
  l.sort_order === "desc" ? V(y) : G(y)
3036
3017
  ));
3037
3018
  }
3038
- const m = (await c.offset(t * r).limit(r)).map(rt);
3019
+ const h = (await c.offset(t * r).limit(r)).map(it);
3039
3020
  if (!o)
3040
- return { connections: m };
3021
+ return { connections: h };
3041
3022
  const [f] = await n.select({ count: R() }).from(K).where(u);
3042
3023
  return {
3043
- connections: m,
3024
+ connections: h,
3044
3025
  start: t * r,
3045
3026
  limit: r,
3046
3027
  length: Number((f == null ? void 0 : f.count) ?? 0)
@@ -3056,7 +3037,7 @@ function es(n) {
3056
3037
  }
3057
3038
  };
3058
3039
  }
3059
- function Ke(n) {
3040
+ function Ue(n) {
3060
3041
  const { tenant_id: i, domain_metadata: e, ...t } = n;
3061
3042
  return z({
3062
3043
  ...t,
@@ -3082,7 +3063,7 @@ function ts(n) {
3082
3063
  created_at: t,
3083
3064
  updated_at: t
3084
3065
  };
3085
- return await n.insert(se).values(o), Ke({ ...o, tenant_id: i });
3066
+ return await n.insert(se).values(o), Ue({ ...o, tenant_id: i });
3086
3067
  },
3087
3068
  async get(i, e) {
3088
3069
  const t = await n.select().from(se).where(
@@ -3091,17 +3072,17 @@ function ts(n) {
3091
3072
  a(se.custom_domain_id, e)
3092
3073
  )
3093
3074
  ).get();
3094
- return t ? Ke(t) : null;
3075
+ return t ? Ue(t) : null;
3095
3076
  },
3096
3077
  async getByDomain(i) {
3097
3078
  const e = await n.select().from(se).where(a(se.domain, i)).get();
3098
3079
  return e ? {
3099
- ...Ke(e),
3080
+ ...Ue(e),
3100
3081
  tenant_id: e.tenant_id
3101
3082
  } : null;
3102
3083
  },
3103
3084
  async list(i) {
3104
- return (await n.select().from(se).where(a(se.tenant_id, i)).all()).map(Ke);
3085
+ return (await n.select().from(se).where(a(se.tenant_id, i)).all()).map(Ue);
3105
3086
  },
3106
3087
  async update(i, e, t) {
3107
3088
  const r = {
@@ -3256,13 +3237,13 @@ function rs(n) {
3256
3237
  } = e || {};
3257
3238
  let _ = n.select().from(re).where(a(re.tenant_id, i)).$dynamic();
3258
3239
  if (l != null && l.sort_by) {
3259
- const m = re[l.sort_by];
3260
- m && (_ = _.orderBy(
3261
- l.sort_order === "desc" ? V(m) : G(m)
3240
+ const h = re[l.sort_by];
3241
+ h && (_ = _.orderBy(
3242
+ l.sort_order === "desc" ? V(h) : G(h)
3262
3243
  ));
3263
3244
  }
3264
- const c = (await _.offset(t * r).limit(r)).map((m) => {
3265
- const { tenant_id: f, actions: y, ...N } = m;
3245
+ const c = (await _.offset(t * r).limit(r)).map((h) => {
3246
+ const { tenant_id: f, actions: y, ...N } = h;
3266
3247
  return z({
3267
3248
  ...N,
3268
3249
  actions: x(y, [])
@@ -3283,7 +3264,7 @@ function rs(n) {
3283
3264
  }
3284
3265
  };
3285
3266
  }
3286
- const je = ["nodes", "start", "ending"];
3267
+ const Ke = ["nodes", "start", "ending"];
3287
3268
  function ss(n) {
3288
3269
  return {
3289
3270
  async create(i, e) {
@@ -3298,7 +3279,7 @@ function ss(n) {
3298
3279
  created_at: t,
3299
3280
  updated_at: t
3300
3281
  };
3301
- for (const l of je)
3282
+ for (const l of Ke)
3302
3283
  o[l] = JSON.stringify(
3303
3284
  e[l] || (l === "nodes" ? [] : {})
3304
3285
  );
@@ -3313,7 +3294,7 @@ function ss(n) {
3313
3294
  const t = await n.select().from(ie).where(g(a(ie.tenant_id, i), a(ie.id, e))).get();
3314
3295
  if (!t) return null;
3315
3296
  const { tenant_id: r, ...o } = t, l = { ...o };
3316
- for (const _ of je)
3297
+ for (const _ of Ke)
3317
3298
  l[_] = x(o[_]);
3318
3299
  return z(l);
3319
3300
  },
@@ -3322,7 +3303,7 @@ function ss(n) {
3322
3303
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3323
3304
  };
3324
3305
  for (const [l, _] of Object.entries(t))
3325
- _ !== void 0 && (je.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
3306
+ _ !== void 0 && (Ke.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
3326
3307
  return (await n.update(ie).set(r).where(g(a(ie.tenant_id, i), a(ie.id, e))).returning()).length > 0;
3327
3308
  },
3328
3309
  async list(i, e) {
@@ -3334,15 +3315,15 @@ function ss(n) {
3334
3315
  } = e || {};
3335
3316
  let _ = n.select().from(ie).where(a(ie.tenant_id, i)).$dynamic();
3336
3317
  if (l != null && l.sort_by) {
3337
- const m = ie[l.sort_by];
3338
- m && (_ = _.orderBy(
3339
- l.sort_order === "desc" ? V(m) : G(m)
3318
+ const h = ie[l.sort_by];
3319
+ h && (_ = _.orderBy(
3320
+ l.sort_order === "desc" ? V(h) : G(h)
3340
3321
  ));
3341
3322
  }
3342
- const c = (await _.offset(t * r).limit(r)).map((m) => {
3343
- const { tenant_id: f, ...y } = m, N = { ...y };
3344
- for (const A of je)
3345
- N[A] = x(y[A]);
3323
+ const c = (await _.offset(t * r).limit(r)).map((h) => {
3324
+ const { tenant_id: f, ...y } = h, N = { ...y };
3325
+ for (const B of Ke)
3326
+ N[B] = x(y[B]);
3346
3327
  return z(N);
3347
3328
  });
3348
3329
  if (!o)
@@ -3360,7 +3341,7 @@ function ss(n) {
3360
3341
  }
3361
3342
  };
3362
3343
  }
3363
- function hr(n) {
3344
+ function pr(n) {
3364
3345
  if (n != null) {
3365
3346
  if (typeof n == "number")
3366
3347
  return new Date(n).toISOString();
@@ -3373,7 +3354,7 @@ function hr(n) {
3373
3354
  }
3374
3355
  }
3375
3356
  function wt(n, i = (/* @__PURE__ */ new Date(0)).toISOString()) {
3376
- return hr(n) ?? i;
3357
+ return pr(n) ?? i;
3377
3358
  }
3378
3359
  function j(n) {
3379
3360
  if (!n || n === "")
@@ -3381,7 +3362,7 @@ function j(n) {
3381
3362
  const i = new Date(n);
3382
3363
  return isNaN(i.getTime()) ? null : i.getTime();
3383
3364
  }
3384
- function Fe(n, i, e = []) {
3365
+ function Pe(n, i, e = []) {
3385
3366
  const t = {};
3386
3367
  for (const r of i) {
3387
3368
  const o = r.replace(/_ts$/, "");
@@ -3389,7 +3370,7 @@ function Fe(n, i, e = []) {
3389
3370
  }
3390
3371
  for (const r of e) {
3391
3372
  const o = r.replace(/_ts$/, "");
3392
- t[o] = hr(n[r]);
3373
+ t[o] = pr(n[r]);
3393
3374
  }
3394
3375
  return t;
3395
3376
  }
@@ -3398,7 +3379,7 @@ function as() {
3398
3379
  return `hc_${os()}`;
3399
3380
  }
3400
3381
  function At(n) {
3401
- const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Fe({ created_at_ts: i, updated_at_ts: e }, [
3382
+ const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Pe({ created_at_ts: i, updated_at_ts: e }, [
3402
3383
  "created_at_ts",
3403
3384
  "updated_at_ts"
3404
3385
  ]);
@@ -3419,20 +3400,20 @@ function ls(n) {
3419
3400
  created_at_ts: t,
3420
3401
  updated_at_ts: t
3421
3402
  };
3422
- return await n.insert(he).values(o), At({ ...o, tenant_id: i });
3403
+ return await n.insert(pe).values(o), At({ ...o, tenant_id: i });
3423
3404
  },
3424
3405
  async get(i, e) {
3425
- const t = await n.select().from(he).where(g(a(he.tenant_id, i), a(he.id, e))).get();
3406
+ const t = await n.select().from(pe).where(g(a(pe.tenant_id, i), a(pe.id, e))).get();
3426
3407
  return t ? At(t) : null;
3427
3408
  },
3428
3409
  async update(i, e, t) {
3429
3410
  const r = {
3430
3411
  updated_at_ts: Date.now()
3431
3412
  };
3432
- return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(he).set(r).where(g(a(he.tenant_id, i), a(he.id, e))).returning()).length > 0;
3413
+ return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(pe).set(r).where(g(a(pe.tenant_id, i), a(pe.id, e))).returning()).length > 0;
3433
3414
  },
3434
3415
  async remove(i, e) {
3435
- return (await n.delete(he).where(g(a(he.tenant_id, i), a(he.id, e))).returning()).length > 0;
3416
+ return (await n.delete(pe).where(g(a(pe.tenant_id, i), a(pe.id, e))).returning()).length > 0;
3436
3417
  }
3437
3418
  };
3438
3419
  }
@@ -3440,8 +3421,8 @@ function _s() {
3440
3421
  const { customAlphabet: n } = require("nanoid");
3441
3422
  return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3442
3423
  }
3443
- function st(n) {
3444
- const { tenant_id: i, created_at_ts: e, updated_at_ts: t, ...r } = n, o = Fe({ created_at_ts: e, updated_at_ts: t }, [
3424
+ function rt(n) {
3425
+ const { tenant_id: i, created_at_ts: e, updated_at_ts: t, ...r } = n, o = Pe({ created_at_ts: e, updated_at_ts: t }, [
3445
3426
  "created_at_ts",
3446
3427
  "updated_at_ts"
3447
3428
  ]);
@@ -3469,11 +3450,11 @@ function us(n) {
3469
3450
  created_at_ts: t,
3470
3451
  updated_at_ts: t
3471
3452
  };
3472
- return await n.insert(ee).values(o), st({ ...o, tenant_id: i });
3453
+ return await n.insert(ee).values(o), rt({ ...o, tenant_id: i });
3473
3454
  },
3474
3455
  async get(i, e) {
3475
3456
  const t = await n.select().from(ee).where(g(a(ee.tenant_id, i), a(ee.hook_id, e))).get();
3476
- return t ? st(t) : null;
3457
+ return t ? rt(t) : null;
3477
3458
  },
3478
3459
  async update(i, e, t) {
3479
3460
  const r = {
@@ -3488,7 +3469,7 @@ function us(n) {
3488
3469
  include_totals: o = !1,
3489
3470
  sort: l,
3490
3471
  q: _
3491
- } = e || {}, u = _ ? pe(ee, _, [
3472
+ } = e || {}, u = _ ? me(ee, _, [
3492
3473
  "url",
3493
3474
  "form_id",
3494
3475
  "template_id",
@@ -3501,7 +3482,7 @@ function us(n) {
3501
3482
  l.sort_order === "desc" ? V(N) : G(N)
3502
3483
  ));
3503
3484
  }
3504
- const f = (await d.offset(t * r).limit(r)).map(st);
3485
+ const f = (await d.offset(t * r).limit(r)).map(rt);
3505
3486
  if (!o)
3506
3487
  return { hooks: f };
3507
3488
  const [y] = await n.select({ count: R() }).from(ee).where(c);
@@ -3528,7 +3509,7 @@ const Nt = [
3528
3509
  "user_metadata",
3529
3510
  "roles"
3530
3511
  ];
3531
- function ot(n) {
3512
+ function st(n) {
3532
3513
  const { tenant_id: i, send_invitation_email: e, ...t } = n, r = { ...t };
3533
3514
  for (const o of Nt)
3534
3515
  r[o] = x(t[o], o === "roles" ? [] : {});
@@ -3558,11 +3539,11 @@ function cs(n) {
3558
3539
  } catch (d) {
3559
3540
  throw (u = d == null ? void 0 : d.message) != null && u.includes("UNIQUE constraint failed") || (c = d == null ? void 0 : d.message) != null && c.includes("duplicate key") ? new be(409, { message: "Invite already exists" }) : d;
3560
3541
  }
3561
- return ot({ ..._, tenant_id: i });
3542
+ return st({ ..._, tenant_id: i });
3562
3543
  },
3563
3544
  async get(i, e) {
3564
3545
  const t = await n.select().from(ne).where(g(a(ne.tenant_id, i), a(ne.id, e))).get();
3565
- return t ? ot(t) : null;
3546
+ return t ? st(t) : null;
3566
3547
  },
3567
3548
  async update(i, e, t) {
3568
3549
  const r = {};
@@ -3581,12 +3562,12 @@ function cs(n) {
3581
3562
  } = e || {};
3582
3563
  let _ = n.select().from(ne).where(a(ne.tenant_id, i)).$dynamic();
3583
3564
  if (l != null && l.sort_by) {
3584
- const m = ne[l.sort_by];
3585
- m && (_ = _.orderBy(
3586
- l.sort_order === "desc" ? V(m) : G(m)
3565
+ const h = ne[l.sort_by];
3566
+ h && (_ = _.orderBy(
3567
+ l.sort_order === "desc" ? V(h) : G(h)
3587
3568
  ));
3588
3569
  }
3589
- const c = (await _.offset(t * r).limit(r)).map(ot);
3570
+ const c = (await _.offset(t * r).limit(r)).map(st);
3590
3571
  if (!o)
3591
3572
  return { invites: c };
3592
3573
  const [d] = await n.select({ count: R() }).from(ne).where(a(ne.tenant_id, i));
@@ -3605,7 +3586,7 @@ function cs(n) {
3605
3586
  function gs(n) {
3606
3587
  return {
3607
3588
  async create(i) {
3608
- await n.insert(me).values({
3589
+ await n.insert(he).values({
3609
3590
  ...i,
3610
3591
  created_at: (/* @__PURE__ */ new Date()).toDateString()
3611
3592
  });
@@ -3617,20 +3598,20 @@ function gs(n) {
3617
3598
  include_totals: r = !1,
3618
3599
  sort: o
3619
3600
  } = i || {}, l = (/* @__PURE__ */ new Date()).toISOString();
3620
- let _ = n.select().from(me).where(de(He(me.revoked_at, l), ye(me.revoked_at))).$dynamic();
3601
+ let _ = n.select().from(he).where(de(We(he.revoked_at, l), ye(he.revoked_at))).$dynamic();
3621
3602
  if (o != null && o.sort_by) {
3622
- const m = me[o.sort_by];
3623
- m && (_ = _.orderBy(
3624
- o.sort_order === "desc" ? V(m) : G(m)
3603
+ const h = he[o.sort_by];
3604
+ h && (_ = _.orderBy(
3605
+ o.sort_order === "desc" ? V(h) : G(h)
3625
3606
  ));
3626
3607
  }
3627
- const c = (await _.offset(e * t).limit(t)).map((m) => {
3628
- const { created_at: f, ...y } = m;
3608
+ const c = (await _.offset(e * t).limit(t)).map((h) => {
3609
+ const { created_at: f, ...y } = h;
3629
3610
  return z(y);
3630
3611
  });
3631
3612
  if (!r)
3632
3613
  return { signingKeys: c };
3633
- const [d] = await n.select({ count: R() }).from(me).where(de(He(me.revoked_at, l), ye(me.revoked_at)));
3614
+ const [d] = await n.select({ count: R() }).from(he).where(de(We(he.revoked_at, l), ye(he.revoked_at)));
3634
3615
  return {
3635
3616
  signingKeys: c,
3636
3617
  start: e * t,
@@ -3639,19 +3620,19 @@ function gs(n) {
3639
3620
  };
3640
3621
  },
3641
3622
  async update(i, e) {
3642
- return (await n.update(me).set(e).where(a(me.kid, i)).returning()).length > 0;
3623
+ return (await n.update(he).set(e).where(a(he.kid, i)).returning()).length > 0;
3643
3624
  }
3644
3625
  };
3645
3626
  }
3646
- const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", at = vt.length;
3627
+ const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ot = vt.length;
3647
3628
  function fs() {
3648
3629
  let e = Date.now(), t = "";
3649
3630
  for (let o = 10; o > 0; o--)
3650
- t = vt.charAt(e % at) + t, e = Math.floor(e / at);
3631
+ t = vt.charAt(e % ot) + t, e = Math.floor(e / ot);
3651
3632
  const r = new Uint8Array(16);
3652
3633
  crypto.getRandomValues(r);
3653
3634
  for (let o = 0; o < 16; o++)
3654
- t += vt.charAt(r[o] % at);
3635
+ t += vt.charAt(r[o] % ot);
3655
3636
  return t;
3656
3637
  }
3657
3638
  function Bt(n) {
@@ -3661,35 +3642,32 @@ function Bt(n) {
3661
3642
  updated_at_ts: t,
3662
3643
  expires_at_ts: r,
3663
3644
  state_data: o,
3664
- ...l
3665
- } = n, _ = Fe(
3645
+ auth_params: l,
3646
+ ..._
3647
+ } = n, u = Pe(
3666
3648
  { created_at_ts: e, updated_at_ts: t, expires_at_ts: r },
3667
3649
  ["created_at_ts", "updated_at_ts", "expires_at_ts"]
3668
- ), u = {};
3669
- for (const [d, m] of Object.entries(l))
3670
- m != null && (u[d] = m);
3671
- const c = fr(u, [
3672
- "authParams",
3673
- "auth_strategy"
3674
- ]);
3650
+ ), c = {};
3651
+ for (const [h, f] of Object.entries(_))
3652
+ f != null && (c[h] = f);
3653
+ const d = fr(c, ["auth_strategy"]);
3675
3654
  return z({
3676
- ...c,
3677
- ..._,
3655
+ ...d,
3656
+ authParams: typeof l == "string" && l.length > 0 ? JSON.parse(l) : {},
3657
+ ...u,
3678
3658
  state_data: x(o)
3679
3659
  });
3680
3660
  }
3681
- function hs(n) {
3661
+ function ps(n) {
3682
3662
  return {
3683
3663
  async create(i, e) {
3684
- var _, u;
3685
- const t = Date.now(), r = fs(), o = Pe(
3686
- { authParams: e.authParams || {} },
3687
- "authParams"
3688
- ), l = {
3689
- id: r,
3664
+ var l, _;
3665
+ const t = Date.now(), o = {
3666
+ id: fs(),
3690
3667
  tenant_id: i,
3691
3668
  session_id: e.session_id,
3692
3669
  csrf_token: e.csrf_token,
3670
+ auth_params: JSON.stringify(e.authParams || {}),
3693
3671
  authorization_url: e.authorization_url ? e.authorization_url.substring(0, 1024) : void 0,
3694
3672
  ip: e.ip,
3695
3673
  useragent: e.useragent,
@@ -3699,19 +3677,17 @@ function hs(n) {
3699
3677
  failure_reason: e.failure_reason,
3700
3678
  user_id: e.user_id,
3701
3679
  auth_connection: e.auth_connection,
3702
- auth_strategy_strategy: (_ = e.auth_strategy) == null ? void 0 : _.strategy,
3703
- auth_strategy_strategy_type: (u = e.auth_strategy) == null ? void 0 : u.strategy_type,
3680
+ auth_strategy_strategy: (l = e.auth_strategy) == null ? void 0 : l.strategy,
3681
+ auth_strategy_strategy_type: (_ = e.auth_strategy) == null ? void 0 : _.strategy_type,
3704
3682
  authenticated_at: e.authenticated_at,
3705
3683
  created_at_ts: t,
3706
3684
  updated_at_ts: t,
3707
3685
  expires_at_ts: e.expires_at ? j(e.expires_at) : t + 1e3 * 60 * 60 * 24
3708
3686
  };
3709
- for (const [c, d] of Object.entries(o))
3710
- l[c] = d;
3711
- return await n.insert(B).values(l), Bt({ ...l, tenant_id: i });
3687
+ return await n.insert(L).values(o), Bt({ ...o, tenant_id: i });
3712
3688
  },
3713
3689
  async get(i, e) {
3714
- const t = i ? g(a(B.tenant_id, i), a(B.id, e)) : a(B.id, e), r = await n.select().from(B).where(t).get();
3690
+ const t = i ? g(a(L.tenant_id, i), a(L.id, e)) : a(L.id, e), r = await n.select().from(L).where(t).get();
3715
3691
  return r ? Bt(r) : null;
3716
3692
  },
3717
3693
  async update(i, e, t) {
@@ -3722,25 +3698,30 @@ function hs(n) {
3722
3698
  if (t.session_id !== void 0 && (r.session_id = t.session_id), t.state !== void 0 && (r.state = t.state), t.state_data !== void 0 && (r.state_data = JSON.stringify(t.state_data)), t.failure_reason !== void 0 && (r.failure_reason = t.failure_reason), t.user_id !== void 0 && (r.user_id = t.user_id), t.auth_connection !== void 0 && (r.auth_connection = t.auth_connection), t.auth_strategy !== void 0 && (r.auth_strategy_strategy = (o = t.auth_strategy) == null ? void 0 : o.strategy, r.auth_strategy_strategy_type = (l = t.auth_strategy) == null ? void 0 : l.strategy_type), t.authenticated_at !== void 0 && (r.authenticated_at = t.authenticated_at), t.authorization_url !== void 0 && (r.authorization_url = (_ = t.authorization_url) == null ? void 0 : _.substring(
3723
3699
  0,
3724
3700
  1024
3725
- )), t.expires_at !== void 0 && (r.expires_at_ts = j(t.expires_at)), t.authParams) {
3726
- const u = Pe(
3727
- { authParams: t.authParams },
3728
- "authParams"
3729
- );
3730
- Object.assign(r, u);
3701
+ )), t.expires_at !== void 0 && (r.expires_at_ts = j(t.expires_at)), t.authParams !== void 0) {
3702
+ const u = await n.select({ auth_params: L.auth_params }).from(L).where(
3703
+ g(
3704
+ a(L.tenant_id, i),
3705
+ a(L.id, e)
3706
+ )
3707
+ ).get(), c = u != null && u.auth_params && typeof u.auth_params == "string" && u.auth_params.length > 0 ? JSON.parse(u.auth_params) : {};
3708
+ r.auth_params = JSON.stringify({
3709
+ ...c,
3710
+ ...t.authParams
3711
+ });
3731
3712
  }
3732
- return await n.update(B).set(r).where(
3733
- g(a(B.tenant_id, i), a(B.id, e))
3713
+ return await n.update(L).set(r).where(
3714
+ g(a(L.tenant_id, i), a(L.id, e))
3734
3715
  ), !0;
3735
3716
  },
3736
3717
  async remove(i, e) {
3737
- return (await n.delete(B).where(
3738
- g(a(B.tenant_id, i), a(B.id, e))
3718
+ return (await n.delete(L).where(
3719
+ g(a(L.tenant_id, i), a(L.id, e))
3739
3720
  ).returning()).length > 0;
3740
3721
  }
3741
3722
  };
3742
3723
  }
3743
- function lt(n) {
3724
+ function at(n) {
3744
3725
  const {
3745
3726
  tenant_id: i,
3746
3727
  isMobile: e,
@@ -3752,14 +3733,14 @@ function lt(n) {
3752
3733
  longitude: u,
3753
3734
  time_zone: c,
3754
3735
  continent_code: d,
3755
- scope: m,
3736
+ scope: h,
3756
3737
  ...f
3757
3738
  } = n, y = {
3758
3739
  ...f,
3759
3740
  isMobile: !!e,
3760
3741
  auth0_client: x(t),
3761
3742
  details: x(r),
3762
- scope: m ? m.split(",") : void 0
3743
+ scope: h ? h.split(",") : void 0
3763
3744
  };
3764
3745
  return o && (y.location_info = z({
3765
3746
  country_code: o,
@@ -3770,7 +3751,7 @@ function lt(n) {
3770
3751
  continent_code: d
3771
3752
  })), z(y);
3772
3753
  }
3773
- function ms(n) {
3754
+ function hs(n) {
3774
3755
  return {
3775
3756
  async create(i, e) {
3776
3757
  var o, l;
@@ -3797,7 +3778,7 @@ function ms(n) {
3797
3778
  hostname: e.hostname,
3798
3779
  session_connection: e.session_connection
3799
3780
  };
3800
- return e.auth0_client && (r.auth0_client = JSON.stringify(e.auth0_client)), e.details && (r.details = JSON.stringify(e.details).substring(0, 8192)), e.location_info && (r.country_code = e.location_info.country_code, r.city_name = e.location_info.city_name, r.latitude = e.location_info.latitude, r.longitude = e.location_info.longitude, r.time_zone = e.location_info.time_zone, r.continent_code = e.location_info.continent_code), await n.insert(q).values(r), lt({ ...r, tenant_id: i });
3781
+ return e.auth0_client && (r.auth0_client = JSON.stringify(e.auth0_client)), e.details && (r.details = JSON.stringify(e.details).substring(0, 8192)), e.location_info && (r.country_code = e.location_info.country_code, r.city_name = e.location_info.city_name, r.latitude = e.location_info.latitude, r.longitude = e.location_info.longitude, r.time_zone = e.location_info.time_zone, r.continent_code = e.location_info.continent_code), await n.insert(q).values(r), at({ ...r, tenant_id: i });
3801
3782
  },
3802
3783
  async list(i, e) {
3803
3784
  const {
@@ -3809,7 +3790,7 @@ function ms(n) {
3809
3790
  } = e || {};
3810
3791
  let u = n.select().from(q).where(a(q.tenant_id, i)).$dynamic();
3811
3792
  if (_) {
3812
- const f = pe(q, _, [
3793
+ const f = me(q, _, [
3813
3794
  "user_id",
3814
3795
  "ip",
3815
3796
  "type",
@@ -3824,35 +3805,35 @@ function ms(n) {
3824
3805
  ));
3825
3806
  } else
3826
3807
  u = u.orderBy(V(q.date));
3827
- const d = (await u.offset(t * r).limit(r)).map(lt);
3808
+ const d = (await u.offset(t * r).limit(r)).map(at);
3828
3809
  if (!o)
3829
3810
  return { logs: d };
3830
- const [m] = await n.select({ count: R() }).from(q).where(a(q.tenant_id, i));
3811
+ const [h] = await n.select({ count: R() }).from(q).where(a(q.tenant_id, i));
3831
3812
  return {
3832
3813
  logs: d,
3833
3814
  start: t * r,
3834
3815
  limit: r,
3835
- length: Number((m == null ? void 0 : m.count) ?? 0)
3816
+ length: Number((h == null ? void 0 : h.count) ?? 0)
3836
3817
  };
3837
3818
  },
3838
3819
  async get(i, e) {
3839
3820
  const t = await n.select().from(q).where(g(a(q.tenant_id, i), a(q.log_id, e))).get();
3840
- return t ? lt(t) : null;
3821
+ return t ? at(t) : null;
3841
3822
  }
3842
3823
  };
3843
3824
  }
3844
- const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", _t = St.length;
3845
- function ps() {
3825
+ const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", lt = St.length;
3826
+ function ms() {
3846
3827
  let e = Date.now(), t = "";
3847
3828
  for (let o = 10; o > 0; o--)
3848
- t = St.charAt(e % _t) + t, e = Math.floor(e / _t);
3829
+ t = St.charAt(e % lt) + t, e = Math.floor(e / lt);
3849
3830
  const r = new Uint8Array(16);
3850
3831
  crypto.getRandomValues(r);
3851
3832
  for (let o = 0; o < 16; o++)
3852
- t += St.charAt(r[o] % _t);
3833
+ t += St.charAt(r[o] % lt);
3853
3834
  return t;
3854
3835
  }
3855
- function Me(n) {
3836
+ function je(n) {
3856
3837
  const {
3857
3838
  tenant_id: i,
3858
3839
  created_at_ts: e,
@@ -3875,7 +3856,7 @@ function ys(n) {
3875
3856
  return {
3876
3857
  async create(i, e) {
3877
3858
  const t = Date.now(), o = {
3878
- id: e.id || ps(),
3859
+ id: e.id || ms(),
3879
3860
  tenant_id: i,
3880
3861
  user_id: e.user_id,
3881
3862
  type: e.type,
@@ -3891,7 +3872,7 @@ function ys(n) {
3891
3872
  created_at_ts: t,
3892
3873
  updated_at_ts: t
3893
3874
  };
3894
- return await n.insert(U).values(o), Me({ ...o, tenant_id: i });
3875
+ return await n.insert(U).values(o), je({ ...o, tenant_id: i });
3895
3876
  },
3896
3877
  async get(i, e) {
3897
3878
  const t = await n.select().from(U).where(
@@ -3900,7 +3881,7 @@ function ys(n) {
3900
3881
  a(U.id, e)
3901
3882
  )
3902
3883
  ).get();
3903
- return t ? Me(t) : null;
3884
+ return t ? je(t) : null;
3904
3885
  },
3905
3886
  async getByCredentialId(i, e) {
3906
3887
  const t = await n.select().from(U).where(
@@ -3909,7 +3890,7 @@ function ys(n) {
3909
3890
  a(U.credential_id, e)
3910
3891
  )
3911
3892
  ).get();
3912
- return t ? Me(t) : null;
3893
+ return t ? je(t) : null;
3913
3894
  },
3914
3895
  async list(i, e) {
3915
3896
  return (await n.select().from(U).where(
@@ -3917,7 +3898,7 @@ function ys(n) {
3917
3898
  a(U.tenant_id, i),
3918
3899
  a(U.user_id, e)
3919
3900
  )
3920
- ).all()).map(Me);
3901
+ ).all()).map(je);
3921
3902
  },
3922
3903
  async update(i, e, t) {
3923
3904
  const r = {
@@ -3950,7 +3931,7 @@ function ws() {
3950
3931
  const { customAlphabet: n } = require("nanoid");
3951
3932
  return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3952
3933
  }
3953
- function ut(n) {
3934
+ function _t(n) {
3954
3935
  const {
3955
3936
  tenant_id: i,
3956
3937
  branding: e,
@@ -3984,24 +3965,24 @@ function Ns(n) {
3984
3965
  updated_at: t
3985
3966
  };
3986
3967
  try {
3987
- await n.insert(L).values(o);
3968
+ await n.insert(E).values(o);
3988
3969
  } catch (u) {
3989
3970
  throw (l = u == null ? void 0 : u.message) != null && l.includes("UNIQUE constraint failed") || (_ = u == null ? void 0 : u.message) != null && _.includes("AlreadyExists") ? new be(409, {
3990
3971
  message: "Organization already exists"
3991
3972
  }) : u;
3992
3973
  }
3993
- return ut({ ...o, tenant_id: i });
3974
+ return _t({ ...o, tenant_id: i });
3994
3975
  },
3995
3976
  async get(i, e) {
3996
- let t = await n.select().from(L).where(
3997
- g(a(L.tenant_id, i), a(L.id, e))
3977
+ let t = await n.select().from(E).where(
3978
+ g(a(E.tenant_id, i), a(E.id, e))
3998
3979
  ).get();
3999
- return t || (t = await n.select().from(L).where(
3980
+ return t || (t = await n.select().from(E).where(
4000
3981
  g(
4001
- a(L.tenant_id, i),
4002
- a(L.name, e)
3982
+ a(E.tenant_id, i),
3983
+ a(E.name, e)
4003
3984
  )
4004
- ).get()), t ? ut(t) : null;
3985
+ ).get()), t ? _t(t) : null;
4005
3986
  },
4006
3987
  async update(i, e, t) {
4007
3988
  const r = {
@@ -4009,8 +3990,8 @@ function Ns(n) {
4009
3990
  };
4010
3991
  return t.name !== void 0 && (r.name = t.name), t.display_name !== void 0 && (r.display_name = t.display_name), t.branding !== void 0 && (r.branding = JSON.stringify(t.branding)), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.enabled_connections !== void 0 && (r.enabled_connections = JSON.stringify(
4011
3992
  t.enabled_connections
4012
- )), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(L).set(r).where(
4013
- g(a(L.tenant_id, i), a(L.id, e))
3993
+ )), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(E).set(r).where(
3994
+ g(a(E.tenant_id, i), a(E.id, e))
4014
3995
  ).returning()).length > 0;
4015
3996
  },
4016
3997
  async list(i, e) {
@@ -4021,29 +4002,29 @@ function Ns(n) {
4021
4002
  sort: l,
4022
4003
  q: _
4023
4004
  } = e || {};
4024
- let u = n.select().from(L).where(a(L.tenant_id, i)).$dynamic();
4005
+ let u = n.select().from(E).where(a(E.tenant_id, i)).$dynamic();
4025
4006
  if (_ && (u = u.where(
4026
4007
  de(
4027
- Ie(L.name, `%${_}%`),
4028
- Ie(L.display_name, `%${_}%`)
4008
+ Ie(E.name, `%${_}%`),
4009
+ Ie(E.display_name, `%${_}%`)
4029
4010
  )
4030
4011
  )), l != null && l.sort_by) {
4031
- const y = L[l.sort_by];
4012
+ const y = E[l.sort_by];
4032
4013
  y && (u = u.orderBy(
4033
4014
  l.sort_order === "desc" ? V(y) : G(y)
4034
4015
  ));
4035
4016
  }
4036
- const d = (await u.offset(t * r).limit(r)).map(ut);
4017
+ const d = (await u.offset(t * r).limit(r)).map(_t);
4037
4018
  if (!o)
4038
4019
  return { organizations: d };
4039
- const m = [a(L.tenant_id, i)];
4040
- _ && m.push(
4020
+ const h = [a(E.tenant_id, i)];
4021
+ _ && h.push(
4041
4022
  de(
4042
- Ie(L.name, `%${_}%`),
4043
- Ie(L.display_name, `%${_}%`)
4023
+ Ie(E.name, `%${_}%`),
4024
+ Ie(E.display_name, `%${_}%`)
4044
4025
  )
4045
4026
  );
4046
- const [f] = await n.select({ count: R() }).from(L).where(g(...m));
4027
+ const [f] = await n.select({ count: R() }).from(E).where(g(...h));
4047
4028
  return {
4048
4029
  organizations: d,
4049
4030
  start: t * r,
@@ -4052,13 +4033,13 @@ function Ns(n) {
4052
4033
  };
4053
4034
  },
4054
4035
  async remove(i, e) {
4055
- return (await n.delete(L).where(
4056
- g(a(L.tenant_id, i), a(L.id, e))
4036
+ return (await n.delete(E).where(
4037
+ g(a(E.tenant_id, i), a(E.id, e))
4057
4038
  ).returning()).length > 0;
4058
4039
  }
4059
4040
  };
4060
4041
  }
4061
- function dt(n) {
4042
+ function ut(n) {
4062
4043
  const { tenant_id: i, is_current: e, ...t } = n;
4063
4044
  return {
4064
4045
  ...t,
@@ -4069,10 +4050,10 @@ function vs(n) {
4069
4050
  return {
4070
4051
  async create(i, e) {
4071
4052
  const t = (/* @__PURE__ */ new Date()).toISOString(), r = e.id || ae();
4072
- e.is_current !== !1 && await n.update(C).set({ is_current: 0 }).where(
4053
+ e.is_current !== !1 && await n.update(A).set({ is_current: 0 }).where(
4073
4054
  g(
4074
- a(C.tenant_id, i),
4075
- a(C.user_id, e.user_id)
4055
+ a(A.tenant_id, i),
4056
+ a(A.user_id, e.user_id)
4076
4057
  )
4077
4058
  );
4078
4059
  const o = {
@@ -4085,41 +4066,41 @@ function vs(n) {
4085
4066
  created_at: t,
4086
4067
  updated_at: t
4087
4068
  };
4088
- return await n.insert(C).values(o), dt({ ...o, tenant_id: i });
4069
+ return await n.insert(A).values(o), ut({ ...o, tenant_id: i });
4089
4070
  },
4090
4071
  async get(i, e) {
4091
- const t = await n.select().from(C).where(
4072
+ const t = await n.select().from(A).where(
4092
4073
  g(
4093
- a(C.tenant_id, i),
4094
- a(C.user_id, e),
4095
- a(C.is_current, 1)
4074
+ a(A.tenant_id, i),
4075
+ a(A.user_id, e),
4076
+ a(A.is_current, 1)
4096
4077
  )
4097
4078
  ).get();
4098
- return t ? dt(t) : null;
4079
+ return t ? ut(t) : null;
4099
4080
  },
4100
4081
  async list(i, e, t) {
4101
- let r = n.select().from(C).where(
4082
+ let r = n.select().from(A).where(
4102
4083
  g(
4103
- a(C.tenant_id, i),
4104
- a(C.user_id, e)
4084
+ a(A.tenant_id, i),
4085
+ a(A.user_id, e)
4105
4086
  )
4106
- ).orderBy(V(C.created_at)).$dynamic();
4107
- return t && (r = r.limit(t)), (await r).map(dt);
4087
+ ).orderBy(V(A.created_at)).$dynamic();
4088
+ return t && (r = r.limit(t)), (await r).map(ut);
4108
4089
  },
4109
4090
  async update(i, e) {
4110
4091
  const t = {
4111
4092
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4112
4093
  };
4113
- return e.password !== void 0 && (t.password = e.password), e.algorithm !== void 0 && (t.algorithm = e.algorithm), e.is_current !== void 0 && (t.is_current = e.is_current ? 1 : 0), e.id ? await n.update(C).set(t).where(
4094
+ return e.password !== void 0 && (t.password = e.password), e.algorithm !== void 0 && (t.algorithm = e.algorithm), e.is_current !== void 0 && (t.is_current = e.is_current ? 1 : 0), e.id ? await n.update(A).set(t).where(
4114
4095
  g(
4115
- a(C.tenant_id, i),
4116
- a(C.id, e.id)
4096
+ a(A.tenant_id, i),
4097
+ a(A.id, e.id)
4117
4098
  )
4118
- ) : await n.update(C).set(t).where(
4099
+ ) : await n.update(A).set(t).where(
4119
4100
  g(
4120
- a(C.tenant_id, i),
4121
- a(C.user_id, e.user_id),
4122
- a(C.is_current, 1)
4101
+ a(A.tenant_id, i),
4102
+ a(A.user_id, e.user_id),
4103
+ a(A.is_current, 1)
4123
4104
  )
4124
4105
  ), !0;
4125
4106
  }
@@ -4160,7 +4141,7 @@ function Ss(n) {
4160
4141
  }
4161
4142
  };
4162
4143
  }
4163
- function ct(n) {
4144
+ function dt(n) {
4164
4145
  const {
4165
4146
  tenant_id: i,
4166
4147
  created_at_ts: e,
@@ -4171,7 +4152,7 @@ function ct(n) {
4171
4152
  resource_servers: _,
4172
4153
  rotating: u,
4173
4154
  ...c
4174
- } = n, d = Fe(
4155
+ } = n, d = Pe(
4175
4156
  { created_at_ts: e, expires_at_ts: t, idle_expires_at_ts: r, last_exchanged_at_ts: o },
4176
4157
  ["created_at_ts"],
4177
4158
  ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
@@ -4211,26 +4192,26 @@ function xs(n) {
4211
4192
  r.expires_at_ts,
4212
4193
  r.idle_expires_at_ts
4213
4194
  );
4214
- o > 0 && r.login_id && await n.update(B).set({
4195
+ o > 0 && r.login_id && await n.update(L).set({
4215
4196
  expires_at_ts: o,
4216
4197
  updated_at_ts: t
4217
4198
  }).where(
4218
4199
  g(
4219
- a(B.tenant_id, i),
4220
- a(B.id, r.login_id),
4221
- we(B.expires_at_ts, o)
4200
+ a(L.tenant_id, i),
4201
+ a(L.id, r.login_id),
4202
+ we(L.expires_at_ts, o)
4222
4203
  )
4223
4204
  ), await n.run(w`COMMIT`);
4224
4205
  } catch (o) {
4225
4206
  throw await n.run(w`ROLLBACK`), o;
4226
4207
  }
4227
- return ct({ ...r, tenant_id: i });
4208
+ return dt({ ...r, tenant_id: i });
4228
4209
  },
4229
4210
  async get(i, e) {
4230
4211
  const t = await n.select().from(T).where(
4231
4212
  g(a(T.tenant_id, i), a(T.id, e))
4232
4213
  ).get();
4233
- return t ? ct(t) : null;
4214
+ return t ? dt(t) : null;
4234
4215
  },
4235
4216
  async update(i, e, t) {
4236
4217
  const r = {};
@@ -4260,14 +4241,14 @@ function xs(n) {
4260
4241
  u.expires_at_ts,
4261
4242
  u.idle_expires_at_ts
4262
4243
  );
4263
- c > 0 && await n.update(B).set({
4244
+ c > 0 && await n.update(L).set({
4264
4245
  expires_at_ts: c,
4265
4246
  updated_at_ts: Date.now()
4266
4247
  }).where(
4267
4248
  g(
4268
- a(B.tenant_id, i),
4269
- a(B.id, u.login_id),
4270
- we(B.expires_at_ts, c)
4249
+ a(L.tenant_id, i),
4250
+ a(L.id, u.login_id),
4251
+ we(L.expires_at_ts, c)
4271
4252
  )
4272
4253
  );
4273
4254
  }
@@ -4287,7 +4268,7 @@ function xs(n) {
4287
4268
  } = e || {};
4288
4269
  let u = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
4289
4270
  if (_) {
4290
- const f = pe(T, _, ["user_id"]);
4271
+ const f = me(T, _, ["user_id"]);
4291
4272
  f && (u = u.where(
4292
4273
  g(a(T.tenant_id, i), f)
4293
4274
  ));
@@ -4298,15 +4279,15 @@ function xs(n) {
4298
4279
  l.sort_order === "desc" ? V(f) : G(f)
4299
4280
  ));
4300
4281
  }
4301
- const d = (await u.offset(t * r).limit(r)).map(ct);
4282
+ const d = (await u.offset(t * r).limit(r)).map(dt);
4302
4283
  if (!o)
4303
4284
  return { refresh_tokens: d };
4304
- const [m] = await n.select({ count: R() }).from(T).where(a(T.tenant_id, i));
4285
+ const [h] = await n.select({ count: R() }).from(T).where(a(T.tenant_id, i));
4305
4286
  return {
4306
4287
  refresh_tokens: d,
4307
4288
  start: t * r,
4308
4289
  limit: r,
4309
- length: Number((m == null ? void 0 : m.count) ?? 0)
4290
+ length: Number((h == null ? void 0 : h.count) ?? 0)
4310
4291
  };
4311
4292
  },
4312
4293
  async remove(i, e) {
@@ -4324,7 +4305,7 @@ const xt = [
4324
4305
  "skip_consent_for_verifiable_first_party_clients",
4325
4306
  "allow_offline_access",
4326
4307
  "is_system"
4327
- ], Pt = /* @__PURE__ */ new Set([
4308
+ ], Qt = /* @__PURE__ */ new Set([
4328
4309
  "id",
4329
4310
  "tenant_id",
4330
4311
  "identifier",
@@ -4343,7 +4324,7 @@ const xt = [
4343
4324
  "created_at",
4344
4325
  "updated_at"
4345
4326
  ]);
4346
- function gt(n) {
4327
+ function ct(n) {
4347
4328
  const {
4348
4329
  tenant_id: i,
4349
4330
  verification_key: e,
@@ -4378,28 +4359,28 @@ function Ds(n) {
4378
4359
  };
4379
4360
  for (const l of xt)
4380
4361
  e[l] !== void 0 && (o[l] = e[l] ? 1 : 0);
4381
- return o.is_system === void 0 && (o.is_system = 0), await n.insert(E).values(o), gt({ ...o, tenant_id: i });
4362
+ return o.is_system === void 0 && (o.is_system = 0), await n.insert(C).values(o), ct({ ...o, tenant_id: i });
4382
4363
  },
4383
4364
  async get(i, e) {
4384
- const t = await n.select().from(E).where(
4365
+ const t = await n.select().from(C).where(
4385
4366
  g(
4386
- a(E.tenant_id, i),
4387
- a(E.id, e)
4367
+ a(C.tenant_id, i),
4368
+ a(C.id, e)
4388
4369
  )
4389
4370
  ).get();
4390
- return t ? gt(t) : null;
4371
+ return t ? ct(t) : null;
4391
4372
  },
4392
4373
  async update(i, e, t) {
4393
4374
  const r = {
4394
4375
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4395
4376
  };
4396
- t.name !== void 0 && (r.name = t.name), t.identifier !== void 0 && (r.identifier = t.identifier), t.signing_alg !== void 0 && (r.signing_alg = t.signing_alg), t.signing_secret !== void 0 && (r.signing_secret = t.signing_secret), t.token_lifetime !== void 0 && (r.token_lifetime = t.token_lifetime), t.token_lifetime_for_web !== void 0 && (r.token_lifetime_for_web = t.token_lifetime_for_web), t.scopes !== void 0 && (r.scopes = JSON.stringify(t.scopes)), t.options !== void 0 && (r.options = w`json_patch(COALESCE(${E.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
4377
+ t.name !== void 0 && (r.name = t.name), t.identifier !== void 0 && (r.identifier = t.identifier), t.signing_alg !== void 0 && (r.signing_alg = t.signing_alg), t.signing_secret !== void 0 && (r.signing_secret = t.signing_secret), t.token_lifetime !== void 0 && (r.token_lifetime = t.token_lifetime), t.token_lifetime_for_web !== void 0 && (r.token_lifetime_for_web = t.token_lifetime_for_web), t.scopes !== void 0 && (r.scopes = JSON.stringify(t.scopes)), t.options !== void 0 && (r.options = w`json_patch(COALESCE(${C.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
4397
4378
  for (const l of xt)
4398
4379
  t[l] !== void 0 && (r[l] = t[l] ? 1 : 0);
4399
- return (await n.update(E).set(r).where(
4380
+ return (await n.update(C).set(r).where(
4400
4381
  g(
4401
- a(E.tenant_id, i),
4402
- a(E.id, e)
4382
+ a(C.tenant_id, i),
4383
+ a(C.id, e)
4403
4384
  )
4404
4385
  ).returning()).length > 0;
4405
4386
  },
@@ -4413,28 +4394,28 @@ function Ds(n) {
4413
4394
  } = e || {}, u = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
4414
4395
  Math.max(1, Math.floor(Number(r) || 50)),
4415
4396
  500
4416
- ), d = [a(E.tenant_id, i)];
4397
+ ), d = [a(C.tenant_id, i)];
4417
4398
  if (_) {
4418
- const A = _.match(/^([^:]+):(.+)$/);
4419
- if (A) {
4420
- const [, W, H] = A, ke = W == null ? void 0 : W.startsWith("-"), qe = ke ? W == null ? void 0 : W.substring(1) : W;
4421
- if (qe && Pt.has(qe) && !ke) {
4422
- const yr = E[qe];
4399
+ const B = _.match(/^([^:]+):(.+)$/);
4400
+ if (B) {
4401
+ const [, W, H] = B, ke = W == null ? void 0 : W.startsWith("-"), qe = ke ? W == null ? void 0 : W.substring(1) : W;
4402
+ if (qe && Qt.has(qe) && !ke) {
4403
+ const yr = C[qe];
4423
4404
  d.push(Ie(yr, `%${H}%`));
4424
4405
  }
4425
4406
  }
4426
4407
  }
4427
- let m = n.select().from(E).where(g(...d)).$dynamic();
4428
- if (l != null && l.sort_by && Pt.has(l.sort_by)) {
4429
- const A = E[l.sort_by];
4430
- m = m.orderBy(
4431
- l.sort_order === "desc" ? V(A) : G(A)
4408
+ let h = n.select().from(C).where(g(...d)).$dynamic();
4409
+ if (l != null && l.sort_by && Qt.has(l.sort_by)) {
4410
+ const B = C[l.sort_by];
4411
+ h = h.orderBy(
4412
+ l.sort_order === "desc" ? V(B) : G(B)
4432
4413
  );
4433
4414
  }
4434
- const y = (await m.offset(u * c).limit(c)).map(gt);
4415
+ const y = (await h.offset(u * c).limit(c)).map(ct);
4435
4416
  if (!o)
4436
4417
  return { resource_servers: y };
4437
- const [N] = await n.select({ count: R() }).from(E).where(g(...d));
4418
+ const [N] = await n.select({ count: R() }).from(C).where(g(...d));
4438
4419
  return {
4439
4420
  resource_servers: y,
4440
4421
  start: u * c,
@@ -4443,10 +4424,10 @@ function Ds(n) {
4443
4424
  };
4444
4425
  },
4445
4426
  async remove(i, e) {
4446
- return (await n.delete(E).where(
4427
+ return (await n.delete(C).where(
4447
4428
  g(
4448
- a(E.tenant_id, i),
4449
- a(E.id, e)
4429
+ a(C.tenant_id, i),
4430
+ a(C.id, e)
4450
4431
  )
4451
4432
  ).returning()).length > 0;
4452
4433
  }
@@ -4481,12 +4462,12 @@ function Os(n) {
4481
4462
  ], l = /* @__PURE__ */ new Map();
4482
4463
  if (o.length > 0) {
4483
4464
  const _ = await n.select({
4484
- identifier: E.identifier,
4485
- name: E.name
4486
- }).from(E).where(
4465
+ identifier: C.identifier,
4466
+ name: C.name
4467
+ }).from(C).where(
4487
4468
  g(
4488
- a(E.tenant_id, i),
4489
- Ne(E.identifier, o)
4469
+ a(C.tenant_id, i),
4470
+ Ne(C.identifier, o)
4490
4471
  )
4491
4472
  ).all();
4492
4473
  for (const u of _)
@@ -4546,10 +4527,10 @@ function ks(n) {
4546
4527
  const l = await n.select().from(_e).where(g(...o)).all();
4547
4528
  return await Promise.all(
4548
4529
  l.map(async (u) => {
4549
- const c = await n.select({ name: E.name }).from(E).where(
4530
+ const c = await n.select({ name: C.name }).from(C).where(
4550
4531
  g(
4551
- a(E.tenant_id, i),
4552
- a(E.identifier, u.resource_server_identifier)
4532
+ a(C.tenant_id, i),
4533
+ a(C.identifier, u.resource_server_identifier)
4553
4534
  )
4554
4535
  ).get();
4555
4536
  return {
@@ -4577,7 +4558,7 @@ function ks(n) {
4577
4558
  }
4578
4559
  };
4579
4560
  }
4580
- function ft(n) {
4561
+ function gt(n) {
4581
4562
  const { tenant_id: i, is_system: e, metadata: t, ...r } = n;
4582
4563
  return z({
4583
4564
  ...r,
@@ -4598,11 +4579,11 @@ function Is(n) {
4598
4579
  created_at: t,
4599
4580
  updated_at: t
4600
4581
  };
4601
- return await n.insert(F).values(o), ft({ ...o, tenant_id: i });
4582
+ return await n.insert(F).values(o), gt({ ...o, tenant_id: i });
4602
4583
  },
4603
4584
  async get(i, e) {
4604
4585
  const t = await n.select().from(F).where(g(a(F.tenant_id, i), a(F.id, e))).get();
4605
- return t ? ft(t) : null;
4586
+ return t ? gt(t) : null;
4606
4587
  },
4607
4588
  async update(i, e, t) {
4608
4589
  const r = {
@@ -4617,7 +4598,7 @@ function Is(n) {
4617
4598
  include_totals: o = !1,
4618
4599
  sort: l,
4619
4600
  q: _
4620
- } = e || {}, u = _ ? pe(F, _, ["name"]) : void 0, c = u ? g(a(F.tenant_id, i), u) : a(F.tenant_id, i);
4601
+ } = e || {}, u = _ ? me(F, _, ["name"]) : void 0, c = u ? g(a(F.tenant_id, i), u) : a(F.tenant_id, i);
4621
4602
  let d = n.select().from(F).where(c).$dynamic();
4622
4603
  if (l != null && l.sort_by) {
4623
4604
  const N = F[l.sort_by];
@@ -4625,7 +4606,7 @@ function Is(n) {
4625
4606
  l.sort_order === "desc" ? V(N) : G(N)
4626
4607
  ));
4627
4608
  }
4628
- const f = (await d.offset(t * r).limit(r)).map(ft);
4609
+ const f = (await d.offset(t * r).limit(r)).map(gt);
4629
4610
  if (!o)
4630
4611
  return { roles: f };
4631
4612
  const [y] = await n.select({ count: R() }).from(F).where(c);
@@ -4649,7 +4630,7 @@ const zs = ["created_at_ts", "updated_at_ts"], Ts = [
4649
4630
  "used_at_ts",
4650
4631
  "revoked_at_ts"
4651
4632
  ];
4652
- function ht(n) {
4633
+ function ft(n) {
4653
4634
  const {
4654
4635
  tenant_id: i,
4655
4636
  created_at_ts: e,
@@ -4661,9 +4642,9 @@ function ht(n) {
4661
4642
  used_at_ts: u,
4662
4643
  revoked_at_ts: c,
4663
4644
  device: d,
4664
- clients: m,
4645
+ clients: h,
4665
4646
  ...f
4666
- } = n, y = Fe(
4647
+ } = n, y = Pe(
4667
4648
  {
4668
4649
  created_at_ts: e,
4669
4650
  updated_at_ts: t,
@@ -4681,7 +4662,7 @@ function ht(n) {
4681
4662
  ...f,
4682
4663
  ...y,
4683
4664
  device: x(d, {}),
4684
- clients: x(m, [])
4665
+ clients: x(h, [])
4685
4666
  });
4686
4667
  }
4687
4668
  function qs(n) {
@@ -4703,11 +4684,11 @@ function qs(n) {
4703
4684
  used_at_ts: j(e.used_at),
4704
4685
  revoked_at_ts: j(e.revoked_at)
4705
4686
  };
4706
- return await n.insert($).values(r), ht({ ...r, tenant_id: i });
4687
+ return await n.insert($).values(r), ft({ ...r, tenant_id: i });
4707
4688
  },
4708
4689
  async get(i, e) {
4709
4690
  const t = await n.select().from($).where(g(a($.tenant_id, i), a($.id, e))).get();
4710
- return t ? ht(t) : null;
4691
+ return t ? ft(t) : null;
4711
4692
  },
4712
4693
  async update(i, e, t) {
4713
4694
  const r = {
@@ -4724,7 +4705,7 @@ function qs(n) {
4724
4705
  include_totals: o = !1,
4725
4706
  sort: l,
4726
4707
  q: _
4727
- } = e || {}, u = _ ? pe($, _, ["user_id"]) : void 0, c = u ? g(a($.tenant_id, i), u) : a($.tenant_id, i);
4708
+ } = e || {}, u = _ ? me($, _, ["user_id"]) : void 0, c = u ? g(a($.tenant_id, i), u) : a($.tenant_id, i);
4728
4709
  let d = n.select().from($).where(c).$dynamic();
4729
4710
  if (l != null && l.sort_by) {
4730
4711
  const N = $[l.sort_by];
@@ -4732,7 +4713,7 @@ function qs(n) {
4732
4713
  l.sort_order === "desc" ? V(N) : G(N)
4733
4714
  ));
4734
4715
  }
4735
- const f = (await d.offset(t * r).limit(r)).map(ht);
4716
+ const f = (await d.offset(t * r).limit(r)).map(ft);
4736
4717
  if (!o)
4737
4718
  return { sessions: f };
4738
4719
  const [y] = await n.select({ count: R() }).from($).where(c);
@@ -4748,7 +4729,7 @@ function qs(n) {
4748
4729
  }
4749
4730
  };
4750
4731
  }
4751
- const mr = [
4732
+ const hr = [
4752
4733
  "session_cookie",
4753
4734
  "enabled_locales",
4754
4735
  "error_page",
@@ -4764,28 +4745,28 @@ const mr = [
4764
4745
  "acr_values_supported",
4765
4746
  "mtls",
4766
4747
  "mfa"
4767
- ], pr = [
4748
+ ], mr = [
4768
4749
  "allow_organization_name_in_authentication_api",
4769
4750
  "customize_mfa_in_postlogin_action",
4770
4751
  "pushed_authorization_requests_supported",
4771
4752
  "authorization_response_iss_parameter_supported"
4772
4753
  ];
4773
- function Qt(n) {
4754
+ function Jt(n) {
4774
4755
  const i = { ...n };
4775
- for (const e of mr)
4756
+ for (const e of hr)
4776
4757
  typeof i[e] == "string" && (i[e] = x(i[e]));
4777
- for (const e of pr)
4758
+ for (const e of mr)
4778
4759
  i[e] !== void 0 && i[e] !== null && (i[e] = i[e] === 1);
4779
4760
  return z(i);
4780
4761
  }
4781
- function Jt(n) {
4762
+ function Pt(n) {
4782
4763
  const i = { ...n };
4783
- Jr(
4764
+ Pr(
4784
4765
  n,
4785
- mr,
4766
+ hr,
4786
4767
  i
4787
4768
  );
4788
- for (const e of pr)
4769
+ for (const e of mr)
4789
4770
  n[e] !== void 0 && (i[e] = n[e] ? 1 : 0);
4790
4771
  return gr(i);
4791
4772
  }
@@ -4798,7 +4779,7 @@ function Ls(n) {
4798
4779
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
4799
4780
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
4800
4781
  ...i
4801
- }, t = Jt(e);
4782
+ }, t = Pt(e);
4802
4783
  try {
4803
4784
  await n.insert(D).values(t);
4804
4785
  } catch (l) {
@@ -4810,7 +4791,7 @@ function Ls(n) {
4810
4791
  },
4811
4792
  async get(i) {
4812
4793
  const e = await n.select().from(D).where(a(D.id, i)).get();
4813
- return e ? Qt(e) : null;
4794
+ return e ? Jt(e) : null;
4814
4795
  },
4815
4796
  async list(i) {
4816
4797
  const {
@@ -4822,16 +4803,16 @@ function Ls(n) {
4822
4803
  } = i || {};
4823
4804
  let _ = n.select().from(D).$dynamic();
4824
4805
  if (l) {
4825
- const m = pe(D, l, ["friendly_name"]);
4826
- m && (_ = _.where(m));
4806
+ const h = me(D, l, ["friendly_name"]);
4807
+ h && (_ = _.where(h));
4827
4808
  }
4828
4809
  if (o != null && o.sort_by) {
4829
- const m = D[o.sort_by];
4830
- m && (_ = _.orderBy(
4831
- o.sort_order === "desc" ? V(m) : G(m)
4810
+ const h = D[o.sort_by];
4811
+ h && (_ = _.orderBy(
4812
+ o.sort_order === "desc" ? V(h) : G(h)
4832
4813
  ));
4833
4814
  }
4834
- const c = (await _.offset(e * t).limit(t)).map(Qt);
4815
+ const c = (await _.offset(e * t).limit(t)).map(Jt);
4835
4816
  if (!r)
4836
4817
  return { tenants: c };
4837
4818
  const [d] = await n.select({ count: R() }).from(D);
@@ -4843,7 +4824,7 @@ function Ls(n) {
4843
4824
  };
4844
4825
  },
4845
4826
  async update(i, e) {
4846
- const t = Jt({
4827
+ const t = Pt({
4847
4828
  ...e,
4848
4829
  id: i,
4849
4830
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -4870,7 +4851,7 @@ function Cs(n) {
4870
4851
  return {
4871
4852
  async create(i, e, t) {
4872
4853
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = t || ae(), _ = {
4873
- ...Pe(e),
4854
+ ...yt(e),
4874
4855
  tenant_id: i,
4875
4856
  themeId: o,
4876
4857
  created_at: r,
@@ -4885,7 +4866,7 @@ function Cs(n) {
4885
4866
  return t ? Ft(t) : null;
4886
4867
  },
4887
4868
  async update(i, e, t) {
4888
- const r = Pe(t);
4869
+ const r = yt(t);
4889
4870
  return r.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await n.update(fe).set(r).where(
4890
4871
  g(a(fe.tenant_id, i), a(fe.themeId, e))
4891
4872
  ), !0;
@@ -4936,7 +4917,7 @@ function Ut(n, i) {
4936
4917
  ...typeof n.profileData == "string" ? x(n.profileData, {}) : {}
4937
4918
  }, e;
4938
4919
  }
4939
- function mt(n, i = []) {
4920
+ function pt(n, i = []) {
4940
4921
  const {
4941
4922
  tenant_id: e,
4942
4923
  app_metadata: t,
@@ -4947,10 +4928,10 @@ function mt(n, i = []) {
4947
4928
  is_social: u,
4948
4929
  linked_to: c,
4949
4930
  profileData: d,
4950
- ...m
4931
+ ...h
4951
4932
  } = n, f = Ut(n, !0), y = i.map((N) => Ut(N, !1));
4952
4933
  return z({
4953
- ...m,
4934
+ ...h,
4954
4935
  email: n.email || "",
4955
4936
  email_verified: !!l,
4956
4937
  phone_verified: _ != null ? !!_ : void 0,
@@ -5004,7 +4985,7 @@ function Bs(n) {
5004
4985
  if (t.password && l) {
5005
4986
  await n.run(w`BEGIN`);
5006
4987
  try {
5007
- await n.insert(k).values(o), await n.insert(C).values({
4988
+ await n.insert(k).values(o), await n.insert(A).values({
5008
4989
  id: l,
5009
4990
  tenant_id: e,
5010
4991
  user_id: t.user_id,
@@ -5024,7 +5005,7 @@ function Bs(n) {
5024
5005
  message: "Internal server error"
5025
5006
  }));
5026
5007
  }
5027
- return mt(o);
5008
+ return pt(o);
5028
5009
  };
5029
5010
  return {
5030
5011
  create: i,
@@ -5035,7 +5016,7 @@ function Bs(n) {
5035
5016
  const o = await n.select().from(k).where(
5036
5017
  g(a(k.tenant_id, e), a(k.linked_to, t))
5037
5018
  ).all();
5038
- return mt(r, o);
5019
+ return pt(r, o);
5039
5020
  },
5040
5021
  async update(e, t, r) {
5041
5022
  const o = {
@@ -5081,7 +5062,7 @@ function Bs(n) {
5081
5062
  ye(k.linked_to)
5082
5063
  ];
5083
5064
  if (u) {
5084
- const H = pe(k, u, [
5065
+ const H = me(k, u, [
5085
5066
  "email",
5086
5067
  "name",
5087
5068
  "nickname",
@@ -5090,14 +5071,14 @@ function Bs(n) {
5090
5071
  H && c.push(H);
5091
5072
  }
5092
5073
  const d = g(...c);
5093
- let m = n.select().from(k).where(d).$dynamic();
5074
+ let h = n.select().from(k).where(d).$dynamic();
5094
5075
  if (_ != null && _.sort_by) {
5095
5076
  const H = k[_.sort_by];
5096
- H && (m = m.orderBy(
5077
+ H && (h = h.orderBy(
5097
5078
  _.sort_order === "desc" ? V(H) : G(H)
5098
5079
  ));
5099
5080
  }
5100
- const f = await m.offset(r * o).limit(o), y = f.map((H) => H.user_id);
5081
+ const f = await h.offset(r * o).limit(o), y = f.map((H) => H.user_id);
5101
5082
  let N = [];
5102
5083
  y.length > 0 && (N = await n.select().from(k).where(
5103
5084
  g(
@@ -5105,15 +5086,15 @@ function Bs(n) {
5105
5086
  Ne(k.linked_to, y)
5106
5087
  )
5107
5088
  ));
5108
- const A = f.map((H) => {
5089
+ const B = f.map((H) => {
5109
5090
  const ke = N.filter((qe) => qe.linked_to === H.user_id);
5110
- return mt(H, ke);
5091
+ return pt(H, ke);
5111
5092
  });
5112
5093
  if (!l)
5113
- return { users: A };
5094
+ return { users: B };
5114
5095
  const [W] = await n.select({ count: R() }).from(k).where(d);
5115
5096
  return {
5116
- users: A,
5097
+ users: B,
5117
5098
  start: r * o,
5118
5099
  limit: o,
5119
5100
  length: Number((W == null ? void 0 : W.count) ?? 0)
@@ -5130,10 +5111,10 @@ function Bs(n) {
5130
5111
  a(U.tenant_id, e),
5131
5112
  Ne(U.user_id, o)
5132
5113
  )
5133
- ), await n.delete(C).where(
5114
+ ), await n.delete(A).where(
5134
5115
  g(
5135
- a(C.tenant_id, e),
5136
- Ne(C.user_id, o)
5116
+ a(A.tenant_id, e),
5117
+ Ne(A.user_id, o)
5137
5118
  )
5138
5119
  ), await n.delete(k).where(
5139
5120
  g(a(k.tenant_id, e), a(k.linked_to, t))
@@ -5192,10 +5173,10 @@ function $s(n) {
5192
5173
  g(a(F.tenant_id, i), a(F.id, u.role_id))
5193
5174
  ).get();
5194
5175
  if (!c) return null;
5195
- const { tenant_id: d, is_system: m, metadata: f, ...y } = c;
5176
+ const { tenant_id: d, is_system: h, metadata: f, ...y } = c;
5196
5177
  return z({
5197
5178
  ...y,
5198
- is_system: m ? !0 : void 0,
5179
+ is_system: h ? !0 : void 0,
5199
5180
  metadata: x(f)
5200
5181
  });
5201
5182
  })
@@ -5213,7 +5194,7 @@ function $s(n) {
5213
5194
  }
5214
5195
  };
5215
5196
  }
5216
- function Ps(n) {
5197
+ function Qs(n) {
5217
5198
  return {
5218
5199
  async create(i, e) {
5219
5200
  var u, c;
@@ -5226,7 +5207,7 @@ function Ps(n) {
5226
5207
  updated_at: t
5227
5208
  };
5228
5209
  try {
5229
- await n.insert(Q).values(o);
5210
+ await n.insert(J).values(o);
5230
5211
  } catch (d) {
5231
5212
  throw (u = d == null ? void 0 : d.message) != null && u.includes("UNIQUE constraint") || (c = d == null ? void 0 : d.message) != null && c.includes("duplicate key") ? new be(409, {
5232
5213
  message: "User organization already exists"
@@ -5236,10 +5217,10 @@ function Ps(n) {
5236
5217
  return _;
5237
5218
  },
5238
5219
  async get(i, e) {
5239
- const t = await n.select().from(Q).where(
5220
+ const t = await n.select().from(J).where(
5240
5221
  g(
5241
- a(Q.tenant_id, i),
5242
- a(Q.id, e)
5222
+ a(J.tenant_id, i),
5223
+ a(J.id, e)
5243
5224
  )
5244
5225
  ).get();
5245
5226
  if (!t) return null;
@@ -5250,10 +5231,10 @@ function Ps(n) {
5250
5231
  const r = {
5251
5232
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
5252
5233
  };
5253
- return t.user_id !== void 0 && (r.user_id = t.user_id), t.organization_id !== void 0 && (r.organization_id = t.organization_id), (await n.update(Q).set(r).where(
5234
+ return t.user_id !== void 0 && (r.user_id = t.user_id), t.organization_id !== void 0 && (r.organization_id = t.organization_id), (await n.update(J).set(r).where(
5254
5235
  g(
5255
- a(Q.tenant_id, i),
5256
- a(Q.id, e)
5236
+ a(J.tenant_id, i),
5237
+ a(J.id, e)
5257
5238
  )
5258
5239
  ).returning()).length > 0;
5259
5240
  },
@@ -5263,48 +5244,48 @@ function Ps(n) {
5263
5244
  per_page: r = 50,
5264
5245
  include_totals: o = !1,
5265
5246
  q: l
5266
- } = e || {}, _ = a(Q.tenant_id, i);
5247
+ } = e || {}, _ = a(J.tenant_id, i);
5267
5248
  let u = _;
5268
5249
  if (l) {
5269
- const f = pe(Q, l, [
5250
+ const f = me(J, l, [
5270
5251
  "user_id",
5271
5252
  "organization_id"
5272
5253
  ]);
5273
5254
  f && (u = g(_, f));
5274
5255
  }
5275
- const d = (await n.select().from(Q).where(u).offset(t * r).limit(r)).map((f) => {
5256
+ const d = (await n.select().from(J).where(u).offset(t * r).limit(r)).map((f) => {
5276
5257
  const { tenant_id: y, ...N } = f;
5277
5258
  return N;
5278
5259
  });
5279
5260
  if (!o)
5280
5261
  return { userOrganizations: d };
5281
- const [m] = await n.select({ count: R() }).from(Q).where(u);
5262
+ const [h] = await n.select({ count: R() }).from(J).where(u);
5282
5263
  return {
5283
5264
  userOrganizations: d,
5284
5265
  start: t * r,
5285
5266
  limit: r,
5286
- length: Number((m == null ? void 0 : m.count) ?? 0)
5267
+ length: Number((h == null ? void 0 : h.count) ?? 0)
5287
5268
  };
5288
5269
  },
5289
5270
  async listUserOrganizations(i, e, t) {
5290
- const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(Q).where(
5271
+ const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(J).where(
5291
5272
  g(
5292
- a(Q.tenant_id, i),
5293
- a(Q.user_id, e)
5273
+ a(J.tenant_id, i),
5274
+ a(J.user_id, e)
5294
5275
  )
5295
5276
  ).offset(r * o).limit(o).all(), c = (await Promise.all(
5296
- _.map(async (m) => {
5297
- const f = await n.select().from(L).where(
5277
+ _.map(async (h) => {
5278
+ const f = await n.select().from(E).where(
5298
5279
  g(
5299
- a(L.tenant_id, i),
5300
- a(L.id, m.organization_id)
5280
+ a(E.tenant_id, i),
5281
+ a(E.id, h.organization_id)
5301
5282
  )
5302
5283
  ).get();
5303
5284
  if (!f) return null;
5304
5285
  const {
5305
5286
  tenant_id: y,
5306
5287
  branding: N,
5307
- metadata: A,
5288
+ metadata: B,
5308
5289
  enabled_connections: W,
5309
5290
  token_quota: H,
5310
5291
  ...ke
@@ -5312,7 +5293,7 @@ function Ps(n) {
5312
5293
  return z({
5313
5294
  ...ke,
5314
5295
  branding: x(N, {}),
5315
- metadata: x(A, {}),
5296
+ metadata: x(B, {}),
5316
5297
  enabled_connections: x(W, []),
5317
5298
  token_quota: x(H, {})
5318
5299
  });
@@ -5320,10 +5301,10 @@ function Ps(n) {
5320
5301
  )).filter(Boolean);
5321
5302
  if (!l)
5322
5303
  return { organizations: c };
5323
- const [d] = await n.select({ count: R() }).from(Q).where(
5304
+ const [d] = await n.select({ count: R() }).from(J).where(
5324
5305
  g(
5325
- a(Q.tenant_id, i),
5326
- a(Q.user_id, e)
5306
+ a(J.tenant_id, i),
5307
+ a(J.user_id, e)
5327
5308
  )
5328
5309
  );
5329
5310
  return {
@@ -5334,17 +5315,17 @@ function Ps(n) {
5334
5315
  };
5335
5316
  },
5336
5317
  async remove(i, e) {
5337
- return (await n.delete(Q).where(
5318
+ return (await n.delete(J).where(
5338
5319
  g(
5339
- a(Q.tenant_id, i),
5340
- a(Q.id, e)
5320
+ a(J.tenant_id, i),
5321
+ a(J.id, e)
5341
5322
  )
5342
5323
  ).returning()).length > 0;
5343
5324
  }
5344
5325
  };
5345
5326
  }
5346
- const Kt = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Qs = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
5347
- function Js(n) {
5327
+ const Kt = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Js = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
5328
+ function Ps(n) {
5348
5329
  return {
5349
5330
  async getDaily(i, e) {
5350
5331
  const t = /* @__PURE__ */ new Date(), r = (e == null ? void 0 : e.from) || new Date(t.getTime() - 30 * 24 * 60 * 60 * 1e3).toISOString().split("T")[0], o = (e == null ? void 0 : e.to) || t.toISOString().split("T")[0];
@@ -5358,13 +5339,13 @@ function Js(n) {
5358
5339
  "signups"
5359
5340
  ),
5360
5341
  leaked_passwords: w`SUM(CASE WHEN ${q.type} IN (${w.join(
5361
- Qs.map((_) => w`${_}`),
5342
+ Js.map((_) => w`${_}`),
5362
5343
  w`, `
5363
5344
  )}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
5364
5345
  }).from(q).where(
5365
5346
  g(
5366
5347
  a(q.tenant_id, i),
5367
- Ge(q.date, r),
5348
+ He(q.date, r),
5368
5349
  Oe(q.date, `${o}T23:59:59.999Z`)
5369
5350
  )
5370
5351
  ).groupBy(w`substr(${q.date}, 1, 10)`).orderBy(w`substr(${q.date}, 1, 10)`).all()).map((_) => ({
@@ -5384,7 +5365,7 @@ function Js(n) {
5384
5365
  }).from(q).where(
5385
5366
  g(
5386
5367
  a(q.tenant_id, i),
5387
- Ge(q.date, e),
5368
+ He(q.date, e),
5388
5369
  w`${q.type} IN (${w.join(
5389
5370
  Kt.map((r) => w`${r}`),
5390
5371
  w`, `
@@ -5495,7 +5476,7 @@ function Fs(n) {
5495
5476
  const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(b).where(
5496
5477
  g(
5497
5478
  a(b.tenant_id, i),
5498
- Ve(b.dead_lettered_at)
5479
+ Me(b.dead_lettered_at)
5499
5480
  )
5500
5481
  ).orderBy(V(b.dead_lettered_at), G(b.id)).offset(t * r).limit(r).all()).map((c) => ({
5501
5482
  ...x(c.payload, {}),
@@ -5513,7 +5494,7 @@ function Fs(n) {
5513
5494
  const [c] = await n.select({ total: R() }).from(b).where(
5514
5495
  g(
5515
5496
  a(b.tenant_id, i),
5516
- Ve(b.dead_lettered_at)
5497
+ Me(b.dead_lettered_at)
5517
5498
  )
5518
5499
  );
5519
5500
  u = Number((c == null ? void 0 : c.total) ?? _.length);
@@ -5537,7 +5518,7 @@ function Fs(n) {
5537
5518
  g(
5538
5519
  a(b.id, i),
5539
5520
  a(b.tenant_id, e),
5540
- Ve(b.dead_lettered_at)
5521
+ Me(b.dead_lettered_at)
5541
5522
  )
5542
5523
  ).returning()).length > 0;
5543
5524
  }
@@ -5559,7 +5540,7 @@ function Ks(n) {
5559
5540
  we($.expires_at_ts, e),
5560
5541
  we($.idle_expires_at_ts, e)
5561
5542
  )
5562
- ], i != null && i.tenant_id && t.push(a($.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a($.user_id, i.user_id)), await n.delete($).where(g(...t)), t = [we(B.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(B.tenant_id, i.tenant_id)), await n.delete(B).where(g(...t));
5543
+ ], i != null && i.tenant_id && t.push(a($.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a($.user_id, i.user_id)), await n.delete($).where(g(...t)), t = [we(L.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(L.tenant_id, i.tenant_id)), await n.delete(L).where(g(...t));
5563
5544
  } catch (t) {
5564
5545
  console.error("Session cleanup error:", t);
5565
5546
  }
@@ -5583,8 +5564,8 @@ function Vs(n, i = { useTransactions: !0 }) {
5583
5564
  hooks: us(n),
5584
5565
  invites: cs(n),
5585
5566
  keys: gs(n),
5586
- loginSessions: hs(n),
5587
- logs: ms(n),
5567
+ loginSessions: ps(n),
5568
+ logs: hs(n),
5588
5569
  authenticationMethods: ys(n),
5589
5570
  organizations: Ns(n),
5590
5571
  passwords: vs(n),
@@ -5601,8 +5582,8 @@ function Vs(n, i = { useTransactions: !0 }) {
5601
5582
  universalLoginTemplates: As(n),
5602
5583
  users: Bs(n),
5603
5584
  userRoles: $s(n),
5604
- userOrganizations: Ps(n),
5605
- stats: Js(n),
5585
+ userOrganizations: Qs(n),
5586
+ stats: Ps(n),
5606
5587
  outbox: Fs(n),
5607
5588
  async transaction(t) {
5608
5589
  if (i.useTransactions === !1)