@authhero/drizzle 0.39.0 → 0.41.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 F([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 F = 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 F([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 F([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 F(e);
436
436
  }
437
437
  ((n) => {
438
438
  function i() {
439
- return new J([]);
439
+ return new F([]);
440
440
  }
441
441
  n.empty = i;
442
442
  function e(u) {
443
- return new J(u);
443
+ return new F(u);
444
444
  }
445
445
  n.fromList = e;
446
446
  function t(u) {
447
- return new J([new Z(u)]);
447
+ return new F([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 F(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
+ })(F || (F = {}));
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 F([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 F([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 F([this]);
528
528
  };
529
529
  M.prototype.getSQL = function() {
530
- return new J([this]);
530
+ return new F([this]);
531
531
  };
532
532
  bt.prototype.getSQL = function() {
533
- return new J([this]);
533
+ return new F([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 F(i) : new F([
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 F(i) : new F([
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
- function ye(n) {
572
+ function me(n) {
573
573
  return w`${n} is null`;
574
574
  }
575
- function Ve(n) {
575
+ function Me(n) {
576
576
  return w`${n} is not null`;
577
577
  }
578
578
  function Ie(n, i) {
@@ -606,11 +606,11 @@ gn = v;
606
606
  class Bi {
607
607
  constructor(i, e) {
608
608
  /** @internal */
609
- h(this, "reference");
609
+ p(this, "reference");
610
610
  /** @internal */
611
- h(this, "_onUpdate");
611
+ p(this, "_onUpdate");
612
612
  /** @internal */
613
- h(this, "_onDelete");
613
+ p(this, "_onDelete");
614
614
  this.reference = () => {
615
615
  const { name: t, columns: r, foreignColumns: o } = i();
616
616
  return { name: t, columns: r, foreignTable: o[0].table, foreignColumns: o };
@@ -627,14 +627,14 @@ class Bi {
627
627
  return new $i(i, this);
628
628
  }
629
629
  }
630
- h(Bi, gn, "SQLiteForeignKeyBuilder");
630
+ p(Bi, gn, "SQLiteForeignKeyBuilder");
631
631
  var fn;
632
632
  fn = v;
633
633
  class $i {
634
634
  constructor(i, e) {
635
- h(this, "reference");
636
- h(this, "onUpdate");
637
- h(this, "onDelete");
635
+ p(this, "reference");
636
+ p(this, "onUpdate");
637
+ p(this, "onDelete");
638
638
  this.table = i, this.reference = e.reference, this.onUpdate = e._onUpdate, this.onDelete = e._onDelete;
639
639
  }
640
640
  getName() {
@@ -647,15 +647,15 @@ class $i {
647
647
  return i ?? `${l.join("_")}_fk`;
648
648
  }
649
649
  }
650
- h($i, fn, "SQLiteForeignKey");
650
+ p($i, fn, "SQLiteForeignKey");
651
651
  function zr(n, i) {
652
652
  return `${n[ze]}_${i.join("_")}_unique`;
653
653
  }
654
- var hn, mn;
655
- class ce extends (mn = qi, hn = v, mn) {
654
+ var pn, hn;
655
+ class ce extends (hn = qi, pn = v, hn) {
656
656
  constructor() {
657
657
  super(...arguments);
658
- h(this, "foreignKeyConfigs", []);
658
+ p(this, "foreignKeyConfigs", []);
659
659
  }
660
660
  references(e, t = {}) {
661
661
  return this.foreignKeyConfigs.push({ ref: e, actions: t }), this;
@@ -681,27 +681,27 @@ class ce extends (mn = qi, hn = v, mn) {
681
681
  })(r, o));
682
682
  }
683
683
  }
684
- h(ce, hn, "SQLiteColumnBuilder");
685
- var pn, yn;
686
- class ge extends (yn = Qe, pn = v, yn) {
684
+ p(ce, pn, "SQLiteColumnBuilder");
685
+ var mn, yn;
686
+ class ge extends (yn = Qe, mn = v, yn) {
687
687
  constructor(i, e) {
688
688
  e.uniqueName || (e.uniqueName = zr(i, [e.name])), super(i, e), this.table = i;
689
689
  }
690
690
  }
691
- h(ge, pn, "SQLiteColumn");
691
+ p(ge, mn, "SQLiteColumn");
692
692
  var wn, Nn;
693
- class Pi extends (Nn = ce, wn = v, Nn) {
693
+ class Qi extends (Nn = ce, wn = v, Nn) {
694
694
  constructor(i) {
695
695
  super(i, "bigint", "SQLiteBigInt");
696
696
  }
697
697
  /** @internal */
698
698
  build(i) {
699
- return new Qi(i, this.config);
699
+ return new Ji(i, this.config);
700
700
  }
701
701
  }
702
- h(Pi, wn, "SQLiteBigIntBuilder");
702
+ p(Qi, wn, "SQLiteBigIntBuilder");
703
703
  var vn, Sn;
704
- class Qi extends (Sn = ge, vn = v, Sn) {
704
+ class Ji extends (Sn = ge, vn = v, Sn) {
705
705
  getSQLType() {
706
706
  return "blob";
707
707
  }
@@ -716,9 +716,9 @@ class Qi extends (Sn = ge, vn = v, Sn) {
716
716
  return Buffer.from(i.toString());
717
717
  }
718
718
  }
719
- h(Qi, vn, "SQLiteBigInt");
719
+ p(Ji, vn, "SQLiteBigInt");
720
720
  var xn, bn;
721
- class Ji extends (bn = ce, xn = v, bn) {
721
+ class Pi extends (bn = ce, xn = v, bn) {
722
722
  constructor(i) {
723
723
  super(i, "json", "SQLiteBlobJson");
724
724
  }
@@ -730,7 +730,7 @@ class Ji extends (bn = ce, xn = v, bn) {
730
730
  );
731
731
  }
732
732
  }
733
- h(Ji, xn, "SQLiteBlobJsonBuilder");
733
+ p(Pi, xn, "SQLiteBlobJsonBuilder");
734
734
  var Dn, On;
735
735
  class Fi extends (On = ge, Dn = v, On) {
736
736
  getSQLType() {
@@ -747,7 +747,7 @@ class Fi extends (On = ge, Dn = v, On) {
747
747
  return Buffer.from(JSON.stringify(i));
748
748
  }
749
749
  }
750
- h(Fi, Dn, "SQLiteBlobJson");
750
+ p(Fi, Dn, "SQLiteBlobJson");
751
751
  var kn, In;
752
752
  class Ui extends (In = ce, kn = v, In) {
753
753
  constructor(i) {
@@ -758,7 +758,7 @@ class Ui extends (In = ce, kn = v, In) {
758
758
  return new Ki(i, this.config);
759
759
  }
760
760
  }
761
- h(Ui, kn, "SQLiteBlobBufferBuilder");
761
+ p(Ui, kn, "SQLiteBlobBufferBuilder");
762
762
  var zn, Tn;
763
763
  class Ki extends (Tn = ge, zn = v, Tn) {
764
764
  mapFromDriverValue(i) {
@@ -768,10 +768,10 @@ class Ki extends (Tn = ge, zn = v, Tn) {
768
768
  return "blob";
769
769
  }
770
770
  }
771
- h(Ki, zn, "SQLiteBlobBuffer");
771
+ p(Ki, zn, "SQLiteBlobBuffer");
772
772
  function Tr(n, i) {
773
773
  const { name: e, config: t } = Je(n, i);
774
- return (t == null ? void 0 : t.mode) === "json" ? new Ji(e) : (t == null ? void 0 : t.mode) === "bigint" ? new Pi(e) : new Ui(e);
774
+ return (t == null ? void 0 : t.mode) === "json" ? new Pi(e) : (t == null ? void 0 : t.mode) === "bigint" ? new Qi(e) : new Ui(e);
775
775
  }
776
776
  var qn, Ln;
777
777
  class ji extends (Ln = ce, qn = v, Ln) {
@@ -786,14 +786,14 @@ class ji extends (Ln = ce, qn = v, Ln) {
786
786
  );
787
787
  }
788
788
  }
789
- h(ji, qn, "SQLiteCustomColumnBuilder");
789
+ p(ji, qn, "SQLiteCustomColumnBuilder");
790
790
  var En, Cn;
791
791
  class Mi extends (Cn = ge, En = v, Cn) {
792
792
  constructor(e, t) {
793
793
  super(e, t);
794
- h(this, "sqlName");
795
- h(this, "mapTo");
796
- h(this, "mapFrom");
794
+ p(this, "sqlName");
795
+ p(this, "mapTo");
796
+ p(this, "mapFrom");
797
797
  this.sqlName = t.customTypeParams.dataType(t.fieldConfig), this.mapTo = t.customTypeParams.toDriver, this.mapFrom = t.customTypeParams.fromDriver;
798
798
  }
799
799
  getSQLType() {
@@ -806,7 +806,7 @@ class Mi extends (Cn = ge, En = v, Cn) {
806
806
  return typeof this.mapTo == "function" ? this.mapTo(e) : e;
807
807
  }
808
808
  }
809
- h(Mi, En, "SQLiteCustomColumn");
809
+ p(Mi, En, "SQLiteCustomColumn");
810
810
  function qr(n) {
811
811
  return (i, e) => {
812
812
  const { name: t, config: r } = Je(i, e);
@@ -818,7 +818,7 @@ function qr(n) {
818
818
  };
819
819
  }
820
820
  var An, Bn;
821
- class Ye extends (Bn = ce, An = v, Bn) {
821
+ class Ge extends (Bn = ce, An = v, Bn) {
822
822
  constructor(i, e, t) {
823
823
  super(i, e, t), this.config.autoIncrement = !1;
824
824
  }
@@ -826,20 +826,20 @@ class Ye extends (Bn = ce, An = v, Bn) {
826
826
  return i != null && i.autoIncrement && (this.config.autoIncrement = !0), this.config.hasDefault = !0, super.primaryKey();
827
827
  }
828
828
  }
829
- h(Ye, An, "SQLiteBaseIntegerBuilder");
830
- var $n, Pn;
831
- class Xe extends (Pn = ge, $n = v, Pn) {
829
+ p(Ge, An, "SQLiteBaseIntegerBuilder");
830
+ var $n, Qn;
831
+ class Ye extends (Qn = ge, $n = v, Qn) {
832
832
  constructor() {
833
833
  super(...arguments);
834
- h(this, "autoIncrement", this.config.autoIncrement);
834
+ p(this, "autoIncrement", this.config.autoIncrement);
835
835
  }
836
836
  getSQLType() {
837
837
  return "integer";
838
838
  }
839
839
  }
840
- h(Xe, $n, "SQLiteBaseInteger");
841
- var Qn, Jn;
842
- class Vi extends (Jn = Ye, Qn = v, Jn) {
840
+ p(Ye, $n, "SQLiteBaseInteger");
841
+ var Jn, Pn;
842
+ class Vi extends (Pn = Ge, Jn = v, Pn) {
843
843
  constructor(i) {
844
844
  super(i, "number", "SQLiteInteger");
845
845
  }
@@ -850,13 +850,13 @@ class Vi extends (Jn = Ye, Qn = v, Jn) {
850
850
  );
851
851
  }
852
852
  }
853
- h(Vi, Qn, "SQLiteIntegerBuilder");
853
+ p(Vi, Jn, "SQLiteIntegerBuilder");
854
854
  var Fn, Un;
855
- class Ri extends (Un = Xe, Fn = v, Un) {
855
+ class Ri extends (Un = Ye, Fn = v, Un) {
856
856
  }
857
- h(Ri, Fn, "SQLiteInteger");
857
+ p(Ri, Fn, "SQLiteInteger");
858
858
  var Kn, jn;
859
- class Wi extends (jn = Ye, Kn = v, jn) {
859
+ class Wi extends (jn = Ge, Kn = v, jn) {
860
860
  constructor(i, e) {
861
861
  super(i, "date", "SQLiteTimestamp"), this.config.mode = e;
862
862
  }
@@ -875,12 +875,12 @@ class Wi extends (jn = Ye, Kn = v, jn) {
875
875
  );
876
876
  }
877
877
  }
878
- h(Wi, Kn, "SQLiteTimestampBuilder");
878
+ p(Wi, Kn, "SQLiteTimestampBuilder");
879
879
  var Mn, Vn;
880
- class Hi extends (Vn = Xe, Mn = v, Vn) {
880
+ class Hi extends (Vn = Ye, Mn = v, Vn) {
881
881
  constructor() {
882
882
  super(...arguments);
883
- h(this, "mode", this.config.mode);
883
+ p(this, "mode", this.config.mode);
884
884
  }
885
885
  mapFromDriverValue(e) {
886
886
  return this.config.mode === "timestamp" ? new Date(e * 1e3) : new Date(e);
@@ -890,9 +890,9 @@ class Hi extends (Vn = Xe, Mn = v, Vn) {
890
890
  return this.config.mode === "timestamp" ? Math.floor(t / 1e3) : t;
891
891
  }
892
892
  }
893
- h(Hi, Mn, "SQLiteTimestamp");
893
+ p(Hi, Mn, "SQLiteTimestamp");
894
894
  var Rn, Wn;
895
- class Gi extends (Wn = Ye, Rn = v, Wn) {
895
+ class Gi extends (Wn = Ge, Rn = v, Wn) {
896
896
  constructor(i, e) {
897
897
  super(i, "boolean", "SQLiteBoolean"), this.config.mode = e;
898
898
  }
@@ -903,12 +903,12 @@ class Gi extends (Wn = Ye, Rn = v, Wn) {
903
903
  );
904
904
  }
905
905
  }
906
- h(Gi, Rn, "SQLiteBooleanBuilder");
906
+ p(Gi, Rn, "SQLiteBooleanBuilder");
907
907
  var Hn, Gn;
908
- class Yi extends (Gn = Xe, Hn = v, Gn) {
908
+ class Yi extends (Gn = Ye, Hn = v, Gn) {
909
909
  constructor() {
910
910
  super(...arguments);
911
- h(this, "mode", this.config.mode);
911
+ p(this, "mode", this.config.mode);
912
912
  }
913
913
  mapFromDriverValue(e) {
914
914
  return Number(e) === 1;
@@ -917,8 +917,8 @@ class Yi extends (Gn = Xe, Hn = v, Gn) {
917
917
  return e ? 1 : 0;
918
918
  }
919
919
  }
920
- h(Yi, Hn, "SQLiteBoolean");
921
- function p(n, i) {
920
+ p(Yi, Hn, "SQLiteBoolean");
921
+ function m(n, i) {
922
922
  const { name: e, config: t } = Je(n, i);
923
923
  return (t == null ? void 0 : t.mode) === "timestamp" || (t == null ? void 0 : t.mode) === "timestamp_ms" ? new Wi(e, t.mode) : (t == null ? void 0 : t.mode) === "boolean" ? new Gi(e, t.mode) : new Vi(e);
924
924
  }
@@ -935,7 +935,7 @@ class Xi extends (Xn = ce, Yn = v, Xn) {
935
935
  );
936
936
  }
937
937
  }
938
- h(Xi, Yn, "SQLiteNumericBuilder");
938
+ p(Xi, Yn, "SQLiteNumericBuilder");
939
939
  var Zn, ei;
940
940
  class Zi extends (ei = ge, Zn = v, ei) {
941
941
  mapFromDriverValue(i) {
@@ -945,7 +945,7 @@ class Zi extends (ei = ge, Zn = v, ei) {
945
945
  return "numeric";
946
946
  }
947
947
  }
948
- h(Zi, Zn, "SQLiteNumeric");
948
+ p(Zi, Zn, "SQLiteNumeric");
949
949
  var ti, ni;
950
950
  class er extends (ni = ce, ti = v, ni) {
951
951
  constructor(i) {
@@ -959,12 +959,12 @@ class er extends (ni = ce, ti = v, ni) {
959
959
  );
960
960
  }
961
961
  }
962
- h(er, ti, "SQLiteNumericNumberBuilder");
962
+ p(er, ti, "SQLiteNumericNumberBuilder");
963
963
  var ii, ri;
964
964
  class tr extends (ri = ge, ii = v, ri) {
965
965
  constructor() {
966
966
  super(...arguments);
967
- h(this, "mapToDriverValue", String);
967
+ p(this, "mapToDriverValue", String);
968
968
  }
969
969
  mapFromDriverValue(e) {
970
970
  return typeof e == "number" ? e : Number(e);
@@ -973,7 +973,7 @@ class tr extends (ri = ge, ii = v, ri) {
973
973
  return "numeric";
974
974
  }
975
975
  }
976
- h(tr, ii, "SQLiteNumericNumber");
976
+ p(tr, ii, "SQLiteNumericNumber");
977
977
  var si, oi;
978
978
  class nr extends (oi = ce, si = v, oi) {
979
979
  constructor(i) {
@@ -987,19 +987,19 @@ class nr extends (oi = ce, si = v, oi) {
987
987
  );
988
988
  }
989
989
  }
990
- h(nr, si, "SQLiteNumericBigIntBuilder");
990
+ p(nr, si, "SQLiteNumericBigIntBuilder");
991
991
  var ai, li;
992
992
  class ir extends (li = ge, ai = v, li) {
993
993
  constructor() {
994
994
  super(...arguments);
995
- h(this, "mapFromDriverValue", BigInt);
996
- h(this, "mapToDriverValue", String);
995
+ p(this, "mapFromDriverValue", BigInt);
996
+ p(this, "mapToDriverValue", String);
997
997
  }
998
998
  getSQLType() {
999
999
  return "numeric";
1000
1000
  }
1001
1001
  }
1002
- h(ir, ai, "SQLiteNumericBigInt");
1002
+ p(ir, ai, "SQLiteNumericBigInt");
1003
1003
  function Lr(n, i) {
1004
1004
  const { name: e, config: t } = Je(n, i), r = t == null ? void 0 : t.mode;
1005
1005
  return r === "number" ? new er(e) : r === "bigint" ? new nr(e) : new Xi(e);
@@ -1014,14 +1014,14 @@ class rr extends (ui = ce, _i = v, ui) {
1014
1014
  return new sr(i, this.config);
1015
1015
  }
1016
1016
  }
1017
- h(rr, _i, "SQLiteRealBuilder");
1017
+ p(rr, _i, "SQLiteRealBuilder");
1018
1018
  var di, ci;
1019
1019
  class sr extends (ci = ge, di = v, ci) {
1020
1020
  getSQLType() {
1021
1021
  return "real";
1022
1022
  }
1023
1023
  }
1024
- h(sr, di, "SQLiteReal");
1024
+ p(sr, di, "SQLiteReal");
1025
1025
  function Er(n) {
1026
1026
  return new rr(n ?? "");
1027
1027
  }
@@ -1038,21 +1038,21 @@ class or extends (fi = ce, gi = v, fi) {
1038
1038
  );
1039
1039
  }
1040
1040
  }
1041
- h(or, gi, "SQLiteTextBuilder");
1042
- var hi, mi;
1043
- class ar extends (mi = ge, hi = v, mi) {
1041
+ p(or, gi, "SQLiteTextBuilder");
1042
+ var pi, hi;
1043
+ class ar extends (hi = ge, pi = v, hi) {
1044
1044
  constructor(e, t) {
1045
1045
  super(e, t);
1046
- h(this, "enumValues", this.config.enumValues);
1047
- h(this, "length", this.config.length);
1046
+ p(this, "enumValues", this.config.enumValues);
1047
+ p(this, "length", this.config.length);
1048
1048
  }
1049
1049
  getSQLType() {
1050
1050
  return `text${this.config.length ? `(${this.config.length})` : ""}`;
1051
1051
  }
1052
1052
  }
1053
- h(ar, hi, "SQLiteText");
1054
- var pi, yi;
1055
- class lr extends (yi = ce, pi = v, yi) {
1053
+ p(ar, pi, "SQLiteText");
1054
+ var mi, yi;
1055
+ class lr extends (yi = ce, mi = v, yi) {
1056
1056
  constructor(i) {
1057
1057
  super(i, "json", "SQLiteTextJson");
1058
1058
  }
@@ -1064,7 +1064,7 @@ class lr extends (yi = ce, pi = v, yi) {
1064
1064
  );
1065
1065
  }
1066
1066
  }
1067
- h(lr, pi, "SQLiteTextJsonBuilder");
1067
+ p(lr, mi, "SQLiteTextJsonBuilder");
1068
1068
  var wi, Ni;
1069
1069
  class _r extends (Ni = ge, wi = v, Ni) {
1070
1070
  getSQLType() {
@@ -1077,7 +1077,7 @@ class _r extends (Ni = ge, wi = v, Ni) {
1077
1077
  return JSON.stringify(i);
1078
1078
  }
1079
1079
  }
1080
- h(_r, wi, "SQLiteTextJson");
1080
+ p(_r, wi, "SQLiteTextJson");
1081
1081
  function s(n, i = {}) {
1082
1082
  const { name: e, config: t } = Je(n, i);
1083
1083
  return t.mode === "json" ? new lr(e) : new or(e, t);
@@ -1086,36 +1086,36 @@ function Cr() {
1086
1086
  return {
1087
1087
  blob: Tr,
1088
1088
  customType: qr,
1089
- integer: p,
1089
+ integer: m,
1090
1090
  numeric: Lr,
1091
1091
  real: Er,
1092
1092
  text: s
1093
1093
  };
1094
1094
  }
1095
- const pt = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1095
+ const ht = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1096
1096
  var vi, Si, xi, bi, Di;
1097
- class $e extends (Di = M, bi = v, xi = M.Symbol.Columns, Si = pt, vi = M.Symbol.ExtraConfigBuilder, Di) {
1097
+ class $e extends (Di = M, bi = v, xi = M.Symbol.Columns, Si = ht, vi = M.Symbol.ExtraConfigBuilder, Di) {
1098
1098
  constructor() {
1099
1099
  super(...arguments);
1100
1100
  /** @internal */
1101
- h(this, xi);
1101
+ p(this, xi);
1102
1102
  /** @internal */
1103
- h(this, Si, []);
1103
+ p(this, Si, []);
1104
1104
  /** @internal */
1105
- h(this, vi);
1105
+ p(this, vi);
1106
1106
  }
1107
1107
  }
1108
- h($e, bi, "SQLiteTable"), /** @internal */
1109
- h($e, "Symbol", Object.assign({}, M.Symbol, {
1110
- InlineForeignKeys: pt
1108
+ p($e, bi, "SQLiteTable"), /** @internal */
1109
+ p($e, "Symbol", Object.assign({}, M.Symbol, {
1110
+ InlineForeignKeys: ht
1111
1111
  }));
1112
1112
  function Ar(n, i, e, t, r = n) {
1113
1113
  const o = new $e(n, t, r), l = typeof i == "function" ? i(Cr()) : i, _ = Object.fromEntries(
1114
1114
  Object.entries(l).map(([c, d]) => {
1115
- const m = d;
1116
- m.setName(c);
1117
- const f = m.build(o);
1118
- return o[pt].push(...m.buildForeignKeys(f, o)), [c, f];
1115
+ const h = d;
1116
+ h.setName(c);
1117
+ const f = h.build(o);
1118
+ return o[ht].push(...h.buildForeignKeys(f, o)), [c, f];
1119
1119
  })
1120
1120
  ), u = Object.assign(o, _);
1121
1121
  return u[M.Symbol.Columns] = _, u[M.Symbol.ExtraConfigColumns] = _, e && (u[$e.Symbol.ExtraConfigBuilder] = e), u;
@@ -1131,13 +1131,13 @@ class Ot {
1131
1131
  return new ur(this.name, i, this.unique);
1132
1132
  }
1133
1133
  }
1134
- h(Ot, Oi, "SQLiteIndexBuilderOn");
1134
+ p(Ot, Oi, "SQLiteIndexBuilderOn");
1135
1135
  var ki;
1136
1136
  ki = v;
1137
1137
  class ur {
1138
1138
  constructor(i, e, t) {
1139
1139
  /** @internal */
1140
- h(this, "config");
1140
+ p(this, "config");
1141
1141
  this.config = {
1142
1142
  name: i,
1143
1143
  columns: e,
@@ -1156,16 +1156,16 @@ class ur {
1156
1156
  return new dr(this.config, i);
1157
1157
  }
1158
1158
  }
1159
- h(ur, ki, "SQLiteIndexBuilder");
1159
+ p(ur, ki, "SQLiteIndexBuilder");
1160
1160
  var Ii;
1161
1161
  Ii = v;
1162
1162
  class dr {
1163
1163
  constructor(i, e) {
1164
- h(this, "config");
1164
+ p(this, "config");
1165
1165
  this.config = { ...i, table: e };
1166
1166
  }
1167
1167
  }
1168
- h(dr, Ii, "SQLiteIndex");
1168
+ p(dr, Ii, "SQLiteIndex");
1169
1169
  function S(n) {
1170
1170
  return new Ot(n, !1);
1171
1171
  }
@@ -1173,16 +1173,16 @@ function Te(n) {
1173
1173
  return new Ot(n, !0);
1174
1174
  }
1175
1175
  function oe(...n) {
1176
- return n[0].columns ? new yt(n[0].columns, n[0].name) : new yt(n);
1176
+ return n[0].columns ? new mt(n[0].columns, n[0].name) : new mt(n);
1177
1177
  }
1178
1178
  var zi;
1179
1179
  zi = v;
1180
- class yt {
1180
+ class mt {
1181
1181
  constructor(i, e) {
1182
1182
  /** @internal */
1183
- h(this, "columns");
1183
+ p(this, "columns");
1184
1184
  /** @internal */
1185
- h(this, "name");
1185
+ p(this, "name");
1186
1186
  this.columns = i, this.name = e;
1187
1187
  }
1188
1188
  /** @internal */
@@ -1190,20 +1190,20 @@ class yt {
1190
1190
  return new cr(i, this.columns, this.name);
1191
1191
  }
1192
1192
  }
1193
- h(yt, zi, "SQLitePrimaryKeyBuilder");
1193
+ p(mt, zi, "SQLitePrimaryKeyBuilder");
1194
1194
  var Ti;
1195
1195
  Ti = v;
1196
1196
  class cr {
1197
1197
  constructor(i, e, t) {
1198
- h(this, "columns");
1199
- h(this, "name");
1198
+ p(this, "columns");
1199
+ p(this, "name");
1200
1200
  this.table = i, this.columns = e, this.name = t;
1201
1201
  }
1202
1202
  getName() {
1203
1203
  return this.name ?? `${this.table[$e.Symbol.Name]}_${this.columns.map((i) => i.name).join("_")}_pk`;
1204
1204
  }
1205
1205
  }
1206
- h(cr, Ti, "SQLitePrimaryKey");
1206
+ p(cr, Ti, "SQLitePrimaryKey");
1207
1207
  const D = O("tenants", {
1208
1208
  id: s("id", { length: 191 }).primaryKey(),
1209
1209
  name: s("name", { length: 255 }),
@@ -1217,12 +1217,12 @@ const D = O("tenants", {
1217
1217
  created_at: s("created_at", { length: 35 }).notNull(),
1218
1218
  updated_at: s("updated_at", { length: 35 }).notNull(),
1219
1219
  support_url: s("support_url", { length: 255 }),
1220
- idle_session_lifetime: p("idle_session_lifetime"),
1221
- session_lifetime: p("session_lifetime"),
1220
+ idle_session_lifetime: m("idle_session_lifetime"),
1221
+ session_lifetime: m("session_lifetime"),
1222
1222
  session_cookie: s("session_cookie"),
1223
1223
  allowed_logout_urls: s("allowed_logout_urls"),
1224
- ephemeral_session_lifetime: p("ephemeral_session_lifetime"),
1225
- idle_ephemeral_session_lifetime: p("idle_ephemeral_session_lifetime"),
1224
+ ephemeral_session_lifetime: m("ephemeral_session_lifetime"),
1225
+ idle_ephemeral_session_lifetime: m("idle_ephemeral_session_lifetime"),
1226
1226
  default_redirection_uri: s("default_redirection_uri"),
1227
1227
  enabled_locales: s("enabled_locales"),
1228
1228
  default_directory: s("default_directory", { length: 255 }),
@@ -1242,18 +1242,18 @@ const D = O("tenants", {
1242
1242
  default_organization: s("default_organization", { length: 255 }),
1243
1243
  sessions: s("sessions"),
1244
1244
  oidc_logout: s("oidc_logout"),
1245
- allow_organization_name_in_authentication_api: p(
1245
+ allow_organization_name_in_authentication_api: m(
1246
1246
  "allow_organization_name_in_authentication_api"
1247
1247
  ),
1248
- customize_mfa_in_postlogin_action: p(
1248
+ customize_mfa_in_postlogin_action: m(
1249
1249
  "customize_mfa_in_postlogin_action"
1250
1250
  ),
1251
1251
  acr_values_supported: s("acr_values_supported"),
1252
1252
  mtls: s("mtls"),
1253
- pushed_authorization_requests_supported: p(
1253
+ pushed_authorization_requests_supported: m(
1254
1254
  "pushed_authorization_requests_supported"
1255
1255
  ),
1256
- authorization_response_iss_parameter_supported: p(
1256
+ authorization_response_iss_parameter_supported: m(
1257
1257
  "authorization_response_iss_parameter_supported"
1258
1258
  )
1259
1259
  }), k = O(
@@ -1269,21 +1269,21 @@ const D = O("tenants", {
1269
1269
  picture: s("picture", { length: 2083 }),
1270
1270
  tags: s("tags", { length: 255 }),
1271
1271
  phone_number: s("phone_number", { length: 17 }),
1272
- phone_verified: p("phone_verified", { mode: "boolean" }),
1272
+ phone_verified: m("phone_verified", { mode: "boolean" }),
1273
1273
  username: s("username", { length: 128 }),
1274
1274
  created_at: s("created_at", { length: 35 }).notNull(),
1275
1275
  updated_at: s("updated_at", { length: 35 }).notNull(),
1276
1276
  linked_to: s("linked_to", { length: 255 }),
1277
1277
  last_ip: s("last_ip", { length: 255 }),
1278
- login_count: p("login_count").notNull(),
1278
+ login_count: m("login_count").notNull(),
1279
1279
  last_login: s("last_login", { length: 255 }),
1280
1280
  registration_completed_at: s("registration_completed_at", {
1281
1281
  length: 35
1282
1282
  }),
1283
1283
  provider: s("provider", { length: 255 }).notNull(),
1284
1284
  connection: s("connection", { length: 255 }),
1285
- email_verified: p("email_verified", { mode: "boolean" }).notNull(),
1286
- is_social: p("is_social", { mode: "boolean" }).notNull(),
1285
+ email_verified: m("email_verified", { mode: "boolean" }).notNull(),
1286
+ is_social: m("is_social", { mode: "boolean" }).notNull(),
1287
1287
  app_metadata: s("app_metadata", { length: 4096 }).notNull().default("{}"),
1288
1288
  user_metadata: s("user_metadata").notNull().default("{}"),
1289
1289
  profileData: s("profileData", { length: 2048 }),
@@ -1332,7 +1332,7 @@ const D = O("tenants", {
1332
1332
  n.provider
1333
1333
  )
1334
1334
  ]
1335
- ), C = O("passwords", {
1335
+ ), A = O("passwords", {
1336
1336
  id: s("id", { length: 21 }).primaryKey(),
1337
1337
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1338
1338
  user_id: s("user_id", { length: 255 }).notNull(),
@@ -1340,21 +1340,21 @@ const D = O("tenants", {
1340
1340
  updated_at: s("updated_at", { length: 35 }).notNull(),
1341
1341
  password: s("password", { length: 255 }).notNull(),
1342
1342
  algorithm: s("algorithm", { length: 16 }).notNull().default("bcrypt"),
1343
- is_current: p("is_current").notNull().default(1)
1343
+ is_current: m("is_current").notNull().default(1)
1344
1344
  }), $ = O(
1345
1345
  "sessions",
1346
1346
  {
1347
1347
  id: s("id", { length: 21 }).notNull(),
1348
1348
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1349
1349
  user_id: s("user_id", { length: 255 }),
1350
- created_at_ts: p("created_at_ts").notNull(),
1351
- updated_at_ts: p("updated_at_ts").notNull(),
1352
- expires_at_ts: p("expires_at_ts"),
1353
- idle_expires_at_ts: p("idle_expires_at_ts"),
1354
- authenticated_at_ts: p("authenticated_at_ts"),
1355
- last_interaction_at_ts: p("last_interaction_at_ts"),
1356
- used_at_ts: p("used_at_ts"),
1357
- revoked_at_ts: p("revoked_at_ts"),
1350
+ created_at_ts: m("created_at_ts").notNull(),
1351
+ updated_at_ts: m("updated_at_ts").notNull(),
1352
+ expires_at_ts: m("expires_at_ts"),
1353
+ idle_expires_at_ts: m("idle_expires_at_ts"),
1354
+ authenticated_at_ts: m("authenticated_at_ts"),
1355
+ last_interaction_at_ts: m("last_interaction_at_ts"),
1356
+ used_at_ts: m("used_at_ts"),
1357
+ revoked_at_ts: m("revoked_at_ts"),
1358
1358
  device: s("device").notNull(),
1359
1359
  clients: s("clients").notNull(),
1360
1360
  login_session_id: s("login_session_id", { length: 21 })
@@ -1365,7 +1365,7 @@ const D = O("tenants", {
1365
1365
  S("idx_sessions_user_id").on(n.tenant_id, n.user_id),
1366
1366
  S("idx_sessions_expires_at_ts").on(n.expires_at_ts)
1367
1367
  ]
1368
- ), T = O(
1368
+ ), z = O(
1369
1369
  "refresh_tokens",
1370
1370
  {
1371
1371
  id: s("id", { length: 21 }).notNull(),
@@ -1375,11 +1375,12 @@ 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
+ revoked_at_ts: m("revoked_at_ts")
1383
1384
  },
1384
1385
  (n) => [
1385
1386
  oe({
@@ -1390,39 +1391,20 @@ const D = O("tenants", {
1390
1391
  S("idx_refresh_tokens_login_id").on(n.login_id),
1391
1392
  S("idx_refresh_tokens_expires_at_ts").on(n.expires_at_ts)
1392
1393
  ]
1393
- ), B = O(
1394
+ ), L = O(
1394
1395
  "login_sessions",
1395
1396
  {
1396
1397
  id: s("id", { length: 21 }).notNull(),
1397
1398
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1398
1399
  session_id: s("session_id", { length: 21 }),
1399
1400
  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 }),
1401
+ // JSON-serialized authParams. Canonical source of truth. Replaces the
1402
+ // legacy hoisted authParams_* columns, which were dropped.
1403
+ auth_params: s("auth_params"),
1422
1404
  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(),
1405
+ created_at_ts: m("created_at_ts").notNull(),
1406
+ updated_at_ts: m("updated_at_ts").notNull(),
1407
+ expires_at_ts: m("expires_at_ts").notNull(),
1426
1408
  ip: s("ip", { length: 39 }),
1427
1409
  useragent: s("useragent"),
1428
1410
  auth0Client: s("auth0Client", { length: 255 }),
@@ -1452,7 +1434,7 @@ const D = O("tenants", {
1452
1434
  S("login_sessions_tenant_user_idx").on(n.tenant_id, n.user_id),
1453
1435
  S("idx_login_sessions_expires_at_ts").on(n.expires_at_ts)
1454
1436
  ]
1455
- ), P = O(
1437
+ ), J = O(
1456
1438
  "codes",
1457
1439
  {
1458
1440
  code_id: s("code_id", { length: 191 }).notNull(),
@@ -1518,7 +1500,7 @@ const D = O("tenants", {
1518
1500
  S("otps_email_index").on(n.email),
1519
1501
  S("otps_expires_at_index").on(n.expires_at)
1520
1502
  ]
1521
- ), Pr = O("tickets", {
1503
+ ), Qr = O("tickets", {
1522
1504
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1523
1505
  id: s("id", { length: 255 }).primaryKey(),
1524
1506
  client_id: s("client_id", { length: 255 }).notNull(),
@@ -1539,13 +1521,13 @@ const D = O("tenants", {
1539
1521
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1540
1522
  name: s("name", { length: 255 }).notNull(),
1541
1523
  description: s("description", { length: 140 }),
1542
- global: p("global").notNull().default(0),
1524
+ global: m("global").notNull().default(0),
1543
1525
  client_secret: s("client_secret", { length: 255 }),
1544
1526
  app_type: s("app_type", { length: 64 }).default("regular_web"),
1545
1527
  logo_uri: s("logo_uri", { length: 2083 }),
1546
- is_first_party: p("is_first_party").notNull().default(0),
1547
- oidc_conformant: p("oidc_conformant").notNull().default(1),
1548
- auth0_conformant: p("auth0_conformant").notNull().default(1),
1528
+ is_first_party: m("is_first_party").notNull().default(0),
1529
+ oidc_conformant: m("oidc_conformant").notNull().default(1),
1530
+ auth0_conformant: m("auth0_conformant").notNull().default(1),
1549
1531
  callbacks: s("callbacks").notNull(),
1550
1532
  allowed_origins: s("allowed_origins").notNull(),
1551
1533
  web_origins: s("web_origins").notNull(),
@@ -1558,11 +1540,11 @@ const D = O("tenants", {
1558
1540
  jwt_configuration: s("jwt_configuration").notNull(),
1559
1541
  signing_keys: s("signing_keys").notNull(),
1560
1542
  encryption_key: s("encryption_key").notNull(),
1561
- sso: p("sso").notNull().default(0),
1562
- sso_disabled: p("sso_disabled").notNull().default(1),
1563
- cross_origin_authentication: p("cross_origin_authentication").notNull().default(0),
1543
+ sso: m("sso").notNull().default(0),
1544
+ sso_disabled: m("sso_disabled").notNull().default(1),
1545
+ cross_origin_authentication: m("cross_origin_authentication").notNull().default(0),
1564
1546
  cross_origin_loc: s("cross_origin_loc", { length: 2083 }),
1565
- custom_login_page_on: p("custom_login_page_on").notNull().default(0),
1547
+ custom_login_page_on: m("custom_login_page_on").notNull().default(0),
1566
1548
  custom_login_page: s("custom_login_page"),
1567
1549
  custom_login_page_preview: s("custom_login_page_preview"),
1568
1550
  form_template: s("form_template"),
@@ -1585,13 +1567,13 @@ const D = O("tenants", {
1585
1567
  client_authentication_methods: s(
1586
1568
  "client_authentication_methods"
1587
1569
  ).notNull(),
1588
- require_pushed_authorization_requests: p(
1570
+ require_pushed_authorization_requests: m(
1589
1571
  "require_pushed_authorization_requests"
1590
1572
  ).notNull().default(0),
1591
- require_proof_of_possession: p("require_proof_of_possession").notNull().default(0),
1573
+ require_proof_of_possession: m("require_proof_of_possession").notNull().default(0),
1592
1574
  signed_request_object: s("signed_request_object").notNull(),
1593
1575
  compliance_level: s("compliance_level", { length: 64 }),
1594
- par_request_expiry: p("par_request_expiry"),
1576
+ par_request_expiry: m("par_request_expiry"),
1595
1577
  token_quota: s("token_quota").notNull(),
1596
1578
  created_at: s("created_at", { length: 35 }).notNull(),
1597
1579
  updated_at: s("updated_at", { length: 35 }).notNull(),
@@ -1612,8 +1594,8 @@ const D = O("tenants", {
1612
1594
  audience: s("audience", { length: 191 }).notNull(),
1613
1595
  scope: s("scope").default("[]"),
1614
1596
  organization_usage: s("organization_usage", { length: 32 }),
1615
- allow_any_organization: p("allow_any_organization").default(0),
1616
- is_system: p("is_system").default(0),
1597
+ allow_any_organization: m("allow_any_organization").default(0),
1598
+ is_system: m("is_system").default(0),
1617
1599
  subject_type: s("subject_type", { length: 32 }),
1618
1600
  authorization_details_types: s("authorization_details_types").default(
1619
1601
  "[]"
@@ -1628,7 +1610,7 @@ const D = O("tenants", {
1628
1610
  }),
1629
1611
  S("idx_client_grants_audience").on(n.audience)
1630
1612
  ]
1631
- ), K = O(
1613
+ ), j = O(
1632
1614
  "connections",
1633
1615
  {
1634
1616
  id: s("id", { length: 255 }).notNull(),
@@ -1641,9 +1623,9 @@ const D = O("tenants", {
1641
1623
  created_at: s("created_at", { length: 35 }).notNull(),
1642
1624
  updated_at: s("updated_at", { length: 35 }).notNull(),
1643
1625
  display_name: s("display_name", { length: 255 }),
1644
- is_domain_connection: p("is_domain_connection"),
1645
- show_as_button: p("show_as_button"),
1646
- is_system: p("is_system").notNull().default(0),
1626
+ is_domain_connection: m("is_domain_connection"),
1627
+ show_as_button: m("show_as_button"),
1628
+ is_system: m("is_system").notNull().default(0),
1647
1629
  metadata: s("metadata", { length: 4096 })
1648
1630
  },
1649
1631
  (n) => [
@@ -1658,7 +1640,7 @@ const D = O("tenants", {
1658
1640
  custom_domain_id: s("custom_domain_id", { length: 256 }).primaryKey(),
1659
1641
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1660
1642
  domain: s("domain", { length: 255 }).notNull(),
1661
- primary: p("primary", { mode: "boolean" }).notNull(),
1643
+ primary: m("primary", { mode: "boolean" }).notNull(),
1662
1644
  status: s("status", { length: 50 }).notNull(),
1663
1645
  type: s("type", { length: 50 }).notNull(),
1664
1646
  origin_domain_name: s("origin_domain_name", { length: 255 }),
@@ -1670,7 +1652,7 @@ const D = O("tenants", {
1670
1652
  updated_at: s("updated_at", { length: 35 }).notNull()
1671
1653
  },
1672
1654
  (n) => [Te("custom_domains_domain_unique").on(n.domain)]
1673
- ), Qr = O("domains", {
1655
+ ), Jr = O("domains", {
1674
1656
  id: s("id", { length: 255 }).primaryKey(),
1675
1657
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1676
1658
  domain: s("domain", { length: 255 }).notNull(),
@@ -1680,7 +1662,7 @@ const D = O("tenants", {
1680
1662
  dkim_public_key: s("dkim_public_key", { length: 2048 }),
1681
1663
  created_at: s("created_at", { length: 35 }).notNull(),
1682
1664
  updated_at: s("updated_at", { length: 35 }).notNull()
1683
- }), L = O(
1665
+ }), E = O(
1684
1666
  "organizations",
1685
1667
  {
1686
1668
  id: s("id", { length: 21 }).primaryKey(),
@@ -1695,7 +1677,7 @@ const D = O("tenants", {
1695
1677
  updated_at: s("updated_at", { length: 35 }).notNull()
1696
1678
  },
1697
1679
  (n) => [S("idx_organizations_tenant_id").on(n.tenant_id)]
1698
- ), Q = O(
1680
+ ), P = O(
1699
1681
  "user_organizations",
1700
1682
  {
1701
1683
  id: s("id", { length: 21 }).primaryKey(),
@@ -1732,8 +1714,8 @@ const D = O("tenants", {
1732
1714
  user_metadata: s("user_metadata"),
1733
1715
  roles: s("roles"),
1734
1716
  ticket_id: s("ticket_id", { length: 191 }),
1735
- ttl_sec: p("ttl_sec"),
1736
- send_invitation_email: p("send_invitation_email")
1717
+ ttl_sec: m("ttl_sec"),
1718
+ send_invitation_email: m("send_invitation_email")
1737
1719
  },
1738
1720
  (n) => [
1739
1721
  S("idx_invites_tenant_id").on(n.tenant_id),
@@ -1741,14 +1723,14 @@ const D = O("tenants", {
1741
1723
  S("idx_invites_expires_at").on(n.expires_at),
1742
1724
  S("idx_invites_tenant_created").on(n.tenant_id, n.created_at)
1743
1725
  ]
1744
- ), F = O(
1726
+ ), U = O(
1745
1727
  "roles",
1746
1728
  {
1747
1729
  id: s("id", { length: 21 }).notNull(),
1748
1730
  tenant_id: s("tenant_id", { length: 191 }).notNull(),
1749
1731
  name: s("name", { length: 50 }).notNull(),
1750
1732
  description: s("description", { length: 255 }),
1751
- is_system: p("is_system").notNull().default(0),
1733
+ is_system: m("is_system").notNull().default(0),
1752
1734
  metadata: s("metadata", { length: 4096 }),
1753
1735
  created_at: s("created_at", { length: 35 }).notNull(),
1754
1736
  updated_at: s("updated_at", { length: 35 }).notNull()
@@ -1838,7 +1820,7 @@ const D = O("tenants", {
1838
1820
  S("user_roles_role_fk").on(n.tenant_id, n.role_id),
1839
1821
  S("user_roles_organization_fk").on(n.organization_id)
1840
1822
  ]
1841
- ), E = O(
1823
+ ), C = O(
1842
1824
  "resource_servers",
1843
1825
  {
1844
1826
  id: s("id", { length: 21 }).notNull(),
@@ -1848,15 +1830,15 @@ const D = O("tenants", {
1848
1830
  scopes: s("scopes", { length: 4096 }),
1849
1831
  signing_alg: s("signing_alg", { length: 64 }),
1850
1832
  signing_secret: s("signing_secret", { length: 2048 }),
1851
- token_lifetime: p("token_lifetime"),
1852
- token_lifetime_for_web: p("token_lifetime_for_web"),
1853
- skip_consent_for_verifiable_first_party_clients: p(
1833
+ token_lifetime: m("token_lifetime"),
1834
+ token_lifetime_for_web: m("token_lifetime_for_web"),
1835
+ skip_consent_for_verifiable_first_party_clients: m(
1854
1836
  "skip_consent_for_verifiable_first_party_clients"
1855
1837
  ),
1856
- allow_offline_access: p("allow_offline_access"),
1838
+ allow_offline_access: m("allow_offline_access"),
1857
1839
  verification_key: s("verification_key", { length: 4096 }),
1858
1840
  options: s("options", { length: 4096 }),
1859
- is_system: p("is_system").notNull().default(0),
1841
+ is_system: m("is_system").notNull().default(0),
1860
1842
  metadata: s("metadata", { length: 4096 }),
1861
1843
  created_at: s("created_at", { length: 35 }).notNull(),
1862
1844
  updated_at: s("updated_at", { length: 35 }).notNull()
@@ -1880,14 +1862,14 @@ const D = O("tenants", {
1880
1862
  length: 8
1881
1863
  }),
1882
1864
  colors_page_background_end: s("colors_page_background_end", { length: 8 }),
1883
- colors_page_background_angle_dev: p("colors_page_background_angle_dev")
1865
+ colors_page_background_angle_dev: m("colors_page_background_angle_dev")
1884
1866
  }), ve = O(
1885
1867
  "universal_login_templates",
1886
1868
  {
1887
1869
  tenant_id: s("tenant_id", { length: 191 }).primaryKey().references(() => D.id, { onDelete: "cascade" }),
1888
1870
  body: s("body").notNull(),
1889
- created_at_ts: p("created_at_ts").notNull(),
1890
- updated_at_ts: p("updated_at_ts").notNull()
1871
+ created_at_ts: m("created_at_ts").notNull(),
1872
+ updated_at_ts: m("updated_at_ts").notNull()
1891
1873
  }
1892
1874
  ), fe = O(
1893
1875
  "themes",
@@ -1940,54 +1922,54 @@ const D = O("tenants", {
1940
1922
  colors_widget_border: s("colors_widget_border", {
1941
1923
  length: 24
1942
1924
  }).notNull(),
1943
- borders_button_border_radius: p(
1925
+ borders_button_border_radius: m(
1944
1926
  "borders_button_border_radius"
1945
1927
  ).notNull(),
1946
- borders_button_border_weight: p(
1928
+ borders_button_border_weight: m(
1947
1929
  "borders_button_border_weight"
1948
1930
  ).notNull(),
1949
1931
  borders_buttons_style: s("borders_buttons_style", {
1950
1932
  length: 24
1951
1933
  }).notNull(),
1952
- borders_input_border_radius: p(
1934
+ borders_input_border_radius: m(
1953
1935
  "borders_input_border_radius"
1954
1936
  ).notNull(),
1955
- borders_input_border_weight: p(
1937
+ borders_input_border_weight: m(
1956
1938
  "borders_input_border_weight"
1957
1939
  ).notNull(),
1958
1940
  borders_inputs_style: s("borders_inputs_style", {
1959
1941
  length: 24
1960
1942
  }).notNull(),
1961
- borders_show_widget_shadow: p("borders_show_widget_shadow", {
1943
+ borders_show_widget_shadow: m("borders_show_widget_shadow", {
1962
1944
  mode: "boolean"
1963
1945
  }).notNull(),
1964
- borders_widget_border_weight: p(
1946
+ borders_widget_border_weight: m(
1965
1947
  "borders_widget_border_weight"
1966
1948
  ).notNull(),
1967
- borders_widget_corner_radius: p(
1949
+ borders_widget_corner_radius: m(
1968
1950
  "borders_widget_corner_radius"
1969
1951
  ).notNull(),
1970
- fonts_body_text_bold: p("fonts_body_text_bold").notNull(),
1971
- fonts_body_text_size: p("fonts_body_text_size").notNull(),
1972
- fonts_buttons_text_bold: p("fonts_buttons_text_bold").notNull(),
1973
- fonts_buttons_text_size: p("fonts_buttons_text_size").notNull(),
1952
+ fonts_body_text_bold: m("fonts_body_text_bold").notNull(),
1953
+ fonts_body_text_size: m("fonts_body_text_size").notNull(),
1954
+ fonts_buttons_text_bold: m("fonts_buttons_text_bold").notNull(),
1955
+ fonts_buttons_text_size: m("fonts_buttons_text_size").notNull(),
1974
1956
  fonts_font_url: s("fonts_font_url", { length: 255 }).notNull(),
1975
- fonts_input_labels_bold: p("fonts_input_labels_bold").notNull(),
1976
- fonts_input_labels_size: p("fonts_input_labels_size").notNull(),
1977
- fonts_links_bold: p("fonts_links_bold", {
1957
+ fonts_input_labels_bold: m("fonts_input_labels_bold").notNull(),
1958
+ fonts_input_labels_size: m("fonts_input_labels_size").notNull(),
1959
+ fonts_links_bold: m("fonts_links_bold", {
1978
1960
  mode: "boolean"
1979
1961
  }).notNull(),
1980
- fonts_links_size: p("fonts_links_size").notNull(),
1962
+ fonts_links_size: m("fonts_links_size").notNull(),
1981
1963
  fonts_links_style: s("fonts_links_style", { length: 24 }).notNull(),
1982
- fonts_reference_text_size: p("fonts_reference_text_size").notNull(),
1983
- fonts_subtitle_bold: p("fonts_subtitle_bold", {
1964
+ fonts_reference_text_size: m("fonts_reference_text_size").notNull(),
1965
+ fonts_subtitle_bold: m("fonts_subtitle_bold", {
1984
1966
  mode: "boolean"
1985
1967
  }).notNull(),
1986
- fonts_subtitle_size: p("fonts_subtitle_size").notNull(),
1987
- fonts_title_bold: p("fonts_title_bold", {
1968
+ fonts_subtitle_size: m("fonts_subtitle_size").notNull(),
1969
+ fonts_title_bold: m("fonts_title_bold", {
1988
1970
  mode: "boolean"
1989
1971
  }).notNull(),
1990
- fonts_title_size: p("fonts_title_size").notNull(),
1972
+ fonts_title_size: m("fonts_title_size").notNull(),
1991
1973
  page_background_background_color: s("page_background_background_color", {
1992
1974
  length: 24
1993
1975
  }).notNull(),
@@ -2001,7 +1983,7 @@ const D = O("tenants", {
2001
1983
  widget_header_text_alignment: s("widget_header_text_alignment", {
2002
1984
  length: 24
2003
1985
  }).notNull(),
2004
- widget_logo_height: p("widget_logo_height").notNull(),
1986
+ widget_logo_height: m("widget_logo_height").notNull(),
2005
1987
  widget_logo_position: s("widget_logo_position", {
2006
1988
  length: 24
2007
1989
  }).notNull(),
@@ -2050,15 +2032,15 @@ const D = O("tenants", {
2050
2032
  ), Ee = O("prompt_settings", {
2051
2033
  tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
2052
2034
  universal_login_experience: s("universal_login_experience", { length: 16 }).notNull().default("new"),
2053
- identifier_first: p("identifier_first", { mode: "boolean" }).notNull().default(!0),
2054
- password_first: p("password_first", { mode: "boolean" }).notNull().default(!1),
2055
- webauthn_platform_first_factor: p("webauthn_platform_first_factor", {
2035
+ identifier_first: m("identifier_first", { mode: "boolean" }).notNull().default(!0),
2036
+ password_first: m("password_first", { mode: "boolean" }).notNull().default(!1),
2037
+ webauthn_platform_first_factor: m("webauthn_platform_first_factor", {
2056
2038
  mode: "boolean"
2057
2039
  }).notNull().default(!1)
2058
2040
  }), Se = O("email_providers", {
2059
2041
  tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
2060
2042
  name: s("name", { length: 255 }).notNull(),
2061
- enabled: p("enabled", { mode: "boolean" }).notNull(),
2043
+ enabled: m("enabled", { mode: "boolean" }).notNull(),
2062
2044
  default_from_address: s("default_from_address", { length: 255 }),
2063
2045
  credentials: s("credentials", { length: 2048 }).notNull().default("{}"),
2064
2046
  settings: s("settings", { length: 2048 }).notNull().default("{}"),
@@ -2072,11 +2054,11 @@ const D = O("tenants", {
2072
2054
  url: s("url", { length: 512 }),
2073
2055
  // nullable - only required for webhook type hooks
2074
2056
  trigger_id: s("trigger_id", { length: 255 }).notNull(),
2075
- enabled: p("enabled", { mode: "boolean" }).notNull(),
2076
- created_at_ts: p("created_at_ts").notNull(),
2077
- updated_at_ts: p("updated_at_ts").notNull(),
2078
- synchronous: p("synchronous", { mode: "boolean" }).notNull().default(!1),
2079
- priority: p("priority"),
2057
+ enabled: m("enabled", { mode: "boolean" }).notNull(),
2058
+ created_at_ts: m("created_at_ts").notNull(),
2059
+ updated_at_ts: m("updated_at_ts").notNull(),
2060
+ synchronous: m("synchronous", { mode: "boolean" }).notNull().default(!1),
2061
+ priority: m("priority"),
2080
2062
  form_id: s("form_id", { length: 128 }),
2081
2063
  // only required for form type hooks
2082
2064
  template_id: s("template_id", { length: 64 }),
@@ -2085,18 +2067,18 @@ const D = O("tenants", {
2085
2067
  // only required for code type hooks
2086
2068
  },
2087
2069
  (n) => [S("hooks_tenant_id_idx").on(n.tenant_id)]
2088
- ), he = O(
2070
+ ), pe = O(
2089
2071
  "hook_code",
2090
2072
  {
2091
2073
  id: s("id", { length: 21 }).primaryKey(),
2092
2074
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
2093
2075
  code: s("code").notNull(),
2094
2076
  secrets: s("secrets"),
2095
- created_at_ts: p("created_at_ts").notNull(),
2096
- updated_at_ts: p("updated_at_ts").notNull()
2077
+ created_at_ts: m("created_at_ts").notNull(),
2078
+ updated_at_ts: m("updated_at_ts").notNull()
2097
2079
  },
2098
2080
  (n) => [S("hook_code_tenant_id_idx").on(n.tenant_id)]
2099
- ), me = O("keys", {
2081
+ ), he = O("keys", {
2100
2082
  kid: s("kid", { length: 255 }).primaryKey(),
2101
2083
  tenant_id: s("tenant_id", { length: 191 }).references(() => D.id, {
2102
2084
  onDelete: "cascade"
@@ -2111,7 +2093,7 @@ const D = O("tenants", {
2111
2093
  current_until: s("current_until", { length: 35 }),
2112
2094
  type: s("type", { length: 50 }).notNull().default("jwt_signing"),
2113
2095
  connection: s("connection", { length: 255 }).references(
2114
- () => K.id,
2096
+ () => j.id,
2115
2097
  { onDelete: "cascade" }
2116
2098
  )
2117
2099
  }), te = O(
@@ -2121,13 +2103,13 @@ const D = O("tenants", {
2121
2103
  prompt: s("prompt", { length: 64 }).notNull(),
2122
2104
  language: s("language", { length: 16 }).notNull(),
2123
2105
  custom_text: s("custom_text").notNull(),
2124
- created_at_ts: p("created_at_ts").notNull(),
2125
- updated_at_ts: p("updated_at_ts").notNull()
2106
+ created_at_ts: m("created_at_ts").notNull(),
2107
+ updated_at_ts: m("updated_at_ts").notNull()
2126
2108
  },
2127
2109
  (n) => [
2128
2110
  oe({ columns: [n.tenant_id, n.prompt, n.language] })
2129
2111
  ]
2130
- ), U = O(
2112
+ ), K = O(
2131
2113
  "authentication_methods",
2132
2114
  {
2133
2115
  id: s("id", { length: 26 }).primaryKey(),
@@ -2138,13 +2120,13 @@ const D = O("tenants", {
2138
2120
  totp_secret: s("totp_secret", { length: 255 }),
2139
2121
  credential_id: s("credential_id", { length: 512 }),
2140
2122
  public_key: s("public_key"),
2141
- sign_count: p("sign_count"),
2142
- credential_backed_up: p("credential_backed_up"),
2123
+ sign_count: m("sign_count"),
2124
+ credential_backed_up: m("credential_backed_up"),
2143
2125
  transports: s("transports", { length: 512 }),
2144
2126
  friendly_name: s("friendly_name", { length: 255 }),
2145
- confirmed: p("confirmed").notNull().default(0),
2146
- created_at_ts: p("created_at_ts").notNull(),
2147
- updated_at_ts: p("updated_at_ts").notNull()
2127
+ confirmed: m("confirmed").notNull().default(0),
2128
+ created_at_ts: m("created_at_ts").notNull(),
2129
+ updated_at_ts: m("updated_at_ts").notNull()
2148
2130
  },
2149
2131
  (n) => [
2150
2132
  S("authentication_methods_tenant_user_idx").on(
@@ -2168,7 +2150,7 @@ const D = O("tenants", {
2168
2150
  user_agent: s("user_agent", { length: 255 }),
2169
2151
  description: s("description", { length: 255 }),
2170
2152
  details: s("details", { length: 2048 }),
2171
- isMobile: p("isMobile"),
2153
+ isMobile: m("isMobile"),
2172
2154
  user_name: s("user_name", { length: 255 }),
2173
2155
  connection: s("connection", { length: 255 }),
2174
2156
  connection_id: s("connection_id", { length: 255 }),
@@ -2209,7 +2191,7 @@ const D = O("tenants", {
2209
2191
  payload: s("payload").notNull(),
2210
2192
  created_at: s("created_at", { length: 35 }).notNull(),
2211
2193
  processed_at: s("processed_at", { length: 35 }),
2212
- retry_count: p("retry_count").notNull().default(0),
2194
+ retry_count: m("retry_count").notNull().default(0),
2213
2195
  next_retry_at: s("next_retry_at", { length: 35 }),
2214
2196
  error: s("error"),
2215
2197
  claimed_by: s("claimed_by", { length: 255 }),
@@ -2233,60 +2215,60 @@ const D = O("tenants", {
2233
2215
  ), Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2234
2216
  __proto__: null,
2235
2217
  authenticationCodes: Br,
2236
- authenticationMethods: U,
2218
+ authenticationMethods: K,
2237
2219
  branding: Le,
2238
2220
  clientGrants: Y,
2239
2221
  clients: I,
2240
- codes: P,
2241
- connections: K,
2222
+ codes: J,
2223
+ connections: j,
2242
2224
  customDomains: se,
2243
2225
  customText: te,
2244
- domains: Qr,
2226
+ domains: Jr,
2245
2227
  emailProviders: Se,
2246
2228
  flows: re,
2247
2229
  forms: ie,
2248
- hookCode: he,
2230
+ hookCode: pe,
2249
2231
  hooks: ee,
2250
2232
  invites: ne,
2251
- keys: me,
2252
- loginSessions: B,
2233
+ keys: he,
2234
+ loginSessions: L,
2253
2235
  logs: q,
2254
- organizations: L,
2236
+ organizations: E,
2255
2237
  otps: $r,
2256
2238
  outboxEvents: b,
2257
- passwords: C,
2239
+ passwords: A,
2258
2240
  promptSettings: Ee,
2259
- refreshTokens: T,
2260
- resourceServers: E,
2241
+ refreshTokens: z,
2242
+ resourceServers: C,
2261
2243
  rolePermissions: le,
2262
- roles: F,
2244
+ roles: U,
2263
2245
  sessions: $,
2264
2246
  tenants: D,
2265
2247
  themes: fe,
2266
- tickets: Pr,
2248
+ tickets: Qr,
2267
2249
  universalLoginTemplates: ve,
2268
- userOrganizations: Q,
2250
+ userOrganizations: P,
2269
2251
  userPermissions: _e,
2270
2252
  userRoles: ue,
2271
2253
  users: k
2272
2254
  }, Symbol.toStringTag, { value: "Module" }));
2273
- function z(n) {
2255
+ function T(n) {
2274
2256
  if (n == null || typeof n != "object")
2275
2257
  return n;
2276
2258
  if (Array.isArray(n))
2277
2259
  return n.map(
2278
- (e) => e !== null && typeof e == "object" ? z(e) : e
2260
+ (e) => e !== null && typeof e == "object" ? T(e) : e
2279
2261
  );
2280
2262
  const i = { ...n };
2281
2263
  for (const e in i) {
2282
2264
  const t = i[e];
2283
2265
  t === null ? delete i[e] : t !== null && typeof t == "object" && (Array.isArray(t) ? i[e] = t.map(
2284
- (r) => r !== null && typeof r == "object" ? z(r) : r
2285
- ) : i[e] = z(t));
2266
+ (r) => r !== null && typeof r == "object" ? T(r) : r
2267
+ ) : i[e] = T(t));
2286
2268
  }
2287
2269
  return i;
2288
2270
  }
2289
- function Jr(n, i, e = { ...n }) {
2271
+ function Pr(n, i, e = { ...n }) {
2290
2272
  for (const t of i)
2291
2273
  n[t] !== void 0 && (e[t] = JSON.stringify(n[t]));
2292
2274
  return e;
@@ -2312,11 +2294,11 @@ function x(n, i) {
2312
2294
  }
2313
2295
  return n;
2314
2296
  }
2315
- function Pe(n, i = "", e = {}) {
2297
+ function yt(n, i = "", e = {}) {
2316
2298
  for (const t in n)
2317
2299
  if (Object.prototype.hasOwnProperty.call(n, t)) {
2318
2300
  const r = i ? `${i}_${t}` : t, o = n[t];
2319
- typeof o == "object" && o !== null && !Array.isArray(o) ? Pe(o, r, e) : typeof o == "boolean" ? e[r] = o ? 1 : 0 : e[r] = o;
2301
+ typeof o == "object" && o !== null && !Array.isArray(o) ? yt(o, r, e) : typeof o == "boolean" ? e[r] = o ? 1 : 0 : e[r] = o;
2320
2302
  }
2321
2303
  return e;
2322
2304
  }
@@ -2356,7 +2338,7 @@ function Kr(n) {
2356
2338
  font_url: c,
2357
2339
  ...d
2358
2340
  } = e;
2359
- return z({
2341
+ return T({
2360
2342
  ...d,
2361
2343
  colors: {
2362
2344
  primary: r,
@@ -2371,7 +2353,7 @@ function Kr(n) {
2371
2353
  });
2372
2354
  },
2373
2355
  async set(i, e) {
2374
- var _, u, c, d, m, f, y, N;
2356
+ var _, u, c, d, h, f, y, N;
2375
2357
  const { colors: t, font: r, ...o } = e, l = {
2376
2358
  ...o,
2377
2359
  tenant_id: i,
@@ -2387,7 +2369,7 @@ function Kr(n) {
2387
2369
  set: {
2388
2370
  ...o,
2389
2371
  colors_primary: t == null ? void 0 : t.primary,
2390
- colors_page_background_type: (m = t == null ? void 0 : t.page_background) == null ? void 0 : m.type,
2372
+ colors_page_background_type: (h = t == null ? void 0 : t.page_background) == null ? void 0 : h.type,
2391
2373
  colors_page_background_start: (f = t == null ? void 0 : t.page_background) == null ? void 0 : f.start,
2392
2374
  colors_page_background_end: (y = t == null ? void 0 : t.page_background) == null ? void 0 : y.end,
2393
2375
  colors_page_background_angle_dev: (N = t == null ? void 0 : t.page_background) == null ? void 0 : N.angle_deg,
@@ -2405,8 +2387,8 @@ var be = class extends Error {
2405
2387
  */
2406
2388
  constructor(i = 500, e) {
2407
2389
  super(e == null ? void 0 : e.message, { cause: e == null ? void 0 : e.cause });
2408
- h(this, "res");
2409
- h(this, "status");
2390
+ p(this, "res");
2391
+ p(this, "status");
2410
2392
  this.res = e == null ? void 0 : e.res, this.status = i;
2411
2393
  }
2412
2394
  /**
@@ -2423,16 +2405,16 @@ var be = class extends Error {
2423
2405
  });
2424
2406
  }
2425
2407
  };
2426
- function pe(n, i, e) {
2408
+ function ye(n, i, e) {
2427
2409
  const t = i.split(/ OR /i);
2428
2410
  if (t.length > 1) {
2429
2411
  const c = t.map((d) => {
2430
- const m = d.trim().match(/^([^:]+):(.+)$/);
2431
- if (m) {
2432
- const [, f, y] = m;
2412
+ const h = d.trim().match(/^([^:]+):(.+)$/);
2413
+ if (h) {
2414
+ const [, f, y] = h;
2433
2415
  if (!f || !y) return null;
2434
- const N = y.replace(/^"(.*)"$/, "$1"), A = n[f.trim()];
2435
- return A ? a(A, N.trim()) : null;
2416
+ const N = y.replace(/^"(.*)"$/, "$1"), B = n[f.trim()];
2417
+ return B ? a(B, N.trim()) : null;
2436
2418
  }
2437
2419
  return null;
2438
2420
  }).filter(Boolean);
@@ -2446,32 +2428,32 @@ function pe(n, i, e) {
2446
2428
  }
2447
2429
  o.trim() && r.push(o.trim());
2448
2430
  const _ = r.map((c) => c.replace(/^([^:]+)=/g, "$1:")).map((c) => {
2449
- let d = c.startsWith("-"), m = null, f = "", y = !1, N;
2431
+ let d = c.startsWith("-"), h = null, f = "", y = !1, N;
2450
2432
  if (c.startsWith("-_exists_:"))
2451
- m = c.substring(10), y = !0, d = !0;
2433
+ h = c.substring(10), y = !0, d = !0;
2452
2434
  else if (c.startsWith("_exists_:"))
2453
- m = c.substring(9), y = !0, d = !1;
2435
+ h = c.substring(9), y = !0, d = !1;
2454
2436
  else if (c.includes(":")) {
2455
- const A = d ? c.substring(1) : c, W = A.indexOf(":");
2456
- m = A.substring(0, W), f = A.substring(W + 1), y = !1, f.startsWith(">=") ? (N = ">=", f = f.substring(2)) : f.startsWith(">") ? (N = ">", f = f.substring(1)) : f.startsWith("<=") ? (N = "<=", f = f.substring(2)) : f.startsWith("<") ? (N = "<", f = f.substring(1)) : N = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
2437
+ const B = d ? c.substring(1) : c, W = B.indexOf(":");
2438
+ h = B.substring(0, W), f = B.substring(W + 1), y = !1, f.startsWith(">=") ? (N = ">=", f = f.substring(2)) : f.startsWith(">") ? (N = ">", f = f.substring(1)) : f.startsWith("<=") ? (N = "<=", f = f.substring(2)) : f.startsWith("<") ? (N = "<", f = f.substring(1)) : N = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
2457
2439
  } else
2458
- m = null, f = c, y = !1;
2459
- return { key: m, value: f, isNegation: d, isExistsQuery: y, operator: N };
2440
+ h = null, f = c, y = !1;
2441
+ return { key: h, value: f, isNegation: d, isExistsQuery: y, operator: N };
2460
2442
  }), u = [];
2461
- for (const { key: c, value: d, isNegation: m, isExistsQuery: f, operator: y } of _)
2443
+ for (const { key: c, value: d, isNegation: h, isExistsQuery: f, operator: y } of _)
2462
2444
  if (c) {
2463
2445
  const N = n[c];
2464
2446
  if (!N) {
2465
2447
  f ? u.push(
2466
- m ? w`${w.identifier(c)} IS NULL` : w`${w.identifier(c)} IS NOT NULL`
2448
+ h ? w`${w.identifier(c)} IS NULL` : w`${w.identifier(c)} IS NOT NULL`
2467
2449
  ) : u.push(
2468
- w`${w.identifier(c)} ${w.raw(m ? "!=" : y ?? "=")} ${d}`
2450
+ w`${w.identifier(c)} ${w.raw(h ? "!=" : y ?? "=")} ${d}`
2469
2451
  );
2470
2452
  continue;
2471
2453
  }
2472
2454
  if (f)
2473
- u.push(m ? ye(N) : Ve(N));
2474
- else if (m)
2455
+ u.push(h ? me(N) : Me(N));
2456
+ else if (h)
2475
2457
  switch (y) {
2476
2458
  case ">":
2477
2459
  u.push(Oe(N, d));
@@ -2480,10 +2462,10 @@ function pe(n, i, e) {
2480
2462
  u.push(we(N, d));
2481
2463
  break;
2482
2464
  case "<":
2483
- u.push(Ge(N, d));
2465
+ u.push(He(N, d));
2484
2466
  break;
2485
2467
  case "<=":
2486
- u.push(He(N, d));
2468
+ u.push(We(N, d));
2487
2469
  break;
2488
2470
  default:
2489
2471
  u.push(kr(N, d));
@@ -2491,10 +2473,10 @@ function pe(n, i, e) {
2491
2473
  else
2492
2474
  switch (y) {
2493
2475
  case ">":
2494
- u.push(He(N, d));
2476
+ u.push(We(N, d));
2495
2477
  break;
2496
2478
  case ">=":
2497
- u.push(Ge(N, d));
2479
+ u.push(He(N, d));
2498
2480
  break;
2499
2481
  case "<":
2500
2482
  u.push(we(N, d));
@@ -2506,11 +2488,11 @@ function pe(n, i, e) {
2506
2488
  u.push(a(N, d));
2507
2489
  }
2508
2490
  } else if (d) {
2509
- const A = (d.includes("|") ? [...e, "user_id"] : e).map((W) => {
2491
+ const B = (d.includes("|") ? [...e, "user_id"] : e).map((W) => {
2510
2492
  const H = n[W];
2511
2493
  return H ? W === "user_id" ? a(H, d) : Ie(H, `%${d}%`) : null;
2512
2494
  }).filter(Boolean);
2513
- A.length > 0 && u.push(de(...A));
2495
+ B.length > 0 && u.push(de(...B));
2514
2496
  }
2515
2497
  if (u.length !== 0)
2516
2498
  return u.length === 1 ? u[0] : g(...u);
@@ -2550,7 +2532,7 @@ const kt = [
2550
2532
  "signed_request_object",
2551
2533
  "token_quota"
2552
2534
  ];
2553
- function Ue(n) {
2535
+ function Fe(n) {
2554
2536
  const { tenant_id: i, connections: e, ...t } = n, r = { ...t };
2555
2537
  for (const o of kt)
2556
2538
  r[o] = !!t[o];
@@ -2558,7 +2540,7 @@ function Ue(n) {
2558
2540
  r[o] = x(t[o], []);
2559
2541
  for (const o of zt)
2560
2542
  r[o] = x(t[o], {});
2561
- return r.connections = x(e, []), z(r);
2543
+ return r.connections = x(e, []), T(r);
2562
2544
  }
2563
2545
  function Ct(n) {
2564
2546
  const i = { ...n };
@@ -2614,7 +2596,7 @@ function jr(n) {
2614
2596
  message: "Client already exists"
2615
2597
  }) : u;
2616
2598
  }
2617
- return Ue({ ...o, tenant_id: i });
2599
+ return Fe({ ...o, tenant_id: i });
2618
2600
  },
2619
2601
  async get(i, e) {
2620
2602
  const t = await n.select().from(I).where(
@@ -2623,12 +2605,12 @@ function jr(n) {
2623
2605
  a(I.client_id, e)
2624
2606
  )
2625
2607
  ).get();
2626
- return t ? Ue(t) : null;
2608
+ return t ? Fe(t) : null;
2627
2609
  },
2628
2610
  async getByClientId(i) {
2629
2611
  const e = await n.select().from(I).where(a(I.client_id, i)).get();
2630
2612
  return e ? {
2631
- ...Ue(e),
2613
+ ...Fe(e),
2632
2614
  tenant_id: e.tenant_id
2633
2615
  } : null;
2634
2616
  },
@@ -2654,7 +2636,7 @@ function jr(n) {
2654
2636
  } = e || {};
2655
2637
  let u = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
2656
2638
  if (_) {
2657
- const f = pe(I, _, ["name", "client_id"]);
2639
+ const f = ye(I, _, ["name", "client_id"]);
2658
2640
  f && (u = u.where(g(a(I.tenant_id, i), f)));
2659
2641
  }
2660
2642
  if (l != null && l.sort_by) {
@@ -2663,15 +2645,15 @@ function jr(n) {
2663
2645
  l.sort_order === "desc" ? V(f) : G(f)
2664
2646
  ));
2665
2647
  }
2666
- const d = (await u.offset(t * r).limit(r)).map(Ue);
2648
+ const d = (await u.offset(t * r).limit(r)).map(Fe);
2667
2649
  if (!o)
2668
2650
  return { clients: d };
2669
- const [m] = await n.select({ count: R() }).from(I).where(a(I.tenant_id, i));
2651
+ const [h] = await n.select({ count: R() }).from(I).where(a(I.tenant_id, i));
2670
2652
  return {
2671
2653
  clients: d,
2672
2654
  start: t * r,
2673
2655
  limit: r,
2674
- length: Number((m == null ? void 0 : m.count) ?? 0)
2656
+ length: Number((h == null ? void 0 : h.count) ?? 0)
2675
2657
  };
2676
2658
  },
2677
2659
  async remove(i, e) {
@@ -2686,7 +2668,7 @@ function jr(n) {
2686
2668
  }
2687
2669
  function Mr(n) {
2688
2670
  const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
2689
- return z({
2671
+ return T({
2690
2672
  ...o,
2691
2673
  options: x(t, {}),
2692
2674
  metadata: x(r),
@@ -2705,10 +2687,10 @@ function Vr(n) {
2705
2687
  if (!t) return [];
2706
2688
  const r = x(t.connections, []) || [];
2707
2689
  if (r.length === 0) return [];
2708
- const l = (await n.select().from(K).where(
2690
+ const l = (await n.select().from(j).where(
2709
2691
  g(
2710
- a(K.tenant_id, i),
2711
- Ne(K.id, r)
2692
+ a(j.tenant_id, i),
2693
+ Ne(j.id, r)
2712
2694
  )
2713
2695
  ).all()).map(Mr);
2714
2696
  return r.map((_) => l.find((u) => u.id === _)).filter(Boolean);
@@ -2792,7 +2774,7 @@ let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr
2792
2774
  i += Rr[e[n] & 63];
2793
2775
  return i;
2794
2776
  };
2795
- function nt(n) {
2777
+ function tt(n) {
2796
2778
  const {
2797
2779
  tenant_id: i,
2798
2780
  scope: e,
@@ -2801,7 +2783,7 @@ function nt(n) {
2801
2783
  is_system: o,
2802
2784
  ...l
2803
2785
  } = n;
2804
- return z({
2786
+ return T({
2805
2787
  ...l,
2806
2788
  scope: x(e, []),
2807
2789
  authorization_details_types: x(
@@ -2831,13 +2813,13 @@ function Yr(n) {
2831
2813
  created_at: t,
2832
2814
  updated_at: t
2833
2815
  };
2834
- return await n.insert(Y).values(o), nt({ ...o, tenant_id: i });
2816
+ return await n.insert(Y).values(o), tt({ ...o, tenant_id: i });
2835
2817
  },
2836
2818
  async get(i, e) {
2837
2819
  const t = await n.select().from(Y).where(
2838
2820
  g(a(Y.tenant_id, i), a(Y.id, e))
2839
2821
  ).get();
2840
- return t ? nt(t) : null;
2822
+ return t ? tt(t) : null;
2841
2823
  },
2842
2824
  async update(i, e, t) {
2843
2825
  const {
@@ -2863,7 +2845,7 @@ function Yr(n) {
2863
2845
  include_totals: o = !1,
2864
2846
  sort: l,
2865
2847
  q: _
2866
- } = e || {}, u = _ ? pe(Y, _, ["client_id", "audience"]) : void 0, c = u ? g(a(Y.tenant_id, i), u) : a(Y.tenant_id, i);
2848
+ } = e || {}, u = _ ? ye(Y, _, ["client_id", "audience"]) : void 0, c = u ? g(a(Y.tenant_id, i), u) : a(Y.tenant_id, i);
2867
2849
  let d = n.select().from(Y).where(c).$dynamic();
2868
2850
  if (l != null && l.sort_by) {
2869
2851
  const N = Y[l.sort_by];
@@ -2872,7 +2854,7 @@ function Yr(n) {
2872
2854
  ));
2873
2855
  } else
2874
2856
  d = d.orderBy(G(Y.created_at));
2875
- const f = (await d.offset(t * r).limit(r)).map(nt);
2857
+ const f = (await d.offset(t * r).limit(r)).map(tt);
2876
2858
  if (!o)
2877
2859
  return { client_grants: f };
2878
2860
  const [y] = await n.select({ count: R() }).from(Y).where(c);
@@ -2890,9 +2872,9 @@ function Yr(n) {
2890
2872
  }
2891
2873
  };
2892
2874
  }
2893
- function it(n) {
2875
+ function nt(n) {
2894
2876
  const { tenant_id: i, ...e } = n;
2895
- return z(e);
2877
+ return T(e);
2896
2878
  }
2897
2879
  function Xr(n) {
2898
2880
  return {
@@ -2903,19 +2885,19 @@ function Xr(n) {
2903
2885
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
2904
2886
  expires_at: e.expires_at
2905
2887
  };
2906
- return await n.insert(P).values(t), it(t);
2888
+ return await n.insert(J).values(t), nt(t);
2907
2889
  },
2908
2890
  async get(i, e, t) {
2909
2891
  if (!i)
2910
2892
  throw new Error("tenant_id is required");
2911
- const r = await n.select().from(P).where(
2893
+ const r = await n.select().from(J).where(
2912
2894
  g(
2913
- a(P.tenant_id, i),
2914
- a(P.code_id, e),
2915
- a(P.code_type, t)
2895
+ a(J.tenant_id, i),
2896
+ a(J.code_id, e),
2897
+ a(J.code_type, t)
2916
2898
  )
2917
2899
  ).get();
2918
- return r ? it(r) : null;
2900
+ return r ? nt(r) : null;
2919
2901
  },
2920
2902
  async list(i, e) {
2921
2903
  const {
@@ -2924,17 +2906,17 @@ function Xr(n) {
2924
2906
  include_totals: o = !1,
2925
2907
  sort: l
2926
2908
  } = e || {};
2927
- let _ = n.select().from(P).where(a(P.tenant_id, i)).$dynamic();
2909
+ let _ = n.select().from(J).where(a(J.tenant_id, i)).$dynamic();
2928
2910
  if (l != null && l.sort_by) {
2929
- const m = P[l.sort_by];
2930
- m && (_ = _.orderBy(
2931
- l.sort_order === "desc" ? V(m) : G(m)
2911
+ const h = J[l.sort_by];
2912
+ h && (_ = _.orderBy(
2913
+ l.sort_order === "desc" ? V(h) : G(h)
2932
2914
  ));
2933
2915
  }
2934
- const c = (await _.offset(t * r).limit(r)).map(it);
2916
+ const c = (await _.offset(t * r).limit(r)).map(nt);
2935
2917
  if (!o)
2936
2918
  return { codes: c };
2937
- const [d] = await n.select({ count: R() }).from(P).where(a(P.tenant_id, i));
2919
+ const [d] = await n.select({ count: R() }).from(J).where(a(J.tenant_id, i));
2938
2920
  return {
2939
2921
  codes: c,
2940
2922
  start: t * r,
@@ -2943,19 +2925,19 @@ function Xr(n) {
2943
2925
  };
2944
2926
  },
2945
2927
  async used(i, e) {
2946
- return (await n.update(P).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(g(a(P.tenant_id, i), a(P.code_id, e))).returning()).length > 0;
2928
+ return (await n.update(J).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(g(a(J.tenant_id, i), a(J.code_id, e))).returning()).length > 0;
2947
2929
  },
2948
2930
  async consume(i, e) {
2949
- return (await n.update(P).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
2931
+ return (await n.update(J).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
2950
2932
  g(
2951
- a(P.tenant_id, i),
2952
- a(P.code_id, e),
2953
- ye(P.used_at)
2933
+ a(J.tenant_id, i),
2934
+ a(J.code_id, e),
2935
+ me(J.used_at)
2954
2936
  )
2955
2937
  ).returning()).length > 0;
2956
2938
  },
2957
2939
  async remove(i, e) {
2958
- return (await n.delete(P).where(g(a(P.tenant_id, i), a(P.code_id, e))).returning()).length > 0;
2940
+ return (await n.delete(J).where(g(a(J.tenant_id, i), a(J.code_id, e))).returning()).length > 0;
2959
2941
  }
2960
2942
  };
2961
2943
  }
@@ -2963,9 +2945,9 @@ function Zr() {
2963
2945
  const { customAlphabet: n } = require("nanoid");
2964
2946
  return `con_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
2965
2947
  }
2966
- function rt(n) {
2948
+ function it(n) {
2967
2949
  const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
2968
- return z({
2950
+ return T({
2969
2951
  ...o,
2970
2952
  options: x(t, {}),
2971
2953
  metadata: x(r),
@@ -2987,31 +2969,31 @@ function es(n) {
2987
2969
  updated_at: t
2988
2970
  };
2989
2971
  try {
2990
- await n.insert(K).values(r);
2972
+ await n.insert(j).values(r);
2991
2973
  } catch (_) {
2992
2974
  throw (o = _ == null ? void 0 : _.message) != null && o.includes("UNIQUE constraint failed") || (l = _ == null ? void 0 : _.message) != null && l.includes("duplicate key") ? new be(409, {
2993
2975
  message: "Connection already exists"
2994
2976
  }) : _;
2995
2977
  }
2996
- return rt(r);
2978
+ return it(r);
2997
2979
  },
2998
2980
  async get(i, e) {
2999
- const t = await n.select().from(K).where(
2981
+ const t = await n.select().from(j).where(
3000
2982
  g(
3001
- a(K.tenant_id, i),
3002
- a(K.id, e)
2983
+ a(j.tenant_id, i),
2984
+ a(j.id, e)
3003
2985
  )
3004
2986
  ).get();
3005
- return t ? rt(t) : null;
2987
+ return t ? it(t) : null;
3006
2988
  },
3007
2989
  async update(i, e, t) {
3008
2990
  const r = {
3009
2991
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3010
2992
  };
3011
- return t.name !== void 0 && (r.name = t.name), t.strategy !== void 0 && (r.strategy = t.strategy), t.options !== void 0 && (r.options = JSON.stringify(t.options)), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.display_name !== void 0 && (r.display_name = t.display_name), t.response_type !== void 0 && (r.response_type = t.response_type), t.response_mode !== void 0 && (r.response_mode = t.response_mode), await n.update(K).set(r).where(
2993
+ return t.name !== void 0 && (r.name = t.name), t.strategy !== void 0 && (r.strategy = t.strategy), t.options !== void 0 && (r.options = JSON.stringify(t.options)), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.display_name !== void 0 && (r.display_name = t.display_name), t.response_type !== void 0 && (r.response_type = t.response_type), t.response_mode !== void 0 && (r.response_mode = t.response_mode), await n.update(j).set(r).where(
3012
2994
  g(
3013
- a(K.tenant_id, i),
3014
- a(K.id, e)
2995
+ a(j.tenant_id, i),
2996
+ a(j.id, e)
3015
2997
  )
3016
2998
  ), !0;
3017
2999
  },
@@ -3023,42 +3005,42 @@ function es(n) {
3023
3005
  sort: l,
3024
3006
  q: _
3025
3007
  } = e || {};
3026
- let u = a(K.tenant_id, i);
3008
+ let u = a(j.tenant_id, i);
3027
3009
  if (_) {
3028
- const y = pe(K, _, ["name"]);
3010
+ const y = ye(j, _, ["name"]);
3029
3011
  y && (u = g(u, y));
3030
3012
  }
3031
- let c = n.select().from(K).where(u).$dynamic();
3013
+ let c = n.select().from(j).where(u).$dynamic();
3032
3014
  if (l != null && l.sort_by) {
3033
- const y = K[l.sort_by];
3015
+ const y = j[l.sort_by];
3034
3016
  y && (c = c.orderBy(
3035
3017
  l.sort_order === "desc" ? V(y) : G(y)
3036
3018
  ));
3037
3019
  }
3038
- const m = (await c.offset(t * r).limit(r)).map(rt);
3020
+ const h = (await c.offset(t * r).limit(r)).map(it);
3039
3021
  if (!o)
3040
- return { connections: m };
3041
- const [f] = await n.select({ count: R() }).from(K).where(u);
3022
+ return { connections: h };
3023
+ const [f] = await n.select({ count: R() }).from(j).where(u);
3042
3024
  return {
3043
- connections: m,
3025
+ connections: h,
3044
3026
  start: t * r,
3045
3027
  limit: r,
3046
3028
  length: Number((f == null ? void 0 : f.count) ?? 0)
3047
3029
  };
3048
3030
  },
3049
3031
  async remove(i, e) {
3050
- return (await n.delete(K).where(
3032
+ return (await n.delete(j).where(
3051
3033
  g(
3052
- a(K.tenant_id, i),
3053
- a(K.id, e)
3034
+ a(j.tenant_id, i),
3035
+ a(j.id, e)
3054
3036
  )
3055
3037
  ).returning()).length > 0;
3056
3038
  }
3057
3039
  };
3058
3040
  }
3059
- function Ke(n) {
3041
+ function Ue(n) {
3060
3042
  const { tenant_id: i, domain_metadata: e, ...t } = n;
3061
- return z({
3043
+ return T({
3062
3044
  ...t,
3063
3045
  primary: !!t.primary,
3064
3046
  domain_metadata: x(e)
@@ -3082,7 +3064,7 @@ function ts(n) {
3082
3064
  created_at: t,
3083
3065
  updated_at: t
3084
3066
  };
3085
- return await n.insert(se).values(o), Ke({ ...o, tenant_id: i });
3067
+ return await n.insert(se).values(o), Ue({ ...o, tenant_id: i });
3086
3068
  },
3087
3069
  async get(i, e) {
3088
3070
  const t = await n.select().from(se).where(
@@ -3091,17 +3073,17 @@ function ts(n) {
3091
3073
  a(se.custom_domain_id, e)
3092
3074
  )
3093
3075
  ).get();
3094
- return t ? Ke(t) : null;
3076
+ return t ? Ue(t) : null;
3095
3077
  },
3096
3078
  async getByDomain(i) {
3097
3079
  const e = await n.select().from(se).where(a(se.domain, i)).get();
3098
3080
  return e ? {
3099
- ...Ke(e),
3081
+ ...Ue(e),
3100
3082
  tenant_id: e.tenant_id
3101
3083
  } : null;
3102
3084
  },
3103
3085
  async list(i) {
3104
- return (await n.select().from(se).where(a(se.tenant_id, i)).all()).map(Ke);
3086
+ return (await n.select().from(se).where(a(se.tenant_id, i)).all()).map(Ue);
3105
3087
  },
3106
3088
  async update(i, e, t) {
3107
3089
  const r = {
@@ -3195,7 +3177,7 @@ function is(n) {
3195
3177
  const e = await n.select().from(Se).where(a(Se.tenant_id, i)).get();
3196
3178
  if (!e) return null;
3197
3179
  const { tenant_id: t, ...r } = e;
3198
- return z({
3180
+ return T({
3199
3181
  ...r,
3200
3182
  enabled: !!r.enabled,
3201
3183
  credentials: x(r.credentials, {}),
@@ -3236,7 +3218,7 @@ function rs(n) {
3236
3218
  const t = await n.select().from(re).where(g(a(re.tenant_id, i), a(re.id, e))).get();
3237
3219
  if (!t) return null;
3238
3220
  const { tenant_id: r, actions: o, ...l } = t;
3239
- return z({
3221
+ return T({
3240
3222
  ...l,
3241
3223
  actions: x(o, [])
3242
3224
  });
@@ -3256,14 +3238,14 @@ function rs(n) {
3256
3238
  } = e || {};
3257
3239
  let _ = n.select().from(re).where(a(re.tenant_id, i)).$dynamic();
3258
3240
  if (l != null && l.sort_by) {
3259
- const m = re[l.sort_by];
3260
- m && (_ = _.orderBy(
3261
- l.sort_order === "desc" ? V(m) : G(m)
3241
+ const h = re[l.sort_by];
3242
+ h && (_ = _.orderBy(
3243
+ l.sort_order === "desc" ? V(h) : G(h)
3262
3244
  ));
3263
3245
  }
3264
- const c = (await _.offset(t * r).limit(r)).map((m) => {
3265
- const { tenant_id: f, actions: y, ...N } = m;
3266
- return z({
3246
+ const c = (await _.offset(t * r).limit(r)).map((h) => {
3247
+ const { tenant_id: f, actions: y, ...N } = h;
3248
+ return T({
3267
3249
  ...N,
3268
3250
  actions: x(y, [])
3269
3251
  });
@@ -3283,7 +3265,7 @@ function rs(n) {
3283
3265
  }
3284
3266
  };
3285
3267
  }
3286
- const je = ["nodes", "start", "ending"];
3268
+ const Ke = ["nodes", "start", "ending"];
3287
3269
  function ss(n) {
3288
3270
  return {
3289
3271
  async create(i, e) {
@@ -3298,7 +3280,7 @@ function ss(n) {
3298
3280
  created_at: t,
3299
3281
  updated_at: t
3300
3282
  };
3301
- for (const l of je)
3283
+ for (const l of Ke)
3302
3284
  o[l] = JSON.stringify(
3303
3285
  e[l] || (l === "nodes" ? [] : {})
3304
3286
  );
@@ -3313,16 +3295,16 @@ function ss(n) {
3313
3295
  const t = await n.select().from(ie).where(g(a(ie.tenant_id, i), a(ie.id, e))).get();
3314
3296
  if (!t) return null;
3315
3297
  const { tenant_id: r, ...o } = t, l = { ...o };
3316
- for (const _ of je)
3298
+ for (const _ of Ke)
3317
3299
  l[_] = x(o[_]);
3318
- return z(l);
3300
+ return T(l);
3319
3301
  },
3320
3302
  async update(i, e, t) {
3321
3303
  const r = {
3322
3304
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
3323
3305
  };
3324
3306
  for (const [l, _] of Object.entries(t))
3325
- _ !== void 0 && (je.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
3307
+ _ !== void 0 && (Ke.includes(l) ? r[l] = JSON.stringify(_) : r[l] = _);
3326
3308
  return (await n.update(ie).set(r).where(g(a(ie.tenant_id, i), a(ie.id, e))).returning()).length > 0;
3327
3309
  },
3328
3310
  async list(i, e) {
@@ -3334,16 +3316,16 @@ function ss(n) {
3334
3316
  } = e || {};
3335
3317
  let _ = n.select().from(ie).where(a(ie.tenant_id, i)).$dynamic();
3336
3318
  if (l != null && l.sort_by) {
3337
- const m = ie[l.sort_by];
3338
- m && (_ = _.orderBy(
3339
- l.sort_order === "desc" ? V(m) : G(m)
3319
+ const h = ie[l.sort_by];
3320
+ h && (_ = _.orderBy(
3321
+ l.sort_order === "desc" ? V(h) : G(h)
3340
3322
  ));
3341
3323
  }
3342
- const c = (await _.offset(t * r).limit(r)).map((m) => {
3343
- const { tenant_id: f, ...y } = m, N = { ...y };
3344
- for (const A of je)
3345
- N[A] = x(y[A]);
3346
- return z(N);
3324
+ const c = (await _.offset(t * r).limit(r)).map((h) => {
3325
+ const { tenant_id: f, ...y } = h, N = { ...y };
3326
+ for (const B of Ke)
3327
+ N[B] = x(y[B]);
3328
+ return T(N);
3347
3329
  });
3348
3330
  if (!o)
3349
3331
  return { forms: c };
@@ -3360,7 +3342,7 @@ function ss(n) {
3360
3342
  }
3361
3343
  };
3362
3344
  }
3363
- function hr(n) {
3345
+ function pr(n) {
3364
3346
  if (n != null) {
3365
3347
  if (typeof n == "number")
3366
3348
  return new Date(n).toISOString();
@@ -3373,15 +3355,15 @@ function hr(n) {
3373
3355
  }
3374
3356
  }
3375
3357
  function wt(n, i = (/* @__PURE__ */ new Date(0)).toISOString()) {
3376
- return hr(n) ?? i;
3358
+ return pr(n) ?? i;
3377
3359
  }
3378
- function j(n) {
3360
+ function Q(n) {
3379
3361
  if (!n || n === "")
3380
3362
  return null;
3381
3363
  const i = new Date(n);
3382
3364
  return isNaN(i.getTime()) ? null : i.getTime();
3383
3365
  }
3384
- function Fe(n, i, e = []) {
3366
+ function Pe(n, i, e = []) {
3385
3367
  const t = {};
3386
3368
  for (const r of i) {
3387
3369
  const o = r.replace(/_ts$/, "");
@@ -3389,7 +3371,7 @@ function Fe(n, i, e = []) {
3389
3371
  }
3390
3372
  for (const r of e) {
3391
3373
  const o = r.replace(/_ts$/, "");
3392
- t[o] = hr(n[r]);
3374
+ t[o] = pr(n[r]);
3393
3375
  }
3394
3376
  return t;
3395
3377
  }
@@ -3398,7 +3380,7 @@ function as() {
3398
3380
  return `hc_${os()}`;
3399
3381
  }
3400
3382
  function At(n) {
3401
- const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Fe({ created_at_ts: i, updated_at_ts: e }, [
3383
+ const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Pe({ created_at_ts: i, updated_at_ts: e }, [
3402
3384
  "created_at_ts",
3403
3385
  "updated_at_ts"
3404
3386
  ]);
@@ -3419,20 +3401,20 @@ function ls(n) {
3419
3401
  created_at_ts: t,
3420
3402
  updated_at_ts: t
3421
3403
  };
3422
- return await n.insert(he).values(o), At({ ...o, tenant_id: i });
3404
+ return await n.insert(pe).values(o), At({ ...o, tenant_id: i });
3423
3405
  },
3424
3406
  async get(i, e) {
3425
- const t = await n.select().from(he).where(g(a(he.tenant_id, i), a(he.id, e))).get();
3407
+ const t = await n.select().from(pe).where(g(a(pe.tenant_id, i), a(pe.id, e))).get();
3426
3408
  return t ? At(t) : null;
3427
3409
  },
3428
3410
  async update(i, e, t) {
3429
3411
  const r = {
3430
3412
  updated_at_ts: Date.now()
3431
3413
  };
3432
- return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(he).set(r).where(g(a(he.tenant_id, i), a(he.id, e))).returning()).length > 0;
3414
+ return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(pe).set(r).where(g(a(pe.tenant_id, i), a(pe.id, e))).returning()).length > 0;
3433
3415
  },
3434
3416
  async remove(i, e) {
3435
- return (await n.delete(he).where(g(a(he.tenant_id, i), a(he.id, e))).returning()).length > 0;
3417
+ return (await n.delete(pe).where(g(a(pe.tenant_id, i), a(pe.id, e))).returning()).length > 0;
3436
3418
  }
3437
3419
  };
3438
3420
  }
@@ -3440,12 +3422,12 @@ function _s() {
3440
3422
  const { customAlphabet: n } = require("nanoid");
3441
3423
  return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3442
3424
  }
3443
- function st(n) {
3444
- const { tenant_id: i, created_at_ts: e, updated_at_ts: t, ...r } = n, o = Fe({ created_at_ts: e, updated_at_ts: t }, [
3425
+ function rt(n) {
3426
+ const { tenant_id: i, created_at_ts: e, updated_at_ts: t, ...r } = n, o = Pe({ created_at_ts: e, updated_at_ts: t }, [
3445
3427
  "created_at_ts",
3446
3428
  "updated_at_ts"
3447
3429
  ]);
3448
- return z({
3430
+ return T({
3449
3431
  ...r,
3450
3432
  enabled: !!r.enabled,
3451
3433
  synchronous: !!r.synchronous,
@@ -3469,11 +3451,11 @@ function us(n) {
3469
3451
  created_at_ts: t,
3470
3452
  updated_at_ts: t
3471
3453
  };
3472
- return await n.insert(ee).values(o), st({ ...o, tenant_id: i });
3454
+ return await n.insert(ee).values(o), rt({ ...o, tenant_id: i });
3473
3455
  },
3474
3456
  async get(i, e) {
3475
3457
  const t = await n.select().from(ee).where(g(a(ee.tenant_id, i), a(ee.hook_id, e))).get();
3476
- return t ? st(t) : null;
3458
+ return t ? rt(t) : null;
3477
3459
  },
3478
3460
  async update(i, e, t) {
3479
3461
  const r = {
@@ -3488,7 +3470,7 @@ function us(n) {
3488
3470
  include_totals: o = !1,
3489
3471
  sort: l,
3490
3472
  q: _
3491
- } = e || {}, u = _ ? pe(ee, _, [
3473
+ } = e || {}, u = _ ? ye(ee, _, [
3492
3474
  "url",
3493
3475
  "form_id",
3494
3476
  "template_id",
@@ -3501,7 +3483,7 @@ function us(n) {
3501
3483
  l.sort_order === "desc" ? V(N) : G(N)
3502
3484
  ));
3503
3485
  }
3504
- const f = (await d.offset(t * r).limit(r)).map(st);
3486
+ const f = (await d.offset(t * r).limit(r)).map(rt);
3505
3487
  if (!o)
3506
3488
  return { hooks: f };
3507
3489
  const [y] = await n.select({ count: R() }).from(ee).where(c);
@@ -3528,11 +3510,11 @@ const Nt = [
3528
3510
  "user_metadata",
3529
3511
  "roles"
3530
3512
  ];
3531
- function ot(n) {
3513
+ function st(n) {
3532
3514
  const { tenant_id: i, send_invitation_email: e, ...t } = n, r = { ...t };
3533
3515
  for (const o of Nt)
3534
3516
  r[o] = x(t[o], o === "roles" ? [] : {});
3535
- return r.send_invitation_email = !!e, z(r);
3517
+ return r.send_invitation_email = !!e, T(r);
3536
3518
  }
3537
3519
  function cs(n) {
3538
3520
  return {
@@ -3558,11 +3540,11 @@ function cs(n) {
3558
3540
  } catch (d) {
3559
3541
  throw (u = d == null ? void 0 : d.message) != null && u.includes("UNIQUE constraint failed") || (c = d == null ? void 0 : d.message) != null && c.includes("duplicate key") ? new be(409, { message: "Invite already exists" }) : d;
3560
3542
  }
3561
- return ot({ ..._, tenant_id: i });
3543
+ return st({ ..._, tenant_id: i });
3562
3544
  },
3563
3545
  async get(i, e) {
3564
3546
  const t = await n.select().from(ne).where(g(a(ne.tenant_id, i), a(ne.id, e))).get();
3565
- return t ? ot(t) : null;
3547
+ return t ? st(t) : null;
3566
3548
  },
3567
3549
  async update(i, e, t) {
3568
3550
  const r = {};
@@ -3581,12 +3563,12 @@ function cs(n) {
3581
3563
  } = e || {};
3582
3564
  let _ = n.select().from(ne).where(a(ne.tenant_id, i)).$dynamic();
3583
3565
  if (l != null && l.sort_by) {
3584
- const m = ne[l.sort_by];
3585
- m && (_ = _.orderBy(
3586
- l.sort_order === "desc" ? V(m) : G(m)
3566
+ const h = ne[l.sort_by];
3567
+ h && (_ = _.orderBy(
3568
+ l.sort_order === "desc" ? V(h) : G(h)
3587
3569
  ));
3588
3570
  }
3589
- const c = (await _.offset(t * r).limit(r)).map(ot);
3571
+ const c = (await _.offset(t * r).limit(r)).map(st);
3590
3572
  if (!o)
3591
3573
  return { invites: c };
3592
3574
  const [d] = await n.select({ count: R() }).from(ne).where(a(ne.tenant_id, i));
@@ -3605,7 +3587,7 @@ function cs(n) {
3605
3587
  function gs(n) {
3606
3588
  return {
3607
3589
  async create(i) {
3608
- await n.insert(me).values({
3590
+ await n.insert(he).values({
3609
3591
  ...i,
3610
3592
  created_at: (/* @__PURE__ */ new Date()).toDateString()
3611
3593
  });
@@ -3617,20 +3599,20 @@ function gs(n) {
3617
3599
  include_totals: r = !1,
3618
3600
  sort: o
3619
3601
  } = i || {}, l = (/* @__PURE__ */ new Date()).toISOString();
3620
- let _ = n.select().from(me).where(de(He(me.revoked_at, l), ye(me.revoked_at))).$dynamic();
3602
+ let _ = n.select().from(he).where(de(We(he.revoked_at, l), me(he.revoked_at))).$dynamic();
3621
3603
  if (o != null && o.sort_by) {
3622
- const m = me[o.sort_by];
3623
- m && (_ = _.orderBy(
3624
- o.sort_order === "desc" ? V(m) : G(m)
3604
+ const h = he[o.sort_by];
3605
+ h && (_ = _.orderBy(
3606
+ o.sort_order === "desc" ? V(h) : G(h)
3625
3607
  ));
3626
3608
  }
3627
- const c = (await _.offset(e * t).limit(t)).map((m) => {
3628
- const { created_at: f, ...y } = m;
3629
- return z(y);
3609
+ const c = (await _.offset(e * t).limit(t)).map((h) => {
3610
+ const { created_at: f, ...y } = h;
3611
+ return T(y);
3630
3612
  });
3631
3613
  if (!r)
3632
3614
  return { signingKeys: c };
3633
- const [d] = await n.select({ count: R() }).from(me).where(de(He(me.revoked_at, l), ye(me.revoked_at)));
3615
+ const [d] = await n.select({ count: R() }).from(he).where(de(We(he.revoked_at, l), me(he.revoked_at)));
3634
3616
  return {
3635
3617
  signingKeys: c,
3636
3618
  start: e * t,
@@ -3639,19 +3621,19 @@ function gs(n) {
3639
3621
  };
3640
3622
  },
3641
3623
  async update(i, e) {
3642
- return (await n.update(me).set(e).where(a(me.kid, i)).returning()).length > 0;
3624
+ return (await n.update(he).set(e).where(a(he.kid, i)).returning()).length > 0;
3643
3625
  }
3644
3626
  };
3645
3627
  }
3646
- const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", at = vt.length;
3628
+ const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ot = vt.length;
3647
3629
  function fs() {
3648
3630
  let e = Date.now(), t = "";
3649
3631
  for (let o = 10; o > 0; o--)
3650
- t = vt.charAt(e % at) + t, e = Math.floor(e / at);
3632
+ t = vt.charAt(e % ot) + t, e = Math.floor(e / ot);
3651
3633
  const r = new Uint8Array(16);
3652
3634
  crypto.getRandomValues(r);
3653
3635
  for (let o = 0; o < 16; o++)
3654
- t += vt.charAt(r[o] % at);
3636
+ t += vt.charAt(r[o] % ot);
3655
3637
  return t;
3656
3638
  }
3657
3639
  function Bt(n) {
@@ -3661,35 +3643,32 @@ function Bt(n) {
3661
3643
  updated_at_ts: t,
3662
3644
  expires_at_ts: r,
3663
3645
  state_data: o,
3664
- ...l
3665
- } = n, _ = Fe(
3646
+ auth_params: l,
3647
+ ..._
3648
+ } = n, u = Pe(
3666
3649
  { created_at_ts: e, updated_at_ts: t, expires_at_ts: r },
3667
3650
  ["created_at_ts", "updated_at_ts", "expires_at_ts"]
3668
- ), u = {};
3669
- for (const [d, m] of Object.entries(l))
3670
- m != null && (u[d] = m);
3671
- const c = fr(u, [
3672
- "authParams",
3673
- "auth_strategy"
3674
- ]);
3675
- return z({
3676
- ...c,
3677
- ..._,
3651
+ ), c = {};
3652
+ for (const [h, f] of Object.entries(_))
3653
+ f != null && (c[h] = f);
3654
+ const d = fr(c, ["auth_strategy"]);
3655
+ return T({
3656
+ ...d,
3657
+ authParams: typeof l == "string" && l.length > 0 ? JSON.parse(l) : {},
3658
+ ...u,
3678
3659
  state_data: x(o)
3679
3660
  });
3680
3661
  }
3681
- function hs(n) {
3662
+ function ps(n) {
3682
3663
  return {
3683
3664
  async create(i, e) {
3684
- var _, u;
3685
- const t = Date.now(), r = fs(), o = Pe(
3686
- { authParams: e.authParams || {} },
3687
- "authParams"
3688
- ), l = {
3689
- id: r,
3665
+ var l, _;
3666
+ const t = Date.now(), o = {
3667
+ id: fs(),
3690
3668
  tenant_id: i,
3691
3669
  session_id: e.session_id,
3692
3670
  csrf_token: e.csrf_token,
3671
+ auth_params: JSON.stringify(e.authParams || {}),
3693
3672
  authorization_url: e.authorization_url ? e.authorization_url.substring(0, 1024) : void 0,
3694
3673
  ip: e.ip,
3695
3674
  useragent: e.useragent,
@@ -3699,19 +3678,17 @@ function hs(n) {
3699
3678
  failure_reason: e.failure_reason,
3700
3679
  user_id: e.user_id,
3701
3680
  auth_connection: e.auth_connection,
3702
- auth_strategy_strategy: (_ = e.auth_strategy) == null ? void 0 : _.strategy,
3703
- auth_strategy_strategy_type: (u = e.auth_strategy) == null ? void 0 : u.strategy_type,
3681
+ auth_strategy_strategy: (l = e.auth_strategy) == null ? void 0 : l.strategy,
3682
+ auth_strategy_strategy_type: (_ = e.auth_strategy) == null ? void 0 : _.strategy_type,
3704
3683
  authenticated_at: e.authenticated_at,
3705
3684
  created_at_ts: t,
3706
3685
  updated_at_ts: t,
3707
- expires_at_ts: e.expires_at ? j(e.expires_at) : t + 1e3 * 60 * 60 * 24
3686
+ expires_at_ts: e.expires_at ? Q(e.expires_at) : t + 1e3 * 60 * 60 * 24
3708
3687
  };
3709
- for (const [c, d] of Object.entries(o))
3710
- l[c] = d;
3711
- return await n.insert(B).values(l), Bt({ ...l, tenant_id: i });
3688
+ return await n.insert(L).values(o), Bt({ ...o, tenant_id: i });
3712
3689
  },
3713
3690
  async get(i, e) {
3714
- const t = i ? g(a(B.tenant_id, i), a(B.id, e)) : a(B.id, e), r = await n.select().from(B).where(t).get();
3691
+ const t = i ? g(a(L.tenant_id, i), a(L.id, e)) : a(L.id, e), r = await n.select().from(L).where(t).get();
3715
3692
  return r ? Bt(r) : null;
3716
3693
  },
3717
3694
  async update(i, e, t) {
@@ -3722,25 +3699,30 @@ function hs(n) {
3722
3699
  if (t.session_id !== void 0 && (r.session_id = t.session_id), t.state !== void 0 && (r.state = t.state), t.state_data !== void 0 && (r.state_data = JSON.stringify(t.state_data)), t.failure_reason !== void 0 && (r.failure_reason = t.failure_reason), t.user_id !== void 0 && (r.user_id = t.user_id), t.auth_connection !== void 0 && (r.auth_connection = t.auth_connection), t.auth_strategy !== void 0 && (r.auth_strategy_strategy = (o = t.auth_strategy) == null ? void 0 : o.strategy, r.auth_strategy_strategy_type = (l = t.auth_strategy) == null ? void 0 : l.strategy_type), t.authenticated_at !== void 0 && (r.authenticated_at = t.authenticated_at), t.authorization_url !== void 0 && (r.authorization_url = (_ = t.authorization_url) == null ? void 0 : _.substring(
3723
3700
  0,
3724
3701
  1024
3725
- )), t.expires_at !== void 0 && (r.expires_at_ts = j(t.expires_at)), t.authParams) {
3726
- const u = Pe(
3727
- { authParams: t.authParams },
3728
- "authParams"
3729
- );
3730
- Object.assign(r, u);
3702
+ )), t.expires_at !== void 0 && (r.expires_at_ts = Q(t.expires_at)), t.authParams !== void 0) {
3703
+ const u = await n.select({ auth_params: L.auth_params }).from(L).where(
3704
+ g(
3705
+ a(L.tenant_id, i),
3706
+ a(L.id, e)
3707
+ )
3708
+ ).get(), c = u != null && u.auth_params && typeof u.auth_params == "string" && u.auth_params.length > 0 ? JSON.parse(u.auth_params) : {};
3709
+ r.auth_params = JSON.stringify({
3710
+ ...c,
3711
+ ...t.authParams
3712
+ });
3731
3713
  }
3732
- return await n.update(B).set(r).where(
3733
- g(a(B.tenant_id, i), a(B.id, e))
3714
+ return await n.update(L).set(r).where(
3715
+ g(a(L.tenant_id, i), a(L.id, e))
3734
3716
  ), !0;
3735
3717
  },
3736
3718
  async remove(i, e) {
3737
- return (await n.delete(B).where(
3738
- g(a(B.tenant_id, i), a(B.id, e))
3719
+ return (await n.delete(L).where(
3720
+ g(a(L.tenant_id, i), a(L.id, e))
3739
3721
  ).returning()).length > 0;
3740
3722
  }
3741
3723
  };
3742
3724
  }
3743
- function lt(n) {
3725
+ function at(n) {
3744
3726
  const {
3745
3727
  tenant_id: i,
3746
3728
  isMobile: e,
@@ -3752,25 +3734,25 @@ function lt(n) {
3752
3734
  longitude: u,
3753
3735
  time_zone: c,
3754
3736
  continent_code: d,
3755
- scope: m,
3737
+ scope: h,
3756
3738
  ...f
3757
3739
  } = n, y = {
3758
3740
  ...f,
3759
3741
  isMobile: !!e,
3760
3742
  auth0_client: x(t),
3761
3743
  details: x(r),
3762
- scope: m ? m.split(",") : void 0
3744
+ scope: h ? h.split(",") : void 0
3763
3745
  };
3764
- return o && (y.location_info = z({
3746
+ return o && (y.location_info = T({
3765
3747
  country_code: o,
3766
3748
  city_name: l,
3767
3749
  latitude: _,
3768
3750
  longitude: u,
3769
3751
  time_zone: c,
3770
3752
  continent_code: d
3771
- })), z(y);
3753
+ })), T(y);
3772
3754
  }
3773
- function ms(n) {
3755
+ function hs(n) {
3774
3756
  return {
3775
3757
  async create(i, e) {
3776
3758
  var o, l;
@@ -3797,7 +3779,7 @@ function ms(n) {
3797
3779
  hostname: e.hostname,
3798
3780
  session_connection: e.session_connection
3799
3781
  };
3800
- return e.auth0_client && (r.auth0_client = JSON.stringify(e.auth0_client)), e.details && (r.details = JSON.stringify(e.details).substring(0, 8192)), e.location_info && (r.country_code = e.location_info.country_code, r.city_name = e.location_info.city_name, r.latitude = e.location_info.latitude, r.longitude = e.location_info.longitude, r.time_zone = e.location_info.time_zone, r.continent_code = e.location_info.continent_code), await n.insert(q).values(r), lt({ ...r, tenant_id: i });
3782
+ return e.auth0_client && (r.auth0_client = JSON.stringify(e.auth0_client)), e.details && (r.details = JSON.stringify(e.details).substring(0, 8192)), e.location_info && (r.country_code = e.location_info.country_code, r.city_name = e.location_info.city_name, r.latitude = e.location_info.latitude, r.longitude = e.location_info.longitude, r.time_zone = e.location_info.time_zone, r.continent_code = e.location_info.continent_code), await n.insert(q).values(r), at({ ...r, tenant_id: i });
3801
3783
  },
3802
3784
  async list(i, e) {
3803
3785
  const {
@@ -3809,7 +3791,7 @@ function ms(n) {
3809
3791
  } = e || {};
3810
3792
  let u = n.select().from(q).where(a(q.tenant_id, i)).$dynamic();
3811
3793
  if (_) {
3812
- const f = pe(q, _, [
3794
+ const f = ye(q, _, [
3813
3795
  "user_id",
3814
3796
  "ip",
3815
3797
  "type",
@@ -3824,35 +3806,35 @@ function ms(n) {
3824
3806
  ));
3825
3807
  } else
3826
3808
  u = u.orderBy(V(q.date));
3827
- const d = (await u.offset(t * r).limit(r)).map(lt);
3809
+ const d = (await u.offset(t * r).limit(r)).map(at);
3828
3810
  if (!o)
3829
3811
  return { logs: d };
3830
- const [m] = await n.select({ count: R() }).from(q).where(a(q.tenant_id, i));
3812
+ const [h] = await n.select({ count: R() }).from(q).where(a(q.tenant_id, i));
3831
3813
  return {
3832
3814
  logs: d,
3833
3815
  start: t * r,
3834
3816
  limit: r,
3835
- length: Number((m == null ? void 0 : m.count) ?? 0)
3817
+ length: Number((h == null ? void 0 : h.count) ?? 0)
3836
3818
  };
3837
3819
  },
3838
3820
  async get(i, e) {
3839
3821
  const t = await n.select().from(q).where(g(a(q.tenant_id, i), a(q.log_id, e))).get();
3840
- return t ? lt(t) : null;
3822
+ return t ? at(t) : null;
3841
3823
  }
3842
3824
  };
3843
3825
  }
3844
- const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", _t = St.length;
3845
- function ps() {
3826
+ const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", lt = St.length;
3827
+ function ms() {
3846
3828
  let e = Date.now(), t = "";
3847
3829
  for (let o = 10; o > 0; o--)
3848
- t = St.charAt(e % _t) + t, e = Math.floor(e / _t);
3830
+ t = St.charAt(e % lt) + t, e = Math.floor(e / lt);
3849
3831
  const r = new Uint8Array(16);
3850
3832
  crypto.getRandomValues(r);
3851
3833
  for (let o = 0; o < 16; o++)
3852
- t += St.charAt(r[o] % _t);
3834
+ t += St.charAt(r[o] % lt);
3853
3835
  return t;
3854
3836
  }
3855
- function Me(n) {
3837
+ function je(n) {
3856
3838
  const {
3857
3839
  tenant_id: i,
3858
3840
  created_at_ts: e,
@@ -3862,7 +3844,7 @@ function Me(n) {
3862
3844
  transports: l,
3863
3845
  ..._
3864
3846
  } = n;
3865
- return z({
3847
+ return T({
3866
3848
  ..._,
3867
3849
  confirmed: !!o,
3868
3850
  credential_backed_up: r != null ? !!r : void 0,
@@ -3875,7 +3857,7 @@ function ys(n) {
3875
3857
  return {
3876
3858
  async create(i, e) {
3877
3859
  const t = Date.now(), o = {
3878
- id: e.id || ps(),
3860
+ id: e.id || ms(),
3879
3861
  tenant_id: i,
3880
3862
  user_id: e.user_id,
3881
3863
  type: e.type,
@@ -3891,42 +3873,42 @@ function ys(n) {
3891
3873
  created_at_ts: t,
3892
3874
  updated_at_ts: t
3893
3875
  };
3894
- return await n.insert(U).values(o), Me({ ...o, tenant_id: i });
3876
+ return await n.insert(K).values(o), je({ ...o, tenant_id: i });
3895
3877
  },
3896
3878
  async get(i, e) {
3897
- const t = await n.select().from(U).where(
3879
+ const t = await n.select().from(K).where(
3898
3880
  g(
3899
- a(U.tenant_id, i),
3900
- a(U.id, e)
3881
+ a(K.tenant_id, i),
3882
+ a(K.id, e)
3901
3883
  )
3902
3884
  ).get();
3903
- return t ? Me(t) : null;
3885
+ return t ? je(t) : null;
3904
3886
  },
3905
3887
  async getByCredentialId(i, e) {
3906
- const t = await n.select().from(U).where(
3888
+ const t = await n.select().from(K).where(
3907
3889
  g(
3908
- a(U.tenant_id, i),
3909
- a(U.credential_id, e)
3890
+ a(K.tenant_id, i),
3891
+ a(K.credential_id, e)
3910
3892
  )
3911
3893
  ).get();
3912
- return t ? Me(t) : null;
3894
+ return t ? je(t) : null;
3913
3895
  },
3914
3896
  async list(i, e) {
3915
- return (await n.select().from(U).where(
3897
+ return (await n.select().from(K).where(
3916
3898
  g(
3917
- a(U.tenant_id, i),
3918
- a(U.user_id, e)
3899
+ a(K.tenant_id, i),
3900
+ a(K.user_id, e)
3919
3901
  )
3920
- ).all()).map(Me);
3902
+ ).all()).map(je);
3921
3903
  },
3922
3904
  async update(i, e, t) {
3923
3905
  const r = {
3924
3906
  updated_at_ts: Date.now()
3925
3907
  };
3926
- t.type !== void 0 && (r.type = t.type), t.phone_number !== void 0 && (r.phone_number = t.phone_number), t.totp_secret !== void 0 && (r.totp_secret = t.totp_secret), t.credential_id !== void 0 && (r.credential_id = t.credential_id), t.public_key !== void 0 && (r.public_key = t.public_key), t.sign_count !== void 0 && (r.sign_count = t.sign_count), t.credential_backed_up !== void 0 && (r.credential_backed_up = t.credential_backed_up ? 1 : 0), t.transports !== void 0 && (r.transports = JSON.stringify(t.transports)), t.friendly_name !== void 0 && (r.friendly_name = t.friendly_name), t.confirmed !== void 0 && (r.confirmed = t.confirmed ? 1 : 0), await n.update(U).set(r).where(
3908
+ t.type !== void 0 && (r.type = t.type), t.phone_number !== void 0 && (r.phone_number = t.phone_number), t.totp_secret !== void 0 && (r.totp_secret = t.totp_secret), t.credential_id !== void 0 && (r.credential_id = t.credential_id), t.public_key !== void 0 && (r.public_key = t.public_key), t.sign_count !== void 0 && (r.sign_count = t.sign_count), t.credential_backed_up !== void 0 && (r.credential_backed_up = t.credential_backed_up ? 1 : 0), t.transports !== void 0 && (r.transports = JSON.stringify(t.transports)), t.friendly_name !== void 0 && (r.friendly_name = t.friendly_name), t.confirmed !== void 0 && (r.confirmed = t.confirmed ? 1 : 0), await n.update(K).set(r).where(
3927
3909
  g(
3928
- a(U.tenant_id, i),
3929
- a(U.id, e)
3910
+ a(K.tenant_id, i),
3911
+ a(K.id, e)
3930
3912
  )
3931
3913
  );
3932
3914
  const o = await this.get(i, e);
@@ -3937,10 +3919,10 @@ function ys(n) {
3937
3919
  return o;
3938
3920
  },
3939
3921
  async remove(i, e) {
3940
- return (await n.delete(U).where(
3922
+ return (await n.delete(K).where(
3941
3923
  g(
3942
- a(U.tenant_id, i),
3943
- a(U.id, e)
3924
+ a(K.tenant_id, i),
3925
+ a(K.id, e)
3944
3926
  )
3945
3927
  ).returning()).length > 0;
3946
3928
  }
@@ -3950,7 +3932,7 @@ function ws() {
3950
3932
  const { customAlphabet: n } = require("nanoid");
3951
3933
  return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3952
3934
  }
3953
- function ut(n) {
3935
+ function _t(n) {
3954
3936
  const {
3955
3937
  tenant_id: i,
3956
3938
  branding: e,
@@ -3959,7 +3941,7 @@ function ut(n) {
3959
3941
  token_quota: o,
3960
3942
  ...l
3961
3943
  } = n;
3962
- return z({
3944
+ return T({
3963
3945
  ...l,
3964
3946
  branding: x(e, {}),
3965
3947
  metadata: x(t, {}),
@@ -3984,24 +3966,24 @@ function Ns(n) {
3984
3966
  updated_at: t
3985
3967
  };
3986
3968
  try {
3987
- await n.insert(L).values(o);
3969
+ await n.insert(E).values(o);
3988
3970
  } catch (u) {
3989
3971
  throw (l = u == null ? void 0 : u.message) != null && l.includes("UNIQUE constraint failed") || (_ = u == null ? void 0 : u.message) != null && _.includes("AlreadyExists") ? new be(409, {
3990
3972
  message: "Organization already exists"
3991
3973
  }) : u;
3992
3974
  }
3993
- return ut({ ...o, tenant_id: i });
3975
+ return _t({ ...o, tenant_id: i });
3994
3976
  },
3995
3977
  async get(i, e) {
3996
- let t = await n.select().from(L).where(
3997
- g(a(L.tenant_id, i), a(L.id, e))
3978
+ let t = await n.select().from(E).where(
3979
+ g(a(E.tenant_id, i), a(E.id, e))
3998
3980
  ).get();
3999
- return t || (t = await n.select().from(L).where(
3981
+ return t || (t = await n.select().from(E).where(
4000
3982
  g(
4001
- a(L.tenant_id, i),
4002
- a(L.name, e)
3983
+ a(E.tenant_id, i),
3984
+ a(E.name, e)
4003
3985
  )
4004
- ).get()), t ? ut(t) : null;
3986
+ ).get()), t ? _t(t) : null;
4005
3987
  },
4006
3988
  async update(i, e, t) {
4007
3989
  const r = {
@@ -4009,8 +3991,8 @@ function Ns(n) {
4009
3991
  };
4010
3992
  return t.name !== void 0 && (r.name = t.name), t.display_name !== void 0 && (r.display_name = t.display_name), t.branding !== void 0 && (r.branding = JSON.stringify(t.branding)), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.enabled_connections !== void 0 && (r.enabled_connections = JSON.stringify(
4011
3993
  t.enabled_connections
4012
- )), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(L).set(r).where(
4013
- g(a(L.tenant_id, i), a(L.id, e))
3994
+ )), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(E).set(r).where(
3995
+ g(a(E.tenant_id, i), a(E.id, e))
4014
3996
  ).returning()).length > 0;
4015
3997
  },
4016
3998
  async list(i, e) {
@@ -4021,29 +4003,29 @@ function Ns(n) {
4021
4003
  sort: l,
4022
4004
  q: _
4023
4005
  } = e || {};
4024
- let u = n.select().from(L).where(a(L.tenant_id, i)).$dynamic();
4006
+ let u = n.select().from(E).where(a(E.tenant_id, i)).$dynamic();
4025
4007
  if (_ && (u = u.where(
4026
4008
  de(
4027
- Ie(L.name, `%${_}%`),
4028
- Ie(L.display_name, `%${_}%`)
4009
+ Ie(E.name, `%${_}%`),
4010
+ Ie(E.display_name, `%${_}%`)
4029
4011
  )
4030
4012
  )), l != null && l.sort_by) {
4031
- const y = L[l.sort_by];
4013
+ const y = E[l.sort_by];
4032
4014
  y && (u = u.orderBy(
4033
4015
  l.sort_order === "desc" ? V(y) : G(y)
4034
4016
  ));
4035
4017
  }
4036
- const d = (await u.offset(t * r).limit(r)).map(ut);
4018
+ const d = (await u.offset(t * r).limit(r)).map(_t);
4037
4019
  if (!o)
4038
4020
  return { organizations: d };
4039
- const m = [a(L.tenant_id, i)];
4040
- _ && m.push(
4021
+ const h = [a(E.tenant_id, i)];
4022
+ _ && h.push(
4041
4023
  de(
4042
- Ie(L.name, `%${_}%`),
4043
- Ie(L.display_name, `%${_}%`)
4024
+ Ie(E.name, `%${_}%`),
4025
+ Ie(E.display_name, `%${_}%`)
4044
4026
  )
4045
4027
  );
4046
- const [f] = await n.select({ count: R() }).from(L).where(g(...m));
4028
+ const [f] = await n.select({ count: R() }).from(E).where(g(...h));
4047
4029
  return {
4048
4030
  organizations: d,
4049
4031
  start: t * r,
@@ -4052,13 +4034,13 @@ function Ns(n) {
4052
4034
  };
4053
4035
  },
4054
4036
  async remove(i, e) {
4055
- return (await n.delete(L).where(
4056
- g(a(L.tenant_id, i), a(L.id, e))
4037
+ return (await n.delete(E).where(
4038
+ g(a(E.tenant_id, i), a(E.id, e))
4057
4039
  ).returning()).length > 0;
4058
4040
  }
4059
4041
  };
4060
4042
  }
4061
- function dt(n) {
4043
+ function ut(n) {
4062
4044
  const { tenant_id: i, is_current: e, ...t } = n;
4063
4045
  return {
4064
4046
  ...t,
@@ -4069,10 +4051,10 @@ function vs(n) {
4069
4051
  return {
4070
4052
  async create(i, e) {
4071
4053
  const t = (/* @__PURE__ */ new Date()).toISOString(), r = e.id || ae();
4072
- e.is_current !== !1 && await n.update(C).set({ is_current: 0 }).where(
4054
+ e.is_current !== !1 && await n.update(A).set({ is_current: 0 }).where(
4073
4055
  g(
4074
- a(C.tenant_id, i),
4075
- a(C.user_id, e.user_id)
4056
+ a(A.tenant_id, i),
4057
+ a(A.user_id, e.user_id)
4076
4058
  )
4077
4059
  );
4078
4060
  const o = {
@@ -4085,41 +4067,41 @@ function vs(n) {
4085
4067
  created_at: t,
4086
4068
  updated_at: t
4087
4069
  };
4088
- return await n.insert(C).values(o), dt({ ...o, tenant_id: i });
4070
+ return await n.insert(A).values(o), ut({ ...o, tenant_id: i });
4089
4071
  },
4090
4072
  async get(i, e) {
4091
- const t = await n.select().from(C).where(
4073
+ const t = await n.select().from(A).where(
4092
4074
  g(
4093
- a(C.tenant_id, i),
4094
- a(C.user_id, e),
4095
- a(C.is_current, 1)
4075
+ a(A.tenant_id, i),
4076
+ a(A.user_id, e),
4077
+ a(A.is_current, 1)
4096
4078
  )
4097
4079
  ).get();
4098
- return t ? dt(t) : null;
4080
+ return t ? ut(t) : null;
4099
4081
  },
4100
4082
  async list(i, e, t) {
4101
- let r = n.select().from(C).where(
4083
+ let r = n.select().from(A).where(
4102
4084
  g(
4103
- a(C.tenant_id, i),
4104
- a(C.user_id, e)
4085
+ a(A.tenant_id, i),
4086
+ a(A.user_id, e)
4105
4087
  )
4106
- ).orderBy(V(C.created_at)).$dynamic();
4107
- return t && (r = r.limit(t)), (await r).map(dt);
4088
+ ).orderBy(V(A.created_at)).$dynamic();
4089
+ return t && (r = r.limit(t)), (await r).map(ut);
4108
4090
  },
4109
4091
  async update(i, e) {
4110
4092
  const t = {
4111
4093
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4112
4094
  };
4113
- return e.password !== void 0 && (t.password = e.password), e.algorithm !== void 0 && (t.algorithm = e.algorithm), e.is_current !== void 0 && (t.is_current = e.is_current ? 1 : 0), e.id ? await n.update(C).set(t).where(
4095
+ return e.password !== void 0 && (t.password = e.password), e.algorithm !== void 0 && (t.algorithm = e.algorithm), e.is_current !== void 0 && (t.is_current = e.is_current ? 1 : 0), e.id ? await n.update(A).set(t).where(
4114
4096
  g(
4115
- a(C.tenant_id, i),
4116
- a(C.id, e.id)
4097
+ a(A.tenant_id, i),
4098
+ a(A.id, e.id)
4117
4099
  )
4118
- ) : await n.update(C).set(t).where(
4100
+ ) : await n.update(A).set(t).where(
4119
4101
  g(
4120
- a(C.tenant_id, i),
4121
- a(C.user_id, e.user_id),
4122
- a(C.is_current, 1)
4102
+ a(A.tenant_id, i),
4103
+ a(A.user_id, e.user_id),
4104
+ a(A.is_current, 1)
4123
4105
  )
4124
4106
  ), !0;
4125
4107
  }
@@ -4160,28 +4142,40 @@ function Ss(n) {
4160
4142
  }
4161
4143
  };
4162
4144
  }
4163
- function ct(n) {
4145
+ function dt(n) {
4164
4146
  const {
4165
4147
  tenant_id: i,
4166
4148
  created_at_ts: e,
4167
4149
  expires_at_ts: t,
4168
4150
  idle_expires_at_ts: r,
4169
4151
  last_exchanged_at_ts: o,
4170
- device: l,
4171
- resource_servers: _,
4172
- rotating: u,
4173
- ...c
4174
- } = n, d = Fe(
4175
- { created_at_ts: e, expires_at_ts: t, idle_expires_at_ts: r, last_exchanged_at_ts: o },
4152
+ revoked_at_ts: l,
4153
+ device: _,
4154
+ resource_servers: u,
4155
+ rotating: c,
4156
+ ...d
4157
+ } = n, h = Pe(
4158
+ {
4159
+ created_at_ts: e,
4160
+ expires_at_ts: t,
4161
+ idle_expires_at_ts: r,
4162
+ last_exchanged_at_ts: o,
4163
+ revoked_at_ts: l
4164
+ },
4176
4165
  ["created_at_ts"],
4177
- ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
4166
+ [
4167
+ "expires_at_ts",
4168
+ "idle_expires_at_ts",
4169
+ "last_exchanged_at_ts",
4170
+ "revoked_at_ts"
4171
+ ]
4178
4172
  );
4179
- return z({
4180
- ...c,
4173
+ return T({
4181
4174
  ...d,
4182
- rotating: !!u,
4183
- device: x(l, {}),
4184
- resource_servers: x(_, [])
4175
+ ...h,
4176
+ rotating: !!c,
4177
+ device: x(_, {}),
4178
+ resource_servers: x(u, [])
4185
4179
  });
4186
4180
  }
4187
4181
  function $t(n, i) {
@@ -4200,59 +4194,59 @@ function xs(n) {
4200
4194
  resource_servers: JSON.stringify(e.resource_servers || []),
4201
4195
  rotating: e.rotating ?? !1,
4202
4196
  created_at_ts: t,
4203
- expires_at_ts: j(e.expires_at),
4204
- idle_expires_at_ts: j(e.idle_expires_at),
4205
- last_exchanged_at_ts: j(e.last_exchanged_at)
4197
+ expires_at_ts: Q(e.expires_at),
4198
+ idle_expires_at_ts: Q(e.idle_expires_at),
4199
+ last_exchanged_at_ts: Q(e.last_exchanged_at)
4206
4200
  };
4207
4201
  await n.run(w`BEGIN`);
4208
4202
  try {
4209
- await n.insert(T).values(r);
4203
+ await n.insert(z).values(r);
4210
4204
  const o = $t(
4211
4205
  r.expires_at_ts,
4212
4206
  r.idle_expires_at_ts
4213
4207
  );
4214
- o > 0 && r.login_id && await n.update(B).set({
4208
+ o > 0 && r.login_id && await n.update(L).set({
4215
4209
  expires_at_ts: o,
4216
4210
  updated_at_ts: t
4217
4211
  }).where(
4218
4212
  g(
4219
- a(B.tenant_id, i),
4220
- a(B.id, r.login_id),
4221
- we(B.expires_at_ts, o)
4213
+ a(L.tenant_id, i),
4214
+ a(L.id, r.login_id),
4215
+ we(L.expires_at_ts, o)
4222
4216
  )
4223
4217
  ), await n.run(w`COMMIT`);
4224
4218
  } catch (o) {
4225
4219
  throw await n.run(w`ROLLBACK`), o;
4226
4220
  }
4227
- return ct({ ...r, tenant_id: i });
4221
+ return dt({ ...r, tenant_id: i });
4228
4222
  },
4229
4223
  async get(i, e) {
4230
- const t = await n.select().from(T).where(
4231
- g(a(T.tenant_id, i), a(T.id, e))
4224
+ const t = await n.select().from(z).where(
4225
+ g(a(z.tenant_id, i), a(z.id, e))
4232
4226
  ).get();
4233
- return t ? ct(t) : null;
4227
+ return t ? dt(t) : null;
4234
4228
  },
4235
4229
  async update(i, e, t) {
4236
4230
  const r = {};
4237
- t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.resource_servers !== void 0 && (r.resource_servers = JSON.stringify(t.resource_servers)), t.rotating !== void 0 && (r.rotating = t.rotating), 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.last_exchanged_at !== void 0 && (r.last_exchanged_at_ts = j(t.last_exchanged_at));
4231
+ t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.resource_servers !== void 0 && (r.resource_servers = JSON.stringify(t.resource_servers)), t.rotating !== void 0 && (r.rotating = t.rotating), t.expires_at !== void 0 && (r.expires_at_ts = Q(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = Q(t.idle_expires_at)), t.last_exchanged_at !== void 0 && (r.last_exchanged_at_ts = Q(t.last_exchanged_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = Q(t.revoked_at));
4238
4232
  const o = r.expires_at_ts !== void 0 || r.idle_expires_at_ts !== void 0;
4239
4233
  await n.run(w`BEGIN`);
4240
4234
  try {
4241
- const _ = (await n.update(T).set(r).where(
4235
+ const _ = (await n.update(z).set(r).where(
4242
4236
  g(
4243
- a(T.tenant_id, i),
4244
- a(T.id, e)
4237
+ a(z.tenant_id, i),
4238
+ a(z.id, e)
4245
4239
  )
4246
4240
  ).returning()).length > 0;
4247
4241
  if (_ && o) {
4248
4242
  const u = await n.select({
4249
- login_id: T.login_id,
4250
- expires_at_ts: T.expires_at_ts,
4251
- idle_expires_at_ts: T.idle_expires_at_ts
4252
- }).from(T).where(
4243
+ login_id: z.login_id,
4244
+ expires_at_ts: z.expires_at_ts,
4245
+ idle_expires_at_ts: z.idle_expires_at_ts
4246
+ }).from(z).where(
4253
4247
  g(
4254
- a(T.tenant_id, i),
4255
- a(T.id, e)
4248
+ a(z.tenant_id, i),
4249
+ a(z.id, e)
4256
4250
  )
4257
4251
  ).get();
4258
4252
  if (u != null && u.login_id) {
@@ -4260,14 +4254,14 @@ function xs(n) {
4260
4254
  u.expires_at_ts,
4261
4255
  u.idle_expires_at_ts
4262
4256
  );
4263
- c > 0 && await n.update(B).set({
4257
+ c > 0 && await n.update(L).set({
4264
4258
  expires_at_ts: c,
4265
4259
  updated_at_ts: Date.now()
4266
4260
  }).where(
4267
4261
  g(
4268
- a(B.tenant_id, i),
4269
- a(B.id, u.login_id),
4270
- we(B.expires_at_ts, c)
4262
+ a(L.tenant_id, i),
4263
+ a(L.id, u.login_id),
4264
+ we(L.expires_at_ts, c)
4271
4265
  )
4272
4266
  );
4273
4267
  }
@@ -4285,34 +4279,43 @@ function xs(n) {
4285
4279
  sort: l,
4286
4280
  q: _
4287
4281
  } = e || {};
4288
- let u = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
4282
+ let u = n.select().from(z).where(a(z.tenant_id, i)).$dynamic();
4289
4283
  if (_) {
4290
- const f = pe(T, _, ["user_id"]);
4284
+ const f = ye(z, _, ["user_id"]);
4291
4285
  f && (u = u.where(
4292
- g(a(T.tenant_id, i), f)
4286
+ g(a(z.tenant_id, i), f)
4293
4287
  ));
4294
4288
  }
4295
4289
  if (l != null && l.sort_by) {
4296
- const f = T[l.sort_by];
4290
+ const f = z[l.sort_by];
4297
4291
  f && (u = u.orderBy(
4298
4292
  l.sort_order === "desc" ? V(f) : G(f)
4299
4293
  ));
4300
4294
  }
4301
- const d = (await u.offset(t * r).limit(r)).map(ct);
4295
+ const d = (await u.offset(t * r).limit(r)).map(dt);
4302
4296
  if (!o)
4303
4297
  return { refresh_tokens: d };
4304
- const [m] = await n.select({ count: R() }).from(T).where(a(T.tenant_id, i));
4298
+ const [h] = await n.select({ count: R() }).from(z).where(a(z.tenant_id, i));
4305
4299
  return {
4306
4300
  refresh_tokens: d,
4307
4301
  start: t * r,
4308
4302
  limit: r,
4309
- length: Number((m == null ? void 0 : m.count) ?? 0)
4303
+ length: Number((h == null ? void 0 : h.count) ?? 0)
4310
4304
  };
4311
4305
  },
4312
4306
  async remove(i, e) {
4313
- return (await n.delete(T).where(
4314
- g(a(T.tenant_id, i), a(T.id, e))
4307
+ return (await n.delete(z).where(
4308
+ g(a(z.tenant_id, i), a(z.id, e))
4315
4309
  ).returning()).length > 0;
4310
+ },
4311
+ async revokeByLoginSession(i, e, t) {
4312
+ return (await n.update(z).set({ revoked_at_ts: Q(t) }).where(
4313
+ g(
4314
+ a(z.tenant_id, i),
4315
+ a(z.login_id, e),
4316
+ me(z.revoked_at_ts)
4317
+ )
4318
+ ).returning()).length;
4316
4319
  }
4317
4320
  };
4318
4321
  }
@@ -4324,7 +4327,7 @@ const xt = [
4324
4327
  "skip_consent_for_verifiable_first_party_clients",
4325
4328
  "allow_offline_access",
4326
4329
  "is_system"
4327
- ], Pt = /* @__PURE__ */ new Set([
4330
+ ], Qt = /* @__PURE__ */ new Set([
4328
4331
  "id",
4329
4332
  "tenant_id",
4330
4333
  "identifier",
@@ -4343,7 +4346,7 @@ const xt = [
4343
4346
  "created_at",
4344
4347
  "updated_at"
4345
4348
  ]);
4346
- function gt(n) {
4349
+ function ct(n) {
4347
4350
  const {
4348
4351
  tenant_id: i,
4349
4352
  verification_key: e,
@@ -4355,7 +4358,7 @@ function gt(n) {
4355
4358
  _.scopes = x(t, []), _.options = x(r, {}), _.metadata = x(o), e !== void 0 && (_.verificationKey = e);
4356
4359
  for (const u of xt)
4357
4360
  l[u] !== void 0 && l[u] !== null && (_[u] = !!l[u]);
4358
- return z(_);
4361
+ return T(_);
4359
4362
  }
4360
4363
  function Ds(n) {
4361
4364
  return {
@@ -4378,28 +4381,28 @@ function Ds(n) {
4378
4381
  };
4379
4382
  for (const l of xt)
4380
4383
  e[l] !== void 0 && (o[l] = e[l] ? 1 : 0);
4381
- return o.is_system === void 0 && (o.is_system = 0), await n.insert(E).values(o), gt({ ...o, tenant_id: i });
4384
+ return o.is_system === void 0 && (o.is_system = 0), await n.insert(C).values(o), ct({ ...o, tenant_id: i });
4382
4385
  },
4383
4386
  async get(i, e) {
4384
- const t = await n.select().from(E).where(
4387
+ const t = await n.select().from(C).where(
4385
4388
  g(
4386
- a(E.tenant_id, i),
4387
- a(E.id, e)
4389
+ a(C.tenant_id, i),
4390
+ a(C.id, e)
4388
4391
  )
4389
4392
  ).get();
4390
- return t ? gt(t) : null;
4393
+ return t ? ct(t) : null;
4391
4394
  },
4392
4395
  async update(i, e, t) {
4393
4396
  const r = {
4394
4397
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4395
4398
  };
4396
- t.name !== void 0 && (r.name = t.name), t.identifier !== void 0 && (r.identifier = t.identifier), t.signing_alg !== void 0 && (r.signing_alg = t.signing_alg), t.signing_secret !== void 0 && (r.signing_secret = t.signing_secret), t.token_lifetime !== void 0 && (r.token_lifetime = t.token_lifetime), t.token_lifetime_for_web !== void 0 && (r.token_lifetime_for_web = t.token_lifetime_for_web), t.scopes !== void 0 && (r.scopes = JSON.stringify(t.scopes)), t.options !== void 0 && (r.options = w`json_patch(COALESCE(${E.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
4399
+ t.name !== void 0 && (r.name = t.name), t.identifier !== void 0 && (r.identifier = t.identifier), t.signing_alg !== void 0 && (r.signing_alg = t.signing_alg), t.signing_secret !== void 0 && (r.signing_secret = t.signing_secret), t.token_lifetime !== void 0 && (r.token_lifetime = t.token_lifetime), t.token_lifetime_for_web !== void 0 && (r.token_lifetime_for_web = t.token_lifetime_for_web), t.scopes !== void 0 && (r.scopes = JSON.stringify(t.scopes)), t.options !== void 0 && (r.options = w`json_patch(COALESCE(${C.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
4397
4400
  for (const l of xt)
4398
4401
  t[l] !== void 0 && (r[l] = t[l] ? 1 : 0);
4399
- return (await n.update(E).set(r).where(
4402
+ return (await n.update(C).set(r).where(
4400
4403
  g(
4401
- a(E.tenant_id, i),
4402
- a(E.id, e)
4404
+ a(C.tenant_id, i),
4405
+ a(C.id, e)
4403
4406
  )
4404
4407
  ).returning()).length > 0;
4405
4408
  },
@@ -4413,28 +4416,28 @@ function Ds(n) {
4413
4416
  } = e || {}, u = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
4414
4417
  Math.max(1, Math.floor(Number(r) || 50)),
4415
4418
  500
4416
- ), d = [a(E.tenant_id, i)];
4419
+ ), d = [a(C.tenant_id, i)];
4417
4420
  if (_) {
4418
- const A = _.match(/^([^:]+):(.+)$/);
4419
- if (A) {
4420
- const [, W, H] = A, ke = W == null ? void 0 : W.startsWith("-"), qe = ke ? W == null ? void 0 : W.substring(1) : W;
4421
- if (qe && Pt.has(qe) && !ke) {
4422
- const yr = E[qe];
4421
+ const B = _.match(/^([^:]+):(.+)$/);
4422
+ if (B) {
4423
+ const [, W, H] = B, ke = W == null ? void 0 : W.startsWith("-"), qe = ke ? W == null ? void 0 : W.substring(1) : W;
4424
+ if (qe && Qt.has(qe) && !ke) {
4425
+ const yr = C[qe];
4423
4426
  d.push(Ie(yr, `%${H}%`));
4424
4427
  }
4425
4428
  }
4426
4429
  }
4427
- let m = n.select().from(E).where(g(...d)).$dynamic();
4428
- if (l != null && l.sort_by && Pt.has(l.sort_by)) {
4429
- const A = E[l.sort_by];
4430
- m = m.orderBy(
4431
- l.sort_order === "desc" ? V(A) : G(A)
4430
+ let h = n.select().from(C).where(g(...d)).$dynamic();
4431
+ if (l != null && l.sort_by && Qt.has(l.sort_by)) {
4432
+ const B = C[l.sort_by];
4433
+ h = h.orderBy(
4434
+ l.sort_order === "desc" ? V(B) : G(B)
4432
4435
  );
4433
4436
  }
4434
- const y = (await m.offset(u * c).limit(c)).map(gt);
4437
+ const y = (await h.offset(u * c).limit(c)).map(ct);
4435
4438
  if (!o)
4436
4439
  return { resource_servers: y };
4437
- const [N] = await n.select({ count: R() }).from(E).where(g(...d));
4440
+ const [N] = await n.select({ count: R() }).from(C).where(g(...d));
4438
4441
  return {
4439
4442
  resource_servers: y,
4440
4443
  start: u * c,
@@ -4443,10 +4446,10 @@ function Ds(n) {
4443
4446
  };
4444
4447
  },
4445
4448
  async remove(i, e) {
4446
- return (await n.delete(E).where(
4449
+ return (await n.delete(C).where(
4447
4450
  g(
4448
- a(E.tenant_id, i),
4449
- a(E.id, e)
4451
+ a(C.tenant_id, i),
4452
+ a(C.id, e)
4450
4453
  )
4451
4454
  ).returning()).length > 0;
4452
4455
  }
@@ -4481,12 +4484,12 @@ function Os(n) {
4481
4484
  ], l = /* @__PURE__ */ new Map();
4482
4485
  if (o.length > 0) {
4483
4486
  const _ = await n.select({
4484
- identifier: E.identifier,
4485
- name: E.name
4486
- }).from(E).where(
4487
+ identifier: C.identifier,
4488
+ name: C.name
4489
+ }).from(C).where(
4487
4490
  g(
4488
- a(E.tenant_id, i),
4489
- Ne(E.identifier, o)
4491
+ a(C.tenant_id, i),
4492
+ Ne(C.identifier, o)
4490
4493
  )
4491
4494
  ).all();
4492
4495
  for (const u of _)
@@ -4546,10 +4549,10 @@ function ks(n) {
4546
4549
  const l = await n.select().from(_e).where(g(...o)).all();
4547
4550
  return await Promise.all(
4548
4551
  l.map(async (u) => {
4549
- const c = await n.select({ name: E.name }).from(E).where(
4552
+ const c = await n.select({ name: C.name }).from(C).where(
4550
4553
  g(
4551
- a(E.tenant_id, i),
4552
- a(E.identifier, u.resource_server_identifier)
4554
+ a(C.tenant_id, i),
4555
+ a(C.identifier, u.resource_server_identifier)
4553
4556
  )
4554
4557
  ).get();
4555
4558
  return {
@@ -4577,9 +4580,9 @@ function ks(n) {
4577
4580
  }
4578
4581
  };
4579
4582
  }
4580
- function ft(n) {
4583
+ function gt(n) {
4581
4584
  const { tenant_id: i, is_system: e, metadata: t, ...r } = n;
4582
- return z({
4585
+ return T({
4583
4586
  ...r,
4584
4587
  is_system: e ? !0 : void 0,
4585
4588
  metadata: x(t)
@@ -4598,17 +4601,17 @@ function Is(n) {
4598
4601
  created_at: t,
4599
4602
  updated_at: t
4600
4603
  };
4601
- return await n.insert(F).values(o), ft({ ...o, tenant_id: i });
4604
+ return await n.insert(U).values(o), gt({ ...o, tenant_id: i });
4602
4605
  },
4603
4606
  async get(i, e) {
4604
- const t = await n.select().from(F).where(g(a(F.tenant_id, i), a(F.id, e))).get();
4605
- return t ? ft(t) : null;
4607
+ const t = await n.select().from(U).where(g(a(U.tenant_id, i), a(U.id, e))).get();
4608
+ return t ? gt(t) : null;
4606
4609
  },
4607
4610
  async update(i, e, t) {
4608
4611
  const r = {
4609
4612
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4610
4613
  };
4611
- return t.name !== void 0 && (r.name = t.name), t.description !== void 0 && (r.description = t.description), t.is_system !== void 0 && (r.is_system = t.is_system ? 1 : 0), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), (await n.update(F).set(r).where(g(a(F.tenant_id, i), a(F.id, e))).returning()).length > 0;
4614
+ return t.name !== void 0 && (r.name = t.name), t.description !== void 0 && (r.description = t.description), t.is_system !== void 0 && (r.is_system = t.is_system ? 1 : 0), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), (await n.update(U).set(r).where(g(a(U.tenant_id, i), a(U.id, e))).returning()).length > 0;
4612
4615
  },
4613
4616
  async list(i, e) {
4614
4617
  const {
@@ -4617,18 +4620,18 @@ function Is(n) {
4617
4620
  include_totals: o = !1,
4618
4621
  sort: l,
4619
4622
  q: _
4620
- } = e || {}, u = _ ? pe(F, _, ["name"]) : void 0, c = u ? g(a(F.tenant_id, i), u) : a(F.tenant_id, i);
4621
- let d = n.select().from(F).where(c).$dynamic();
4623
+ } = e || {}, u = _ ? ye(U, _, ["name"]) : void 0, c = u ? g(a(U.tenant_id, i), u) : a(U.tenant_id, i);
4624
+ let d = n.select().from(U).where(c).$dynamic();
4622
4625
  if (l != null && l.sort_by) {
4623
- const N = F[l.sort_by];
4626
+ const N = U[l.sort_by];
4624
4627
  N && (d = d.orderBy(
4625
4628
  l.sort_order === "desc" ? V(N) : G(N)
4626
4629
  ));
4627
4630
  }
4628
- const f = (await d.offset(t * r).limit(r)).map(ft);
4631
+ const f = (await d.offset(t * r).limit(r)).map(gt);
4629
4632
  if (!o)
4630
4633
  return { roles: f };
4631
- const [y] = await n.select({ count: R() }).from(F).where(c);
4634
+ const [y] = await n.select({ count: R() }).from(U).where(c);
4632
4635
  return {
4633
4636
  roles: f,
4634
4637
  start: t * r,
@@ -4637,7 +4640,7 @@ function Is(n) {
4637
4640
  };
4638
4641
  },
4639
4642
  async remove(i, e) {
4640
- return (await n.delete(F).where(g(a(F.tenant_id, i), a(F.id, e))).returning()).length > 0;
4643
+ return (await n.delete(U).where(g(a(U.tenant_id, i), a(U.id, e))).returning()).length > 0;
4641
4644
  }
4642
4645
  };
4643
4646
  }
@@ -4649,7 +4652,7 @@ const zs = ["created_at_ts", "updated_at_ts"], Ts = [
4649
4652
  "used_at_ts",
4650
4653
  "revoked_at_ts"
4651
4654
  ];
4652
- function ht(n) {
4655
+ function ft(n) {
4653
4656
  const {
4654
4657
  tenant_id: i,
4655
4658
  created_at_ts: e,
@@ -4661,9 +4664,9 @@ function ht(n) {
4661
4664
  used_at_ts: u,
4662
4665
  revoked_at_ts: c,
4663
4666
  device: d,
4664
- clients: m,
4667
+ clients: h,
4665
4668
  ...f
4666
- } = n, y = Fe(
4669
+ } = n, y = Pe(
4667
4670
  {
4668
4671
  created_at_ts: e,
4669
4672
  updated_at_ts: t,
@@ -4677,11 +4680,11 @@ function ht(n) {
4677
4680
  [...zs],
4678
4681
  [...Ts]
4679
4682
  );
4680
- return z({
4683
+ return T({
4681
4684
  ...f,
4682
4685
  ...y,
4683
4686
  device: x(d, {}),
4684
- clients: x(m, [])
4687
+ clients: x(h, [])
4685
4688
  });
4686
4689
  }
4687
4690
  function qs(n) {
@@ -4696,26 +4699,26 @@ function qs(n) {
4696
4699
  clients: JSON.stringify(e.clients || []),
4697
4700
  created_at_ts: t,
4698
4701
  updated_at_ts: t,
4699
- expires_at_ts: j(e.expires_at),
4700
- idle_expires_at_ts: j(e.idle_expires_at),
4701
- authenticated_at_ts: e.authenticated_at ? j(e.authenticated_at) : t,
4702
- last_interaction_at_ts: e.last_interaction_at ? j(e.last_interaction_at) : t,
4703
- used_at_ts: j(e.used_at),
4704
- revoked_at_ts: j(e.revoked_at)
4702
+ expires_at_ts: Q(e.expires_at),
4703
+ idle_expires_at_ts: Q(e.idle_expires_at),
4704
+ authenticated_at_ts: e.authenticated_at ? Q(e.authenticated_at) : t,
4705
+ last_interaction_at_ts: e.last_interaction_at ? Q(e.last_interaction_at) : t,
4706
+ used_at_ts: Q(e.used_at),
4707
+ revoked_at_ts: Q(e.revoked_at)
4705
4708
  };
4706
- return await n.insert($).values(r), ht({ ...r, tenant_id: i });
4709
+ return await n.insert($).values(r), ft({ ...r, tenant_id: i });
4707
4710
  },
4708
4711
  async get(i, e) {
4709
4712
  const t = await n.select().from($).where(g(a($.tenant_id, i), a($.id, e))).get();
4710
- return t ? ht(t) : null;
4713
+ return t ? ft(t) : null;
4711
4714
  },
4712
4715
  async update(i, e, t) {
4713
4716
  const r = {
4714
4717
  updated_at_ts: Date.now()
4715
4718
  };
4716
- 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(
4719
+ 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 = Q(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = Q(t.idle_expires_at)), t.authenticated_at !== void 0 && (r.authenticated_at_ts = Q(t.authenticated_at)), t.last_interaction_at !== void 0 && (r.last_interaction_at_ts = Q(
4717
4720
  t.last_interaction_at
4718
- )), 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;
4721
+ )), t.used_at !== void 0 && (r.used_at_ts = Q(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = Q(t.revoked_at)), (await n.update($).set(r).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
4719
4722
  },
4720
4723
  async list(i, e) {
4721
4724
  const {
@@ -4724,7 +4727,7 @@ function qs(n) {
4724
4727
  include_totals: o = !1,
4725
4728
  sort: l,
4726
4729
  q: _
4727
- } = e || {}, u = _ ? pe($, _, ["user_id"]) : void 0, c = u ? g(a($.tenant_id, i), u) : a($.tenant_id, i);
4730
+ } = e || {}, u = _ ? ye($, _, ["user_id"]) : void 0, c = u ? g(a($.tenant_id, i), u) : a($.tenant_id, i);
4728
4731
  let d = n.select().from($).where(c).$dynamic();
4729
4732
  if (l != null && l.sort_by) {
4730
4733
  const N = $[l.sort_by];
@@ -4732,7 +4735,7 @@ function qs(n) {
4732
4735
  l.sort_order === "desc" ? V(N) : G(N)
4733
4736
  ));
4734
4737
  }
4735
- const f = (await d.offset(t * r).limit(r)).map(ht);
4738
+ const f = (await d.offset(t * r).limit(r)).map(ft);
4736
4739
  if (!o)
4737
4740
  return { sessions: f };
4738
4741
  const [y] = await n.select({ count: R() }).from($).where(c);
@@ -4748,7 +4751,7 @@ function qs(n) {
4748
4751
  }
4749
4752
  };
4750
4753
  }
4751
- const mr = [
4754
+ const hr = [
4752
4755
  "session_cookie",
4753
4756
  "enabled_locales",
4754
4757
  "error_page",
@@ -4764,28 +4767,28 @@ const mr = [
4764
4767
  "acr_values_supported",
4765
4768
  "mtls",
4766
4769
  "mfa"
4767
- ], pr = [
4770
+ ], mr = [
4768
4771
  "allow_organization_name_in_authentication_api",
4769
4772
  "customize_mfa_in_postlogin_action",
4770
4773
  "pushed_authorization_requests_supported",
4771
4774
  "authorization_response_iss_parameter_supported"
4772
4775
  ];
4773
- function Qt(n) {
4776
+ function Jt(n) {
4774
4777
  const i = { ...n };
4775
- for (const e of mr)
4778
+ for (const e of hr)
4776
4779
  typeof i[e] == "string" && (i[e] = x(i[e]));
4777
- for (const e of pr)
4780
+ for (const e of mr)
4778
4781
  i[e] !== void 0 && i[e] !== null && (i[e] = i[e] === 1);
4779
- return z(i);
4782
+ return T(i);
4780
4783
  }
4781
- function Jt(n) {
4784
+ function Pt(n) {
4782
4785
  const i = { ...n };
4783
- Jr(
4786
+ Pr(
4784
4787
  n,
4785
- mr,
4788
+ hr,
4786
4789
  i
4787
4790
  );
4788
- for (const e of pr)
4791
+ for (const e of mr)
4789
4792
  n[e] !== void 0 && (i[e] = n[e] ? 1 : 0);
4790
4793
  return gr(i);
4791
4794
  }
@@ -4798,7 +4801,7 @@ function Ls(n) {
4798
4801
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
4799
4802
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
4800
4803
  ...i
4801
- }, t = Jt(e);
4804
+ }, t = Pt(e);
4802
4805
  try {
4803
4806
  await n.insert(D).values(t);
4804
4807
  } catch (l) {
@@ -4810,7 +4813,7 @@ function Ls(n) {
4810
4813
  },
4811
4814
  async get(i) {
4812
4815
  const e = await n.select().from(D).where(a(D.id, i)).get();
4813
- return e ? Qt(e) : null;
4816
+ return e ? Jt(e) : null;
4814
4817
  },
4815
4818
  async list(i) {
4816
4819
  const {
@@ -4822,16 +4825,16 @@ function Ls(n) {
4822
4825
  } = i || {};
4823
4826
  let _ = n.select().from(D).$dynamic();
4824
4827
  if (l) {
4825
- const m = pe(D, l, ["friendly_name"]);
4826
- m && (_ = _.where(m));
4828
+ const h = ye(D, l, ["friendly_name"]);
4829
+ h && (_ = _.where(h));
4827
4830
  }
4828
4831
  if (o != null && o.sort_by) {
4829
- const m = D[o.sort_by];
4830
- m && (_ = _.orderBy(
4831
- o.sort_order === "desc" ? V(m) : G(m)
4832
+ const h = D[o.sort_by];
4833
+ h && (_ = _.orderBy(
4834
+ o.sort_order === "desc" ? V(h) : G(h)
4832
4835
  ));
4833
4836
  }
4834
- const c = (await _.offset(e * t).limit(t)).map(Qt);
4837
+ const c = (await _.offset(e * t).limit(t)).map(Jt);
4835
4838
  if (!r)
4836
4839
  return { tenants: c };
4837
4840
  const [d] = await n.select({ count: R() }).from(D);
@@ -4843,7 +4846,7 @@ function Ls(n) {
4843
4846
  };
4844
4847
  },
4845
4848
  async update(i, e) {
4846
- const t = Jt({
4849
+ const t = Pt({
4847
4850
  ...e,
4848
4851
  id: i,
4849
4852
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -4864,13 +4867,13 @@ const Es = [
4864
4867
  ];
4865
4868
  function Ft(n) {
4866
4869
  const { tenant_id: i, ...e } = n, t = fr(e, Es);
4867
- return t.borders && (t.borders.show_widget_shadow = !!t.borders.show_widget_shadow), t.fonts && (t.fonts.links_bold = !!t.fonts.links_bold, t.fonts.subtitle_bold = !!t.fonts.subtitle_bold, t.fonts.title_bold = !!t.fonts.title_bold), z(t);
4870
+ return t.borders && (t.borders.show_widget_shadow = !!t.borders.show_widget_shadow), t.fonts && (t.fonts.links_bold = !!t.fonts.links_bold, t.fonts.subtitle_bold = !!t.fonts.subtitle_bold, t.fonts.title_bold = !!t.fonts.title_bold), T(t);
4868
4871
  }
4869
4872
  function Cs(n) {
4870
4873
  return {
4871
4874
  async create(i, e, t) {
4872
4875
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = t || ae(), _ = {
4873
- ...Pe(e),
4876
+ ...yt(e),
4874
4877
  tenant_id: i,
4875
4878
  themeId: o,
4876
4879
  created_at: r,
@@ -4885,7 +4888,7 @@ function Cs(n) {
4885
4888
  return t ? Ft(t) : null;
4886
4889
  },
4887
4890
  async update(i, e, t) {
4888
- const r = Pe(t);
4891
+ const r = yt(t);
4889
4892
  return r.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await n.update(fe).set(r).where(
4890
4893
  g(a(fe.tenant_id, i), a(fe.themeId, e))
4891
4894
  ), !0;
@@ -4936,7 +4939,7 @@ function Ut(n, i) {
4936
4939
  ...typeof n.profileData == "string" ? x(n.profileData, {}) : {}
4937
4940
  }, e;
4938
4941
  }
4939
- function mt(n, i = []) {
4942
+ function pt(n, i = []) {
4940
4943
  const {
4941
4944
  tenant_id: e,
4942
4945
  app_metadata: t,
@@ -4947,10 +4950,10 @@ function mt(n, i = []) {
4947
4950
  is_social: u,
4948
4951
  linked_to: c,
4949
4952
  profileData: d,
4950
- ...m
4953
+ ...h
4951
4954
  } = n, f = Ut(n, !0), y = i.map((N) => Ut(N, !1));
4952
- return z({
4953
- ...m,
4955
+ return T({
4956
+ ...h,
4954
4957
  email: n.email || "",
4955
4958
  email_verified: !!l,
4956
4959
  phone_verified: _ != null ? !!_ : void 0,
@@ -5004,7 +5007,7 @@ function Bs(n) {
5004
5007
  if (t.password && l) {
5005
5008
  await n.run(w`BEGIN`);
5006
5009
  try {
5007
- await n.insert(k).values(o), await n.insert(C).values({
5010
+ await n.insert(k).values(o), await n.insert(A).values({
5008
5011
  id: l,
5009
5012
  tenant_id: e,
5010
5013
  user_id: t.user_id,
@@ -5024,7 +5027,7 @@ function Bs(n) {
5024
5027
  message: "Internal server error"
5025
5028
  }));
5026
5029
  }
5027
- return mt(o);
5030
+ return pt(o);
5028
5031
  };
5029
5032
  return {
5030
5033
  create: i,
@@ -5035,7 +5038,7 @@ function Bs(n) {
5035
5038
  const o = await n.select().from(k).where(
5036
5039
  g(a(k.tenant_id, e), a(k.linked_to, t))
5037
5040
  ).all();
5038
- return mt(r, o);
5041
+ return pt(r, o);
5039
5042
  },
5040
5043
  async update(e, t, r) {
5041
5044
  const o = {
@@ -5078,10 +5081,10 @@ function Bs(n) {
5078
5081
  q: u
5079
5082
  } = t || {}, c = [
5080
5083
  a(k.tenant_id, e),
5081
- ye(k.linked_to)
5084
+ me(k.linked_to)
5082
5085
  ];
5083
5086
  if (u) {
5084
- const H = pe(k, u, [
5087
+ const H = ye(k, u, [
5085
5088
  "email",
5086
5089
  "name",
5087
5090
  "nickname",
@@ -5090,14 +5093,14 @@ function Bs(n) {
5090
5093
  H && c.push(H);
5091
5094
  }
5092
5095
  const d = g(...c);
5093
- let m = n.select().from(k).where(d).$dynamic();
5096
+ let h = n.select().from(k).where(d).$dynamic();
5094
5097
  if (_ != null && _.sort_by) {
5095
5098
  const H = k[_.sort_by];
5096
- H && (m = m.orderBy(
5099
+ H && (h = h.orderBy(
5097
5100
  _.sort_order === "desc" ? V(H) : G(H)
5098
5101
  ));
5099
5102
  }
5100
- const f = await m.offset(r * o).limit(o), y = f.map((H) => H.user_id);
5103
+ const f = await h.offset(r * o).limit(o), y = f.map((H) => H.user_id);
5101
5104
  let N = [];
5102
5105
  y.length > 0 && (N = await n.select().from(k).where(
5103
5106
  g(
@@ -5105,15 +5108,15 @@ function Bs(n) {
5105
5108
  Ne(k.linked_to, y)
5106
5109
  )
5107
5110
  ));
5108
- const A = f.map((H) => {
5111
+ const B = f.map((H) => {
5109
5112
  const ke = N.filter((qe) => qe.linked_to === H.user_id);
5110
- return mt(H, ke);
5113
+ return pt(H, ke);
5111
5114
  });
5112
5115
  if (!l)
5113
- return { users: A };
5116
+ return { users: B };
5114
5117
  const [W] = await n.select({ count: R() }).from(k).where(d);
5115
5118
  return {
5116
- users: A,
5119
+ users: B,
5117
5120
  start: r * o,
5118
5121
  limit: o,
5119
5122
  length: Number((W == null ? void 0 : W.count) ?? 0)
@@ -5125,15 +5128,15 @@ function Bs(n) {
5125
5128
  const r = await n.select({ user_id: k.user_id }).from(k).where(
5126
5129
  g(a(k.tenant_id, e), a(k.linked_to, t))
5127
5130
  ), o = [t, ...r.map((_) => _.user_id)];
5128
- await n.delete(U).where(
5131
+ await n.delete(K).where(
5129
5132
  g(
5130
- a(U.tenant_id, e),
5131
- Ne(U.user_id, o)
5133
+ a(K.tenant_id, e),
5134
+ Ne(K.user_id, o)
5132
5135
  )
5133
- ), await n.delete(C).where(
5136
+ ), await n.delete(A).where(
5134
5137
  g(
5135
- a(C.tenant_id, e),
5136
- Ne(C.user_id, o)
5138
+ a(A.tenant_id, e),
5139
+ Ne(A.user_id, o)
5137
5140
  )
5138
5141
  ), await n.delete(k).where(
5139
5142
  g(a(k.tenant_id, e), a(k.linked_to, t))
@@ -5188,14 +5191,14 @@ function $s(n) {
5188
5191
  }).from(ue).where(g(...o)).all();
5189
5192
  return l.length === 0 ? [] : (await Promise.all(
5190
5193
  l.map(async (u) => {
5191
- const c = await n.select().from(F).where(
5192
- g(a(F.tenant_id, i), a(F.id, u.role_id))
5194
+ const c = await n.select().from(U).where(
5195
+ g(a(U.tenant_id, i), a(U.id, u.role_id))
5193
5196
  ).get();
5194
5197
  if (!c) return null;
5195
- const { tenant_id: d, is_system: m, metadata: f, ...y } = c;
5196
- return z({
5198
+ const { tenant_id: d, is_system: h, metadata: f, ...y } = c;
5199
+ return T({
5197
5200
  ...y,
5198
- is_system: m ? !0 : void 0,
5201
+ is_system: h ? !0 : void 0,
5199
5202
  metadata: x(f)
5200
5203
  });
5201
5204
  })
@@ -5213,7 +5216,7 @@ function $s(n) {
5213
5216
  }
5214
5217
  };
5215
5218
  }
5216
- function Ps(n) {
5219
+ function Qs(n) {
5217
5220
  return {
5218
5221
  async create(i, e) {
5219
5222
  var u, c;
@@ -5226,7 +5229,7 @@ function Ps(n) {
5226
5229
  updated_at: t
5227
5230
  };
5228
5231
  try {
5229
- await n.insert(Q).values(o);
5232
+ await n.insert(P).values(o);
5230
5233
  } catch (d) {
5231
5234
  throw (u = d == null ? void 0 : d.message) != null && u.includes("UNIQUE constraint") || (c = d == null ? void 0 : d.message) != null && c.includes("duplicate key") ? new be(409, {
5232
5235
  message: "User organization already exists"
@@ -5236,10 +5239,10 @@ function Ps(n) {
5236
5239
  return _;
5237
5240
  },
5238
5241
  async get(i, e) {
5239
- const t = await n.select().from(Q).where(
5242
+ const t = await n.select().from(P).where(
5240
5243
  g(
5241
- a(Q.tenant_id, i),
5242
- a(Q.id, e)
5244
+ a(P.tenant_id, i),
5245
+ a(P.id, e)
5243
5246
  )
5244
5247
  ).get();
5245
5248
  if (!t) return null;
@@ -5250,10 +5253,10 @@ function Ps(n) {
5250
5253
  const r = {
5251
5254
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
5252
5255
  };
5253
- return t.user_id !== void 0 && (r.user_id = t.user_id), t.organization_id !== void 0 && (r.organization_id = t.organization_id), (await n.update(Q).set(r).where(
5256
+ 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(P).set(r).where(
5254
5257
  g(
5255
- a(Q.tenant_id, i),
5256
- a(Q.id, e)
5258
+ a(P.tenant_id, i),
5259
+ a(P.id, e)
5257
5260
  )
5258
5261
  ).returning()).length > 0;
5259
5262
  },
@@ -5263,56 +5266,56 @@ function Ps(n) {
5263
5266
  per_page: r = 50,
5264
5267
  include_totals: o = !1,
5265
5268
  q: l
5266
- } = e || {}, _ = a(Q.tenant_id, i);
5269
+ } = e || {}, _ = a(P.tenant_id, i);
5267
5270
  let u = _;
5268
5271
  if (l) {
5269
- const f = pe(Q, l, [
5272
+ const f = ye(P, l, [
5270
5273
  "user_id",
5271
5274
  "organization_id"
5272
5275
  ]);
5273
5276
  f && (u = g(_, f));
5274
5277
  }
5275
- const d = (await n.select().from(Q).where(u).offset(t * r).limit(r)).map((f) => {
5278
+ const d = (await n.select().from(P).where(u).offset(t * r).limit(r)).map((f) => {
5276
5279
  const { tenant_id: y, ...N } = f;
5277
5280
  return N;
5278
5281
  });
5279
5282
  if (!o)
5280
5283
  return { userOrganizations: d };
5281
- const [m] = await n.select({ count: R() }).from(Q).where(u);
5284
+ const [h] = await n.select({ count: R() }).from(P).where(u);
5282
5285
  return {
5283
5286
  userOrganizations: d,
5284
5287
  start: t * r,
5285
5288
  limit: r,
5286
- length: Number((m == null ? void 0 : m.count) ?? 0)
5289
+ length: Number((h == null ? void 0 : h.count) ?? 0)
5287
5290
  };
5288
5291
  },
5289
5292
  async listUserOrganizations(i, e, t) {
5290
- const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(Q).where(
5293
+ const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(P).where(
5291
5294
  g(
5292
- a(Q.tenant_id, i),
5293
- a(Q.user_id, e)
5295
+ a(P.tenant_id, i),
5296
+ a(P.user_id, e)
5294
5297
  )
5295
5298
  ).offset(r * o).limit(o).all(), c = (await Promise.all(
5296
- _.map(async (m) => {
5297
- const f = await n.select().from(L).where(
5299
+ _.map(async (h) => {
5300
+ const f = await n.select().from(E).where(
5298
5301
  g(
5299
- a(L.tenant_id, i),
5300
- a(L.id, m.organization_id)
5302
+ a(E.tenant_id, i),
5303
+ a(E.id, h.organization_id)
5301
5304
  )
5302
5305
  ).get();
5303
5306
  if (!f) return null;
5304
5307
  const {
5305
5308
  tenant_id: y,
5306
5309
  branding: N,
5307
- metadata: A,
5310
+ metadata: B,
5308
5311
  enabled_connections: W,
5309
5312
  token_quota: H,
5310
5313
  ...ke
5311
5314
  } = f;
5312
- return z({
5315
+ return T({
5313
5316
  ...ke,
5314
5317
  branding: x(N, {}),
5315
- metadata: x(A, {}),
5318
+ metadata: x(B, {}),
5316
5319
  enabled_connections: x(W, []),
5317
5320
  token_quota: x(H, {})
5318
5321
  });
@@ -5320,10 +5323,10 @@ function Ps(n) {
5320
5323
  )).filter(Boolean);
5321
5324
  if (!l)
5322
5325
  return { organizations: c };
5323
- const [d] = await n.select({ count: R() }).from(Q).where(
5326
+ const [d] = await n.select({ count: R() }).from(P).where(
5324
5327
  g(
5325
- a(Q.tenant_id, i),
5326
- a(Q.user_id, e)
5328
+ a(P.tenant_id, i),
5329
+ a(P.user_id, e)
5327
5330
  )
5328
5331
  );
5329
5332
  return {
@@ -5334,17 +5337,17 @@ function Ps(n) {
5334
5337
  };
5335
5338
  },
5336
5339
  async remove(i, e) {
5337
- return (await n.delete(Q).where(
5340
+ return (await n.delete(P).where(
5338
5341
  g(
5339
- a(Q.tenant_id, i),
5340
- a(Q.id, e)
5342
+ a(P.tenant_id, i),
5343
+ a(P.id, e)
5341
5344
  )
5342
5345
  ).returning()).length > 0;
5343
5346
  }
5344
5347
  };
5345
5348
  }
5346
- const Kt = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Qs = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
5347
- function Js(n) {
5349
+ const Kt = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Js = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
5350
+ function Ps(n) {
5348
5351
  return {
5349
5352
  async getDaily(i, e) {
5350
5353
  const t = /* @__PURE__ */ new Date(), r = (e == null ? void 0 : e.from) || new Date(t.getTime() - 30 * 24 * 60 * 60 * 1e3).toISOString().split("T")[0], o = (e == null ? void 0 : e.to) || t.toISOString().split("T")[0];
@@ -5358,13 +5361,13 @@ function Js(n) {
5358
5361
  "signups"
5359
5362
  ),
5360
5363
  leaked_passwords: w`SUM(CASE WHEN ${q.type} IN (${w.join(
5361
- Qs.map((_) => w`${_}`),
5364
+ Js.map((_) => w`${_}`),
5362
5365
  w`, `
5363
5366
  )}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
5364
5367
  }).from(q).where(
5365
5368
  g(
5366
5369
  a(q.tenant_id, i),
5367
- Ge(q.date, r),
5370
+ He(q.date, r),
5368
5371
  Oe(q.date, `${o}T23:59:59.999Z`)
5369
5372
  )
5370
5373
  ).groupBy(w`substr(${q.date}, 1, 10)`).orderBy(w`substr(${q.date}, 1, 10)`).all()).map((_) => ({
@@ -5384,7 +5387,7 @@ function Js(n) {
5384
5387
  }).from(q).where(
5385
5388
  g(
5386
5389
  a(q.tenant_id, i),
5387
- Ge(q.date, e),
5390
+ He(q.date, e),
5388
5391
  w`${q.type} IN (${w.join(
5389
5392
  Kt.map((r) => w`${r}`),
5390
5393
  w`, `
@@ -5429,13 +5432,13 @@ function Fs(n) {
5429
5432
  const e = (/* @__PURE__ */ new Date()).toISOString();
5430
5433
  return (await n.select().from(b).where(
5431
5434
  g(
5432
- ye(b.processed_at),
5435
+ me(b.processed_at),
5433
5436
  de(
5434
- ye(b.next_retry_at),
5437
+ me(b.next_retry_at),
5435
5438
  Oe(b.next_retry_at, e)
5436
5439
  ),
5437
5440
  de(
5438
- ye(b.claimed_by),
5441
+ me(b.claimed_by),
5439
5442
  Oe(b.claim_expires_at, e)
5440
5443
  )
5441
5444
  )
@@ -5450,9 +5453,9 @@ function Fs(n) {
5450
5453
  }).where(
5451
5454
  g(
5452
5455
  Ne(b.id, i),
5453
- ye(b.processed_at),
5456
+ me(b.processed_at),
5454
5457
  de(
5455
- ye(b.claimed_by),
5458
+ me(b.claimed_by),
5456
5459
  Oe(b.claim_expires_at, r)
5457
5460
  )
5458
5461
  )
@@ -5495,7 +5498,7 @@ function Fs(n) {
5495
5498
  const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(b).where(
5496
5499
  g(
5497
5500
  a(b.tenant_id, i),
5498
- Ve(b.dead_lettered_at)
5501
+ Me(b.dead_lettered_at)
5499
5502
  )
5500
5503
  ).orderBy(V(b.dead_lettered_at), G(b.id)).offset(t * r).limit(r).all()).map((c) => ({
5501
5504
  ...x(c.payload, {}),
@@ -5513,7 +5516,7 @@ function Fs(n) {
5513
5516
  const [c] = await n.select({ total: R() }).from(b).where(
5514
5517
  g(
5515
5518
  a(b.tenant_id, i),
5516
- Ve(b.dead_lettered_at)
5519
+ Me(b.dead_lettered_at)
5517
5520
  )
5518
5521
  );
5519
5522
  u = Number((c == null ? void 0 : c.total) ?? _.length);
@@ -5537,7 +5540,7 @@ function Fs(n) {
5537
5540
  g(
5538
5541
  a(b.id, i),
5539
5542
  a(b.tenant_id, e),
5540
- Ve(b.dead_lettered_at)
5543
+ Me(b.dead_lettered_at)
5541
5544
  )
5542
5545
  ).returning()).length > 0;
5543
5546
  }
@@ -5550,16 +5553,16 @@ function Ks(n) {
5550
5553
  try {
5551
5554
  let t = [
5552
5555
  de(
5553
- we(T.expires_at_ts, e),
5554
- we(T.idle_expires_at_ts, e)
5556
+ we(z.expires_at_ts, e),
5557
+ we(z.idle_expires_at_ts, e)
5555
5558
  )
5556
5559
  ];
5557
- i != null && i.tenant_id && t.push(a(T.tenant_id, i.tenant_id)), await n.delete(T).where(g(...t)), t = [
5560
+ i != null && i.tenant_id && t.push(a(z.tenant_id, i.tenant_id)), await n.delete(z).where(g(...t)), t = [
5558
5561
  de(
5559
5562
  we($.expires_at_ts, e),
5560
5563
  we($.idle_expires_at_ts, e)
5561
5564
  )
5562
- ], i != null && i.tenant_id && t.push(a($.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a($.user_id, i.user_id)), await n.delete($).where(g(...t)), t = [we(B.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(B.tenant_id, i.tenant_id)), await n.delete(B).where(g(...t));
5565
+ ], i != null && i.tenant_id && t.push(a($.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a($.user_id, i.user_id)), await n.delete($).where(g(...t)), t = [we(L.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(L.tenant_id, i.tenant_id)), await n.delete(L).where(g(...t));
5563
5566
  } catch (t) {
5564
5567
  console.error("Session cleanup error:", t);
5565
5568
  }
@@ -5583,8 +5586,8 @@ function Vs(n, i = { useTransactions: !0 }) {
5583
5586
  hooks: us(n),
5584
5587
  invites: cs(n),
5585
5588
  keys: gs(n),
5586
- loginSessions: hs(n),
5587
- logs: ms(n),
5589
+ loginSessions: ps(n),
5590
+ logs: hs(n),
5588
5591
  authenticationMethods: ys(n),
5589
5592
  organizations: Ns(n),
5590
5593
  passwords: vs(n),
@@ -5601,8 +5604,8 @@ function Vs(n, i = { useTransactions: !0 }) {
5601
5604
  universalLoginTemplates: As(n),
5602
5605
  users: Bs(n),
5603
5606
  userRoles: $s(n),
5604
- userOrganizations: Ps(n),
5605
- stats: Js(n),
5607
+ userOrganizations: Qs(n),
5608
+ stats: Ps(n),
5606
5609
  outbox: Fs(n),
5607
5610
  async transaction(t) {
5608
5611
  if (i.useTransactions === !1)