@inweb/client 26.9.3 → 26.9.5
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/README.md +1 -1
- package/dist/client.js +47 -3160
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +24 -1
- package/dist/client.module.js +807 -678
- package/dist/client.module.js.map +1 -1
- package/package.json +2 -2
package/dist/client.module.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { EventEmitter2 } from '@inweb/eventemitter2';
|
|
2
25
|
|
|
3
26
|
class Endpoint {
|
|
4
27
|
constructor(path, httpClient, headers = {}) {
|
|
@@ -7,7 +30,8 @@ class Endpoint {
|
|
|
7
30
|
this.headers = headers;
|
|
8
31
|
}
|
|
9
32
|
appendVersionParam(relativePath) {
|
|
10
|
-
if (this._useVersion === undefined)
|
|
33
|
+
if (this._useVersion === undefined)
|
|
34
|
+
return relativePath;
|
|
11
35
|
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
12
36
|
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
13
37
|
}
|
|
@@ -15,25 +39,16 @@ class Endpoint {
|
|
|
15
39
|
return this.appendVersionParam(`${this.path}${relativePath}`);
|
|
16
40
|
}
|
|
17
41
|
get(relativePath, signal) {
|
|
18
|
-
return this.httpClient.get(this.getEndpointPath(relativePath), {
|
|
19
|
-
signal: signal,
|
|
20
|
-
headers: this.headers
|
|
21
|
-
});
|
|
42
|
+
return this.httpClient.get(this.getEndpointPath(relativePath), { signal, headers: this.headers });
|
|
22
43
|
}
|
|
23
44
|
post(relativePath, body) {
|
|
24
|
-
return this.httpClient.post(this.getEndpointPath(relativePath), body, {
|
|
25
|
-
headers: this.headers
|
|
26
|
-
});
|
|
45
|
+
return this.httpClient.post(this.getEndpointPath(relativePath), body, { headers: this.headers });
|
|
27
46
|
}
|
|
28
47
|
put(relativePath, body) {
|
|
29
|
-
return this.httpClient.put(this.getEndpointPath(relativePath), body, {
|
|
30
|
-
headers: this.headers
|
|
31
|
-
});
|
|
48
|
+
return this.httpClient.put(this.getEndpointPath(relativePath), body, { headers: this.headers });
|
|
32
49
|
}
|
|
33
50
|
delete(relativePath) {
|
|
34
|
-
return this.httpClient.delete(this.getEndpointPath(relativePath), {
|
|
35
|
-
headers: this.headers
|
|
36
|
-
});
|
|
51
|
+
return this.httpClient.delete(this.getEndpointPath(relativePath), { headers: this.headers });
|
|
37
52
|
}
|
|
38
53
|
useVersion(version) {
|
|
39
54
|
this._useVersion = version;
|
|
@@ -104,21 +119,19 @@ const STATUS_CODES = {
|
|
|
104
119
|
508: "Loop Detected",
|
|
105
120
|
509: "Bandwidth Limit Exceeded",
|
|
106
121
|
510: "Not Extended",
|
|
107
|
-
511: "Network Authentication Required"
|
|
122
|
+
511: "Network Authentication Required",
|
|
108
123
|
};
|
|
109
|
-
|
|
110
124
|
function statusText(status) {
|
|
111
125
|
return STATUS_CODES[status] || `Error ${status}`;
|
|
112
126
|
}
|
|
113
|
-
|
|
114
127
|
function error400(text, _default = "400") {
|
|
115
128
|
try {
|
|
116
129
|
return JSON.parse(text).description;
|
|
117
|
-
}
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
118
132
|
return _default;
|
|
119
133
|
}
|
|
120
134
|
}
|
|
121
|
-
|
|
122
135
|
class FetchError extends Error {
|
|
123
136
|
constructor(status, message) {
|
|
124
137
|
super(message || statusText(status));
|
|
@@ -171,7 +184,7 @@ class Model extends Endpoint {
|
|
|
171
184
|
return this.data.version;
|
|
172
185
|
}
|
|
173
186
|
getModels() {
|
|
174
|
-
return Promise.resolve([
|
|
187
|
+
return Promise.resolve([this]);
|
|
175
188
|
}
|
|
176
189
|
getModelTransformMatrix(handle) {
|
|
177
190
|
return this.file.getModelTransformMatrix(handle);
|
|
@@ -180,16 +193,14 @@ class Model extends Endpoint {
|
|
|
180
193
|
return this.file.setModelTransformMatrix(handle, transform).then(() => this);
|
|
181
194
|
}
|
|
182
195
|
getViewpoints() {
|
|
183
|
-
return this._file
|
|
196
|
+
return this._file
|
|
197
|
+
.getViewpoints()
|
|
198
|
+
.then((array) => array.filter(({ custom_fields = {} }) => custom_fields.modelId === this.id || custom_fields.modelName === this.name));
|
|
184
199
|
}
|
|
185
200
|
saveViewpoint(viewpoint) {
|
|
186
201
|
return this._file.saveViewpoint({
|
|
187
202
|
...viewpoint,
|
|
188
|
-
custom_fields: {
|
|
189
|
-
...viewpoint.custom_fields,
|
|
190
|
-
modelId: this.id,
|
|
191
|
-
modelName: this.name
|
|
192
|
-
}
|
|
203
|
+
custom_fields: { ...viewpoint.custom_fields, modelId: this.id, modelName: this.name },
|
|
193
204
|
});
|
|
194
205
|
}
|
|
195
206
|
deleteViewpoint(guid) {
|
|
@@ -212,22 +223,20 @@ class Model extends Endpoint {
|
|
|
212
223
|
return this.downloadResource(dataId, onProgress, signal);
|
|
213
224
|
}
|
|
214
225
|
async downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
215
|
-
if (!records)
|
|
226
|
+
if (!records)
|
|
227
|
+
return;
|
|
216
228
|
let ranges = [];
|
|
217
229
|
if (records.length) {
|
|
218
|
-
ranges = records.map(record => ({
|
|
230
|
+
ranges = records.map((record) => ({
|
|
219
231
|
begin: Number(record.begin),
|
|
220
232
|
end: Number(record.end),
|
|
221
|
-
requestId: record.reqId
|
|
233
|
+
requestId: record.reqId,
|
|
222
234
|
}));
|
|
223
|
-
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
224
237
|
for (let i = 0; i < records.size(); i++) {
|
|
225
238
|
const record = records.get(i);
|
|
226
|
-
ranges.push({
|
|
227
|
-
begin: Number(record.begin),
|
|
228
|
-
end: Number(record.end),
|
|
229
|
-
requestId: requestId
|
|
230
|
-
});
|
|
239
|
+
ranges.push({ begin: Number(record.begin), end: Number(record.end), requestId });
|
|
231
240
|
record.delete();
|
|
232
241
|
}
|
|
233
242
|
}
|
|
@@ -239,7 +248,7 @@ class Model extends Endpoint {
|
|
|
239
248
|
}
|
|
240
249
|
|
|
241
250
|
function delay(ms, signal) {
|
|
242
|
-
return new Promise(resolve => {
|
|
251
|
+
return new Promise((resolve) => {
|
|
243
252
|
let timeoutId = 0;
|
|
244
253
|
const abortHandler = () => {
|
|
245
254
|
clearTimeout(timeoutId);
|
|
@@ -249,38 +258,43 @@ function delay(ms, signal) {
|
|
|
249
258
|
signal.removeEventListener("abort", abortHandler);
|
|
250
259
|
resolve(false);
|
|
251
260
|
}, ms);
|
|
252
|
-
signal.addEventListener("abort", abortHandler, {
|
|
253
|
-
once: true
|
|
254
|
-
});
|
|
261
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
255
262
|
});
|
|
256
263
|
}
|
|
257
|
-
|
|
258
264
|
async function waitFor(func, params = {}) {
|
|
259
265
|
var _a, _b, _c;
|
|
260
|
-
const timeout = params.timeout ||
|
|
261
|
-
const interval = params.interval ||
|
|
262
|
-
const signal = (_a = params.signal) !== null && _a !== void 0 ? _a :
|
|
266
|
+
const timeout = params.timeout || 600000;
|
|
267
|
+
const interval = params.interval || 3000;
|
|
268
|
+
const signal = (_a = params.signal) !== null && _a !== void 0 ? _a : new AbortController().signal;
|
|
263
269
|
const abortError = (_b = params.abortError) !== null && _b !== void 0 ? _b : new DOMException("Aborted", "AbortError");
|
|
264
270
|
const timeoutError = (_c = params.timeoutError) !== null && _c !== void 0 ? _c : new DOMException("Timeout", "TimeoutError");
|
|
265
271
|
const end = performance.now() + timeout;
|
|
266
272
|
let count = timeout / interval;
|
|
267
273
|
do {
|
|
268
|
-
if (await func(params))
|
|
269
|
-
|
|
274
|
+
if (await func(params))
|
|
275
|
+
return Promise.resolve(params.result);
|
|
276
|
+
if ((await delay(interval, signal)) || signal.aborted)
|
|
277
|
+
return Promise.reject(abortError);
|
|
270
278
|
} while (performance.now() < end && --count > 0);
|
|
271
279
|
return Promise.reject(timeoutError);
|
|
272
280
|
}
|
|
273
|
-
|
|
274
281
|
function parseArgs(args) {
|
|
275
282
|
if (typeof args === "string") {
|
|
276
283
|
const firstArg = args.indexOf("--");
|
|
277
|
-
if (firstArg !== -1)
|
|
278
|
-
|
|
284
|
+
if (firstArg !== -1)
|
|
285
|
+
args = args.slice(firstArg);
|
|
286
|
+
const argArray = args
|
|
287
|
+
.split("--")
|
|
288
|
+
.map((x) => x
|
|
289
|
+
.split("=")
|
|
290
|
+
.map((y) => y.split(" "))
|
|
291
|
+
.flat())
|
|
292
|
+
.filter((x) => x[0])
|
|
293
|
+
.map((x) => x.concat([""]));
|
|
279
294
|
return Object.fromEntries(argArray);
|
|
280
295
|
}
|
|
281
296
|
return args || {};
|
|
282
297
|
}
|
|
283
|
-
|
|
284
298
|
function userFullName(firstName, lastName = "", userName = "") {
|
|
285
299
|
var _a;
|
|
286
300
|
if (firstName && typeof firstName !== "string") {
|
|
@@ -288,13 +302,15 @@ function userFullName(firstName, lastName = "", userName = "") {
|
|
|
288
302
|
}
|
|
289
303
|
return `${firstName !== null && firstName !== void 0 ? firstName : ""} ${lastName !== null && lastName !== void 0 ? lastName : ""}`.trim() || userName;
|
|
290
304
|
}
|
|
291
|
-
|
|
292
305
|
function userInitials(fullName = "") {
|
|
293
|
-
const names = fullName.split(" ").filter(x => x);
|
|
294
|
-
return names
|
|
295
|
-
|
|
306
|
+
const names = fullName.split(" ").filter((x) => x);
|
|
307
|
+
return names
|
|
308
|
+
.reduce((initials, name, index) => {
|
|
309
|
+
if (index === 0 || index === names.length - 1)
|
|
310
|
+
initials += name.charAt(0);
|
|
296
311
|
return initials;
|
|
297
|
-
}, "")
|
|
312
|
+
}, "")
|
|
313
|
+
.toUpperCase();
|
|
298
314
|
}
|
|
299
315
|
|
|
300
316
|
class ClashTest extends Endpoint {
|
|
@@ -361,22 +377,22 @@ class ClashTest extends Endpoint {
|
|
|
361
377
|
return this;
|
|
362
378
|
}
|
|
363
379
|
delete() {
|
|
364
|
-
return super.delete("").then(response => response.json());
|
|
380
|
+
return super.delete("").then((response) => response.json());
|
|
365
381
|
}
|
|
366
382
|
save() {
|
|
367
383
|
return this.update(this.data);
|
|
368
384
|
}
|
|
369
385
|
waitForDone(params) {
|
|
370
|
-
const checkDone = () => this.checkout().then(test => {
|
|
386
|
+
const checkDone = () => this.checkout().then((test) => {
|
|
371
387
|
var _a;
|
|
372
|
-
const ready = [
|
|
388
|
+
const ready = ["done", "failed"].includes(test.status);
|
|
373
389
|
const cancel = (_a = params === null || params === void 0 ? void 0 : params.onCheckout) === null || _a === void 0 ? void 0 : _a.call(params, test, ready);
|
|
374
390
|
return cancel || ready;
|
|
375
391
|
});
|
|
376
392
|
return waitFor(checkDone, params).then(() => this);
|
|
377
393
|
}
|
|
378
394
|
getReport() {
|
|
379
|
-
return this.get("/report").then(response => response.json());
|
|
395
|
+
return this.get("/report").then((response) => response.json());
|
|
380
396
|
}
|
|
381
397
|
}
|
|
382
398
|
|
|
@@ -404,8 +420,8 @@ class Assembly extends Endpoint {
|
|
|
404
420
|
this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
|
|
405
421
|
this._data.owner.fullName = userFullName(this._data.owner);
|
|
406
422
|
this._data.owner.initials = userInitials(this._data.owner.fullName);
|
|
407
|
-
(_a = (_b = this._data).associatedFiles) !== null && _a !== void 0 ? _a : _b.associatedFiles = [];
|
|
408
|
-
this._data.associatedFiles.forEach(file => file.link = `${this.httpClient.serverUrl}/files/${file.fileId}`);
|
|
423
|
+
(_a = (_b = this._data).associatedFiles) !== null && _a !== void 0 ? _a : (_b.associatedFiles = []);
|
|
424
|
+
this._data.associatedFiles.forEach((file) => (file.link = `${this.httpClient.serverUrl}/files/${file.fileId}`));
|
|
409
425
|
}
|
|
410
426
|
get files() {
|
|
411
427
|
return this.data.files;
|
|
@@ -457,7 +473,7 @@ class Assembly extends Endpoint {
|
|
|
457
473
|
return this;
|
|
458
474
|
}
|
|
459
475
|
delete() {
|
|
460
|
-
return super.delete("").then(response => response.json());
|
|
476
|
+
return super.delete("").then((response) => response.json());
|
|
461
477
|
}
|
|
462
478
|
save() {
|
|
463
479
|
return this.update(this.data);
|
|
@@ -471,64 +487,67 @@ class Assembly extends Endpoint {
|
|
|
471
487
|
return Promise.resolve(this);
|
|
472
488
|
}
|
|
473
489
|
getModels() {
|
|
474
|
-
return this.get("/geometry")
|
|
490
|
+
return this.get("/geometry")
|
|
491
|
+
.then((response) => response.json())
|
|
492
|
+
.then((array) => array.map((data) => new Model(data, this)));
|
|
475
493
|
}
|
|
476
494
|
getModelTransformMatrix(handle) {
|
|
477
495
|
return this.data.transform[handle];
|
|
478
496
|
}
|
|
479
497
|
setModelTransformMatrix(handle, transform) {
|
|
480
|
-
const obj = {
|
|
481
|
-
...this.data.transform
|
|
482
|
-
};
|
|
498
|
+
const obj = { ...this.data.transform };
|
|
483
499
|
obj[handle] = transform;
|
|
484
|
-
return this.update({
|
|
485
|
-
transform: obj
|
|
486
|
-
});
|
|
500
|
+
return this.update({ transform: obj });
|
|
487
501
|
}
|
|
488
502
|
getProperties(handles, group = false) {
|
|
489
|
-
const searchParams = new URLSearchParams;
|
|
503
|
+
const searchParams = new URLSearchParams();
|
|
490
504
|
if (handles) {
|
|
491
|
-
if (Array.isArray(handles))
|
|
492
|
-
|
|
493
|
-
if (handles
|
|
505
|
+
if (Array.isArray(handles))
|
|
506
|
+
handles = handles.join(",");
|
|
507
|
+
if (typeof handles === "string")
|
|
508
|
+
handles = handles.trim();
|
|
509
|
+
if (handles)
|
|
510
|
+
searchParams.set("handles", handles);
|
|
494
511
|
}
|
|
495
|
-
if (group)
|
|
512
|
+
if (group)
|
|
513
|
+
searchParams.set("group", "true");
|
|
496
514
|
let queryString = searchParams.toString();
|
|
497
|
-
if (queryString)
|
|
498
|
-
|
|
515
|
+
if (queryString)
|
|
516
|
+
queryString = "?" + queryString;
|
|
517
|
+
return this.get(`/properties${queryString}`).then((response) => response.json());
|
|
499
518
|
}
|
|
500
519
|
searchProperties(searchPattern) {
|
|
501
|
-
return this.post("/properties/search", searchPattern).then(response => response.json());
|
|
520
|
+
return this.post("/properties/search", searchPattern).then((response) => response.json());
|
|
502
521
|
}
|
|
503
522
|
getCdaTree() {
|
|
504
|
-
return this.get(`/properties/tree`).then(response => response.json());
|
|
523
|
+
return this.get(`/properties/tree`).then((response) => response.json());
|
|
505
524
|
}
|
|
506
525
|
getViewpoints() {
|
|
507
|
-
return this.get("/viewpoints")
|
|
526
|
+
return this.get("/viewpoints")
|
|
527
|
+
.then((response) => response.json())
|
|
528
|
+
.then((viewpoints) => viewpoints.result);
|
|
508
529
|
}
|
|
509
530
|
saveViewpoint(viewpoint) {
|
|
510
|
-
return this.post("/viewpoints", viewpoint).then(response => response.json());
|
|
531
|
+
return this.post("/viewpoints", viewpoint).then((response) => response.json());
|
|
511
532
|
}
|
|
512
533
|
deleteViewpoint(guid) {
|
|
513
|
-
return super.delete(`/viewpoints/${guid}`).then(response => response.json());
|
|
534
|
+
return super.delete(`/viewpoints/${guid}`).then((response) => response.json());
|
|
514
535
|
}
|
|
515
536
|
getSnapshot(guid) {
|
|
516
|
-
return this.get(`/viewpoints/${guid}/snapshot`).then(response => response.text());
|
|
537
|
+
return this.get(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
|
|
517
538
|
}
|
|
518
539
|
getSnapshotData(guid, bitmapGuid) {
|
|
519
|
-
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then(response => response.text());
|
|
540
|
+
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
|
|
520
541
|
}
|
|
521
542
|
downloadResource(dataId, onProgress, signal) {
|
|
522
|
-
return this.httpClient
|
|
523
|
-
signal:
|
|
524
|
-
|
|
525
|
-
}).then(response => response.arrayBuffer());
|
|
543
|
+
return this.httpClient
|
|
544
|
+
.downloadFile(this.getEndpointPath(`/downloads/${dataId}`), onProgress, { signal, headers: this.headers })
|
|
545
|
+
.then((response) => response.arrayBuffer());
|
|
526
546
|
}
|
|
527
547
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
528
|
-
return this.httpClient
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}).then(response => response.arrayBuffer());
|
|
548
|
+
return this.httpClient
|
|
549
|
+
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}${requestId ? "?requestId=" + requestId : ""}`), requestId, ranges, onProgress, { signal, headers: this.headers })
|
|
550
|
+
.then((response) => response.arrayBuffer());
|
|
532
551
|
}
|
|
533
552
|
partialDownloadResource(dataId, onProgress, signal) {
|
|
534
553
|
console.warn("Assembly.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Assembly.downloadResource() instead.");
|
|
@@ -539,62 +558,84 @@ class Assembly extends Endpoint {
|
|
|
539
558
|
}
|
|
540
559
|
async getReferences(signal) {
|
|
541
560
|
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
542
|
-
const references = await Promise.all(this.associatedFiles
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
references
|
|
546
|
-
|
|
561
|
+
const references = await Promise.all(this.associatedFiles
|
|
562
|
+
.map((file) => `/${file.fileId}/references`)
|
|
563
|
+
.map((link) => files.get(link, signal).then((response) => response.json())))
|
|
564
|
+
.then((references) => references.map((x) => x.references))
|
|
565
|
+
.then((references) => references.reduce((x, v) => [...v, ...x], []))
|
|
566
|
+
.then((references) => [...new Set(references.map(JSON.stringify))].map((x) => JSON.parse(x)));
|
|
567
|
+
return { id: "", references };
|
|
547
568
|
}
|
|
548
569
|
waitForDone(params) {
|
|
549
|
-
const checkDone = () => this.checkout().then(assembly => {
|
|
570
|
+
const checkDone = () => this.checkout().then((assembly) => {
|
|
550
571
|
var _a;
|
|
551
|
-
const ready = [
|
|
572
|
+
const ready = ["done", "failed"].includes(assembly.status);
|
|
552
573
|
const cancel = (_a = params === null || params === void 0 ? void 0 : params.onCheckout) === null || _a === void 0 ? void 0 : _a.call(params, assembly, ready);
|
|
553
574
|
return cancel || ready;
|
|
554
575
|
});
|
|
555
576
|
return waitFor(checkDone, params).then(() => this);
|
|
556
577
|
}
|
|
557
578
|
getClashTests(start, limit, name, ids, sortByDesc, sortField) {
|
|
558
|
-
const searchParams = new URLSearchParams;
|
|
559
|
-
if (start > 0)
|
|
560
|
-
|
|
561
|
-
if (
|
|
579
|
+
const searchParams = new URLSearchParams();
|
|
580
|
+
if (start > 0)
|
|
581
|
+
searchParams.set("start", start.toString());
|
|
582
|
+
if (limit > 0)
|
|
583
|
+
searchParams.set("limit", limit.toString());
|
|
584
|
+
if (name)
|
|
585
|
+
searchParams.set("name", name);
|
|
562
586
|
if (ids) {
|
|
563
|
-
if (Array.isArray(ids))
|
|
564
|
-
|
|
565
|
-
if (ids
|
|
587
|
+
if (Array.isArray(ids))
|
|
588
|
+
ids = ids.join("|");
|
|
589
|
+
if (typeof ids === "string")
|
|
590
|
+
ids = ids.trim();
|
|
591
|
+
if (ids)
|
|
592
|
+
searchParams.set("id", ids);
|
|
566
593
|
}
|
|
567
|
-
if (sortByDesc !== undefined)
|
|
568
|
-
|
|
594
|
+
if (sortByDesc !== undefined)
|
|
595
|
+
searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
596
|
+
if (sortField)
|
|
597
|
+
searchParams.set("sortField", sortField);
|
|
569
598
|
let queryString = searchParams.toString();
|
|
570
|
-
if (queryString)
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
599
|
+
if (queryString)
|
|
600
|
+
queryString = "?" + queryString;
|
|
601
|
+
return this.get(`/clashes${queryString}`)
|
|
602
|
+
.then((response) => response.json())
|
|
603
|
+
.then((tests) => {
|
|
604
|
+
return {
|
|
605
|
+
...tests,
|
|
606
|
+
result: tests.result.map((data) => new ClashTest(data, this.path, this.httpClient)),
|
|
607
|
+
};
|
|
608
|
+
});
|
|
575
609
|
}
|
|
576
610
|
getClashTest(testId) {
|
|
577
|
-
return this.get(`/clashes/${testId}`)
|
|
611
|
+
return this.get(`/clashes/${testId}`)
|
|
612
|
+
.then((response) => response.json())
|
|
613
|
+
.then((data) => new ClashTest(data, this.path, this.httpClient));
|
|
578
614
|
}
|
|
579
615
|
createClashTest(name, selectionTypeA, selectionTypeB, selectionSetA, selectionSetB, params) {
|
|
580
|
-
const {
|
|
581
|
-
if (!Array.isArray(selectionSetA))
|
|
582
|
-
|
|
616
|
+
const { tolerance, clearance, waitForDone } = params !== null && params !== void 0 ? params : {};
|
|
617
|
+
if (!Array.isArray(selectionSetA))
|
|
618
|
+
selectionSetA = [selectionSetA];
|
|
619
|
+
if (!Array.isArray(selectionSetB))
|
|
620
|
+
selectionSetB = [selectionSetB];
|
|
583
621
|
return this.post("/clashes", {
|
|
584
|
-
name
|
|
585
|
-
selectionTypeA
|
|
586
|
-
selectionTypeB
|
|
587
|
-
selectionSetA
|
|
588
|
-
selectionSetB
|
|
589
|
-
tolerance
|
|
590
|
-
clearance
|
|
591
|
-
})
|
|
622
|
+
name,
|
|
623
|
+
selectionTypeA,
|
|
624
|
+
selectionTypeB,
|
|
625
|
+
selectionSetA,
|
|
626
|
+
selectionSetB,
|
|
627
|
+
tolerance,
|
|
628
|
+
clearance,
|
|
629
|
+
})
|
|
630
|
+
.then((response) => response.json())
|
|
631
|
+
.then((data) => new ClashTest(data, this.path, this.httpClient))
|
|
632
|
+
.then((result) => (waitForDone ? result.waitForDone(params) : result));
|
|
592
633
|
}
|
|
593
634
|
deleteClashTest(testId) {
|
|
594
|
-
return super.delete(`/clashes/${testId}`).then(response => response.json());
|
|
635
|
+
return super.delete(`/clashes/${testId}`).then((response) => response.json());
|
|
595
636
|
}
|
|
596
637
|
updateVersion(files, params = {
|
|
597
|
-
waitForDone: false
|
|
638
|
+
waitForDone: false,
|
|
598
639
|
}) {
|
|
599
640
|
return Promise.reject(new Error("Assembly version support will be implemeted in a future release"));
|
|
600
641
|
}
|
|
@@ -608,9 +649,7 @@ class Assembly extends Endpoint {
|
|
|
608
649
|
return Promise.reject(new FetchError(404));
|
|
609
650
|
}
|
|
610
651
|
setActiveVersion(version) {
|
|
611
|
-
return this.update({
|
|
612
|
-
activeVersion: version
|
|
613
|
-
});
|
|
652
|
+
return this.update({ activeVersion: version });
|
|
614
653
|
}
|
|
615
654
|
createSharedLink(permissions) {
|
|
616
655
|
return Promise.reject(new Error("Assembly shared link will be implemeted in a future release"));
|
|
@@ -626,60 +665,53 @@ class Assembly extends Endpoint {
|
|
|
626
665
|
function handleFetchError(response) {
|
|
627
666
|
if (!response.ok) {
|
|
628
667
|
switch (response.status) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return response.text().then(text => {
|
|
668
|
+
case 400: {
|
|
669
|
+
return response.text().then((text) => {
|
|
632
670
|
console.error(text);
|
|
633
671
|
return Promise.reject(new FetchError(400, error400(text)));
|
|
634
672
|
});
|
|
635
673
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
{
|
|
639
|
-
return response.text().then(text => {
|
|
674
|
+
case 500: {
|
|
675
|
+
return response.text().then((text) => {
|
|
640
676
|
console.error(error400(text, text));
|
|
641
677
|
return Promise.reject(new FetchError(500));
|
|
642
678
|
});
|
|
643
679
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return Promise.reject(new FetchError(response.status));
|
|
680
|
+
default:
|
|
681
|
+
return Promise.reject(new FetchError(response.status));
|
|
647
682
|
}
|
|
648
683
|
}
|
|
649
684
|
return Promise.resolve(response);
|
|
650
685
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
method: "GET"
|
|
654
|
-
}) {
|
|
655
|
-
const headers = {
|
|
656
|
-
...init.headers
|
|
657
|
-
};
|
|
686
|
+
function $fetch(url, init = { method: "GET" }) {
|
|
687
|
+
const headers = { ...init.headers };
|
|
658
688
|
delete headers["Content-Type"];
|
|
659
|
-
Object.keys(headers)
|
|
689
|
+
Object.keys(headers)
|
|
690
|
+
.filter((x) => headers[x] === undefined)
|
|
691
|
+
.forEach((x) => delete headers[x]);
|
|
660
692
|
let body = undefined;
|
|
661
693
|
if (init.method === "POST" || init.method === "PUT") {
|
|
662
694
|
if (init.body instanceof FormData) {
|
|
663
695
|
body = init.body;
|
|
664
|
-
}
|
|
665
|
-
|
|
696
|
+
}
|
|
697
|
+
else if (init.body instanceof Blob) {
|
|
698
|
+
body = new FormData();
|
|
666
699
|
body.append("file", init.body);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
body
|
|
670
|
-
|
|
700
|
+
}
|
|
701
|
+
else if (init.body instanceof ArrayBuffer) {
|
|
702
|
+
body = new FormData();
|
|
703
|
+
body.append("file", new Blob([init.body]));
|
|
704
|
+
}
|
|
705
|
+
else if (typeof init.body === "object") {
|
|
671
706
|
body = JSON.stringify(init.body);
|
|
672
707
|
headers["Content-Type"] = "application/json";
|
|
673
|
-
}
|
|
708
|
+
}
|
|
709
|
+
else if (typeof init.body === "string") {
|
|
674
710
|
body = init.body;
|
|
675
711
|
headers["Content-Type"] = "text/plain";
|
|
676
712
|
}
|
|
677
713
|
}
|
|
678
|
-
return fetch(url, {
|
|
679
|
-
...init,
|
|
680
|
-
headers: headers,
|
|
681
|
-
body: body
|
|
682
|
-
}).then(handleFetchError);
|
|
714
|
+
return fetch(url, { ...init, headers, body }).then(handleFetchError);
|
|
683
715
|
}
|
|
684
716
|
|
|
685
717
|
function handleXMLHttpError(xhr) {
|
|
@@ -688,32 +720,24 @@ function handleXMLHttpError(xhr) {
|
|
|
688
720
|
}
|
|
689
721
|
if (xhr.status < 200 || xhr.status > 299) {
|
|
690
722
|
switch (xhr.status) {
|
|
691
|
-
|
|
692
|
-
{
|
|
723
|
+
case 400: {
|
|
693
724
|
console.error(xhr.responseText);
|
|
694
725
|
return Promise.reject(new FetchError(400, error400(xhr.responseText)));
|
|
695
726
|
}
|
|
696
|
-
|
|
697
|
-
case 500:
|
|
698
|
-
{
|
|
727
|
+
case 500: {
|
|
699
728
|
console.error(error400(xhr.responseText, xhr.responseText));
|
|
700
729
|
return Promise.reject(new FetchError(500));
|
|
701
730
|
}
|
|
702
|
-
|
|
703
|
-
default:
|
|
704
|
-
{
|
|
731
|
+
default: {
|
|
705
732
|
return Promise.reject(new FetchError(xhr.status));
|
|
706
733
|
}
|
|
707
734
|
}
|
|
708
735
|
}
|
|
709
736
|
return Promise.resolve(xhr);
|
|
710
737
|
}
|
|
711
|
-
|
|
712
|
-
function $xmlhttp(url, params = {
|
|
713
|
-
method: "GET"
|
|
714
|
-
}) {
|
|
738
|
+
function $xmlhttp(url, params = { method: "GET" }) {
|
|
715
739
|
return new Promise((resolve, reject) => {
|
|
716
|
-
const xhr = new XMLHttpRequest;
|
|
740
|
+
const xhr = new XMLHttpRequest();
|
|
717
741
|
xhr.open(params.method, url, true);
|
|
718
742
|
for (const key in params.headers) {
|
|
719
743
|
xhr.setRequestHeader(key, params.headers[key]);
|
|
@@ -721,9 +745,9 @@ function $xmlhttp(url, params = {
|
|
|
721
745
|
function calcProgress(event) {
|
|
722
746
|
return event.lengthComputable ? event.loaded / event.total : 1;
|
|
723
747
|
}
|
|
724
|
-
xhr.upload.onprogress = event => params.uploadProgress && params.uploadProgress(calcProgress(event));
|
|
725
|
-
xhr.onprogress = event => params.downloadProgress && params.downloadProgress(calcProgress(event));
|
|
726
|
-
xhr.onloadend = event => handleXMLHttpError(event.target).then(resolve, reject);
|
|
748
|
+
xhr.upload.onprogress = (event) => params.uploadProgress && params.uploadProgress(calcProgress(event));
|
|
749
|
+
xhr.onprogress = (event) => params.downloadProgress && params.downloadProgress(calcProgress(event));
|
|
750
|
+
xhr.onloadend = (event) => handleXMLHttpError(event.target).then(resolve, reject);
|
|
727
751
|
xhr.send(params.body);
|
|
728
752
|
});
|
|
729
753
|
}
|
|
@@ -739,60 +763,46 @@ class HttpClient {
|
|
|
739
763
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
740
764
|
...init,
|
|
741
765
|
method: "GET",
|
|
742
|
-
headers: {
|
|
743
|
-
...this.headers,
|
|
744
|
-
...init.headers
|
|
745
|
-
}
|
|
766
|
+
headers: { ...this.headers, ...init.headers },
|
|
746
767
|
});
|
|
747
768
|
}
|
|
748
769
|
post(relativePath, body, init = {}) {
|
|
749
770
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
750
771
|
...init,
|
|
751
772
|
method: "POST",
|
|
752
|
-
headers: {
|
|
753
|
-
|
|
754
|
-
...init.headers
|
|
755
|
-
},
|
|
756
|
-
body: body
|
|
773
|
+
headers: { ...this.headers, ...init.headers },
|
|
774
|
+
body,
|
|
757
775
|
});
|
|
758
776
|
}
|
|
759
777
|
put(relativePath, body, init = {}) {
|
|
760
778
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
761
779
|
...init,
|
|
762
780
|
method: "PUT",
|
|
763
|
-
headers: {
|
|
764
|
-
|
|
765
|
-
...init.headers
|
|
766
|
-
},
|
|
767
|
-
body: body
|
|
781
|
+
headers: { ...this.headers, ...init.headers },
|
|
782
|
+
body,
|
|
768
783
|
});
|
|
769
784
|
}
|
|
770
785
|
delete(relativePath, init = {}) {
|
|
771
786
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
772
787
|
...init,
|
|
773
788
|
method: "DELETE",
|
|
774
|
-
headers: {
|
|
775
|
-
...this.headers,
|
|
776
|
-
...init.headers
|
|
777
|
-
}
|
|
789
|
+
headers: { ...this.headers, ...init.headers },
|
|
778
790
|
});
|
|
779
791
|
}
|
|
780
792
|
uploadFile(relativePath, file, onProgress, init = {}) {
|
|
781
|
-
const data = new FormData;
|
|
793
|
+
const data = new FormData();
|
|
782
794
|
data.append("file", file);
|
|
783
795
|
return $xmlhttp(`${this.serverUrl}${relativePath}`, {
|
|
784
796
|
method: "POST",
|
|
785
|
-
headers: {
|
|
786
|
-
...this.headers,
|
|
787
|
-
...init.headers
|
|
788
|
-
},
|
|
797
|
+
headers: { ...this.headers, ...init.headers },
|
|
789
798
|
body: data,
|
|
790
|
-
uploadProgress: onProgress
|
|
799
|
+
uploadProgress: onProgress,
|
|
791
800
|
});
|
|
792
801
|
}
|
|
793
802
|
async downloadFile(relativePath, onProgress, init = {}) {
|
|
794
803
|
const response = await this.get(relativePath, init);
|
|
795
|
-
if (!onProgress)
|
|
804
|
+
if (!onProgress)
|
|
805
|
+
return response;
|
|
796
806
|
const contentLength = response.headers.get("Content-Length");
|
|
797
807
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
798
808
|
const stream = new ReadableStream({
|
|
@@ -800,27 +810,26 @@ class HttpClient {
|
|
|
800
810
|
const reader = response.body.getReader();
|
|
801
811
|
let loaded = 0;
|
|
802
812
|
while (true) {
|
|
803
|
-
const {
|
|
804
|
-
if (done)
|
|
813
|
+
const { done, value } = await reader.read();
|
|
814
|
+
if (done)
|
|
815
|
+
break;
|
|
805
816
|
controller.enqueue(value);
|
|
806
817
|
loaded += value.length;
|
|
807
818
|
onProgress(loaded / total, value);
|
|
808
819
|
}
|
|
809
820
|
controller.close();
|
|
810
|
-
}
|
|
821
|
+
},
|
|
811
822
|
});
|
|
812
823
|
return new Response(stream);
|
|
813
824
|
}
|
|
814
825
|
async downloadFileRange(relativePath, reserved, ranges, onProgress, init = {}) {
|
|
815
826
|
const headers = {
|
|
816
827
|
...init.headers,
|
|
817
|
-
Range: "bytes=" + ranges.map(x => `${x.begin}-${x.end}`).join(",")
|
|
828
|
+
Range: "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(","),
|
|
818
829
|
};
|
|
819
|
-
const response = await this.get(relativePath, {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
});
|
|
823
|
-
if (!onProgress) return response;
|
|
830
|
+
const response = await this.get(relativePath, { ...init, headers });
|
|
831
|
+
if (!onProgress)
|
|
832
|
+
return response;
|
|
824
833
|
const contentLength = response.headers.get("content-length");
|
|
825
834
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
826
835
|
const stream = new ReadableStream({
|
|
@@ -830,8 +839,9 @@ class HttpClient {
|
|
|
830
839
|
let rangedIndex = 0;
|
|
831
840
|
let rangePos = 0;
|
|
832
841
|
while (true) {
|
|
833
|
-
const {
|
|
834
|
-
if (done)
|
|
842
|
+
const { done, value } = await reader.read();
|
|
843
|
+
if (done)
|
|
844
|
+
break;
|
|
835
845
|
controller.enqueue(value);
|
|
836
846
|
loaded += value.length;
|
|
837
847
|
let chunkLeft = value.length;
|
|
@@ -844,7 +854,8 @@ class HttpClient {
|
|
|
844
854
|
onProgress(loaded / total, chunk, range.requestId);
|
|
845
855
|
rangePos += chunkLeft;
|
|
846
856
|
chunkLeft = 0;
|
|
847
|
-
}
|
|
857
|
+
}
|
|
858
|
+
else {
|
|
848
859
|
const chunk = value.subarray(chunkPos, chunkPos + rangeLeft);
|
|
849
860
|
onProgress(loaded / total, chunk, range.requestId);
|
|
850
861
|
chunkPos += rangeLeft;
|
|
@@ -855,7 +866,7 @@ class HttpClient {
|
|
|
855
866
|
}
|
|
856
867
|
}
|
|
857
868
|
controller.close();
|
|
858
|
-
}
|
|
869
|
+
},
|
|
859
870
|
});
|
|
860
871
|
return new Response(stream);
|
|
861
872
|
}
|
|
@@ -904,7 +915,7 @@ class Permission extends Endpoint {
|
|
|
904
915
|
return this;
|
|
905
916
|
}
|
|
906
917
|
delete() {
|
|
907
|
-
return super.delete("").then(response => response.json());
|
|
918
|
+
return super.delete("").then((response) => response.json());
|
|
908
919
|
}
|
|
909
920
|
save() {
|
|
910
921
|
return this.update(this.data);
|
|
@@ -969,12 +980,12 @@ class Job extends Endpoint {
|
|
|
969
980
|
return this;
|
|
970
981
|
}
|
|
971
982
|
delete() {
|
|
972
|
-
return super.delete("").then(response => response.json());
|
|
983
|
+
return super.delete("").then((response) => response.json());
|
|
973
984
|
}
|
|
974
985
|
waitForDone(params) {
|
|
975
|
-
const checkDone = () => this.checkout().then(job => {
|
|
986
|
+
const checkDone = () => this.checkout().then((job) => {
|
|
976
987
|
var _a;
|
|
977
|
-
const ready = [
|
|
988
|
+
const ready = ["done", "failed"].includes(job.status);
|
|
978
989
|
const cancel = (_a = params === null || params === void 0 ? void 0 : params.onCheckout) === null || _a === void 0 ? void 0 : _a.call(params, job, ready);
|
|
979
990
|
return cancel || ready;
|
|
980
991
|
});
|
|
@@ -1000,10 +1011,7 @@ class SharedLink extends Endpoint {
|
|
|
1000
1011
|
return this.data.permissions;
|
|
1001
1012
|
}
|
|
1002
1013
|
set permissions(value) {
|
|
1003
|
-
this.data.permissions = {
|
|
1004
|
-
...this.data.permissions,
|
|
1005
|
-
...value
|
|
1006
|
-
};
|
|
1014
|
+
this.data.permissions = { ...this.data.permissions, ...value };
|
|
1007
1015
|
}
|
|
1008
1016
|
get token() {
|
|
1009
1017
|
return this.data.token;
|
|
@@ -1022,7 +1030,7 @@ class SharedLink extends Endpoint {
|
|
|
1022
1030
|
return this;
|
|
1023
1031
|
}
|
|
1024
1032
|
delete() {
|
|
1025
|
-
return super.delete("").then(response => response.json());
|
|
1033
|
+
return super.delete("").then((response) => response.json());
|
|
1026
1034
|
}
|
|
1027
1035
|
save() {
|
|
1028
1036
|
return this.update(this.data);
|
|
@@ -1053,42 +1061,38 @@ class File extends Endpoint {
|
|
|
1053
1061
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1054
1062
|
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
1055
1063
|
this._data = value;
|
|
1056
|
-
this._data.previewUrl = value.preview
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1064
|
+
this._data.previewUrl = value.preview
|
|
1065
|
+
? `${this.httpClient.serverUrl}${this.path}/preview?updated=${value.updatedAt}`
|
|
1066
|
+
: "";
|
|
1067
|
+
if (typeof this._data.owner === "string")
|
|
1068
|
+
this._data.owner = { userId: this._data.owner };
|
|
1069
|
+
(_a = (_p = this._data).owner) !== null && _a !== void 0 ? _a : (_p.owner = {});
|
|
1061
1070
|
this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
|
|
1062
1071
|
this._data.owner.fullName = userFullName(this._data.owner);
|
|
1063
1072
|
this._data.owner.initials = userInitials(this._data.owner.fullName);
|
|
1064
|
-
(_b = (_q = this._data).status) !== null && _b !== void 0 ? _b : _q.status = {};
|
|
1065
|
-
(_c = (_r = this._data.status).geometry) !== null && _c !== void 0 ? _c : _r.geometry = {
|
|
1066
|
-
|
|
1067
|
-
};
|
|
1068
|
-
(
|
|
1069
|
-
state: (_f = this._data.propertiesStatus) !== null && _f !== void 0 ? _f : "none"
|
|
1070
|
-
};
|
|
1071
|
-
(_g = (_t = this._data.status).validation) !== null && _g !== void 0 ? _g : _t.validation = {
|
|
1072
|
-
state: (_h = this._data.validationStatus) !== null && _h !== void 0 ? _h : "none"
|
|
1073
|
-
};
|
|
1074
|
-
(_j = (_u = this._data).updatedBy) !== null && _j !== void 0 ? _j : _u.updatedBy = {};
|
|
1073
|
+
(_b = (_q = this._data).status) !== null && _b !== void 0 ? _b : (_q.status = {});
|
|
1074
|
+
(_c = (_r = this._data.status).geometry) !== null && _c !== void 0 ? _c : (_r.geometry = { state: (_d = this._data.geometryStatus) !== null && _d !== void 0 ? _d : "none" });
|
|
1075
|
+
(_e = (_s = this._data.status).properties) !== null && _e !== void 0 ? _e : (_s.properties = { state: (_f = this._data.propertiesStatus) !== null && _f !== void 0 ? _f : "none" });
|
|
1076
|
+
(_g = (_t = this._data.status).validation) !== null && _g !== void 0 ? _g : (_t.validation = { state: (_h = this._data.validationStatus) !== null && _h !== void 0 ? _h : "none" });
|
|
1077
|
+
(_j = (_u = this._data).updatedBy) !== null && _j !== void 0 ? _j : (_u.updatedBy = {});
|
|
1075
1078
|
this._data.updatedBy.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.updatedBy.userId}/avatar`;
|
|
1076
1079
|
this._data.updatedBy.fullName = userFullName(this._data.updatedBy);
|
|
1077
1080
|
this._data.updatedBy.initials = userInitials(this._data.updatedBy.fullName);
|
|
1078
|
-
(_k = (_v = this._data).versions) !== null && _k !== void 0 ? _k : _v.versions = [
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
(
|
|
1082
|
-
state: "none"
|
|
1083
|
-
};
|
|
1084
|
-
(_m = (_x = this._data).isFileDeleted) !== null && _m !== void 0 ? _m : _x.isFileDeleted = false;
|
|
1085
|
-
(_o = (_y = this._data).sharedLinkToken) !== null && _o !== void 0 ? _o : _y.sharedLinkToken = null;
|
|
1081
|
+
(_k = (_v = this._data).versions) !== null && _k !== void 0 ? _k : (_v.versions = [{ ...value }]);
|
|
1082
|
+
(_l = (_w = this._data.status).geometryGltf) !== null && _l !== void 0 ? _l : (_w.geometryGltf = { state: "none" });
|
|
1083
|
+
(_m = (_x = this._data).isFileDeleted) !== null && _m !== void 0 ? _m : (_x.isFileDeleted = false);
|
|
1084
|
+
(_o = (_y = this._data).sharedLinkToken) !== null && _o !== void 0 ? _o : (_y.sharedLinkToken = null);
|
|
1086
1085
|
}
|
|
1087
1086
|
get exports() {
|
|
1088
1087
|
return this.data.exports;
|
|
1089
1088
|
}
|
|
1090
1089
|
get geometryType() {
|
|
1091
|
-
if (this.status.geometryGltf.state === "done")
|
|
1090
|
+
if (this.status.geometryGltf.state === "done")
|
|
1091
|
+
return "gltf";
|
|
1092
|
+
else if (this.status.geometry.state === "done")
|
|
1093
|
+
return "vsfx";
|
|
1094
|
+
else
|
|
1095
|
+
return "";
|
|
1092
1096
|
}
|
|
1093
1097
|
get id() {
|
|
1094
1098
|
return this.data.id;
|
|
@@ -1149,7 +1153,7 @@ class File extends Endpoint {
|
|
|
1149
1153
|
return this;
|
|
1150
1154
|
}
|
|
1151
1155
|
delete() {
|
|
1152
|
-
return super.delete("").then(response => response.json());
|
|
1156
|
+
return super.delete("").then((response) => response.json());
|
|
1153
1157
|
}
|
|
1154
1158
|
save() {
|
|
1155
1159
|
return this.update(this.data);
|
|
@@ -1157,7 +1161,8 @@ class File extends Endpoint {
|
|
|
1157
1161
|
async setPreview(image) {
|
|
1158
1162
|
if (!image) {
|
|
1159
1163
|
await this.deletePreview();
|
|
1160
|
-
}
|
|
1164
|
+
}
|
|
1165
|
+
else {
|
|
1161
1166
|
const response = await this.post("/preview", image);
|
|
1162
1167
|
this.data = await response.json();
|
|
1163
1168
|
}
|
|
@@ -1169,7 +1174,9 @@ class File extends Endpoint {
|
|
|
1169
1174
|
return this;
|
|
1170
1175
|
}
|
|
1171
1176
|
getModels() {
|
|
1172
|
-
return this.get("/geometry")
|
|
1177
|
+
return this.get("/geometry")
|
|
1178
|
+
.then((response) => response.json())
|
|
1179
|
+
.then((array) => array.map((data) => new Model(data, this)));
|
|
1173
1180
|
}
|
|
1174
1181
|
getModelTransformMatrix(handle) {
|
|
1175
1182
|
return undefined;
|
|
@@ -1179,55 +1186,59 @@ class File extends Endpoint {
|
|
|
1179
1186
|
return Promise.resolve(this);
|
|
1180
1187
|
}
|
|
1181
1188
|
getProperties(handles, group = false) {
|
|
1182
|
-
const searchParams = new URLSearchParams;
|
|
1189
|
+
const searchParams = new URLSearchParams();
|
|
1183
1190
|
if (handles) {
|
|
1184
|
-
if (Array.isArray(handles))
|
|
1185
|
-
|
|
1186
|
-
if (handles
|
|
1191
|
+
if (Array.isArray(handles))
|
|
1192
|
+
handles = handles.join(",");
|
|
1193
|
+
if (typeof handles === "string")
|
|
1194
|
+
handles = handles.trim();
|
|
1195
|
+
if (handles)
|
|
1196
|
+
searchParams.set("handles", handles);
|
|
1187
1197
|
}
|
|
1188
|
-
if (group)
|
|
1198
|
+
if (group)
|
|
1199
|
+
searchParams.set("group", "true");
|
|
1189
1200
|
let queryString = searchParams.toString();
|
|
1190
|
-
if (queryString)
|
|
1191
|
-
|
|
1201
|
+
if (queryString)
|
|
1202
|
+
queryString = "?" + queryString;
|
|
1203
|
+
return this.get(`/properties${queryString}`).then((response) => response.json());
|
|
1192
1204
|
}
|
|
1193
1205
|
searchProperties(searchPattern) {
|
|
1194
|
-
return this.post("/properties/search", searchPattern).then(response => response.json());
|
|
1206
|
+
return this.post("/properties/search", searchPattern).then((response) => response.json());
|
|
1195
1207
|
}
|
|
1196
1208
|
getCdaTree() {
|
|
1197
|
-
return this.get(`/properties/tree`).then(response => response.json());
|
|
1209
|
+
return this.get(`/properties/tree`).then((response) => response.json());
|
|
1198
1210
|
}
|
|
1199
1211
|
getViewpoints() {
|
|
1200
|
-
return this.get("/viewpoints")
|
|
1212
|
+
return this.get("/viewpoints")
|
|
1213
|
+
.then((response) => response.json())
|
|
1214
|
+
.then((viewpoints) => viewpoints.result);
|
|
1201
1215
|
}
|
|
1202
1216
|
saveViewpoint(viewpoint) {
|
|
1203
|
-
return this.post("/viewpoints", viewpoint).then(response => response.json());
|
|
1217
|
+
return this.post("/viewpoints", viewpoint).then((response) => response.json());
|
|
1204
1218
|
}
|
|
1205
1219
|
deleteViewpoint(guid) {
|
|
1206
|
-
return super.delete(`/viewpoints/${guid}`).then(response => response.json());
|
|
1220
|
+
return super.delete(`/viewpoints/${guid}`).then((response) => response.json());
|
|
1207
1221
|
}
|
|
1208
1222
|
getSnapshot(guid) {
|
|
1209
|
-
return this.get(`/viewpoints/${guid}/snapshot`).then(response => response.text());
|
|
1223
|
+
return this.get(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
|
|
1210
1224
|
}
|
|
1211
1225
|
getSnapshotData(guid, bitmapGuid) {
|
|
1212
|
-
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then(response => response.text());
|
|
1226
|
+
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
|
|
1213
1227
|
}
|
|
1214
1228
|
download(onProgress, signal) {
|
|
1215
|
-
return this.httpClient
|
|
1216
|
-
signal:
|
|
1217
|
-
|
|
1218
|
-
}).then(response => response.arrayBuffer());
|
|
1229
|
+
return this.httpClient
|
|
1230
|
+
.downloadFile(this.getEndpointPath("/downloads"), onProgress, { signal, headers: this.headers })
|
|
1231
|
+
.then((response) => response.arrayBuffer());
|
|
1219
1232
|
}
|
|
1220
1233
|
downloadResource(dataId, onProgress, signal) {
|
|
1221
|
-
return this.httpClient
|
|
1222
|
-
signal:
|
|
1223
|
-
|
|
1224
|
-
}).then(response => response.arrayBuffer());
|
|
1234
|
+
return this.httpClient
|
|
1235
|
+
.downloadFile(this.getEndpointPath(`/downloads/${dataId}`), onProgress, { signal, headers: this.headers })
|
|
1236
|
+
.then((response) => response.arrayBuffer());
|
|
1225
1237
|
}
|
|
1226
1238
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
1227
|
-
return this.httpClient
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
}).then(response => response.arrayBuffer());
|
|
1239
|
+
return this.httpClient
|
|
1240
|
+
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}${requestId ? "?requestId=" + requestId : ""}`), requestId, ranges, onProgress, { signal, headers: this.headers })
|
|
1241
|
+
.then((response) => response.arrayBuffer());
|
|
1231
1242
|
}
|
|
1232
1243
|
partialDownloadResource(dataId, onProgress, signal) {
|
|
1233
1244
|
console.warn("File.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use File.downloadResource() instead.");
|
|
@@ -1237,18 +1248,21 @@ class File extends Endpoint {
|
|
|
1237
1248
|
await this.downloadResourceRange(dataId, requestId, records, onProgress, signal);
|
|
1238
1249
|
}
|
|
1239
1250
|
getReferences(signal) {
|
|
1240
|
-
return this.get("/references", signal).then(response => response.json());
|
|
1251
|
+
return this.get("/references", signal).then((response) => response.json());
|
|
1241
1252
|
}
|
|
1242
1253
|
setReferences(references) {
|
|
1243
|
-
return this.put("/references", references).then(response => response.json());
|
|
1254
|
+
return this.put("/references", references).then((response) => response.json());
|
|
1244
1255
|
}
|
|
1245
1256
|
createJob(outputFormat, parameters) {
|
|
1246
1257
|
const jobs = new Endpoint("/jobs", this.httpClient, this.headers);
|
|
1247
|
-
return jobs
|
|
1258
|
+
return jobs
|
|
1259
|
+
.post(this.appendVersionParam(""), {
|
|
1248
1260
|
fileId: this.id,
|
|
1249
|
-
outputFormat
|
|
1250
|
-
parameters: parseArgs(parameters)
|
|
1251
|
-
})
|
|
1261
|
+
outputFormat,
|
|
1262
|
+
parameters: parseArgs(parameters),
|
|
1263
|
+
})
|
|
1264
|
+
.then((response) => response.json())
|
|
1265
|
+
.then((data) => new Job(data, this.httpClient));
|
|
1252
1266
|
}
|
|
1253
1267
|
extractGeometry(type, parameters) {
|
|
1254
1268
|
return this.createJob(type === "gltf" ? "geometryGltf" : "geometry", parameters);
|
|
@@ -1260,13 +1274,14 @@ class File extends Endpoint {
|
|
|
1260
1274
|
return this.createJob("validation", parameters);
|
|
1261
1275
|
}
|
|
1262
1276
|
waitForDone(jobs, waitAll, params) {
|
|
1263
|
-
const waitJobs = Array.isArray(jobs) ? jobs : [
|
|
1264
|
-
if (waitAll === undefined)
|
|
1265
|
-
|
|
1277
|
+
const waitJobs = Array.isArray(jobs) ? jobs : [jobs];
|
|
1278
|
+
if (waitAll === undefined)
|
|
1279
|
+
waitAll = true;
|
|
1280
|
+
const checkDone = () => this.checkout().then((file) => {
|
|
1266
1281
|
var _a;
|
|
1267
|
-
const readyJobs = waitJobs.filter(job => {
|
|
1282
|
+
const readyJobs = waitJobs.filter((job) => {
|
|
1268
1283
|
const jobStatus = file.status[job] || {};
|
|
1269
|
-
return [
|
|
1284
|
+
return ["none", "done", "failed"].includes(jobStatus.state || "none");
|
|
1270
1285
|
});
|
|
1271
1286
|
const ready = waitAll ? readyJobs.length === waitJobs.length : readyJobs.length > 0;
|
|
1272
1287
|
const cancel = (_a = params === null || params === void 0 ? void 0 : params.onCheckout) === null || _a === void 0 ? void 0 : _a.call(params, file, ready);
|
|
@@ -1275,50 +1290,70 @@ class File extends Endpoint {
|
|
|
1275
1290
|
return waitFor(checkDone, params).then(() => this);
|
|
1276
1291
|
}
|
|
1277
1292
|
getPermissions() {
|
|
1278
|
-
return this.get("/permissions")
|
|
1293
|
+
return this.get("/permissions")
|
|
1294
|
+
.then((response) => response.json())
|
|
1295
|
+
.then((array) => array.map((data) => new Permission(data, this.id, this.httpClient)));
|
|
1279
1296
|
}
|
|
1280
1297
|
getPermission(permissionId) {
|
|
1281
|
-
return this.get(`/permissions/${permissionId}`)
|
|
1298
|
+
return this.get(`/permissions/${permissionId}`)
|
|
1299
|
+
.then((response) => response.json())
|
|
1300
|
+
.then((data) => new Permission(data, this.id, this.httpClient));
|
|
1282
1301
|
}
|
|
1283
1302
|
createPermission(actions, grantedTo, _public) {
|
|
1284
1303
|
return this.post("/permissions", {
|
|
1285
|
-
actions: Array.isArray(actions) ? actions : [
|
|
1286
|
-
grantedTo
|
|
1287
|
-
public: _public
|
|
1288
|
-
})
|
|
1304
|
+
actions: Array.isArray(actions) ? actions : [actions],
|
|
1305
|
+
grantedTo,
|
|
1306
|
+
public: _public,
|
|
1307
|
+
})
|
|
1308
|
+
.then((response) => response.json())
|
|
1309
|
+
.then((data) => new Permission(data, this.id, this.httpClient));
|
|
1289
1310
|
}
|
|
1290
1311
|
deletePermission(permissionId) {
|
|
1291
|
-
return super.delete(`/permissions/${permissionId}`).then(response => response.json());
|
|
1312
|
+
return super.delete(`/permissions/${permissionId}`).then((response) => response.json());
|
|
1292
1313
|
}
|
|
1293
1314
|
async uploadVersion(file, params = {
|
|
1294
|
-
waitForDone: false
|
|
1315
|
+
waitForDone: false,
|
|
1295
1316
|
}) {
|
|
1296
|
-
const result = await this.httpClient
|
|
1297
|
-
var _a;
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1317
|
+
const result = await this.httpClient
|
|
1318
|
+
.uploadFile(this.getEndpointPath("/versions"), file, (progress) => { var _a; return (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file); }, {
|
|
1319
|
+
headers: this.headers,
|
|
1320
|
+
})
|
|
1321
|
+
.then((xhr) => JSON.parse(xhr.responseText))
|
|
1322
|
+
.then((data) => new File(data, this.httpClient));
|
|
1302
1323
|
let geometryType = "";
|
|
1303
|
-
if (this.versions[0].status.geometryGltf.state !== "none")
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
};
|
|
1308
|
-
if (params.geometry === undefined)
|
|
1309
|
-
|
|
1324
|
+
if (this.versions[0].status.geometryGltf.state !== "none")
|
|
1325
|
+
geometryType = "gltf";
|
|
1326
|
+
if (this.versions[0].status.geometry.state !== "none")
|
|
1327
|
+
geometryType = "vsfx";
|
|
1328
|
+
params = { ...params };
|
|
1329
|
+
if (params.geometry === undefined)
|
|
1330
|
+
params.geometry = geometryType !== "";
|
|
1331
|
+
if (params.properties === undefined)
|
|
1332
|
+
params.properties = this.versions[0].status.properties.state !== "none";
|
|
1310
1333
|
const jobs = [];
|
|
1311
|
-
if (params.geometry)
|
|
1312
|
-
|
|
1313
|
-
if (
|
|
1334
|
+
if (params.geometry)
|
|
1335
|
+
jobs.push((await result.extractGeometry(geometryType)).outputFormat);
|
|
1336
|
+
if (params.properties)
|
|
1337
|
+
jobs.push((await result.extractProperties()).outputFormat);
|
|
1338
|
+
if (jobs.length > 0)
|
|
1339
|
+
if (params.waitForDone)
|
|
1340
|
+
await result.waitForDone(jobs, true, params);
|
|
1341
|
+
else
|
|
1342
|
+
await result.checkout();
|
|
1314
1343
|
await this.checkout();
|
|
1315
1344
|
return result;
|
|
1316
1345
|
}
|
|
1317
1346
|
getVersions() {
|
|
1318
|
-
return this.get("/versions")
|
|
1347
|
+
return this.get("/versions")
|
|
1348
|
+
.then((response) => response.json())
|
|
1349
|
+
.then((files) => files.map((data) => new File(data, this.httpClient)))
|
|
1350
|
+
.then((files) => files.map((file) => (file.id == file.originalFileId ? file.useVersion(0) : file)));
|
|
1319
1351
|
}
|
|
1320
1352
|
getVersion(version) {
|
|
1321
|
-
return this.get(`/versions/${version}`)
|
|
1353
|
+
return this.get(`/versions/${version}`)
|
|
1354
|
+
.then((response) => response.json())
|
|
1355
|
+
.then((data) => new File(data, this.httpClient))
|
|
1356
|
+
.then((file) => (file.id == file.originalFileId ? file.useVersion(0) : file));
|
|
1322
1357
|
}
|
|
1323
1358
|
async deleteVersion(version) {
|
|
1324
1359
|
const response = await super.delete(`/versions/${version}`);
|
|
@@ -1327,9 +1362,7 @@ class File extends Endpoint {
|
|
|
1327
1362
|
return data;
|
|
1328
1363
|
}
|
|
1329
1364
|
setActiveVersion(version) {
|
|
1330
|
-
return this.update({
|
|
1331
|
-
activeVersion: version
|
|
1332
|
-
});
|
|
1365
|
+
return this.update({ activeVersion: version });
|
|
1333
1366
|
}
|
|
1334
1367
|
useVersion(version) {
|
|
1335
1368
|
return super.useVersion(version);
|
|
@@ -1341,16 +1374,14 @@ class File extends Endpoint {
|
|
|
1341
1374
|
}
|
|
1342
1375
|
async createSharedLink(permissions) {
|
|
1343
1376
|
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
1344
|
-
const response = await shares.post("", {
|
|
1345
|
-
fileId: this.id,
|
|
1346
|
-
permissions: permissions
|
|
1347
|
-
});
|
|
1377
|
+
const response = await shares.post("", { fileId: this.id, permissions });
|
|
1348
1378
|
const data = await response.json();
|
|
1349
1379
|
await this.checkout();
|
|
1350
1380
|
return new SharedLink(data, this.httpClient);
|
|
1351
1381
|
}
|
|
1352
1382
|
async getSharedLink() {
|
|
1353
|
-
if (!this.sharedLinkToken)
|
|
1383
|
+
if (!this.sharedLinkToken)
|
|
1384
|
+
return Promise.resolve(undefined);
|
|
1354
1385
|
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
1355
1386
|
const response = await shares.get(`/${this.sharedLinkToken}`);
|
|
1356
1387
|
const data = await response.json();
|
|
@@ -1407,7 +1438,7 @@ class Role extends Endpoint {
|
|
|
1407
1438
|
return this;
|
|
1408
1439
|
}
|
|
1409
1440
|
delete() {
|
|
1410
|
-
return super.delete("").then(response => response.json());
|
|
1441
|
+
return super.delete("").then((response) => response.json());
|
|
1411
1442
|
}
|
|
1412
1443
|
save() {
|
|
1413
1444
|
return this.update(this.data);
|
|
@@ -1454,7 +1485,7 @@ class Member extends Endpoint {
|
|
|
1454
1485
|
return this;
|
|
1455
1486
|
}
|
|
1456
1487
|
delete() {
|
|
1457
|
-
return super.delete("").then(response => response.json());
|
|
1488
|
+
return super.delete("").then((response) => response.json());
|
|
1458
1489
|
}
|
|
1459
1490
|
save() {
|
|
1460
1491
|
return this.update(this.data);
|
|
@@ -1483,7 +1514,9 @@ class Project extends Endpoint {
|
|
|
1483
1514
|
}
|
|
1484
1515
|
set data(value) {
|
|
1485
1516
|
this._data = value;
|
|
1486
|
-
this._data.previewUrl = value.avatarUrl
|
|
1517
|
+
this._data.previewUrl = value.avatarUrl
|
|
1518
|
+
? `${this.httpClient.serverUrl}/projects/${this._data.id}/preview?updated=${value.updatedAt}`
|
|
1519
|
+
: "";
|
|
1487
1520
|
this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
|
|
1488
1521
|
this._data.owner.fullName = userFullName(this._data.owner);
|
|
1489
1522
|
this._data.owner.initials = userInitials(this._data.owner.fullName);
|
|
@@ -1550,13 +1583,15 @@ class Project extends Endpoint {
|
|
|
1550
1583
|
return this;
|
|
1551
1584
|
}
|
|
1552
1585
|
delete() {
|
|
1553
|
-
return super
|
|
1586
|
+
return super
|
|
1587
|
+
.delete("")
|
|
1588
|
+
.then((response) => response.text())
|
|
1589
|
+
.then((text) => {
|
|
1554
1590
|
try {
|
|
1555
1591
|
return JSON.parse(text);
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
};
|
|
1592
|
+
}
|
|
1593
|
+
catch {
|
|
1594
|
+
return { id: this.id };
|
|
1560
1595
|
}
|
|
1561
1596
|
});
|
|
1562
1597
|
}
|
|
@@ -1566,7 +1601,8 @@ class Project extends Endpoint {
|
|
|
1566
1601
|
async setPreview(image) {
|
|
1567
1602
|
if (!image) {
|
|
1568
1603
|
await this.deletePreview();
|
|
1569
|
-
}
|
|
1604
|
+
}
|
|
1605
|
+
else {
|
|
1570
1606
|
const response = await this.post("/preview", image);
|
|
1571
1607
|
this.data = await response.json();
|
|
1572
1608
|
}
|
|
@@ -1578,41 +1614,55 @@ class Project extends Endpoint {
|
|
|
1578
1614
|
return this;
|
|
1579
1615
|
}
|
|
1580
1616
|
getRoles() {
|
|
1581
|
-
return this.get("/roles")
|
|
1617
|
+
return this.get("/roles")
|
|
1618
|
+
.then((response) => response.json())
|
|
1619
|
+
.then((array) => array.map((data) => new Role(data, this.id, this.httpClient)));
|
|
1582
1620
|
}
|
|
1583
1621
|
getRole(name) {
|
|
1584
|
-
return this.get(`/roles/${name}`)
|
|
1622
|
+
return this.get(`/roles/${name}`)
|
|
1623
|
+
.then((response) => response.json())
|
|
1624
|
+
.then((data) => new Role(data, this.id, this.httpClient));
|
|
1585
1625
|
}
|
|
1586
1626
|
createRole(name, description, permissions) {
|
|
1587
1627
|
return this.post("/roles", {
|
|
1588
|
-
name
|
|
1589
|
-
description
|
|
1590
|
-
permissions: permissions || {}
|
|
1591
|
-
})
|
|
1628
|
+
name,
|
|
1629
|
+
description,
|
|
1630
|
+
permissions: permissions || {},
|
|
1631
|
+
})
|
|
1632
|
+
.then((response) => response.json())
|
|
1633
|
+
.then((data) => new Role(data, this.id, this.httpClient));
|
|
1592
1634
|
}
|
|
1593
1635
|
deleteRole(name) {
|
|
1594
|
-
return super.delete(`/roles/${name}`).then(response => response.json());
|
|
1636
|
+
return super.delete(`/roles/${name}`).then((response) => response.json());
|
|
1595
1637
|
}
|
|
1596
1638
|
getMembers() {
|
|
1597
|
-
return this.get("/members")
|
|
1639
|
+
return this.get("/members")
|
|
1640
|
+
.then((response) => response.json())
|
|
1641
|
+
.then((array) => array.map((data) => new Member(data, this.id, this.httpClient)));
|
|
1598
1642
|
}
|
|
1599
1643
|
getMember(memberId) {
|
|
1600
|
-
return this.get(`/members/${memberId}`)
|
|
1644
|
+
return this.get(`/members/${memberId}`)
|
|
1645
|
+
.then((response) => response.json())
|
|
1646
|
+
.then((data) => new Member(data, this.id, this.httpClient));
|
|
1601
1647
|
}
|
|
1602
1648
|
addMember(userId, role) {
|
|
1603
|
-
return this.post("/members", {
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
}).then(response => response.json()).then(data => new Member(data, this.id, this.httpClient));
|
|
1649
|
+
return this.post("/members", { userId, role })
|
|
1650
|
+
.then((response) => response.json())
|
|
1651
|
+
.then((data) => new Member(data, this.id, this.httpClient));
|
|
1607
1652
|
}
|
|
1608
1653
|
removeMember(memberId) {
|
|
1609
|
-
return super.delete(`/members/${memberId}`).then(response => response.json());
|
|
1654
|
+
return super.delete(`/members/${memberId}`).then((response) => response.json());
|
|
1610
1655
|
}
|
|
1611
1656
|
getFilesInformation() {
|
|
1612
1657
|
const bcfProjects = new Endpoint("/bcf/3.0/projects", this.httpClient, this.headers);
|
|
1613
|
-
return bcfProjects
|
|
1614
|
-
|
|
1615
|
-
|
|
1658
|
+
return bcfProjects
|
|
1659
|
+
.get(`/${this.id}/files_information`)
|
|
1660
|
+
.then((response) => response.json())
|
|
1661
|
+
.then((items) => {
|
|
1662
|
+
items.forEach((item) => {
|
|
1663
|
+
const getFieldValue = (displayName) => {
|
|
1664
|
+
return (item.display_information.find((x) => x.field_display_name === displayName) || {}).field_value;
|
|
1665
|
+
};
|
|
1616
1666
|
const previewUrl = `${this.httpClient.serverUrl}/files/${item.file.reference}/preview`;
|
|
1617
1667
|
const ownerAvatarUrl = `${this.httpClient.serverUrl}/users/${getFieldValue("Owner")}/avatar`;
|
|
1618
1668
|
const ownerFirstName = getFieldValue("Owner First Name");
|
|
@@ -1620,22 +1670,10 @@ class Project extends Endpoint {
|
|
|
1620
1670
|
const ownerUserName = getFieldValue("Owner User Name");
|
|
1621
1671
|
const ownerFullName = userFullName(ownerFirstName, ownerLastName, ownerUserName);
|
|
1622
1672
|
const ownerInitials = userInitials(ownerFullName);
|
|
1623
|
-
item.display_information.push({
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
});
|
|
1627
|
-
item.display_information.push({
|
|
1628
|
-
field_display_name: "Owner Avatar URL",
|
|
1629
|
-
field_value: ownerAvatarUrl
|
|
1630
|
-
});
|
|
1631
|
-
item.display_information.push({
|
|
1632
|
-
field_display_name: "Owner Full Name",
|
|
1633
|
-
field_value: ownerFullName
|
|
1634
|
-
});
|
|
1635
|
-
item.display_information.push({
|
|
1636
|
-
field_display_name: "Owner Initials",
|
|
1637
|
-
field_value: ownerInitials
|
|
1638
|
-
});
|
|
1673
|
+
item.display_information.push({ field_display_name: "Preview URL", field_value: previewUrl });
|
|
1674
|
+
item.display_information.push({ field_display_name: "Owner Avatar URL", field_value: ownerAvatarUrl });
|
|
1675
|
+
item.display_information.push({ field_display_name: "Owner Full Name", field_value: ownerFullName });
|
|
1676
|
+
item.display_information.push({ field_display_name: "Owner Initials", field_value: ownerInitials });
|
|
1639
1677
|
const updatedByAvatarUrl = `${this.httpClient.serverUrl}/users/${getFieldValue("Updated By")}/avatar`;
|
|
1640
1678
|
const updatedByFirstName = getFieldValue("Updated By First Name");
|
|
1641
1679
|
const updatedByLastName = getFieldValue("Updated By Last Name");
|
|
@@ -1644,53 +1682,48 @@ class Project extends Endpoint {
|
|
|
1644
1682
|
const updatedByInitials = userInitials(updatedByFullName);
|
|
1645
1683
|
item.display_information.push({
|
|
1646
1684
|
field_display_name: "Updated By Avatar URL",
|
|
1647
|
-
field_value: updatedByAvatarUrl
|
|
1648
|
-
});
|
|
1649
|
-
item.display_information.push({
|
|
1650
|
-
field_display_name: "Updated By Full Name",
|
|
1651
|
-
field_value: updatedByFullName
|
|
1652
|
-
});
|
|
1653
|
-
item.display_information.push({
|
|
1654
|
-
field_display_name: "Updated By Initials",
|
|
1655
|
-
field_value: updatedByInitials
|
|
1685
|
+
field_value: updatedByAvatarUrl,
|
|
1656
1686
|
});
|
|
1687
|
+
item.display_information.push({ field_display_name: "Updated By Full Name", field_value: updatedByFullName });
|
|
1688
|
+
item.display_information.push({ field_display_name: "Updated By Initials", field_value: updatedByInitials });
|
|
1657
1689
|
const geometry = getFieldValue("Geometry Status");
|
|
1658
1690
|
const geometryGltf = getFieldValue("GeometryGltf Status");
|
|
1659
1691
|
const geometryType = geometry === "done" ? "vsfx" : geometryGltf === "done" ? "gltf" : "";
|
|
1660
|
-
item.display_information.push({
|
|
1661
|
-
field_display_name: "Geometry Type",
|
|
1662
|
-
field_value: geometryType
|
|
1663
|
-
});
|
|
1692
|
+
item.display_information.push({ field_display_name: "Geometry Type", field_value: geometryType });
|
|
1664
1693
|
});
|
|
1665
1694
|
return items;
|
|
1666
1695
|
});
|
|
1667
1696
|
}
|
|
1668
1697
|
getModels() {
|
|
1669
|
-
return this.getFilesInformation()
|
|
1698
|
+
return this.getFilesInformation()
|
|
1699
|
+
.then((filesInformation) => filesInformation.map((item) => item.file.reference))
|
|
1700
|
+
.then((ids) => {
|
|
1670
1701
|
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
1671
1702
|
return files.get(`?id=${ids.join("|")}`);
|
|
1672
|
-
})
|
|
1703
|
+
})
|
|
1704
|
+
.then((response) => response.json())
|
|
1705
|
+
.then((files) => files.result.map((data) => new File(data, this.httpClient)));
|
|
1673
1706
|
}
|
|
1674
1707
|
async addModel(fileId, actions, _public) {
|
|
1675
1708
|
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
1676
|
-
const file = await files
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
}
|
|
1682
|
-
} ];
|
|
1709
|
+
const file = await files
|
|
1710
|
+
.get(`/${fileId}`)
|
|
1711
|
+
.then((response) => response.json())
|
|
1712
|
+
.then((data) => new File(data, this.httpClient));
|
|
1713
|
+
const grantedTo = [{ project: { id: this.id, name: this.name } }];
|
|
1683
1714
|
await file.createPermission(actions, grantedTo, _public);
|
|
1684
1715
|
return file;
|
|
1685
1716
|
}
|
|
1686
1717
|
async removeModel(fileId) {
|
|
1687
1718
|
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
1688
|
-
const file = await files
|
|
1719
|
+
const file = await files
|
|
1720
|
+
.get(`/${fileId}`)
|
|
1721
|
+
.then((response) => response.json())
|
|
1722
|
+
.then((data) => new File(data, this.httpClient));
|
|
1689
1723
|
const permissions = await file.getPermissions();
|
|
1690
|
-
await Promise.allSettled(permissions
|
|
1691
|
-
var _a;
|
|
1692
|
-
|
|
1693
|
-
})).map(permission => permission.delete()));
|
|
1724
|
+
await Promise.allSettled(permissions
|
|
1725
|
+
.filter((permission) => permission.grantedTo.some((x) => { var _a; return ((_a = x.project) === null || _a === void 0 ? void 0 : _a.id) === this.id; }))
|
|
1726
|
+
.map((permission) => permission.delete()));
|
|
1694
1727
|
return file;
|
|
1695
1728
|
}
|
|
1696
1729
|
}
|
|
@@ -1723,7 +1756,9 @@ class User extends Endpoint {
|
|
|
1723
1756
|
}
|
|
1724
1757
|
set data(value) {
|
|
1725
1758
|
this._data = value;
|
|
1726
|
-
this._data.avatarUrl = value.avatarImage
|
|
1759
|
+
this._data.avatarUrl = value.avatarImage
|
|
1760
|
+
? `${this.httpClient.serverUrl}/users/${this._data.id}/avatar?updated=${value.lastModified}`
|
|
1761
|
+
: "";
|
|
1727
1762
|
this._data.fullName = userFullName(this._data);
|
|
1728
1763
|
this._data.initials = userInitials(this._data.fullName);
|
|
1729
1764
|
}
|
|
@@ -1803,48 +1838,40 @@ class User extends Endpoint {
|
|
|
1803
1838
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1804
1839
|
const response = await this.get(`/users/${this.id}`);
|
|
1805
1840
|
const data = await response.json();
|
|
1806
|
-
this.data = {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
};
|
|
1810
|
-
} else if (this.id === this.httpClient.signInUserId) {
|
|
1841
|
+
this.data = { id: data.id, ...data.userBrief };
|
|
1842
|
+
}
|
|
1843
|
+
else if (this.id === this.httpClient.signInUserId) {
|
|
1811
1844
|
const response = await this.get("/user");
|
|
1812
1845
|
const data = await response.json();
|
|
1813
|
-
this.data = {
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
};
|
|
1817
|
-
} else {
|
|
1846
|
+
this.data = { id: this.id, ...data };
|
|
1847
|
+
}
|
|
1848
|
+
else {
|
|
1818
1849
|
return Promise.reject(new FetchError(403));
|
|
1819
1850
|
}
|
|
1820
1851
|
return this;
|
|
1821
1852
|
}
|
|
1822
1853
|
async update(data) {
|
|
1823
1854
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1824
|
-
const response = await this.put(`/users/${this.id}`, {
|
|
1825
|
-
isAdmin: data.isAdmin,
|
|
1826
|
-
userBrief: data
|
|
1827
|
-
});
|
|
1855
|
+
const response = await this.put(`/users/${this.id}`, { isAdmin: data.isAdmin, userBrief: data });
|
|
1828
1856
|
const newData = await response.json();
|
|
1829
|
-
this.data = {
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
};
|
|
1833
|
-
} else if (this.id === this.httpClient.signInUserId) {
|
|
1857
|
+
this.data = { id: newData.id, ...newData.userBrief };
|
|
1858
|
+
}
|
|
1859
|
+
else if (this.id === this.httpClient.signInUserId) {
|
|
1834
1860
|
const response = await this.put("/user", data);
|
|
1835
1861
|
const newData = await response.json();
|
|
1836
|
-
this.data = {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
};
|
|
1840
|
-
} else {
|
|
1862
|
+
this.data = { id: this.id, ...newData };
|
|
1863
|
+
}
|
|
1864
|
+
else {
|
|
1841
1865
|
return Promise.reject(new FetchError(403));
|
|
1842
1866
|
}
|
|
1843
1867
|
return this;
|
|
1844
1868
|
}
|
|
1845
1869
|
delete() {
|
|
1846
1870
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1847
|
-
return super
|
|
1871
|
+
return super
|
|
1872
|
+
.delete(`/users/${this.id}`)
|
|
1873
|
+
.then((response) => response.json())
|
|
1874
|
+
.then((data) => {
|
|
1848
1875
|
if (this.id === this.httpClient.signInUserId) {
|
|
1849
1876
|
delete this.httpClient.headers["Authorization"];
|
|
1850
1877
|
this.httpClient.signInUserId = "";
|
|
@@ -1852,7 +1879,8 @@ class User extends Endpoint {
|
|
|
1852
1879
|
}
|
|
1853
1880
|
return data;
|
|
1854
1881
|
});
|
|
1855
|
-
}
|
|
1882
|
+
}
|
|
1883
|
+
else {
|
|
1856
1884
|
return Promise.reject(new FetchError(403));
|
|
1857
1885
|
}
|
|
1858
1886
|
}
|
|
@@ -1862,21 +1890,18 @@ class User extends Endpoint {
|
|
|
1862
1890
|
async setAvatar(image) {
|
|
1863
1891
|
if (!image) {
|
|
1864
1892
|
await this.deleteAvatar();
|
|
1865
|
-
}
|
|
1893
|
+
}
|
|
1894
|
+
else if (this.httpClient.signInUserIsAdmin) {
|
|
1866
1895
|
const response = await this.post(`/users/${this.id}/avatar`, image);
|
|
1867
1896
|
const data = await response.json();
|
|
1868
|
-
this.data = {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
};
|
|
1872
|
-
} else if (this.id === this.httpClient.signInUserId) {
|
|
1897
|
+
this.data = { id: data.id, ...data.userBrief };
|
|
1898
|
+
}
|
|
1899
|
+
else if (this.id === this.httpClient.signInUserId) {
|
|
1873
1900
|
const response = await this.post("/user/avatar", image);
|
|
1874
1901
|
const data = await response.json();
|
|
1875
|
-
this.data = {
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
};
|
|
1879
|
-
} else {
|
|
1902
|
+
this.data = { id: this.id, ...data };
|
|
1903
|
+
}
|
|
1904
|
+
else {
|
|
1880
1905
|
return Promise.reject(new FetchError(403));
|
|
1881
1906
|
}
|
|
1882
1907
|
return this;
|
|
@@ -1885,43 +1910,30 @@ class User extends Endpoint {
|
|
|
1885
1910
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1886
1911
|
const response = await super.delete(`/users/${this.id}/avatar`);
|
|
1887
1912
|
const data = await response.json();
|
|
1888
|
-
this.data = {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
};
|
|
1892
|
-
} else if (this.id === this.httpClient.signInUserId) {
|
|
1913
|
+
this.data = { id: data.id, ...data.userBrief };
|
|
1914
|
+
}
|
|
1915
|
+
else if (this.id === this.httpClient.signInUserId) {
|
|
1893
1916
|
const response = await super.delete("/user/avatar");
|
|
1894
1917
|
const data = await response.json();
|
|
1895
|
-
this.data = {
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
};
|
|
1899
|
-
} else {
|
|
1918
|
+
this.data = { id: this.id, ...data };
|
|
1919
|
+
}
|
|
1920
|
+
else {
|
|
1900
1921
|
return Promise.reject(new FetchError(403));
|
|
1901
1922
|
}
|
|
1902
1923
|
return this;
|
|
1903
1924
|
}
|
|
1904
1925
|
async changePassword(newPassword, oldPassword) {
|
|
1905
1926
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1906
|
-
const response = await this.put(`/users/${this.id}/password`, {
|
|
1907
|
-
new: newPassword
|
|
1908
|
-
});
|
|
1927
|
+
const response = await this.put(`/users/${this.id}/password`, { new: newPassword });
|
|
1909
1928
|
const data = await response.json();
|
|
1910
|
-
this.data = {
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
};
|
|
1914
|
-
} else if (this.id === this.httpClient.signInUserId) {
|
|
1915
|
-
const response = await this.put("/user/password", {
|
|
1916
|
-
old: oldPassword,
|
|
1917
|
-
new: newPassword
|
|
1918
|
-
});
|
|
1929
|
+
this.data = { id: data.id, ...data.userBrief };
|
|
1930
|
+
}
|
|
1931
|
+
else if (this.id === this.httpClient.signInUserId) {
|
|
1932
|
+
const response = await this.put("/user/password", { old: oldPassword, new: newPassword });
|
|
1919
1933
|
const data = await response.json();
|
|
1920
|
-
this.data = {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
};
|
|
1924
|
-
} else {
|
|
1934
|
+
this.data = { id: this.id, ...data };
|
|
1935
|
+
}
|
|
1936
|
+
else {
|
|
1925
1937
|
return Promise.reject(new FetchError(403));
|
|
1926
1938
|
}
|
|
1927
1939
|
return this;
|
|
@@ -1986,7 +1998,7 @@ class OAuthClient extends Endpoint {
|
|
|
1986
1998
|
return this;
|
|
1987
1999
|
}
|
|
1988
2000
|
delete() {
|
|
1989
|
-
return super.delete("").then(response => response.json());
|
|
2001
|
+
return super.delete("").then((response) => response.json());
|
|
1990
2002
|
}
|
|
1991
2003
|
save() {
|
|
1992
2004
|
return this.update(this.data);
|
|
@@ -2001,9 +2013,7 @@ class SharedFile extends File {
|
|
|
2001
2013
|
constructor(data, password, httpClient) {
|
|
2002
2014
|
super(data.file, httpClient);
|
|
2003
2015
|
this.path = `/shares/${data.file.sharedLinkToken}`;
|
|
2004
|
-
this.headers = {
|
|
2005
|
-
"InWeb-Password": password
|
|
2006
|
-
};
|
|
2016
|
+
this.headers = { "InWeb-Password": password };
|
|
2007
2017
|
}
|
|
2008
2018
|
async checkout() {
|
|
2009
2019
|
const response = await this.get("/info");
|
|
@@ -2071,7 +2081,7 @@ class Plugin extends Endpoint {
|
|
|
2071
2081
|
return this;
|
|
2072
2082
|
}
|
|
2073
2083
|
delete() {
|
|
2074
|
-
return super.delete("").then(response => response.json());
|
|
2084
|
+
return super.delete("").then((response) => response.json());
|
|
2075
2085
|
}
|
|
2076
2086
|
async enable() {
|
|
2077
2087
|
const response = await this.put("/enable");
|
|
@@ -2084,23 +2094,22 @@ class Plugin extends Endpoint {
|
|
|
2084
2094
|
return this;
|
|
2085
2095
|
}
|
|
2086
2096
|
download(onProgress, signal) {
|
|
2087
|
-
return this.httpClient
|
|
2088
|
-
signal:
|
|
2089
|
-
|
|
2090
|
-
}).then(response => response.arrayBuffer());
|
|
2097
|
+
return this.httpClient
|
|
2098
|
+
.downloadFile(this.getEndpointPath("/download"), onProgress, { signal, headers: this.headers })
|
|
2099
|
+
.then((response) => response.arrayBuffer());
|
|
2091
2100
|
}
|
|
2092
2101
|
getManifest() {
|
|
2093
|
-
return this.get("/manifest").then(response => response.json());
|
|
2102
|
+
return this.get("/manifest").then((response) => response.json());
|
|
2094
2103
|
}
|
|
2095
2104
|
getSettings() {
|
|
2096
|
-
return this.get("/settings").then(response => response.json());
|
|
2105
|
+
return this.get("/settings").then((response) => response.json());
|
|
2097
2106
|
}
|
|
2098
2107
|
updateSettings(settings) {
|
|
2099
|
-
return this.post("/settings", settings).then(response => response.json());
|
|
2108
|
+
return this.post("/settings", settings).then((response) => response.json());
|
|
2100
2109
|
}
|
|
2101
2110
|
executeCommand(command, parameters) {
|
|
2102
2111
|
const commands = new Endpoint(`/plugins/${this.name}/commands`, this.httpClient, this.headers);
|
|
2103
|
-
return commands.post(`/${command}?version=${this.version}`, parameters).then(response => response.json());
|
|
2112
|
+
return commands.post(`/${command}?version=${this.version}`, parameters).then((response) => response.json());
|
|
2104
2113
|
}
|
|
2105
2114
|
}
|
|
2106
2115
|
|
|
@@ -2133,21 +2142,9 @@ class Client extends EventEmitter2 {
|
|
|
2133
2142
|
enableStreamingMode: true,
|
|
2134
2143
|
enablePartialMode: false,
|
|
2135
2144
|
memoryLimit: 3294967296,
|
|
2136
|
-
cuttingPlaneFillColor: {
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
blue: 0
|
|
2140
|
-
},
|
|
2141
|
-
edgesColor: {
|
|
2142
|
-
r: 255,
|
|
2143
|
-
g: 152,
|
|
2144
|
-
b: 0
|
|
2145
|
-
},
|
|
2146
|
-
facesColor: {
|
|
2147
|
-
r: 255,
|
|
2148
|
-
g: 152,
|
|
2149
|
-
b: 0
|
|
2150
|
-
},
|
|
2145
|
+
cuttingPlaneFillColor: { red: 0xff, green: 0x98, blue: 0x00 },
|
|
2146
|
+
edgesColor: { r: 0xff, g: 0x98, b: 0x00 },
|
|
2147
|
+
facesColor: { r: 0xff, g: 0x98, b: 0x00 },
|
|
2151
2148
|
edgesVisibility: true,
|
|
2152
2149
|
edgesOverlap: true,
|
|
2153
2150
|
facesOverlap: false,
|
|
@@ -2157,15 +2154,15 @@ class Client extends EventEmitter2 {
|
|
|
2157
2154
|
edgeModel: true,
|
|
2158
2155
|
reverseZoomWheel: false,
|
|
2159
2156
|
enableZoomWheel: true,
|
|
2160
|
-
enableGestures: true
|
|
2157
|
+
enableGestures: true,
|
|
2161
2158
|
};
|
|
2162
2159
|
return {
|
|
2163
2160
|
...data,
|
|
2164
|
-
data
|
|
2161
|
+
data,
|
|
2165
2162
|
defaults: () => data,
|
|
2166
|
-
resetToDefaults: () => {},
|
|
2167
|
-
saveToStorage: () => {},
|
|
2168
|
-
loadFromStorage: () => {}
|
|
2163
|
+
resetToDefaults: () => { },
|
|
2164
|
+
saveToStorage: () => { },
|
|
2165
|
+
loadFromStorage: () => { },
|
|
2169
2166
|
};
|
|
2170
2167
|
}
|
|
2171
2168
|
configure(params) {
|
|
@@ -2175,27 +2172,33 @@ class Client extends EventEmitter2 {
|
|
|
2175
2172
|
return this;
|
|
2176
2173
|
}
|
|
2177
2174
|
version() {
|
|
2178
|
-
return this.httpClient
|
|
2175
|
+
return this.httpClient
|
|
2176
|
+
.get("/version")
|
|
2177
|
+
.then((response) => response.json())
|
|
2178
|
+
.then((data) => ({
|
|
2179
2179
|
...data,
|
|
2180
2180
|
server: data.version,
|
|
2181
|
-
client: "26.9.
|
|
2181
|
+
client: "26.9.5",
|
|
2182
2182
|
}));
|
|
2183
2183
|
}
|
|
2184
2184
|
registerUser(email, password, userName) {
|
|
2185
|
-
return this.httpClient
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2185
|
+
return this.httpClient
|
|
2186
|
+
.post("/register", {
|
|
2187
|
+
email,
|
|
2188
|
+
password,
|
|
2189
|
+
userName: userName !== null && userName !== void 0 ? userName : (email + "").split("@").shift(),
|
|
2190
|
+
})
|
|
2191
|
+
.then((response) => response.json());
|
|
2190
2192
|
}
|
|
2191
2193
|
resendConfirmationEmail(email, password) {
|
|
2192
|
-
return this.httpClient
|
|
2193
|
-
email
|
|
2194
|
-
|
|
2195
|
-
}).then(response => response.json());
|
|
2194
|
+
return this.httpClient
|
|
2195
|
+
.post("/register/email-confirmation", { email, password })
|
|
2196
|
+
.then((response) => response.json());
|
|
2196
2197
|
}
|
|
2197
2198
|
confirmUserEmail(emailConfirmationId) {
|
|
2198
|
-
return this.httpClient
|
|
2199
|
+
return this.httpClient
|
|
2200
|
+
.get(`/register/email-confirmation/${emailConfirmationId}`)
|
|
2201
|
+
.then((response) => response.json());
|
|
2199
2202
|
}
|
|
2200
2203
|
async signInWithEmail(email, password) {
|
|
2201
2204
|
const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
|
|
@@ -2227,325 +2230,451 @@ class Client extends EventEmitter2 {
|
|
|
2227
2230
|
this.httpClient.signInUserIsAdmin = false;
|
|
2228
2231
|
}
|
|
2229
2232
|
getCurrentUser() {
|
|
2230
|
-
if (this._user && !this.httpClient.signInUserId)
|
|
2233
|
+
if (this._user && !this.httpClient.signInUserId)
|
|
2234
|
+
this._user = null;
|
|
2231
2235
|
return this._user;
|
|
2232
2236
|
}
|
|
2233
2237
|
getIdentityProviders() {
|
|
2234
|
-
return this.httpClient.get("/identity").then(response => response.json());
|
|
2238
|
+
return this.httpClient.get("/identity").then((response) => response.json());
|
|
2235
2239
|
}
|
|
2236
2240
|
getServerSettings() {
|
|
2237
|
-
return this.httpClient.get("/settings").then(response => response.json());
|
|
2241
|
+
return this.httpClient.get("/settings").then((response) => response.json());
|
|
2238
2242
|
}
|
|
2239
2243
|
updateServerSettings(settings) {
|
|
2240
|
-
return this.httpClient.put("/settings", settings).then(response => response.json());
|
|
2244
|
+
return this.httpClient.put("/settings", settings).then((response) => response.json());
|
|
2241
2245
|
}
|
|
2242
2246
|
getOAuthClients(start, limit) {
|
|
2243
|
-
const searchParams = new URLSearchParams;
|
|
2244
|
-
if (start > 0)
|
|
2245
|
-
|
|
2247
|
+
const searchParams = new URLSearchParams();
|
|
2248
|
+
if (start > 0)
|
|
2249
|
+
searchParams.set("start", start.toString());
|
|
2250
|
+
if (limit > 0)
|
|
2251
|
+
searchParams.set("limit", limit.toString());
|
|
2246
2252
|
let queryString = searchParams.toString();
|
|
2247
|
-
if (queryString)
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2253
|
+
if (queryString)
|
|
2254
|
+
queryString = "?" + queryString;
|
|
2255
|
+
return this.httpClient
|
|
2256
|
+
.get(`/oauth/clients${queryString}`)
|
|
2257
|
+
.then((response) => response.json())
|
|
2258
|
+
.then((clients) => {
|
|
2259
|
+
return {
|
|
2260
|
+
...clients,
|
|
2261
|
+
result: clients.result.map((data) => new OAuthClient(data, this.httpClient)),
|
|
2262
|
+
};
|
|
2263
|
+
});
|
|
2252
2264
|
}
|
|
2253
2265
|
getOAuthClient(clientId) {
|
|
2254
|
-
return this.httpClient
|
|
2266
|
+
return this.httpClient
|
|
2267
|
+
.get(`/oauth/clients/${clientId}`)
|
|
2268
|
+
.then((response) => response.json())
|
|
2269
|
+
.then((data) => new OAuthClient(data, this.httpClient));
|
|
2255
2270
|
}
|
|
2256
2271
|
createOAuthClient(name, redirectUrl, description) {
|
|
2257
|
-
return this.httpClient
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2272
|
+
return this.httpClient
|
|
2273
|
+
.post("/oauth/clients", {
|
|
2274
|
+
name,
|
|
2275
|
+
redirectUrl,
|
|
2276
|
+
description,
|
|
2277
|
+
})
|
|
2278
|
+
.then((response) => response.json())
|
|
2279
|
+
.then((data) => new OAuthClient(data, this.httpClient));
|
|
2262
2280
|
}
|
|
2263
2281
|
deleteOAuthClient(clientId) {
|
|
2264
|
-
return this.httpClient.delete(`/oauth/clients/${clientId}`).then(response => response.json());
|
|
2282
|
+
return this.httpClient.delete(`/oauth/clients/${clientId}`).then((response) => response.json());
|
|
2265
2283
|
}
|
|
2266
2284
|
getUsers() {
|
|
2267
|
-
return this.httpClient
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2285
|
+
return this.httpClient
|
|
2286
|
+
.get("/users")
|
|
2287
|
+
.then((response) => response.json())
|
|
2288
|
+
.then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
|
|
2289
|
+
.then((array) => array.map((data) => new User(data, this.httpClient)));
|
|
2271
2290
|
}
|
|
2272
2291
|
getUser(userId) {
|
|
2273
2292
|
if (this.httpClient.signInUserIsAdmin) {
|
|
2274
|
-
return this.httpClient
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2293
|
+
return this.httpClient
|
|
2294
|
+
.get(`/users/${userId}`)
|
|
2295
|
+
.then((response) => response.json())
|
|
2296
|
+
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
2297
|
+
.then((data) => new User(data, this.httpClient));
|
|
2298
|
+
}
|
|
2299
|
+
else if (userId === this.httpClient.signInUserId) {
|
|
2300
|
+
return this.httpClient
|
|
2301
|
+
.get("/user")
|
|
2302
|
+
.then((response) => response.json())
|
|
2303
|
+
.then((data) => ({ id: userId, ...data }))
|
|
2304
|
+
.then((data) => new User(data, this.httpClient));
|
|
2305
|
+
}
|
|
2306
|
+
else {
|
|
2284
2307
|
return Promise.reject(new FetchError(403));
|
|
2285
2308
|
}
|
|
2286
2309
|
}
|
|
2287
2310
|
createUser(email, password, params = {}) {
|
|
2288
|
-
const {
|
|
2289
|
-
return this.httpClient
|
|
2290
|
-
|
|
2311
|
+
const { isAdmin, userName, ...rest } = params;
|
|
2312
|
+
return this.httpClient
|
|
2313
|
+
.post("/users", {
|
|
2314
|
+
isAdmin,
|
|
2291
2315
|
userBrief: {
|
|
2292
2316
|
...rest,
|
|
2293
|
-
email
|
|
2294
|
-
userName: userName !== null && userName !== void 0 ? userName : (email + "").split("@").shift()
|
|
2317
|
+
email,
|
|
2318
|
+
userName: userName !== null && userName !== void 0 ? userName : (email + "").split("@").shift(),
|
|
2295
2319
|
},
|
|
2296
|
-
password
|
|
2297
|
-
})
|
|
2298
|
-
|
|
2299
|
-
...data.userBrief
|
|
2300
|
-
|
|
2320
|
+
password,
|
|
2321
|
+
})
|
|
2322
|
+
.then((response) => response.json())
|
|
2323
|
+
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
2324
|
+
.then((data) => new User(data, this.httpClient));
|
|
2301
2325
|
}
|
|
2302
2326
|
deleteUser(userId) {
|
|
2303
2327
|
if (this.httpClient.signInUserIsAdmin) {
|
|
2304
|
-
return this.httpClient
|
|
2328
|
+
return this.httpClient
|
|
2329
|
+
.delete(`/users/${userId}`)
|
|
2330
|
+
.then((response) => response.json())
|
|
2331
|
+
.then((data) => {
|
|
2305
2332
|
if (userId === this.httpClient.signInUserId) {
|
|
2306
2333
|
this.clearCurrentUser();
|
|
2307
2334
|
}
|
|
2308
2335
|
return data;
|
|
2309
2336
|
});
|
|
2310
|
-
}
|
|
2337
|
+
}
|
|
2338
|
+
else {
|
|
2311
2339
|
return Promise.reject(new FetchError(403));
|
|
2312
2340
|
}
|
|
2313
2341
|
}
|
|
2314
2342
|
getFiles(start, limit, name, ext, ids, sortByDesc, sortField, shared) {
|
|
2315
|
-
const searchParams = new URLSearchParams;
|
|
2316
|
-
if (start > 0)
|
|
2317
|
-
|
|
2318
|
-
if (
|
|
2343
|
+
const searchParams = new URLSearchParams();
|
|
2344
|
+
if (start > 0)
|
|
2345
|
+
searchParams.set("start", start.toString());
|
|
2346
|
+
if (limit > 0)
|
|
2347
|
+
searchParams.set("limit", limit.toString());
|
|
2348
|
+
if (name)
|
|
2349
|
+
searchParams.set("name", name);
|
|
2319
2350
|
if (ext) {
|
|
2320
|
-
if (Array.isArray(ext))
|
|
2321
|
-
|
|
2322
|
-
if (ext
|
|
2351
|
+
if (Array.isArray(ext))
|
|
2352
|
+
ext = ext.join("|");
|
|
2353
|
+
if (typeof ext === "string")
|
|
2354
|
+
ext = ext.toLowerCase();
|
|
2355
|
+
if (ext)
|
|
2356
|
+
searchParams.set("ext", ext);
|
|
2323
2357
|
}
|
|
2324
2358
|
if (ids) {
|
|
2325
|
-
if (Array.isArray(ids))
|
|
2359
|
+
if (Array.isArray(ids))
|
|
2360
|
+
ids = ids.join("|");
|
|
2326
2361
|
searchParams.set("id", ids);
|
|
2327
2362
|
}
|
|
2328
|
-
if (sortByDesc !== undefined)
|
|
2329
|
-
|
|
2330
|
-
if (
|
|
2363
|
+
if (sortByDesc !== undefined)
|
|
2364
|
+
searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
2365
|
+
if (sortField)
|
|
2366
|
+
searchParams.set("sortField", sortField);
|
|
2367
|
+
if (shared)
|
|
2368
|
+
searchParams.set("shared", "true");
|
|
2331
2369
|
let queryString = searchParams.toString();
|
|
2332
|
-
if (queryString)
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2370
|
+
if (queryString)
|
|
2371
|
+
queryString = "?" + queryString;
|
|
2372
|
+
return this.httpClient
|
|
2373
|
+
.get(`/files${queryString}`)
|
|
2374
|
+
.then((response) => response.json())
|
|
2375
|
+
.then((files) => {
|
|
2376
|
+
return {
|
|
2377
|
+
...files,
|
|
2378
|
+
result: files.result.map((data) => new File(data, this.httpClient)),
|
|
2379
|
+
};
|
|
2380
|
+
});
|
|
2337
2381
|
}
|
|
2338
2382
|
getFile(fileId) {
|
|
2339
|
-
return this.httpClient
|
|
2383
|
+
return this.httpClient
|
|
2384
|
+
.get(`/files/${fileId}`)
|
|
2385
|
+
.then((response) => response.json())
|
|
2386
|
+
.then((data) => new File(data, this.httpClient));
|
|
2340
2387
|
}
|
|
2341
2388
|
async uploadFile(file, params = {
|
|
2342
2389
|
geometry: true,
|
|
2343
2390
|
properties: false,
|
|
2344
|
-
waitForDone: false
|
|
2391
|
+
waitForDone: false,
|
|
2345
2392
|
}) {
|
|
2346
|
-
const result = await this.httpClient
|
|
2393
|
+
const result = await this.httpClient
|
|
2394
|
+
.uploadFile("/files", file, (progress) => {
|
|
2347
2395
|
var _a;
|
|
2348
|
-
this.emitEvent({
|
|
2349
|
-
type: "uploadprogress",
|
|
2350
|
-
data: progress,
|
|
2351
|
-
file: file
|
|
2352
|
-
});
|
|
2396
|
+
this.emitEvent({ type: "uploadprogress", data: progress, file });
|
|
2353
2397
|
(_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
|
|
2354
|
-
})
|
|
2398
|
+
})
|
|
2399
|
+
.then((xhr) => JSON.parse(xhr.responseText))
|
|
2400
|
+
.then((data) => new File(data, this.httpClient));
|
|
2355
2401
|
const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
|
|
2356
2402
|
const jobParameters = params.jobParameters || {};
|
|
2357
2403
|
const jobs = [];
|
|
2358
|
-
if (params.geometry)
|
|
2359
|
-
|
|
2360
|
-
if (
|
|
2404
|
+
if (params.geometry)
|
|
2405
|
+
jobs.push((await result.extractGeometry(geometryType, jobParameters.geometry)).outputFormat);
|
|
2406
|
+
if (params.properties)
|
|
2407
|
+
jobs.push((await result.extractProperties(jobParameters.properties)).outputFormat);
|
|
2408
|
+
if (jobs.length > 0)
|
|
2409
|
+
if (params.waitForDone)
|
|
2410
|
+
await result.waitForDone(jobs, true, params);
|
|
2411
|
+
else
|
|
2412
|
+
await result.checkout();
|
|
2361
2413
|
return result;
|
|
2362
2414
|
}
|
|
2363
2415
|
deleteFile(fileId) {
|
|
2364
|
-
return this.httpClient.delete(`/files/${fileId}`).then(response => response.json());
|
|
2416
|
+
return this.httpClient.delete(`/files/${fileId}`).then((response) => response.json());
|
|
2365
2417
|
}
|
|
2366
2418
|
downloadFile(fileId, onProgress, signal) {
|
|
2367
|
-
return this.httpClient
|
|
2368
|
-
signal
|
|
2369
|
-
|
|
2419
|
+
return this.httpClient
|
|
2420
|
+
.downloadFile(`/files/${fileId}/downloads`, onProgress, { signal })
|
|
2421
|
+
.then((response) => response.arrayBuffer());
|
|
2370
2422
|
}
|
|
2371
2423
|
getJobs(status, limit, start, sortByDesc, sortField) {
|
|
2372
|
-
const searchParams = new URLSearchParams;
|
|
2373
|
-
if (start > 0)
|
|
2374
|
-
|
|
2424
|
+
const searchParams = new URLSearchParams();
|
|
2425
|
+
if (start > 0)
|
|
2426
|
+
searchParams.set("start", start.toString());
|
|
2427
|
+
if (limit > 0)
|
|
2428
|
+
searchParams.set("limit", limit.toString());
|
|
2375
2429
|
if (status) {
|
|
2376
|
-
if (Array.isArray(status))
|
|
2377
|
-
|
|
2378
|
-
if (status
|
|
2430
|
+
if (Array.isArray(status))
|
|
2431
|
+
status = status.join("|");
|
|
2432
|
+
if (typeof status === "string")
|
|
2433
|
+
status = status.trim().toLowerCase();
|
|
2434
|
+
if (status)
|
|
2435
|
+
searchParams.set("status", status);
|
|
2379
2436
|
}
|
|
2380
|
-
if (sortByDesc !== undefined)
|
|
2381
|
-
|
|
2437
|
+
if (sortByDesc !== undefined)
|
|
2438
|
+
searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
2439
|
+
if (sortField)
|
|
2440
|
+
searchParams.set("sortField", sortField);
|
|
2382
2441
|
let queryString = searchParams.toString();
|
|
2383
|
-
if (queryString)
|
|
2384
|
-
|
|
2442
|
+
if (queryString)
|
|
2443
|
+
queryString = "?" + queryString;
|
|
2444
|
+
return this.httpClient
|
|
2445
|
+
.get(`/jobs${queryString}`)
|
|
2446
|
+
.then((response) => response.json())
|
|
2447
|
+
.then((jobs) => ({
|
|
2385
2448
|
...jobs,
|
|
2386
|
-
result: jobs.result.map(data => new Job(data, this.httpClient))
|
|
2449
|
+
result: jobs.result.map((data) => new Job(data, this.httpClient)),
|
|
2387
2450
|
}));
|
|
2388
2451
|
}
|
|
2389
2452
|
getJob(jobId) {
|
|
2390
|
-
return this.httpClient
|
|
2453
|
+
return this.httpClient
|
|
2454
|
+
.get(`/jobs/${jobId}`)
|
|
2455
|
+
.then((response) => response.json())
|
|
2456
|
+
.then((data) => new Job(data, this.httpClient));
|
|
2391
2457
|
}
|
|
2392
2458
|
createJob(fileId, outputFormat, parameters) {
|
|
2393
|
-
return this.httpClient
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2459
|
+
return this.httpClient
|
|
2460
|
+
.post("/jobs", {
|
|
2461
|
+
fileId,
|
|
2462
|
+
outputFormat,
|
|
2463
|
+
parameters: parseArgs(parameters),
|
|
2464
|
+
})
|
|
2465
|
+
.then((response) => response.json())
|
|
2466
|
+
.then((data) => new Job(data, this.httpClient));
|
|
2398
2467
|
}
|
|
2399
2468
|
deleteJob(jobId) {
|
|
2400
|
-
return this.httpClient.delete(`/jobs/${jobId}`).then(response => response.json());
|
|
2469
|
+
return this.httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
|
|
2401
2470
|
}
|
|
2402
2471
|
getAssemblies(start, limit, name, ids, sortByDesc, sortField) {
|
|
2403
|
-
const searchParams = new URLSearchParams;
|
|
2404
|
-
if (start > 0)
|
|
2405
|
-
|
|
2406
|
-
if (
|
|
2472
|
+
const searchParams = new URLSearchParams();
|
|
2473
|
+
if (start > 0)
|
|
2474
|
+
searchParams.set("start", start.toString());
|
|
2475
|
+
if (limit > 0)
|
|
2476
|
+
searchParams.set("limit", limit.toString());
|
|
2477
|
+
if (name)
|
|
2478
|
+
searchParams.set("name", name);
|
|
2407
2479
|
if (ids) {
|
|
2408
|
-
if (Array.isArray(ids))
|
|
2409
|
-
|
|
2410
|
-
if (ids
|
|
2480
|
+
if (Array.isArray(ids))
|
|
2481
|
+
ids = ids.join("|");
|
|
2482
|
+
if (typeof ids === "string")
|
|
2483
|
+
ids = ids.trim();
|
|
2484
|
+
if (ids)
|
|
2485
|
+
searchParams.set("id", ids);
|
|
2411
2486
|
}
|
|
2412
|
-
if (sortByDesc !== undefined)
|
|
2413
|
-
|
|
2487
|
+
if (sortByDesc !== undefined)
|
|
2488
|
+
searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
2489
|
+
if (sortField)
|
|
2490
|
+
searchParams.set("sortField", sortField);
|
|
2414
2491
|
let queryString = searchParams.toString();
|
|
2415
|
-
if (queryString)
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2492
|
+
if (queryString)
|
|
2493
|
+
queryString = "?" + queryString;
|
|
2494
|
+
return this.httpClient
|
|
2495
|
+
.get(`/assemblies${queryString}`)
|
|
2496
|
+
.then((response) => response.json())
|
|
2497
|
+
.then((assemblies) => {
|
|
2498
|
+
return {
|
|
2499
|
+
...assemblies,
|
|
2500
|
+
result: assemblies.result.map((data) => new Assembly(data, this.httpClient)),
|
|
2501
|
+
};
|
|
2502
|
+
});
|
|
2420
2503
|
}
|
|
2421
2504
|
getAssembly(assemblyId) {
|
|
2422
|
-
return this.httpClient
|
|
2505
|
+
return this.httpClient
|
|
2506
|
+
.get(`/assemblies/${assemblyId}`)
|
|
2507
|
+
.then((response) => response.json())
|
|
2508
|
+
.then((data) => new Assembly(data, this.httpClient));
|
|
2423
2509
|
}
|
|
2424
2510
|
createAssembly(files, name, params = {}) {
|
|
2425
2511
|
const jobParameters = params.jobParameters || {};
|
|
2426
|
-
return this.httpClient
|
|
2427
|
-
|
|
2428
|
-
|
|
2512
|
+
return this.httpClient
|
|
2513
|
+
.post("/assemblies", {
|
|
2514
|
+
name,
|
|
2515
|
+
files,
|
|
2429
2516
|
jobParameters: {
|
|
2430
2517
|
geometry: parseArgs(jobParameters.geometry),
|
|
2431
|
-
properties: parseArgs(jobParameters.properties)
|
|
2432
|
-
}
|
|
2433
|
-
})
|
|
2518
|
+
properties: parseArgs(jobParameters.properties),
|
|
2519
|
+
},
|
|
2520
|
+
})
|
|
2521
|
+
.then((response) => response.json())
|
|
2522
|
+
.then((data) => new Assembly(data, this.httpClient))
|
|
2523
|
+
.then((result) => (params.waitForDone ? result.waitForDone(params) : result));
|
|
2434
2524
|
}
|
|
2435
2525
|
deleteAssembly(assemblyId) {
|
|
2436
|
-
return this.httpClient.delete(`/assemblies/${assemblyId}`).then(response => response.json());
|
|
2526
|
+
return this.httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
|
|
2437
2527
|
}
|
|
2438
2528
|
getProjects(start, limit, name, ids, sortByDesc) {
|
|
2439
|
-
const searchParams = new URLSearchParams;
|
|
2440
|
-
if (start > 0)
|
|
2441
|
-
|
|
2442
|
-
if (
|
|
2529
|
+
const searchParams = new URLSearchParams();
|
|
2530
|
+
if (start > 0)
|
|
2531
|
+
searchParams.set("start", start.toString());
|
|
2532
|
+
if (limit > 0)
|
|
2533
|
+
searchParams.set("limit", limit.toString());
|
|
2534
|
+
if (name)
|
|
2535
|
+
searchParams.set("name", name);
|
|
2443
2536
|
if (ids) {
|
|
2444
|
-
if (Array.isArray(ids))
|
|
2445
|
-
|
|
2446
|
-
if (ids
|
|
2537
|
+
if (Array.isArray(ids))
|
|
2538
|
+
ids = ids.join("|");
|
|
2539
|
+
if (typeof ids === "string")
|
|
2540
|
+
ids = ids.trim();
|
|
2541
|
+
if (ids)
|
|
2542
|
+
searchParams.set("id", ids);
|
|
2447
2543
|
}
|
|
2448
|
-
if (sortByDesc !== undefined)
|
|
2544
|
+
if (sortByDesc !== undefined)
|
|
2545
|
+
searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
2449
2546
|
let queryString = searchParams.toString();
|
|
2450
|
-
if (queryString)
|
|
2451
|
-
|
|
2547
|
+
if (queryString)
|
|
2548
|
+
queryString = "?" + queryString;
|
|
2549
|
+
return this.httpClient
|
|
2550
|
+
.get(`/projects${queryString}`)
|
|
2551
|
+
.then((response) => response.json())
|
|
2552
|
+
.then((projects) => {
|
|
2452
2553
|
if (Array.isArray(projects)) {
|
|
2453
2554
|
let result = projects;
|
|
2454
|
-
if (ids)
|
|
2455
|
-
|
|
2555
|
+
if (ids)
|
|
2556
|
+
result = result.filter((x) => ids.includes(x.id));
|
|
2557
|
+
if (name)
|
|
2558
|
+
result = result.filter((x) => x.name.includes(name));
|
|
2456
2559
|
if (limit > 0) {
|
|
2457
2560
|
const begin = start > 0 ? start : 0;
|
|
2458
2561
|
result = result.slice(begin, begin + limit);
|
|
2459
2562
|
}
|
|
2460
2563
|
return {
|
|
2461
2564
|
allSize: projects.length,
|
|
2462
|
-
start
|
|
2463
|
-
limit
|
|
2464
|
-
result
|
|
2465
|
-
size: result.length
|
|
2565
|
+
start,
|
|
2566
|
+
limit,
|
|
2567
|
+
result,
|
|
2568
|
+
size: result.length,
|
|
2466
2569
|
};
|
|
2467
2570
|
}
|
|
2468
2571
|
return projects;
|
|
2469
|
-
})
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2572
|
+
})
|
|
2573
|
+
.then((projects) => {
|
|
2574
|
+
return {
|
|
2575
|
+
...projects,
|
|
2576
|
+
result: projects.result.map((data) => new Project(data, this.httpClient)),
|
|
2577
|
+
};
|
|
2578
|
+
});
|
|
2473
2579
|
}
|
|
2474
2580
|
getProject(projectId) {
|
|
2475
|
-
return this.httpClient
|
|
2581
|
+
return this.httpClient
|
|
2582
|
+
.get(`/projects/${projectId}`)
|
|
2583
|
+
.then((response) => response.json())
|
|
2584
|
+
.then((data) => new Project(data, this.httpClient));
|
|
2476
2585
|
}
|
|
2477
2586
|
createProject(name, description, startDate, endDate) {
|
|
2478
|
-
return this.httpClient
|
|
2479
|
-
|
|
2480
|
-
|
|
2587
|
+
return this.httpClient
|
|
2588
|
+
.post("/projects", {
|
|
2589
|
+
name,
|
|
2590
|
+
description,
|
|
2481
2591
|
startDate: startDate instanceof Date ? startDate.toISOString() : startDate,
|
|
2482
|
-
endDate: endDate instanceof Date ? endDate.toISOString() : endDate
|
|
2483
|
-
})
|
|
2592
|
+
endDate: endDate instanceof Date ? endDate.toISOString() : endDate,
|
|
2593
|
+
})
|
|
2594
|
+
.then((response) => response.json())
|
|
2595
|
+
.then((data) => new Project(data, this.httpClient));
|
|
2484
2596
|
}
|
|
2485
2597
|
deleteProject(projectId) {
|
|
2486
|
-
return this.httpClient
|
|
2598
|
+
return this.httpClient
|
|
2599
|
+
.delete(`/projects/${projectId}`)
|
|
2600
|
+
.then((response) => response.text())
|
|
2601
|
+
.then((text) => {
|
|
2487
2602
|
try {
|
|
2488
2603
|
return JSON.parse(text);
|
|
2489
|
-
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
};
|
|
2604
|
+
}
|
|
2605
|
+
catch {
|
|
2606
|
+
return { id: projectId };
|
|
2493
2607
|
}
|
|
2494
2608
|
});
|
|
2495
2609
|
}
|
|
2496
2610
|
getSharedLink(token) {
|
|
2497
|
-
return this.httpClient
|
|
2611
|
+
return this.httpClient
|
|
2612
|
+
.get(`/shares/${token}`)
|
|
2613
|
+
.then((response) => response.json())
|
|
2614
|
+
.then((data) => new SharedLink(data, this.httpClient));
|
|
2498
2615
|
}
|
|
2499
2616
|
createSharedLink(fileId, permissions) {
|
|
2500
|
-
return this.httpClient
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2617
|
+
return this.httpClient
|
|
2618
|
+
.post("/shares", {
|
|
2619
|
+
fileId,
|
|
2620
|
+
permissions,
|
|
2621
|
+
})
|
|
2622
|
+
.then((response) => response.json())
|
|
2623
|
+
.then((data) => new SharedLink(data, this.httpClient));
|
|
2504
2624
|
}
|
|
2505
2625
|
deleteSharedLink(token) {
|
|
2506
|
-
return this.httpClient.delete(`/shares/${token}`).then(response => response.json());
|
|
2626
|
+
return this.httpClient.delete(`/shares/${token}`).then((response) => response.json());
|
|
2507
2627
|
}
|
|
2508
2628
|
getSharedFile(token, password) {
|
|
2509
|
-
return this.httpClient
|
|
2510
|
-
headers: {
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
}).then(response => response.json()).then(data => new SharedFile(data, password, this.httpClient));
|
|
2629
|
+
return this.httpClient
|
|
2630
|
+
.get(`/shares/${token}/info`, { headers: { "InWeb-Password": password } })
|
|
2631
|
+
.then((response) => response.json())
|
|
2632
|
+
.then((data) => new SharedFile(data, password, this.httpClient));
|
|
2514
2633
|
}
|
|
2515
2634
|
getPlugins() {
|
|
2516
|
-
return this.httpClient
|
|
2635
|
+
return this.httpClient
|
|
2636
|
+
.get("/plugins")
|
|
2637
|
+
.then((response) => response.json())
|
|
2638
|
+
.then((array) => array.map((data) => new Plugin(data, this.httpClient)));
|
|
2517
2639
|
}
|
|
2518
2640
|
getPlugin(name, version) {
|
|
2519
|
-
return this.httpClient
|
|
2641
|
+
return this.httpClient
|
|
2642
|
+
.get(`/plugins/${name}/${version}`)
|
|
2643
|
+
.then((response) => response.json())
|
|
2644
|
+
.then((data) => new Plugin(data, this.httpClient));
|
|
2520
2645
|
}
|
|
2521
2646
|
async uploadPlugin(file, onProgress) {
|
|
2522
|
-
return await this.httpClient
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2647
|
+
return await this.httpClient
|
|
2648
|
+
.uploadFile("/plugins", file, (progress) => {
|
|
2649
|
+
this.emitEvent({ type: "uploadprogress", data: progress, file });
|
|
2650
|
+
if (onProgress)
|
|
2651
|
+
onProgress(progress, file);
|
|
2652
|
+
})
|
|
2653
|
+
.then((xhr) => JSON.parse(xhr.responseText))
|
|
2654
|
+
.then((data) => new Plugin(data, this.httpClient));
|
|
2530
2655
|
}
|
|
2531
2656
|
deletePlugin(name, version) {
|
|
2532
|
-
return this.httpClient.delete(`/plugins/${name}/${version}`).then(response => response.json());
|
|
2657
|
+
return this.httpClient.delete(`/plugins/${name}/${version}`).then((response) => response.json());
|
|
2533
2658
|
}
|
|
2534
2659
|
downloadPlugin(name, version, onProgress, signal) {
|
|
2535
|
-
return this.httpClient
|
|
2536
|
-
signal
|
|
2537
|
-
|
|
2660
|
+
return this.httpClient
|
|
2661
|
+
.downloadFile(`/plugins/${name}/${version}/download`, onProgress, { signal })
|
|
2662
|
+
.then((response) => response.arrayBuffer());
|
|
2538
2663
|
}
|
|
2539
2664
|
executePluginCommand(name, version, command, parameters) {
|
|
2540
|
-
const searchParams = new URLSearchParams;
|
|
2541
|
-
if (version)
|
|
2665
|
+
const searchParams = new URLSearchParams();
|
|
2666
|
+
if (version)
|
|
2667
|
+
searchParams.set("version", version);
|
|
2542
2668
|
let queryString = searchParams.toString();
|
|
2543
|
-
if (queryString)
|
|
2544
|
-
|
|
2669
|
+
if (queryString)
|
|
2670
|
+
queryString = "?" + queryString;
|
|
2671
|
+
return this.httpClient
|
|
2672
|
+
.post(`/plugins/${name}/commands/${command}${queryString}`, parameters)
|
|
2673
|
+
.then((response) => response.json());
|
|
2545
2674
|
}
|
|
2546
2675
|
}
|
|
2547
2676
|
|
|
2548
|
-
const version = "26.9.
|
|
2677
|
+
const version = "26.9.5";
|
|
2549
2678
|
|
|
2550
2679
|
export { Assembly, ClashTest, Client, Endpoint, FetchError, File, Job, Member, Model, OAuthClient, Permission, Plugin, Project, Role, SharedFile, SharedLink, User, parseArgs, statusText, userFullName, userInitials, version, waitFor };
|
|
2551
2680
|
//# sourceMappingURL=client.module.js.map
|