skipcheck

TM1 client · Docs · The client

Tm1Request

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

One TM1 REST call, described but not sent: the method, path, query, headers and body, and how to read the response.

Every service method is built on one of these. The same request can be sent on its own (the service's ordinary methods do that) or added to a $batch, so anything the client can do one request at a time, it can also batch. Requests are immutable.

// A cube's name, read as plain JSON
const cube = Tm1Request.get(ODataPath.of("Cubes").key("Sales"), ODataQuery.none().select("Name"));
// An action with no answer
const reserve = Tm1Request.post(ODataPath.of("Cubes").key("Sales").action("tm1.Reserve"), {});

Members

method propertyThe HTTP method.
path propertyThe resource path, relative to the service root.
query propertyThe query options, possibly ODataQuery.none.
headers propertyThe headers this request adds, in the order they were added.
body propertyThe body, serialized as JSON when sent, or null for none.
response propertyHow the response body is read.
type propertyWhat reads the answer (Java's Class<T>); undefined reads JSON as is.
timeout propertyHow long to wait for the answer, in milliseconds, instead of the session's request timeout.
get staticGET of one entity or value, read as type.
list staticGET of a collection, read item by item as itemType.
bytes staticGET of raw bytes, such as a document's Content.
put staticPUT of raw bytes, such as a document's content.
text staticGET of plain text, such as Configuration/ProductVersion/$value.
postList staticPOST whose response is a collection, read item by item as itemType.
post staticPOST, reading the answer as type; with no type, reading nothing (Mono<Void>).
patch staticChange the properties in body, leaving the rest as they are.
delete staticDELETE of the entity at path.
isIdempotentMethod static@internal GET, PUT, DELETE and HEAD.
withQueryA copy with these query options instead.
withHeaderA copy with a header added or replaced, such as If-Match.
withTimeout@param timeout milliseconds
requiresThe request, checked against the server's $metadata before it's sent.
requirementWhat the server must define for the request, if anything.
ifMatchA copy sent with If-Match.
isIdempotentWhether sending the request again does what sending it once did (GET, PUT, DELETE, HEAD), so it may be retried after a response was lost.
relativeUriThe path and query, relative to the service root.
accept@internal
toStringMETHOD relative-uri, unencoded, for logs.

method

property
method: string

The HTTP method.

path

property
path: ODataPath

The resource path, relative to the service root.

query

property
query: ODataQuery

The query options, possibly ODataQuery.none.

headers

property
headers: Readonly<Record<string, string>>

The headers this request adds, in the order they were added.

body

property
body: unknown

The body, serialized as JSON when sent, or null for none.

response

property
response: Tm1Response

How the response body is read.

type

property
type: Tm1Model<T> | undefined

What reads the answer (Java's Class<T>); undefined reads JSON as is.

timeout

property
timeout: number | undefined

How long to wait for the answer, in milliseconds, instead of the session's request timeout.

get

static
static get<T = unknown>(path: ODataPath, query?: ODataQuery | null, type?: Tm1Model<T>): Tm1Request<T>

GET of one entity or value, read as type.

list

static
static list<T = unknown>(path: ODataPath, query?: ODataQuery | null, itemType?: Tm1Model<T>): Tm1Request<T>

GET of a collection, read item by item as itemType.

bytes

static
static bytes(path: ODataPath): Tm1Request<Uint8Array>

GET of raw bytes, such as a document's Content.

put

static
static put(path: ODataPath, content: Uint8Array, contentType = "application/octet-stream"): Tm1Request<void>

PUT of raw bytes, such as a document's content.

text

static
static text(path: ODataPath): Tm1Request<string>

GET of plain text, such as Configuration/ProductVersion/$value.

postList

static
static postList<T = unknown>(path: ODataPath, body: unknown, itemType?: Tm1Model<T>): Tm1Request<T>

POST whose response is a collection, read item by item as itemType: an action returning Collection(...), such as tm1.CheckRules. The body is the parameters, written as JSON.

post

static
static post<T = void>(path: ODataPath, body?: unknown, type?: Tm1Model<T>): Tm1Request<T>

POST, reading the answer as type; with no type, reading nothing (Mono<Void>).

patch

static
static patch(path: ODataPath, body: unknown): Tm1Request<void>

PATCH: change the properties in body, leaving the rest as they are.

delete

static
static delete(path: ODataPath): Tm1Request<void>

DELETE of the entity at path.

isIdempotentMethod

static
static isIdempotentMethod(method: string): boolean

@internal GET, PUT, DELETE and HEAD: sending one again does what sending it once did.

withQuery

withQuery(query: ODataQuery | null | undefined): Tm1Request<T>

A copy with these query options instead.

withHeader

withHeader(name: string, value: string): Tm1Request<T>

A copy with a header added or replaced, such as If-Match.

withTimeout

withTimeout(timeout: number): Tm1Request<T>

@param timeout milliseconds

requires

requires(capability: Tm1Capability): Tm1Request<T>

The request, checked against the server's $metadata before it's sent.

requirement

requirement(): Tm1Capability | undefined

What the server must define for the request, if anything.

ifMatch

ifMatch(etag: string): Tm1Request<T>

A copy sent with If-Match: etag, failing with 412 if the entity has changed since.

isIdempotent

isIdempotent(): boolean

Whether sending the request again does what sending it once did (GET, PUT, DELETE, HEAD), so it may be retried after a response was lost.

relativeUri

relativeUri(): string

The path and query, relative to the service root.

accept

accept(): string

@internal

toString

toString(): string

METHOD relative-uri, unencoded, for logs.