@inweb/client 25.3.19 → 25.3.21
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 +32 -33
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +29 -27
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +9 -13
- package/lib/Api/ClashTest.d.ts +3 -3
- package/lib/Api/Client.d.ts +1 -1
- package/lib/Api/FetchError.d.ts +1 -1
- package/lib/Api/File.d.ts +8 -9
- package/lib/Api/Job.d.ts +3 -3
- package/lib/Api/Member.d.ts +3 -3
- package/lib/Api/Model.d.ts +2 -6
- package/lib/Api/Permission.d.ts +3 -3
- package/lib/Api/Project.d.ts +4 -4
- package/lib/Api/Role.d.ts +3 -3
- package/lib/Api/User.d.ts +3 -3
- package/lib/Api/Utils.d.ts +1 -1
- package/package.json +3 -3
- package/src/Api/Assembly.ts +15 -16
- package/src/Api/ClashTest.ts +4 -4
- package/src/Api/Client.ts +5 -9
- package/src/Api/Fetch.ts +1 -1
- package/src/Api/FetchError.ts +1 -1
- package/src/Api/File.ts +18 -18
- package/src/Api/HttpClient.ts +4 -4
- package/src/Api/Job.ts +6 -6
- package/src/Api/Member.ts +6 -6
- package/src/Api/Model.ts +2 -3
- package/src/Api/Permission.ts +6 -6
- package/src/Api/Project.ts +8 -8
- package/src/Api/Role.ts +6 -6
- package/src/Api/User.ts +4 -4
- package/src/Api/Utils.ts +6 -6
- package/src/Api/XMLHttp.ts +1 -1
package/src/Api/File.ts
CHANGED
|
@@ -54,22 +54,22 @@ export class File {
|
|
|
54
54
|
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
private internalGet(relativePath: string, signal?: AbortSignal) {
|
|
57
|
+
private internalGet(relativePath: string, signal?: AbortSignal): Promise<Response> {
|
|
58
58
|
relativePath = this.appendVersionParam(relativePath);
|
|
59
59
|
return this.httpClient.get(`${this.path}${relativePath}`, signal);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
private internalPost(relativePath: string, body?: BodyInit | object) {
|
|
62
|
+
private internalPost(relativePath: string, body?: BodyInit | object): Promise<Response> {
|
|
63
63
|
relativePath = this.appendVersionParam(relativePath);
|
|
64
64
|
return this.httpClient.post(`${this.path}${relativePath}`, body);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
private internalPut(relativePath: string, body?: BodyInit | object) {
|
|
67
|
+
private internalPut(relativePath: string, body?: BodyInit | object): Promise<Response> {
|
|
68
68
|
relativePath = this.appendVersionParam(relativePath);
|
|
69
69
|
return this.httpClient.put(`${this.path}${relativePath}`, body);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
private internalDelete(relativePath: string) {
|
|
72
|
+
private internalDelete(relativePath: string): Promise<Response> {
|
|
73
73
|
relativePath = this.appendVersionParam(relativePath);
|
|
74
74
|
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
75
75
|
}
|
|
@@ -314,7 +314,7 @@ export class File {
|
|
|
314
314
|
*
|
|
315
315
|
* @async
|
|
316
316
|
*/
|
|
317
|
-
async checkout(): Promise<
|
|
317
|
+
async checkout(): Promise<this> {
|
|
318
318
|
const response = await this.internalGet("");
|
|
319
319
|
this.data = await response.json();
|
|
320
320
|
return this;
|
|
@@ -326,7 +326,7 @@ export class File {
|
|
|
326
326
|
* @async
|
|
327
327
|
* @param data - Raw file data.
|
|
328
328
|
*/
|
|
329
|
-
async update(data: any): Promise<
|
|
329
|
+
async update(data: any): Promise<this> {
|
|
330
330
|
const response = await this.internalPut("", data);
|
|
331
331
|
this.data = await response.json();
|
|
332
332
|
return this;
|
|
@@ -348,7 +348,7 @@ export class File {
|
|
|
348
348
|
*
|
|
349
349
|
* @async
|
|
350
350
|
*/
|
|
351
|
-
save(): Promise<
|
|
351
|
+
save(): Promise<this> {
|
|
352
352
|
return this.update(this.data);
|
|
353
353
|
}
|
|
354
354
|
|
|
@@ -365,7 +365,7 @@ export class File {
|
|
|
365
365
|
* Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
|
|
366
366
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
|
|
367
367
|
*/
|
|
368
|
-
async setPreview(image: BodyInit | null): Promise<
|
|
368
|
+
async setPreview(image: BodyInit | null): Promise<this> {
|
|
369
369
|
const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
|
|
370
370
|
this.data = await response.json();
|
|
371
371
|
return this;
|
|
@@ -388,7 +388,7 @@ export class File {
|
|
|
388
388
|
return undefined;
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
setModelTransformMatrix(handle: string, transform: any): Promise<
|
|
391
|
+
setModelTransformMatrix(handle: string, transform: any): Promise<this> {
|
|
392
392
|
console.warn("File does not support model transformation");
|
|
393
393
|
return Promise.resolve(this);
|
|
394
394
|
}
|
|
@@ -483,8 +483,7 @@ export class File {
|
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
/**
|
|
486
|
-
* Add new file viewpoint. To create a new viewpoint use
|
|
487
|
-
* {@link Viewer#createViewpoint | Viewer.createViewpoint()}.
|
|
486
|
+
* Add new file viewpoint. To create a new viewpoint use `Viewer.createViewpoint()`.
|
|
488
487
|
*
|
|
489
488
|
* @async
|
|
490
489
|
* @param viewpoint - Viewpoint.
|
|
@@ -745,7 +744,7 @@ export class File {
|
|
|
745
744
|
* @returns {Promise<File>}
|
|
746
745
|
*/
|
|
747
746
|
waitForDone(
|
|
748
|
-
jobs,
|
|
747
|
+
jobs: string | string[],
|
|
749
748
|
waitAll?: boolean,
|
|
750
749
|
params?: {
|
|
751
750
|
timeout?: number;
|
|
@@ -754,15 +753,16 @@ export class File {
|
|
|
754
753
|
onCheckout?: (file: File, ready: boolean) => boolean;
|
|
755
754
|
}
|
|
756
755
|
): Promise<this> {
|
|
757
|
-
|
|
756
|
+
const waitJobs = Array.isArray(jobs) ? jobs : [jobs];
|
|
758
757
|
if (waitAll === undefined) waitAll = true;
|
|
759
758
|
|
|
760
759
|
const checkDone = () =>
|
|
761
760
|
this.checkout().then((file) => {
|
|
762
|
-
const readyJobs =
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
761
|
+
const readyJobs = waitJobs.filter((job: string) => {
|
|
762
|
+
const jobStatus = file.status[job] || { state: none };
|
|
763
|
+
return ["none", "done", "failed"].includes(jobStatus.state);
|
|
764
|
+
});
|
|
765
|
+
const ready = waitAll ? readyJobs.length === waitJobs.length : readyJobs.length > 0;
|
|
766
766
|
const cancel = params?.onCheckout?.(file, ready);
|
|
767
767
|
return cancel || ready;
|
|
768
768
|
});
|
|
@@ -923,7 +923,7 @@ export class File {
|
|
|
923
923
|
* @param version - Desired active version.
|
|
924
924
|
*/
|
|
925
925
|
|
|
926
|
-
setActiveVersion(version: number): Promise<
|
|
926
|
+
setActiveVersion(version: number): Promise<this> {
|
|
927
927
|
return this.update({ activeVersion: version });
|
|
928
928
|
}
|
|
929
929
|
|
package/src/Api/HttpClient.ts
CHANGED
|
@@ -27,8 +27,8 @@ import { $xmlhttp } from "./XMLHttp";
|
|
|
27
27
|
|
|
28
28
|
export class HttpClient implements IHttpClient {
|
|
29
29
|
serverUrl: string;
|
|
30
|
-
headers: HeadersInit;
|
|
31
|
-
signInUserId
|
|
30
|
+
headers: HeadersInit = {};
|
|
31
|
+
signInUserId = "";
|
|
32
32
|
|
|
33
33
|
constructor(serverUrl: string) {
|
|
34
34
|
this.serverUrl = serverUrl;
|
|
@@ -90,7 +90,7 @@ export class HttpClient implements IHttpClient {
|
|
|
90
90
|
): Promise<Response> {
|
|
91
91
|
const response = await this.get(relativePath, signal);
|
|
92
92
|
const contentLength = response.headers.get("Content-Length");
|
|
93
|
-
const total = parseInt(contentLength, 10) || 1;
|
|
93
|
+
const total = parseInt(contentLength || "", 10) || 1;
|
|
94
94
|
return new Response(
|
|
95
95
|
new ReadableStream({
|
|
96
96
|
async start(controller) {
|
|
@@ -120,7 +120,7 @@ export class HttpClient implements IHttpClient {
|
|
|
120
120
|
headers["Range"] = "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(",");
|
|
121
121
|
const response = await $fetch(`${this.serverUrl}${relativePath}`, { method: "GET", headers, signal });
|
|
122
122
|
const contentLength = response.headers.get("content-length");
|
|
123
|
-
const total = parseInt(contentLength, 10) || 1;
|
|
123
|
+
const total = parseInt(contentLength || "", 10) || 1;
|
|
124
124
|
return new Response(
|
|
125
125
|
new ReadableStream({
|
|
126
126
|
async start(controller) {
|
package/src/Api/Job.ts
CHANGED
|
@@ -41,15 +41,15 @@ export class Job {
|
|
|
41
41
|
this.data = data;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
protected internalGet() {
|
|
44
|
+
protected internalGet(): Promise<Response> {
|
|
45
45
|
return this.httpClient.get(`/jobs/${this.data.id}`);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
protected internalPut(body?: BodyInit | object) {
|
|
48
|
+
protected internalPut(body?: BodyInit | object): Promise<Response> {
|
|
49
49
|
return this.httpClient.put(`/jobs/${this.data.id}`, body);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
protected internalDelete() {
|
|
52
|
+
protected internalDelete(): Promise<Response> {
|
|
53
53
|
return this.httpClient.delete(`/jobs/${this.data.id}`);
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -183,7 +183,7 @@ export class Job {
|
|
|
183
183
|
*
|
|
184
184
|
* @async
|
|
185
185
|
*/
|
|
186
|
-
async checkout(): Promise<
|
|
186
|
+
async checkout(): Promise<this> {
|
|
187
187
|
const response = await this.internalGet();
|
|
188
188
|
this.data = await response.json();
|
|
189
189
|
return this;
|
|
@@ -195,7 +195,7 @@ export class Job {
|
|
|
195
195
|
* @async
|
|
196
196
|
* @param data - Raw job data.
|
|
197
197
|
*/
|
|
198
|
-
async update(data: any): Promise<
|
|
198
|
+
async update(data: any): Promise<this> {
|
|
199
199
|
const response = await this.internalPut(data);
|
|
200
200
|
this.data = await response.json();
|
|
201
201
|
return this;
|
|
@@ -242,7 +242,7 @@ export class Job {
|
|
|
242
242
|
interval?: number;
|
|
243
243
|
signal?: AbortSignal;
|
|
244
244
|
onCheckout?: (job: Job, ready: boolean) => boolean;
|
|
245
|
-
}): Promise<
|
|
245
|
+
}): Promise<this> {
|
|
246
246
|
const checkDone = () =>
|
|
247
247
|
this.checkout().then((job) => {
|
|
248
248
|
const ready = ["done", "failed"].includes(job.status);
|
package/src/Api/Member.ts
CHANGED
|
@@ -44,15 +44,15 @@ export class Member {
|
|
|
44
44
|
this.data = data;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
private internalGet() {
|
|
47
|
+
private internalGet(): Promise<Response> {
|
|
48
48
|
return this.httpClient.get(`/projects/${this.projectId}/members/${this.id}`);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
private internalPut(body?: BodyInit | object) {
|
|
51
|
+
private internalPut(body?: BodyInit | object): Promise<Response> {
|
|
52
52
|
return this.httpClient.put(`/projects/${this.projectId}/members/${this.id}`, body);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
private internalDelete() {
|
|
55
|
+
private internalDelete(): Promise<Response> {
|
|
56
56
|
return this.httpClient.delete(`/projects/${this.projectId}/members/${this.id}`);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -123,7 +123,7 @@ export class Member {
|
|
|
123
123
|
*
|
|
124
124
|
* @async
|
|
125
125
|
*/
|
|
126
|
-
async checkout(): Promise<
|
|
126
|
+
async checkout(): Promise<this> {
|
|
127
127
|
const response = await this.internalGet();
|
|
128
128
|
this.data = await response.json();
|
|
129
129
|
return this;
|
|
@@ -135,7 +135,7 @@ export class Member {
|
|
|
135
135
|
* @async
|
|
136
136
|
* @param data - Raw member data.
|
|
137
137
|
*/
|
|
138
|
-
async update(data: any): Promise<
|
|
138
|
+
async update(data: any): Promise<this> {
|
|
139
139
|
const response = await this.internalPut(data);
|
|
140
140
|
this.data = await response.json();
|
|
141
141
|
return this;
|
|
@@ -157,7 +157,7 @@ export class Member {
|
|
|
157
157
|
*
|
|
158
158
|
* @async
|
|
159
159
|
*/
|
|
160
|
-
save(): Promise<
|
|
160
|
+
save(): Promise<this> {
|
|
161
161
|
return this.update(this.data);
|
|
162
162
|
}
|
|
163
163
|
}
|
package/src/Api/Model.ts
CHANGED
|
@@ -195,8 +195,7 @@ export class Model {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
|
-
* Add new model viewpoint. To create a new viewpoint use
|
|
199
|
-
* {@link Viewer#createViewpoint | Viewer.createViewpoint()}.
|
|
198
|
+
* Add new model viewpoint. To create a new viewpoint use `Viewer.createViewpoint()`.
|
|
200
199
|
*
|
|
201
200
|
* _**Note**: Assemblу models do not support viewpoints_.
|
|
202
201
|
*
|
|
@@ -339,7 +338,7 @@ export class Model {
|
|
|
339
338
|
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
340
339
|
* signal object instance, which can be used to abort waiting as desired.
|
|
341
340
|
*/
|
|
342
|
-
getReferences(signal?: AbortSignal) {
|
|
341
|
+
getReferences(signal?: AbortSignal): Promise<any> {
|
|
343
342
|
return this._file.getReferences(signal);
|
|
344
343
|
}
|
|
345
344
|
}
|
package/src/Api/Permission.ts
CHANGED
|
@@ -43,15 +43,15 @@ export class Permission {
|
|
|
43
43
|
this.data = data;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
private internalGet() {
|
|
46
|
+
private internalGet(): Promise<Response> {
|
|
47
47
|
return this.httpClient.get(`/files/${this.fileId}/permissions/${this.id}`);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
private internalPut(body?: BodyInit | object) {
|
|
50
|
+
private internalPut(body?: BodyInit | object): Promise<Response> {
|
|
51
51
|
return this.httpClient.put(`/files/${this.fileId}/permissions/${this.id}`, body);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
private internalDelete() {
|
|
54
|
+
private internalDelete(): Promise<Response> {
|
|
55
55
|
return this.httpClient.delete(`/files/${this.fileId}/permissions/${this.id}`);
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -134,7 +134,7 @@ export class Permission {
|
|
|
134
134
|
*
|
|
135
135
|
* @async
|
|
136
136
|
*/
|
|
137
|
-
async checkout(): Promise<
|
|
137
|
+
async checkout(): Promise<this> {
|
|
138
138
|
const response = await this.internalGet();
|
|
139
139
|
this.data = await response.json();
|
|
140
140
|
return this;
|
|
@@ -146,7 +146,7 @@ export class Permission {
|
|
|
146
146
|
* @async
|
|
147
147
|
* @param data - Raw permission data.
|
|
148
148
|
*/
|
|
149
|
-
async update(data: any): Promise<
|
|
149
|
+
async update(data: any): Promise<this> {
|
|
150
150
|
const response = await this.internalPut(data);
|
|
151
151
|
this.data = await response.json();
|
|
152
152
|
return this;
|
|
@@ -168,7 +168,7 @@ export class Permission {
|
|
|
168
168
|
*
|
|
169
169
|
* @async
|
|
170
170
|
*/
|
|
171
|
-
save(): Promise<
|
|
171
|
+
save(): Promise<this> {
|
|
172
172
|
return this.update(this.data);
|
|
173
173
|
}
|
|
174
174
|
}
|
package/src/Api/Project.ts
CHANGED
|
@@ -43,19 +43,19 @@ export class Project {
|
|
|
43
43
|
this.data = data;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
protected internalGet(relativePath: string) {
|
|
46
|
+
protected internalGet(relativePath: string): Promise<Response> {
|
|
47
47
|
return this.httpClient.get(`/projects/${this.id}${relativePath}`);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
protected internalPost(relativePath: string, body?: BodyInit | object) {
|
|
50
|
+
protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response> {
|
|
51
51
|
return this.httpClient.post(`/projects/${this.id}${relativePath}`, body);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
protected internalPut(relativePath: string, body?: BodyInit | object) {
|
|
54
|
+
protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response> {
|
|
55
55
|
return this.httpClient.put(`/projects/${this.id}${relativePath}`, body);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
protected internalDelete(relativePath: string) {
|
|
58
|
+
protected internalDelete(relativePath: string): Promise<Response> {
|
|
59
59
|
return this.httpClient.delete(`/projects/${this.id}${relativePath}`);
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -242,7 +242,7 @@ export class Project {
|
|
|
242
242
|
*
|
|
243
243
|
* @async
|
|
244
244
|
*/
|
|
245
|
-
async checkout(): Promise<
|
|
245
|
+
async checkout(): Promise<this> {
|
|
246
246
|
const response = await this.internalGet("");
|
|
247
247
|
this.data = await response.json();
|
|
248
248
|
return this;
|
|
@@ -254,7 +254,7 @@ export class Project {
|
|
|
254
254
|
* @async
|
|
255
255
|
* @param data - Raw project data.
|
|
256
256
|
*/
|
|
257
|
-
async update(data: any): Promise<
|
|
257
|
+
async update(data: any): Promise<this> {
|
|
258
258
|
const response = await this.internalPut("", data);
|
|
259
259
|
this.data = await response.json();
|
|
260
260
|
return this;
|
|
@@ -285,7 +285,7 @@ export class Project {
|
|
|
285
285
|
*
|
|
286
286
|
* @async
|
|
287
287
|
*/
|
|
288
|
-
save(): Promise<
|
|
288
|
+
save(): Promise<this> {
|
|
289
289
|
return this.update(this.data);
|
|
290
290
|
}
|
|
291
291
|
|
|
@@ -303,7 +303,7 @@ export class Project {
|
|
|
303
303
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
|
|
304
304
|
*/
|
|
305
305
|
|
|
306
|
-
async setPreview(image: BodyInit | null) {
|
|
306
|
+
async setPreview(image: BodyInit | null): Promise<any> {
|
|
307
307
|
const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
|
|
308
308
|
this.data = await response.json();
|
|
309
309
|
return this;
|
package/src/Api/Role.ts
CHANGED
|
@@ -42,15 +42,15 @@ export class Role {
|
|
|
42
42
|
this.data = data;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
private internalGet() {
|
|
45
|
+
private internalGet(): Promise<Response> {
|
|
46
46
|
return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
private internalPut(body?: BodyInit | object) {
|
|
49
|
+
private internalPut(body?: BodyInit | object): Promise<Response> {
|
|
50
50
|
return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`, body);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
private internalDelete() {
|
|
53
|
+
private internalDelete(): Promise<Response> {
|
|
54
54
|
return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -119,7 +119,7 @@ export class Role {
|
|
|
119
119
|
*
|
|
120
120
|
* @async
|
|
121
121
|
*/
|
|
122
|
-
async checkout(): Promise<
|
|
122
|
+
async checkout(): Promise<this> {
|
|
123
123
|
const response = await this.internalGet();
|
|
124
124
|
this.data = await response.json();
|
|
125
125
|
return this;
|
|
@@ -131,7 +131,7 @@ export class Role {
|
|
|
131
131
|
* @async
|
|
132
132
|
* @param data - Raw role data.
|
|
133
133
|
*/
|
|
134
|
-
async update(data: any): Promise<
|
|
134
|
+
async update(data: any): Promise<this> {
|
|
135
135
|
const response = await this.internalPut(data);
|
|
136
136
|
this.data = await response.json();
|
|
137
137
|
return this;
|
|
@@ -153,7 +153,7 @@ export class Role {
|
|
|
153
153
|
*
|
|
154
154
|
* @async
|
|
155
155
|
*/
|
|
156
|
-
save(): Promise<
|
|
156
|
+
save(): Promise<this> {
|
|
157
157
|
return this.update(this.data);
|
|
158
158
|
}
|
|
159
159
|
}
|
package/src/Api/User.ts
CHANGED
|
@@ -257,7 +257,7 @@ export class User {
|
|
|
257
257
|
* does not have administrator rights, hi can only checkout himself, otherwise an exception
|
|
258
258
|
* will be thrown.
|
|
259
259
|
*/
|
|
260
|
-
async checkout(): Promise<
|
|
260
|
+
async checkout(): Promise<this> {
|
|
261
261
|
if (this.id === this.httpClient.signInUserId) {
|
|
262
262
|
const response = await this.httpClient.get("/user");
|
|
263
263
|
const data = await response.json();
|
|
@@ -278,7 +278,7 @@ export class User {
|
|
|
278
278
|
* @async
|
|
279
279
|
* @param data - Raw user data.
|
|
280
280
|
*/
|
|
281
|
-
async update(data: any) {
|
|
281
|
+
async update(data: any): Promise<this> {
|
|
282
282
|
if (this.id === this.httpClient.signInUserId) {
|
|
283
283
|
const response = await this.httpClient.put("/user", data);
|
|
284
284
|
const newData = await response.json();
|
|
@@ -322,7 +322,7 @@ export class User {
|
|
|
322
322
|
*
|
|
323
323
|
* @async
|
|
324
324
|
*/
|
|
325
|
-
save(): Promise<
|
|
325
|
+
save(): Promise<this> {
|
|
326
326
|
return this.update(this.data);
|
|
327
327
|
}
|
|
328
328
|
|
|
@@ -341,7 +341,7 @@ export class User {
|
|
|
341
341
|
* Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
|
|
342
342
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the avatar.
|
|
343
343
|
*/
|
|
344
|
-
async setAvatar(image: BodyInit | null): Promise<
|
|
344
|
+
async setAvatar(image: BodyInit | null): Promise<this> {
|
|
345
345
|
if (image) {
|
|
346
346
|
if (this.id === this.httpClient.signInUserId) {
|
|
347
347
|
const response = await this.httpClient.post("/user/avatar", image);
|
package/src/Api/Utils.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
function delay(ms: number, signal: AbortSignal) {
|
|
24
|
+
function delay(ms: number, signal: AbortSignal): Promise<boolean> {
|
|
25
25
|
return new Promise((resolve) => {
|
|
26
26
|
let timeoutId = 0;
|
|
27
27
|
|
|
@@ -49,9 +49,9 @@ export async function waitFor(
|
|
|
49
49
|
timeoutError?: DOMException;
|
|
50
50
|
result?: any;
|
|
51
51
|
} = {}
|
|
52
|
-
) {
|
|
53
|
-
const timeout = params.timeout
|
|
54
|
-
const interval = params.interval
|
|
52
|
+
): Promise<any> {
|
|
53
|
+
const timeout = params.timeout || 600000;
|
|
54
|
+
const interval = params.interval || 3000;
|
|
55
55
|
const signal = params.signal ?? new AbortController().signal;
|
|
56
56
|
const abortError = params.abortError ?? new DOMException("Aborted", "AbortError");
|
|
57
57
|
const timeoutError = params.timeoutError ?? new DOMException("Timeout", "TimeoutError");
|
|
@@ -67,7 +67,7 @@ export async function waitFor(
|
|
|
67
67
|
return Promise.reject(timeoutError);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export function parseArgs(args
|
|
70
|
+
export function parseArgs(args?: string | object): object {
|
|
71
71
|
if (typeof args === "string") {
|
|
72
72
|
const firstArg = args.indexOf("--");
|
|
73
73
|
if (firstArg !== -1) args = args.slice(firstArg);
|
|
@@ -83,7 +83,7 @@ export function parseArgs(args: string | object): object {
|
|
|
83
83
|
.map((x) => x.concat([""]));
|
|
84
84
|
return Object.fromEntries(argArray);
|
|
85
85
|
}
|
|
86
|
-
return args
|
|
86
|
+
return args || {};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export function userFullName(firstName: string | any, lastName = "", userName = ""): string {
|
package/src/Api/XMLHttp.ts
CHANGED
|
@@ -61,7 +61,7 @@ export function $xmlhttp(
|
|
|
61
61
|
for (const key in params.headers) {
|
|
62
62
|
xhr.setRequestHeader(key, params.headers[key]);
|
|
63
63
|
}
|
|
64
|
-
function calcProgress(event: ProgressEvent) {
|
|
64
|
+
function calcProgress(event: ProgressEvent): number {
|
|
65
65
|
return event.lengthComputable ? event.loaded / event.total : 1;
|
|
66
66
|
}
|
|
67
67
|
xhr.upload.onprogress = (event) => params.uploadProgress && params.uploadProgress(calcProgress(event));
|