@hahnpro/hpc-api 3.8.1 → 4.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/dist/api.d.ts CHANGED
@@ -6,7 +6,6 @@ import { EventsService } from './events.service';
6
6
  import { HttpClient } from './http.service';
7
7
  import { ProxyService } from './proxy.service';
8
8
  import { SecretService } from './secret.service';
9
- import { SiDriveIqService } from './sidriveiq.service';
10
9
  import { TaskService } from './task.service';
11
10
  import { TimeSeriesService } from './timeseries.service';
12
11
  import { UserService } from './user.service';
@@ -18,7 +17,7 @@ import { LabelService } from './label.service';
18
17
  import { VaultService } from './vault.service';
19
18
  import { NotificationService } from './notification.service';
20
19
  export declare class API {
21
- httpClient: HttpClient;
20
+ readonly httpClient?: HttpClient;
22
21
  assets: AssetService;
23
22
  assetTypes: AssetTypesService;
24
23
  contents: ContentService;
@@ -36,41 +35,5 @@ export declare class API {
36
35
  users: UserService;
37
36
  vault: VaultService;
38
37
  notifications: NotificationService;
39
- /**
40
- * @deprecated use "assets" instead
41
- */
42
- assetManager: AssetService;
43
- /**
44
- * @deprecated use "contents" instead
45
- */
46
- contentManager: ContentService;
47
- /**
48
- * @deprecated use "endpoints" instead
49
- */
50
- endpointManager: EndpointService;
51
- /**
52
- * @deprecated use "events" instead
53
- */
54
- eventsManager: EventsService;
55
- /**
56
- * @deprecated use "secrets" instead
57
- */
58
- secretsManager: SecretService;
59
- /**
60
- * @deprecated use proxy service instead
61
- */
62
- siDrive: SiDriveIqService;
63
- /**
64
- * @deprecated use "tasks" instead
65
- */
66
- taskManager: TaskService;
67
- /**
68
- * @deprecated use "timeSeries" instead
69
- */
70
- timeSeriesManager: TimeSeriesService;
71
- /**
72
- * @deprecated use "users" instead
73
- */
74
- userManager: UserService;
75
- constructor();
38
+ constructor(httpClient?: HttpClient);
76
39
  }
package/dist/api.js CHANGED
@@ -9,7 +9,6 @@ const events_service_1 = require("./events.service");
9
9
  const http_service_1 = require("./http.service");
10
10
  const proxy_service_1 = require("./proxy.service");
11
11
  const secret_service_1 = require("./secret.service");
12
- const sidriveiq_service_1 = require("./sidriveiq.service");
13
12
  const task_service_1 = require("./task.service");
14
13
  const timeseries_service_1 = require("./timeseries.service");
15
14
  const user_service_1 = require("./user.service");
@@ -21,23 +20,26 @@ const label_service_1 = require("./label.service");
21
20
  const vault_service_1 = require("./vault.service");
22
21
  const notification_service_1 = require("./notification.service");
23
22
  class API {
24
- constructor() {
25
- const normalizePath = (value = '', defaultValue = '') => value.replace(/(?:^\/+)|(?:\/+$)/g, '') || defaultValue;
26
- let apiBaseUrl = process.env.API_BASE_URL || 'https://testing.hahnpro.com';
27
- if (!apiBaseUrl.startsWith('https') && !apiBaseUrl.startsWith('http')) {
28
- console.info('no protocol specified - using HTTPS');
29
- apiBaseUrl = `https://${apiBaseUrl}`;
23
+ constructor(httpClient) {
24
+ this.httpClient = httpClient;
25
+ if (!httpClient) {
26
+ const normalizePath = (value = '', defaultValue = '') => value.replace(/(?:^\/+)|(?:\/+$)/g, '') || defaultValue;
27
+ let apiBaseUrl = process.env.API_BASE_URL || 'https://testing.hahnpro.com';
28
+ if (!apiBaseUrl.startsWith('https') && !apiBaseUrl.startsWith('http')) {
29
+ console.info('no protocol specified - using HTTPS');
30
+ apiBaseUrl = `https://${apiBaseUrl}`;
31
+ }
32
+ const apiUrl = apiBaseUrl + '/' + normalizePath(process.env.API_BASE_PATH, 'api');
33
+ const authBaseUrl = process.env.AUTH_BASE_URL || apiBaseUrl;
34
+ const authUrl = authBaseUrl + '/' + normalizePath(process.env.AUTH_BASE_PATH, 'auth');
35
+ const realm = process.env.AUTH_REALM || 'hpc';
36
+ const client = process.env.API_USER || 'flow-executor-service';
37
+ const secret = process.env.AUTH_SECRET;
38
+ if (!secret) {
39
+ throw new Error('"API_BASE_URL", "API_USER", "AUTH_REALM" and "AUTH_SECRET" environment variables must be set');
40
+ }
41
+ this.httpClient = new http_service_1.HttpClient(apiUrl, authUrl, realm, client, secret);
30
42
  }
31
- const apiUrl = apiBaseUrl + '/' + normalizePath(process.env.API_BASE_PATH, 'api');
32
- const authBaseUrl = process.env.AUTH_BASE_URL || apiBaseUrl;
33
- const authUrl = authBaseUrl + '/' + normalizePath(process.env.AUTH_BASE_PATH, 'auth');
34
- const realm = process.env.AUTH_REALM || 'hpc';
35
- const client = process.env.API_USER || 'flow-executor-service';
36
- const secret = process.env.AUTH_SECRET;
37
- if (!secret) {
38
- throw new Error('"API_BASE_URL", "API_USER", "AUTH_REALM" and "AUTH_SECRET" environment variables must be set');
39
- }
40
- this.httpClient = new http_service_1.HttpClient(apiUrl, authUrl, realm, client, secret);
41
43
  this.assets = new asset_service_1.AssetService(this.httpClient);
42
44
  this.assetTypes = new assettypes_service_1.AssetTypesService(this.httpClient);
43
45
  this.contents = new content_service_1.ContentService(this.httpClient);
@@ -55,15 +57,6 @@ class API {
55
57
  this.users = new user_service_1.UserService(this.httpClient);
56
58
  this.vault = new vault_service_1.VaultService(this.httpClient);
57
59
  this.notifications = new notification_service_1.NotificationService(this.httpClient);
58
- this.assetManager = this.assets;
59
- this.contentManager = this.contents;
60
- this.endpointManager = this.endpoints;
61
- this.eventsManager = this.events;
62
- this.secretsManager = this.secrets;
63
- this.siDrive = new sidriveiq_service_1.SiDriveIqService(this.httpClient);
64
- this.taskManager = this.tasks;
65
- this.timeSeriesManager = this.timeSeries;
66
- this.userManager = this.users;
67
60
  }
68
61
  }
69
62
  exports.API = API;
@@ -1,14 +1,15 @@
1
- import { AxiosRequestConfig } from 'axios';
1
+ import { AxiosInstance, AxiosRequestConfig, Method } from 'axios';
2
2
  import EventSource from 'eventsource';
3
+ import { Queue } from './Queue';
3
4
  export declare class HttpClient {
4
- private readonly baseURL;
5
- private readonly authBaseURL;
6
- private readonly realm;
7
- private readonly clientId;
8
- private readonly clientSecret;
9
- private readonly axiosInstance;
10
- private readonly authAxiosInstance;
11
- private readonly requestQueue;
5
+ protected readonly baseURL: string;
6
+ protected readonly authBaseURL: string;
7
+ protected readonly realm: string;
8
+ protected readonly clientId: string;
9
+ protected readonly clientSecret: string;
10
+ protected readonly axiosInstance: AxiosInstance;
11
+ protected readonly authAxiosInstance: AxiosInstance;
12
+ protected readonly requestQueue: Queue;
12
13
  private tokenSet;
13
14
  eventSourcesMap: Map<string, {
14
15
  eventSource: EventSource;
@@ -26,12 +27,21 @@ export declare class HttpClient {
26
27
  get: <T>(url: string, config?: AxiosRequestConfig) => Promise<T>;
27
28
  post: <T>(url: string, data: any, config?: AxiosRequestConfig) => Promise<T>;
28
29
  put: <T>(url: string, data: any, config?: AxiosRequestConfig) => Promise<T>;
29
- private request;
30
+ protected request: <T>(method: Method, url: string, config?: AxiosRequestConfig, data?: any) => Promise<T>;
30
31
  addEventSource(url: string, listener: (event: MessageEvent) => void, errorListener?: (event: MessageEvent) => void): Promise<any>;
31
32
  destroyEventSource(id: string): void;
32
33
  destroyAllEventSources(): void;
33
34
  getAccessToken: (forceRefresh?: boolean) => Promise<string>;
34
- private validateIssuer;
35
- private discoverIssuer;
36
- private requestAccessToken;
35
+ protected validateIssuer(issuer: Issuer): Issuer;
36
+ protected discoverIssuer(uri: string): Promise<Issuer>;
37
+ protected requestAccessToken(): Promise<string>;
37
38
  }
39
+ interface Issuer {
40
+ issuer: string;
41
+ token_endpoint: string;
42
+ grant_types_supported: string[];
43
+ token_endpoint_auth_methods_supported: string[];
44
+ token_endpoint_auth_signing_alg?: string;
45
+ token_endpoint_auth_signing_alg_values_supported: string[];
46
+ }
47
+ export {};
@@ -4,11 +4,11 @@ exports.HttpClient = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const axios_1 = tslib_1.__importDefault(require("axios"));
6
6
  const eventsource_1 = tslib_1.__importDefault(require("eventsource"));
7
- const uuid_1 = require("uuid");
8
7
  const jose_1 = require("jose");
8
+ const node_querystring_1 = require("node:querystring");
9
+ const uuid_1 = require("uuid");
9
10
  const Queue_1 = require("./Queue");
10
11
  const token_set_1 = require("./token-set");
11
- const querystring_1 = require("querystring");
12
12
  class HttpClient {
13
13
  constructor(baseURL, authBaseURL, realm, clientId, clientSecret) {
14
14
  this.baseURL = baseURL;
@@ -117,7 +117,7 @@ class HttpClient {
117
117
  client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
118
118
  grant_type: 'client_credentials',
119
119
  };
120
- const authResponse = await this.authAxiosInstance.post(issuer.token_endpoint, (0, querystring_1.stringify)(opts), {
120
+ const authResponse = await this.authAxiosInstance.post(issuer.token_endpoint, (0, node_querystring_1.stringify)(opts), {
121
121
  headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' },
122
122
  });
123
123
  if (((_b = authResponse === null || authResponse === void 0 ? void 0 : authResponse.data) === null || _b === void 0 ? void 0 : _b.access_token) && authResponse.data.expires_in) {
package/dist/index.d.ts CHANGED
@@ -18,4 +18,3 @@ export * from './resource.interface';
18
18
  export * from './schema.interface';
19
19
  export * from './vault.interface';
20
20
  export * from './notification.interface';
21
- export * as SiDrive from './sidriveiq.interface';
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SiDrive = void 0;
4
3
  const tslib_1 = require("tslib");
5
4
  tslib_1.__exportStar(require("./api"), exports);
6
5
  tslib_1.__exportStar(require("./asset.interface"), exports);
@@ -22,4 +21,3 @@ tslib_1.__exportStar(require("./resource.interface"), exports);
22
21
  tslib_1.__exportStar(require("./schema.interface"), exports);
23
22
  tslib_1.__exportStar(require("./vault.interface"), exports);
24
23
  tslib_1.__exportStar(require("./notification.interface"), exports);
25
- exports.SiDrive = tslib_1.__importStar(require("./sidriveiq.interface"));
@@ -49,15 +49,6 @@ export declare class MockAPI implements API {
49
49
  users: UserMockService;
50
50
  vault: VaultMockService;
51
51
  notifications: NotificationMockService;
52
- assetManager: AssetMockService;
53
- contentManager: ContentMockService;
54
- endpointManager: EndpointMockService;
55
- eventsManager: EventsMockService;
56
- secretsManager: SecretMockService;
57
- siDrive: any;
58
- taskManager: TaskMockService;
59
- timeSeriesManager: TimeseriesMockService;
60
- userManager: UserMockService;
61
52
  constructor(initData: {
62
53
  assets?: AssetInit[];
63
54
  assetRevisions?: AssetRevisionInit[];
@@ -23,7 +23,6 @@ class MockAPI {
23
23
  constructor(initData) {
24
24
  this.httpClient = null;
25
25
  this.proxy = null;
26
- this.siDrive = null;
27
26
  const { assets = [], assetRevisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, flows = [], flowRevisions = [], deployments = [], functions = [], functionRevisions = [], modules = [], diagrams = [], labels = [], vault = [], notifications = [], } = initData;
28
27
  const assetTypes = assets
29
28
  .map((v) => v.type)
@@ -131,14 +130,6 @@ class MockAPI {
131
130
  this.labels = new label_mock_service_1.LabelMockService(labels1);
132
131
  this.vault = new vault_mock_service_1.VaultMockService(vaultSecrets1);
133
132
  this.notifications = new notification_mock_service_1.NotificationMockService(notifications1);
134
- this.assetManager = this.assets;
135
- this.contentManager = this.contents;
136
- this.endpointManager = this.endpoints;
137
- this.secretsManager = this.secrets;
138
- this.timeSeriesManager = this.timeSeries;
139
- this.taskManager = this.tasks;
140
- this.eventsManager = this.events;
141
- this.userManager = this.users;
142
133
  }
143
134
  }
144
135
  exports.MockAPI = MockAPI;
@@ -55,12 +55,12 @@ class AssetMockService extends BaseService {
55
55
  }
56
56
  async addAttachment(id, form) {
57
57
  const asset = this.data.find((v) => v.id === id);
58
- const content = await this.api.contentManager.upload(form);
58
+ const content = await this.api.contents.upload(form);
59
59
  asset.attachments.push(content.id);
60
60
  return Promise.resolve(asset);
61
61
  }
62
62
  async getAttachments(assetId) {
63
- const contents = await this.api.contentManager.getMany();
63
+ const contents = await this.api.contents.getMany();
64
64
  const docs = contents.docs.filter((c) => { var _a, _b; return (_b = (_a = c.assets) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, assetId); });
65
65
  return { docs, total: docs.length, limit: 0 };
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "3.8.1",
3
+ "version": "4.0.0",
4
4
  "description": "Module for easy access to the HahnPRO API",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,10 +24,10 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "axios": "~1.3.6",
27
+ "axios": "~1.4.0",
28
28
  "eventsource": "^2.0.2",
29
29
  "form-data": "^4.0.0",
30
- "jose": "^4.14.1",
30
+ "jose": "^4.14.4",
31
31
  "jwt-decode": "^3.1.2",
32
32
  "p-queue": "^6.6.2",
33
33
  "ts-mixer": "^6.0.3",
@@ -1,104 +0,0 @@
1
- export interface Asset {
2
- id: string;
3
- type_id: string;
4
- name: string;
5
- description: string;
6
- tag: string;
7
- agent_id: string;
8
- is_active: boolean;
9
- }
10
- export interface File {
11
- id: string;
12
- name: string;
13
- status: string;
14
- content_type: string;
15
- created_at: string;
16
- length: number;
17
- }
18
- export interface List<T> {
19
- cursor: string;
20
- values: T[];
21
- }
22
- export interface Log {
23
- ref_id: string;
24
- ref_type: RefType;
25
- severity: Severity;
26
- created_at: string;
27
- text: string;
28
- actor: string;
29
- category: string;
30
- item_type: string;
31
- gone_at: string;
32
- }
33
- export interface Mail {
34
- from: string;
35
- to: string;
36
- cc?: string;
37
- subject: string;
38
- body: string;
39
- is_html: boolean;
40
- }
41
- export interface Property {
42
- path: string;
43
- name: string;
44
- unit: string;
45
- data_type: string;
46
- is_mandatory: boolean;
47
- }
48
- export type RefType = 'Unknown' | 'Asset' | 'AssetType' | 'Container' | 'ContainerType' | 'Action' | 'AssetReport' | 'ReportType';
49
- export type Severity = 'Info' | 'Warning' | 'Error' | 'All';
50
- export interface Subset {
51
- id: string;
52
- name: string;
53
- }
54
- export interface TimeSeries {
55
- ts: string;
56
- v: any;
57
- }
58
- export interface RangeParams {
59
- from?: string | Date;
60
- to?: string | Date;
61
- }
62
- export interface CursorParams {
63
- limit?: number;
64
- cursor?: string;
65
- }
66
- export interface PaginationParams {
67
- page?: number;
68
- page_size?: number;
69
- sort?: string;
70
- }
71
- export interface AssetsParams extends CursorParams {
72
- name_filter?: string;
73
- type_filter?: string;
74
- tag_filter?: string;
75
- agent_filter?: string;
76
- }
77
- export interface PropertiesParams extends CursorParams {
78
- path_filter?: string;
79
- subset_filter?: string;
80
- only_assigned?: boolean;
81
- only_mandatory?: boolean;
82
- }
83
- export interface TimeSeriesParams extends CursorParams, RangeParams {
84
- }
85
- export interface FilesCountParams extends RangeParams {
86
- name_filter?: string;
87
- status_filter?: 'Imported' | 'Scanned' | 'ScannedButEmpty';
88
- exclude?: string;
89
- }
90
- export interface FilesParams extends FilesCountParams, PaginationParams {
91
- }
92
- export interface LogsParams extends PaginationParams, RangeParams {
93
- categories: string[];
94
- severity?: Severity;
95
- filter?: string;
96
- }
97
- export interface LogDto {
98
- text: string;
99
- severity: Severity;
100
- created_at: string;
101
- actor: string;
102
- category: string;
103
- gone_at: string;
104
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,97 +0,0 @@
1
- import FormData from 'form-data';
2
- import { HttpClient } from './http.service';
3
- import { Asset, AssetsParams, File, FilesCountParams, FilesParams, List, Log, LogDto, LogsParams, Mail, PropertiesParams, Property, RangeParams, Subset, TimeSeries, TimeSeriesParams } from './sidriveiq.interface';
4
- export declare class SiDriveIqService {
5
- private readonly httpClient;
6
- private basePath;
7
- constructor(httpClient: HttpClient);
8
- /**
9
- * @deprecated
10
- */
11
- getAssets(params?: AssetsParams): Promise<List<Asset>>;
12
- /**
13
- * @deprecated
14
- */
15
- getAssetCount(params?: AssetsParams): Promise<number>;
16
- /**
17
- * @deprecated
18
- */
19
- getAsset(assetId: string | number): Promise<Asset>;
20
- /**
21
- * @deprecated
22
- */
23
- getProperties(assetId: string | number, params?: PropertiesParams): Promise<List<Property>>;
24
- /**
25
- * @deprecated
26
- */
27
- getProperty(assetId: string | number, path: string): Promise<Property>;
28
- /**
29
- * @deprecated
30
- */
31
- getSubsets(assetId: string | number): Promise<List<TimeSeries>>;
32
- /**
33
- * @deprecated
34
- */
35
- getSubset(assetId: string | number, subsetId: string): Promise<Subset>;
36
- /**
37
- * @deprecated
38
- */
39
- getSubsetProperties(assetId: string | number, subsetId: string, pathFilter?: string): Promise<List<Property>>;
40
- /**
41
- * @deprecated
42
- */
43
- getTimeSeries(assetId: string | number, path: string, params?: TimeSeriesParams): Promise<List<TimeSeries>>;
44
- /**
45
- * @deprecated
46
- */
47
- getTimeSeriesCount(assetId: string | number, path: string, params?: RangeParams): Promise<number>;
48
- /**
49
- * @deprecated
50
- */
51
- getRecentTimeSeries(assetId: string | number, path: string, timestamp?: Date): Promise<TimeSeries>;
52
- /**
53
- * @deprecated
54
- */
55
- addTimeSeries(assetId: string | number, path: string, values: TimeSeries[]): Promise<void>;
56
- /**
57
- * @deprecated
58
- */
59
- getFiles(assetId: string | number, params?: FilesParams): Promise<File[]>;
60
- /**
61
- * @deprecated
62
- */
63
- getFileCount(assetId: string | number, params?: FilesCountParams): Promise<number>;
64
- /**
65
- * @deprecated
66
- */
67
- getFile(assetId: string | number, fileId: string): Promise<File>;
68
- /**
69
- * @deprecated
70
- */
71
- downloadFile(assetId: string | number, fileId: string): Promise<ArrayBuffer>;
72
- /**
73
- * @deprecated
74
- */
75
- uploadFile(assetId: string | number, form: FormData): Promise<string>;
76
- /**
77
- * @deprecated
78
- */
79
- deleteFile(assetId: string | number, fileId: string): Promise<void>;
80
- /**
81
- * @deprecated
82
- */
83
- getLogs(assetId: string | number, params: LogsParams): Promise<List<Log>>;
84
- /**
85
- * @deprecated
86
- */
87
- getLogCount(assetId: string | number, params: LogsParams): Promise<number>;
88
- /**
89
- * @deprecated
90
- */
91
- addLog(assetId: string | number, item: LogDto): Promise<void>;
92
- /**
93
- * @deprecated
94
- */
95
- sendMail(mail: Mail): Promise<string>;
96
- private convertDates;
97
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SiDriveIqService = void 0;
4
- class SiDriveIqService {
5
- constructor(httpClient) {
6
- this.httpClient = httpClient;
7
- this.basePath = '/proxy/sidrive/api/v0';
8
- }
9
- getAssets(params = {}) {
10
- return this.httpClient.get(`${this.basePath}/assets`, { params });
11
- }
12
- getAssetCount(params = {}) {
13
- return this.httpClient.get(`${this.basePath}/assets/count`, { params });
14
- }
15
- getAsset(assetId) {
16
- return this.httpClient.get(`${this.basePath}/assets/${assetId}`);
17
- }
18
- getProperties(assetId, params = {}) {
19
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties`, { params });
20
- }
21
- getProperty(assetId, path) {
22
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}`);
23
- }
24
- getSubsets(assetId) {
25
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/subsets`);
26
- }
27
- getSubset(assetId, subsetId) {
28
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/subsets/${subsetId}`);
29
- }
30
- getSubsetProperties(assetId, subsetId, pathFilter) {
31
- const params = Object.assign({}, (pathFilter && { path_filter: pathFilter }));
32
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/subsets/${subsetId}/properties`, { params });
33
- }
34
- getTimeSeries(assetId, path, params = {}) {
35
- params = this.convertDates(params);
36
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries`, { params });
37
- }
38
- getTimeSeriesCount(assetId, path, params = {}) {
39
- params = this.convertDates(params);
40
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries/count`, { params });
41
- }
42
- getRecentTimeSeries(assetId, path, timestamp) {
43
- const params = Object.assign({}, (timestamp && { timestamp: timestamp.toISOString() }));
44
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries/recent`, { params });
45
- }
46
- addTimeSeries(assetId, path, values) {
47
- return this.httpClient.post(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries`, values);
48
- }
49
- getFiles(assetId, params = {}) {
50
- params = this.convertDates(params);
51
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import`, { params });
52
- }
53
- getFileCount(assetId, params = {}) {
54
- params = this.convertDates(params);
55
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import/count`, { params });
56
- }
57
- getFile(assetId, fileId) {
58
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import/${fileId}`);
59
- }
60
- downloadFile(assetId, fileId) {
61
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import/${fileId}/download`, {
62
- headers: { 'response-type': 'arraybuffer' },
63
- responseType: 'arraybuffer',
64
- });
65
- }
66
- uploadFile(assetId, form) {
67
- const headers = Object.assign({}, form.getHeaders());
68
- return this.httpClient.post(`${this.basePath}/assets/${assetId}/files/import`, form, { headers });
69
- }
70
- deleteFile(assetId, fileId) {
71
- return this.httpClient.delete(`${this.basePath}/assets/${assetId}/files/import/${fileId}`);
72
- }
73
- getLogs(assetId, params) {
74
- params = this.convertDates(params);
75
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/logs`, { params });
76
- }
77
- getLogCount(assetId, params) {
78
- params = this.convertDates(params);
79
- return this.httpClient.get(`${this.basePath}/assets/${assetId}/logs/count`, { params });
80
- }
81
- addLog(assetId, item) {
82
- return this.httpClient.post(`${this.basePath}/assets/${assetId}/logs`, item);
83
- }
84
- sendMail(mail) {
85
- return this.httpClient.post(`${this.basePath}/mails`, mail);
86
- }
87
- convertDates(params) {
88
- if (params.from) {
89
- params.from = new Date(params.from).toISOString();
90
- }
91
- if (params.to) {
92
- params.to = new Date(params.to).toISOString();
93
- }
94
- return params;
95
- }
96
- }
97
- exports.SiDriveIqService = SiDriveIqService;