skipcheck

TM1 client · Docs · More services

ContentService

import { ContentService } from "@skipcheck/tm1-client";

The contents tree, where Planning Analytics keeps applications: folders, documents, links, and references to cubes, dimensions, subsets, views, processes and chores. Entries are addressed by ContentPath.

What TM1 (11.8) does here that you might not expect:

  • Entries are found by ID, not Name (see ContentPath).
  • A document made in an application becomes a DocumentReference there, to a Document TM1 makes in Blobs with a timestamp in its name, such as notes_20261122125939.txt. Its content goes through the reference (content, upload). A copy of the reference refers to the same document; deleting a reference leaves the document while another refers to it.
  • Entries can't be changed: TM1 refuses a PATCH ("PATCH not supported on this resource"), so there's no update. To rename one, copy it with a new name and delete the original.

Build an application: a folder, a link and a cube reference:

// An application: a folder with a link and a reference to a cube
const planning = ContentPath.applications().child("Planning");
await tm1.contents.create(ContentPath.applications(), ContentScope.Public, FolderPatch.builder().name("Planning").build());
await tm1.contents.create(planning, ContentScope.Public, LinkPatch.builder().name("Guide").url("https://example.com/planning-guide").build());
const sales = CubeReferencePatch.builder().name("Sales").bindCube(ODataPath.of("Cubes").key("Sales")).build();
return tm1.contents.create(planning, ContentScope.Public, sales);

Upload a document from a file:

// A document made in an application is a reference to one TM1 keeps in Blobs; the
// reference, as create returns it, is where its content goes
const planning = ContentPath.applications().child("Planning");
const reference = await tm1.contents.create(planning, ContentScope.Public, DocumentPatch.builder().name("notes.txt").build());
// TM1 refuses a chunked upload, so the content is sent whole
await tm1.contents.upload(planning.child(reference), await readFile(file));

Download a document's content to a file:

// Streamed to the file, never held whole
const notes = ContentPath.applications().child("Planning").child("notes.txt.blob");
await pipeline(tm1.contents.content(notes), createWriteStream(file));

List the cubes an application refers to:

// The cubes an application refers to, by a cast expand
const planning = ContentPath.applications().child("Planning");
const names: string[] = [];
for await (const entry of tm1.contents.contents(planning, ContentScope.Public, ODataQuery.none().expand("tm1.CubeReference/Cube($select=Name)"))) {
  const cube = typeOf(Entry, entry) === "CubeReference" ? (entry as CubeReference).Cube : undefined;
  if (cube?.Name) names.push(cube.Name);
}
return names;

Members

rootsGET Contents, streamed.
getGET of one entry, of its own kind (Folder, Link, CubeReference ….
contentsA folder's public or private entries, streamed, each of its own kind.
createMakes an entry in a folder, public or private.
deleteDELETE of an entry, and everything in it if it's a folder.
containedByThe folder an entry is in.
localizedAttributesLocalizedAttributes, streamed.
copyCopies an entry into a folder, public or private, named name or, with none, as the entry.
moveMoves an entry into a folder, public or private, renamed name if given; returns the entry where it is now.
documentThe document a reference refers to, in Blobs, with its Size and LastUpdated.
contentA document's Content, as chunks of bytes.
uploadReplaces a document's Content.

roots

roots(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Entry>

GET Contents, streamed: the root folders, Applications and Blobs.

TM1 REST EntitySet Contents

get

get(entry: ContentPath, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Entry>

GET of one entry, of its own kind (Folder, Link, CubeReference …: see typeOf), or a Tm1NotFoundException if there's none. A reference's object comes by a cast expand, such as expand("tm1.CubeReference/Cube").

TM1 REST EntitySet Contents

contents

contents(folder: ContentPath, scope: ContentScope, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Entry>

A folder's public or private entries, streamed, each of its own kind. References' objects come by a cast expand, such as expand("tm1.CubeReference/Cube($select=Name)").

create

create(folder: ContentPath, scope: ContentScope, entry: EntryPatch, options?: Tm1CallOptions): Promise<Entry>

Makes an entry in a folder, public or private: a FolderPatch, DocumentPatch, LinkPatch or a reference, such as a CubeReferencePatch with bindCube(ODataPath.of("Cubes").key("Sales")). A document made outside Blobs comes back as a DocumentReference, with an empty document behind it; upload gives it content. Returns the entry as made, with the ID to find it by.

TM1 REST Navigation Folder/Contents Navigation Folder/PrivateContents

delete

delete(entry: ContentPath, options?: Tm1CallOptions): Promise<void>

DELETE of an entry, and everything in it if it's a folder.

TM1 REST EntitySet Contents

containedBy

containedBy(entry: ContentPath, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Folder>

ContainedBy: the folder an entry is in.

TM1 REST Navigation Entry/ContainedBy

localizedAttributes

localizedAttributes(entry: ContentPath, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<LocalizedAttributes>

LocalizedAttributes, streamed: an entry's attributes in each locale.

TM1 REST Navigation Entry/LocalizedAttributes

copy

copy(entry: ContentPath, target: ContentPath, scope: ContentScope, name?: string | null, options?: Tm1CallOptions): Promise<Entry>

tm1.Copy: copies an entry into a folder, public or private, named name or, with none, as the entry. A copied document reference refers to the same document.

TM1 REST Action Entry/Copy

move

move(entry: ContentPath, target: ContentPath, scope: ContentScope, name?: string | null, options?: Tm1CallOptions): Promise<Entry>

tm1.Move: moves an entry into a folder, public or private, renamed name if given; returns the entry where it is now.

TM1 REST Action Entry/Move

document

document(reference: ContentPath, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Document>

Document: the document a reference refers to, in Blobs, with its Size and LastUpdated.

TM1 REST Navigation DocumentReference/Document

content

content(document: ContentPath, options?: Tm1CallOptions): Tm1Stream<Uint8Array>

A document's Content, as chunks of bytes. The path is a document reference, or a document in Blobs. Nothing is sent until it's iterated; each iteration sends it again.

TM1 REST Navigation DocumentReference/Document

upload

upload(document: ContentPath, content: ContentSource, options?: Tm1CallOptions): Promise<void>

Replaces a document's Content. The path is a document reference, or a document in Blobs. TM1 (11.8) refuses a chunked upload, so the content is gathered and sent with its length: it's held in memory whole while it's sent (and so can be sent again if the session has to log in again).

TM1 REST Navigation DocumentReference/Document