@authhero/drizzle 0.43.3 → 0.43.4

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,
@@ -7952,7 +7966,7 @@ _({
7952
7966
  ]),
7953
7967
  settings: _({}).optional()
7954
7968
  });
7955
- const Gd = _({
7969
+ const Jd = _({
7956
7970
  // The actual refresh token value (primary key).
7957
7971
  id: o(),
7958
7972
  // Link to the login session
@@ -7980,7 +7994,7 @@ _({
7980
7994
  // When the token was explicitly revoked (null = still active).
7981
7995
  revoked_at: o().optional(),
7982
7996
  // Spread in the rest of the refresh token properties.
7983
- ...Gd.shape
7997
+ ...Jd.shape
7984
7998
  });
7985
7999
  _({
7986
8000
  to: o(),
@@ -7990,7 +8004,7 @@ _({
7990
8004
  name: o(),
7991
8005
  options: _({})
7992
8006
  });
7993
- const Jd = _({
8007
+ const Gd = _({
7994
8008
  value: o(),
7995
8009
  description: o().optional()
7996
8010
  }), Wd = _({
@@ -8007,7 +8021,7 @@ const Jd = _({
8007
8021
  id: o().optional(),
8008
8022
  name: o(),
8009
8023
  identifier: o(),
8010
- scopes: b(Jd).optional(),
8024
+ scopes: b(Gd).optional(),
8011
8025
  signing_alg: o().optional(),
8012
8026
  signing_secret: o().optional(),
8013
8027
  token_lifetime: I().default(86400),
@@ -8425,7 +8439,7 @@ function vc(n) {
8425
8439
  return {
8426
8440
  async create(e, t) {
8427
8441
  const i = Date.now();
8428
- return await n.insert(G).values({
8442
+ return await n.insert(J).values({
8429
8443
  id: t.id,
8430
8444
  tenant_id: e,
8431
8445
  token_hash: t.token_hash,
@@ -8449,63 +8463,63 @@ function vc(n) {
8449
8463
  };
8450
8464
  },
8451
8465
  async get(e, t) {
8452
- const i = await n.select().from(G).where(
8466
+ const i = await n.select().from(J).where(
8453
8467
  g(
8454
- c(G.tenant_id, e),
8455
- c(G.id, t)
8468
+ c(J.tenant_id, e),
8469
+ c(J.id, t)
8456
8470
  )
8457
8471
  ).get();
8458
8472
  return i ? Rn(i) : null;
8459
8473
  },
8460
8474
  async getByHash(e, t) {
8461
- const i = await n.select().from(G).where(
8475
+ const i = await n.select().from(J).where(
8462
8476
  g(
8463
- c(G.tenant_id, e),
8464
- c(G.token_hash, t)
8477
+ c(J.tenant_id, e),
8478
+ c(J.token_hash, t)
8465
8479
  )
8466
8480
  ).get();
8467
8481
  return i ? Rn(i) : null;
8468
8482
  },
8469
8483
  async listByClient(e, t) {
8470
- return (await n.select().from(G).where(
8484
+ return (await n.select().from(J).where(
8471
8485
  g(
8472
- c(G.tenant_id, e),
8473
- c(G.client_id, t)
8486
+ c(J.tenant_id, e),
8487
+ c(J.client_id, t)
8474
8488
  )
8475
- ).orderBy(ce(G.created_at_ts))).map(Rn);
8489
+ ).orderBy(ce(J.created_at_ts))).map(Rn);
8476
8490
  },
8477
8491
  async markUsed(e, t, i) {
8478
- return (await n.update(G).set({ used_at_ts: Xt(i) }).where(
8492
+ return (await n.update(J).set({ used_at_ts: Xt(i) }).where(
8479
8493
  g(
8480
- c(G.tenant_id, e),
8481
- c(G.id, t),
8482
- Ae(G.used_at_ts)
8494
+ c(J.tenant_id, e),
8495
+ c(J.id, t),
8496
+ Ae(J.used_at_ts)
8483
8497
  )
8484
8498
  ).returning()).length > 0;
8485
8499
  },
8486
8500
  async revoke(e, t, i) {
8487
- return (await n.update(G).set({ revoked_at_ts: Xt(i) }).where(
8501
+ return (await n.update(J).set({ revoked_at_ts: Xt(i) }).where(
8488
8502
  g(
8489
- c(G.tenant_id, e),
8490
- c(G.id, t),
8491
- Ae(G.revoked_at_ts)
8503
+ c(J.tenant_id, e),
8504
+ c(J.id, t),
8505
+ Ae(J.revoked_at_ts)
8492
8506
  )
8493
8507
  ).returning()).length > 0;
8494
8508
  },
8495
8509
  async revokeByClient(e, t, i) {
8496
- return (await n.update(G).set({ revoked_at_ts: Xt(i) }).where(
8510
+ return (await n.update(J).set({ revoked_at_ts: Xt(i) }).where(
8497
8511
  g(
8498
- c(G.tenant_id, e),
8499
- c(G.client_id, t),
8500
- Ae(G.revoked_at_ts)
8512
+ c(J.tenant_id, e),
8513
+ c(J.client_id, t),
8514
+ Ae(J.revoked_at_ts)
8501
8515
  )
8502
8516
  ).returning()).length;
8503
8517
  },
8504
8518
  async remove(e, t) {
8505
- return (await n.delete(G).where(
8519
+ return (await n.delete(J).where(
8506
8520
  g(
8507
- c(G.tenant_id, e),
8508
- c(G.id, t)
8521
+ c(J.tenant_id, e),
8522
+ c(J.id, t)
8509
8523
  )
8510
8524
  ).returning()).length > 0;
8511
8525
  }
@@ -8801,7 +8815,7 @@ function xc(n) {
8801
8815
  return {
8802
8816
  async create(e, t) {
8803
8817
  const i = (/* @__PURE__ */ new Date()).toISOString();
8804
- await n.insert(it).values({
8818
+ await n.insert(at).values({
8805
8819
  tenant_id: e,
8806
8820
  name: t.name,
8807
8821
  enabled: t.enabled,
@@ -8813,7 +8827,7 @@ function xc(n) {
8813
8827
  });
8814
8828
  },
8815
8829
  async get(e) {
8816
- const t = await n.select().from(it).where(c(it.tenant_id, e)).get();
8830
+ const t = await n.select().from(at).where(c(at.tenant_id, e)).get();
8817
8831
  if (!t) return null;
8818
8832
  const { tenant_id: i, ...a } = t;
8819
8833
  return K({
@@ -8827,10 +8841,10 @@ function xc(n) {
8827
8841
  const i = {
8828
8842
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
8829
8843
  };
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));
8844
+ 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
8845
  },
8832
8846
  async remove(e) {
8833
- await n.delete(it).where(c(it.tenant_id, e));
8847
+ await n.delete(at).where(c(at.tenant_id, e));
8834
8848
  }
8835
8849
  };
8836
8850
  }
@@ -9002,7 +9016,7 @@ function ne(n) {
9002
9016
  const e = new Date(n);
9003
9017
  return isNaN(e.getTime()) ? null : e.getTime();
9004
9018
  }
9005
- function Jt(n, e, t = []) {
9019
+ function Gt(n, e, t = []) {
9006
9020
  const i = {};
9007
9021
  for (const a of e) {
9008
9022
  const r = a.replace(/_ts$/, "");
@@ -9019,7 +9033,7 @@ function Ac() {
9019
9033
  return `hc_${Tc()}`;
9020
9034
  }
9021
9035
  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 }, [
9036
+ const { created_at_ts: e, updated_at_ts: t, secrets: i, ...a } = n, r = Gt({ created_at_ts: e, updated_at_ts: t }, [
9023
9037
  "created_at_ts",
9024
9038
  "updated_at_ts"
9025
9039
  ]);
@@ -9061,19 +9075,29 @@ function Cc() {
9061
9075
  const { customAlphabet: n } = require("nanoid");
9062
9076
  return `h_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9063
9077
  }
9078
+ function Dc(n) {
9079
+ if (!(typeof n != "string" || !n))
9080
+ try {
9081
+ const e = JSON.parse(n);
9082
+ return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
9083
+ } catch {
9084
+ return;
9085
+ }
9086
+ }
9064
9087
  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 }, [
9088
+ 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
9089
  "created_at_ts",
9067
9090
  "updated_at_ts"
9068
9091
  ]);
9069
9092
  return K({
9070
- ...a,
9071
- enabled: !!a.enabled,
9072
- synchronous: !!a.synchronous,
9073
- ...r
9093
+ ...r,
9094
+ enabled: !!r.enabled,
9095
+ synchronous: !!r.synchronous,
9096
+ metadata: Dc(a),
9097
+ ...l
9074
9098
  });
9075
9099
  }
9076
- function Dc(n) {
9100
+ function Lc(n) {
9077
9101
  return {
9078
9102
  async create(e, t) {
9079
9103
  const i = Date.now(), r = {
@@ -9087,6 +9111,7 @@ function Dc(n) {
9087
9111
  form_id: t.form_id,
9088
9112
  template_id: t.template_id,
9089
9113
  code_id: t.code_id,
9114
+ metadata: t.metadata ? JSON.stringify(t.metadata) : null,
9090
9115
  created_at_ts: i,
9091
9116
  updated_at_ts: i
9092
9117
  };
@@ -9100,7 +9125,7 @@ function Dc(n) {
9100
9125
  const a = {
9101
9126
  updated_at_ts: Date.now()
9102
9127
  };
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;
9128
+ 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
9129
  },
9105
9130
  async list(e, t) {
9106
9131
  const {
@@ -9138,7 +9163,7 @@ function Dc(n) {
9138
9163
  }
9139
9164
  };
9140
9165
  }
9141
- function Lc() {
9166
+ function Rc() {
9142
9167
  const { customAlphabet: n } = require("nanoid");
9143
9168
  return `inv_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9144
9169
  }
@@ -9155,11 +9180,11 @@ function Pn(n) {
9155
9180
  a[r] = z(i[r], r === "roles" ? [] : {});
9156
9181
  return a.send_invitation_email = !!t, K(a);
9157
9182
  }
9158
- function Rc(n) {
9183
+ function Uc(n) {
9159
9184
  return {
9160
9185
  async create(e, t) {
9161
9186
  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 = {
9187
+ const i = t.id || Rc(), a = t.ttl_sec || 604800, r = /* @__PURE__ */ new Date(), l = new Date(r.getTime() + a * 1e3).toISOString(), d = {
9163
9188
  id: i,
9164
9189
  tenant_id: e,
9165
9190
  organization_id: t.organization_id,
@@ -9223,7 +9248,7 @@ function Rc(n) {
9223
9248
  }
9224
9249
  };
9225
9250
  }
9226
- function Uc(n) {
9251
+ function zc(n) {
9227
9252
  return {
9228
9253
  async create(e) {
9229
9254
  await n.insert(Be).values({
@@ -9265,7 +9290,7 @@ function Uc(n) {
9265
9290
  };
9266
9291
  }
9267
9292
  const di = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Mn = di.length;
9268
- function zc() {
9293
+ function Fc() {
9269
9294
  let t = Date.now(), i = "";
9270
9295
  for (let r = 10; r > 0; r--)
9271
9296
  i = di.charAt(t % Mn) + i, t = Math.floor(t / Mn);
@@ -9284,7 +9309,7 @@ function Ti(n) {
9284
9309
  state_data: r,
9285
9310
  auth_params: l,
9286
9311
  ...d
9287
- } = n, u = Jt(
9312
+ } = n, u = Gt(
9288
9313
  { created_at_ts: t, updated_at_ts: i, expires_at_ts: a },
9289
9314
  ["created_at_ts", "updated_at_ts", "expires_at_ts"]
9290
9315
  ), f = {};
@@ -9298,12 +9323,12 @@ function Ti(n) {
9298
9323
  state_data: z(r)
9299
9324
  });
9300
9325
  }
9301
- function Fc(n) {
9326
+ function Pc(n) {
9302
9327
  return {
9303
9328
  async create(e, t) {
9304
9329
  var l, d;
9305
9330
  const i = Date.now(), r = {
9306
- id: zc(),
9331
+ id: Fc(),
9307
9332
  tenant_id: e,
9308
9333
  session_id: t.session_id,
9309
9334
  csrf_token: t.csrf_token,
@@ -9324,10 +9349,10 @@ function Fc(n) {
9324
9349
  updated_at_ts: i,
9325
9350
  expires_at_ts: t.expires_at ? ne(t.expires_at) : i + 1e3 * 60 * 60 * 24
9326
9351
  };
9327
- return await n.insert(J).values(r), Ti({ ...r, tenant_id: e });
9352
+ return await n.insert(G).values(r), Ti({ ...r, tenant_id: e });
9328
9353
  },
9329
9354
  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();
9355
+ 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
9356
  return a ? Ti(a) : null;
9332
9357
  },
9333
9358
  async update(e, t, i) {
@@ -9339,10 +9364,10 @@ function Fc(n) {
9339
9364
  0,
9340
9365
  1024
9341
9366
  )), 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(
9367
+ const u = await n.select({ auth_params: G.auth_params }).from(G).where(
9343
9368
  g(
9344
- c(J.tenant_id, e),
9345
- c(J.id, t)
9369
+ c(G.tenant_id, e),
9370
+ c(G.id, t)
9346
9371
  )
9347
9372
  ).get(), f = u != null && u.auth_params && typeof u.auth_params == "string" && u.auth_params.length > 0 ? JSON.parse(u.auth_params) : {};
9348
9373
  a.auth_params = JSON.stringify({
@@ -9350,13 +9375,13 @@ function Fc(n) {
9350
9375
  ...i.authParams
9351
9376
  });
9352
9377
  }
9353
- return await n.update(J).set(a).where(
9354
- g(c(J.tenant_id, e), c(J.id, t))
9378
+ return await n.update(G).set(a).where(
9379
+ g(c(G.tenant_id, e), c(G.id, t))
9355
9380
  ), !0;
9356
9381
  },
9357
9382
  async remove(e, t) {
9358
- return (await n.delete(J).where(
9359
- g(c(J.tenant_id, e), c(J.id, t))
9383
+ return (await n.delete(G).where(
9384
+ g(c(G.tenant_id, e), c(G.id, t))
9360
9385
  ).returning()).length > 0;
9361
9386
  }
9362
9387
  };
@@ -9391,7 +9416,7 @@ function qn(n) {
9391
9416
  continent_code: p
9392
9417
  })), K(S);
9393
9418
  }
9394
- function Pc(n) {
9419
+ function Mc(n) {
9395
9420
  return {
9396
9421
  async create(e, t) {
9397
9422
  var r, l;
@@ -9463,7 +9488,7 @@ function Pc(n) {
9463
9488
  };
9464
9489
  }
9465
9490
  const ci = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Bn = ci.length;
9466
- function Mc() {
9491
+ function qc() {
9467
9492
  let t = Date.now(), i = "";
9468
9493
  for (let r = 10; r > 0; r--)
9469
9494
  i = ci.charAt(t % Bn) + i, t = Math.floor(t / Bn);
@@ -9492,11 +9517,11 @@ function tn(n) {
9492
9517
  updated_at: si(i)
9493
9518
  });
9494
9519
  }
9495
- function qc(n) {
9520
+ function Bc(n) {
9496
9521
  return {
9497
9522
  async create(e, t) {
9498
9523
  const i = Date.now(), r = {
9499
- id: t.id || Mc(),
9524
+ id: t.id || qc(),
9500
9525
  tenant_id: e,
9501
9526
  user_id: t.user_id,
9502
9527
  type: t.type,
@@ -9567,7 +9592,7 @@ function qc(n) {
9567
9592
  }
9568
9593
  };
9569
9594
  }
9570
- function Bc() {
9595
+ function $c() {
9571
9596
  const { customAlphabet: n } = require("nanoid");
9572
9597
  return `org_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9573
9598
  }
@@ -9588,12 +9613,12 @@ function $n(n) {
9588
9613
  token_quota: z(r, {})
9589
9614
  });
9590
9615
  }
9591
- function $c(n) {
9616
+ function jc(n) {
9592
9617
  return {
9593
9618
  async create(e, t) {
9594
9619
  var l, d;
9595
9620
  const i = (/* @__PURE__ */ new Date()).toISOString(), r = {
9596
- id: t.id || Bc(),
9621
+ id: t.id || $c(),
9597
9622
  tenant_id: e,
9598
9623
  name: t.name,
9599
9624
  display_name: t.display_name,
@@ -9686,7 +9711,7 @@ function jn(n) {
9686
9711
  is_current: !!t
9687
9712
  };
9688
9713
  }
9689
- function jc(n) {
9714
+ function Vc(n) {
9690
9715
  return {
9691
9716
  async create(e, t) {
9692
9717
  const i = (/* @__PURE__ */ new Date()).toISOString(), a = t.id || Ie();
@@ -9746,7 +9771,7 @@ function jc(n) {
9746
9771
  }
9747
9772
  };
9748
9773
  }
9749
- function Vc(n) {
9774
+ function Zc(n) {
9750
9775
  return {
9751
9776
  async get(e) {
9752
9777
  const t = await n.select().from(It).where(c(It.tenant_id, e)).get();
@@ -9793,7 +9818,7 @@ function Vn(n) {
9793
9818
  resource_servers: u,
9794
9819
  rotating: f,
9795
9820
  ...p
9796
- } = n, v = Jt(
9821
+ } = n, v = Gt(
9797
9822
  {
9798
9823
  created_at_ts: t,
9799
9824
  expires_at_ts: i,
@@ -9817,10 +9842,10 @@ function Vn(n) {
9817
9842
  resource_servers: z(u, [])
9818
9843
  });
9819
9844
  }
9820
- function Zc(n, e) {
9845
+ function Hc(n, e) {
9821
9846
  return Math.max(n ?? 0, e ?? 0);
9822
9847
  }
9823
- function Hc(n) {
9848
+ function Kc(n) {
9824
9849
  return {
9825
9850
  async create(e, t) {
9826
9851
  const i = Date.now(), a = {
@@ -9840,18 +9865,18 @@ function Hc(n) {
9840
9865
  await n.run(A`BEGIN`);
9841
9866
  try {
9842
9867
  await n.insert(X).values(a);
9843
- const r = Zc(
9868
+ const r = Hc(
9844
9869
  a.expires_at_ts,
9845
9870
  a.idle_expires_at_ts
9846
9871
  );
9847
- r > 0 && a.login_id && await n.update(J).set({
9872
+ r > 0 && a.login_id && await n.update(G).set({
9848
9873
  expires_at_ts: r,
9849
9874
  updated_at_ts: i
9850
9875
  }).where(
9851
9876
  g(
9852
- c(J.tenant_id, e),
9853
- c(J.id, a.login_id),
9854
- Xe(J.expires_at_ts, r)
9877
+ c(G.tenant_id, e),
9878
+ c(G.id, a.login_id),
9879
+ Xe(G.expires_at_ts, r)
9855
9880
  )
9856
9881
  ), await n.run(A`COMMIT`);
9857
9882
  } catch (r) {
@@ -9874,14 +9899,14 @@ function Hc(n) {
9874
9899
  c(X.id, t)
9875
9900
  )
9876
9901
  ).returning();
9877
- return l != null && l.login_id && d && d > 0 && await n.update(J).set({
9902
+ return l != null && l.login_id && d && d > 0 && await n.update(G).set({
9878
9903
  expires_at_ts: d,
9879
9904
  updated_at_ts: Date.now()
9880
9905
  }).where(
9881
9906
  g(
9882
- c(J.tenant_id, e),
9883
- c(J.id, l.login_id),
9884
- Xe(J.expires_at_ts, d)
9907
+ c(G.tenant_id, e),
9908
+ c(G.id, l.login_id),
9909
+ Xe(G.expires_at_ts, d)
9885
9910
  )
9886
9911
  ).catch(() => {
9887
9912
  }), u.length > 0;
@@ -9934,7 +9959,7 @@ function Hc(n) {
9934
9959
  }
9935
9960
  };
9936
9961
  }
9937
- function Kc() {
9962
+ function Qc() {
9938
9963
  const { customAlphabet: n } = require("nanoid");
9939
9964
  return `api_${n("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
9940
9965
  }
@@ -9975,11 +10000,11 @@ function Zn(n) {
9975
10000
  l[u] !== void 0 && l[u] !== null && (d[u] = !!l[u]);
9976
10001
  return K(d);
9977
10002
  }
9978
- function Qc(n) {
10003
+ function Jc(n) {
9979
10004
  return {
9980
10005
  async create(e, t) {
9981
10006
  const i = (/* @__PURE__ */ new Date()).toISOString(), r = {
9982
- id: t.id || Kc(),
10007
+ id: t.id || Qc(),
9983
10008
  tenant_id: e,
9984
10009
  identifier: t.identifier,
9985
10010
  name: t.name,
@@ -10035,8 +10060,8 @@ function Qc(n) {
10035
10060
  if (d) {
10036
10061
  const ee = d.match(/^([^:]+):(.+)$/);
10037
10062
  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) {
10063
+ const [, ie, ae] = ee, Je = ie == null ? void 0 : ie.startsWith("-"), ut = Je ? ie == null ? void 0 : ie.substring(1) : ie;
10064
+ if (ut && Ai.has(ut) && !Je) {
10040
10065
  const vn = Y[ut];
10041
10066
  p.push(Nt(vn, `%${ae}%`));
10042
10067
  }
@@ -10135,7 +10160,7 @@ function Gc(n) {
10135
10160
  }
10136
10161
  };
10137
10162
  }
10138
- function Jc(n) {
10163
+ function Wc(n) {
10139
10164
  return {
10140
10165
  async create(e, t, i, a) {
10141
10166
  var r, l;
@@ -10203,7 +10228,7 @@ function Hn(n) {
10203
10228
  metadata: z(i)
10204
10229
  });
10205
10230
  }
10206
- function Wc(n) {
10231
+ function Xc(n) {
10207
10232
  return {
10208
10233
  async create(e, t) {
10209
10234
  const i = (/* @__PURE__ */ new Date()).toISOString(), r = {
@@ -10259,7 +10284,7 @@ function Wc(n) {
10259
10284
  }
10260
10285
  };
10261
10286
  }
10262
- const Xc = ["created_at_ts", "updated_at_ts"], Yc = [
10287
+ const Yc = ["created_at_ts", "updated_at_ts"], e_ = [
10263
10288
  "expires_at_ts",
10264
10289
  "idle_expires_at_ts",
10265
10290
  "authenticated_at_ts",
@@ -10281,7 +10306,7 @@ function Kn(n) {
10281
10306
  device: p,
10282
10307
  clients: v,
10283
10308
  ...m
10284
- } = n, S = Jt(
10309
+ } = n, S = Gt(
10285
10310
  {
10286
10311
  created_at_ts: t,
10287
10312
  updated_at_ts: i,
@@ -10292,8 +10317,8 @@ function Kn(n) {
10292
10317
  used_at_ts: u,
10293
10318
  revoked_at_ts: f
10294
10319
  },
10295
- [...Xc],
10296
- [...Yc]
10320
+ [...Yc],
10321
+ [...e_]
10297
10322
  );
10298
10323
  return K({
10299
10324
  ...m,
@@ -10302,7 +10327,7 @@ function Kn(n) {
10302
10327
  clients: z(v, [])
10303
10328
  });
10304
10329
  }
10305
- function e_(n) {
10330
+ function t_(n) {
10306
10331
  return {
10307
10332
  async create(e, t) {
10308
10333
  const i = Date.now(), a = {
@@ -10407,7 +10432,7 @@ function Ci(n) {
10407
10432
  n[t] !== void 0 && (e[t] = n[t] ? 1 : 0);
10408
10433
  return ar(e);
10409
10434
  }
10410
- function t_(n) {
10435
+ function n_(n) {
10411
10436
  return {
10412
10437
  async create(e) {
10413
10438
  var a, r;
@@ -10473,7 +10498,7 @@ function t_(n) {
10473
10498
  }
10474
10499
  };
10475
10500
  }
10476
- const n_ = [
10501
+ const i_ = [
10477
10502
  "colors",
10478
10503
  "borders",
10479
10504
  "fonts",
@@ -10481,10 +10506,10 @@ const n_ = [
10481
10506
  "widget"
10482
10507
  ];
10483
10508
  function Di(n) {
10484
- const { tenant_id: e, ...t } = n, i = or(t, n_);
10509
+ const { tenant_id: e, ...t } = n, i = or(t, i_);
10485
10510
  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
10511
  }
10487
- function i_(n) {
10512
+ function a_(n) {
10488
10513
  return {
10489
10514
  async create(e, t, i) {
10490
10515
  const a = (/* @__PURE__ */ new Date()).toISOString(), r = i || Ie(), d = {
@@ -10515,21 +10540,21 @@ function i_(n) {
10515
10540
  }
10516
10541
  };
10517
10542
  }
10518
- function a_(n) {
10543
+ function o_(n) {
10519
10544
  return {
10520
10545
  async get(e) {
10521
- const t = await n.select({ body: nt.body }).from(nt).where(c(nt.tenant_id, e)).get();
10546
+ const t = await n.select({ body: it.body }).from(it).where(c(it.tenant_id, e)).get();
10522
10547
  return t ? { body: t.body } : null;
10523
10548
  },
10524
10549
  async set(e, t) {
10525
10550
  const i = Date.now();
10526
- await n.insert(nt).values({
10551
+ await n.insert(it).values({
10527
10552
  tenant_id: e,
10528
10553
  body: t.body,
10529
10554
  created_at_ts: i,
10530
10555
  updated_at_ts: i
10531
10556
  }).onConflictDoUpdate({
10532
- target: nt.tenant_id,
10557
+ target: it.tenant_id,
10533
10558
  set: {
10534
10559
  body: t.body,
10535
10560
  updated_at_ts: i
@@ -10537,7 +10562,7 @@ function a_(n) {
10537
10562
  });
10538
10563
  },
10539
10564
  async delete(e) {
10540
- await n.delete(nt).where(c(nt.tenant_id, e));
10565
+ await n.delete(it).where(c(it.tenant_id, e));
10541
10566
  }
10542
10567
  };
10543
10568
  }
@@ -10579,7 +10604,7 @@ function Qn(n, e = []) {
10579
10604
  identities: [m, ...S]
10580
10605
  });
10581
10606
  }
10582
- function o_(n) {
10607
+ function r_(n) {
10583
10608
  const e = async (t, i) => {
10584
10609
  var d, u;
10585
10610
  const a = (/* @__PURE__ */ new Date()).toISOString(), r = {
@@ -10724,8 +10749,8 @@ function o_(n) {
10724
10749
  )
10725
10750
  ));
10726
10751
  const ee = m.map((ae) => {
10727
- const Ge = T.filter((ut) => ut.linked_to === ae.user_id);
10728
- return Qn(ae, Ge);
10752
+ const Je = T.filter((ut) => ut.linked_to === ae.user_id);
10753
+ return Qn(ae, Je);
10729
10754
  });
10730
10755
  if (!l)
10731
10756
  return { users: ee };
@@ -10776,7 +10801,7 @@ function o_(n) {
10776
10801
  }
10777
10802
  };
10778
10803
  }
10779
- function r_(n) {
10804
+ function s_(n) {
10780
10805
  return {
10781
10806
  async create(e, t, i, a) {
10782
10807
  var r, l;
@@ -10831,7 +10856,7 @@ function r_(n) {
10831
10856
  }
10832
10857
  };
10833
10858
  }
10834
- function s_(n) {
10859
+ function l_(n) {
10835
10860
  return {
10836
10861
  async create(e, t) {
10837
10862
  var u, f;
@@ -10925,10 +10950,10 @@ function s_(n) {
10925
10950
  metadata: ee,
10926
10951
  enabled_connections: ie,
10927
10952
  token_quota: ae,
10928
- ...Ge
10953
+ ...Je
10929
10954
  } = m;
10930
10955
  return K({
10931
- ...Ge,
10956
+ ...Je,
10932
10957
  branding: z(T, {}),
10933
10958
  metadata: z(ee, {}),
10934
10959
  enabled_connections: z(ie, []),
@@ -10961,8 +10986,8 @@ function s_(n) {
10961
10986
  }
10962
10987
  };
10963
10988
  }
10964
- const Ri = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], l_ = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
10965
- function d_(n) {
10989
+ const Ri = ["s", "seacft", "seccft", "sepft", "sertft", "ssa"], d_ = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
10990
+ function c_(n) {
10966
10991
  return {
10967
10992
  async getDaily(e, t) {
10968
10993
  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 +11001,7 @@ function d_(n) {
10976
11001
  "signups"
10977
11002
  ),
10978
11003
  leaked_passwords: A`SUM(CASE WHEN ${Q.type} IN (${A.join(
10979
- l_.map((d) => A`${d}`),
11004
+ d_.map((d) => A`${d}`),
10980
11005
  A`, `
10981
11006
  )}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
10982
11007
  }).from(Q).where(
@@ -11019,7 +11044,7 @@ function Ui(n) {
11019
11044
  payload: z(n.payload, {})
11020
11045
  };
11021
11046
  }
11022
- function c_(n) {
11047
+ function __(n) {
11023
11048
  return {
11024
11049
  async create(e, t) {
11025
11050
  const i = Ie(), a = (/* @__PURE__ */ new Date()).toISOString();
@@ -11161,10 +11186,10 @@ function c_(n) {
11161
11186
  }
11162
11187
  };
11163
11188
  }
11164
- const __ = 7 * 24 * 60 * 60 * 1e3;
11165
- function u_(n) {
11189
+ const u_ = 7 * 24 * 60 * 60 * 1e3;
11190
+ function p_(n) {
11166
11191
  return async (e) => {
11167
- const t = Date.now() - __;
11192
+ const t = Date.now() - u_;
11168
11193
  try {
11169
11194
  let i = [
11170
11195
  Ue(
@@ -11177,13 +11202,13 @@ function u_(n) {
11177
11202
  Xe(oe.expires_at_ts, t),
11178
11203
  Xe(oe.idle_expires_at_ts, t)
11179
11204
  )
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));
11205
+ ], 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
11206
  } catch (i) {
11182
11207
  console.error("Session cleanup error:", i);
11183
11208
  }
11184
11209
  };
11185
11210
  }
11186
- function h_(n, e = { useTransactions: !0 }) {
11211
+ function g_(n, e = { useTransactions: !0 }) {
11187
11212
  const t = {
11188
11213
  actions: $r(),
11189
11214
  branding: is(n),
@@ -11199,30 +11224,30 @@ function h_(n, e = { useTransactions: !0 }) {
11199
11224
  flows: kc(n),
11200
11225
  forms: Oc(n),
11201
11226
  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),
11227
+ hooks: Lc(n),
11228
+ invites: Uc(n),
11229
+ keys: zc(n),
11230
+ loginSessions: Pc(n),
11231
+ logs: Mc(n),
11232
+ authenticationMethods: Bc(n),
11233
+ organizations: jc(n),
11234
+ passwords: Vc(n),
11235
+ promptSettings: Zc(n),
11236
+ refreshTokens: Kc(n),
11237
+ resourceServers: Jc(n),
11213
11238
  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),
11239
+ userPermissions: Wc(n),
11240
+ roles: Xc(n),
11241
+ sessions: t_(n),
11242
+ sessionCleanup: p_(n),
11243
+ tenants: n_(n),
11244
+ themes: a_(n),
11245
+ universalLoginTemplates: o_(n),
11246
+ users: r_(n),
11247
+ userRoles: s_(n),
11248
+ userOrganizations: l_(n),
11249
+ stats: c_(n),
11250
+ outbox: __(n),
11226
11251
  async transaction(i) {
11227
11252
  if (e.useTransactions === !1)
11228
11253
  return i(t);
@@ -11238,6 +11263,6 @@ function h_(n, e = { useTransactions: !0 }) {
11238
11263
  return t;
11239
11264
  }
11240
11265
  export {
11241
- h_ as default,
11242
- f_ as sqlite
11266
+ g_ as default,
11267
+ h_ as sqlite
11243
11268
  };