@inweb/client 25.4.2 → 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 +62 -60
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +57 -57
- package/dist/client.module.js.map +1 -1
- package/lib/Api/ClashTest.d.ts +2 -2
- package/lib/Api/Client.d.ts +2 -1
- 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 +1 -1
- package/lib/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/Api/ClashTest.ts +2 -2
- package/src/Api/Client.ts +57 -57
- 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 +1 -1
- 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
|
/**
|
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
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,8 +198,8 @@ 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
|
}
|
|
@@ -211,8 +211,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
211
211
|
* @param token - An access token for authentication request. See {@link User.token} for more details.
|
|
212
212
|
*/
|
|
213
213
|
async signInWithToken(token: string): Promise<User> {
|
|
214
|
-
this.
|
|
215
|
-
const response = await this.
|
|
214
|
+
this.httpClient.headers = { Authorization: token };
|
|
215
|
+
const response = await this.httpClient.get("/user");
|
|
216
216
|
const data = await response.json();
|
|
217
217
|
return this.setCurrentUser(data);
|
|
218
218
|
}
|
|
@@ -227,22 +227,22 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
227
227
|
* message if the `error` search parameter is present, or log in with the `token` search parameter.
|
|
228
228
|
*/
|
|
229
229
|
getIdentityProviders(): Promise<any> {
|
|
230
|
-
return this.
|
|
230
|
+
return this.httpClient.get("/identity").then((response) => response.json());
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
// Save the current logged in user information for internal use.
|
|
234
234
|
|
|
235
235
|
private setCurrentUser(data: any): User {
|
|
236
|
-
this._user = new User(data, this.
|
|
237
|
-
this.
|
|
238
|
-
this.
|
|
236
|
+
this._user = new User(data, this.httpClient);
|
|
237
|
+
this.httpClient.headers = { Authorization: data.tokenInfo.token };
|
|
238
|
+
this.httpClient.signInUserId = this._user.id;
|
|
239
239
|
return this._user;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
private clearCurrentUser(): void {
|
|
243
243
|
this._user = null;
|
|
244
|
-
this.
|
|
245
|
-
this.
|
|
244
|
+
this.httpClient.headers = {};
|
|
245
|
+
this.httpClient.signInUserId = "";
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
/**
|
|
@@ -250,7 +250,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
250
250
|
* in or the logged in user has deleted himself.
|
|
251
251
|
*/
|
|
252
252
|
getCurrentUser(): User | null {
|
|
253
|
-
if (this._user && !this.
|
|
253
|
+
if (this._user && !this.httpClient.signInUserId) this._user = null;
|
|
254
254
|
return this._user;
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -261,11 +261,11 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
261
261
|
* @async
|
|
262
262
|
*/
|
|
263
263
|
getUsers(): Promise<User[]> {
|
|
264
|
-
return this.
|
|
264
|
+
return this.httpClient
|
|
265
265
|
.get("/users")
|
|
266
266
|
.then((response) => response.json())
|
|
267
267
|
.then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
|
|
268
|
-
.then((array) => array.map((data) => new User(data, this.
|
|
268
|
+
.then((array) => array.map((data) => new User(data, this.httpClient)));
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
/**
|
|
@@ -277,18 +277,18 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
277
277
|
* @param userId - User ID.
|
|
278
278
|
*/
|
|
279
279
|
getUser(userId: string): Promise<User> {
|
|
280
|
-
if (userId === this.
|
|
281
|
-
return this.
|
|
280
|
+
if (userId === this.httpClient.signInUserId) {
|
|
281
|
+
return this.httpClient
|
|
282
282
|
.get("/user")
|
|
283
283
|
.then((response) => response.json())
|
|
284
284
|
.then((data) => ({ id: userId, ...data }))
|
|
285
|
-
.then((data) => new User(data, this.
|
|
285
|
+
.then((data) => new User(data, this.httpClient));
|
|
286
286
|
} else {
|
|
287
|
-
return this.
|
|
287
|
+
return this.httpClient
|
|
288
288
|
.get(`/users/${userId}`)
|
|
289
289
|
.then((response) => response.json())
|
|
290
290
|
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
291
|
-
.then((data) => new User(data, this.
|
|
291
|
+
.then((data) => new User(data, this.httpClient));
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
@@ -324,7 +324,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
324
324
|
} = {}
|
|
325
325
|
): Promise<User> {
|
|
326
326
|
const { isAdmin, userName, ...rest } = params;
|
|
327
|
-
return this.
|
|
327
|
+
return this.httpClient
|
|
328
328
|
.post("/users", {
|
|
329
329
|
isAdmin,
|
|
330
330
|
userBrief: {
|
|
@@ -336,7 +336,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
336
336
|
})
|
|
337
337
|
.then((response) => response.json())
|
|
338
338
|
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
339
|
-
.then((data) => new User(data, this.
|
|
339
|
+
.then((data) => new User(data, this.httpClient));
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
/**
|
|
@@ -353,11 +353,11 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
353
353
|
* @returns Returns the raw data of a deleted user.
|
|
354
354
|
*/
|
|
355
355
|
deleteUser(userId: string): Promise<any> {
|
|
356
|
-
return this.
|
|
356
|
+
return this.httpClient
|
|
357
357
|
.delete(`/users/${userId}`)
|
|
358
358
|
.then((response) => response.json())
|
|
359
359
|
.then((data) => {
|
|
360
|
-
if (userId === this.
|
|
360
|
+
if (userId === this.httpClient.signInUserId) {
|
|
361
361
|
this.clearCurrentUser();
|
|
362
362
|
}
|
|
363
363
|
return data;
|
|
@@ -420,13 +420,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
420
420
|
let queryString = searchParams.toString();
|
|
421
421
|
if (queryString) queryString = "?" + queryString;
|
|
422
422
|
|
|
423
|
-
return this.
|
|
423
|
+
return this.httpClient
|
|
424
424
|
.get(`/files${queryString}`)
|
|
425
425
|
.then((response) => response.json())
|
|
426
426
|
.then((files) => {
|
|
427
427
|
return {
|
|
428
428
|
...files,
|
|
429
|
-
result: files.result.map((data) => new File(data, this.
|
|
429
|
+
result: files.result.map((data) => new File(data, this.httpClient)),
|
|
430
430
|
};
|
|
431
431
|
});
|
|
432
432
|
}
|
|
@@ -438,10 +438,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
438
438
|
* @param fileId - File ID.
|
|
439
439
|
*/
|
|
440
440
|
getFile(fileId: string): Promise<File> {
|
|
441
|
-
return this.
|
|
441
|
+
return this.httpClient
|
|
442
442
|
.get(`/files/${fileId}`)
|
|
443
443
|
.then((response) => response.json())
|
|
444
|
-
.then((data) => new File(data, this.
|
|
444
|
+
.then((data) => new File(data, this.httpClient));
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
/**
|
|
@@ -490,13 +490,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
490
490
|
waitForDone: false,
|
|
491
491
|
}
|
|
492
492
|
): Promise<File> {
|
|
493
|
-
const result = await this.
|
|
493
|
+
const result = await this.httpClient
|
|
494
494
|
.uploadFile("/files", file, (progress) => {
|
|
495
495
|
this.emitEvent({ type: "uploadprogress", data: progress, file });
|
|
496
496
|
params.onProgress?.(progress, file);
|
|
497
497
|
})
|
|
498
498
|
.then((xhr: XMLHttpRequest) => JSON.parse(xhr.responseText))
|
|
499
|
-
.then((data) => new File(data, this.
|
|
499
|
+
.then((data) => new File(data, this.httpClient));
|
|
500
500
|
|
|
501
501
|
const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
|
|
502
502
|
|
|
@@ -518,7 +518,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
518
518
|
* @returns Returns the raw data of a deleted file.
|
|
519
519
|
*/
|
|
520
520
|
deleteFile(fileId: string): Promise<any> {
|
|
521
|
-
return this.
|
|
521
|
+
return this.httpClient.delete(`/files/${fileId}`).then((response) => response.json());
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
/**
|
|
@@ -532,7 +532,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
532
532
|
* and abort it if desired.
|
|
533
533
|
*/
|
|
534
534
|
downloadFile(fileId: string, onProgress?: (progress: number) => void, signal?: AbortSignal): Promise<ArrayBuffer> {
|
|
535
|
-
return this.
|
|
535
|
+
return this.httpClient
|
|
536
536
|
.downloadFile(`/files/${fileId}/downloads`, onProgress, signal)
|
|
537
537
|
.then((response) => response.arrayBuffer());
|
|
538
538
|
}
|
|
@@ -581,12 +581,12 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
581
581
|
let queryString = searchParams.toString();
|
|
582
582
|
if (queryString) queryString = "?" + queryString;
|
|
583
583
|
|
|
584
|
-
return this.
|
|
584
|
+
return this.httpClient
|
|
585
585
|
.get(`/jobs${queryString}`)
|
|
586
586
|
.then((response) => response.json())
|
|
587
587
|
.then((jobs) => ({
|
|
588
588
|
...jobs,
|
|
589
|
-
result: jobs.result.map((data) => new Job(data, this.
|
|
589
|
+
result: jobs.result.map((data) => new Job(data, this.httpClient)),
|
|
590
590
|
}));
|
|
591
591
|
}
|
|
592
592
|
|
|
@@ -597,10 +597,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
597
597
|
* @param jobId - Job ID.
|
|
598
598
|
*/
|
|
599
599
|
getJob(jobId: string): Promise<Job> {
|
|
600
|
-
return this.
|
|
600
|
+
return this.httpClient
|
|
601
601
|
.get(`/jobs/${jobId}`)
|
|
602
602
|
.then((response) => response.json())
|
|
603
|
-
.then((data) => new Job(data, this.
|
|
603
|
+
.then((data) => new Job(data, this.httpClient));
|
|
604
604
|
}
|
|
605
605
|
|
|
606
606
|
/**
|
|
@@ -622,14 +622,14 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
622
622
|
* for the File Converter tool in form "--arg=value".
|
|
623
623
|
*/
|
|
624
624
|
createJob(fileId: string, outputFormat: string, parameters?: string | object): Promise<Job> {
|
|
625
|
-
return this.
|
|
625
|
+
return this.httpClient
|
|
626
626
|
.post("/jobs", {
|
|
627
627
|
fileId,
|
|
628
628
|
outputFormat,
|
|
629
629
|
parameters: parseArgs(parameters),
|
|
630
630
|
})
|
|
631
631
|
.then((response) => response.json())
|
|
632
|
-
.then((data) => new Job(data, this.
|
|
632
|
+
.then((data) => new Job(data, this.httpClient));
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
/**
|
|
@@ -641,7 +641,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
641
641
|
* @returns Returns the raw data of a deleted job.
|
|
642
642
|
*/
|
|
643
643
|
deleteJob(jobId: string): Promise<any> {
|
|
644
|
-
return this.
|
|
644
|
+
return this.httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
|
|
645
645
|
}
|
|
646
646
|
|
|
647
647
|
/**
|
|
@@ -692,13 +692,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
692
692
|
let queryString = searchParams.toString();
|
|
693
693
|
if (queryString) queryString = "?" + queryString;
|
|
694
694
|
|
|
695
|
-
return this.
|
|
695
|
+
return this.httpClient
|
|
696
696
|
.get(`/assemblies${queryString}`)
|
|
697
697
|
.then((response) => response.json())
|
|
698
698
|
.then((assemblies) => {
|
|
699
699
|
return {
|
|
700
700
|
...assemblies,
|
|
701
|
-
result: assemblies.result.map((data) => new Assembly(data, this.
|
|
701
|
+
result: assemblies.result.map((data) => new Assembly(data, this.httpClient)),
|
|
702
702
|
};
|
|
703
703
|
});
|
|
704
704
|
}
|
|
@@ -710,10 +710,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
710
710
|
* @param assemblyId - Assembly ID.
|
|
711
711
|
*/
|
|
712
712
|
getAssembly(assemblyId: string): Promise<Assembly> {
|
|
713
|
-
return this.
|
|
713
|
+
return this.httpClient
|
|
714
714
|
.get(`/assemblies/${assemblyId}`)
|
|
715
715
|
.then((response) => response.json())
|
|
716
|
-
.then((data) => new Assembly(data, this.
|
|
716
|
+
.then((data) => new Assembly(data, this.httpClient));
|
|
717
717
|
}
|
|
718
718
|
|
|
719
719
|
/**
|
|
@@ -736,10 +736,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
736
736
|
}
|
|
737
737
|
): Promise<Assembly> {
|
|
738
738
|
const { waitForDone } = params ?? {};
|
|
739
|
-
return this.
|
|
739
|
+
return this.httpClient
|
|
740
740
|
.post("/assemblies", { name, files })
|
|
741
741
|
.then((response) => response.json())
|
|
742
|
-
.then((data) => new Assembly(data, this.
|
|
742
|
+
.then((data) => new Assembly(data, this.httpClient))
|
|
743
743
|
.then((result) => (waitForDone ? result.waitForDone(params) : result));
|
|
744
744
|
}
|
|
745
745
|
|
|
@@ -751,7 +751,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
751
751
|
* @returns Returns the raw data of a deleted assembly.
|
|
752
752
|
*/
|
|
753
753
|
deleteAssembly(assemblyId: string): Promise<any> {
|
|
754
|
-
return this.
|
|
754
|
+
return this.httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
|
|
755
755
|
}
|
|
756
756
|
|
|
757
757
|
/**
|
|
@@ -797,7 +797,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
797
797
|
|
|
798
798
|
let queryString = searchParams.toString();
|
|
799
799
|
if (queryString) queryString = "?" + queryString;
|
|
800
|
-
return this.
|
|
800
|
+
return this.httpClient
|
|
801
801
|
.get(`/projects${queryString}`)
|
|
802
802
|
.then((response) => response.json())
|
|
803
803
|
.then((projects) => {
|
|
@@ -823,7 +823,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
823
823
|
.then((projects) => {
|
|
824
824
|
return {
|
|
825
825
|
...projects,
|
|
826
|
-
result: projects.result.map((data) => new Project(data, this.
|
|
826
|
+
result: projects.result.map((data) => new Project(data, this.httpClient)),
|
|
827
827
|
};
|
|
828
828
|
});
|
|
829
829
|
}
|
|
@@ -835,10 +835,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
835
835
|
* @param projectId - Project ID.
|
|
836
836
|
*/
|
|
837
837
|
getProject(projectId: string): Promise<Project> {
|
|
838
|
-
return this.
|
|
838
|
+
return this.httpClient
|
|
839
839
|
.get(`/projects/${projectId}`)
|
|
840
840
|
.then((response) => response.json())
|
|
841
|
-
.then((data) => new Project(data, this.
|
|
841
|
+
.then((data) => new Project(data, this.httpClient));
|
|
842
842
|
}
|
|
843
843
|
|
|
844
844
|
/**
|
|
@@ -860,7 +860,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
860
860
|
endDate?: Date | string,
|
|
861
861
|
avatarUrl?: string
|
|
862
862
|
): Promise<Project> {
|
|
863
|
-
return this.
|
|
863
|
+
return this.httpClient
|
|
864
864
|
.post("/projects", {
|
|
865
865
|
name,
|
|
866
866
|
description,
|
|
@@ -869,7 +869,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
869
869
|
avatarUrl,
|
|
870
870
|
})
|
|
871
871
|
.then((response) => response.json())
|
|
872
|
-
.then((data) => new Project(data, this.
|
|
872
|
+
.then((data) => new Project(data, this.httpClient));
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
/**
|
|
@@ -880,7 +880,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
880
880
|
* @returns Returns the raw data of a deleted project.
|
|
881
881
|
*/
|
|
882
882
|
deleteProject(projectId: string): Promise<any> {
|
|
883
|
-
return this.
|
|
883
|
+
return this.httpClient
|
|
884
884
|
.delete(`/projects/${projectId}`)
|
|
885
885
|
.then((response) => response.text())
|
|
886
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.
|
package/src/Api/User.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export { Client } from "./Api/Client";
|
|
|
26
26
|
export { ClashTest } from "./Api/ClashTest";
|
|
27
27
|
export * from "./Api/ClientEvents";
|
|
28
28
|
export { File } from "./Api/File";
|
|
29
|
+
export { FetchError, statusText } from "./Api/FetchError";
|
|
29
30
|
export { Job } from "./Api/Job";
|
|
30
31
|
export { Member } from "./Api/Member";
|
|
31
32
|
export { Model } from "./Api/Model";
|