@inweb/client 25.4.1 → 25.4.3
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/dist/client.js +76 -63
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +59 -56
- package/dist/client.module.js.map +1 -1
- package/lib/Api/ClashTest.d.ts +2 -2
- package/lib/Api/Client.d.ts +14 -4
- package/lib/Api/Job.d.ts +1 -1
- package/lib/Api/Member.d.ts +2 -2
- package/lib/Api/Permission.d.ts +2 -2
- package/lib/Api/Project.d.ts +1 -1
- package/lib/Api/Role.d.ts +2 -2
- package/lib/Api/User.d.ts +2 -2
- package/lib/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/Api/ClashTest.ts +2 -2
- package/src/Api/Client.ts +71 -59
- package/src/Api/Fetch.ts +2 -2
- package/src/Api/HttpClient.ts +3 -3
- package/src/Api/Job.ts +1 -1
- package/src/Api/Member.ts +2 -2
- package/src/Api/Permission.ts +2 -2
- package/src/Api/Project.ts +1 -1
- package/src/Api/Role.ts +2 -2
- package/src/Api/User.ts +2 -2
- package/src/index.ts +1 -0
package/lib/Api/ClashTest.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { IShortUserDescription } from "./IUser";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class ClashTest {
|
|
7
7
|
private _data;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
basePath: string;
|
|
9
|
+
httpClient: IHttpClient;
|
|
10
10
|
/**
|
|
11
11
|
* @param data - Raw test data.
|
|
12
12
|
* @param basePath - Clash tests API base path for the owner file/assembly.
|
package/lib/Api/Client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
2
|
+
import { IHttpClient } from "./IHttpClient";
|
|
2
3
|
import { ClientEventMap } from "./ClientEvents";
|
|
3
4
|
import { Assembly } from "./Assembly";
|
|
4
5
|
import { File } from "./File";
|
|
@@ -12,7 +13,7 @@ import { User } from "./User";
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
14
15
|
private _serverUrl;
|
|
15
|
-
|
|
16
|
+
httpClient: IHttpClient;
|
|
16
17
|
private _user;
|
|
17
18
|
eventEmitter: EventEmitter2;
|
|
18
19
|
/**
|
|
@@ -92,13 +93,22 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
92
93
|
*/
|
|
93
94
|
signInWithEmail(email: string, password: string): Promise<User>;
|
|
94
95
|
/**
|
|
95
|
-
* Log in an existing user using API Key.
|
|
96
|
+
* Log in an existing user using access token (API Key).
|
|
96
97
|
*
|
|
97
98
|
* @async
|
|
98
|
-
* @param token - An access token for authentication request. See
|
|
99
|
-
* {@link User#token | User.token} for more details.
|
|
99
|
+
* @param token - An access token for authentication request. See {@link User.token} for more details.
|
|
100
100
|
*/
|
|
101
101
|
signInWithToken(token: string): Promise<User>;
|
|
102
|
+
/**
|
|
103
|
+
* Get the list of server indentity providers.
|
|
104
|
+
*
|
|
105
|
+
* To sign in with the provider in your web application:
|
|
106
|
+
*
|
|
107
|
+
* - Open the `provider.url` link using `window.open()`.
|
|
108
|
+
* - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
|
|
109
|
+
* message if the `error` search parameter is present, or log in with the `token` search parameter.
|
|
110
|
+
*/
|
|
111
|
+
getIdentityProviders(): Promise<any>;
|
|
102
112
|
private setCurrentUser;
|
|
103
113
|
private clearCurrentUser;
|
|
104
114
|
/**
|
package/lib/Api/Job.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { IHttpClient } from "./IHttpClient";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class Job {
|
|
7
7
|
private _data;
|
|
8
|
-
|
|
8
|
+
httpClient: IHttpClient;
|
|
9
9
|
/**
|
|
10
10
|
* @param data - An object that implements job data storage.
|
|
11
11
|
* @param httpClient - Http client.
|
package/lib/Api/Member.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { IShortUserDescription } from "./IUser";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class Member {
|
|
7
7
|
private _data;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
projectId: string;
|
|
9
|
+
httpClient: IHttpClient;
|
|
10
10
|
/**
|
|
11
11
|
* @param data - An object that implements member data storage.
|
|
12
12
|
* @param projectId - Owner project ID.
|
package/lib/Api/Permission.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { IHttpClient } from "./IHttpClient";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class Permission {
|
|
7
7
|
private _data;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
fileId: string;
|
|
9
|
+
httpClient: IHttpClient;
|
|
10
10
|
/**
|
|
11
11
|
* @param data - An object that implements permission data storage.
|
|
12
12
|
* @param fileId - Owner file ID.
|
package/lib/Api/Project.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Member } from "./Member";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class Project {
|
|
9
9
|
private _data;
|
|
10
|
-
|
|
10
|
+
httpClient: IHttpClient;
|
|
11
11
|
/**
|
|
12
12
|
* @param data - An object that implements project data storage.
|
|
13
13
|
* @param httpClient - Http client.
|
package/lib/Api/Role.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { IHttpClient } from "./IHttpClient";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class Role {
|
|
6
6
|
private _data;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
projectId: string;
|
|
8
|
+
httpClient: IHttpClient;
|
|
9
9
|
/**
|
|
10
10
|
* @param data - An object that implements role data storage.
|
|
11
11
|
* @param projectId - Owner project ID.
|
package/lib/Api/User.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface UserParams {
|
|
|
34
34
|
*/
|
|
35
35
|
export declare class User {
|
|
36
36
|
private _data;
|
|
37
|
-
|
|
37
|
+
httpClient: IHttpClient;
|
|
38
38
|
/**
|
|
39
39
|
* @param data - An object that implements user data storage.
|
|
40
40
|
* @param httpClient - Http client.
|
|
@@ -132,7 +132,7 @@ export declare class User {
|
|
|
132
132
|
*/
|
|
133
133
|
get projectsLimit(): number;
|
|
134
134
|
/**
|
|
135
|
-
* The user's API key.
|
|
135
|
+
* The user's access token (API key). Use {@link Client.signInWithToken()} to log in using token.
|
|
136
136
|
*
|
|
137
137
|
* @readonly
|
|
138
138
|
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { Client } from "./Api/Client";
|
|
|
3
3
|
export { ClashTest } from "./Api/ClashTest";
|
|
4
4
|
export * from "./Api/ClientEvents";
|
|
5
5
|
export { File } from "./Api/File";
|
|
6
|
+
export { FetchError, statusText } from "./Api/FetchError";
|
|
6
7
|
export { Job } from "./Api/Job";
|
|
7
8
|
export { Member } from "./Api/Member";
|
|
8
9
|
export { Model } from "./Api/Model";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/client",
|
|
3
|
-
"version": "25.4.
|
|
3
|
+
"version": "25.4.3",
|
|
4
4
|
"description": "JavaScript REST API client for the Open Cloud Server",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"ts-docs": "typedoc"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inweb/eventemitter2": "~25.4.
|
|
29
|
+
"@inweb/eventemitter2": "~25.4.3"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/Api/ClashTest.ts
CHANGED
|
@@ -30,8 +30,8 @@ import { waitFor, userFullName, userInitials } from "./Utils";
|
|
|
30
30
|
*/
|
|
31
31
|
export class ClashTest {
|
|
32
32
|
private _data: any;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
public basePath: string;
|
|
34
|
+
public httpClient: IHttpClient;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* @param data - Raw test data.
|
package/src/Api/Client.ts
CHANGED
|
@@ -40,7 +40,7 @@ import { parseArgs } from "./Utils";
|
|
|
40
40
|
*/
|
|
41
41
|
export class Client extends EventEmitter2<ClientEventMap> {
|
|
42
42
|
private _serverUrl = "";
|
|
43
|
-
|
|
43
|
+
public httpClient: IHttpClient = new HttpClient("");
|
|
44
44
|
private _user: User | null = null;
|
|
45
45
|
public eventEmitter: EventEmitter2 = this;
|
|
46
46
|
|
|
@@ -114,7 +114,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
114
114
|
*/
|
|
115
115
|
configure(params: { serverUrl?: string }): this {
|
|
116
116
|
this._serverUrl = (params.serverUrl || "").replace(/\/+$/, "");
|
|
117
|
-
this.
|
|
117
|
+
this.httpClient = new HttpClient(this.serverUrl);
|
|
118
118
|
this._user = null;
|
|
119
119
|
return this;
|
|
120
120
|
}
|
|
@@ -133,7 +133,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
133
133
|
* @async
|
|
134
134
|
*/
|
|
135
135
|
version(): Promise<any> {
|
|
136
|
-
return this.
|
|
136
|
+
return this.httpClient
|
|
137
137
|
.get("/version")
|
|
138
138
|
.then((response) => response.json())
|
|
139
139
|
.then((data) => ({
|
|
@@ -154,7 +154,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
154
154
|
* `username` from email.
|
|
155
155
|
*/
|
|
156
156
|
registerUser(email: string, password: string, userName?: string): Promise<any> {
|
|
157
|
-
return this.
|
|
157
|
+
return this.httpClient
|
|
158
158
|
.post("/register", {
|
|
159
159
|
email,
|
|
160
160
|
password,
|
|
@@ -172,7 +172,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
172
172
|
* @param password - User password.
|
|
173
173
|
*/
|
|
174
174
|
resendConfirmationEmail(email: string, password: string): Promise<any> {
|
|
175
|
-
return this.
|
|
175
|
+
return this.httpClient
|
|
176
176
|
.post("/register/email-confirmation", { email, password })
|
|
177
177
|
.then((response) => response.json());
|
|
178
178
|
}
|
|
@@ -184,7 +184,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
184
184
|
* @param emailConfirmationId - Confirmation code from the Confirmation Email.
|
|
185
185
|
*/
|
|
186
186
|
confirmUserEmail(emailConfirmationId: string): Promise<any> {
|
|
187
|
-
return this.
|
|
187
|
+
return this.httpClient
|
|
188
188
|
.get(`/register/email-confirmation/${emailConfirmationId}`)
|
|
189
189
|
.then((response) => response.json());
|
|
190
190
|
}
|
|
@@ -198,39 +198,51 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
198
198
|
*/
|
|
199
199
|
async signInWithEmail(email: string, password: string): Promise<User> {
|
|
200
200
|
const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
|
|
201
|
-
this.
|
|
202
|
-
const response = await this.
|
|
201
|
+
this.httpClient.headers = { Authorization: "Basic " + credentials };
|
|
202
|
+
const response = await this.httpClient.get("/token");
|
|
203
203
|
const data = await response.json();
|
|
204
204
|
return this.setCurrentUser(data);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
* Log in an existing user using API Key.
|
|
208
|
+
* Log in an existing user using access token (API Key).
|
|
209
209
|
*
|
|
210
210
|
* @async
|
|
211
|
-
* @param token - An access token for authentication request. See
|
|
212
|
-
* {@link User#token | User.token} for more details.
|
|
211
|
+
* @param token - An access token for authentication request. See {@link User.token} for more details.
|
|
213
212
|
*/
|
|
214
213
|
async signInWithToken(token: string): Promise<User> {
|
|
215
|
-
this.
|
|
216
|
-
const response = await this.
|
|
214
|
+
this.httpClient.headers = { Authorization: token };
|
|
215
|
+
const response = await this.httpClient.get("/user");
|
|
217
216
|
const data = await response.json();
|
|
218
217
|
return this.setCurrentUser(data);
|
|
219
218
|
}
|
|
220
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Get the list of server indentity providers.
|
|
222
|
+
*
|
|
223
|
+
* To sign in with the provider in your web application:
|
|
224
|
+
*
|
|
225
|
+
* - Open the `provider.url` link using `window.open()`.
|
|
226
|
+
* - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
|
|
227
|
+
* message if the `error` search parameter is present, or log in with the `token` search parameter.
|
|
228
|
+
*/
|
|
229
|
+
getIdentityProviders(): Promise<any> {
|
|
230
|
+
return this.httpClient.get("/identity").then((response) => response.json());
|
|
231
|
+
}
|
|
232
|
+
|
|
221
233
|
// Save the current logged in user information for internal use.
|
|
222
234
|
|
|
223
235
|
private setCurrentUser(data: any): User {
|
|
224
|
-
this._user = new User(data, this.
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
236
|
+
this._user = new User(data, this.httpClient);
|
|
237
|
+
this.httpClient.headers = { Authorization: data.tokenInfo.token };
|
|
238
|
+
this.httpClient.signInUserId = this._user.id;
|
|
227
239
|
return this._user;
|
|
228
240
|
}
|
|
229
241
|
|
|
230
242
|
private clearCurrentUser(): void {
|
|
231
243
|
this._user = null;
|
|
232
|
-
this.
|
|
233
|
-
this.
|
|
244
|
+
this.httpClient.headers = {};
|
|
245
|
+
this.httpClient.signInUserId = "";
|
|
234
246
|
}
|
|
235
247
|
|
|
236
248
|
/**
|
|
@@ -238,7 +250,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
238
250
|
* in or the logged in user has deleted himself.
|
|
239
251
|
*/
|
|
240
252
|
getCurrentUser(): User | null {
|
|
241
|
-
if (this._user && !this.
|
|
253
|
+
if (this._user && !this.httpClient.signInUserId) this._user = null;
|
|
242
254
|
return this._user;
|
|
243
255
|
}
|
|
244
256
|
|
|
@@ -249,11 +261,11 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
249
261
|
* @async
|
|
250
262
|
*/
|
|
251
263
|
getUsers(): Promise<User[]> {
|
|
252
|
-
return this.
|
|
264
|
+
return this.httpClient
|
|
253
265
|
.get("/users")
|
|
254
266
|
.then((response) => response.json())
|
|
255
267
|
.then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
|
|
256
|
-
.then((array) => array.map((data) => new User(data, this.
|
|
268
|
+
.then((array) => array.map((data) => new User(data, this.httpClient)));
|
|
257
269
|
}
|
|
258
270
|
|
|
259
271
|
/**
|
|
@@ -265,18 +277,18 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
265
277
|
* @param userId - User ID.
|
|
266
278
|
*/
|
|
267
279
|
getUser(userId: string): Promise<User> {
|
|
268
|
-
if (userId === this.
|
|
269
|
-
return this.
|
|
280
|
+
if (userId === this.httpClient.signInUserId) {
|
|
281
|
+
return this.httpClient
|
|
270
282
|
.get("/user")
|
|
271
283
|
.then((response) => response.json())
|
|
272
284
|
.then((data) => ({ id: userId, ...data }))
|
|
273
|
-
.then((data) => new User(data, this.
|
|
285
|
+
.then((data) => new User(data, this.httpClient));
|
|
274
286
|
} else {
|
|
275
|
-
return this.
|
|
287
|
+
return this.httpClient
|
|
276
288
|
.get(`/users/${userId}`)
|
|
277
289
|
.then((response) => response.json())
|
|
278
290
|
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
279
|
-
.then((data) => new User(data, this.
|
|
291
|
+
.then((data) => new User(data, this.httpClient));
|
|
280
292
|
}
|
|
281
293
|
}
|
|
282
294
|
|
|
@@ -312,7 +324,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
312
324
|
} = {}
|
|
313
325
|
): Promise<User> {
|
|
314
326
|
const { isAdmin, userName, ...rest } = params;
|
|
315
|
-
return this.
|
|
327
|
+
return this.httpClient
|
|
316
328
|
.post("/users", {
|
|
317
329
|
isAdmin,
|
|
318
330
|
userBrief: {
|
|
@@ -324,7 +336,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
324
336
|
})
|
|
325
337
|
.then((response) => response.json())
|
|
326
338
|
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
327
|
-
.then((data) => new User(data, this.
|
|
339
|
+
.then((data) => new User(data, this.httpClient));
|
|
328
340
|
}
|
|
329
341
|
|
|
330
342
|
/**
|
|
@@ -341,11 +353,11 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
341
353
|
* @returns Returns the raw data of a deleted user.
|
|
342
354
|
*/
|
|
343
355
|
deleteUser(userId: string): Promise<any> {
|
|
344
|
-
return this.
|
|
356
|
+
return this.httpClient
|
|
345
357
|
.delete(`/users/${userId}`)
|
|
346
358
|
.then((response) => response.json())
|
|
347
359
|
.then((data) => {
|
|
348
|
-
if (userId === this.
|
|
360
|
+
if (userId === this.httpClient.signInUserId) {
|
|
349
361
|
this.clearCurrentUser();
|
|
350
362
|
}
|
|
351
363
|
return data;
|
|
@@ -408,13 +420,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
408
420
|
let queryString = searchParams.toString();
|
|
409
421
|
if (queryString) queryString = "?" + queryString;
|
|
410
422
|
|
|
411
|
-
return this.
|
|
423
|
+
return this.httpClient
|
|
412
424
|
.get(`/files${queryString}`)
|
|
413
425
|
.then((response) => response.json())
|
|
414
426
|
.then((files) => {
|
|
415
427
|
return {
|
|
416
428
|
...files,
|
|
417
|
-
result: files.result.map((data) => new File(data, this.
|
|
429
|
+
result: files.result.map((data) => new File(data, this.httpClient)),
|
|
418
430
|
};
|
|
419
431
|
});
|
|
420
432
|
}
|
|
@@ -426,10 +438,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
426
438
|
* @param fileId - File ID.
|
|
427
439
|
*/
|
|
428
440
|
getFile(fileId: string): Promise<File> {
|
|
429
|
-
return this.
|
|
441
|
+
return this.httpClient
|
|
430
442
|
.get(`/files/${fileId}`)
|
|
431
443
|
.then((response) => response.json())
|
|
432
|
-
.then((data) => new File(data, this.
|
|
444
|
+
.then((data) => new File(data, this.httpClient));
|
|
433
445
|
}
|
|
434
446
|
|
|
435
447
|
/**
|
|
@@ -478,13 +490,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
478
490
|
waitForDone: false,
|
|
479
491
|
}
|
|
480
492
|
): Promise<File> {
|
|
481
|
-
const result = await this.
|
|
493
|
+
const result = await this.httpClient
|
|
482
494
|
.uploadFile("/files", file, (progress) => {
|
|
483
495
|
this.emitEvent({ type: "uploadprogress", data: progress, file });
|
|
484
496
|
params.onProgress?.(progress, file);
|
|
485
497
|
})
|
|
486
498
|
.then((xhr: XMLHttpRequest) => JSON.parse(xhr.responseText))
|
|
487
|
-
.then((data) => new File(data, this.
|
|
499
|
+
.then((data) => new File(data, this.httpClient));
|
|
488
500
|
|
|
489
501
|
const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
|
|
490
502
|
|
|
@@ -506,7 +518,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
506
518
|
* @returns Returns the raw data of a deleted file.
|
|
507
519
|
*/
|
|
508
520
|
deleteFile(fileId: string): Promise<any> {
|
|
509
|
-
return this.
|
|
521
|
+
return this.httpClient.delete(`/files/${fileId}`).then((response) => response.json());
|
|
510
522
|
}
|
|
511
523
|
|
|
512
524
|
/**
|
|
@@ -520,7 +532,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
520
532
|
* and abort it if desired.
|
|
521
533
|
*/
|
|
522
534
|
downloadFile(fileId: string, onProgress?: (progress: number) => void, signal?: AbortSignal): Promise<ArrayBuffer> {
|
|
523
|
-
return this.
|
|
535
|
+
return this.httpClient
|
|
524
536
|
.downloadFile(`/files/${fileId}/downloads`, onProgress, signal)
|
|
525
537
|
.then((response) => response.arrayBuffer());
|
|
526
538
|
}
|
|
@@ -569,12 +581,12 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
569
581
|
let queryString = searchParams.toString();
|
|
570
582
|
if (queryString) queryString = "?" + queryString;
|
|
571
583
|
|
|
572
|
-
return this.
|
|
584
|
+
return this.httpClient
|
|
573
585
|
.get(`/jobs${queryString}`)
|
|
574
586
|
.then((response) => response.json())
|
|
575
587
|
.then((jobs) => ({
|
|
576
588
|
...jobs,
|
|
577
|
-
result: jobs.result.map((data) => new Job(data, this.
|
|
589
|
+
result: jobs.result.map((data) => new Job(data, this.httpClient)),
|
|
578
590
|
}));
|
|
579
591
|
}
|
|
580
592
|
|
|
@@ -585,10 +597,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
585
597
|
* @param jobId - Job ID.
|
|
586
598
|
*/
|
|
587
599
|
getJob(jobId: string): Promise<Job> {
|
|
588
|
-
return this.
|
|
600
|
+
return this.httpClient
|
|
589
601
|
.get(`/jobs/${jobId}`)
|
|
590
602
|
.then((response) => response.json())
|
|
591
|
-
.then((data) => new Job(data, this.
|
|
603
|
+
.then((data) => new Job(data, this.httpClient));
|
|
592
604
|
}
|
|
593
605
|
|
|
594
606
|
/**
|
|
@@ -610,14 +622,14 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
610
622
|
* for the File Converter tool in form "--arg=value".
|
|
611
623
|
*/
|
|
612
624
|
createJob(fileId: string, outputFormat: string, parameters?: string | object): Promise<Job> {
|
|
613
|
-
return this.
|
|
625
|
+
return this.httpClient
|
|
614
626
|
.post("/jobs", {
|
|
615
627
|
fileId,
|
|
616
628
|
outputFormat,
|
|
617
629
|
parameters: parseArgs(parameters),
|
|
618
630
|
})
|
|
619
631
|
.then((response) => response.json())
|
|
620
|
-
.then((data) => new Job(data, this.
|
|
632
|
+
.then((data) => new Job(data, this.httpClient));
|
|
621
633
|
}
|
|
622
634
|
|
|
623
635
|
/**
|
|
@@ -629,7 +641,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
629
641
|
* @returns Returns the raw data of a deleted job.
|
|
630
642
|
*/
|
|
631
643
|
deleteJob(jobId: string): Promise<any> {
|
|
632
|
-
return this.
|
|
644
|
+
return this.httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
|
|
633
645
|
}
|
|
634
646
|
|
|
635
647
|
/**
|
|
@@ -680,13 +692,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
680
692
|
let queryString = searchParams.toString();
|
|
681
693
|
if (queryString) queryString = "?" + queryString;
|
|
682
694
|
|
|
683
|
-
return this.
|
|
695
|
+
return this.httpClient
|
|
684
696
|
.get(`/assemblies${queryString}`)
|
|
685
697
|
.then((response) => response.json())
|
|
686
698
|
.then((assemblies) => {
|
|
687
699
|
return {
|
|
688
700
|
...assemblies,
|
|
689
|
-
result: assemblies.result.map((data) => new Assembly(data, this.
|
|
701
|
+
result: assemblies.result.map((data) => new Assembly(data, this.httpClient)),
|
|
690
702
|
};
|
|
691
703
|
});
|
|
692
704
|
}
|
|
@@ -698,10 +710,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
698
710
|
* @param assemblyId - Assembly ID.
|
|
699
711
|
*/
|
|
700
712
|
getAssembly(assemblyId: string): Promise<Assembly> {
|
|
701
|
-
return this.
|
|
713
|
+
return this.httpClient
|
|
702
714
|
.get(`/assemblies/${assemblyId}`)
|
|
703
715
|
.then((response) => response.json())
|
|
704
|
-
.then((data) => new Assembly(data, this.
|
|
716
|
+
.then((data) => new Assembly(data, this.httpClient));
|
|
705
717
|
}
|
|
706
718
|
|
|
707
719
|
/**
|
|
@@ -724,10 +736,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
724
736
|
}
|
|
725
737
|
): Promise<Assembly> {
|
|
726
738
|
const { waitForDone } = params ?? {};
|
|
727
|
-
return this.
|
|
739
|
+
return this.httpClient
|
|
728
740
|
.post("/assemblies", { name, files })
|
|
729
741
|
.then((response) => response.json())
|
|
730
|
-
.then((data) => new Assembly(data, this.
|
|
742
|
+
.then((data) => new Assembly(data, this.httpClient))
|
|
731
743
|
.then((result) => (waitForDone ? result.waitForDone(params) : result));
|
|
732
744
|
}
|
|
733
745
|
|
|
@@ -739,7 +751,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
739
751
|
* @returns Returns the raw data of a deleted assembly.
|
|
740
752
|
*/
|
|
741
753
|
deleteAssembly(assemblyId: string): Promise<any> {
|
|
742
|
-
return this.
|
|
754
|
+
return this.httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
|
|
743
755
|
}
|
|
744
756
|
|
|
745
757
|
/**
|
|
@@ -785,7 +797,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
785
797
|
|
|
786
798
|
let queryString = searchParams.toString();
|
|
787
799
|
if (queryString) queryString = "?" + queryString;
|
|
788
|
-
return this.
|
|
800
|
+
return this.httpClient
|
|
789
801
|
.get(`/projects${queryString}`)
|
|
790
802
|
.then((response) => response.json())
|
|
791
803
|
.then((projects) => {
|
|
@@ -811,7 +823,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
811
823
|
.then((projects) => {
|
|
812
824
|
return {
|
|
813
825
|
...projects,
|
|
814
|
-
result: projects.result.map((data) => new Project(data, this.
|
|
826
|
+
result: projects.result.map((data) => new Project(data, this.httpClient)),
|
|
815
827
|
};
|
|
816
828
|
});
|
|
817
829
|
}
|
|
@@ -823,10 +835,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
823
835
|
* @param projectId - Project ID.
|
|
824
836
|
*/
|
|
825
837
|
getProject(projectId: string): Promise<Project> {
|
|
826
|
-
return this.
|
|
838
|
+
return this.httpClient
|
|
827
839
|
.get(`/projects/${projectId}`)
|
|
828
840
|
.then((response) => response.json())
|
|
829
|
-
.then((data) => new Project(data, this.
|
|
841
|
+
.then((data) => new Project(data, this.httpClient));
|
|
830
842
|
}
|
|
831
843
|
|
|
832
844
|
/**
|
|
@@ -848,7 +860,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
848
860
|
endDate?: Date | string,
|
|
849
861
|
avatarUrl?: string
|
|
850
862
|
): Promise<Project> {
|
|
851
|
-
return this.
|
|
863
|
+
return this.httpClient
|
|
852
864
|
.post("/projects", {
|
|
853
865
|
name,
|
|
854
866
|
description,
|
|
@@ -857,7 +869,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
857
869
|
avatarUrl,
|
|
858
870
|
})
|
|
859
871
|
.then((response) => response.json())
|
|
860
|
-
.then((data) => new Project(data, this.
|
|
872
|
+
.then((data) => new Project(data, this.httpClient));
|
|
861
873
|
}
|
|
862
874
|
|
|
863
875
|
/**
|
|
@@ -868,7 +880,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
868
880
|
* @returns Returns the raw data of a deleted project.
|
|
869
881
|
*/
|
|
870
882
|
deleteProject(projectId: string): Promise<any> {
|
|
871
|
-
return this.
|
|
883
|
+
return this.httpClient
|
|
872
884
|
.delete(`/projects/${projectId}`)
|
|
873
885
|
.then((response) => response.text())
|
|
874
886
|
.then((text) => {
|
package/src/Api/Fetch.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { FetchError,
|
|
24
|
+
import { FetchError, error400 } from "./FetchError";
|
|
25
25
|
|
|
26
26
|
function handleFetchError(response: Response): Promise<Response> {
|
|
27
27
|
if (!response.ok) {
|
|
@@ -39,7 +39,7 @@ function handleFetchError(response: Response): Promise<Response> {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
default:
|
|
42
|
-
return Promise.reject(new FetchError(response.status
|
|
42
|
+
return Promise.reject(new FetchError(response.status));
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
return Promise.resolve(response);
|
package/src/Api/HttpClient.ts
CHANGED
|
@@ -26,9 +26,9 @@ import { $fetch } from "./Fetch";
|
|
|
26
26
|
import { $xmlhttp } from "./XMLHttp";
|
|
27
27
|
|
|
28
28
|
export class HttpClient implements IHttpClient {
|
|
29
|
-
serverUrl: string;
|
|
30
|
-
headers: HeadersInit = {};
|
|
31
|
-
signInUserId = "";
|
|
29
|
+
public serverUrl: string;
|
|
30
|
+
public headers: HeadersInit = {};
|
|
31
|
+
public signInUserId = "";
|
|
32
32
|
|
|
33
33
|
constructor(serverUrl: string) {
|
|
34
34
|
this.serverUrl = serverUrl;
|
package/src/Api/Job.ts
CHANGED
package/src/Api/Member.ts
CHANGED
|
@@ -30,8 +30,8 @@ import { userFullName, userInitials } from "./Utils";
|
|
|
30
30
|
*/
|
|
31
31
|
export class Member {
|
|
32
32
|
private _data: any;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
public projectId: string;
|
|
34
|
+
public httpClient: IHttpClient;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* @param data - An object that implements member data storage.
|
package/src/Api/Permission.ts
CHANGED
|
@@ -29,8 +29,8 @@ import { IHttpClient } from "./IHttpClient";
|
|
|
29
29
|
*/
|
|
30
30
|
export class Permission {
|
|
31
31
|
private _data: any;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
public fileId: string;
|
|
33
|
+
public httpClient: IHttpClient;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* @param data - An object that implements permission data storage.
|
package/src/Api/Project.ts
CHANGED
package/src/Api/Role.ts
CHANGED
|
@@ -28,8 +28,8 @@ import { IHttpClient } from "./IHttpClient";
|
|
|
28
28
|
*/
|
|
29
29
|
export class Role {
|
|
30
30
|
private _data: any;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
public projectId: string;
|
|
32
|
+
public httpClient: IHttpClient;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @param data - An object that implements role data storage.
|