@api-client/core 0.9.10 → 0.9.12
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/build/browser.d.ts +1 -1
- package/build/browser.js +1 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/src/events/BaseEvents.d.ts +5 -1
- package/build/src/models/TrashEntry.d.ts +19 -0
- package/build/src/runtime/store/FilesSdk.d.ts +20 -0
- package/build/src/runtime/store/FilesSdk.js +47 -1
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/RouteBuilder.d.ts +5 -2
- package/build/src/runtime/store/RouteBuilder.js +14 -4
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/SdkBase.d.ts +18 -0
- package/build/src/runtime/store/SdkBase.js +59 -0
- package/build/src/runtime/store/SdkBase.js.map +1 -1
- package/build/src/runtime/store/SpacesSdk.d.ts +26 -1
- package/build/src/runtime/store/SpacesSdk.js +67 -0
- package/build/src/runtime/store/SpacesSdk.js.map +1 -1
- package/build/src/runtime/store/TrashSdk.d.ts +12 -2
- package/build/src/runtime/store/TrashSdk.js +47 -16
- package/build/src/runtime/store/TrashSdk.js.map +1 -1
- package/build/src/runtime/store/interfaces/Trash.d.ts +17 -5
- package/package.json +1 -1
- package/src/events/BaseEvents.ts +5 -1
- package/src/models/TrashEntry.ts +20 -0
- package/src/runtime/store/FilesSdk.ts +61 -2
- package/src/runtime/store/RouteBuilder.ts +17 -4
- package/src/runtime/store/SdkBase.ts +65 -0
- package/src/runtime/store/SpacesSdk.ts +72 -1
- package/src/runtime/store/TrashSdk.ts +63 -18
- package/src/runtime/store/interfaces/Trash.ts +20 -5
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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
|
-
*
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
return this.genericDelete(url, key, 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 !==
|
|
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.
|
|
@@ -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
|
-
*
|
|
25
|
+
* Permanently deletes a file.
|
|
26
|
+
*
|
|
26
27
|
* @param key The key of the deleted object
|
|
27
28
|
*/
|
|
28
|
-
delete(key: string): Promise<
|
|
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
|
|
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.
|