@authhero/drizzle 0.40.0 → 0.42.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
- var wr = Object.defineProperty;
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 p = (n, i, e) => Nr(n, typeof i != "symbol" ? i + "" : i, e);
1
+ var yr = Object.defineProperty;
2
+ var wr = (n, i, e) => i in n ? yr(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var h = (n, i, e) => wr(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")
@@ -20,27 +20,27 @@ function X(n, i) {
20
20
  }
21
21
  return !1;
22
22
  }
23
- var Mt;
24
- Mt = v;
23
+ var jt;
24
+ jt = v;
25
25
  class Qe {
26
26
  constructor(i, e) {
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");
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");
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
- p(Qe, Mt, "Column");
58
- var Vt;
59
- Vt = v;
60
- class qi {
57
+ h(Qe, jt, "Column");
58
+ var Mt;
59
+ Mt = v;
60
+ class Ti {
61
61
  constructor(i, e, t) {
62
- p(this, "config");
62
+ h(this, "config");
63
63
  /**
64
64
  * Alias for {@link $defaultFn}.
65
65
  */
66
- p(this, "$default", this.$defaultFn);
66
+ h(this, "$default", this.$defaultFn);
67
67
  /**
68
68
  * Alias for {@link $onUpdateFn}.
69
69
  */
70
- p(this, "$onUpdate", this.$onUpdateFn);
70
+ h(this, "$onUpdate", this.$onUpdateFn);
71
71
  this.config = {
72
72
  name: i,
73
73
  keyAsName: i === "",
@@ -147,14 +147,14 @@ class qi {
147
147
  this.config.name === "" && (this.config.name = i);
148
148
  }
149
149
  }
150
- p(qi, Vt, "ColumnBuilder");
150
+ h(Ti, Mt, "ColumnBuilder");
151
151
  const ze = Symbol.for("drizzle:Name"), Tt = Symbol.for("drizzle:isPgEnum");
152
- function vr(n) {
152
+ function Nr(n) {
153
153
  return !!n && typeof n == "function" && Tt in n && n[Tt] === !0;
154
154
  }
155
- var Rt;
156
- Rt = v;
157
- class bt {
155
+ var Vt;
156
+ Vt = v;
157
+ class xt {
158
158
  constructor(i, e, t, r = !1, o = []) {
159
159
  this._ = {
160
160
  brand: "Subquery",
@@ -169,48 +169,48 @@ class bt {
169
169
  // return new SQL([this]);
170
170
  // }
171
171
  }
172
- p(bt, Rt, "Subquery");
173
- const Sr = {
172
+ h(xt, Vt, "Subquery");
173
+ const vr = {
174
174
  startActiveSpan(n, i) {
175
175
  return i();
176
176
  }
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
- var Wt, Ht, Gt, Yt, Xt, Zt, en, tn, nn, rn;
179
- rn = v, nn = ze, tn = Ze, en = Xe, Zt = qt, Xt = Lt, Yt = et, Gt = Ve, Ht = xr, Wt = Et;
177
+ }, Ae = 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"), Sr = Symbol.for("drizzle:IsDrizzleTable");
178
+ var Rt, Wt, Ht, Gt, Yt, Xt, Zt, en, tn, nn;
179
+ nn = v, tn = ze, en = Ze, Zt = Xe, Xt = qt, Yt = Lt, Gt = et, Ht = Ve, Wt = Sr, Rt = 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
- p(this, nn);
186
+ h(this, tn);
187
187
  /**
188
188
  * @internal
189
189
  * Used to store the original name of the table, before any aliasing.
190
190
  */
191
- p(this, tn);
191
+ h(this, en);
192
192
  /** @internal */
193
- p(this, en);
193
+ h(this, Zt);
194
194
  /** @internal */
195
- p(this, Zt);
195
+ h(this, Xt);
196
196
  /** @internal */
197
- p(this, Xt);
197
+ h(this, Yt);
198
198
  /**
199
199
  * @internal
200
200
  * Used to store the table name before the transformation via the `tableCreator` functions.
201
201
  */
202
- p(this, Yt);
202
+ h(this, Gt);
203
203
  /** @internal */
204
- p(this, Gt, !1);
204
+ h(this, Ht, !1);
205
205
  /** @internal */
206
- p(this, Ht, !0);
206
+ h(this, Wt, !0);
207
207
  /** @internal */
208
- p(this, Wt);
208
+ h(this, Rt);
209
209
  this[ze] = this[Ze] = i, this[Xe] = e, this[et] = t;
210
210
  }
211
211
  }
212
- p(M, rn, "Table"), /** @internal */
213
- p(M, "Symbol", {
212
+ h(M, nn, "Table"), /** @internal */
213
+ h(M, "Symbol", {
214
214
  Name: ze,
215
215
  Schema: Xe,
216
216
  OriginalName: Ze,
@@ -220,7 +220,7 @@ p(M, "Symbol", {
220
220
  IsAlias: Ve,
221
221
  ExtraConfigBuilder: Et
222
222
  });
223
- function Li(n) {
223
+ function qi(n) {
224
224
  return n != null && typeof n.getSQL == "function";
225
225
  }
226
226
  function br(n) {
@@ -230,27 +230,27 @@ function br(n) {
230
230
  i.sql += t.sql, i.params.push(...t.params), (e = t.typings) != null && e.length && (i.typings || (i.typings = []), i.typings.push(...t.typings));
231
231
  return i;
232
232
  }
233
- var sn;
234
- sn = v;
233
+ var rn;
234
+ rn = v;
235
235
  class Z {
236
236
  constructor(i) {
237
- p(this, "value");
237
+ h(this, "value");
238
238
  this.value = Array.isArray(i) ? i : [i];
239
239
  }
240
240
  getSQL() {
241
- return new P([this]);
241
+ return new F([this]);
242
242
  }
243
243
  }
244
- p(Z, sn, "StringChunk");
245
- var on;
246
- on = v;
244
+ h(Z, rn, "StringChunk");
245
+ var sn;
246
+ sn = v;
247
247
  const De = class De {
248
248
  constructor(i) {
249
249
  /** @internal */
250
- p(this, "decoder", Ei);
251
- p(this, "shouldInlineParams", !1);
250
+ h(this, "decoder", Li);
251
+ h(this, "shouldInlineParams", !1);
252
252
  /** @internal */
253
- p(this, "usedTables", []);
253
+ h(this, "usedTables", []);
254
254
  this.queryChunks = i;
255
255
  for (const e of i)
256
256
  if (X(e, M)) {
@@ -264,7 +264,7 @@ const De = class De {
264
264
  return this.queryChunks.push(...i.queryChunks), this;
265
265
  }
266
266
  toQuery(i) {
267
- return Sr.startActiveSpan("drizzle.buildSQL", (e) => {
267
+ return vr.startActiveSpan("drizzle.buildSQL", (e) => {
268
268
  const t = this.buildQueryFromSourceParams(this.queryChunks, i);
269
269
  return e == null || e.setAttributes({
270
270
  "drizzle.query.text": t.sql,
@@ -281,73 +281,73 @@ const De = class De {
281
281
  escapeName: o,
282
282
  escapeParam: l,
283
283
  prepareTyping: _,
284
- inlineParams: u,
284
+ inlineParams: d,
285
285
  paramStartIndex: c
286
286
  } = t;
287
- return br(i.map((d) => {
288
- var h;
289
- if (X(d, Z))
290
- return { sql: d.value.join(""), params: [] };
291
- if (X(d, Re))
292
- return { sql: o(d.value), params: [] };
293
- if (d === void 0)
287
+ return br(i.map((u) => {
288
+ var p;
289
+ if (X(u, Z))
290
+ return { sql: u.value.join(""), params: [] };
291
+ if (X(u, Re))
292
+ return { sql: o(u.value), params: [] };
293
+ if (u === void 0)
294
294
  return { sql: "", params: [] };
295
- if (Array.isArray(d)) {
295
+ if (Array.isArray(u)) {
296
296
  const f = [new Z("(")];
297
- for (const [y, N] of d.entries())
298
- f.push(N), y < d.length - 1 && f.push(new Z(", "));
297
+ for (const [y, w] of u.entries())
298
+ f.push(w), y < u.length - 1 && f.push(new Z(", "));
299
299
  return f.push(new Z(")")), this.buildQueryFromSourceParams(f, t);
300
300
  }
301
- if (X(d, De))
302
- return this.buildQueryFromSourceParams(d.queryChunks, {
301
+ if (X(u, De))
302
+ return this.buildQueryFromSourceParams(u.queryChunks, {
303
303
  ...t,
304
- inlineParams: u || d.shouldInlineParams
304
+ inlineParams: d || u.shouldInlineParams
305
305
  });
306
- if (X(d, M)) {
307
- const f = d[M.Symbol.Schema], y = d[M.Symbol.Name];
306
+ if (X(u, M)) {
307
+ const f = u[M.Symbol.Schema], y = u[M.Symbol.Name];
308
308
  return {
309
- sql: f === void 0 || d[Ve] ? o(y) : o(f) + "." + o(y),
309
+ sql: f === void 0 || u[Ve] ? o(y) : o(f) + "." + o(y),
310
310
  params: []
311
311
  };
312
312
  }
313
- if (X(d, Qe)) {
314
- const f = r.getColumnCasing(d);
313
+ if (X(u, Qe)) {
314
+ const f = r.getColumnCasing(u);
315
315
  if (e.invokeSource === "indexes")
316
316
  return { sql: o(f), params: [] };
317
- const y = d.table[M.Symbol.Schema];
317
+ const y = u.table[M.Symbol.Schema];
318
318
  return {
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),
319
+ sql: u.table[Ve] || y === void 0 ? o(u.table[M.Symbol.Name]) + "." + o(f) : o(y) + "." + o(u.table[M.Symbol.Name]) + "." + o(f),
320
320
  params: []
321
321
  };
322
322
  }
323
- if (X(d, Dt)) {
324
- const f = d[Ce].schema, y = d[Ce].name;
323
+ if (X(u, Dt)) {
324
+ const f = u[Ae].schema, y = u[Ae].name;
325
325
  return {
326
- sql: f === void 0 || d[Ce].isAlias ? o(y) : o(f) + "." + o(y),
326
+ sql: f === void 0 || u[Ae].isAlias ? o(y) : o(f) + "." + o(y),
327
327
  params: []
328
328
  };
329
329
  }
330
- if (X(d, Ae)) {
331
- if (X(d.value, Be))
332
- return { sql: l(c.value++, d), params: [d], typings: ["none"] };
333
- const f = d.value === null ? null : d.encoder.mapToDriverValue(d.value);
330
+ if (X(u, Ce)) {
331
+ if (X(u.value, Be))
332
+ return { sql: l(c.value++, u), params: [u], typings: ["none"] };
333
+ const f = u.value === null ? null : u.encoder.mapToDriverValue(u.value);
334
334
  if (X(f, De))
335
335
  return this.buildQueryFromSourceParams([f], t);
336
- if (u)
336
+ if (d)
337
337
  return { sql: this.mapInlineParam(f, t), params: [] };
338
338
  let y = ["none"];
339
- return _ && (y = [_(d.encoder)]), { sql: l(c.value++, f), params: [f], typings: y };
339
+ return _ && (y = [_(u.encoder)]), { sql: l(c.value++, f), params: [f], typings: y };
340
340
  }
341
- return X(d, Be) ? { sql: l(c.value++, d), params: [d], typings: ["none"] } : X(d, De.Aliased) && d.fieldAlias !== void 0 ? { sql: o(d.fieldAlias), params: [] } : X(d, bt) ? d._.isWith ? { sql: o(d._.alias), params: [] } : this.buildQueryFromSourceParams([
341
+ return X(u, Be) ? { sql: l(c.value++, u), params: [u], typings: ["none"] } : X(u, De.Aliased) && u.fieldAlias !== void 0 ? { sql: o(u.fieldAlias), params: [] } : X(u, xt) ? u._.isWith ? { sql: o(u._.alias), params: [] } : this.buildQueryFromSourceParams([
342
342
  new Z("("),
343
- d._.sql,
343
+ u._.sql,
344
344
  new Z(") "),
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([
345
+ new Re(u._.alias)
346
+ ], t) : Nr(u) ? u.schema ? { sql: o(u.schema) + "." + o(u.enumName), params: [] } : { sql: o(u.enumName), params: [] } : qi(u) ? (p = u.shouldOmitSQLParens) != null && p.call(u) ? this.buildQueryFromSourceParams([u.getSQL()], t) : this.buildQueryFromSourceParams([
347
347
  new Z("("),
348
- d.getSQL(),
348
+ u.getSQL(),
349
349
  new Z(")")
350
- ], t) : u ? { sql: this.mapInlineParam(d, t), params: [] } : { sql: l(c.value++, d), params: [d], typings: ["none"] };
350
+ ], t) : d ? { sql: this.mapInlineParam(u, t), params: [] } : { sql: l(c.value++, u), params: [u], typings: ["none"] };
351
351
  }));
352
352
  }
353
353
  mapInlineParam(i, { escapeString: e }) {
@@ -385,95 +385,95 @@ const De = class De {
385
385
  return i ? this : void 0;
386
386
  }
387
387
  };
388
- p(De, on, "SQL");
389
- let P = De;
390
- var an;
391
- an = v;
388
+ h(De, sn, "SQL");
389
+ let F = De;
390
+ var on;
391
+ on = v;
392
392
  class Re {
393
393
  constructor(i) {
394
- p(this, "brand");
394
+ h(this, "brand");
395
395
  this.value = i;
396
396
  }
397
397
  getSQL() {
398
- return new P([this]);
398
+ return new F([this]);
399
399
  }
400
400
  }
401
- p(Re, an, "Name");
402
- function Dr(n) {
401
+ h(Re, on, "Name");
402
+ function xr(n) {
403
403
  return typeof n == "object" && n !== null && "mapToDriverValue" in n && typeof n.mapToDriverValue == "function";
404
404
  }
405
- const Ei = {
405
+ const Li = {
406
406
  mapFromDriverValue: (n) => n
407
- }, Ci = {
407
+ }, Ei = {
408
408
  mapToDriverValue: (n) => n
409
409
  };
410
410
  ({
411
- ...Ei,
412
- ...Ci
411
+ ...Li,
412
+ ...Ei
413
413
  });
414
- var ln;
415
- ln = v;
416
- class Ae {
414
+ var an;
415
+ an = v;
416
+ class Ce {
417
417
  /**
418
418
  * @param value - Parameter value
419
419
  * @param encoder - Encoder to convert the value to a driver parameter
420
420
  */
421
- constructor(i, e = Ci) {
422
- p(this, "brand");
421
+ constructor(i, e = Ei) {
422
+ h(this, "brand");
423
423
  this.value = i, this.encoder = e;
424
424
  }
425
425
  getSQL() {
426
- return new P([this]);
426
+ return new F([this]);
427
427
  }
428
428
  }
429
- p(Ae, ln, "Param");
430
- function w(n, ...i) {
429
+ h(Ce, an, "Param");
430
+ function N(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 P(e);
435
+ return new F(e);
436
436
  }
437
437
  ((n) => {
438
438
  function i() {
439
- return new P([]);
439
+ return new F([]);
440
440
  }
441
441
  n.empty = i;
442
- function e(u) {
443
- return new P(u);
442
+ function e(d) {
443
+ return new F(d);
444
444
  }
445
445
  n.fromList = e;
446
- function t(u) {
447
- return new P([new Z(u)]);
446
+ function t(d) {
447
+ return new F([new Z(d)]);
448
448
  }
449
449
  n.raw = t;
450
- function r(u, c) {
451
- const d = [];
452
- for (const [h, f] of u.entries())
453
- h > 0 && c !== void 0 && d.push(c), d.push(f);
454
- return new P(d);
450
+ function r(d, c) {
451
+ const u = [];
452
+ for (const [p, f] of d.entries())
453
+ p > 0 && c !== void 0 && u.push(c), u.push(f);
454
+ return new F(u);
455
455
  }
456
456
  n.join = r;
457
- function o(u) {
458
- return new Re(u);
457
+ function o(d) {
458
+ return new Re(d);
459
459
  }
460
460
  n.identifier = o;
461
- function l(u) {
462
- return new Be(u);
461
+ function l(d) {
462
+ return new Be(d);
463
463
  }
464
464
  n.placeholder = l;
465
- function _(u, c) {
466
- return new Ae(u, c);
465
+ function _(d, c) {
466
+ return new Ce(d, c);
467
467
  }
468
468
  n.param = _;
469
- })(w || (w = {}));
469
+ })(N || (N = {}));
470
470
  ((n) => {
471
471
  var e;
472
472
  e = v;
473
473
  const t = class t {
474
474
  constructor(o, l) {
475
475
  /** @internal */
476
- p(this, "isSelectionField", !1);
476
+ h(this, "isSelectionField", !1);
477
477
  this.sql = o, this.fieldAlias = l;
478
478
  }
479
479
  getSQL() {
@@ -484,31 +484,31 @@ function w(n, ...i) {
484
484
  return new t(this.sql, this.fieldAlias);
485
485
  }
486
486
  };
487
- p(t, e, "SQL.Aliased");
487
+ h(t, e, "SQL.Aliased");
488
488
  let i = t;
489
489
  n.Aliased = i;
490
- })(P || (P = {}));
491
- var _n;
492
- _n = v;
490
+ })(F || (F = {}));
491
+ var ln;
492
+ ln = v;
493
493
  class Be {
494
494
  constructor(i) {
495
495
  this.name = i;
496
496
  }
497
497
  getSQL() {
498
- return new P([this]);
498
+ return new F([this]);
499
499
  }
500
500
  }
501
- p(Be, _n, "Placeholder");
502
- const Or = Symbol.for("drizzle:IsDrizzleView");
503
- var un, dn, cn;
504
- cn = v, dn = Ce, un = Or;
501
+ h(Be, ln, "Placeholder");
502
+ const Dr = Symbol.for("drizzle:IsDrizzleView");
503
+ var _n, un, dn;
504
+ dn = v, un = Ae, _n = Dr;
505
505
  class Dt {
506
506
  constructor({ name: i, schema: e, selectedFields: t, query: r }) {
507
507
  /** @internal */
508
- p(this, dn);
508
+ h(this, un);
509
509
  /** @internal */
510
- p(this, un, !0);
511
- this[Ce] = {
510
+ h(this, _n, !0);
511
+ this[Ae] = {
512
512
  name: i,
513
513
  originalName: i,
514
514
  schema: e,
@@ -519,18 +519,18 @@ class Dt {
519
519
  };
520
520
  }
521
521
  getSQL() {
522
- return new P([this]);
522
+ return new F([this]);
523
523
  }
524
524
  }
525
- p(Dt, cn, "View");
525
+ h(Dt, dn, "View");
526
526
  Qe.prototype.getSQL = function() {
527
- return new P([this]);
527
+ return new F([this]);
528
528
  };
529
529
  M.prototype.getSQL = function() {
530
- return new P([this]);
530
+ return new F([this]);
531
531
  };
532
- bt.prototype.getSQL = function() {
533
- return new P([this]);
532
+ xt.prototype.getSQL = function() {
533
+ return new F([this]);
534
534
  };
535
535
  function Je(n, i) {
536
536
  return {
@@ -539,18 +539,18 @@ function Je(n, i) {
539
539
  };
540
540
  }
541
541
  const Ai = typeof TextDecoder > "u" ? null : new TextDecoder();
542
- function xe(n, i) {
543
- return Dr(i) && !Li(n) && !X(n, Ae) && !X(n, Be) && !X(n, Qe) && !X(n, M) && !X(n, Dt) ? new Ae(n, i) : n;
542
+ function be(n, i) {
543
+ return xr(i) && !qi(n) && !X(n, Ce) && !X(n, Be) && !X(n, Qe) && !X(n, M) && !X(n, Dt) ? new Ce(n, i) : n;
544
544
  }
545
- const a = (n, i) => w`${n} = ${xe(i, n)}`, kr = (n, i) => w`${n} <> ${xe(i, n)}`;
545
+ const a = (n, i) => N`${n} = ${be(i, n)}`, Or = (n, i) => N`${n} <> ${be(i, n)}`;
546
546
  function g(...n) {
547
547
  const i = n.filter(
548
548
  (e) => e !== void 0
549
549
  );
550
550
  if (i.length !== 0)
551
- return i.length === 1 ? new P(i) : new P([
551
+ return i.length === 1 ? new F(i) : new F([
552
552
  new Z("("),
553
- w.join(i, new Z(" and ")),
553
+ N.join(i, new Z(" and ")),
554
554
  new Z(")")
555
555
  ]);
556
556
  }
@@ -559,35 +559,35 @@ function de(...n) {
559
559
  (e) => e !== void 0
560
560
  );
561
561
  if (i.length !== 0)
562
- return i.length === 1 ? new P(i) : new P([
562
+ return i.length === 1 ? new F(i) : new F([
563
563
  new Z("("),
564
- w.join(i, new Z(" or ")),
564
+ N.join(i, new Z(" or ")),
565
565
  new Z(")")
566
566
  ]);
567
567
  }
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)}`;
568
+ const We = (n, i) => N`${n} > ${be(i, n)}`, He = (n, i) => N`${n} >= ${be(i, n)}`, we = (n, i) => N`${n} < ${be(i, n)}`, Oe = (n, i) => N`${n} <= ${be(i, n)}`;
569
569
  function Ne(n, i) {
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)}`;
570
+ return Array.isArray(i) ? i.length === 0 ? N`false` : N`${n} in ${i.map((e) => be(e, n))}` : N`${n} in ${be(i, n)}`;
571
571
  }
572
- function ye(n) {
573
- return w`${n} is null`;
572
+ function me(n) {
573
+ return N`${n} is null`;
574
574
  }
575
575
  function Me(n) {
576
- return w`${n} is not null`;
576
+ return N`${n} is not null`;
577
577
  }
578
578
  function Ie(n, i) {
579
- return w`${n} like ${i}`;
579
+ return N`${n} like ${i}`;
580
580
  }
581
581
  function G(n) {
582
- return w`${n} asc`;
582
+ return N`${n} asc`;
583
583
  }
584
584
  function V(n) {
585
- return w`${n} desc`;
585
+ return N`${n} desc`;
586
586
  }
587
587
  function R(n) {
588
- return w`count(${w.raw("*")})`.mapWith(Number);
588
+ return N`count(${N.raw("*")})`.mapWith(Number);
589
589
  }
590
- function Ir() {
590
+ function kr() {
591
591
  const n = (i) => {
592
592
  throw new Error(
593
593
  `Actions are not implemented in the Drizzle adapter (called ${i}). Use the Kysely adapter for tenants that require actions.`
@@ -601,16 +601,16 @@ function Ir() {
601
601
  remove: () => n("remove")
602
602
  };
603
603
  }
604
- var gn;
605
- gn = v;
606
- class Bi {
604
+ var cn;
605
+ cn = v;
606
+ class Ci {
607
607
  constructor(i, e) {
608
608
  /** @internal */
609
- p(this, "reference");
609
+ h(this, "reference");
610
610
  /** @internal */
611
- p(this, "_onUpdate");
611
+ h(this, "_onUpdate");
612
612
  /** @internal */
613
- p(this, "_onDelete");
613
+ h(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 };
@@ -624,17 +624,17 @@ class Bi {
624
624
  }
625
625
  /** @internal */
626
626
  build(i) {
627
- return new $i(i, this);
627
+ return new Bi(i, this);
628
628
  }
629
629
  }
630
- p(Bi, gn, "SQLiteForeignKeyBuilder");
631
- var fn;
632
- fn = v;
633
- class $i {
630
+ h(Ci, cn, "SQLiteForeignKeyBuilder");
631
+ var gn;
632
+ gn = v;
633
+ class Bi {
634
634
  constructor(i, e) {
635
- p(this, "reference");
636
- p(this, "onUpdate");
637
- p(this, "onDelete");
635
+ h(this, "reference");
636
+ h(this, "onUpdate");
637
+ h(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
- p($i, fn, "SQLiteForeignKey");
651
- function zr(n, i) {
650
+ h(Bi, gn, "SQLiteForeignKey");
651
+ function Ir(n, i) {
652
652
  return `${n[ze]}_${i.join("_")}_unique`;
653
653
  }
654
- var pn, hn;
655
- class ce extends (hn = qi, pn = v, hn) {
654
+ var fn, hn;
655
+ class ce extends (hn = Ti, fn = v, hn) {
656
656
  constructor() {
657
657
  super(...arguments);
658
- p(this, "foreignKeyConfigs", []);
658
+ h(this, "foreignKeyConfigs", []);
659
659
  }
660
660
  references(e, t = {}) {
661
661
  return this.foreignKeyConfigs.push({ ref: e, actions: t }), this;
@@ -673,35 +673,35 @@ class ce extends (hn = qi, pn = v, hn) {
673
673
  /** @internal */
674
674
  buildForeignKeys(e, t) {
675
675
  return this.foreignKeyConfigs.map(({ ref: r, actions: o }) => ((l, _) => {
676
- const u = new Bi(() => {
676
+ const d = new Ci(() => {
677
677
  const c = l();
678
678
  return { columns: [e], foreignColumns: [c] };
679
679
  });
680
- return _.onUpdate && u.onUpdate(_.onUpdate), _.onDelete && u.onDelete(_.onDelete), u.build(t);
680
+ return _.onUpdate && d.onUpdate(_.onUpdate), _.onDelete && d.onDelete(_.onDelete), d.build(t);
681
681
  })(r, o));
682
682
  }
683
683
  }
684
- p(ce, pn, "SQLiteColumnBuilder");
685
- var mn, yn;
686
- class ge extends (yn = Qe, mn = v, yn) {
684
+ h(ce, fn, "SQLiteColumnBuilder");
685
+ var pn, mn;
686
+ class ge extends (mn = Qe, pn = v, mn) {
687
687
  constructor(i, e) {
688
- e.uniqueName || (e.uniqueName = zr(i, [e.name])), super(i, e), this.table = i;
688
+ e.uniqueName || (e.uniqueName = Ir(i, [e.name])), super(i, e), this.table = i;
689
689
  }
690
690
  }
691
- p(ge, mn, "SQLiteColumn");
692
- var wn, Nn;
693
- class Qi extends (Nn = ce, wn = v, Nn) {
691
+ h(ge, pn, "SQLiteColumn");
692
+ var yn, wn;
693
+ class $i extends (wn = ce, yn = v, wn) {
694
694
  constructor(i) {
695
695
  super(i, "bigint", "SQLiteBigInt");
696
696
  }
697
697
  /** @internal */
698
698
  build(i) {
699
- return new Ji(i, this.config);
699
+ return new Qi(i, this.config);
700
700
  }
701
701
  }
702
- p(Qi, wn, "SQLiteBigIntBuilder");
703
- var vn, Sn;
704
- class Ji extends (Sn = ge, vn = v, Sn) {
702
+ h($i, yn, "SQLiteBigIntBuilder");
703
+ var Nn, vn;
704
+ class Qi extends (vn = ge, Nn = v, vn) {
705
705
  getSQLType() {
706
706
  return "blob";
707
707
  }
@@ -716,23 +716,23 @@ class Ji extends (Sn = ge, vn = v, Sn) {
716
716
  return Buffer.from(i.toString());
717
717
  }
718
718
  }
719
- p(Ji, vn, "SQLiteBigInt");
720
- var xn, bn;
721
- class Pi extends (bn = ce, xn = v, bn) {
719
+ h(Qi, Nn, "SQLiteBigInt");
720
+ var Sn, bn;
721
+ class Ji extends (bn = ce, Sn = v, bn) {
722
722
  constructor(i) {
723
723
  super(i, "json", "SQLiteBlobJson");
724
724
  }
725
725
  /** @internal */
726
726
  build(i) {
727
- return new Fi(
727
+ return new Pi(
728
728
  i,
729
729
  this.config
730
730
  );
731
731
  }
732
732
  }
733
- p(Pi, xn, "SQLiteBlobJsonBuilder");
734
- var Dn, On;
735
- class Fi extends (On = ge, Dn = v, On) {
733
+ h(Ji, Sn, "SQLiteBlobJsonBuilder");
734
+ var xn, Dn;
735
+ class Pi extends (Dn = ge, xn = v, Dn) {
736
736
  getSQLType() {
737
737
  return "blob";
738
738
  }
@@ -747,20 +747,20 @@ class Fi extends (On = ge, Dn = v, On) {
747
747
  return Buffer.from(JSON.stringify(i));
748
748
  }
749
749
  }
750
- p(Fi, Dn, "SQLiteBlobJson");
751
- var kn, In;
752
- class Ui extends (In = ce, kn = v, In) {
750
+ h(Pi, xn, "SQLiteBlobJson");
751
+ var On, kn;
752
+ class Fi extends (kn = ce, On = v, kn) {
753
753
  constructor(i) {
754
754
  super(i, "buffer", "SQLiteBlobBuffer");
755
755
  }
756
756
  /** @internal */
757
757
  build(i) {
758
- return new Ki(i, this.config);
758
+ return new Ui(i, this.config);
759
759
  }
760
760
  }
761
- p(Ui, kn, "SQLiteBlobBufferBuilder");
762
- var zn, Tn;
763
- class Ki extends (Tn = ge, zn = v, Tn) {
761
+ h(Fi, On, "SQLiteBlobBufferBuilder");
762
+ var In, zn;
763
+ class Ui extends (zn = ge, In = v, zn) {
764
764
  mapFromDriverValue(i) {
765
765
  return Buffer.isBuffer(i) ? i : Buffer.from(i);
766
766
  }
@@ -768,32 +768,32 @@ class Ki extends (Tn = ge, zn = v, Tn) {
768
768
  return "blob";
769
769
  }
770
770
  }
771
- p(Ki, zn, "SQLiteBlobBuffer");
772
- function Tr(n, i) {
771
+ h(Ui, In, "SQLiteBlobBuffer");
772
+ function zr(n, i) {
773
773
  const { name: e, config: t } = Je(n, i);
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);
774
+ return (t == null ? void 0 : t.mode) === "json" ? new Ji(e) : (t == null ? void 0 : t.mode) === "bigint" ? new $i(e) : new Fi(e);
775
775
  }
776
- var qn, Ln;
777
- class ji extends (Ln = ce, qn = v, Ln) {
776
+ var Tn, qn;
777
+ class Ki extends (qn = ce, Tn = v, qn) {
778
778
  constructor(i, e, t) {
779
779
  super(i, "custom", "SQLiteCustomColumn"), this.config.fieldConfig = e, this.config.customTypeParams = t;
780
780
  }
781
781
  /** @internal */
782
782
  build(i) {
783
- return new Mi(
783
+ return new ji(
784
784
  i,
785
785
  this.config
786
786
  );
787
787
  }
788
788
  }
789
- p(ji, qn, "SQLiteCustomColumnBuilder");
790
- var En, Cn;
791
- class Mi extends (Cn = ge, En = v, Cn) {
789
+ h(Ki, Tn, "SQLiteCustomColumnBuilder");
790
+ var Ln, En;
791
+ class ji extends (En = ge, Ln = v, En) {
792
792
  constructor(e, t) {
793
793
  super(e, t);
794
- p(this, "sqlName");
795
- p(this, "mapTo");
796
- p(this, "mapFrom");
794
+ h(this, "sqlName");
795
+ h(this, "mapTo");
796
+ h(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,19 +806,19 @@ class Mi extends (Cn = ge, En = v, Cn) {
806
806
  return typeof this.mapTo == "function" ? this.mapTo(e) : e;
807
807
  }
808
808
  }
809
- p(Mi, En, "SQLiteCustomColumn");
810
- function qr(n) {
809
+ h(ji, Ln, "SQLiteCustomColumn");
810
+ function Tr(n) {
811
811
  return (i, e) => {
812
812
  const { name: t, config: r } = Je(i, e);
813
- return new ji(
813
+ return new Ki(
814
814
  t,
815
815
  r,
816
816
  n
817
817
  );
818
818
  };
819
819
  }
820
- var An, Bn;
821
- class Ge extends (Bn = ce, An = v, Bn) {
820
+ var An, Cn;
821
+ class Ge extends (Cn = ce, An = v, Cn) {
822
822
  constructor(i, e, t) {
823
823
  super(i, e, t), this.config.autoIncrement = !1;
824
824
  }
@@ -826,37 +826,37 @@ class Ge 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
- p(Ge, An, "SQLiteBaseIntegerBuilder");
830
- var $n, Qn;
831
- class Ye extends (Qn = ge, $n = v, Qn) {
829
+ h(Ge, An, "SQLiteBaseIntegerBuilder");
830
+ var Bn, $n;
831
+ class Ye extends ($n = ge, Bn = v, $n) {
832
832
  constructor() {
833
833
  super(...arguments);
834
- p(this, "autoIncrement", this.config.autoIncrement);
834
+ h(this, "autoIncrement", this.config.autoIncrement);
835
835
  }
836
836
  getSQLType() {
837
837
  return "integer";
838
838
  }
839
839
  }
840
- p(Ye, $n, "SQLiteBaseInteger");
841
- var Jn, Pn;
842
- class Vi extends (Pn = Ge, Jn = v, Pn) {
840
+ h(Ye, Bn, "SQLiteBaseInteger");
841
+ var Qn, Jn;
842
+ class Mi extends (Jn = Ge, Qn = v, Jn) {
843
843
  constructor(i) {
844
844
  super(i, "number", "SQLiteInteger");
845
845
  }
846
846
  build(i) {
847
- return new Ri(
847
+ return new Vi(
848
848
  i,
849
849
  this.config
850
850
  );
851
851
  }
852
852
  }
853
- p(Vi, Jn, "SQLiteIntegerBuilder");
854
- var Fn, Un;
855
- class Ri extends (Un = Ye, Fn = v, Un) {
853
+ h(Mi, Qn, "SQLiteIntegerBuilder");
854
+ var Pn, Fn;
855
+ class Vi extends (Fn = Ye, Pn = v, Fn) {
856
856
  }
857
- p(Ri, Fn, "SQLiteInteger");
858
- var Kn, jn;
859
- class Wi extends (jn = Ge, Kn = v, jn) {
857
+ h(Vi, Pn, "SQLiteInteger");
858
+ var Un, Kn;
859
+ class Ri extends (Kn = Ge, Un = v, Kn) {
860
860
  constructor(i, e) {
861
861
  super(i, "date", "SQLiteTimestamp"), this.config.mode = e;
862
862
  }
@@ -866,21 +866,21 @@ class Wi extends (jn = Ge, Kn = v, jn) {
866
866
  * Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
867
867
  */
868
868
  defaultNow() {
869
- return this.default(w`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
869
+ return this.default(N`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
870
870
  }
871
871
  build(i) {
872
- return new Hi(
872
+ return new Wi(
873
873
  i,
874
874
  this.config
875
875
  );
876
876
  }
877
877
  }
878
- p(Wi, Kn, "SQLiteTimestampBuilder");
879
- var Mn, Vn;
880
- class Hi extends (Vn = Ye, Mn = v, Vn) {
878
+ h(Ri, Un, "SQLiteTimestampBuilder");
879
+ var jn, Mn;
880
+ class Wi extends (Mn = Ye, jn = v, Mn) {
881
881
  constructor() {
882
882
  super(...arguments);
883
- p(this, "mode", this.config.mode);
883
+ h(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,25 +890,25 @@ class Hi extends (Vn = Ye, Mn = v, Vn) {
890
890
  return this.config.mode === "timestamp" ? Math.floor(t / 1e3) : t;
891
891
  }
892
892
  }
893
- p(Hi, Mn, "SQLiteTimestamp");
894
- var Rn, Wn;
895
- class Gi extends (Wn = Ge, Rn = v, Wn) {
893
+ h(Wi, jn, "SQLiteTimestamp");
894
+ var Vn, Rn;
895
+ class Hi extends (Rn = Ge, Vn = v, Rn) {
896
896
  constructor(i, e) {
897
897
  super(i, "boolean", "SQLiteBoolean"), this.config.mode = e;
898
898
  }
899
899
  build(i) {
900
- return new Yi(
900
+ return new Gi(
901
901
  i,
902
902
  this.config
903
903
  );
904
904
  }
905
905
  }
906
- p(Gi, Rn, "SQLiteBooleanBuilder");
907
- var Hn, Gn;
908
- class Yi extends (Gn = Ye, Hn = v, Gn) {
906
+ h(Hi, Vn, "SQLiteBooleanBuilder");
907
+ var Wn, Hn;
908
+ class Gi extends (Hn = Ye, Wn = v, Hn) {
909
909
  constructor() {
910
910
  super(...arguments);
911
- p(this, "mode", this.config.mode);
911
+ h(this, "mode", this.config.mode);
912
912
  }
913
913
  mapFromDriverValue(e) {
914
914
  return Number(e) === 1;
@@ -917,27 +917,27 @@ class Yi extends (Gn = Ye, Hn = v, Gn) {
917
917
  return e ? 1 : 0;
918
918
  }
919
919
  }
920
- p(Yi, Hn, "SQLiteBoolean");
920
+ h(Gi, Wn, "SQLiteBoolean");
921
921
  function m(n, i) {
922
922
  const { name: e, config: t } = Je(n, i);
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);
923
+ return (t == null ? void 0 : t.mode) === "timestamp" || (t == null ? void 0 : t.mode) === "timestamp_ms" ? new Ri(e, t.mode) : (t == null ? void 0 : t.mode) === "boolean" ? new Hi(e, t.mode) : new Mi(e);
924
924
  }
925
- var Yn, Xn;
926
- class Xi extends (Xn = ce, Yn = v, Xn) {
925
+ var Gn, Yn;
926
+ class Yi extends (Yn = ce, Gn = v, Yn) {
927
927
  constructor(i) {
928
928
  super(i, "string", "SQLiteNumeric");
929
929
  }
930
930
  /** @internal */
931
931
  build(i) {
932
- return new Zi(
932
+ return new Xi(
933
933
  i,
934
934
  this.config
935
935
  );
936
936
  }
937
937
  }
938
- p(Xi, Yn, "SQLiteNumericBuilder");
939
- var Zn, ei;
940
- class Zi extends (ei = ge, Zn = v, ei) {
938
+ h(Yi, Gn, "SQLiteNumericBuilder");
939
+ var Xn, Zn;
940
+ class Xi extends (Zn = ge, Xn = v, Zn) {
941
941
  mapFromDriverValue(i) {
942
942
  return typeof i == "string" ? i : String(i);
943
943
  }
@@ -945,26 +945,26 @@ class Zi extends (ei = ge, Zn = v, ei) {
945
945
  return "numeric";
946
946
  }
947
947
  }
948
- p(Zi, Zn, "SQLiteNumeric");
949
- var ti, ni;
950
- class er extends (ni = ce, ti = v, ni) {
948
+ h(Xi, Xn, "SQLiteNumeric");
949
+ var ei, ti;
950
+ class Zi extends (ti = ce, ei = v, ti) {
951
951
  constructor(i) {
952
952
  super(i, "number", "SQLiteNumericNumber");
953
953
  }
954
954
  /** @internal */
955
955
  build(i) {
956
- return new tr(
956
+ return new er(
957
957
  i,
958
958
  this.config
959
959
  );
960
960
  }
961
961
  }
962
- p(er, ti, "SQLiteNumericNumberBuilder");
963
- var ii, ri;
964
- class tr extends (ri = ge, ii = v, ri) {
962
+ h(Zi, ei, "SQLiteNumericNumberBuilder");
963
+ var ni, ii;
964
+ class er extends (ii = ge, ni = v, ii) {
965
965
  constructor() {
966
966
  super(...arguments);
967
- p(this, "mapToDriverValue", String);
967
+ h(this, "mapToDriverValue", String);
968
968
  }
969
969
  mapFromDriverValue(e) {
970
970
  return typeof e == "number" ? e : Number(e);
@@ -973,100 +973,100 @@ class tr extends (ri = ge, ii = v, ri) {
973
973
  return "numeric";
974
974
  }
975
975
  }
976
- p(tr, ii, "SQLiteNumericNumber");
977
- var si, oi;
978
- class nr extends (oi = ce, si = v, oi) {
976
+ h(er, ni, "SQLiteNumericNumber");
977
+ var ri, si;
978
+ class tr extends (si = ce, ri = v, si) {
979
979
  constructor(i) {
980
980
  super(i, "bigint", "SQLiteNumericBigInt");
981
981
  }
982
982
  /** @internal */
983
983
  build(i) {
984
- return new ir(
984
+ return new nr(
985
985
  i,
986
986
  this.config
987
987
  );
988
988
  }
989
989
  }
990
- p(nr, si, "SQLiteNumericBigIntBuilder");
991
- var ai, li;
992
- class ir extends (li = ge, ai = v, li) {
990
+ h(tr, ri, "SQLiteNumericBigIntBuilder");
991
+ var oi, ai;
992
+ class nr extends (ai = ge, oi = v, ai) {
993
993
  constructor() {
994
994
  super(...arguments);
995
- p(this, "mapFromDriverValue", BigInt);
996
- p(this, "mapToDriverValue", String);
995
+ h(this, "mapFromDriverValue", BigInt);
996
+ h(this, "mapToDriverValue", String);
997
997
  }
998
998
  getSQLType() {
999
999
  return "numeric";
1000
1000
  }
1001
1001
  }
1002
- p(ir, ai, "SQLiteNumericBigInt");
1003
- function Lr(n, i) {
1002
+ h(nr, oi, "SQLiteNumericBigInt");
1003
+ function qr(n, i) {
1004
1004
  const { name: e, config: t } = Je(n, i), r = t == null ? void 0 : t.mode;
1005
- return r === "number" ? new er(e) : r === "bigint" ? new nr(e) : new Xi(e);
1005
+ return r === "number" ? new Zi(e) : r === "bigint" ? new tr(e) : new Yi(e);
1006
1006
  }
1007
- var _i, ui;
1008
- class rr extends (ui = ce, _i = v, ui) {
1007
+ var li, _i;
1008
+ class ir extends (_i = ce, li = v, _i) {
1009
1009
  constructor(i) {
1010
1010
  super(i, "number", "SQLiteReal");
1011
1011
  }
1012
1012
  /** @internal */
1013
1013
  build(i) {
1014
- return new sr(i, this.config);
1014
+ return new rr(i, this.config);
1015
1015
  }
1016
1016
  }
1017
- p(rr, _i, "SQLiteRealBuilder");
1018
- var di, ci;
1019
- class sr extends (ci = ge, di = v, ci) {
1017
+ h(ir, li, "SQLiteRealBuilder");
1018
+ var ui, di;
1019
+ class rr extends (di = ge, ui = v, di) {
1020
1020
  getSQLType() {
1021
1021
  return "real";
1022
1022
  }
1023
1023
  }
1024
- p(sr, di, "SQLiteReal");
1025
- function Er(n) {
1026
- return new rr(n ?? "");
1024
+ h(rr, ui, "SQLiteReal");
1025
+ function Lr(n) {
1026
+ return new ir(n ?? "");
1027
1027
  }
1028
- var gi, fi;
1029
- class or extends (fi = ce, gi = v, fi) {
1028
+ var ci, gi;
1029
+ class sr extends (gi = ce, ci = v, gi) {
1030
1030
  constructor(i, e) {
1031
1031
  super(i, "string", "SQLiteText"), this.config.enumValues = e.enum, this.config.length = e.length;
1032
1032
  }
1033
1033
  /** @internal */
1034
1034
  build(i) {
1035
- return new ar(
1035
+ return new or(
1036
1036
  i,
1037
1037
  this.config
1038
1038
  );
1039
1039
  }
1040
1040
  }
1041
- p(or, gi, "SQLiteTextBuilder");
1042
- var pi, hi;
1043
- class ar extends (hi = ge, pi = v, hi) {
1041
+ h(sr, ci, "SQLiteTextBuilder");
1042
+ var fi, hi;
1043
+ class or extends (hi = ge, fi = v, hi) {
1044
1044
  constructor(e, t) {
1045
1045
  super(e, t);
1046
- p(this, "enumValues", this.config.enumValues);
1047
- p(this, "length", this.config.length);
1046
+ h(this, "enumValues", this.config.enumValues);
1047
+ h(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
- p(ar, pi, "SQLiteText");
1054
- var mi, yi;
1055
- class lr extends (yi = ce, mi = v, yi) {
1053
+ h(or, fi, "SQLiteText");
1054
+ var pi, mi;
1055
+ class ar extends (mi = ce, pi = v, mi) {
1056
1056
  constructor(i) {
1057
1057
  super(i, "json", "SQLiteTextJson");
1058
1058
  }
1059
1059
  /** @internal */
1060
1060
  build(i) {
1061
- return new _r(
1061
+ return new lr(
1062
1062
  i,
1063
1063
  this.config
1064
1064
  );
1065
1065
  }
1066
1066
  }
1067
- p(lr, mi, "SQLiteTextJsonBuilder");
1068
- var wi, Ni;
1069
- class _r extends (Ni = ge, wi = v, Ni) {
1067
+ h(ar, pi, "SQLiteTextJsonBuilder");
1068
+ var yi, wi;
1069
+ class lr extends (wi = ge, yi = v, wi) {
1070
1070
  getSQLType() {
1071
1071
  return "text";
1072
1072
  }
@@ -1077,67 +1077,67 @@ class _r extends (Ni = ge, wi = v, Ni) {
1077
1077
  return JSON.stringify(i);
1078
1078
  }
1079
1079
  }
1080
- p(_r, wi, "SQLiteTextJson");
1080
+ h(lr, yi, "SQLiteTextJson");
1081
1081
  function s(n, i = {}) {
1082
1082
  const { name: e, config: t } = Je(n, i);
1083
- return t.mode === "json" ? new lr(e) : new or(e, t);
1083
+ return t.mode === "json" ? new ar(e) : new sr(e, t);
1084
1084
  }
1085
- function Cr() {
1085
+ function Er() {
1086
1086
  return {
1087
- blob: Tr,
1088
- customType: qr,
1087
+ blob: zr,
1088
+ customType: Tr,
1089
1089
  integer: m,
1090
- numeric: Lr,
1091
- real: Er,
1090
+ numeric: qr,
1091
+ real: Lr,
1092
1092
  text: s
1093
1093
  };
1094
1094
  }
1095
- const ht = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1096
- var vi, Si, xi, bi, Di;
1097
- class $e extends (Di = M, bi = v, xi = M.Symbol.Columns, Si = ht, vi = M.Symbol.ExtraConfigBuilder, Di) {
1095
+ const pt = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1096
+ var Ni, vi, Si, bi, xi;
1097
+ class $e extends (xi = M, bi = v, Si = M.Symbol.Columns, vi = pt, Ni = M.Symbol.ExtraConfigBuilder, xi) {
1098
1098
  constructor() {
1099
1099
  super(...arguments);
1100
1100
  /** @internal */
1101
- p(this, xi);
1101
+ h(this, Si);
1102
1102
  /** @internal */
1103
- p(this, Si, []);
1103
+ h(this, vi, []);
1104
1104
  /** @internal */
1105
- p(this, vi);
1105
+ h(this, Ni);
1106
1106
  }
1107
1107
  }
1108
- p($e, bi, "SQLiteTable"), /** @internal */
1109
- p($e, "Symbol", Object.assign({}, M.Symbol, {
1110
- InlineForeignKeys: ht
1108
+ h($e, bi, "SQLiteTable"), /** @internal */
1109
+ h($e, "Symbol", Object.assign({}, M.Symbol, {
1110
+ InlineForeignKeys: pt
1111
1111
  }));
1112
1112
  function Ar(n, i, e, t, r = n) {
1113
- const o = new $e(n, t, r), l = typeof i == "function" ? i(Cr()) : i, _ = Object.fromEntries(
1114
- Object.entries(l).map(([c, d]) => {
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];
1113
+ const o = new $e(n, t, r), l = typeof i == "function" ? i(Er()) : i, _ = Object.fromEntries(
1114
+ Object.entries(l).map(([c, u]) => {
1115
+ const p = u;
1116
+ p.setName(c);
1117
+ const f = p.build(o);
1118
+ return o[pt].push(...p.buildForeignKeys(f, o)), [c, f];
1119
1119
  })
1120
- ), u = Object.assign(o, _);
1121
- return u[M.Symbol.Columns] = _, u[M.Symbol.ExtraConfigColumns] = _, e && (u[$e.Symbol.ExtraConfigBuilder] = e), u;
1120
+ ), d = Object.assign(o, _);
1121
+ return d[M.Symbol.Columns] = _, d[M.Symbol.ExtraConfigColumns] = _, e && (d[$e.Symbol.ExtraConfigBuilder] = e), d;
1122
1122
  }
1123
1123
  const O = (n, i, e) => Ar(n, i, e);
1124
- var Oi;
1125
- Oi = v;
1124
+ var Di;
1125
+ Di = v;
1126
1126
  class Ot {
1127
1127
  constructor(i, e) {
1128
1128
  this.name = i, this.unique = e;
1129
1129
  }
1130
1130
  on(...i) {
1131
- return new ur(this.name, i, this.unique);
1131
+ return new _r(this.name, i, this.unique);
1132
1132
  }
1133
1133
  }
1134
- p(Ot, Oi, "SQLiteIndexBuilderOn");
1135
- var ki;
1136
- ki = v;
1137
- class ur {
1134
+ h(Ot, Di, "SQLiteIndexBuilderOn");
1135
+ var Oi;
1136
+ Oi = v;
1137
+ class _r {
1138
1138
  constructor(i, e, t) {
1139
1139
  /** @internal */
1140
- p(this, "config");
1140
+ h(this, "config");
1141
1141
  this.config = {
1142
1142
  name: i,
1143
1143
  columns: e,
@@ -1153,19 +1153,19 @@ class ur {
1153
1153
  }
1154
1154
  /** @internal */
1155
1155
  build(i) {
1156
- return new dr(this.config, i);
1156
+ return new ur(this.config, i);
1157
1157
  }
1158
1158
  }
1159
- p(ur, ki, "SQLiteIndexBuilder");
1160
- var Ii;
1161
- Ii = v;
1162
- class dr {
1159
+ h(_r, Oi, "SQLiteIndexBuilder");
1160
+ var ki;
1161
+ ki = v;
1162
+ class ur {
1163
1163
  constructor(i, e) {
1164
- p(this, "config");
1164
+ h(this, "config");
1165
1165
  this.config = { ...i, table: e };
1166
1166
  }
1167
1167
  }
1168
- p(dr, Ii, "SQLiteIndex");
1168
+ h(ur, ki, "SQLiteIndex");
1169
1169
  function S(n) {
1170
1170
  return new Ot(n, !1);
1171
1171
  }
@@ -1175,35 +1175,35 @@ function Te(n) {
1175
1175
  function oe(...n) {
1176
1176
  return n[0].columns ? new mt(n[0].columns, n[0].name) : new mt(n);
1177
1177
  }
1178
- var zi;
1179
- zi = v;
1178
+ var Ii;
1179
+ Ii = v;
1180
1180
  class mt {
1181
1181
  constructor(i, e) {
1182
1182
  /** @internal */
1183
- p(this, "columns");
1183
+ h(this, "columns");
1184
1184
  /** @internal */
1185
- p(this, "name");
1185
+ h(this, "name");
1186
1186
  this.columns = i, this.name = e;
1187
1187
  }
1188
1188
  /** @internal */
1189
1189
  build(i) {
1190
- return new cr(i, this.columns, this.name);
1190
+ return new dr(i, this.columns, this.name);
1191
1191
  }
1192
1192
  }
1193
- p(mt, zi, "SQLitePrimaryKeyBuilder");
1194
- var Ti;
1195
- Ti = v;
1196
- class cr {
1193
+ h(mt, Ii, "SQLitePrimaryKeyBuilder");
1194
+ var zi;
1195
+ zi = v;
1196
+ class dr {
1197
1197
  constructor(i, e, t) {
1198
- p(this, "columns");
1199
- p(this, "name");
1198
+ h(this, "columns");
1199
+ h(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
- p(cr, Ti, "SQLitePrimaryKey");
1206
+ h(dr, zi, "SQLitePrimaryKey");
1207
1207
  const D = O("tenants", {
1208
1208
  id: s("id", { length: 191 }).primaryKey(),
1209
1209
  name: s("name", { length: 255 }),
@@ -1332,7 +1332,7 @@ const D = O("tenants", {
1332
1332
  n.provider
1333
1333
  )
1334
1334
  ]
1335
- ), A = O("passwords", {
1335
+ ), C = 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(),
@@ -1341,7 +1341,7 @@ const D = O("tenants", {
1341
1341
  password: s("password", { length: 255 }).notNull(),
1342
1342
  algorithm: s("algorithm", { length: 16 }).notNull().default("bcrypt"),
1343
1343
  is_current: m("is_current").notNull().default(1)
1344
- }), $ = O(
1344
+ }), Q = O(
1345
1345
  "sessions",
1346
1346
  {
1347
1347
  id: s("id", { length: 21 }).notNull(),
@@ -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
+ ), E = O(
1369
1369
  "refresh_tokens",
1370
1370
  {
1371
1371
  id: s("id", { length: 21 }).notNull(),
@@ -1379,7 +1379,8 @@ const D = O("tenants", {
1379
1379
  created_at_ts: m("created_at_ts").notNull(),
1380
1380
  expires_at_ts: m("expires_at_ts"),
1381
1381
  idle_expires_at_ts: m("idle_expires_at_ts"),
1382
- last_exchanged_at_ts: m("last_exchanged_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,7 +1391,7 @@ 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
- ), L = O(
1394
+ ), q = O(
1394
1395
  "login_sessions",
1395
1396
  {
1396
1397
  id: s("id", { length: 21 }).notNull(),
@@ -1433,7 +1434,7 @@ const D = O("tenants", {
1433
1434
  S("login_sessions_tenant_user_idx").on(n.tenant_id, n.user_id),
1434
1435
  S("idx_login_sessions_expires_at_ts").on(n.expires_at_ts)
1435
1436
  ]
1436
- ), Q = O(
1437
+ ), J = O(
1437
1438
  "codes",
1438
1439
  {
1439
1440
  code_id: s("code_id", { length: 191 }).notNull(),
@@ -1459,7 +1460,7 @@ const D = O("tenants", {
1459
1460
  }),
1460
1461
  S("codes_expires_at_index").on(n.expires_at)
1461
1462
  ]
1462
- ), Br = O("authentication_codes", {
1463
+ ), Cr = O("authentication_codes", {
1463
1464
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1464
1465
  code: s("code", { length: 255 }).primaryKey(),
1465
1466
  client_id: s("client_id", { length: 255 }).notNull(),
@@ -1473,7 +1474,7 @@ const D = O("tenants", {
1473
1474
  created_at: s("created_at", { length: 35 }).notNull(),
1474
1475
  expires_at: s("expires_at", { length: 35 }).notNull(),
1475
1476
  used_at: s("used_at", { length: 35 })
1476
- }), $r = O(
1477
+ }), Br = O(
1477
1478
  "otps",
1478
1479
  {
1479
1480
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
@@ -1499,7 +1500,7 @@ const D = O("tenants", {
1499
1500
  S("otps_email_index").on(n.email),
1500
1501
  S("otps_expires_at_index").on(n.expires_at)
1501
1502
  ]
1502
- ), Qr = O("tickets", {
1503
+ ), $r = O("tickets", {
1503
1504
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1504
1505
  id: s("id", { length: 255 }).primaryKey(),
1505
1506
  client_id: s("client_id", { length: 255 }).notNull(),
@@ -1609,7 +1610,7 @@ const D = O("tenants", {
1609
1610
  }),
1610
1611
  S("idx_client_grants_audience").on(n.audience)
1611
1612
  ]
1612
- ), K = O(
1613
+ ), j = O(
1613
1614
  "connections",
1614
1615
  {
1615
1616
  id: s("id", { length: 255 }).notNull(),
@@ -1651,7 +1652,7 @@ const D = O("tenants", {
1651
1652
  updated_at: s("updated_at", { length: 35 }).notNull()
1652
1653
  },
1653
1654
  (n) => [Te("custom_domains_domain_unique").on(n.domain)]
1654
- ), Jr = O("domains", {
1655
+ ), Qr = O("domains", {
1655
1656
  id: s("id", { length: 255 }).primaryKey(),
1656
1657
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => D.id, { onDelete: "cascade" }),
1657
1658
  domain: s("domain", { length: 255 }).notNull(),
@@ -1661,7 +1662,7 @@ const D = O("tenants", {
1661
1662
  dkim_public_key: s("dkim_public_key", { length: 2048 }),
1662
1663
  created_at: s("created_at", { length: 35 }).notNull(),
1663
1664
  updated_at: s("updated_at", { length: 35 }).notNull()
1664
- }), E = O(
1665
+ }), L = O(
1665
1666
  "organizations",
1666
1667
  {
1667
1668
  id: s("id", { length: 21 }).primaryKey(),
@@ -1676,7 +1677,7 @@ const D = O("tenants", {
1676
1677
  updated_at: s("updated_at", { length: 35 }).notNull()
1677
1678
  },
1678
1679
  (n) => [S("idx_organizations_tenant_id").on(n.tenant_id)]
1679
- ), J = O(
1680
+ ), P = O(
1680
1681
  "user_organizations",
1681
1682
  {
1682
1683
  id: s("id", { length: 21 }).primaryKey(),
@@ -1722,7 +1723,7 @@ const D = O("tenants", {
1722
1723
  S("idx_invites_expires_at").on(n.expires_at),
1723
1724
  S("idx_invites_tenant_created").on(n.tenant_id, n.created_at)
1724
1725
  ]
1725
- ), F = O(
1726
+ ), U = O(
1726
1727
  "roles",
1727
1728
  {
1728
1729
  id: s("id", { length: 21 }).notNull(),
@@ -1819,7 +1820,7 @@ const D = O("tenants", {
1819
1820
  S("user_roles_role_fk").on(n.tenant_id, n.role_id),
1820
1821
  S("user_roles_organization_fk").on(n.organization_id)
1821
1822
  ]
1822
- ), C = O(
1823
+ ), A = O(
1823
1824
  "resource_servers",
1824
1825
  {
1825
1826
  id: s("id", { length: 21 }).notNull(),
@@ -2066,7 +2067,7 @@ const D = O("tenants", {
2066
2067
  // only required for code type hooks
2067
2068
  },
2068
2069
  (n) => [S("hooks_tenant_id_idx").on(n.tenant_id)]
2069
- ), pe = O(
2070
+ ), he = O(
2070
2071
  "hook_code",
2071
2072
  {
2072
2073
  id: s("id", { length: 21 }).primaryKey(),
@@ -2077,7 +2078,7 @@ const D = O("tenants", {
2077
2078
  updated_at_ts: m("updated_at_ts").notNull()
2078
2079
  },
2079
2080
  (n) => [S("hook_code_tenant_id_idx").on(n.tenant_id)]
2080
- ), he = O("keys", {
2081
+ ), pe = O("keys", {
2081
2082
  kid: s("kid", { length: 255 }).primaryKey(),
2082
2083
  tenant_id: s("tenant_id", { length: 191 }).references(() => D.id, {
2083
2084
  onDelete: "cascade"
@@ -2092,7 +2093,7 @@ const D = O("tenants", {
2092
2093
  current_until: s("current_until", { length: 35 }),
2093
2094
  type: s("type", { length: 50 }).notNull().default("jwt_signing"),
2094
2095
  connection: s("connection", { length: 255 }).references(
2095
- () => K.id,
2096
+ () => j.id,
2096
2097
  { onDelete: "cascade" }
2097
2098
  )
2098
2099
  }), te = O(
@@ -2108,7 +2109,7 @@ const D = O("tenants", {
2108
2109
  (n) => [
2109
2110
  oe({ columns: [n.tenant_id, n.prompt, n.language] })
2110
2111
  ]
2111
- ), U = O(
2112
+ ), K = O(
2112
2113
  "authentication_methods",
2113
2114
  {
2114
2115
  id: s("id", { length: 26 }).primaryKey(),
@@ -2134,7 +2135,7 @@ const D = O("tenants", {
2134
2135
  ),
2135
2136
  S("authentication_methods_credential_id_idx").on(n.credential_id)
2136
2137
  ]
2137
- ), q = O(
2138
+ ), T = O(
2138
2139
  "logs",
2139
2140
  {
2140
2141
  log_id: s("log_id", { length: 21 }).primaryKey(),
@@ -2178,7 +2179,7 @@ const D = O("tenants", {
2178
2179
  n.user_id
2179
2180
  )
2180
2181
  ]
2181
- ), b = O(
2182
+ ), x = O(
2182
2183
  "outbox_events",
2183
2184
  {
2184
2185
  id: s("id", { length: 26 }).primaryKey(),
@@ -2213,40 +2214,40 @@ const D = O("tenants", {
2213
2214
  ]
2214
2215
  ), Ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2215
2216
  __proto__: null,
2216
- authenticationCodes: Br,
2217
- authenticationMethods: U,
2217
+ authenticationCodes: Cr,
2218
+ authenticationMethods: K,
2218
2219
  branding: Le,
2219
2220
  clientGrants: Y,
2220
2221
  clients: I,
2221
- codes: Q,
2222
- connections: K,
2222
+ codes: J,
2223
+ connections: j,
2223
2224
  customDomains: se,
2224
2225
  customText: te,
2225
- domains: Jr,
2226
+ domains: Qr,
2226
2227
  emailProviders: Se,
2227
2228
  flows: re,
2228
2229
  forms: ie,
2229
- hookCode: pe,
2230
+ hookCode: he,
2230
2231
  hooks: ee,
2231
2232
  invites: ne,
2232
- keys: he,
2233
- loginSessions: L,
2234
- logs: q,
2235
- organizations: E,
2236
- otps: $r,
2237
- outboxEvents: b,
2238
- passwords: A,
2233
+ keys: pe,
2234
+ loginSessions: q,
2235
+ logs: T,
2236
+ organizations: L,
2237
+ otps: Br,
2238
+ outboxEvents: x,
2239
+ passwords: C,
2239
2240
  promptSettings: Ee,
2240
- refreshTokens: T,
2241
- resourceServers: C,
2241
+ refreshTokens: E,
2242
+ resourceServers: A,
2242
2243
  rolePermissions: le,
2243
- roles: F,
2244
- sessions: $,
2244
+ roles: U,
2245
+ sessions: Q,
2245
2246
  tenants: D,
2246
2247
  themes: fe,
2247
- tickets: Qr,
2248
+ tickets: $r,
2248
2249
  universalLoginTemplates: ve,
2249
- userOrganizations: J,
2250
+ userOrganizations: P,
2250
2251
  userPermissions: _e,
2251
2252
  userRoles: ue,
2252
2253
  users: k
@@ -2267,22 +2268,22 @@ function z(n) {
2267
2268
  }
2268
2269
  return i;
2269
2270
  }
2270
- function Pr(n, i, e = { ...n }) {
2271
+ function Jr(n, i, e = { ...n }) {
2271
2272
  for (const t of i)
2272
2273
  n[t] !== void 0 && (e[t] = JSON.stringify(n[t]));
2273
2274
  return e;
2274
2275
  }
2275
- function Fr(n, i, e = n) {
2276
+ function Pr(n, i, e = n) {
2276
2277
  for (const t of i)
2277
2278
  n[t] !== void 0 && (e[t] = n[t] ? 1 : 0);
2278
2279
  }
2279
- function gr(n) {
2280
+ function cr(n) {
2280
2281
  const i = {};
2281
2282
  for (const e in n)
2282
2283
  n[e] !== void 0 && n[e] !== null && (i[e] = n[e]);
2283
2284
  return i;
2284
2285
  }
2285
- function x(n, i) {
2286
+ function b(n, i) {
2286
2287
  if (n == null)
2287
2288
  return i;
2288
2289
  if (typeof n == "string")
@@ -2301,7 +2302,7 @@ function yt(n, i = "", e = {}) {
2301
2302
  }
2302
2303
  return e;
2303
2304
  }
2304
- function fr(n, i) {
2305
+ function gr(n, i) {
2305
2306
  const e = {};
2306
2307
  for (const [t, r] of Object.entries(n)) {
2307
2308
  const o = i.find(
@@ -2319,10 +2320,10 @@ function fr(n, i) {
2319
2320
  }
2320
2321
  return e;
2321
2322
  }
2322
- function Ur(n) {
2323
+ function Fr(n) {
2323
2324
  return typeof n == "string" ? parseInt(n, 10) : typeof n == "bigint" ? Number(n) : n;
2324
2325
  }
2325
- function Kr(n) {
2326
+ function Ur(n) {
2326
2327
  return {
2327
2328
  async get(i) {
2328
2329
  const e = await n.select().from(Le).where(a(Le.tenant_id, i)).get();
@@ -2333,34 +2334,34 @@ function Kr(n) {
2333
2334
  colors_page_background_type: o,
2334
2335
  colors_page_background_start: l,
2335
2336
  colors_page_background_end: _,
2336
- colors_page_background_angle_dev: u,
2337
+ colors_page_background_angle_dev: d,
2337
2338
  font_url: c,
2338
- ...d
2339
+ ...u
2339
2340
  } = e;
2340
2341
  return z({
2341
- ...d,
2342
+ ...u,
2342
2343
  colors: {
2343
2344
  primary: r,
2344
2345
  page_background: {
2345
2346
  type: o,
2346
2347
  start: l,
2347
2348
  end: _,
2348
- angle_deg: u
2349
+ angle_deg: d
2349
2350
  }
2350
2351
  },
2351
2352
  font: c ? { url: c } : void 0
2352
2353
  });
2353
2354
  },
2354
2355
  async set(i, e) {
2355
- var _, u, c, d, h, f, y, N;
2356
+ var _, d, c, u, p, f, y, w;
2356
2357
  const { colors: t, font: r, ...o } = e, l = {
2357
2358
  ...o,
2358
2359
  tenant_id: i,
2359
2360
  colors_primary: t == null ? void 0 : t.primary,
2360
2361
  colors_page_background_type: (_ = t == null ? void 0 : t.page_background) == null ? void 0 : _.type,
2361
- colors_page_background_start: (u = t == null ? void 0 : t.page_background) == null ? void 0 : u.start,
2362
+ colors_page_background_start: (d = t == null ? void 0 : t.page_background) == null ? void 0 : d.start,
2362
2363
  colors_page_background_end: (c = t == null ? void 0 : t.page_background) == null ? void 0 : c.end,
2363
- colors_page_background_angle_dev: (d = t == null ? void 0 : t.page_background) == null ? void 0 : d.angle_deg,
2364
+ colors_page_background_angle_dev: (u = t == null ? void 0 : t.page_background) == null ? void 0 : u.angle_deg,
2364
2365
  font_url: r == null ? void 0 : r.url
2365
2366
  };
2366
2367
  await n.insert(Le).values(l).onConflictDoUpdate({
@@ -2368,17 +2369,17 @@ function Kr(n) {
2368
2369
  set: {
2369
2370
  ...o,
2370
2371
  colors_primary: t == null ? void 0 : t.primary,
2371
- colors_page_background_type: (h = t == null ? void 0 : t.page_background) == null ? void 0 : h.type,
2372
+ colors_page_background_type: (p = t == null ? void 0 : t.page_background) == null ? void 0 : p.type,
2372
2373
  colors_page_background_start: (f = t == null ? void 0 : t.page_background) == null ? void 0 : f.start,
2373
2374
  colors_page_background_end: (y = t == null ? void 0 : t.page_background) == null ? void 0 : y.end,
2374
- colors_page_background_angle_dev: (N = t == null ? void 0 : t.page_background) == null ? void 0 : N.angle_deg,
2375
+ colors_page_background_angle_dev: (w = t == null ? void 0 : t.page_background) == null ? void 0 : w.angle_deg,
2375
2376
  font_url: r == null ? void 0 : r.url
2376
2377
  }
2377
2378
  });
2378
2379
  }
2379
2380
  };
2380
2381
  }
2381
- var be = class extends Error {
2382
+ var xe = class extends Error {
2382
2383
  /**
2383
2384
  * Creates an instance of `HTTPException`.
2384
2385
  * @param status - HTTP status code for the exception. Defaults to 500.
@@ -2386,8 +2387,8 @@ var be = class extends Error {
2386
2387
  */
2387
2388
  constructor(i = 500, e) {
2388
2389
  super(e == null ? void 0 : e.message, { cause: e == null ? void 0 : e.cause });
2389
- p(this, "res");
2390
- p(this, "status");
2390
+ h(this, "res");
2391
+ h(this, "status");
2391
2392
  this.res = e == null ? void 0 : e.res, this.status = i;
2392
2393
  }
2393
2394
  /**
@@ -2404,16 +2405,16 @@ var be = class extends Error {
2404
2405
  });
2405
2406
  }
2406
2407
  };
2407
- function me(n, i, e) {
2408
+ function ye(n, i, e) {
2408
2409
  const t = i.split(/ OR /i);
2409
2410
  if (t.length > 1) {
2410
- const c = t.map((d) => {
2411
- const h = d.trim().match(/^([^:]+):(.+)$/);
2412
- if (h) {
2413
- const [, f, y] = h;
2411
+ const c = t.map((u) => {
2412
+ const p = u.trim().match(/^([^:]+):(.+)$/);
2413
+ if (p) {
2414
+ const [, f, y] = p;
2414
2415
  if (!f || !y) return null;
2415
- const N = y.replace(/^"(.*)"$/, "$1"), B = n[f.trim()];
2416
- return B ? a(B, N.trim()) : null;
2416
+ const w = y.replace(/^"(.*)"$/, "$1"), B = n[f.trim()];
2417
+ return B ? a(B, w.trim()) : null;
2417
2418
  }
2418
2419
  return null;
2419
2420
  }).filter(Boolean);
@@ -2422,79 +2423,79 @@ function me(n, i, e) {
2422
2423
  const r = [];
2423
2424
  let o = "", l = !1;
2424
2425
  for (let c = 0; c < i.length; c++) {
2425
- const d = i[c];
2426
- d === '"' ? (l = !l, o += d) : d === " " && !l ? o.trim() && (r.push(o.trim()), o = "") : o += d;
2426
+ const u = i[c];
2427
+ u === '"' ? (l = !l, o += u) : u === " " && !l ? o.trim() && (r.push(o.trim()), o = "") : o += u;
2427
2428
  }
2428
2429
  o.trim() && r.push(o.trim());
2429
2430
  const _ = r.map((c) => c.replace(/^([^:]+)=/g, "$1:")).map((c) => {
2430
- let d = c.startsWith("-"), h = null, f = "", y = !1, N;
2431
+ let u = c.startsWith("-"), p = null, f = "", y = !1, w;
2431
2432
  if (c.startsWith("-_exists_:"))
2432
- h = c.substring(10), y = !0, d = !0;
2433
+ p = c.substring(10), y = !0, u = !0;
2433
2434
  else if (c.startsWith("_exists_:"))
2434
- h = c.substring(9), y = !0, d = !1;
2435
+ p = c.substring(9), y = !0, u = !1;
2435
2436
  else if (c.includes(":")) {
2436
- const B = d ? c.substring(1) : c, W = B.indexOf(":");
2437
- h = B.substring(0, W), f = B.substring(W + 1), y = !1, f.startsWith(">=") ? (N = ">=", f = f.substring(2)) : f.startsWith(">") ? (N = ">", f = f.substring(1)) : f.startsWith("<=") ? (N = "<=", f = f.substring(2)) : f.startsWith("<") ? (N = "<", f = f.substring(1)) : N = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
2437
+ const B = u ? c.substring(1) : c, W = B.indexOf(":");
2438
+ p = B.substring(0, W), f = B.substring(W + 1), y = !1, f.startsWith(">=") ? (w = ">=", f = f.substring(2)) : f.startsWith(">") ? (w = ">", f = f.substring(1)) : f.startsWith("<=") ? (w = "<=", f = f.substring(2)) : f.startsWith("<") ? (w = "<", f = f.substring(1)) : w = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
2438
2439
  } else
2439
- h = null, f = c, y = !1;
2440
- return { key: h, value: f, isNegation: d, isExistsQuery: y, operator: N };
2441
- }), u = [];
2442
- for (const { key: c, value: d, isNegation: h, isExistsQuery: f, operator: y } of _)
2440
+ p = null, f = c, y = !1;
2441
+ return { key: p, value: f, isNegation: u, isExistsQuery: y, operator: w };
2442
+ }), d = [];
2443
+ for (const { key: c, value: u, isNegation: p, isExistsQuery: f, operator: y } of _)
2443
2444
  if (c) {
2444
- const N = n[c];
2445
- if (!N) {
2446
- f ? u.push(
2447
- h ? w`${w.identifier(c)} IS NULL` : w`${w.identifier(c)} IS NOT NULL`
2448
- ) : u.push(
2449
- w`${w.identifier(c)} ${w.raw(h ? "!=" : y ?? "=")} ${d}`
2445
+ const w = n[c];
2446
+ if (!w) {
2447
+ f ? d.push(
2448
+ p ? N`${N.identifier(c)} IS NULL` : N`${N.identifier(c)} IS NOT NULL`
2449
+ ) : d.push(
2450
+ N`${N.identifier(c)} ${N.raw(p ? "!=" : y ?? "=")} ${u}`
2450
2451
  );
2451
2452
  continue;
2452
2453
  }
2453
2454
  if (f)
2454
- u.push(h ? ye(N) : Me(N));
2455
- else if (h)
2455
+ d.push(p ? me(w) : Me(w));
2456
+ else if (p)
2456
2457
  switch (y) {
2457
2458
  case ">":
2458
- u.push(Oe(N, d));
2459
+ d.push(Oe(w, u));
2459
2460
  break;
2460
2461
  case ">=":
2461
- u.push(we(N, d));
2462
+ d.push(we(w, u));
2462
2463
  break;
2463
2464
  case "<":
2464
- u.push(He(N, d));
2465
+ d.push(He(w, u));
2465
2466
  break;
2466
2467
  case "<=":
2467
- u.push(We(N, d));
2468
+ d.push(We(w, u));
2468
2469
  break;
2469
2470
  default:
2470
- u.push(kr(N, d));
2471
+ d.push(Or(w, u));
2471
2472
  }
2472
2473
  else
2473
2474
  switch (y) {
2474
2475
  case ">":
2475
- u.push(We(N, d));
2476
+ d.push(We(w, u));
2476
2477
  break;
2477
2478
  case ">=":
2478
- u.push(He(N, d));
2479
+ d.push(He(w, u));
2479
2480
  break;
2480
2481
  case "<":
2481
- u.push(we(N, d));
2482
+ d.push(we(w, u));
2482
2483
  break;
2483
2484
  case "<=":
2484
- u.push(Oe(N, d));
2485
+ d.push(Oe(w, u));
2485
2486
  break;
2486
2487
  default:
2487
- u.push(a(N, d));
2488
+ d.push(a(w, u));
2488
2489
  }
2489
- } else if (d) {
2490
- const B = (d.includes("|") ? [...e, "user_id"] : e).map((W) => {
2490
+ } else if (u) {
2491
+ const B = (u.includes("|") ? [...e, "user_id"] : e).map((W) => {
2491
2492
  const H = n[W];
2492
- return H ? W === "user_id" ? a(H, d) : Ie(H, `%${d}%`) : null;
2493
+ return H ? W === "user_id" ? a(H, u) : Ie(H, `%${u}%`) : null;
2493
2494
  }).filter(Boolean);
2494
- B.length > 0 && u.push(de(...B));
2495
+ B.length > 0 && d.push(de(...B));
2495
2496
  }
2496
- if (u.length !== 0)
2497
- return u.length === 1 ? u[0] : g(...u);
2497
+ if (d.length !== 0)
2498
+ return d.length === 1 ? d[0] : g(...d);
2498
2499
  }
2499
2500
  const kt = [
2500
2501
  "global",
@@ -2536,14 +2537,14 @@ function Fe(n) {
2536
2537
  for (const o of kt)
2537
2538
  r[o] = !!t[o];
2538
2539
  for (const o of It)
2539
- r[o] = x(t[o], []);
2540
+ r[o] = b(t[o], []);
2540
2541
  for (const o of zt)
2541
- r[o] = x(t[o], {});
2542
- return r.connections = x(e, []), z(r);
2542
+ r[o] = b(t[o], {});
2543
+ return r.connections = b(e, []), z(r);
2543
2544
  }
2544
- function Ct(n) {
2545
+ function At(n) {
2545
2546
  const i = { ...n };
2546
- Fr(
2547
+ Pr(
2547
2548
  n,
2548
2549
  kt,
2549
2550
  i
@@ -2552,9 +2553,9 @@ function Ct(n) {
2552
2553
  n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || []));
2553
2554
  for (const e of zt)
2554
2555
  n[e] !== void 0 && (i[e] = JSON.stringify(n[e] || {}));
2555
- return n.connections !== void 0 && (i.connections = JSON.stringify(n.connections || [])), gr(i);
2556
+ return n.connections !== void 0 && (i.connections = JSON.stringify(n.connections || [])), cr(i);
2556
2557
  }
2557
- function jr(n) {
2558
+ function Kr(n) {
2558
2559
  return {
2559
2560
  async create(i, e) {
2560
2561
  var l, _;
@@ -2579,21 +2580,21 @@ function jr(n) {
2579
2580
  created_at: t,
2580
2581
  updated_at: t
2581
2582
  };
2582
- for (const u of kt)
2583
- r[u] = e[u] ?? !1;
2583
+ for (const d of kt)
2584
+ r[d] = e[d] ?? !1;
2584
2585
  r.oidc_conformant = e.oidc_conformant ?? !0, r.auth0_conformant = e.auth0_conformant ?? !0, r.sso_disabled = e.sso_disabled ?? !1;
2585
- for (const u of It)
2586
- r[u] = e[u] || [];
2587
- for (const u of zt)
2588
- r[u] = e[u] || {};
2586
+ for (const d of It)
2587
+ r[d] = e[d] || [];
2588
+ for (const d of zt)
2589
+ r[d] = e[d] || {};
2589
2590
  r.connections = e.connections || [];
2590
- const o = Ct(r);
2591
+ const o = At(r);
2591
2592
  try {
2592
2593
  await n.insert(I).values({ ...o, tenant_id: i });
2593
- } catch (u) {
2594
- throw (l = u == null ? void 0 : u.message) != null && l.includes("UNIQUE constraint failed") || (_ = u == null ? void 0 : u.message) != null && _.includes("duplicate key") ? new be(409, {
2594
+ } catch (d) {
2595
+ throw (l = d == null ? void 0 : d.message) != null && l.includes("UNIQUE constraint failed") || (_ = d == null ? void 0 : d.message) != null && _.includes("duplicate key") ? new xe(409, {
2595
2596
  message: "Client already exists"
2596
- }) : u;
2597
+ }) : d;
2597
2598
  }
2598
2599
  return Fe({ ...o, tenant_id: i });
2599
2600
  },
@@ -2614,7 +2615,7 @@ function jr(n) {
2614
2615
  } : null;
2615
2616
  },
2616
2617
  async update(i, e, t) {
2617
- const r = Ct({
2618
+ const r = At({
2618
2619
  ...t,
2619
2620
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2620
2621
  });
@@ -2633,26 +2634,26 @@ function jr(n) {
2633
2634
  sort: l,
2634
2635
  q: _
2635
2636
  } = e || {};
2636
- let u = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
2637
+ let d = n.select().from(I).where(a(I.tenant_id, i)).$dynamic();
2637
2638
  if (_) {
2638
- const f = me(I, _, ["name", "client_id"]);
2639
- f && (u = u.where(g(a(I.tenant_id, i), f)));
2639
+ const f = ye(I, _, ["name", "client_id"]);
2640
+ f && (d = d.where(g(a(I.tenant_id, i), f)));
2640
2641
  }
2641
2642
  if (l != null && l.sort_by) {
2642
2643
  const f = I[l.sort_by];
2643
- f && (u = u.orderBy(
2644
+ f && (d = d.orderBy(
2644
2645
  l.sort_order === "desc" ? V(f) : G(f)
2645
2646
  ));
2646
2647
  }
2647
- const d = (await u.offset(t * r).limit(r)).map(Fe);
2648
+ const u = (await d.offset(t * r).limit(r)).map(Fe);
2648
2649
  if (!o)
2649
- return { clients: d };
2650
- const [h] = await n.select({ count: R() }).from(I).where(a(I.tenant_id, i));
2650
+ return { clients: u };
2651
+ const [p] = await n.select({ count: R() }).from(I).where(a(I.tenant_id, i));
2651
2652
  return {
2652
- clients: d,
2653
+ clients: u,
2653
2654
  start: t * r,
2654
2655
  limit: r,
2655
- length: Number((h == null ? void 0 : h.count) ?? 0)
2656
+ length: Number((p == null ? void 0 : p.count) ?? 0)
2656
2657
  };
2657
2658
  },
2658
2659
  async remove(i, e) {
@@ -2665,16 +2666,16 @@ function jr(n) {
2665
2666
  }
2666
2667
  };
2667
2668
  }
2668
- function Mr(n) {
2669
+ function jr(n) {
2669
2670
  const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
2670
2671
  return z({
2671
2672
  ...o,
2672
- options: x(t, {}),
2673
- metadata: x(r),
2673
+ options: b(t, {}),
2674
+ metadata: b(r),
2674
2675
  is_system: e ? !0 : void 0
2675
2676
  });
2676
2677
  }
2677
- function Vr(n) {
2678
+ function Mr(n) {
2678
2679
  return {
2679
2680
  async listByClient(i, e) {
2680
2681
  const t = await n.select({ connections: I.connections }).from(I).where(
@@ -2684,15 +2685,15 @@ function Vr(n) {
2684
2685
  )
2685
2686
  ).get();
2686
2687
  if (!t) return [];
2687
- const r = x(t.connections, []) || [];
2688
+ const r = b(t.connections, []) || [];
2688
2689
  if (r.length === 0) return [];
2689
- const l = (await n.select().from(K).where(
2690
+ const l = (await n.select().from(j).where(
2690
2691
  g(
2691
- a(K.tenant_id, i),
2692
- Ne(K.id, r)
2692
+ a(j.tenant_id, i),
2693
+ Ne(j.id, r)
2693
2694
  )
2694
- ).all()).map(Mr);
2695
- return r.map((_) => l.find((u) => u.id === _)).filter(Boolean);
2695
+ ).all()).map(jr);
2696
+ return r.map((_) => l.find((d) => d.id === _)).filter(Boolean);
2696
2697
  },
2697
2698
  async updateByClient(i, e, t) {
2698
2699
  return (await n.update(I).set({ connections: JSON.stringify([...new Set(t)]) }).where(
@@ -2706,7 +2707,7 @@ function Vr(n) {
2706
2707
  return (await n.select({
2707
2708
  client_id: I.client_id,
2708
2709
  connections: I.connections
2709
- }).from(I).where(a(I.tenant_id, i)).all()).filter((r) => (x(r.connections, []) || []).includes(e)).map((r) => r.client_id);
2710
+ }).from(I).where(a(I.tenant_id, i)).all()).filter((r) => (b(r.connections, []) || []).includes(e)).map((r) => r.client_id);
2710
2711
  },
2711
2712
  async addClientToConnection(i, e, t) {
2712
2713
  var _;
@@ -2717,7 +2718,7 @@ function Vr(n) {
2717
2718
  )
2718
2719
  ).get()) return !1;
2719
2720
  const o = await n.run(
2720
- w`UPDATE clients SET connections = CASE
2721
+ N`UPDATE clients SET connections = CASE
2721
2722
  WHEN connections IS NULL OR connections = '[]' OR connections = ''
2722
2723
  THEN json_array(${e})
2723
2724
  WHEN EXISTS (SELECT 1 FROM json_each(connections) WHERE value = ${e})
@@ -2731,7 +2732,7 @@ function Vr(n) {
2731
2732
  async removeClientFromConnection(i, e, t) {
2732
2733
  var l;
2733
2734
  const r = await n.run(
2734
- w`UPDATE clients SET connections = (
2735
+ N`UPDATE clients SET connections = (
2735
2736
  SELECT COALESCE(json_group_array(je.value), '[]')
2736
2737
  FROM json_each(COALESCE(connections, '[]')) AS je
2737
2738
  WHERE je.value != ${e}
@@ -2742,7 +2743,7 @@ function Vr(n) {
2742
2743
  }
2743
2744
  };
2744
2745
  }
2745
- let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr = (n) => crypto.getRandomValues(new Uint8Array(n)), Hr = (n, i, e) => {
2746
+ let Vr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Rr = (n) => crypto.getRandomValues(new Uint8Array(n)), Wr = (n, i, e) => {
2746
2747
  let t = 256 - 256 % n.length;
2747
2748
  if (t === 256) {
2748
2749
  let o = n.length - 1;
@@ -2750,9 +2751,9 @@ let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr
2750
2751
  if (!l) return "";
2751
2752
  let _ = "";
2752
2753
  for (; ; ) {
2753
- let u = e(l), c = l;
2754
+ let d = e(l), c = l;
2754
2755
  for (; c--; )
2755
- if (_ += n[u[c] & o], _.length >= l) return _;
2756
+ if (_ += n[d[c] & o], _.length >= l) return _;
2756
2757
  }
2757
2758
  };
2758
2759
  }
@@ -2761,16 +2762,16 @@ let Rr = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Wr
2761
2762
  if (!o) return "";
2762
2763
  let l = "";
2763
2764
  for (; ; ) {
2764
- let _ = e(r), u = r;
2765
- for (; u--; )
2766
- if (_[u] < t && (l += n[_[u] % n.length], l.length >= o))
2765
+ let _ = e(r), d = r;
2766
+ for (; d--; )
2767
+ if (_[d] < t && (l += n[_[d] % n.length], l.length >= o))
2767
2768
  return l;
2768
2769
  }
2769
2770
  };
2770
- }, Gr = (n, i = 21) => Hr(n, i | 0, Wr), ae = (n = 21) => {
2771
+ }, Hr = (n, i = 21) => Wr(n, i | 0, Rr), ae = (n = 21) => {
2771
2772
  let i = "", e = crypto.getRandomValues(new Uint8Array(n |= 0));
2772
2773
  for (; n--; )
2773
- i += Rr[e[n] & 63];
2774
+ i += Vr[e[n] & 63];
2774
2775
  return i;
2775
2776
  };
2776
2777
  function tt(n) {
@@ -2784,8 +2785,8 @@ function tt(n) {
2784
2785
  } = n;
2785
2786
  return z({
2786
2787
  ...l,
2787
- scope: x(e, []),
2788
- authorization_details_types: x(
2788
+ scope: b(e, []),
2789
+ authorization_details_types: b(
2789
2790
  t,
2790
2791
  []
2791
2792
  ),
@@ -2793,7 +2794,7 @@ function tt(n) {
2793
2794
  is_system: !!o
2794
2795
  });
2795
2796
  }
2796
- function Yr(n) {
2797
+ function Gr(n) {
2797
2798
  return {
2798
2799
  async create(i, e) {
2799
2800
  const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
@@ -2826,9 +2827,9 @@ function Yr(n) {
2826
2827
  authorization_details_types: o,
2827
2828
  allow_any_organization: l,
2828
2829
  is_system: _,
2829
- ...u
2830
+ ...d
2830
2831
  } = t, c = {
2831
- ...u,
2832
+ ...d,
2832
2833
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2833
2834
  };
2834
2835
  return r !== void 0 && (c.scope = JSON.stringify(r)), o !== void 0 && (c.authorization_details_types = JSON.stringify(
@@ -2844,16 +2845,16 @@ function Yr(n) {
2844
2845
  include_totals: o = !1,
2845
2846
  sort: l,
2846
2847
  q: _
2847
- } = e || {}, u = _ ? me(Y, _, ["client_id", "audience"]) : void 0, c = u ? g(a(Y.tenant_id, i), u) : a(Y.tenant_id, i);
2848
- let d = n.select().from(Y).where(c).$dynamic();
2848
+ } = e || {}, d = _ ? ye(Y, _, ["client_id", "audience"]) : void 0, c = d ? g(a(Y.tenant_id, i), d) : a(Y.tenant_id, i);
2849
+ let u = n.select().from(Y).where(c).$dynamic();
2849
2850
  if (l != null && l.sort_by) {
2850
- const N = Y[l.sort_by];
2851
- N && (d = d.orderBy(
2852
- l.sort_order === "desc" ? V(N) : G(N)
2851
+ const w = Y[l.sort_by];
2852
+ w && (u = u.orderBy(
2853
+ l.sort_order === "desc" ? V(w) : G(w)
2853
2854
  ));
2854
2855
  } else
2855
- d = d.orderBy(G(Y.created_at));
2856
- const f = (await d.offset(t * r).limit(r)).map(tt);
2856
+ u = u.orderBy(G(Y.created_at));
2857
+ const f = (await u.offset(t * r).limit(r)).map(tt);
2857
2858
  if (!o)
2858
2859
  return { client_grants: f };
2859
2860
  const [y] = await n.select({ count: R() }).from(Y).where(c);
@@ -2875,7 +2876,7 @@ function nt(n) {
2875
2876
  const { tenant_id: i, ...e } = n;
2876
2877
  return z(e);
2877
2878
  }
2878
- function Xr(n) {
2879
+ function Yr(n) {
2879
2880
  return {
2880
2881
  async create(i, e) {
2881
2882
  const t = {
@@ -2884,16 +2885,16 @@ function Xr(n) {
2884
2885
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
2885
2886
  expires_at: e.expires_at
2886
2887
  };
2887
- return await n.insert(Q).values(t), nt(t);
2888
+ return await n.insert(J).values(t), nt(t);
2888
2889
  },
2889
2890
  async get(i, e, t) {
2890
2891
  if (!i)
2891
2892
  throw new Error("tenant_id is required");
2892
- const r = await n.select().from(Q).where(
2893
+ const r = await n.select().from(J).where(
2893
2894
  g(
2894
- a(Q.tenant_id, i),
2895
- a(Q.code_id, e),
2896
- a(Q.code_type, t)
2895
+ a(J.tenant_id, i),
2896
+ a(J.code_id, e),
2897
+ a(J.code_type, t)
2897
2898
  )
2898
2899
  ).get();
2899
2900
  return r ? nt(r) : null;
@@ -2905,42 +2906,42 @@ function Xr(n) {
2905
2906
  include_totals: o = !1,
2906
2907
  sort: l
2907
2908
  } = e || {};
2908
- let _ = n.select().from(Q).where(a(Q.tenant_id, i)).$dynamic();
2909
+ let _ = n.select().from(J).where(a(J.tenant_id, i)).$dynamic();
2909
2910
  if (l != null && l.sort_by) {
2910
- const h = Q[l.sort_by];
2911
- h && (_ = _.orderBy(
2912
- l.sort_order === "desc" ? V(h) : G(h)
2911
+ const p = J[l.sort_by];
2912
+ p && (_ = _.orderBy(
2913
+ l.sort_order === "desc" ? V(p) : G(p)
2913
2914
  ));
2914
2915
  }
2915
2916
  const c = (await _.offset(t * r).limit(r)).map(nt);
2916
2917
  if (!o)
2917
2918
  return { codes: c };
2918
- const [d] = await n.select({ count: R() }).from(Q).where(a(Q.tenant_id, i));
2919
+ const [u] = await n.select({ count: R() }).from(J).where(a(J.tenant_id, i));
2919
2920
  return {
2920
2921
  codes: c,
2921
2922
  start: t * r,
2922
2923
  limit: r,
2923
- length: Number((d == null ? void 0 : d.count) ?? 0)
2924
+ length: Number((u == null ? void 0 : u.count) ?? 0)
2924
2925
  };
2925
2926
  },
2926
2927
  async used(i, e) {
2927
- return (await n.update(Q).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(g(a(Q.tenant_id, i), a(Q.code_id, e))).returning()).length > 0;
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;
2928
2929
  },
2929
2930
  async consume(i, e) {
2930
- return (await n.update(Q).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
2931
+ return (await n.update(J).set({ used_at: (/* @__PURE__ */ new Date()).toISOString() }).where(
2931
2932
  g(
2932
- a(Q.tenant_id, i),
2933
- a(Q.code_id, e),
2934
- ye(Q.used_at)
2933
+ a(J.tenant_id, i),
2934
+ a(J.code_id, e),
2935
+ me(J.used_at)
2935
2936
  )
2936
2937
  ).returning()).length > 0;
2937
2938
  },
2938
2939
  async remove(i, e) {
2939
- return (await n.delete(Q).where(g(a(Q.tenant_id, i), a(Q.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;
2940
2941
  }
2941
2942
  };
2942
2943
  }
2943
- function Zr() {
2944
+ function Xr() {
2944
2945
  const { customAlphabet: n } = require("nanoid");
2945
2946
  return `con_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
2946
2947
  }
@@ -2948,17 +2949,17 @@ function it(n) {
2948
2949
  const { tenant_id: i, is_system: e, options: t, metadata: r, ...o } = n;
2949
2950
  return z({
2950
2951
  ...o,
2951
- options: x(t, {}),
2952
- metadata: x(r),
2952
+ options: b(t, {}),
2953
+ metadata: b(r),
2953
2954
  is_system: e ? !0 : void 0
2954
2955
  });
2955
2956
  }
2956
- function es(n) {
2957
+ function Zr(n) {
2957
2958
  return {
2958
2959
  async create(i, e) {
2959
2960
  var o, l;
2960
2961
  const t = (/* @__PURE__ */ new Date()).toISOString(), r = {
2961
- id: e.id || Zr(),
2962
+ id: e.id || Xr(),
2962
2963
  ...e,
2963
2964
  tenant_id: i,
2964
2965
  options: JSON.stringify(e.options || {}),
@@ -2968,19 +2969,19 @@ function es(n) {
2968
2969
  updated_at: t
2969
2970
  };
2970
2971
  try {
2971
- await n.insert(K).values(r);
2972
+ await n.insert(j).values(r);
2972
2973
  } catch (_) {
2973
- 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, {
2974
+ throw (o = _ == null ? void 0 : _.message) != null && o.includes("UNIQUE constraint failed") || (l = _ == null ? void 0 : _.message) != null && l.includes("duplicate key") ? new xe(409, {
2974
2975
  message: "Connection already exists"
2975
2976
  }) : _;
2976
2977
  }
2977
2978
  return it(r);
2978
2979
  },
2979
2980
  async get(i, e) {
2980
- const t = await n.select().from(K).where(
2981
+ const t = await n.select().from(j).where(
2981
2982
  g(
2982
- a(K.tenant_id, i),
2983
- a(K.id, e)
2983
+ a(j.tenant_id, i),
2984
+ a(j.id, e)
2984
2985
  )
2985
2986
  ).get();
2986
2987
  return t ? it(t) : null;
@@ -2989,10 +2990,10 @@ function es(n) {
2989
2990
  const r = {
2990
2991
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2991
2992
  };
2992
- 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(
2993
2994
  g(
2994
- a(K.tenant_id, i),
2995
- a(K.id, e)
2995
+ a(j.tenant_id, i),
2996
+ a(j.id, e)
2996
2997
  )
2997
2998
  ), !0;
2998
2999
  },
@@ -3004,34 +3005,34 @@ function es(n) {
3004
3005
  sort: l,
3005
3006
  q: _
3006
3007
  } = e || {};
3007
- let u = a(K.tenant_id, i);
3008
+ let d = a(j.tenant_id, i);
3008
3009
  if (_) {
3009
- const y = me(K, _, ["name"]);
3010
- y && (u = g(u, y));
3010
+ const y = ye(j, _, ["name"]);
3011
+ y && (d = g(d, y));
3011
3012
  }
3012
- let c = n.select().from(K).where(u).$dynamic();
3013
+ let c = n.select().from(j).where(d).$dynamic();
3013
3014
  if (l != null && l.sort_by) {
3014
- const y = K[l.sort_by];
3015
+ const y = j[l.sort_by];
3015
3016
  y && (c = c.orderBy(
3016
3017
  l.sort_order === "desc" ? V(y) : G(y)
3017
3018
  ));
3018
3019
  }
3019
- const h = (await c.offset(t * r).limit(r)).map(it);
3020
+ const p = (await c.offset(t * r).limit(r)).map(it);
3020
3021
  if (!o)
3021
- return { connections: h };
3022
- const [f] = await n.select({ count: R() }).from(K).where(u);
3022
+ return { connections: p };
3023
+ const [f] = await n.select({ count: R() }).from(j).where(d);
3023
3024
  return {
3024
- connections: h,
3025
+ connections: p,
3025
3026
  start: t * r,
3026
3027
  limit: r,
3027
3028
  length: Number((f == null ? void 0 : f.count) ?? 0)
3028
3029
  };
3029
3030
  },
3030
3031
  async remove(i, e) {
3031
- return (await n.delete(K).where(
3032
+ return (await n.delete(j).where(
3032
3033
  g(
3033
- a(K.tenant_id, i),
3034
- a(K.id, e)
3034
+ a(j.tenant_id, i),
3035
+ a(j.id, e)
3035
3036
  )
3036
3037
  ).returning()).length > 0;
3037
3038
  }
@@ -3042,10 +3043,10 @@ function Ue(n) {
3042
3043
  return z({
3043
3044
  ...t,
3044
3045
  primary: !!t.primary,
3045
- domain_metadata: x(e)
3046
+ domain_metadata: b(e)
3046
3047
  });
3047
3048
  }
3048
- function ts(n) {
3049
+ function es(n) {
3049
3050
  return {
3050
3051
  async create(i, e) {
3051
3052
  const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
@@ -3105,7 +3106,7 @@ function ts(n) {
3105
3106
  }
3106
3107
  };
3107
3108
  }
3108
- function ns(n) {
3109
+ function ts(n) {
3109
3110
  return {
3110
3111
  async get(i, e, t) {
3111
3112
  const r = await n.select().from(te).where(
@@ -3157,7 +3158,7 @@ function ns(n) {
3157
3158
  }
3158
3159
  };
3159
3160
  }
3160
- function is(n) {
3161
+ function ns(n) {
3161
3162
  return {
3162
3163
  async create(i, e) {
3163
3164
  const t = (/* @__PURE__ */ new Date()).toISOString();
@@ -3179,8 +3180,8 @@ function is(n) {
3179
3180
  return z({
3180
3181
  ...r,
3181
3182
  enabled: !!r.enabled,
3182
- credentials: x(r.credentials, {}),
3183
- settings: x(r.settings, {})
3183
+ credentials: b(r.credentials, {}),
3184
+ settings: b(r.settings, {})
3184
3185
  });
3185
3186
  },
3186
3187
  async update(i, e) {
@@ -3194,7 +3195,7 @@ function is(n) {
3194
3195
  }
3195
3196
  };
3196
3197
  }
3197
- function rs(n) {
3198
+ function is(n) {
3198
3199
  return {
3199
3200
  async create(i, e) {
3200
3201
  const t = (/* @__PURE__ */ new Date()).toISOString(), r = `af_${ae()}`;
@@ -3219,7 +3220,7 @@ function rs(n) {
3219
3220
  const { tenant_id: r, actions: o, ...l } = t;
3220
3221
  return z({
3221
3222
  ...l,
3222
- actions: x(o, [])
3223
+ actions: b(o, [])
3223
3224
  });
3224
3225
  },
3225
3226
  async update(i, e, t) {
@@ -3237,26 +3238,26 @@ function rs(n) {
3237
3238
  } = e || {};
3238
3239
  let _ = n.select().from(re).where(a(re.tenant_id, i)).$dynamic();
3239
3240
  if (l != null && l.sort_by) {
3240
- const h = re[l.sort_by];
3241
- h && (_ = _.orderBy(
3242
- l.sort_order === "desc" ? V(h) : G(h)
3241
+ const p = re[l.sort_by];
3242
+ p && (_ = _.orderBy(
3243
+ l.sort_order === "desc" ? V(p) : G(p)
3243
3244
  ));
3244
3245
  }
3245
- const c = (await _.offset(t * r).limit(r)).map((h) => {
3246
- const { tenant_id: f, actions: y, ...N } = h;
3246
+ const c = (await _.offset(t * r).limit(r)).map((p) => {
3247
+ const { tenant_id: f, actions: y, ...w } = p;
3247
3248
  return z({
3248
- ...N,
3249
- actions: x(y, [])
3249
+ ...w,
3250
+ actions: b(y, [])
3250
3251
  });
3251
3252
  });
3252
3253
  if (!o)
3253
3254
  return { flows: c };
3254
- const [d] = await n.select({ count: R() }).from(re).where(a(re.tenant_id, i));
3255
+ const [u] = await n.select({ count: R() }).from(re).where(a(re.tenant_id, i));
3255
3256
  return {
3256
3257
  flows: c,
3257
3258
  start: t * r,
3258
3259
  limit: r,
3259
- length: Number((d == null ? void 0 : d.count) ?? 0)
3260
+ length: Number((u == null ? void 0 : u.count) ?? 0)
3260
3261
  };
3261
3262
  },
3262
3263
  async remove(i, e) {
@@ -3265,7 +3266,7 @@ function rs(n) {
3265
3266
  };
3266
3267
  }
3267
3268
  const Ke = ["nodes", "start", "ending"];
3268
- function ss(n) {
3269
+ function rs(n) {
3269
3270
  return {
3270
3271
  async create(i, e) {
3271
3272
  const t = (/* @__PURE__ */ new Date()).toISOString(), r = ae(), o = {
@@ -3295,7 +3296,7 @@ function ss(n) {
3295
3296
  if (!t) return null;
3296
3297
  const { tenant_id: r, ...o } = t, l = { ...o };
3297
3298
  for (const _ of Ke)
3298
- l[_] = x(o[_]);
3299
+ l[_] = b(o[_]);
3299
3300
  return z(l);
3300
3301
  },
3301
3302
  async update(i, e, t) {
@@ -3315,25 +3316,25 @@ function ss(n) {
3315
3316
  } = e || {};
3316
3317
  let _ = n.select().from(ie).where(a(ie.tenant_id, i)).$dynamic();
3317
3318
  if (l != null && l.sort_by) {
3318
- const h = ie[l.sort_by];
3319
- h && (_ = _.orderBy(
3320
- l.sort_order === "desc" ? V(h) : G(h)
3319
+ const p = ie[l.sort_by];
3320
+ p && (_ = _.orderBy(
3321
+ l.sort_order === "desc" ? V(p) : G(p)
3321
3322
  ));
3322
3323
  }
3323
- const c = (await _.offset(t * r).limit(r)).map((h) => {
3324
- const { tenant_id: f, ...y } = h, N = { ...y };
3324
+ const c = (await _.offset(t * r).limit(r)).map((p) => {
3325
+ const { tenant_id: f, ...y } = p, w = { ...y };
3325
3326
  for (const B of Ke)
3326
- N[B] = x(y[B]);
3327
- return z(N);
3327
+ w[B] = b(y[B]);
3328
+ return z(w);
3328
3329
  });
3329
3330
  if (!o)
3330
3331
  return { forms: c };
3331
- const [d] = await n.select({ count: R() }).from(ie).where(a(ie.tenant_id, i));
3332
+ const [u] = await n.select({ count: R() }).from(ie).where(a(ie.tenant_id, i));
3332
3333
  return {
3333
3334
  forms: c,
3334
3335
  start: t * r,
3335
3336
  limit: r,
3336
- length: Number((d == null ? void 0 : d.count) ?? 0)
3337
+ length: Number((u == null ? void 0 : u.count) ?? 0)
3337
3338
  };
3338
3339
  },
3339
3340
  async remove(i, e) {
@@ -3341,7 +3342,7 @@ function ss(n) {
3341
3342
  }
3342
3343
  };
3343
3344
  }
3344
- function pr(n) {
3345
+ function fr(n) {
3345
3346
  if (n != null) {
3346
3347
  if (typeof n == "number")
3347
3348
  return new Date(n).toISOString();
@@ -3354,9 +3355,9 @@ function pr(n) {
3354
3355
  }
3355
3356
  }
3356
3357
  function wt(n, i = (/* @__PURE__ */ new Date(0)).toISOString()) {
3357
- return pr(n) ?? i;
3358
+ return fr(n) ?? i;
3358
3359
  }
3359
- function j(n) {
3360
+ function $(n) {
3360
3361
  if (!n || n === "")
3361
3362
  return null;
3362
3363
  const i = new Date(n);
@@ -3370,15 +3371,15 @@ function Pe(n, i, e = []) {
3370
3371
  }
3371
3372
  for (const r of e) {
3372
3373
  const o = r.replace(/_ts$/, "");
3373
- t[o] = pr(n[r]);
3374
+ t[o] = fr(n[r]);
3374
3375
  }
3375
3376
  return t;
3376
3377
  }
3377
- const os = Gr("0123456789abcdefghijklmnopqrstuvwxyz", 17);
3378
- function as() {
3379
- return `hc_${os()}`;
3378
+ const ss = Hr("0123456789abcdefghijklmnopqrstuvwxyz", 17);
3379
+ function os() {
3380
+ return `hc_${ss()}`;
3380
3381
  }
3381
- function At(n) {
3382
+ function Ct(n) {
3382
3383
  const { created_at_ts: i, updated_at_ts: e, secrets: t, ...r } = n, o = Pe({ created_at_ts: i, updated_at_ts: e }, [
3383
3384
  "created_at_ts",
3384
3385
  "updated_at_ts"
@@ -3389,35 +3390,35 @@ function At(n) {
3389
3390
  secrets: t ? JSON.parse(t) : void 0
3390
3391
  };
3391
3392
  }
3392
- function ls(n) {
3393
+ function as(n) {
3393
3394
  return {
3394
3395
  async create(i, e) {
3395
3396
  const t = Date.now(), o = {
3396
- id: as(),
3397
+ id: os(),
3397
3398
  tenant_id: i,
3398
3399
  code: e.code,
3399
3400
  secrets: e.secrets ? JSON.stringify(e.secrets) : null,
3400
3401
  created_at_ts: t,
3401
3402
  updated_at_ts: t
3402
3403
  };
3403
- return await n.insert(pe).values(o), At({ ...o, tenant_id: i });
3404
+ return await n.insert(he).values(o), Ct({ ...o, tenant_id: i });
3404
3405
  },
3405
3406
  async get(i, e) {
3406
- const t = await n.select().from(pe).where(g(a(pe.tenant_id, i), a(pe.id, e))).get();
3407
- return t ? At(t) : null;
3407
+ const t = await n.select().from(he).where(g(a(he.tenant_id, i), a(he.id, e))).get();
3408
+ return t ? Ct(t) : null;
3408
3409
  },
3409
3410
  async update(i, e, t) {
3410
3411
  const r = {
3411
3412
  updated_at_ts: Date.now()
3412
3413
  };
3413
- return t.code !== void 0 && (r.code = t.code), t.secrets !== void 0 && (r.secrets = JSON.stringify(t.secrets)), (await n.update(pe).set(r).where(g(a(pe.tenant_id, i), a(pe.id, e))).returning()).length > 0;
3414
+ 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
3415
  },
3415
3416
  async remove(i, e) {
3416
- return (await n.delete(pe).where(g(a(pe.tenant_id, i), a(pe.id, e))).returning()).length > 0;
3417
+ return (await n.delete(he).where(g(a(he.tenant_id, i), a(he.id, e))).returning()).length > 0;
3417
3418
  }
3418
3419
  };
3419
3420
  }
3420
- function _s() {
3421
+ function ls() {
3421
3422
  const { customAlphabet: n } = require("nanoid");
3422
3423
  return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3423
3424
  }
@@ -3433,11 +3434,11 @@ function rt(n) {
3433
3434
  ...o
3434
3435
  });
3435
3436
  }
3436
- function us(n) {
3437
+ function _s(n) {
3437
3438
  return {
3438
3439
  async create(i, e) {
3439
3440
  const t = Date.now(), o = {
3440
- hook_id: e.hook_id || _s(),
3441
+ hook_id: e.hook_id || ls(),
3441
3442
  tenant_id: i,
3442
3443
  trigger_id: e.trigger_id,
3443
3444
  url: e.url,
@@ -3469,20 +3470,20 @@ function us(n) {
3469
3470
  include_totals: o = !1,
3470
3471
  sort: l,
3471
3472
  q: _
3472
- } = e || {}, u = _ ? me(ee, _, [
3473
+ } = e || {}, d = _ ? ye(ee, _, [
3473
3474
  "url",
3474
3475
  "form_id",
3475
3476
  "template_id",
3476
3477
  "code_id"
3477
- ]) : void 0, c = u ? g(a(ee.tenant_id, i), u) : a(ee.tenant_id, i);
3478
- let d = n.select().from(ee).where(c).$dynamic();
3478
+ ]) : void 0, c = d ? g(a(ee.tenant_id, i), d) : a(ee.tenant_id, i);
3479
+ let u = n.select().from(ee).where(c).$dynamic();
3479
3480
  if (l != null && l.sort_by) {
3480
- const N = ee[l.sort_by];
3481
- N && (d = d.orderBy(
3482
- l.sort_order === "desc" ? V(N) : G(N)
3481
+ const w = ee[l.sort_by];
3482
+ w && (u = u.orderBy(
3483
+ l.sort_order === "desc" ? V(w) : G(w)
3483
3484
  ));
3484
3485
  }
3485
- const f = (await d.offset(t * r).limit(r)).map(rt);
3486
+ const f = (await u.offset(t * r).limit(r)).map(rt);
3486
3487
  if (!o)
3487
3488
  return { hooks: f };
3488
3489
  const [y] = await n.select({ count: R() }).from(ee).where(c);
@@ -3498,7 +3499,7 @@ function us(n) {
3498
3499
  }
3499
3500
  };
3500
3501
  }
3501
- function ds() {
3502
+ function us() {
3502
3503
  const { customAlphabet: n } = require("nanoid");
3503
3504
  return `inv_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3504
3505
  }
@@ -3512,14 +3513,14 @@ const Nt = [
3512
3513
  function st(n) {
3513
3514
  const { tenant_id: i, send_invitation_email: e, ...t } = n, r = { ...t };
3514
3515
  for (const o of Nt)
3515
- r[o] = x(t[o], o === "roles" ? [] : {});
3516
+ r[o] = b(t[o], o === "roles" ? [] : {});
3516
3517
  return r.send_invitation_email = !!e, z(r);
3517
3518
  }
3518
- function cs(n) {
3519
+ function ds(n) {
3519
3520
  return {
3520
3521
  async create(i, e) {
3521
- var u, c;
3522
- const t = e.id || ds(), r = e.ttl_sec || 604800, o = /* @__PURE__ */ new Date(), l = new Date(o.getTime() + r * 1e3).toISOString(), _ = {
3522
+ var d, c;
3523
+ const t = e.id || us(), r = e.ttl_sec || 604800, o = /* @__PURE__ */ new Date(), l = new Date(o.getTime() + r * 1e3).toISOString(), _ = {
3523
3524
  id: t,
3524
3525
  tenant_id: i,
3525
3526
  organization_id: e.organization_id,
@@ -3532,12 +3533,12 @@ function cs(n) {
3532
3533
  created_at: o.toISOString(),
3533
3534
  expires_at: l
3534
3535
  };
3535
- for (const d of Nt)
3536
- e[d] !== void 0 && (_[d] = JSON.stringify(e[d]));
3536
+ for (const u of Nt)
3537
+ e[u] !== void 0 && (_[u] = JSON.stringify(e[u]));
3537
3538
  try {
3538
3539
  await n.insert(ne).values(_);
3539
- } catch (d) {
3540
- throw (u = d == null ? void 0 : d.message) != null && u.includes("UNIQUE constraint failed") || (c = d == null ? void 0 : d.message) != null && c.includes("duplicate key") ? new be(409, { message: "Invite already exists" }) : d;
3540
+ } catch (u) {
3541
+ throw (d = u == null ? void 0 : u.message) != null && d.includes("UNIQUE constraint failed") || (c = u == null ? void 0 : u.message) != null && c.includes("duplicate key") ? new xe(409, { message: "Invite already exists" }) : u;
3541
3542
  }
3542
3543
  return st({ ..._, tenant_id: i });
3543
3544
  },
@@ -3562,20 +3563,20 @@ function cs(n) {
3562
3563
  } = e || {};
3563
3564
  let _ = n.select().from(ne).where(a(ne.tenant_id, i)).$dynamic();
3564
3565
  if (l != null && l.sort_by) {
3565
- const h = ne[l.sort_by];
3566
- h && (_ = _.orderBy(
3567
- l.sort_order === "desc" ? V(h) : G(h)
3566
+ const p = ne[l.sort_by];
3567
+ p && (_ = _.orderBy(
3568
+ l.sort_order === "desc" ? V(p) : G(p)
3568
3569
  ));
3569
3570
  }
3570
3571
  const c = (await _.offset(t * r).limit(r)).map(st);
3571
3572
  if (!o)
3572
3573
  return { invites: c };
3573
- const [d] = await n.select({ count: R() }).from(ne).where(a(ne.tenant_id, i));
3574
+ const [u] = await n.select({ count: R() }).from(ne).where(a(ne.tenant_id, i));
3574
3575
  return {
3575
3576
  invites: c,
3576
3577
  start: t * r,
3577
3578
  limit: r,
3578
- length: Number((d == null ? void 0 : d.count) ?? 0)
3579
+ length: Number((u == null ? void 0 : u.count) ?? 0)
3579
3580
  };
3580
3581
  },
3581
3582
  async remove(i, e) {
@@ -3583,10 +3584,10 @@ function cs(n) {
3583
3584
  }
3584
3585
  };
3585
3586
  }
3586
- function gs(n) {
3587
+ function cs(n) {
3587
3588
  return {
3588
3589
  async create(i) {
3589
- await n.insert(he).values({
3590
+ await n.insert(pe).values({
3590
3591
  ...i,
3591
3592
  created_at: (/* @__PURE__ */ new Date()).toDateString()
3592
3593
  });
@@ -3598,34 +3599,34 @@ function gs(n) {
3598
3599
  include_totals: r = !1,
3599
3600
  sort: o
3600
3601
  } = i || {}, l = (/* @__PURE__ */ new Date()).toISOString();
3601
- let _ = n.select().from(he).where(de(We(he.revoked_at, l), ye(he.revoked_at))).$dynamic();
3602
+ let _ = n.select().from(pe).where(de(We(pe.revoked_at, l), me(pe.revoked_at))).$dynamic();
3602
3603
  if (o != null && o.sort_by) {
3603
- const h = he[o.sort_by];
3604
- h && (_ = _.orderBy(
3605
- o.sort_order === "desc" ? V(h) : G(h)
3604
+ const p = pe[o.sort_by];
3605
+ p && (_ = _.orderBy(
3606
+ o.sort_order === "desc" ? V(p) : G(p)
3606
3607
  ));
3607
3608
  }
3608
- const c = (await _.offset(e * t).limit(t)).map((h) => {
3609
- const { created_at: f, ...y } = h;
3609
+ const c = (await _.offset(e * t).limit(t)).map((p) => {
3610
+ const { created_at: f, ...y } = p;
3610
3611
  return z(y);
3611
3612
  });
3612
3613
  if (!r)
3613
3614
  return { signingKeys: c };
3614
- const [d] = await n.select({ count: R() }).from(he).where(de(We(he.revoked_at, l), ye(he.revoked_at)));
3615
+ const [u] = await n.select({ count: R() }).from(pe).where(de(We(pe.revoked_at, l), me(pe.revoked_at)));
3615
3616
  return {
3616
3617
  signingKeys: c,
3617
3618
  start: e * t,
3618
3619
  limit: t,
3619
- length: Ur((d == null ? void 0 : d.count) ?? 0)
3620
+ length: Fr((u == null ? void 0 : u.count) ?? 0)
3620
3621
  };
3621
3622
  },
3622
3623
  async update(i, e) {
3623
- return (await n.update(he).set(e).where(a(he.kid, i)).returning()).length > 0;
3624
+ return (await n.update(pe).set(e).where(a(pe.kid, i)).returning()).length > 0;
3624
3625
  }
3625
3626
  };
3626
3627
  }
3627
3628
  const vt = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", ot = vt.length;
3628
- function fs() {
3629
+ function gs() {
3629
3630
  let e = Date.now(), t = "";
3630
3631
  for (let o = 10; o > 0; o--)
3631
3632
  t = vt.charAt(e % ot) + t, e = Math.floor(e / ot);
@@ -3644,26 +3645,26 @@ function Bt(n) {
3644
3645
  state_data: o,
3645
3646
  auth_params: l,
3646
3647
  ..._
3647
- } = n, u = Pe(
3648
+ } = n, d = Pe(
3648
3649
  { created_at_ts: e, updated_at_ts: t, expires_at_ts: r },
3649
3650
  ["created_at_ts", "updated_at_ts", "expires_at_ts"]
3650
3651
  ), c = {};
3651
- for (const [h, f] of Object.entries(_))
3652
- f != null && (c[h] = f);
3653
- const d = fr(c, ["auth_strategy"]);
3652
+ for (const [p, f] of Object.entries(_))
3653
+ f != null && (c[p] = f);
3654
+ const u = gr(c, ["auth_strategy"]);
3654
3655
  return z({
3655
- ...d,
3656
- authParams: typeof l == "string" && l.length > 0 ? JSON.parse(l) : {},
3657
3656
  ...u,
3658
- state_data: x(o)
3657
+ authParams: typeof l == "string" && l.length > 0 ? JSON.parse(l) : {},
3658
+ ...d,
3659
+ state_data: b(o)
3659
3660
  });
3660
3661
  }
3661
- function ps(n) {
3662
+ function fs(n) {
3662
3663
  return {
3663
3664
  async create(i, e) {
3664
3665
  var l, _;
3665
3666
  const t = Date.now(), o = {
3666
- id: fs(),
3667
+ id: gs(),
3667
3668
  tenant_id: i,
3668
3669
  session_id: e.session_id,
3669
3670
  csrf_token: e.csrf_token,
@@ -3682,12 +3683,12 @@ function ps(n) {
3682
3683
  authenticated_at: e.authenticated_at,
3683
3684
  created_at_ts: t,
3684
3685
  updated_at_ts: t,
3685
- expires_at_ts: e.expires_at ? j(e.expires_at) : t + 1e3 * 60 * 60 * 24
3686
+ expires_at_ts: e.expires_at ? $(e.expires_at) : t + 1e3 * 60 * 60 * 24
3686
3687
  };
3687
- return await n.insert(L).values(o), Bt({ ...o, tenant_id: i });
3688
+ return await n.insert(q).values(o), Bt({ ...o, tenant_id: i });
3688
3689
  },
3689
3690
  async get(i, e) {
3690
- const t = i ? g(a(L.tenant_id, i), a(L.id, e)) : a(L.id, e), r = await n.select().from(L).where(t).get();
3691
+ const t = i ? g(a(q.tenant_id, i), a(q.id, e)) : a(q.id, e), r = await n.select().from(q).where(t).get();
3691
3692
  return r ? Bt(r) : null;
3692
3693
  },
3693
3694
  async update(i, e, t) {
@@ -3698,25 +3699,25 @@ function ps(n) {
3698
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(
3699
3700
  0,
3700
3701
  1024
3701
- )), t.expires_at !== void 0 && (r.expires_at_ts = j(t.expires_at)), t.authParams !== void 0) {
3702
- const u = await n.select({ auth_params: L.auth_params }).from(L).where(
3702
+ )), t.expires_at !== void 0 && (r.expires_at_ts = $(t.expires_at)), t.authParams !== void 0) {
3703
+ const d = await n.select({ auth_params: q.auth_params }).from(q).where(
3703
3704
  g(
3704
- a(L.tenant_id, i),
3705
- a(L.id, e)
3705
+ a(q.tenant_id, i),
3706
+ a(q.id, e)
3706
3707
  )
3707
- ).get(), c = u != null && u.auth_params && typeof u.auth_params == "string" && u.auth_params.length > 0 ? JSON.parse(u.auth_params) : {};
3708
+ ).get(), c = d != null && d.auth_params && typeof d.auth_params == "string" && d.auth_params.length > 0 ? JSON.parse(d.auth_params) : {};
3708
3709
  r.auth_params = JSON.stringify({
3709
3710
  ...c,
3710
3711
  ...t.authParams
3711
3712
  });
3712
3713
  }
3713
- return await n.update(L).set(r).where(
3714
- g(a(L.tenant_id, i), a(L.id, e))
3714
+ return await n.update(q).set(r).where(
3715
+ g(a(q.tenant_id, i), a(q.id, e))
3715
3716
  ), !0;
3716
3717
  },
3717
3718
  async remove(i, e) {
3718
- return (await n.delete(L).where(
3719
- g(a(L.tenant_id, i), a(L.id, e))
3719
+ return (await n.delete(q).where(
3720
+ g(a(q.tenant_id, i), a(q.id, e))
3720
3721
  ).returning()).length > 0;
3721
3722
  }
3722
3723
  };
@@ -3730,25 +3731,25 @@ function at(n) {
3730
3731
  country_code: o,
3731
3732
  city_name: l,
3732
3733
  latitude: _,
3733
- longitude: u,
3734
+ longitude: d,
3734
3735
  time_zone: c,
3735
- continent_code: d,
3736
- scope: h,
3736
+ continent_code: u,
3737
+ scope: p,
3737
3738
  ...f
3738
3739
  } = n, y = {
3739
3740
  ...f,
3740
3741
  isMobile: !!e,
3741
- auth0_client: x(t),
3742
- details: x(r),
3743
- scope: h ? h.split(",") : void 0
3742
+ auth0_client: b(t),
3743
+ details: b(r),
3744
+ scope: p ? p.split(",") : void 0
3744
3745
  };
3745
3746
  return o && (y.location_info = z({
3746
3747
  country_code: o,
3747
3748
  city_name: l,
3748
3749
  latitude: _,
3749
- longitude: u,
3750
+ longitude: d,
3750
3751
  time_zone: c,
3751
- continent_code: d
3752
+ continent_code: u
3752
3753
  })), z(y);
3753
3754
  }
3754
3755
  function hs(n) {
@@ -3778,7 +3779,7 @@ function hs(n) {
3778
3779
  hostname: e.hostname,
3779
3780
  session_connection: e.session_connection
3780
3781
  };
3781
- return e.auth0_client && (r.auth0_client = JSON.stringify(e.auth0_client)), e.details && (r.details = JSON.stringify(e.details).substring(0, 8192)), e.location_info && (r.country_code = e.location_info.country_code, r.city_name = e.location_info.city_name, r.latitude = e.location_info.latitude, r.longitude = e.location_info.longitude, r.time_zone = e.location_info.time_zone, r.continent_code = e.location_info.continent_code), await n.insert(q).values(r), at({ ...r, tenant_id: i });
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(T).values(r), at({ ...r, tenant_id: i });
3782
3783
  },
3783
3784
  async list(i, e) {
3784
3785
  const {
@@ -3788,42 +3789,42 @@ function hs(n) {
3788
3789
  sort: l,
3789
3790
  q: _
3790
3791
  } = e || {};
3791
- let u = n.select().from(q).where(a(q.tenant_id, i)).$dynamic();
3792
+ let d = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
3792
3793
  if (_) {
3793
- const f = me(q, _, [
3794
+ const f = ye(T, _, [
3794
3795
  "user_id",
3795
3796
  "ip",
3796
3797
  "type",
3797
3798
  "client_id"
3798
3799
  ]);
3799
- f && (u = u.where(g(a(q.tenant_id, i), f)));
3800
+ f && (d = d.where(g(a(T.tenant_id, i), f)));
3800
3801
  }
3801
3802
  if (l != null && l.sort_by) {
3802
- const f = q[l.sort_by];
3803
- f && (u = u.orderBy(
3803
+ const f = T[l.sort_by];
3804
+ f && (d = d.orderBy(
3804
3805
  l.sort_order === "desc" ? V(f) : G(f)
3805
3806
  ));
3806
3807
  } else
3807
- u = u.orderBy(V(q.date));
3808
- const d = (await u.offset(t * r).limit(r)).map(at);
3808
+ d = d.orderBy(V(T.date));
3809
+ const u = (await d.offset(t * r).limit(r)).map(at);
3809
3810
  if (!o)
3810
- return { logs: d };
3811
- const [h] = await n.select({ count: R() }).from(q).where(a(q.tenant_id, i));
3811
+ return { logs: u };
3812
+ const [p] = await n.select({ count: R() }).from(T).where(a(T.tenant_id, i));
3812
3813
  return {
3813
- logs: d,
3814
+ logs: u,
3814
3815
  start: t * r,
3815
3816
  limit: r,
3816
- length: Number((h == null ? void 0 : h.count) ?? 0)
3817
+ length: Number((p == null ? void 0 : p.count) ?? 0)
3817
3818
  };
3818
3819
  },
3819
3820
  async get(i, e) {
3820
- const t = await n.select().from(q).where(g(a(q.tenant_id, i), a(q.log_id, e))).get();
3821
+ const t = await n.select().from(T).where(g(a(T.tenant_id, i), a(T.log_id, e))).get();
3821
3822
  return t ? at(t) : null;
3822
3823
  }
3823
3824
  };
3824
3825
  }
3825
3826
  const St = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", lt = St.length;
3826
- function ms() {
3827
+ function ps() {
3827
3828
  let e = Date.now(), t = "";
3828
3829
  for (let o = 10; o > 0; o--)
3829
3830
  t = St.charAt(e % lt) + t, e = Math.floor(e / lt);
@@ -3847,16 +3848,16 @@ function je(n) {
3847
3848
  ..._,
3848
3849
  confirmed: !!o,
3849
3850
  credential_backed_up: r != null ? !!r : void 0,
3850
- transports: x(l),
3851
+ transports: b(l),
3851
3852
  created_at: wt(e),
3852
3853
  updated_at: wt(t)
3853
3854
  });
3854
3855
  }
3855
- function ys(n) {
3856
+ function ms(n) {
3856
3857
  return {
3857
3858
  async create(i, e) {
3858
3859
  const t = Date.now(), o = {
3859
- id: e.id || ms(),
3860
+ id: e.id || ps(),
3860
3861
  tenant_id: i,
3861
3862
  user_id: e.user_id,
3862
3863
  type: e.type,
@@ -3872,31 +3873,31 @@ function ys(n) {
3872
3873
  created_at_ts: t,
3873
3874
  updated_at_ts: t
3874
3875
  };
3875
- return await n.insert(U).values(o), je({ ...o, tenant_id: i });
3876
+ return await n.insert(K).values(o), je({ ...o, tenant_id: i });
3876
3877
  },
3877
3878
  async get(i, e) {
3878
- const t = await n.select().from(U).where(
3879
+ const t = await n.select().from(K).where(
3879
3880
  g(
3880
- a(U.tenant_id, i),
3881
- a(U.id, e)
3881
+ a(K.tenant_id, i),
3882
+ a(K.id, e)
3882
3883
  )
3883
3884
  ).get();
3884
3885
  return t ? je(t) : null;
3885
3886
  },
3886
3887
  async getByCredentialId(i, e) {
3887
- const t = await n.select().from(U).where(
3888
+ const t = await n.select().from(K).where(
3888
3889
  g(
3889
- a(U.tenant_id, i),
3890
- a(U.credential_id, e)
3890
+ a(K.tenant_id, i),
3891
+ a(K.credential_id, e)
3891
3892
  )
3892
3893
  ).get();
3893
3894
  return t ? je(t) : null;
3894
3895
  },
3895
3896
  async list(i, e) {
3896
- return (await n.select().from(U).where(
3897
+ return (await n.select().from(K).where(
3897
3898
  g(
3898
- a(U.tenant_id, i),
3899
- a(U.user_id, e)
3899
+ a(K.tenant_id, i),
3900
+ a(K.user_id, e)
3900
3901
  )
3901
3902
  ).all()).map(je);
3902
3903
  },
@@ -3904,10 +3905,10 @@ function ys(n) {
3904
3905
  const r = {
3905
3906
  updated_at_ts: Date.now()
3906
3907
  };
3907
- 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(
3908
3909
  g(
3909
- a(U.tenant_id, i),
3910
- a(U.id, e)
3910
+ a(K.tenant_id, i),
3911
+ a(K.id, e)
3911
3912
  )
3912
3913
  );
3913
3914
  const o = await this.get(i, e);
@@ -3918,16 +3919,16 @@ function ys(n) {
3918
3919
  return o;
3919
3920
  },
3920
3921
  async remove(i, e) {
3921
- return (await n.delete(U).where(
3922
+ return (await n.delete(K).where(
3922
3923
  g(
3923
- a(U.tenant_id, i),
3924
- a(U.id, e)
3924
+ a(K.tenant_id, i),
3925
+ a(K.id, e)
3925
3926
  )
3926
3927
  ).returning()).length > 0;
3927
3928
  }
3928
3929
  };
3929
3930
  }
3930
- function ws() {
3931
+ function ys() {
3931
3932
  const { customAlphabet: n } = require("nanoid");
3932
3933
  return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3933
3934
  }
@@ -3942,18 +3943,18 @@ function _t(n) {
3942
3943
  } = n;
3943
3944
  return z({
3944
3945
  ...l,
3945
- branding: x(e, {}),
3946
- metadata: x(t, {}),
3947
- enabled_connections: x(r, []),
3948
- token_quota: x(o, {})
3946
+ branding: b(e, {}),
3947
+ metadata: b(t, {}),
3948
+ enabled_connections: b(r, []),
3949
+ token_quota: b(o, {})
3949
3950
  });
3950
3951
  }
3951
- function Ns(n) {
3952
+ function ws(n) {
3952
3953
  return {
3953
3954
  async create(i, e) {
3954
3955
  var l, _;
3955
3956
  const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
3956
- id: e.id || ws(),
3957
+ id: e.id || ys(),
3957
3958
  tenant_id: i,
3958
3959
  name: e.name,
3959
3960
  display_name: e.display_name,
@@ -3965,22 +3966,22 @@ function Ns(n) {
3965
3966
  updated_at: t
3966
3967
  };
3967
3968
  try {
3968
- await n.insert(E).values(o);
3969
- } catch (u) {
3970
- throw (l = u == null ? void 0 : u.message) != null && l.includes("UNIQUE constraint failed") || (_ = u == null ? void 0 : u.message) != null && _.includes("AlreadyExists") ? new be(409, {
3969
+ await n.insert(L).values(o);
3970
+ } catch (d) {
3971
+ throw (l = d == null ? void 0 : d.message) != null && l.includes("UNIQUE constraint failed") || (_ = d == null ? void 0 : d.message) != null && _.includes("AlreadyExists") ? new xe(409, {
3971
3972
  message: "Organization already exists"
3972
- }) : u;
3973
+ }) : d;
3973
3974
  }
3974
3975
  return _t({ ...o, tenant_id: i });
3975
3976
  },
3976
3977
  async get(i, e) {
3977
- let t = await n.select().from(E).where(
3978
- g(a(E.tenant_id, i), a(E.id, e))
3978
+ let t = await n.select().from(L).where(
3979
+ g(a(L.tenant_id, i), a(L.id, e))
3979
3980
  ).get();
3980
- return t || (t = await n.select().from(E).where(
3981
+ return t || (t = await n.select().from(L).where(
3981
3982
  g(
3982
- a(E.tenant_id, i),
3983
- a(E.name, e)
3983
+ a(L.tenant_id, i),
3984
+ a(L.name, e)
3984
3985
  )
3985
3986
  ).get()), t ? _t(t) : null;
3986
3987
  },
@@ -3990,8 +3991,8 @@ function Ns(n) {
3990
3991
  };
3991
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(
3992
3993
  t.enabled_connections
3993
- )), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(E).set(r).where(
3994
- g(a(E.tenant_id, i), a(E.id, e))
3994
+ )), t.token_quota !== void 0 && (r.token_quota = JSON.stringify(t.token_quota)), (await n.update(L).set(r).where(
3995
+ g(a(L.tenant_id, i), a(L.id, e))
3995
3996
  ).returning()).length > 0;
3996
3997
  },
3997
3998
  async list(i, e) {
@@ -4002,39 +4003,39 @@ function Ns(n) {
4002
4003
  sort: l,
4003
4004
  q: _
4004
4005
  } = e || {};
4005
- let u = n.select().from(E).where(a(E.tenant_id, i)).$dynamic();
4006
- if (_ && (u = u.where(
4006
+ let d = n.select().from(L).where(a(L.tenant_id, i)).$dynamic();
4007
+ if (_ && (d = d.where(
4007
4008
  de(
4008
- Ie(E.name, `%${_}%`),
4009
- Ie(E.display_name, `%${_}%`)
4009
+ Ie(L.name, `%${_}%`),
4010
+ Ie(L.display_name, `%${_}%`)
4010
4011
  )
4011
4012
  )), l != null && l.sort_by) {
4012
- const y = E[l.sort_by];
4013
- y && (u = u.orderBy(
4013
+ const y = L[l.sort_by];
4014
+ y && (d = d.orderBy(
4014
4015
  l.sort_order === "desc" ? V(y) : G(y)
4015
4016
  ));
4016
4017
  }
4017
- const d = (await u.offset(t * r).limit(r)).map(_t);
4018
+ const u = (await d.offset(t * r).limit(r)).map(_t);
4018
4019
  if (!o)
4019
- return { organizations: d };
4020
- const h = [a(E.tenant_id, i)];
4021
- _ && h.push(
4020
+ return { organizations: u };
4021
+ const p = [a(L.tenant_id, i)];
4022
+ _ && p.push(
4022
4023
  de(
4023
- Ie(E.name, `%${_}%`),
4024
- Ie(E.display_name, `%${_}%`)
4024
+ Ie(L.name, `%${_}%`),
4025
+ Ie(L.display_name, `%${_}%`)
4025
4026
  )
4026
4027
  );
4027
- const [f] = await n.select({ count: R() }).from(E).where(g(...h));
4028
+ const [f] = await n.select({ count: R() }).from(L).where(g(...p));
4028
4029
  return {
4029
- organizations: d,
4030
+ organizations: u,
4030
4031
  start: t * r,
4031
4032
  limit: r,
4032
4033
  length: Number((f == null ? void 0 : f.count) ?? 0)
4033
4034
  };
4034
4035
  },
4035
4036
  async remove(i, e) {
4036
- return (await n.delete(E).where(
4037
- g(a(E.tenant_id, i), a(E.id, e))
4037
+ return (await n.delete(L).where(
4038
+ g(a(L.tenant_id, i), a(L.id, e))
4038
4039
  ).returning()).length > 0;
4039
4040
  }
4040
4041
  };
@@ -4046,14 +4047,14 @@ function ut(n) {
4046
4047
  is_current: !!e
4047
4048
  };
4048
4049
  }
4049
- function vs(n) {
4050
+ function Ns(n) {
4050
4051
  return {
4051
4052
  async create(i, e) {
4052
4053
  const t = (/* @__PURE__ */ new Date()).toISOString(), r = e.id || ae();
4053
- e.is_current !== !1 && await n.update(A).set({ is_current: 0 }).where(
4054
+ e.is_current !== !1 && await n.update(C).set({ is_current: 0 }).where(
4054
4055
  g(
4055
- a(A.tenant_id, i),
4056
- a(A.user_id, e.user_id)
4056
+ a(C.tenant_id, i),
4057
+ a(C.user_id, e.user_id)
4057
4058
  )
4058
4059
  );
4059
4060
  const o = {
@@ -4066,47 +4067,47 @@ function vs(n) {
4066
4067
  created_at: t,
4067
4068
  updated_at: t
4068
4069
  };
4069
- return await n.insert(A).values(o), ut({ ...o, tenant_id: i });
4070
+ return await n.insert(C).values(o), ut({ ...o, tenant_id: i });
4070
4071
  },
4071
4072
  async get(i, e) {
4072
- const t = await n.select().from(A).where(
4073
+ const t = await n.select().from(C).where(
4073
4074
  g(
4074
- a(A.tenant_id, i),
4075
- a(A.user_id, e),
4076
- a(A.is_current, 1)
4075
+ a(C.tenant_id, i),
4076
+ a(C.user_id, e),
4077
+ a(C.is_current, 1)
4077
4078
  )
4078
4079
  ).get();
4079
4080
  return t ? ut(t) : null;
4080
4081
  },
4081
4082
  async list(i, e, t) {
4082
- let r = n.select().from(A).where(
4083
+ let r = n.select().from(C).where(
4083
4084
  g(
4084
- a(A.tenant_id, i),
4085
- a(A.user_id, e)
4085
+ a(C.tenant_id, i),
4086
+ a(C.user_id, e)
4086
4087
  )
4087
- ).orderBy(V(A.created_at)).$dynamic();
4088
+ ).orderBy(V(C.created_at)).$dynamic();
4088
4089
  return t && (r = r.limit(t)), (await r).map(ut);
4089
4090
  },
4090
4091
  async update(i, e) {
4091
4092
  const t = {
4092
4093
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4093
4094
  };
4094
- return e.password !== void 0 && (t.password = e.password), e.algorithm !== void 0 && (t.algorithm = e.algorithm), e.is_current !== void 0 && (t.is_current = e.is_current ? 1 : 0), e.id ? await n.update(A).set(t).where(
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(C).set(t).where(
4095
4096
  g(
4096
- a(A.tenant_id, i),
4097
- a(A.id, e.id)
4097
+ a(C.tenant_id, i),
4098
+ a(C.id, e.id)
4098
4099
  )
4099
- ) : await n.update(A).set(t).where(
4100
+ ) : await n.update(C).set(t).where(
4100
4101
  g(
4101
- a(A.tenant_id, i),
4102
- a(A.user_id, e.user_id),
4103
- a(A.is_current, 1)
4102
+ a(C.tenant_id, i),
4103
+ a(C.user_id, e.user_id),
4104
+ a(C.is_current, 1)
4104
4105
  )
4105
4106
  ), !0;
4106
4107
  }
4107
4108
  };
4108
4109
  }
4109
- function Ss(n) {
4110
+ function vs(n) {
4110
4111
  return {
4111
4112
  async get(i) {
4112
4113
  const e = await n.select().from(Ee).where(a(Ee.tenant_id, i)).get();
@@ -4148,27 +4149,39 @@ function dt(n) {
4148
4149
  expires_at_ts: t,
4149
4150
  idle_expires_at_ts: r,
4150
4151
  last_exchanged_at_ts: o,
4151
- device: l,
4152
- resource_servers: _,
4153
- rotating: u,
4154
- ...c
4155
- } = n, d = Pe(
4156
- { 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: d,
4155
+ rotating: c,
4156
+ ...u
4157
+ } = n, p = 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
+ },
4157
4165
  ["created_at_ts"],
4158
- ["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
+ ]
4159
4172
  );
4160
4173
  return z({
4161
- ...c,
4162
- ...d,
4163
- rotating: !!u,
4164
- device: x(l, {}),
4165
- resource_servers: x(_, [])
4174
+ ...u,
4175
+ ...p,
4176
+ rotating: !!c,
4177
+ device: b(_, {}),
4178
+ resource_servers: b(d, [])
4166
4179
  });
4167
4180
  }
4168
- function $t(n, i) {
4181
+ function Ss(n, i) {
4169
4182
  return Math.max(n ?? 0, i ?? 0);
4170
4183
  }
4171
- function xs(n) {
4184
+ function bs(n) {
4172
4185
  return {
4173
4186
  async create(i, e) {
4174
4187
  const t = Date.now(), r = {
@@ -4181,82 +4194,58 @@ function xs(n) {
4181
4194
  resource_servers: JSON.stringify(e.resource_servers || []),
4182
4195
  rotating: e.rotating ?? !1,
4183
4196
  created_at_ts: t,
4184
- expires_at_ts: j(e.expires_at),
4185
- idle_expires_at_ts: j(e.idle_expires_at),
4186
- last_exchanged_at_ts: j(e.last_exchanged_at)
4197
+ expires_at_ts: $(e.expires_at),
4198
+ idle_expires_at_ts: $(e.idle_expires_at),
4199
+ last_exchanged_at_ts: $(e.last_exchanged_at)
4187
4200
  };
4188
- await n.run(w`BEGIN`);
4201
+ await n.run(N`BEGIN`);
4189
4202
  try {
4190
- await n.insert(T).values(r);
4191
- const o = $t(
4203
+ await n.insert(E).values(r);
4204
+ const o = Ss(
4192
4205
  r.expires_at_ts,
4193
4206
  r.idle_expires_at_ts
4194
4207
  );
4195
- o > 0 && r.login_id && await n.update(L).set({
4208
+ o > 0 && r.login_id && await n.update(q).set({
4196
4209
  expires_at_ts: o,
4197
4210
  updated_at_ts: t
4198
4211
  }).where(
4199
4212
  g(
4200
- a(L.tenant_id, i),
4201
- a(L.id, r.login_id),
4202
- we(L.expires_at_ts, o)
4213
+ a(q.tenant_id, i),
4214
+ a(q.id, r.login_id),
4215
+ we(q.expires_at_ts, o)
4203
4216
  )
4204
- ), await n.run(w`COMMIT`);
4217
+ ), await n.run(N`COMMIT`);
4205
4218
  } catch (o) {
4206
- throw await n.run(w`ROLLBACK`), o;
4219
+ throw await n.run(N`ROLLBACK`), o;
4207
4220
  }
4208
4221
  return dt({ ...r, tenant_id: i });
4209
4222
  },
4210
4223
  async get(i, e) {
4211
- const t = await n.select().from(T).where(
4212
- g(a(T.tenant_id, i), a(T.id, e))
4224
+ const t = await n.select().from(E).where(
4225
+ g(a(E.tenant_id, i), a(E.id, e))
4213
4226
  ).get();
4214
4227
  return t ? dt(t) : null;
4215
4228
  },
4216
- async update(i, e, t) {
4217
- const r = {};
4218
- 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));
4219
- const o = r.expires_at_ts !== void 0 || r.idle_expires_at_ts !== void 0;
4220
- await n.run(w`BEGIN`);
4221
- try {
4222
- const _ = (await n.update(T).set(r).where(
4223
- g(
4224
- a(T.tenant_id, i),
4225
- a(T.id, e)
4226
- )
4227
- ).returning()).length > 0;
4228
- if (_ && o) {
4229
- const u = await n.select({
4230
- login_id: T.login_id,
4231
- expires_at_ts: T.expires_at_ts,
4232
- idle_expires_at_ts: T.idle_expires_at_ts
4233
- }).from(T).where(
4234
- g(
4235
- a(T.tenant_id, i),
4236
- a(T.id, e)
4237
- )
4238
- ).get();
4239
- if (u != null && u.login_id) {
4240
- const c = $t(
4241
- u.expires_at_ts,
4242
- u.idle_expires_at_ts
4243
- );
4244
- c > 0 && await n.update(L).set({
4245
- expires_at_ts: c,
4246
- updated_at_ts: Date.now()
4247
- }).where(
4248
- g(
4249
- a(L.tenant_id, i),
4250
- a(L.id, u.login_id),
4251
- we(L.expires_at_ts, c)
4252
- )
4253
- );
4254
- }
4255
- }
4256
- return await n.run(w`COMMIT`), _;
4257
- } catch (l) {
4258
- throw await n.run(w`ROLLBACK`), l;
4259
- }
4229
+ async update(i, e, t, r) {
4230
+ const o = {};
4231
+ t.device !== void 0 && (o.device = JSON.stringify(t.device)), t.resource_servers !== void 0 && (o.resource_servers = JSON.stringify(t.resource_servers)), t.rotating !== void 0 && (o.rotating = t.rotating), t.expires_at !== void 0 && (o.expires_at_ts = $(t.expires_at)), t.idle_expires_at !== void 0 && (o.idle_expires_at_ts = $(t.idle_expires_at)), t.last_exchanged_at !== void 0 && (o.last_exchanged_at_ts = $(t.last_exchanged_at)), t.revoked_at !== void 0 && (o.revoked_at_ts = $(t.revoked_at));
4232
+ const l = r == null ? void 0 : r.loginSessionBump, _ = l ? $(l.expires_at) : null, d = await n.update(E).set(o).where(
4233
+ g(
4234
+ a(E.tenant_id, i),
4235
+ a(E.id, e)
4236
+ )
4237
+ ).returning();
4238
+ return l != null && l.login_id && _ && _ > 0 && await n.update(q).set({
4239
+ expires_at_ts: _,
4240
+ updated_at_ts: Date.now()
4241
+ }).where(
4242
+ g(
4243
+ a(q.tenant_id, i),
4244
+ a(q.id, l.login_id),
4245
+ we(q.expires_at_ts, _)
4246
+ )
4247
+ ).catch(() => {
4248
+ }), d.length > 0;
4260
4249
  },
4261
4250
  async list(i, e) {
4262
4251
  const {
@@ -4266,46 +4255,55 @@ function xs(n) {
4266
4255
  sort: l,
4267
4256
  q: _
4268
4257
  } = e || {};
4269
- let u = n.select().from(T).where(a(T.tenant_id, i)).$dynamic();
4258
+ let d = n.select().from(E).where(a(E.tenant_id, i)).$dynamic();
4270
4259
  if (_) {
4271
- const f = me(T, _, ["user_id"]);
4272
- f && (u = u.where(
4273
- g(a(T.tenant_id, i), f)
4260
+ const f = ye(E, _, ["user_id"]);
4261
+ f && (d = d.where(
4262
+ g(a(E.tenant_id, i), f)
4274
4263
  ));
4275
4264
  }
4276
4265
  if (l != null && l.sort_by) {
4277
- const f = T[l.sort_by];
4278
- f && (u = u.orderBy(
4266
+ const f = E[l.sort_by];
4267
+ f && (d = d.orderBy(
4279
4268
  l.sort_order === "desc" ? V(f) : G(f)
4280
4269
  ));
4281
4270
  }
4282
- const d = (await u.offset(t * r).limit(r)).map(dt);
4271
+ const u = (await d.offset(t * r).limit(r)).map(dt);
4283
4272
  if (!o)
4284
- return { refresh_tokens: d };
4285
- const [h] = await n.select({ count: R() }).from(T).where(a(T.tenant_id, i));
4273
+ return { refresh_tokens: u };
4274
+ const [p] = await n.select({ count: R() }).from(E).where(a(E.tenant_id, i));
4286
4275
  return {
4287
- refresh_tokens: d,
4276
+ refresh_tokens: u,
4288
4277
  start: t * r,
4289
4278
  limit: r,
4290
- length: Number((h == null ? void 0 : h.count) ?? 0)
4279
+ length: Number((p == null ? void 0 : p.count) ?? 0)
4291
4280
  };
4292
4281
  },
4293
4282
  async remove(i, e) {
4294
- return (await n.delete(T).where(
4295
- g(a(T.tenant_id, i), a(T.id, e))
4283
+ return (await n.delete(E).where(
4284
+ g(a(E.tenant_id, i), a(E.id, e))
4296
4285
  ).returning()).length > 0;
4286
+ },
4287
+ async revokeByLoginSession(i, e, t) {
4288
+ return (await n.update(E).set({ revoked_at_ts: $(t) }).where(
4289
+ g(
4290
+ a(E.tenant_id, i),
4291
+ a(E.login_id, e),
4292
+ me(E.revoked_at_ts)
4293
+ )
4294
+ ).returning()).length;
4297
4295
  }
4298
4296
  };
4299
4297
  }
4300
- function bs() {
4298
+ function xs() {
4301
4299
  const { customAlphabet: n } = require("nanoid");
4302
4300
  return `api_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
4303
4301
  }
4304
- const xt = [
4302
+ const bt = [
4305
4303
  "skip_consent_for_verifiable_first_party_clients",
4306
4304
  "allow_offline_access",
4307
4305
  "is_system"
4308
- ], Qt = /* @__PURE__ */ new Set([
4306
+ ], $t = /* @__PURE__ */ new Set([
4309
4307
  "id",
4310
4308
  "tenant_id",
4311
4309
  "identifier",
@@ -4333,16 +4331,16 @@ function ct(n) {
4333
4331
  metadata: o,
4334
4332
  ...l
4335
4333
  } = n, _ = { ...l };
4336
- _.scopes = x(t, []), _.options = x(r, {}), _.metadata = x(o), e !== void 0 && (_.verificationKey = e);
4337
- for (const u of xt)
4338
- l[u] !== void 0 && l[u] !== null && (_[u] = !!l[u]);
4334
+ _.scopes = b(t, []), _.options = b(r, {}), _.metadata = b(o), e !== void 0 && (_.verificationKey = e);
4335
+ for (const d of bt)
4336
+ l[d] !== void 0 && l[d] !== null && (_[d] = !!l[d]);
4339
4337
  return z(_);
4340
4338
  }
4341
4339
  function Ds(n) {
4342
4340
  return {
4343
4341
  async create(i, e) {
4344
4342
  const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
4345
- id: e.id || bs(),
4343
+ id: e.id || xs(),
4346
4344
  tenant_id: i,
4347
4345
  identifier: e.identifier,
4348
4346
  name: e.name,
@@ -4357,15 +4355,15 @@ function Ds(n) {
4357
4355
  created_at: t,
4358
4356
  updated_at: t
4359
4357
  };
4360
- for (const l of xt)
4358
+ for (const l of bt)
4361
4359
  e[l] !== void 0 && (o[l] = e[l] ? 1 : 0);
4362
- return o.is_system === void 0 && (o.is_system = 0), await n.insert(C).values(o), ct({ ...o, tenant_id: i });
4360
+ return o.is_system === void 0 && (o.is_system = 0), await n.insert(A).values(o), ct({ ...o, tenant_id: i });
4363
4361
  },
4364
4362
  async get(i, e) {
4365
- const t = await n.select().from(C).where(
4363
+ const t = await n.select().from(A).where(
4366
4364
  g(
4367
- a(C.tenant_id, i),
4368
- a(C.id, e)
4365
+ a(A.tenant_id, i),
4366
+ a(A.id, e)
4369
4367
  )
4370
4368
  ).get();
4371
4369
  return t ? ct(t) : null;
@@ -4374,13 +4372,13 @@ function Ds(n) {
4374
4372
  const r = {
4375
4373
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4376
4374
  };
4377
- t.name !== void 0 && (r.name = t.name), t.identifier !== void 0 && (r.identifier = t.identifier), t.signing_alg !== void 0 && (r.signing_alg = t.signing_alg), t.signing_secret !== void 0 && (r.signing_secret = t.signing_secret), t.token_lifetime !== void 0 && (r.token_lifetime = t.token_lifetime), t.token_lifetime_for_web !== void 0 && (r.token_lifetime_for_web = t.token_lifetime_for_web), t.scopes !== void 0 && (r.scopes = JSON.stringify(t.scopes)), t.options !== void 0 && (r.options = w`json_patch(COALESCE(${C.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
4378
- for (const l of xt)
4375
+ 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 = N`json_patch(COALESCE(${A.options}, '{}'), ${JSON.stringify(t.options)})`), t.metadata !== void 0 && (r.metadata = JSON.stringify(t.metadata)), t.verificationKey !== void 0 && (r.verification_key = t.verificationKey);
4376
+ for (const l of bt)
4379
4377
  t[l] !== void 0 && (r[l] = t[l] ? 1 : 0);
4380
- return (await n.update(C).set(r).where(
4378
+ return (await n.update(A).set(r).where(
4381
4379
  g(
4382
- a(C.tenant_id, i),
4383
- a(C.id, e)
4380
+ a(A.tenant_id, i),
4381
+ a(A.id, e)
4384
4382
  )
4385
4383
  ).returning()).length > 0;
4386
4384
  },
@@ -4391,43 +4389,43 @@ function Ds(n) {
4391
4389
  include_totals: o = !1,
4392
4390
  sort: l,
4393
4391
  q: _
4394
- } = e || {}, u = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
4392
+ } = e || {}, d = Math.max(0, Math.floor(Number(t) || 0)), c = Math.min(
4395
4393
  Math.max(1, Math.floor(Number(r) || 50)),
4396
4394
  500
4397
- ), d = [a(C.tenant_id, i)];
4395
+ ), u = [a(A.tenant_id, i)];
4398
4396
  if (_) {
4399
4397
  const B = _.match(/^([^:]+):(.+)$/);
4400
4398
  if (B) {
4401
4399
  const [, W, H] = B, ke = W == null ? void 0 : W.startsWith("-"), qe = ke ? W == null ? void 0 : W.substring(1) : W;
4402
- if (qe && Qt.has(qe) && !ke) {
4403
- const yr = C[qe];
4404
- d.push(Ie(yr, `%${H}%`));
4400
+ if (qe && $t.has(qe) && !ke) {
4401
+ const mr = A[qe];
4402
+ u.push(Ie(mr, `%${H}%`));
4405
4403
  }
4406
4404
  }
4407
4405
  }
4408
- let h = n.select().from(C).where(g(...d)).$dynamic();
4409
- if (l != null && l.sort_by && Qt.has(l.sort_by)) {
4410
- const B = C[l.sort_by];
4411
- h = h.orderBy(
4406
+ let p = n.select().from(A).where(g(...u)).$dynamic();
4407
+ if (l != null && l.sort_by && $t.has(l.sort_by)) {
4408
+ const B = A[l.sort_by];
4409
+ p = p.orderBy(
4412
4410
  l.sort_order === "desc" ? V(B) : G(B)
4413
4411
  );
4414
4412
  }
4415
- const y = (await h.offset(u * c).limit(c)).map(ct);
4413
+ const y = (await p.offset(d * c).limit(c)).map(ct);
4416
4414
  if (!o)
4417
4415
  return { resource_servers: y };
4418
- const [N] = await n.select({ count: R() }).from(C).where(g(...d));
4416
+ const [w] = await n.select({ count: R() }).from(A).where(g(...u));
4419
4417
  return {
4420
4418
  resource_servers: y,
4421
- start: u * c,
4419
+ start: d * c,
4422
4420
  limit: c,
4423
- length: Number((N == null ? void 0 : N.count) ?? 0)
4421
+ length: Number((w == null ? void 0 : w.count) ?? 0)
4424
4422
  };
4425
4423
  },
4426
4424
  async remove(i, e) {
4427
- return (await n.delete(C).where(
4425
+ return (await n.delete(A).where(
4428
4426
  g(
4429
- a(C.tenant_id, i),
4430
- a(C.id, e)
4427
+ a(A.tenant_id, i),
4428
+ a(A.id, e)
4431
4429
  )
4432
4430
  ).returning()).length > 0;
4433
4431
  }
@@ -4462,16 +4460,16 @@ function Os(n) {
4462
4460
  ], l = /* @__PURE__ */ new Map();
4463
4461
  if (o.length > 0) {
4464
4462
  const _ = await n.select({
4465
- identifier: C.identifier,
4466
- name: C.name
4467
- }).from(C).where(
4463
+ identifier: A.identifier,
4464
+ name: A.name
4465
+ }).from(A).where(
4468
4466
  g(
4469
- a(C.tenant_id, i),
4470
- Ne(C.identifier, o)
4467
+ a(A.tenant_id, i),
4468
+ Ne(A.identifier, o)
4471
4469
  )
4472
4470
  ).all();
4473
- for (const u of _)
4474
- l.set(u.identifier, u.name);
4471
+ for (const d of _)
4472
+ l.set(d.identifier, d.name);
4475
4473
  }
4476
4474
  return r.map((_) => ({
4477
4475
  ..._,
@@ -4526,18 +4524,18 @@ function ks(n) {
4526
4524
  r && o.push(a(_e.organization_id, r));
4527
4525
  const l = await n.select().from(_e).where(g(...o)).all();
4528
4526
  return await Promise.all(
4529
- l.map(async (u) => {
4530
- const c = await n.select({ name: C.name }).from(C).where(
4527
+ l.map(async (d) => {
4528
+ const c = await n.select({ name: A.name }).from(A).where(
4531
4529
  g(
4532
- a(C.tenant_id, i),
4533
- a(C.identifier, u.resource_server_identifier)
4530
+ a(A.tenant_id, i),
4531
+ a(A.identifier, d.resource_server_identifier)
4534
4532
  )
4535
4533
  ).get();
4536
4534
  return {
4537
- resource_server_identifier: u.resource_server_identifier,
4538
- permission_name: u.permission_name,
4539
- resource_server_name: (c == null ? void 0 : c.name) || u.resource_server_identifier,
4540
- organization_id: u.organization_id === "" ? void 0 : u.organization_id
4535
+ resource_server_identifier: d.resource_server_identifier,
4536
+ permission_name: d.permission_name,
4537
+ resource_server_name: (c == null ? void 0 : c.name) || d.resource_server_identifier,
4538
+ organization_id: d.organization_id === "" ? void 0 : d.organization_id
4541
4539
  };
4542
4540
  })
4543
4541
  );
@@ -4563,7 +4561,7 @@ function gt(n) {
4563
4561
  return z({
4564
4562
  ...r,
4565
4563
  is_system: e ? !0 : void 0,
4566
- metadata: x(t)
4564
+ metadata: b(t)
4567
4565
  });
4568
4566
  }
4569
4567
  function Is(n) {
@@ -4579,17 +4577,17 @@ function Is(n) {
4579
4577
  created_at: t,
4580
4578
  updated_at: t
4581
4579
  };
4582
- return await n.insert(F).values(o), gt({ ...o, tenant_id: i });
4580
+ return await n.insert(U).values(o), gt({ ...o, tenant_id: i });
4583
4581
  },
4584
4582
  async get(i, e) {
4585
- const t = await n.select().from(F).where(g(a(F.tenant_id, i), a(F.id, e))).get();
4583
+ const t = await n.select().from(U).where(g(a(U.tenant_id, i), a(U.id, e))).get();
4586
4584
  return t ? gt(t) : null;
4587
4585
  },
4588
4586
  async update(i, e, t) {
4589
4587
  const r = {
4590
4588
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
4591
4589
  };
4592
- 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;
4590
+ 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;
4593
4591
  },
4594
4592
  async list(i, e) {
4595
4593
  const {
@@ -4598,18 +4596,18 @@ function Is(n) {
4598
4596
  include_totals: o = !1,
4599
4597
  sort: l,
4600
4598
  q: _
4601
- } = e || {}, u = _ ? me(F, _, ["name"]) : void 0, c = u ? g(a(F.tenant_id, i), u) : a(F.tenant_id, i);
4602
- let d = n.select().from(F).where(c).$dynamic();
4599
+ } = e || {}, d = _ ? ye(U, _, ["name"]) : void 0, c = d ? g(a(U.tenant_id, i), d) : a(U.tenant_id, i);
4600
+ let u = n.select().from(U).where(c).$dynamic();
4603
4601
  if (l != null && l.sort_by) {
4604
- const N = F[l.sort_by];
4605
- N && (d = d.orderBy(
4606
- l.sort_order === "desc" ? V(N) : G(N)
4602
+ const w = U[l.sort_by];
4603
+ w && (u = u.orderBy(
4604
+ l.sort_order === "desc" ? V(w) : G(w)
4607
4605
  ));
4608
4606
  }
4609
- const f = (await d.offset(t * r).limit(r)).map(gt);
4607
+ const f = (await u.offset(t * r).limit(r)).map(gt);
4610
4608
  if (!o)
4611
4609
  return { roles: f };
4612
- const [y] = await n.select({ count: R() }).from(F).where(c);
4610
+ const [y] = await n.select({ count: R() }).from(U).where(c);
4613
4611
  return {
4614
4612
  roles: f,
4615
4613
  start: t * r,
@@ -4618,7 +4616,7 @@ function Is(n) {
4618
4616
  };
4619
4617
  },
4620
4618
  async remove(i, e) {
4621
- return (await n.delete(F).where(g(a(F.tenant_id, i), a(F.id, e))).returning()).length > 0;
4619
+ return (await n.delete(U).where(g(a(U.tenant_id, i), a(U.id, e))).returning()).length > 0;
4622
4620
  }
4623
4621
  };
4624
4622
  }
@@ -4639,10 +4637,10 @@ function ft(n) {
4639
4637
  idle_expires_at_ts: o,
4640
4638
  authenticated_at_ts: l,
4641
4639
  last_interaction_at_ts: _,
4642
- used_at_ts: u,
4640
+ used_at_ts: d,
4643
4641
  revoked_at_ts: c,
4644
- device: d,
4645
- clients: h,
4642
+ device: u,
4643
+ clients: p,
4646
4644
  ...f
4647
4645
  } = n, y = Pe(
4648
4646
  {
@@ -4652,7 +4650,7 @@ function ft(n) {
4652
4650
  idle_expires_at_ts: o,
4653
4651
  authenticated_at_ts: l,
4654
4652
  last_interaction_at_ts: _,
4655
- used_at_ts: u,
4653
+ used_at_ts: d,
4656
4654
  revoked_at_ts: c
4657
4655
  },
4658
4656
  [...zs],
@@ -4661,8 +4659,8 @@ function ft(n) {
4661
4659
  return z({
4662
4660
  ...f,
4663
4661
  ...y,
4664
- device: x(d, {}),
4665
- clients: x(h, [])
4662
+ device: b(u, {}),
4663
+ clients: b(p, [])
4666
4664
  });
4667
4665
  }
4668
4666
  function qs(n) {
@@ -4677,26 +4675,26 @@ function qs(n) {
4677
4675
  clients: JSON.stringify(e.clients || []),
4678
4676
  created_at_ts: t,
4679
4677
  updated_at_ts: t,
4680
- expires_at_ts: j(e.expires_at),
4681
- idle_expires_at_ts: j(e.idle_expires_at),
4682
- authenticated_at_ts: e.authenticated_at ? j(e.authenticated_at) : t,
4683
- last_interaction_at_ts: e.last_interaction_at ? j(e.last_interaction_at) : t,
4684
- used_at_ts: j(e.used_at),
4685
- revoked_at_ts: j(e.revoked_at)
4678
+ expires_at_ts: $(e.expires_at),
4679
+ idle_expires_at_ts: $(e.idle_expires_at),
4680
+ authenticated_at_ts: e.authenticated_at ? $(e.authenticated_at) : t,
4681
+ last_interaction_at_ts: e.last_interaction_at ? $(e.last_interaction_at) : t,
4682
+ used_at_ts: $(e.used_at),
4683
+ revoked_at_ts: $(e.revoked_at)
4686
4684
  };
4687
- return await n.insert($).values(r), ft({ ...r, tenant_id: i });
4685
+ return await n.insert(Q).values(r), ft({ ...r, tenant_id: i });
4688
4686
  },
4689
4687
  async get(i, e) {
4690
- const t = await n.select().from($).where(g(a($.tenant_id, i), a($.id, e))).get();
4688
+ const t = await n.select().from(Q).where(g(a(Q.tenant_id, i), a(Q.id, e))).get();
4691
4689
  return t ? ft(t) : null;
4692
4690
  },
4693
4691
  async update(i, e, t) {
4694
4692
  const r = {
4695
4693
  updated_at_ts: Date.now()
4696
4694
  };
4697
- return t.user_id !== void 0 && (r.user_id = t.user_id), t.login_session_id !== void 0 && (r.login_session_id = t.login_session_id), t.device !== void 0 && (r.device = JSON.stringify(t.device)), t.clients !== void 0 && (r.clients = JSON.stringify(t.clients)), t.expires_at !== void 0 && (r.expires_at_ts = j(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = j(t.idle_expires_at)), t.authenticated_at !== void 0 && (r.authenticated_at_ts = j(t.authenticated_at)), t.last_interaction_at !== void 0 && (r.last_interaction_at_ts = j(
4695
+ 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 = $(t.expires_at)), t.idle_expires_at !== void 0 && (r.idle_expires_at_ts = $(t.idle_expires_at)), t.authenticated_at !== void 0 && (r.authenticated_at_ts = $(t.authenticated_at)), t.last_interaction_at !== void 0 && (r.last_interaction_at_ts = $(
4698
4696
  t.last_interaction_at
4699
- )), t.used_at !== void 0 && (r.used_at_ts = j(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = j(t.revoked_at)), (await n.update($).set(r).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
4697
+ )), t.used_at !== void 0 && (r.used_at_ts = $(t.used_at)), t.revoked_at !== void 0 && (r.revoked_at_ts = $(t.revoked_at)), (await n.update(Q).set(r).where(g(a(Q.tenant_id, i), a(Q.id, e))).returning()).length > 0;
4700
4698
  },
4701
4699
  async list(i, e) {
4702
4700
  const {
@@ -4705,18 +4703,18 @@ function qs(n) {
4705
4703
  include_totals: o = !1,
4706
4704
  sort: l,
4707
4705
  q: _
4708
- } = e || {}, u = _ ? me($, _, ["user_id"]) : void 0, c = u ? g(a($.tenant_id, i), u) : a($.tenant_id, i);
4709
- let d = n.select().from($).where(c).$dynamic();
4706
+ } = e || {}, d = _ ? ye(Q, _, ["user_id"]) : void 0, c = d ? g(a(Q.tenant_id, i), d) : a(Q.tenant_id, i);
4707
+ let u = n.select().from(Q).where(c).$dynamic();
4710
4708
  if (l != null && l.sort_by) {
4711
- const N = $[l.sort_by];
4712
- N && (d = d.orderBy(
4713
- l.sort_order === "desc" ? V(N) : G(N)
4709
+ const w = Q[l.sort_by];
4710
+ w && (u = u.orderBy(
4711
+ l.sort_order === "desc" ? V(w) : G(w)
4714
4712
  ));
4715
4713
  }
4716
- const f = (await d.offset(t * r).limit(r)).map(ft);
4714
+ const f = (await u.offset(t * r).limit(r)).map(ft);
4717
4715
  if (!o)
4718
4716
  return { sessions: f };
4719
- const [y] = await n.select({ count: R() }).from($).where(c);
4717
+ const [y] = await n.select({ count: R() }).from(Q).where(c);
4720
4718
  return {
4721
4719
  sessions: f,
4722
4720
  start: t * r,
@@ -4725,7 +4723,7 @@ function qs(n) {
4725
4723
  };
4726
4724
  },
4727
4725
  async remove(i, e) {
4728
- return (await n.delete($).where(g(a($.tenant_id, i), a($.id, e))).returning()).length > 0;
4726
+ return (await n.delete(Q).where(g(a(Q.tenant_id, i), a(Q.id, e))).returning()).length > 0;
4729
4727
  }
4730
4728
  };
4731
4729
  }
@@ -4745,30 +4743,30 @@ const hr = [
4745
4743
  "acr_values_supported",
4746
4744
  "mtls",
4747
4745
  "mfa"
4748
- ], mr = [
4746
+ ], pr = [
4749
4747
  "allow_organization_name_in_authentication_api",
4750
4748
  "customize_mfa_in_postlogin_action",
4751
4749
  "pushed_authorization_requests_supported",
4752
4750
  "authorization_response_iss_parameter_supported"
4753
4751
  ];
4754
- function Jt(n) {
4752
+ function Qt(n) {
4755
4753
  const i = { ...n };
4756
4754
  for (const e of hr)
4757
- typeof i[e] == "string" && (i[e] = x(i[e]));
4758
- for (const e of mr)
4755
+ typeof i[e] == "string" && (i[e] = b(i[e]));
4756
+ for (const e of pr)
4759
4757
  i[e] !== void 0 && i[e] !== null && (i[e] = i[e] === 1);
4760
4758
  return z(i);
4761
4759
  }
4762
- function Pt(n) {
4760
+ function Jt(n) {
4763
4761
  const i = { ...n };
4764
- Pr(
4762
+ Jr(
4765
4763
  n,
4766
4764
  hr,
4767
4765
  i
4768
4766
  );
4769
- for (const e of mr)
4767
+ for (const e of pr)
4770
4768
  n[e] !== void 0 && (i[e] = n[e] ? 1 : 0);
4771
- return gr(i);
4769
+ return cr(i);
4772
4770
  }
4773
4771
  function Ls(n) {
4774
4772
  return {
@@ -4779,11 +4777,11 @@ function Ls(n) {
4779
4777
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
4780
4778
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
4781
4779
  ...i
4782
- }, t = Pt(e);
4780
+ }, t = Jt(e);
4783
4781
  try {
4784
4782
  await n.insert(D).values(t);
4785
4783
  } catch (l) {
4786
- throw (r = l == null ? void 0 : l.message) != null && r.includes("UNIQUE constraint failed") || (o = l == null ? void 0 : l.message) != null && o.includes("duplicate key") || (l == null ? void 0 : l.code) === "SQLITE_CONSTRAINT" ? new be(409, {
4784
+ throw (r = l == null ? void 0 : l.message) != null && r.includes("UNIQUE constraint failed") || (o = l == null ? void 0 : l.message) != null && o.includes("duplicate key") || (l == null ? void 0 : l.code) === "SQLITE_CONSTRAINT" ? new xe(409, {
4787
4785
  message: `Tenant with ID '${e.id}' already exists`
4788
4786
  }) : l;
4789
4787
  }
@@ -4791,7 +4789,7 @@ function Ls(n) {
4791
4789
  },
4792
4790
  async get(i) {
4793
4791
  const e = await n.select().from(D).where(a(D.id, i)).get();
4794
- return e ? Jt(e) : null;
4792
+ return e ? Qt(e) : null;
4795
4793
  },
4796
4794
  async list(i) {
4797
4795
  const {
@@ -4803,28 +4801,28 @@ function Ls(n) {
4803
4801
  } = i || {};
4804
4802
  let _ = n.select().from(D).$dynamic();
4805
4803
  if (l) {
4806
- const h = me(D, l, ["friendly_name"]);
4807
- h && (_ = _.where(h));
4804
+ const p = ye(D, l, ["friendly_name"]);
4805
+ p && (_ = _.where(p));
4808
4806
  }
4809
4807
  if (o != null && o.sort_by) {
4810
- const h = D[o.sort_by];
4811
- h && (_ = _.orderBy(
4812
- o.sort_order === "desc" ? V(h) : G(h)
4808
+ const p = D[o.sort_by];
4809
+ p && (_ = _.orderBy(
4810
+ o.sort_order === "desc" ? V(p) : G(p)
4813
4811
  ));
4814
4812
  }
4815
- const c = (await _.offset(e * t).limit(t)).map(Jt);
4813
+ const c = (await _.offset(e * t).limit(t)).map(Qt);
4816
4814
  if (!r)
4817
4815
  return { tenants: c };
4818
- const [d] = await n.select({ count: R() }).from(D);
4816
+ const [u] = await n.select({ count: R() }).from(D);
4819
4817
  return {
4820
4818
  tenants: c,
4821
4819
  start: e * t,
4822
4820
  limit: t,
4823
- length: Number((d == null ? void 0 : d.count) ?? 0)
4821
+ length: Number((u == null ? void 0 : u.count) ?? 0)
4824
4822
  };
4825
4823
  },
4826
4824
  async update(i, e) {
4827
- const t = Pt({
4825
+ const t = Jt({
4828
4826
  ...e,
4829
4827
  id: i,
4830
4828
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -4843,11 +4841,11 @@ const Es = [
4843
4841
  "page_background",
4844
4842
  "widget"
4845
4843
  ];
4846
- function Ft(n) {
4847
- const { tenant_id: i, ...e } = n, t = fr(e, Es);
4844
+ function Pt(n) {
4845
+ const { tenant_id: i, ...e } = n, t = gr(e, Es);
4848
4846
  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);
4849
4847
  }
4850
- function Cs(n) {
4848
+ function As(n) {
4851
4849
  return {
4852
4850
  async create(i, e, t) {
4853
4851
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = t || ae(), _ = {
@@ -4857,13 +4855,13 @@ function Cs(n) {
4857
4855
  created_at: r,
4858
4856
  updated_at: r
4859
4857
  };
4860
- return await n.insert(fe).values(_), Ft({ ..._, tenant_id: i });
4858
+ return await n.insert(fe).values(_), Pt({ ..._, tenant_id: i });
4861
4859
  },
4862
4860
  async get(i, e) {
4863
4861
  const t = await n.select().from(fe).where(
4864
4862
  g(a(fe.tenant_id, i), a(fe.themeId, e))
4865
4863
  ).get();
4866
- return t ? Ft(t) : null;
4864
+ return t ? Pt(t) : null;
4867
4865
  },
4868
4866
  async update(i, e, t) {
4869
4867
  const r = yt(t);
@@ -4878,7 +4876,7 @@ function Cs(n) {
4878
4876
  }
4879
4877
  };
4880
4878
  }
4881
- function As(n) {
4879
+ function Cs(n) {
4882
4880
  return {
4883
4881
  async get(i) {
4884
4882
  const e = await n.select({ body: ve.body }).from(ve).where(a(ve.tenant_id, i)).get();
@@ -4904,7 +4902,7 @@ function As(n) {
4904
4902
  }
4905
4903
  };
4906
4904
  }
4907
- function Ut(n, i) {
4905
+ function Ft(n, i) {
4908
4906
  const e = {
4909
4907
  connection: n.connection,
4910
4908
  provider: n.provider,
@@ -4914,10 +4912,10 @@ function Ut(n, i) {
4914
4912
  return i ? e.isPrimary = !0 : e.profileData = {
4915
4913
  email: n.email,
4916
4914
  email_verified: !!n.email_verified,
4917
- ...typeof n.profileData == "string" ? x(n.profileData, {}) : {}
4915
+ ...typeof n.profileData == "string" ? b(n.profileData, {}) : {}
4918
4916
  }, e;
4919
4917
  }
4920
- function pt(n, i = []) {
4918
+ function ht(n, i = []) {
4921
4919
  const {
4922
4920
  tenant_id: e,
4923
4921
  app_metadata: t,
@@ -4925,26 +4923,26 @@ function pt(n, i = []) {
4925
4923
  address: o,
4926
4924
  email_verified: l,
4927
4925
  phone_verified: _,
4928
- is_social: u,
4926
+ is_social: d,
4929
4927
  linked_to: c,
4930
- profileData: d,
4931
- ...h
4932
- } = n, f = Ut(n, !0), y = i.map((N) => Ut(N, !1));
4928
+ profileData: u,
4929
+ ...p
4930
+ } = n, f = Ft(n, !0), y = i.map((w) => Ft(w, !1));
4933
4931
  return z({
4934
- ...h,
4932
+ ...p,
4935
4933
  email: n.email || "",
4936
4934
  email_verified: !!l,
4937
4935
  phone_verified: _ != null ? !!_ : void 0,
4938
- is_social: !!u,
4939
- app_metadata: x(t, {}),
4940
- user_metadata: x(r, {}),
4941
- address: x(o),
4936
+ is_social: !!d,
4937
+ app_metadata: b(t, {}),
4938
+ user_metadata: b(r, {}),
4939
+ address: b(o),
4942
4940
  identities: [f, ...y]
4943
4941
  });
4944
4942
  }
4945
4943
  function Bs(n) {
4946
4944
  const i = async (e, t) => {
4947
- var _, u;
4945
+ var _, d;
4948
4946
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = {
4949
4947
  user_id: t.user_id,
4950
4948
  tenant_id: e,
@@ -4983,9 +4981,9 @@ function Bs(n) {
4983
4981
  }, l = t.password ? ae() : void 0;
4984
4982
  try {
4985
4983
  if (t.password && l) {
4986
- await n.run(w`BEGIN`);
4984
+ await n.run(N`BEGIN`);
4987
4985
  try {
4988
- await n.insert(k).values(o), await n.insert(A).values({
4986
+ await n.insert(k).values(o), await n.insert(C).values({
4989
4987
  id: l,
4990
4988
  tenant_id: e,
4991
4989
  user_id: t.user_id,
@@ -4994,18 +4992,18 @@ function Bs(n) {
4994
4992
  is_current: 1,
4995
4993
  created_at: r,
4996
4994
  updated_at: r
4997
- }), await n.run(w`COMMIT`);
4995
+ }), await n.run(N`COMMIT`);
4998
4996
  } catch (c) {
4999
- throw await n.run(w`ROLLBACK`), c;
4997
+ throw await n.run(N`ROLLBACK`), c;
5000
4998
  }
5001
4999
  } else
5002
5000
  await n.insert(k).values(o);
5003
5001
  } catch (c) {
5004
- throw (_ = c == null ? void 0 : c.message) != null && _.includes("UNIQUE constraint") || (u = c == null ? void 0 : c.message) != null && u.includes("AlreadyExists") ? new be(409, { message: "User already exists" }) : (console.error("User upsert failed:", c == null ? void 0 : c.code, c == null ? void 0 : c.message), new be(500, {
5002
+ throw (_ = c == null ? void 0 : c.message) != null && _.includes("UNIQUE constraint") || (d = c == null ? void 0 : c.message) != null && d.includes("AlreadyExists") ? new xe(409, { message: "User already exists" }) : (console.error("User upsert failed:", c == null ? void 0 : c.code, c == null ? void 0 : c.message), new xe(500, {
5005
5003
  message: "Internal server error"
5006
5004
  }));
5007
5005
  }
5008
- return pt(o);
5006
+ return ht(o);
5009
5007
  };
5010
5008
  return {
5011
5009
  create: i,
@@ -5016,7 +5014,7 @@ function Bs(n) {
5016
5014
  const o = await n.select().from(k).where(
5017
5015
  g(a(k.tenant_id, e), a(k.linked_to, t))
5018
5016
  ).all();
5019
- return pt(r, o);
5017
+ return ht(r, o);
5020
5018
  },
5021
5019
  async update(e, t, r) {
5022
5020
  const o = {
@@ -5046,8 +5044,8 @@ function Bs(n) {
5046
5044
  "birthdate",
5047
5045
  "zoneinfo"
5048
5046
  ];
5049
- for (const u of l)
5050
- r[u] !== void 0 && (o[u] = r[u]);
5047
+ for (const d of l)
5048
+ r[d] !== void 0 && (o[d] = r[d]);
5051
5049
  return r.email_verified !== void 0 && (o.email_verified = r.email_verified), r.phone_verified !== void 0 && (o.phone_verified = r.phone_verified), r.is_social !== void 0 && (o.is_social = r.is_social), r.app_metadata !== void 0 && (o.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata !== void 0 && (o.user_metadata = JSON.stringify(r.user_metadata)), r.address !== void 0 && (o.address = JSON.stringify(r.address)), r.profileData !== void 0 && (o.profileData = JSON.stringify(r.profileData)), (await n.update(k).set(o).where(g(a(k.tenant_id, e), a(k.user_id, t))).returning()).length > 0;
5052
5050
  },
5053
5051
  async list(e, t) {
@@ -5056,13 +5054,13 @@ function Bs(n) {
5056
5054
  per_page: o = 50,
5057
5055
  include_totals: l = !1,
5058
5056
  sort: _,
5059
- q: u
5057
+ q: d
5060
5058
  } = t || {}, c = [
5061
5059
  a(k.tenant_id, e),
5062
- ye(k.linked_to)
5060
+ me(k.linked_to)
5063
5061
  ];
5064
- if (u) {
5065
- const H = me(k, u, [
5062
+ if (d) {
5063
+ const H = ye(k, d, [
5066
5064
  "email",
5067
5065
  "name",
5068
5066
  "nickname",
@@ -5070,29 +5068,29 @@ function Bs(n) {
5070
5068
  ]);
5071
5069
  H && c.push(H);
5072
5070
  }
5073
- const d = g(...c);
5074
- let h = n.select().from(k).where(d).$dynamic();
5071
+ const u = g(...c);
5072
+ let p = n.select().from(k).where(u).$dynamic();
5075
5073
  if (_ != null && _.sort_by) {
5076
5074
  const H = k[_.sort_by];
5077
- H && (h = h.orderBy(
5075
+ H && (p = p.orderBy(
5078
5076
  _.sort_order === "desc" ? V(H) : G(H)
5079
5077
  ));
5080
5078
  }
5081
- const f = await h.offset(r * o).limit(o), y = f.map((H) => H.user_id);
5082
- let N = [];
5083
- y.length > 0 && (N = await n.select().from(k).where(
5079
+ const f = await p.offset(r * o).limit(o), y = f.map((H) => H.user_id);
5080
+ let w = [];
5081
+ y.length > 0 && (w = await n.select().from(k).where(
5084
5082
  g(
5085
5083
  a(k.tenant_id, e),
5086
5084
  Ne(k.linked_to, y)
5087
5085
  )
5088
5086
  ));
5089
5087
  const B = f.map((H) => {
5090
- const ke = N.filter((qe) => qe.linked_to === H.user_id);
5091
- return pt(H, ke);
5088
+ const ke = w.filter((qe) => qe.linked_to === H.user_id);
5089
+ return ht(H, ke);
5092
5090
  });
5093
5091
  if (!l)
5094
5092
  return { users: B };
5095
- const [W] = await n.select({ count: R() }).from(k).where(d);
5093
+ const [W] = await n.select({ count: R() }).from(k).where(u);
5096
5094
  return {
5097
5095
  users: B,
5098
5096
  start: r * o,
@@ -5101,20 +5099,20 @@ function Bs(n) {
5101
5099
  };
5102
5100
  },
5103
5101
  async remove(e, t) {
5104
- await n.run(w`BEGIN`);
5102
+ await n.run(N`BEGIN`);
5105
5103
  try {
5106
5104
  const r = await n.select({ user_id: k.user_id }).from(k).where(
5107
5105
  g(a(k.tenant_id, e), a(k.linked_to, t))
5108
5106
  ), o = [t, ...r.map((_) => _.user_id)];
5109
- await n.delete(U).where(
5107
+ await n.delete(K).where(
5110
5108
  g(
5111
- a(U.tenant_id, e),
5112
- Ne(U.user_id, o)
5109
+ a(K.tenant_id, e),
5110
+ Ne(K.user_id, o)
5113
5111
  )
5114
- ), await n.delete(A).where(
5112
+ ), await n.delete(C).where(
5115
5113
  g(
5116
- a(A.tenant_id, e),
5117
- Ne(A.user_id, o)
5114
+ a(C.tenant_id, e),
5115
+ Ne(C.user_id, o)
5118
5116
  )
5119
5117
  ), await n.delete(k).where(
5120
5118
  g(a(k.tenant_id, e), a(k.linked_to, t))
@@ -5122,9 +5120,9 @@ function Bs(n) {
5122
5120
  const l = await n.delete(k).where(
5123
5121
  g(a(k.tenant_id, e), a(k.user_id, t))
5124
5122
  ).returning();
5125
- return await n.run(w`COMMIT`), l.length > 0;
5123
+ return await n.run(N`COMMIT`), l.length > 0;
5126
5124
  } catch (r) {
5127
- throw await n.run(w`ROLLBACK`), r;
5125
+ throw await n.run(N`ROLLBACK`), r;
5128
5126
  }
5129
5127
  },
5130
5128
  async unlink(e, t, r, o) {
@@ -5168,16 +5166,16 @@ function $s(n) {
5168
5166
  role_id: ue.role_id
5169
5167
  }).from(ue).where(g(...o)).all();
5170
5168
  return l.length === 0 ? [] : (await Promise.all(
5171
- l.map(async (u) => {
5172
- const c = await n.select().from(F).where(
5173
- g(a(F.tenant_id, i), a(F.id, u.role_id))
5169
+ l.map(async (d) => {
5170
+ const c = await n.select().from(U).where(
5171
+ g(a(U.tenant_id, i), a(U.id, d.role_id))
5174
5172
  ).get();
5175
5173
  if (!c) return null;
5176
- const { tenant_id: d, is_system: h, metadata: f, ...y } = c;
5174
+ const { tenant_id: u, is_system: p, metadata: f, ...y } = c;
5177
5175
  return z({
5178
5176
  ...y,
5179
- is_system: h ? !0 : void 0,
5180
- metadata: x(f)
5177
+ is_system: p ? !0 : void 0,
5178
+ metadata: b(f)
5181
5179
  });
5182
5180
  })
5183
5181
  )).filter(Boolean);
@@ -5197,7 +5195,7 @@ function $s(n) {
5197
5195
  function Qs(n) {
5198
5196
  return {
5199
5197
  async create(i, e) {
5200
- var u, c;
5198
+ var d, c;
5201
5199
  const t = (/* @__PURE__ */ new Date()).toISOString(), o = {
5202
5200
  id: e.id || ae(),
5203
5201
  tenant_id: i,
@@ -5207,20 +5205,20 @@ function Qs(n) {
5207
5205
  updated_at: t
5208
5206
  };
5209
5207
  try {
5210
- await n.insert(J).values(o);
5211
- } catch (d) {
5212
- throw (u = d == null ? void 0 : d.message) != null && u.includes("UNIQUE constraint") || (c = d == null ? void 0 : d.message) != null && c.includes("duplicate key") ? new be(409, {
5208
+ await n.insert(P).values(o);
5209
+ } catch (u) {
5210
+ throw (d = u == null ? void 0 : u.message) != null && d.includes("UNIQUE constraint") || (c = u == null ? void 0 : u.message) != null && c.includes("duplicate key") ? new xe(409, {
5213
5211
  message: "User organization already exists"
5214
- }) : d;
5212
+ }) : u;
5215
5213
  }
5216
5214
  const { tenant_id: l, ..._ } = o;
5217
5215
  return _;
5218
5216
  },
5219
5217
  async get(i, e) {
5220
- const t = await n.select().from(J).where(
5218
+ const t = await n.select().from(P).where(
5221
5219
  g(
5222
- a(J.tenant_id, i),
5223
- a(J.id, e)
5220
+ a(P.tenant_id, i),
5221
+ a(P.id, e)
5224
5222
  )
5225
5223
  ).get();
5226
5224
  if (!t) return null;
@@ -5231,10 +5229,10 @@ function Qs(n) {
5231
5229
  const r = {
5232
5230
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
5233
5231
  };
5234
- return t.user_id !== void 0 && (r.user_id = t.user_id), t.organization_id !== void 0 && (r.organization_id = t.organization_id), (await n.update(J).set(r).where(
5232
+ 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(
5235
5233
  g(
5236
- a(J.tenant_id, i),
5237
- a(J.id, e)
5234
+ a(P.tenant_id, i),
5235
+ a(P.id, e)
5238
5236
  )
5239
5237
  ).returning()).length > 0;
5240
5238
  },
@@ -5244,47 +5242,47 @@ function Qs(n) {
5244
5242
  per_page: r = 50,
5245
5243
  include_totals: o = !1,
5246
5244
  q: l
5247
- } = e || {}, _ = a(J.tenant_id, i);
5248
- let u = _;
5245
+ } = e || {}, _ = a(P.tenant_id, i);
5246
+ let d = _;
5249
5247
  if (l) {
5250
- const f = me(J, l, [
5248
+ const f = ye(P, l, [
5251
5249
  "user_id",
5252
5250
  "organization_id"
5253
5251
  ]);
5254
- f && (u = g(_, f));
5252
+ f && (d = g(_, f));
5255
5253
  }
5256
- const d = (await n.select().from(J).where(u).offset(t * r).limit(r)).map((f) => {
5257
- const { tenant_id: y, ...N } = f;
5258
- return N;
5254
+ const u = (await n.select().from(P).where(d).offset(t * r).limit(r)).map((f) => {
5255
+ const { tenant_id: y, ...w } = f;
5256
+ return w;
5259
5257
  });
5260
5258
  if (!o)
5261
- return { userOrganizations: d };
5262
- const [h] = await n.select({ count: R() }).from(J).where(u);
5259
+ return { userOrganizations: u };
5260
+ const [p] = await n.select({ count: R() }).from(P).where(d);
5263
5261
  return {
5264
- userOrganizations: d,
5262
+ userOrganizations: u,
5265
5263
  start: t * r,
5266
5264
  limit: r,
5267
- length: Number((h == null ? void 0 : h.count) ?? 0)
5265
+ length: Number((p == null ? void 0 : p.count) ?? 0)
5268
5266
  };
5269
5267
  },
5270
5268
  async listUserOrganizations(i, e, t) {
5271
- const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(J).where(
5269
+ const { page: r = 0, per_page: o = 50, include_totals: l = !1 } = t || {}, _ = await n.select().from(P).where(
5272
5270
  g(
5273
- a(J.tenant_id, i),
5274
- a(J.user_id, e)
5271
+ a(P.tenant_id, i),
5272
+ a(P.user_id, e)
5275
5273
  )
5276
5274
  ).offset(r * o).limit(o).all(), c = (await Promise.all(
5277
- _.map(async (h) => {
5278
- const f = await n.select().from(E).where(
5275
+ _.map(async (p) => {
5276
+ const f = await n.select().from(L).where(
5279
5277
  g(
5280
- a(E.tenant_id, i),
5281
- a(E.id, h.organization_id)
5278
+ a(L.tenant_id, i),
5279
+ a(L.id, p.organization_id)
5282
5280
  )
5283
5281
  ).get();
5284
5282
  if (!f) return null;
5285
5283
  const {
5286
5284
  tenant_id: y,
5287
- branding: N,
5285
+ branding: w,
5288
5286
  metadata: B,
5289
5287
  enabled_connections: W,
5290
5288
  token_quota: H,
@@ -5292,63 +5290,63 @@ function Qs(n) {
5292
5290
  } = f;
5293
5291
  return z({
5294
5292
  ...ke,
5295
- branding: x(N, {}),
5296
- metadata: x(B, {}),
5297
- enabled_connections: x(W, []),
5298
- token_quota: x(H, {})
5293
+ branding: b(w, {}),
5294
+ metadata: b(B, {}),
5295
+ enabled_connections: b(W, []),
5296
+ token_quota: b(H, {})
5299
5297
  });
5300
5298
  })
5301
5299
  )).filter(Boolean);
5302
5300
  if (!l)
5303
5301
  return { organizations: c };
5304
- const [d] = await n.select({ count: R() }).from(J).where(
5302
+ const [u] = await n.select({ count: R() }).from(P).where(
5305
5303
  g(
5306
- a(J.tenant_id, i),
5307
- a(J.user_id, e)
5304
+ a(P.tenant_id, i),
5305
+ a(P.user_id, e)
5308
5306
  )
5309
5307
  );
5310
5308
  return {
5311
5309
  organizations: c,
5312
5310
  start: r * o,
5313
5311
  limit: o,
5314
- length: Number((d == null ? void 0 : d.count) ?? 0)
5312
+ length: Number((u == null ? void 0 : u.count) ?? 0)
5315
5313
  };
5316
5314
  },
5317
5315
  async remove(i, e) {
5318
- return (await n.delete(J).where(
5316
+ return (await n.delete(P).where(
5319
5317
  g(
5320
- a(J.tenant_id, i),
5321
- a(J.id, e)
5318
+ a(P.tenant_id, i),
5319
+ a(P.id, e)
5322
5320
  )
5323
5321
  ).returning()).length > 0;
5324
5322
  }
5325
5323
  };
5326
5324
  }
5327
- const Kt = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Js = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
5325
+ const Ut = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], Js = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
5328
5326
  function Ps(n) {
5329
5327
  return {
5330
5328
  async getDaily(i, e) {
5331
5329
  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];
5332
5330
  return (await n.select({
5333
- date: w`substr(${q.date}, 1, 10)`.as("date"),
5334
- logins: w`SUM(CASE WHEN ${q.type} IN (${w.join(
5335
- Kt.map((_) => w`${_}`),
5336
- w`, `
5331
+ date: N`substr(${T.date}, 1, 10)`.as("date"),
5332
+ logins: N`SUM(CASE WHEN ${T.type} IN (${N.join(
5333
+ Ut.map((_) => N`${_}`),
5334
+ N`, `
5337
5335
  )}) THEN 1 ELSE 0 END)`.as("logins"),
5338
- signups: w`SUM(CASE WHEN ${q.type} = 'ss' THEN 1 ELSE 0 END)`.as(
5336
+ signups: N`SUM(CASE WHEN ${T.type} = 'ss' THEN 1 ELSE 0 END)`.as(
5339
5337
  "signups"
5340
5338
  ),
5341
- leaked_passwords: w`SUM(CASE WHEN ${q.type} IN (${w.join(
5342
- Js.map((_) => w`${_}`),
5343
- w`, `
5339
+ leaked_passwords: N`SUM(CASE WHEN ${T.type} IN (${N.join(
5340
+ Js.map((_) => N`${_}`),
5341
+ N`, `
5344
5342
  )}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
5345
- }).from(q).where(
5343
+ }).from(T).where(
5346
5344
  g(
5347
- a(q.tenant_id, i),
5348
- He(q.date, r),
5349
- Oe(q.date, `${o}T23:59:59.999Z`)
5345
+ a(T.tenant_id, i),
5346
+ He(T.date, r),
5347
+ Oe(T.date, `${o}T23:59:59.999Z`)
5350
5348
  )
5351
- ).groupBy(w`substr(${q.date}, 1, 10)`).orderBy(w`substr(${q.date}, 1, 10)`).all()).map((_) => ({
5349
+ ).groupBy(N`substr(${T.date}, 1, 10)`).orderBy(N`substr(${T.date}, 1, 10)`).all()).map((_) => ({
5352
5350
  date: _.date,
5353
5351
  logins: Number(_.logins) || 0,
5354
5352
  signups: Number(_.signups) || 0,
@@ -5361,14 +5359,14 @@ function Ps(n) {
5361
5359
  const e = new Date(
5362
5360
  Date.now() - 2592e6
5363
5361
  ).toISOString(), [t] = await n.select({
5364
- count: w`COUNT(DISTINCT ${q.user_id})`.as("count")
5365
- }).from(q).where(
5362
+ count: N`COUNT(DISTINCT ${T.user_id})`.as("count")
5363
+ }).from(T).where(
5366
5364
  g(
5367
- a(q.tenant_id, i),
5368
- He(q.date, e),
5369
- w`${q.type} IN (${w.join(
5370
- Kt.map((r) => w`${r}`),
5371
- w`, `
5365
+ a(T.tenant_id, i),
5366
+ He(T.date, e),
5367
+ N`${T.type} IN (${N.join(
5368
+ Ut.map((r) => N`${r}`),
5369
+ N`, `
5372
5370
  )})`
5373
5371
  )
5374
5372
  );
@@ -5376,17 +5374,17 @@ function Ps(n) {
5376
5374
  }
5377
5375
  };
5378
5376
  }
5379
- function jt(n) {
5377
+ function Kt(n) {
5380
5378
  return {
5381
5379
  ...n,
5382
- payload: x(n.payload, {})
5380
+ payload: b(n.payload, {})
5383
5381
  };
5384
5382
  }
5385
5383
  function Fs(n) {
5386
5384
  return {
5387
5385
  async create(i, e) {
5388
5386
  const t = ae(), r = (/* @__PURE__ */ new Date()).toISOString();
5389
- return await n.insert(b).values({
5387
+ return await n.insert(x).values({
5390
5388
  id: t,
5391
5389
  tenant_id: i,
5392
5390
  event_type: e.event_type,
@@ -5404,82 +5402,82 @@ function Fs(n) {
5404
5402
  }), t;
5405
5403
  },
5406
5404
  async getByIds(i) {
5407
- return i.length === 0 ? [] : (await n.select().from(b).where(Ne(b.id, i)).all()).map(jt);
5405
+ return i.length === 0 ? [] : (await n.select().from(x).where(Ne(x.id, i)).all()).map(Kt);
5408
5406
  },
5409
5407
  async getUnprocessed(i) {
5410
5408
  const e = (/* @__PURE__ */ new Date()).toISOString();
5411
- return (await n.select().from(b).where(
5409
+ return (await n.select().from(x).where(
5412
5410
  g(
5413
- ye(b.processed_at),
5411
+ me(x.processed_at),
5414
5412
  de(
5415
- ye(b.next_retry_at),
5416
- Oe(b.next_retry_at, e)
5413
+ me(x.next_retry_at),
5414
+ Oe(x.next_retry_at, e)
5417
5415
  ),
5418
5416
  de(
5419
- ye(b.claimed_by),
5420
- Oe(b.claim_expires_at, e)
5417
+ me(x.claimed_by),
5418
+ Oe(x.claim_expires_at, e)
5421
5419
  )
5422
5420
  )
5423
- ).orderBy(b.created_at, b.id).limit(i).all()).map(jt);
5421
+ ).orderBy(x.created_at, x.id).limit(i).all()).map(Kt);
5424
5422
  },
5425
5423
  async claimEvents(i, e, t) {
5426
5424
  if (i.length === 0) return [];
5427
5425
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = new Date(Date.now() + t).toISOString();
5428
- return await n.update(b).set({
5426
+ return await n.update(x).set({
5429
5427
  claimed_by: e,
5430
5428
  claim_expires_at: o
5431
5429
  }).where(
5432
5430
  g(
5433
- Ne(b.id, i),
5434
- ye(b.processed_at),
5431
+ Ne(x.id, i),
5432
+ me(x.processed_at),
5435
5433
  de(
5436
- ye(b.claimed_by),
5437
- Oe(b.claim_expires_at, r)
5434
+ me(x.claimed_by),
5435
+ Oe(x.claim_expires_at, r)
5438
5436
  )
5439
5437
  )
5440
- ), (await n.select({ id: b.id }).from(b).where(
5438
+ ), (await n.select({ id: x.id }).from(x).where(
5441
5439
  g(
5442
- Ne(b.id, i),
5443
- a(b.claimed_by, e)
5440
+ Ne(x.id, i),
5441
+ a(x.claimed_by, e)
5444
5442
  )
5445
5443
  ).all()).map((_) => _.id);
5446
5444
  },
5447
5445
  async markProcessed(i) {
5448
- i.length !== 0 && await n.update(b).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(Ne(b.id, i));
5446
+ i.length !== 0 && await n.update(x).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(Ne(x.id, i));
5449
5447
  },
5450
5448
  async markRetry(i, e, t) {
5451
- await n.update(b).set({
5449
+ await n.update(x).set({
5452
5450
  error: e,
5453
5451
  next_retry_at: t,
5454
- retry_count: w`${b.retry_count} + 1`,
5452
+ retry_count: N`${x.retry_count} + 1`,
5455
5453
  claimed_by: null,
5456
5454
  claim_expires_at: null
5457
- }).where(a(b.id, i));
5455
+ }).where(a(x.id, i));
5458
5456
  },
5459
5457
  async cleanup(i) {
5460
- return (await n.delete(b).where(
5458
+ return (await n.delete(x).where(
5461
5459
  g(
5462
- w`${b.processed_at} IS NOT NULL`,
5463
- Oe(b.processed_at, i)
5460
+ N`${x.processed_at} IS NOT NULL`,
5461
+ Oe(x.processed_at, i)
5464
5462
  )
5465
5463
  ).returning()).length;
5466
5464
  },
5467
5465
  async deadLetter(i, e) {
5468
5466
  const t = (/* @__PURE__ */ new Date()).toISOString();
5469
- await n.update(b).set({
5467
+ await n.update(x).set({
5470
5468
  processed_at: t,
5471
5469
  dead_lettered_at: t,
5472
5470
  final_error: e
5473
- }).where(a(b.id, i));
5471
+ }).where(a(x.id, i));
5474
5472
  },
5475
5473
  async listFailed(i, e = {}) {
5476
- const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(b).where(
5474
+ const { page: t = 0, per_page: r = 50, include_totals: o = !1 } = e, _ = (await n.select().from(x).where(
5477
5475
  g(
5478
- a(b.tenant_id, i),
5479
- Me(b.dead_lettered_at)
5476
+ a(x.tenant_id, i),
5477
+ Me(x.dead_lettered_at)
5480
5478
  )
5481
- ).orderBy(V(b.dead_lettered_at), G(b.id)).offset(t * r).limit(r).all()).map((c) => ({
5482
- ...x(c.payload, {}),
5479
+ ).orderBy(V(x.dead_lettered_at), G(x.id)).offset(t * r).limit(r).all()).map((c) => ({
5480
+ ...b(c.payload, {}),
5483
5481
  id: c.id,
5484
5482
  created_at: c.created_at,
5485
5483
  processed_at: c.processed_at,
@@ -5489,25 +5487,25 @@ function Fs(n) {
5489
5487
  dead_lettered_at: c.dead_lettered_at,
5490
5488
  final_error: c.final_error
5491
5489
  }));
5492
- let u = _.length;
5490
+ let d = _.length;
5493
5491
  if (o) {
5494
- const [c] = await n.select({ total: R() }).from(b).where(
5492
+ const [c] = await n.select({ total: R() }).from(x).where(
5495
5493
  g(
5496
- a(b.tenant_id, i),
5497
- Me(b.dead_lettered_at)
5494
+ a(x.tenant_id, i),
5495
+ Me(x.dead_lettered_at)
5498
5496
  )
5499
5497
  );
5500
- u = Number((c == null ? void 0 : c.total) ?? _.length);
5498
+ d = Number((c == null ? void 0 : c.total) ?? _.length);
5501
5499
  }
5502
5500
  return {
5503
5501
  events: _,
5504
5502
  start: t * r,
5505
5503
  limit: r,
5506
- length: u
5504
+ length: d
5507
5505
  };
5508
5506
  },
5509
5507
  async replay(i, e) {
5510
- return (await n.update(b).set({
5508
+ return (await n.update(x).set({
5511
5509
  processed_at: null,
5512
5510
  dead_lettered_at: null,
5513
5511
  final_error: null,
@@ -5516,9 +5514,9 @@ function Fs(n) {
5516
5514
  error: null
5517
5515
  }).where(
5518
5516
  g(
5519
- a(b.id, i),
5520
- a(b.tenant_id, e),
5521
- Me(b.dead_lettered_at)
5517
+ a(x.id, i),
5518
+ a(x.tenant_id, e),
5519
+ Me(x.dead_lettered_at)
5522
5520
  )
5523
5521
  ).returning()).length > 0;
5524
5522
  }
@@ -5531,16 +5529,16 @@ function Ks(n) {
5531
5529
  try {
5532
5530
  let t = [
5533
5531
  de(
5534
- we(T.expires_at_ts, e),
5535
- we(T.idle_expires_at_ts, e)
5532
+ we(E.expires_at_ts, e),
5533
+ we(E.idle_expires_at_ts, e)
5536
5534
  )
5537
5535
  ];
5538
- i != null && i.tenant_id && t.push(a(T.tenant_id, i.tenant_id)), await n.delete(T).where(g(...t)), t = [
5536
+ i != null && i.tenant_id && t.push(a(E.tenant_id, i.tenant_id)), await n.delete(E).where(g(...t)), t = [
5539
5537
  de(
5540
- we($.expires_at_ts, e),
5541
- we($.idle_expires_at_ts, e)
5538
+ we(Q.expires_at_ts, e),
5539
+ we(Q.idle_expires_at_ts, e)
5542
5540
  )
5543
- ], i != null && i.tenant_id && t.push(a($.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a($.user_id, i.user_id)), await n.delete($).where(g(...t)), t = [we(L.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(L.tenant_id, i.tenant_id)), await n.delete(L).where(g(...t));
5541
+ ], i != null && i.tenant_id && t.push(a(Q.tenant_id, i.tenant_id)), i != null && i.user_id && t.push(a(Q.user_id, i.user_id)), await n.delete(Q).where(g(...t)), t = [we(q.expires_at_ts, e)], i != null && i.tenant_id && t.push(a(q.tenant_id, i.tenant_id)), await n.delete(q).where(g(...t));
5544
5542
  } catch (t) {
5545
5543
  console.error("Session cleanup error:", t);
5546
5544
  }
@@ -5548,29 +5546,29 @@ function Ks(n) {
5548
5546
  }
5549
5547
  function Vs(n, i = { useTransactions: !0 }) {
5550
5548
  const e = {
5551
- actions: Ir(),
5552
- branding: Kr(n),
5553
- clients: jr(n),
5554
- clientConnections: Vr(n),
5555
- clientGrants: Yr(n),
5556
- codes: Xr(n),
5557
- connections: es(n),
5558
- customDomains: ts(n),
5559
- customText: ns(n),
5560
- emailProviders: is(n),
5561
- flows: rs(n),
5562
- forms: ss(n),
5563
- hookCode: ls(n),
5564
- hooks: us(n),
5565
- invites: cs(n),
5566
- keys: gs(n),
5567
- loginSessions: ps(n),
5549
+ actions: kr(),
5550
+ branding: Ur(n),
5551
+ clients: Kr(n),
5552
+ clientConnections: Mr(n),
5553
+ clientGrants: Gr(n),
5554
+ codes: Yr(n),
5555
+ connections: Zr(n),
5556
+ customDomains: es(n),
5557
+ customText: ts(n),
5558
+ emailProviders: ns(n),
5559
+ flows: is(n),
5560
+ forms: rs(n),
5561
+ hookCode: as(n),
5562
+ hooks: _s(n),
5563
+ invites: ds(n),
5564
+ keys: cs(n),
5565
+ loginSessions: fs(n),
5568
5566
  logs: hs(n),
5569
- authenticationMethods: ys(n),
5570
- organizations: Ns(n),
5571
- passwords: vs(n),
5572
- promptSettings: Ss(n),
5573
- refreshTokens: xs(n),
5567
+ authenticationMethods: ms(n),
5568
+ organizations: ws(n),
5569
+ passwords: Ns(n),
5570
+ promptSettings: vs(n),
5571
+ refreshTokens: bs(n),
5574
5572
  resourceServers: Ds(n),
5575
5573
  rolePermissions: Os(n),
5576
5574
  userPermissions: ks(n),
@@ -5578,8 +5576,8 @@ function Vs(n, i = { useTransactions: !0 }) {
5578
5576
  sessions: qs(n),
5579
5577
  sessionCleanup: Ks(n),
5580
5578
  tenants: Ls(n),
5581
- themes: Cs(n),
5582
- universalLoginTemplates: As(n),
5579
+ themes: As(n),
5580
+ universalLoginTemplates: Cs(n),
5583
5581
  users: Bs(n),
5584
5582
  userRoles: $s(n),
5585
5583
  userOrganizations: Qs(n),
@@ -5588,12 +5586,12 @@ function Vs(n, i = { useTransactions: !0 }) {
5588
5586
  async transaction(t) {
5589
5587
  if (i.useTransactions === !1)
5590
5588
  return t(e);
5591
- await n.run(w`BEGIN`);
5589
+ await n.run(N`BEGIN`);
5592
5590
  try {
5593
5591
  const r = await t(e);
5594
- return await n.run(w`COMMIT`), r;
5592
+ return await n.run(N`COMMIT`), r;
5595
5593
  } catch (r) {
5596
- throw await n.run(w`ROLLBACK`), r;
5594
+ throw await n.run(N`ROLLBACK`), r;
5597
5595
  }
5598
5596
  }
5599
5597
  };