@authhero/drizzle 0.38.2 → 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)
1344
- }), B = O(
1343
+ is_current: m("is_current").notNull().default(1)
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
- ), $ = 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 }),
@@ -1431,7 +1412,12 @@ const D = O("tenants", {
1431
1412
  // JSON: { hookId?, continuationScope?, continuationReturnUrl? }
1432
1413
  failure_reason: s("failure_reason"),
1433
1414
  user_id: s("user_id", { length: 255 }),
1434
- auth_connection: s("auth_connection", { length: 255 })
1415
+ auth_connection: s("auth_connection", { length: 255 }),
1416
+ auth_strategy_strategy: s("auth_strategy_strategy", { length: 64 }),
1417
+ auth_strategy_strategy_type: s("auth_strategy_strategy_type", {
1418
+ length: 64
1419
+ }),
1420
+ authenticated_at: s("authenticated_at", { length: 35 })
1435
1421
  },
1436
1422
  (n) => [
1437
1423
  oe({
@@ -1447,7 +1433,7 @@ const D = O("tenants", {
1447
1433
  S("login_sessions_tenant_user_idx").on(n.tenant_id, n.user_id),
1448
1434
  S("idx_login_sessions_expires_at_ts").on(n.expires_at_ts)
1449
1435
  ]
1450
- ), P = O(
1436
+ ), Q = O(
1451
1437
  "codes",
1452
1438
  {
1453
1439
  code_id: s("code_id", { length: 191 }).notNull(),
@@ -1513,7 +1499,7 @@ const D = O("tenants", {
1513
1499
  S("otps_email_index").on(n.email),
1514
1500
  S("otps_expires_at_index").on(n.expires_at)
1515
1501
  ]
1516
- ), Pr = O("tickets", {
1502
+ ), Qr = O("tickets", {
1517
1503
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1518
1504
  id: s("id", { length: 255 }).primaryKey(),
1519
1505
  client_id: s("client_id", { length: 255 }).notNull(),
@@ -1534,13 +1520,13 @@ const D = O("tenants", {
1534
1520
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1535
1521
  name: s("name", { length: 255 }).notNull(),
1536
1522
  description: s("description", { length: 140 }),
1537
- global: p("global").notNull().default(0),
1523
+ global: m("global").notNull().default(0),
1538
1524
  client_secret: s("client_secret", { length: 255 }),
1539
1525
  app_type: s("app_type", { length: 64 }).default("regular_web"),
1540
1526
  logo_uri: s("logo_uri", { length: 2083 }),
1541
- is_first_party: p("is_first_party").notNull().default(0),
1542
- oidc_conformant: p("oidc_conformant").notNull().default(1),
1543
- 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),
1544
1530
  callbacks: s("callbacks").notNull(),
1545
1531
  allowed_origins: s("allowed_origins").notNull(),
1546
1532
  web_origins: s("web_origins").notNull(),
@@ -1553,11 +1539,11 @@ const D = O("tenants", {
1553
1539
  jwt_configuration: s("jwt_configuration").notNull(),
1554
1540
  signing_keys: s("signing_keys").notNull(),
1555
1541
  encryption_key: s("encryption_key").notNull(),
1556
- sso: p("sso").notNull().default(0),
1557
- sso_disabled: p("sso_disabled").notNull().default(1),
1558
- 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),
1559
1545
  cross_origin_loc: s("cross_origin_loc", { length: 2083 }),
1560
- 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),
1561
1547
  custom_login_page: s("custom_login_page"),
1562
1548
  custom_login_page_preview: s("custom_login_page_preview"),
1563
1549
  form_template: s("form_template"),
@@ -1580,13 +1566,13 @@ const D = O("tenants", {
1580
1566
  client_authentication_methods: s(
1581
1567
  "client_authentication_methods"
1582
1568
  ).notNull(),
1583
- require_pushed_authorization_requests: p(
1569
+ require_pushed_authorization_requests: m(
1584
1570
  "require_pushed_authorization_requests"
1585
1571
  ).notNull().default(0),
1586
- 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),
1587
1573
  signed_request_object: s("signed_request_object").notNull(),
1588
1574
  compliance_level: s("compliance_level", { length: 64 }),
1589
- par_request_expiry: p("par_request_expiry"),
1575
+ par_request_expiry: m("par_request_expiry"),
1590
1576
  token_quota: s("token_quota").notNull(),
1591
1577
  created_at: s("created_at", { length: 35 }).notNull(),
1592
1578
  updated_at: s("updated_at", { length: 35 }).notNull(),
@@ -1607,8 +1593,8 @@ const D = O("tenants", {
1607
1593
  audience: s("audience", { length: 191 }).notNull(),
1608
1594
  scope: s("scope").default("[]"),
1609
1595
  organization_usage: s("organization_usage", { length: 32 }),
1610
- allow_any_organization: p("allow_any_organization").default(0),
1611
- 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),
1612
1598
  subject_type: s("subject_type", { length: 32 }),
1613
1599
  authorization_details_types: s("authorization_details_types").default(
1614
1600
  "[]"
@@ -1636,9 +1622,9 @@ const D = O("tenants", {
1636
1622
  created_at: s("created_at", { length: 35 }).notNull(),
1637
1623
  updated_at: s("updated_at", { length: 35 }).notNull(),
1638
1624
  display_name: s("display_name", { length: 255 }),
1639
- is_domain_connection: p("is_domain_connection"),
1640
- show_as_button: p("show_as_button"),
1641
- 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),
1642
1628
  metadata: s("metadata", { length: 4096 })
1643
1629
  },
1644
1630
  (n) => [
@@ -1653,7 +1639,7 @@ const D = O("tenants", {
1653
1639
  custom_domain_id: s("custom_domain_id", { length: 256 }).primaryKey(),
1654
1640
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1655
1641
  domain: s("domain", { length: 255 }).notNull(),
1656
- primary: p("primary", { mode: "boolean" }).notNull(),
1642
+ primary: m("primary", { mode: "boolean" }).notNull(),
1657
1643
  status: s("status", { length: 50 }).notNull(),
1658
1644
  type: s("type", { length: 50 }).notNull(),
1659
1645
  origin_domain_name: s("origin_domain_name", { length: 255 }),
@@ -1665,7 +1651,7 @@ const D = O("tenants", {
1665
1651
  updated_at: s("updated_at", { length: 35 }).notNull()
1666
1652
  },
1667
1653
  (n) => [Te("custom_domains_domain_unique").on(n.domain)]
1668
- ), Qr = O("domains", {
1654
+ ), Jr = O("domains", {
1669
1655
  id: s("id", { length: 255 }).primaryKey(),
1670
1656
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1671
1657
  domain: s("domain", { length: 255 }).notNull(),
@@ -1675,7 +1661,7 @@ const D = O("tenants", {
1675
1661
  dkim_public_key: s("dkim_public_key", { length: 2048 }),
1676
1662
  created_at: s("created_at", { length: 35 }).notNull(),
1677
1663
  updated_at: s("updated_at", { length: 35 }).notNull()
1678
- }), L = O(
1664
+ }), E = O(
1679
1665
  "organizations",
1680
1666
  {
1681
1667
  id: s("id", { length: 21 }).primaryKey(),
@@ -1690,7 +1676,7 @@ const D = O("tenants", {
1690
1676
  updated_at: s("updated_at", { length: 35 }).notNull()
1691
1677
  },
1692
1678
  (n) => [S("idx_organizations_tenant_id").on(n.tenant_id)]
1693
- ), Q = O(
1679
+ ), J = O(
1694
1680
  "user_organizations",
1695
1681
  {
1696
1682
  id: s("id", { length: 21 }).primaryKey(),
@@ -1727,8 +1713,8 @@ const D = O("tenants", {
1727
1713
  user_metadata: s("user_metadata"),
1728
1714
  roles: s("roles"),
1729
1715
  ticket_id: s("ticket_id", { length: 191 }),
1730
- ttl_sec: p("ttl_sec"),
1731
- send_invitation_email: p("send_invitation_email")
1716
+ ttl_sec: m("ttl_sec"),
1717
+ send_invitation_email: m("send_invitation_email")
1732
1718
  },
1733
1719
  (n) => [
1734
1720
  S("idx_invites_tenant_id").on(n.tenant_id),
@@ -1743,7 +1729,7 @@ const D = O("tenants", {
1743
1729
  tenant_id: s("tenant_id", { length: 191 }).notNull(),
1744
1730
  name: s("name", { length: 50 }).notNull(),
1745
1731
  description: s("description", { length: 255 }),
1746
- is_system: p("is_system").notNull().default(0),
1732
+ is_system: m("is_system").notNull().default(0),
1747
1733
  metadata: s("metadata", { length: 4096 }),
1748
1734
  created_at: s("created_at", { length: 35 }).notNull(),
1749
1735
  updated_at: s("updated_at", { length: 35 }).notNull()
@@ -1833,7 +1819,7 @@ const D = O("tenants", {
1833
1819
  S("user_roles_role_fk").on(n.tenant_id, n.role_id),
1834
1820
  S("user_roles_organization_fk").on(n.organization_id)
1835
1821
  ]
1836
- ), E = O(
1822
+ ), C = O(
1837
1823
  "resource_servers",
1838
1824
  {
1839
1825
  id: s("id", { length: 21 }).notNull(),
@@ -1843,15 +1829,15 @@ const D = O("tenants", {
1843
1829
  scopes: s("scopes", { length: 4096 }),
1844
1830
  signing_alg: s("signing_alg", { length: 64 }),
1845
1831
  signing_secret: s("signing_secret", { length: 2048 }),
1846
- token_lifetime: p("token_lifetime"),
1847
- token_lifetime_for_web: p("token_lifetime_for_web"),
1848
- 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(
1849
1835
  "skip_consent_for_verifiable_first_party_clients"
1850
1836
  ),
1851
- allow_offline_access: p("allow_offline_access"),
1837
+ allow_offline_access: m("allow_offline_access"),
1852
1838
  verification_key: s("verification_key", { length: 4096 }),
1853
1839
  options: s("options", { length: 4096 }),
1854
- is_system: p("is_system").notNull().default(0),
1840
+ is_system: m("is_system").notNull().default(0),
1855
1841
  metadata: s("metadata", { length: 4096 }),
1856
1842
  created_at: s("created_at", { length: 35 }).notNull(),
1857
1843
  updated_at: s("updated_at", { length: 35 }).notNull()
@@ -1875,14 +1861,14 @@ const D = O("tenants", {
1875
1861
  length: 8
1876
1862
  }),
1877
1863
  colors_page_background_end: s("colors_page_background_end", { length: 8 }),
1878
- colors_page_background_angle_dev: p("colors_page_background_angle_dev")
1864
+ colors_page_background_angle_dev: m("colors_page_background_angle_dev")
1879
1865
  }), ve = O(
1880
1866
  "universal_login_templates",
1881
1867
  {
1882
1868
  tenant_id: s("tenant_id", { length: 191 }).primaryKey().references(() => D.id, { onDelete: "cascade" }),
1883
1869
  body: s("body").notNull(),
1884
- created_at_ts: p("created_at_ts").notNull(),
1885
- 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()
1886
1872
  }
1887
1873
  ), fe = O(
1888
1874
  "themes",
@@ -1935,54 +1921,54 @@ const D = O("tenants", {
1935
1921
  colors_widget_border: s("colors_widget_border", {
1936
1922
  length: 24
1937
1923
  }).notNull(),
1938
- borders_button_border_radius: p(
1924
+ borders_button_border_radius: m(
1939
1925
  "borders_button_border_radius"
1940
1926
  ).notNull(),
1941
- borders_button_border_weight: p(
1927
+ borders_button_border_weight: m(
1942
1928
  "borders_button_border_weight"
1943
1929
  ).notNull(),
1944
1930
  borders_buttons_style: s("borders_buttons_style", {
1945
1931
  length: 24
1946
1932
  }).notNull(),
1947
- borders_input_border_radius: p(
1933
+ borders_input_border_radius: m(
1948
1934
  "borders_input_border_radius"
1949
1935
  ).notNull(),
1950
- borders_input_border_weight: p(
1936
+ borders_input_border_weight: m(
1951
1937
  "borders_input_border_weight"
1952
1938
  ).notNull(),
1953
1939
  borders_inputs_style: s("borders_inputs_style", {
1954
1940
  length: 24
1955
1941
  }).notNull(),
1956
- borders_show_widget_shadow: p("borders_show_widget_shadow", {
1942
+ borders_show_widget_shadow: m("borders_show_widget_shadow", {
1957
1943
  mode: "boolean"
1958
1944
  }).notNull(),
1959
- borders_widget_border_weight: p(
1945
+ borders_widget_border_weight: m(
1960
1946
  "borders_widget_border_weight"
1961
1947
  ).notNull(),
1962
- borders_widget_corner_radius: p(
1948
+ borders_widget_corner_radius: m(
1963
1949
  "borders_widget_corner_radius"
1964
1950
  ).notNull(),
1965
- fonts_body_text_bold: p("fonts_body_text_bold").notNull(),
1966
- fonts_body_text_size: p("fonts_body_text_size").notNull(),
1967
- fonts_buttons_text_bold: p("fonts_buttons_text_bold").notNull(),
1968
- 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(),
1969
1955
  fonts_font_url: s("fonts_font_url", { length: 255 }).notNull(),
1970
- fonts_input_labels_bold: p("fonts_input_labels_bold").notNull(),
1971
- fonts_input_labels_size: p("fonts_input_labels_size").notNull(),
1972
- 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", {
1973
1959
  mode: "boolean"
1974
1960
  }).notNull(),
1975
- fonts_links_size: p("fonts_links_size").notNull(),
1961
+ fonts_links_size: m("fonts_links_size").notNull(),
1976
1962
  fonts_links_style: s("fonts_links_style", { length: 24 }).notNull(),
1977
- fonts_reference_text_size: p("fonts_reference_text_size").notNull(),
1978
- 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", {
1979
1965
  mode: "boolean"
1980
1966
  }).notNull(),
1981
- fonts_subtitle_size: p("fonts_subtitle_size").notNull(),
1982
- fonts_title_bold: p("fonts_title_bold", {
1967
+ fonts_subtitle_size: m("fonts_subtitle_size").notNull(),
1968
+ fonts_title_bold: m("fonts_title_bold", {
1983
1969
  mode: "boolean"
1984
1970
  }).notNull(),
1985
- fonts_title_size: p("fonts_title_size").notNull(),
1971
+ fonts_title_size: m("fonts_title_size").notNull(),
1986
1972
  page_background_background_color: s("page_background_background_color", {
1987
1973
  length: 24
1988
1974
  }).notNull(),
@@ -1996,7 +1982,7 @@ const D = O("tenants", {
1996
1982
  widget_header_text_alignment: s("widget_header_text_alignment", {
1997
1983
  length: 24
1998
1984
  }).notNull(),
1999
- widget_logo_height: p("widget_logo_height").notNull(),
1985
+ widget_logo_height: m("widget_logo_height").notNull(),
2000
1986
  widget_logo_position: s("widget_logo_position", {
2001
1987
  length: 24
2002
1988
  }).notNull(),
@@ -2045,15 +2031,15 @@ const D = O("tenants", {
2045
2031
  ), Ee = O("prompt_settings", {
2046
2032
  tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
2047
2033
  universal_login_experience: s("universal_login_experience", { length: 16 }).notNull().default("new"),
2048
- identifier_first: p("identifier_first", { mode: "boolean" }).notNull().default(!0),
2049
- password_first: p("password_first", { mode: "boolean" }).notNull().default(!1),
2050
- 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", {
2051
2037
  mode: "boolean"
2052
2038
  }).notNull().default(!1)
2053
2039
  }), Se = O("email_providers", {
2054
2040
  tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
2055
2041
  name: s("name", { length: 255 }).notNull(),
2056
- enabled: p("enabled", { mode: "boolean" }).notNull(),
2042
+ enabled: m("enabled", { mode: "boolean" }).notNull(),
2057
2043
  default_from_address: s("default_from_address", { length: 255 }),
2058
2044
  credentials: s("credentials", { length: 2048 }).notNull().default("{}"),
2059
2045
  settings: s("settings", { length: 2048 }).notNull().default("{}"),
@@ -2067,11 +2053,11 @@ const D = O("tenants", {
2067
2053
  url: s("url", { length: 512 }),
2068
2054
  // nullable - only required for webhook type hooks
2069
2055
  trigger_id: s("trigger_id", { length: 255 }).notNull(),
2070
- enabled: p("enabled", { mode: "boolean" }).notNull(),
2071
- created_at_ts: p("created_at_ts").notNull(),
2072
- updated_at_ts: p("updated_at_ts").notNull(),
2073
- synchronous: p("synchronous", { mode: "boolean" }).notNull().default(!1),
2074
- 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"),
2075
2061
  form_id: s("form_id", { length: 128 }),
2076
2062
  // only required for form type hooks
2077
2063
  template_id: s("template_id", { length: 64 }),
@@ -2080,18 +2066,18 @@ const D = O("tenants", {
2080
2066
  // only required for code type hooks
2081
2067
  },
2082
2068
  (n) => [S("hooks_tenant_id_idx").on(n.tenant_id)]
2083
- ), he = O(
2069
+ ), pe = O(
2084
2070
  "hook_code",
2085
2071
  {
2086
2072
  id: s("id", { length: 21 }).primaryKey(),
2087
2073
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
2088
2074
  code: s("code").notNull(),
2089
2075
  secrets: s("secrets"),
2090
- created_at_ts: p("created_at_ts").notNull(),
2091
- 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()
2092
2078
  },
2093
2079
  (n) => [S("hook_code_tenant_id_idx").on(n.tenant_id)]
2094
- ), me = O("keys", {
2080
+ ), he = O("keys", {
2095
2081
  kid: s("kid", { length: 255 }).primaryKey(),
2096
2082
  tenant_id: s("tenant_id", { length: 191 }).references(() => D.id, {
2097
2083
  onDelete: "cascade"
@@ -2116,8 +2102,8 @@ const D = O("tenants", {
2116
2102
  prompt: s("prompt", { length: 64 }).notNull(),
2117
2103
  language: s("language", { length: 16 }).notNull(),
2118
2104
  custom_text: s("custom_text").notNull(),
2119
- created_at_ts: p("created_at_ts").notNull(),
2120
- 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()
2121
2107
  },
2122
2108
  (n) => [
2123
2109
  oe({ columns: [n.tenant_id, n.prompt, n.language] })
@@ -2133,13 +2119,13 @@ const D = O("tenants", {
2133
2119
  totp_secret: s("totp_secret", { length: 255 }),
2134
2120
  credential_id: s("credential_id", { length: 512 }),
2135
2121
  public_key: s("public_key"),
2136
- sign_count: p("sign_count"),
2137
- credential_backed_up: p("credential_backed_up"),
2122
+ sign_count: m("sign_count"),
2123
+ credential_backed_up: m("credential_backed_up"),
2138
2124
  transports: s("transports", { length: 512 }),
2139
2125
  friendly_name: s("friendly_name", { length: 255 }),
2140
- confirmed: p("confirmed").notNull().default(0),
2141
- created_at_ts: p("created_at_ts").notNull(),
2142
- 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()
2143
2129
  },
2144
2130
  (n) => [
2145
2131
  S("authentication_methods_tenant_user_idx").on(
@@ -2163,7 +2149,7 @@ const D = O("tenants", {
2163
2149
  user_agent: s("user_agent", { length: 255 }),
2164
2150
  description: s("description", { length: 255 }),
2165
2151
  details: s("details", { length: 2048 }),
2166
- isMobile: p("isMobile"),
2152
+ isMobile: m("isMobile"),
2167
2153
  user_name: s("user_name", { length: 255 }),
2168
2154
  connection: s("connection", { length: 255 }),
2169
2155
  connection_id: s("connection_id", { length: 255 }),
@@ -2204,7 +2190,7 @@ const D = O("tenants", {
2204
2190
  payload: s("payload").notNull(),
2205
2191
  created_at: s("created_at", { length: 35 }).notNull(),
2206
2192
  processed_at: s("processed_at", { length: 35 }),
2207
- retry_count: p("retry_count").notNull().default(0),
2193
+ retry_count: m("retry_count").notNull().default(0),
2208
2194
  next_retry_at: s("next_retry_at", { length: 35 }),
2209
2195
  error: s("error"),
2210
2196
  claimed_by: s("claimed_by", { length: 255 }),
@@ -2232,35 +2218,35 @@ const D = O("tenants", {
2232
2218
  branding: Le,
2233
2219
  clientGrants: Y,
2234
2220
  clients: I,
2235
- codes: P,
2221
+ codes: Q,
2236
2222
  connections: K,
2237
2223
  customDomains: se,
2238
2224
  customText: te,
2239
- domains: Qr,
2225
+ domains: Jr,
2240
2226
  emailProviders: Se,
2241
2227
  flows: re,
2242
2228
  forms: ie,
2243
- hookCode: he,
2229
+ hookCode: pe,
2244
2230
  hooks: ee,
2245
2231
  invites: ne,
2246
- keys: me,
2247
- loginSessions: $,
2232
+ keys: he,
2233
+ loginSessions: L,
2248
2234
  logs: q,
2249
- organizations: L,
2235
+ organizations: E,
2250
2236
  otps: $r,
2251
2237
  outboxEvents: b,
2252
- passwords: C,
2238
+ passwords: A,
2253
2239
  promptSettings: Ee,
2254
2240
  refreshTokens: T,
2255
- resourceServers: E,
2241
+ resourceServers: C,
2256
2242
  rolePermissions: le,
2257
2243
  roles: F,
2258
- sessions: B,
2244
+ sessions: $,
2259
2245
  tenants: D,
2260
2246
  themes: fe,
2261
- tickets: Pr,
2247
+ tickets: Qr,
2262
2248
  universalLoginTemplates: ve,
2263
- userOrganizations: Q,
2249
+ userOrganizations: J,
2264
2250
  userPermissions: _e,
2265
2251
  userRoles: ue,
2266
2252
  users: k
@@ -2281,7 +2267,7 @@ function z(n) {
2281
2267
  }
2282
2268
  return i;
2283
2269
  }
2284
- function Jr(n, i, e = { ...n }) {
2270
+ function Pr(n, i, e = { ...n }) {
2285
2271
  for (const t of i)
2286
2272
  n[t] !== void 0 && (e[t] = JSON.stringify(n[t]));
2287
2273
  return e;
@@ -2307,11 +2293,11 @@ function x(n, i) {
2307
2293
  }
2308
2294
  return n;
2309
2295
  }
2310
- function Pe(n, i = "", e = {}) {
2296
+ function yt(n, i = "", e = {}) {
2311
2297
  for (const t in n)
2312
2298
  if (Object.prototype.hasOwnProperty.call(n, t)) {
2313
2299
  const r = i ? `${i}_${t}` : t, o = n[t];
2314
- 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;
2315
2301
  }
2316
2302
  return e;
2317
2303
  }
@@ -2366,7 +2352,7 @@ function Kr(n) {
2366
2352
  });
2367
2353
  },
2368
2354
  async set(i, e) {
2369
- var _, u, c, d, m, f, y, N;
2355
+ var _, u, c, d, h, f, y, N;
2370
2356
  const { colors: t, font: r, ...o } = e, l = {
2371
2357
  ...o,
2372
2358
  tenant_id: i,
@@ -2382,7 +2368,7 @@ function Kr(n) {
2382
2368
  set: {
2383
2369
  ...o,
2384
2370
  colors_primary: t == null ? void 0 : t.primary,
2385
- 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,
2386
2372
  colors_page_background_start: (f = t == null ? void 0 : t.page_background) == null ? void 0 : f.start,
2387
2373
  colors_page_background_end: (y = t == null ? void 0 : t.page_background) == null ? void 0 : y.end,
2388
2374
  colors_page_background_angle_dev: (N = t == null ? void 0 : t.page_background) == null ? void 0 : N.angle_deg,
@@ -2400,8 +2386,8 @@ var be = class extends Error {
2400
2386
  */
2401
2387
  constructor(i = 500, e) {
2402
2388
  super(e == null ? void 0 : e.message, { cause: e == null ? void 0 : e.cause });
2403
- h(this, "res");
2404
- h(this, "status");
2389
+ p(this, "res");
2390
+ p(this, "status");
2405
2391
  this.res = e == null ? void 0 : e.res, this.status = i;
2406
2392
  }
2407
2393
  /**
@@ -2418,16 +2404,16 @@ var be = class extends Error {
2418
2404
  });
2419
2405
  }
2420
2406
  };
2421
- function pe(n, i, e) {
2407
+ function me(n, i, e) {
2422
2408
  const t = i.split(/ OR /i);
2423
2409
  if (t.length > 1) {
2424
2410
  const c = t.map((d) => {
2425
- const m = d.trim().match(/^([^:]+):(.+)$/);
2426
- if (m) {
2427
- const [, f, y] = m;
2411
+ const h = d.trim().match(/^([^:]+):(.+)$/);
2412
+ if (h) {
2413
+ const [, f, y] = h;
2428
2414
  if (!f || !y) return null;
2429
- const N = y.replace(/^"(.*)"$/, "$1"), A = n[f.trim()];
2430
- 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;
2431
2417
  }
2432
2418
  return null;
2433
2419
  }).filter(Boolean);
@@ -2441,32 +2427,32 @@ function pe(n, i, e) {
2441
2427
  }
2442
2428
  o.trim() && r.push(o.trim());
2443
2429
  const _ = r.map((c) => c.replace(/^([^:]+)=/g, "$1:")).map((c) => {
2444
- let d = c.startsWith("-"), m = null, f = "", y = !1, N;
2430
+ let d = c.startsWith("-"), h = null, f = "", y = !1, N;
2445
2431
  if (c.startsWith("-_exists_:"))
2446
- m = c.substring(10), y = !0, d = !0;
2432
+ h = c.substring(10), y = !0, d = !0;
2447
2433
  else if (c.startsWith("_exists_:"))
2448
- m = c.substring(9), y = !0, d = !1;
2434
+ h = c.substring(9), y = !0, d = !1;
2449
2435
  else if (c.includes(":")) {
2450
- const A = d ? c.substring(1) : c, W = A.indexOf(":");
2451
- 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));
2452
2438
  } else
2453
- m = null, f = c, y = !1;
2454
- 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 };
2455
2441
  }), u = [];
2456
- 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 _)
2457
2443
  if (c) {
2458
2444
  const N = n[c];
2459
2445
  if (!N) {
2460
2446
  f ? u.push(
2461
- 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`
2462
2448
  ) : u.push(
2463
- w`${w.identifier(c)} ${w.raw(m ? "!=" : y ?? "=")} ${d}`
2449
+ w`${w.identifier(c)} ${w.raw(h ? "!=" : y ?? "=")} ${d}`
2464
2450
  );
2465
2451
  continue;
2466
2452
  }
2467
2453
  if (f)
2468
- u.push(m ? ye(N) : Ve(N));
2469
- else if (m)
2454
+ u.push(h ? ye(N) : Me(N));
2455
+ else if (h)
2470
2456
  switch (y) {
2471
2457
  case ">":
2472
2458
  u.push(Oe(N, d));
@@ -2475,10 +2461,10 @@ function pe(n, i, e) {
2475
2461
  u.push(we(N, d));
2476
2462
  break;
2477
2463
  case "<":
2478
- u.push(Ge(N, d));
2464
+ u.push(He(N, d));
2479
2465
  break;
2480
2466
  case "<=":
2481
- u.push(He(N, d));
2467
+ u.push(We(N, d));
2482
2468
  break;
2483
2469
  default:
2484
2470
  u.push(kr(N, d));
@@ -2486,10 +2472,10 @@ function pe(n, i, e) {
2486
2472
  else
2487
2473
  switch (y) {
2488
2474
  case ">":
2489
- u.push(He(N, d));
2475
+ u.push(We(N, d));
2490
2476
  break;
2491
2477
  case ">=":
2492
- u.push(Ge(N, d));
2478
+ u.push(He(N, d));
2493
2479
  break;
2494
2480
  case "<":
2495
2481
  u.push(we(N, d));
@@ -2501,11 +2487,11 @@ function pe(n, i, e) {
2501
2487
  u.push(a(N, d));
2502
2488
  }
2503
2489
  } else if (d) {
2504
- const A = (d.includes("|") ? [...e, "user_id"] : e).map((W) => {
2490
+ const B = (d.includes("|") ? [...e, "user_id"] : e).map((W) => {
2505
2491
  const H = n[W];
2506
2492
  return H ? W === "user_id" ? a(H, d) : Ie(H, `%${d}%`) : null;
2507
2493
  }).filter(Boolean);
2508
- A.length > 0 && u.push(de(...A));
2494
+ B.length > 0 && u.push(de(...B));
2509
2495
  }
2510
2496
  if (u.length !== 0)
2511
2497
  return u.length === 1 ? u[0] : g(...u);
@@ -2545,7 +2531,7 @@ const kt = [
2545
2531
  "signed_request_object",
2546
2532
  "token_quota"
2547
2533
  ];
2548
- function Ue(n) {
2534
+ function Fe(n) {
2549
2535
  const { tenant_id: i, connections: e, ...t } = n, r = { ...t };
2550
2536
  for (const o of kt)
2551
2537
  r[o] = !!t[o];
@@ -2609,7 +2595,7 @@ function jr(n) {
2609
2595
  message: "Client already exists"
2610
2596
  }) : u;
2611
2597
  }
2612
- return Ue({ ...o, tenant_id: i });
2598
+ return Fe({ ...o, tenant_id: i });
2613
2599
  },
2614
2600
  async get(i, e) {
2615
2601
  const t = await n.select().from(I).where(
@@ -2618,12 +2604,12 @@ function jr(n) {
2618
2604
  a(I.client_id, e)
2619
2605
  )
2620
2606
  ).get();
2621
- return t ? Ue(t) : null;
2607
+ return t ? Fe(t) : null;
2622
2608
  },
2623
2609
  async getByClientId(i) {
2624
2610
  const e = await n.select().from(I).where(a(I.client_id, i)).get();
2625
2611
  return e ? {
2626
- ...Ue(e),
2612
+ ...Fe(e),
2627
2613
  tenant_id: e.tenant_id
2628
2614
  } : null;
2629
2615
  },
@@ -2649,7 +2635,7 @@ function jr(n) {
2649
2635
  } = e || {};
2650
2636
  let u = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
2651
2637
  if (_) {
2652
- const f = pe(I, _, ["name", "client_id"]);
2638
+ const f = me(I, _, ["name", "client_id"]);
2653
2639
  f && (u = u.where(g(a(I.tenant_id, i), f)));
2654
2640
  }
2655
2641
  if (l != null && l.sort_by) {
@@ -2658,15 +2644,15 @@ function jr(n) {
2658
2644
  l.sort_order === "desc" ? V(f) : G(f)
2659
2645
  ));
2660
2646
  }
2661
- const d = (await u.offset(t * r).limit(r)).map(Ue);
2647
+ const d = (await u.offset(t * r).limit(r)).map(Fe);
2662
2648
  if (!o)
2663
2649
  return { clients: d };
2664
- 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));
2665
2651
  return {
2666
2652
  clients: d,
2667
2653
  start: t * r,
2668
2654
  limit: r,
2669
- length: Number((m == null ? void 0 : m.count) ?? 0)
2655
+ length: Number((h == null ? void 0 : h.count) ?? 0)
2670
2656
  };
2671
2657
  },
2672
2658
  async remove(i, e) {
@@ -2787,7 +2773,7 @@ let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr
2787
2773
  i += Rr[e[n] & 63];
2788
2774
  return i;
2789
2775
  };
2790
- function nt(n) {
2776
+ function tt(n) {
2791
2777
  const {
2792
2778
  tenant_id: i,
2793
2779
  scope: e,
@@ -2826,13 +2812,13 @@ function Yr(n) {
2826
2812
  created_at: t,
2827
2813
  updated_at: t
2828
2814
  };
2829
- 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 });
2830
2816
  },
2831
2817
  async get(i, e) {
2832
2818
  const t = await n.select().from(Y).where(
2833
2819
  g(a(Y.tenant_id, i), a(Y.id, e))
2834
2820
  ).get();
2835
- return t ? nt(t) : null;
2821
+ return t ? tt(t) : null;
2836
2822
  },
2837
2823
  async update(i, e, t) {
2838
2824
  const {
@@ -2858,7 +2844,7 @@ function Yr(n) {
2858
2844
  include_totals: o = !1,
2859
2845
  sort: l,
2860
2846
  q: _
2861
- } = 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);
2862
2848
  let d = n.select().from(Y).where(c).$dynamic();
2863
2849
  if (l != null && l.sort_by) {
2864
2850
  const N = Y[l.sort_by];
@@ -2867,7 +2853,7 @@ function Yr(n) {
2867
2853
  ));
2868
2854
  } else
2869
2855
  d = d.orderBy(G(Y.created_at));
2870
- const f = (await d.offset(t * r).limit(r)).map(nt);
2856
+ const f = (await d.offset(t * r).limit(r)).map(tt);
2871
2857
  if (!o)
2872
2858
  return { client_grants: f };
2873
2859
  const [y] = await n.select({ count: R() }).from(Y).where(c);
@@ -2885,7 +2871,7 @@ function Yr(n) {
2885
2871
  }
2886
2872
  };
2887
2873
  }
2888
- function it(n) {
2874
+ function nt(n) {
2889
2875
  const { tenant_id: i, ...e } = n;
2890
2876
  return z(e);
2891
2877
  }
@@ -2898,19 +2884,19 @@ function Xr(n) {
2898
2884
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
2899
2885
  expires_at: e.expires_at
2900
2886
  };
2901
- return await n.insert(P).values(t), it(t);
2887
+ return await n.insert(Q).values(t), nt(t);
2902
2888
  },
2903
2889
  async get(i, e, t) {
2904
2890
  if (!i)
2905
2891
  throw new Error("tenant_id is required");
2906
- const r = await n.select().from(P).where(
2892
+ const r = await n.select().from(Q).where(
2907
2893
  g(
2908
- a(P.tenant_id, i),
2909
- a(P.code_id, e),
2910
- a(P.code_type, t)
2894
+ a(Q.tenant_id, i),
2895
+ a(Q.code_id, e),
2896
+ a(Q.code_type, t)
2911
2897
  )
2912
2898
  ).get();
2913
- return r ? it(r) : null;
2899
+ return r ? nt(r) : null;
2914
2900
  },
2915
2901
  async list(i, e) {
2916
2902
  const {
@@ -2919,17 +2905,17 @@ function Xr(n) {
2919
2905
  include_totals: o = !1,
2920
2906
  sort: l
2921
2907
  } = e || {};
2922
- 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();
2923
2909
  if (l != null && l.sort_by) {
2924
- const m = P[l.sort_by];
2925
- m && (_ = _.orderBy(
2926
- 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)
2927
2913
  ));
2928
2914
  }
2929
- const c = (await _.offset(t * r).limit(r)).map(it);
2915
+ const c = (await _.offset(t * r).limit(r)).map(nt);
2930
2916
  if (!o)
2931
2917
  return { codes: c };
2932
- 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));
2933
2919
  return {
2934
2920
  codes: c,
2935
2921
  start: t * r,
@@ -2938,19 +2924,19 @@ function Xr(n) {
2938
2924
  };
2939
2925
  },
2940
2926
  async used(i, e) {
2941
- 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;
2942
2928
  },
2943
2929
  async consume(i, e) {
2944
- 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(
2945
2931
  g(
2946
- a(P.tenant_id, i),
2947
- a(P.code_id, e),
2948
- ye(P.used_at)
2932
+ a(Q.tenant_id, i),
2933
+ a(Q.code_id, e),
2934
+ ye(Q.used_at)
2949
2935
  )
2950
2936
  ).returning()).length > 0;
2951
2937
  },
2952
2938
  async remove(i, e) {
2953
- 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;
2954
2940
  }
2955
2941
  };
2956
2942
  }
@@ -2958,7 +2944,7 @@ function Zr() {
2958
2944
  const { customAlphabet: n } = require("nanoid");
2959
2945
  return `con_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
2960
2946
  }
2961
- function rt(n) {
2947
+ function it(n) {
2962
2948
  const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
2963
2949
  return z({
2964
2950
  ...o,
@@ -2988,7 +2974,7 @@ function es(n) {
2988
2974
  message: "Connection already exists"
2989
2975
  }) : _;
2990
2976
  }
2991
- return rt(r);
2977
+ return it(r);
2992
2978
  },
2993
2979
  async get(i, e) {
2994
2980
  const t = await n.select().from(K).where(
@@ -2997,7 +2983,7 @@ function es(n) {
2997
2983
  a(K.id, e)
2998
2984
  )
2999
2985
  ).get();
3000
- return t ? rt(t) : null;
2986
+ return t ? it(t) : null;
3001
2987
  },
3002
2988
  async update(i, e, t) {
3003
2989
  const r = {
@@ -3020,7 +3006,7 @@ function es(n) {
3020
3006
  } = e || {};
3021
3007
  let u = a(K.tenant_id, i);
3022
3008
  if (_) {
3023
- const y = pe(K, _, ["name"]);
3009
+ const y = me(K, _, ["name"]);
3024
3010
  y && (u = g(u, y));
3025
3011
  }
3026
3012
  let c = n.select().from(K).where(u).$dynamic();
@@ -3030,12 +3016,12 @@ function es(n) {
3030
3016
  l.sort_order === "desc" ? V(y) : G(y)
3031
3017
  ));
3032
3018
  }
3033
- const m = (await c.offset(t * r).limit(r)).map(rt);
3019
+ const h = (await c.offset(t * r).limit(r)).map(it);
3034
3020
  if (!o)
3035
- return { connections: m };
3021
+ return { connections: h };
3036
3022
  const [f] = await n.select({ count: R() }).from(K).where(u);
3037
3023
  return {
3038
- connections: m,
3024
+ connections: h,
3039
3025
  start: t * r,
3040
3026
  limit: r,
3041
3027
  length: Number((f == null ? void 0 : f.count) ?? 0)
@@ -3051,7 +3037,7 @@ function es(n) {
3051
3037
  }
3052
3038
  };
3053
3039
  }
3054
- function Ke(n) {
3040
+ function Ue(n) {
3055
3041
  const { tenant_id: i, domain_metadata: e, ...t } = n;
3056
3042
  return z({
3057
3043
  ...t,
@@ -3077,7 +3063,7 @@ function ts(n) {
3077
3063
  created_at: t,
3078
3064
  updated_at: t
3079
3065
  };
3080
- 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 });
3081
3067
  },
3082
3068
  async get(i, e) {
3083
3069
  const t = await n.select().from(se).where(
@@ -3086,17 +3072,17 @@ function ts(n) {
3086
3072
  a(se.custom_domain_id, e)
3087
3073
  )
3088
3074
  ).get();
3089
- return t ? Ke(t) : null;
3075
+ return t ? Ue(t) : null;
3090
3076
  },
3091
3077
  async getByDomain(i) {
3092
3078
  const e = await n.select().from(se).where(a(se.domain, i)).get();
3093
3079
  return e ? {
3094
- ...Ke(e),
3080
+ ...Ue(e),
3095
3081
  tenant_id: e.tenant_id
3096
3082
  } : null;
3097
3083
  },
3098
3084
  async list(i) {
3099
- 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);
3100
3086
  },
3101
3087
  async update(i, e, t) {
3102
3088
  const r = {
@@ -3251,13 +3237,13 @@ function rs(n) {
3251
3237
  } = e || {};
3252
3238
  let _ = n.select().from(re).where(a(re.tenant_id, i)).$dynamic();
3253
3239
  if (l != null && l.sort_by) {
3254
- const m = re[l.sort_by];
3255
- m && (_ = _.orderBy(
3256
- 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)
3257
3243
  ));
3258
3244
  }
3259
- const c = (await _.offset(t * r).limit(r)).map((m) => {
3260
- 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;
3261
3247
  return z({
3262
3248
  ...N,
3263
3249
  actions: x(y, [])
@@ -3278,7 +3264,7 @@ function rs(n) {
3278
3264
  }
3279
3265
  };
3280
3266
  }
3281
- const je = ["nodes", "start", "ending"];
3267
+ const Ke = ["nodes", "start", "ending"];
3282
3268
  function ss(n) {
3283
3269
  return {
3284
3270
  async create(i, e) {
@@ -3293,7 +3279,7 @@ function ss(n) {
3293
3279
  created_at: t,
3294
3280
  updated_at: t
3295
3281
  };
3296
- for (const l of je)
3282
+ for (const l of Ke)
3297
3283
  o[l] = JSON.stringify(
3298
3284
  e[l] || (l === "nodes" ? [] : {})
3299
3285
  );
@@ -3308,7 +3294,7 @@ function ss(n) {
3308
3294
  const t = await n.select().from(ie).where(g(a(ie.tenant_id, i), a(ie.id, e))).get();
3309
3295
  if (!t) return null;
3310
3296
  const { tenant_id: r, ...o } = t, l = { ...o };
3311
- for (const _ of je)
3297
+ for (const _ of Ke)
3312
3298
  l[_] = x(o[_]);
3313
3299
  return z(l);
3314
3300
  },
@@ -3317,7 +3303,7 @@ function ss(n) {
3317
3303
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3318
3304
  };
3319
3305
  for (const [l, _] of Object.entries(t))
3320
- _ !== void 0 && (je.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
3306
+ _ !== void 0 && (Ke.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
3321
3307
  return (await n.update(ie).set(r).where(g(a(ie.tenant_id, i), a(ie.id, e))).returning()).length > 0;
3322
3308
  },
3323
3309
  async list(i, e) {
@@ -3329,15 +3315,15 @@ function ss(n) {
3329
3315
  } = e || {};
3330
3316
  let _ = n.select().from(ie).where(a(ie.tenant_id, i)).$dynamic();
3331
3317
  if (l != null && l.sort_by) {
3332
- const m = ie[l.sort_by];
3333
- m && (_ = _.orderBy(
3334
- 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)
3335
3321
  ));
3336
3322
  }
3337
- const c = (await _.offset(t * r).limit(r)).map((m) => {
3338
- const { tenant_id: f, ...y } = m, N = { ...y };
3339
- for (const A of je)
3340
- 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]);
3341
3327
  return z(N);
3342
3328
  });
3343
3329
  if (!o)
@@ -3355,7 +3341,7 @@ function ss(n) {
3355
3341
  }
3356
3342
  };
3357
3343
  }
3358
- function hr(n) {
3344
+ function pr(n) {
3359
3345
  if (n != null) {
3360
3346
  if (typeof n == "number")
3361
3347
  return new Date(n).toISOString();
@@ -3368,7 +3354,7 @@ function hr(n) {
3368
3354
  }
3369
3355
  }
3370
3356
  function wt(n, i = (/* @__PURE__ */ new Date(0)).toISOString()) {
3371
- return hr(n) ?? i;
3357
+ return pr(n) ?? i;
3372
3358
  }
3373
3359
  function j(n) {
3374
3360
  if (!n || n === "")
@@ -3376,7 +3362,7 @@ function j(n) {
3376
3362
  const i = new Date(n);
3377
3363
  return isNaN(i.getTime()) ? null : i.getTime();
3378
3364
  }
3379
- function Fe(n, i, e = []) {
3365
+ function Pe(n, i, e = []) {
3380
3366
  const t = {};
3381
3367
  for (const r of i) {
3382
3368
  const o = r.replace(/_ts$/, "");
@@ -3384,7 +3370,7 @@ function Fe(n, i, e = []) {
3384
3370
  }
3385
3371
  for (const r of e) {
3386
3372
  const o = r.replace(/_ts$/, "");
3387
- t[o] = hr(n[r]);
3373
+ t[o] = pr(n[r]);
3388
3374
  }
3389
3375
  return t;
3390
3376
  }
@@ -3393,7 +3379,7 @@ function as() {
3393
3379
  return `hc_${os()}`;
3394
3380
  }
3395
3381
  function At(n) {
3396
- 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 }, [
3397
3383
  "created_at_ts",
3398
3384
  "updated_at_ts"
3399
3385
  ]);
@@ -3414,20 +3400,20 @@ function ls(n) {
3414
3400
  created_at_ts: t,
3415
3401
  updated_at_ts: t
3416
3402
  };
3417
- 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 });
3418
3404
  },
3419
3405
  async get(i, e) {
3420
- 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();
3421
3407
  return t ? At(t) : null;
3422
3408
  },
3423
3409
  async update(i, e, t) {
3424
3410
  const r = {
3425
3411
  updated_at_ts: Date.now()
3426
3412
  };
3427
- 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;
3428
3414
  },
3429
3415
  async remove(i, e) {
3430
- 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;
3431
3417
  }
3432
3418
  };
3433
3419
  }
@@ -3435,8 +3421,8 @@ function _s() {
3435
3421
  const { customAlphabet: n } = require("nanoid");
3436
3422
  return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3437
3423
  }
3438
- function st(n) {
3439
- 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 }, [
3440
3426
  "created_at_ts",
3441
3427
  "updated_at_ts"
3442
3428
  ]);
@@ -3464,11 +3450,11 @@ function us(n) {
3464
3450
  created_at_ts: t,
3465
3451
  updated_at_ts: t
3466
3452
  };
3467
- 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 });
3468
3454
  },
3469
3455
  async get(i, e) {
3470
3456
  const t = await n.select().from(ee).where(g(a(ee.tenant_id, i), a(ee.hook_id, e))).get();
3471
- return t ? st(t) : null;
3457
+ return t ? rt(t) : null;
3472
3458
  },
3473
3459
  async update(i, e, t) {
3474
3460
  const r = {
@@ -3483,7 +3469,7 @@ function us(n) {
3483
3469
  include_totals: o = !1,
3484
3470
  sort: l,
3485
3471
  q: _
3486
- } = e || {}, u = _ ? pe(ee, _, [
3472
+ } = e || {}, u = _ ? me(ee, _, [
3487
3473
  "url",
3488
3474
  "form_id",
3489
3475
  "template_id",
@@ -3496,7 +3482,7 @@ function us(n) {
3496
3482
  l.sort_order === "desc" ? V(N) : G(N)
3497
3483
  ));
3498
3484
  }
3499
- const f = (await d.offset(t * r).limit(r)).map(st);
3485
+ const f = (await d.offset(t * r).limit(r)).map(rt);
3500
3486
  if (!o)
3501
3487
  return { hooks: f };
3502
3488
  const [y] = await n.select({ count: R() }).from(ee).where(c);
@@ -3523,7 +3509,7 @@ const Nt = [
3523
3509
  "user_metadata",
3524
3510
  "roles"
3525
3511
  ];
3526
- function ot(n) {
3512
+ function st(n) {
3527
3513
  const { tenant_id: i, send_invitation_email: e, ...t } = n, r = { ...t };
3528
3514
  for (const o of Nt)
3529
3515
  r[o] = x(t[o], o === "roles" ? [] : {});
@@ -3553,11 +3539,11 @@ function cs(n) {
3553
3539
  } catch (d) {
3554
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;
3555
3541
  }
3556
- return ot({ ..._, tenant_id: i });
3542
+ return st({ ..._, tenant_id: i });
3557
3543
  },
3558
3544
  async get(i, e) {
3559
3545
  const t = await n.select().from(ne).where(g(a(ne.tenant_id, i), a(ne.id, e))).get();
3560
- return t ? ot(t) : null;
3546
+ return t ? st(t) : null;
3561
3547
  },
3562
3548
  async update(i, e, t) {
3563
3549
  const r = {};
@@ -3576,12 +3562,12 @@ function cs(n) {
3576
3562
  } = e || {};
3577
3563
  let _ = n.select().from(ne).where(a(ne.tenant_id, i)).$dynamic();
3578
3564
  if (l != null && l.sort_by) {
3579
- const m = ne[l.sort_by];
3580
- m && (_ = _.orderBy(
3581
- 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)
3582
3568
  ));
3583
3569
  }
3584
- const c = (await _.offset(t * r).limit(r)).map(ot);
3570
+ const c = (await _.offset(t * r).limit(r)).map(st);
3585
3571
  if (!o)
3586
3572
  return { invites: c };
3587
3573
  const [d] = await n.select({ count: R() }).from(ne).where(a(ne.tenant_id, i));
@@ -3600,7 +3586,7 @@ function cs(n) {
3600
3586
  function gs(n) {
3601
3587
  return {
3602
3588
  async create(i) {
3603
- await n.insert(me).values({
3589
+ await n.insert(he).values({
3604
3590
  ...i,
3605
3591
  created_at: (/* @__PURE__ */ new Date()).toDateString()
3606
3592
  });
@@ -3612,20 +3598,20 @@ function gs(n) {
3612
3598
  include_totals: r = !1,
3613
3599
  sort: o
3614
3600
  } = i || {}, l = (/* @__PURE__ */ new Date()).toISOString();
3615
- 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();
3616
3602
  if (o != null && o.sort_by) {
3617
- const m = me[o.sort_by];
3618
- m && (_ = _.orderBy(
3619
- 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)
3620
3606
  ));
3621
3607
  }
3622
- const c = (await _.offset(e * t).limit(t)).map((m) => {
3623
- const { created_at: f, ...y } = m;
3608
+ const c = (await _.offset(e * t).limit(t)).map((h) => {
3609
+ const { created_at: f, ...y } = h;
3624
3610
  return z(y);
3625
3611
  });
3626
3612
  if (!r)
3627
3613
  return { signingKeys: c };
3628
- 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)));
3629
3615
  return {
3630
3616
  signingKeys: c,
3631
3617
  start: e * t,
@@ -3634,19 +3620,19 @@ function gs(n) {
3634
3620
  };
3635
3621
  },
3636
3622
  async update(i, e) {
3637
- 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;
3638
3624
  }
3639
3625
  };
3640
3626
  }
3641
- const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", at = vt.length;
3627
+ const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ot = vt.length;
3642
3628
  function fs() {
3643
3629
  let e = Date.now(), t = "";
3644
3630
  for (let o = 10; o > 0; o--)
3645
- t = vt.charAt(e % at) + t, e = Math.floor(e / at);
3631
+ t = vt.charAt(e % ot) + t, e = Math.floor(e / ot);
3646
3632
  const r = new Uint8Array(16);
3647
3633
  crypto.getRandomValues(r);
3648
3634
  for (let o = 0; o < 16; o++)
3649
- t += vt.charAt(r[o] % at);
3635
+ t += vt.charAt(r[o] % ot);
3650
3636
  return t;
3651
3637
  }
3652
3638
  function Bt(n) {
@@ -3656,28 +3642,32 @@ function Bt(n) {
3656
3642
  updated_at_ts: t,
3657
3643
  expires_at_ts: r,
3658
3644
  state_data: o,
3659
- ...l
3660
- } = n, _ = Fe(
3645
+ auth_params: l,
3646
+ ..._
3647
+ } = n, u = Pe(
3661
3648
  { created_at_ts: e, updated_at_ts: t, expires_at_ts: r },
3662
3649
  ["created_at_ts", "updated_at_ts", "expires_at_ts"]
3663
- ), u = fr(l, ["authParams"]);
3650
+ ), c = {};
3651
+ for (const [h, f] of Object.entries(_))
3652
+ f != null && (c[h] = f);
3653
+ const d = fr(c, ["auth_strategy"]);
3664
3654
  return z({
3655
+ ...d,
3656
+ authParams: typeof l == "string" && l.length > 0 ? JSON.parse(l) : {},
3665
3657
  ...u,
3666
- ..._,
3667
3658
  state_data: x(o)
3668
3659
  });
3669
3660
  }
3670
- function hs(n) {
3661
+ function ps(n) {
3671
3662
  return {
3672
3663
  async create(i, e) {
3673
- const t = Date.now(), r = fs(), o = Pe(
3674
- { authParams: e.authParams || {} },
3675
- "authParams"
3676
- ), l = {
3677
- id: r,
3664
+ var l, _;
3665
+ const t = Date.now(), o = {
3666
+ id: fs(),
3678
3667
  tenant_id: i,
3679
3668
  session_id: e.session_id,
3680
3669
  csrf_token: e.csrf_token,
3670
+ auth_params: JSON.stringify(e.authParams || {}),
3681
3671
  authorization_url: e.authorization_url ? e.authorization_url.substring(0, 1024) : void 0,
3682
3672
  ip: e.ip,
3683
3673
  useragent: e.useragent,
@@ -3687,47 +3677,51 @@ function hs(n) {
3687
3677
  failure_reason: e.failure_reason,
3688
3678
  user_id: e.user_id,
3689
3679
  auth_connection: e.auth_connection,
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,
3682
+ authenticated_at: e.authenticated_at,
3690
3683
  created_at_ts: t,
3691
3684
  updated_at_ts: t,
3692
3685
  expires_at_ts: e.expires_at ? j(e.expires_at) : t + 1e3 * 60 * 60 * 24
3693
3686
  };
3694
- for (const [_, u] of Object.entries(o))
3695
- l[_] = u;
3696
- return await n.insert($).values(l), Bt({ ...l, tenant_id: i });
3687
+ return await n.insert(L).values(o), Bt({ ...o, tenant_id: i });
3697
3688
  },
3698
3689
  async get(i, e) {
3699
- const t = await n.select().from($).where(
3700
- g(a($.tenant_id, i), a($.id, e))
3701
- ).get();
3702
- return t ? Bt(t) : null;
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();
3691
+ return r ? Bt(r) : null;
3703
3692
  },
3704
3693
  async update(i, e, t) {
3705
- var o;
3694
+ var o, l, _;
3706
3695
  const r = {
3707
3696
  updated_at_ts: Date.now()
3708
3697
  };
3709
- 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.authorization_url !== void 0 && (r.authorization_url = (o = t.authorization_url) == null ? void 0 : o.substring(
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(
3710
3699
  0,
3711
3700
  1024
3712
- )), t.expires_at !== void 0 && (r.expires_at_ts = j(t.expires_at)), t.authParams) {
3713
- const l = Pe(
3714
- { authParams: t.authParams },
3715
- "authParams"
3716
- );
3717
- Object.assign(r, l);
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
+ });
3718
3712
  }
3719
- return await n.update($).set(r).where(
3720
- g(a($.tenant_id, i), a($.id, e))
3713
+ return await n.update(L).set(r).where(
3714
+ g(a(L.tenant_id, i), a(L.id, e))
3721
3715
  ), !0;
3722
3716
  },
3723
3717
  async remove(i, e) {
3724
- return (await n.delete($).where(
3725
- g(a($.tenant_id, i), a($.id, e))
3718
+ return (await n.delete(L).where(
3719
+ g(a(L.tenant_id, i), a(L.id, e))
3726
3720
  ).returning()).length > 0;
3727
3721
  }
3728
3722
  };
3729
3723
  }
3730
- function lt(n) {
3724
+ function at(n) {
3731
3725
  const {
3732
3726
  tenant_id: i,
3733
3727
  isMobile: e,
@@ -3739,14 +3733,14 @@ function lt(n) {
3739
3733
  longitude: u,
3740
3734
  time_zone: c,
3741
3735
  continent_code: d,
3742
- scope: m,
3736
+ scope: h,
3743
3737
  ...f
3744
3738
  } = n, y = {
3745
3739
  ...f,
3746
3740
  isMobile: !!e,
3747
3741
  auth0_client: x(t),
3748
3742
  details: x(r),
3749
- scope: m ? m.split(",") : void 0
3743
+ scope: h ? h.split(",") : void 0
3750
3744
  };
3751
3745
  return o && (y.location_info = z({
3752
3746
  country_code: o,
@@ -3757,7 +3751,7 @@ function lt(n) {
3757
3751
  continent_code: d
3758
3752
  })), z(y);
3759
3753
  }
3760
- function ms(n) {
3754
+ function hs(n) {
3761
3755
  return {
3762
3756
  async create(i, e) {
3763
3757
  var o, l;
@@ -3784,7 +3778,7 @@ function ms(n) {
3784
3778
  hostname: e.hostname,
3785
3779
  session_connection: e.session_connection
3786
3780
  };
3787
- 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 });
3788
3782
  },
3789
3783
  async list(i, e) {
3790
3784
  const {
@@ -3796,7 +3790,7 @@ function ms(n) {
3796
3790
  } = e || {};
3797
3791
  let u = n.select().from(q).where(a(q.tenant_id, i)).$dynamic();
3798
3792
  if (_) {
3799
- const f = pe(q, _, [
3793
+ const f = me(q, _, [
3800
3794
  "user_id",
3801
3795
  "ip",
3802
3796
  "type",
@@ -3811,35 +3805,35 @@ function ms(n) {
3811
3805
  ));
3812
3806
  } else
3813
3807
  u = u.orderBy(V(q.date));
3814
- const d = (await u.offset(t * r).limit(r)).map(lt);
3808
+ const d = (await u.offset(t * r).limit(r)).map(at);
3815
3809
  if (!o)
3816
3810
  return { logs: d };
3817
- 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));
3818
3812
  return {
3819
3813
  logs: d,
3820
3814
  start: t * r,
3821
3815
  limit: r,
3822
- length: Number((m == null ? void 0 : m.count) ?? 0)
3816
+ length: Number((h == null ? void 0 : h.count) ?? 0)
3823
3817
  };
3824
3818
  },
3825
3819
  async get(i, e) {
3826
3820
  const t = await n.select().from(q).where(g(a(q.tenant_id, i), a(q.log_id, e))).get();
3827
- return t ? lt(t) : null;
3821
+ return t ? at(t) : null;
3828
3822
  }
3829
3823
  };
3830
3824
  }
3831
- const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", _t = St.length;
3832
- function ps() {
3825
+ const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", lt = St.length;
3826
+ function ms() {
3833
3827
  let e = Date.now(), t = "";
3834
3828
  for (let o = 10; o > 0; o--)
3835
- t = St.charAt(e % _t) + t, e = Math.floor(e / _t);
3829
+ t = St.charAt(e % lt) + t, e = Math.floor(e / lt);
3836
3830
  const r = new Uint8Array(16);
3837
3831
  crypto.getRandomValues(r);
3838
3832
  for (let o = 0; o < 16; o++)
3839
- t += St.charAt(r[o] % _t);
3833
+ t += St.charAt(r[o] % lt);
3840
3834
  return t;
3841
3835
  }
3842
- function Me(n) {
3836
+ function je(n) {
3843
3837
  const {
3844
3838
  tenant_id: i,
3845
3839
  created_at_ts: e,
@@ -3862,7 +3856,7 @@ function ys(n) {
3862
3856
  return {
3863
3857
  async create(i, e) {
3864
3858
  const t = Date.now(), o = {
3865
- id: e.id || ps(),
3859
+ id: e.id || ms(),
3866
3860
  tenant_id: i,
3867
3861
  user_id: e.user_id,
3868
3862
  type: e.type,
@@ -3878,7 +3872,7 @@ function ys(n) {
3878
3872
  created_at_ts: t,
3879
3873
  updated_at_ts: t
3880
3874
  };
3881
- 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 });
3882
3876
  },
3883
3877
  async get(i, e) {
3884
3878
  const t = await n.select().from(U).where(
@@ -3887,7 +3881,7 @@ function ys(n) {
3887
3881
  a(U.id, e)
3888
3882
  )
3889
3883
  ).get();
3890
- return t ? Me(t) : null;
3884
+ return t ? je(t) : null;
3891
3885
  },
3892
3886
  async getByCredentialId(i, e) {
3893
3887
  const t = await n.select().from(U).where(
@@ -3896,7 +3890,7 @@ function ys(n) {
3896
3890
  a(U.credential_id, e)
3897
3891
  )
3898
3892
  ).get();
3899
- return t ? Me(t) : null;
3893
+ return t ? je(t) : null;
3900
3894
  },
3901
3895
  async list(i, e) {
3902
3896
  return (await n.select().from(U).where(
@@ -3904,7 +3898,7 @@ function ys(n) {
3904
3898
  a(U.tenant_id, i),
3905
3899
  a(U.user_id, e)
3906
3900
  )
3907
- ).all()).map(Me);
3901
+ ).all()).map(je);
3908
3902
  },
3909
3903
  async update(i, e, t) {
3910
3904
  const r = {
@@ -3937,7 +3931,7 @@ function ws() {
3937
3931
  const { customAlphabet: n } = require("nanoid");
3938
3932
  return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3939
3933
  }
3940
- function ut(n) {
3934
+ function _t(n) {
3941
3935
  const {
3942
3936
  tenant_id: i,
3943
3937
  branding: e,
@@ -3971,24 +3965,24 @@ function Ns(n) {
3971
3965
  updated_at: t
3972
3966
  };
3973
3967
  try {
3974
- await n.insert(L).values(o);
3968
+ await n.insert(E).values(o);
3975
3969
  } catch (u) {
3976
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, {
3977
3971
  message: "Organization already exists"
3978
3972
  }) : u;
3979
3973
  }
3980
- return ut({ ...o, tenant_id: i });
3974
+ return _t({ ...o, tenant_id: i });
3981
3975
  },
3982
3976
  async get(i, e) {
3983
- let t = await n.select().from(L).where(
3984
- 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))
3985
3979
  ).get();
3986
- return t || (t = await n.select().from(L).where(
3980
+ return t || (t = await n.select().from(E).where(
3987
3981
  g(
3988
- a(L.tenant_id, i),
3989
- a(L.name, e)
3982
+ a(E.tenant_id, i),
3983
+ a(E.name, e)
3990
3984
  )
3991
- ).get()), t ? ut(t) : null;
3985
+ ).get()), t ? _t(t) : null;
3992
3986
  },
3993
3987
  async update(i, e, t) {
3994
3988
  const r = {
@@ -3996,8 +3990,8 @@ function Ns(n) {
3996
3990
  };
3997
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(
3998
3992
  t.enabled_connections
3999
- )), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(L).set(r).where(
4000
- 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))
4001
3995
  ).returning()).length > 0;
4002
3996
  },
4003
3997
  async list(i, e) {
@@ -4008,29 +4002,29 @@ function Ns(n) {
4008
4002
  sort: l,
4009
4003
  q: _
4010
4004
  } = e || {};
4011
- 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();
4012
4006
  if (_ && (u = u.where(
4013
4007
  de(
4014
- Ie(L.name, `%${_}%`),
4015
- Ie(L.display_name, `%${_}%`)
4008
+ Ie(E.name, `%${_}%`),
4009
+ Ie(E.display_name, `%${_}%`)
4016
4010
  )
4017
4011
  )), l != null && l.sort_by) {
4018
- const y = L[l.sort_by];
4012
+ const y = E[l.sort_by];
4019
4013
  y && (u = u.orderBy(
4020
4014
  l.sort_order === "desc" ? V(y) : G(y)
4021
4015
  ));
4022
4016
  }
4023
- const d = (await u.offset(t * r).limit(r)).map(ut);
4017
+ const d = (await u.offset(t * r).limit(r)).map(_t);
4024
4018
  if (!o)
4025
4019
  return { organizations: d };
4026
- const m = [a(L.tenant_id, i)];
4027
- _ && m.push(
4020
+ const h = [a(E.tenant_id, i)];
4021
+ _ && h.push(
4028
4022
  de(
4029
- Ie(L.name, `%${_}%`),
4030
- Ie(L.display_name, `%${_}%`)
4023
+ Ie(E.name, `%${_}%`),
4024
+ Ie(E.display_name, `%${_}%`)
4031
4025
  )
4032
4026
  );
4033
- 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));
4034
4028
  return {
4035
4029
  organizations: d,
4036
4030
  start: t * r,
@@ -4039,13 +4033,13 @@ function Ns(n) {
4039
4033
  };
4040
4034
  },
4041
4035
  async remove(i, e) {
4042
- return (await n.delete(L).where(
4043
- 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))
4044
4038
  ).returning()).length > 0;
4045
4039
  }
4046
4040
  };
4047
4041
  }
4048
- function dt(n) {
4042
+ function ut(n) {
4049
4043
  const { tenant_id: i, is_current: e, ...t } = n;
4050
4044
  return {
4051
4045
  ...t,
@@ -4056,10 +4050,10 @@ function vs(n) {
4056
4050
  return {
4057
4051
  async create(i, e) {
4058
4052
  const t = (/* @__PURE__ */ new Date()).toISOString(), r = e.id || ae();
4059
- 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(
4060
4054
  g(
4061
- a(C.tenant_id, i),
4062
- a(C.user_id, e.user_id)
4055
+ a(A.tenant_id, i),
4056
+ a(A.user_id, e.user_id)
4063
4057
  )
4064
4058
  );
4065
4059
  const o = {
@@ -4072,41 +4066,41 @@ function vs(n) {
4072
4066
  created_at: t,
4073
4067
  updated_at: t
4074
4068
  };
4075
- 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 });
4076
4070
  },
4077
4071
  async get(i, e) {
4078
- const t = await n.select().from(C).where(
4072
+ const t = await n.select().from(A).where(
4079
4073
  g(
4080
- a(C.tenant_id, i),
4081
- a(C.user_id, e),
4082
- a(C.is_current, 1)
4074
+ a(A.tenant_id, i),
4075
+ a(A.user_id, e),
4076
+ a(A.is_current, 1)
4083
4077
  )
4084
4078
  ).get();
4085
- return t ? dt(t) : null;
4079
+ return t ? ut(t) : null;
4086
4080
  },
4087
4081
  async list(i, e, t) {
4088
- let r = n.select().from(C).where(
4082
+ let r = n.select().from(A).where(
4089
4083
  g(
4090
- a(C.tenant_id, i),
4091
- a(C.user_id, e)
4084
+ a(A.tenant_id, i),
4085
+ a(A.user_id, e)
4092
4086
  )
4093
- ).orderBy(V(C.created_at)).$dynamic();
4094
- 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);
4095
4089
  },
4096
4090
  async update(i, e) {
4097
4091
  const t = {
4098
4092
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4099
4093
  };
4100
- 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(
4101
4095
  g(
4102
- a(C.tenant_id, i),
4103
- a(C.id, e.id)
4096
+ a(A.tenant_id, i),
4097
+ a(A.id, e.id)
4104
4098
  )
4105
- ) : await n.update(C).set(t).where(
4099
+ ) : await n.update(A).set(t).where(
4106
4100
  g(
4107
- a(C.tenant_id, i),
4108
- a(C.user_id, e.user_id),
4109
- 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)
4110
4104
  )
4111
4105
  ), !0;
4112
4106
  }
@@ -4147,7 +4141,7 @@ function Ss(n) {
4147
4141
  }
4148
4142
  };
4149
4143
  }
4150
- function ct(n) {
4144
+ function dt(n) {
4151
4145
  const {
4152
4146
  tenant_id: i,
4153
4147
  created_at_ts: e,
@@ -4158,7 +4152,7 @@ function ct(n) {
4158
4152
  resource_servers: _,
4159
4153
  rotating: u,
4160
4154
  ...c
4161
- } = n, d = Fe(
4155
+ } = n, d = Pe(
4162
4156
  { created_at_ts: e, expires_at_ts: t, idle_expires_at_ts: r, last_exchanged_at_ts: o },
4163
4157
  ["created_at_ts"],
4164
4158
  ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
@@ -4198,26 +4192,26 @@ function xs(n) {
4198
4192
  r.expires_at_ts,
4199
4193
  r.idle_expires_at_ts
4200
4194
  );
4201
- o > 0 && r.login_id && await n.update($).set({
4195
+ o > 0 && r.login_id && await n.update(L).set({
4202
4196
  expires_at_ts: o,
4203
4197
  updated_at_ts: t
4204
4198
  }).where(
4205
4199
  g(
4206
- a($.tenant_id, i),
4207
- a($.id, r.login_id),
4208
- we($.expires_at_ts, o)
4200
+ a(L.tenant_id, i),
4201
+ a(L.id, r.login_id),
4202
+ we(L.expires_at_ts, o)
4209
4203
  )
4210
4204
  ), await n.run(w`COMMIT`);
4211
4205
  } catch (o) {
4212
4206
  throw await n.run(w`ROLLBACK`), o;
4213
4207
  }
4214
- return ct({ ...r, tenant_id: i });
4208
+ return dt({ ...r, tenant_id: i });
4215
4209
  },
4216
4210
  async get(i, e) {
4217
4211
  const t = await n.select().from(T).where(
4218
4212
  g(a(T.tenant_id, i), a(T.id, e))
4219
4213
  ).get();
4220
- return t ? ct(t) : null;
4214
+ return t ? dt(t) : null;
4221
4215
  },
4222
4216
  async update(i, e, t) {
4223
4217
  const r = {};
@@ -4247,14 +4241,14 @@ function xs(n) {
4247
4241
  u.expires_at_ts,
4248
4242
  u.idle_expires_at_ts
4249
4243
  );
4250
- c > 0 && await n.update($).set({
4244
+ c > 0 && await n.update(L).set({
4251
4245
  expires_at_ts: c,
4252
4246
  updated_at_ts: Date.now()
4253
4247
  }).where(
4254
4248
  g(
4255
- a($.tenant_id, i),
4256
- a($.id, u.login_id),
4257
- we($.expires_at_ts, c)
4249
+ a(L.tenant_id, i),
4250
+ a(L.id, u.login_id),
4251
+ we(L.expires_at_ts, c)
4258
4252
  )
4259
4253
  );
4260
4254
  }
@@ -4274,7 +4268,7 @@ function xs(n) {
4274
4268
  } = e || {};
4275
4269
  let u = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
4276
4270
  if (_) {
4277
- const f = pe(T, _, ["user_id"]);
4271
+ const f = me(T, _, ["user_id"]);
4278
4272
  f && (u = u.where(
4279
4273
  g(a(T.tenant_id, i), f)
4280
4274
  ));
@@ -4285,15 +4279,15 @@ function xs(n) {
4285
4279
  l.sort_order === "desc" ? V(f) : G(f)
4286
4280
  ));
4287
4281
  }
4288
- const d = (await u.offset(t * r).limit(r)).map(ct);
4282
+ const d = (await u.offset(t * r).limit(r)).map(dt);
4289
4283
  if (!o)
4290
4284
  return { refresh_tokens: d };
4291
- 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));
4292
4286
  return {
4293
4287
  refresh_tokens: d,
4294
4288
  start: t * r,
4295
4289
  limit: r,
4296
- length: Number((m == null ? void 0 : m.count) ?? 0)
4290
+ length: Number((h == null ? void 0 : h.count) ?? 0)
4297
4291
  };
4298
4292
  },
4299
4293
  async remove(i, e) {
@@ -4311,7 +4305,7 @@ const xt = [
4311
4305
  "skip_consent_for_verifiable_first_party_clients",
4312
4306
  "allow_offline_access",
4313
4307
  "is_system"
4314
- ], Pt = /* @__PURE__ */ new Set([
4308
+ ], Qt = /* @__PURE__ */ new Set([
4315
4309
  "id",
4316
4310
  "tenant_id",
4317
4311
  "identifier",
@@ -4330,7 +4324,7 @@ const xt = [
4330
4324
  "created_at",
4331
4325
  "updated_at"
4332
4326
  ]);
4333
- function gt(n) {
4327
+ function ct(n) {
4334
4328
  const {
4335
4329
  tenant_id: i,
4336
4330
  verification_key: e,
@@ -4365,28 +4359,28 @@ function Ds(n) {
4365
4359
  };
4366
4360
  for (const l of xt)
4367
4361
  e[l] !== void 0 && (o[l] = e[l] ? 1 : 0);
4368
- 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 });
4369
4363
  },
4370
4364
  async get(i, e) {
4371
- const t = await n.select().from(E).where(
4365
+ const t = await n.select().from(C).where(
4372
4366
  g(
4373
- a(E.tenant_id, i),
4374
- a(E.id, e)
4367
+ a(C.tenant_id, i),
4368
+ a(C.id, e)
4375
4369
  )
4376
4370
  ).get();
4377
- return t ? gt(t) : null;
4371
+ return t ? ct(t) : null;
4378
4372
  },
4379
4373
  async update(i, e, t) {
4380
4374
  const r = {
4381
4375
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4382
4376
  };
4383
- 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);
4384
4378
  for (const l of xt)
4385
4379
  t[l] !== void 0 && (r[l] = t[l] ? 1 : 0);
4386
- return (await n.update(E).set(r).where(
4380
+ return (await n.update(C).set(r).where(
4387
4381
  g(
4388
- a(E.tenant_id, i),
4389
- a(E.id, e)
4382
+ a(C.tenant_id, i),
4383
+ a(C.id, e)
4390
4384
  )
4391
4385
  ).returning()).length > 0;
4392
4386
  },
@@ -4400,28 +4394,28 @@ function Ds(n) {
4400
4394
  } = e || {}, u = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
4401
4395
  Math.max(1, Math.floor(Number(r) || 50)),
4402
4396
  500
4403
- ), d = [a(E.tenant_id, i)];
4397
+ ), d = [a(C.tenant_id, i)];
4404
4398
  if (_) {
4405
- const A = _.match(/^([^:]+):(.+)$/);
4406
- if (A) {
4407
- const [, W, H] = A, ke = W == null ? void 0 : W.startsWith("-"), qe = ke ? W == null ? void 0 : W.substring(1) : W;
4408
- if (qe && Pt.has(qe) && !ke) {
4409
- 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];
4410
4404
  d.push(Ie(yr, `%${H}%`));
4411
4405
  }
4412
4406
  }
4413
4407
  }
4414
- let m = n.select().from(E).where(g(...d)).$dynamic();
4415
- if (l != null && l.sort_by && Pt.has(l.sort_by)) {
4416
- const A = E[l.sort_by];
4417
- m = m.orderBy(
4418
- 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)
4419
4413
  );
4420
4414
  }
4421
- const y = (await m.offset(u * c).limit(c)).map(gt);
4415
+ const y = (await h.offset(u * c).limit(c)).map(ct);
4422
4416
  if (!o)
4423
4417
  return { resource_servers: y };
4424
- 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));
4425
4419
  return {
4426
4420
  resource_servers: y,
4427
4421
  start: u * c,
@@ -4430,10 +4424,10 @@ function Ds(n) {
4430
4424
  };
4431
4425
  },
4432
4426
  async remove(i, e) {
4433
- return (await n.delete(E).where(
4427
+ return (await n.delete(C).where(
4434
4428
  g(
4435
- a(E.tenant_id, i),
4436
- a(E.id, e)
4429
+ a(C.tenant_id, i),
4430
+ a(C.id, e)
4437
4431
  )
4438
4432
  ).returning()).length > 0;
4439
4433
  }
@@ -4468,12 +4462,12 @@ function Os(n) {
4468
4462
  ], l = /* @__PURE__ */ new Map();
4469
4463
  if (o.length > 0) {
4470
4464
  const _ = await n.select({
4471
- identifier: E.identifier,
4472
- name: E.name
4473
- }).from(E).where(
4465
+ identifier: C.identifier,
4466
+ name: C.name
4467
+ }).from(C).where(
4474
4468
  g(
4475
- a(E.tenant_id, i),
4476
- Ne(E.identifier, o)
4469
+ a(C.tenant_id, i),
4470
+ Ne(C.identifier, o)
4477
4471
  )
4478
4472
  ).all();
4479
4473
  for (const u of _)
@@ -4533,10 +4527,10 @@ function ks(n) {
4533
4527
  const l = await n.select().from(_e).where(g(...o)).all();
4534
4528
  return await Promise.all(
4535
4529
  l.map(async (u) => {
4536
- const c = await n.select({ name: E.name }).from(E).where(
4530
+ const c = await n.select({ name: C.name }).from(C).where(
4537
4531
  g(
4538
- a(E.tenant_id, i),
4539
- a(E.identifier, u.resource_server_identifier)
4532
+ a(C.tenant_id, i),
4533
+ a(C.identifier, u.resource_server_identifier)
4540
4534
  )
4541
4535
  ).get();
4542
4536
  return {
@@ -4564,7 +4558,7 @@ function ks(n) {
4564
4558
  }
4565
4559
  };
4566
4560
  }
4567
- function ft(n) {
4561
+ function gt(n) {
4568
4562
  const { tenant_id: i, is_system: e, metadata: t, ...r } = n;
4569
4563
  return z({
4570
4564
  ...r,
@@ -4585,11 +4579,11 @@ function Is(n) {
4585
4579
  created_at: t,
4586
4580
  updated_at: t
4587
4581
  };
4588
- 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 });
4589
4583
  },
4590
4584
  async get(i, e) {
4591
4585
  const t = await n.select().from(F).where(g(a(F.tenant_id, i), a(F.id, e))).get();
4592
- return t ? ft(t) : null;
4586
+ return t ? gt(t) : null;
4593
4587
  },
4594
4588
  async update(i, e, t) {
4595
4589
  const r = {
@@ -4604,7 +4598,7 @@ function Is(n) {
4604
4598
  include_totals: o = !1,
4605
4599
  sort: l,
4606
4600
  q: _
4607
- } = 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);
4608
4602
  let d = n.select().from(F).where(c).$dynamic();
4609
4603
  if (l != null && l.sort_by) {
4610
4604
  const N = F[l.sort_by];
@@ -4612,7 +4606,7 @@ function Is(n) {
4612
4606
  l.sort_order === "desc" ? V(N) : G(N)
4613
4607
  ));
4614
4608
  }
4615
- const f = (await d.offset(t * r).limit(r)).map(ft);
4609
+ const f = (await d.offset(t * r).limit(r)).map(gt);
4616
4610
  if (!o)
4617
4611
  return { roles: f };
4618
4612
  const [y] = await n.select({ count: R() }).from(F).where(c);
@@ -4636,7 +4630,7 @@ const zs = ["created_at_ts", "updated_at_ts"], Ts = [
4636
4630
  "used_at_ts",
4637
4631
  "revoked_at_ts"
4638
4632
  ];
4639
- function ht(n) {
4633
+ function ft(n) {
4640
4634
  const {
4641
4635
  tenant_id: i,
4642
4636
  created_at_ts: e,
@@ -4648,9 +4642,9 @@ function ht(n) {
4648
4642
  used_at_ts: u,
4649
4643
  revoked_at_ts: c,
4650
4644
  device: d,
4651
- clients: m,
4645
+ clients: h,
4652
4646
  ...f
4653
- } = n, y = Fe(
4647
+ } = n, y = Pe(
4654
4648
  {
4655
4649
  created_at_ts: e,
4656
4650
  updated_at_ts: t,
@@ -4668,7 +4662,7 @@ function ht(n) {
4668
4662
  ...f,
4669
4663
  ...y,
4670
4664
  device: x(d, {}),
4671
- clients: x(m, [])
4665
+ clients: x(h, [])
4672
4666
  });
4673
4667
  }
4674
4668
  function qs(n) {
@@ -4690,11 +4684,11 @@ function qs(n) {
4690
4684
  used_at_ts: j(e.used_at),
4691
4685
  revoked_at_ts: j(e.revoked_at)
4692
4686
  };
4693
- return await n.insert(B).values(r), ht({ ...r, tenant_id: i });
4687
+ return await n.insert($).values(r), ft({ ...r, tenant_id: i });
4694
4688
  },
4695
4689
  async get(i, e) {
4696
- const t = await n.select().from(B).where(g(a(B.tenant_id, i), a(B.id, e))).get();
4697
- return t ? ht(t) : null;
4690
+ const t = await n.select().from($).where(g(a($.tenant_id, i), a($.id, e))).get();
4691
+ return t ? ft(t) : null;
4698
4692
  },
4699
4693
  async update(i, e, t) {
4700
4694
  const r = {
@@ -4702,7 +4696,7 @@ function qs(n) {
4702
4696
  };
4703
4697
  return t.user_id !== void 0 && (r.user_id = t.user_id), t.login_session_id !== void 0 && (r.login_session_id = t.login_session_id), t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.clients !== void 0 && (r.clients = JSON.stringify(t.clients)), t.expires_at !== void 0 && (r.expires_at_ts = j(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = j(t.idle_expires_at)), t.authenticated_at !== void 0 && (r.authenticated_at_ts = j(t.authenticated_at)), t.last_interaction_at !== void 0 && (r.last_interaction_at_ts = j(
4704
4698
  t.last_interaction_at
4705
- )), t.used_at !== void 0 && (r.used_at_ts = j(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = j(t.revoked_at)), (await n.update(B).set(r).where(g(a(B.tenant_id, i), a(B.id, e))).returning()).length > 0;
4699
+ )), t.used_at !== void 0 && (r.used_at_ts = j(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = j(t.revoked_at)), (await n.update($).set(r).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
4706
4700
  },
4707
4701
  async list(i, e) {
4708
4702
  const {
@@ -4711,18 +4705,18 @@ function qs(n) {
4711
4705
  include_totals: o = !1,
4712
4706
  sort: l,
4713
4707
  q: _
4714
- } = e || {}, u = _ ? pe(B, _, ["user_id"]) : void 0, c = u ? g(a(B.tenant_id, i), u) : a(B.tenant_id, i);
4715
- let d = n.select().from(B).where(c).$dynamic();
4708
+ } = e || {}, u = _ ? me($, _, ["user_id"]) : void 0, c = u ? g(a($.tenant_id, i), u) : a($.tenant_id, i);
4709
+ let d = n.select().from($).where(c).$dynamic();
4716
4710
  if (l != null && l.sort_by) {
4717
- const N = B[l.sort_by];
4711
+ const N = $[l.sort_by];
4718
4712
  N && (d = d.orderBy(
4719
4713
  l.sort_order === "desc" ? V(N) : G(N)
4720
4714
  ));
4721
4715
  }
4722
- const f = (await d.offset(t * r).limit(r)).map(ht);
4716
+ const f = (await d.offset(t * r).limit(r)).map(ft);
4723
4717
  if (!o)
4724
4718
  return { sessions: f };
4725
- const [y] = await n.select({ count: R() }).from(B).where(c);
4719
+ const [y] = await n.select({ count: R() }).from($).where(c);
4726
4720
  return {
4727
4721
  sessions: f,
4728
4722
  start: t * r,
@@ -4731,11 +4725,11 @@ function qs(n) {
4731
4725
  };
4732
4726
  },
4733
4727
  async remove(i, e) {
4734
- return (await n.delete(B).where(g(a(B.tenant_id, i), a(B.id, e))).returning()).length > 0;
4728
+ return (await n.delete($).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
4735
4729
  }
4736
4730
  };
4737
4731
  }
4738
- const mr = [
4732
+ const hr = [
4739
4733
  "session_cookie",
4740
4734
  "enabled_locales",
4741
4735
  "error_page",
@@ -4751,28 +4745,28 @@ const mr = [
4751
4745
  "acr_values_supported",
4752
4746
  "mtls",
4753
4747
  "mfa"
4754
- ], pr = [
4748
+ ], mr = [
4755
4749
  "allow_organization_name_in_authentication_api",
4756
4750
  "customize_mfa_in_postlogin_action",
4757
4751
  "pushed_authorization_requests_supported",
4758
4752
  "authorization_response_iss_parameter_supported"
4759
4753
  ];
4760
- function Qt(n) {
4754
+ function Jt(n) {
4761
4755
  const i = { ...n };
4762
- for (const e of mr)
4756
+ for (const e of hr)
4763
4757
  typeof i[e] == "string" && (i[e] = x(i[e]));
4764
- for (const e of pr)
4758
+ for (const e of mr)
4765
4759
  i[e] !== void 0 && i[e] !== null && (i[e] = i[e] === 1);
4766
4760
  return z(i);
4767
4761
  }
4768
- function Jt(n) {
4762
+ function Pt(n) {
4769
4763
  const i = { ...n };
4770
- Jr(
4764
+ Pr(
4771
4765
  n,
4772
- mr,
4766
+ hr,
4773
4767
  i
4774
4768
  );
4775
- for (const e of pr)
4769
+ for (const e of mr)
4776
4770
  n[e] !== void 0 && (i[e] = n[e] ? 1 : 0);
4777
4771
  return gr(i);
4778
4772
  }
@@ -4785,7 +4779,7 @@ function Ls(n) {
4785
4779
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
4786
4780
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
4787
4781
  ...i
4788
- }, t = Jt(e);
4782
+ }, t = Pt(e);
4789
4783
  try {
4790
4784
  await n.insert(D).values(t);
4791
4785
  } catch (l) {
@@ -4797,7 +4791,7 @@ function Ls(n) {
4797
4791
  },
4798
4792
  async get(i) {
4799
4793
  const e = await n.select().from(D).where(a(D.id, i)).get();
4800
- return e ? Qt(e) : null;
4794
+ return e ? Jt(e) : null;
4801
4795
  },
4802
4796
  async list(i) {
4803
4797
  const {
@@ -4809,16 +4803,16 @@ function Ls(n) {
4809
4803
  } = i || {};
4810
4804
  let _ = n.select().from(D).$dynamic();
4811
4805
  if (l) {
4812
- const m = pe(D, l, ["friendly_name"]);
4813
- m && (_ = _.where(m));
4806
+ const h = me(D, l, ["friendly_name"]);
4807
+ h && (_ = _.where(h));
4814
4808
  }
4815
4809
  if (o != null && o.sort_by) {
4816
- const m = D[o.sort_by];
4817
- m && (_ = _.orderBy(
4818
- 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)
4819
4813
  ));
4820
4814
  }
4821
- const c = (await _.offset(e * t).limit(t)).map(Qt);
4815
+ const c = (await _.offset(e * t).limit(t)).map(Jt);
4822
4816
  if (!r)
4823
4817
  return { tenants: c };
4824
4818
  const [d] = await n.select({ count: R() }).from(D);
@@ -4830,7 +4824,7 @@ function Ls(n) {
4830
4824
  };
4831
4825
  },
4832
4826
  async update(i, e) {
4833
- const t = Jt({
4827
+ const t = Pt({
4834
4828
  ...e,
4835
4829
  id: i,
4836
4830
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -4857,7 +4851,7 @@ function Cs(n) {
4857
4851
  return {
4858
4852
  async create(i, e, t) {
4859
4853
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = t || ae(), _ = {
4860
- ...Pe(e),
4854
+ ...yt(e),
4861
4855
  tenant_id: i,
4862
4856
  themeId: o,
4863
4857
  created_at: r,
@@ -4872,7 +4866,7 @@ function Cs(n) {
4872
4866
  return t ? Ft(t) : null;
4873
4867
  },
4874
4868
  async update(i, e, t) {
4875
- const r = Pe(t);
4869
+ const r = yt(t);
4876
4870
  return r.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await n.update(fe).set(r).where(
4877
4871
  g(a(fe.tenant_id, i), a(fe.themeId, e))
4878
4872
  ), !0;
@@ -4923,7 +4917,7 @@ function Ut(n, i) {
4923
4917
  ...typeof n.profileData == "string" ? x(n.profileData, {}) : {}
4924
4918
  }, e;
4925
4919
  }
4926
- function mt(n, i = []) {
4920
+ function pt(n, i = []) {
4927
4921
  const {
4928
4922
  tenant_id: e,
4929
4923
  app_metadata: t,
@@ -4934,10 +4928,10 @@ function mt(n, i = []) {
4934
4928
  is_social: u,
4935
4929
  linked_to: c,
4936
4930
  profileData: d,
4937
- ...m
4931
+ ...h
4938
4932
  } = n, f = Ut(n, !0), y = i.map((N) => Ut(N, !1));
4939
4933
  return z({
4940
- ...m,
4934
+ ...h,
4941
4935
  email: n.email || "",
4942
4936
  email_verified: !!l,
4943
4937
  phone_verified: _ != null ? !!_ : void 0,
@@ -4991,7 +4985,7 @@ function Bs(n) {
4991
4985
  if (t.password && l) {
4992
4986
  await n.run(w`BEGIN`);
4993
4987
  try {
4994
- await n.insert(k).values(o), await n.insert(C).values({
4988
+ await n.insert(k).values(o), await n.insert(A).values({
4995
4989
  id: l,
4996
4990
  tenant_id: e,
4997
4991
  user_id: t.user_id,
@@ -5011,7 +5005,7 @@ function Bs(n) {
5011
5005
  message: "Internal server error"
5012
5006
  }));
5013
5007
  }
5014
- return mt(o);
5008
+ return pt(o);
5015
5009
  };
5016
5010
  return {
5017
5011
  create: i,
@@ -5022,7 +5016,7 @@ function Bs(n) {
5022
5016
  const o = await n.select().from(k).where(
5023
5017
  g(a(k.tenant_id, e), a(k.linked_to, t))
5024
5018
  ).all();
5025
- return mt(r, o);
5019
+ return pt(r, o);
5026
5020
  },
5027
5021
  async update(e, t, r) {
5028
5022
  const o = {
@@ -5068,7 +5062,7 @@ function Bs(n) {
5068
5062
  ye(k.linked_to)
5069
5063
  ];
5070
5064
  if (u) {
5071
- const H = pe(k, u, [
5065
+ const H = me(k, u, [
5072
5066
  "email",
5073
5067
  "name",
5074
5068
  "nickname",
@@ -5077,14 +5071,14 @@ function Bs(n) {
5077
5071
  H && c.push(H);
5078
5072
  }
5079
5073
  const d = g(...c);
5080
- let m = n.select().from(k).where(d).$dynamic();
5074
+ let h = n.select().from(k).where(d).$dynamic();
5081
5075
  if (_ != null && _.sort_by) {
5082
5076
  const H = k[_.sort_by];
5083
- H && (m = m.orderBy(
5077
+ H && (h = h.orderBy(
5084
5078
  _.sort_order === "desc" ? V(H) : G(H)
5085
5079
  ));
5086
5080
  }
5087
- 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);
5088
5082
  let N = [];
5089
5083
  y.length > 0 && (N = await n.select().from(k).where(
5090
5084
  g(
@@ -5092,15 +5086,15 @@ function Bs(n) {
5092
5086
  Ne(k.linked_to, y)
5093
5087
  )
5094
5088
  ));
5095
- const A = f.map((H) => {
5089
+ const B = f.map((H) => {
5096
5090
  const ke = N.filter((qe) => qe.linked_to === H.user_id);
5097
- return mt(H, ke);
5091
+ return pt(H, ke);
5098
5092
  });
5099
5093
  if (!l)
5100
- return { users: A };
5094
+ return { users: B };
5101
5095
  const [W] = await n.select({ count: R() }).from(k).where(d);
5102
5096
  return {
5103
- users: A,
5097
+ users: B,
5104
5098
  start: r * o,
5105
5099
  limit: o,
5106
5100
  length: Number((W == null ? void 0 : W.count) ?? 0)
@@ -5117,10 +5111,10 @@ function Bs(n) {
5117
5111
  a(U.tenant_id, e),
5118
5112
  Ne(U.user_id, o)
5119
5113
  )
5120
- ), await n.delete(C).where(
5114
+ ), await n.delete(A).where(
5121
5115
  g(
5122
- a(C.tenant_id, e),
5123
- Ne(C.user_id, o)
5116
+ a(A.tenant_id, e),
5117
+ Ne(A.user_id, o)
5124
5118
  )
5125
5119
  ), await n.delete(k).where(
5126
5120
  g(a(k.tenant_id, e), a(k.linked_to, t))
@@ -5179,10 +5173,10 @@ function $s(n) {
5179
5173
  g(a(F.tenant_id, i), a(F.id, u.role_id))
5180
5174
  ).get();
5181
5175
  if (!c) return null;
5182
- const { tenant_id: d, is_system: m, metadata: f, ...y } = c;
5176
+ const { tenant_id: d, is_system: h, metadata: f, ...y } = c;
5183
5177
  return z({
5184
5178
  ...y,
5185
- is_system: m ? !0 : void 0,
5179
+ is_system: h ? !0 : void 0,
5186
5180
  metadata: x(f)
5187
5181
  });
5188
5182
  })
@@ -5200,7 +5194,7 @@ function $s(n) {
5200
5194
  }
5201
5195
  };
5202
5196
  }
5203
- function Ps(n) {
5197
+ function Qs(n) {
5204
5198
  return {
5205
5199
  async create(i, e) {
5206
5200
  var u, c;
@@ -5213,7 +5207,7 @@ function Ps(n) {
5213
5207
  updated_at: t
5214
5208
  };
5215
5209
  try {
5216
- await n.insert(Q).values(o);
5210
+ await n.insert(J).values(o);
5217
5211
  } catch (d) {
5218
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, {
5219
5213
  message: "User organization already exists"
@@ -5223,10 +5217,10 @@ function Ps(n) {
5223
5217
  return _;
5224
5218
  },
5225
5219
  async get(i, e) {
5226
- const t = await n.select().from(Q).where(
5220
+ const t = await n.select().from(J).where(
5227
5221
  g(
5228
- a(Q.tenant_id, i),
5229
- a(Q.id, e)
5222
+ a(J.tenant_id, i),
5223
+ a(J.id, e)
5230
5224
  )
5231
5225
  ).get();
5232
5226
  if (!t) return null;
@@ -5237,10 +5231,10 @@ function Ps(n) {
5237
5231
  const r = {
5238
5232
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
5239
5233
  };
5240
- 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(
5241
5235
  g(
5242
- a(Q.tenant_id, i),
5243
- a(Q.id, e)
5236
+ a(J.tenant_id, i),
5237
+ a(J.id, e)
5244
5238
  )
5245
5239
  ).returning()).length > 0;
5246
5240
  },
@@ -5250,48 +5244,48 @@ function Ps(n) {
5250
5244
  per_page: r = 50,
5251
5245
  include_totals: o = !1,
5252
5246
  q: l
5253
- } = e || {}, _ = a(Q.tenant_id, i);
5247
+ } = e || {}, _ = a(J.tenant_id, i);
5254
5248
  let u = _;
5255
5249
  if (l) {
5256
- const f = pe(Q, l, [
5250
+ const f = me(J, l, [
5257
5251
  "user_id",
5258
5252
  "organization_id"
5259
5253
  ]);
5260
5254
  f && (u = g(_, f));
5261
5255
  }
5262
- 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) => {
5263
5257
  const { tenant_id: y, ...N } = f;
5264
5258
  return N;
5265
5259
  });
5266
5260
  if (!o)
5267
5261
  return { userOrganizations: d };
5268
- const [m] = await n.select({ count: R() }).from(Q).where(u);
5262
+ const [h] = await n.select({ count: R() }).from(J).where(u);
5269
5263
  return {
5270
5264
  userOrganizations: d,
5271
5265
  start: t * r,
5272
5266
  limit: r,
5273
- length: Number((m == null ? void 0 : m.count) ?? 0)
5267
+ length: Number((h == null ? void 0 : h.count) ?? 0)
5274
5268
  };
5275
5269
  },
5276
5270
  async listUserOrganizations(i, e, t) {
5277
- 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(
5278
5272
  g(
5279
- a(Q.tenant_id, i),
5280
- a(Q.user_id, e)
5273
+ a(J.tenant_id, i),
5274
+ a(J.user_id, e)
5281
5275
  )
5282
5276
  ).offset(r * o).limit(o).all(), c = (await Promise.all(
5283
- _.map(async (m) => {
5284
- const f = await n.select().from(L).where(
5277
+ _.map(async (h) => {
5278
+ const f = await n.select().from(E).where(
5285
5279
  g(
5286
- a(L.tenant_id, i),
5287
- a(L.id, m.organization_id)
5280
+ a(E.tenant_id, i),
5281
+ a(E.id, h.organization_id)
5288
5282
  )
5289
5283
  ).get();
5290
5284
  if (!f) return null;
5291
5285
  const {
5292
5286
  tenant_id: y,
5293
5287
  branding: N,
5294
- metadata: A,
5288
+ metadata: B,
5295
5289
  enabled_connections: W,
5296
5290
  token_quota: H,
5297
5291
  ...ke
@@ -5299,7 +5293,7 @@ function Ps(n) {
5299
5293
  return z({
5300
5294
  ...ke,
5301
5295
  branding: x(N, {}),
5302
- metadata: x(A, {}),
5296
+ metadata: x(B, {}),
5303
5297
  enabled_connections: x(W, []),
5304
5298
  token_quota: x(H, {})
5305
5299
  });
@@ -5307,10 +5301,10 @@ function Ps(n) {
5307
5301
  )).filter(Boolean);
5308
5302
  if (!l)
5309
5303
  return { organizations: c };
5310
- const [d] = await n.select({ count: R() }).from(Q).where(
5304
+ const [d] = await n.select({ count: R() }).from(J).where(
5311
5305
  g(
5312
- a(Q.tenant_id, i),
5313
- a(Q.user_id, e)
5306
+ a(J.tenant_id, i),
5307
+ a(J.user_id, e)
5314
5308
  )
5315
5309
  );
5316
5310
  return {
@@ -5321,17 +5315,17 @@ function Ps(n) {
5321
5315
  };
5322
5316
  },
5323
5317
  async remove(i, e) {
5324
- return (await n.delete(Q).where(
5318
+ return (await n.delete(J).where(
5325
5319
  g(
5326
- a(Q.tenant_id, i),
5327
- a(Q.id, e)
5320
+ a(J.tenant_id, i),
5321
+ a(J.id, e)
5328
5322
  )
5329
5323
  ).returning()).length > 0;
5330
5324
  }
5331
5325
  };
5332
5326
  }
5333
- const Kt = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Qs = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
5334
- 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) {
5335
5329
  return {
5336
5330
  async getDaily(i, e) {
5337
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];
@@ -5345,13 +5339,13 @@ function Js(n) {
5345
5339
  "signups"
5346
5340
  ),
5347
5341
  leaked_passwords: w`SUM(CASE WHEN ${q.type} IN (${w.join(
5348
- Qs.map((_) => w`${_}`),
5342
+ Js.map((_) => w`${_}`),
5349
5343
  w`, `
5350
5344
  )}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
5351
5345
  }).from(q).where(
5352
5346
  g(
5353
5347
  a(q.tenant_id, i),
5354
- Ge(q.date, r),
5348
+ He(q.date, r),
5355
5349
  Oe(q.date, `${o}T23:59:59.999Z`)
5356
5350
  )
5357
5351
  ).groupBy(w`substr(${q.date}, 1, 10)`).orderBy(w`substr(${q.date}, 1, 10)`).all()).map((_) => ({
@@ -5371,7 +5365,7 @@ function Js(n) {
5371
5365
  }).from(q).where(
5372
5366
  g(
5373
5367
  a(q.tenant_id, i),
5374
- Ge(q.date, e),
5368
+ He(q.date, e),
5375
5369
  w`${q.type} IN (${w.join(
5376
5370
  Kt.map((r) => w`${r}`),
5377
5371
  w`, `
@@ -5482,7 +5476,7 @@ function Fs(n) {
5482
5476
  const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(b).where(
5483
5477
  g(
5484
5478
  a(b.tenant_id, i),
5485
- Ve(b.dead_lettered_at)
5479
+ Me(b.dead_lettered_at)
5486
5480
  )
5487
5481
  ).orderBy(V(b.dead_lettered_at), G(b.id)).offset(t * r).limit(r).all()).map((c) => ({
5488
5482
  ...x(c.payload, {}),
@@ -5500,7 +5494,7 @@ function Fs(n) {
5500
5494
  const [c] = await n.select({ total: R() }).from(b).where(
5501
5495
  g(
5502
5496
  a(b.tenant_id, i),
5503
- Ve(b.dead_lettered_at)
5497
+ Me(b.dead_lettered_at)
5504
5498
  )
5505
5499
  );
5506
5500
  u = Number((c == null ? void 0 : c.total) ?? _.length);
@@ -5524,7 +5518,7 @@ function Fs(n) {
5524
5518
  g(
5525
5519
  a(b.id, i),
5526
5520
  a(b.tenant_id, e),
5527
- Ve(b.dead_lettered_at)
5521
+ Me(b.dead_lettered_at)
5528
5522
  )
5529
5523
  ).returning()).length > 0;
5530
5524
  }
@@ -5543,10 +5537,10 @@ function Ks(n) {
5543
5537
  ];
5544
5538
  i != null && i.tenant_id && t.push(a(T.tenant_id, i.tenant_id)), await n.delete(T).where(g(...t)), t = [
5545
5539
  de(
5546
- we(B.expires_at_ts, e),
5547
- we(B.idle_expires_at_ts, e)
5540
+ we($.expires_at_ts, e),
5541
+ we($.idle_expires_at_ts, e)
5548
5542
  )
5549
- ], i != null && i.tenant_id && t.push(a(B.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a(B.user_id, i.user_id)), await n.delete(B).where(g(...t)), t = [we($.expires_at_ts, e)], i != null && i.tenant_id && t.push(a($.tenant_id, i.tenant_id)), await n.delete($).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));
5550
5544
  } catch (t) {
5551
5545
  console.error("Session cleanup error:", t);
5552
5546
  }
@@ -5570,8 +5564,8 @@ function Vs(n, i = { useTransactions: !0 }) {
5570
5564
  hooks: us(n),
5571
5565
  invites: cs(n),
5572
5566
  keys: gs(n),
5573
- loginSessions: hs(n),
5574
- logs: ms(n),
5567
+ loginSessions: ps(n),
5568
+ logs: hs(n),
5575
5569
  authenticationMethods: ys(n),
5576
5570
  organizations: Ns(n),
5577
5571
  passwords: vs(n),
@@ -5588,8 +5582,8 @@ function Vs(n, i = { useTransactions: !0 }) {
5588
5582
  universalLoginTemplates: As(n),
5589
5583
  users: Bs(n),
5590
5584
  userRoles: $s(n),
5591
- userOrganizations: Ps(n),
5592
- stats: Js(n),
5585
+ userOrganizations: Qs(n),
5586
+ stats: Ps(n),
5593
5587
  outbox: Fs(n),
5594
5588
  async transaction(t) {
5595
5589
  if (i.useTransactions === !1)