SandboxService
import { SandboxService } from "@skipcheck/tm1-client";Sandboxes: private copies of the data a user writes to before publishing. They belong to the user the session is for.
Reading and writing in a sandbox go through a session view:
Tm1Session.withSandbox or Tm1Client.withSandbox, which add TM1's
!sandbox option to every request. This service manages the sandboxes
themselves.
Create a sandbox, write to it, and publish the changes to base data:
// Write to a new sandbox, leaving base data alone until the changes are published
const cell = { Version: "Budget", Region: "North", Month: "Jan", Measure: "Revenue" };
await tm1.sandboxes.create(SandboxPatch.builder().name("What If").build());
await tm1.withSandbox("What If").cells.update("Sales", cell, 1500);
await tm1.sandboxes.publish("What If");
Read a cell in base data and in a sandbox:
// The same cell read in base data and in a sandbox: the same query, through a client
// for each
const mdx =
"SELECT {[Month].[Month].[Jan]} ON 0, {[Region].[Region].[North]} ON 1 FROM [Sales]" +
" WHERE ([Version].[Version].[Budget], [Measure].[Measure].[Revenue])";
const values = ODataQuery.none().select(CellsetCell.Fields.Value);
const first = (client: Tm1Client): Promise<unknown> => client.cellsets.stream(mdx, values, 1, (_cellset, cells) => cells.map((cell) => cell.Value)).first();
const [base, whatIf] = await Promise.all([first(tm1), first(tm1.withSandbox("What If"))]);
return `base ${String(base)}, what-if ${String(whatIf)}`;
Members
list | GET Sandboxes, streamed. |
get | The sandbox, or a Tm1NotFoundException if there's none. |
create | Creates an empty sandbox; it needs a name. |
update | Changes the properties the patch sets, such as IncludeInSandboxDimension. |
delete | DELETE Sandboxes('name'), with its unpublished changes. |
load | Loads the sandbox into memory. |
unload | Frees the sandbox's memory, keeping its changes. |
discardChanges | Throws away the sandbox's changes, keeping the sandbox. |
publish | Writes the sandbox's changes to base data; with conflicts, what to do with cells changed in base data since, whether to wait for a lock rather than fail (allowQueueing), and whether to empty the sandbox once published (cleanAfter). |
publish | tm1.Publish, saying what to do with cells changed in base data since (conflicts), whether to wait for a lock rather than fail (allowQueueing), and whether to empty the sandbox once published (cleanAfter). |
publish | |
merge | Copies the sandbox's changes into the sandbox target; with conflicts, what to do with cells the target changed too, whether to wait for a lock rather than fail (allowQueueing), and whether to empty this sandbox once merged (cleanAfter). |
merge | tm1.Merge, saying what to do with cells the target changed too (conflicts), whether to wait for a lock rather than fail (allowQueueing), and whether to empty this sandbox once merged (cleanAfter). |
merge |
list
list(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Sandbox>GET Sandboxes, streamed: the session user's sandboxes.
TM1 REST EntitySet Sandboxes
get
get(name: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Sandbox>GET Sandboxes('name'): the sandbox, or a Tm1NotFoundException if there's none.
TM1 REST EntitySet Sandboxes
create
create(sandbox: SandboxPatch, options?: Tm1CallOptions): Promise<Sandbox>POST Sandboxes: creates an empty sandbox; it needs a name. Returns the sandbox as created.
TM1 REST EntitySet Sandboxes
update
update(name: string, patch: SandboxPatch, options?: Tm1CallOptions): Promise<void>PATCH Sandboxes('name'): changes the properties the patch sets, such as IncludeInSandboxDimension.
TM1 REST EntitySet Sandboxes
delete
delete(name: string, options?: Tm1CallOptions): Promise<void>DELETE Sandboxes('name'), with its unpublished changes.
TM1 REST EntitySet Sandboxes
load
load(name: string, options?: Tm1CallOptions): Promise<void>tm1.Load: loads the sandbox into memory.
TM1 REST Action Sandbox/Load
unload
unload(name: string, options?: Tm1CallOptions): Promise<void>tm1.Unload: frees the sandbox's memory, keeping its changes.
TM1 REST Action Sandbox/Unload
discardChanges
discardChanges(name: string, options?: Tm1CallOptions): Promise<void>tm1.DiscardChanges: throws away the sandbox's changes, keeping the sandbox.
TM1 REST Action Sandbox/DiscardChanges
publish
publish(name: string, options?: Tm1CallOptions): Promise<void>tm1.Publish: writes the sandbox's changes to base data; with conflicts, what to do with cells changed in base data since, whether to wait for a lock rather than fail (allowQueueing), and whether to empty the sandbox once published (cleanAfter).
TM1 REST Action Sandbox/Publish
publish
publish(name: string, conflicts: ConflictResolution, allowQueueing: boolean, cleanAfter: boolean, options?: Tm1CallOptions): Promise<void>tm1.Publish, saying what to do with cells changed in base data since (conflicts), whether to wait for a lock rather than fail (allowQueueing), and whether to empty the sandbox once published (cleanAfter).
TM1 REST Action Sandbox/Publish
publish
publish( name: string, conflicts?: ConflictResolution | Tm1CallOptions, allowQueueing?: boolean, cleanAfter?: boolean, options?: Tm1CallOptions, ): Promise<void>TM1 REST Action Sandbox/Publish
merge
merge(name: string, target: string, options?: Tm1CallOptions): Promise<void>tm1.Merge: copies the sandbox's changes into the sandbox target; with conflicts, what to do with cells the target changed too, whether to wait for a lock rather than fail (allowQueueing), and whether to empty this sandbox once merged (cleanAfter).
TM1 REST Action Sandbox/Merge
merge
merge(name: string, target: string, conflicts: ConflictResolution, allowQueueing: boolean, cleanAfter: boolean, options?: Tm1CallOptions): Promise<void>tm1.Merge, saying what to do with cells the target changed too (conflicts), whether to wait for a lock rather than fail (allowQueueing), and whether to empty this sandbox once merged (cleanAfter).
TM1 REST Action Sandbox/Merge
merge
merge( name: string, target: string, conflicts?: ConflictResolution | Tm1CallOptions, allowQueueing?: boolean, cleanAfter?: boolean, options?: Tm1CallOptions, ): Promise<void>TM1 REST Action Sandbox/Merge