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.
Files changed (78) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/lib/index.d.ts +1 -1
  3. package/lib/index.d.ts.map +1 -1
  4. package/lib/services/ApplicationService.d.ts +19 -3
  5. package/lib/services/ApplicationService.d.ts.map +1 -1
  6. package/lib/services/ApplicationService.js +232 -6
  7. package/lib/services/AsyncOperationService.d.ts +8 -1
  8. package/lib/services/AsyncOperationService.d.ts.map +1 -1
  9. package/lib/services/AsyncOperationService.js +69 -26
  10. package/lib/services/ElementService.d.ts +67 -1
  11. package/lib/services/ElementService.d.ts.map +1 -1
  12. package/lib/services/ElementService.js +214 -0
  13. package/lib/services/FileService.d.ts.map +1 -1
  14. package/lib/services/HierarchyService.d.ts +26 -0
  15. package/lib/services/HierarchyService.d.ts.map +1 -1
  16. package/lib/services/HierarchyService.js +306 -0
  17. package/lib/services/ProcessService.d.ts +40 -22
  18. package/lib/services/ProcessService.d.ts.map +1 -1
  19. package/lib/services/ProcessService.js +118 -111
  20. package/lib/services/RestService.d.ts +213 -25
  21. package/lib/services/RestService.d.ts.map +1 -1
  22. package/lib/services/RestService.js +841 -263
  23. package/lib/services/SubsetService.d.ts +2 -0
  24. package/lib/services/SubsetService.d.ts.map +1 -1
  25. package/lib/services/SubsetService.js +33 -0
  26. package/lib/services/TM1Service.d.ts +44 -1
  27. package/lib/services/TM1Service.d.ts.map +1 -1
  28. package/lib/services/TM1Service.js +96 -4
  29. package/lib/services/index.d.ts +1 -1
  30. package/lib/services/index.d.ts.map +1 -1
  31. package/lib/tests/100PercentParityCheck.test.js +23 -6
  32. package/lib/tests/applicationService.issue38.test.d.ts +5 -0
  33. package/lib/tests/applicationService.issue38.test.d.ts.map +1 -0
  34. package/lib/tests/applicationService.issue38.test.js +237 -0
  35. package/lib/tests/asyncOperationService.test.js +51 -45
  36. package/lib/tests/bugfix28.test.js +12 -4
  37. package/lib/tests/elementService.issue37.test.d.ts +5 -0
  38. package/lib/tests/elementService.issue37.test.d.ts.map +1 -0
  39. package/lib/tests/elementService.issue37.test.js +413 -0
  40. package/lib/tests/elementService.issue38.test.d.ts +5 -0
  41. package/lib/tests/elementService.issue38.test.d.ts.map +1 -0
  42. package/lib/tests/elementService.issue38.test.js +79 -0
  43. package/lib/tests/hierarchyService.issue38.test.d.ts +5 -0
  44. package/lib/tests/hierarchyService.issue38.test.d.ts.map +1 -0
  45. package/lib/tests/hierarchyService.issue38.test.js +460 -0
  46. package/lib/tests/processService.comprehensive.test.js +9 -9
  47. package/lib/tests/processService.test.js +234 -0
  48. package/lib/tests/restService.test.d.ts +0 -4
  49. package/lib/tests/restService.test.d.ts.map +1 -1
  50. package/lib/tests/restService.test.js +1558 -143
  51. package/lib/tests/subsetService.issue38.test.d.ts +5 -0
  52. package/lib/tests/subsetService.issue38.test.d.ts.map +1 -0
  53. package/lib/tests/subsetService.issue38.test.js +113 -0
  54. package/lib/tests/tm1Service.test.js +80 -8
  55. package/package.json +1 -1
  56. package/src/index.ts +1 -1
  57. package/src/services/ApplicationService.ts +282 -10
  58. package/src/services/AsyncOperationService.ts +76 -29
  59. package/src/services/ElementService.ts +322 -1
  60. package/src/services/FileService.ts +3 -3
  61. package/src/services/HierarchyService.ts +419 -1
  62. package/src/services/ProcessService.ts +185 -142
  63. package/src/services/RestService.ts +1021 -267
  64. package/src/services/SubsetService.ts +48 -0
  65. package/src/services/TM1Service.ts +127 -6
  66. package/src/services/index.ts +1 -1
  67. package/src/tests/100PercentParityCheck.test.ts +29 -8
  68. package/src/tests/applicationService.issue38.test.ts +293 -0
  69. package/src/tests/asyncOperationService.test.ts +52 -48
  70. package/src/tests/bugfix28.test.ts +12 -4
  71. package/src/tests/elementService.issue37.test.ts +571 -0
  72. package/src/tests/elementService.issue38.test.ts +103 -0
  73. package/src/tests/hierarchyService.issue38.test.ts +599 -0
  74. package/src/tests/processService.comprehensive.test.ts +10 -10
  75. package/src/tests/processService.test.ts +295 -3
  76. package/src/tests/restService.test.ts +1844 -139
  77. package/src/tests/subsetService.issue38.test.ts +182 -0
  78. package/src/tests/tm1Service.test.ts +95 -11
package/CHANGELOG.md ADDED
@@ -0,0 +1,89 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ ## 2.0.0 — 2026-04-16
6
+
7
+ ### BREAKING CHANGES
8
+
9
+ **RestService HTTP methods now use tm1py-parity semantics**
10
+ (see [#80](https://github.com/KimKaoPoo/tm1npm/pull/95)).
11
+
12
+ - **Timeout unit is seconds, not milliseconds.** `get/post/patch/put/delete`
13
+ now accept a `RequestOptions` object (extending `Omit<AxiosRequestConfig,
14
+ 'timeout'>`) whose `timeout` is specified in seconds to match tm1py's
15
+ `RestService.request(timeout: float)`. The value is converted to
16
+ milliseconds internally before reaching Axios.
17
+ - Migration: `rest.get(url, { timeout: 30000 })` → `rest.get(url, { timeout: 30 })`.
18
+ - TypeScript will **not** flag the change because both old and new
19
+ values are `number`; audit call sites before upgrading.
20
+ - Heuristic to find likely millisecond-valued call sites:
21
+ ```
22
+ rg -n 'rest\.(get|post|patch|put|delete).*timeout:\s*\d{4,}' src/
23
+ ```
24
+
25
+ - **`retrieve_async_response` now returns the full `AxiosResponse`**
26
+ instead of `response.data`. This matches tm1py's `retrieve_async_response`
27
+ which returns `requests.Response`.
28
+ - Migration: `(await rest.retrieve_async_response(id)).Status` →
29
+ `(await rest.retrieve_async_response(id)).data.Status`.
30
+
31
+ - **`get_async_operation_status` was removed.** The `/_async('{id}')`
32
+ endpoint does not expose a `Status` sub-resource, so the helper always
33
+ returned `'Unknown'` on real servers. Use `retrieve_async_response` and
34
+ inspect the response status instead.
35
+
36
+ - **`wait_for_async_operation` parameter order.** `cancel_at_timeout` is
37
+ now the fourth parameter (after `poll_interval_seconds`) to preserve
38
+ the pre-existing signature of callers passing a polling cadence.
39
+
40
+ - **`getConnectionStats().timeout` is now in seconds** (was
41
+ `(config.timeout || 60) * 1000` i.e. milliseconds). Dashboards or
42
+ logging that compare the value against an ms threshold will need
43
+ updating.
44
+ - Migration: `stats.timeout / 1000` → `stats.timeout` (already seconds).
45
+
46
+ ### Added
47
+
48
+ - Central `_request()` dispatcher in `RestService` that routes to sync or
49
+ async execution and honors new per-request options: `asyncRequestsMode`,
50
+ `returnAsyncId`, `cancelAtTimeout`, `timeout` (seconds), `idempotent`,
51
+ `verifyResponse`.
52
+ - `_executeAsyncRequest` sends `Prefer: respond-async[,wait=55]`, parses
53
+ the `Location` header on `202 Accepted`, and polls `/_async('{id}')`
54
+ via `waitTimeGenerator` (exponential backoff capped at
55
+ `asyncPollingMaxDelay`).
56
+ - `cancel_async_operation` and `retrieve_async_response` now target the
57
+ correct TM1 v12 endpoint `/_async('{id}')` (previously
58
+ `/AsyncOperations('{id}')`). `AsyncOperationService` updated to match.
59
+ - `wait_for_async_operation` detects the `asyncresult` response header
60
+ and throws `TM1RestException` on non-2xx embedded status codes to
61
+ match tm1py's `_transform_async_response` semantics.
62
+
63
+ ### Changed
64
+
65
+ - 5xx and network-level retries in the response interceptor now only
66
+ apply when the request is marked `idempotent: true` (default `true`
67
+ for GET, `false` for POST/PATCH/PUT/DELETE).
68
+ - `verifyResponse: false` honors a caller-supplied `validateStatus`
69
+ instead of silently overwriting it.
70
+ - `AsyncOperationService.createAsyncOperation` now marks returned
71
+ operations with `trackedLocally: true` so `getAsyncOperationStatus`
72
+ reads from the in-memory cache instead of polling `/_async('{id}')`
73
+ with a client-side UUID (which the server does not recognize).
74
+ `ProcessService.executeWithReturnAsync` / `pollProcessExecution`
75
+ depend on this behavior for their background-resolve pattern.
76
+ - `retrieve_async_response` no longer throws on non-2xx statuses; it
77
+ returns the raw `AxiosResponse` so the internal poller can retry on
78
+ transient 404s (resource not yet materialized) without aborting.
79
+
80
+ ### Known Parity Gaps
81
+
82
+ - **No `cancel_running_operation` / thread cancellation on sync
83
+ timeout.** tm1py's `request()` catches `Timeout` / `ConnectionError`
84
+ and calls `cancel_running_operation()` (which uses
85
+ `MonitoringService.cancel_thread()` to abort the server-side thread).
86
+ tm1npm cancels via `DELETE /_async('{id}')` in the async-polling path,
87
+ but has no top-level thread-cancellation fallback for sync-mode
88
+ timeouts or pre-202 async timeouts. Tracked for a future PR once
89
+ `MonitoringService.cancelThread` is implemented.
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { DimensionService } from './services/DimensionService';
4
4
  export { HierarchyService } from './services/HierarchyService';
5
5
  export { SubsetService } from './services/SubsetService';
6
6
  export { ObjectService } from './services/ObjectService';
7
- export { CubeService, ElementService, CellService, ProcessService, ViewService, SecurityService, FileService, SessionService, ConfigurationService, ServerService, MonitoringService, AnnotationService, ApplicationService, AuditLogService, ChoreService, GitService, JobService, LoggerService, ManageService, MessageLogService, PowerBiService, SandboxService, ThreadService, TransactionLogService, UserService } from './services';
7
+ export { CubeService, ElementService, CellService, ProcessService, CompileSyntaxError, ViewService, SecurityService, FileService, SessionService, ConfigurationService, ServerService, MonitoringService, AnnotationService, ApplicationService, AuditLogService, ChoreService, GitService, JobService, LoggerService, ManageService, MessageLogService, PowerBiService, SandboxService, ThreadService, TransactionLogService, UserService } from './services';
8
8
  export { TM1Object } from './objects/TM1Object';
9
9
  export { Dimension } from './objects/Dimension';
10
10
  export { Hierarchy } from './objects/Hierarchy';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0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GvE,eAAO,MAAM,OAAO,UAAU,CAAC"}
@@ -3,23 +3,39 @@ import { RestService } from './RestService';
3
3
  import { ObjectService } from './ObjectService';
4
4
  import { Application, ApplicationTypes, DocumentApplication } from '../objects/Application';
5
5
  export declare class ApplicationService extends ObjectService {
6
+ private pathCache;
6
7
  constructor(rest: RestService);
8
+ clearPathCache(): void;
7
9
  getAllPublicRootNames(): Promise<string[]>;
8
10
  getAllPrivateRootNames(): Promise<string[]>;
9
- getNames(path: string, isPrivate?: boolean): Promise<string[]>;
10
- get(path: string, applicationType: string | ApplicationTypes, name: string, isPrivate?: boolean): Promise<Application>;
11
+ getNames(path: string, isPrivate?: boolean, useCache?: boolean): Promise<string[]>;
12
+ get(path: string, applicationType: string | ApplicationTypes, name: string, isPrivate?: boolean, useCache?: boolean): Promise<Application>;
11
13
  getDocument(path: string, name: string, isPrivate?: boolean): Promise<DocumentApplication>;
12
14
  create(application: Application, isPrivate?: boolean): Promise<AxiosResponse>;
13
15
  update(application: Application, isPrivate?: boolean): Promise<AxiosResponse>;
14
16
  delete(path: string, applicationType: ApplicationTypes, name: string, isPrivate?: boolean): Promise<AxiosResponse>;
15
17
  rename(path: string, applicationType: ApplicationTypes, currentName: string, newName: string, isPrivate?: boolean): Promise<AxiosResponse>;
16
- exists(path: string, applicationType: ApplicationTypes, name: string, isPrivate?: boolean): Promise<boolean>;
18
+ exists(path: string, applicationType: ApplicationTypes, name: string, isPrivate?: boolean, useCache?: boolean): Promise<boolean>;
17
19
  updateOrCreate(application: Application, isPrivate?: boolean): Promise<AxiosResponse>;
18
20
  updateOrCreateDocumentFromFile(path: string, name: string, filePath: string, isPrivate?: boolean): Promise<AxiosResponse>;
19
21
  createDocumentFromFile(filePath: string, applicationPath: string, applicationName: string, isPrivate?: boolean): Promise<AxiosResponse>;
20
22
  updateDocumentFromFile(filePath: string, applicationPath: string, applicationName: string, isPrivate?: boolean): Promise<AxiosResponse>;
23
+ discover(path?: string, includePrivate?: boolean, recursive?: boolean, _flat?: boolean): Promise<Array<{
24
+ type: string;
25
+ name: string;
26
+ path: string;
27
+ is_private: boolean;
28
+ }>>;
29
+ private _discoverAtPath;
30
+ private _getContentsRaw;
31
+ private _processItems;
32
+ private _extractTypeFromOdata;
33
+ private _findPrivateBoundary;
34
+ private _buildPathUrl;
35
+ private _resolvePath;
21
36
  private parseApplicationType;
22
37
  private buildPathSegments;
38
+ private buildPrivatePathSegments;
23
39
  private getContentsCollection;
24
40
  private buildApplicationUrl;
25
41
  private withLegacySuffix;
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationService.d.ts","sourceRoot":"","sources":["../../src/services/ApplicationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACH,WAAW,EACX,gBAAgB,EAIhB,mBAAmB,EAOtB,MAAM,wBAAwB,CAAC;AAGhC,qBAAa,kBAAmB,SAAQ,aAAa;gBACrC,IAAI,EAAE,WAAW;IAIhB,qBAAqB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAM1C,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAM3C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAQrE,GAAG,CACZ,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,MAAM,GAAG,gBAAgB,EAC1C,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,OAAe,GAC3B,OAAO,CAAC,WAAW,CAAC;IAsEV,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA8BjG,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,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,CAAC,CAAC;YAItE,eAAe;YA2Bf,eAAe;YAmBf,aAAa;IA0C3B,OAAO,CAAC,qBAAqB;YASf,oBAAoB;IA0BlC,OAAO,CAAC,aAAa;YAgBP,YAAY;IA0E1B,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,wBAAwB;IAWhC,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,eAAe;CAO1B"}
@@ -5,9 +5,14 @@ const fs_1 = require("fs");
5
5
  const ObjectService_1 = require("./ObjectService");
6
6
  const Application_1 = require("../objects/Application");
7
7
  const Utils_1 = require("../utils/Utils");
8
+ const TM1Exception_1 = require("../exceptions/TM1Exception");
8
9
  class ApplicationService extends ObjectService_1.ObjectService {
9
10
  constructor(rest) {
10
11
  super(rest);
12
+ this.pathCache = new Map();
13
+ }
14
+ clearPathCache() {
15
+ this.pathCache.clear();
11
16
  }
12
17
  async getAllPublicRootNames() {
13
18
  const url = "/Contents('Applications')/Contents";
@@ -19,21 +24,35 @@ class ApplicationService extends ObjectService_1.ObjectService {
19
24
  const response = await this.rest.get(url);
20
25
  return response.data.value.map((application) => application.Name);
21
26
  }
22
- async getNames(path, isPrivate = false) {
27
+ async getNames(path, isPrivate = false, useCache = false) {
28
+ if (isPrivate) {
29
+ const resolved = await this._resolvePath(path, true, useCache);
30
+ // Leaf collection is always PrivateContents when isPrivate — even if parent path is public
31
+ const url = resolved.baseUrl + '/PrivateContents';
32
+ const response = await this.rest.get(url);
33
+ return response.data.value.map((application) => application.Name);
34
+ }
23
35
  const contents = this.getContentsCollection(isPrivate);
24
36
  const mid = this.buildPathSegments(path);
25
37
  const baseUrl = "/Contents('Applications')" + mid + "/" + contents;
26
38
  const response = await this.rest.get(baseUrl);
27
39
  return response.data.value.map((application) => application.Name);
28
40
  }
29
- async get(path, applicationType, name, isPrivate = false) {
41
+ async get(path, applicationType, name, isPrivate = false, useCache = false) {
30
42
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
31
43
  const appType = this.parseApplicationType(applicationType);
32
44
  if (appType === Application_1.ApplicationTypes.DOCUMENT) {
33
45
  return await this.getDocument(path, name, isPrivate);
34
46
  }
35
47
  const requestName = this.withLegacySuffix(name, appType);
36
- const baseUrl = this.buildApplicationUrl(path, isPrivate, requestName);
48
+ let baseUrl;
49
+ if (isPrivate) {
50
+ const resolved = await this._resolvePath(path, true, useCache);
51
+ baseUrl = (0, Utils_1.formatUrl)(resolved.baseUrl + "/PrivateContents('{}')", requestName);
52
+ }
53
+ else {
54
+ baseUrl = this.buildApplicationUrl(path, isPrivate, requestName);
55
+ }
37
56
  switch (appType) {
38
57
  case Application_1.ApplicationTypes.CUBE: {
39
58
  const response = await this.rest.get(baseUrl + "?$expand=Cube($select=Name)");
@@ -55,7 +74,6 @@ class ApplicationService extends ObjectService_1.ObjectService {
55
74
  return new Application_1.FolderApplication(path, name);
56
75
  }
57
76
  case Application_1.ApplicationTypes.LINK: {
58
- await this.rest.get(baseUrl);
59
77
  const response = await this.rest.get(baseUrl + "?$expand=*");
60
78
  return new Application_1.LinkApplication(path, ((_o = response.data) === null || _o === void 0 ? void 0 : _o.Name) || name, ((_p = response.data) === null || _p === void 0 ? void 0 : _p.URL) || '');
61
79
  }
@@ -135,10 +153,27 @@ class ApplicationService extends ObjectService_1.ObjectService {
135
153
  const payload = { Name: newName };
136
154
  return await this.rest.post(url, JSON.stringify(payload));
137
155
  }
138
- async exists(path, applicationType, name, isPrivate = false) {
156
+ async exists(path, applicationType, name, isPrivate = false, useCache = false) {
157
+ const requestName = this.withLegacySuffix(name, applicationType);
158
+ if (isPrivate) {
159
+ try {
160
+ const resolved = await this._resolvePath(path, true, useCache);
161
+ const url = (0, Utils_1.formatUrl)(resolved.baseUrl + "/PrivateContents('{}')", requestName);
162
+ return await this._exists(url);
163
+ }
164
+ catch (error) {
165
+ // Path-not-found from _resolvePath means item doesn't exist
166
+ if (error instanceof Error && error.message.includes('not found')) {
167
+ return false;
168
+ }
169
+ if (error instanceof TM1Exception_1.TM1RestException && error.statusCode === 404) {
170
+ return false;
171
+ }
172
+ throw error;
173
+ }
174
+ }
139
175
  const contents = this.getContentsCollection(isPrivate);
140
176
  const mid = this.buildPathSegments(path);
141
- const requestName = this.withLegacySuffix(name, applicationType);
142
177
  const url = (0, Utils_1.formatUrl)("/Contents('Applications')" + mid + "/" + contents + "('{}')", requestName);
143
178
  return await this._exists(url);
144
179
  }
@@ -166,6 +201,187 @@ class ApplicationService extends ObjectService_1.ObjectService {
166
201
  const document = new Application_1.DocumentApplication(applicationPath, applicationName, content);
167
202
  return await this.update(document, isPrivate);
168
203
  }
204
+ // NOTE: `flat` parameter is accepted for tm1py signature parity but output is always flat.
205
+ // Nested (tree) mode is not yet implemented.
206
+ async discover(path = '', includePrivate = false, recursive = false, _flat = false) {
207
+ return this._discoverAtPath(path, includePrivate, recursive, false);
208
+ }
209
+ async _discoverAtPath(path, includePrivate, recursive, inPrivateContext) {
210
+ const results = [];
211
+ if (!inPrivateContext) {
212
+ const publicItems = await this._getContentsRaw(path, false, false);
213
+ const processed = await this._processItems(publicItems, path, false, includePrivate, recursive, false);
214
+ results.push(...processed);
215
+ }
216
+ if (includePrivate || inPrivateContext) {
217
+ const privateItems = await this._getContentsRaw(path, true, inPrivateContext);
218
+ const processed = await this._processItems(privateItems, path, true, includePrivate, recursive, true);
219
+ results.push(...processed);
220
+ }
221
+ return results;
222
+ }
223
+ async _getContentsRaw(path, isPrivate, inPrivateContext) {
224
+ var _a;
225
+ try {
226
+ // Path segments: use PrivateContents only if we're already inside a private folder tree.
227
+ // Leaf collection: PrivateContents if isPrivate or inPrivateContext, else Contents.
228
+ const mid = inPrivateContext
229
+ ? this.buildPrivatePathSegments(path)
230
+ : this.buildPathSegments(path);
231
+ const collection = (inPrivateContext || isPrivate) ? 'PrivateContents' : 'Contents';
232
+ const url = "/Contents('Applications')" + mid + "/" + collection;
233
+ const response = await this.rest.get(url);
234
+ return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.value) || [];
235
+ }
236
+ catch (error) {
237
+ if (error instanceof TM1Exception_1.TM1RestException && error.statusCode === 404) {
238
+ return [];
239
+ }
240
+ throw error;
241
+ }
242
+ }
243
+ async _processItems(items, path, isPrivate, includePrivate, recursive, inPrivateContext) {
244
+ const results = [];
245
+ const folderPromises = [];
246
+ for (const item of items) {
247
+ const odataType = item['@odata.type'] || '';
248
+ const typeName = this._extractTypeFromOdata(odataType);
249
+ const itemName = item.Name || '';
250
+ const itemPath = path ? `${path}/${itemName}` : itemName;
251
+ results.push({
252
+ type: typeName,
253
+ name: itemName,
254
+ path: itemPath,
255
+ is_private: isPrivate || inPrivateContext
256
+ });
257
+ if (recursive && typeName === 'Folder') {
258
+ folderPromises.push(this._discoverAtPath(itemPath, includePrivate, recursive, inPrivateContext || isPrivate));
259
+ }
260
+ }
261
+ const folderResults = await Promise.all(folderPromises);
262
+ for (const subItems of folderResults) {
263
+ results.push(...subItems);
264
+ }
265
+ return results;
266
+ }
267
+ _extractTypeFromOdata(odataType) {
268
+ if (!odataType)
269
+ return 'Unknown';
270
+ const parts = odataType.split('.');
271
+ const raw = parts[parts.length - 1] || 'Unknown';
272
+ // TM1 returns types like 'FolderApplication', 'CubeApplication' — strip suffix
273
+ // so folder check works consistently
274
+ return raw.replace(/Application$/, '') || raw;
275
+ }
276
+ async _findPrivateBoundary(segments) {
277
+ let publicUrl = "/Contents('Applications')";
278
+ for (let i = 0; i < segments.length; i++) {
279
+ const testUrl = publicUrl + (0, Utils_1.formatUrl)("/Contents('{}')", segments[i]) + "?$top=0";
280
+ try {
281
+ await this.rest.get(testUrl);
282
+ publicUrl += (0, Utils_1.formatUrl)("/Contents('{}')", segments[i]);
283
+ }
284
+ catch (error) {
285
+ if (error instanceof TM1Exception_1.TM1RestException && error.statusCode === 404) {
286
+ const privateTestUrl = publicUrl + (0, Utils_1.formatUrl)("/PrivateContents('{}')", segments[i]) + "?$top=0";
287
+ try {
288
+ await this.rest.get(privateTestUrl);
289
+ return i;
290
+ }
291
+ catch (innerError) {
292
+ if (innerError instanceof TM1Exception_1.TM1RestException && innerError.statusCode === 404) {
293
+ return -1;
294
+ }
295
+ throw innerError;
296
+ }
297
+ }
298
+ throw error;
299
+ }
300
+ }
301
+ return segments.length;
302
+ }
303
+ _buildPathUrl(segments, privateBoundary) {
304
+ if (!segments.length)
305
+ return '';
306
+ let url = '';
307
+ const boundary = privateBoundary !== null && privateBoundary !== void 0 ? privateBoundary : segments.length;
308
+ for (let i = 0; i < segments.length; i++) {
309
+ if (i < boundary) {
310
+ url += (0, Utils_1.formatUrl)("/Contents('{}')", segments[i]);
311
+ }
312
+ else {
313
+ url += (0, Utils_1.formatUrl)("/PrivateContents('{}')", segments[i]);
314
+ }
315
+ }
316
+ return url;
317
+ }
318
+ async _resolvePath(path, isPrivate = false, useCache = false) {
319
+ if (!path || !path.trim()) {
320
+ return { baseUrl: "/Contents('Applications')", inPrivateContext: isPrivate };
321
+ }
322
+ const segments = path.split('/').filter(s => s.trim().length > 0);
323
+ if (!isPrivate) {
324
+ const mid = segments.map(s => (0, Utils_1.formatUrl)("/Contents('{}')", s)).join('');
325
+ return { baseUrl: "/Contents('Applications')" + mid, inPrivateContext: false };
326
+ }
327
+ const cacheKey = path;
328
+ if (useCache && this.pathCache.has(cacheKey)) {
329
+ const boundary = this.pathCache.get(cacheKey);
330
+ const mid = this._buildPathUrl(segments, boundary);
331
+ return {
332
+ baseUrl: "/Contents('Applications')" + mid,
333
+ inPrivateContext: boundary < segments.length
334
+ };
335
+ }
336
+ // Try all-public first (optimistic)
337
+ try {
338
+ const publicUrl = "/Contents('Applications')" +
339
+ segments.map(s => (0, Utils_1.formatUrl)("/Contents('{}')", s)).join('') + "?$top=0";
340
+ await this.rest.get(publicUrl);
341
+ if (useCache)
342
+ this.pathCache.set(cacheKey, segments.length);
343
+ return {
344
+ baseUrl: "/Contents('Applications')" +
345
+ segments.map(s => (0, Utils_1.formatUrl)("/Contents('{}')", s)).join(''),
346
+ inPrivateContext: false
347
+ };
348
+ }
349
+ catch (error) {
350
+ if (!(error instanceof TM1Exception_1.TM1RestException && error.statusCode === 404)) {
351
+ throw error;
352
+ }
353
+ }
354
+ // Try all-private
355
+ try {
356
+ const privateUrl = "/Contents('Applications')" +
357
+ segments.map(s => (0, Utils_1.formatUrl)("/PrivateContents('{}')", s)).join('') + "?$top=0";
358
+ await this.rest.get(privateUrl);
359
+ if (useCache)
360
+ this.pathCache.set(cacheKey, 0);
361
+ return {
362
+ baseUrl: "/Contents('Applications')" +
363
+ segments.map(s => (0, Utils_1.formatUrl)("/PrivateContents('{}')", s)).join(''),
364
+ inPrivateContext: true
365
+ };
366
+ }
367
+ catch (error) {
368
+ if (!(error instanceof TM1Exception_1.TM1RestException && error.statusCode === 404)) {
369
+ throw error;
370
+ }
371
+ }
372
+ // Iterative boundary search
373
+ const boundary = await this._findPrivateBoundary(segments);
374
+ if (boundary === -1) {
375
+ throw new Error(`Application path not found: ${path}`);
376
+ }
377
+ if (useCache)
378
+ this.pathCache.set(cacheKey, boundary);
379
+ const mid = this._buildPathUrl(segments, boundary);
380
+ return {
381
+ baseUrl: "/Contents('Applications')" + mid,
382
+ inPrivateContext: boundary < segments.length
383
+ };
384
+ }
169
385
  parseApplicationType(applicationType) {
170
386
  if (typeof applicationType === 'string') {
171
387
  const upper = applicationType.toUpperCase();
@@ -186,6 +402,16 @@ class ApplicationService extends ObjectService_1.ObjectService {
186
402
  .map(segment => (0, Utils_1.formatUrl)("/Contents('{}')", segment))
187
403
  .join('');
188
404
  }
405
+ buildPrivatePathSegments(path) {
406
+ if (!path || !path.trim()) {
407
+ return '';
408
+ }
409
+ return path
410
+ .split('/')
411
+ .filter(segment => segment.trim().length > 0)
412
+ .map(segment => (0, Utils_1.formatUrl)("/PrivateContents('{}')", segment))
413
+ .join('');
414
+ }
189
415
  getContentsCollection(isPrivate) {
190
416
  return isPrivate ? 'PrivateContents' : 'Contents';
191
417
  }
@@ -46,6 +46,12 @@ export interface AsyncOperation {
46
46
  result?: any;
47
47
  parameters?: Record<string, any>;
48
48
  metadata?: Record<string, any>;
49
+ /**
50
+ * When true, the operation is tracked with a client-side UUID and the
51
+ * TM1 server has no record of it. `getAsyncOperationStatus` returns the
52
+ * cached status instead of polling `/_async('{id}')`.
53
+ */
54
+ trackedLocally?: boolean;
49
55
  }
50
56
  /**
51
57
  * Interface for schedule configuration
@@ -87,6 +93,8 @@ export declare class AsyncOperationService {
87
93
  * @returns Promise resolving to the operation status
88
94
  */
89
95
  getAsyncOperationStatus(operationId: string): Promise<OperationStatus>;
96
+ private deriveStatusFromResponse;
97
+ private extractErrorFromResponse;
90
98
  /**
91
99
  * List all active async operations
92
100
  *
@@ -169,7 +177,6 @@ export declare class AsyncOperationService {
169
177
  getAllOperations(): AsyncOperation[];
170
178
  private generateOperationId;
171
179
  private isTerminalStatus;
172
- private mapServerStatus;
173
180
  private stopPolling;
174
181
  private sleep;
175
182
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncOperationService.d.ts","sourceRoot":"","sources":["../../src/services/AsyncOperationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;GAEG;AACH,oBAAY,eAAe;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,OAAO,YAAY;CACtB;AAED;;GAEG;AACH,oBAAY,aAAa;IACrB,iBAAiB,qBAAqB;IACtC,SAAS,aAAa;IACtB,cAAc,kBAAkB;IAChC,cAAc,kBAAkB;IAChC,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU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CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIpE;;;;OAIG;IACI,0BAA0B,CAAC,QAAQ,GAAE,MAAgB,GAAG,IAAI;IAmBnE;;;;OAIG;IACI,gBAAgB,IAAI,cAAc,EAAE;IAM3C,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,KAAK;IAIb;;OAEG;IACI,OAAO,IAAI,IAAI;CAMzB"}
1
+ {"version":3,"file":"AsyncOperationService.d.ts","sourceRoot":"","sources":["../../src/services/AsyncOperationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;GAEG;AACH,oBAAY,eAAe;IACvB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,OAAO,YAAY;CACtB;AAED;;GAEG;AACH,oBAAY,aAAa;IACrB,iBAAiB,qBAAqB;IACtC,SAAS,aAAa;IACtB,cAAc,kBAAkB;IAChC,cAAc,kBAAkB;IAChC,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ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