@authhero/drizzle 0.43.3 → 0.43.5

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.
@@ -230,8 +230,8 @@ function Pr(n) {
230
230
  e.sql += i.sql, e.params.push(...i.params), (t = i.typings) != null && t.length && (e.typings || (e.typings = []), e.typings.push(...i.typings));
231
231
  return e;
232
232
  }
233
- var Gi;
234
- Gi = L;
233
+ var Ji;
234
+ Ji = L;
235
235
  class ve {
236
236
  constructor(e) {
237
237
  y(this, "value");
@@ -241,9 +241,9 @@ class ve {
241
241
  return new de([this]);
242
242
  }
243
243
  }
244
- y(ve, Gi, "StringChunk");
245
- var Ji;
246
- Ji = L;
244
+ y(ve, Ji, "StringChunk");
245
+ var Gi;
246
+ Gi = L;
247
247
  const pt = class pt {
248
248
  constructor(e) {
249
249
  /** @internal */
@@ -385,7 +385,7 @@ const pt = class pt {
385
385
  return e ? this : void 0;
386
386
  }
387
387
  };
388
- y(pt, Ji, "SQL");
388
+ y(pt, Gi, "SQL");
389
389
  let de = pt;
390
390
  var Wi;
391
391
  Wi = L;
@@ -532,7 +532,7 @@ fe.prototype.getSQL = function() {
532
532
  ui.prototype.getSQL = function() {
533
533
  return new de([this]);
534
534
  };
535
- function Gt(n, e) {
535
+ function Jt(n, e) {
536
536
  return {
537
537
  name: typeof n == "string" && n.length > 0 ? n : "",
538
538
  config: typeof n == "object" ? n : e
@@ -770,7 +770,7 @@ class Ro extends (wa = Fe, va = L, wa) {
770
770
  }
771
771
  y(Ro, va, "SQLiteBlobBuffer");
772
772
  function Vr(n, e) {
773
- const { name: t, config: i } = Gt(n, e);
773
+ const { name: t, config: i } = Jt(n, e);
774
774
  return (i == null ? void 0 : i.mode) === "json" ? new Co(t) : (i == null ? void 0 : i.mode) === "bigint" ? new Ao(t) : new Lo(t);
775
775
  }
776
776
  var Na, Sa;
@@ -809,7 +809,7 @@ class zo extends (Ea = Fe, ba = L, Ea) {
809
809
  y(zo, ba, "SQLiteCustomColumn");
810
810
  function Zr(n) {
811
811
  return (e, t) => {
812
- const { name: i, config: a } = Gt(e, t);
812
+ const { name: i, config: a } = Jt(e, t);
813
813
  return new Uo(
814
814
  i,
815
815
  a,
@@ -919,7 +919,7 @@ class $o extends (qa = hn, Ma = L, qa) {
919
919
  }
920
920
  y($o, Ma, "SQLiteBoolean");
921
921
  function w(n, e) {
922
- const { name: t, config: i } = Gt(n, e);
922
+ const { name: t, config: i } = Jt(n, e);
923
923
  return (i == null ? void 0 : i.mode) === "timestamp" || (i == null ? void 0 : i.mode) === "timestamp_ms" ? new Mo(t, i.mode) : (i == null ? void 0 : i.mode) === "boolean" ? new Bo(t, i.mode) : new Fo(t);
924
924
  }
925
925
  var Ba, $a;
@@ -974,8 +974,8 @@ class Ho extends (Qa = Fe, Ka = L, Qa) {
974
974
  }
975
975
  }
976
976
  y(Ho, Ka, "SQLiteNumericNumber");
977
- var Ga, Ja;
978
- class Ko extends (Ja = ze, Ga = L, Ja) {
977
+ var Ja, Ga;
978
+ class Ko extends (Ga = ze, Ja = L, Ga) {
979
979
  constructor(e) {
980
980
  super(e, "bigint", "SQLiteNumericBigInt");
981
981
  }
@@ -987,7 +987,7 @@ class Ko extends (Ja = ze, Ga = L, Ja) {
987
987
  );
988
988
  }
989
989
  }
990
- y(Ko, Ga, "SQLiteNumericBigIntBuilder");
990
+ y(Ko, Ja, "SQLiteNumericBigIntBuilder");
991
991
  var Wa, Xa;
992
992
  class Qo extends (Xa = Fe, Wa = L, Xa) {
993
993
  constructor() {
@@ -1001,29 +1001,29 @@ class Qo extends (Xa = Fe, Wa = L, Xa) {
1001
1001
  }
1002
1002
  y(Qo, Wa, "SQLiteNumericBigInt");
1003
1003
  function Hr(n, e) {
1004
- const { name: t, config: i } = Gt(n, e), a = i == null ? void 0 : i.mode;
1004
+ const { name: t, config: i } = Jt(n, e), a = i == null ? void 0 : i.mode;
1005
1005
  return a === "number" ? new Zo(t) : a === "bigint" ? new Ko(t) : new jo(t);
1006
1006
  }
1007
1007
  var Ya, eo;
1008
- class Go extends (eo = ze, Ya = L, eo) {
1008
+ class Jo extends (eo = ze, Ya = L, eo) {
1009
1009
  constructor(e) {
1010
1010
  super(e, "number", "SQLiteReal");
1011
1011
  }
1012
1012
  /** @internal */
1013
1013
  build(e) {
1014
- return new Jo(e, this.config);
1014
+ return new Go(e, this.config);
1015
1015
  }
1016
1016
  }
1017
- y(Go, Ya, "SQLiteRealBuilder");
1017
+ y(Jo, Ya, "SQLiteRealBuilder");
1018
1018
  var to, no;
1019
- class Jo extends (no = Fe, to = L, no) {
1019
+ class Go extends (no = Fe, to = L, no) {
1020
1020
  getSQLType() {
1021
1021
  return "real";
1022
1022
  }
1023
1023
  }
1024
- y(Jo, to, "SQLiteReal");
1024
+ y(Go, to, "SQLiteReal");
1025
1025
  function Kr(n) {
1026
- return new Go(n ?? "");
1026
+ return new Jo(n ?? "");
1027
1027
  }
1028
1028
  var io, ao;
1029
1029
  class Wo extends (ao = ze, io = L, ao) {
@@ -1079,7 +1079,7 @@ class er extends (_o = Fe, co = L, _o) {
1079
1079
  }
1080
1080
  y(er, co, "SQLiteTextJson");
1081
1081
  function s(n, e = {}) {
1082
- const { name: t, config: i } = Gt(n, e);
1082
+ const { name: t, config: i } = Jt(n, e);
1083
1083
  return i.mode === "json" ? new Yo(t) : new Wo(t, i);
1084
1084
  }
1085
1085
  function Qr() {
@@ -1092,9 +1092,9 @@ function Qr() {
1092
1092
  text: s
1093
1093
  };
1094
1094
  }
1095
- const Gn = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1095
+ const Jn = Symbol.for("drizzle:SQLiteInlineForeignKeys");
1096
1096
  var uo, po, fo, ho, go;
1097
- class Rt extends (go = fe, ho = L, fo = fe.Symbol.Columns, po = Gn, uo = fe.Symbol.ExtraConfigBuilder, go) {
1097
+ class Rt extends (go = fe, ho = L, fo = fe.Symbol.Columns, po = Jn, uo = fe.Symbol.ExtraConfigBuilder, go) {
1098
1098
  constructor() {
1099
1099
  super(...arguments);
1100
1100
  /** @internal */
@@ -1107,20 +1107,20 @@ class Rt extends (go = fe, ho = L, fo = fe.Symbol.Columns, po = Gn, uo = fe.Symb
1107
1107
  }
1108
1108
  y(Rt, ho, "SQLiteTable"), /** @internal */
1109
1109
  y(Rt, "Symbol", Object.assign({}, fe.Symbol, {
1110
- InlineForeignKeys: Gn
1110
+ InlineForeignKeys: Jn
1111
1111
  }));
1112
- function Gr(n, e, t, i, a = n) {
1112
+ function Jr(n, e, t, i, a = n) {
1113
1113
  const r = new Rt(n, i, a), l = typeof e == "function" ? e(Qr()) : e, d = Object.fromEntries(
1114
1114
  Object.entries(l).map(([f, p]) => {
1115
1115
  const v = p;
1116
1116
  v.setName(f);
1117
1117
  const m = v.build(r);
1118
- return r[Gn].push(...v.buildForeignKeys(m, r)), [f, m];
1118
+ return r[Jn].push(...v.buildForeignKeys(m, r)), [f, m];
1119
1119
  })
1120
1120
  ), u = Object.assign(r, d);
1121
1121
  return u[fe.Symbol.Columns] = d, u[fe.Symbol.ExtraConfigColumns] = d, t && (u[Rt.Symbol.ExtraConfigBuilder] = t), u;
1122
1122
  }
1123
- const $ = (n, e, t) => Gr(n, e, t);
1123
+ const $ = (n, e, t) => Jr(n, e, t);
1124
1124
  var mo;
1125
1125
  mo = L;
1126
1126
  class fi {
@@ -1173,11 +1173,11 @@ function ht(n) {
1173
1173
  return new fi(n, !0);
1174
1174
  }
1175
1175
  function Te(...n) {
1176
- return n[0].columns ? new Jn(n[0].columns, n[0].name) : new Jn(n);
1176
+ return n[0].columns ? new Gn(n[0].columns, n[0].name) : new Gn(n);
1177
1177
  }
1178
1178
  var wo;
1179
1179
  wo = L;
1180
- class Jn {
1180
+ class Gn {
1181
1181
  constructor(e, t) {
1182
1182
  /** @internal */
1183
1183
  y(this, "columns");
@@ -1190,7 +1190,7 @@ class Jn {
1190
1190
  return new ir(e, this.columns, this.name);
1191
1191
  }
1192
1192
  }
1193
- y(Jn, wo, "SQLitePrimaryKeyBuilder");
1193
+ y(Gn, wo, "SQLitePrimaryKeyBuilder");
1194
1194
  var No;
1195
1195
  No = L;
1196
1196
  class ir {
@@ -1391,7 +1391,7 @@ const B = $("tenants", {
1391
1391
  D("idx_refresh_tokens_login_id").on(n.login_id),
1392
1392
  D("idx_refresh_tokens_expires_at_ts").on(n.expires_at_ts)
1393
1393
  ]
1394
- ), J = $(
1394
+ ), G = $(
1395
1395
  "login_sessions",
1396
1396
  {
1397
1397
  id: s("id", { length: 21 }).notNull(),
@@ -1460,7 +1460,7 @@ const B = $("tenants", {
1460
1460
  }),
1461
1461
  D("codes_expires_at_index").on(n.expires_at)
1462
1462
  ]
1463
- ), Jr = $("authentication_codes", {
1463
+ ), Gr = $("authentication_codes", {
1464
1464
  tenant_id: s("tenant_id", { length: 191 }).notNull().references(() => B.id, { onDelete: "cascade" }),
1465
1465
  code: s("code", { length: 255 }).primaryKey(),
1466
1466
  client_id: s("client_id", { length: 255 }).notNull(),
@@ -1590,7 +1590,7 @@ const B = $("tenants", {
1590
1590
  }),
1591
1591
  D("idx_clients_owner_user_id").on(n.tenant_id, n.owner_user_id)
1592
1592
  ]
1593
- ), G = $(
1593
+ ), J = $(
1594
1594
  "client_registration_tokens",
1595
1595
  {
1596
1596
  id: s("id", { length: 255 }).primaryKey(),
@@ -1894,7 +1894,7 @@ const B = $("tenants", {
1894
1894
  }),
1895
1895
  colors_page_background_end: s("colors_page_background_end", { length: 8 }),
1896
1896
  colors_page_background_angle_dev: w("colors_page_background_angle_dev")
1897
- }), nt = $(
1897
+ }), it = $(
1898
1898
  "universal_login_templates",
1899
1899
  {
1900
1900
  tenant_id: s("tenant_id", { length: 191 }).primaryKey().references(() => B.id, { onDelete: "cascade" }),
@@ -2068,7 +2068,7 @@ const B = $("tenants", {
2068
2068
  webauthn_platform_first_factor: w("webauthn_platform_first_factor", {
2069
2069
  mode: "boolean"
2070
2070
  }).notNull().default(!1)
2071
- }), it = $("email_providers", {
2071
+ }), at = $("email_providers", {
2072
2072
  tenant_id: s("tenant_id", { length: 191 }).primaryKey(),
2073
2073
  name: s("name", { length: 255 }).notNull(),
2074
2074
  enabled: w("enabled", { mode: "boolean" }).notNull(),
@@ -2094,8 +2094,10 @@ const B = $("tenants", {
2094
2094
  // only required for form type hooks
2095
2095
  template_id: s("template_id", { length: 64 }),
2096
2096
  // only required for template type hooks
2097
- code_id: s("code_id", { length: 21 })
2097
+ code_id: s("code_id", { length: 21 }),
2098
2098
  // only required for code type hooks
2099
+ metadata: s("metadata")
2100
+ // JSON property bag (inheritable flag, template options)
2099
2101
  },
2100
2102
  (n) => [D("hooks_tenant_id_idx").on(n.tenant_id)]
2101
2103
  ), qe = $(
@@ -2243,27 +2245,27 @@ const B = $("tenants", {
2243
2245
  n.dead_lettered_at
2244
2246
  )
2245
2247
  ]
2246
- ), f_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2248
+ ), h_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2247
2249
  __proto__: null,
2248
- authenticationCodes: Jr,
2250
+ authenticationCodes: Gr,
2249
2251
  authenticationMethods: ue,
2250
2252
  branding: At,
2251
2253
  clientGrants: me,
2252
- clientRegistrationTokens: G,
2254
+ clientRegistrationTokens: J,
2253
2255
  clients: Z,
2254
2256
  codes: re,
2255
2257
  connections: pe,
2256
2258
  customDomains: Oe,
2257
2259
  customText: Ne,
2258
2260
  domains: Yr,
2259
- emailProviders: it,
2261
+ emailProviders: at,
2260
2262
  flows: xe,
2261
2263
  forms: Ee,
2262
2264
  hookCode: qe,
2263
2265
  hooks: we,
2264
2266
  invites: be,
2265
2267
  keys: Be,
2266
- loginSessions: J,
2268
+ loginSessions: G,
2267
2269
  logs: Q,
2268
2270
  organizations: W,
2269
2271
  otps: Wr,
@@ -2278,7 +2280,7 @@ const B = $("tenants", {
2278
2280
  tenants: B,
2279
2281
  themes: Me,
2280
2282
  tickets: Xr,
2281
- universalLoginTemplates: nt,
2283
+ universalLoginTemplates: it,
2282
2284
  userOrganizations: se,
2283
2285
  userPermissions: Le,
2284
2286
  userRoles: Re,
@@ -2931,10 +2933,10 @@ function fs(n) {
2931
2933
  var l, d, u, f, p, v;
2932
2934
  const m = typeof a == "string" ? r : a, S = m ?? {}, { param: T } = S, ee = us(S, ["param"]), ie = Object.assign(Object.assign({}, (l = this._def.openapi) === null || l === void 0 ? void 0 : l._internal), typeof a == "string" ? { refId: a } : void 0), ae = Object.assign(Object.assign(Object.assign({}, (d = this._def.openapi) === null || d === void 0 ? void 0 : d.metadata), ee), !((f = (u = this._def.openapi) === null || u === void 0 ? void 0 : u.metadata) === null || f === void 0) && f.param || T ? {
2933
2935
  param: Object.assign(Object.assign({}, (v = (p = this._def.openapi) === null || p === void 0 ? void 0 : p.metadata) === null || v === void 0 ? void 0 : v.param), T)
2934
- } : void 0), Ge = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(ie).length > 0 ? { _internal: ie } : void 0), Object.keys(ae).length > 0 ? { metadata: ae } : void 0) }));
2936
+ } : void 0), Je = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(ie).length > 0 ? { _internal: ie } : void 0), Object.keys(ae).length > 0 ? { metadata: ae } : void 0) }));
2935
2937
  if (ps(this, "ZodObject")) {
2936
2938
  const ut = this.extend;
2937
- Ge.extend = function(...vn) {
2939
+ Je.extend = function(...vn) {
2938
2940
  var wn, Nn, Sn, bn, En, xn, kn;
2939
2941
  const On = ut.apply(this, vn);
2940
2942
  return On._def.openapi = {
@@ -2945,7 +2947,7 @@ function fs(n) {
2945
2947
  }, On;
2946
2948
  };
2947
2949
  }
2948
- return Ge;
2950
+ return Je;
2949
2951
  }, Tt(n, "optional"), Tt(n, "nullable"), Tt(n, "default"), Tt(n, "transform"), Tt(n, "refine");
2950
2952
  const e = n.ZodObject.prototype.deepPartial;
2951
2953
  n.ZodObject.prototype.deepPartial = function() {
@@ -3446,7 +3448,7 @@ class q {
3446
3448
  return this._refinement((i, a) => e(i) ? !0 : (a.addIssue(typeof t == "function" ? t(i, a) : t), !1));
3447
3449
  }
3448
3450
  _refinement(e) {
3449
- return new tt({
3451
+ return new nt({
3450
3452
  schema: this,
3451
3453
  typeName: U.ZodEffects,
3452
3454
  effect: { type: "refinement", refinement: e }
@@ -3484,7 +3486,7 @@ class q {
3484
3486
  return Mt.create(this, e, this._def);
3485
3487
  }
3486
3488
  transform(e) {
3487
- return new tt({
3489
+ return new nt({
3488
3490
  ...M(this._def),
3489
3491
  schema: this,
3490
3492
  typeName: U.ZodEffects,
@@ -4435,7 +4437,7 @@ un.create = (n) => new un({
4435
4437
  typeName: U.ZodUnknown,
4436
4438
  ...M(n)
4437
4439
  });
4438
- class et extends q {
4440
+ class tt extends q {
4439
4441
  _parse(e) {
4440
4442
  const t = this._getOrReturnCtx(e);
4441
4443
  return E(t, {
@@ -4445,7 +4447,7 @@ class et extends q {
4445
4447
  }), R;
4446
4448
  }
4447
4449
  }
4448
- et.create = (n) => new et({
4450
+ tt.create = (n) => new tt({
4449
4451
  typeName: U.ZodNever,
4450
4452
  ...M(n)
4451
4453
  });
@@ -4575,7 +4577,7 @@ class le extends q {
4575
4577
  }), R;
4576
4578
  }
4577
4579
  const { status: i, ctx: a } = this._processInputParams(e), { shape: r, keys: l } = this._getCached(), d = [];
4578
- if (!(this._def.catchall instanceof et && this._def.unknownKeys === "strip"))
4580
+ if (!(this._def.catchall instanceof tt && this._def.unknownKeys === "strip"))
4579
4581
  for (const f in a.data)
4580
4582
  l.includes(f) || d.push(f);
4581
4583
  const u = [];
@@ -4587,7 +4589,7 @@ class le extends q {
4587
4589
  alwaysSet: f in a.data
4588
4590
  });
4589
4591
  }
4590
- if (this._def.catchall instanceof et) {
4592
+ if (this._def.catchall instanceof tt) {
4591
4593
  const f = this._def.unknownKeys;
4592
4594
  if (f === "passthrough")
4593
4595
  for (const p of d)
@@ -4825,21 +4827,21 @@ class le extends q {
4825
4827
  le.create = (n, e) => new le({
4826
4828
  shape: () => n,
4827
4829
  unknownKeys: "strip",
4828
- catchall: et.create(),
4830
+ catchall: tt.create(),
4829
4831
  typeName: U.ZodObject,
4830
4832
  ...M(e)
4831
4833
  });
4832
4834
  le.strictCreate = (n, e) => new le({
4833
4835
  shape: () => n,
4834
4836
  unknownKeys: "strict",
4835
- catchall: et.create(),
4837
+ catchall: tt.create(),
4836
4838
  typeName: U.ZodObject,
4837
4839
  ...M(e)
4838
4840
  });
4839
4841
  le.lazycreate = (n, e) => new le({
4840
4842
  shape: n,
4841
4843
  unknownKeys: "strip",
4842
- catchall: et.create(),
4844
+ catchall: tt.create(),
4843
4845
  typeName: U.ZodObject,
4844
4846
  ...M(e)
4845
4847
  });
@@ -4916,7 +4918,7 @@ Pt.create = (n, e) => new Pt({
4916
4918
  typeName: U.ZodUnion,
4917
4919
  ...M(e)
4918
4920
  });
4919
- const Je = (n) => n instanceof pn ? Je(n.schema) : n instanceof tt ? Je(n.innerType()) : n instanceof Bt ? [n.value] : n instanceof lt ? n.options : n instanceof $t ? H.objectValues(n.enum) : n instanceof Vt ? Je(n._def.innerType) : n instanceof cn ? [void 0] : n instanceof _n ? [null] : n instanceof He ? [void 0, ...Je(n.unwrap())] : n instanceof dt ? [null, ...Je(n.unwrap())] : n instanceof yi || n instanceof Ht ? Je(n.unwrap()) : n instanceof Zt ? Je(n._def.innerType) : [];
4921
+ const Ge = (n) => n instanceof pn ? Ge(n.schema) : n instanceof nt ? Ge(n.innerType()) : n instanceof Bt ? [n.value] : n instanceof lt ? n.options : n instanceof $t ? H.objectValues(n.enum) : n instanceof Vt ? Ge(n._def.innerType) : n instanceof cn ? [void 0] : n instanceof _n ? [null] : n instanceof He ? [void 0, ...Ge(n.unwrap())] : n instanceof dt ? [null, ...Ge(n.unwrap())] : n instanceof yi || n instanceof Ht ? Ge(n.unwrap()) : n instanceof Zt ? Ge(n._def.innerType) : [];
4920
4922
  class gn extends q {
4921
4923
  _parse(e) {
4922
4924
  const { ctx: t } = this._processInputParams(e);
@@ -4961,7 +4963,7 @@ class gn extends q {
4961
4963
  static create(e, t, i) {
4962
4964
  const a = /* @__PURE__ */ new Map();
4963
4965
  for (const r of t) {
4964
- const l = Je(r.shape[e]);
4966
+ const l = Ge(r.shape[e]);
4965
4967
  if (!l.length)
4966
4968
  throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
4967
4969
  for (const d of l) {
@@ -5397,7 +5399,7 @@ jt.create = (n, e) => new jt({
5397
5399
  typeName: U.ZodPromise,
5398
5400
  ...M(e)
5399
5401
  });
5400
- class tt extends q {
5402
+ class nt extends q {
5401
5403
  innerType() {
5402
5404
  return this._def.schema;
5403
5405
  }
@@ -5477,13 +5479,13 @@ class tt extends q {
5477
5479
  H.assertNever(a);
5478
5480
  }
5479
5481
  }
5480
- tt.create = (n, e, t) => new tt({
5482
+ nt.create = (n, e, t) => new nt({
5481
5483
  schema: n,
5482
5484
  typeName: U.ZodEffects,
5483
5485
  effect: e,
5484
5486
  ...M(t)
5485
5487
  });
5486
- tt.createWithPreprocess = (n, e, t) => new tt({
5488
+ nt.createWithPreprocess = (n, e, t) => new nt({
5487
5489
  schema: e,
5488
5490
  effect: { type: "preprocess", transform: n },
5489
5491
  typeName: U.ZodEffects,
@@ -5669,8 +5671,8 @@ var U;
5669
5671
  (function(n) {
5670
5672
  n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
5671
5673
  })(U || (U = {}));
5672
- const o = Ze.create, I = yt.create, h = dn.create, j = Ft.create, at = un.create;
5673
- et.create;
5674
+ const o = Ze.create, I = yt.create, h = dn.create, j = Ft.create, et = un.create;
5675
+ tt.create;
5674
5676
  const b = $e.create, _ = le.create, Pe = Pt.create, kt = gn.create;
5675
5677
  Mt.create;
5676
5678
  st.create;
@@ -5694,7 +5696,7 @@ const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5694
5696
  ZodDate: zt,
5695
5697
  ZodDefault: Vt,
5696
5698
  ZodDiscriminatedUnion: gn,
5697
- ZodEffects: tt,
5699
+ ZodEffects: nt,
5698
5700
  ZodEnum: lt,
5699
5701
  ZodError: Ke,
5700
5702
  get ZodFirstPartyTypeKind() {
@@ -5707,7 +5709,7 @@ const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5707
5709
  ZodMap: ai,
5708
5710
  ZodNaN: oi,
5709
5711
  ZodNativeEnum: $t,
5710
- ZodNever: et,
5712
+ ZodNever: tt,
5711
5713
  ZodNull: _n,
5712
5714
  ZodNullable: dt,
5713
5715
  ZodNumber: yt,
@@ -5722,7 +5724,7 @@ const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5722
5724
  ZodSet: xt,
5723
5725
  ZodString: Ze,
5724
5726
  ZodSymbol: ti,
5725
- ZodTransformer: tt,
5727
+ ZodTransformer: nt,
5726
5728
  ZodTuple: st,
5727
5729
  ZodType: q,
5728
5730
  ZodUndefined: cn,
@@ -5755,7 +5757,7 @@ const Fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5755
5757
  record: P,
5756
5758
  string: o,
5757
5759
  union: Pe,
5758
- unknown: at,
5760
+ unknown: et,
5759
5761
  get util() {
5760
5762
  return H;
5761
5763
  }
@@ -5815,20 +5817,20 @@ const Bs = x([
5815
5817
  }), js = _({
5816
5818
  type: o(),
5817
5819
  id: o(),
5818
- before: P(at()).optional(),
5819
- after: P(at()).optional(),
5820
- diff: P(_({ old: at(), new: at() })).optional()
5820
+ before: P(et()).optional(),
5821
+ after: P(et()).optional(),
5822
+ diff: P(_({ old: et(), new: et() })).optional()
5821
5823
  }), Vs = _({
5822
5824
  method: o(),
5823
5825
  path: o(),
5824
5826
  query: P(o()).optional(),
5825
- body: at().optional(),
5827
+ body: et().optional(),
5826
5828
  ip: o(),
5827
5829
  user_agent: o().optional(),
5828
5830
  correlation_id: o().optional()
5829
5831
  }), Zs = _({
5830
5832
  status_code: I(),
5831
- body: at().optional()
5833
+ body: et().optional()
5832
5834
  }), Hs = _({
5833
5835
  country_code: o(),
5834
5836
  city_name: o(),
@@ -5873,14 +5875,14 @@ x([
5873
5875
  "SEND_EMAIL"
5874
5876
  ]);
5875
5877
  x(["VERIFY_EMAIL"]);
5876
- const Gs = _({
5878
+ const Js = _({
5877
5879
  require_mx_record: h().optional(),
5878
5880
  block_aliases: h().optional(),
5879
5881
  block_free_emails: h().optional(),
5880
5882
  block_disposable_emails: h().optional(),
5881
5883
  blocklist: b(o()).optional(),
5882
5884
  allowlist: b(o()).optional()
5883
- }), Js = _({
5885
+ }), Gs = _({
5884
5886
  id: o(),
5885
5887
  alias: o().max(100).optional(),
5886
5888
  type: O("AUTH0"),
@@ -5901,7 +5903,7 @@ const Gs = _({
5901
5903
  mask_output: h().optional(),
5902
5904
  params: _({
5903
5905
  email: o(),
5904
- rules: Gs.optional()
5906
+ rules: Js.optional()
5905
5907
  })
5906
5908
  }), Xs = x(["change-email", "account", "custom"]), Ys = _({
5907
5909
  id: o(),
@@ -5919,7 +5921,7 @@ const Gs = _({
5919
5921
  })
5920
5922
  })
5921
5923
  }), el = Pe([
5922
- Js,
5924
+ Gs,
5923
5925
  Ws,
5924
5926
  Ys
5925
5927
  ]), tl = _({
@@ -6310,7 +6312,7 @@ const fr = x(["iat", "rat"]), ul = _({
6310
6312
  type: fr,
6311
6313
  client_id: o().optional(),
6312
6314
  sub: o().optional(),
6313
- constraints: P(at()).optional(),
6315
+ constraints: P(et()).optional(),
6314
6316
  single_use: h().default(!1),
6315
6317
  expires_at: o().optional()
6316
6318
  });
@@ -6899,7 +6901,7 @@ const vi = _({
6899
6901
  multiple: h().optional(),
6900
6902
  default_value: Pe([o(), b(o())]).optional()
6901
6903
  }).optional()
6902
- }), Gl = Se.extend({
6904
+ }), Jl = Se.extend({
6903
6905
  type: O("CUSTOM"),
6904
6906
  config: _({
6905
6907
  component: o().optional(),
@@ -6907,7 +6909,7 @@ const vi = _({
6907
6909
  schema: P(j()).optional(),
6908
6910
  code: o().optional()
6909
6911
  })
6910
- }), Jl = Se.extend({
6912
+ }), Gl = Se.extend({
6911
6913
  type: O("DATE"),
6912
6914
  config: _({
6913
6915
  format: o().optional(),
@@ -7033,8 +7035,8 @@ const vi = _({
7033
7035
  Kl,
7034
7036
  Ql,
7035
7037
  sd,
7036
- Gl,
7037
7038
  Jl,
7039
+ Gl,
7038
7040
  Wl,
7039
7041
  Xl,
7040
7042
  Yl,
@@ -7200,7 +7202,19 @@ const Nr = x([
7200
7202
  enabled: h().default(!1),
7201
7203
  synchronous: h().default(!1),
7202
7204
  priority: I().optional(),
7203
- hook_id: o().optional()
7205
+ hook_id: o().optional(),
7206
+ /**
7207
+ * Free-form key/value bag for hook properties. Two well-known keys:
7208
+ *
7209
+ * - `inheritable: true` — when set on a hook on the control-plane tenant,
7210
+ * the multi-tenancy sync surfaces this hook to sub-tenants (Phase 2).
7211
+ * - Template-specific options. Templates read their config here, e.g.
7212
+ * `account-linking` reads `copy_user_metadata: true` to merge secondary
7213
+ * user_metadata into the primary on link.
7214
+ *
7215
+ * Everything else is opaque to the runtime. Persisted as JSON.
7216
+ */
7217
+ metadata: P(et()).optional()
7204
7218
  }, vd = _({
7205
7219
  ..._t,
7206
7220
  trigger_id: Nr,
@@ -7321,8 +7335,10 @@ _({
7321
7335
  jwks_uri: o(),
7322
7336
  registration_endpoint: o().optional(),
7323
7337
  revocation_endpoint: o(),
7338
+ end_session_endpoint: o().optional(),
7324
7339
  scopes_supported: b(o()),
7325
7340
  response_types_supported: b(o()),
7341
+ grant_types_supported: b(o()).optional(),
7326
7342
  code_challenge_methods_supported: b(o()),
7327
7343
  response_modes_supported: b(o()),
7328
7344
  subject_types_supported: b(o()),
@@ -7952,7 +7968,7 @@ _({
7952
7968
  ]),
7953
7969
  settings: _({}).optional()
7954
7970
  });
7955
- const Gd = _({
7971
+ const Jd = _({
7956
7972
  // The actual refresh token value (primary key).
7957
7973
  id: o(),
7958
7974
  // Link to the login session
@@ -7980,7 +7996,7 @@ _({
7980
7996
  // When the token was explicitly revoked (null = still active).
7981
7997
  revoked_at: o().optional(),
7982
7998
  // Spread in the rest of the refresh token properties.
7983
- ...Gd.shape
7999
+ ...Jd.shape
7984
8000
  });
7985
8001
  _({
7986
8002
  to: o(),
@@ -7990,7 +8006,7 @@ _({
7990
8006
  name: o(),
7991
8007
  options: _({})
7992
8008
  });
7993
- const Jd = _({
8009
+ const Gd = _({
7994
8010
  value: o(),
7995
8011
  description: o().optional()
7996
8012
  }), Wd = _({
@@ -8007,7 +8023,7 @@ const Jd = _({
8007
8023
  id: o().optional(),
8008
8024
  name: o(),
8009
8025
  identifier: o(),
8010
- scopes: b(Jd).optional(),
8026
+ scopes: b(Gd).optional(),
8011
8027
  signing_alg: o().optional(),
8012
8028
  signing_secret: o().optional(),
8013
8029
  token_lifetime: I().default(86400),
@@ -8425,7 +8441,7 @@ function vc(n) {
8425
8441
  return {
8426
8442
  async create(e, t) {
8427
8443
  const i = Date.now();
8428
- return await n.insert(G).values({
8444
+ return await n.insert(J).values({
8429
8445
  id: t.id,
8430
8446
  tenant_id: e,
8431
8447
  token_hash: t.token_hash,
@@ -8449,63 +8465,63 @@ function vc(n) {
8449
8465
  };
8450
8466
  },
8451
8467
  async get(e, t) {
8452
- const i = await n.select().from(G).where(
8468
+ const i = await n.select().from(J).where(
8453
8469
  g(
8454
- c(G.tenant_id, e),
8455
- c(G.id, t)
8470
+ c(J.tenant_id, e),
8471
+ c(J.id, t)
8456
8472
  )
8457
8473
  ).get();
8458
8474
  return i ? Rn(i) : null;
8459
8475
  },
8460
8476
  async getByHash(e, t) {
8461
- const i = await n.select().from(G).where(
8477
+ const i = await n.select().from(J).where(
8462
8478
  g(
8463
- c(G.tenant_id, e),
8464
- c(G.token_hash, t)
8479
+ c(J.tenant_id, e),
8480
+ c(J.token_hash, t)
8465
8481
  )
8466
8482
  ).get();
8467
8483
  return i ? Rn(i) : null;
8468
8484
  },
8469
8485
  async listByClient(e, t) {
8470
- return (await n.select().from(G).where(
8486
+ return (await n.select().from(J).where(
8471
8487
  g(
8472
- c(G.tenant_id, e),
8473
- c(G.client_id, t)
8488
+ c(J.tenant_id, e),
8489
+ c(J.client_id, t)
8474
8490
  )
8475
- ).orderBy(ce(G.created_at_ts))).map(Rn);
8491
+ ).orderBy(ce(J.created_at_ts))).map(Rn);
8476
8492
  },
8477
8493
  async markUsed(e, t, i) {
8478
- return (await n.update(G).set({ used_at_ts: Xt(i) }).where(
8494
+ return (await n.update(J).set({ used_at_ts: Xt(i) }).where(
8479
8495
  g(
8480
- c(G.tenant_id, e),
8481
- c(G.id, t),
8482
- Ae(G.used_at_ts)
8496
+ c(J.tenant_id, e),
8497
+ c(J.id, t),
8498
+ Ae(J.used_at_ts)
8483
8499
  )
8484
8500
  ).returning()).length > 0;
8485
8501
  },
8486
8502
  async revoke(e, t, i) {
8487
- return (await n.update(G).set({ revoked_at_ts: Xt(i) }).where(
8503
+ return (await n.update(J).set({ revoked_at_ts: Xt(i) }).where(
8488
8504
  g(
8489
- c(G.tenant_id, e),
8490
- c(G.id, t),
8491
- Ae(G.revoked_at_ts)
8505
+ c(J.tenant_id, e),
8506
+ c(J.id, t),
8507
+ Ae(J.revoked_at_ts)
8492
8508
  )
8493
8509
  ).returning()).length > 0;
8494
8510
  },
8495
8511
  async revokeByClient(e, t, i) {
8496
- return (await n.update(G).set({ revoked_at_ts: Xt(i) }).where(
8512
+ return (await n.update(J).set({ revoked_at_ts: Xt(i) }).where(
8497
8513
  g(
8498
- c(G.tenant_id, e),
8499
- c(G.client_id, t),
8500
- Ae(G.revoked_at_ts)
8514
+ c(J.tenant_id, e),
8515
+ c(J.client_id, t),
8516
+ Ae(J.revoked_at_ts)
8501
8517
  )
8502
8518
  ).returning()).length;
8503
8519
  },
8504
8520
  async remove(e, t) {
8505
- return (await n.delete(G).where(
8521
+ return (await n.delete(J).where(
8506
8522
  g(
8507
- c(G.tenant_id, e),
8508
- c(G.id, t)
8523
+ c(J.tenant_id, e),
8524
+ c(J.id, t)
8509
8525
  )
8510
8526
  ).returning()).length > 0;
8511
8527
  }
@@ -8801,7 +8817,7 @@ function xc(n) {
8801
8817
  return {
8802
8818
  async create(e, t) {
8803
8819
  const i = (/* @__PURE__ */ new Date()).toISOString();
8804
- await n.insert(it).values({
8820
+ await n.insert(at).values({
8805
8821
  tenant_id: e,
8806
8822
  name: t.name,
8807
8823
  enabled: t.enabled,
@@ -8813,7 +8829,7 @@ function xc(n) {
8813
8829
  });
8814
8830
  },
8815
8831
  async get(e) {
8816
- const t = await n.select().from(it).where(c(it.tenant_id, e)).get();
8832
+ const t = await n.select().from(at).where(c(at.tenant_id, e)).get();
8817
8833
  if (!t) return null;
8818
8834
  const { tenant_id: i, ...a } = t;
8819
8835
  return K({
@@ -8827,10 +8843,10 @@ function xc(n) {
8827
8843
  const i = {
8828
8844
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
8829
8845
  };
8830
- t.name !== void 0 && (i.name = t.name), t.enabled !== void 0 && (i.enabled = t.enabled), t.default_from_address !== void 0 && (i.default_from_address = t.default_from_address), t.credentials !== void 0 && (i.credentials = JSON.stringify(t.credentials)), t.settings !== void 0 && (i.settings = JSON.stringify(t.settings)), await n.update(it).set(i).where(c(it.tenant_id, e));
8846
+ t.name !== void 0 && (i.name = t.name), t.enabled !== void 0 && (i.enabled = t.enabled), t.default_from_address !== void 0 && (i.default_from_address = t.default_from_address), t.credentials !== void 0 && (i.credentials = JSON.stringify(t.credentials)), t.settings !== void 0 && (i.settings = JSON.stringify(t.settings)), await n.update(at).set(i).where(c(at.tenant_id, e));
8831
8847
  },
8832
8848
  async remove(e) {
8833
- await n.delete(it).where(c(it.tenant_id, e));
8849
+ await n.delete(at).where(c(at.tenant_id, e));
8834
8850
  }
8835
8851
  };
8836
8852
  }
@@ -9002,7 +9018,7 @@ function ne(n) {
9002
9018
  const e = new Date(n);
9003
9019
  return isNaN(e.getTime()) ? null : e.getTime();
9004
9020
  }
9005
- function Jt(n, e, t = []) {
9021
+ function Gt(n, e, t = []) {
9006
9022
  const i = {};
9007
9023
  for (const a of e) {
9008
9024
  const r = a.replace(/_ts$/, "");
@@ -9019,7 +9035,7 @@ function Ac() {
9019
9035
  return `hc_${Tc()}`;
9020
9036
  }
9021
9037
  function Oi(n) {
9022
- const { created_at_ts: e, updated_at_ts: t, secrets: i, ...a } = n, r = Jt({ created_at_ts: e, updated_at_ts: t }, [
9038
+ const { created_at_ts: e, updated_at_ts: t, secrets: i, ...a } = n, r = Gt({ created_at_ts: e, updated_at_ts: t }, [
9023
9039
  "created_at_ts",
9024
9040
  "updated_at_ts"
9025
9041
  ]);
@@ -9061,19 +9077,29 @@ function Cc() {
9061
9077
  const { customAlphabet: n } = require("nanoid");
9062
9078
  return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9063
9079
  }
9080
+ function Dc(n) {
9081
+ if (!(typeof n != "string" || !n))
9082
+ try {
9083
+ const e = JSON.parse(n);
9084
+ return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
9085
+ } catch {
9086
+ return;
9087
+ }
9088
+ }
9064
9089
  function Fn(n) {
9065
- const { tenant_id: e, created_at_ts: t, updated_at_ts: i, ...a } = n, r = Jt({ created_at_ts: t, updated_at_ts: i }, [
9090
+ const { tenant_id: e, created_at_ts: t, updated_at_ts: i, metadata: a, ...r } = n, l = Gt({ created_at_ts: t, updated_at_ts: i }, [
9066
9091
  "created_at_ts",
9067
9092
  "updated_at_ts"
9068
9093
  ]);
9069
9094
  return K({
9070
- ...a,
9071
- enabled: !!a.enabled,
9072
- synchronous: !!a.synchronous,
9073
- ...r
9095
+ ...r,
9096
+ enabled: !!r.enabled,
9097
+ synchronous: !!r.synchronous,
9098
+ metadata: Dc(a),
9099
+ ...l
9074
9100
  });
9075
9101
  }
9076
- function Dc(n) {
9102
+ function Lc(n) {
9077
9103
  return {
9078
9104
  async create(e, t) {
9079
9105
  const i = Date.now(), r = {
@@ -9087,6 +9113,7 @@ function Dc(n) {
9087
9113
  form_id: t.form_id,
9088
9114
  template_id: t.template_id,
9089
9115
  code_id: t.code_id,
9116
+ metadata: t.metadata ? JSON.stringify(t.metadata) : null,
9090
9117
  created_at_ts: i,
9091
9118
  updated_at_ts: i
9092
9119
  };
@@ -9100,7 +9127,7 @@ function Dc(n) {
9100
9127
  const a = {
9101
9128
  updated_at_ts: Date.now()
9102
9129
  };
9103
- return i.trigger_id !== void 0 && (a.trigger_id = i.trigger_id), i.url !== void 0 && (a.url = i.url), i.enabled !== void 0 && (a.enabled = i.enabled), i.synchronous !== void 0 && (a.synchronous = i.synchronous), i.priority !== void 0 && (a.priority = i.priority), i.form_id !== void 0 && (a.form_id = i.form_id), i.template_id !== void 0 && (a.template_id = i.template_id), i.code_id !== void 0 && (a.code_id = i.code_id), (await n.update(we).set(a).where(g(c(we.tenant_id, e), c(we.hook_id, t))).returning()).length > 0;
9130
+ return i.trigger_id !== void 0 && (a.trigger_id = i.trigger_id), i.url !== void 0 && (a.url = i.url), i.enabled !== void 0 && (a.enabled = i.enabled), i.synchronous !== void 0 && (a.synchronous = i.synchronous), i.priority !== void 0 && (a.priority = i.priority), i.form_id !== void 0 && (a.form_id = i.form_id), i.template_id !== void 0 && (a.template_id = i.template_id), i.code_id !== void 0 && (a.code_id = i.code_id), i.metadata !== void 0 && (a.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await n.update(we).set(a).where(g(c(we.tenant_id, e), c(we.hook_id, t))).returning()).length > 0;
9104
9131
  },
9105
9132
  async list(e, t) {
9106
9133
  const {
@@ -9138,7 +9165,7 @@ function Dc(n) {
9138
9165
  }
9139
9166
  };
9140
9167
  }
9141
- function Lc() {
9168
+ function Rc() {
9142
9169
  const { customAlphabet: n } = require("nanoid");
9143
9170
  return `inv_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9144
9171
  }
@@ -9155,11 +9182,11 @@ function Pn(n) {
9155
9182
  a[r] = z(i[r], r === "roles" ? [] : {});
9156
9183
  return a.send_invitation_email = !!t, K(a);
9157
9184
  }
9158
- function Rc(n) {
9185
+ function Uc(n) {
9159
9186
  return {
9160
9187
  async create(e, t) {
9161
9188
  var u, f;
9162
- const i = t.id || Lc(), a = t.ttl_sec || 604800, r = /* @__PURE__ */ new Date(), l = new Date(r.getTime() + a * 1e3).toISOString(), d = {
9189
+ const i = t.id || Rc(), a = t.ttl_sec || 604800, r = /* @__PURE__ */ new Date(), l = new Date(r.getTime() + a * 1e3).toISOString(), d = {
9163
9190
  id: i,
9164
9191
  tenant_id: e,
9165
9192
  organization_id: t.organization_id,
@@ -9223,7 +9250,7 @@ function Rc(n) {
9223
9250
  }
9224
9251
  };
9225
9252
  }
9226
- function Uc(n) {
9253
+ function zc(n) {
9227
9254
  return {
9228
9255
  async create(e) {
9229
9256
  await n.insert(Be).values({
@@ -9265,7 +9292,7 @@ function Uc(n) {
9265
9292
  };
9266
9293
  }
9267
9294
  const di = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Mn = di.length;
9268
- function zc() {
9295
+ function Fc() {
9269
9296
  let t = Date.now(), i = "";
9270
9297
  for (let r = 10; r > 0; r--)
9271
9298
  i = di.charAt(t % Mn) + i, t = Math.floor(t / Mn);
@@ -9284,7 +9311,7 @@ function Ti(n) {
9284
9311
  state_data: r,
9285
9312
  auth_params: l,
9286
9313
  ...d
9287
- } = n, u = Jt(
9314
+ } = n, u = Gt(
9288
9315
  { created_at_ts: t, updated_at_ts: i, expires_at_ts: a },
9289
9316
  ["created_at_ts", "updated_at_ts", "expires_at_ts"]
9290
9317
  ), f = {};
@@ -9298,12 +9325,12 @@ function Ti(n) {
9298
9325
  state_data: z(r)
9299
9326
  });
9300
9327
  }
9301
- function Fc(n) {
9328
+ function Pc(n) {
9302
9329
  return {
9303
9330
  async create(e, t) {
9304
9331
  var l, d;
9305
9332
  const i = Date.now(), r = {
9306
- id: zc(),
9333
+ id: Fc(),
9307
9334
  tenant_id: e,
9308
9335
  session_id: t.session_id,
9309
9336
  csrf_token: t.csrf_token,
@@ -9324,10 +9351,10 @@ function Fc(n) {
9324
9351
  updated_at_ts: i,
9325
9352
  expires_at_ts: t.expires_at ? ne(t.expires_at) : i + 1e3 * 60 * 60 * 24
9326
9353
  };
9327
- return await n.insert(J).values(r), Ti({ ...r, tenant_id: e });
9354
+ return await n.insert(G).values(r), Ti({ ...r, tenant_id: e });
9328
9355
  },
9329
9356
  async get(e, t) {
9330
- const i = e ? g(c(J.tenant_id, e), c(J.id, t)) : c(J.id, t), a = await n.select().from(J).where(i).get();
9357
+ const i = e ? g(c(G.tenant_id, e), c(G.id, t)) : c(G.id, t), a = await n.select().from(G).where(i).get();
9331
9358
  return a ? Ti(a) : null;
9332
9359
  },
9333
9360
  async update(e, t, i) {
@@ -9339,10 +9366,10 @@ function Fc(n) {
9339
9366
  0,
9340
9367
  1024
9341
9368
  )), i.expires_at !== void 0 && (a.expires_at_ts = ne(i.expires_at)), i.authParams !== void 0) {
9342
- const u = await n.select({ auth_params: J.auth_params }).from(J).where(
9369
+ const u = await n.select({ auth_params: G.auth_params }).from(G).where(
9343
9370
  g(
9344
- c(J.tenant_id, e),
9345
- c(J.id, t)
9371
+ c(G.tenant_id, e),
9372
+ c(G.id, t)
9346
9373
  )
9347
9374
  ).get(), f = u != null && u.auth_params && typeof u.auth_params == "string" && u.auth_params.length > 0 ? JSON.parse(u.auth_params) : {};
9348
9375
  a.auth_params = JSON.stringify({
@@ -9350,13 +9377,13 @@ function Fc(n) {
9350
9377
  ...i.authParams
9351
9378
  });
9352
9379
  }
9353
- return await n.update(J).set(a).where(
9354
- g(c(J.tenant_id, e), c(J.id, t))
9380
+ return await n.update(G).set(a).where(
9381
+ g(c(G.tenant_id, e), c(G.id, t))
9355
9382
  ), !0;
9356
9383
  },
9357
9384
  async remove(e, t) {
9358
- return (await n.delete(J).where(
9359
- g(c(J.tenant_id, e), c(J.id, t))
9385
+ return (await n.delete(G).where(
9386
+ g(c(G.tenant_id, e), c(G.id, t))
9360
9387
  ).returning()).length > 0;
9361
9388
  }
9362
9389
  };
@@ -9391,7 +9418,7 @@ function qn(n) {
9391
9418
  continent_code: p
9392
9419
  })), K(S);
9393
9420
  }
9394
- function Pc(n) {
9421
+ function Mc(n) {
9395
9422
  return {
9396
9423
  async create(e, t) {
9397
9424
  var r, l;
@@ -9463,7 +9490,7 @@ function Pc(n) {
9463
9490
  };
9464
9491
  }
9465
9492
  const ci = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Bn = ci.length;
9466
- function Mc() {
9493
+ function qc() {
9467
9494
  let t = Date.now(), i = "";
9468
9495
  for (let r = 10; r > 0; r--)
9469
9496
  i = ci.charAt(t % Bn) + i, t = Math.floor(t / Bn);
@@ -9492,11 +9519,11 @@ function tn(n) {
9492
9519
  updated_at: si(i)
9493
9520
  });
9494
9521
  }
9495
- function qc(n) {
9522
+ function Bc(n) {
9496
9523
  return {
9497
9524
  async create(e, t) {
9498
9525
  const i = Date.now(), r = {
9499
- id: t.id || Mc(),
9526
+ id: t.id || qc(),
9500
9527
  tenant_id: e,
9501
9528
  user_id: t.user_id,
9502
9529
  type: t.type,
@@ -9567,7 +9594,7 @@ function qc(n) {
9567
9594
  }
9568
9595
  };
9569
9596
  }
9570
- function Bc() {
9597
+ function $c() {
9571
9598
  const { customAlphabet: n } = require("nanoid");
9572
9599
  return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9573
9600
  }
@@ -9588,12 +9615,12 @@ function $n(n) {
9588
9615
  token_quota: z(r, {})
9589
9616
  });
9590
9617
  }
9591
- function $c(n) {
9618
+ function jc(n) {
9592
9619
  return {
9593
9620
  async create(e, t) {
9594
9621
  var l, d;
9595
9622
  const i = (/* @__PURE__ */ new Date()).toISOString(), r = {
9596
- id: t.id || Bc(),
9623
+ id: t.id || $c(),
9597
9624
  tenant_id: e,
9598
9625
  name: t.name,
9599
9626
  display_name: t.display_name,
@@ -9686,7 +9713,7 @@ function jn(n) {
9686
9713
  is_current: !!t
9687
9714
  };
9688
9715
  }
9689
- function jc(n) {
9716
+ function Vc(n) {
9690
9717
  return {
9691
9718
  async create(e, t) {
9692
9719
  const i = (/* @__PURE__ */ new Date()).toISOString(), a = t.id || Ie();
@@ -9746,7 +9773,7 @@ function jc(n) {
9746
9773
  }
9747
9774
  };
9748
9775
  }
9749
- function Vc(n) {
9776
+ function Zc(n) {
9750
9777
  return {
9751
9778
  async get(e) {
9752
9779
  const t = await n.select().from(It).where(c(It.tenant_id, e)).get();
@@ -9793,7 +9820,7 @@ function Vn(n) {
9793
9820
  resource_servers: u,
9794
9821
  rotating: f,
9795
9822
  ...p
9796
- } = n, v = Jt(
9823
+ } = n, v = Gt(
9797
9824
  {
9798
9825
  created_at_ts: t,
9799
9826
  expires_at_ts: i,
@@ -9817,10 +9844,10 @@ function Vn(n) {
9817
9844
  resource_servers: z(u, [])
9818
9845
  });
9819
9846
  }
9820
- function Zc(n, e) {
9847
+ function Hc(n, e) {
9821
9848
  return Math.max(n ?? 0, e ?? 0);
9822
9849
  }
9823
- function Hc(n) {
9850
+ function Kc(n) {
9824
9851
  return {
9825
9852
  async create(e, t) {
9826
9853
  const i = Date.now(), a = {
@@ -9840,18 +9867,18 @@ function Hc(n) {
9840
9867
  await n.run(A`BEGIN`);
9841
9868
  try {
9842
9869
  await n.insert(X).values(a);
9843
- const r = Zc(
9870
+ const r = Hc(
9844
9871
  a.expires_at_ts,
9845
9872
  a.idle_expires_at_ts
9846
9873
  );
9847
- r > 0 && a.login_id && await n.update(J).set({
9874
+ r > 0 && a.login_id && await n.update(G).set({
9848
9875
  expires_at_ts: r,
9849
9876
  updated_at_ts: i
9850
9877
  }).where(
9851
9878
  g(
9852
- c(J.tenant_id, e),
9853
- c(J.id, a.login_id),
9854
- Xe(J.expires_at_ts, r)
9879
+ c(G.tenant_id, e),
9880
+ c(G.id, a.login_id),
9881
+ Xe(G.expires_at_ts, r)
9855
9882
  )
9856
9883
  ), await n.run(A`COMMIT`);
9857
9884
  } catch (r) {
@@ -9869,19 +9896,16 @@ function Hc(n) {
9869
9896
  const r = {};
9870
9897
  i.device !== void 0 && (r.device = JSON.stringify(i.device)), i.resource_servers !== void 0 && (r.resource_servers = JSON.stringify(i.resource_servers)), i.rotating !== void 0 && (r.rotating = i.rotating), i.expires_at !== void 0 && (r.expires_at_ts = ne(i.expires_at)), i.idle_expires_at !== void 0 && (r.idle_expires_at_ts = ne(i.idle_expires_at)), i.last_exchanged_at !== void 0 && (r.last_exchanged_at_ts = ne(i.last_exchanged_at)), i.revoked_at !== void 0 && (r.revoked_at_ts = ne(i.revoked_at));
9871
9898
  const l = a == null ? void 0 : a.loginSessionBump, d = l ? ne(l.expires_at) : null, u = await n.update(X).set(r).where(
9872
- g(
9873
- c(X.tenant_id, e),
9874
- c(X.id, t)
9875
- )
9899
+ g(c(X.tenant_id, e), c(X.id, t))
9876
9900
  ).returning();
9877
- return l != null && l.login_id && d && d > 0 && await n.update(J).set({
9901
+ return l != null && l.login_id && d && d > 0 && await n.update(G).set({
9878
9902
  expires_at_ts: d,
9879
9903
  updated_at_ts: Date.now()
9880
9904
  }).where(
9881
9905
  g(
9882
- c(J.tenant_id, e),
9883
- c(J.id, l.login_id),
9884
- Xe(J.expires_at_ts, d)
9906
+ c(G.tenant_id, e),
9907
+ c(G.id, l.login_id),
9908
+ Xe(G.expires_at_ts, d)
9885
9909
  )
9886
9910
  ).catch(() => {
9887
9911
  }), u.length > 0;
@@ -9934,7 +9958,7 @@ function Hc(n) {
9934
9958
  }
9935
9959
  };
9936
9960
  }
9937
- function Kc() {
9961
+ function Qc() {
9938
9962
  const { customAlphabet: n } = require("nanoid");
9939
9963
  return `api_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9940
9964
  }
@@ -9975,11 +9999,11 @@ function Zn(n) {
9975
9999
  l[u] !== void 0 && l[u] !== null && (d[u] = !!l[u]);
9976
10000
  return K(d);
9977
10001
  }
9978
- function Qc(n) {
10002
+ function Jc(n) {
9979
10003
  return {
9980
10004
  async create(e, t) {
9981
10005
  const i = (/* @__PURE__ */ new Date()).toISOString(), r = {
9982
- id: t.id || Kc(),
10006
+ id: t.id || Qc(),
9983
10007
  tenant_id: e,
9984
10008
  identifier: t.identifier,
9985
10009
  name: t.name,
@@ -10035,8 +10059,8 @@ function Qc(n) {
10035
10059
  if (d) {
10036
10060
  const ee = d.match(/^([^:]+):(.+)$/);
10037
10061
  if (ee) {
10038
- const [, ie, ae] = ee, Ge = ie == null ? void 0 : ie.startsWith("-"), ut = Ge ? ie == null ? void 0 : ie.substring(1) : ie;
10039
- if (ut && Ai.has(ut) && !Ge) {
10062
+ const [, ie, ae] = ee, Je = ie == null ? void 0 : ie.startsWith("-"), ut = Je ? ie == null ? void 0 : ie.substring(1) : ie;
10063
+ if (ut && Ai.has(ut) && !Je) {
10040
10064
  const vn = Y[ut];
10041
10065
  p.push(Nt(vn, `%${ae}%`));
10042
10066
  }
@@ -10135,7 +10159,7 @@ function Gc(n) {
10135
10159
  }
10136
10160
  };
10137
10161
  }
10138
- function Jc(n) {
10162
+ function Wc(n) {
10139
10163
  return {
10140
10164
  async create(e, t, i, a) {
10141
10165
  var r, l;
@@ -10203,7 +10227,7 @@ function Hn(n) {
10203
10227
  metadata: z(i)
10204
10228
  });
10205
10229
  }
10206
- function Wc(n) {
10230
+ function Xc(n) {
10207
10231
  return {
10208
10232
  async create(e, t) {
10209
10233
  const i = (/* @__PURE__ */ new Date()).toISOString(), r = {
@@ -10259,7 +10283,7 @@ function Wc(n) {
10259
10283
  }
10260
10284
  };
10261
10285
  }
10262
- const Xc = ["created_at_ts", "updated_at_ts"], Yc = [
10286
+ const Yc = ["created_at_ts", "updated_at_ts"], e_ = [
10263
10287
  "expires_at_ts",
10264
10288
  "idle_expires_at_ts",
10265
10289
  "authenticated_at_ts",
@@ -10281,7 +10305,7 @@ function Kn(n) {
10281
10305
  device: p,
10282
10306
  clients: v,
10283
10307
  ...m
10284
- } = n, S = Jt(
10308
+ } = n, S = Gt(
10285
10309
  {
10286
10310
  created_at_ts: t,
10287
10311
  updated_at_ts: i,
@@ -10292,8 +10316,8 @@ function Kn(n) {
10292
10316
  used_at_ts: u,
10293
10317
  revoked_at_ts: f
10294
10318
  },
10295
- [...Xc],
10296
- [...Yc]
10319
+ [...Yc],
10320
+ [...e_]
10297
10321
  );
10298
10322
  return K({
10299
10323
  ...m,
@@ -10302,7 +10326,7 @@ function Kn(n) {
10302
10326
  clients: z(v, [])
10303
10327
  });
10304
10328
  }
10305
- function e_(n) {
10329
+ function t_(n) {
10306
10330
  return {
10307
10331
  async create(e, t) {
10308
10332
  const i = Date.now(), a = {
@@ -10407,7 +10431,7 @@ function Ci(n) {
10407
10431
  n[t] !== void 0 && (e[t] = n[t] ? 1 : 0);
10408
10432
  return ar(e);
10409
10433
  }
10410
- function t_(n) {
10434
+ function n_(n) {
10411
10435
  return {
10412
10436
  async create(e) {
10413
10437
  var a, r;
@@ -10473,7 +10497,7 @@ function t_(n) {
10473
10497
  }
10474
10498
  };
10475
10499
  }
10476
- const n_ = [
10500
+ const i_ = [
10477
10501
  "colors",
10478
10502
  "borders",
10479
10503
  "fonts",
@@ -10481,10 +10505,10 @@ const n_ = [
10481
10505
  "widget"
10482
10506
  ];
10483
10507
  function Di(n) {
10484
- const { tenant_id: e, ...t } = n, i = or(t, n_);
10508
+ const { tenant_id: e, ...t } = n, i = or(t, i_);
10485
10509
  return i.borders && (i.borders.show_widget_shadow = !!i.borders.show_widget_shadow), i.fonts && (i.fonts.links_bold = !!i.fonts.links_bold, i.fonts.subtitle_bold = !!i.fonts.subtitle_bold, i.fonts.title_bold = !!i.fonts.title_bold), K(i);
10486
10510
  }
10487
- function i_(n) {
10511
+ function a_(n) {
10488
10512
  return {
10489
10513
  async create(e, t, i) {
10490
10514
  const a = (/* @__PURE__ */ new Date()).toISOString(), r = i || Ie(), d = {
@@ -10515,21 +10539,21 @@ function i_(n) {
10515
10539
  }
10516
10540
  };
10517
10541
  }
10518
- function a_(n) {
10542
+ function o_(n) {
10519
10543
  return {
10520
10544
  async get(e) {
10521
- const t = await n.select({ body: nt.body }).from(nt).where(c(nt.tenant_id, e)).get();
10545
+ const t = await n.select({ body: it.body }).from(it).where(c(it.tenant_id, e)).get();
10522
10546
  return t ? { body: t.body } : null;
10523
10547
  },
10524
10548
  async set(e, t) {
10525
10549
  const i = Date.now();
10526
- await n.insert(nt).values({
10550
+ await n.insert(it).values({
10527
10551
  tenant_id: e,
10528
10552
  body: t.body,
10529
10553
  created_at_ts: i,
10530
10554
  updated_at_ts: i
10531
10555
  }).onConflictDoUpdate({
10532
- target: nt.tenant_id,
10556
+ target: it.tenant_id,
10533
10557
  set: {
10534
10558
  body: t.body,
10535
10559
  updated_at_ts: i
@@ -10537,7 +10561,7 @@ function a_(n) {
10537
10561
  });
10538
10562
  },
10539
10563
  async delete(e) {
10540
- await n.delete(nt).where(c(nt.tenant_id, e));
10564
+ await n.delete(it).where(c(it.tenant_id, e));
10541
10565
  }
10542
10566
  };
10543
10567
  }
@@ -10579,7 +10603,7 @@ function Qn(n, e = []) {
10579
10603
  identities: [m, ...S]
10580
10604
  });
10581
10605
  }
10582
- function o_(n) {
10606
+ function r_(n) {
10583
10607
  const e = async (t, i) => {
10584
10608
  var d, u;
10585
10609
  const a = (/* @__PURE__ */ new Date()).toISOString(), r = {
@@ -10724,8 +10748,8 @@ function o_(n) {
10724
10748
  )
10725
10749
  ));
10726
10750
  const ee = m.map((ae) => {
10727
- const Ge = T.filter((ut) => ut.linked_to === ae.user_id);
10728
- return Qn(ae, Ge);
10751
+ const Je = T.filter((ut) => ut.linked_to === ae.user_id);
10752
+ return Qn(ae, Je);
10729
10753
  });
10730
10754
  if (!l)
10731
10755
  return { users: ee };
@@ -10776,7 +10800,7 @@ function o_(n) {
10776
10800
  }
10777
10801
  };
10778
10802
  }
10779
- function r_(n) {
10803
+ function s_(n) {
10780
10804
  return {
10781
10805
  async create(e, t, i, a) {
10782
10806
  var r, l;
@@ -10831,7 +10855,7 @@ function r_(n) {
10831
10855
  }
10832
10856
  };
10833
10857
  }
10834
- function s_(n) {
10858
+ function l_(n) {
10835
10859
  return {
10836
10860
  async create(e, t) {
10837
10861
  var u, f;
@@ -10925,10 +10949,10 @@ function s_(n) {
10925
10949
  metadata: ee,
10926
10950
  enabled_connections: ie,
10927
10951
  token_quota: ae,
10928
- ...Ge
10952
+ ...Je
10929
10953
  } = m;
10930
10954
  return K({
10931
- ...Ge,
10955
+ ...Je,
10932
10956
  branding: z(T, {}),
10933
10957
  metadata: z(ee, {}),
10934
10958
  enabled_connections: z(ie, []),
@@ -10961,8 +10985,8 @@ function s_(n) {
10961
10985
  }
10962
10986
  };
10963
10987
  }
10964
- const Ri = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], l_ = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
10965
- function d_(n) {
10988
+ const Ri = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], d_ = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
10989
+ function c_(n) {
10966
10990
  return {
10967
10991
  async getDaily(e, t) {
10968
10992
  const i = /* @__PURE__ */ new Date(), a = (t == null ? void 0 : t.from) || new Date(i.getTime() - 30 * 24 * 60 * 60 * 1e3).toISOString().split("T")[0], r = (t == null ? void 0 : t.to) || i.toISOString().split("T")[0];
@@ -10976,7 +11000,7 @@ function d_(n) {
10976
11000
  "signups"
10977
11001
  ),
10978
11002
  leaked_passwords: A`SUM(CASE WHEN ${Q.type} IN (${A.join(
10979
- l_.map((d) => A`${d}`),
11003
+ d_.map((d) => A`${d}`),
10980
11004
  A`, `
10981
11005
  )}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
10982
11006
  }).from(Q).where(
@@ -11019,7 +11043,7 @@ function Ui(n) {
11019
11043
  payload: z(n.payload, {})
11020
11044
  };
11021
11045
  }
11022
- function c_(n) {
11046
+ function __(n) {
11023
11047
  return {
11024
11048
  async create(e, t) {
11025
11049
  const i = Ie(), a = (/* @__PURE__ */ new Date()).toISOString();
@@ -11161,10 +11185,10 @@ function c_(n) {
11161
11185
  }
11162
11186
  };
11163
11187
  }
11164
- const __ = 7 * 24 * 60 * 60 * 1e3;
11165
- function u_(n) {
11188
+ const u_ = 7 * 24 * 60 * 60 * 1e3;
11189
+ function p_(n) {
11166
11190
  return async (e) => {
11167
- const t = Date.now() - __;
11191
+ const t = Date.now() - u_;
11168
11192
  try {
11169
11193
  let i = [
11170
11194
  Ue(
@@ -11177,13 +11201,13 @@ function u_(n) {
11177
11201
  Xe(oe.expires_at_ts, t),
11178
11202
  Xe(oe.idle_expires_at_ts, t)
11179
11203
  )
11180
- ], e != null && e.tenant_id && i.push(c(oe.tenant_id, e.tenant_id)), e != null && e.user_id && i.push(c(oe.user_id, e.user_id)), await n.delete(oe).where(g(...i)), i = [Xe(J.expires_at_ts, t)], e != null && e.tenant_id && i.push(c(J.tenant_id, e.tenant_id)), await n.delete(J).where(g(...i));
11204
+ ], e != null && e.tenant_id && i.push(c(oe.tenant_id, e.tenant_id)), e != null && e.user_id && i.push(c(oe.user_id, e.user_id)), await n.delete(oe).where(g(...i)), i = [Xe(G.expires_at_ts, t)], e != null && e.tenant_id && i.push(c(G.tenant_id, e.tenant_id)), await n.delete(G).where(g(...i));
11181
11205
  } catch (i) {
11182
11206
  console.error("Session cleanup error:", i);
11183
11207
  }
11184
11208
  };
11185
11209
  }
11186
- function h_(n, e = { useTransactions: !0 }) {
11210
+ function g_(n, e = { useTransactions: !0 }) {
11187
11211
  const t = {
11188
11212
  actions: $r(),
11189
11213
  branding: is(n),
@@ -11199,30 +11223,30 @@ function h_(n, e = { useTransactions: !0 }) {
11199
11223
  flows: kc(n),
11200
11224
  forms: Oc(n),
11201
11225
  hookCode: Ic(n),
11202
- hooks: Dc(n),
11203
- invites: Rc(n),
11204
- keys: Uc(n),
11205
- loginSessions: Fc(n),
11206
- logs: Pc(n),
11207
- authenticationMethods: qc(n),
11208
- organizations: $c(n),
11209
- passwords: jc(n),
11210
- promptSettings: Vc(n),
11211
- refreshTokens: Hc(n),
11212
- resourceServers: Qc(n),
11226
+ hooks: Lc(n),
11227
+ invites: Uc(n),
11228
+ keys: zc(n),
11229
+ loginSessions: Pc(n),
11230
+ logs: Mc(n),
11231
+ authenticationMethods: Bc(n),
11232
+ organizations: jc(n),
11233
+ passwords: Vc(n),
11234
+ promptSettings: Zc(n),
11235
+ refreshTokens: Kc(n),
11236
+ resourceServers: Jc(n),
11213
11237
  rolePermissions: Gc(n),
11214
- userPermissions: Jc(n),
11215
- roles: Wc(n),
11216
- sessions: e_(n),
11217
- sessionCleanup: u_(n),
11218
- tenants: t_(n),
11219
- themes: i_(n),
11220
- universalLoginTemplates: a_(n),
11221
- users: o_(n),
11222
- userRoles: r_(n),
11223
- userOrganizations: s_(n),
11224
- stats: d_(n),
11225
- outbox: c_(n),
11238
+ userPermissions: Wc(n),
11239
+ roles: Xc(n),
11240
+ sessions: t_(n),
11241
+ sessionCleanup: p_(n),
11242
+ tenants: n_(n),
11243
+ themes: a_(n),
11244
+ universalLoginTemplates: o_(n),
11245
+ users: r_(n),
11246
+ userRoles: s_(n),
11247
+ userOrganizations: l_(n),
11248
+ stats: c_(n),
11249
+ outbox: __(n),
11226
11250
  async transaction(i) {
11227
11251
  if (e.useTransactions === !1)
11228
11252
  return i(t);
@@ -11238,6 +11262,6 @@ function h_(n, e = { useTransactions: !0 }) {
11238
11262
  return t;
11239
11263
  }
11240
11264
  export {
11241
- h_ as default,
11242
- f_ as sqlite
11265
+ g_ as default,
11266
+ h_ as sqlite
11243
11267
  };