@odla-ai/chapter 0.33.0 → 0.33.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.
@@ -499,7 +499,16 @@ function asStored(row) {
499
499
  if (!row || typeof row.document !== "object" || row.document === null) return null;
500
500
  return row;
501
501
  }
502
+ async function hasSignupControl(db, targetId, environment, active) {
503
+ const where = { targetId, environment, ...active ? { active: true } : {} };
504
+ if (db.aggregate) {
505
+ return Number((await db.aggregate("signupControls", { count: true }, { where })).count ?? 0) > 0;
506
+ }
507
+ const rows2 = (await db.query({ signupControls: {} })).signupControls;
508
+ return Array.isArray(rows2) && rows2.some((row) => row.targetId === targetId && row.environment === environment && (!active || row.active === true));
509
+ }
502
510
  async function loadLatestSignupControl(db, targetId, environment) {
511
+ if (!await hasSignupControl(db, targetId, environment)) return null;
503
512
  const rows2 = (await db.query({ signupControls: { $: {
504
513
  where: { targetId, environment },
505
514
  order: { revision: "desc" },
@@ -509,6 +518,7 @@ async function loadLatestSignupControl(db, targetId, environment) {
509
518
  return asStored(latest);
510
519
  }
511
520
  async function loadActiveSignupControl(db, targetId, environment) {
521
+ if (!await hasSignupControl(db, targetId, environment, true)) return null;
512
522
  const rows2 = (await db.query({ signupControls: { $: {
513
523
  where: { targetId, environment, active: true },
514
524
  order: { revision: "desc" },