OpenFolia

Save a template file’s working copy

PUT
/change-sets/{changeSetId}/page-design-templates/{templateId}/files/working-copy

Autosave: stores the editor’s content as the change set’s working copy (Postgres), without a commit and without an audit event; a save point commits it later. The shape is checked (400 otherwise); validation issues come back in meta.issues without refusing it, since a draft may be incomplete. Send meta.version: the version last read or saved (0 for none yet); the answer has the next one. Send meta.baseCommit: the commit the content is based on. Only the change set’s author works on its working copies (403 for anyone else who holds content.read.draft; for anyone else another author’s change set is 404, exactly like a missing one). Needs the change set to be a draft holding the subject’s lock, and the content.edit permission covering the content (and the committed file). A text file of a page design’s own template (#396), templates/<templateId>/<path>: like a page design, it needs content.edit through a role whose scope restricts nothing (it lays out every manual whose design names the template). The content is the file’s whole text, at most 256 KiB as UTF-8; a path no file has yet makes a new one (manual.typ a new template) at the save point. Whether the template compiles is not checked here: the template’s preview (GET /page-design-templates/{templateId}/preview/pages/{page}.png) shows it, and the change set’s checks hold a broken one (page-design-template-error). Deleting a file is a save point’s deletes.

Authorization

bearer
headerAuthorizationBearer <JWT>

A service account's token (ccms_sat_…, issued by POST /service-accounts/{id}/tokens), or, for local use and demo mode, the server's shared CCMS_API_TOKEN.

Path Parameters

changeSetId*string

The change set’s ID (a UUID). One that names no change set, malformed or not, is 404.

Formatuuid
templateId*string
Match^[a-z0-9]+(?:-[a-z0-9]+)*$
Lengthlength <= 100

Query Parameters

path*string

The file’s path in the template’s folder (templates/<templateId>/<path>): names of letters, digits, _, - and . joined by /, none starting with ., at most 8 deep and 150 characters, ending in a text file’s extension (.typ, .yaml, .yml, .json, .toml, .csv, .txt, .xml, .svg, .bib). Any other path is 404, never a file outside the folder.

Lengthlength <= 1000

Header Parameters

X-Ccms-User?string

Demo mode only (CCMS_AUTH_MODE=demo): the user ID to act as. The bearer token is still required; without demo mode the header is refused (400).

Request Body

application/vnd.api+json
  1. body
data*
meta*

Response Body

Saved, at its new version.

application/vnd.api+json
  1. response
data*

id is <changeSetId>/module/<lang>/<moduleId>, <changeSetId>/manual/<manualId>, <changeSetId>/config, <changeSetId>/term/<termId>, <changeSetId>/design/<designId> or <changeSetId>/template/<templateId>/<path>.

Example Request
curl -X PUT 'http://localhost:3000/change-sets/497f6eca-6276-4993-bfeb-53cbbbba6f08/page-design-templates/house/files/working-copy?path=parts%2Fnotice.typ' \  -H 'Content-Type: application/vnd.api+json' \  -d '{  "data": {    "type": "WorkingCopy",    "attributes": {      "content": {        "schemaVersion": 1,        "text": "string"      }    }  },  "meta": {    "version": 0,    "baseCommit": "string"  }}'
Example Response
{  "data": {    "type": "WorkingCopy",    "id": "string",    "attributes": {      "subject": {        "type": "module",        "lang": "string",        "moduleId": "string"      },      "content": {        "schemaVersion": 1,        "text": "string"      },      "version": 0,      "baseCommit": "string",      "updatedBy": {        "kind": "user",        "id": "string"      },      "updatedAt": "2019-08-24T14:15:22Z"    },    "relationships": {      "changeSet": {        "data": {          "type": "ChangeSet",          "id": "string"        }      }    },    "meta": {      "saved": true,      "issues": [        {          "severity": "error",          "code": "string",          "message": "string",          "at": "string"        }      ]    }  }}