@api-client/core 0.9.11 → 0.9.13

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.
Files changed (39) hide show
  1. package/build/browser.d.ts +2 -2
  2. package/build/browser.js +1 -0
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +2 -1
  5. package/build/index.js +1 -0
  6. package/build/index.js.map +1 -1
  7. package/build/src/models/TrashEntry.d.ts +19 -0
  8. package/build/src/runtime/store/ProjectExecutionsSdk.d.ts +55 -0
  9. package/build/src/runtime/store/ProjectExecutionsSdk.js +114 -0
  10. package/build/src/runtime/store/ProjectExecutionsSdk.js.map +1 -0
  11. package/build/src/runtime/store/RouteBuilder.d.ts +8 -2
  12. package/build/src/runtime/store/RouteBuilder.js +23 -4
  13. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  14. package/build/src/runtime/store/Sdk.d.ts +2 -0
  15. package/build/src/runtime/store/Sdk.js +2 -0
  16. package/build/src/runtime/store/Sdk.js.map +1 -1
  17. package/build/src/runtime/store/SdkBase.d.ts +20 -0
  18. package/build/src/runtime/store/SdkBase.js +114 -0
  19. package/build/src/runtime/store/SdkBase.js.map +1 -1
  20. package/build/src/runtime/store/TrashSdk.d.ts +12 -2
  21. package/build/src/runtime/store/TrashSdk.js +47 -16
  22. package/build/src/runtime/store/TrashSdk.js.map +1 -1
  23. package/build/src/runtime/store/interfaces/ApiClientStore.d.ts +2 -2
  24. package/build/src/runtime/store/interfaces/{ProjectRuns.d.ts → ProjectExecutions.d.ts} +1 -1
  25. package/build/src/runtime/store/interfaces/ProjectExecutions.js +2 -0
  26. package/build/src/runtime/store/interfaces/ProjectExecutions.js.map +1 -0
  27. package/build/src/runtime/store/interfaces/Trash.d.ts +17 -5
  28. package/package.json +1 -1
  29. package/src/models/TrashEntry.ts +20 -0
  30. package/src/runtime/store/ProjectExecutionsSdk.ts +122 -0
  31. package/src/runtime/store/RouteBuilder.ts +29 -4
  32. package/src/runtime/store/Sdk.ts +3 -0
  33. package/src/runtime/store/SdkBase.ts +123 -0
  34. package/src/runtime/store/TrashSdk.ts +63 -18
  35. package/src/runtime/store/interfaces/ApiClientStore.ts +2 -2
  36. package/src/runtime/store/interfaces/{ProjectRuns.ts → ProjectExecutions.ts} +1 -1
  37. package/src/runtime/store/interfaces/Trash.ts +20 -5
  38. package/build/src/runtime/store/interfaces/ProjectRuns.js +0 -2
  39. package/build/src/runtime/store/interfaces/ProjectRuns.js.map +0 -1
@@ -1,6 +1,19 @@
1
- import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
1
+ import {
2
+ SdkBase,
3
+ E_RESPONSE_STATUS,
4
+ E_RESPONSE_NO_VALUE,
5
+ E_INVALID_JSON,
6
+ E_RESPONSE_UNKNOWN,
7
+ ISdkRequestOptions
8
+ } from './SdkBase.js';
2
9
  import { RouteBuilder } from './RouteBuilder.js';
3
- import { ContextChangeRecord, ContextListResult, ContextSpaceListOptions } from '../../events/BaseEvents.js';
10
+ import {
11
+ ContextChangeRecord,
12
+ ContextDeleteRecord,
13
+ ContextListResult,
14
+ ContextSpaceListOptions,
15
+ IBulkOperationResult
16
+ } from '../../events/BaseEvents.js';
4
17
  import { SdkError } from './Errors.js';
5
18
  import { IFile } from '../../models/store/File.js';
6
19
  import { TrashEntry, TrashEntryCreate } from '../../models/TrashEntry.js';
@@ -80,24 +93,26 @@ export class TrashSdk extends SdkBase {
80
93
  }
81
94
 
82
95
  /**
83
- * Removes a trash entry permanently from the store.
96
+ * Permanently deletes a file.
97
+ *
84
98
  * @param key The key of the deleted object
85
99
  */
86
100
  async delete(key: string, request: ISdkRequestOptions = {}): Promise<void> {
87
- const token = request.token || this.sdk.token;
88
101
  const url = this.sdk.getUrl(RouteBuilder.trashItem(key));
89
- const result = await this.sdk.http.delete(url.toString(), { token });
90
- this.inspectCommonStatusCodes(result);
91
- const E_PREFIX = 'Unable to delete the trash entry. ';
92
- if (result.status !== 204) {
93
- this.logInvalidResponse(result);
94
- let e = this.createGenericSdkError(result.body)
95
- if (!e) {
96
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
97
- e.response = result.body;
98
- }
99
- throw e;
100
- }
102
+ return this.genericDelete(url, request);
103
+ }
104
+
105
+ /**
106
+ * Permanently deletes a number of files in a batch operation.
107
+ *
108
+ * @param keys The list of trash entry keys to delete.
109
+ * @param request Optional request options.
110
+ * @returns The list of delete records.
111
+ */
112
+ async batchDelete(keys: string[], request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextDeleteRecord>> {
113
+ const path = RouteBuilder.trashBatchDelete();
114
+ const url = this.sdk.getUrl(path);
115
+ return this.genericBatchDelete(url, keys, request);
101
116
  }
102
117
 
103
118
  /**
@@ -107,12 +122,12 @@ export class TrashSdk extends SdkBase {
107
122
  * @param key The key of the file to restore
108
123
  */
109
124
  async restore(key: string, request: ISdkRequestOptions = {}): Promise<ContextChangeRecord<IFile>> {
110
- const token = request.token || this.sdk.token;
111
125
  const url = this.sdk.getUrl(RouteBuilder.trashRestore(key));
126
+ const token = request.token || this.sdk.token;
112
127
  const result = await this.sdk.http.put(url.toString(), { token });
113
128
  this.inspectCommonStatusCodes(result);
114
129
  const E_PREFIX = 'Unable to restore from trash. ';
115
- if (result.status !== 204) {
130
+ if (result.status !== 200) {
116
131
  this.logInvalidResponse(result);
117
132
  let e = this.createGenericSdkError(result.body)
118
133
  if (!e) {
@@ -136,6 +151,36 @@ export class TrashSdk extends SdkBase {
136
151
  return data;
137
152
  }
138
153
 
154
+ async batchRestore(keys: string[], request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextChangeRecord<IFile>>> {
155
+ const url = this.sdk.getUrl(RouteBuilder.trashBatchRestore());
156
+ const token = request.token || this.sdk.token;
157
+ const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(keys) });
158
+ this.inspectCommonStatusCodes(result);
159
+ const E_PREFIX = 'Unable to restore from trash. ';
160
+ if (result.status !== 200) {
161
+ this.logInvalidResponse(result);
162
+ let e = this.createGenericSdkError(result.body)
163
+ if (!e) {
164
+ e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
165
+ e.response = result.body;
166
+ }
167
+ throw e;
168
+ }
169
+ if (!result.body) {
170
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
171
+ }
172
+ let data: IBulkOperationResult<ContextChangeRecord<IFile>>;
173
+ try {
174
+ data = JSON.parse(result.body);
175
+ } catch (e) {
176
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
177
+ }
178
+ if (!Array.isArray(data.items)) {
179
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
180
+ }
181
+ return data;
182
+ }
183
+
139
184
  /**
140
185
  * Empties the trash for the given space.
141
186
  * @param space The space key to remove trash for.
@@ -2,7 +2,7 @@ import { Certificates } from "./Certificates.js";
2
2
  import { Files } from "./Files.js";
3
3
  import { History } from "./History.js";
4
4
  import { Media } from "./Media.js";
5
- import { ProjectRuns } from "./ProjectRuns.js";
5
+ import { ProjectExecutions } from "./ProjectExecutions.js";
6
6
  import { Revisions } from "./Revisions.js";
7
7
  import { Spaces } from "./Spaces.js";
8
8
  import { Trash } from "./Trash.js";
@@ -38,5 +38,5 @@ export interface ApiClientStore {
38
38
 
39
39
  files: Files;
40
40
 
41
- projectRuns: ProjectRuns;
41
+ projectExecutions: ProjectExecutions;
42
42
  }
@@ -4,7 +4,7 @@ import { IProjectExecution } from "../../../models/ProjectExecution.js";
4
4
  /**
5
5
  * A store where project execution logs are kept.
6
6
  */
7
- export interface ProjectRuns {
7
+ export interface ProjectExecutions {
8
8
  /**
9
9
  * Adds an execution logs object to the store.
10
10
  *
@@ -1,5 +1,5 @@
1
1
  import { IFile } from "../../../models/store/File.js";
2
- import { ContextChangeRecord, ContextListResult, ContextSpaceListOptions } from "../../../events/BaseEvents.js";
2
+ import { ContextChangeRecord, ContextDeleteRecord, ContextListResult, ContextSpaceListOptions, IBulkOperationResult } from "../../../events/BaseEvents.js";
3
3
  import { TrashEntry, TrashEntryCreate } from "../../../models/TrashEntry.js";
4
4
 
5
5
  /**
@@ -22,18 +22,33 @@ export interface Trash {
22
22
  list(options: ContextSpaceListOptions): Promise<ContextListResult<TrashEntry>>;
23
23
 
24
24
  /**
25
- * Removes a trash entry permanently from the store.
25
+ * Permanently deletes a file.
26
+ *
26
27
  * @param key The key of the deleted object
27
28
  */
28
- delete(key: string): Promise<void>;
29
+ delete(key: string): Promise<ContextDeleteRecord>;
30
+
31
+ /**
32
+ * Permanently deletes a number of files in a batch operation.
33
+ *
34
+ * @param keys The list of trash entry keys to delete.
35
+ */
36
+ batchDelete(keys: string[]): Promise<IBulkOperationResult<ContextDeleteRecord>>;
37
+
29
38
  /**
30
- * Restores a file from the trash.
31
- * It deletes a trash entry and updates the `file` object.
39
+ * Restores trash entries permanently from the store.
32
40
  *
33
41
  * @param key The key of the file to restore
34
42
  */
35
43
  restore(key: string): Promise<ContextChangeRecord<IFile>>;
36
44
 
45
+ /**
46
+ * Restores multiple files in a batch operation.
47
+ *
48
+ * @param keys The lit of trash keys to restore.
49
+ */
50
+ batchRestore(keys: string[]): Promise<IBulkOperationResult<ContextChangeRecord<IFile>>>;
51
+
37
52
  /**
38
53
  * Empties the trash for the given space.
39
54
  * @param space The space key to remove trash for.
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ProjectRuns.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProjectRuns.js","sourceRoot":"","sources":["../../../../../src/runtime/store/interfaces/ProjectRuns.ts"],"names":[],"mappings":""}