Table of contents
Classic UI
@ulyxie/cs-rest/classic adds session.classic: what Content Server's REST API cannot do, done through its Classic UI's own HTML form handlers, the way a browser does it. New in 4.1.0.
import { Session } from "@ulyxie/cs-rest";
import "@ulyxie/cs-rest/classic";
const draft = await session.classic.editCategory(categoryId);
await draft.addAttribute({ type: "textPopup", name: "Status", values: ["Open", "Closed"], required: true });
await draft.save(); // a new version of the category
await session.classic.upgradeCategoryItems(categoryId); // every item onto it
Caveats
- Unofficial. These are form handlers, not an API. OpenText does not document them and they can change with any update. Everything here was checked on 26.1. Version gating does not apply: no spec lists them.
- Node and Bun only. The Classic pages accept the session's ticket only as the
LLCookiecookie, never theOTCSTicketheader, and a browser does not let a script set a cookie. In a browser every method throws aClassicErrorsaying so. - Errors are
ClassicError. The pages report errors as ordinary 200 pages; the module recognises them and throws with the server's reason and Request ID (error.details.requestId). A redirect to sign-in also throws. - Permissions apply as in the UI. Editing a category needs Modify on it, and it must not be reserved by someone else; the Facets volume needs the rights the Classic UI asks for.
- Use REST for what REST does: create a category with
nodes.create({ type: 131, parent_id, name }), read its definition withforms.categoryCreateFormV1, upgrade one item withcategories.upgrade, read a container's columns withnodes.columns, and delete what this module creates withnodes.delete. Columns, facets, facet trees and facet folders skip the Recycle Bin. The server refuses to delete a facet that a facet tree uses, and a category that items still carry.
Categories
The Classic editor never edits a category directly. It works on a cached copy on the server (a CacheID) and writes it back as a new version; nothing is visible to users until then.
| Method | Does |
|---|---|
editCategory(id) |
Opens a CategoryDraft |
draft.attributes() |
The working copy's attributes: { id, name, type, parentId } (parentId 1 = top level; attributes inside a set carry the set's id and no type label) |
draft.addAttribute(spec) |
Adds one and resolves with its id |
draft.updateAttribute(id, changes) |
Changes its settings (not its type) |
draft.removeAttribute(id) |
Removes it (a set with everything in it) |
draft.save({ defaults }) |
Writes the copy as a new version; defaults sets single-value default values by attribute id |
categoryAttributeTypes(id) |
The types the editor offers: { type, label } |
upgradeCategoryItems(id) |
Moves every item on an older version to the current one: { items, upgraded, skipped } |
addAttribute takes type by name or id, and name; everything else is optional and left as the server's form serves it:
| Type name | Id | Type-specific options |
|---|---|---|
text |
-1 | length, displayLength, multilingual |
textPopup |
10 | values |
textMultiline |
11 | lines, columns |
textTableKeyLookup |
10013 | through fields |
textReference |
11481 | through fields |
integer |
2 | |
integerPopup |
12 | values |
date |
-7 | time |
datePopup |
13 | values are not supported: add it, then set them in the editor |
dateCalendar |
10058 | currentDate |
checkbox |
5 | |
user |
14 | groups |
ou, signer |
11480, 101 | through fields |
set, partnerSet |
-18, 10146 | children are added with parentId: <set id> |
Common options: parentId, description, required, showInSearch, rows: { initial, max, fixed }, position. fields sets any other form field by name.
Popup values: a Text popup posts an OScript list ({'A','B'}); a value containing ' is written double-quoted, and one containing both quote characters is refused. An Integer popup takes one value per line.
The upgrade starts the same server-side batch as the Classic "Upgrade Items" page and repeats its step until the server reports it complete; each step handles up to 200 items.
Columns
A column is a Column node (type 902) in a Facet Folder (905) of the Facets volume, showing a data source: a category attribute (attr_<category id>_<attribute id>), a system field (sys_*), or a module's field.
| Method | Does |
|---|---|
columnDataSources(facetFolderId) |
The data sources available: { value, label } |
createColumn(facetFolderId, { name, dataSource, sortable?, description? }) |
Creates one and resolves with its id. It is "Not available" until registered |
columnSettings(id) / updateColumnSettings(id, changes) |
Width, alignment, long-text mode, link (URL, display value, title, new window) |
setContainerColumns(containerId, { columns, cascade?, sort? }) |
The columns a container shows, in order; cascade pushes some to its sub-containers; sort is { column, ascending }. Only columns available there can be shown. Read the state with REST nodes.columns |
Facets
| Method | Does |
|---|---|
facetDataSources(facetFolderId) |
The data sources a facet can use |
createFacet(facetFolderId, { name, dataSource, description?, classificationId? }) |
A Facet (904) |
facetSettings(id) / updateFacetSettings(id, changes) |
Enabled, hide-less-than, items to show, display mode, priority, count accuracy, "show text in More" |
createFacetTree(facetFolderId, name) |
A Facet Tree (903): a named arrangement of facets |
facetTree(id) / setFacetTree(id, tree) |
Its definition: [{ facetId, children: [...] }], and the facets it can use |
createFacetFolder(parentId, name) |
A Facet Folder (905) in the Facets volume or another facet folder |
Registering
A column or a facet tree is used where it is available:
| Method | Does |
|---|---|
availability(id) |
{ mode: "none" | "global" | "specific", locations: [{ id, path }] } |
setAvailability(id, "none" | "global" | { locations: [...] }) |
Registers it nowhere, everywhere, or in the given containers and below |
How it works
- Every request goes to
<cgi>?func=...with the ticket asLLCookie(core'sticketCookierequest option) and redirects returned rather than followed (redirect: "manual"). A handler answers a successful submit with a redirect. - Writes carry a
secureRequestTokenfrom?func=ll.GetRequestToken, fetched once per Session and refetched once if the server refuses it. - Forms are read from the served page with a small regex reader (
src/classic/html.ts) and posted as the browser would: urlencoded, or multipart for the create forms. Most pages need anextURL, which the module always sends. - A create answers with a bare redirect, so the new object's id is found by name in its parent through REST.
The endpoint inventory behind this module is in specs/unofficial-ui-endpoints/.
cs-rest 4.0.0
Using it
Working on it