@truenas/api-client
    Preparing search index...

    Class VersionDiscovery

    Discovers available API versions from TrueNAS systems.

    Performs a fetch GET to the /api/versions endpoint and:

    • Parses version strings
    • Filters to compatible versions (within MIN/MAX range)
    • Selects the latest compatible version
    • Caches results per hostname
    • Classifies failures into typed VersionDiscoveryError subclasses

    This is the framework-agnostic replacement for the app's Angular HttpClient service. Because fetch resolves (rather than rejects) on non-2xx responses and throws a TypeError on network/CORS/unreachable failures, the error contract differs from the original: a network/CORS/unreachable failure surfaces as a VersionDiscoveryNetworkError — the sentinel the client factory keys on for its CORS fallback (replacing the old HttpErrorResponse.status === 0 check).

    Index
    • Clears the version cache for a specific hostname or all hostnames.

      Parameters

      • Optionalhostname: string

        Optional hostname to clear. If omitted, clears all cached versions.

      Returns void

    • Discovers the API version for a given hostname.

      Makes a GET request to https://{hostname}/api/versions and returns the latest compatible version. Results are cached per hostname; the cache entry is removed on failure so the next call retries.

      Parameters

      • hostname: string

        The TrueNAS system hostname (e.g., "truenas.local")

      Returns Observable<ApiVersion>

      Observable that emits the selected ApiVersion

      VersionDiscoveryError subclasses for specific failure scenarios