skipcheck

TM1 client · Docs · Sessions and logins

Tm1SessionBuilder

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

Builds a Tm1Session. Only baseUrl and credentials are required.

Members

baseUrlThe service root, such as http://localhost:8010/api/v1/.
addressThe server's address, such as http://tm1:8010.
dialectThe kind of deployment, for address.
basicAuthBasic authentication, for TM1 security modes 1 and 2.
authenticatorHow to log in.
impersonateLogs in as the service account but acts as user (TM1-Impersonate).
withoutImpersonationLogs in as the credentials' own user.
sessionContextA label TM1 shows for the session (TM1-SessionContext, sent with the login), such as the application's name.
timeoutsTimeouts by kind of work; Tm1Timeouts.DEFAULTS unless set.
errorClassifierHow error responses are classified; Tm1ErrorClassifier.defaults unless set.
transportWhat sends the requests (Java's webClient and connector).
checkCapabilitiesWhether requests check the server's $metadata for what they need.
clockThe clock refused logins are timed by, in milliseconds (for tests).
copyA copy of these settings, for a pool to build one session per identity.
baseUrlOrUnset@internal The service root, or a placeholder if it isn't set yet, for the pool's messages.
buildThe session.

baseUrl

baseUrl(baseUrl: string): this

The service root, such as http://localhost:8010/api/v1/: an absolute URL with no query or fragment. A missing trailing / is added.

Throws

RangeError if baseUrl isn't absolute or has a query or fragment

address

address(address: string): this

The server's address, such as http://tm1:8010: its scheme, host and HTTP port. The service root comes from the dialect, Tm1Dialect.V11 unless set (before this), which adds /api/v1/. Use baseUrl to give the service root itself.

Throws

RangeError if the address doesn't fit the dialect

dialect

dialect(dialect: Tm1Dialect): this

The kind of deployment, for address: Tm1Dialect.V11 unless set.

basicAuth

basicAuth(user: string, password?: string | null): this

Basic authentication, for TM1 security modes 1 and 2: shorthand for authenticator(Tm1Authenticator.basic(user, password)). A null password counts as empty.

authenticator

authenticator(authenticator: Tm1Authenticator): this

How to log in: TM1's own security, CAM, or credentials of your own. Asked for credentials on every login.

impersonate

impersonate(user: string): this

Logs in as the service account but acts as user (TM1-Impersonate). TM1 matches the name ignoring case and spaces. A name with characters outside ASCII goes out as UTF-8, which is how TM1 (11.8) reads the header: the value is handed to fetch as one character for each UTF-8 byte, which Node's fetch and, by the Fetch standard, a browser's send as those bytes. A custom Tm1Transport must send each character of a header value as one byte, as fetch does.

Throws

RangeError if user is blank, which TM1 would take as no impersonation at all, or has a control character

withoutImpersonation

withoutImpersonation(): this

Logs in as the credentials' own user: no impersonation.

sessionContext

sessionContext(sessionContext: string): this

A label TM1 shows for the session (TM1-SessionContext, sent with the login), such as the application's name: in TM1's thread and session lists and its audit log. At most 250 characters, which is all TM1 keeps. It goes out as UTF-8, as TM1 reads it.

timeouts

timeouts(timeouts: Tm1Timeouts): this

Timeouts by kind of work; Tm1Timeouts.DEFAULTS unless set.

errorClassifier

errorClassifier(classifier: Tm1ErrorClassifier): this

How error responses are classified; Tm1ErrorClassifier.defaults unless set.

transport

transport(transport: Tm1Transport): this

What sends the requests (Java's webClient and connector): fetchTransport by default.

checkCapabilities

checkCapabilities(check: boolean): this

Whether requests check the server's $metadata for what they need.

clock

clock(clock: () => number): this

The clock refused logins are timed by, in milliseconds (for tests).

copy

copy(): Tm1SessionBuilder

A copy of these settings, for a pool to build one session per identity.

baseUrlOrUnset

baseUrlOrUnset(): string

@internal The service root, or a placeholder if it isn't set yet, for the pool's messages.

build

build(): Tm1Session

The session. Nothing is sent to TM1 until the first request. @throws Error if the base URL or credentials aren't set