@hahnpro/hpc-api 2025.3.3 → 2025.3.6
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 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/lib/api.d.ts +1 -2
- package/src/lib/api.js +1 -2
- package/src/lib/data.service.d.ts +1 -1
- package/src/lib/http.service.d.ts +1 -0
- package/src/lib/http.service.js +1 -0
- package/src/lib/interfaces/index.d.ts +2 -0
- package/src/lib/interfaces/label.interface.d.ts +16 -0
- package/src/lib/interfaces/search.interface.d.ts +24 -0
- package/src/lib/interfaces/search.interface.js +2 -0
- package/src/lib/mock/api.mock.d.ts +1 -2
- package/src/lib/mock/api.mock.js +5 -0
- package/src/lib/mock/asset.mock.service.d.ts +3 -1
- package/src/lib/mock/asset.mock.service.js +11 -0
- package/src/lib/mock/flow-deployment.mock.service.js +2 -1
- package/src/lib/mock/label.mock.service.d.ts +3 -2
- package/src/lib/mock/label.mock.service.js +9 -0
- package/src/lib/mock/organization.mock.service.d.ts +4 -1
- package/src/lib/mock/organization.mock.service.js +28 -1
- package/src/lib/mock/task.mock.service.d.ts +15 -2
- package/src/lib/mock/task.mock.service.js +92 -1
- package/src/lib/organization.interface.d.ts +10 -0
- package/src/lib/organization.service.d.ts +4 -1
- package/src/lib/organization.service.js +9 -0
- package/src/lib/services/asset.service.d.ts +3 -1
- package/src/lib/services/asset.service.js +7 -0
- package/src/lib/services/index.d.ts +1 -0
- package/src/lib/services/index.js +3 -1
- package/src/lib/services/label.service.d.ts +10 -0
- package/src/lib/{label.service.js → services/label.service.js} +4 -1
- package/src/lib/task.interface.d.ts +28 -0
- package/src/lib/task.service.d.ts +11 -1
- package/src/lib/task.service.js +27 -0
- package/src/lib/label.interface.d.ts +0 -8
- package/src/lib/label.service.d.ts +0 -9
- /package/src/lib/{label.interface.js → interfaces/label.interface.js} +0 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -8,10 +8,11 @@ export * from './lib/flow.interface';
|
|
|
8
8
|
export * from './lib/flow-deployment.interface';
|
|
9
9
|
export * from './lib/flow-function.interface';
|
|
10
10
|
export * from './lib/http.service';
|
|
11
|
-
export * from './lib/label.interface';
|
|
12
11
|
export * from './lib/mock';
|
|
13
12
|
export * from './lib/notification.interface';
|
|
13
|
+
export * from './lib/organization.interface';
|
|
14
14
|
export * from './lib/schema.interface';
|
|
15
15
|
export * from './lib/secret.interface';
|
|
16
16
|
export * from './lib/task.interface';
|
|
17
17
|
export * from './lib/vault.interface';
|
|
18
|
+
export * from './lib/task.service';
|
package/src/index.js
CHANGED
|
@@ -10,10 +10,11 @@ tslib_1.__exportStar(require("./lib/flow.interface"), exports);
|
|
|
10
10
|
tslib_1.__exportStar(require("./lib/flow-deployment.interface"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./lib/flow-function.interface"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./lib/http.service"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./lib/label.interface"), exports);
|
|
14
13
|
tslib_1.__exportStar(require("./lib/mock"), exports);
|
|
15
14
|
tslib_1.__exportStar(require("./lib/notification.interface"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./lib/organization.interface"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./lib/schema.interface"), exports);
|
|
17
17
|
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
|
+
tslib_1.__exportStar(require("./lib/task.service"), exports);
|
package/src/lib/api.d.ts
CHANGED
|
@@ -6,13 +6,12 @@ import { FlowFunctionService } from './flow-function.service';
|
|
|
6
6
|
import { FlowModuleService } from './flow-module.service';
|
|
7
7
|
import { FlowService } from './flow.service';
|
|
8
8
|
import { HttpClient } from './http.service';
|
|
9
|
-
import { LabelService } from './label.service';
|
|
10
9
|
import { NotificationRuleService } from './notification-rule.service';
|
|
11
10
|
import { NotificationService } from './notification.service';
|
|
12
11
|
import { OrganizationService } from './organization.service';
|
|
13
12
|
import { ProxyService } from './proxy.service';
|
|
14
13
|
import { SecretService } from './secret.service';
|
|
15
|
-
import { AiService, AssetService, AssetTypesService, EventService, TimeSeriesService } from './services';
|
|
14
|
+
import { AiService, AssetService, AssetTypesService, EventService, LabelService, TimeSeriesService } from './services';
|
|
16
15
|
import { TaskService } from './task.service';
|
|
17
16
|
import { UserService } from './user.service';
|
|
18
17
|
import { VaultService } from './vault.service';
|
package/src/lib/api.js
CHANGED
|
@@ -9,7 +9,6 @@ const flow_function_service_1 = require("./flow-function.service");
|
|
|
9
9
|
const flow_module_service_1 = require("./flow-module.service");
|
|
10
10
|
const flow_service_1 = require("./flow.service");
|
|
11
11
|
const http_service_1 = require("./http.service");
|
|
12
|
-
const label_service_1 = require("./label.service");
|
|
13
12
|
const notification_rule_service_1 = require("./notification-rule.service");
|
|
14
13
|
const notification_service_1 = require("./notification.service");
|
|
15
14
|
const organization_service_1 = require("./organization.service");
|
|
@@ -53,7 +52,7 @@ class API {
|
|
|
53
52
|
this.flowDeployments = new flow_deployment_service_1.FlowDeploymentService(this.httpClient);
|
|
54
53
|
this.flowFunctions = new flow_function_service_1.FlowFunctionService(this.httpClient);
|
|
55
54
|
this.flowModules = new flow_module_service_1.FlowModuleService(this.httpClient);
|
|
56
|
-
this.labels = new
|
|
55
|
+
this.labels = new services_1.LabelService(this.httpClient);
|
|
57
56
|
this.organizations = new organization_service_1.OrganizationService(this.httpClient);
|
|
58
57
|
this.proxy = new proxy_service_1.ProxyService(this.httpClient);
|
|
59
58
|
this.secrets = new secret_service_1.SecretService(this.httpClient);
|
|
@@ -23,5 +23,5 @@ export declare class DataService<T> extends APIBase implements DataInterface<T>
|
|
|
23
23
|
[key: string]: any;
|
|
24
24
|
}): Promise<T>;
|
|
25
25
|
deleteOne(id: string, force?: boolean, options?: TokenOption): Promise<any>;
|
|
26
|
-
|
|
26
|
+
protected getFilterString(filter: Filter): string;
|
|
27
27
|
}
|
|
@@ -35,6 +35,7 @@ export declare class HttpClient {
|
|
|
35
35
|
get: <T>(url: string, config?: Config) => Promise<T>;
|
|
36
36
|
post: <T>(url: string, data: any, config?: Config) => Promise<T>;
|
|
37
37
|
put: <T>(url: string, data: any, config?: Config) => Promise<T>;
|
|
38
|
+
patch: <T>(url: string, data: any, config?: Config) => Promise<T>;
|
|
38
39
|
protected request: <T>(method: Method, url: string, config?: Config, data?: any) => Promise<T>;
|
|
39
40
|
addEventSource(url: string, listener: (event: MessageEvent) => void, errorListener?: (event: MessageEvent) => void, options?: TokenOption): Promise<string>;
|
|
40
41
|
destroyEventSource(id: string): void;
|
package/src/lib/http.service.js
CHANGED
|
@@ -22,6 +22,7 @@ class HttpClient {
|
|
|
22
22
|
this.get = (url, config) => this.request('GET', url, config);
|
|
23
23
|
this.post = (url, data, config) => this.request('POST', url, config, data);
|
|
24
24
|
this.put = (url, data, config) => this.request('PUT', url, config, data);
|
|
25
|
+
this.patch = (url, data, config) => this.request('PATCH', url, config, data);
|
|
25
26
|
this.request = (method, url, config = {}, data) => {
|
|
26
27
|
return this.requestQueue.add(() => new Promise((resolve, reject) => {
|
|
27
28
|
const tokenP = config.token ? Promise.resolve(config.token) : this.getAccessToken();
|
|
@@ -2,4 +2,6 @@ export type { Resource, ResourceReference, Owner, OwnerType, Author } from './re
|
|
|
2
2
|
export type { AiAssistant, AssistantMessage, Message, SpeechToken, SystemMessage, Thread, ThreadPopulated, ToolMessage, UserMessage, } from './ai.interface';
|
|
3
3
|
export type { Action, ActionRevision, Asset, AssetRevision, AssetType, AssetTypeRevision, Attachment, EventCause, EventLevelOverride, Template, } from './asset.interface';
|
|
4
4
|
export type { Event, EventLevel, CreateEventDto } from './event.interface';
|
|
5
|
+
export type { Label, CreateLabelDto, UpdateLabelDto } from './label.interface';
|
|
5
6
|
export type { TimeSeries, TimeSeriesBucket, TimeSeriesCondition, TimeSeriesValue, TS_GROUPS } from './timeseries.interface';
|
|
7
|
+
export type { SearchOptions, SearchResult, SearchSortOption, SortableField } from './search.interface';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Author, Owner } from './resource.interface';
|
|
2
|
+
export interface Label {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
readPermissions?: string[];
|
|
8
|
+
readWritePermissions: string[];
|
|
9
|
+
owner: Owner;
|
|
10
|
+
createdBy: Author;
|
|
11
|
+
updatedBy: Author;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export type CreateLabelDto = Pick<Label, 'name' | 'description' | 'color' | 'readPermissions' | 'readWritePermissions'>;
|
|
16
|
+
export type UpdateLabelDto = Partial<CreateLabelDto>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SearchOptions<T extends {
|
|
2
|
+
id?: string;
|
|
3
|
+
}, K extends keyof T & string = keyof T & string> {
|
|
4
|
+
query: string;
|
|
5
|
+
sort?: SearchSortOption<T>[];
|
|
6
|
+
limit?: number;
|
|
7
|
+
offset?: number;
|
|
8
|
+
trackTotal?: boolean;
|
|
9
|
+
resultFields?: K[];
|
|
10
|
+
searchFields?: string[];
|
|
11
|
+
}
|
|
12
|
+
export type SortableField<T> = keyof T | `${keyof T & string}.keyword`;
|
|
13
|
+
export interface SearchSortOption<T> {
|
|
14
|
+
field: SortableField<T>;
|
|
15
|
+
order: 'asc' | 'desc';
|
|
16
|
+
}
|
|
17
|
+
export interface SearchResult<T extends {
|
|
18
|
+
id?: string;
|
|
19
|
+
} = any, K extends keyof T & string = keyof T & string> {
|
|
20
|
+
docs: Pick<T, K | 'id'>[];
|
|
21
|
+
limit: number;
|
|
22
|
+
offset: number;
|
|
23
|
+
total: number;
|
|
24
|
+
}
|
|
@@ -10,8 +10,7 @@ import { FlowModule } from '../flow-module.interface';
|
|
|
10
10
|
import { FlowModuleService } from '../flow-module.service';
|
|
11
11
|
import { FlowDiagram, FlowDto, FlowRevision } from '../flow.interface';
|
|
12
12
|
import { FlowService } from '../flow.service';
|
|
13
|
-
import { Asset, AssetRevision, AssetType, Event, TimeSeries, TimeSeriesValue } from '../interfaces';
|
|
14
|
-
import { Label } from '../label.interface';
|
|
13
|
+
import { Asset, AssetRevision, AssetType, Event, Label, TimeSeries, TimeSeriesValue } from '../interfaces';
|
|
15
14
|
import { NotificationRuleService } from '../notification-rule.service';
|
|
16
15
|
import { Notification } from '../notification.interface';
|
|
17
16
|
import { Organization } from '../organization.interface';
|
package/src/lib/mock/api.mock.js
CHANGED
|
@@ -168,6 +168,11 @@ class MockAPI {
|
|
|
168
168
|
description: v.description ?? '',
|
|
169
169
|
readPermissions: v.readPermissions ?? [],
|
|
170
170
|
readWritePermissions: v.readWritePermissions ?? [],
|
|
171
|
+
owner: v.owner ?? { id: '123', type: 'org' },
|
|
172
|
+
createdBy: v.createdBy ?? { id: '123', username: 'test-user' },
|
|
173
|
+
updatedBy: v.updatedBy ?? { id: '123', username: 'test-user' },
|
|
174
|
+
createdAt: v.createdAt ?? new Date().toISOString(),
|
|
175
|
+
updatedAt: v.updatedAt ?? new Date().toISOString(),
|
|
171
176
|
}));
|
|
172
177
|
const vaultSecrets1 = vault.map((v) => ({
|
|
173
178
|
...v,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
-
import { Paginated, RequestParameter } from '../data.interface';
|
|
2
|
+
import { Filter, Paginated, RequestParameter } from '../data.interface';
|
|
3
3
|
import { TokenOption } from '../http.service';
|
|
4
4
|
import { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from '../interfaces';
|
|
5
5
|
import { AssetService } from '../services';
|
|
@@ -17,6 +17,7 @@ export declare class AssetMockService extends BaseService implements AssetServic
|
|
|
17
17
|
constructor(api: MockAPI, assets: Asset[], revisions: AssetRevision[]);
|
|
18
18
|
private getAssets;
|
|
19
19
|
addOne(dto: Asset): Promise<Asset>;
|
|
20
|
+
count(filter: Filter, options?: TokenOption): Promise<number>;
|
|
20
21
|
deleteOne(assetId: string, force?: boolean): Promise<Asset>;
|
|
21
22
|
getMany(params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
22
23
|
updateOne(assetId: string, dto: Asset): Promise<Asset>;
|
|
@@ -30,5 +31,6 @@ export declare class AssetMockService extends BaseService implements AssetServic
|
|
|
30
31
|
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
31
32
|
findOneExternal(key: string, options?: TokenOption): Promise<Asset>;
|
|
32
33
|
updateOneExternal(key: string, dto: any, options?: TokenOption): Promise<Asset>;
|
|
34
|
+
findByName(name: string, options?: TokenOption): Promise<Paginated<Asset[]>>;
|
|
33
35
|
}
|
|
34
36
|
export {};
|
|
@@ -30,6 +30,9 @@ class AssetMockService extends BaseService {
|
|
|
30
30
|
this.revisions.push({ ...dto, originalId: dto.id });
|
|
31
31
|
return super.addOne(dto);
|
|
32
32
|
}
|
|
33
|
+
count(filter, options = {}) {
|
|
34
|
+
return Promise.resolve(this.data.length);
|
|
35
|
+
}
|
|
33
36
|
deleteOne(assetId, force = false) {
|
|
34
37
|
const asset = this.data.find((v) => v.id === assetId);
|
|
35
38
|
if (!asset?.deletedAt && !force) {
|
|
@@ -120,5 +123,13 @@ class AssetMockService extends BaseService {
|
|
|
120
123
|
this.data[index] = { ...asset, ...dto };
|
|
121
124
|
return Promise.resolve(this.data[index]);
|
|
122
125
|
}
|
|
126
|
+
findByName(name, options = {}) {
|
|
127
|
+
const docs = this.data.filter((asset) => asset.name === name);
|
|
128
|
+
return Promise.resolve({
|
|
129
|
+
docs,
|
|
130
|
+
total: docs.length,
|
|
131
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
123
134
|
}
|
|
124
135
|
exports.AssetMockService = AssetMockService;
|
|
@@ -112,8 +112,9 @@ class FlowDeploymentMockService extends BaseService {
|
|
|
112
112
|
async getReferences(properties) {
|
|
113
113
|
// super simplified version of real resolver
|
|
114
114
|
return Promise.all(Object.keys(properties).map(async (prop) => {
|
|
115
|
-
if (prop !== 'assetId')
|
|
115
|
+
if (prop !== 'assetId') {
|
|
116
116
|
throw new Error('not implemented');
|
|
117
|
+
}
|
|
117
118
|
return { id: (await this.api.assets.getOne(properties[prop])).id, resourceType: 'asset' };
|
|
118
119
|
}));
|
|
119
120
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Label } from '../
|
|
2
|
-
import { LabelService } from '../label.service';
|
|
1
|
+
import type { Label, SearchOptions, SearchResult } from '../interfaces';
|
|
2
|
+
import { LabelService } from '../services/label.service';
|
|
3
3
|
import { DataMockService } from './data.mock.service';
|
|
4
4
|
export declare class LabelMockService extends DataMockService<Label> implements LabelService {
|
|
5
5
|
constructor(labels: Label[]);
|
|
6
6
|
count(): Promise<number>;
|
|
7
7
|
getOneByName(name: string): Promise<Label>;
|
|
8
|
+
search(query: SearchOptions<Label>, _: any): Promise<SearchResult<Label>>;
|
|
8
9
|
}
|
|
@@ -13,5 +13,14 @@ class LabelMockService extends data_mock_service_1.DataMockService {
|
|
|
13
13
|
getOneByName(name) {
|
|
14
14
|
return Promise.resolve(this.data.find((label) => label.name === name));
|
|
15
15
|
}
|
|
16
|
+
search(query, _) {
|
|
17
|
+
const docs = this.data.filter((label) => label.name.includes(query.query));
|
|
18
|
+
return Promise.resolve({
|
|
19
|
+
docs,
|
|
20
|
+
limit: query.limit,
|
|
21
|
+
offset: query.offset,
|
|
22
|
+
total: docs.length,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
16
25
|
}
|
|
17
26
|
exports.LabelMockService = LabelMockService;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { Organization } from '../organization.interface';
|
|
1
|
+
import { Organization, OrganizationName, SubscriptionType, UserWithOrgRoles } from '../organization.interface';
|
|
2
2
|
import { OrganizationService } from '../organization.service';
|
|
3
3
|
import { DataMockService } from './data.mock.service';
|
|
4
4
|
export declare class OrganizationMockService extends DataMockService<Organization> implements OrganizationService {
|
|
5
5
|
constructor(organizations: Organization[]);
|
|
6
6
|
addOrganizationInvitation(id: string, email: string, roles: string[]): Promise<void>;
|
|
7
|
+
addOrganizationMembers(id: string, usersWithOrgRoles: UserWithOrgRoles[]): Promise<void>;
|
|
8
|
+
addSubscriptionToOrganization(id: string, type: SubscriptionType): Promise<Organization>;
|
|
9
|
+
getOrganizationIdByName(name: string): Promise<OrganizationName>;
|
|
7
10
|
}
|
|
@@ -9,9 +9,36 @@ class OrganizationMockService extends data_mock_service_1.DataMockService {
|
|
|
9
9
|
}
|
|
10
10
|
addOrganizationInvitation(id, email, roles) {
|
|
11
11
|
if (!id || !email || !roles?.length) {
|
|
12
|
-
return Promise.reject();
|
|
12
|
+
return Promise.reject('Bad Request');
|
|
13
13
|
}
|
|
14
14
|
return Promise.resolve();
|
|
15
15
|
}
|
|
16
|
+
addOrganizationMembers(id, usersWithOrgRoles) {
|
|
17
|
+
if (!id ||
|
|
18
|
+
!usersWithOrgRoles?.length ||
|
|
19
|
+
usersWithOrgRoles.some((userWithOrgRoles) => !userWithOrgRoles.username || !userWithOrgRoles.orgRoles?.length)) {
|
|
20
|
+
return Promise.reject('Bad Request');
|
|
21
|
+
}
|
|
22
|
+
return Promise.resolve();
|
|
23
|
+
}
|
|
24
|
+
addSubscriptionToOrganization(id, type) {
|
|
25
|
+
if (!id || !type) {
|
|
26
|
+
return Promise.reject('Bad Request');
|
|
27
|
+
}
|
|
28
|
+
const organization = this.data.find((org) => org.id === id);
|
|
29
|
+
if (!organization) {
|
|
30
|
+
return Promise.reject('Not Found');
|
|
31
|
+
}
|
|
32
|
+
const existingId = organization.subscriptionId;
|
|
33
|
+
if (existingId) {
|
|
34
|
+
organization.previousSubscriptions = [existingId, ...(organization.previousSubscriptions || [])];
|
|
35
|
+
}
|
|
36
|
+
organization.subscriptionId = `test-subscription-${organization.previousSubscriptions?.length || 0}`;
|
|
37
|
+
return Promise.resolve(organization);
|
|
38
|
+
}
|
|
39
|
+
getOrganizationIdByName(name) {
|
|
40
|
+
const id = this.data.find((org) => org.name === name)?.id;
|
|
41
|
+
return Promise.resolve({ id });
|
|
42
|
+
}
|
|
16
43
|
}
|
|
17
44
|
exports.OrganizationMockService = OrganizationMockService;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Paginated, RequestParameter } from '../data.interface';
|
|
2
|
-
import {
|
|
2
|
+
import { TokenOption } from '../http.service';
|
|
3
|
+
import { LogbookEntry, LogbookEntryDto, Task } from '../task.interface';
|
|
3
4
|
import { TaskService } from '../task.service';
|
|
4
5
|
import { APIBaseMock } from './api-base.mock';
|
|
5
6
|
import { DataMockService } from './data.mock.service';
|
|
@@ -9,9 +10,21 @@ interface BaseService extends DataMockService<Task>, TrashMockService<Task> {
|
|
|
9
10
|
declare class BaseService extends APIBaseMock<Task> {
|
|
10
11
|
}
|
|
11
12
|
export declare class TaskMockService extends BaseService implements TaskService {
|
|
12
|
-
|
|
13
|
+
private entries;
|
|
14
|
+
constructor(tasks: Task[], logbookEntries?: LogbookEntry[]);
|
|
13
15
|
createTaskAttachedToAsset(dto: any): Promise<Task>;
|
|
14
16
|
deleteOne(taskId: string, force?: boolean): Promise<Task>;
|
|
15
17
|
getMany(params?: RequestParameter): Promise<Paginated<Task[]>>;
|
|
18
|
+
findByName(name: string, options?: any): Promise<Paginated<Task[]>>;
|
|
19
|
+
findByAsset(assetId: string, options?: any): Promise<Paginated<Task[]>>;
|
|
20
|
+
getLogbookEntries(taskId: string, limit?: number, offset?: number, _options?: TokenOption): Promise<Paginated<LogbookEntry[]>>;
|
|
21
|
+
addLogbookEntry(taskId: string, dto: LogbookEntryDto, _options?: TokenOption): Promise<LogbookEntry>;
|
|
22
|
+
updateLogbookEntry(taskId: string, entryId: string, dto: Partial<LogbookEntryDto>, _options?: TokenOption): Promise<LogbookEntry>;
|
|
23
|
+
deleteLogbookEntry(taskId: string, entryId: string, _options?: TokenOption): Promise<{
|
|
24
|
+
deleted: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
getUserLogbookEntries(limit?: number, offset?: number, _options?: TokenOption, userId?: string): Promise<Paginated<LogbookEntry[]>>;
|
|
27
|
+
seed(entries: LogbookEntry[]): void;
|
|
28
|
+
clear(): void;
|
|
16
29
|
}
|
|
17
30
|
export {};
|
|
@@ -12,8 +12,10 @@ BaseService = tslib_1.__decorate([
|
|
|
12
12
|
(0, ts_mixer_1.mix)(data_mock_service_1.DataMockService, trash_mock_service_1.TrashMockService)
|
|
13
13
|
], BaseService);
|
|
14
14
|
class TaskMockService extends BaseService {
|
|
15
|
-
constructor(tasks) {
|
|
15
|
+
constructor(tasks, logbookEntries = []) {
|
|
16
16
|
super(tasks);
|
|
17
|
+
this.entries = [];
|
|
18
|
+
this.entries = [...logbookEntries];
|
|
17
19
|
}
|
|
18
20
|
async createTaskAttachedToAsset(dto) {
|
|
19
21
|
this.data.push(dto);
|
|
@@ -32,5 +34,94 @@ class TaskMockService extends BaseService {
|
|
|
32
34
|
const page = this.getItems(params, false);
|
|
33
35
|
return Promise.resolve(page);
|
|
34
36
|
}
|
|
37
|
+
findByName(name, options = {}) {
|
|
38
|
+
const filtered = this.data.filter((task) => task.name === name);
|
|
39
|
+
const result = {
|
|
40
|
+
docs: filtered,
|
|
41
|
+
total: filtered.length,
|
|
42
|
+
page: 1,
|
|
43
|
+
limit: filtered.length,
|
|
44
|
+
};
|
|
45
|
+
return Promise.resolve(result);
|
|
46
|
+
}
|
|
47
|
+
findByAsset(assetId, options = {}) {
|
|
48
|
+
const filtered = this.data.filter((task) => task.assetRef === assetId);
|
|
49
|
+
const result = {
|
|
50
|
+
docs: filtered,
|
|
51
|
+
total: filtered.length,
|
|
52
|
+
page: 1,
|
|
53
|
+
limit: filtered.length,
|
|
54
|
+
};
|
|
55
|
+
return Promise.resolve(result);
|
|
56
|
+
}
|
|
57
|
+
// override network methods to in‑memory versions
|
|
58
|
+
async getLogbookEntries(taskId, limit = 50, offset = 0, _options = {}) {
|
|
59
|
+
const taskEntries = this.entries.filter((e) => e.taskId === taskId);
|
|
60
|
+
const docs = taskEntries.slice(offset, offset + limit);
|
|
61
|
+
return {
|
|
62
|
+
docs,
|
|
63
|
+
limit,
|
|
64
|
+
offset,
|
|
65
|
+
total: taskEntries.length,
|
|
66
|
+
page: Math.floor(offset / limit) + 1,
|
|
67
|
+
pages: Math.max(1, Math.ceil(taskEntries.length / limit)),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async addLogbookEntry(taskId, dto, _options = {}) {
|
|
71
|
+
const id = globalThis.crypto?.randomUUID?.() || Math.random().toString(36).slice(2);
|
|
72
|
+
const now = new Date().toISOString();
|
|
73
|
+
const entry = {
|
|
74
|
+
id,
|
|
75
|
+
taskId,
|
|
76
|
+
date: dto.date || now,
|
|
77
|
+
duration: dto.duration ?? 0,
|
|
78
|
+
materials: dto.materials || [],
|
|
79
|
+
comment: dto.comment || '',
|
|
80
|
+
source: 'manual',
|
|
81
|
+
createdAt: now,
|
|
82
|
+
updatedAt: now,
|
|
83
|
+
createdBy: dto.createdBy || { id: 'mock-user', username: 'mock-user' },
|
|
84
|
+
};
|
|
85
|
+
this.entries.push(entry);
|
|
86
|
+
return entry;
|
|
87
|
+
}
|
|
88
|
+
async updateLogbookEntry(taskId, entryId, dto, _options = {}) {
|
|
89
|
+
const idx = this.entries.findIndex((e) => e.id === entryId && e.taskId === taskId);
|
|
90
|
+
if (idx === -1) {
|
|
91
|
+
throw new Error('Not found');
|
|
92
|
+
}
|
|
93
|
+
const updated = {
|
|
94
|
+
...this.entries[idx],
|
|
95
|
+
...dto,
|
|
96
|
+
materials: dto.materials !== undefined ? dto.materials : this.entries[idx].materials,
|
|
97
|
+
updatedAt: new Date().toISOString(),
|
|
98
|
+
};
|
|
99
|
+
this.entries[idx] = updated;
|
|
100
|
+
return updated;
|
|
101
|
+
}
|
|
102
|
+
async deleteLogbookEntry(taskId, entryId, _options = {}) {
|
|
103
|
+
const before = this.entries.length;
|
|
104
|
+
this.entries = this.entries.filter((e) => !(e.id === entryId && e.taskId === taskId));
|
|
105
|
+
return { deleted: this.entries.length < before };
|
|
106
|
+
}
|
|
107
|
+
async getUserLogbookEntries(limit = 50, offset = 0, _options = {}, userId = 'mock-user') {
|
|
108
|
+
const userEntries = this.entries.filter((e) => e.createdBy?.id === userId);
|
|
109
|
+
const docs = userEntries.slice(offset, offset + limit);
|
|
110
|
+
return {
|
|
111
|
+
docs,
|
|
112
|
+
limit,
|
|
113
|
+
offset,
|
|
114
|
+
total: userEntries.length,
|
|
115
|
+
page: Math.floor(offset / limit) + 1,
|
|
116
|
+
pages: Math.max(1, Math.ceil(userEntries.length / limit)),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// test helpers
|
|
120
|
+
seed(entries) {
|
|
121
|
+
this.entries = [...entries];
|
|
122
|
+
}
|
|
123
|
+
clear() {
|
|
124
|
+
this.entries = [];
|
|
125
|
+
}
|
|
35
126
|
}
|
|
36
127
|
exports.TaskMockService = TaskMockService;
|
|
@@ -24,3 +24,13 @@ export interface Organization {
|
|
|
24
24
|
createdBy?: Author;
|
|
25
25
|
updatedBy?: Author;
|
|
26
26
|
}
|
|
27
|
+
export interface OrganizationName {
|
|
28
|
+
id: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
isDeleted?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface UserWithOrgRoles {
|
|
33
|
+
username: string;
|
|
34
|
+
orgRoles: string[];
|
|
35
|
+
}
|
|
36
|
+
export type SubscriptionType = 'dev' | 'free' | 'inactive' | 'pro';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { DataService } from './data.service';
|
|
2
2
|
import { HttpClient } from './http.service';
|
|
3
|
-
import { Organization } from './organization.interface';
|
|
3
|
+
import { Organization, OrganizationName, SubscriptionType, UserWithOrgRoles } from './organization.interface';
|
|
4
4
|
export declare class OrganizationService extends DataService<Organization> {
|
|
5
5
|
constructor(httpClient: HttpClient);
|
|
6
6
|
addOrganizationInvitation(id: string, email: string, roles: string[]): Promise<void>;
|
|
7
|
+
addOrganizationMembers(id: string, usersWithOrgRoles: UserWithOrgRoles[]): Promise<void>;
|
|
8
|
+
addSubscriptionToOrganization(id: string, type: SubscriptionType): Promise<Organization>;
|
|
9
|
+
getOrganizationIdByName(name: string): Promise<OrganizationName>;
|
|
7
10
|
}
|
|
@@ -9,5 +9,14 @@ class OrganizationService extends data_service_1.DataService {
|
|
|
9
9
|
addOrganizationInvitation(id, email, roles) {
|
|
10
10
|
return this.httpClient.post(`${this.basePath}/${id}/data/invitations`, { roles, email });
|
|
11
11
|
}
|
|
12
|
+
addOrganizationMembers(id, usersWithOrgRoles) {
|
|
13
|
+
return this.httpClient.post(`${this.basePath}/${id}/members`, { usersWithOrgRoles });
|
|
14
|
+
}
|
|
15
|
+
addSubscriptionToOrganization(id, type) {
|
|
16
|
+
return this.httpClient.post(`${this.basePath}/${id}/subscription`, { type });
|
|
17
|
+
}
|
|
18
|
+
getOrganizationIdByName(name) {
|
|
19
|
+
return this.httpClient.get(`${this.basePath}/names/${name}`);
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
exports.OrganizationService = OrganizationService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
2
|
import { APIBase } from '../api-base';
|
|
3
|
-
import { Paginated, RequestParameter } from '../data.interface';
|
|
3
|
+
import { Filter, Paginated, RequestParameter } from '../data.interface';
|
|
4
4
|
import { DataService } from '../data.service';
|
|
5
5
|
import { HttpClient, TokenOption } from '../http.service';
|
|
6
6
|
import { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from '../interfaces';
|
|
@@ -11,6 +11,7 @@ declare class BaseService extends APIBase {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class AssetService extends BaseService {
|
|
13
13
|
constructor(httpClient: HttpClient);
|
|
14
|
+
count(filter: Filter, options?: TokenOption): Promise<number>;
|
|
14
15
|
deleteOne(id: string, force?: boolean, options?: TokenOption): Promise<any>;
|
|
15
16
|
addAttachment: (id: string, form: FormData, options?: TokenOption) => Promise<Asset>;
|
|
16
17
|
getChildren(assetId: string, params?: RequestParameter, options?: TokenOption): Promise<Paginated<Asset[]>>;
|
|
@@ -22,5 +23,6 @@ export declare class AssetService extends BaseService {
|
|
|
22
23
|
deleteRevision(assetId: string, revisionId: string, options?: TokenOption): Promise<any>;
|
|
23
24
|
findOneExternal(key: string, options?: TokenOption): Promise<Asset>;
|
|
24
25
|
updateOneExternal(key: string, dto: any, options?: TokenOption): Promise<Asset>;
|
|
26
|
+
findByName(name: string, options?: TokenOption): Promise<Paginated<Asset[]>>;
|
|
25
27
|
}
|
|
26
28
|
export {};
|
|
@@ -24,6 +24,10 @@ class AssetService extends BaseService {
|
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
count(filter, options = {}) {
|
|
28
|
+
const params = { filter: this.getFilterString(filter) };
|
|
29
|
+
return this.httpClient.get(`${this.basePath}/count`, { params, ...options });
|
|
30
|
+
}
|
|
27
31
|
deleteOne(id, force = false, options = {}) {
|
|
28
32
|
return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
|
|
29
33
|
}
|
|
@@ -54,5 +58,8 @@ class AssetService extends BaseService {
|
|
|
54
58
|
updateOneExternal(key, dto, options = {}) {
|
|
55
59
|
return this.httpClient.put(`${this.basePath}/external/${key}`, dto, options);
|
|
56
60
|
}
|
|
61
|
+
findByName(name, options = {}) {
|
|
62
|
+
return this.httpClient.get(`${this.basePath}?name=${encodeURIComponent(name)}`, options);
|
|
63
|
+
}
|
|
57
64
|
}
|
|
58
65
|
exports.AssetService = AssetService;
|
|
@@ -2,4 +2,5 @@ export { AiService } from './ai.service';
|
|
|
2
2
|
export { AssetService } from './asset.service';
|
|
3
3
|
export { AssetTypesService } from './assettypes.service';
|
|
4
4
|
export { EventService } from './event.service';
|
|
5
|
+
export { LabelService } from './label.service';
|
|
5
6
|
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.EventService = exports.AssetTypesService = exports.AssetService = exports.AiService = void 0;
|
|
3
|
+
exports.TimeSeriesService = 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");
|
|
@@ -9,5 +9,7 @@ var assettypes_service_1 = require("./assettypes.service");
|
|
|
9
9
|
Object.defineProperty(exports, "AssetTypesService", { enumerable: true, get: function () { return assettypes_service_1.AssetTypesService; } });
|
|
10
10
|
var event_service_1 = require("./event.service");
|
|
11
11
|
Object.defineProperty(exports, "EventService", { enumerable: true, get: function () { return event_service_1.EventService; } });
|
|
12
|
+
var label_service_1 = require("./label.service");
|
|
13
|
+
Object.defineProperty(exports, "LabelService", { enumerable: true, get: function () { return label_service_1.LabelService; } });
|
|
12
14
|
var timeseries_service_1 = require("./timeseries.service");
|
|
13
15
|
Object.defineProperty(exports, "TimeSeriesService", { enumerable: true, get: function () { return timeseries_service_1.TimeSeriesService; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataService } from '../data.service';
|
|
2
|
+
import { HttpClient, TokenOption } from '../http.service';
|
|
3
|
+
import type { Label, SearchOptions, SearchResult } from '../interfaces';
|
|
4
|
+
export declare class LabelService extends DataService<Label> {
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
addMany(dtos: Label[], options?: TokenOption): Promise<Label[]>;
|
|
7
|
+
getOneByName(name: string, options?: TokenOption): Promise<Label>;
|
|
8
|
+
count(options?: TokenOption): Promise<number>;
|
|
9
|
+
search<K extends keyof Label>(query: SearchOptions<Label, K>, tokenOption?: TokenOption): Promise<SearchResult<Label, K>>;
|
|
10
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LabelService = void 0;
|
|
4
|
-
const data_service_1 = require("
|
|
4
|
+
const data_service_1 = require("../data.service");
|
|
5
5
|
class LabelService extends data_service_1.DataService {
|
|
6
6
|
constructor(httpClient) {
|
|
7
7
|
super(httpClient, '/labels');
|
|
@@ -15,5 +15,8 @@ class LabelService extends data_service_1.DataService {
|
|
|
15
15
|
count(options = {}) {
|
|
16
16
|
return this.httpClient.get(`${this.basePath}/count`, options);
|
|
17
17
|
}
|
|
18
|
+
search(query, tokenOption = {}) {
|
|
19
|
+
return this.httpClient.post(`${this.basePath}/search`, query, tokenOption);
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
exports.LabelService = LabelService;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Author } from './interfaces/resource.interface';
|
|
1
2
|
export interface Task {
|
|
2
3
|
id: string;
|
|
3
4
|
name: string;
|
|
@@ -21,3 +22,30 @@ export interface Task {
|
|
|
21
22
|
updatedAt?: string;
|
|
22
23
|
deletedAt?: string;
|
|
23
24
|
}
|
|
25
|
+
export interface LogbookEntry {
|
|
26
|
+
id: string;
|
|
27
|
+
taskId: string;
|
|
28
|
+
date: string;
|
|
29
|
+
duration: number;
|
|
30
|
+
materials: {
|
|
31
|
+
name: string;
|
|
32
|
+
quantity: number;
|
|
33
|
+
}[];
|
|
34
|
+
comment?: string;
|
|
35
|
+
source: 'manual' | 'voice' | 'automatic';
|
|
36
|
+
createdBy: Author;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
}
|
|
40
|
+
export interface LogbookEntryDto {
|
|
41
|
+
date: string;
|
|
42
|
+
duration: number;
|
|
43
|
+
materials: {
|
|
44
|
+
name: string;
|
|
45
|
+
quantity: number;
|
|
46
|
+
}[];
|
|
47
|
+
comment?: string;
|
|
48
|
+
source?: 'manual' | 'voice' | 'automatic';
|
|
49
|
+
taskId: string;
|
|
50
|
+
createdBy?: Author;
|
|
51
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { APIBase } from './api-base';
|
|
2
|
+
import { Paginated } from './data.interface';
|
|
2
3
|
import { DataService } from './data.service';
|
|
3
4
|
import { HttpClient, TokenOption } from './http.service';
|
|
4
|
-
import { Task } from './task.interface';
|
|
5
|
+
import { LogbookEntry, LogbookEntryDto, Task } from './task.interface';
|
|
5
6
|
import { TrashService } from './trash.service';
|
|
6
7
|
interface BaseService extends DataService<Task>, TrashService<Task> {
|
|
7
8
|
}
|
|
@@ -10,5 +11,14 @@ declare class BaseService extends APIBase {
|
|
|
10
11
|
export declare class TaskService extends BaseService {
|
|
11
12
|
constructor(httpClient: HttpClient);
|
|
12
13
|
createTaskAttachedToAsset(dto: any, options?: TokenOption): Promise<Task>;
|
|
14
|
+
findByName(name: string, options?: TokenOption): Promise<Paginated<Task[]>>;
|
|
15
|
+
findByAsset(assetId: string, options?: TokenOption): Promise<Paginated<Task[]>>;
|
|
16
|
+
getLogbookEntries(taskId: string, limit?: number, offset?: number, options?: TokenOption): Promise<Paginated<LogbookEntry[]>>;
|
|
17
|
+
addLogbookEntry(taskId: string, entry: LogbookEntryDto, options?: TokenOption): Promise<LogbookEntry>;
|
|
18
|
+
updateLogbookEntry(taskId: string, entryId: string, entry: Partial<LogbookEntryDto>, options?: TokenOption): Promise<LogbookEntry>;
|
|
19
|
+
deleteLogbookEntry(taskId: string, entryId: string, options?: TokenOption): Promise<{
|
|
20
|
+
deleted: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
getUserLogbookEntries(limit?: number, offset?: number, options?: TokenOption): Promise<Paginated<LogbookEntry[]>>;
|
|
13
23
|
}
|
|
14
24
|
export {};
|
package/src/lib/task.service.js
CHANGED
|
@@ -19,5 +19,32 @@ class TaskService extends BaseService {
|
|
|
19
19
|
createTaskAttachedToAsset(dto, options = {}) {
|
|
20
20
|
return this.httpClient.post(this.basePath, dto, options);
|
|
21
21
|
}
|
|
22
|
+
findByName(name, options = {}) {
|
|
23
|
+
return this.httpClient.get(`${this.basePath}?name=${encodeURIComponent(name)}`, options);
|
|
24
|
+
}
|
|
25
|
+
findByAsset(assetId, options = {}) {
|
|
26
|
+
return this.httpClient.get(`${this.basePath}?assetRef=${assetId}`, options);
|
|
27
|
+
}
|
|
28
|
+
getLogbookEntries(taskId, limit = 50, offset = 0, options = {}) {
|
|
29
|
+
return this.httpClient.get(`${this.basePath}/${taskId}/logbook`, {
|
|
30
|
+
...options,
|
|
31
|
+
params: { limit: String(limit), offset: String(offset) },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
addLogbookEntry(taskId, entry, options = {}) {
|
|
35
|
+
return this.httpClient.post(`${this.basePath}/${taskId}/logbook`, entry, options);
|
|
36
|
+
}
|
|
37
|
+
updateLogbookEntry(taskId, entryId, entry, options = {}) {
|
|
38
|
+
return this.httpClient.patch(`${this.basePath}/${taskId}/logbook/${entryId}`, entry, options);
|
|
39
|
+
}
|
|
40
|
+
deleteLogbookEntry(taskId, entryId, options = {}) {
|
|
41
|
+
return this.httpClient.delete(`${this.basePath}/${taskId}/logbook/${entryId}`, options);
|
|
42
|
+
}
|
|
43
|
+
getUserLogbookEntries(limit = 50, offset = 0, options = {}) {
|
|
44
|
+
return this.httpClient.get(`${this.basePath}/logbook/mine`, {
|
|
45
|
+
...options,
|
|
46
|
+
params: { limit: String(limit), offset: String(offset) },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
22
49
|
}
|
|
23
50
|
exports.TaskService = TaskService;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DataService } from './data.service';
|
|
2
|
-
import { HttpClient, TokenOption } from './http.service';
|
|
3
|
-
import { Label } from './label.interface';
|
|
4
|
-
export declare class LabelService extends DataService<Label> {
|
|
5
|
-
constructor(httpClient: HttpClient);
|
|
6
|
-
addMany(dtos: Label[], options?: TokenOption): Promise<Label[]>;
|
|
7
|
-
getOneByName(name: string, options?: TokenOption): Promise<Label>;
|
|
8
|
-
count(options?: TokenOption): Promise<number>;
|
|
9
|
-
}
|
|
File without changes
|