@hahnpro/hpc-api 2025.2.12 → 2025.2.15

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @hahnpro/hpc-api
2
2
 
3
+ ## 2025.2.15
4
+
5
+ ### Major Changes
6
+
7
+ - **Breaking Change:** The signature of `timeseries::addAssetTimeSeriesValues` has been changed. Now it includes an additional _metadata_ parameter.
8
+ - **Breaking Change:** The signature of `timeseries::addManyAssetTimeSeriesValues` has been changed. The _timeSeries_ parameter now includes _values_ and _metadata_ fields.
9
+
3
10
  ## 2025.2.0
4
11
 
5
12
  ### Major Changes
@@ -26,13 +33,11 @@
26
33
  The third option is to overwrite the `getAccessToken()` method of the `HttpClient`.
27
34
 
28
35
  The hierarchy of options is:
29
-
30
36
  1. token from api-call
31
37
  2. token from `provideExternalToken`
32
38
  3. token from `getAccessToken`
33
39
 
34
40
  # Breaking Changes
35
-
36
41
  1. The signature of `flowDeployments::updateOne` has been changed. The positional parameter `force` is now part of the `options` object (where you can also provide a token as described above).
37
42
 
38
43
  ## 5.3.4
@@ -130,7 +135,6 @@
130
135
  - 19af51f: Updated dependencies to reduce vulnerabilities
131
136
 
132
137
  **Breaking changes**
133
-
134
138
  - Raise minimum Node.js version to v18 for hpc-api and flow-sdk packages
135
139
 
136
140
  ## 4.1.2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "2025.2.12",
3
+ "version": "2025.2.15",
4
4
  "description": "Module for easy access to the HahnPRO Cloud API",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -8,9 +8,9 @@
8
8
  "url": "https://hahnpro.com"
9
9
  },
10
10
  "dependencies": {
11
- "axios": "1.8.4",
12
- "eventsource": "3.0.6",
13
- "form-data": "4.0.2",
11
+ "axios": "1.10.0",
12
+ "eventsource": "4.0.0",
13
+ "form-data": "4.0.3",
14
14
  "jose": "5.10.0",
15
15
  "jwt-decode": "4.0.0",
16
16
  "p-queue": "6.6.2",
@@ -12,7 +12,7 @@ class DataService extends api_base_1.APIBase {
12
12
  }
13
13
  getOne(id, options = {}) {
14
14
  const params = options.populate ? { populate: options.populate } : {};
15
- return this.httpClient.get(`${this.basePath}/${id}`, { params });
15
+ return this.httpClient.get(`${this.basePath}/${id}`, { params, ...options });
16
16
  }
17
17
  getMany(params = {}, options = {}) {
18
18
  params.limit = params.limit || 0;
@@ -15,11 +15,13 @@ interface AssistantLabels {
15
15
  }
16
16
  interface BaseMessage {
17
17
  id?: string;
18
+ responseId?: string;
18
19
  thread: string;
19
20
  createdAt?: string;
20
21
  updatedAt?: string;
21
22
  }
22
23
  export interface AssistantMessage extends BaseMessage {
24
+ responseId?: string;
23
25
  role: 'assistant';
24
26
  content?: string;
25
27
  agentStack?: string[];
@@ -39,6 +41,11 @@ export interface AssistantMessage extends BaseMessage {
39
41
  }[];
40
42
  contextVariables?: Record<string, unknown>;
41
43
  finishReason?: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
44
+ traceId?: string;
45
+ feedback?: {
46
+ value: number;
47
+ comment?: string;
48
+ };
42
49
  }
43
50
  export interface SystemMessage extends BaseMessage {
44
51
  role: 'system';
@@ -1,16 +1,12 @@
1
1
  import { Author, Owner, Resource } from './resource.interface';
2
2
  export interface Event extends Resource {
3
- data?: {
4
- tsField: string;
5
- timestamp: string;
6
- value: number;
7
- };
3
+ data?: Record<string, any>;
8
4
  assetRef?: string;
9
5
  assetRef$name?: string;
10
6
  alertRef?: string;
11
7
  tsRef?: string;
12
8
  eventRef?: string;
13
- cause: string;
9
+ cause?: string;
14
10
  level: EventLevel;
15
11
  group?: string;
16
12
  owner?: Owner;
@@ -14,6 +14,7 @@ export interface TimeSeries {
14
14
  tsRef?: [string];
15
15
  autoDelData: Date;
16
16
  autoDelBucket: Date;
17
+ metadata?: Record<string, any>;
17
18
  deletedAt?: string;
18
19
  }
19
20
  export interface TimeSeriesCondition {
@@ -17,5 +17,6 @@ export declare class AiMockService extends APIBase implements AiService {
17
17
  getLatestThread(): Promise<ThreadPopulated>;
18
18
  listThreads(): Promise<ThreadPopulated[]>;
19
19
  listAssistantThreads(assistantId: string): Promise<ThreadPopulated[]>;
20
+ provideFeedback(traceId: string, value: number, comment?: string): Promise<void>;
20
21
  deleteThread(threadId: string): Promise<Thread>;
21
22
  }
@@ -36,6 +36,9 @@ class AiMockService extends api_base_1.APIBase {
36
36
  listAssistantThreads(assistantId) {
37
37
  throw new Error('Method not implemented.');
38
38
  }
39
+ provideFeedback(traceId, value, comment) {
40
+ throw new Error('Method not implemented.');
41
+ }
39
42
  deleteThread(threadId) {
40
43
  throw new Error('Method not implemented.');
41
44
  }
@@ -22,10 +22,13 @@ export declare class TimeseriesMockService extends BaseService implements TimeSe
22
22
  })[]>>;
23
23
  addAssetTimeSeriesValues(assetId: string, name: string, readPermissions: string[], readWritePermissions: string[], values: {
24
24
  [timestamp: string]: any;
25
- }): Promise<TimeSeries>;
25
+ }, metadata?: Record<string, any>): Promise<TimeSeries>;
26
26
  addManyAssetTimeSeriesValues(assetId: string, readPermissions: string[], readWritePermissions: string[], timeSeries: {
27
27
  [timeSeriesName: string]: {
28
- [timestamp: string]: any;
28
+ values: {
29
+ [timestamp: string]: any;
30
+ };
31
+ metadata?: Record<string, any>;
29
32
  };
30
33
  }): Promise<PromiseSettledResult<TimeSeries>[]>;
31
34
  addValue(id: string, value: {
@@ -29,7 +29,7 @@ class TimeseriesMockService extends BaseService {
29
29
  const page = this.getItems(params, false);
30
30
  return Promise.resolve(page);
31
31
  }
32
- addAssetTimeSeriesValues(assetId, name, readPermissions, readWritePermissions, values) {
32
+ addAssetTimeSeriesValues(assetId, name, readPermissions, readWritePermissions, values, metadata) {
33
33
  const ts = this.data.find((v) => v.assetRef === assetId);
34
34
  const data = Object.entries(values).map(([timestamp, value]) => {
35
35
  if (value !== null && typeof value === 'object') {
@@ -52,6 +52,7 @@ class TimeseriesMockService extends BaseService {
52
52
  readWritePermissions,
53
53
  assetRef: assetId,
54
54
  data,
55
+ metadata,
55
56
  };
56
57
  return this.addOne(dto);
57
58
  }
@@ -61,7 +62,7 @@ class TimeseriesMockService extends BaseService {
61
62
  addManyAssetTimeSeriesValues(assetId, readPermissions, readWritePermissions, timeSeries) {
62
63
  const ts = this.data.find((v) => v.assetRef === assetId);
63
64
  const psr = [];
64
- for (const [tsName, values] of Object.entries(timeSeries)) {
65
+ for (const [tsName, { values, metadata }] of Object.entries(timeSeries)) {
65
66
  const data = Object.entries(values).map(([timestamp, value]) => {
66
67
  if (value !== null && typeof value === 'object') {
67
68
  return { timestamp, ...value };
@@ -83,6 +84,7 @@ class TimeseriesMockService extends BaseService {
83
84
  readWritePermissions,
84
85
  assetRef: assetId,
85
86
  data,
87
+ metadata,
86
88
  };
87
89
  this.addOne(dto).then((v) => psr.push({ status: 'fulfilled', value: v }));
88
90
  }
@@ -4,7 +4,7 @@ import { HttpClient, TokenOption } from '../http.service';
4
4
  import { AiAssistant, Message, SpeechToken, Thread, ThreadPopulated } from '../interfaces';
5
5
  export declare class AiService extends APIBase {
6
6
  constructor(httpClient: HttpClient);
7
- addMessage(message: string, threadId?: string, assistantId?: string): Promise<Message>;
7
+ addMessage(message: string, threadId?: string, assistantId?: string, context?: Record<string, unknown>): Promise<Message>;
8
8
  createThread(assistantId: string, isEphemeral?: boolean): Promise<ThreadPopulated>;
9
9
  getLatestAssistantThread(assistantId: string): Promise<ThreadPopulated>;
10
10
  listAssistantThreads(assistantId: string): Promise<ThreadPopulated[]>;
@@ -15,5 +15,6 @@ export declare class AiService extends APIBase {
15
15
  getThread(threadId: string): Promise<ThreadPopulated>;
16
16
  getLatestThread(): Promise<ThreadPopulated>;
17
17
  listThreads(assistantIds?: string[], params?: {}, options?: TokenOption): Promise<ThreadPopulated[]>;
18
+ provideFeedback(traceId: string, value: number, comment?: string): Promise<void>;
18
19
  deleteThread(threadId: string): Promise<Thread>;
19
20
  }
@@ -6,8 +6,8 @@ class AiService extends api_base_1.APIBase {
6
6
  constructor(httpClient) {
7
7
  super(httpClient, '/ai');
8
8
  }
9
- addMessage(message, threadId, assistantId) {
10
- return this.httpClient.post(`${this.basePath}/message`, { message, threadId, assistantId });
9
+ addMessage(message, threadId, assistantId, context) {
10
+ return this.httpClient.post(`${this.basePath}/message`, { message, threadId, assistantId, context });
11
11
  }
12
12
  createThread(assistantId, isEphemeral) {
13
13
  return this.httpClient.post(`${this.basePath}/threads`, { assistantId, isEphemeral });
@@ -42,6 +42,9 @@ class AiService extends api_base_1.APIBase {
42
42
  }
43
43
  return this.httpClient.get(`${this.basePath}/threads`, { params, ...options });
44
44
  }
45
+ provideFeedback(traceId, value, comment) {
46
+ return this.httpClient.post(`${this.basePath}/feedback`, { traceId, value, comment });
47
+ }
45
48
  deleteThread(threadId) {
46
49
  return this.httpClient.delete(`${this.basePath}/threads/${threadId}`);
47
50
  }
@@ -26,11 +26,12 @@ export declare class TimeSeriesService extends BaseService {
26
26
  * ...
27
27
  * }
28
28
  * @param options
29
+ * @param metadata - Optional metadata to be associated with the time series.
29
30
  * @returns a promise that resolves to the time series that was added.
30
31
  */
31
32
  addAssetTimeSeriesValues(assetId: string, name: string, readPermissions: string[], readWritePermissions: string[], values: {
32
33
  [timestamp: string]: any;
33
- }, options?: TokenOption): Promise<TimeSeries>;
34
+ }, metadata?: Record<string, any>, options?: TokenOption): Promise<TimeSeries>;
34
35
  /**
35
36
  * Adds multiple time series values to an asset by the name of the time series.
36
37
  * If the time series does not exist, it is created.
@@ -42,8 +43,11 @@ export declare class TimeSeriesService extends BaseService {
42
43
  * @param timeSeries - The time series values are specified as an object with the following structure:
43
44
  * {
44
45
  * [timeSeriesName: string]: { // The name of the time series
45
- * [timestamp: string]: any, // The timestamp and value pairs
46
- * ...
46
+ * values: { // The time series values are specified as an object with the following structure:
47
+ * [timestamp: string]: any, // The timestamp and value pairs
48
+ * ...
49
+ * },
50
+ * metadata?: Record<string, any>, // Optional metadata to be associated with the time series
47
51
  * },
48
52
  * ...
49
53
  * }
@@ -58,7 +62,10 @@ export declare class TimeSeriesService extends BaseService {
58
62
  */
59
63
  addManyAssetTimeSeriesValues(assetId: string, readPermissions: string[], readWritePermissions: string[], timeSeries: {
60
64
  [timeSeriesName: string]: {
61
- [timestamp: string]: any;
65
+ values: {
66
+ [timestamp: string]: any;
67
+ };
68
+ metadata?: Record<string, any>;
62
69
  };
63
70
  }, options?: TokenOption): Promise<PromiseSettledResult<TimeSeries>[]>;
64
71
  getMostRecentValue(id: string, before?: Date, options?: TokenOption): Promise<TimeSeriesValue>;
@@ -31,14 +31,16 @@ class TimeSeriesService extends BaseService {
31
31
  * ...
32
32
  * }
33
33
  * @param options
34
+ * @param metadata - Optional metadata to be associated with the time series.
34
35
  * @returns a promise that resolves to the time series that was added.
35
36
  */
36
- addAssetTimeSeriesValues(assetId, name, readPermissions, readWritePermissions, values, options = {}) {
37
+ addAssetTimeSeriesValues(assetId, name, readPermissions, readWritePermissions, values, metadata, options = {}) {
37
38
  const dto = {
38
39
  name,
39
40
  readPermissions,
40
41
  readWritePermissions,
41
42
  values,
43
+ metadata,
42
44
  };
43
45
  return this.httpClient.post(`${this.basePath}/assets/${assetId}`, dto, options);
44
46
  }
@@ -53,8 +55,11 @@ class TimeSeriesService extends BaseService {
53
55
  * @param timeSeries - The time series values are specified as an object with the following structure:
54
56
  * {
55
57
  * [timeSeriesName: string]: { // The name of the time series
56
- * [timestamp: string]: any, // The timestamp and value pairs
57
- * ...
58
+ * values: { // The time series values are specified as an object with the following structure:
59
+ * [timestamp: string]: any, // The timestamp and value pairs
60
+ * ...
61
+ * },
62
+ * metadata?: Record<string, any>, // Optional metadata to be associated with the time series
58
63
  * },
59
64
  * ...
60
65
  * }
@@ -68,11 +73,12 @@ class TimeSeriesService extends BaseService {
68
73
  * }
69
74
  */
70
75
  addManyAssetTimeSeriesValues(assetId, readPermissions, readWritePermissions, timeSeries, options = {}) {
71
- const dtos = Object.entries(timeSeries).map(([name, values]) => ({
76
+ const dtos = Object.entries(timeSeries).map(([name, { values, metadata }]) => ({
72
77
  name,
73
78
  readPermissions,
74
79
  readWritePermissions,
75
80
  values,
81
+ metadata,
76
82
  }));
77
83
  return this.httpClient.post(`${this.basePath}/assets/${assetId}/bulk`, dtos, options);
78
84
  }