@authhero/kysely-adapter 12.5.0 → 12.5.1

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.
@@ -6456,14 +6456,23 @@ async function xs(e) {
6456
6456
  //#endregion
6457
6457
  //#region migrate/migrations/2026-08-21T12:00:00_refresh_token_session_id_backfill.ts
6458
6458
  var Ss = /* @__PURE__ */ w({
6459
- down: () => Es,
6460
- up: () => Ts
6461
- }), Cs = 500, ws = 20;
6462
- async function Ts(e) {
6459
+ down: () => Os,
6460
+ up: () => Ds
6461
+ }), Cs = 500, ws = 20, Ts = 500, Es = "packages/kysely/migrate/data-migrations/refresh-token-session-id-backfill.sql";
6462
+ async function Ds(e) {
6463
6463
  try {
6464
- let t = 0;
6464
+ let t = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select((e) => e.fn.countAll().as("count")).executeTakeFirst(), n = Number(t?.count ?? 0);
6465
+ if (n > Ts) {
6466
+ Q(`refresh_tokens backfill: ${n} rows in scope, above the in-process limit of ${Ts}. SKIPPING — run the bulk path instead: ${Es}. This must be completed before login_sessions retention is enabled, or the auth-event facts are lost for good.`);
6467
+ return;
6468
+ }
6469
+ if (n === 0) {
6470
+ Z("refresh_tokens backfill: nothing to do");
6471
+ return;
6472
+ }
6473
+ let r = 0;
6465
6474
  for (;;) {
6466
- let n = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select([
6475
+ let t = await e.selectFrom("refresh_tokens").innerJoin("login_sessions", "login_sessions.id", "refresh_tokens.login_id").whereRef("login_sessions.tenant_id", "=", "refresh_tokens.tenant_id").where("refresh_tokens.session_id", "is", null).where("login_sessions.session_id", "is not", null).select([
6467
6476
  "refresh_tokens.id as id",
6468
6477
  "refresh_tokens.tenant_id as tenant_id",
6469
6478
  "login_sessions.session_id as ls_session_id",
@@ -6472,9 +6481,9 @@ async function Ts(e) {
6472
6481
  "login_sessions.auth_strategy_strategy_type as ls_strategy_type",
6473
6482
  "login_sessions.auth_params as ls_auth_params"
6474
6483
  ]).limit(Cs).execute();
6475
- if (n.length === 0) break;
6476
- for (let t = 0; t < n.length; t += ws) {
6477
- let r = n.slice(t, t + ws);
6484
+ if (t.length === 0) break;
6485
+ for (let n = 0; n < t.length; n += ws) {
6486
+ let r = t.slice(n, n + ws);
6478
6487
  await Promise.all(r.map(async (t) => {
6479
6488
  let n = null;
6480
6489
  if (t.ls_auth_params) try {
@@ -6491,17 +6500,17 @@ async function Ts(e) {
6491
6500
  }).where("tenant_id", "=", t.tenant_id).where("id", "=", t.id).execute();
6492
6501
  }));
6493
6502
  }
6494
- if (t += n.length, Z(`refresh_tokens backfill: ${t} rows populated so far`), n.length < Cs) break;
6503
+ if (r += t.length, Z(`refresh_tokens backfill: ${r} rows populated so far`), t.length < Cs) break;
6495
6504
  }
6496
- Z(`refresh_tokens backfill: done, ${t} rows updated`);
6505
+ Z(`refresh_tokens backfill: done, ${r} rows updated`);
6497
6506
  } catch (e) {
6498
6507
  throw Q("refresh_tokens backfill failed:", e), e;
6499
6508
  }
6500
6509
  }
6501
- async function Es() {}
6510
+ async function Os() {}
6502
6511
  //#endregion
6503
6512
  //#region migrate/migrations/index.ts
6504
- var Ds = {
6513
+ var ks = {
6505
6514
  "2026-07-16T14:00:00_baseline": ko,
6506
6515
  "2026-07-16T15:00:00_codes_expires_at_ts": Io,
6507
6516
  "2026-08-04T12:00:00_scim_inbound_provisioning": qo,
@@ -6514,21 +6523,21 @@ var Ds = {
6514
6523
  };
6515
6524
  //#endregion
6516
6525
  //#region migrate/migrate.ts
6517
- async function Os(e, t = !1) {
6526
+ async function As(e, t = !1) {
6518
6527
  Fo(t), t && console.log("migrating...");
6519
6528
  let { error: n, results: r } = await new be({
6520
6529
  db: e,
6521
- provider: new Oo(Ds)
6530
+ provider: new Oo(ks)
6522
6531
  }).migrateToLatest();
6523
6532
  if (r?.forEach((e) => {
6524
6533
  e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was executed successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
6525
6534
  }), n) throw console.error("failed to migrate"), console.error(n), n;
6526
6535
  }
6527
- async function ks(e, t = !1) {
6536
+ async function js(e, t = !1) {
6528
6537
  Fo(t), t && console.log("migrating...");
6529
6538
  let { error: n, results: r } = await new be({
6530
6539
  db: e,
6531
- provider: new Oo(Ds)
6540
+ provider: new Oo(ks)
6532
6541
  }).migrateDown();
6533
6542
  if (r?.forEach((e) => {
6534
6543
  e.status === "Success" ? t && console.log(`migration "${e.migrationName}" was reverted successfully`) : e.status === "Error" && console.error(`failed to execute migration "${e.migrationName}"`);
@@ -6536,7 +6545,7 @@ async function ks(e, t = !1) {
6536
6545
  }
6537
6546
  //#endregion
6538
6547
  //#region src/index.ts
6539
- function As(e, t = { useTransactions: !0 }) {
6548
+ function Ms(e, t = { useTransactions: !0 }) {
6540
6549
  let n = {
6541
6550
  actions: Be(e),
6542
6551
  actionExecutions: Ke(e),
@@ -6593,7 +6602,7 @@ function As(e, t = { useTransactions: !0 }) {
6593
6602
  analytics: ja(e),
6594
6603
  outbox: Ya(e),
6595
6604
  async transaction(r) {
6596
- return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(As(e, {
6605
+ return t.useTransactions === !1 ? r(n) : e.transaction().execute(async (e) => r(Ms(e, {
6597
6606
  ...t,
6598
6607
  useTransactions: !1
6599
6608
  })));
@@ -6602,4 +6611,4 @@ function As(e, t = { useTransactions: !0 }) {
6602
6611
  return n;
6603
6612
  }
6604
6613
  //#endregion
6605
- export { to as createProxyDataAdapter, J as createProxyRoutesAdapter, As as default, ks as migrateDown, Os as migrateToLatest };
6614
+ export { to as createProxyDataAdapter, J as createProxyRoutesAdapter, Ms as default, js as migrateDown, As as migrateToLatest };