@inweb/client 25.12.0 → 26.1.0
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 +618 -322
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +393 -312
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +7 -10
- package/lib/Api/ClashTest.d.ts +4 -8
- package/lib/Api/Client.d.ts +53 -4
- package/lib/Api/Endpoint.d.ts +73 -0
- package/lib/Api/Fetch.d.ts +3 -3
- package/lib/Api/File.d.ts +32 -14
- package/lib/Api/HttpClient.d.ts +7 -7
- package/lib/Api/IFile.d.ts +1 -1
- package/lib/Api/IHttpClient.d.ts +31 -26
- package/lib/Api/ISharedLink.d.ts +36 -0
- package/lib/Api/Job.d.ts +2 -5
- package/lib/Api/Member.d.ts +2 -6
- package/lib/Api/Model.d.ts +2 -4
- package/lib/Api/OAuthClient.d.ts +2 -6
- package/lib/Api/Permission.d.ts +3 -7
- package/lib/Api/Project.d.ts +3 -7
- package/lib/Api/Role.d.ts +2 -5
- package/lib/Api/SharedFile.d.ts +9 -0
- package/lib/Api/SharedLink.d.ts +70 -0
- package/lib/Api/User.d.ts +2 -2
- package/lib/Api/XMLHttp.d.ts +1 -1
- package/lib/index.d.ts +5 -1
- package/package.json +2 -2
- package/src/Api/Assembly.ts +45 -58
- package/src/Api/ClashTest.ts +10 -24
- package/src/Api/Client.ts +88 -9
- package/src/Api/Endpoint.ts +130 -0
- package/src/Api/Fetch.ts +20 -20
- package/src/Api/File.ts +101 -75
- package/src/Api/HttpClient.ts +40 -17
- package/src/Api/IFile.ts +1 -1
- package/src/Api/IHttpClient.ts +32 -26
- package/src/Api/ISharedLink.ts +63 -0
- package/src/Api/Job.ts +7 -19
- package/src/Api/Member.ts +7 -21
- package/src/Api/Model.ts +4 -7
- package/src/Api/OAuthClient.ts +8 -24
- package/src/Api/Permission.ts +8 -22
- package/src/Api/Project.ts +30 -43
- package/src/Api/Role.ts +8 -19
- package/src/Api/SharedFile.ts +54 -0
- package/src/Api/SharedLink.ts +135 -0
- package/src/Api/User.ts +16 -16
- package/src/Api/XMLHttp.ts +1 -1
- package/src/index.ts +5 -9
package/dist/client.module.js
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
class Endpoint {
|
|
2
|
+
constructor(path, httpClient, headers = {}) {
|
|
3
|
+
this.path = path;
|
|
4
|
+
this.httpClient = httpClient;
|
|
5
|
+
this.headers = headers;
|
|
6
|
+
}
|
|
7
|
+
appendVersionParam(relativePath) {
|
|
8
|
+
if (this._useVersion === undefined) return relativePath;
|
|
9
|
+
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
10
|
+
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
11
|
+
}
|
|
12
|
+
getEndpointPath(relativePath) {
|
|
13
|
+
return this.appendVersionParam(`${this.path}${relativePath}`);
|
|
14
|
+
}
|
|
15
|
+
get(relativePath, signal) {
|
|
16
|
+
return this.httpClient.get(this.getEndpointPath(relativePath), {
|
|
17
|
+
signal: signal,
|
|
18
|
+
headers: this.headers
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
post(relativePath, body) {
|
|
22
|
+
return this.httpClient.post(this.getEndpointPath(relativePath), body, {
|
|
23
|
+
headers: this.headers
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
put(relativePath, body) {
|
|
27
|
+
return this.httpClient.put(this.getEndpointPath(relativePath), body, {
|
|
28
|
+
headers: this.headers
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
delete(relativePath) {
|
|
32
|
+
return this.httpClient.delete(this.getEndpointPath(relativePath), {
|
|
33
|
+
headers: this.headers
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
useVersion(version) {
|
|
37
|
+
this._useVersion = version;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
1
42
|
const STATUS_CODES = {
|
|
2
43
|
100: "Continue",
|
|
3
44
|
101: "Switching Protocols",
|
|
@@ -85,12 +126,11 @@ class FetchError extends Error {
|
|
|
85
126
|
}
|
|
86
127
|
}
|
|
87
128
|
|
|
88
|
-
class Model {
|
|
129
|
+
class Model extends Endpoint {
|
|
89
130
|
constructor(data, file) {
|
|
90
|
-
|
|
91
|
-
this.httpClient = file.httpClient;
|
|
92
|
-
this._file = file;
|
|
131
|
+
super(`${file.path}/downloads`, file.httpClient);
|
|
93
132
|
this._data = data;
|
|
133
|
+
this._file = file;
|
|
94
134
|
}
|
|
95
135
|
get assembly() {
|
|
96
136
|
return this._file;
|
|
@@ -255,21 +295,11 @@ function userInitials(fullName = "") {
|
|
|
255
295
|
}), "").toUpperCase();
|
|
256
296
|
}
|
|
257
297
|
|
|
258
|
-
class ClashTest {
|
|
259
|
-
constructor(data,
|
|
260
|
-
|
|
261
|
-
this.basePath = basePath;
|
|
298
|
+
class ClashTest extends Endpoint {
|
|
299
|
+
constructor(data, path, httpClient) {
|
|
300
|
+
super(`${path}/clashes/${data.id}`, httpClient);
|
|
262
301
|
this.data = data;
|
|
263
302
|
}
|
|
264
|
-
internalGet(relativePath) {
|
|
265
|
-
return this.httpClient.get(`${this.basePath}/clashes/${this.id}${relativePath}`);
|
|
266
|
-
}
|
|
267
|
-
internalPut(relativePath, body) {
|
|
268
|
-
return this.httpClient.put(`${this.basePath}/clashes/${this.id}${relativePath}`, body);
|
|
269
|
-
}
|
|
270
|
-
internalDelete(relativePath) {
|
|
271
|
-
return this.httpClient.delete(`${this.basePath}/clashes/${this.id}${relativePath}`);
|
|
272
|
-
}
|
|
273
303
|
get clearance() {
|
|
274
304
|
return this.data.clearance;
|
|
275
305
|
}
|
|
@@ -319,17 +349,17 @@ class ClashTest {
|
|
|
319
349
|
return this.data.tolerance;
|
|
320
350
|
}
|
|
321
351
|
async checkout() {
|
|
322
|
-
const response = await this.
|
|
352
|
+
const response = await this.get("");
|
|
323
353
|
this.data = await response.json();
|
|
324
354
|
return this;
|
|
325
355
|
}
|
|
326
356
|
async update(data) {
|
|
327
|
-
const response = await this.
|
|
357
|
+
const response = await this.put("", data);
|
|
328
358
|
this.data = await response.json();
|
|
329
359
|
return this;
|
|
330
360
|
}
|
|
331
361
|
delete() {
|
|
332
|
-
return
|
|
362
|
+
return super.delete("").then((response => response.json()));
|
|
333
363
|
}
|
|
334
364
|
save() {
|
|
335
365
|
return this.update(this.data);
|
|
@@ -344,37 +374,15 @@ class ClashTest {
|
|
|
344
374
|
return waitFor(checkDone, params).then((() => this));
|
|
345
375
|
}
|
|
346
376
|
getReport() {
|
|
347
|
-
return this.
|
|
377
|
+
return this.get("/report").then((response => response.json()));
|
|
348
378
|
}
|
|
349
379
|
}
|
|
350
380
|
|
|
351
|
-
class Assembly {
|
|
381
|
+
class Assembly extends Endpoint {
|
|
352
382
|
constructor(data, httpClient) {
|
|
353
|
-
|
|
354
|
-
this.httpClient = httpClient;
|
|
383
|
+
super(`/assemblies/${data.id}`, httpClient);
|
|
355
384
|
this.data = data;
|
|
356
385
|
}
|
|
357
|
-
appendVersionParam(relativePath) {
|
|
358
|
-
if (this._useVersion === undefined) return relativePath;
|
|
359
|
-
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
360
|
-
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
361
|
-
}
|
|
362
|
-
internalGet(relativePath, signal) {
|
|
363
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
364
|
-
return this.httpClient.get(`${this.path}${relativePath}`, signal);
|
|
365
|
-
}
|
|
366
|
-
internalPost(relativePath, body) {
|
|
367
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
368
|
-
return this.httpClient.post(`${this.path}${relativePath}`, body);
|
|
369
|
-
}
|
|
370
|
-
internalPut(relativePath, body) {
|
|
371
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
372
|
-
return this.httpClient.put(`${this.path}${relativePath}`, body);
|
|
373
|
-
}
|
|
374
|
-
internalDelete(relativePath) {
|
|
375
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
376
|
-
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
377
|
-
}
|
|
378
386
|
get activeVersion() {
|
|
379
387
|
return this.data.activeVersion;
|
|
380
388
|
}
|
|
@@ -437,17 +445,17 @@ class Assembly {
|
|
|
437
445
|
return this.data.versions;
|
|
438
446
|
}
|
|
439
447
|
async checkout() {
|
|
440
|
-
const response = await this.
|
|
448
|
+
const response = await this.get("");
|
|
441
449
|
this.data = await response.json();
|
|
442
450
|
return this;
|
|
443
451
|
}
|
|
444
452
|
async update(data) {
|
|
445
|
-
const response = await this.
|
|
453
|
+
const response = await this.put("", data);
|
|
446
454
|
this.data = await response.json();
|
|
447
455
|
return this;
|
|
448
456
|
}
|
|
449
457
|
delete() {
|
|
450
|
-
return
|
|
458
|
+
return super.delete("").then((response => response.json()));
|
|
451
459
|
}
|
|
452
460
|
save() {
|
|
453
461
|
return this.update(this.data);
|
|
@@ -461,7 +469,7 @@ class Assembly {
|
|
|
461
469
|
return Promise.resolve(this);
|
|
462
470
|
}
|
|
463
471
|
getModels() {
|
|
464
|
-
return this.
|
|
472
|
+
return this.get("/geometry").then((response => response.json())).then((array => array.map((data => new Model(data, this)))));
|
|
465
473
|
}
|
|
466
474
|
getModelTransformMatrix(handle) {
|
|
467
475
|
return this.data.transform[handle];
|
|
@@ -477,36 +485,40 @@ class Assembly {
|
|
|
477
485
|
}
|
|
478
486
|
getProperties(handles) {
|
|
479
487
|
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
480
|
-
return this.
|
|
488
|
+
return this.get(relativePath).then((response => response.json()));
|
|
481
489
|
}
|
|
482
490
|
searchProperties(searchPattern) {
|
|
483
|
-
return this.
|
|
491
|
+
return this.post("/properties/search", searchPattern).then((response => response.json()));
|
|
484
492
|
}
|
|
485
493
|
getCdaTree() {
|
|
486
|
-
return this.
|
|
494
|
+
return this.get(`/properties/tree`).then((response => response.json()));
|
|
487
495
|
}
|
|
488
496
|
getViewpoints() {
|
|
489
|
-
return this.
|
|
497
|
+
return this.get("/viewpoints").then((response => response.json())).then((viewpoints => viewpoints.result));
|
|
490
498
|
}
|
|
491
499
|
saveViewpoint(viewpoint) {
|
|
492
|
-
return this.
|
|
500
|
+
return this.post("/viewpoints", viewpoint).then((response => response.json()));
|
|
493
501
|
}
|
|
494
502
|
deleteViewpoint(guid) {
|
|
495
|
-
return
|
|
503
|
+
return super.delete(`/viewpoints/${guid}`).then((response => response.json()));
|
|
496
504
|
}
|
|
497
505
|
getSnapshot(guid) {
|
|
498
|
-
return this.
|
|
506
|
+
return this.get(`/viewpoints/${guid}/snapshot`).then((response => response.text()));
|
|
499
507
|
}
|
|
500
508
|
getSnapshotData(guid, bitmapGuid) {
|
|
501
|
-
return this.
|
|
509
|
+
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response => response.text()));
|
|
502
510
|
}
|
|
503
511
|
downloadResource(dataId, onProgress, signal) {
|
|
504
|
-
|
|
505
|
-
|
|
512
|
+
return this.httpClient.downloadFile(this.getEndpointPath(`/downloads/${dataId}`), onProgress, {
|
|
513
|
+
signal: signal,
|
|
514
|
+
headers: this.headers
|
|
515
|
+
}).then((response => response.arrayBuffer()));
|
|
506
516
|
}
|
|
507
517
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
508
|
-
|
|
509
|
-
|
|
518
|
+
return this.httpClient.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}?requestId=${requestId}`), requestId, ranges, onProgress, {
|
|
519
|
+
signal: signal,
|
|
520
|
+
headers: this.headers
|
|
521
|
+
}).then((response => response.arrayBuffer()));
|
|
510
522
|
}
|
|
511
523
|
partialDownloadResource(dataId, onProgress, signal) {
|
|
512
524
|
console.warn("Assembly.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Assembly.downloadResource() instead.");
|
|
@@ -516,7 +528,8 @@ class Assembly {
|
|
|
516
528
|
await this.downloadResourceRange(dataId, requestId, records, onProgress, signal);
|
|
517
529
|
}
|
|
518
530
|
async getReferences(signal) {
|
|
519
|
-
const
|
|
531
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
532
|
+
const references = await Promise.all(this.associatedFiles.map((file => `/${file.fileId}/references`)).map((link => files.get(link, signal).then((response => response.json()))))).then((references => references.map((x => x.references)))).then((references => references.reduce(((x, v) => [ ...v, ...x ]), []))).then((references => [ ...new Set(references.map(JSON.stringify)) ].map((x => JSON.parse(x)))));
|
|
520
533
|
return {
|
|
521
534
|
id: "",
|
|
522
535
|
references: references
|
|
@@ -545,19 +558,19 @@ class Assembly {
|
|
|
545
558
|
if (sortField) searchParams.set("sortField", sortField);
|
|
546
559
|
let queryString = searchParams.toString();
|
|
547
560
|
if (queryString) queryString = "?" + queryString;
|
|
548
|
-
return this.
|
|
561
|
+
return this.get(`/clashes${queryString}`).then((response => response.json())).then((tests => ({
|
|
549
562
|
...tests,
|
|
550
563
|
result: tests.result.map((data => new ClashTest(data, this.path, this.httpClient)))
|
|
551
564
|
})));
|
|
552
565
|
}
|
|
553
566
|
getClashTest(testId) {
|
|
554
|
-
return this.
|
|
567
|
+
return this.get(`/clashes/${testId}`).then((response => response.json())).then((data => new ClashTest(data, this.path, this.httpClient)));
|
|
555
568
|
}
|
|
556
569
|
createClashTest(name, selectionTypeA, selectionTypeB, selectionSetA, selectionSetB, params) {
|
|
557
570
|
const {tolerance: tolerance, clearance: clearance, waitForDone: waitForDone} = params !== null && params !== void 0 ? params : {};
|
|
558
571
|
if (!Array.isArray(selectionSetA)) selectionSetA = [ selectionSetA ];
|
|
559
572
|
if (!Array.isArray(selectionSetB)) selectionSetB = [ selectionSetB ];
|
|
560
|
-
return this.
|
|
573
|
+
return this.post("/clashes", {
|
|
561
574
|
name: name,
|
|
562
575
|
selectionTypeA: selectionTypeA,
|
|
563
576
|
selectionTypeB: selectionTypeB,
|
|
@@ -568,7 +581,7 @@ class Assembly {
|
|
|
568
581
|
}).then((response => response.json())).then((data => new ClashTest(data, this.path, this.httpClient))).then((result => waitForDone ? result.waitForDone(params) : result));
|
|
569
582
|
}
|
|
570
583
|
deleteClashTest(testId) {
|
|
571
|
-
return
|
|
584
|
+
return super.delete(`/clashes/${testId}`).then((response => response.json()));
|
|
572
585
|
}
|
|
573
586
|
updateVersion(files, params = {
|
|
574
587
|
waitForDone: false
|
|
@@ -589,9 +602,14 @@ class Assembly {
|
|
|
589
602
|
activeVersion: version
|
|
590
603
|
});
|
|
591
604
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
605
|
+
async createSharedLink(permissions) {
|
|
606
|
+
return Promise.reject(new Error("Assembly shared link will be implemeted in a future release"));
|
|
607
|
+
}
|
|
608
|
+
async getSharedLink() {
|
|
609
|
+
return Promise.resolve(undefined);
|
|
610
|
+
}
|
|
611
|
+
async deleteSharedLink() {
|
|
612
|
+
return Promise.reject(new FetchError(404));
|
|
595
613
|
}
|
|
596
614
|
}
|
|
597
615
|
|
|
@@ -660,38 +678,37 @@ function handleFetchError(response) {
|
|
|
660
678
|
return Promise.resolve(response);
|
|
661
679
|
}
|
|
662
680
|
|
|
663
|
-
function $fetch(url,
|
|
681
|
+
function $fetch(url, init = {
|
|
664
682
|
method: "GET"
|
|
665
683
|
}) {
|
|
666
684
|
const headers = {
|
|
667
|
-
...
|
|
685
|
+
...init.headers
|
|
668
686
|
};
|
|
669
687
|
delete headers["Content-Type"];
|
|
688
|
+
Object.keys(headers).filter((x => headers[x] === undefined)).forEach((x => delete headers[x]));
|
|
670
689
|
let body = undefined;
|
|
671
|
-
if (
|
|
672
|
-
if (
|
|
673
|
-
body =
|
|
674
|
-
} else if (
|
|
690
|
+
if (init.method === "POST" || init.method === "PUT") {
|
|
691
|
+
if (init.body instanceof FormData) {
|
|
692
|
+
body = init.body;
|
|
693
|
+
} else if (init.body instanceof Blob) {
|
|
675
694
|
body = new FormData;
|
|
676
|
-
body.append("file",
|
|
677
|
-
} else if (
|
|
695
|
+
body.append("file", init.body);
|
|
696
|
+
} else if (init.body instanceof ArrayBuffer) {
|
|
678
697
|
body = new FormData;
|
|
679
|
-
body.append("file", new Blob([
|
|
680
|
-
} else if (typeof
|
|
681
|
-
body = JSON.stringify(
|
|
698
|
+
body.append("file", new Blob([ init.body ]));
|
|
699
|
+
} else if (typeof init.body === "object") {
|
|
700
|
+
body = JSON.stringify(init.body);
|
|
682
701
|
headers["Content-Type"] = "application/json";
|
|
683
|
-
} else if (typeof
|
|
684
|
-
body =
|
|
702
|
+
} else if (typeof init.body === "string") {
|
|
703
|
+
body = init.body;
|
|
685
704
|
headers["Content-Type"] = "text/plain";
|
|
686
705
|
}
|
|
687
706
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
headers: headers
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
if (params.signal) init.signal = params.signal;
|
|
694
|
-
return fetch(url, init).then(handleFetchError);
|
|
707
|
+
return fetch(url, {
|
|
708
|
+
...init,
|
|
709
|
+
headers: headers,
|
|
710
|
+
body: body
|
|
711
|
+
}).then(handleFetchError);
|
|
695
712
|
}
|
|
696
713
|
|
|
697
714
|
function handleXMLHttpError(xhr) {
|
|
@@ -747,45 +764,63 @@ class HttpClient {
|
|
|
747
764
|
this.signInUserIsAdmin = false;
|
|
748
765
|
this.serverUrl = serverUrl;
|
|
749
766
|
}
|
|
750
|
-
get(relativePath,
|
|
767
|
+
get(relativePath, init = {}) {
|
|
751
768
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
769
|
+
...init,
|
|
752
770
|
method: "GET",
|
|
753
|
-
headers:
|
|
754
|
-
|
|
771
|
+
headers: {
|
|
772
|
+
...this.headers,
|
|
773
|
+
...init.headers
|
|
774
|
+
}
|
|
755
775
|
});
|
|
756
776
|
}
|
|
757
|
-
post(relativePath, body) {
|
|
777
|
+
post(relativePath, body, init = {}) {
|
|
758
778
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
779
|
+
...init,
|
|
759
780
|
method: "POST",
|
|
760
|
-
headers:
|
|
781
|
+
headers: {
|
|
782
|
+
...this.headers,
|
|
783
|
+
...init.headers
|
|
784
|
+
},
|
|
761
785
|
body: body
|
|
762
786
|
});
|
|
763
787
|
}
|
|
764
|
-
put(relativePath, body) {
|
|
788
|
+
put(relativePath, body, init = {}) {
|
|
765
789
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
790
|
+
...init,
|
|
766
791
|
method: "PUT",
|
|
767
|
-
headers:
|
|
792
|
+
headers: {
|
|
793
|
+
...this.headers,
|
|
794
|
+
...init.headers
|
|
795
|
+
},
|
|
768
796
|
body: body
|
|
769
797
|
});
|
|
770
798
|
}
|
|
771
|
-
delete(relativePath) {
|
|
799
|
+
delete(relativePath, init = {}) {
|
|
772
800
|
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
801
|
+
...init,
|
|
773
802
|
method: "DELETE",
|
|
774
|
-
headers:
|
|
803
|
+
headers: {
|
|
804
|
+
...this.headers,
|
|
805
|
+
...init.headers
|
|
806
|
+
}
|
|
775
807
|
});
|
|
776
808
|
}
|
|
777
|
-
uploadFile(relativePath, file, onProgress) {
|
|
809
|
+
uploadFile(relativePath, file, onProgress, init = {}) {
|
|
778
810
|
const data = new FormData;
|
|
779
811
|
data.append("file", file);
|
|
780
812
|
return $xmlhttp(`${this.serverUrl}${relativePath}`, {
|
|
781
813
|
method: "POST",
|
|
782
|
-
headers:
|
|
814
|
+
headers: {
|
|
815
|
+
...this.headers,
|
|
816
|
+
...init.headers
|
|
817
|
+
},
|
|
783
818
|
body: data,
|
|
784
819
|
uploadProgress: onProgress
|
|
785
820
|
});
|
|
786
821
|
}
|
|
787
|
-
async downloadFile(relativePath, onProgress,
|
|
788
|
-
const response = await this.get(relativePath,
|
|
822
|
+
async downloadFile(relativePath, onProgress, init = {}) {
|
|
823
|
+
const response = await this.get(relativePath, init);
|
|
789
824
|
const contentLength = response.headers.get("Content-Length");
|
|
790
825
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
791
826
|
return new Response(new ReadableStream({
|
|
@@ -803,15 +838,14 @@ class HttpClient {
|
|
|
803
838
|
}
|
|
804
839
|
}));
|
|
805
840
|
}
|
|
806
|
-
async downloadFileRange(relativePath, reserved, ranges, onProgress,
|
|
841
|
+
async downloadFileRange(relativePath, reserved, ranges, onProgress, init = {}) {
|
|
807
842
|
const headers = {
|
|
808
|
-
...
|
|
843
|
+
...init.headers
|
|
809
844
|
};
|
|
810
845
|
headers["Range"] = "bytes=" + ranges.map((x => `${x.begin}-${x.end}`)).join(",");
|
|
811
|
-
const response = await
|
|
812
|
-
|
|
813
|
-
headers: headers
|
|
814
|
-
signal: signal
|
|
846
|
+
const response = await this.get(relativePath, {
|
|
847
|
+
...init,
|
|
848
|
+
headers: headers
|
|
815
849
|
});
|
|
816
850
|
const contentLength = response.headers.get("content-length");
|
|
817
851
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
@@ -852,21 +886,11 @@ class HttpClient {
|
|
|
852
886
|
}
|
|
853
887
|
}
|
|
854
888
|
|
|
855
|
-
class Permission {
|
|
889
|
+
class Permission extends Endpoint {
|
|
856
890
|
constructor(data, fileId, httpClient) {
|
|
857
|
-
|
|
858
|
-
this.fileId = fileId;
|
|
891
|
+
super(`/files/${fileId}/permissions/${data.id}`, httpClient);
|
|
859
892
|
this.data = data;
|
|
860
893
|
}
|
|
861
|
-
internalGet() {
|
|
862
|
-
return this.httpClient.get(`/files/${this.fileId}/permissions/${this.id}`);
|
|
863
|
-
}
|
|
864
|
-
internalPut(body) {
|
|
865
|
-
return this.httpClient.put(`/files/${this.fileId}/permissions/${this.id}`, body);
|
|
866
|
-
}
|
|
867
|
-
internalDelete() {
|
|
868
|
-
return this.httpClient.delete(`/files/${this.fileId}/permissions/${this.id}`);
|
|
869
|
-
}
|
|
870
894
|
get actions() {
|
|
871
895
|
return this.data.actions;
|
|
872
896
|
}
|
|
@@ -895,37 +919,28 @@ class Permission {
|
|
|
895
919
|
this.data.public = value;
|
|
896
920
|
}
|
|
897
921
|
async checkout() {
|
|
898
|
-
const response = await this.
|
|
922
|
+
const response = await this.get("");
|
|
899
923
|
this.data = await response.json();
|
|
900
924
|
return this;
|
|
901
925
|
}
|
|
902
926
|
async update(data) {
|
|
903
|
-
const response = await this.
|
|
927
|
+
const response = await this.put("", data);
|
|
904
928
|
this.data = await response.json();
|
|
905
929
|
return this;
|
|
906
930
|
}
|
|
907
931
|
delete() {
|
|
908
|
-
return
|
|
932
|
+
return super.delete("").then((response => response.json()));
|
|
909
933
|
}
|
|
910
934
|
save() {
|
|
911
935
|
return this.update(this.data);
|
|
912
936
|
}
|
|
913
937
|
}
|
|
914
938
|
|
|
915
|
-
class Job {
|
|
939
|
+
class Job extends Endpoint {
|
|
916
940
|
constructor(data, httpClient) {
|
|
917
|
-
|
|
941
|
+
super(`/jobs/${data.id}`, httpClient);
|
|
918
942
|
this.data = data;
|
|
919
943
|
}
|
|
920
|
-
internalGet() {
|
|
921
|
-
return this.httpClient.get(`/jobs/${this.data.id}`);
|
|
922
|
-
}
|
|
923
|
-
internalPut(body) {
|
|
924
|
-
return this.httpClient.put(`/jobs/${this.data.id}`, body);
|
|
925
|
-
}
|
|
926
|
-
internalDelete() {
|
|
927
|
-
return this.httpClient.delete(`/jobs/${this.data.id}`);
|
|
928
|
-
}
|
|
929
944
|
get assemblyId() {
|
|
930
945
|
return this.data.assemblyId;
|
|
931
946
|
}
|
|
@@ -969,17 +984,17 @@ class Job {
|
|
|
969
984
|
return this.data.startedAt;
|
|
970
985
|
}
|
|
971
986
|
async checkout() {
|
|
972
|
-
const response = await this.
|
|
987
|
+
const response = await this.get("");
|
|
973
988
|
this.data = await response.json();
|
|
974
989
|
return this;
|
|
975
990
|
}
|
|
976
991
|
async update(data) {
|
|
977
|
-
const response = await this.
|
|
992
|
+
const response = await this.put("", data);
|
|
978
993
|
this.data = await response.json();
|
|
979
994
|
return this;
|
|
980
995
|
}
|
|
981
996
|
delete() {
|
|
982
|
-
return
|
|
997
|
+
return super.delete("").then((response => response.json()));
|
|
983
998
|
}
|
|
984
999
|
waitForDone(params) {
|
|
985
1000
|
const checkDone = () => this.checkout().then((job => {
|
|
@@ -992,32 +1007,57 @@ class Job {
|
|
|
992
1007
|
}
|
|
993
1008
|
}
|
|
994
1009
|
|
|
995
|
-
class
|
|
1010
|
+
class SharedLink extends Endpoint {
|
|
996
1011
|
constructor(data, httpClient) {
|
|
997
|
-
|
|
998
|
-
this.httpClient = httpClient;
|
|
1012
|
+
super(`/shares/${data.token}`, httpClient);
|
|
999
1013
|
this.data = data;
|
|
1000
1014
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
1004
|
-
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
1015
|
+
get createdAt() {
|
|
1016
|
+
return this.data.createdAt;
|
|
1005
1017
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
return this.httpClient.get(`${this.path}${relativePath}`, signal);
|
|
1018
|
+
get data() {
|
|
1019
|
+
return this._data;
|
|
1009
1020
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
return this.httpClient.post(`${this.path}${relativePath}`, body);
|
|
1021
|
+
set data(value) {
|
|
1022
|
+
this._data = value;
|
|
1013
1023
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
return this.httpClient.put(`${this.path}${relativePath}`, body);
|
|
1024
|
+
get permissions() {
|
|
1025
|
+
return this.data.permissions;
|
|
1017
1026
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1027
|
+
set permissions(value) {
|
|
1028
|
+
this.data.permissions = {
|
|
1029
|
+
...this.data.permissions,
|
|
1030
|
+
...value
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
get token() {
|
|
1034
|
+
return this.data.token;
|
|
1035
|
+
}
|
|
1036
|
+
get url() {
|
|
1037
|
+
return this.data.url;
|
|
1038
|
+
}
|
|
1039
|
+
async checkout() {
|
|
1040
|
+
const response = await this.get("");
|
|
1041
|
+
this.data = await response.json();
|
|
1042
|
+
return this;
|
|
1043
|
+
}
|
|
1044
|
+
async update(data) {
|
|
1045
|
+
const response = await this.put("", data);
|
|
1046
|
+
this.data = await response.json();
|
|
1047
|
+
return this;
|
|
1048
|
+
}
|
|
1049
|
+
delete() {
|
|
1050
|
+
return super.delete("").then((response => response.json()));
|
|
1051
|
+
}
|
|
1052
|
+
save() {
|
|
1053
|
+
return this.update(this.data);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
class File extends Endpoint {
|
|
1058
|
+
constructor(data, httpClient) {
|
|
1059
|
+
super(`/files/${data.id}`, httpClient);
|
|
1060
|
+
this.data = data;
|
|
1021
1061
|
}
|
|
1022
1062
|
get activeVersion() {
|
|
1023
1063
|
return this.data.activeVersion;
|
|
@@ -1035,38 +1075,39 @@ class File {
|
|
|
1035
1075
|
return this._data;
|
|
1036
1076
|
}
|
|
1037
1077
|
set data(value) {
|
|
1038
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1039
|
-
var
|
|
1078
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1079
|
+
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
1040
1080
|
this._data = value;
|
|
1041
1081
|
this._data.previewUrl = value.preview ? `${this.httpClient.serverUrl}${this.path}/preview?updated=${value.updatedAt}` : "";
|
|
1042
1082
|
if (typeof this._data.owner === "string") this._data.owner = {
|
|
1043
1083
|
userId: this._data.owner
|
|
1044
1084
|
};
|
|
1045
|
-
(_a = (
|
|
1085
|
+
(_a = (_p = this._data).owner) !== null && _a !== void 0 ? _a : _p.owner = {};
|
|
1046
1086
|
this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
|
|
1047
1087
|
this._data.owner.fullName = userFullName(this._data.owner);
|
|
1048
1088
|
this._data.owner.initials = userInitials(this._data.owner.fullName);
|
|
1049
|
-
(_b = (
|
|
1050
|
-
(_c = (
|
|
1089
|
+
(_b = (_q = this._data).status) !== null && _b !== void 0 ? _b : _q.status = {};
|
|
1090
|
+
(_c = (_r = this._data.status).geometry) !== null && _c !== void 0 ? _c : _r.geometry = {
|
|
1051
1091
|
state: (_d = this._data.geometryStatus) !== null && _d !== void 0 ? _d : "none"
|
|
1052
1092
|
};
|
|
1053
|
-
(_e = (
|
|
1093
|
+
(_e = (_s = this._data.status).properties) !== null && _e !== void 0 ? _e : _s.properties = {
|
|
1054
1094
|
state: (_f = this._data.propertiesStatus) !== null && _f !== void 0 ? _f : "none"
|
|
1055
1095
|
};
|
|
1056
|
-
(_g = (
|
|
1096
|
+
(_g = (_t = this._data.status).validation) !== null && _g !== void 0 ? _g : _t.validation = {
|
|
1057
1097
|
state: (_h = this._data.validationStatus) !== null && _h !== void 0 ? _h : "none"
|
|
1058
1098
|
};
|
|
1059
|
-
(_j = (
|
|
1099
|
+
(_j = (_u = this._data).updatedBy) !== null && _j !== void 0 ? _j : _u.updatedBy = {};
|
|
1060
1100
|
this._data.updatedBy.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.updatedBy.userId}/avatar`;
|
|
1061
1101
|
this._data.updatedBy.fullName = userFullName(this._data.updatedBy);
|
|
1062
1102
|
this._data.updatedBy.initials = userInitials(this._data.updatedBy.fullName);
|
|
1063
|
-
(_k = (
|
|
1103
|
+
(_k = (_v = this._data).versions) !== null && _k !== void 0 ? _k : _v.versions = [ {
|
|
1064
1104
|
...value
|
|
1065
1105
|
} ];
|
|
1066
|
-
(_l = (
|
|
1106
|
+
(_l = (_w = this._data.status).geometryGltf) !== null && _l !== void 0 ? _l : _w.geometryGltf = {
|
|
1067
1107
|
state: "none"
|
|
1068
1108
|
};
|
|
1069
|
-
(_m = (
|
|
1109
|
+
(_m = (_x = this._data).isFileDeleted) !== null && _m !== void 0 ? _m : _x.isFileDeleted = false;
|
|
1110
|
+
(_o = (_y = this._data).sharedLinkToken) !== null && _o !== void 0 ? _o : _y.sharedLinkToken = null;
|
|
1070
1111
|
}
|
|
1071
1112
|
get exports() {
|
|
1072
1113
|
return this.data.exports;
|
|
@@ -1101,6 +1142,9 @@ class File {
|
|
|
1101
1142
|
get sizeTotal() {
|
|
1102
1143
|
return this.data.sizeTotal;
|
|
1103
1144
|
}
|
|
1145
|
+
get sharedLinkToken() {
|
|
1146
|
+
return this.data.sharedLinkToken;
|
|
1147
|
+
}
|
|
1104
1148
|
get status() {
|
|
1105
1149
|
return this.data.status;
|
|
1106
1150
|
}
|
|
@@ -1120,17 +1164,17 @@ class File {
|
|
|
1120
1164
|
return this.data.versions;
|
|
1121
1165
|
}
|
|
1122
1166
|
async checkout() {
|
|
1123
|
-
const response = await this.
|
|
1167
|
+
const response = await this.get("");
|
|
1124
1168
|
this.data = await response.json();
|
|
1125
1169
|
return this;
|
|
1126
1170
|
}
|
|
1127
1171
|
async update(data) {
|
|
1128
|
-
const response = await this.
|
|
1172
|
+
const response = await this.put("", data);
|
|
1129
1173
|
this.data = await response.json();
|
|
1130
1174
|
return this;
|
|
1131
1175
|
}
|
|
1132
1176
|
delete() {
|
|
1133
|
-
return
|
|
1177
|
+
return super.delete("").then((response => response.json()));
|
|
1134
1178
|
}
|
|
1135
1179
|
save() {
|
|
1136
1180
|
return this.update(this.data);
|
|
@@ -1139,18 +1183,18 @@ class File {
|
|
|
1139
1183
|
if (!image) {
|
|
1140
1184
|
await this.deletePreview();
|
|
1141
1185
|
} else {
|
|
1142
|
-
const response = await this.
|
|
1186
|
+
const response = await this.post("/preview", image);
|
|
1143
1187
|
this.data = await response.json();
|
|
1144
1188
|
}
|
|
1145
1189
|
return this;
|
|
1146
1190
|
}
|
|
1147
1191
|
async deletePreview() {
|
|
1148
|
-
const response = await
|
|
1192
|
+
const response = await super.delete("/preview");
|
|
1149
1193
|
this.data = await response.json();
|
|
1150
1194
|
return this;
|
|
1151
1195
|
}
|
|
1152
1196
|
getModels() {
|
|
1153
|
-
return this.
|
|
1197
|
+
return this.get("/geometry").then((response => response.json())).then((array => array.map((data => new Model(data, this)))));
|
|
1154
1198
|
}
|
|
1155
1199
|
getModelTransformMatrix(handle) {
|
|
1156
1200
|
return undefined;
|
|
@@ -1161,40 +1205,46 @@ class File {
|
|
|
1161
1205
|
}
|
|
1162
1206
|
getProperties(handles) {
|
|
1163
1207
|
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
1164
|
-
return this.
|
|
1208
|
+
return this.get(relativePath).then((response => response.json()));
|
|
1165
1209
|
}
|
|
1166
1210
|
searchProperties(searchPattern) {
|
|
1167
|
-
return this.
|
|
1211
|
+
return this.post("/properties/search", searchPattern).then((response => response.json()));
|
|
1168
1212
|
}
|
|
1169
1213
|
getCdaTree() {
|
|
1170
|
-
return this.
|
|
1214
|
+
return this.get(`/properties/tree`).then((response => response.json()));
|
|
1171
1215
|
}
|
|
1172
1216
|
getViewpoints() {
|
|
1173
|
-
return this.
|
|
1217
|
+
return this.get("/viewpoints").then((response => response.json())).then((viewpoints => viewpoints.result));
|
|
1174
1218
|
}
|
|
1175
1219
|
saveViewpoint(viewpoint) {
|
|
1176
|
-
return this.
|
|
1220
|
+
return this.post("/viewpoints", viewpoint).then((response => response.json()));
|
|
1177
1221
|
}
|
|
1178
1222
|
deleteViewpoint(guid) {
|
|
1179
|
-
return
|
|
1223
|
+
return super.delete(`/viewpoints/${guid}`).then((response => response.json()));
|
|
1180
1224
|
}
|
|
1181
1225
|
getSnapshot(guid) {
|
|
1182
|
-
return this.
|
|
1226
|
+
return this.get(`/viewpoints/${guid}/snapshot`).then((response => response.text()));
|
|
1183
1227
|
}
|
|
1184
1228
|
getSnapshotData(guid, bitmapGuid) {
|
|
1185
|
-
return this.
|
|
1229
|
+
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response => response.text()));
|
|
1186
1230
|
}
|
|
1187
1231
|
download(onProgress, signal) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1232
|
+
return this.httpClient.downloadFile(this.getEndpointPath("/downloads"), onProgress, {
|
|
1233
|
+
signal: signal,
|
|
1234
|
+
headers: this.headers
|
|
1235
|
+
}).then((response => response.arrayBuffer()));
|
|
1190
1236
|
}
|
|
1191
1237
|
downloadResource(dataId, onProgress, signal) {
|
|
1192
|
-
|
|
1193
|
-
|
|
1238
|
+
return this.httpClient.downloadFile(this.getEndpointPath(`/downloads/${dataId}`), onProgress, {
|
|
1239
|
+
signal: signal,
|
|
1240
|
+
headers: this.headers
|
|
1241
|
+
}).then((response => response.arrayBuffer()));
|
|
1194
1242
|
}
|
|
1195
1243
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
1196
|
-
|
|
1197
|
-
|
|
1244
|
+
return this.httpClient.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}?requestId=${requestId}`), requestId, ranges, onProgress, {
|
|
1245
|
+
signal: signal,
|
|
1246
|
+
headers: this.headers
|
|
1247
|
+
}).then((response => response.arrayBuffer()));
|
|
1198
1248
|
}
|
|
1199
1249
|
partialDownloadResource(dataId, onProgress, signal) {
|
|
1200
1250
|
console.warn("File.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use File.downloadResource() instead.");
|
|
@@ -1204,14 +1254,14 @@ class File {
|
|
|
1204
1254
|
await this.downloadResourceRange(dataId, requestId, records, onProgress, signal);
|
|
1205
1255
|
}
|
|
1206
1256
|
getReferences(signal) {
|
|
1207
|
-
return this.
|
|
1257
|
+
return this.get("/references", signal).then((response => response.json()));
|
|
1208
1258
|
}
|
|
1209
1259
|
setReferences(references) {
|
|
1210
|
-
return this.
|
|
1260
|
+
return this.put("/references", references).then((response => response.json()));
|
|
1211
1261
|
}
|
|
1212
1262
|
createJob(outputFormat, parameters) {
|
|
1213
|
-
const
|
|
1214
|
-
return
|
|
1263
|
+
const jobs = new Endpoint("/jobs", this.httpClient, this.headers);
|
|
1264
|
+
return jobs.post(this.appendVersionParam(""), {
|
|
1215
1265
|
fileId: this.id,
|
|
1216
1266
|
outputFormat: outputFormat,
|
|
1217
1267
|
parameters: parseArgs(parameters)
|
|
@@ -1242,28 +1292,30 @@ class File {
|
|
|
1242
1292
|
return waitFor(checkDone, params).then((() => this));
|
|
1243
1293
|
}
|
|
1244
1294
|
getPermissions() {
|
|
1245
|
-
return this.
|
|
1295
|
+
return this.get("/permissions").then((response => response.json())).then((array => array.map((data => new Permission(data, this.id, this.httpClient)))));
|
|
1246
1296
|
}
|
|
1247
1297
|
getPermission(permissionId) {
|
|
1248
|
-
return this.
|
|
1298
|
+
return this.get(`/permissions/${permissionId}`).then((response => response.json())).then((data => new Permission(data, this.id, this.httpClient)));
|
|
1249
1299
|
}
|
|
1250
1300
|
createPermission(actions, grantedTo, _public) {
|
|
1251
|
-
return this.
|
|
1301
|
+
return this.post("/permissions", {
|
|
1252
1302
|
actions: Array.isArray(actions) ? actions : [ actions ],
|
|
1253
1303
|
grantedTo: grantedTo,
|
|
1254
1304
|
public: _public
|
|
1255
1305
|
}).then((response => response.json())).then((data => new Permission(data, this.id, this.httpClient)));
|
|
1256
1306
|
}
|
|
1257
1307
|
deletePermission(permissionId) {
|
|
1258
|
-
return
|
|
1308
|
+
return super.delete(`/permissions/${permissionId}`).then((response => response.json()));
|
|
1259
1309
|
}
|
|
1260
1310
|
async uploadVersion(file, params = {
|
|
1261
1311
|
waitForDone: false
|
|
1262
1312
|
}) {
|
|
1263
|
-
const result = await this.httpClient.uploadFile(
|
|
1313
|
+
const result = await this.httpClient.uploadFile(this.getEndpointPath("/versions"), file, (progress => {
|
|
1264
1314
|
var _a;
|
|
1265
1315
|
return (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
|
|
1266
|
-
})
|
|
1316
|
+
}), {
|
|
1317
|
+
headers: this.headers
|
|
1318
|
+
}).then((xhr => JSON.parse(xhr.responseText))).then((data => new File(data, this.httpClient)));
|
|
1267
1319
|
let geometryType = "";
|
|
1268
1320
|
if (this.versions[0].status.geometryGltf.state !== "none") geometryType = "gltf";
|
|
1269
1321
|
if (this.versions[0].status.geometry.state !== "none") geometryType = "vsfx";
|
|
@@ -1280,13 +1332,13 @@ class File {
|
|
|
1280
1332
|
return result;
|
|
1281
1333
|
}
|
|
1282
1334
|
getVersions() {
|
|
1283
|
-
return this.
|
|
1335
|
+
return this.get("/versions").then((response => response.json())).then((files => files.map((data => new File(data, this.httpClient))))).then((files => files.map((file => file.id == file.originalFileId ? file.useVersion(0) : file))));
|
|
1284
1336
|
}
|
|
1285
1337
|
getVersion(version) {
|
|
1286
|
-
return this.
|
|
1338
|
+
return this.get(`/versions/${version}`).then((response => response.json())).then((data => new File(data, this.httpClient))).then((file => file.id == file.originalFileId ? file.useVersion(0) : file));
|
|
1287
1339
|
}
|
|
1288
1340
|
async deleteVersion(version) {
|
|
1289
|
-
const response = await
|
|
1341
|
+
const response = await super.delete(`/versions/${version}`);
|
|
1290
1342
|
const data = await response.json();
|
|
1291
1343
|
await this.checkout();
|
|
1292
1344
|
return data;
|
|
@@ -1297,31 +1349,45 @@ class File {
|
|
|
1297
1349
|
});
|
|
1298
1350
|
}
|
|
1299
1351
|
useVersion(version) {
|
|
1300
|
-
|
|
1301
|
-
return this;
|
|
1352
|
+
return super.useVersion(version);
|
|
1302
1353
|
}
|
|
1303
1354
|
async deleteSource() {
|
|
1304
|
-
const response = await
|
|
1355
|
+
const response = await super.delete("/source");
|
|
1305
1356
|
this.data = await response.json();
|
|
1306
1357
|
return this;
|
|
1307
1358
|
}
|
|
1359
|
+
async createSharedLink(permissions) {
|
|
1360
|
+
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
1361
|
+
const response = await shares.post("", {
|
|
1362
|
+
fileId: this.id,
|
|
1363
|
+
permissions: permissions
|
|
1364
|
+
});
|
|
1365
|
+
const data = await response.json();
|
|
1366
|
+
await this.checkout();
|
|
1367
|
+
return new SharedLink(data, this.httpClient);
|
|
1368
|
+
}
|
|
1369
|
+
async getSharedLink() {
|
|
1370
|
+
if (!this.sharedLinkToken) return Promise.resolve(undefined);
|
|
1371
|
+
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
1372
|
+
const response = await shares.get(`/${this.sharedLinkToken}`);
|
|
1373
|
+
const data = await response.json();
|
|
1374
|
+
return new SharedLink(data, this.httpClient);
|
|
1375
|
+
}
|
|
1376
|
+
async deleteSharedLink() {
|
|
1377
|
+
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
1378
|
+
const response = await shares.delete(`/${this.sharedLinkToken}`);
|
|
1379
|
+
const data = await response.json();
|
|
1380
|
+
await this.checkout();
|
|
1381
|
+
return data;
|
|
1382
|
+
}
|
|
1308
1383
|
}
|
|
1309
1384
|
|
|
1310
|
-
class Role {
|
|
1385
|
+
class Role extends Endpoint {
|
|
1311
1386
|
constructor(data, projectId, httpClient) {
|
|
1312
|
-
|
|
1387
|
+
super("", httpClient);
|
|
1313
1388
|
this.projectId = projectId;
|
|
1314
1389
|
this.data = data;
|
|
1315
1390
|
}
|
|
1316
|
-
internalGet() {
|
|
1317
|
-
return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`);
|
|
1318
|
-
}
|
|
1319
|
-
internalPut(body) {
|
|
1320
|
-
return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`, body);
|
|
1321
|
-
}
|
|
1322
|
-
internalDelete() {
|
|
1323
|
-
return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`);
|
|
1324
|
-
}
|
|
1325
1391
|
get description() {
|
|
1326
1392
|
return this.data.description;
|
|
1327
1393
|
}
|
|
@@ -1333,6 +1399,7 @@ class Role {
|
|
|
1333
1399
|
}
|
|
1334
1400
|
set data(value) {
|
|
1335
1401
|
this._data = value;
|
|
1402
|
+
this.path = `/projects/${this.projectId}/roles/${value.name}`;
|
|
1336
1403
|
}
|
|
1337
1404
|
get name() {
|
|
1338
1405
|
return this.data.name;
|
|
@@ -1347,38 +1414,28 @@ class Role {
|
|
|
1347
1414
|
this.data.permissions = value || {};
|
|
1348
1415
|
}
|
|
1349
1416
|
async checkout() {
|
|
1350
|
-
const response = await this.
|
|
1417
|
+
const response = await this.get("");
|
|
1351
1418
|
this.data = await response.json();
|
|
1352
1419
|
return this;
|
|
1353
1420
|
}
|
|
1354
1421
|
async update(data) {
|
|
1355
|
-
const response = await this.
|
|
1422
|
+
const response = await this.put("", data);
|
|
1356
1423
|
this.data = await response.json();
|
|
1357
1424
|
return this;
|
|
1358
1425
|
}
|
|
1359
1426
|
delete() {
|
|
1360
|
-
return
|
|
1427
|
+
return super.delete("").then((response => response.json()));
|
|
1361
1428
|
}
|
|
1362
1429
|
save() {
|
|
1363
1430
|
return this.update(this.data);
|
|
1364
1431
|
}
|
|
1365
1432
|
}
|
|
1366
1433
|
|
|
1367
|
-
class Member {
|
|
1434
|
+
class Member extends Endpoint {
|
|
1368
1435
|
constructor(data, projectId, httpClient) {
|
|
1369
|
-
|
|
1370
|
-
this.projectId = projectId;
|
|
1436
|
+
super(`/projects/${projectId}/members/${data.id}`, httpClient);
|
|
1371
1437
|
this.data = data;
|
|
1372
1438
|
}
|
|
1373
|
-
internalGet() {
|
|
1374
|
-
return this.httpClient.get(`/projects/${this.projectId}/members/${this.id}`);
|
|
1375
|
-
}
|
|
1376
|
-
internalPut(body) {
|
|
1377
|
-
return this.httpClient.put(`/projects/${this.projectId}/members/${this.id}`, body);
|
|
1378
|
-
}
|
|
1379
|
-
internalDelete() {
|
|
1380
|
-
return this.httpClient.delete(`/projects/${this.projectId}/members/${this.id}`);
|
|
1381
|
-
}
|
|
1382
1439
|
get data() {
|
|
1383
1440
|
return this._data;
|
|
1384
1441
|
}
|
|
@@ -1404,40 +1461,28 @@ class Member {
|
|
|
1404
1461
|
return this.data.user;
|
|
1405
1462
|
}
|
|
1406
1463
|
async checkout() {
|
|
1407
|
-
const response = await this.
|
|
1464
|
+
const response = await this.get("");
|
|
1408
1465
|
this.data = await response.json();
|
|
1409
1466
|
return this;
|
|
1410
1467
|
}
|
|
1411
1468
|
async update(data) {
|
|
1412
|
-
const response = await this.
|
|
1469
|
+
const response = await this.put("", data);
|
|
1413
1470
|
this.data = await response.json();
|
|
1414
1471
|
return this;
|
|
1415
1472
|
}
|
|
1416
1473
|
delete() {
|
|
1417
|
-
return
|
|
1474
|
+
return super.delete("").then((response => response.json()));
|
|
1418
1475
|
}
|
|
1419
1476
|
save() {
|
|
1420
1477
|
return this.update(this.data);
|
|
1421
1478
|
}
|
|
1422
1479
|
}
|
|
1423
1480
|
|
|
1424
|
-
class Project {
|
|
1481
|
+
class Project extends Endpoint {
|
|
1425
1482
|
constructor(data, httpClient) {
|
|
1426
|
-
|
|
1483
|
+
super(`/projects/${data.id}`, httpClient);
|
|
1427
1484
|
this.data = data;
|
|
1428
1485
|
}
|
|
1429
|
-
internalGet(relativePath) {
|
|
1430
|
-
return this.httpClient.get(`/projects/${this.id}${relativePath}`);
|
|
1431
|
-
}
|
|
1432
|
-
internalPost(relativePath, body) {
|
|
1433
|
-
return this.httpClient.post(`/projects/${this.id}${relativePath}`, body);
|
|
1434
|
-
}
|
|
1435
|
-
internalPut(relativePath, body) {
|
|
1436
|
-
return this.httpClient.put(`/projects/${this.id}${relativePath}`, body);
|
|
1437
|
-
}
|
|
1438
|
-
internalDelete(relativePath) {
|
|
1439
|
-
return this.httpClient.delete(`/projects/${this.id}${relativePath}`);
|
|
1440
|
-
}
|
|
1441
1486
|
get authorization() {
|
|
1442
1487
|
return this.data.authorization;
|
|
1443
1488
|
}
|
|
@@ -1512,17 +1557,17 @@ class Project {
|
|
|
1512
1557
|
return this.data.updatedAt;
|
|
1513
1558
|
}
|
|
1514
1559
|
async checkout() {
|
|
1515
|
-
const response = await this.
|
|
1560
|
+
const response = await this.get("");
|
|
1516
1561
|
this.data = await response.json();
|
|
1517
1562
|
return this;
|
|
1518
1563
|
}
|
|
1519
1564
|
async update(data) {
|
|
1520
|
-
const response = await this.
|
|
1565
|
+
const response = await this.put("", data);
|
|
1521
1566
|
this.data = await response.json();
|
|
1522
1567
|
return this;
|
|
1523
1568
|
}
|
|
1524
1569
|
delete() {
|
|
1525
|
-
return
|
|
1570
|
+
return super.delete("").then((response => response.text())).then((text => {
|
|
1526
1571
|
try {
|
|
1527
1572
|
return JSON.parse(text);
|
|
1528
1573
|
} catch {
|
|
@@ -1539,49 +1584,50 @@ class Project {
|
|
|
1539
1584
|
if (!image) {
|
|
1540
1585
|
await this.deletePreview();
|
|
1541
1586
|
} else {
|
|
1542
|
-
const response = await this.
|
|
1587
|
+
const response = await this.post("/preview", image);
|
|
1543
1588
|
this.data = await response.json();
|
|
1544
1589
|
}
|
|
1545
1590
|
return this;
|
|
1546
1591
|
}
|
|
1547
1592
|
async deletePreview() {
|
|
1548
|
-
const response = await
|
|
1593
|
+
const response = await super.delete("/preview");
|
|
1549
1594
|
this.data = await response.json();
|
|
1550
1595
|
return this;
|
|
1551
1596
|
}
|
|
1552
1597
|
getRoles() {
|
|
1553
|
-
return this.
|
|
1598
|
+
return this.get("/roles").then((response => response.json())).then((array => array.map((data => new Role(data, this.id, this.httpClient)))));
|
|
1554
1599
|
}
|
|
1555
1600
|
getRole(name) {
|
|
1556
|
-
return this.
|
|
1601
|
+
return this.get(`/roles/${name}`).then((response => response.json())).then((data => new Role(data, this.id, this.httpClient)));
|
|
1557
1602
|
}
|
|
1558
1603
|
createRole(name, description, permissions) {
|
|
1559
|
-
return this.
|
|
1604
|
+
return this.post("/roles", {
|
|
1560
1605
|
name: name,
|
|
1561
1606
|
description: description,
|
|
1562
1607
|
permissions: permissions || {}
|
|
1563
1608
|
}).then((response => response.json())).then((data => new Role(data, this.id, this.httpClient)));
|
|
1564
1609
|
}
|
|
1565
1610
|
deleteRole(name) {
|
|
1566
|
-
return
|
|
1611
|
+
return super.delete(`/roles/${name}`).then((response => response.json()));
|
|
1567
1612
|
}
|
|
1568
1613
|
getMembers() {
|
|
1569
|
-
return this.
|
|
1614
|
+
return this.get("/members").then((response => response.json())).then((array => array.map((data => new Member(data, this.id, this.httpClient)))));
|
|
1570
1615
|
}
|
|
1571
1616
|
getMember(memberId) {
|
|
1572
|
-
return this.
|
|
1617
|
+
return this.get(`/members/${memberId}`).then((response => response.json())).then((data => new Member(data, this.id, this.httpClient)));
|
|
1573
1618
|
}
|
|
1574
1619
|
addMember(userId, role) {
|
|
1575
|
-
return this.
|
|
1620
|
+
return this.post("/members", {
|
|
1576
1621
|
userId: userId,
|
|
1577
1622
|
role: role
|
|
1578
1623
|
}).then((response => response.json())).then((data => new Member(data, this.id, this.httpClient)));
|
|
1579
1624
|
}
|
|
1580
1625
|
removeMember(memberId) {
|
|
1581
|
-
return
|
|
1626
|
+
return super.delete(`/members/${memberId}`).then((response => response.json()));
|
|
1582
1627
|
}
|
|
1583
1628
|
getFilesInformation() {
|
|
1584
|
-
|
|
1629
|
+
const bcfProjects = new Endpoint("/bcf/3.0/projects", this.httpClient, this.headers);
|
|
1630
|
+
return bcfProjects.get(`/${this.id}/files_information`).then((response => response.json())).then((items => {
|
|
1585
1631
|
items.forEach((item => {
|
|
1586
1632
|
const getFieldValue = displayName => (item.display_information.find((x => x.field_display_name === displayName)) || {}).field_value;
|
|
1587
1633
|
const previewUrl = `${this.httpClient.serverUrl}/files/${item.file.reference}/preview`;
|
|
@@ -1638,13 +1684,13 @@ class Project {
|
|
|
1638
1684
|
}
|
|
1639
1685
|
getModels() {
|
|
1640
1686
|
return this.getFilesInformation().then((filesInformation => filesInformation.map((item => item.file.reference)))).then((ids => {
|
|
1641
|
-
const
|
|
1642
|
-
|
|
1643
|
-
return this.httpClient.get(`/files?${searchParams.toString()}`);
|
|
1687
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
1688
|
+
return files.get(`?id=${ids.join("|")}`);
|
|
1644
1689
|
})).then((response => response.json())).then((files => files.result.map((data => new File(data, this.httpClient)))));
|
|
1645
1690
|
}
|
|
1646
1691
|
async addModel(fileId, actions, _public) {
|
|
1647
|
-
const
|
|
1692
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
1693
|
+
const file = await files.get(`/${fileId}`).then((response => response.json())).then((data => new File(data, this.httpClient)));
|
|
1648
1694
|
const grantedTo = [ {
|
|
1649
1695
|
project: {
|
|
1650
1696
|
id: this.id,
|
|
@@ -1655,7 +1701,8 @@ class Project {
|
|
|
1655
1701
|
return file;
|
|
1656
1702
|
}
|
|
1657
1703
|
async removeModel(fileId) {
|
|
1658
|
-
const
|
|
1704
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
1705
|
+
const file = await files.get(`/${fileId}`).then((response => response.json())).then((data => new File(data, this.httpClient)));
|
|
1659
1706
|
const permissions = await file.getPermissions();
|
|
1660
1707
|
await Promise.allSettled(permissions.filter((permission => permission.grantedTo.some((x => {
|
|
1661
1708
|
var _a;
|
|
@@ -1665,9 +1712,9 @@ class Project {
|
|
|
1665
1712
|
}
|
|
1666
1713
|
}
|
|
1667
1714
|
|
|
1668
|
-
class User {
|
|
1715
|
+
class User extends Endpoint {
|
|
1669
1716
|
constructor(data, httpClient) {
|
|
1670
|
-
|
|
1717
|
+
super("", httpClient);
|
|
1671
1718
|
this.data = data;
|
|
1672
1719
|
}
|
|
1673
1720
|
get avatarUrl() {
|
|
@@ -1771,14 +1818,14 @@ class User {
|
|
|
1771
1818
|
}
|
|
1772
1819
|
async checkout() {
|
|
1773
1820
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1774
|
-
const response = await this.
|
|
1821
|
+
const response = await this.get(`/users/${this.id}`);
|
|
1775
1822
|
const data = await response.json();
|
|
1776
1823
|
this.data = {
|
|
1777
1824
|
id: data.id,
|
|
1778
1825
|
...data.userBrief
|
|
1779
1826
|
};
|
|
1780
1827
|
} else if (this.id === this.httpClient.signInUserId) {
|
|
1781
|
-
const response = await this.
|
|
1828
|
+
const response = await this.get("/user");
|
|
1782
1829
|
const data = await response.json();
|
|
1783
1830
|
this.data = {
|
|
1784
1831
|
id: this.id,
|
|
@@ -1791,7 +1838,7 @@ class User {
|
|
|
1791
1838
|
}
|
|
1792
1839
|
async update(data) {
|
|
1793
1840
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1794
|
-
const response = await this.
|
|
1841
|
+
const response = await this.put(`/users/${this.id}`, {
|
|
1795
1842
|
isAdmin: data.isAdmin,
|
|
1796
1843
|
userBrief: data
|
|
1797
1844
|
});
|
|
@@ -1801,7 +1848,7 @@ class User {
|
|
|
1801
1848
|
...newData.userBrief
|
|
1802
1849
|
};
|
|
1803
1850
|
} else if (this.id === this.httpClient.signInUserId) {
|
|
1804
|
-
const response = await this.
|
|
1851
|
+
const response = await this.put("/user", data);
|
|
1805
1852
|
const newData = await response.json();
|
|
1806
1853
|
this.data = {
|
|
1807
1854
|
id: this.id,
|
|
@@ -1814,9 +1861,9 @@ class User {
|
|
|
1814
1861
|
}
|
|
1815
1862
|
delete() {
|
|
1816
1863
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1817
|
-
return
|
|
1864
|
+
return super.delete(`/users/${this.id}`).then((response => response.json())).then((data => {
|
|
1818
1865
|
if (this.id === this.httpClient.signInUserId) {
|
|
1819
|
-
this.httpClient.headers
|
|
1866
|
+
delete this.httpClient.headers["Authorization"];
|
|
1820
1867
|
this.httpClient.signInUserId = "";
|
|
1821
1868
|
this.httpClient.signInUserIsAdmin = false;
|
|
1822
1869
|
}
|
|
@@ -1833,14 +1880,14 @@ class User {
|
|
|
1833
1880
|
if (!image) {
|
|
1834
1881
|
await this.deleteAvatar();
|
|
1835
1882
|
} else if (this.httpClient.signInUserIsAdmin) {
|
|
1836
|
-
const response = await this.
|
|
1883
|
+
const response = await this.post(`/users/${this.id}/avatar`, image);
|
|
1837
1884
|
const data = await response.json();
|
|
1838
1885
|
this.data = {
|
|
1839
1886
|
id: data.id,
|
|
1840
1887
|
...data.userBrief
|
|
1841
1888
|
};
|
|
1842
1889
|
} else if (this.id === this.httpClient.signInUserId) {
|
|
1843
|
-
const response = await this.
|
|
1890
|
+
const response = await this.post("/user/avatar", image);
|
|
1844
1891
|
const data = await response.json();
|
|
1845
1892
|
this.data = {
|
|
1846
1893
|
id: this.id,
|
|
@@ -1853,14 +1900,14 @@ class User {
|
|
|
1853
1900
|
}
|
|
1854
1901
|
async deleteAvatar() {
|
|
1855
1902
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1856
|
-
const response = await
|
|
1903
|
+
const response = await super.delete(`/users/${this.id}/avatar`);
|
|
1857
1904
|
const data = await response.json();
|
|
1858
1905
|
this.data = {
|
|
1859
1906
|
id: data.id,
|
|
1860
1907
|
...data.userBrief
|
|
1861
1908
|
};
|
|
1862
1909
|
} else if (this.id === this.httpClient.signInUserId) {
|
|
1863
|
-
const response = await
|
|
1910
|
+
const response = await super.delete("/user/avatar");
|
|
1864
1911
|
const data = await response.json();
|
|
1865
1912
|
this.data = {
|
|
1866
1913
|
id: this.id,
|
|
@@ -1873,7 +1920,7 @@ class User {
|
|
|
1873
1920
|
}
|
|
1874
1921
|
async changePassword(newPassword, oldPassword) {
|
|
1875
1922
|
if (this.httpClient.signInUserIsAdmin) {
|
|
1876
|
-
const response = await this.
|
|
1923
|
+
const response = await this.put(`/users/${this.id}/password`, {
|
|
1877
1924
|
new: newPassword
|
|
1878
1925
|
});
|
|
1879
1926
|
const data = await response.json();
|
|
@@ -1882,7 +1929,7 @@ class User {
|
|
|
1882
1929
|
...data.userBrief
|
|
1883
1930
|
};
|
|
1884
1931
|
} else if (this.id === this.httpClient.signInUserId) {
|
|
1885
|
-
const response = await this.
|
|
1932
|
+
const response = await this.put("/user/password", {
|
|
1886
1933
|
old: oldPassword,
|
|
1887
1934
|
new: newPassword
|
|
1888
1935
|
});
|
|
@@ -1898,23 +1945,11 @@ class User {
|
|
|
1898
1945
|
}
|
|
1899
1946
|
}
|
|
1900
1947
|
|
|
1901
|
-
class OAuthClient {
|
|
1948
|
+
class OAuthClient extends Endpoint {
|
|
1902
1949
|
constructor(data, httpClient) {
|
|
1903
|
-
|
|
1950
|
+
super(`/oauth/clients/${data.clientId}`, httpClient);
|
|
1904
1951
|
this.data = data;
|
|
1905
1952
|
}
|
|
1906
|
-
internalGet() {
|
|
1907
|
-
return this.httpClient.get(`/oauth/clients/${this.clientId}`);
|
|
1908
|
-
}
|
|
1909
|
-
internalPost(relativePath, body) {
|
|
1910
|
-
return this.httpClient.post(`/oauth/clients/${this.clientId}${relativePath}`, body);
|
|
1911
|
-
}
|
|
1912
|
-
internalPut(body) {
|
|
1913
|
-
return this.httpClient.put(`/oauth/clients/${this.clientId}`, body);
|
|
1914
|
-
}
|
|
1915
|
-
internalDelete() {
|
|
1916
|
-
return this.httpClient.delete(`/oauth/clients/${this.clientId}`);
|
|
1917
|
-
}
|
|
1918
1953
|
get authUrl() {
|
|
1919
1954
|
return this.data.authUrl;
|
|
1920
1955
|
}
|
|
@@ -1958,23 +1993,50 @@ class OAuthClient {
|
|
|
1958
1993
|
return this.data.updatedAt;
|
|
1959
1994
|
}
|
|
1960
1995
|
async checkout() {
|
|
1961
|
-
const response = await this.
|
|
1996
|
+
const response = await this.get("");
|
|
1962
1997
|
this.data = await response.json();
|
|
1963
1998
|
return this;
|
|
1964
1999
|
}
|
|
1965
2000
|
async update(data) {
|
|
1966
|
-
const response = await this.
|
|
2001
|
+
const response = await this.put("", data);
|
|
1967
2002
|
this.data = await response.json();
|
|
1968
2003
|
return this;
|
|
1969
2004
|
}
|
|
1970
2005
|
delete() {
|
|
1971
|
-
return
|
|
2006
|
+
return super.delete("").then((response => response.json()));
|
|
1972
2007
|
}
|
|
1973
2008
|
save() {
|
|
1974
2009
|
return this.update(this.data);
|
|
1975
2010
|
}
|
|
1976
2011
|
async revoke() {
|
|
1977
|
-
await this.
|
|
2012
|
+
await this.post("/revoke");
|
|
2013
|
+
return this;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
class SharedFile extends File {
|
|
2018
|
+
constructor(data, password, httpClient) {
|
|
2019
|
+
super(data.file, httpClient);
|
|
2020
|
+
this.path = `/shares/${data.file.sharedLinkToken}`;
|
|
2021
|
+
this.headers = {
|
|
2022
|
+
"InWeb-Password": password
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
async checkout() {
|
|
2026
|
+
const response = await this.get("/info");
|
|
2027
|
+
const data = await response.json();
|
|
2028
|
+
this.data = data.file;
|
|
2029
|
+
return this;
|
|
2030
|
+
}
|
|
2031
|
+
async update(data) {
|
|
2032
|
+
const response = await this.put("/info", data);
|
|
2033
|
+
this.data = await response.json();
|
|
2034
|
+
return this;
|
|
2035
|
+
}
|
|
2036
|
+
getVersions() {
|
|
2037
|
+
return Promise.resolve(undefined);
|
|
2038
|
+
}
|
|
2039
|
+
useVersion(version) {
|
|
1978
2040
|
return this;
|
|
1979
2041
|
}
|
|
1980
2042
|
}
|
|
@@ -2053,7 +2115,7 @@ class Client extends EventEmitter2 {
|
|
|
2053
2115
|
return this.httpClient.get("/version").then((response => response.json())).then((data => ({
|
|
2054
2116
|
...data,
|
|
2055
2117
|
server: data.version,
|
|
2056
|
-
client: "
|
|
2118
|
+
client: "26.1.0"
|
|
2057
2119
|
})));
|
|
2058
2120
|
}
|
|
2059
2121
|
registerUser(email, password, userName) {
|
|
@@ -2074,33 +2136,30 @@ class Client extends EventEmitter2 {
|
|
|
2074
2136
|
}
|
|
2075
2137
|
async signInWithEmail(email, password) {
|
|
2076
2138
|
const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
|
|
2077
|
-
this.httpClient.headers =
|
|
2078
|
-
Authorization: "Basic " + credentials
|
|
2079
|
-
};
|
|
2139
|
+
this.httpClient.headers["Authorization"] = "Basic " + credentials;
|
|
2080
2140
|
const response = await this.httpClient.get("/token");
|
|
2081
2141
|
const data = await response.json();
|
|
2082
2142
|
return this.setCurrentUser(data);
|
|
2083
2143
|
}
|
|
2084
2144
|
async signInWithToken(token) {
|
|
2085
|
-
this.httpClient.headers =
|
|
2086
|
-
Authorization: token
|
|
2087
|
-
};
|
|
2145
|
+
this.httpClient.headers["Authorization"] = token;
|
|
2088
2146
|
const response = await this.httpClient.get("/user");
|
|
2089
2147
|
const data = await response.json();
|
|
2090
2148
|
return this.setCurrentUser(data);
|
|
2091
2149
|
}
|
|
2150
|
+
signOut() {
|
|
2151
|
+
this.clearCurrentUser();
|
|
2152
|
+
}
|
|
2092
2153
|
setCurrentUser(data) {
|
|
2093
2154
|
this._user = new User(data, this.httpClient);
|
|
2094
|
-
this.httpClient.headers =
|
|
2095
|
-
Authorization: data.tokenInfo.token
|
|
2096
|
-
};
|
|
2155
|
+
this.httpClient.headers["Authorization"] = data.tokenInfo.token;
|
|
2097
2156
|
this.httpClient.signInUserId = this._user.id;
|
|
2098
2157
|
this.httpClient.signInUserIsAdmin = this._user.isAdmin;
|
|
2099
2158
|
return this._user;
|
|
2100
2159
|
}
|
|
2101
2160
|
clearCurrentUser() {
|
|
2102
2161
|
this._user = null;
|
|
2103
|
-
this.httpClient.headers
|
|
2162
|
+
delete this.httpClient.headers["Authorization"];
|
|
2104
2163
|
this.httpClient.signInUserId = "";
|
|
2105
2164
|
this.httpClient.signInUserIsAdmin = false;
|
|
2106
2165
|
}
|
|
@@ -2189,7 +2248,7 @@ class Client extends EventEmitter2 {
|
|
|
2189
2248
|
return Promise.reject(new FetchError(403));
|
|
2190
2249
|
}
|
|
2191
2250
|
}
|
|
2192
|
-
getFiles(start, limit, name, ext, ids, sortByDesc, sortField) {
|
|
2251
|
+
getFiles(start, limit, name, ext, ids, sortByDesc, sortField, shared) {
|
|
2193
2252
|
const searchParams = new URLSearchParams;
|
|
2194
2253
|
if (start > 0) searchParams.set("start", start.toString());
|
|
2195
2254
|
if (limit > 0) searchParams.set("limit", limit.toString());
|
|
@@ -2205,6 +2264,7 @@ class Client extends EventEmitter2 {
|
|
|
2205
2264
|
}
|
|
2206
2265
|
if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
2207
2266
|
if (sortField) searchParams.set("sortField", sortField);
|
|
2267
|
+
if (shared) searchParams.set("shared", "true");
|
|
2208
2268
|
let queryString = searchParams.toString();
|
|
2209
2269
|
if (queryString) queryString = "?" + queryString;
|
|
2210
2270
|
return this.httpClient.get(`/files${queryString}`).then((response => response.json())).then((files => ({
|
|
@@ -2240,7 +2300,9 @@ class Client extends EventEmitter2 {
|
|
|
2240
2300
|
return this.httpClient.delete(`/files/${fileId}`).then((response => response.json()));
|
|
2241
2301
|
}
|
|
2242
2302
|
downloadFile(fileId, onProgress, signal) {
|
|
2243
|
-
return this.httpClient.downloadFile(`/files/${fileId}/downloads`, onProgress,
|
|
2303
|
+
return this.httpClient.downloadFile(`/files/${fileId}/downloads`, onProgress, {
|
|
2304
|
+
signal: signal
|
|
2305
|
+
}).then((response => response.arrayBuffer()));
|
|
2244
2306
|
}
|
|
2245
2307
|
getJobs(status, limit, start, sortByDesc, sortField) {
|
|
2246
2308
|
const searchParams = new URLSearchParams;
|
|
@@ -2363,9 +2425,28 @@ class Client extends EventEmitter2 {
|
|
|
2363
2425
|
}
|
|
2364
2426
|
}));
|
|
2365
2427
|
}
|
|
2428
|
+
getSharedLink(token) {
|
|
2429
|
+
return this.httpClient.get(`/shares/${token}`).then((response => response.json())).then((data => new SharedLink(data, this.httpClient)));
|
|
2430
|
+
}
|
|
2431
|
+
createSharedLink(fileId, permissions) {
|
|
2432
|
+
return this.httpClient.post("/shares", {
|
|
2433
|
+
fileId: fileId,
|
|
2434
|
+
permissions: permissions
|
|
2435
|
+
}).then((response => response.json())).then((data => new SharedLink(data, this.httpClient)));
|
|
2436
|
+
}
|
|
2437
|
+
deleteSharedLink(token) {
|
|
2438
|
+
return this.httpClient.delete(`/shares/${token}`).then((response => response.json()));
|
|
2439
|
+
}
|
|
2440
|
+
getSharedFile(token, password) {
|
|
2441
|
+
return this.httpClient.get(`/shares/${token}/info`, {
|
|
2442
|
+
headers: {
|
|
2443
|
+
"InWeb-Password": password
|
|
2444
|
+
}
|
|
2445
|
+
}).then((response => response.json())).then((data => new SharedFile(data, password, this.httpClient)));
|
|
2446
|
+
}
|
|
2366
2447
|
}
|
|
2367
2448
|
|
|
2368
|
-
const version = "
|
|
2449
|
+
const version = "26.1.0";
|
|
2369
2450
|
|
|
2370
|
-
export { Assembly, ClashTest, Client, FetchError, File, Job, Member, Model, OAuthClient, Permission, Project, Role, User, parseArgs, statusText, userFullName, userInitials, version, waitFor };
|
|
2451
|
+
export { Assembly, ClashTest, Client, Endpoint, FetchError, File, Job, Member, Model, OAuthClient, Permission, Project, Role, SharedFile, SharedLink, User, parseArgs, statusText, userFullName, userInitials, version, waitFor };
|
|
2371
2452
|
//# sourceMappingURL=client.module.js.map
|