@hahnpro/hpc-api 4.0.2 → 4.1.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.
@@ -65,3 +65,12 @@ export interface Action {
65
65
  export type ActionRevision = Action & {
66
66
  originalId: string;
67
67
  };
68
+ export interface EventCause {
69
+ cause: string;
70
+ level: string;
71
+ }
72
+ export interface EventLevelOverride {
73
+ [assetId: string]: {
74
+ [eventCause: string]: string;
75
+ };
76
+ }
@@ -1,6 +1,6 @@
1
1
  import FormData from 'form-data';
2
2
  import { APIBase } from './api-base';
3
- import { Asset, AssetRevision, Attachment } from './asset.interface';
3
+ import { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from './asset.interface';
4
4
  import { Paginated, RequestParameter } from './data.interface';
5
5
  import { DataService } from './data.service';
6
6
  import { HttpClient } from './http.service';
@@ -15,6 +15,8 @@ export declare class AssetService extends BaseService {
15
15
  addAttachment: (id: string, form: FormData) => Promise<Asset>;
16
16
  getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
17
17
  getAttachments(assetId: string): Promise<Paginated<Attachment[]>>;
18
+ getEventLevelOverride(ids: string[], causes: string[]): Promise<EventLevelOverride>;
19
+ updateEventCausesAsset(id: string, dto: EventCause): Promise<Asset>;
18
20
  getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
19
21
  rollback(assetId: string, revisionId: string): Promise<Asset>;
20
22
  deleteRevision(assetId: string, revisionId: string): Promise<any>;
@@ -32,6 +32,14 @@ class AssetService extends BaseService {
32
32
  getAttachments(assetId) {
33
33
  return this.httpClient.get(`${this.basePath}/${assetId}/attachments`);
34
34
  }
35
+ getEventLevelOverride(ids, causes) {
36
+ return this.httpClient.get(`${this.basePath}/eventcauses`, {
37
+ params: { ids: ids.join(','), causes: causes.join(',') },
38
+ });
39
+ }
40
+ updateEventCausesAsset(id, dto) {
41
+ return this.httpClient.put(`${this.basePath}/${id}/eventcauses`, dto);
42
+ }
35
43
  getRevisions(assetId) {
36
44
  return this.httpClient.get(`${this.basePath}/${assetId}/revisions`);
37
45
  }
@@ -1,5 +1,5 @@
1
1
  import FormData from 'form-data';
2
- import { Asset, AssetRevision, Attachment } from '../asset.interface';
2
+ import { Asset, AssetRevision, Attachment, EventCause, EventLevelOverride } from '../asset.interface';
3
3
  import { AssetService } from '../asset.service';
4
4
  import { Paginated, RequestParameter } from '../data.interface';
5
5
  import { MockAPI } from './api.mock';
@@ -22,6 +22,8 @@ export declare class AssetMockService extends BaseService implements AssetServic
22
22
  addAttachment(id: string, form: FormData): Promise<Asset>;
23
23
  getAttachments(assetId: string): Promise<Paginated<Attachment[]>>;
24
24
  getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
25
+ getEventLevelOverride(ids: string[], causes: string[]): Promise<EventLevelOverride>;
26
+ updateEventCausesAsset(id: string, dto: EventCause): Promise<Asset>;
25
27
  getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
26
28
  rollback(assetId: string, revisionId: string): Promise<Asset>;
27
29
  deleteRevision(assetId: string, revisionId: string): Promise<any>;
@@ -67,6 +67,30 @@ class AssetMockService extends BaseService {
67
67
  getChildren(assetId, params = {}) {
68
68
  return this.getManyFiltered({ parent: assetId }, params);
69
69
  }
70
+ getEventLevelOverride(ids, causes) {
71
+ const eventCausesAssets = this.data.filter((v) => v.name.startsWith('hpc-event-causes-'));
72
+ return Promise.resolve(ids.reduce((acc, id) => ({
73
+ ...acc,
74
+ [id]: eventCausesAssets.find((v) => v.name.includes(id))?.data ?? {},
75
+ }), {}));
76
+ }
77
+ updateEventCausesAsset(id, dto) {
78
+ const asset = this.data.find((v) => v.id === id);
79
+ const eventCausesAsset = this.data.find((v) => v.name === 'hpc-event-causes-' + asset.id);
80
+ if (eventCausesAsset) {
81
+ eventCausesAsset.data[dto.cause] = dto.level;
82
+ return Promise.resolve(eventCausesAsset);
83
+ }
84
+ return this.addOne({
85
+ name: 'hpc-event-causes-' + asset.id,
86
+ type: undefined,
87
+ readPermissions: [],
88
+ readWritePermissions: [],
89
+ data: {
90
+ [dto.cause]: dto.level,
91
+ },
92
+ });
93
+ }
70
94
  getRevisions(assetId) {
71
95
  const revisions = this.revisions.filter((revision) => revision.originalId === assetId);
72
96
  const page = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "description": "Module for easy access to the HahnPRO API",
5
5
  "license": "MIT",
6
6
  "author": {