DimensionService
import { DimensionService } from "@skipcheck/tm1-client";Used in the walkthrough Test your code against a real TM1.
Dimensions: /Dimensions and the operations bound to a dimension.
A dimension's hierarchies, elements and subsets have services of their own.
List dimensions with a query: here, the names of the model dimensions.
// The names of the model dimensions, in name order
const dimensions = await tm1.dimensions.modelDimensions(ODataQuery.none().select(Dimension.Fields.Name).orderBy(Dimension.Fields.Name)).toArray();
return dimensions.map((dimension) => dimension.Name!);
Create a dimension with its hierarchy, elements and edges in one request:
// Region, with one hierarchy of the same name: Total = North + South
const total = ElementPatch.builder().name("Total").type(ElementType.Consolidated).build();
const north = ElementPatch.builder().name("North").type(ElementType.Numeric).build();
const south = ElementPatch.builder().name("South").type(ElementType.Numeric).build();
const region = HierarchyPatch.builder()
.name("Region")
.elements([total, north, south])
.edges([
EdgePatch.builder().parentName("Total").componentName("North").weight(1).build(),
EdgePatch.builder().parentName("Total").componentName("South").weight(1).build(),
])
.build();
return tm1.dimensions.create(DimensionPatch.builder().name("Region").hierarchies([region]).build());
Read a dimension with its hierarchies expanded:
// A dimension with its hierarchies' names expanded in the same request
const withHierarchies = ODataQuery.none().expand(Dimension.Fields.Hierarchies, (h) => h.select(Hierarchy.Fields.Name));
const region = await tm1.dimensions.get("Region", withHierarchies);
return (region.Hierarchies ?? []).map((hierarchy) => hierarchy.Name!);
Members
list | Every dimension, control dimensions included, streamed. |
modelDimensions | The dimensions that aren't control dimensions (whose names start with }), streamed. |
controlDimensions | The control dimensions, such as }Clients, streamed. |
get | The dimension, or a Tm1NotFoundException if there's none. |
create | Creates a dimension, with its hierarchies, elements and edges if the patch has them (a deep insert). |
update | Changes the properties the patch sets. |
delete | DELETE Dimensions('name'). |
saveAs | Copies a dimension under a new name, failing if one exists; returns the copy. |
saveAs | Copies a dimension under a new name; overwrite replaces a dimension that already has it, and keepExistingAttributes, when overwriting, keeps the attributes of what's replaced (when not, true creates no attributes for the copy). |
saveAs | |
addAllLeavesHierarchy | Adds a hierarchy of all the dimension's leaves, named Leaves and not visible, which makes it a multi-hierarchy dimension; returns the new hierarchy. |
addAllLeavesHierarchy | Adds a hierarchy of all the dimension's leaves, named hierarchyName, visible or not, which makes it a multi-hierarchy dimension. |
addAllLeavesHierarchy | |
lock | Stops everyone else changing the dimension until it's unlocked. |
unlock | tm1.Unlock. |
reserve | Stops everyone else changing the dimension until it's released. |
release | tm1.Release. |
list
list(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Dimension>GET Dimensions: every dimension, control dimensions included, streamed.
TM1 REST EntitySet Dimensions
modelDimensions
modelDimensions(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Dimension>ModelDimensions(): the dimensions that aren't control dimensions (whose names start with }), streamed.
TM1 REST FunctionImport ModelDimensions
controlDimensions
controlDimensions(query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Dimension>ControlDimensions(): the control dimensions, such as }Clients, streamed.
TM1 REST FunctionImport ControlDimensions
get
get(name: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Dimension>GET Dimensions('name'): the dimension, or a Tm1NotFoundException if there's none.
TM1 REST EntitySet Dimensions
create
create(dimension: DimensionPatch, options?: Tm1CallOptions): Promise<Dimension>POST Dimensions: creates a dimension, with its hierarchies, elements and edges if the patch has them (a deep insert). It needs a name; returns the dimension as created.
TM1 REST EntitySet Dimensions
update
update(name: string, patch: DimensionPatch, etag?: string | null, options?: Tm1CallOptions): Promise<void>PATCH Dimensions('name'): changes the properties the patch sets. With etag (dimension["@odata.etag"], from a read), sent as If-Match: only if the dimension hasn't changed since, else a Tm1PreconditionFailedException. TM1 (11.8) accepts Hierarchies and AllLeavesHierarchyName in a dimension PATCH and ignores them: change hierarchies through their own service, and add an all-leaves hierarchy with addAllLeavesHierarchy.
TM1 REST EntitySet Dimensions
delete
delete(name: string, options?: Tm1CallOptions): Promise<void>DELETE Dimensions('name').
TM1 REST EntitySet Dimensions
saveAs
saveAs(name: string, newName: string, options?: Tm1CallOptions): Promise<Dimension>tm1.SaveAs: copies a dimension under a new name, failing if one exists; returns the copy.
TM1 REST Action Dimension/SaveAs
saveAs
saveAs(name: string, newName: string, overwrite: boolean, keepExistingAttributes: boolean, options?: Tm1CallOptions): Promise<Dimension>tm1.SaveAs: copies a dimension under a new name; overwrite replaces a dimension that already has it, and keepExistingAttributes, when overwriting, keeps the attributes of what's replaced (when not, true creates no attributes for the copy). Returns the copy.
TM1 REST Action Dimension/SaveAs
saveAs
saveAs(name: string, newName: string, overwrite?: boolean | Tm1CallOptions, keepExistingAttributes?: boolean, options?: Tm1CallOptions): Promise<Dimension>TM1 REST Action Dimension/SaveAs
addAllLeavesHierarchy
addAllLeavesHierarchy(name: string, options?: Tm1CallOptions): Promise<Hierarchy>tm1.AddAllLeavesHierarchy: adds a hierarchy of all the dimension's leaves, named Leaves and not visible, which makes it a multi-hierarchy dimension; returns the new hierarchy.
TM1 REST Action Dimension/AddAllLeavesHierarchy
addAllLeavesHierarchy
addAllLeavesHierarchy(name: string, hierarchyName: string, visible: boolean, options?: Tm1CallOptions): Promise<Hierarchy>tm1.AddAllLeavesHierarchy: adds a hierarchy of all the dimension's leaves, named hierarchyName, visible or not, which makes it a multi-hierarchy dimension.
TM1 REST Action Dimension/AddAllLeavesHierarchy
addAllLeavesHierarchy
addAllLeavesHierarchy(name: string, hierarchyName?: string | Tm1CallOptions, visible?: boolean, options?: Tm1CallOptions): Promise<Hierarchy>TM1 REST Action Dimension/AddAllLeavesHierarchy
lock
lock(name: string, options?: Tm1CallOptions): Promise<void>tm1.Lock: stops everyone else changing the dimension until it's unlocked.
TM1 REST Action Dimension/Lock
unlock
unlock(name: string, options?: Tm1CallOptions): Promise<void>tm1.Unlock.
TM1 REST Action Dimension/Unlock
reserve
reserve(name: string, options?: Tm1CallOptions): Promise<void>tm1.Reserve: stops everyone else changing the dimension until it's released. Needs schema 11.8.34.
TM1 REST Action Dimension/Reserve
release
release(name: string, options?: Tm1CallOptions): Promise<void>tm1.Release. Needs schema 11.8.34.
TM1 REST Action Dimension/Release