ChangeSetService
import { ChangeSetService } from "@skipcheck/tm1-client";Change sets: groups of cell writes that can be undone together.
A write joins a change set through TM1's !ChangeSet query option, which a
session view from Tm1Session.withChangeSet adds to every request
($metadata doesn't say how; TM1 11.8 does it this way). within does it
all: begins a change set, gives the work a session that records into it, and ends it
however the work finishes.
Make some writes in a change set, keeping its ID:
// Record some writes in a change set, and keep its ID to undo them later
const cell = { Version: "Forecast", Region: "North", Month: "Jan", Measure: "Revenue" };
const id = await tm1.changeSets
.within(async (session) => {
await Tm1Client.of(session).cells.update("Sales", cell, 1500);
return session.changeSet();
})
.first();
return id!;
Undo them later:
// Revert every write recorded in the change set; writes outside it stay
return tm1.changeSets.undo(changeSet);
Members
begin | Starts a change set, and gives its ID, for Tm1Session.withChangeSet. |
end | Stops recording into a change set; it can still be undone. |
undo | Reverts every write recorded in a change set. |
within | Runs work in a new change set. |
begin
begin(options?: Tm1CallOptions): Promise<string>BeginChangeSet: starts a change set, and gives its ID, for Tm1Session.withChangeSet. Needs schema 10.2.2.6.
TM1 REST ActionImport BeginChangeSet
end
end(id: string, options?: Tm1CallOptions): Promise<number>EndChangeSet: stops recording into a change set; it can still be undone. Gives TM1's return code. Needs schema 10.2.2.6.
TM1 REST ActionImport EndChangeSet
undo
undo(id: string, options?: Tm1CallOptions): Promise<void>UndoChangeSet: reverts every write recorded in a change set. Needs schema 10.2.2.6.
TM1 REST ActionImport UndoChangeSet
within
within<R>(work: (session: Tm1Session) => Tm1Work<R>, options?: Tm1CallOptions): Tm1Stream<R>Runs work in a new change set: begins it, gives the work a view of the session that records into it (session.changeSet() has the ID, for a later undo), and ends it when the work completes, fails or is abandoned. Streamed, as Java's Flux: nothing runs until it's iterated (await …toArray()), and it gives what the work gives, item by item.
// Record some writes in a change set, and keep its ID to undo them later
const cell = { Version: "Forecast", Region: "North", Month: "Jan", Measure: "Revenue" };
const id = await tm1.changeSets
.within(async (session) => {
await Tm1Client.of(session).cells.update("Sales", cell, 1500);
return session.changeSet();
})
.first();
return id!;TM1 REST ActionImport BeginChangeSet ActionImport EndChangeSet