tm1npm 1.5.3 → 2.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 +89 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/services/ApplicationService.d.ts +19 -3
- package/lib/services/ApplicationService.d.ts.map +1 -1
- package/lib/services/ApplicationService.js +232 -6
- package/lib/services/AsyncOperationService.d.ts +8 -1
- package/lib/services/AsyncOperationService.d.ts.map +1 -1
- package/lib/services/AsyncOperationService.js +69 -26
- package/lib/services/ElementService.d.ts +67 -1
- package/lib/services/ElementService.d.ts.map +1 -1
- package/lib/services/ElementService.js +214 -0
- package/lib/services/FileService.d.ts.map +1 -1
- package/lib/services/HierarchyService.d.ts +26 -0
- package/lib/services/HierarchyService.d.ts.map +1 -1
- package/lib/services/HierarchyService.js +306 -0
- package/lib/services/ProcessService.d.ts +40 -22
- package/lib/services/ProcessService.d.ts.map +1 -1
- package/lib/services/ProcessService.js +118 -111
- package/lib/services/RestService.d.ts +213 -25
- package/lib/services/RestService.d.ts.map +1 -1
- package/lib/services/RestService.js +841 -263
- package/lib/services/SubsetService.d.ts +2 -0
- package/lib/services/SubsetService.d.ts.map +1 -1
- package/lib/services/SubsetService.js +33 -0
- package/lib/services/TM1Service.d.ts +44 -1
- package/lib/services/TM1Service.d.ts.map +1 -1
- package/lib/services/TM1Service.js +96 -4
- package/lib/services/index.d.ts +1 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/tests/100PercentParityCheck.test.js +23 -6
- package/lib/tests/applicationService.issue38.test.d.ts +5 -0
- package/lib/tests/applicationService.issue38.test.d.ts.map +1 -0
- package/lib/tests/applicationService.issue38.test.js +237 -0
- package/lib/tests/asyncOperationService.test.js +51 -45
- package/lib/tests/bugfix28.test.js +12 -4
- package/lib/tests/elementService.issue37.test.d.ts +5 -0
- package/lib/tests/elementService.issue37.test.d.ts.map +1 -0
- package/lib/tests/elementService.issue37.test.js +413 -0
- package/lib/tests/elementService.issue38.test.d.ts +5 -0
- package/lib/tests/elementService.issue38.test.d.ts.map +1 -0
- package/lib/tests/elementService.issue38.test.js +79 -0
- package/lib/tests/hierarchyService.issue38.test.d.ts +5 -0
- package/lib/tests/hierarchyService.issue38.test.d.ts.map +1 -0
- package/lib/tests/hierarchyService.issue38.test.js +460 -0
- package/lib/tests/processService.comprehensive.test.js +9 -9
- package/lib/tests/processService.test.js +234 -0
- package/lib/tests/restService.test.d.ts +0 -4
- package/lib/tests/restService.test.d.ts.map +1 -1
- package/lib/tests/restService.test.js +1558 -143
- package/lib/tests/subsetService.issue38.test.d.ts +5 -0
- package/lib/tests/subsetService.issue38.test.d.ts.map +1 -0
- package/lib/tests/subsetService.issue38.test.js +113 -0
- package/lib/tests/tm1Service.test.js +80 -8
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/services/ApplicationService.ts +282 -10
- package/src/services/AsyncOperationService.ts +76 -29
- package/src/services/ElementService.ts +322 -1
- package/src/services/FileService.ts +3 -3
- package/src/services/HierarchyService.ts +419 -1
- package/src/services/ProcessService.ts +185 -142
- package/src/services/RestService.ts +1021 -267
- package/src/services/SubsetService.ts +48 -0
- package/src/services/TM1Service.ts +127 -6
- package/src/services/index.ts +1 -1
- package/src/tests/100PercentParityCheck.test.ts +29 -8
- package/src/tests/applicationService.issue38.test.ts +293 -0
- package/src/tests/asyncOperationService.test.ts +52 -48
- package/src/tests/bugfix28.test.ts +12 -4
- package/src/tests/elementService.issue37.test.ts +571 -0
- package/src/tests/elementService.issue38.test.ts +103 -0
- package/src/tests/hierarchyService.issue38.test.ts +599 -0
- package/src/tests/processService.comprehensive.test.ts +10 -10
- package/src/tests/processService.test.ts +295 -3
- package/src/tests/restService.test.ts +1844 -139
- package/src/tests/subsetService.issue38.test.ts +182 -0
- package/src/tests/tm1Service.test.ts +95 -11
|
@@ -3,13 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HierarchyService = void 0;
|
|
4
4
|
const Hierarchy_1 = require("../objects/Hierarchy");
|
|
5
5
|
const ElementAttribute_1 = require("../objects/ElementAttribute");
|
|
6
|
+
const Element_1 = require("../objects/Element");
|
|
7
|
+
const Dimension_1 = require("../objects/Dimension");
|
|
6
8
|
const TM1Exception_1 = require("../exceptions/TM1Exception");
|
|
7
9
|
const ObjectService_1 = require("./ObjectService");
|
|
10
|
+
const ElementService_1 = require("./ElementService");
|
|
11
|
+
const CellService_1 = require("./CellService");
|
|
12
|
+
const DimensionService_1 = require("./DimensionService");
|
|
8
13
|
const Utils_1 = require("../utils/Utils");
|
|
9
14
|
class HierarchyService extends ObjectService_1.ObjectService {
|
|
10
15
|
constructor(rest) {
|
|
11
16
|
super(rest);
|
|
12
17
|
}
|
|
18
|
+
getElementService() {
|
|
19
|
+
if (!this.elementService) {
|
|
20
|
+
this.elementService = new ElementService_1.ElementService(this.rest);
|
|
21
|
+
}
|
|
22
|
+
return this.elementService;
|
|
23
|
+
}
|
|
13
24
|
async create(hierarchy) {
|
|
14
25
|
const url = this.formatUrl("/Dimensions('{}')/Hierarchies", hierarchy.dimensionName);
|
|
15
26
|
const response = await this.rest.post(url, hierarchy.body);
|
|
@@ -30,6 +41,12 @@ class HierarchyService extends ObjectService_1.ObjectService {
|
|
|
30
41
|
await this.updateElementAttributes(hierarchy, keepExistingAttributes);
|
|
31
42
|
return responses;
|
|
32
43
|
}
|
|
44
|
+
async updateOrCreate(hierarchy) {
|
|
45
|
+
if (await this.exists(hierarchy.dimensionName, hierarchy.name)) {
|
|
46
|
+
return await this.update(hierarchy);
|
|
47
|
+
}
|
|
48
|
+
return await this.create(hierarchy);
|
|
49
|
+
}
|
|
33
50
|
async delete(dimensionName, hierarchyName) {
|
|
34
51
|
const url = this.formatUrl("/Dimensions('{}')/Hierarchies('{}')", dimensionName, hierarchyName);
|
|
35
52
|
return await this.rest.delete(url);
|
|
@@ -58,6 +75,295 @@ class HierarchyService extends ObjectService_1.ObjectService {
|
|
|
58
75
|
const response = await this.rest.get(url);
|
|
59
76
|
return response.data.value.map((h) => Hierarchy_1.Hierarchy.fromDict(h, dimensionName));
|
|
60
77
|
}
|
|
78
|
+
async getHierarchySummary(dimensionName, hierarchyName) {
|
|
79
|
+
var _a, _b, _c, _d, _e;
|
|
80
|
+
const hierarchy = hierarchyName || dimensionName;
|
|
81
|
+
const url = this.formatUrl("/Dimensions('{}')/Hierarchies('{}')" +
|
|
82
|
+
"?$expand=Edges/$count,Elements/$count,ElementAttributes/$count,Members/$count,Levels/$count" +
|
|
83
|
+
"&$select=Cardinality", dimensionName, hierarchy);
|
|
84
|
+
const response = await this.rest.get(url);
|
|
85
|
+
const data = response.data;
|
|
86
|
+
return {
|
|
87
|
+
Elements: (_a = data['Elements@odata.count']) !== null && _a !== void 0 ? _a : 0,
|
|
88
|
+
Edges: (_b = data['Edges@odata.count']) !== null && _b !== void 0 ? _b : 0,
|
|
89
|
+
ElementAttributes: (_c = data['ElementAttributes@odata.count']) !== null && _c !== void 0 ? _c : 0,
|
|
90
|
+
Members: (_d = data['Members@odata.count']) !== null && _d !== void 0 ? _d : 0,
|
|
91
|
+
Levels: (_e = data['Levels@odata.count']) !== null && _e !== void 0 ? _e : 0
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async getDefaultMember(dimensionName, hierarchyName) {
|
|
95
|
+
var _a;
|
|
96
|
+
const hierarchy = hierarchyName || dimensionName;
|
|
97
|
+
const url = this.formatUrl("/Dimensions('{}')/Hierarchies('{}')/DefaultMember", dimensionName, hierarchy);
|
|
98
|
+
try {
|
|
99
|
+
const response = await this.rest.get(url);
|
|
100
|
+
return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.Name) || null;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error instanceof TM1Exception_1.TM1RestException && error.statusCode === 404) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async updateDefaultMember(dimensionName, hierarchyName, memberName = '') {
|
|
110
|
+
const hierarchy = hierarchyName || dimensionName;
|
|
111
|
+
// Default to API approach (v12+) when version is unknown
|
|
112
|
+
if (!this.version || (0, Utils_1.verifyVersion)(this.version, '12.0.0')) {
|
|
113
|
+
return this._updateDefaultMemberViaApi(dimensionName, hierarchy, memberName);
|
|
114
|
+
}
|
|
115
|
+
return this._updateDefaultMemberViaPropsCube(dimensionName, hierarchy, memberName);
|
|
116
|
+
}
|
|
117
|
+
async _updateDefaultMemberViaApi(dimensionName, hierarchyName, memberName) {
|
|
118
|
+
const url = this.formatUrl("/Dimensions('{}')/Hierarchies('{}')", dimensionName, hierarchyName);
|
|
119
|
+
const body = {};
|
|
120
|
+
if (memberName) {
|
|
121
|
+
body['DefaultMember@odata.bind'] = (0, Utils_1.formatUrl)("Dimensions('{}')/Hierarchies('{}')/Elements('{}')", dimensionName, hierarchyName, memberName);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
body['DefaultMember@odata.bind'] = null;
|
|
125
|
+
}
|
|
126
|
+
return await this.rest.patch(url, JSON.stringify(body));
|
|
127
|
+
}
|
|
128
|
+
async _updateDefaultMemberViaPropsCube(dimensionName, hierarchyName, memberName) {
|
|
129
|
+
const cellService = new CellService_1.CellService(this.rest);
|
|
130
|
+
const value = memberName || '';
|
|
131
|
+
await cellService.writeValue('}HierarchyProperties', [dimensionName, hierarchyName, 'MEMBER_DEFAULT'], value);
|
|
132
|
+
}
|
|
133
|
+
async removeEdgesUnderConsolidation(dimensionName, hierarchyName, consolidationElement) {
|
|
134
|
+
const hierarchy = await this.get(dimensionName, hierarchyName);
|
|
135
|
+
const descendants = hierarchy.getDescendants(consolidationElement, true);
|
|
136
|
+
const membersUnderConsolidation = new Utils_1.CaseAndSpaceInsensitiveSet(descendants);
|
|
137
|
+
membersUnderConsolidation.add(consolidationElement);
|
|
138
|
+
const edgesToRemove = [];
|
|
139
|
+
for (const [parent, children] of hierarchy.edges) {
|
|
140
|
+
if (membersUnderConsolidation.has(parent)) {
|
|
141
|
+
for (const child of children.keys()) {
|
|
142
|
+
edgesToRemove.push([parent, child]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const [parent, child] of edgesToRemove) {
|
|
147
|
+
hierarchy.removeEdge(parent, child);
|
|
148
|
+
}
|
|
149
|
+
return await this.update(hierarchy);
|
|
150
|
+
}
|
|
151
|
+
async addEdges(dimensionName, hierarchyName, edges) {
|
|
152
|
+
return this.getElementService().addEdges(dimensionName, hierarchyName || dimensionName, edges);
|
|
153
|
+
}
|
|
154
|
+
async addElements(dimensionName, hierarchyName, elements) {
|
|
155
|
+
return this.getElementService().addElements(dimensionName, hierarchyName, elements);
|
|
156
|
+
}
|
|
157
|
+
async addElementAttributes(dimensionName, hierarchyName, elementAttributes) {
|
|
158
|
+
return this.getElementService().addElementAttributes(dimensionName, hierarchyName, elementAttributes);
|
|
159
|
+
}
|
|
160
|
+
async updateOrCreateHierarchyFromDataframe(dimensionName, hierarchyName, df, options = {}) {
|
|
161
|
+
const { elementColumn: elemCol, verifyUniqueElements = false, elementTypeColumn = 'ElementType', unwindAll = false, unwindConsolidations, deleteOrphanedConsolidations = false } = options;
|
|
162
|
+
const elementColumn = elemCol || df.columns[0];
|
|
163
|
+
const rows = df.toJson();
|
|
164
|
+
const numericSuffix = (col) => parseInt(col.replace(/\D/g, ''), 10);
|
|
165
|
+
const levelColumns = df.columns
|
|
166
|
+
.filter(c => /^Level\d+$/i.test(c))
|
|
167
|
+
.sort((a, b) => numericSuffix(a) - numericSuffix(b));
|
|
168
|
+
const weightColumns = df.columns
|
|
169
|
+
.filter(c => /^Weight\d+$/i.test(c))
|
|
170
|
+
.sort((a, b) => numericSuffix(a) - numericSuffix(b));
|
|
171
|
+
const reservedColumns = new Set([
|
|
172
|
+
elementColumn.toLowerCase(),
|
|
173
|
+
elementTypeColumn.toLowerCase(),
|
|
174
|
+
...levelColumns.map(c => c.toLowerCase()),
|
|
175
|
+
...weightColumns.map(c => c.toLowerCase())
|
|
176
|
+
]);
|
|
177
|
+
const attributeColumns = df.columns.filter(c => !reservedColumns.has(c.toLowerCase()));
|
|
178
|
+
if (verifyUniqueElements) {
|
|
179
|
+
const seen = new Utils_1.CaseAndSpaceInsensitiveSet();
|
|
180
|
+
for (const row of rows) {
|
|
181
|
+
const name = String(row[elementColumn]);
|
|
182
|
+
if (seen.has(name)) {
|
|
183
|
+
throw new Error(`Duplicate element found: '${name}'`);
|
|
184
|
+
}
|
|
185
|
+
seen.add(name);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Parse DataFrame rows into elements, edges, and attribute values
|
|
189
|
+
const elementsToAdd = [];
|
|
190
|
+
const edgesToAdd = {};
|
|
191
|
+
const attributeValues = new Map();
|
|
192
|
+
for (const row of rows) {
|
|
193
|
+
const elementName = String(row[elementColumn]);
|
|
194
|
+
const elementTypeStr = df.columns.includes(elementTypeColumn)
|
|
195
|
+
? String(row[elementTypeColumn] || 'Numeric')
|
|
196
|
+
: 'Numeric';
|
|
197
|
+
// Element constructor handles string→ElementType conversion
|
|
198
|
+
elementsToAdd.push(new Element_1.Element(elementName, elementTypeStr));
|
|
199
|
+
for (let i = 0; i < levelColumns.length; i++) {
|
|
200
|
+
const parentName = row[levelColumns[i]];
|
|
201
|
+
if (parentName && String(parentName).trim()) {
|
|
202
|
+
const weight = weightColumns[i] ? Number(row[weightColumns[i]] || 1) : 1;
|
|
203
|
+
const parentStr = String(parentName);
|
|
204
|
+
if (!edgesToAdd[parentStr]) {
|
|
205
|
+
edgesToAdd[parentStr] = {};
|
|
206
|
+
}
|
|
207
|
+
edgesToAdd[parentStr][elementName] = weight;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (attributeColumns.length > 0) {
|
|
211
|
+
const attrs = new Map();
|
|
212
|
+
for (const col of attributeColumns) {
|
|
213
|
+
if (row[col] !== undefined && row[col] !== null && row[col] !== '') {
|
|
214
|
+
attrs.set(col, row[col]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (attrs.size > 0) {
|
|
218
|
+
attributeValues.set(elementName, attrs);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Get or create the dimension/hierarchy
|
|
223
|
+
const dimensionService = new DimensionService_1.DimensionService(this.rest);
|
|
224
|
+
const hierarchyExists = await this.exists(dimensionName, hierarchyName).catch(() => false);
|
|
225
|
+
let hierarchy;
|
|
226
|
+
if (hierarchyExists) {
|
|
227
|
+
hierarchy = await this.get(dimensionName, hierarchyName);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
const newHierarchy = new Hierarchy_1.Hierarchy(hierarchyName, dimensionName);
|
|
231
|
+
try {
|
|
232
|
+
const dim = new Dimension_1.Dimension(dimensionName, [newHierarchy]);
|
|
233
|
+
await dimensionService.create(dim);
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
const isAlreadyExists = (e instanceof TM1Exception_1.TM1RestException && e.statusCode === 409)
|
|
237
|
+
|| (e.message && e.message.includes('already exists'));
|
|
238
|
+
if (isAlreadyExists) {
|
|
239
|
+
// Dimension exists but hierarchy doesn't — create just the hierarchy
|
|
240
|
+
await this.create(newHierarchy);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
throw e;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
hierarchy = await this.get(dimensionName, hierarchyName);
|
|
247
|
+
}
|
|
248
|
+
// Unwind edges if requested
|
|
249
|
+
if (unwindAll) {
|
|
250
|
+
await this.removeAllEdges(dimensionName, hierarchyName);
|
|
251
|
+
}
|
|
252
|
+
else if (unwindConsolidations && unwindConsolidations.length > 0) {
|
|
253
|
+
for (const consolidation of unwindConsolidations) {
|
|
254
|
+
try {
|
|
255
|
+
await this.removeEdgesUnderConsolidation(dimensionName, hierarchyName, consolidation);
|
|
256
|
+
}
|
|
257
|
+
catch (e) {
|
|
258
|
+
if (!(e instanceof TM1Exception_1.TM1RestException && e.statusCode === 404)) {
|
|
259
|
+
throw e;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// Re-fetch hierarchy only if edges were modified
|
|
265
|
+
if (unwindAll || (unwindConsolidations && unwindConsolidations.length > 0)) {
|
|
266
|
+
hierarchy = await this.get(dimensionName, hierarchyName);
|
|
267
|
+
}
|
|
268
|
+
// Add new elements not already in hierarchy
|
|
269
|
+
const existingElementNames = new Utils_1.CaseAndSpaceInsensitiveSet(hierarchy.elements.map(e => e.name));
|
|
270
|
+
const newElements = elementsToAdd.filter(e => !existingElementNames.has(e.name));
|
|
271
|
+
// Ensure parent elements from edges exist as Consolidated type
|
|
272
|
+
const newElementNames = new Utils_1.CaseAndSpaceInsensitiveSet(newElements.map(e => e.name));
|
|
273
|
+
const parentElementsToAdd = [];
|
|
274
|
+
for (const parentName of Object.keys(edgesToAdd)) {
|
|
275
|
+
if (!existingElementNames.has(parentName) && !newElementNames.has(parentName)) {
|
|
276
|
+
parentElementsToAdd.push(new Element_1.Element(parentName, Element_1.ElementType.CONSOLIDATED));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const allNewElements = [...newElements, ...parentElementsToAdd];
|
|
280
|
+
if (allNewElements.length > 0) {
|
|
281
|
+
await this.addElements(dimensionName, hierarchyName, allNewElements);
|
|
282
|
+
}
|
|
283
|
+
// Create missing element attributes and write values
|
|
284
|
+
if (attributeColumns.length > 0) {
|
|
285
|
+
const existingAttrs = await this.getElementAttributes(dimensionName, hierarchyName);
|
|
286
|
+
const existingAttrNames = new Utils_1.CaseAndSpaceInsensitiveSet(existingAttrs.map(a => a.name));
|
|
287
|
+
const newAttrs = [];
|
|
288
|
+
for (const col of attributeColumns) {
|
|
289
|
+
if (!existingAttrNames.has(col)) {
|
|
290
|
+
const values = rows.map(r => r[col]).filter(v => v !== undefined && v !== null && v !== '');
|
|
291
|
+
const isNumeric = values.length > 0 && values.every(v => !isNaN(Number(v)));
|
|
292
|
+
newAttrs.push(new ElementAttribute_1.ElementAttribute(col, isNumeric ? 'Numeric' : 'String'));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (newAttrs.length > 0) {
|
|
296
|
+
await this.addElementAttributes(dimensionName, hierarchyName, newAttrs);
|
|
297
|
+
}
|
|
298
|
+
// Write attribute values in parallel batches
|
|
299
|
+
if (attributeValues.size > 0) {
|
|
300
|
+
const cellService = new CellService_1.CellService(this.rest);
|
|
301
|
+
const cubeName = `}ElementAttributes_${dimensionName}`;
|
|
302
|
+
const writePromises = [];
|
|
303
|
+
for (const [elementName, attrs] of attributeValues) {
|
|
304
|
+
for (const [attrName, value] of attrs) {
|
|
305
|
+
writePromises.push(cellService.writeValue(cubeName, [elementName, attrName], value)
|
|
306
|
+
.catch((e) => {
|
|
307
|
+
// Expected: element may not exist in control dimension
|
|
308
|
+
if (!(e instanceof TM1Exception_1.TM1RestException && e.statusCode === 404)) {
|
|
309
|
+
throw e;
|
|
310
|
+
}
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
await Promise.all(writePromises);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// Add edges
|
|
318
|
+
if (Object.keys(edgesToAdd).length > 0) {
|
|
319
|
+
try {
|
|
320
|
+
await this.addEdges(dimensionName, hierarchyName, edgesToAdd);
|
|
321
|
+
}
|
|
322
|
+
catch (bulkError) {
|
|
323
|
+
// Only fall back on client errors (400, 422); re-throw server/network errors
|
|
324
|
+
if (!(bulkError instanceof TM1Exception_1.TM1RestException) ||
|
|
325
|
+
(bulkError.statusCode !== 400 && bulkError.statusCode !== 422)) {
|
|
326
|
+
throw bulkError;
|
|
327
|
+
}
|
|
328
|
+
// Bulk failed due to validation; fall back to individual edge adds
|
|
329
|
+
const edgePromises = [];
|
|
330
|
+
for (const [parent, children] of Object.entries(edgesToAdd)) {
|
|
331
|
+
for (const [child, weight] of Object.entries(children)) {
|
|
332
|
+
edgePromises.push(this.addEdges(dimensionName, hierarchyName, { [parent]: { [child]: weight } })
|
|
333
|
+
.catch((e) => {
|
|
334
|
+
if (e instanceof TM1Exception_1.TM1RestException && e.statusCode === 409) {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
throw e;
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
await Promise.all(edgePromises);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// Delete orphaned consolidations (consolidated elements with no children)
|
|
345
|
+
if (deleteOrphanedConsolidations) {
|
|
346
|
+
const updatedHierarchy = await this.get(dimensionName, hierarchyName);
|
|
347
|
+
const parentNames = new Utils_1.CaseAndSpaceInsensitiveSet();
|
|
348
|
+
for (const [parent] of updatedHierarchy.edges) {
|
|
349
|
+
parentNames.add(parent);
|
|
350
|
+
}
|
|
351
|
+
const elemService = this.getElementService();
|
|
352
|
+
const deletePromises = [];
|
|
353
|
+
for (const element of updatedHierarchy.elements) {
|
|
354
|
+
if (element.elementType === Element_1.ElementType.CONSOLIDATED && !parentNames.has(element.name)) {
|
|
355
|
+
deletePromises.push(elemService.delete(dimensionName, hierarchyName, element.name)
|
|
356
|
+
.catch((e) => {
|
|
357
|
+
// Expected: element may have been deleted already (404)
|
|
358
|
+
if (!(e instanceof TM1Exception_1.TM1RestException && e.statusCode === 404)) {
|
|
359
|
+
throw e;
|
|
360
|
+
}
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
await Promise.all(deletePromises);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
61
367
|
async updateElementAttributes(hierarchy, keepExisting = false) {
|
|
62
368
|
const existingAttributes = await this.getElementAttributes(hierarchy.dimensionName, hierarchy.name);
|
|
63
369
|
const existingByName = new Utils_1.CaseAndSpaceInsensitiveDict();
|
|
@@ -4,6 +4,19 @@ import { ObjectService } from './ObjectService';
|
|
|
4
4
|
import { Process } from '../objects/Process';
|
|
5
5
|
import { ProcessDebugBreakpoint } from '../objects/ProcessDebugBreakpoint';
|
|
6
6
|
import { OperationStatus } from './AsyncOperationService';
|
|
7
|
+
export interface CompileSyntaxError {
|
|
8
|
+
LineNumber: number;
|
|
9
|
+
Message: string;
|
|
10
|
+
}
|
|
11
|
+
interface ValidationError {
|
|
12
|
+
line: number;
|
|
13
|
+
message: string;
|
|
14
|
+
severity: string;
|
|
15
|
+
}
|
|
16
|
+
interface ValidationResult {
|
|
17
|
+
isValid: boolean;
|
|
18
|
+
errors: ValidationError[];
|
|
19
|
+
}
|
|
7
20
|
export declare class ProcessService extends ObjectService {
|
|
8
21
|
/** Service to handle Object Updates for TI Processes
|
|
9
22
|
*
|
|
@@ -20,19 +33,20 @@ export declare class ProcessService extends ObjectService {
|
|
|
20
33
|
execute(processName: string, parameters?: Record<string, any>): Promise<any>;
|
|
21
34
|
executeWithReturn(processName: string, parameters?: Record<string, any>, timeout?: number): Promise<any>;
|
|
22
35
|
compile(processName: string): Promise<AxiosResponse>;
|
|
23
|
-
compileProcess(
|
|
24
|
-
success: boolean;
|
|
25
|
-
errors: string[];
|
|
26
|
-
}>;
|
|
36
|
+
compileProcess(process: Process): Promise<CompileSyntaxError[]>;
|
|
27
37
|
/**
|
|
28
|
-
* Poll
|
|
38
|
+
* Poll for async execution result
|
|
39
|
+
*
|
|
40
|
+
* :param asyncId: async operation ID returned from executeWithReturn with returnAsyncId=true
|
|
41
|
+
* :return: tuple of [success, status, errorLogFile] or null if not ready
|
|
29
42
|
*/
|
|
30
|
-
pollExecuteWithReturn(
|
|
43
|
+
pollExecuteWithReturn(asyncId: string): Promise<[boolean, string, string | null] | null>;
|
|
44
|
+
private _executeWithReturnParseResponse;
|
|
31
45
|
executeProcessWithReturn(processName: string, parameters?: Record<string, any>): Promise<any>;
|
|
32
46
|
getLastMessageFromMessagelog(_processName: string): Promise<string>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
debugGetBreakpoints(debugId: string): Promise<ProcessDebugBreakpoint[]>;
|
|
48
|
+
debugAddBreakpoint(debugId: string, breakpoint: ProcessDebugBreakpoint): Promise<AxiosResponse>;
|
|
49
|
+
debugRemoveBreakpoint(debugId: string, breakpointId: number): Promise<AxiosResponse>;
|
|
36
50
|
/**
|
|
37
51
|
* Add multiple breakpoints to a debug context
|
|
38
52
|
*/
|
|
@@ -105,6 +119,14 @@ export declare class ProcessService extends ObjectService {
|
|
|
105
119
|
* ProcessQuit is called (status=QuitCalled), otherwise completes successfully.
|
|
106
120
|
*/
|
|
107
121
|
evaluateBooleanTiExpression(expression: string): Promise<boolean>;
|
|
122
|
+
/**
|
|
123
|
+
* Evaluate a TI expression and return the string result.
|
|
124
|
+
*
|
|
125
|
+
* Creates a temporary process with sFunc = {formula}, compiles it,
|
|
126
|
+
* starts a debug session, adds a data breakpoint on sFunc, continues
|
|
127
|
+
* execution to evaluate, reads the result, and cleans up.
|
|
128
|
+
*/
|
|
129
|
+
evaluateTiExpression(formula: string): Promise<string>;
|
|
108
130
|
/**
|
|
109
131
|
* Analyze process dependencies (what cubes/dimensions/processes it uses)
|
|
110
132
|
*
|
|
@@ -114,8 +136,8 @@ export declare class ProcessService extends ObjectService {
|
|
|
114
136
|
* @example
|
|
115
137
|
* ```typescript
|
|
116
138
|
* const deps = await processService.analyzeProcessDependencies('ImportData');
|
|
117
|
-
*
|
|
118
|
-
*
|
|
139
|
+
* // deps.cubes => array of cube names referenced in the process
|
|
140
|
+
* // deps.dimensions => array of dimension names referenced in the process
|
|
119
141
|
* ```
|
|
120
142
|
*/
|
|
121
143
|
analyzeProcessDependencies(processName: string): Promise<any>;
|
|
@@ -123,20 +145,17 @@ export declare class ProcessService extends ObjectService {
|
|
|
123
145
|
* Validate process syntax without executing it
|
|
124
146
|
*
|
|
125
147
|
* @param processName - Name of the process
|
|
126
|
-
* @returns Promise<
|
|
148
|
+
* @returns Promise<ValidationResult> - Validation result
|
|
127
149
|
*
|
|
128
150
|
* @example
|
|
129
151
|
* ```typescript
|
|
130
152
|
* const result = await processService.validateProcessSyntax('MyProcess');
|
|
131
153
|
* if (!result.isValid) {
|
|
132
|
-
*
|
|
154
|
+
* // result.errors contains ValidationError[] entries
|
|
133
155
|
* }
|
|
134
156
|
* ```
|
|
135
157
|
*/
|
|
136
|
-
validateProcessSyntax(processName: string): Promise<
|
|
137
|
-
isValid: boolean;
|
|
138
|
-
errors: any[];
|
|
139
|
-
}>;
|
|
158
|
+
validateProcessSyntax(processName: string): Promise<ValidationResult>;
|
|
140
159
|
/**
|
|
141
160
|
* Get process execution plan (estimated resource usage)
|
|
142
161
|
*
|
|
@@ -146,7 +165,7 @@ export declare class ProcessService extends ObjectService {
|
|
|
146
165
|
* @example
|
|
147
166
|
* ```typescript
|
|
148
167
|
* const plan = await processService.getProcessExecutionPlan('ImportData');
|
|
149
|
-
*
|
|
168
|
+
* // plan.estimatedTime => estimated execution time (ms)
|
|
150
169
|
* ```
|
|
151
170
|
*/
|
|
152
171
|
getProcessExecutionPlan(processName: string): Promise<any>;
|
|
@@ -176,9 +195,7 @@ export declare class ProcessService extends ObjectService {
|
|
|
176
195
|
* @example
|
|
177
196
|
* ```typescript
|
|
178
197
|
* const status = await processService.pollProcessExecution(operationId);
|
|
179
|
-
* if (status === OperationStatus.COMPLETED)
|
|
180
|
-
* console.log('Process completed!');
|
|
181
|
-
* }
|
|
198
|
+
* // if (status === OperationStatus.COMPLETED) handle completion
|
|
182
199
|
* ```
|
|
183
200
|
*/
|
|
184
201
|
pollProcessExecution(operationId: string): Promise<OperationStatus>;
|
|
@@ -191,9 +208,10 @@ export declare class ProcessService extends ObjectService {
|
|
|
191
208
|
* @example
|
|
192
209
|
* ```typescript
|
|
193
210
|
* await processService.cancelProcessExecution(operationId);
|
|
194
|
-
*
|
|
211
|
+
* // cancellation is acknowledged once the promise resolves
|
|
195
212
|
* ```
|
|
196
213
|
*/
|
|
197
214
|
cancelProcessExecution(operationId: string): Promise<void>;
|
|
198
215
|
}
|
|
216
|
+
export {};
|
|
199
217
|
//# sourceMappingURL=ProcessService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessService.d.ts","sourceRoot":"","sources":["../../src/services/ProcessService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,
|
|
1
|
+
{"version":3,"file":"ProcessService.d.ts","sourceRoot":"","sources":["../../src/services/ProcessService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAA2B,MAAM,mCAAmC,CAAC;AAGpG,OAAO,EAAE,eAAe,EAAiB,MAAM,yBAAyB,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACnB;AAWD,UAAU,eAAe;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,gBAAgB;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED,qBAAa,cAAe,SAAQ,aAAa;IAC7C;;OAEG;gBAES,IAAI,EAAE,WAAW;IAIhB,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1C,MAAM,CAAC,oBAAoB,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA+BjE,WAAW,CAAC,oBAAoB,GAAE,OAAe,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAerE,kBA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