@adcp/sdk API Reference - v7.9.0
    Preparing search index...

    Function enforceMapCap

    • Reject new entries when map has reached cap. Use inside TestControllerStore methods before .set() on any Map that accumulates per-session state (account statuses, media-buy states, simulated deliveries). Existing keys are allowed to overwrite — only net-new keys are rejected at the cap.

      Rejects via TestControllerError with code INVALID_STATE, which the dispatcher converts to a typed ControllerError response. The caller gets a clear "clear the session or reuse an existing id" error rather than silent LRU eviction that would make compliance tests nondeterministic.

      Type Parameters

      • V

      Parameters

      • map: Map<string, V>
      • key: string
      • label: string

        Human-readable plural noun used in the error message ("account statuses", "media buy states"). Intended to be a caller-controlled string literal; defensively truncated to 64 chars and stripped of non-printable characters before interpolation so user-controlled input can't spam logs.

      • cap: number = SESSION_ENTRY_CAP

      Returns void

      async forceAccountStatus(accountId, status) {
      enforceMapCap(session.accountStatuses, accountId, 'account statuses');
      const prev = session.accountStatuses.get(accountId) ?? 'active';
      session.accountStatuses.set(accountId, status);
      return { success: true, previous_state: prev, current_state: status };
      }