@ffschrattenecker/tm1-mcp-server 7.0.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -1
- package/README.md +5 -5
- package/dist/config.js +34 -17
- package/dist/connections.d.ts +18 -1
- package/dist/connections.js +34 -18
- package/dist/http-transport.js +51 -4
- package/dist/lib/callgraph/referenceIndex.js +2 -1
- package/dist/lib/callgraph/rulesLinter.d.ts +0 -19
- package/dist/lib/callgraph/rulesLinter.js +0 -590
- package/dist/lib/callgraph/tiParser.js +10 -5
- package/dist/lib/callgraph/tm1-adapter.d.ts +5 -1
- package/dist/lib/callgraph/tm1-adapter.js +41 -9
- package/dist/lib/callgraph/variableEnv.js +3 -2
- package/dist/lib/cell-address.d.ts +1 -1
- package/dist/lib/cell-address.js +2 -2
- package/dist/lib/complexity/antipatterns.js +3 -1
- package/dist/lib/complexity/comment-classifier.js +2 -1
- package/dist/lib/feeders/element-type-cache.js +4 -6
- package/dist/lib/naming/odata-filter.js +2 -1
- package/dist/lib/pro-parser.js +13 -4
- package/dist/lib/safe-regex.d.ts +0 -13
- package/dist/lib/safe-regex.js +40 -13
- package/dist/lib/ti-identifier.d.ts +11 -0
- package/dist/lib/ti-identifier.js +11 -0
- package/dist/lib/tm1-name.d.ts +9 -0
- package/dist/lib/tm1-name.js +9 -0
- package/dist/lib/v12-compat/deprecated-ti.js +2 -2
- package/dist/session-manager.d.ts +1 -0
- package/dist/session-manager.js +24 -0
- package/dist/tm1-client/connection/profile.js +2 -4
- package/dist/tm1-client/dispatcher.d.ts +1 -1
- package/dist/tm1-client/dispatcher.js +18 -6
- package/dist/tm1-client/http.d.ts +21 -0
- package/dist/tm1-client/http.js +39 -30
- package/dist/tm1-client/services/cell-service.d.ts +9 -7
- package/dist/tm1-client/services/cell-service.js +51 -25
- package/dist/tm1-client/services/chore-service.js +8 -9
- package/dist/tm1-client/services/cube-service.d.ts +14 -18
- package/dist/tm1-client/services/cube-service.js +51 -45
- package/dist/tm1-client/services/dimension-order.d.ts +13 -0
- package/dist/tm1-client/services/dimension-order.js +42 -0
- package/dist/tm1-client/services/dimension-service.js +4 -6
- package/dist/tm1-client/services/element-service.d.ts +35 -11
- package/dist/tm1-client/services/element-service.js +124 -60
- package/dist/tm1-client/services/file-service.d.ts +42 -6
- package/dist/tm1-client/services/file-service.js +225 -28
- package/dist/tm1-client/services/hierarchy-service.d.ts +19 -9
- package/dist/tm1-client/services/hierarchy-service.js +118 -12
- package/dist/tm1-client/services/monitoring-service.js +2 -5
- package/dist/tm1-client/services/odata-page.d.ts +6 -0
- package/dist/tm1-client/services/odata-page.js +8 -0
- package/dist/tm1-client/services/process-service.d.ts +1 -1
- package/dist/tm1-client/services/process-service.js +26 -26
- package/dist/tm1-client/services/security-service.js +8 -9
- package/dist/tm1-client/services/server-service.js +14 -15
- package/dist/tm1-client/services/subset-service.d.ts +23 -10
- package/dist/tm1-client/services/subset-service.js +82 -26
- package/dist/tm1-client/services/view-service.js +12 -13
- package/dist/tm1-client.js +5 -2
- package/dist/tools/analysis/check-v12-readiness.js +3 -3
- package/dist/tools/celldata/check-feeders.js +6 -6
- package/dist/tools/celldata/check-writable-coords.js +33 -22
- package/dist/tools/celldata/execute-mdx.js +10 -9
- package/dist/tools/celldata/get-view.js +10 -9
- package/dist/tools/celldata/member-ref.d.ts +15 -0
- package/dist/tools/celldata/member-ref.js +67 -0
- package/dist/tools/celldata/trace-cell-calculation.js +6 -6
- package/dist/tools/celldata/trace-feeders.js +6 -6
- package/dist/tools/celldata/write-cells.js +62 -12
- package/dist/tools/dimension-management/create-element-attribute.js +1 -1
- package/dist/tools/dimension-management/delete-hierarchy.js +3 -4
- package/dist/tools/dimension-management/get-element-attribute-values.js +7 -2
- package/dist/tools/dimension-management/list-element-attributes.js +1 -1
- package/dist/tools/dimension-management/update-element-attribute-value.js +8 -3
- package/dist/tools/dimension-management/update-element.js +14 -7
- package/dist/tools/fileops/container.d.ts +8 -0
- package/dist/tools/fileops/container.js +11 -0
- package/dist/tools/fileops/delete-file.js +4 -2
- package/dist/tools/fileops/get-file-content.js +45 -7
- package/dist/tools/fileops/list-files.js +5 -2
- package/dist/tools/fileops/search-files.js +4 -1
- package/dist/tools/fileops/upload-file.js +5 -2
- package/dist/tools/index.js +0 -2
- package/dist/tools/model-building/check-cube-rule.js +3 -2
- package/dist/tools/model-building/clear-cube.js +35 -26
- package/dist/tools/model-building/set-cube-rules.js +13 -20
- package/dist/tools/model-building/unload-cube.js +1 -1
- package/dist/tools/operations/get-cube-stats.js +1 -1
- package/dist/tools/operations/get-transaction-log.js +1 -1
- package/dist/tools/operations/list-error-logs.js +27 -2
- package/dist/tools/schemas/items-fileops.d.ts +4 -0
- package/dist/tools/schemas/items-fileops.js +1 -0
- package/dist/tools/security/list-clients.js +5 -5
- package/dist/tools/security/list-groups.js +1 -1
- package/dist/tools/subsets/create-subset.js +9 -5
- package/dist/tools/subsets/delete-subset.js +8 -3
- package/dist/tools/subsets/update-subset.js +9 -9
- package/dist/tools/ti-development/diff-process-with-file.js +4 -29
- package/dist/tools/ti-development/diff-processes.js +9 -0
- package/dist/tools/ti-development/export-process-to-git.js +9 -7
- package/dist/tools/ti-development/export-process-to-pro.js +15 -8
- package/dist/tools/ti-development/import-pro-file.js +10 -21
- package/dist/tools/ti-development/import-process-from-git.js +8 -18
- package/dist/tools/ti-development/install-pro-bundle.js +2 -2
- package/dist/tools/ti-development/upsert-process.js +26 -5
- package/npm-shrinkwrap.json +10 -9
- package/package.json +9 -5
- package/dist/tools/dimension-management/move-element.d.ts +0 -2
- package/dist/tools/dimension-management/move-element.js +0 -28
package/dist/tm1-client/http.js
CHANGED
|
@@ -51,6 +51,24 @@ export class TM1HttpClient {
|
|
|
51
51
|
this.logger = logger;
|
|
52
52
|
this.profile = createConnectionProfile(config);
|
|
53
53
|
}
|
|
54
|
+
mutationListeners = [];
|
|
55
|
+
/**
|
|
56
|
+
* @internal — subscribe to THIS connection's successful mutations. Unlike
|
|
57
|
+
* the process-global `tm1Events` bus, listeners die with the client, so a
|
|
58
|
+
* per-connection cache needs no unsubscribe and never sees another
|
|
59
|
+
* connection's writes.
|
|
60
|
+
*/
|
|
61
|
+
onMutation(listener) {
|
|
62
|
+
this.mutationListeners.push(listener);
|
|
63
|
+
}
|
|
64
|
+
emitMutation(method, path) {
|
|
65
|
+
if (isSafeHttpMethod(method))
|
|
66
|
+
return;
|
|
67
|
+
const e = { method, path, connectionId: connectionIdOf(this.config) };
|
|
68
|
+
tm1Events.emit("mutation", e);
|
|
69
|
+
for (const listener of this.mutationListeners)
|
|
70
|
+
listener(e);
|
|
71
|
+
}
|
|
54
72
|
/**
|
|
55
73
|
* TM1 major version (11 | 12) — the single numeric source of truth for
|
|
56
74
|
* version-conditional service code. Branch on this, never on the display
|
|
@@ -110,23 +128,11 @@ export class TM1HttpClient {
|
|
|
110
128
|
});
|
|
111
129
|
}
|
|
112
130
|
const retryResult = await this.handleResponse(retryResponse, path);
|
|
113
|
-
|
|
114
|
-
tm1Events.emit("mutation", {
|
|
115
|
-
method,
|
|
116
|
-
path,
|
|
117
|
-
connectionId: connectionIdOf(this.config),
|
|
118
|
-
});
|
|
119
|
-
}
|
|
131
|
+
this.emitMutation(method, path);
|
|
120
132
|
return retryResult;
|
|
121
133
|
}
|
|
122
134
|
const result = await this.handleResponse(response, path);
|
|
123
|
-
|
|
124
|
-
tm1Events.emit("mutation", {
|
|
125
|
-
method,
|
|
126
|
-
path,
|
|
127
|
-
connectionId: connectionIdOf(this.config),
|
|
128
|
-
});
|
|
129
|
-
}
|
|
135
|
+
this.emitMutation(method, path);
|
|
130
136
|
return result;
|
|
131
137
|
}
|
|
132
138
|
catch (error) {
|
|
@@ -174,6 +180,22 @@ export class TM1HttpClient {
|
|
|
174
180
|
*/
|
|
175
181
|
/** @internal — for Service-layer use; not part of the public consumer API. */
|
|
176
182
|
async requestRaw(method, path, opts) {
|
|
183
|
+
return (await this.fetchRaw(method, path, opts)).text();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Same request as requestRaw, but hands back the bytes instead of a string.
|
|
187
|
+
*
|
|
188
|
+
* requestRaw decodes the body as UTF-8, which silently destroys anything
|
|
189
|
+
* that is not text — a spreadsheet read that way comes back as replacement
|
|
190
|
+
* characters. Callers that may face binary content use this and decide how
|
|
191
|
+
* to present it.
|
|
192
|
+
*/
|
|
193
|
+
/** @internal — for Service-layer use; not part of the public consumer API. */
|
|
194
|
+
async requestRawBytes(method, path, opts) {
|
|
195
|
+
const res = await this.fetchRaw(method, path, opts);
|
|
196
|
+
return Buffer.from(await res.arrayBuffer());
|
|
197
|
+
}
|
|
198
|
+
async fetchRaw(method, path, opts) {
|
|
177
199
|
const url = `${this.config.baseUrl}${this.profile.resolveApiPath(path)}`;
|
|
178
200
|
const effectiveTimeout = opts?.timeoutMs ?? this.config.requestTimeoutMs;
|
|
179
201
|
const cookie = await this.sessionManager.ensureSession();
|
|
@@ -198,15 +220,8 @@ export class TM1HttpClient {
|
|
|
198
220
|
}
|
|
199
221
|
throw this.classifyHttpError(response.status, path, body || undefined);
|
|
200
222
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
tm1Events.emit("mutation", {
|
|
204
|
-
method,
|
|
205
|
-
path,
|
|
206
|
-
connectionId: connectionIdOf(this.config),
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return text;
|
|
223
|
+
this.emitMutation(method, path);
|
|
224
|
+
return response;
|
|
210
225
|
}
|
|
211
226
|
/**
|
|
212
227
|
* Make an authenticated HTTP request with a binary body (Buffer/Uint8Array).
|
|
@@ -237,13 +252,7 @@ export class TM1HttpClient {
|
|
|
237
252
|
}
|
|
238
253
|
throw this.classifyHttpError(response.status, path, errBody || undefined);
|
|
239
254
|
}
|
|
240
|
-
|
|
241
|
-
tm1Events.emit("mutation", {
|
|
242
|
-
method,
|
|
243
|
-
path,
|
|
244
|
-
connectionId: connectionIdOf(this.config),
|
|
245
|
-
});
|
|
246
|
-
}
|
|
255
|
+
this.emitMutation(method, path);
|
|
247
256
|
}
|
|
248
257
|
/**
|
|
249
258
|
* Low-level single fetch with timeout + AbortSignal wiring.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { CalculationTraceNode, CellValue, FedCellDescriptor, FeederTraceResult, MdxResult } from "../../types.js";
|
|
2
2
|
import type { RequestOptions, TM1HttpClient } from "../http.js";
|
|
3
|
+
import { DimensionOrderCache } from "./dimension-order.js";
|
|
3
4
|
export declare class CellService {
|
|
4
5
|
private readonly http;
|
|
5
|
-
|
|
6
|
+
private readonly dimOrder;
|
|
7
|
+
constructor(http: TM1HttpClient, dimOrder?: DimensionOrderCache);
|
|
6
8
|
/**
|
|
7
9
|
* Get a single cell value via a 1-tuple MDX query.
|
|
8
10
|
*
|
|
@@ -42,20 +44,20 @@ export declare class CellService {
|
|
|
42
44
|
}>): Promise<void>;
|
|
43
45
|
/**
|
|
44
46
|
* Resolve the cube's dimension order and build Tuple@odata.bind paths for
|
|
45
|
-
* the cell-bound trace actions.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
47
|
+
* the cell-bound trace actions. Each entry addresses the dimension's default
|
|
48
|
+
* hierarchy, or an alternate one when written `Hier:Elem` — see
|
|
49
|
+
* splitHierarchyQualified().
|
|
48
50
|
*/
|
|
49
51
|
private tupleBinds;
|
|
50
52
|
/**
|
|
51
53
|
* Check the feeders of a cell: returns the cells fed by this cell with a
|
|
52
|
-
* Fed flag per target — Fed=false marks a broken/missing feeder.
|
|
54
|
+
* Fed flag per target — Fed=false marks a broken/missing feeder.
|
|
53
55
|
* POST /api/v1/Cubes('{cube}')/tm1.CheckFeeders
|
|
54
56
|
*/
|
|
55
57
|
checkFeeders(cubeName: string, elements: string[], opts?: RequestOptions): Promise<FedCellDescriptor[]>;
|
|
56
58
|
/**
|
|
57
59
|
* Trace the feeders of a cell: returns the cells this cell feeds plus the
|
|
58
|
-
* feeder statements involved.
|
|
60
|
+
* feeder statements involved.
|
|
59
61
|
* POST /api/v1/Cubes('{cube}')/tm1.TraceFeeders
|
|
60
62
|
*/
|
|
61
63
|
traceFeeders(cubeName: string, elements: string[], opts?: RequestOptions): Promise<FeederTraceResult>;
|
|
@@ -63,7 +65,7 @@ export declare class CellService {
|
|
|
63
65
|
* Trace how a cell value is calculated: recursive component tree with
|
|
64
66
|
* per-component type (consolidation/rule), status, value, and rule
|
|
65
67
|
* statements. The server returns the full tree; maxDepth/maxComponents
|
|
66
|
-
* truncate client-side to keep responses bounded.
|
|
68
|
+
* truncate client-side to keep responses bounded.
|
|
67
69
|
* POST /api/v1/Cubes('{cube}')/tm1.TraceCellCalculation
|
|
68
70
|
*/
|
|
69
71
|
traceCellCalculation(cubeName: string, elements: string[], maxDepth?: number, maxComponents?: number, opts?: RequestOptions): Promise<CalculationTraceNode>;
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
// Cell domain service. Owns single-cell reads, MDX cellset execution, and
|
|
2
2
|
// cell writes via the cellset PATCH path. Cube-shape lookups (resolving
|
|
3
|
-
// dimension order for getValue) go through the
|
|
4
|
-
// than CubeService to avoid a CubeService → CellService cycle later.
|
|
3
|
+
// dimension order for getValue) go through the shared DimensionOrderCache
|
|
4
|
+
// rather than CubeService to avoid a CubeService → CellService cycle later.
|
|
5
5
|
//
|
|
6
6
|
// See docs/ARCHITECTURE.md for the layering.
|
|
7
7
|
import { TM1Error, TM1ErrorCode } from "../../types.js";
|
|
8
8
|
import { escapeMdxName } from "../../lib/mdx.js";
|
|
9
9
|
import { dimensionCountMismatch } from "../../lib/coordinate-error.js";
|
|
10
10
|
import { bindLeftOutSandbox } from "../../lib/cell-address.js";
|
|
11
|
+
import { mapSettledWithConcurrency } from "../../lib/concurrency.js";
|
|
11
12
|
import { freeCellset, transformCellsetResponse } from "./cellset-transform.js";
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
import { odataKey } from "./odata-page.js";
|
|
14
|
+
import { DimensionOrderCache } from "./dimension-order.js";
|
|
15
|
+
// In-flight cap for the per-cell re-walk after a refused bulk write.
|
|
16
|
+
const FALLBACK_CONCURRENCY = 8;
|
|
17
|
+
/**
|
|
18
|
+
* Split one entry of a cell coordinate into (hierarchy, element).
|
|
19
|
+
*
|
|
20
|
+
* A bare name addresses the dimension's DEFAULT hierarchy, which carries the
|
|
21
|
+
* dimension's own name. `Hier:Elem` addresses an alternate hierarchy — the
|
|
22
|
+
* same `Dim:Hier` idiom TM1 rules use, one slot down.
|
|
23
|
+
*
|
|
24
|
+
* The split takes the FIRST colon, and the dimension's default hierarchy can
|
|
25
|
+
* always be named explicitly, so an element whose own name contains a colon
|
|
26
|
+
* stays reachable: in dimension `Region`, `Region:A:B` is element `A:B` in
|
|
27
|
+
* the default hierarchy. A leading or trailing colon cannot separate anything,
|
|
28
|
+
* so such an entry is taken as a plain element name.
|
|
29
|
+
*/
|
|
30
|
+
function splitHierarchyQualified(entry, dimension) {
|
|
31
|
+
const i = entry.indexOf(":");
|
|
32
|
+
if (i <= 0 || i === entry.length - 1)
|
|
33
|
+
return { hierarchy: dimension, element: entry };
|
|
34
|
+
return { hierarchy: entry.slice(0, i), element: entry.slice(i + 1) };
|
|
35
|
+
}
|
|
14
36
|
// Build a fully-qualified MDX member reference for a write coordinate.
|
|
15
37
|
// A caller may pass a pre-qualified ref to target an ALTERNATE hierarchy
|
|
16
38
|
// (`[Dim].[AltHier].[Elem]`, or `[Dim].[Elem]` for the default) — passed
|
|
@@ -27,8 +49,10 @@ function qualifyWriteMember(dim, element) {
|
|
|
27
49
|
}
|
|
28
50
|
export class CellService {
|
|
29
51
|
http;
|
|
30
|
-
|
|
52
|
+
dimOrder;
|
|
53
|
+
constructor(http, dimOrder = new DimensionOrderCache(http)) {
|
|
31
54
|
this.http = http;
|
|
55
|
+
this.dimOrder = dimOrder;
|
|
32
56
|
}
|
|
33
57
|
/**
|
|
34
58
|
* Get a single cell value via a 1-tuple MDX query.
|
|
@@ -42,9 +66,7 @@ export class CellService {
|
|
|
42
66
|
if (elements.length === 0) {
|
|
43
67
|
return null;
|
|
44
68
|
}
|
|
45
|
-
const
|
|
46
|
-
const cubeMeta = await this.http.request("GET", cubePath);
|
|
47
|
-
const dims = cubeMeta.Dimensions.map((d) => d.Name);
|
|
69
|
+
const dims = await this.dimOrder.get(cubeName);
|
|
48
70
|
// Sandboxes left out → Base, as tm1_write_cells does.
|
|
49
71
|
elements = bindLeftOutSandbox(dims, elements) ?? elements;
|
|
50
72
|
if (elements.length !== dims.length) {
|
|
@@ -164,11 +186,11 @@ export class CellService {
|
|
|
164
186
|
const cellset = await this.http.request("POST", "/api/v1/ExecuteMDX", { MDX: mdx });
|
|
165
187
|
const id = cellset.ID;
|
|
166
188
|
try {
|
|
167
|
-
await this.http.request("PATCH", `/api/v1/Cellsets('${
|
|
189
|
+
await this.http.request("PATCH", `/api/v1/Cellsets('${odataKey(id)}')/Cells(0)`, { Value: c.value });
|
|
168
190
|
}
|
|
169
191
|
finally {
|
|
170
192
|
try {
|
|
171
|
-
await this.http.request("DELETE", `/api/v1/Cellsets('${
|
|
193
|
+
await this.http.request("DELETE", `/api/v1/Cellsets('${odataKey(id)}')`);
|
|
172
194
|
}
|
|
173
195
|
catch {
|
|
174
196
|
// cleanup best-effort
|
|
@@ -186,7 +208,7 @@ export class CellService {
|
|
|
186
208
|
let bulkFailed = false;
|
|
187
209
|
const cellset = await this.http.request("POST", "/api/v1/ExecuteMDX", { MDX: mdx });
|
|
188
210
|
try {
|
|
189
|
-
await this.http.request("PATCH", `/api/v1/Cellsets('${
|
|
211
|
+
await this.http.request("PATCH", `/api/v1/Cellsets('${odataKey(cellset.ID)}')/Cells`, chunk.map((c, ordinal) => ({ Ordinal: ordinal, Value: c.value })));
|
|
190
212
|
written += chunk.length;
|
|
191
213
|
}
|
|
192
214
|
catch {
|
|
@@ -200,7 +222,7 @@ export class CellService {
|
|
|
200
222
|
}
|
|
201
223
|
finally {
|
|
202
224
|
try {
|
|
203
|
-
await this.http.request("DELETE", `/api/v1/Cellsets('${
|
|
225
|
+
await this.http.request("DELETE", `/api/v1/Cellsets('${odataKey(cellset.ID)}')`);
|
|
204
226
|
}
|
|
205
227
|
catch {
|
|
206
228
|
// cleanup best-effort
|
|
@@ -208,7 +230,9 @@ export class CellService {
|
|
|
208
230
|
}
|
|
209
231
|
if (!bulkFailed)
|
|
210
232
|
continue;
|
|
211
|
-
|
|
233
|
+
// Bounded: re-walking a 500-cell chunk unbounded put ~1500 requests
|
|
234
|
+
// (cellset, PATCH, delete per cell) in flight against the worker pool.
|
|
235
|
+
const results = await mapSettledWithConcurrency(chunk, FALLBACK_CONCURRENCY, (c) => writeOne(c));
|
|
212
236
|
const failed = [];
|
|
213
237
|
results.forEach((r, j) => {
|
|
214
238
|
if (r.status === "fulfilled") {
|
|
@@ -238,39 +262,41 @@ export class CellService {
|
|
|
238
262
|
}
|
|
239
263
|
/**
|
|
240
264
|
* Resolve the cube's dimension order and build Tuple@odata.bind paths for
|
|
241
|
-
* the cell-bound trace actions.
|
|
242
|
-
*
|
|
243
|
-
*
|
|
265
|
+
* the cell-bound trace actions. Each entry addresses the dimension's default
|
|
266
|
+
* hierarchy, or an alternate one when written `Hier:Elem` — see
|
|
267
|
+
* splitHierarchyQualified().
|
|
244
268
|
*/
|
|
245
269
|
async tupleBinds(cubeName, elements) {
|
|
246
|
-
const
|
|
247
|
-
const dims = cubeMeta.Dimensions.map((d) => d.Name);
|
|
270
|
+
const dims = await this.dimOrder.get(cubeName);
|
|
248
271
|
if (elements.length !== dims.length) {
|
|
249
272
|
throw new TM1Error({
|
|
250
273
|
code: TM1ErrorCode.VALIDATION_ERROR,
|
|
251
274
|
message: `Cube '${cubeName}' has ${dims.length} dimension(s) (${dims.join(", ")}) but ${elements.length} element(s) were given`,
|
|
252
275
|
});
|
|
253
276
|
}
|
|
254
|
-
return dims.map((d, i) =>
|
|
277
|
+
return dims.map((d, i) => {
|
|
278
|
+
const { hierarchy, element } = splitHierarchyQualified(elements[i], d);
|
|
279
|
+
return `Dimensions('${odataKey(d)}')/Hierarchies('${odataKey(hierarchy)}')/Elements('${odataKey(element)}')`;
|
|
280
|
+
});
|
|
255
281
|
}
|
|
256
282
|
/**
|
|
257
283
|
* Check the feeders of a cell: returns the cells fed by this cell with a
|
|
258
|
-
* Fed flag per target — Fed=false marks a broken/missing feeder.
|
|
284
|
+
* Fed flag per target — Fed=false marks a broken/missing feeder.
|
|
259
285
|
* POST /api/v1/Cubes('{cube}')/tm1.CheckFeeders
|
|
260
286
|
*/
|
|
261
287
|
async checkFeeders(cubeName, elements, opts) {
|
|
262
288
|
const binds = await this.tupleBinds(cubeName, elements);
|
|
263
|
-
const response = await this.http.request("POST", `/api/v1/Cubes('${
|
|
289
|
+
const response = await this.http.request("POST", `/api/v1/Cubes('${odataKey(cubeName)}')/tm1.CheckFeeders?$expand=Cube($select=Name),Tuple($select=Name)`, { "Tuple@odata.bind": binds }, opts);
|
|
264
290
|
return (response.value ?? []).map(mapFedCell);
|
|
265
291
|
}
|
|
266
292
|
/**
|
|
267
293
|
* Trace the feeders of a cell: returns the cells this cell feeds plus the
|
|
268
|
-
* feeder statements involved.
|
|
294
|
+
* feeder statements involved.
|
|
269
295
|
* POST /api/v1/Cubes('{cube}')/tm1.TraceFeeders
|
|
270
296
|
*/
|
|
271
297
|
async traceFeeders(cubeName, elements, opts) {
|
|
272
298
|
const binds = await this.tupleBinds(cubeName, elements);
|
|
273
|
-
const response = await this.http.request("POST", `/api/v1/Cubes('${
|
|
299
|
+
const response = await this.http.request("POST", `/api/v1/Cubes('${odataKey(cubeName)}')/tm1.TraceFeeders?$expand=FedCells/Cube($select=Name),FedCells/Tuple($select=Name)`, { "Tuple@odata.bind": binds }, opts);
|
|
274
300
|
return {
|
|
275
301
|
fedCells: (response.FedCells ?? []).map(mapFedCell),
|
|
276
302
|
statements: response.Statements ?? [],
|
|
@@ -280,7 +306,7 @@ export class CellService {
|
|
|
280
306
|
* Trace how a cell value is calculated: recursive component tree with
|
|
281
307
|
* per-component type (consolidation/rule), status, value, and rule
|
|
282
308
|
* statements. The server returns the full tree; maxDepth/maxComponents
|
|
283
|
-
* truncate client-side to keep responses bounded.
|
|
309
|
+
* truncate client-side to keep responses bounded.
|
|
284
310
|
* POST /api/v1/Cubes('{cube}')/tm1.TraceCellCalculation
|
|
285
311
|
*/
|
|
286
312
|
async traceCellCalculation(cubeName, elements, maxDepth = 3, maxComponents = 20, opts) {
|
|
@@ -296,7 +322,7 @@ export class CellService {
|
|
|
296
322
|
const prefix = "Components/".repeat(level);
|
|
297
323
|
expandParts.push(`${prefix}Tuple($select=Name)`, `${prefix}Cube($select=Name)`);
|
|
298
324
|
}
|
|
299
|
-
const response = await this.http.request("POST", `/api/v1/Cubes('${
|
|
325
|
+
const response = await this.http.request("POST", `/api/v1/Cubes('${odataKey(cubeName)}')/tm1.TraceCellCalculation?$expand=${expandParts.join(",")}`, { "Tuple@odata.bind": binds }, opts);
|
|
300
326
|
return mapCalcComponent(response, maxDepth, maxComponents);
|
|
301
327
|
}
|
|
302
328
|
}
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import { CHORE_STATUS_UNAVAILABLE, TM1Error, TM1ErrorCode, } from "../../types.js";
|
|
6
6
|
import { classifyChoreExecution } from "./chore-status.js";
|
|
7
7
|
import { rethrowIfSystemic } from "./fallback.js";
|
|
8
|
-
|
|
9
|
-
const enc = (s) => encodeURIComponent(String(s).replace(/'/g, "''"));
|
|
8
|
+
import { odataKey } from "./odata-page.js";
|
|
10
9
|
function frequencyDuration(f) {
|
|
11
10
|
return `P${f.days}DT${String(f.hours).padStart(2, "0")}H${String(f.minutes).padStart(2, "0")}M${String(f.seconds).padStart(2, "0")}S`;
|
|
12
11
|
}
|
|
@@ -45,7 +44,7 @@ export class ChoreService {
|
|
|
45
44
|
* PATCH /api/v1/Chores('{name}') with { Active: bool }
|
|
46
45
|
*/
|
|
47
46
|
async toggleActive(choreName, active) {
|
|
48
|
-
const path = `/api/v1/Chores('${
|
|
47
|
+
const path = `/api/v1/Chores('${odataKey(choreName)}')`;
|
|
49
48
|
await this.http.request("PATCH", path, { Active: active });
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
@@ -65,11 +64,11 @@ export class ChoreService {
|
|
|
65
64
|
* — everywhere else. Returns 204, so no status exists to report.
|
|
66
65
|
*/
|
|
67
66
|
async execute(choreName, opts) {
|
|
68
|
-
const plain = `/api/v1/Chores('${
|
|
67
|
+
const plain = `/api/v1/Chores('${odataKey(choreName)}')/tm1.Execute`;
|
|
69
68
|
if (this.withReturnSupported === false) {
|
|
70
69
|
return this.executeWithoutStatus(plain, opts);
|
|
71
70
|
}
|
|
72
|
-
const withReturn = `/api/v1/Chores('${
|
|
71
|
+
const withReturn = `/api/v1/Chores('${odataKey(choreName)}')/tm1.ExecuteWithReturn?$expand=ErrorLogFile`;
|
|
73
72
|
try {
|
|
74
73
|
const response = await this.http.request("POST", withReturn, {}, opts);
|
|
75
74
|
this.withReturnSupported = true;
|
|
@@ -129,7 +128,7 @@ export class ChoreService {
|
|
|
129
128
|
Frequency: frequencyDuration(chore.frequency),
|
|
130
129
|
Tasks: chore.steps.map((step, idx) => ({
|
|
131
130
|
Step: idx,
|
|
132
|
-
"Process@odata.bind": `Processes('${
|
|
131
|
+
"Process@odata.bind": `Processes('${odataKey(step.process)}')`,
|
|
133
132
|
Parameters: step.parameters.map((p) => ({
|
|
134
133
|
Name: p.name,
|
|
135
134
|
Value: p.value,
|
|
@@ -143,7 +142,7 @@ export class ChoreService {
|
|
|
143
142
|
* PATCH /api/v1/Chores('{name}')
|
|
144
143
|
*/
|
|
145
144
|
async update(choreName, updates) {
|
|
146
|
-
const path = `/api/v1/Chores('${
|
|
145
|
+
const path = `/api/v1/Chores('${odataKey(choreName)}')`;
|
|
147
146
|
const body = {};
|
|
148
147
|
if (updates.startTime !== undefined)
|
|
149
148
|
body.StartTime = updates.startTime;
|
|
@@ -159,7 +158,7 @@ export class ChoreService {
|
|
|
159
158
|
if (updates.steps !== undefined) {
|
|
160
159
|
body.Tasks = updates.steps.map((step, idx) => ({
|
|
161
160
|
Step: idx,
|
|
162
|
-
"Process@odata.bind": `Processes('${
|
|
161
|
+
"Process@odata.bind": `Processes('${odataKey(step.process)}')`,
|
|
163
162
|
Parameters: step.parameters.map((p) => ({
|
|
164
163
|
Name: p.name,
|
|
165
164
|
Value: p.value,
|
|
@@ -173,7 +172,7 @@ export class ChoreService {
|
|
|
173
172
|
* DELETE /api/v1/Chores('{name}')
|
|
174
173
|
*/
|
|
175
174
|
async delete(choreName) {
|
|
176
|
-
await this.http.request("DELETE", `/api/v1/Chores('${
|
|
175
|
+
await this.http.request("DELETE", `/api/v1/Chores('${odataKey(choreName)}')`);
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
//# sourceMappingURL=chore-service.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Cube, CubeRules, RuleSyntaxError } from "../../types.js";
|
|
2
|
-
import type { TM1HttpClient } from "../http.js";
|
|
2
|
+
import type { RequestOptions, TM1HttpClient } from "../http.js";
|
|
3
3
|
import { type NameFilterOpts, type Paged, type PageOpts } from "./odata-page.js";
|
|
4
|
+
import { DimensionOrderCache } from "./dimension-order.js";
|
|
4
5
|
export interface AllRulesOpts {
|
|
5
6
|
/** Include control cubes (`}`-prefixed). Default false. */
|
|
6
7
|
includeControl?: boolean;
|
|
@@ -14,7 +15,8 @@ export interface CubeListOpts extends NameFilterOpts {
|
|
|
14
15
|
}
|
|
15
16
|
export declare class CubeService {
|
|
16
17
|
private readonly http;
|
|
17
|
-
|
|
18
|
+
private readonly dimOrder;
|
|
19
|
+
constructor(http: TM1HttpClient, dimOrder?: DimensionOrderCache);
|
|
18
20
|
/**
|
|
19
21
|
* List all cubes with their dimension names.
|
|
20
22
|
* GET /api/v1/Cubes?$expand=Dimensions($select=Name)
|
|
@@ -36,7 +38,8 @@ export declare class CubeService {
|
|
|
36
38
|
page: PageOpts;
|
|
37
39
|
}): Promise<Paged<Cube>>;
|
|
38
40
|
/**
|
|
39
|
-
* Return ordered dimension-name list of a cube.
|
|
41
|
+
* Return ordered dimension-name list of a cube. Cached per connection —
|
|
42
|
+
* see dimension-order.ts.
|
|
40
43
|
* GET /api/v1/Cubes('{name}')?$expand=Dimensions($select=Name)
|
|
41
44
|
*/
|
|
42
45
|
getDimensionNames(cubeName: string): Promise<string[]>;
|
|
@@ -104,23 +107,16 @@ export declare class CubeService {
|
|
|
104
107
|
*/
|
|
105
108
|
checkRule(cubeName: string, ruleText: string): Promise<RuleSyntaxError[]>;
|
|
106
109
|
/**
|
|
107
|
-
* Clear cube
|
|
110
|
+
* Clear every cell in a cube.
|
|
108
111
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* to
|
|
115
|
-
*
|
|
116
|
-
* A **partial** clear would need tuple selectors, which only tm1.Clear
|
|
117
|
-
* offers, so no server reachable here can do one. Callers get
|
|
118
|
-
* UNSUPPORTED_OPERATION pointing at bedrock `}bedrock.cube.data.clear`
|
|
119
|
-
* rather than a request that is known to 404.
|
|
112
|
+
* The clear runs an ephemeral TI with CubeClearData(). tm1.Clear is not an
|
|
113
|
+
* alternative on either build: 11.8 and 12.5 both answer "'tm1.Clear'
|
|
114
|
+
* resource can not be resolved on type 'Cube'" for a cube that exists, and
|
|
115
|
+
* neither declares a clear action anywhere in $metadata — Cube carries only
|
|
116
|
+
* Lock and Unlock. CubeClearData() is the only route measured to work, and
|
|
117
|
+
* it takes a cube name and nothing else, so there is no region to scope.
|
|
120
118
|
*/
|
|
121
|
-
clear(cubeName: string,
|
|
122
|
-
/** Same verdict for both versions: no tuple-selective clear on this server. */
|
|
123
|
-
private partialClearUnsupported;
|
|
119
|
+
clear(cubeName: string, opts?: Pick<RequestOptions, "timeoutMs">): Promise<void>;
|
|
124
120
|
/**
|
|
125
121
|
* Unload a cube from memory. Forces TM1 to discard the in-memory fed-cell
|
|
126
122
|
* index and reload from disk on next access. Required for feeder corrections
|