SessionService
import { SessionService } from "@skipcheck/tm1-client"; Server sessions: every session logged in to the server (/Sessions), this one's
(ActiveSession), their users and threads, and closing another session.
To close this client's own session, close the Tm1Session or Tm1Client:
it sends ActiveSession/tm1.Close, and knows not to log in again. A closed
session stays listed in Sessions for a few seconds (5 to 9 in TM1 11.8).
List who's logged in, expanding each session's user:
// Every session on the server, with its user's name and its label
const withUsers = ODataQuery.none()
.select(Session.Fields.ID, Session.Fields.Context)
.expand(Session.Fields.User, (user) => user.select(User.Fields.Name));
const sessions = await tm1.sessions.list(withUsers).toArray();
return sessions.map((session) => `${session.ID} ${session.User?.Name} ${session.Context}`);
Close other clients' sessions by their label, sparing this one:
// Close the sessions labelled "Nightly load", except this client's own
const own = (await tm1.sessions.activeSession(ODataQuery.none().select(Session.Fields.ID))).ID;
const labelled = ODataQuery.none().select(Session.Fields.ID).filter(Session.Fields.Context.eq("Nightly load"));
for await (const session of tm1.sessions.list(labelled)) {
if (session.ID !== own) await tm1.sessions.close(session.ID!);
}
Members
list | GET Sessions, streamed. |
get | The session, or a Tm1NotFoundException if there's none. |
activeSession | This client's own session on the server. |
user | The session's user. |
threads | GET Sessions(id)/Threads, streamed. |
close | Ends another session; its client must log in again. |
list
list(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Session>GET Sessions, streamed: every session on the server, for an admin. Expand User or Threads with the query.
TM1 REST EntitySet Sessions
get
get(id: number, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Session>GET Sessions(id): the session, or a Tm1NotFoundException if there's none.
TM1 REST EntitySet Sessions
activeSession
activeSession(query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Session>GET ActiveSession: this client's own session on the server.
TM1 REST Singleton ActiveSession
user
user(id: number, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<User>GET Sessions(id)/User: the session's user.
TM1 REST Navigation Session/User
threads
threads(id: number, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Thread>GET Sessions(id)/Threads, streamed: what the session is running now.
TM1 REST Navigation Session/Threads
close
close(id: number, options?: Tm1CallOptions): Promise<void>tm1.Close: ends another session; its client must log in again. Needs schema 10.2.2.5.
TM1 REST Action Session/Close