Version Gating
Content Server gains endpoints with each release. Calling one that an older server lacks usually fails with an unhelpful error. With gating, the client refuses the call before sending it and names the release the endpoint arrived in.
Gating is opt-in. Without version or detectVersion, a session gates nothing and behaves as 3.x did.
Telling the session its release
import { Session, CSVersion, isUnsupportedOperationError } from "@ulyxie/cs-rest";
const session = new Session({
baseUrl: "https://server/otcs/cs.exe",
otcsticket: "<token>",
version: CSVersion.V22_1, // or "22.1"
});
try {
await session.volumes.recycleBin();
} catch (e) {
if (isUnsupportedOperationError(e)) {
// [cs-rest] GET /v2/volumes/recyclebin/nodes is not available on
// Content Server 22.1: it arrived in 22.4.
e.operation; // "GET /v2/volumes/recyclebin/nodes"
e.version; // "22.1"
e.since; // "22.4"
e.removedAfter; // set when the endpoint was later dropped
}
}
Known releases: 20.3, 20.4, 21.1, 21.3, 21.4, 22.1 - 22.4, 23.1, 23.3, 23.4, 24.1 - 24.4, 25.1 - 25.4, 26.1 and 26.2. OpenText published no spec for 21.2 or 23.2.
Asking the server
const session = new Session({ baseUrl, otcsticket, detectVersion: true });
await session.resolveVersion(); // e.g. "26.1"
session.version; // the same, once resolved
- Detection costs one
GET /v1/serverinfo, made once and cached. - Every handler call waits for it, so calling
resolveVersion()yourself is optional. - It never rejects. If the server cannot be read, the session keeps the
versionit was given (or"latest") and warns. - If you also set
version, that value is used until detection completes, and as the fallback if it fails.
Whenever detection changes what you are gated against, it warns:
| Situation | What happens |
|---|---|
| Server reports a release with no spec (21.2, 23.2) | Gated as the nearest known release below it |
| Server is newer than 26.2 | Gated as 26.2; endpoints added later pass unchecked |
Server disagrees with a version you configured |
The server wins, and the warning names both. Pass detectVersion: false to keep yours |
| Server predates 20.3 | Cannot be placed; gating stays as configured |
Checking before calling
if (session.supports("GET /v2/volumes/recyclebin/nodes")) {
// ...
}
Write the operation as "METHOD /path", with the path templated the way the spec writes it and no /api prefix.
How far to trust it
sinceis a lower bound. It comes from the published specs. An endpoint first documented in 23.3 may have shipped in 23.2, which has no spec.- Unknown means allowed. An endpoint no spec documents is never refused. Gating guards against endpoints known to be missing; it is not an allowlist.
- Dropped from the docs is not removed. An endpoint the specs stop documenting is refused on later releases, unless the live 26.1 route list shows the server still serves it. Two such endpoints, both dropped after 20.4, are allowed for that reason.
- Specs are not servers. A documented endpoint can still be refused for permissions, licensing or configuration.
Binary fallback
versions.content(), contentAs() and download() fall back to v1 on releases before 23.1, where v2 has no version content. Only binary content falls back. JSON responses differ between generations, so falling back there would change what the method returns.
cs-rest 4.0.0
Using it
Working on it