@inweb/client 25.3.19 → 25.3.20
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 +23 -24
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +24 -24
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +8 -12
- package/lib/Api/ClashTest.d.ts +3 -3
- package/lib/Api/FetchError.d.ts +1 -1
- package/lib/Api/File.d.ts +7 -7
- package/lib/Api/Job.d.ts +3 -3
- package/lib/Api/Member.d.ts +3 -3
- package/lib/Api/Model.d.ts +1 -4
- 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 +2 -2
- package/src/Api/Assembly.ts +14 -15
- package/src/Api/ClashTest.ts +4 -4
- package/src/Api/Client.ts +4 -8
- package/src/Api/Fetch.ts +1 -1
- package/src/Api/FetchError.ts +1 -1
- package/src/Api/File.ts +12 -12
- 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 +1 -1
- 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/lib/Api/Assembly.d.ts
CHANGED
|
@@ -110,14 +110,14 @@ export declare class Assembly {
|
|
|
110
110
|
*
|
|
111
111
|
* @async
|
|
112
112
|
*/
|
|
113
|
-
checkout(): Promise<
|
|
113
|
+
checkout(): Promise<this>;
|
|
114
114
|
/**
|
|
115
115
|
* Updates assembly data on the server.
|
|
116
116
|
*
|
|
117
117
|
* @async
|
|
118
118
|
* @param data - Raw assembly data.
|
|
119
119
|
*/
|
|
120
|
-
update(data: any): Promise<
|
|
120
|
+
update(data: any): Promise<this>;
|
|
121
121
|
/**
|
|
122
122
|
* Delete the assembly from the server.
|
|
123
123
|
*
|
|
@@ -131,8 +131,8 @@ export declare class Assembly {
|
|
|
131
131
|
*
|
|
132
132
|
* @async
|
|
133
133
|
*/
|
|
134
|
-
save(): Promise<
|
|
135
|
-
setPreview(image: BodyInit | null): Promise<
|
|
134
|
+
save(): Promise<this>;
|
|
135
|
+
setPreview(image: BodyInit | null): Promise<this>;
|
|
136
136
|
/**
|
|
137
137
|
* Returns list of assembly models.
|
|
138
138
|
*
|
|
@@ -168,7 +168,7 @@ export declare class Assembly {
|
|
|
168
168
|
* @param handle - Model handle.
|
|
169
169
|
* @param transform - Transformation matrix. To delete transformation provide this to `undefined`.
|
|
170
170
|
*/
|
|
171
|
-
setModelTransformMatrix(handle: string, transform: any): Promise<
|
|
171
|
+
setModelTransformMatrix(handle: string, transform: any): Promise<this>;
|
|
172
172
|
/**
|
|
173
173
|
* Returns the properties for an objects in the assembly.
|
|
174
174
|
*
|
|
@@ -253,10 +253,7 @@ export declare class Assembly {
|
|
|
253
253
|
* Deprecated since `25.3`. Use {@link Assembly.downloadResourceRange()} instead.
|
|
254
254
|
*/
|
|
255
255
|
downloadFileRange(requestId: number, records: any | null, dataId: string, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise<void>;
|
|
256
|
-
getReferences(signal?: AbortSignal): Promise<
|
|
257
|
-
fileId: string;
|
|
258
|
-
references: any[];
|
|
259
|
-
}>;
|
|
256
|
+
getReferences(signal?: AbortSignal): Promise<any>;
|
|
260
257
|
/**
|
|
261
258
|
* Wait for assembly to be created. Assembly is created when it changes to `done` or `failed` status.
|
|
262
259
|
*
|
|
@@ -270,14 +267,13 @@ export declare class Assembly {
|
|
|
270
267
|
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
271
268
|
* signal object instance, which can be used to abort waiting as desired.
|
|
272
269
|
* @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
|
|
273
|
-
* @returns {Promise<Assembly>}
|
|
274
270
|
*/
|
|
275
271
|
waitForDone(params?: {
|
|
276
272
|
timeout?: number;
|
|
277
273
|
interval?: number;
|
|
278
274
|
signal?: AbortSignal;
|
|
279
275
|
onCheckout?: (assembly: Assembly, ready: boolean) => boolean;
|
|
280
|
-
}): Promise<
|
|
276
|
+
}): Promise<this>;
|
|
281
277
|
/**
|
|
282
278
|
* Returns a list of assembly clash tests.
|
|
283
279
|
*
|
|
@@ -357,6 +353,6 @@ export declare class Assembly {
|
|
|
357
353
|
getVersions(): Promise<Assembly[] | undefined>;
|
|
358
354
|
getVersion(version: number): Promise<Assembly>;
|
|
359
355
|
deleteVersion(version: number): Promise<any>;
|
|
360
|
-
setActiveVersion(version: number): Promise<
|
|
356
|
+
setActiveVersion(version: number): Promise<this>;
|
|
361
357
|
useVersion(version?: number): this;
|
|
362
358
|
}
|
package/lib/Api/ClashTest.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ export declare class ClashTest {
|
|
|
13
13
|
* @param httpClient - Http client.
|
|
14
14
|
*/
|
|
15
15
|
constructor(data: any, basePath: string, httpClient: IHttpClient);
|
|
16
|
-
protected internalGet(relativePath: string): Promise<
|
|
17
|
-
protected internalPut(relativePath: string, body?: BodyInit | object): Promise<
|
|
18
|
-
protected internalDelete(relativePath: string): Promise<
|
|
16
|
+
protected internalGet(relativePath: string): Promise<Response>;
|
|
17
|
+
protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
|
18
|
+
protected internalDelete(relativePath: string): Promise<Response>;
|
|
19
19
|
/**
|
|
20
20
|
* The type of the clashes that the test detects:
|
|
21
21
|
*
|
package/lib/Api/FetchError.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function statusText(status: number): string;
|
|
2
|
-
export declare function error400(text: string, _default?: string):
|
|
2
|
+
export declare function error400(text: string, _default?: string): string;
|
|
3
3
|
/**
|
|
4
4
|
* The `FetchError` object indicates an error when request to Open Cloud Server could not be
|
|
5
5
|
* performed. A `FetchError` is typically (but not exclusively) thrown when a network error
|
package/lib/Api/File.d.ts
CHANGED
|
@@ -174,14 +174,14 @@ export declare class File {
|
|
|
174
174
|
*
|
|
175
175
|
* @async
|
|
176
176
|
*/
|
|
177
|
-
checkout(): Promise<
|
|
177
|
+
checkout(): Promise<this>;
|
|
178
178
|
/**
|
|
179
179
|
* Update file data on the server.
|
|
180
180
|
*
|
|
181
181
|
* @async
|
|
182
182
|
* @param data - Raw file data.
|
|
183
183
|
*/
|
|
184
|
-
update(data: any): Promise<
|
|
184
|
+
update(data: any): Promise<this>;
|
|
185
185
|
/**
|
|
186
186
|
* Delete the file and all its versions from the server.
|
|
187
187
|
*
|
|
@@ -195,7 +195,7 @@ export declare class File {
|
|
|
195
195
|
*
|
|
196
196
|
* @async
|
|
197
197
|
*/
|
|
198
|
-
save(): Promise<
|
|
198
|
+
save(): Promise<this>;
|
|
199
199
|
/**
|
|
200
200
|
* Set or remove the file preview.
|
|
201
201
|
*
|
|
@@ -209,7 +209,7 @@ export declare class File {
|
|
|
209
209
|
* Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
|
|
210
210
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
|
|
211
211
|
*/
|
|
212
|
-
setPreview(image: BodyInit | null): Promise<
|
|
212
|
+
setPreview(image: BodyInit | null): Promise<this>;
|
|
213
213
|
/**
|
|
214
214
|
* Returns a list of models of the active version of the file.
|
|
215
215
|
*
|
|
@@ -217,7 +217,7 @@ export declare class File {
|
|
|
217
217
|
*/
|
|
218
218
|
getModels(): Promise<Model[]>;
|
|
219
219
|
getModelTransformMatrix(handle: string): any;
|
|
220
|
-
setModelTransformMatrix(handle: string, transform: any): Promise<
|
|
220
|
+
setModelTransformMatrix(handle: string, transform: any): Promise<this>;
|
|
221
221
|
/**
|
|
222
222
|
* Object properties.
|
|
223
223
|
*
|
|
@@ -469,7 +469,7 @@ export declare class File {
|
|
|
469
469
|
* @param {function} [params.onCheckout] - Waiting progress callback. Return `true` to cancel waiting.
|
|
470
470
|
* @returns {Promise<File>}
|
|
471
471
|
*/
|
|
472
|
-
waitForDone(jobs:
|
|
472
|
+
waitForDone(jobs: string | string[], waitAll?: boolean, params?: {
|
|
473
473
|
timeout?: number;
|
|
474
474
|
interval?: number;
|
|
475
475
|
signal?: AbortSignal;
|
|
@@ -563,7 +563,7 @@ export declare class File {
|
|
|
563
563
|
* @async
|
|
564
564
|
* @param version - Desired active version.
|
|
565
565
|
*/
|
|
566
|
-
setActiveVersion(version: number): Promise<
|
|
566
|
+
setActiveVersion(version: number): Promise<this>;
|
|
567
567
|
/**
|
|
568
568
|
* Use given version instead of active version for current file on client side. This version
|
|
569
569
|
* change will affect the result:
|
package/lib/Api/Job.d.ts
CHANGED
|
@@ -102,14 +102,14 @@ export declare class Job {
|
|
|
102
102
|
*
|
|
103
103
|
* @async
|
|
104
104
|
*/
|
|
105
|
-
checkout(): Promise<
|
|
105
|
+
checkout(): Promise<this>;
|
|
106
106
|
/**
|
|
107
107
|
* Update job data on the server. Only admins can update job data.
|
|
108
108
|
*
|
|
109
109
|
* @async
|
|
110
110
|
* @param data - Raw job data.
|
|
111
111
|
*/
|
|
112
|
-
update(data: any): Promise<
|
|
112
|
+
update(data: any): Promise<this>;
|
|
113
113
|
/**
|
|
114
114
|
* Remove a job from the server job list. Jobs that are in progress or have already been
|
|
115
115
|
* completed cannot be deleted.
|
|
@@ -137,5 +137,5 @@ export declare class Job {
|
|
|
137
137
|
interval?: number;
|
|
138
138
|
signal?: AbortSignal;
|
|
139
139
|
onCheckout?: (job: Job, ready: boolean) => boolean;
|
|
140
|
-
}): Promise<
|
|
140
|
+
}): Promise<this>;
|
|
141
141
|
}
|
package/lib/Api/Member.d.ts
CHANGED
|
@@ -59,14 +59,14 @@ export declare class Member {
|
|
|
59
59
|
*
|
|
60
60
|
* @async
|
|
61
61
|
*/
|
|
62
|
-
checkout(): Promise<
|
|
62
|
+
checkout(): Promise<this>;
|
|
63
63
|
/**
|
|
64
64
|
* Update member data on the server.
|
|
65
65
|
*
|
|
66
66
|
* @async
|
|
67
67
|
* @param data - Raw member data.
|
|
68
68
|
*/
|
|
69
|
-
update(data: any): Promise<
|
|
69
|
+
update(data: any): Promise<this>;
|
|
70
70
|
/**
|
|
71
71
|
* Remove a member from a project.
|
|
72
72
|
*
|
|
@@ -80,5 +80,5 @@ export declare class Member {
|
|
|
80
80
|
*
|
|
81
81
|
* @async
|
|
82
82
|
*/
|
|
83
|
-
save(): Promise<
|
|
83
|
+
save(): Promise<this>;
|
|
84
84
|
}
|
package/lib/Api/Model.d.ts
CHANGED
|
@@ -190,8 +190,5 @@ export declare class Model {
|
|
|
190
190
|
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
191
191
|
* signal object instance, which can be used to abort waiting as desired.
|
|
192
192
|
*/
|
|
193
|
-
getReferences(signal?: AbortSignal): Promise<
|
|
194
|
-
fileId: string;
|
|
195
|
-
references: any[];
|
|
196
|
-
}>;
|
|
193
|
+
getReferences(signal?: AbortSignal): Promise<any>;
|
|
197
194
|
}
|
package/lib/Api/Permission.d.ts
CHANGED
|
@@ -67,14 +67,14 @@ export declare class Permission {
|
|
|
67
67
|
*
|
|
68
68
|
* @async
|
|
69
69
|
*/
|
|
70
|
-
checkout(): Promise<
|
|
70
|
+
checkout(): Promise<this>;
|
|
71
71
|
/**
|
|
72
72
|
* Update permission data on the server.
|
|
73
73
|
*
|
|
74
74
|
* @async
|
|
75
75
|
* @param data - Raw permission data.
|
|
76
76
|
*/
|
|
77
|
-
update(data: any): Promise<
|
|
77
|
+
update(data: any): Promise<this>;
|
|
78
78
|
/**
|
|
79
79
|
* Remove a permission from a file.
|
|
80
80
|
*
|
|
@@ -88,5 +88,5 @@ export declare class Permission {
|
|
|
88
88
|
*
|
|
89
89
|
* @async
|
|
90
90
|
*/
|
|
91
|
-
save(): Promise<
|
|
91
|
+
save(): Promise<this>;
|
|
92
92
|
}
|
package/lib/Api/Project.d.ts
CHANGED
|
@@ -127,14 +127,14 @@ export declare class Project {
|
|
|
127
127
|
*
|
|
128
128
|
* @async
|
|
129
129
|
*/
|
|
130
|
-
checkout(): Promise<
|
|
130
|
+
checkout(): Promise<this>;
|
|
131
131
|
/**
|
|
132
132
|
* Update project data on the server.
|
|
133
133
|
*
|
|
134
134
|
* @async
|
|
135
135
|
* @param data - Raw project data.
|
|
136
136
|
*/
|
|
137
|
-
update(data: any): Promise<
|
|
137
|
+
update(data: any): Promise<this>;
|
|
138
138
|
/**
|
|
139
139
|
* Delete the project from the server.
|
|
140
140
|
*
|
|
@@ -148,7 +148,7 @@ export declare class Project {
|
|
|
148
148
|
*
|
|
149
149
|
* @async
|
|
150
150
|
*/
|
|
151
|
-
save(): Promise<
|
|
151
|
+
save(): Promise<this>;
|
|
152
152
|
/**
|
|
153
153
|
* Set or remove the project preview.
|
|
154
154
|
*
|
|
@@ -162,7 +162,7 @@ export declare class Project {
|
|
|
162
162
|
* Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
|
|
163
163
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
|
|
164
164
|
*/
|
|
165
|
-
setPreview(image: BodyInit | null): Promise<
|
|
165
|
+
setPreview(image: BodyInit | null): Promise<any>;
|
|
166
166
|
/**
|
|
167
167
|
* Returns a list of project roles. Project {@link Member | members} have different abilities
|
|
168
168
|
* depending on the role they have in a project.
|
package/lib/Api/Role.d.ts
CHANGED
|
@@ -56,14 +56,14 @@ export declare class Role {
|
|
|
56
56
|
*
|
|
57
57
|
* @async
|
|
58
58
|
*/
|
|
59
|
-
checkout(): Promise<
|
|
59
|
+
checkout(): Promise<this>;
|
|
60
60
|
/**
|
|
61
61
|
* Update role data on the server.
|
|
62
62
|
*
|
|
63
63
|
* @async
|
|
64
64
|
* @param data - Raw role data.
|
|
65
65
|
*/
|
|
66
|
-
update(data: any): Promise<
|
|
66
|
+
update(data: any): Promise<this>;
|
|
67
67
|
/**
|
|
68
68
|
* Delete a role from the project.
|
|
69
69
|
*
|
|
@@ -77,5 +77,5 @@ export declare class Role {
|
|
|
77
77
|
*
|
|
78
78
|
* @async
|
|
79
79
|
*/
|
|
80
|
-
save(): Promise<
|
|
80
|
+
save(): Promise<this>;
|
|
81
81
|
}
|
package/lib/Api/User.d.ts
CHANGED
|
@@ -147,7 +147,7 @@ export declare class User {
|
|
|
147
147
|
* does not have administrator rights, hi can only checkout himself, otherwise an exception
|
|
148
148
|
* will be thrown.
|
|
149
149
|
*/
|
|
150
|
-
checkout(): Promise<
|
|
150
|
+
checkout(): Promise<this>;
|
|
151
151
|
/**
|
|
152
152
|
* Update user data on the server. Only admins can update other users, if the current logged
|
|
153
153
|
* in user does not have administrator rights, hi can only update himself, otherwise an
|
|
@@ -176,7 +176,7 @@ export declare class User {
|
|
|
176
176
|
*
|
|
177
177
|
* @async
|
|
178
178
|
*/
|
|
179
|
-
save(): Promise<
|
|
179
|
+
save(): Promise<this>;
|
|
180
180
|
/**
|
|
181
181
|
* Set or remove the user avatar. Only admins can set the avatar of other users, if the
|
|
182
182
|
* current logged in user does not have administrator rights, he can only set his own avatar,
|
|
@@ -192,5 +192,5 @@ export declare class User {
|
|
|
192
192
|
* Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
|
|
193
193
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the avatar.
|
|
194
194
|
*/
|
|
195
|
-
setAvatar(image: BodyInit | null): Promise<
|
|
195
|
+
setAvatar(image: BodyInit | null): Promise<this>;
|
|
196
196
|
}
|
package/lib/Api/Utils.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export declare function waitFor(func: (params: any) => Promise<boolean>, params?
|
|
|
6
6
|
timeoutError?: DOMException;
|
|
7
7
|
result?: any;
|
|
8
8
|
}): Promise<any>;
|
|
9
|
-
export declare function parseArgs(args
|
|
9
|
+
export declare function parseArgs(args?: string | object): object;
|
|
10
10
|
export declare function userFullName(firstName: string | any, lastName?: string, userName?: string): string;
|
|
11
11
|
export declare function userInitials(fullName?: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/client",
|
|
3
|
-
"version": "25.3.
|
|
3
|
+
"version": "25.3.20",
|
|
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",
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
"ts-docs": "typedoc"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@inweb/eventemitter2": "^25.3.
|
|
30
|
+
"@inweb/eventemitter2": "^25.3.19"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/Api/Assembly.ts
CHANGED
|
@@ -54,22 +54,22 @@ export class Assembly {
|
|
|
54
54
|
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
protected internalGet(relativePath: string, signal?: AbortSignal) {
|
|
57
|
+
protected 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
|
-
protected internalPost(relativePath: string, body?: BodyInit | object) {
|
|
62
|
+
protected 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
|
-
protected internalPut(relativePath: string, body?: BodyInit | object) {
|
|
67
|
+
protected 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
|
-
protected internalDelete(relativePath: string) {
|
|
72
|
+
protected internalDelete(relativePath: string): Promise<Response> {
|
|
73
73
|
relativePath = this.appendVersionParam(relativePath);
|
|
74
74
|
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
75
75
|
}
|
|
@@ -184,7 +184,7 @@ export class Assembly {
|
|
|
184
184
|
// Reserved for future use
|
|
185
185
|
|
|
186
186
|
get previewUrl(): string {
|
|
187
|
-
return this.data.previewUrl
|
|
187
|
+
return this.data.previewUrl || "";
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
@@ -231,7 +231,7 @@ export class Assembly {
|
|
|
231
231
|
*
|
|
232
232
|
* @async
|
|
233
233
|
*/
|
|
234
|
-
async checkout(): Promise<
|
|
234
|
+
async checkout(): Promise<this> {
|
|
235
235
|
const response = await this.internalGet("");
|
|
236
236
|
this.data = await response.json();
|
|
237
237
|
return this;
|
|
@@ -243,7 +243,7 @@ export class Assembly {
|
|
|
243
243
|
* @async
|
|
244
244
|
* @param data - Raw assembly data.
|
|
245
245
|
*/
|
|
246
|
-
async update(data: any): Promise<
|
|
246
|
+
async update(data: any): Promise<this> {
|
|
247
247
|
const response = await this.internalPut("", data);
|
|
248
248
|
this.data = await response.json();
|
|
249
249
|
return this;
|
|
@@ -265,13 +265,13 @@ export class Assembly {
|
|
|
265
265
|
*
|
|
266
266
|
* @async
|
|
267
267
|
*/
|
|
268
|
-
save(): Promise<
|
|
268
|
+
save(): Promise<this> {
|
|
269
269
|
return this.update(this.data);
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
// Reserved for future use
|
|
273
273
|
|
|
274
|
-
setPreview(image: BodyInit | null) {
|
|
274
|
+
setPreview(image: BodyInit | null): Promise<this> {
|
|
275
275
|
console.warn("Assembly does not support preview");
|
|
276
276
|
return Promise.resolve(this);
|
|
277
277
|
}
|
|
@@ -320,7 +320,7 @@ export class Assembly {
|
|
|
320
320
|
* @param handle - Model handle.
|
|
321
321
|
* @param transform - Transformation matrix. To delete transformation provide this to `undefined`.
|
|
322
322
|
*/
|
|
323
|
-
setModelTransformMatrix(handle: string, transform: any): Promise<
|
|
323
|
+
setModelTransformMatrix(handle: string, transform: any): Promise<this> {
|
|
324
324
|
const obj = { ...this.data.transform };
|
|
325
325
|
obj[handle] = transform;
|
|
326
326
|
return this.update({ transform: obj });
|
|
@@ -481,7 +481,7 @@ export class Assembly {
|
|
|
481
481
|
|
|
482
482
|
// Reserved for future use
|
|
483
483
|
|
|
484
|
-
getReferences(signal?: AbortSignal) {
|
|
484
|
+
getReferences(signal?: AbortSignal): Promise<any> {
|
|
485
485
|
return Promise.resolve({ fileId: "", references: [] });
|
|
486
486
|
}
|
|
487
487
|
|
|
@@ -498,14 +498,13 @@ export class Assembly {
|
|
|
498
498
|
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
499
499
|
* signal object instance, which can be used to abort waiting as desired.
|
|
500
500
|
* @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
|
|
501
|
-
* @returns {Promise<Assembly>}
|
|
502
501
|
*/
|
|
503
502
|
waitForDone(params?: {
|
|
504
503
|
timeout?: number;
|
|
505
504
|
interval?: number;
|
|
506
505
|
signal?: AbortSignal;
|
|
507
506
|
onCheckout?: (assembly: Assembly, ready: boolean) => boolean;
|
|
508
|
-
}): Promise<
|
|
507
|
+
}): Promise<this> {
|
|
509
508
|
const checkDone = () =>
|
|
510
509
|
this.checkout().then((assembly) => {
|
|
511
510
|
const ready = ["done", "failed"].includes(assembly.status);
|
|
@@ -673,11 +672,11 @@ export class Assembly {
|
|
|
673
672
|
return Promise.reject(new FetchError(404));
|
|
674
673
|
}
|
|
675
674
|
|
|
676
|
-
setActiveVersion(version: number) {
|
|
675
|
+
setActiveVersion(version: number): Promise<this> {
|
|
677
676
|
return this.update({ activeVersion: version });
|
|
678
677
|
}
|
|
679
678
|
|
|
680
|
-
useVersion(version?: number) {
|
|
679
|
+
useVersion(version?: number): this {
|
|
681
680
|
this._useVersion = undefined;
|
|
682
681
|
return this;
|
|
683
682
|
}
|
package/src/Api/ClashTest.ts
CHANGED
|
@@ -44,15 +44,15 @@ export class ClashTest {
|
|
|
44
44
|
this.data = data;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
protected internalGet(relativePath: string): Promise<
|
|
47
|
+
protected internalGet(relativePath: string): Promise<Response> {
|
|
48
48
|
return this.httpClient.get(`${this.basePath}/clashes/${this.id}${relativePath}`);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
protected internalPut(relativePath: string, body?: BodyInit | object): Promise<
|
|
51
|
+
protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response> {
|
|
52
52
|
return this.httpClient.put(`${this.basePath}/clashes/${this.id}${relativePath}`, body);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
protected internalDelete(relativePath: string): Promise<
|
|
55
|
+
protected internalDelete(relativePath: string): Promise<Response> {
|
|
56
56
|
return this.httpClient.delete(`${this.basePath}/clashes/${this.id}${relativePath}`);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -265,7 +265,7 @@ export class ClashTest {
|
|
|
265
265
|
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
266
266
|
* signal object instance, which can be used to abort waiting as desired.
|
|
267
267
|
*/
|
|
268
|
-
waitForDone(params?: { timeout?: number; interval?: number; signal?: AbortSignal }) {
|
|
268
|
+
waitForDone(params?: { timeout?: number; interval?: number; signal?: AbortSignal }): Promise<this> {
|
|
269
269
|
const checkDone = () => this.checkout().then((test) => ["done", "failed"].includes(test.status));
|
|
270
270
|
return waitFor(checkDone, params).then(() => this);
|
|
271
271
|
}
|
package/src/Api/Client.ts
CHANGED
|
@@ -39,12 +39,10 @@ import { parseArgs } from "./Utils";
|
|
|
39
39
|
* Projects, Files, Issues etc.
|
|
40
40
|
*/
|
|
41
41
|
export class Client extends EventEmitter2<ClientEventMap> {
|
|
42
|
-
private _serverUrl
|
|
43
|
-
|
|
44
|
-
private
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
public eventEmitter: EventEmitter2;
|
|
42
|
+
private _serverUrl = "";
|
|
43
|
+
private _httpClient: IHttpClient = new HttpClient("");
|
|
44
|
+
private _user: User | null = null;
|
|
45
|
+
public eventEmitter: EventEmitter2 = this;
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
48
|
* @param params - An object containing client configuration parameters.
|
|
@@ -53,8 +51,6 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
53
51
|
constructor(params: { serverUrl?: string; url?: string } = {}) {
|
|
54
52
|
super();
|
|
55
53
|
this.configure(params);
|
|
56
|
-
this.eventEmitter = this;
|
|
57
|
-
this._user = null;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
/**
|
package/src/Api/Fetch.ts
CHANGED
|
@@ -57,7 +57,7 @@ export function $fetch(
|
|
|
57
57
|
const headers = { ...params.headers };
|
|
58
58
|
delete headers["Content-Type"];
|
|
59
59
|
|
|
60
|
-
let body: FormData | string;
|
|
60
|
+
let body: FormData | string | undefined = undefined;
|
|
61
61
|
if (params.method === "POST" || params.method === "PUT") {
|
|
62
62
|
if (params.body instanceof FormData) {
|
|
63
63
|
body = params.body;
|
package/src/Api/FetchError.ts
CHANGED
|
@@ -91,7 +91,7 @@ export function statusText(status: number): string {
|
|
|
91
91
|
return STATUS_CODES[status] || `Error ${status}`;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function error400(text: string, _default = "400") {
|
|
94
|
+
export function error400(text: string, _default = "400"): string {
|
|
95
95
|
try {
|
|
96
96
|
return JSON.parse(text).description;
|
|
97
97
|
} catch {
|
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
|
}
|
|
@@ -745,7 +745,7 @@ export class File {
|
|
|
745
745
|
* @returns {Promise<File>}
|
|
746
746
|
*/
|
|
747
747
|
waitForDone(
|
|
748
|
-
jobs,
|
|
748
|
+
jobs: string | string[],
|
|
749
749
|
waitAll?: boolean,
|
|
750
750
|
params?: {
|
|
751
751
|
timeout?: number;
|
|
@@ -760,7 +760,7 @@ export class File {
|
|
|
760
760
|
const checkDone = () =>
|
|
761
761
|
this.checkout().then((file) => {
|
|
762
762
|
const readyJobs = jobs.filter((x: string) =>
|
|
763
|
-
["none", "done", "failed"].includes(file.status[x]?.state
|
|
763
|
+
["none", "done", "failed"].includes(file.status[x]?.state || "none")
|
|
764
764
|
);
|
|
765
765
|
const ready = waitAll ? readyJobs.length === jobs.length : readyJobs.length > 0;
|
|
766
766
|
const cancel = params?.onCheckout?.(file, ready);
|
|
@@ -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) {
|