@hahnpro/hpc-api 3.6.6 → 3.7.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.
@@ -1,3 +1,4 @@
1
+ import { Content } from './content.interface';
1
2
  export interface AssetType {
2
3
  id?: string;
3
4
  name: string;
@@ -44,13 +45,7 @@ export interface Asset {
44
45
  export type AssetRevision = Asset & {
45
46
  originalId: string;
46
47
  };
47
- export interface Attachment {
48
- id?: string;
49
- filename: string;
50
- metadata: {
51
- mimetype: string;
52
- };
53
- }
48
+ export type Attachment = Content;
54
49
  export interface Action {
55
50
  id?: string;
56
51
  name?: string;
@@ -1,6 +1,6 @@
1
1
  import FormData from 'form-data';
2
2
  import { APIBase } from './api-base';
3
- import { Asset, AssetRevision } from './asset.interface';
3
+ import { Asset, AssetRevision, Attachment } 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';
@@ -14,6 +14,7 @@ export declare class AssetService extends BaseService {
14
14
  deleteOne(id: string, force?: boolean): Promise<any>;
15
15
  addAttachment: (id: string, form: FormData) => Promise<Asset>;
16
16
  getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
17
+ getAttachments(assetId: string): Promise<Paginated<Attachment[]>>;
17
18
  getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
18
19
  rollback(assetId: string, revisionId: string): Promise<Asset>;
19
20
  deleteRevision(assetId: string, revisionId: string): Promise<any>;
@@ -29,6 +29,9 @@ class AssetService extends BaseService {
29
29
  getChildren(assetId, params = {}) {
30
30
  return this.getManyFiltered({ parent: assetId }, params);
31
31
  }
32
+ getAttachments(assetId) {
33
+ return this.httpClient.get(`${this.basePath}/${assetId}/attachments`);
34
+ }
32
35
  getRevisions(assetId) {
33
36
  return this.httpClient.get(`${this.basePath}/${assetId}/revisions`);
34
37
  }
@@ -1,5 +1,5 @@
1
1
  import FormData from 'form-data';
2
- import { Asset, AssetRevision } from '../asset.interface';
2
+ import { Asset, AssetRevision, Attachment } 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';
@@ -20,6 +20,7 @@ export declare class AssetMockService extends BaseService implements AssetServic
20
20
  getMany(params?: RequestParameter): Promise<Paginated<Asset[]>>;
21
21
  updateOne(assetId: string, dto: Asset): Promise<Asset>;
22
22
  addAttachment(id: string, form: FormData): Promise<Asset>;
23
+ getAttachments(assetId: string): Promise<Paginated<Attachment[]>>;
23
24
  getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
24
25
  getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
25
26
  rollback(assetId: string, revisionId: string): Promise<Asset>;
@@ -59,6 +59,11 @@ class AssetMockService extends BaseService {
59
59
  asset.attachments.push(content.id);
60
60
  return Promise.resolve(asset);
61
61
  }
62
+ async getAttachments(assetId) {
63
+ const contents = await this.api.contentManager.getMany();
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
+ return { docs, total: docs.length, limit: 0 };
66
+ }
62
67
  getChildren(assetId, params = {}) {
63
68
  return this.getManyFiltered({ parent: assetId }, params);
64
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/hpc-api",
3
- "version": "3.6.6",
3
+ "version": "3.7.0",
4
4
  "description": "Module for easy access to the HahnPRO API",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,17 +24,17 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "axios": "~1.2.2",
27
+ "axios": "~1.3.3",
28
28
  "eventsource": "^2.0.2",
29
29
  "form-data": "^4.0.0",
30
- "jose": "^4.11.2",
30
+ "jose": "^4.12.0",
31
31
  "jwt-decode": "^3.1.2",
32
32
  "p-queue": "^6.6.2",
33
- "ts-mixer": "^6.0.2",
33
+ "ts-mixer": "^6.0.3",
34
34
  "uuid": "^9.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/eventsource": "^1.1.10",
37
+ "@types/eventsource": "1.1.10",
38
38
  "axios-mock-adapter": "^1.21.2"
39
39
  },
40
40
  "engines": {