Migrating from 3.x
The rule
Every method now calls exactly one API generation, and its name says which:
- an unsuffixed method calls v2;
- a method ending in
V1calls v1; - a method ending in
V3calls one of the few v3 routes.
Methods no longer take an apiVersion argument.
What to check
Most 3.x code keeps working: old call shapes are recognised, warn once, and go to the generation they always used. What breaks silently is a call whose name stayed the same while the generation behind it changed, because the response shape differs. Search your code for those first; they are the first table below.
Also:
- Node 20.19 or newer, Bun, or a current browser. The package is ES modules only;
require()still works on Node 20.19+ and 22.12+. - Some handlers need an import.
session.workflow,session.webreportsandsession.rhcore/rpcClient()- the 3.x handlers outside the core - each need their module imported once:import "@ulyxie/cs-rest/workflow","@ulyxie/cs-rest/webreports","@ulyxie/cs-rest/rpc".RPCClient,RPCErrorandisRPCErrormoved to@ulyxie/cs-rest/rpc. Without the import the getter throws an error naming it. See Modules. - No axios. Requests go through Node's own
httpin Node andfetchin Bun and browsers. Responses are still{ data, status, statusText, headers }, and errors still carryerror.response.status/.data, but they areHTTPErrors, notAxiosErrors.session.axiosis gone; anhttpsAgentbecomes theagentoption, and Transports covers proxies or keeping axios. - Binary responses:
"arraybuffer"now gives anArrayBufferin Node as well (Buffer.from(data)if you need a Buffer), and"stream"a webReadableStream(Readable.fromWeb(data)for a Node stream). response.datais unchanged. Normalised methods addresponse.result, which you can move to at your own pace; see Normalised Results.- The new workflow methods (
createDraft,updateDraft,forms.draftProcessUpdateV1) resolve with the full response. The 3.x names they replace still resolve with the body. - Where only the id moved, as with
addDocument,response.result.idreads it from either generation.
Breaking and deprecated calls
Only calls whose name stayed the same while their API generation changed break silently - the response shape differs. Everything else either keeps working with a once-per-method deprecation warning, or fails loudly.
| 3.x call | 4.0.0 behaviour | To keep the 3.x behaviour |
|---|---|---|
nodes.delete(id) |
calls v2 (was v1) | nodes.deleteV1(id) |
nodes.addDocument({...}) |
calls v2 (was v1); new id at data.results.data.properties.id, not data.id |
nodes.addDocumentV1({...}) |
versions.list(id) |
calls v2 (was v1) | versions.listV1(id) |
volumes.volumeInfo(type) |
calls v2 (was v1) | volumes.volumeInfoV1(type) |
volumes.browse(type, "v1"), volumeInfo(type, "v2"), volumes("v1") |
the apiVersion argument is gone; the second argument is now params |
browseV1 / volumeInfoV1 / volumesV1 |
Still working, with a deprecation warning (3.x call shapes are detected and dispatched to the generation they always used):
| 3.x | Replacement |
|---|---|
nodes.node({ dataid, apiVersion, params }) |
nodes.node(id, params) / nodeV1 |
nodes.audit({ dataid, apiVersion, params }) |
nodes.audit(id, params) / auditV1 |
nodes.download({ dataid, apiVersion, filePath }) |
nodes.download(id, filePath) / downloadV1 |
nodes.nodes(id, params) |
nodes.children(id, params) |
nodes.ancestors(id) |
nodes.ancestorsV1(id) |
nodes.addablenodetypes(id) |
nodes.addableTypesV1(id) |
nodes.volumeInfo(type) / nodes.volumes() |
volumes.volumeInfoV1(type) / volumes.volumes() |
versions.addVersion({ dataid, fileHandler, options }) |
versions.add(id, file, fields) / addV1 |
versions.download({ dataid, version, filePath }) |
versions.download(id, n, filePath) / downloadV1 |
versions.version(id), version(id, "latest") |
versions.latestV1(id) |
versions.promote({ dataid, versionNumber, description }) |
versions.promote(id, n, { description }) |
versions.deleteVersion({ dataid, versionNumber, apiVersion }) |
versions.delete(id, n) / deleteV1 |
versions.purge({ dataid, number_to_keep }) |
versions.purge(id, numberToKeep) |
members.userQuery(query, options, version) |
members.search({ query, where_type }) / searchV1 |
members.member(id, "v1" | "v2") |
members.member(id) / memberV1(id) |
search.regions(params) |
search.regionsV1(params) |
auth.auth() |
auth.currentUserV1() |
webreports.run(id, params) |
webreports.runV1(id, params) |
workflow.draftprocesses(id) |
workflow.createDraft(id) (resolves with the full response) |
workflow.draftprocessesUpdate(id) |
forms.draftProcessUpdateV1(id) (resolves with the full response) |
workflow.draftprocessesPut(id, body) |
workflow.updateDraft(id, body) (resolves with the full response) |
Bugs fixed on the way
These change behaviour, for the better, and are worth knowing if you worked around them:
- Uploads from a Buffer. In Node, only a file path uploaded correctly: a
Buffer was sent without a filename, so Content Server did not treat it as a
file, and a
FileorBlobthrew. Uploads now accept a path, aFile/Blob, or{ data, name }- the last being the form for a Buffer - and stream a path from disk instead of reading it into memory. versions.purge()ignorednumber_to_keep. It was sent through a helper that drops DELETE parameters, so the server default always applied. It is now sent in the query string, where the spec puts it.Session.deleteForm()dropped its parameters - the cause of the purge bug above, and public API in its own right. They are now sent in the query string.deleteBody()consequently sends?body=...instead of nothing.search.regions()never sent its filters. It passed them as the axios config instead of as query parameters.regionsV1()sends them.- Booleans in form fields made Node's
form-datathrow, and were counted as zero bytes inContent-Length. They are now sent as"true"/"false". - Every overloaded method was typed
Promise<any>in the declarations (nodes.node(),nodes.audit(),members.member(),versions.purge(),versions.promote()). They now carry their real response types.
cs-rest 4.0.0
Using it
Working on it