@inweb/client 25.3.15 → 25.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +698 -527
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +473 -484
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +32 -8
- package/lib/Api/ClashTest.d.ts +1 -1
- package/lib/Api/Client.d.ts +2 -3
- package/lib/Api/Fetch.d.ts +6 -0
- package/lib/Api/{impl/FetchError.d.ts → FetchError.d.ts} +2 -0
- package/lib/Api/File.d.ts +34 -10
- package/lib/Api/HttpClient.d.ts +9 -3
- package/lib/Api/IHttpClient.d.ts +10 -4
- package/lib/Api/Job.d.ts +1 -1
- package/lib/Api/Model.d.ts +33 -9
- package/lib/Api/Project.d.ts +3 -3
- package/lib/Api/User.d.ts +1 -1
- package/lib/Api/Utils.d.ts +11 -0
- package/lib/Api/XMLHttp.d.ts +7 -0
- package/lib/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/Api/Assembly.ts +76 -70
- package/src/Api/ClashTest.ts +10 -19
- package/src/Api/Client.ts +92 -56
- package/src/Api/Fetch.ts +84 -0
- package/src/Api/{impl/http.ts → FetchError.ts} +33 -1
- package/src/Api/File.ts +112 -117
- package/src/Api/HttpClient.ts +107 -20
- package/src/Api/IHttpClient.ts +17 -12
- package/src/Api/Job.ts +7 -5
- package/src/Api/Member.ts +7 -5
- package/src/Api/Model.ts +61 -14
- package/src/Api/Permission.ts +6 -5
- package/src/Api/Project.ts +93 -88
- package/src/Api/Role.ts +6 -5
- package/src/Api/User.ts +28 -17
- package/src/Api/Utils.ts +104 -0
- package/src/Api/XMLHttp.ts +72 -0
- package/src/index.ts +1 -1
- package/lib/Api/impl/Utils.d.ts +0 -32
- package/lib/Api/impl/http.d.ts +0 -66
- package/src/Api/impl/FetchError.ts +0 -48
- package/src/Api/impl/Utils.ts +0 -367
package/dist/client.js
CHANGED
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
this._data = value;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Scene description file
|
|
65
|
-
*
|
|
64
|
+
* Scene description resource file name. Use {@link Model.downloadResource()} to download
|
|
65
|
+
* scene description file.
|
|
66
66
|
*
|
|
67
67
|
* @readonly
|
|
68
68
|
*/
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
return this.data.fileId;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
* The list of
|
|
98
|
-
*
|
|
97
|
+
* The list of geometry data resource files. Use {@link Model.downloadResource()} to download
|
|
98
|
+
* geometry data files.
|
|
99
99
|
*
|
|
100
100
|
* @readonly
|
|
101
101
|
*/
|
|
@@ -218,10 +218,11 @@
|
|
|
218
218
|
return this._file.getSnapshotData(guid, bitmapGuid);
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
|
-
*
|
|
221
|
+
* Download model resource file. Resource files are files that contain model scene
|
|
222
|
+
* descriptions, or geometry data.
|
|
222
223
|
*
|
|
223
224
|
* @async
|
|
224
|
-
* @param
|
|
225
|
+
* @param dataId - Resource file name.
|
|
225
226
|
* @param onProgress - Download progress callback.
|
|
226
227
|
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
227
228
|
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
@@ -230,12 +231,50 @@
|
|
|
230
231
|
downloadResource(dataId, onProgress, signal) {
|
|
231
232
|
return this._file.downloadResource(dataId, onProgress, signal);
|
|
232
233
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
/**
|
|
235
|
+
* Download a part of model resource file. Resource files are files that contain model scene
|
|
236
|
+
* descriptions, or geometry data.
|
|
237
|
+
*
|
|
238
|
+
* @param dataId - Resource file name.
|
|
239
|
+
* @param ranges - A range of resource file contents to download.
|
|
240
|
+
* @param requestId - Request ID for download progress callback.
|
|
241
|
+
* @param onProgress - Download progress callback.
|
|
242
|
+
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
243
|
+
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
244
|
+
* and abort it if desired.
|
|
245
|
+
*/
|
|
246
|
+
downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
|
|
247
|
+
return this._file.downloadResourceRange(dataId, ranges, requestId, onProgress, signal);
|
|
236
248
|
}
|
|
237
|
-
|
|
238
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Deprecated since `25.3`. Use {@link Model.downloadResource()} instead.
|
|
251
|
+
*/
|
|
252
|
+
partialDownloadResource(dataId, onProgress, signal) {
|
|
253
|
+
console.warn("Model.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Model.downloadResource() instead.");
|
|
254
|
+
return this.downloadResource(dataId, onProgress, signal);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Deprecated since `25.3`. Use {@link Model.downloadResourceRange()} instead.
|
|
258
|
+
*/
|
|
259
|
+
async downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
260
|
+
if (!records)
|
|
261
|
+
return;
|
|
262
|
+
let ranges = [];
|
|
263
|
+
if (records.length) {
|
|
264
|
+
ranges = records.map((record) => ({
|
|
265
|
+
begin: Number(record.begin),
|
|
266
|
+
end: Number(record.end),
|
|
267
|
+
requestId: record.reqId,
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
for (let i = 0; i < records.size(); i++) {
|
|
272
|
+
const record = records.get(i);
|
|
273
|
+
ranges.push({ begin: Number(record.begin), end: Number(record.end), requestId });
|
|
274
|
+
record.delete();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
await this.downloadResourceRange(dataId, ranges, requestId, onProgress, signal);
|
|
239
278
|
}
|
|
240
279
|
/**
|
|
241
280
|
* Returns a list of references to files used to extract geometry data.
|
|
@@ -272,243 +311,6 @@
|
|
|
272
311
|
// By use of this software, its documentation or related materials, you
|
|
273
312
|
// acknowledge and accept the above terms.
|
|
274
313
|
///////////////////////////////////////////////////////////////////////////////
|
|
275
|
-
const STATUS_CODES = {
|
|
276
|
-
100: "Continue",
|
|
277
|
-
101: "Switching Protocols",
|
|
278
|
-
102: "Processing",
|
|
279
|
-
103: "Early Hints",
|
|
280
|
-
200: "OK",
|
|
281
|
-
201: "Created",
|
|
282
|
-
202: "Accepted",
|
|
283
|
-
203: "Non-Authoritative Information",
|
|
284
|
-
204: "No Content",
|
|
285
|
-
205: "Reset Content",
|
|
286
|
-
206: "Partial Content",
|
|
287
|
-
207: "Multi-Status",
|
|
288
|
-
208: "Already Reported",
|
|
289
|
-
226: "IM Used",
|
|
290
|
-
300: "Multiple Choices",
|
|
291
|
-
301: "Moved Permanently",
|
|
292
|
-
302: "Found",
|
|
293
|
-
303: "See Other",
|
|
294
|
-
304: "Not Modified",
|
|
295
|
-
305: "Use Proxy",
|
|
296
|
-
307: "Temporary Redirect",
|
|
297
|
-
308: "Permanent Redirect",
|
|
298
|
-
400: "Bad Request",
|
|
299
|
-
401: "Unauthorized",
|
|
300
|
-
402: "Payment Required",
|
|
301
|
-
403: "Forbidden",
|
|
302
|
-
404: "Not Found",
|
|
303
|
-
405: "Method Not Allowed",
|
|
304
|
-
406: "Not Acceptable",
|
|
305
|
-
407: "Proxy Authentication Required",
|
|
306
|
-
408: "Request Time-out",
|
|
307
|
-
409: "Conflict",
|
|
308
|
-
410: "Gone",
|
|
309
|
-
411: "Length Required",
|
|
310
|
-
412: "Precondition Failed",
|
|
311
|
-
413: "Payload Too Large",
|
|
312
|
-
414: "URI Too Long",
|
|
313
|
-
415: "Unsupported Media Type",
|
|
314
|
-
416: "Range Not Satisfiable",
|
|
315
|
-
417: "Expectation Failed",
|
|
316
|
-
418: "I'm a teapot",
|
|
317
|
-
421: "Misdirected Request",
|
|
318
|
-
422: "Unprocessable Entity",
|
|
319
|
-
423: "Locked",
|
|
320
|
-
424: "Failed Dependency",
|
|
321
|
-
425: "Too Early",
|
|
322
|
-
426: "Upgrade Required",
|
|
323
|
-
428: "Precondition Required",
|
|
324
|
-
429: "Too Many Requests",
|
|
325
|
-
431: "Header Fields Too Large",
|
|
326
|
-
451: "Unavailable For Legal Reasons",
|
|
327
|
-
500: "Internal Server Error",
|
|
328
|
-
501: "Not Implemented",
|
|
329
|
-
502: "Bad Gateway",
|
|
330
|
-
503: "Service Unavailable",
|
|
331
|
-
504: "Gateway Timeout",
|
|
332
|
-
505: "HTTP Version Not Supported",
|
|
333
|
-
506: "Variant Also Negotiates",
|
|
334
|
-
507: "Insufficient Storage",
|
|
335
|
-
508: "Loop Detected",
|
|
336
|
-
509: "Bandwidth Limit Exceeded",
|
|
337
|
-
510: "Not Extended",
|
|
338
|
-
511: "Network Authentication Required",
|
|
339
|
-
};
|
|
340
|
-
function statusText(status) {
|
|
341
|
-
return STATUS_CODES[status] || `Error ${status}`;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
345
|
-
/**
|
|
346
|
-
* The `FetchError` object indicates an error when request to Open Cloud Server could not be
|
|
347
|
-
* performed. A `FetchError` is typically (but not exclusively) thrown when a network error
|
|
348
|
-
* occurs, access denied, or object not found.
|
|
349
|
-
*/
|
|
350
|
-
class FetchError extends Error {
|
|
351
|
-
/**
|
|
352
|
-
* @property status - The <a href="https://developer.mozilla.org/docs/Web/HTTP/Status" target
|
|
353
|
-
* ="_blank">HTTP status code</a> of the response.
|
|
354
|
-
* @property message - Error message. Inherited from <a
|
|
355
|
-
* href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error"
|
|
356
|
-
* target ="_blank">Error</a>.
|
|
357
|
-
*/
|
|
358
|
-
constructor(status, message) {
|
|
359
|
-
super(message || statusText(status));
|
|
360
|
-
this.status = status;
|
|
361
|
-
this.statusText = statusText(status);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
366
|
-
function json(request) {
|
|
367
|
-
return request.then((response) => response.json());
|
|
368
|
-
}
|
|
369
|
-
function text(request) {
|
|
370
|
-
return request.then((response) => response.text());
|
|
371
|
-
}
|
|
372
|
-
function error400(text, _default = "400") {
|
|
373
|
-
try {
|
|
374
|
-
return JSON.parse(text).description;
|
|
375
|
-
}
|
|
376
|
-
catch {
|
|
377
|
-
return _default;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
function handleXMLHttpError(xhr) {
|
|
381
|
-
if (xhr.status === 0) {
|
|
382
|
-
return Promise.reject(new FetchError(0, "Network error"));
|
|
383
|
-
}
|
|
384
|
-
if (xhr.status < 200 || xhr.status > 299) {
|
|
385
|
-
switch (xhr.status) {
|
|
386
|
-
case 400: {
|
|
387
|
-
console.error(xhr.responseText);
|
|
388
|
-
return Promise.reject(new FetchError(400, error400(xhr.responseText)));
|
|
389
|
-
}
|
|
390
|
-
case 500: {
|
|
391
|
-
console.error(error400(xhr.responseText, xhr.responseText));
|
|
392
|
-
return Promise.reject(new FetchError(500));
|
|
393
|
-
}
|
|
394
|
-
default: {
|
|
395
|
-
return Promise.reject(new FetchError(xhr.status));
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return Promise.resolve(xhr);
|
|
400
|
-
}
|
|
401
|
-
function handleFetchError(response) {
|
|
402
|
-
if (!response.ok) {
|
|
403
|
-
switch (response.status) {
|
|
404
|
-
case 400: {
|
|
405
|
-
return response.text().then((text) => {
|
|
406
|
-
console.error(text);
|
|
407
|
-
return Promise.reject(new FetchError(400, error400(text)));
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
case 500: {
|
|
411
|
-
return response.text().then((text) => {
|
|
412
|
-
console.error(error400(text, text));
|
|
413
|
-
return Promise.reject(new FetchError(500));
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
default:
|
|
417
|
-
return Promise.reject(new FetchError(response.status, statusText(response.status)));
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return Promise.resolve(response);
|
|
421
|
-
}
|
|
422
|
-
function $init(method, headers, body, signal) {
|
|
423
|
-
headers = { ...headers };
|
|
424
|
-
headers["Content-Type"] = "application/json";
|
|
425
|
-
if (method === "POST" || method === "PUT") {
|
|
426
|
-
if (body instanceof FormData) {
|
|
427
|
-
delete headers["Content-Type"];
|
|
428
|
-
}
|
|
429
|
-
else if (body instanceof File || body instanceof Blob) {
|
|
430
|
-
const formData = new FormData();
|
|
431
|
-
formData.append("file", body);
|
|
432
|
-
return $init(method, headers, formData, signal);
|
|
433
|
-
}
|
|
434
|
-
else if (body instanceof ArrayBuffer) {
|
|
435
|
-
const blob = new Blob([body]);
|
|
436
|
-
return $init(method, headers, blob, signal);
|
|
437
|
-
}
|
|
438
|
-
else if (body && typeof body === "object") {
|
|
439
|
-
body = JSON.stringify(body);
|
|
440
|
-
}
|
|
441
|
-
else if (typeof body === "string") {
|
|
442
|
-
headers["Content-Type"] = "text/plain";
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
const result = { method, headers };
|
|
446
|
-
// body with type "object", converted to type "string" in the code above
|
|
447
|
-
if (body &&
|
|
448
|
-
(body instanceof ArrayBuffer ||
|
|
449
|
-
body instanceof Blob ||
|
|
450
|
-
body instanceof globalThis.File ||
|
|
451
|
-
body instanceof FormData ||
|
|
452
|
-
typeof body === "string")) {
|
|
453
|
-
result.body = body;
|
|
454
|
-
}
|
|
455
|
-
if (signal)
|
|
456
|
-
result.signal = signal;
|
|
457
|
-
return result;
|
|
458
|
-
}
|
|
459
|
-
function $fetch(url, init) {
|
|
460
|
-
return fetch(url, init).then((response) => handleFetchError(response));
|
|
461
|
-
}
|
|
462
|
-
function $get(url, headers, signal) {
|
|
463
|
-
return $fetch(url, $init("GET", headers, null, signal));
|
|
464
|
-
}
|
|
465
|
-
function $put(url, headers, body) {
|
|
466
|
-
return $fetch(url, $init("PUT", headers, body));
|
|
467
|
-
}
|
|
468
|
-
function $post(url, headers, body) {
|
|
469
|
-
return $fetch(url, $init("POST", headers, body));
|
|
470
|
-
}
|
|
471
|
-
function $delete(url, headers) {
|
|
472
|
-
return $fetch(url, $init("DELETE", headers));
|
|
473
|
-
}
|
|
474
|
-
function streamProgress(stream, onprogress) {
|
|
475
|
-
const reader = stream.getReader();
|
|
476
|
-
let current = 0;
|
|
477
|
-
function calc(ev) {
|
|
478
|
-
if (!ev.done) {
|
|
479
|
-
reader.read().then(calc).catch(console.error);
|
|
480
|
-
}
|
|
481
|
-
if (ev.value)
|
|
482
|
-
current += ev.value.length;
|
|
483
|
-
onprogress(current);
|
|
484
|
-
}
|
|
485
|
-
reader.read().then(calc).catch(console.error);
|
|
486
|
-
return stream;
|
|
487
|
-
}
|
|
488
|
-
function downloadProgress(response, onprogress) {
|
|
489
|
-
var _a;
|
|
490
|
-
const contentLength = (_a = response.headers.get("Content-Length")) !== null && _a !== void 0 ? _a : "";
|
|
491
|
-
const total = parseInt(contentLength, 10);
|
|
492
|
-
const tee = response.body.tee();
|
|
493
|
-
streamProgress(tee[0], (bytesCount) => onprogress && onprogress(bytesCount / total));
|
|
494
|
-
return new Response(tee[1]);
|
|
495
|
-
}
|
|
496
|
-
function $XMLHttp(url, { headers, method, body, uploadProgress, downloadProgress }) {
|
|
497
|
-
return new Promise((resolve, reject) => {
|
|
498
|
-
const xhr = new XMLHttpRequest();
|
|
499
|
-
xhr.open(method, url, true);
|
|
500
|
-
for (const key in headers) {
|
|
501
|
-
xhr.setRequestHeader(key, headers[key]);
|
|
502
|
-
}
|
|
503
|
-
function calcProgress(event) {
|
|
504
|
-
return event.lengthComputable ? event.loaded / event.total : 1;
|
|
505
|
-
}
|
|
506
|
-
xhr.upload.onprogress = (event) => uploadProgress && uploadProgress(calcProgress(event));
|
|
507
|
-
xhr.onprogress = (event) => downloadProgress && downloadProgress(calcProgress(event));
|
|
508
|
-
xhr.onloadend = (event) => handleXMLHttpError(event.target).then(resolve, reject);
|
|
509
|
-
xhr.send(body);
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
314
|
function delay(ms, signal) {
|
|
513
315
|
return new Promise((resolve) => {
|
|
514
316
|
let timeoutId = 0;
|
|
@@ -540,74 +342,6 @@
|
|
|
540
342
|
} while (performance.now() < end && --count > 0);
|
|
541
343
|
return Promise.reject(timeoutError);
|
|
542
344
|
}
|
|
543
|
-
async function downloadPartOfFile(requestId, records, url, defHeaders, onProgress, signal) {
|
|
544
|
-
var _a;
|
|
545
|
-
const headers = { ...defHeaders };
|
|
546
|
-
const isMultipleResourceParts = records && records.length;
|
|
547
|
-
if (records) {
|
|
548
|
-
const ranges = [];
|
|
549
|
-
if (isMultipleResourceParts) {
|
|
550
|
-
for (let i = 0; i < records.length; i++) {
|
|
551
|
-
const record = records[i];
|
|
552
|
-
ranges.push(`${record.begin}-${record.end}`);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
for (let i = 0; i < records.size(); i++) {
|
|
557
|
-
const record = records.get(i);
|
|
558
|
-
ranges.push(`${record.begin}-${record.end}`);
|
|
559
|
-
record.delete();
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
headers["Range"] = "bytes=" + ranges.join(",");
|
|
563
|
-
}
|
|
564
|
-
const response = await $fetch(url, $init("GET", headers, null, signal));
|
|
565
|
-
const contentLength = (_a = response.headers.get("content-length")) !== null && _a !== void 0 ? _a : "";
|
|
566
|
-
const total = parseInt(contentLength, 10);
|
|
567
|
-
const reader = response.body.getReader();
|
|
568
|
-
if (isMultipleResourceParts) {
|
|
569
|
-
let curRecordIndex = 0;
|
|
570
|
-
let curRecordPos = 0;
|
|
571
|
-
while (true) {
|
|
572
|
-
const { done, value } = await reader.read();
|
|
573
|
-
if (done)
|
|
574
|
-
break;
|
|
575
|
-
let totalLeft = value.byteLength;
|
|
576
|
-
let loadedPos = 0;
|
|
577
|
-
while (totalLeft > 0) {
|
|
578
|
-
const curRecord = records[curRecordIndex];
|
|
579
|
-
const recLeft = curRecord.size - curRecordPos;
|
|
580
|
-
if (totalLeft < recLeft) {
|
|
581
|
-
const buf = value.subarray(loadedPos, loadedPos + totalLeft);
|
|
582
|
-
if (typeof onProgress === "function")
|
|
583
|
-
onProgress(loadedPos / total, buf, curRecord.reqId);
|
|
584
|
-
curRecordPos += totalLeft;
|
|
585
|
-
totalLeft = 0;
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
const buf = value.subarray(loadedPos, loadedPos + recLeft);
|
|
589
|
-
if (typeof onProgress === "function")
|
|
590
|
-
onProgress(loadedPos / total, buf, curRecord.reqId);
|
|
591
|
-
curRecordIndex++;
|
|
592
|
-
curRecordPos = 0;
|
|
593
|
-
loadedPos += recLeft;
|
|
594
|
-
totalLeft -= recLeft;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
600
|
-
let loaded = 0;
|
|
601
|
-
while (true) {
|
|
602
|
-
const { done, value } = await reader.read();
|
|
603
|
-
if (done)
|
|
604
|
-
break;
|
|
605
|
-
loaded += value.byteLength;
|
|
606
|
-
if (onProgress)
|
|
607
|
-
onProgress(loaded / total, value, requestId);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
345
|
function parseArgs(args) {
|
|
612
346
|
if (typeof args === "string") {
|
|
613
347
|
const firstArg = args.indexOf("--");
|
|
@@ -810,13 +544,10 @@
|
|
|
810
544
|
*
|
|
811
545
|
* @async
|
|
812
546
|
*/
|
|
813
|
-
checkout() {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
this.data = data;
|
|
818
|
-
return this;
|
|
819
|
-
});
|
|
547
|
+
async checkout() {
|
|
548
|
+
const response = await this.internalGet("");
|
|
549
|
+
this.data = await response.json();
|
|
550
|
+
return this;
|
|
820
551
|
}
|
|
821
552
|
/**
|
|
822
553
|
* Update test data on the server.
|
|
@@ -824,13 +555,10 @@
|
|
|
824
555
|
* @async
|
|
825
556
|
* @param data - Raw test data.
|
|
826
557
|
*/
|
|
827
|
-
update(data) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
this.data = data;
|
|
832
|
-
return this;
|
|
833
|
-
});
|
|
558
|
+
async update(data) {
|
|
559
|
+
const response = await this.internalPut("", data);
|
|
560
|
+
this.data = await response.json();
|
|
561
|
+
return this;
|
|
834
562
|
}
|
|
835
563
|
/**
|
|
836
564
|
* Remove a test from a file.
|
|
@@ -868,12 +596,130 @@
|
|
|
868
596
|
return waitFor(checkDone, params).then(() => this);
|
|
869
597
|
}
|
|
870
598
|
/**
|
|
871
|
-
* Returns a report with the clash detection results for this test.
|
|
872
|
-
*
|
|
873
|
-
* @async
|
|
599
|
+
* Returns a report with the clash detection results for this test.
|
|
600
|
+
*
|
|
601
|
+
* @async
|
|
602
|
+
*/
|
|
603
|
+
getReport() {
|
|
604
|
+
return this.internalGet("/report").then((response) => response.json());
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
609
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
610
|
+
// All rights reserved.
|
|
611
|
+
//
|
|
612
|
+
// This software and its documentation and related materials are owned by
|
|
613
|
+
// the Alliance. The software may only be incorporated into application
|
|
614
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
615
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
616
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
617
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
618
|
+
// protected by copyright law and international treaty provisions. Application
|
|
619
|
+
// programs incorporating this software must include the following statement
|
|
620
|
+
// with their copyright notices:
|
|
621
|
+
//
|
|
622
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
623
|
+
// license agreement with Open Design Alliance.
|
|
624
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
625
|
+
// All rights reserved.
|
|
626
|
+
//
|
|
627
|
+
// By use of this software, its documentation or related materials, you
|
|
628
|
+
// acknowledge and accept the above terms.
|
|
629
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
630
|
+
const STATUS_CODES = {
|
|
631
|
+
100: "Continue",
|
|
632
|
+
101: "Switching Protocols",
|
|
633
|
+
102: "Processing",
|
|
634
|
+
103: "Early Hints",
|
|
635
|
+
200: "OK",
|
|
636
|
+
201: "Created",
|
|
637
|
+
202: "Accepted",
|
|
638
|
+
203: "Non-Authoritative Information",
|
|
639
|
+
204: "No Content",
|
|
640
|
+
205: "Reset Content",
|
|
641
|
+
206: "Partial Content",
|
|
642
|
+
207: "Multi-Status",
|
|
643
|
+
208: "Already Reported",
|
|
644
|
+
226: "IM Used",
|
|
645
|
+
300: "Multiple Choices",
|
|
646
|
+
301: "Moved Permanently",
|
|
647
|
+
302: "Found",
|
|
648
|
+
303: "See Other",
|
|
649
|
+
304: "Not Modified",
|
|
650
|
+
305: "Use Proxy",
|
|
651
|
+
307: "Temporary Redirect",
|
|
652
|
+
308: "Permanent Redirect",
|
|
653
|
+
400: "Bad Request",
|
|
654
|
+
401: "Unauthorized",
|
|
655
|
+
402: "Payment Required",
|
|
656
|
+
403: "Forbidden",
|
|
657
|
+
404: "Not Found",
|
|
658
|
+
405: "Method Not Allowed",
|
|
659
|
+
406: "Not Acceptable",
|
|
660
|
+
407: "Proxy Authentication Required",
|
|
661
|
+
408: "Request Time-out",
|
|
662
|
+
409: "Conflict",
|
|
663
|
+
410: "Gone",
|
|
664
|
+
411: "Length Required",
|
|
665
|
+
412: "Precondition Failed",
|
|
666
|
+
413: "Payload Too Large",
|
|
667
|
+
414: "URI Too Long",
|
|
668
|
+
415: "Unsupported Media Type",
|
|
669
|
+
416: "Range Not Satisfiable",
|
|
670
|
+
417: "Expectation Failed",
|
|
671
|
+
418: "I'm a teapot",
|
|
672
|
+
421: "Misdirected Request",
|
|
673
|
+
422: "Unprocessable Entity",
|
|
674
|
+
423: "Locked",
|
|
675
|
+
424: "Failed Dependency",
|
|
676
|
+
425: "Too Early",
|
|
677
|
+
426: "Upgrade Required",
|
|
678
|
+
428: "Precondition Required",
|
|
679
|
+
429: "Too Many Requests",
|
|
680
|
+
431: "Header Fields Too Large",
|
|
681
|
+
451: "Unavailable For Legal Reasons",
|
|
682
|
+
500: "Internal Server Error",
|
|
683
|
+
501: "Not Implemented",
|
|
684
|
+
502: "Bad Gateway",
|
|
685
|
+
503: "Service Unavailable",
|
|
686
|
+
504: "Gateway Timeout",
|
|
687
|
+
505: "HTTP Version Not Supported",
|
|
688
|
+
506: "Variant Also Negotiates",
|
|
689
|
+
507: "Insufficient Storage",
|
|
690
|
+
508: "Loop Detected",
|
|
691
|
+
509: "Bandwidth Limit Exceeded",
|
|
692
|
+
510: "Not Extended",
|
|
693
|
+
511: "Network Authentication Required",
|
|
694
|
+
};
|
|
695
|
+
function statusText(status) {
|
|
696
|
+
return STATUS_CODES[status] || `Error ${status}`;
|
|
697
|
+
}
|
|
698
|
+
function error400(text, _default = "400") {
|
|
699
|
+
try {
|
|
700
|
+
return JSON.parse(text).description;
|
|
701
|
+
}
|
|
702
|
+
catch {
|
|
703
|
+
return _default;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* The `FetchError` object indicates an error when request to Open Cloud Server could not be
|
|
708
|
+
* performed. A `FetchError` is typically (but not exclusively) thrown when a network error
|
|
709
|
+
* occurs, access denied, or object not found.
|
|
710
|
+
*/
|
|
711
|
+
class FetchError extends Error {
|
|
712
|
+
/**
|
|
713
|
+
* @property status - The <a href="https://developer.mozilla.org/docs/Web/HTTP/Status" target
|
|
714
|
+
* ="_blank">HTTP status code</a> of the response.
|
|
715
|
+
* @property message - Error message. Inherited from <a
|
|
716
|
+
* href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error"
|
|
717
|
+
* target ="_blank">Error</a>.
|
|
874
718
|
*/
|
|
875
|
-
|
|
876
|
-
|
|
719
|
+
constructor(status, message) {
|
|
720
|
+
super(message || statusText(status));
|
|
721
|
+
this.status = status;
|
|
722
|
+
this.statusText = statusText(status);
|
|
877
723
|
}
|
|
878
724
|
}
|
|
879
725
|
|
|
@@ -913,34 +759,6 @@
|
|
|
913
759
|
relativePath = this.appendVersionParam(relativePath);
|
|
914
760
|
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
915
761
|
}
|
|
916
|
-
async partialDownloadResource(dataId, onProgress, signal) {
|
|
917
|
-
var _a;
|
|
918
|
-
let pathname = `${this.path}/downloads/${dataId}`;
|
|
919
|
-
pathname = this.appendVersionParam(pathname);
|
|
920
|
-
// TODO: replace with $get to handle fetch errors
|
|
921
|
-
const response = await fetch(`${this.httpClient.serverUrl}${pathname}`, {
|
|
922
|
-
headers: this.httpClient.headers,
|
|
923
|
-
signal,
|
|
924
|
-
});
|
|
925
|
-
// TODO: use ReadableStream pipeTo()
|
|
926
|
-
const contentLength = (_a = response.headers.get("Content-Length")) !== null && _a !== void 0 ? _a : "";
|
|
927
|
-
const total = parseInt(contentLength, 10);
|
|
928
|
-
const reader = response.body.getReader();
|
|
929
|
-
let loaded = 0;
|
|
930
|
-
while (true) {
|
|
931
|
-
const { done, value } = await reader.read();
|
|
932
|
-
if (done)
|
|
933
|
-
break;
|
|
934
|
-
loaded += value.byteLength;
|
|
935
|
-
if (typeof onProgress === "function")
|
|
936
|
-
onProgress(loaded / total, value);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
940
|
-
let pathname = `${this.path}/downloads/${dataId}?requestId=${requestId}`;
|
|
941
|
-
pathname = this.appendVersionParam(pathname);
|
|
942
|
-
return downloadPartOfFile(requestId, records, `${this.httpClient.serverUrl}${pathname}`, this.httpClient.headers, onProgress, signal);
|
|
943
|
-
}
|
|
944
762
|
// Reserved for future use
|
|
945
763
|
get activeVersion() {
|
|
946
764
|
return this.data.activeVersion;
|
|
@@ -1080,7 +898,8 @@
|
|
|
1080
898
|
* @async
|
|
1081
899
|
*/
|
|
1082
900
|
async checkout() {
|
|
1083
|
-
|
|
901
|
+
const response = await this.internalGet("");
|
|
902
|
+
this.data = await response.json();
|
|
1084
903
|
return this;
|
|
1085
904
|
}
|
|
1086
905
|
/**
|
|
@@ -1090,7 +909,8 @@
|
|
|
1090
909
|
* @param data - Raw assembly data.
|
|
1091
910
|
*/
|
|
1092
911
|
async update(data) {
|
|
1093
|
-
|
|
912
|
+
const response = await this.internalPut("", data);
|
|
913
|
+
this.data = await response.json();
|
|
1094
914
|
return this;
|
|
1095
915
|
}
|
|
1096
916
|
/**
|
|
@@ -1100,7 +920,7 @@
|
|
|
1100
920
|
* @returns Returns the raw data of a deleted assembly.
|
|
1101
921
|
*/
|
|
1102
922
|
delete() {
|
|
1103
|
-
return
|
|
923
|
+
return this.internalDelete("").then((response) => response.json());
|
|
1104
924
|
}
|
|
1105
925
|
/**
|
|
1106
926
|
* Save assembly data changes to the server. Call this method to update assembly data on the
|
|
@@ -1122,7 +942,9 @@
|
|
|
1122
942
|
* @async
|
|
1123
943
|
*/
|
|
1124
944
|
getModels() {
|
|
1125
|
-
return
|
|
945
|
+
return this.internalGet("/geometry")
|
|
946
|
+
.then((response) => response.json())
|
|
947
|
+
.then((array) => array.map((data) => new Model(data, this)));
|
|
1126
948
|
}
|
|
1127
949
|
/**
|
|
1128
950
|
* Transformation matrix.
|
|
@@ -1169,7 +991,8 @@
|
|
|
1169
991
|
* @returns {Promise<any>}
|
|
1170
992
|
*/
|
|
1171
993
|
getProperties(handles) {
|
|
1172
|
-
|
|
994
|
+
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
995
|
+
return this.internalGet(relativePath).then((response) => response.json());
|
|
1173
996
|
}
|
|
1174
997
|
/**
|
|
1175
998
|
* Returns the list of original handles for an objects in the file that match the specified
|
|
@@ -1198,7 +1021,7 @@
|
|
|
1198
1021
|
* @param searchPattern - Search pattern or combination of the patterns, see example below.
|
|
1199
1022
|
*/
|
|
1200
1023
|
searchProperties(searchPattern) {
|
|
1201
|
-
return
|
|
1024
|
+
return this.internalPost("/properties/search", searchPattern).then((response) => response.json());
|
|
1202
1025
|
}
|
|
1203
1026
|
/**
|
|
1204
1027
|
* Returns the cda.json for an assembly.
|
|
@@ -1206,7 +1029,7 @@
|
|
|
1206
1029
|
* @async
|
|
1207
1030
|
*/
|
|
1208
1031
|
getCdaTree() {
|
|
1209
|
-
return
|
|
1032
|
+
return this.internalGet(`/properties/tree`).then((response) => response.json());
|
|
1210
1033
|
}
|
|
1211
1034
|
// Reserved for future use
|
|
1212
1035
|
getViewpoints() {
|
|
@@ -1230,20 +1053,53 @@
|
|
|
1230
1053
|
return Promise.resolve("");
|
|
1231
1054
|
}
|
|
1232
1055
|
/**
|
|
1233
|
-
* Download assembly resource
|
|
1056
|
+
* Download assembly resource file. Resource files are files that contain model scene
|
|
1057
|
+
* descriptions, or geometry data.
|
|
1234
1058
|
*
|
|
1235
1059
|
* @async
|
|
1236
|
-
* @param dataId - Resource
|
|
1060
|
+
* @param dataId - Resource file name.
|
|
1237
1061
|
* @param onProgress - Download progress callback.
|
|
1238
1062
|
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
1239
1063
|
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
1240
1064
|
* and abort it if desired.
|
|
1241
1065
|
*/
|
|
1242
1066
|
downloadResource(dataId, onProgress, signal) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1067
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}`);
|
|
1068
|
+
return this.httpClient
|
|
1069
|
+
.downloadFile(`${this.path}${relativePath}`, onProgress, signal)
|
|
1070
|
+
.then((response) => response.arrayBuffer());
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Download a part of assembly resource file. Resource files are files that contain model
|
|
1074
|
+
* scene descriptions, or geometry data.
|
|
1075
|
+
*
|
|
1076
|
+
* @param dataId - Resource file name.
|
|
1077
|
+
* @param ranges - A range of resource file contents to download.
|
|
1078
|
+
* @param requestId - Request ID for download progress callback.
|
|
1079
|
+
* @param onProgress - Download progress callback.
|
|
1080
|
+
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
1081
|
+
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
1082
|
+
* and abort it if desired.
|
|
1083
|
+
*/
|
|
1084
|
+
downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
|
|
1085
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
|
|
1086
|
+
return this.httpClient
|
|
1087
|
+
.downloadFileRange(`${this.path}${relativePath}`, ranges, onProgress, signal)
|
|
1245
1088
|
.then((response) => response.arrayBuffer());
|
|
1246
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Deprecated since `25.3`. Use {@link Assembly.downloadResource()} instead.
|
|
1092
|
+
*/
|
|
1093
|
+
partialDownloadResource(dataId, onProgress, signal) {
|
|
1094
|
+
console.warn("Assembly.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Assembly.downloadResource() instead.");
|
|
1095
|
+
return this.downloadResource(dataId, onProgress, signal);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Deprecated since `25.3`. Use {@link Assembly.downloadResourceRange()} instead.
|
|
1099
|
+
*/
|
|
1100
|
+
async downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
1101
|
+
await this.downloadResourceRange(dataId, records, requestId, onProgress, signal);
|
|
1102
|
+
}
|
|
1247
1103
|
// Reserved for future use
|
|
1248
1104
|
getReferences(signal) {
|
|
1249
1105
|
return Promise.resolve({ fileId: "", references: [] });
|
|
@@ -1449,35 +1305,237 @@
|
|
|
1449
1305
|
}
|
|
1450
1306
|
}
|
|
1451
1307
|
|
|
1308
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
1309
|
+
function handleFetchError(response) {
|
|
1310
|
+
if (!response.ok) {
|
|
1311
|
+
switch (response.status) {
|
|
1312
|
+
case 400: {
|
|
1313
|
+
return response.text().then((text) => {
|
|
1314
|
+
console.error(text);
|
|
1315
|
+
return Promise.reject(new FetchError(400, error400(text)));
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
case 500: {
|
|
1319
|
+
return response.text().then((text) => {
|
|
1320
|
+
console.error(error400(text, text));
|
|
1321
|
+
return Promise.reject(new FetchError(500));
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
default:
|
|
1325
|
+
return Promise.reject(new FetchError(response.status, statusText(response.status)));
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
return Promise.resolve(response);
|
|
1329
|
+
}
|
|
1330
|
+
function $fetch(url, params = { method: "GET" }) {
|
|
1331
|
+
const headers = { ...params.headers };
|
|
1332
|
+
delete headers["Content-Type"];
|
|
1333
|
+
let body;
|
|
1334
|
+
if (params.method === "POST" || params.method === "PUT") {
|
|
1335
|
+
if (params.body instanceof FormData) {
|
|
1336
|
+
body = params.body;
|
|
1337
|
+
}
|
|
1338
|
+
else if (params.body instanceof Blob) {
|
|
1339
|
+
body = new FormData();
|
|
1340
|
+
body.append("file", params.body);
|
|
1341
|
+
}
|
|
1342
|
+
else if (params.body instanceof ArrayBuffer) {
|
|
1343
|
+
body = new FormData();
|
|
1344
|
+
body.append("file", new Blob([params.body]));
|
|
1345
|
+
}
|
|
1346
|
+
else if (typeof params.body === "object") {
|
|
1347
|
+
body = JSON.stringify(params.body);
|
|
1348
|
+
headers["Content-Type"] = "application/json";
|
|
1349
|
+
}
|
|
1350
|
+
else if (typeof params.body === "string") {
|
|
1351
|
+
body = params.body;
|
|
1352
|
+
headers["Content-Type"] = "text/plain";
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
const init = { method: params.method, headers };
|
|
1356
|
+
if (body)
|
|
1357
|
+
init.body = body;
|
|
1358
|
+
if (params.signal)
|
|
1359
|
+
init.signal = params.signal;
|
|
1360
|
+
return fetch(url, init).then(handleFetchError);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
1364
|
+
function handleXMLHttpError(xhr) {
|
|
1365
|
+
if (xhr.status === 0) {
|
|
1366
|
+
return Promise.reject(new FetchError(0, "Network error"));
|
|
1367
|
+
}
|
|
1368
|
+
if (xhr.status < 200 || xhr.status > 299) {
|
|
1369
|
+
switch (xhr.status) {
|
|
1370
|
+
case 400: {
|
|
1371
|
+
console.error(xhr.responseText);
|
|
1372
|
+
return Promise.reject(new FetchError(400, error400(xhr.responseText)));
|
|
1373
|
+
}
|
|
1374
|
+
case 500: {
|
|
1375
|
+
console.error(error400(xhr.responseText, xhr.responseText));
|
|
1376
|
+
return Promise.reject(new FetchError(500));
|
|
1377
|
+
}
|
|
1378
|
+
default: {
|
|
1379
|
+
return Promise.reject(new FetchError(xhr.status));
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
return Promise.resolve(xhr);
|
|
1384
|
+
}
|
|
1385
|
+
function $xmlhttp(url, params = { method: "GET" }) {
|
|
1386
|
+
return new Promise((resolve, reject) => {
|
|
1387
|
+
const xhr = new XMLHttpRequest();
|
|
1388
|
+
xhr.open(params.method, url, true);
|
|
1389
|
+
for (const key in params.headers) {
|
|
1390
|
+
xhr.setRequestHeader(key, params.headers[key]);
|
|
1391
|
+
}
|
|
1392
|
+
function calcProgress(event) {
|
|
1393
|
+
return event.lengthComputable ? event.loaded / event.total : 1;
|
|
1394
|
+
}
|
|
1395
|
+
xhr.upload.onprogress = (event) => params.uploadProgress && params.uploadProgress(calcProgress(event));
|
|
1396
|
+
xhr.onprogress = (event) => params.downloadProgress && params.downloadProgress(calcProgress(event));
|
|
1397
|
+
xhr.onloadend = (event) => handleXMLHttpError(event.target).then(resolve, reject);
|
|
1398
|
+
xhr.send(params.body);
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1452
1402
|
///////////////////////////////////////////////////////////////////////////////
|
|
1453
1403
|
class HttpClient {
|
|
1454
1404
|
constructor(serverUrl) {
|
|
1455
1405
|
this.serverUrl = serverUrl;
|
|
1456
1406
|
}
|
|
1457
1407
|
get(relativePath, signal) {
|
|
1458
|
-
return $
|
|
1408
|
+
return $fetch(`${this.serverUrl}${relativePath}`, { method: "GET", headers: this.headers, signal });
|
|
1459
1409
|
}
|
|
1460
1410
|
post(relativePath, body) {
|
|
1461
|
-
return $
|
|
1411
|
+
return $fetch(`${this.serverUrl}${relativePath}`, { method: "POST", headers: this.headers, body });
|
|
1462
1412
|
}
|
|
1463
1413
|
put(relativePath, body) {
|
|
1464
|
-
return $
|
|
1414
|
+
return $fetch(`${this.serverUrl}${relativePath}`, { method: "PUT", headers: this.headers, body });
|
|
1465
1415
|
}
|
|
1466
1416
|
delete(relativePath) {
|
|
1467
|
-
return $
|
|
1417
|
+
return $fetch(`${this.serverUrl}${relativePath}`, { method: "DELETE", headers: this.headers });
|
|
1468
1418
|
}
|
|
1469
|
-
|
|
1419
|
+
uploadFile(relativePath, file, onProgress) {
|
|
1470
1420
|
const data = new FormData();
|
|
1471
1421
|
data.append("file", file);
|
|
1472
|
-
return $
|
|
1422
|
+
return $xmlhttp(`${this.serverUrl}${relativePath}`, {
|
|
1473
1423
|
method: "POST",
|
|
1474
1424
|
headers: this.headers,
|
|
1475
1425
|
body: data,
|
|
1476
1426
|
uploadProgress: onProgress,
|
|
1477
1427
|
});
|
|
1478
1428
|
}
|
|
1429
|
+
// async downloadFile(
|
|
1430
|
+
// relativePath: string,
|
|
1431
|
+
// onProgress?: (progress: number, chunk: Uint8Array) => void,
|
|
1432
|
+
// signal?: AbortSignal
|
|
1433
|
+
// ): Promise<Response> {
|
|
1434
|
+
// const response = await this.get(relativePath, signal);
|
|
1435
|
+
// const teedOff = response.body.tee();
|
|
1436
|
+
// if (onProgress) {
|
|
1437
|
+
// const contentLength = response.headers.get("Content-Length");
|
|
1438
|
+
// const total = parseInt(contentLength, 10) || 1;
|
|
1439
|
+
// let loaded = 0;
|
|
1440
|
+
// const reader = teedOff[0].getReader();
|
|
1441
|
+
// reader.read().then(function processChunk({ done, value }) {
|
|
1442
|
+
// if (done) return;
|
|
1443
|
+
// loaded += value.length;
|
|
1444
|
+
// onProgress(loaded / total, value);
|
|
1445
|
+
// reader.read().then(processChunk);
|
|
1446
|
+
// });
|
|
1447
|
+
// }
|
|
1448
|
+
// return new Response(teedOff[1]);
|
|
1449
|
+
// }
|
|
1450
|
+
async downloadFile(relativePath, onProgress, signal) {
|
|
1451
|
+
const response = await this.get(relativePath, signal);
|
|
1452
|
+
const contentLength = response.headers.get("Content-Length");
|
|
1453
|
+
const total = parseInt(contentLength, 10) || 1;
|
|
1454
|
+
return new Response(new ReadableStream({
|
|
1455
|
+
async start(controller) {
|
|
1456
|
+
const reader = response.body.getReader();
|
|
1457
|
+
let loaded = 0;
|
|
1458
|
+
while (true) {
|
|
1459
|
+
const { done, value } = await reader.read();
|
|
1460
|
+
if (done)
|
|
1461
|
+
break;
|
|
1462
|
+
controller.enqueue(value);
|
|
1463
|
+
loaded += value.length;
|
|
1464
|
+
if (onProgress)
|
|
1465
|
+
onProgress(loaded / total, value);
|
|
1466
|
+
}
|
|
1467
|
+
controller.close();
|
|
1468
|
+
},
|
|
1469
|
+
}));
|
|
1470
|
+
}
|
|
1471
|
+
async downloadFileRange(relativePath, ranges, onProgress, signal) {
|
|
1472
|
+
const headers = { ...this.headers };
|
|
1473
|
+
headers["Range"] = "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(",");
|
|
1474
|
+
const response = await $fetch(`${this.serverUrl}${relativePath}`, { method: "GET", headers, signal });
|
|
1475
|
+
const contentLength = response.headers.get("content-length");
|
|
1476
|
+
const total = parseInt(contentLength, 10) || 1;
|
|
1477
|
+
return new Response(new ReadableStream({
|
|
1478
|
+
async start(controller) {
|
|
1479
|
+
const reader = response.body.getReader();
|
|
1480
|
+
let loaded = 0;
|
|
1481
|
+
let rangedIndex = 0;
|
|
1482
|
+
let rangePos = 0;
|
|
1483
|
+
while (true) {
|
|
1484
|
+
const { done, value } = await reader.read();
|
|
1485
|
+
if (done)
|
|
1486
|
+
break;
|
|
1487
|
+
controller.enqueue(value);
|
|
1488
|
+
loaded += value.length;
|
|
1489
|
+
let chunkLeft = value.length;
|
|
1490
|
+
let chunkPos = 0;
|
|
1491
|
+
while (chunkLeft > 0) {
|
|
1492
|
+
const range = ranges[rangedIndex];
|
|
1493
|
+
const rangeLeft = range.end - range.begin - rangePos;
|
|
1494
|
+
if (chunkLeft < rangeLeft) {
|
|
1495
|
+
const chunk = value.subarray(chunkPos, chunkPos + chunkLeft);
|
|
1496
|
+
if (onProgress)
|
|
1497
|
+
onProgress(loaded / total, chunk, range.requestId);
|
|
1498
|
+
rangePos += chunkLeft;
|
|
1499
|
+
chunkLeft = 0;
|
|
1500
|
+
}
|
|
1501
|
+
else {
|
|
1502
|
+
const chunk = value.subarray(chunkPos, chunkPos + rangeLeft);
|
|
1503
|
+
if (onProgress)
|
|
1504
|
+
onProgress(loaded / total, chunk, range.requestId);
|
|
1505
|
+
chunkPos += rangeLeft;
|
|
1506
|
+
chunkLeft -= rangeLeft;
|
|
1507
|
+
rangedIndex++;
|
|
1508
|
+
rangePos = 0;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
controller.close();
|
|
1513
|
+
},
|
|
1514
|
+
}));
|
|
1515
|
+
}
|
|
1479
1516
|
}
|
|
1480
1517
|
|
|
1518
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
1519
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
1520
|
+
// All rights reserved.
|
|
1521
|
+
//
|
|
1522
|
+
// This software and its documentation and related materials are owned by
|
|
1523
|
+
// the Alliance. The software may only be incorporated into application
|
|
1524
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
1525
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
1526
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
1527
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
1528
|
+
// protected by copyright law and international treaty provisions. Application
|
|
1529
|
+
// programs incorporating this software must include the following statement
|
|
1530
|
+
// with their copyright notices:
|
|
1531
|
+
//
|
|
1532
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
1533
|
+
// license agreement with Open Design Alliance.
|
|
1534
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
1535
|
+
// All rights reserved.
|
|
1536
|
+
//
|
|
1537
|
+
// By use of this software, its documentation or related materials, you
|
|
1538
|
+
// acknowledge and accept the above terms.
|
|
1481
1539
|
///////////////////////////////////////////////////////////////////////////////
|
|
1482
1540
|
/**
|
|
1483
1541
|
* A permission provides information about {@link File | file} sharing granted to a specific
|
|
@@ -1573,7 +1631,8 @@
|
|
|
1573
1631
|
* @async
|
|
1574
1632
|
*/
|
|
1575
1633
|
async checkout() {
|
|
1576
|
-
|
|
1634
|
+
const response = await this.internalGet();
|
|
1635
|
+
this.data = await response.json();
|
|
1577
1636
|
return this;
|
|
1578
1637
|
}
|
|
1579
1638
|
/**
|
|
@@ -1583,7 +1642,8 @@
|
|
|
1583
1642
|
* @param data - Raw permission data.
|
|
1584
1643
|
*/
|
|
1585
1644
|
async update(data) {
|
|
1586
|
-
|
|
1645
|
+
const response = await this.internalPut(data);
|
|
1646
|
+
this.data = await response.json();
|
|
1587
1647
|
return this;
|
|
1588
1648
|
}
|
|
1589
1649
|
/**
|
|
@@ -1593,7 +1653,7 @@
|
|
|
1593
1653
|
* @returns Returns the raw data of a deleted permission.
|
|
1594
1654
|
*/
|
|
1595
1655
|
delete() {
|
|
1596
|
-
return
|
|
1656
|
+
return this.internalDelete().then((response) => response.json());
|
|
1597
1657
|
}
|
|
1598
1658
|
/**
|
|
1599
1659
|
* Save permission data changes to the server. Call this method to update permission data on
|
|
@@ -1746,7 +1806,8 @@
|
|
|
1746
1806
|
* @async
|
|
1747
1807
|
*/
|
|
1748
1808
|
async checkout() {
|
|
1749
|
-
|
|
1809
|
+
const response = await this.internalGet();
|
|
1810
|
+
this.data = await response.json();
|
|
1750
1811
|
return this;
|
|
1751
1812
|
}
|
|
1752
1813
|
/**
|
|
@@ -1756,7 +1817,8 @@
|
|
|
1756
1817
|
* @param data - Raw job data.
|
|
1757
1818
|
*/
|
|
1758
1819
|
async update(data) {
|
|
1759
|
-
|
|
1820
|
+
const response = await this.internalPut(data);
|
|
1821
|
+
this.data = await response.json();
|
|
1760
1822
|
return this;
|
|
1761
1823
|
}
|
|
1762
1824
|
/**
|
|
@@ -1767,7 +1829,7 @@
|
|
|
1767
1829
|
* @returns Returns the raw data of a deleted job.
|
|
1768
1830
|
*/
|
|
1769
1831
|
delete() {
|
|
1770
|
-
return
|
|
1832
|
+
return this.internalDelete().then((response) => response.json());
|
|
1771
1833
|
}
|
|
1772
1834
|
// /**
|
|
1773
1835
|
// * Save job data changes to the server. Call this method to update job data on the server
|
|
@@ -1808,7 +1870,7 @@
|
|
|
1808
1870
|
/**
|
|
1809
1871
|
* The class representing a `file` entity.
|
|
1810
1872
|
*/
|
|
1811
|
-
class File
|
|
1873
|
+
class File {
|
|
1812
1874
|
/**
|
|
1813
1875
|
* @param data - An object that implements file data storage.
|
|
1814
1876
|
* @param httpClient - Http client for API.
|
|
@@ -1840,34 +1902,6 @@
|
|
|
1840
1902
|
relativePath = this.appendVersionParam(relativePath);
|
|
1841
1903
|
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
1842
1904
|
}
|
|
1843
|
-
async partialDownloadResource(dataId, onProgress, signal) {
|
|
1844
|
-
var _a;
|
|
1845
|
-
let pathname = `${this.path}/downloads/${dataId}`;
|
|
1846
|
-
pathname = this.appendVersionParam(pathname);
|
|
1847
|
-
// TODO: replace with $get to handle fetch errors
|
|
1848
|
-
const response = await fetch(`${this.httpClient.serverUrl}${pathname}`, {
|
|
1849
|
-
headers: this.httpClient.headers,
|
|
1850
|
-
signal,
|
|
1851
|
-
});
|
|
1852
|
-
// TODO: use ReadableStream pipeTo()
|
|
1853
|
-
const contentLength = (_a = response.headers.get("Content-Length")) !== null && _a !== void 0 ? _a : "";
|
|
1854
|
-
const total = parseInt(contentLength, 10);
|
|
1855
|
-
const reader = response.body.getReader();
|
|
1856
|
-
let loaded = 0;
|
|
1857
|
-
while (true) {
|
|
1858
|
-
const { done, value } = await reader.read();
|
|
1859
|
-
if (done)
|
|
1860
|
-
break;
|
|
1861
|
-
loaded += value.byteLength;
|
|
1862
|
-
if (typeof onProgress === "function")
|
|
1863
|
-
onProgress(loaded / total, value);
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
1867
|
-
let pathname = `${this.path}/downloads/${dataId}?requestId=${requestId}`;
|
|
1868
|
-
pathname = this.appendVersionParam(pathname);
|
|
1869
|
-
return downloadPartOfFile(requestId, records, `${this.httpClient.serverUrl}${pathname}`, this.httpClient.headers, onProgress, signal);
|
|
1870
|
-
}
|
|
1871
1905
|
/**
|
|
1872
1906
|
* Active version number of the file.
|
|
1873
1907
|
*
|
|
@@ -1930,8 +1964,8 @@
|
|
|
1930
1964
|
(_k = (_s = this._data.status).geometryGltf) !== null && _k !== void 0 ? _k : (_s.geometryGltf = { state: "none" });
|
|
1931
1965
|
}
|
|
1932
1966
|
/**
|
|
1933
|
-
* Returns a list of formats in which the active version of the file was
|
|
1934
|
-
* file to one of the supported formats create File Converter job using
|
|
1967
|
+
* Returns a list of files in different formats in which the active version of the file was
|
|
1968
|
+
* exported. To export file to one of the supported formats create File Converter job using
|
|
1935
1969
|
* {@link File.createJob()}. To download exported file use {@link File.downloadResource()}.
|
|
1936
1970
|
*
|
|
1937
1971
|
* @readonly
|
|
@@ -2092,7 +2126,8 @@
|
|
|
2092
2126
|
* @async
|
|
2093
2127
|
*/
|
|
2094
2128
|
async checkout() {
|
|
2095
|
-
|
|
2129
|
+
const response = await this.internalGet("");
|
|
2130
|
+
this.data = await response.json();
|
|
2096
2131
|
return this;
|
|
2097
2132
|
}
|
|
2098
2133
|
/**
|
|
@@ -2102,7 +2137,8 @@
|
|
|
2102
2137
|
* @param data - Raw file data.
|
|
2103
2138
|
*/
|
|
2104
2139
|
async update(data) {
|
|
2105
|
-
|
|
2140
|
+
const response = await this.internalPut("", data);
|
|
2141
|
+
this.data = await response.json();
|
|
2106
2142
|
return this;
|
|
2107
2143
|
}
|
|
2108
2144
|
/**
|
|
@@ -2112,7 +2148,7 @@
|
|
|
2112
2148
|
* @returns Returns the raw data of a deleted file.
|
|
2113
2149
|
*/
|
|
2114
2150
|
delete() {
|
|
2115
|
-
return
|
|
2151
|
+
return this.internalDelete("").then((response) => response.json());
|
|
2116
2152
|
}
|
|
2117
2153
|
/**
|
|
2118
2154
|
* Save file data changes to the server. Call this method to update file data on the server
|
|
@@ -2137,12 +2173,8 @@
|
|
|
2137
2173
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
|
|
2138
2174
|
*/
|
|
2139
2175
|
async setPreview(image) {
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
}
|
|
2143
|
-
else {
|
|
2144
|
-
this.data = await json(this.internalDelete("/preview"));
|
|
2145
|
-
}
|
|
2176
|
+
const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
|
|
2177
|
+
this.data = await response.json();
|
|
2146
2178
|
return this;
|
|
2147
2179
|
}
|
|
2148
2180
|
/**
|
|
@@ -2151,7 +2183,9 @@
|
|
|
2151
2183
|
* @async
|
|
2152
2184
|
*/
|
|
2153
2185
|
getModels() {
|
|
2154
|
-
return
|
|
2186
|
+
return this.internalGet("/geometry")
|
|
2187
|
+
.then((response) => response.json())
|
|
2188
|
+
.then((array) => array.map((data) => new Model(data, this)));
|
|
2155
2189
|
}
|
|
2156
2190
|
// File does not support model transformation.
|
|
2157
2191
|
getModelTransformMatrix(handle) {
|
|
@@ -2176,7 +2210,8 @@
|
|
|
2176
2210
|
* to get properties for all objects in the file.
|
|
2177
2211
|
*/
|
|
2178
2212
|
getProperties(handles) {
|
|
2179
|
-
|
|
2213
|
+
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
2214
|
+
return this.internalGet(relativePath).then((response) => response.json());
|
|
2180
2215
|
}
|
|
2181
2216
|
/**
|
|
2182
2217
|
* Search pattern.
|
|
@@ -2221,7 +2256,7 @@
|
|
|
2221
2256
|
* @returns {Promise<Properties[]>}
|
|
2222
2257
|
*/
|
|
2223
2258
|
searchProperties(searchPattern) {
|
|
2224
|
-
return
|
|
2259
|
+
return this.internalPost("/properties/search", searchPattern).then((response) => response.json());
|
|
2225
2260
|
}
|
|
2226
2261
|
/**
|
|
2227
2262
|
* Returns the cda.json for an active version of the file.
|
|
@@ -2229,7 +2264,7 @@
|
|
|
2229
2264
|
* @async
|
|
2230
2265
|
*/
|
|
2231
2266
|
getCdaTree() {
|
|
2232
|
-
return
|
|
2267
|
+
return this.internalGet(`/properties/tree`).then((response) => response.json());
|
|
2233
2268
|
}
|
|
2234
2269
|
/**
|
|
2235
2270
|
* Returns a list of file viewpoints.
|
|
@@ -2237,7 +2272,9 @@
|
|
|
2237
2272
|
* @async
|
|
2238
2273
|
*/
|
|
2239
2274
|
getViewpoints() {
|
|
2240
|
-
return
|
|
2275
|
+
return this.internalGet("/viewpoints")
|
|
2276
|
+
.then((response) => response.json())
|
|
2277
|
+
.then((viewpoints) => viewpoints.result);
|
|
2241
2278
|
}
|
|
2242
2279
|
/**
|
|
2243
2280
|
* Add new file viewpoint. To create a new viewpoint use
|
|
@@ -2247,7 +2284,7 @@
|
|
|
2247
2284
|
* @param viewpoint - Viewpoint.
|
|
2248
2285
|
*/
|
|
2249
2286
|
saveViewpoint(viewpoint) {
|
|
2250
|
-
return
|
|
2287
|
+
return this.internalPost("/viewpoints", viewpoint).then((response) => response.json());
|
|
2251
2288
|
}
|
|
2252
2289
|
/**
|
|
2253
2290
|
* Delete file viewpoint.
|
|
@@ -2257,7 +2294,7 @@
|
|
|
2257
2294
|
* @returns Returns the raw data of a deleted viewpoint.
|
|
2258
2295
|
*/
|
|
2259
2296
|
deleteViewpoint(guid) {
|
|
2260
|
-
return
|
|
2297
|
+
return this.internalDelete(`/viewpoints/${guid}`).then((response) => response.json());
|
|
2261
2298
|
}
|
|
2262
2299
|
/**
|
|
2263
2300
|
* Returns viewpoint preview image as <a
|
|
@@ -2268,7 +2305,7 @@
|
|
|
2268
2305
|
* @param guid - Viewpoint GUID.
|
|
2269
2306
|
*/
|
|
2270
2307
|
getSnapshot(guid) {
|
|
2271
|
-
return
|
|
2308
|
+
return this.internalGet(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
|
|
2272
2309
|
}
|
|
2273
2310
|
/**
|
|
2274
2311
|
* Returns viewpoint preview data.
|
|
@@ -2278,7 +2315,7 @@
|
|
|
2278
2315
|
* @param bitmapGuid - Bitmap GUID.
|
|
2279
2316
|
*/
|
|
2280
2317
|
getSnapshotData(guid, bitmapGuid) {
|
|
2281
|
-
return
|
|
2318
|
+
return this.internalGet(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
|
|
2282
2319
|
}
|
|
2283
2320
|
/**
|
|
2284
2321
|
* Download source of active version of the file.
|
|
@@ -2290,33 +2327,67 @@
|
|
|
2290
2327
|
* and abort it if desired.
|
|
2291
2328
|
*/
|
|
2292
2329
|
download(onProgress, signal) {
|
|
2293
|
-
|
|
2294
|
-
|
|
2330
|
+
const relativePath = this.appendVersionParam("/downloads");
|
|
2331
|
+
return this.httpClient
|
|
2332
|
+
.downloadFile(`${this.path}${relativePath}`, onProgress, signal)
|
|
2295
2333
|
.then((response) => response.arrayBuffer());
|
|
2296
2334
|
}
|
|
2297
2335
|
/**
|
|
2298
|
-
* Download
|
|
2336
|
+
* Download a resource file of the active version of the file. Resource files are files that
|
|
2337
|
+
* contain model scene descriptions, or geometry data, or exported files.
|
|
2299
2338
|
*
|
|
2300
2339
|
* @example <caption>Export file to DWG.</caption>
|
|
2301
2340
|
* const job = await file.crateJob("dwg");
|
|
2302
2341
|
* await job.waitForDone();
|
|
2303
|
-
* const
|
|
2304
|
-
* const arrayBuffer = await file.downloadResource(
|
|
2342
|
+
* const dwgFileName = file.exports.find((x) => x.endsWith(".dwg"));
|
|
2343
|
+
* const arrayBuffer = await file.downloadResource(dwgFileName);
|
|
2305
2344
|
* const blob = new Blob([arrayBuffer]);
|
|
2306
2345
|
* const fileName = file.name.replace(/\.[^.]+$/, "") + ".dwg";
|
|
2307
2346
|
* FileSaver.saveAs(blob, fileName);
|
|
2308
2347
|
*
|
|
2309
|
-
* @param dataId - Resource
|
|
2348
|
+
* @param dataId - Resource file name.
|
|
2310
2349
|
* @param onProgress - Download progress callback.
|
|
2311
2350
|
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
2312
2351
|
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
2313
2352
|
* and abort it if desired.
|
|
2314
2353
|
*/
|
|
2315
2354
|
downloadResource(dataId, onProgress, signal) {
|
|
2316
|
-
|
|
2317
|
-
|
|
2355
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}`);
|
|
2356
|
+
return this.httpClient
|
|
2357
|
+
.downloadFile(`${this.path}${relativePath}`, onProgress, signal)
|
|
2358
|
+
.then((response) => response.arrayBuffer());
|
|
2359
|
+
}
|
|
2360
|
+
/**
|
|
2361
|
+
* Download a part of resource file of the active version of the file. Resource files are
|
|
2362
|
+
* files that contain model scene descriptions, or geometry data, or exported files.
|
|
2363
|
+
*
|
|
2364
|
+
* @param dataId - Resource file name.
|
|
2365
|
+
* @param ranges - A range of resource file contents to download.
|
|
2366
|
+
* @param requestId - Request ID for download progress callback.
|
|
2367
|
+
* @param onProgress - Download progress callback.
|
|
2368
|
+
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
2369
|
+
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
2370
|
+
* and abort it if desired.
|
|
2371
|
+
*/
|
|
2372
|
+
downloadResourceRange(dataId, ranges, requestId, onProgress, signal) {
|
|
2373
|
+
const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
|
|
2374
|
+
return this.httpClient
|
|
2375
|
+
.downloadFileRange(`${this.path}${relativePath}`, ranges, onProgress, signal)
|
|
2318
2376
|
.then((response) => response.arrayBuffer());
|
|
2319
2377
|
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Deprecated since `25.3`. Use {@link File.downloadResource()} instead.
|
|
2380
|
+
*/
|
|
2381
|
+
partialDownloadResource(dataId, onProgress, signal) {
|
|
2382
|
+
console.warn("File.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use File.downloadResource() instead.");
|
|
2383
|
+
return this.downloadResource(dataId, onProgress, signal);
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Deprecated since `25.3`. Use {@link File.downloadResourceRange()} instead.
|
|
2387
|
+
*/
|
|
2388
|
+
async downloadFileRange(requestId, records, dataId, onProgress, signal) {
|
|
2389
|
+
await this.downloadResourceRange(dataId, records, requestId, onProgress, signal);
|
|
2390
|
+
}
|
|
2320
2391
|
/**
|
|
2321
2392
|
* Returns a list of references to files used to correct rendering of the current file.
|
|
2322
2393
|
*
|
|
@@ -2326,7 +2397,7 @@
|
|
|
2326
2397
|
* signal object instance, which can be used to abort waiting as desired.
|
|
2327
2398
|
*/
|
|
2328
2399
|
getReferences(signal) {
|
|
2329
|
-
return
|
|
2400
|
+
return this.internalGet("/references", signal).then((response) => response.json());
|
|
2330
2401
|
}
|
|
2331
2402
|
/**
|
|
2332
2403
|
* Set the file references.
|
|
@@ -2335,7 +2406,7 @@
|
|
|
2335
2406
|
* @param references - File references.
|
|
2336
2407
|
*/
|
|
2337
2408
|
setReferences(references) {
|
|
2338
|
-
return
|
|
2409
|
+
return this.internalPut("/references", references).then((response) => response.json());
|
|
2339
2410
|
}
|
|
2340
2411
|
/**
|
|
2341
2412
|
* Create a new job for the active version of the file.
|
|
@@ -2358,9 +2429,9 @@
|
|
|
2358
2429
|
* for the File Converter tool in form "--arg=value".
|
|
2359
2430
|
*/
|
|
2360
2431
|
createJob(outputFormat, parameters) {
|
|
2361
|
-
const
|
|
2432
|
+
const relativePath = this.appendVersionParam("/jobs");
|
|
2362
2433
|
return this.httpClient
|
|
2363
|
-
.post(
|
|
2434
|
+
.post(relativePath, {
|
|
2364
2435
|
fileId: this.id,
|
|
2365
2436
|
outputFormat,
|
|
2366
2437
|
parameters: parseArgs(parameters),
|
|
@@ -2450,7 +2521,9 @@
|
|
|
2450
2521
|
* @async
|
|
2451
2522
|
*/
|
|
2452
2523
|
getPermissions() {
|
|
2453
|
-
return
|
|
2524
|
+
return this.internalGet("/permissions")
|
|
2525
|
+
.then((response) => response.json())
|
|
2526
|
+
.then((array) => array.map((data) => new Permission(data, this.id, this.httpClient)));
|
|
2454
2527
|
}
|
|
2455
2528
|
/**
|
|
2456
2529
|
* Returns the permission information.
|
|
@@ -2459,7 +2532,9 @@
|
|
|
2459
2532
|
* @param permissionId - Permission ID.
|
|
2460
2533
|
*/
|
|
2461
2534
|
getPermission(permissionId) {
|
|
2462
|
-
return
|
|
2535
|
+
return this.internalGet(`/permissions/${permissionId}`)
|
|
2536
|
+
.then((response) => response.json())
|
|
2537
|
+
.then((data) => new Permission(data, this.id, this.httpClient));
|
|
2463
2538
|
}
|
|
2464
2539
|
/**
|
|
2465
2540
|
* Create a new file permission.
|
|
@@ -2471,11 +2546,13 @@
|
|
|
2471
2546
|
* @param public = false - Specifies whether all users have access to the file or not.
|
|
2472
2547
|
*/
|
|
2473
2548
|
createPermission(actions, grantedTo, _public) {
|
|
2474
|
-
return
|
|
2475
|
-
actions:
|
|
2549
|
+
return this.internalPost("/permissions", {
|
|
2550
|
+
actions: Array.isArray(actions) ? actions : [actions],
|
|
2476
2551
|
grantedTo,
|
|
2477
2552
|
public: _public,
|
|
2478
|
-
})
|
|
2553
|
+
})
|
|
2554
|
+
.then((response) => response.json())
|
|
2555
|
+
.then((data) => new Permission(data, this.id, this.httpClient));
|
|
2479
2556
|
}
|
|
2480
2557
|
/**
|
|
2481
2558
|
* Delete file permission.
|
|
@@ -2485,7 +2562,7 @@
|
|
|
2485
2562
|
* @returns Returns the raw data of a deleted permission.
|
|
2486
2563
|
*/
|
|
2487
2564
|
deletePermission(permissionId) {
|
|
2488
|
-
return
|
|
2565
|
+
return this.internalDelete(`/permissions/${permissionId}`).then((response) => response.json());
|
|
2489
2566
|
}
|
|
2490
2567
|
/**
|
|
2491
2568
|
* Upload the new version of the file to the server and extract the geometry and properties as needed.
|
|
@@ -2513,9 +2590,9 @@
|
|
|
2513
2590
|
waitForDone: false,
|
|
2514
2591
|
}) {
|
|
2515
2592
|
const result = await this.httpClient
|
|
2516
|
-
.
|
|
2593
|
+
.uploadFile(`${this.path}/versions`, file, (progress) => { var _a; return (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file); })
|
|
2517
2594
|
.then((xhr) => JSON.parse(xhr.responseText))
|
|
2518
|
-
.then((data) => new File
|
|
2595
|
+
.then((data) => new File(data, this.httpClient));
|
|
2519
2596
|
if (params.geometry === undefined && this.geometryType !== "")
|
|
2520
2597
|
params.geometry = true;
|
|
2521
2598
|
if (params.properties === undefined && this.status.properties.state !== "none")
|
|
@@ -2538,7 +2615,7 @@
|
|
|
2538
2615
|
getVersions() {
|
|
2539
2616
|
return this.internalGet("/versions")
|
|
2540
2617
|
.then((response) => response.json())
|
|
2541
|
-
.then((files) => files.map((data) => new File
|
|
2618
|
+
.then((files) => files.map((data) => new File(data, this.httpClient)))
|
|
2542
2619
|
.then((files) => files.map((file) => (file.id == file.originalFileId ? file.useVersion(0) : file)));
|
|
2543
2620
|
}
|
|
2544
2621
|
/**
|
|
@@ -2550,7 +2627,7 @@
|
|
|
2550
2627
|
getVersion(version) {
|
|
2551
2628
|
return this.internalGet(`/versions/${version}`)
|
|
2552
2629
|
.then((response) => response.json())
|
|
2553
|
-
.then((data) => new File
|
|
2630
|
+
.then((data) => new File(data, this.httpClient))
|
|
2554
2631
|
.then((file) => (file.id == file.originalFileId ? file.useVersion(0) : file));
|
|
2555
2632
|
}
|
|
2556
2633
|
/**
|
|
@@ -2561,9 +2638,9 @@
|
|
|
2561
2638
|
*/
|
|
2562
2639
|
async deleteVersion(version) {
|
|
2563
2640
|
const response = await this.internalDelete(`/versions/${version}`);
|
|
2564
|
-
const
|
|
2641
|
+
const data = await response.json();
|
|
2565
2642
|
await this.checkout();
|
|
2566
|
-
return
|
|
2643
|
+
return data;
|
|
2567
2644
|
}
|
|
2568
2645
|
/**
|
|
2569
2646
|
* Replace the active version of the file with the selected version.
|
|
@@ -2603,6 +2680,27 @@
|
|
|
2603
2680
|
}
|
|
2604
2681
|
}
|
|
2605
2682
|
|
|
2683
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2684
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
2685
|
+
// All rights reserved.
|
|
2686
|
+
//
|
|
2687
|
+
// This software and its documentation and related materials are owned by
|
|
2688
|
+
// the Alliance. The software may only be incorporated into application
|
|
2689
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
2690
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
2691
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
2692
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
2693
|
+
// protected by copyright law and international treaty provisions. Application
|
|
2694
|
+
// programs incorporating this software must include the following statement
|
|
2695
|
+
// with their copyright notices:
|
|
2696
|
+
//
|
|
2697
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
2698
|
+
// license agreement with Open Design Alliance.
|
|
2699
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
2700
|
+
// All rights reserved.
|
|
2701
|
+
//
|
|
2702
|
+
// By use of this software, its documentation or related materials, you
|
|
2703
|
+
// acknowledge and accept the above terms.
|
|
2606
2704
|
///////////////////////////////////////////////////////////////////////////////
|
|
2607
2705
|
/**
|
|
2608
2706
|
* A roles determines what permissions {@link User | users} have on a {@link Project | project}.
|
|
@@ -2685,7 +2783,8 @@
|
|
|
2685
2783
|
* @async
|
|
2686
2784
|
*/
|
|
2687
2785
|
async checkout() {
|
|
2688
|
-
|
|
2786
|
+
const response = await this.internalGet();
|
|
2787
|
+
this.data = await response.json();
|
|
2689
2788
|
return this;
|
|
2690
2789
|
}
|
|
2691
2790
|
/**
|
|
@@ -2695,7 +2794,8 @@
|
|
|
2695
2794
|
* @param data - Raw role data.
|
|
2696
2795
|
*/
|
|
2697
2796
|
async update(data) {
|
|
2698
|
-
|
|
2797
|
+
const response = await this.internalPut(data);
|
|
2798
|
+
this.data = await response.json();
|
|
2699
2799
|
return this;
|
|
2700
2800
|
}
|
|
2701
2801
|
/**
|
|
@@ -2705,7 +2805,7 @@
|
|
|
2705
2805
|
* @returns Returns the raw data of a deleted role.
|
|
2706
2806
|
*/
|
|
2707
2807
|
delete() {
|
|
2708
|
-
return
|
|
2808
|
+
return this.internalDelete().then((response) => response.json());
|
|
2709
2809
|
}
|
|
2710
2810
|
/**
|
|
2711
2811
|
* Save role data changes to the server. Call this method to update role data on the server
|
|
@@ -2803,7 +2903,8 @@
|
|
|
2803
2903
|
* @async
|
|
2804
2904
|
*/
|
|
2805
2905
|
async checkout() {
|
|
2806
|
-
|
|
2906
|
+
const response = await this.internalGet();
|
|
2907
|
+
this.data = await response.json();
|
|
2807
2908
|
return this;
|
|
2808
2909
|
}
|
|
2809
2910
|
/**
|
|
@@ -2813,7 +2914,8 @@
|
|
|
2813
2914
|
* @param data - Raw member data.
|
|
2814
2915
|
*/
|
|
2815
2916
|
async update(data) {
|
|
2816
|
-
|
|
2917
|
+
const response = await this.internalPut(data);
|
|
2918
|
+
this.data = await response.json();
|
|
2817
2919
|
return this;
|
|
2818
2920
|
}
|
|
2819
2921
|
/**
|
|
@@ -2823,7 +2925,7 @@
|
|
|
2823
2925
|
* @returns Returns the raw data of a deleted member.
|
|
2824
2926
|
*/
|
|
2825
2927
|
delete() {
|
|
2826
|
-
return
|
|
2928
|
+
return this.internalDelete().then((response) => response.json());
|
|
2827
2929
|
}
|
|
2828
2930
|
/**
|
|
2829
2931
|
* Save member data changes to the server. Call this method to update member data on the
|
|
@@ -3022,7 +3124,8 @@
|
|
|
3022
3124
|
* @async
|
|
3023
3125
|
*/
|
|
3024
3126
|
async checkout() {
|
|
3025
|
-
|
|
3127
|
+
const response = await this.internalGet("");
|
|
3128
|
+
this.data = await response.json();
|
|
3026
3129
|
return this;
|
|
3027
3130
|
}
|
|
3028
3131
|
/**
|
|
@@ -3032,7 +3135,8 @@
|
|
|
3032
3135
|
* @param data - Raw project data.
|
|
3033
3136
|
*/
|
|
3034
3137
|
async update(data) {
|
|
3035
|
-
|
|
3138
|
+
const response = await this.internalPut("", data);
|
|
3139
|
+
this.data = await response.json();
|
|
3036
3140
|
return this;
|
|
3037
3141
|
}
|
|
3038
3142
|
/**
|
|
@@ -3042,7 +3146,9 @@
|
|
|
3042
3146
|
* @returns Returns the raw data of a deleted project.
|
|
3043
3147
|
*/
|
|
3044
3148
|
delete() {
|
|
3045
|
-
return
|
|
3149
|
+
return this.internalDelete("")
|
|
3150
|
+
.then((response) => response.text())
|
|
3151
|
+
.then((text) => {
|
|
3046
3152
|
// TODO fix for server 23.5 and below
|
|
3047
3153
|
try {
|
|
3048
3154
|
return JSON.parse(text);
|
|
@@ -3075,12 +3181,8 @@
|
|
|
3075
3181
|
* target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
|
|
3076
3182
|
*/
|
|
3077
3183
|
async setPreview(image) {
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
}
|
|
3081
|
-
else {
|
|
3082
|
-
this.data = await json(this.internalDelete("/preview"));
|
|
3083
|
-
}
|
|
3184
|
+
const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
|
|
3185
|
+
this.data = await response.json();
|
|
3084
3186
|
return this;
|
|
3085
3187
|
}
|
|
3086
3188
|
/**
|
|
@@ -3090,7 +3192,9 @@
|
|
|
3090
3192
|
* @async
|
|
3091
3193
|
*/
|
|
3092
3194
|
getRoles() {
|
|
3093
|
-
return
|
|
3195
|
+
return this.internalGet("/roles")
|
|
3196
|
+
.then((response) => response.json())
|
|
3197
|
+
.then((array) => array.map((data) => new Role(data, this.id, this.httpClient)));
|
|
3094
3198
|
}
|
|
3095
3199
|
/**
|
|
3096
3200
|
* Returns the role information.
|
|
@@ -3099,7 +3203,9 @@
|
|
|
3099
3203
|
* @param name - Role name.
|
|
3100
3204
|
*/
|
|
3101
3205
|
getRole(name) {
|
|
3102
|
-
return
|
|
3206
|
+
return this.internalGet(`/roles/${name}`)
|
|
3207
|
+
.then((response) => response.json())
|
|
3208
|
+
.then((data) => new Role(data, this.id, this.httpClient));
|
|
3103
3209
|
}
|
|
3104
3210
|
/**
|
|
3105
3211
|
* Create a new project role.
|
|
@@ -3111,11 +3217,13 @@
|
|
|
3111
3217
|
* {@link Role#permissions | Role.permissions} for more details.
|
|
3112
3218
|
*/
|
|
3113
3219
|
createRole(name, description, permissions) {
|
|
3114
|
-
return
|
|
3220
|
+
return this.internalPost("/roles", {
|
|
3115
3221
|
name,
|
|
3116
3222
|
description,
|
|
3117
3223
|
permissions: permissions || {},
|
|
3118
|
-
})
|
|
3224
|
+
})
|
|
3225
|
+
.then((response) => response.json())
|
|
3226
|
+
.then((data) => new Role(data, this.id, this.httpClient));
|
|
3119
3227
|
}
|
|
3120
3228
|
/**
|
|
3121
3229
|
* Delete project role.
|
|
@@ -3125,7 +3233,7 @@
|
|
|
3125
3233
|
* @returns Returns the raw data of a deleted role.
|
|
3126
3234
|
*/
|
|
3127
3235
|
deleteRole(name) {
|
|
3128
|
-
return
|
|
3236
|
+
return this.internalDelete(`/roles/${name}`).then((response) => response.json());
|
|
3129
3237
|
}
|
|
3130
3238
|
/**
|
|
3131
3239
|
* Returns a list of project members.
|
|
@@ -3133,7 +3241,9 @@
|
|
|
3133
3241
|
* @async
|
|
3134
3242
|
*/
|
|
3135
3243
|
getMembers() {
|
|
3136
|
-
return
|
|
3244
|
+
return this.internalGet("/members")
|
|
3245
|
+
.then((response) => response.json())
|
|
3246
|
+
.then((array) => array.map((data) => new Member(data, this.id, this.httpClient)));
|
|
3137
3247
|
}
|
|
3138
3248
|
/**
|
|
3139
3249
|
* Returns the member information.
|
|
@@ -3142,7 +3252,9 @@
|
|
|
3142
3252
|
* @param memberId - Member ID.
|
|
3143
3253
|
*/
|
|
3144
3254
|
getMember(memberId) {
|
|
3145
|
-
return
|
|
3255
|
+
return this.internalGet(`/members/${memberId}`)
|
|
3256
|
+
.then((response) => response.json())
|
|
3257
|
+
.then((data) => new Member(data, this.id, this.httpClient));
|
|
3146
3258
|
}
|
|
3147
3259
|
/**
|
|
3148
3260
|
* Add a user to the project to become a member and have permission to perform actions.
|
|
@@ -3152,7 +3264,9 @@
|
|
|
3152
3264
|
* @param role - User role from the list of project roles.
|
|
3153
3265
|
*/
|
|
3154
3266
|
addMember(userId, role) {
|
|
3155
|
-
return
|
|
3267
|
+
return this.internalPost("/members", { userId, role })
|
|
3268
|
+
.then((response) => response.json())
|
|
3269
|
+
.then((data) => new Member(data, this.id, this.httpClient));
|
|
3156
3270
|
}
|
|
3157
3271
|
/**
|
|
3158
3272
|
* Remove a member from a project.
|
|
@@ -3162,7 +3276,7 @@
|
|
|
3162
3276
|
* @returns Returns the raw data of a deleted member.
|
|
3163
3277
|
*/
|
|
3164
3278
|
removeMember(memberId) {
|
|
3165
|
-
return
|
|
3279
|
+
return this.internalDelete(`/members/${memberId}`).then((response) => response.json());
|
|
3166
3280
|
}
|
|
3167
3281
|
/**
|
|
3168
3282
|
* Information about the file (model) that can be reference in the project topics.
|
|
@@ -3183,7 +3297,10 @@
|
|
|
3183
3297
|
* @async
|
|
3184
3298
|
*/
|
|
3185
3299
|
getFilesInformation() {
|
|
3186
|
-
return
|
|
3300
|
+
return this.httpClient
|
|
3301
|
+
.get(`/bcf/3.0/projects/${this.data.id}/files_information`)
|
|
3302
|
+
.then((response) => response.json())
|
|
3303
|
+
.then((items) => {
|
|
3187
3304
|
items.forEach((item) => {
|
|
3188
3305
|
const getFieldValue = (displayName) => {
|
|
3189
3306
|
return (item.display_information.find((x) => x.field_display_name === displayName) || {}).field_value;
|
|
@@ -3206,7 +3323,10 @@
|
|
|
3206
3323
|
const updatedByUserName = getFieldValue("Updated By User Name");
|
|
3207
3324
|
const updatedByFullName = userFullName(updatedByFirstName, updatedByLastName, updatedByUserName);
|
|
3208
3325
|
const updatedByInitials = userInitials(updatedByFullName);
|
|
3209
|
-
item.display_information.push({
|
|
3326
|
+
item.display_information.push({
|
|
3327
|
+
field_display_name: "Updated By Avatar URL",
|
|
3328
|
+
field_value: updatedByAvatarUrl,
|
|
3329
|
+
});
|
|
3210
3330
|
item.display_information.push({ field_display_name: "Updated By Full Name", field_value: updatedByFullName });
|
|
3211
3331
|
item.display_information.push({ field_display_name: "Updated By Initials", field_value: updatedByInitials });
|
|
3212
3332
|
// geometryType since 24.12
|
|
@@ -3391,11 +3511,13 @@
|
|
|
3391
3511
|
*/
|
|
3392
3512
|
async checkout() {
|
|
3393
3513
|
if (this.id === this.httpClient.signInUserId) {
|
|
3394
|
-
const
|
|
3514
|
+
const response = await this.httpClient.get("/user");
|
|
3515
|
+
const data = await response.json();
|
|
3395
3516
|
this.data = { id: this.id, ...data };
|
|
3396
3517
|
}
|
|
3397
3518
|
else {
|
|
3398
|
-
const
|
|
3519
|
+
const response = await this.httpClient.get(`/users/${this.id}`);
|
|
3520
|
+
const data = await response.json();
|
|
3399
3521
|
this.data = { id: data.id, ...data.userBrief };
|
|
3400
3522
|
}
|
|
3401
3523
|
return this;
|
|
@@ -3410,11 +3532,13 @@
|
|
|
3410
3532
|
*/
|
|
3411
3533
|
async update(data) {
|
|
3412
3534
|
if (this.id === this.httpClient.signInUserId) {
|
|
3413
|
-
const
|
|
3535
|
+
const response = await this.httpClient.put("/user", data);
|
|
3536
|
+
const newData = await response.json();
|
|
3414
3537
|
this.data = { id: this.id, ...newData };
|
|
3415
3538
|
}
|
|
3416
3539
|
else {
|
|
3417
|
-
const
|
|
3540
|
+
const response = await this.httpClient.put(`/users/${this.id}`, { userBrief: data });
|
|
3541
|
+
const newData = await response.json();
|
|
3418
3542
|
this.data = { id: newData.id, ...newData.userBrief };
|
|
3419
3543
|
}
|
|
3420
3544
|
return this;
|
|
@@ -3432,7 +3556,10 @@
|
|
|
3432
3556
|
* @returns Returns the raw data of a deleted user.
|
|
3433
3557
|
*/
|
|
3434
3558
|
delete() {
|
|
3435
|
-
return
|
|
3559
|
+
return this.httpClient
|
|
3560
|
+
.delete(`/users/${this.id}`)
|
|
3561
|
+
.then((response) => response.json())
|
|
3562
|
+
.then((data) => {
|
|
3436
3563
|
if (this.id === this.httpClient.signInUserId) {
|
|
3437
3564
|
this.httpClient.headers = {};
|
|
3438
3565
|
this.httpClient.signInUserId = "";
|
|
@@ -3467,21 +3594,25 @@
|
|
|
3467
3594
|
async setAvatar(image) {
|
|
3468
3595
|
if (image) {
|
|
3469
3596
|
if (this.id === this.httpClient.signInUserId) {
|
|
3470
|
-
const
|
|
3597
|
+
const response = await this.httpClient.post("/user/avatar", image);
|
|
3598
|
+
const data = await response.json();
|
|
3471
3599
|
this.data = { id: this.id, ...data };
|
|
3472
3600
|
}
|
|
3473
3601
|
else {
|
|
3474
|
-
const
|
|
3602
|
+
const response = await this.httpClient.post(`/users/${this.id}/avatar`, image);
|
|
3603
|
+
const data = await response.json();
|
|
3475
3604
|
this.data = { id: data.id, ...data.userBrief };
|
|
3476
3605
|
}
|
|
3477
3606
|
}
|
|
3478
3607
|
else {
|
|
3479
3608
|
if (this.id === this.httpClient.signInUserId) {
|
|
3480
|
-
const
|
|
3609
|
+
const response = await this.httpClient.delete("/user/avatar");
|
|
3610
|
+
const data = await response.json();
|
|
3481
3611
|
this.data = { id: this.id, ...data };
|
|
3482
3612
|
}
|
|
3483
3613
|
else {
|
|
3484
|
-
const
|
|
3614
|
+
const response = await this.httpClient.delete(`/users/${this.id}/avatar`);
|
|
3615
|
+
const data = await response.json();
|
|
3485
3616
|
this.data = { id: data.id, ...data.userBrief };
|
|
3486
3617
|
}
|
|
3487
3618
|
}
|
|
@@ -3507,7 +3638,7 @@
|
|
|
3507
3638
|
this._user = null;
|
|
3508
3639
|
}
|
|
3509
3640
|
/**
|
|
3510
|
-
* Open Cloud Server URL. Use {@link Client
|
|
3641
|
+
* Open Cloud Server URL. Use {@link Client.configure()} to change server URL.
|
|
3511
3642
|
*
|
|
3512
3643
|
* @readonly
|
|
3513
3644
|
*/
|
|
@@ -3515,8 +3646,7 @@
|
|
|
3515
3646
|
return this._serverUrl;
|
|
3516
3647
|
}
|
|
3517
3648
|
/**
|
|
3518
|
-
* Deprecated since `25.3`. Use
|
|
3519
|
-
* Viewer parameters.
|
|
3649
|
+
* Deprecated since `25.3`. Use {@link Viewer.options()} instead to change Viewer parameters.
|
|
3520
3650
|
*/
|
|
3521
3651
|
get options() {
|
|
3522
3652
|
console.warn("Client.options has been deprecated since 25.3 and will be removed in a future release, use Viewer.options instead.");
|
|
@@ -3587,7 +3717,7 @@
|
|
|
3587
3717
|
.then((data) => ({
|
|
3588
3718
|
...data,
|
|
3589
3719
|
server: data.version,
|
|
3590
|
-
client: "25.3.
|
|
3720
|
+
client: "25.3.18",
|
|
3591
3721
|
}));
|
|
3592
3722
|
}
|
|
3593
3723
|
/**
|
|
@@ -3643,7 +3773,8 @@
|
|
|
3643
3773
|
async signInWithEmail(email, password) {
|
|
3644
3774
|
const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
|
|
3645
3775
|
this._httpClient.headers = { Authorization: "Basic " + credentials };
|
|
3646
|
-
const
|
|
3776
|
+
const response = await this._httpClient.get("/token");
|
|
3777
|
+
const data = await response.json();
|
|
3647
3778
|
return this.setCurrentUser(data);
|
|
3648
3779
|
}
|
|
3649
3780
|
/**
|
|
@@ -3655,7 +3786,8 @@
|
|
|
3655
3786
|
*/
|
|
3656
3787
|
async signInWithToken(token) {
|
|
3657
3788
|
this._httpClient.headers = { Authorization: token };
|
|
3658
|
-
const
|
|
3789
|
+
const response = await this._httpClient.get("/user");
|
|
3790
|
+
const data = await response.json();
|
|
3659
3791
|
return this.setCurrentUser(data);
|
|
3660
3792
|
}
|
|
3661
3793
|
// Save the current logged in user information for internal use.
|
|
@@ -3686,7 +3818,9 @@
|
|
|
3686
3818
|
* @async
|
|
3687
3819
|
*/
|
|
3688
3820
|
getUsers() {
|
|
3689
|
-
return
|
|
3821
|
+
return this._httpClient
|
|
3822
|
+
.get("/users")
|
|
3823
|
+
.then((response) => response.json())
|
|
3690
3824
|
.then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
|
|
3691
3825
|
.then((array) => array.map((data) => new User(data, this._httpClient)));
|
|
3692
3826
|
}
|
|
@@ -3700,12 +3834,16 @@
|
|
|
3700
3834
|
*/
|
|
3701
3835
|
getUser(userId) {
|
|
3702
3836
|
if (userId === this._httpClient.signInUserId) {
|
|
3703
|
-
return
|
|
3837
|
+
return this._httpClient
|
|
3838
|
+
.get("/user")
|
|
3839
|
+
.then((response) => response.json())
|
|
3704
3840
|
.then((data) => ({ id: userId, ...data }))
|
|
3705
3841
|
.then((data) => new User(data, this._httpClient));
|
|
3706
3842
|
}
|
|
3707
3843
|
else {
|
|
3708
|
-
return
|
|
3844
|
+
return this._httpClient
|
|
3845
|
+
.get(`/users/${userId}`)
|
|
3846
|
+
.then((response) => response.json())
|
|
3709
3847
|
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
3710
3848
|
.then((data) => new User(data, this._httpClient));
|
|
3711
3849
|
}
|
|
@@ -3730,7 +3868,8 @@
|
|
|
3730
3868
|
*/
|
|
3731
3869
|
createUser(email, password, params = {}) {
|
|
3732
3870
|
const { isAdmin, userName, ...rest } = params;
|
|
3733
|
-
return
|
|
3871
|
+
return this._httpClient
|
|
3872
|
+
.post("/users", {
|
|
3734
3873
|
isAdmin,
|
|
3735
3874
|
userBrief: {
|
|
3736
3875
|
...rest,
|
|
@@ -3738,7 +3877,8 @@
|
|
|
3738
3877
|
userName: userName !== null && userName !== void 0 ? userName : (email + "").split("@").at(0),
|
|
3739
3878
|
},
|
|
3740
3879
|
password,
|
|
3741
|
-
})
|
|
3880
|
+
})
|
|
3881
|
+
.then((response) => response.json())
|
|
3742
3882
|
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
3743
3883
|
.then((data) => new User(data, this._httpClient));
|
|
3744
3884
|
}
|
|
@@ -3756,7 +3896,10 @@
|
|
|
3756
3896
|
* @returns Returns the raw data of a deleted user.
|
|
3757
3897
|
*/
|
|
3758
3898
|
deleteUser(userId) {
|
|
3759
|
-
return
|
|
3899
|
+
return this._httpClient
|
|
3900
|
+
.delete(`/users/${userId}`)
|
|
3901
|
+
.then((response) => response.json())
|
|
3902
|
+
.then((data) => {
|
|
3760
3903
|
if (userId === this._httpClient.signInUserId) {
|
|
3761
3904
|
this.clearCurrentUser();
|
|
3762
3905
|
}
|
|
@@ -3818,10 +3961,13 @@
|
|
|
3818
3961
|
let queryString = searchParams.toString();
|
|
3819
3962
|
if (queryString)
|
|
3820
3963
|
queryString = "?" + queryString;
|
|
3821
|
-
return
|
|
3964
|
+
return this._httpClient
|
|
3965
|
+
.get(`/files${queryString}`)
|
|
3966
|
+
.then((response) => response.json())
|
|
3967
|
+
.then((files) => {
|
|
3822
3968
|
return {
|
|
3823
3969
|
...files,
|
|
3824
|
-
result: files.result.map((data) => new File
|
|
3970
|
+
result: files.result.map((data) => new File(data, this._httpClient)),
|
|
3825
3971
|
};
|
|
3826
3972
|
});
|
|
3827
3973
|
}
|
|
@@ -3832,7 +3978,10 @@
|
|
|
3832
3978
|
* @param fileId - File ID.
|
|
3833
3979
|
*/
|
|
3834
3980
|
getFile(fileId) {
|
|
3835
|
-
return
|
|
3981
|
+
return this._httpClient
|
|
3982
|
+
.get(`/files/${fileId}`)
|
|
3983
|
+
.then((response) => response.json())
|
|
3984
|
+
.then((data) => new File(data, this._httpClient));
|
|
3836
3985
|
}
|
|
3837
3986
|
/**
|
|
3838
3987
|
* Upload a drawing or reference file to the server.
|
|
@@ -3870,13 +4019,13 @@
|
|
|
3870
4019
|
waitForDone: false,
|
|
3871
4020
|
}) {
|
|
3872
4021
|
const result = await this._httpClient
|
|
3873
|
-
.
|
|
4022
|
+
.uploadFile("/files", file, (progress) => {
|
|
3874
4023
|
var _a;
|
|
3875
4024
|
this.emitEvent({ type: "uploadprogress", data: progress, file });
|
|
3876
4025
|
(_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
|
|
3877
4026
|
})
|
|
3878
4027
|
.then((xhr) => JSON.parse(xhr.responseText))
|
|
3879
|
-
.then((data) => new File
|
|
4028
|
+
.then((data) => new File(data, this._httpClient));
|
|
3880
4029
|
const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
|
|
3881
4030
|
const jobs = [];
|
|
3882
4031
|
if (params.geometry)
|
|
@@ -3895,7 +4044,7 @@
|
|
|
3895
4044
|
* @returns Returns the raw data of a deleted file.
|
|
3896
4045
|
*/
|
|
3897
4046
|
deleteFile(fileId) {
|
|
3898
|
-
return
|
|
4047
|
+
return this._httpClient.delete(`/files/${fileId}`).then((response) => response.json());
|
|
3899
4048
|
}
|
|
3900
4049
|
/**
|
|
3901
4050
|
* Download the drawing or reference file.
|
|
@@ -3909,8 +4058,7 @@
|
|
|
3909
4058
|
*/
|
|
3910
4059
|
downloadFile(fileId, onProgress, signal) {
|
|
3911
4060
|
return this._httpClient
|
|
3912
|
-
.
|
|
3913
|
-
.then((response) => downloadProgress(response, onProgress))
|
|
4061
|
+
.downloadFile(`/files/${fileId}/downloads`, onProgress, signal)
|
|
3914
4062
|
.then((response) => response.arrayBuffer());
|
|
3915
4063
|
}
|
|
3916
4064
|
/**
|
|
@@ -3956,7 +4104,10 @@
|
|
|
3956
4104
|
let queryString = searchParams.toString();
|
|
3957
4105
|
if (queryString)
|
|
3958
4106
|
queryString = "?" + queryString;
|
|
3959
|
-
return
|
|
4107
|
+
return this._httpClient
|
|
4108
|
+
.get(`/jobs${queryString}`)
|
|
4109
|
+
.then((response) => response.json())
|
|
4110
|
+
.then((jobs) => ({
|
|
3960
4111
|
...jobs,
|
|
3961
4112
|
result: jobs.result.map((data) => new Job(data, this._httpClient)),
|
|
3962
4113
|
}));
|
|
@@ -3968,7 +4119,10 @@
|
|
|
3968
4119
|
* @param jobId - Job ID.
|
|
3969
4120
|
*/
|
|
3970
4121
|
getJob(jobId) {
|
|
3971
|
-
return
|
|
4122
|
+
return this._httpClient
|
|
4123
|
+
.get(`/jobs/${jobId}`)
|
|
4124
|
+
.then((response) => response.json())
|
|
4125
|
+
.then((data) => new Job(data, this._httpClient));
|
|
3972
4126
|
}
|
|
3973
4127
|
/**
|
|
3974
4128
|
* Create a new job.
|
|
@@ -4007,7 +4161,7 @@
|
|
|
4007
4161
|
* @returns Returns the raw data of a deleted job.
|
|
4008
4162
|
*/
|
|
4009
4163
|
deleteJob(jobId) {
|
|
4010
|
-
return
|
|
4164
|
+
return this._httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
|
|
4011
4165
|
}
|
|
4012
4166
|
/**
|
|
4013
4167
|
* Result for assembly list.
|
|
@@ -4056,7 +4210,10 @@
|
|
|
4056
4210
|
let queryString = searchParams.toString();
|
|
4057
4211
|
if (queryString)
|
|
4058
4212
|
queryString = "?" + queryString;
|
|
4059
|
-
return
|
|
4213
|
+
return this._httpClient
|
|
4214
|
+
.get(`/assemblies${queryString}`)
|
|
4215
|
+
.then((response) => response.json())
|
|
4216
|
+
.then((assemblies) => {
|
|
4060
4217
|
return {
|
|
4061
4218
|
...assemblies,
|
|
4062
4219
|
result: assemblies.result.map((data) => new Assembly(data, this._httpClient)),
|
|
@@ -4070,7 +4227,10 @@
|
|
|
4070
4227
|
* @param assemblyId - Assembly ID.
|
|
4071
4228
|
*/
|
|
4072
4229
|
getAssembly(assemblyId) {
|
|
4073
|
-
return
|
|
4230
|
+
return this._httpClient
|
|
4231
|
+
.get(`/assemblies/${assemblyId}`)
|
|
4232
|
+
.then((response) => response.json())
|
|
4233
|
+
.then((data) => new Assembly(data, this._httpClient));
|
|
4074
4234
|
}
|
|
4075
4235
|
/**
|
|
4076
4236
|
* Create a new assembly.
|
|
@@ -4097,7 +4257,7 @@
|
|
|
4097
4257
|
* @returns Returns the raw data of a deleted assembly.
|
|
4098
4258
|
*/
|
|
4099
4259
|
deleteAssembly(assemblyId) {
|
|
4100
|
-
return
|
|
4260
|
+
return this._httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
|
|
4101
4261
|
}
|
|
4102
4262
|
/**
|
|
4103
4263
|
* Result for project list.
|
|
@@ -4142,7 +4302,9 @@
|
|
|
4142
4302
|
let queryString = searchParams.toString();
|
|
4143
4303
|
if (queryString)
|
|
4144
4304
|
queryString = "?" + queryString;
|
|
4145
|
-
return
|
|
4305
|
+
return this._httpClient
|
|
4306
|
+
.get(`/projects${queryString}`)
|
|
4307
|
+
.then((response) => response.json())
|
|
4146
4308
|
.then((projects) => {
|
|
4147
4309
|
// fix for server 23.5 and below
|
|
4148
4310
|
if (Array.isArray(projects)) {
|
|
@@ -4179,7 +4341,10 @@
|
|
|
4179
4341
|
* @param projectId - Project ID.
|
|
4180
4342
|
*/
|
|
4181
4343
|
getProject(projectId) {
|
|
4182
|
-
return
|
|
4344
|
+
return this._httpClient
|
|
4345
|
+
.get(`/projects/${projectId}`)
|
|
4346
|
+
.then((response) => response.json())
|
|
4347
|
+
.then((data) => new Project(data, this._httpClient));
|
|
4183
4348
|
}
|
|
4184
4349
|
/**
|
|
4185
4350
|
* Create a new project.
|
|
@@ -4194,13 +4359,16 @@
|
|
|
4194
4359
|
* target="_blank">Data URL</a>.
|
|
4195
4360
|
*/
|
|
4196
4361
|
createProject(name, description, startDate, endDate, avatarUrl) {
|
|
4197
|
-
return
|
|
4362
|
+
return this._httpClient
|
|
4363
|
+
.post("/projects", {
|
|
4198
4364
|
name,
|
|
4199
4365
|
description,
|
|
4200
4366
|
startDate: startDate instanceof Date ? startDate.toISOString() : startDate,
|
|
4201
4367
|
endDate: endDate instanceof Date ? endDate.toISOString() : endDate,
|
|
4202
4368
|
avatarUrl,
|
|
4203
|
-
})
|
|
4369
|
+
})
|
|
4370
|
+
.then((response) => response.json())
|
|
4371
|
+
.then((data) => new Project(data, this._httpClient));
|
|
4204
4372
|
}
|
|
4205
4373
|
/**
|
|
4206
4374
|
* Delete the project from the server.
|
|
@@ -4210,7 +4378,10 @@
|
|
|
4210
4378
|
* @returns Returns the raw data of a deleted project.
|
|
4211
4379
|
*/
|
|
4212
4380
|
deleteProject(projectId) {
|
|
4213
|
-
return
|
|
4381
|
+
return this._httpClient
|
|
4382
|
+
.delete(`/projects/${projectId}`)
|
|
4383
|
+
.then((response) => response.text())
|
|
4384
|
+
.then((text) => {
|
|
4214
4385
|
// fix for server 23.5 and below
|
|
4215
4386
|
try {
|
|
4216
4387
|
return JSON.parse(text);
|
|
@@ -4223,12 +4394,12 @@
|
|
|
4223
4394
|
}
|
|
4224
4395
|
|
|
4225
4396
|
///////////////////////////////////////////////////////////////////////////////
|
|
4226
|
-
const version = "25.3.
|
|
4397
|
+
const version = "25.3.18";
|
|
4227
4398
|
|
|
4228
4399
|
exports.Assembly = Assembly;
|
|
4229
4400
|
exports.ClashTest = ClashTest;
|
|
4230
4401
|
exports.Client = Client;
|
|
4231
|
-
exports.File = File
|
|
4402
|
+
exports.File = File;
|
|
4232
4403
|
exports.Job = Job;
|
|
4233
4404
|
exports.Member = Member;
|
|
4234
4405
|
exports.Model = Model;
|