@hahnpro/hpc-api 2025.3.7 → 2025.3.9
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 +4 -0
- package/package.json +1 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/lib/api.d.ts +2 -1
- package/src/lib/api.js +1 -0
- package/src/lib/content.interface.d.ts +12 -0
- package/src/lib/content.interface.js +4 -1
- package/src/lib/content.service.d.ts +3 -3
- package/src/lib/content.service.js +3 -2
- package/src/lib/data.interface.d.ts +1 -0
- package/src/lib/data.service.d.ts +5 -3
- package/src/lib/flow-module.service.d.ts +2 -2
- package/src/lib/flow-module.service.js +2 -1
- package/src/lib/interfaces/asset.interface.d.ts +11 -21
- package/src/lib/interfaces/index.d.ts +1 -1
- package/src/lib/mock/api.mock.d.ts +2 -0
- package/src/lib/mock/asset.mock.service.d.ts +9 -3
- package/src/lib/mock/asset.mock.service.js +11 -7
- package/src/lib/mock/content.mock.service.d.ts +2 -2
- package/src/lib/mock/flow-modules.mock.service.d.ts +2 -2
- package/src/lib/mock/search.mock.service.d.ts +9 -0
- package/src/lib/mock/search.mock.service.js +10 -0
- package/src/lib/services/asset.service.d.ts +9 -3
- package/src/lib/services/asset.service.js +16 -4
- package/src/lib/services/index.d.ts +1 -0
- package/src/lib/services/index.js +3 -1
- package/src/lib/services/search.service.d.ts +9 -0
- package/src/lib/services/search.service.js +13 -0
- package/src/lib/task.interface.d.ts +1 -1
- package/src/lib/utils.d.ts +11 -0
- package/src/lib/utils.js +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @hahnpro/hpc-api
|
|
2
2
|
|
|
3
|
+
## 2025.3.9
|
|
4
|
+
|
|
5
|
+
- Updated Content Interface and Task Interface, Added `addElementToProperty` and `removeElementToProperty` mehtods to Asset API service
|
|
6
|
+
|
|
3
7
|
## 2025.3.4
|
|
4
8
|
|
|
5
9
|
Added `addOrganizationMembers`, `addSubscriptionToOrganization` and `getOrganizationIdByName` methods to Organizations API service
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "2025.3.
|
|
3
|
+
"version": "2025.3.9",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO Cloud API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"axios": "1.12.2",
|
|
12
12
|
"eventsource": "4.0.0",
|
|
13
|
-
"form-data": "4.0.4",
|
|
14
13
|
"jose": "5.10.0",
|
|
15
14
|
"jwt-decode": "4.0.0",
|
|
16
15
|
"p-queue": "6.6.2",
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -18,3 +18,4 @@ tslib_1.__exportStar(require("./lib/secret.interface"), exports);
|
|
|
18
18
|
tslib_1.__exportStar(require("./lib/task.interface"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./lib/vault.interface"), exports);
|
|
20
20
|
tslib_1.__exportStar(require("./lib/task.service"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./lib/utils"), exports);
|
package/src/lib/api.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { NotificationService } from './notification.service';
|
|
|
11
11
|
import { OrganizationService } from './organization.service';
|
|
12
12
|
import { ProxyService } from './proxy.service';
|
|
13
13
|
import { SecretService } from './secret.service';
|
|
14
|
-
import { AiService, AssetService, AssetTypesService, EventService, LabelService, TimeSeriesService } from './services';
|
|
14
|
+
import { AiService, AssetService, AssetTypesService, EventService, LabelService, SearchService, TimeSeriesService } from './services';
|
|
15
15
|
import { TaskService } from './task.service';
|
|
16
16
|
import { UserService } from './user.service';
|
|
17
17
|
import { VaultService } from './vault.service';
|
|
@@ -31,6 +31,7 @@ export declare class API {
|
|
|
31
31
|
labels: LabelService;
|
|
32
32
|
organizations: OrganizationService;
|
|
33
33
|
proxy: ProxyService;
|
|
34
|
+
search: SearchService;
|
|
34
35
|
secrets: SecretService;
|
|
35
36
|
tasks: TaskService;
|
|
36
37
|
timeSeries: TimeSeriesService;
|
package/src/lib/api.js
CHANGED
|
@@ -55,6 +55,7 @@ class API {
|
|
|
55
55
|
this.labels = new services_1.LabelService(this.httpClient);
|
|
56
56
|
this.organizations = new organization_service_1.OrganizationService(this.httpClient);
|
|
57
57
|
this.proxy = new proxy_service_1.ProxyService(this.httpClient);
|
|
58
|
+
this.search = new services_1.SearchService(this.httpClient);
|
|
58
59
|
this.secrets = new secret_service_1.SecretService(this.httpClient);
|
|
59
60
|
this.tasks = new task_service_1.TaskService(this.httpClient);
|
|
60
61
|
this.timeSeries = new services_1.TimeSeriesService(this.httpClient);
|
|
@@ -17,6 +17,18 @@ export interface Content {
|
|
|
17
17
|
createdAt?: string;
|
|
18
18
|
updatedAt?: string;
|
|
19
19
|
deletedAt?: string;
|
|
20
|
+
analysis?: string | ContentAnalysis;
|
|
21
|
+
}
|
|
22
|
+
export declare class ContentAnalysis {
|
|
23
|
+
id: string;
|
|
24
|
+
contentId: string;
|
|
25
|
+
status: string | 'notStarted' | 'running' | 'failed' | 'succeeded' | 'completed' | 'canceled';
|
|
26
|
+
error?: string;
|
|
27
|
+
text?: string;
|
|
28
|
+
pages?: {
|
|
29
|
+
pageNumber: number;
|
|
30
|
+
text?: string;
|
|
31
|
+
}[];
|
|
20
32
|
}
|
|
21
33
|
export declare enum ReturnType {
|
|
22
34
|
TEXT = 0,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReturnType = void 0;
|
|
3
|
+
exports.ReturnType = exports.ContentAnalysis = void 0;
|
|
4
|
+
class ContentAnalysis {
|
|
5
|
+
}
|
|
6
|
+
exports.ContentAnalysis = ContentAnalysis;
|
|
4
7
|
var ReturnType;
|
|
5
8
|
(function (ReturnType) {
|
|
6
9
|
ReturnType[ReturnType["TEXT"] = 0] = "TEXT";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
1
|
import { APIBase } from './api-base';
|
|
3
2
|
import { Content, ReturnType } from './content.interface';
|
|
4
3
|
import { DataService } from './data.service';
|
|
5
|
-
import { HttpClient, TokenOption } from './http.service';
|
|
4
|
+
import { Config, HttpClient, TokenOption } from './http.service';
|
|
6
5
|
import { TrashService } from './trash.service';
|
|
6
|
+
import { CrossPlatformFormData } from './utils';
|
|
7
7
|
interface BaseService extends DataService<Content>, TrashService<Content> {
|
|
8
8
|
}
|
|
9
9
|
declare class BaseService extends APIBase {
|
|
10
10
|
}
|
|
11
11
|
export declare class ContentService extends BaseService {
|
|
12
12
|
constructor(httpClient: HttpClient);
|
|
13
|
-
upload: (form:
|
|
13
|
+
upload: (form: CrossPlatformFormData, options?: Config) => Promise<Content>;
|
|
14
14
|
download(id: string, raw?: boolean, options?: TokenOption): Promise<Blob | ArrayBuffer>;
|
|
15
15
|
download(id: string, returnType: ReturnType.TEXT, options?: TokenOption): Promise<string>;
|
|
16
16
|
download(id: string, returnType: ReturnType.JSON, options?: TokenOption): Promise<Record<string, unknown>>;
|
|
@@ -7,6 +7,7 @@ const api_base_1 = require("./api-base");
|
|
|
7
7
|
const content_interface_1 = require("./content.interface");
|
|
8
8
|
const data_service_1 = require("./data.service");
|
|
9
9
|
const trash_service_1 = require("./trash.service");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
10
11
|
let BaseService = class BaseService extends api_base_1.APIBase {
|
|
11
12
|
};
|
|
12
13
|
BaseService = tslib_1.__decorate([
|
|
@@ -16,12 +17,12 @@ class ContentService extends BaseService {
|
|
|
16
17
|
constructor(httpClient) {
|
|
17
18
|
super(httpClient, '/contents');
|
|
18
19
|
this.upload = (form, options = {}) => {
|
|
19
|
-
const headers = { ...
|
|
20
|
+
const headers = { ...(0, utils_1.getFormDataHeaders)(form), ...options.headers };
|
|
20
21
|
return this.httpClient.post(`${this.basePath}`, form, {
|
|
21
|
-
headers,
|
|
22
22
|
maxBodyLength: Infinity,
|
|
23
23
|
maxContentLength: Infinity,
|
|
24
24
|
...options,
|
|
25
|
+
headers,
|
|
25
26
|
});
|
|
26
27
|
};
|
|
27
28
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { APIBase } from './api-base';
|
|
2
2
|
import { DataInterface, Filter, Paginated, RequestParameter } from './data.interface';
|
|
3
|
-
import { TokenOption } from './http.service';
|
|
3
|
+
import { Config, TokenOption } from './http.service';
|
|
4
4
|
export declare class DataService<T> extends APIBase implements DataInterface<T> {
|
|
5
|
-
addOne(dto: any, options?: TokenOption
|
|
5
|
+
addOne(dto: any, options?: TokenOption & {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}): Promise<T>;
|
|
6
8
|
addMany(dto: any[], options?: TokenOption): Promise<T[]>;
|
|
7
9
|
getOne(id: string, options?: TokenOption & {
|
|
8
10
|
[key: string]: any;
|
|
9
11
|
}): Promise<T>;
|
|
10
|
-
getMany(params?: RequestParameter, options?:
|
|
12
|
+
getMany(params?: RequestParameter, options?: Config): Promise<Paginated<T[]>>;
|
|
11
13
|
/**
|
|
12
14
|
* Filters the elements by the passed properties. The object with these properties has to be of the form:
|
|
13
15
|
* {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
1
|
import { DataService } from './data.service';
|
|
3
2
|
import { FlowModule } from './flow-module.interface';
|
|
4
3
|
import { HttpClient, TokenOption } from './http.service';
|
|
4
|
+
import { CrossPlatformFormData } from './utils';
|
|
5
5
|
export declare class FlowModuleService extends DataService<FlowModule> {
|
|
6
6
|
constructor(httpClient: HttpClient);
|
|
7
7
|
deleteArtifact(name: string, version: string, options?: TokenOption): Promise<FlowModule>;
|
|
8
|
-
publish(form:
|
|
8
|
+
publish(form: CrossPlatformFormData, options?: TokenOption): Promise<unknown>;
|
|
9
9
|
addOne(_dto: any): Promise<FlowModule>;
|
|
10
10
|
addMany(_dto: any[]): Promise<FlowModule[]>;
|
|
11
11
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowModuleService = void 0;
|
|
4
4
|
const data_service_1 = require("./data.service");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
5
6
|
class FlowModuleService extends data_service_1.DataService {
|
|
6
7
|
constructor(httpClient) {
|
|
7
8
|
super(httpClient, '/flow/modules');
|
|
@@ -11,7 +12,7 @@ class FlowModuleService extends data_service_1.DataService {
|
|
|
11
12
|
}
|
|
12
13
|
publish(form, options = {}) {
|
|
13
14
|
const config = {
|
|
14
|
-
headers:
|
|
15
|
+
headers: (0, utils_1.getFormDataHeaders)(form),
|
|
15
16
|
maxBodyLength: Infinity,
|
|
16
17
|
maxContentLength: Infinity,
|
|
17
18
|
...options,
|
|
@@ -12,9 +12,9 @@ export interface AssetType {
|
|
|
12
12
|
supertype$name?: string;
|
|
13
13
|
typeSchema: any;
|
|
14
14
|
uiSchema: any;
|
|
15
|
-
actions?: string[];
|
|
16
15
|
author?: string;
|
|
17
16
|
revision?: number;
|
|
17
|
+
templates?: string[] | Template[];
|
|
18
18
|
owner?: Owner;
|
|
19
19
|
createdBy?: Author;
|
|
20
20
|
updatedBy?: Author;
|
|
@@ -42,7 +42,8 @@ export interface Asset {
|
|
|
42
42
|
image?: string;
|
|
43
43
|
attachments?: string[];
|
|
44
44
|
notificationEndpoints?: string[];
|
|
45
|
-
|
|
45
|
+
aliases?: string[];
|
|
46
|
+
translationId?: string;
|
|
46
47
|
author?: string;
|
|
47
48
|
revision?: number;
|
|
48
49
|
owner?: Owner;
|
|
@@ -56,25 +57,6 @@ export type AssetRevision = Asset & {
|
|
|
56
57
|
originalId: string;
|
|
57
58
|
};
|
|
58
59
|
export type Attachment = Content;
|
|
59
|
-
export interface Action {
|
|
60
|
-
id?: string;
|
|
61
|
-
name?: string;
|
|
62
|
-
description?: string;
|
|
63
|
-
type?: string;
|
|
64
|
-
method?: string;
|
|
65
|
-
authToken?: string;
|
|
66
|
-
isAuthFromAsset?: boolean;
|
|
67
|
-
url?: string;
|
|
68
|
-
data?: string;
|
|
69
|
-
responseType?: string;
|
|
70
|
-
readPermissions: string[];
|
|
71
|
-
readWritePermissions: string[];
|
|
72
|
-
author?: string;
|
|
73
|
-
revision?: number;
|
|
74
|
-
}
|
|
75
|
-
export type ActionRevision = Action & {
|
|
76
|
-
originalId: string;
|
|
77
|
-
};
|
|
78
60
|
export interface EventCause {
|
|
79
61
|
cause: string;
|
|
80
62
|
level: string;
|
|
@@ -89,3 +71,11 @@ export interface Template {
|
|
|
89
71
|
name: string;
|
|
90
72
|
template: Record<string, any>;
|
|
91
73
|
}
|
|
74
|
+
export interface AddToProperty {
|
|
75
|
+
elementId: string;
|
|
76
|
+
targetProperty: string;
|
|
77
|
+
}
|
|
78
|
+
export interface RemoveFromProperty {
|
|
79
|
+
elementIds: string[];
|
|
80
|
+
targetProperty: string;
|
|
81
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { Resource, ResourceReference, Owner, OwnerType, Author } from './resource.interface';
|
|
2
2
|
export type { AiAssistant, AssistantMessage, Message, SpeechToken, SystemMessage, Thread, ThreadPopulated, ToolMessage, UserMessage, } from './ai.interface';
|
|
3
|
-
export type {
|
|
3
|
+
export type { Asset, AssetRevision, AssetType, AssetTypeRevision, Attachment, EventCause, EventLevelOverride, Template, } from './asset.interface';
|
|
4
4
|
export type { Event, EventLevel, CreateEventDto } from './event.interface';
|
|
5
5
|
export type { Label, CreateLabelDto, UpdateLabelDto } from './label.interface';
|
|
6
6
|
export type { TimeSeries, TimeSeriesBucket, TimeSeriesCondition, TimeSeriesValue, TS_GROUPS } from './timeseries.interface';
|
|
@@ -29,6 +29,7 @@ import { HttpMockService } from './http.mock.service';
|
|
|
29
29
|
import { LabelMockService } from './label.mock.service';
|
|
30
30
|
import { NotificationMockService } from './notification.mock.service';
|
|
31
31
|
import { OrganizationMockService } from './organization.mock.service';
|
|
32
|
+
import { SearchMockService } from './search.mock.service';
|
|
32
33
|
import { SecretMockService } from './secret.mock.service';
|
|
33
34
|
import { TaskMockService } from './task.mock.service';
|
|
34
35
|
import { TimeseriesMockService } from './timeseries.mock.service';
|
|
@@ -72,6 +73,7 @@ export declare class MockAPI implements API {
|
|
|
72
73
|
labels: LabelMockService;
|
|
73
74
|
notificationRules: NotificationRuleService;
|
|
74
75
|
proxy: ProxyService;
|
|
76
|
+
search: SearchMockService;
|
|
75
77
|
secrets: SecretMockService;
|
|
76
78
|
tasks: TaskMockService;
|
|
77
79
|
timeSeries: TimeseriesMockService;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
1
|
import { Filter, Paginated, RequestParameter } from '../data.interface';
|
|
3
2
|
import { TokenOption } from '../http.service';
|
|
4
3
|
import { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from '../interfaces';
|
|
4
|
+
import { AddToProperty, RemoveFromProperty } from '../interfaces/asset.interface';
|
|
5
5
|
import { AssetService } from '../services';
|
|
6
|
+
import { CrossPlatformFormData } from '../utils';
|
|
6
7
|
import { APIBaseMock } from './api-base.mock';
|
|
7
8
|
import { MockAPI } from './api.mock';
|
|
8
9
|
import { DataMockService } from './data.mock.service';
|
|
@@ -15,13 +16,15 @@ export declare class AssetMockService extends BaseService implements AssetServic
|
|
|
15
16
|
private api;
|
|
16
17
|
private revisions;
|
|
17
18
|
constructor(api: MockAPI, assets: Asset[], revisions: AssetRevision[]);
|
|
19
|
+
addElementToProperty(id: string, dto: AddToProperty): Promise<Asset>;
|
|
20
|
+
removeElementFromProperty(id: string, dto: RemoveFromProperty): Promise<Asset>;
|
|
18
21
|
private getAssets;
|
|
19
22
|
addOne(dto: Asset): Promise<Asset>;
|
|
20
23
|
count(filter: Filter, options?: TokenOption): Promise<number>;
|
|
21
24
|
deleteOne(assetId: string, force?: boolean): Promise<Asset>;
|
|
22
25
|
getMany(params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
23
26
|
updateOne(assetId: string, dto: Asset): Promise<Asset>;
|
|
24
|
-
addAttachment(id: string, form:
|
|
27
|
+
addAttachment(id: string, form: CrossPlatformFormData): Promise<Asset>;
|
|
25
28
|
getAttachments(assetId: string): Promise<Paginated<Attachment[]>>;
|
|
26
29
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
27
30
|
getEventLevelOverride(ids: string[], causes: string[]): Promise<EventLevelOverride>;
|
|
@@ -31,6 +34,9 @@ export declare class AssetMockService extends BaseService implements AssetServic
|
|
|
31
34
|
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
32
35
|
findOneExternal(key: string, options?: TokenOption): Promise<Asset>;
|
|
33
36
|
updateOneExternal(key: string, dto: any, options?: TokenOption): Promise<Asset>;
|
|
34
|
-
|
|
37
|
+
findTranslatedNames(lang: string, translationIds: string[], options?: TokenOption): Promise<Record<string, string>>;
|
|
38
|
+
link(id: string, elementId: string, targetProperty: string, options?: TokenOption & {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}): Promise<void>;
|
|
35
41
|
}
|
|
36
42
|
export {};
|
|
@@ -17,6 +17,12 @@ class AssetMockService extends BaseService {
|
|
|
17
17
|
this.api = api;
|
|
18
18
|
this.revisions = revisions;
|
|
19
19
|
}
|
|
20
|
+
addElementToProperty(id, dto) {
|
|
21
|
+
throw new Error('Method not implemented.');
|
|
22
|
+
}
|
|
23
|
+
removeElementFromProperty(id, dto) {
|
|
24
|
+
throw new Error('Method not implemented.');
|
|
25
|
+
}
|
|
20
26
|
getAssets(params, deleted = false) {
|
|
21
27
|
const data = this.data.filter((asset) => !!asset.deletedAt === deleted);
|
|
22
28
|
const page = {
|
|
@@ -123,13 +129,11 @@ class AssetMockService extends BaseService {
|
|
|
123
129
|
this.data[index] = { ...asset, ...dto };
|
|
124
130
|
return Promise.resolve(this.data[index]);
|
|
125
131
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
limit: Number.MAX_SAFE_INTEGER,
|
|
132
|
-
});
|
|
132
|
+
findTranslatedNames(lang, translationIds, options) {
|
|
133
|
+
throw new Error('Method not implemented.');
|
|
134
|
+
}
|
|
135
|
+
link(id, elementId, targetProperty, options = {}) {
|
|
136
|
+
throw new Error('Method not implemented.');
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
exports.AssetMockService = AssetMockService;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
1
|
import { Content, ReturnType } from '../content.interface';
|
|
3
2
|
import { ContentService } from '../content.service';
|
|
4
3
|
import { Paginated, RequestParameter } from '../data.interface';
|
|
4
|
+
import { CrossPlatformFormData } from '../utils';
|
|
5
5
|
import { APIBaseMock } from './api-base.mock';
|
|
6
6
|
import { DataMockService } from './data.mock.service';
|
|
7
7
|
import { TrashMockService } from './trash.mock.service';
|
|
@@ -20,6 +20,6 @@ export declare class ContentMockService extends BaseService implements ContentSe
|
|
|
20
20
|
download(id: string, returnType: ReturnType.ARRAYBUFFER): Promise<ArrayBuffer>;
|
|
21
21
|
deleteOne(contentId: string, force?: boolean): Promise<Content>;
|
|
22
22
|
getMany(params?: RequestParameter): Promise<Paginated<Content[]>>;
|
|
23
|
-
upload(form:
|
|
23
|
+
upload(form: CrossPlatformFormData): Promise<Content>;
|
|
24
24
|
}
|
|
25
25
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
1
|
import { FlowModule } from '../flow-module.interface';
|
|
3
2
|
import { FlowModuleService } from '../flow-module.service';
|
|
4
3
|
import { Artifact } from '../storage.interface';
|
|
4
|
+
import { CrossPlatformFormData } from '../utils';
|
|
5
5
|
import { Replace } from './api.mock';
|
|
6
6
|
import { DataMockService } from './data.mock.service';
|
|
7
7
|
type ExtendedFlowModule = Replace<FlowModule, 'artifacts', Array<Artifact & {
|
|
@@ -10,7 +10,7 @@ type ExtendedFlowModule = Replace<FlowModule, 'artifacts', Array<Artifact & {
|
|
|
10
10
|
export declare class FlowModulesMockService extends DataMockService<ExtendedFlowModule> implements FlowModuleService {
|
|
11
11
|
constructor(modules: ExtendedFlowModule[]);
|
|
12
12
|
deleteArtifact(name: string, version: string): Promise<FlowModule>;
|
|
13
|
-
publish(form:
|
|
13
|
+
publish(form: CrossPlatformFormData): Promise<unknown>;
|
|
14
14
|
getOne(name: string, options?: any): Promise<ExtendedFlowModule>;
|
|
15
15
|
}
|
|
16
16
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TokenOption } from 'lib/hpc-api/src/lib/http.service';
|
|
2
|
+
import { APIBase } from '../api-base';
|
|
3
|
+
import type { SearchOptions, SearchResult } from '../interfaces';
|
|
4
|
+
import { SearchService } from '../services';
|
|
5
|
+
export declare class SearchMockService extends APIBase implements SearchService {
|
|
6
|
+
search<T extends {
|
|
7
|
+
id?: string;
|
|
8
|
+
}, K extends keyof T & string = keyof T & string>(query: SearchOptions<T, K>, tokenOption?: TokenOption): Promise<SearchResult<T, K>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchMockService = void 0;
|
|
4
|
+
const api_base_1 = require("../api-base");
|
|
5
|
+
class SearchMockService extends api_base_1.APIBase {
|
|
6
|
+
search(query, tokenOption = {}) {
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SearchMockService = SearchMockService;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import FormData from 'form-data';
|
|
2
1
|
import { APIBase } from '../api-base';
|
|
3
2
|
import { Filter, Paginated, RequestParameter } from '../data.interface';
|
|
4
3
|
import { DataService } from '../data.service';
|
|
5
4
|
import { HttpClient, TokenOption } from '../http.service';
|
|
6
5
|
import { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from '../interfaces';
|
|
6
|
+
import { AddToProperty, RemoveFromProperty } from '../interfaces/asset.interface';
|
|
7
7
|
import { TrashService } from '../trash.service';
|
|
8
|
+
import { CrossPlatformFormData } from '../utils';
|
|
8
9
|
interface BaseService extends DataService<Asset>, TrashService<Asset> {
|
|
9
10
|
}
|
|
10
11
|
declare class BaseService extends APIBase {
|
|
@@ -13,7 +14,9 @@ export declare class AssetService extends BaseService {
|
|
|
13
14
|
constructor(httpClient: HttpClient);
|
|
14
15
|
count(filter: Filter, options?: TokenOption): Promise<number>;
|
|
15
16
|
deleteOne(id: string, force?: boolean, options?: TokenOption): Promise<any>;
|
|
16
|
-
addAttachment: (id: string, form:
|
|
17
|
+
addAttachment: (id: string, form: CrossPlatformFormData, options?: TokenOption) => Promise<Asset>;
|
|
18
|
+
addElementToProperty(id: string, dto: AddToProperty): Promise<Asset>;
|
|
19
|
+
removeElementFromProperty(id: string, dto: RemoveFromProperty): Promise<Asset>;
|
|
17
20
|
getChildren(assetId: string, params?: RequestParameter, options?: TokenOption): Promise<Paginated<Asset[]>>;
|
|
18
21
|
getAttachments(assetId: string, options?: TokenOption): Promise<Paginated<Attachment[]>>;
|
|
19
22
|
getEventLevelOverride(ids: string[], causes: string[], options?: TokenOption): Promise<EventLevelOverride>;
|
|
@@ -23,6 +26,9 @@ export declare class AssetService extends BaseService {
|
|
|
23
26
|
deleteRevision(assetId: string, revisionId: string, options?: TokenOption): Promise<any>;
|
|
24
27
|
findOneExternal(key: string, options?: TokenOption): Promise<Asset>;
|
|
25
28
|
updateOneExternal(key: string, dto: any, options?: TokenOption): Promise<Asset>;
|
|
26
|
-
|
|
29
|
+
findTranslatedNames(lang: string, translationIds: string[], options?: TokenOption): Promise<Record<string, string>>;
|
|
30
|
+
link(id: string, elementId: string, targetProperty: string, options?: TokenOption & {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}): Promise<void>;
|
|
27
33
|
}
|
|
28
34
|
export {};
|
|
@@ -6,6 +6,7 @@ const ts_mixer_1 = require("ts-mixer");
|
|
|
6
6
|
const api_base_1 = require("../api-base");
|
|
7
7
|
const data_service_1 = require("../data.service");
|
|
8
8
|
const trash_service_1 = require("../trash.service");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
let BaseService = class BaseService extends api_base_1.APIBase {
|
|
10
11
|
};
|
|
11
12
|
BaseService = tslib_1.__decorate([
|
|
@@ -15,9 +16,8 @@ class AssetService extends BaseService {
|
|
|
15
16
|
constructor(httpClient) {
|
|
16
17
|
super(httpClient, '/assets');
|
|
17
18
|
this.addAttachment = (id, form, options = {}) => {
|
|
18
|
-
const headers = { ...form.getHeaders() };
|
|
19
19
|
return this.httpClient.post(`${this.basePath}/${id}/attachment`, form, {
|
|
20
|
-
headers,
|
|
20
|
+
headers: (0, utils_1.getFormDataHeaders)(form),
|
|
21
21
|
maxBodyLength: Infinity,
|
|
22
22
|
maxContentLength: Infinity,
|
|
23
23
|
...options,
|
|
@@ -31,6 +31,12 @@ class AssetService extends BaseService {
|
|
|
31
31
|
deleteOne(id, force = false, options = {}) {
|
|
32
32
|
return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
|
|
33
33
|
}
|
|
34
|
+
addElementToProperty(id, dto) {
|
|
35
|
+
return this.httpClient.post(`${this.basePath}/${id}/link`, dto);
|
|
36
|
+
}
|
|
37
|
+
removeElementFromProperty(id, dto) {
|
|
38
|
+
return this.httpClient.post(`${this.basePath}/${id}/unlink`, dto);
|
|
39
|
+
}
|
|
34
40
|
getChildren(assetId, params = {}, options = {}) {
|
|
35
41
|
return this.getManyFiltered({ parent: assetId }, params, options);
|
|
36
42
|
}
|
|
@@ -58,8 +64,14 @@ class AssetService extends BaseService {
|
|
|
58
64
|
updateOneExternal(key, dto, options = {}) {
|
|
59
65
|
return this.httpClient.put(`${this.basePath}/external/${key}`, dto, options);
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
return this.httpClient.get(`${this.basePath}?
|
|
67
|
+
findTranslatedNames(lang, translationIds, options = {}) {
|
|
68
|
+
return this.httpClient.get(`${this.basePath}/translations/names/${lang}?translationIds=${translationIds.join(',')}`, options);
|
|
69
|
+
}
|
|
70
|
+
link(id, elementId, targetProperty, options = {}) {
|
|
71
|
+
return this.httpClient.post(`${this.basePath}/${id}/link`, {
|
|
72
|
+
elementId,
|
|
73
|
+
targetProperty,
|
|
74
|
+
}, options);
|
|
63
75
|
}
|
|
64
76
|
}
|
|
65
77
|
exports.AssetService = AssetService;
|
|
@@ -3,4 +3,5 @@ export { AssetService } from './asset.service';
|
|
|
3
3
|
export { AssetTypesService } from './assettypes.service';
|
|
4
4
|
export { EventService } from './event.service';
|
|
5
5
|
export { LabelService } from './label.service';
|
|
6
|
+
export { SearchService } from './search.service';
|
|
6
7
|
export { TimeSeriesService } from './timeseries.service';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimeSeriesService = exports.LabelService = exports.EventService = exports.AssetTypesService = exports.AssetService = exports.AiService = void 0;
|
|
3
|
+
exports.TimeSeriesService = exports.SearchService = exports.LabelService = exports.EventService = exports.AssetTypesService = exports.AssetService = exports.AiService = void 0;
|
|
4
4
|
var ai_service_1 = require("./ai.service");
|
|
5
5
|
Object.defineProperty(exports, "AiService", { enumerable: true, get: function () { return ai_service_1.AiService; } });
|
|
6
6
|
var asset_service_1 = require("./asset.service");
|
|
@@ -11,5 +11,7 @@ var event_service_1 = require("./event.service");
|
|
|
11
11
|
Object.defineProperty(exports, "EventService", { enumerable: true, get: function () { return event_service_1.EventService; } });
|
|
12
12
|
var label_service_1 = require("./label.service");
|
|
13
13
|
Object.defineProperty(exports, "LabelService", { enumerable: true, get: function () { return label_service_1.LabelService; } });
|
|
14
|
+
var search_service_1 = require("./search.service");
|
|
15
|
+
Object.defineProperty(exports, "SearchService", { enumerable: true, get: function () { return search_service_1.SearchService; } });
|
|
14
16
|
var timeseries_service_1 = require("./timeseries.service");
|
|
15
17
|
Object.defineProperty(exports, "TimeSeriesService", { enumerable: true, get: function () { return timeseries_service_1.TimeSeriesService; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { APIBase } from '../api-base';
|
|
2
|
+
import { HttpClient, TokenOption } from '../http.service';
|
|
3
|
+
import type { SearchOptions, SearchResult } from '../interfaces';
|
|
4
|
+
export declare class SearchService extends APIBase {
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
search<T extends {
|
|
7
|
+
id?: string;
|
|
8
|
+
}, K extends keyof T & string = keyof T & string>(query: SearchOptions<T, K>, tokenOption?: TokenOption): Promise<SearchResult<T, K>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchService = void 0;
|
|
4
|
+
const api_base_1 = require("../api-base");
|
|
5
|
+
class SearchService extends api_base_1.APIBase {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
super(httpClient, '/search');
|
|
8
|
+
}
|
|
9
|
+
search(query, tokenOption = {}) {
|
|
10
|
+
return this.httpClient.post(this.basePath, query, tokenOption);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SearchService = SearchService;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type CrossPlatformFormData = FormData | {
|
|
2
|
+
getHeaders(): Record<string, string>;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Utility function to get headers from FormData in a cross-platform way.
|
|
6
|
+
* Works with both node form-data package and browser native FormData.
|
|
7
|
+
*
|
|
8
|
+
* @param form - FormData object (either node or browser)
|
|
9
|
+
* @returns Headers object for HTTP requests
|
|
10
|
+
*/
|
|
11
|
+
export declare function getFormDataHeaders(form: CrossPlatformFormData): Record<string, string>;
|
package/src/lib/utils.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFormDataHeaders = getFormDataHeaders;
|
|
4
|
+
/**
|
|
5
|
+
* Utility function to get headers from FormData in a cross-platform way.
|
|
6
|
+
* Works with both node form-data package and browser native FormData.
|
|
7
|
+
*
|
|
8
|
+
* @param form - FormData object (either node or browser)
|
|
9
|
+
* @returns Headers object for HTTP requests
|
|
10
|
+
*/
|
|
11
|
+
function getFormDataHeaders(form) {
|
|
12
|
+
// check if it's node form-data (has getHeaders method)
|
|
13
|
+
if ('getHeaders' in form && typeof form.getHeaders === 'function') {
|
|
14
|
+
return form.getHeaders();
|
|
15
|
+
}
|
|
16
|
+
// for browser FormData, we don't need to set Content-Type header since it will automatically do so
|
|
17
|
+
return {};
|
|
18
|
+
}
|