@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.js
CHANGED
|
@@ -4,6 +4,113 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ODA = global.ODA || {}, global.ODA.Api = global.ODA.Api || {})));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
8
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
9
|
+
// All rights reserved.
|
|
10
|
+
//
|
|
11
|
+
// This software and its documentation and related materials are owned by
|
|
12
|
+
// the Alliance. The software may only be incorporated into application
|
|
13
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
14
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
15
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
16
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
17
|
+
// protected by copyright law and international treaty provisions. Application
|
|
18
|
+
// programs incorporating this software must include the following statement
|
|
19
|
+
// with their copyright notices:
|
|
20
|
+
//
|
|
21
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
22
|
+
// license agreement with Open Design Alliance.
|
|
23
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
24
|
+
// All rights reserved.
|
|
25
|
+
//
|
|
26
|
+
// By use of this software, its documentation or related materials, you
|
|
27
|
+
// acknowledge and accept the above terms.
|
|
28
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
29
|
+
/**
|
|
30
|
+
* Base class for the REST API endpoints.
|
|
31
|
+
*/
|
|
32
|
+
class Endpoint {
|
|
33
|
+
/**
|
|
34
|
+
* @ignore
|
|
35
|
+
* @param path - The API path of the endpoint relative to the REST API server URL of the
|
|
36
|
+
* specified HTTP client.
|
|
37
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
38
|
+
* @param headers - Endpoint-specific HTTP headers.
|
|
39
|
+
*/
|
|
40
|
+
constructor(path, httpClient, headers = {}) {
|
|
41
|
+
this.path = path;
|
|
42
|
+
this.httpClient = httpClient;
|
|
43
|
+
this.headers = headers;
|
|
44
|
+
}
|
|
45
|
+
appendVersionParam(relativePath) {
|
|
46
|
+
if (this._useVersion === undefined)
|
|
47
|
+
return relativePath;
|
|
48
|
+
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
49
|
+
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the endpoint API path.
|
|
53
|
+
*
|
|
54
|
+
* @ignore
|
|
55
|
+
* @param relativePath - Nested endpoint relative path.
|
|
56
|
+
*/
|
|
57
|
+
getEndpointPath(relativePath) {
|
|
58
|
+
return this.appendVersionParam(`${this.path}${relativePath}`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sends the `GET` request to the endpoint.
|
|
62
|
+
*
|
|
63
|
+
* @ignore
|
|
64
|
+
* @param relativePath - Nested endpoint relative path.
|
|
65
|
+
* @param signal - An
|
|
66
|
+
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
|
|
67
|
+
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
68
|
+
*/
|
|
69
|
+
get(relativePath, signal) {
|
|
70
|
+
return this.httpClient.get(this.getEndpointPath(relativePath), { signal, headers: this.headers });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Sends the `POST` request to the endpoint.
|
|
74
|
+
*
|
|
75
|
+
* @ignore
|
|
76
|
+
* @param relativePath - Nested endpoint relative path.
|
|
77
|
+
* @param body - Request body. Can be
|
|
78
|
+
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
|
|
79
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
80
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
|
|
81
|
+
*/
|
|
82
|
+
post(relativePath, body) {
|
|
83
|
+
return this.httpClient.post(this.getEndpointPath(relativePath), body, { headers: this.headers });
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Sends the `PUT` request to the endpoint.
|
|
87
|
+
*
|
|
88
|
+
* @ignore
|
|
89
|
+
* @param relativePath - Nested endpoint relative path.
|
|
90
|
+
* @param body - Request body. Can be
|
|
91
|
+
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
|
|
92
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
93
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
|
|
94
|
+
*/
|
|
95
|
+
put(relativePath, body) {
|
|
96
|
+
return this.httpClient.put(this.getEndpointPath(relativePath), body, { headers: this.headers });
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Sends the `DELETE` request to the endpoint.
|
|
100
|
+
*
|
|
101
|
+
* @ignore
|
|
102
|
+
* @param relativePath - Nested endpoint relative path.
|
|
103
|
+
*/
|
|
104
|
+
delete(relativePath) {
|
|
105
|
+
return this.httpClient.delete(this.getEndpointPath(relativePath), { headers: this.headers });
|
|
106
|
+
}
|
|
107
|
+
// Internal: append the `version` param to the endpoint requests.
|
|
108
|
+
useVersion(version) {
|
|
109
|
+
this._useVersion = version;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
7
114
|
///////////////////////////////////////////////////////////////////////////////
|
|
8
115
|
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
9
116
|
// All rights reserved.
|
|
@@ -148,16 +255,15 @@
|
|
|
148
255
|
* {@link Assembly| assembly}. For example, for `dwg` it is a `Model` space or layout, and for
|
|
149
256
|
* `rvt` files it is a `3D` view.
|
|
150
257
|
*/
|
|
151
|
-
class Model {
|
|
258
|
+
class Model extends Endpoint {
|
|
152
259
|
/**
|
|
153
260
|
* @param data - Raw model data received from the server.
|
|
154
261
|
* @param file - The file/assembly instance that owns the model.
|
|
155
262
|
*/
|
|
156
263
|
constructor(data, file) {
|
|
157
|
-
|
|
158
|
-
this.httpClient = file.httpClient;
|
|
159
|
-
this._file = file;
|
|
264
|
+
super(`${file.path}/downloads`, file.httpClient);
|
|
160
265
|
this._data = data;
|
|
266
|
+
this._file = file;
|
|
161
267
|
}
|
|
162
268
|
/**
|
|
163
269
|
* The `Assembly` instance that owns the model.
|
|
@@ -508,27 +614,17 @@
|
|
|
508
614
|
/**
|
|
509
615
|
* Provides properties and methods for obtaining information about a file/assembly clash detection test.
|
|
510
616
|
*/
|
|
511
|
-
class ClashTest {
|
|
617
|
+
class ClashTest extends Endpoint {
|
|
512
618
|
/**
|
|
513
619
|
* @param data - Raw test data received from the server. For more information, see
|
|
514
620
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
|
|
515
|
-
* @param
|
|
621
|
+
* @param path - The clash test API path of the file/assembly that owns the test.
|
|
516
622
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
517
623
|
*/
|
|
518
|
-
constructor(data,
|
|
519
|
-
|
|
520
|
-
this.basePath = basePath;
|
|
624
|
+
constructor(data, path, httpClient) {
|
|
625
|
+
super(`${path}/clashes/${data.id}`, httpClient);
|
|
521
626
|
this.data = data;
|
|
522
627
|
}
|
|
523
|
-
internalGet(relativePath) {
|
|
524
|
-
return this.httpClient.get(`${this.basePath}/clashes/${this.id}${relativePath}`);
|
|
525
|
-
}
|
|
526
|
-
internalPut(relativePath, body) {
|
|
527
|
-
return this.httpClient.put(`${this.basePath}/clashes/${this.id}${relativePath}`, body);
|
|
528
|
-
}
|
|
529
|
-
internalDelete(relativePath) {
|
|
530
|
-
return this.httpClient.delete(`${this.basePath}/clashes/${this.id}${relativePath}`);
|
|
531
|
-
}
|
|
532
628
|
/**
|
|
533
629
|
* The type of the clashes that the test detects:
|
|
534
630
|
*
|
|
@@ -664,7 +760,7 @@
|
|
|
664
760
|
* Reloads test data from the server.
|
|
665
761
|
*/
|
|
666
762
|
async checkout() {
|
|
667
|
-
const response = await this.
|
|
763
|
+
const response = await this.get("");
|
|
668
764
|
this.data = await response.json();
|
|
669
765
|
return this;
|
|
670
766
|
}
|
|
@@ -675,7 +771,7 @@
|
|
|
675
771
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
|
|
676
772
|
*/
|
|
677
773
|
async update(data) {
|
|
678
|
-
const response = await this.
|
|
774
|
+
const response = await this.put("", data);
|
|
679
775
|
this.data = await response.json();
|
|
680
776
|
return this;
|
|
681
777
|
}
|
|
@@ -686,7 +782,7 @@
|
|
|
686
782
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
|
|
687
783
|
*/
|
|
688
784
|
delete() {
|
|
689
|
-
return
|
|
785
|
+
return super.delete("").then((response) => response.json());
|
|
690
786
|
}
|
|
691
787
|
/**
|
|
692
788
|
* Saves test properties changes to the server. Call this method to update test data on the
|
|
@@ -721,7 +817,7 @@
|
|
|
721
817
|
* Returns a list of detected clashes for this test.
|
|
722
818
|
*/
|
|
723
819
|
getReport() {
|
|
724
|
-
return this.
|
|
820
|
+
return this.get("/report").then((response) => response.json());
|
|
725
821
|
}
|
|
726
822
|
}
|
|
727
823
|
|
|
@@ -751,39 +847,16 @@
|
|
|
751
847
|
* Provides properties and methods for obtaining information about an assembly on the Open
|
|
752
848
|
* Cloud Server and managing its data.
|
|
753
849
|
*/
|
|
754
|
-
class Assembly {
|
|
850
|
+
class Assembly extends Endpoint {
|
|
755
851
|
/**
|
|
756
852
|
* @param data - Raw assembly data received from the server. For more information, see
|
|
757
853
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
|
|
758
854
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
759
855
|
*/
|
|
760
856
|
constructor(data, httpClient) {
|
|
761
|
-
|
|
762
|
-
this.httpClient = httpClient;
|
|
857
|
+
super(`/assemblies/${data.id}`, httpClient);
|
|
763
858
|
this.data = data;
|
|
764
859
|
}
|
|
765
|
-
appendVersionParam(relativePath) {
|
|
766
|
-
if (this._useVersion === undefined)
|
|
767
|
-
return relativePath;
|
|
768
|
-
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
769
|
-
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
770
|
-
}
|
|
771
|
-
internalGet(relativePath, signal) {
|
|
772
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
773
|
-
return this.httpClient.get(`${this.path}${relativePath}`, signal);
|
|
774
|
-
}
|
|
775
|
-
internalPost(relativePath, body) {
|
|
776
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
777
|
-
return this.httpClient.post(`${this.path}${relativePath}`, body);
|
|
778
|
-
}
|
|
779
|
-
internalPut(relativePath, body) {
|
|
780
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
781
|
-
return this.httpClient.put(`${this.path}${relativePath}`, body);
|
|
782
|
-
}
|
|
783
|
-
internalDelete(relativePath) {
|
|
784
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
785
|
-
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
786
|
-
}
|
|
787
860
|
// Reserved for future use
|
|
788
861
|
get activeVersion() {
|
|
789
862
|
return this.data.activeVersion;
|
|
@@ -911,7 +984,7 @@
|
|
|
911
984
|
* Reloads assembly data from the server.
|
|
912
985
|
*/
|
|
913
986
|
async checkout() {
|
|
914
|
-
const response = await this.
|
|
987
|
+
const response = await this.get("");
|
|
915
988
|
this.data = await response.json();
|
|
916
989
|
return this;
|
|
917
990
|
}
|
|
@@ -922,7 +995,7 @@
|
|
|
922
995
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
|
|
923
996
|
*/
|
|
924
997
|
async update(data) {
|
|
925
|
-
const response = await this.
|
|
998
|
+
const response = await this.put("", data);
|
|
926
999
|
this.data = await response.json();
|
|
927
1000
|
return this;
|
|
928
1001
|
}
|
|
@@ -933,7 +1006,7 @@
|
|
|
933
1006
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
|
|
934
1007
|
*/
|
|
935
1008
|
delete() {
|
|
936
|
-
return
|
|
1009
|
+
return super.delete("").then((response) => response.json());
|
|
937
1010
|
}
|
|
938
1011
|
/**
|
|
939
1012
|
* Saves assembly properties changes to the server. Call this method to update assembly data
|
|
@@ -955,7 +1028,7 @@
|
|
|
955
1028
|
* Returns list of assembly models.
|
|
956
1029
|
*/
|
|
957
1030
|
getModels() {
|
|
958
|
-
return this.
|
|
1031
|
+
return this.get("/geometry")
|
|
959
1032
|
.then((response) => response.json())
|
|
960
1033
|
.then((array) => array.map((data) => new Model(data, this)));
|
|
961
1034
|
}
|
|
@@ -993,7 +1066,7 @@
|
|
|
993
1066
|
*/
|
|
994
1067
|
getProperties(handles) {
|
|
995
1068
|
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
996
|
-
return this.
|
|
1069
|
+
return this.get(relativePath).then((response) => response.json());
|
|
997
1070
|
}
|
|
998
1071
|
/**
|
|
999
1072
|
* Returns the list of original handles for an objects in the file that match the specified
|
|
@@ -1021,20 +1094,20 @@
|
|
|
1021
1094
|
* @param searchPattern - Search pattern or combination of the patterns, see example below.
|
|
1022
1095
|
*/
|
|
1023
1096
|
searchProperties(searchPattern) {
|
|
1024
|
-
return this.
|
|
1097
|
+
return this.post("/properties/search", searchPattern).then((response) => response.json());
|
|
1025
1098
|
}
|
|
1026
1099
|
/**
|
|
1027
1100
|
* Returns the CDA tree for an assembly.
|
|
1028
1101
|
*/
|
|
1029
1102
|
getCdaTree() {
|
|
1030
|
-
return this.
|
|
1103
|
+
return this.get(`/properties/tree`).then((response) => response.json());
|
|
1031
1104
|
}
|
|
1032
1105
|
/**
|
|
1033
1106
|
* Returns a list of assembly viewpoints. For more information, see
|
|
1034
1107
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}.
|
|
1035
1108
|
*/
|
|
1036
1109
|
getViewpoints() {
|
|
1037
|
-
return this.
|
|
1110
|
+
return this.get("/viewpoints")
|
|
1038
1111
|
.then((response) => response.json())
|
|
1039
1112
|
.then((viewpoints) => viewpoints.result);
|
|
1040
1113
|
}
|
|
@@ -1045,7 +1118,7 @@
|
|
|
1045
1118
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}.
|
|
1046
1119
|
*/
|
|
1047
1120
|
saveViewpoint(viewpoint) {
|
|
1048
|
-
return this.
|
|
1121
|
+
return this.post("/viewpoints", viewpoint).then((response) => response.json());
|
|
1049
1122
|
}
|
|
1050
1123
|
/**
|
|
1051
1124
|
* Deletes the specified assembly viewpoint.
|
|
@@ -1055,7 +1128,7 @@
|
|
|
1055
1128
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}.
|
|
1056
1129
|
*/
|
|
1057
1130
|
deleteViewpoint(guid) {
|
|
1058
|
-
return
|
|
1131
|
+
return super.delete(`/viewpoints/${guid}`).then((response) => response.json());
|
|
1059
1132
|
}
|
|
1060
1133
|
/**
|
|
1061
1134
|
* Returns the viewpoint snapshot as base64-encoded
|
|
@@ -1064,7 +1137,7 @@
|
|
|
1064
1137
|
* @param guid - Viewpoint GUID.
|
|
1065
1138
|
*/
|
|
1066
1139
|
getSnapshot(guid) {
|
|
1067
|
-
return this.
|
|
1140
|
+
return this.get(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
|
|
1068
1141
|
}
|
|
1069
1142
|
/**
|
|
1070
1143
|
* Returns the viewpoint snapshot data.
|
|
@@ -1073,7 +1146,7 @@
|
|
|
1073
1146
|
* @param bitmapGuid - Bitmap GUID.
|
|
1074
1147
|
*/
|
|
1075
1148
|
getSnapshotData(guid, bitmapGuid) {
|
|
1076
|
-
return this.
|
|
1149
|
+
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
|
|
1077
1150
|
}
|
|
1078
1151
|
/**
|
|
1079
1152
|
* Downloads an assembly resource file. Resource files are files that contain model scene
|
|
@@ -1086,9 +1159,8 @@
|
|
|
1086
1159
|
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
1087
1160
|
*/
|
|
1088
1161
|
downloadResource(dataId, onProgress, signal) {
|
|
1089
|
-
const relativePath = this.appendVersionParam(`/downloads/${dataId}`);
|
|
1090
1162
|
return this.httpClient
|
|
1091
|
-
.downloadFile(
|
|
1163
|
+
.downloadFile(this.getEndpointPath(`/downloads/${dataId}`), onProgress, { signal, headers: this.headers })
|
|
1092
1164
|
.then((response) => response.arrayBuffer());
|
|
1093
1165
|
}
|
|
1094
1166
|
/**
|
|
@@ -1104,9 +1176,8 @@
|
|
|
1104
1176
|
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
1105
1177
|
*/
|
|
1106
1178
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
1107
|
-
const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
|
|
1108
1179
|
return this.httpClient
|
|
1109
|
-
.downloadFileRange(
|
|
1180
|
+
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}?requestId=${requestId}`), requestId, ranges, onProgress, { signal, headers: this.headers })
|
|
1110
1181
|
.then((response) => response.arrayBuffer());
|
|
1111
1182
|
}
|
|
1112
1183
|
/**
|
|
@@ -1135,9 +1206,10 @@
|
|
|
1135
1206
|
* signal, which can be used to abort waiting as desired.
|
|
1136
1207
|
*/
|
|
1137
1208
|
async getReferences(signal) {
|
|
1209
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
1138
1210
|
const references = await Promise.all(this.associatedFiles
|
|
1139
|
-
.map((file) =>
|
|
1140
|
-
.map((link) =>
|
|
1211
|
+
.map((file) => `/${file.fileId}/references`)
|
|
1212
|
+
.map((link) => files.get(link, signal).then((response) => response.json())))
|
|
1141
1213
|
.then((references) => references.map((x) => x.references))
|
|
1142
1214
|
.then((references) => references.reduce((x, v) => [...v, ...x], []))
|
|
1143
1215
|
.then((references) => [...new Set(references.map(JSON.stringify))].map((x) => JSON.parse(x)));
|
|
@@ -1199,7 +1271,7 @@
|
|
|
1199
1271
|
let queryString = searchParams.toString();
|
|
1200
1272
|
if (queryString)
|
|
1201
1273
|
queryString = "?" + queryString;
|
|
1202
|
-
return this.
|
|
1274
|
+
return this.get(`/clashes${queryString}`)
|
|
1203
1275
|
.then((response) => response.json())
|
|
1204
1276
|
.then((tests) => {
|
|
1205
1277
|
return {
|
|
@@ -1214,7 +1286,7 @@
|
|
|
1214
1286
|
* @param testId - Test ID.
|
|
1215
1287
|
*/
|
|
1216
1288
|
getClashTest(testId) {
|
|
1217
|
-
return this.
|
|
1289
|
+
return this.get(`/clashes/${testId}`)
|
|
1218
1290
|
.then((response) => response.json())
|
|
1219
1291
|
.then((data) => new ClashTest(data, this.path, this.httpClient));
|
|
1220
1292
|
}
|
|
@@ -1267,7 +1339,7 @@
|
|
|
1267
1339
|
selectionSetA = [selectionSetA];
|
|
1268
1340
|
if (!Array.isArray(selectionSetB))
|
|
1269
1341
|
selectionSetB = [selectionSetB];
|
|
1270
|
-
return this.
|
|
1342
|
+
return this.post("/clashes", {
|
|
1271
1343
|
name,
|
|
1272
1344
|
selectionTypeA,
|
|
1273
1345
|
selectionTypeB,
|
|
@@ -1288,7 +1360,7 @@
|
|
|
1288
1360
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
|
|
1289
1361
|
*/
|
|
1290
1362
|
deleteClashTest(testId) {
|
|
1291
|
-
return
|
|
1363
|
+
return super.delete(`/clashes/${testId}`).then((response) => response.json());
|
|
1292
1364
|
}
|
|
1293
1365
|
// Reserved for future use
|
|
1294
1366
|
updateVersion(files, params = {
|
|
@@ -1308,9 +1380,15 @@
|
|
|
1308
1380
|
setActiveVersion(version) {
|
|
1309
1381
|
return this.update({ activeVersion: version });
|
|
1310
1382
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
return
|
|
1383
|
+
// Reserved for future use
|
|
1384
|
+
async createSharedLink(permissions) {
|
|
1385
|
+
return Promise.reject(new Error("Assembly shared link will be implemeted in a future release"));
|
|
1386
|
+
}
|
|
1387
|
+
async getSharedLink() {
|
|
1388
|
+
return Promise.resolve(undefined);
|
|
1389
|
+
}
|
|
1390
|
+
async deleteSharedLink() {
|
|
1391
|
+
return Promise.reject(new FetchError(404));
|
|
1314
1392
|
}
|
|
1315
1393
|
}
|
|
1316
1394
|
|
|
@@ -1396,37 +1474,35 @@
|
|
|
1396
1474
|
}
|
|
1397
1475
|
return Promise.resolve(response);
|
|
1398
1476
|
}
|
|
1399
|
-
function $fetch(url,
|
|
1400
|
-
const headers = { ...
|
|
1477
|
+
function $fetch(url, init = { method: "GET" }) {
|
|
1478
|
+
const headers = { ...init.headers };
|
|
1401
1479
|
delete headers["Content-Type"];
|
|
1480
|
+
Object.keys(headers)
|
|
1481
|
+
.filter((x) => headers[x] === undefined)
|
|
1482
|
+
.forEach((x) => delete headers[x]);
|
|
1402
1483
|
let body = undefined;
|
|
1403
|
-
if (
|
|
1404
|
-
if (
|
|
1405
|
-
body =
|
|
1484
|
+
if (init.method === "POST" || init.method === "PUT") {
|
|
1485
|
+
if (init.body instanceof FormData) {
|
|
1486
|
+
body = init.body;
|
|
1406
1487
|
}
|
|
1407
|
-
else if (
|
|
1488
|
+
else if (init.body instanceof Blob) {
|
|
1408
1489
|
body = new FormData();
|
|
1409
|
-
body.append("file",
|
|
1490
|
+
body.append("file", init.body);
|
|
1410
1491
|
}
|
|
1411
|
-
else if (
|
|
1492
|
+
else if (init.body instanceof ArrayBuffer) {
|
|
1412
1493
|
body = new FormData();
|
|
1413
|
-
body.append("file", new Blob([
|
|
1494
|
+
body.append("file", new Blob([init.body]));
|
|
1414
1495
|
}
|
|
1415
|
-
else if (typeof
|
|
1416
|
-
body = JSON.stringify(
|
|
1496
|
+
else if (typeof init.body === "object") {
|
|
1497
|
+
body = JSON.stringify(init.body);
|
|
1417
1498
|
headers["Content-Type"] = "application/json";
|
|
1418
1499
|
}
|
|
1419
|
-
else if (typeof
|
|
1420
|
-
body =
|
|
1500
|
+
else if (typeof init.body === "string") {
|
|
1501
|
+
body = init.body;
|
|
1421
1502
|
headers["Content-Type"] = "text/plain";
|
|
1422
1503
|
}
|
|
1423
1504
|
}
|
|
1424
|
-
|
|
1425
|
-
if (body)
|
|
1426
|
-
init.body = body;
|
|
1427
|
-
if (params.signal)
|
|
1428
|
-
init.signal = params.signal;
|
|
1429
|
-
return fetch(url, init).then(handleFetchError);
|
|
1505
|
+
return fetch(url, { ...init, headers, body }).then(handleFetchError);
|
|
1430
1506
|
}
|
|
1431
1507
|
|
|
1432
1508
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -1518,24 +1594,42 @@
|
|
|
1518
1594
|
this.signInUserIsAdmin = false;
|
|
1519
1595
|
this.serverUrl = serverUrl;
|
|
1520
1596
|
}
|
|
1521
|
-
get(relativePath,
|
|
1522
|
-
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1597
|
+
get(relativePath, init = {}) {
|
|
1598
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1599
|
+
...init,
|
|
1600
|
+
method: "GET",
|
|
1601
|
+
headers: { ...this.headers, ...init.headers },
|
|
1602
|
+
});
|
|
1523
1603
|
}
|
|
1524
|
-
post(relativePath, body) {
|
|
1525
|
-
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1604
|
+
post(relativePath, body, init = {}) {
|
|
1605
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1606
|
+
...init,
|
|
1607
|
+
method: "POST",
|
|
1608
|
+
headers: { ...this.headers, ...init.headers },
|
|
1609
|
+
body,
|
|
1610
|
+
});
|
|
1526
1611
|
}
|
|
1527
|
-
put(relativePath, body) {
|
|
1528
|
-
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1612
|
+
put(relativePath, body, init = {}) {
|
|
1613
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1614
|
+
...init,
|
|
1615
|
+
method: "PUT",
|
|
1616
|
+
headers: { ...this.headers, ...init.headers },
|
|
1617
|
+
body,
|
|
1618
|
+
});
|
|
1529
1619
|
}
|
|
1530
|
-
delete(relativePath) {
|
|
1531
|
-
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1620
|
+
delete(relativePath, init = {}) {
|
|
1621
|
+
return $fetch(`${this.serverUrl}${relativePath}`, {
|
|
1622
|
+
...init,
|
|
1623
|
+
method: "DELETE",
|
|
1624
|
+
headers: { ...this.headers, ...init.headers },
|
|
1625
|
+
});
|
|
1532
1626
|
}
|
|
1533
|
-
uploadFile(relativePath, file, onProgress) {
|
|
1627
|
+
uploadFile(relativePath, file, onProgress, init = {}) {
|
|
1534
1628
|
const data = new FormData();
|
|
1535
1629
|
data.append("file", file);
|
|
1536
1630
|
return $xmlhttp(`${this.serverUrl}${relativePath}`, {
|
|
1537
1631
|
method: "POST",
|
|
1538
|
-
headers: this.headers,
|
|
1632
|
+
headers: { ...this.headers, ...init.headers },
|
|
1539
1633
|
body: data,
|
|
1540
1634
|
uploadProgress: onProgress,
|
|
1541
1635
|
});
|
|
@@ -1543,9 +1637,9 @@
|
|
|
1543
1637
|
// async downloadFile(
|
|
1544
1638
|
// relativePath: string,
|
|
1545
1639
|
// onProgress?: (progress: number, chunk: Uint8Array) => void,
|
|
1546
|
-
//
|
|
1640
|
+
// init: RequestInit = {}
|
|
1547
1641
|
// ): Promise<Response> {
|
|
1548
|
-
// const response = await this.get(relativePath,
|
|
1642
|
+
// const response = await this.get(relativePath, init);
|
|
1549
1643
|
// const teedOff = response.body.tee();
|
|
1550
1644
|
// if (onProgress) {
|
|
1551
1645
|
// const contentLength = response.headers.get("Content-Length");
|
|
@@ -1561,8 +1655,8 @@
|
|
|
1561
1655
|
// }
|
|
1562
1656
|
// return new Response(teedOff[1]);
|
|
1563
1657
|
// }
|
|
1564
|
-
async downloadFile(relativePath, onProgress,
|
|
1565
|
-
const response = await this.get(relativePath,
|
|
1658
|
+
async downloadFile(relativePath, onProgress, init = {}) {
|
|
1659
|
+
const response = await this.get(relativePath, init);
|
|
1566
1660
|
const contentLength = response.headers.get("Content-Length");
|
|
1567
1661
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
1568
1662
|
return new Response(new ReadableStream({
|
|
@@ -1582,10 +1676,10 @@
|
|
|
1582
1676
|
},
|
|
1583
1677
|
}));
|
|
1584
1678
|
}
|
|
1585
|
-
async downloadFileRange(relativePath, reserved, ranges, onProgress,
|
|
1586
|
-
const headers = { ...
|
|
1679
|
+
async downloadFileRange(relativePath, reserved, ranges, onProgress, init = {}) {
|
|
1680
|
+
const headers = { ...init.headers };
|
|
1587
1681
|
headers["Range"] = "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(",");
|
|
1588
|
-
const response = await
|
|
1682
|
+
const response = await this.get(relativePath, { ...init, headers });
|
|
1589
1683
|
const contentLength = response.headers.get("content-length");
|
|
1590
1684
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
1591
1685
|
return new Response(new ReadableStream({
|
|
@@ -1655,7 +1749,7 @@
|
|
|
1655
1749
|
* Provides properties and methods for obtaining information about {@link File | file} actions
|
|
1656
1750
|
* granted to a specific user, project, or group.
|
|
1657
1751
|
*/
|
|
1658
|
-
class Permission {
|
|
1752
|
+
class Permission extends Endpoint {
|
|
1659
1753
|
/**
|
|
1660
1754
|
* @param data - Raw permission data received from the server. For more information, see
|
|
1661
1755
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}.
|
|
@@ -1663,24 +1757,14 @@
|
|
|
1663
1757
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
1664
1758
|
*/
|
|
1665
1759
|
constructor(data, fileId, httpClient) {
|
|
1666
|
-
|
|
1667
|
-
this.fileId = fileId;
|
|
1760
|
+
super(`/files/${fileId}/permissions/${data.id}`, httpClient);
|
|
1668
1761
|
this.data = data;
|
|
1669
1762
|
}
|
|
1670
|
-
internalGet() {
|
|
1671
|
-
return this.httpClient.get(`/files/${this.fileId}/permissions/${this.id}`);
|
|
1672
|
-
}
|
|
1673
|
-
internalPut(body) {
|
|
1674
|
-
return this.httpClient.put(`/files/${this.fileId}/permissions/${this.id}`, body);
|
|
1675
|
-
}
|
|
1676
|
-
internalDelete() {
|
|
1677
|
-
return this.httpClient.delete(`/files/${this.fileId}/permissions/${this.id}`);
|
|
1678
|
-
}
|
|
1679
1763
|
/**
|
|
1680
1764
|
* Defines what actions are allowed to be performed on a file with this permission:
|
|
1681
1765
|
*
|
|
1682
1766
|
* - `read` - The ability to read file description, geometry data and properties.
|
|
1683
|
-
* - `readSourceFile` - The ability to
|
|
1767
|
+
* - `readSourceFile` - The ability to download source file.
|
|
1684
1768
|
* - `write` - The ability to modify file name, description and references.
|
|
1685
1769
|
* - `readViewpoint` - The ability to read file viewpoints.
|
|
1686
1770
|
* - `createViewpoint` - The ability to create file viewpoints.
|
|
@@ -1747,7 +1831,7 @@
|
|
|
1747
1831
|
* Reloads permission data from the server.
|
|
1748
1832
|
*/
|
|
1749
1833
|
async checkout() {
|
|
1750
|
-
const response = await this.
|
|
1834
|
+
const response = await this.get("");
|
|
1751
1835
|
this.data = await response.json();
|
|
1752
1836
|
return this;
|
|
1753
1837
|
}
|
|
@@ -1758,7 +1842,7 @@
|
|
|
1758
1842
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}.
|
|
1759
1843
|
*/
|
|
1760
1844
|
async update(data) {
|
|
1761
|
-
const response = await this.
|
|
1845
|
+
const response = await this.put("", data);
|
|
1762
1846
|
this.data = await response.json();
|
|
1763
1847
|
return this;
|
|
1764
1848
|
}
|
|
@@ -1769,7 +1853,7 @@
|
|
|
1769
1853
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}.
|
|
1770
1854
|
*/
|
|
1771
1855
|
delete() {
|
|
1772
|
-
return
|
|
1856
|
+
return super.delete("").then((response) => response.json());
|
|
1773
1857
|
}
|
|
1774
1858
|
/**
|
|
1775
1859
|
* Saves permission properties changes to the server. Call this method to update permission
|
|
@@ -1805,25 +1889,16 @@
|
|
|
1805
1889
|
/**
|
|
1806
1890
|
* Provides properties and methods for obtaining information about a job on the Open Cloud Server.
|
|
1807
1891
|
*/
|
|
1808
|
-
class Job {
|
|
1892
|
+
class Job extends Endpoint {
|
|
1809
1893
|
/**
|
|
1810
1894
|
* @param data - Raw job data received from the server. For more information, see
|
|
1811
1895
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Jobs | Open Cloud Jobs API}.
|
|
1812
1896
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
1813
1897
|
*/
|
|
1814
1898
|
constructor(data, httpClient) {
|
|
1815
|
-
|
|
1899
|
+
super(`/jobs/${data.id}`, httpClient);
|
|
1816
1900
|
this.data = data;
|
|
1817
1901
|
}
|
|
1818
|
-
internalGet() {
|
|
1819
|
-
return this.httpClient.get(`/jobs/${this.data.id}`);
|
|
1820
|
-
}
|
|
1821
|
-
internalPut(body) {
|
|
1822
|
-
return this.httpClient.put(`/jobs/${this.data.id}`, body);
|
|
1823
|
-
}
|
|
1824
|
-
internalDelete() {
|
|
1825
|
-
return this.httpClient.delete(`/jobs/${this.data.id}`);
|
|
1826
|
-
}
|
|
1827
1902
|
/**
|
|
1828
1903
|
* The ID of the assembly the job is working on (internal).
|
|
1829
1904
|
*
|
|
@@ -1941,7 +2016,7 @@
|
|
|
1941
2016
|
* Reloads job data from the server.
|
|
1942
2017
|
*/
|
|
1943
2018
|
async checkout() {
|
|
1944
|
-
const response = await this.
|
|
2019
|
+
const response = await this.get("");
|
|
1945
2020
|
this.data = await response.json();
|
|
1946
2021
|
return this;
|
|
1947
2022
|
}
|
|
@@ -1955,7 +2030,7 @@
|
|
|
1955
2030
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Jobs | Open Cloud Jobs API}.
|
|
1956
2031
|
*/
|
|
1957
2032
|
async update(data) {
|
|
1958
|
-
const response = await this.
|
|
2033
|
+
const response = await this.put("", data);
|
|
1959
2034
|
this.data = await response.json();
|
|
1960
2035
|
return this;
|
|
1961
2036
|
}
|
|
@@ -1967,7 +2042,7 @@
|
|
|
1967
2042
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Jobs | Open Cloud Jobs API}.
|
|
1968
2043
|
*/
|
|
1969
2044
|
delete() {
|
|
1970
|
-
return
|
|
2045
|
+
return super.delete("").then((response) => response.json());
|
|
1971
2046
|
}
|
|
1972
2047
|
// /**
|
|
1973
2048
|
// * Save job properties changes to the server. Call this method to update job data on the server
|
|
@@ -2023,41 +2098,136 @@
|
|
|
2023
2098
|
// acknowledge and accept the above terms.
|
|
2024
2099
|
///////////////////////////////////////////////////////////////////////////////
|
|
2025
2100
|
/**
|
|
2026
|
-
* Provides properties and methods for obtaining information about a file
|
|
2027
|
-
* Server and managing its data and versions.
|
|
2101
|
+
* Provides properties and methods for obtaining information about a file shared link.
|
|
2028
2102
|
*/
|
|
2029
|
-
class
|
|
2103
|
+
class SharedLink extends Endpoint {
|
|
2030
2104
|
/**
|
|
2031
|
-
* @param data - Raw
|
|
2032
|
-
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#
|
|
2105
|
+
* @param data - Raw shared link data received from the server. For more information, see
|
|
2106
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
|
|
2033
2107
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
2034
2108
|
*/
|
|
2035
2109
|
constructor(data, httpClient) {
|
|
2036
|
-
|
|
2037
|
-
this.httpClient = httpClient;
|
|
2110
|
+
super(`/shares/${data.token}`, httpClient);
|
|
2038
2111
|
this.data = data;
|
|
2039
2112
|
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2113
|
+
/**
|
|
2114
|
+
* Shared link creation time (UTC) in the format specified in
|
|
2115
|
+
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
|
|
2116
|
+
*
|
|
2117
|
+
* @readonly
|
|
2118
|
+
*/
|
|
2119
|
+
get createdAt() {
|
|
2120
|
+
return this.data.createdAt;
|
|
2121
|
+
}
|
|
2122
|
+
/**
|
|
2123
|
+
* Raw shared link data received from the server. For more information, see
|
|
2124
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
|
|
2125
|
+
*
|
|
2126
|
+
* @readonly
|
|
2127
|
+
*/
|
|
2128
|
+
get data() {
|
|
2129
|
+
return this._data;
|
|
2130
|
+
}
|
|
2131
|
+
set data(value) {
|
|
2132
|
+
this._data = value;
|
|
2133
|
+
}
|
|
2134
|
+
/**
|
|
2135
|
+
* Share permissions.
|
|
2136
|
+
*/
|
|
2137
|
+
get permissions() {
|
|
2138
|
+
return this.data.permissions;
|
|
2139
|
+
}
|
|
2140
|
+
set permissions(value) {
|
|
2141
|
+
this.data.permissions = { ...this.data.permissions, ...value };
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Unique shared link token.
|
|
2145
|
+
*
|
|
2146
|
+
* @readonly
|
|
2147
|
+
*/
|
|
2148
|
+
get token() {
|
|
2149
|
+
return this.data.token;
|
|
2045
2150
|
}
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2151
|
+
/**
|
|
2152
|
+
* URL to open shared file in the viewer.
|
|
2153
|
+
*
|
|
2154
|
+
* @readonly
|
|
2155
|
+
*/
|
|
2156
|
+
get url() {
|
|
2157
|
+
return this.data.url;
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2160
|
+
* Reloads shared link data from the server.
|
|
2161
|
+
*/
|
|
2162
|
+
async checkout() {
|
|
2163
|
+
const response = await this.get("");
|
|
2164
|
+
this.data = await response.json();
|
|
2165
|
+
return this;
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Updates shared link data on the server.
|
|
2169
|
+
*
|
|
2170
|
+
* @param data - Raw shared link data. For more information, see
|
|
2171
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
|
|
2172
|
+
*/
|
|
2173
|
+
async update(data) {
|
|
2174
|
+
const response = await this.put("", data);
|
|
2175
|
+
this.data = await response.json();
|
|
2176
|
+
return this;
|
|
2049
2177
|
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2178
|
+
/**
|
|
2179
|
+
* Deletes a shared link from the server.
|
|
2180
|
+
*
|
|
2181
|
+
* @returns Returns the raw data of a deleted shared link. For more information, see
|
|
2182
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#SharedLinks | Open Cloud SharedLinks API}.
|
|
2183
|
+
*/
|
|
2184
|
+
delete() {
|
|
2185
|
+
return super.delete("").then((response) => response.json());
|
|
2053
2186
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2187
|
+
/**
|
|
2188
|
+
* Saves shared link properties changes to the server. Call this method to update shared link
|
|
2189
|
+
* data on the server after any property changes.
|
|
2190
|
+
*/
|
|
2191
|
+
save() {
|
|
2192
|
+
return this.update(this.data);
|
|
2057
2193
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2197
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
2198
|
+
// All rights reserved.
|
|
2199
|
+
//
|
|
2200
|
+
// This software and its documentation and related materials are owned by
|
|
2201
|
+
// the Alliance. The software may only be incorporated into application
|
|
2202
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
2203
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
2204
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
2205
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
2206
|
+
// protected by copyright law and international treaty provisions. Application
|
|
2207
|
+
// programs incorporating this software must include the following statement
|
|
2208
|
+
// with their copyright notices:
|
|
2209
|
+
//
|
|
2210
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
2211
|
+
// license agreement with Open Design Alliance.
|
|
2212
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
2213
|
+
// All rights reserved.
|
|
2214
|
+
//
|
|
2215
|
+
// By use of this software, its documentation or related materials, you
|
|
2216
|
+
// acknowledge and accept the above terms.
|
|
2217
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2218
|
+
/**
|
|
2219
|
+
* Provides properties and methods for obtaining information about a file on the Open Cloud
|
|
2220
|
+
* Server and managing its data and versions.
|
|
2221
|
+
*/
|
|
2222
|
+
class File extends Endpoint {
|
|
2223
|
+
/**
|
|
2224
|
+
* @param data - Raw file data received from the server. For more information, see
|
|
2225
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Files | Open Cloud Files API}.
|
|
2226
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
2227
|
+
*/
|
|
2228
|
+
constructor(data, httpClient) {
|
|
2229
|
+
super(`/files/${data.id}`, httpClient);
|
|
2230
|
+
this.data = data;
|
|
2061
2231
|
}
|
|
2062
2232
|
/**
|
|
2063
2233
|
* Active version number of the file.
|
|
@@ -2078,8 +2248,6 @@
|
|
|
2078
2248
|
}
|
|
2079
2249
|
/**
|
|
2080
2250
|
* File custom fields object, to store custom data.
|
|
2081
|
-
*
|
|
2082
|
-
* @readonly
|
|
2083
2251
|
*/
|
|
2084
2252
|
get customFields() {
|
|
2085
2253
|
return this.data.customFields;
|
|
@@ -2097,8 +2265,8 @@
|
|
|
2097
2265
|
return this._data;
|
|
2098
2266
|
}
|
|
2099
2267
|
set data(value) {
|
|
2100
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2101
|
-
var
|
|
2268
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
2269
|
+
var _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
2102
2270
|
this._data = value;
|
|
2103
2271
|
this._data.previewUrl = value.preview
|
|
2104
2272
|
? `${this.httpClient.serverUrl}${this.path}/preview?updated=${value.updatedAt}`
|
|
@@ -2106,26 +2274,28 @@
|
|
|
2106
2274
|
// owner since 24.8
|
|
2107
2275
|
if (typeof this._data.owner === "string")
|
|
2108
2276
|
this._data.owner = { userId: this._data.owner };
|
|
2109
|
-
(_a = (
|
|
2277
|
+
(_a = (_p = this._data).owner) !== null && _a !== void 0 ? _a : (_p.owner = {});
|
|
2110
2278
|
this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
|
|
2111
2279
|
this._data.owner.fullName = userFullName(this._data.owner);
|
|
2112
2280
|
this._data.owner.initials = userInitials(this._data.owner.fullName);
|
|
2113
2281
|
// status since 24.9
|
|
2114
|
-
(_b = (
|
|
2115
|
-
(_c = (
|
|
2116
|
-
(_e = (
|
|
2117
|
-
(_g = (
|
|
2282
|
+
(_b = (_q = this._data).status) !== null && _b !== void 0 ? _b : (_q.status = {});
|
|
2283
|
+
(_c = (_r = this._data.status).geometry) !== null && _c !== void 0 ? _c : (_r.geometry = { state: (_d = this._data.geometryStatus) !== null && _d !== void 0 ? _d : "none" });
|
|
2284
|
+
(_e = (_s = this._data.status).properties) !== null && _e !== void 0 ? _e : (_s.properties = { state: (_f = this._data.propertiesStatus) !== null && _f !== void 0 ? _f : "none" });
|
|
2285
|
+
(_g = (_t = this._data.status).validation) !== null && _g !== void 0 ? _g : (_t.validation = { state: (_h = this._data.validationStatus) !== null && _h !== void 0 ? _h : "none" });
|
|
2118
2286
|
// updatedBy since 24.10
|
|
2119
|
-
(_j = (
|
|
2287
|
+
(_j = (_u = this._data).updatedBy) !== null && _j !== void 0 ? _j : (_u.updatedBy = {});
|
|
2120
2288
|
this._data.updatedBy.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.updatedBy.userId}/avatar`;
|
|
2121
2289
|
this._data.updatedBy.fullName = userFullName(this._data.updatedBy);
|
|
2122
2290
|
this._data.updatedBy.initials = userInitials(this._data.updatedBy.fullName);
|
|
2123
2291
|
// versions since 24.10
|
|
2124
|
-
(_k = (
|
|
2292
|
+
(_k = (_v = this._data).versions) !== null && _k !== void 0 ? _k : (_v.versions = [{ ...value }]);
|
|
2125
2293
|
// geometryGltf status since 24.12
|
|
2126
|
-
(_l = (
|
|
2294
|
+
(_l = (_w = this._data.status).geometryGltf) !== null && _l !== void 0 ? _l : (_w.geometryGltf = { state: "none" });
|
|
2127
2295
|
// isFileDeleted since 25.7
|
|
2128
|
-
(_m = (
|
|
2296
|
+
(_m = (_x = this._data).isFileDeleted) !== null && _m !== void 0 ? _m : (_x.isFileDeleted = false);
|
|
2297
|
+
// sharedLinkToken since 26.0
|
|
2298
|
+
(_o = (_y = this._data).sharedLinkToken) !== null && _o !== void 0 ? _o : (_y.sharedLinkToken = null);
|
|
2129
2299
|
}
|
|
2130
2300
|
/**
|
|
2131
2301
|
* Returns a list of file formats in which the active version of the file was exported.
|
|
@@ -2134,6 +2304,8 @@
|
|
|
2134
2304
|
* {@link createJob | createJob()}. To download exported file use
|
|
2135
2305
|
* {@link downloadResource | downloadResource()}.
|
|
2136
2306
|
*
|
|
2307
|
+
* For an example of exporting files to other formats, see the {@link downloadResource} help.
|
|
2308
|
+
*
|
|
2137
2309
|
* @readonly
|
|
2138
2310
|
*/
|
|
2139
2311
|
get exports() {
|
|
@@ -2225,6 +2397,14 @@
|
|
|
2225
2397
|
get sizeTotal() {
|
|
2226
2398
|
return this.data.sizeTotal;
|
|
2227
2399
|
}
|
|
2400
|
+
/**
|
|
2401
|
+
* File shared link token or `null` if file is not shared yet.
|
|
2402
|
+
*
|
|
2403
|
+
* @readonly
|
|
2404
|
+
*/
|
|
2405
|
+
get sharedLinkToken() {
|
|
2406
|
+
return this.data.sharedLinkToken;
|
|
2407
|
+
}
|
|
2228
2408
|
/**
|
|
2229
2409
|
* Data status of the active version of the file. Contains:
|
|
2230
2410
|
*
|
|
@@ -2286,7 +2466,7 @@
|
|
|
2286
2466
|
* Reloads file data from the server.
|
|
2287
2467
|
*/
|
|
2288
2468
|
async checkout() {
|
|
2289
|
-
const response = await this.
|
|
2469
|
+
const response = await this.get("");
|
|
2290
2470
|
this.data = await response.json();
|
|
2291
2471
|
return this;
|
|
2292
2472
|
}
|
|
@@ -2297,7 +2477,7 @@
|
|
|
2297
2477
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Files | Open Cloud Files API}.
|
|
2298
2478
|
*/
|
|
2299
2479
|
async update(data) {
|
|
2300
|
-
const response = await this.
|
|
2480
|
+
const response = await this.put("", data);
|
|
2301
2481
|
this.data = await response.json();
|
|
2302
2482
|
return this;
|
|
2303
2483
|
}
|
|
@@ -2311,7 +2491,7 @@
|
|
|
2311
2491
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Files | Open Cloud Files API}.
|
|
2312
2492
|
*/
|
|
2313
2493
|
delete() {
|
|
2314
|
-
return
|
|
2494
|
+
return super.delete("").then((response) => response.json());
|
|
2315
2495
|
}
|
|
2316
2496
|
/**
|
|
2317
2497
|
* Saves file properties changes to the server. Call this method to update file data on the
|
|
@@ -2336,7 +2516,7 @@
|
|
|
2336
2516
|
await this.deletePreview();
|
|
2337
2517
|
}
|
|
2338
2518
|
else {
|
|
2339
|
-
const response = await this.
|
|
2519
|
+
const response = await this.post("/preview", image);
|
|
2340
2520
|
this.data = await response.json();
|
|
2341
2521
|
}
|
|
2342
2522
|
return this;
|
|
@@ -2345,7 +2525,7 @@
|
|
|
2345
2525
|
* Removes the file preview.
|
|
2346
2526
|
*/
|
|
2347
2527
|
async deletePreview() {
|
|
2348
|
-
const response = await
|
|
2528
|
+
const response = await super.delete("/preview");
|
|
2349
2529
|
this.data = await response.json();
|
|
2350
2530
|
return this;
|
|
2351
2531
|
}
|
|
@@ -2353,7 +2533,7 @@
|
|
|
2353
2533
|
* Returns a list of models of the active version of the file.
|
|
2354
2534
|
*/
|
|
2355
2535
|
getModels() {
|
|
2356
|
-
return this.
|
|
2536
|
+
return this.get("/geometry")
|
|
2357
2537
|
.then((response) => response.json())
|
|
2358
2538
|
.then((array) => array.map((data) => new Model(data, this)));
|
|
2359
2539
|
}
|
|
@@ -2380,7 +2560,7 @@
|
|
|
2380
2560
|
*/
|
|
2381
2561
|
getProperties(handles) {
|
|
2382
2562
|
const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
|
|
2383
|
-
return this.
|
|
2563
|
+
return this.get(relativePath).then((response) => response.json());
|
|
2384
2564
|
}
|
|
2385
2565
|
/**
|
|
2386
2566
|
* Search pattern.
|
|
@@ -2424,20 +2604,20 @@
|
|
|
2424
2604
|
* @returns {Promise<Properties[]>}
|
|
2425
2605
|
*/
|
|
2426
2606
|
searchProperties(searchPattern) {
|
|
2427
|
-
return this.
|
|
2607
|
+
return this.post("/properties/search", searchPattern).then((response) => response.json());
|
|
2428
2608
|
}
|
|
2429
2609
|
/**
|
|
2430
2610
|
* Returns the CDA tree for an active version of the file.
|
|
2431
2611
|
*/
|
|
2432
2612
|
getCdaTree() {
|
|
2433
|
-
return this.
|
|
2613
|
+
return this.get(`/properties/tree`).then((response) => response.json());
|
|
2434
2614
|
}
|
|
2435
2615
|
/**
|
|
2436
2616
|
* Returns a list of file viewpoints. For more information, see
|
|
2437
2617
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#FileViewpoints | Open Cloud File Viewpoints API}.
|
|
2438
2618
|
*/
|
|
2439
2619
|
getViewpoints() {
|
|
2440
|
-
return this.
|
|
2620
|
+
return this.get("/viewpoints")
|
|
2441
2621
|
.then((response) => response.json())
|
|
2442
2622
|
.then((viewpoints) => viewpoints.result);
|
|
2443
2623
|
}
|
|
@@ -2448,7 +2628,7 @@
|
|
|
2448
2628
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#FileViewpoints | Open Cloud File Viewpoints API}.
|
|
2449
2629
|
*/
|
|
2450
2630
|
saveViewpoint(viewpoint) {
|
|
2451
|
-
return this.
|
|
2631
|
+
return this.post("/viewpoints", viewpoint).then((response) => response.json());
|
|
2452
2632
|
}
|
|
2453
2633
|
/**
|
|
2454
2634
|
* Deletes the specified file viewpoint.
|
|
@@ -2458,7 +2638,7 @@
|
|
|
2458
2638
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#FileViewpoints | Open Cloud File Viewpoints API}.
|
|
2459
2639
|
*/
|
|
2460
2640
|
deleteViewpoint(guid) {
|
|
2461
|
-
return
|
|
2641
|
+
return super.delete(`/viewpoints/${guid}`).then((response) => response.json());
|
|
2462
2642
|
}
|
|
2463
2643
|
/**
|
|
2464
2644
|
* Returns viewpoint snapshot as base64-encoded
|
|
@@ -2467,7 +2647,7 @@
|
|
|
2467
2647
|
* @param guid - Viewpoint GUID.
|
|
2468
2648
|
*/
|
|
2469
2649
|
getSnapshot(guid) {
|
|
2470
|
-
return this.
|
|
2650
|
+
return this.get(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
|
|
2471
2651
|
}
|
|
2472
2652
|
/**
|
|
2473
2653
|
* Returns viewpoint snapshot data.
|
|
@@ -2476,7 +2656,7 @@
|
|
|
2476
2656
|
* @param bitmapGuid - Bitmap GUID.
|
|
2477
2657
|
*/
|
|
2478
2658
|
getSnapshotData(guid, bitmapGuid) {
|
|
2479
|
-
return this.
|
|
2659
|
+
return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
|
|
2480
2660
|
}
|
|
2481
2661
|
/**
|
|
2482
2662
|
* Downloads the source file of active version of the file from the server.
|
|
@@ -2487,9 +2667,8 @@
|
|
|
2487
2667
|
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
2488
2668
|
*/
|
|
2489
2669
|
download(onProgress, signal) {
|
|
2490
|
-
const relativePath = this.appendVersionParam("/downloads");
|
|
2491
2670
|
return this.httpClient
|
|
2492
|
-
.downloadFile(
|
|
2671
|
+
.downloadFile(this.getEndpointPath("/downloads"), onProgress, { signal, headers: this.headers })
|
|
2493
2672
|
.then((response) => response.arrayBuffer());
|
|
2494
2673
|
}
|
|
2495
2674
|
/**
|
|
@@ -2502,7 +2681,7 @@
|
|
|
2502
2681
|
* const dwgFileName = file.exports.find((x) => x.endsWith(".dwg"));
|
|
2503
2682
|
* const arrayBuffer = await file.downloadResource(dwgFileName);
|
|
2504
2683
|
* const blob = new Blob([arrayBuffer]);
|
|
2505
|
-
* const fileName = file.name
|
|
2684
|
+
* const fileName = file.name + ".dwg";
|
|
2506
2685
|
* FileSaver.saveAs(blob, fileName);
|
|
2507
2686
|
*
|
|
2508
2687
|
* @param dataId - Resource file name.
|
|
@@ -2512,9 +2691,8 @@
|
|
|
2512
2691
|
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
2513
2692
|
*/
|
|
2514
2693
|
downloadResource(dataId, onProgress, signal) {
|
|
2515
|
-
const relativePath = this.appendVersionParam(`/downloads/${dataId}`);
|
|
2516
2694
|
return this.httpClient
|
|
2517
|
-
.downloadFile(
|
|
2695
|
+
.downloadFile(this.getEndpointPath(`/downloads/${dataId}`), onProgress, { signal, headers: this.headers })
|
|
2518
2696
|
.then((response) => response.arrayBuffer());
|
|
2519
2697
|
}
|
|
2520
2698
|
/**
|
|
@@ -2530,9 +2708,8 @@
|
|
|
2530
2708
|
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
2531
2709
|
*/
|
|
2532
2710
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
2533
|
-
const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
|
|
2534
2711
|
return this.httpClient
|
|
2535
|
-
.downloadFileRange(
|
|
2712
|
+
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}?requestId=${requestId}`), requestId, ranges, onProgress, { signal, headers: this.headers })
|
|
2536
2713
|
.then((response) => response.arrayBuffer());
|
|
2537
2714
|
}
|
|
2538
2715
|
/**
|
|
@@ -2562,7 +2739,7 @@
|
|
|
2562
2739
|
* signal, which can be used to abort waiting as desired.
|
|
2563
2740
|
*/
|
|
2564
2741
|
getReferences(signal) {
|
|
2565
|
-
return this.
|
|
2742
|
+
return this.get("/references", signal).then((response) => response.json());
|
|
2566
2743
|
}
|
|
2567
2744
|
/**
|
|
2568
2745
|
* Sets the file references.
|
|
@@ -2573,7 +2750,7 @@
|
|
|
2573
2750
|
* @param references - File references.
|
|
2574
2751
|
*/
|
|
2575
2752
|
setReferences(references) {
|
|
2576
|
-
return this.
|
|
2753
|
+
return this.put("/references", references).then((response) => response.json());
|
|
2577
2754
|
}
|
|
2578
2755
|
/**
|
|
2579
2756
|
* Runs a new job on the server for the active version of the file.
|
|
@@ -2594,9 +2771,9 @@
|
|
|
2594
2771
|
* for the File Converter tool in form `--arg=value`.
|
|
2595
2772
|
*/
|
|
2596
2773
|
createJob(outputFormat, parameters) {
|
|
2597
|
-
const
|
|
2598
|
-
return
|
|
2599
|
-
.post(
|
|
2774
|
+
const jobs = new Endpoint("/jobs", this.httpClient, this.headers);
|
|
2775
|
+
return jobs
|
|
2776
|
+
.post(this.appendVersionParam(""), {
|
|
2600
2777
|
fileId: this.id,
|
|
2601
2778
|
outputFormat,
|
|
2602
2779
|
parameters: parseArgs(parameters),
|
|
@@ -2680,7 +2857,7 @@
|
|
|
2680
2857
|
* Returns a list of file permissions.
|
|
2681
2858
|
*/
|
|
2682
2859
|
getPermissions() {
|
|
2683
|
-
return this.
|
|
2860
|
+
return this.get("/permissions")
|
|
2684
2861
|
.then((response) => response.json())
|
|
2685
2862
|
.then((array) => array.map((data) => new Permission(data, this.id, this.httpClient)));
|
|
2686
2863
|
}
|
|
@@ -2690,7 +2867,7 @@
|
|
|
2690
2867
|
* @param permissionId - Permission ID.
|
|
2691
2868
|
*/
|
|
2692
2869
|
getPermission(permissionId) {
|
|
2693
|
-
return this.
|
|
2870
|
+
return this.get(`/permissions/${permissionId}`)
|
|
2694
2871
|
.then((response) => response.json())
|
|
2695
2872
|
.then((data) => new Permission(data, this.id, this.httpClient));
|
|
2696
2873
|
}
|
|
@@ -2710,7 +2887,7 @@
|
|
|
2710
2887
|
* @param actions - Actions are allowed to be performed on a file with this permission:
|
|
2711
2888
|
*
|
|
2712
2889
|
* - `read` - The ability to read file description, geometry data and properties.
|
|
2713
|
-
* - `readSourceFile` - The ability to
|
|
2890
|
+
* - `readSourceFile` - The ability to download source file.
|
|
2714
2891
|
* - `write` - The ability to modify file name, description and references.
|
|
2715
2892
|
* - `readViewpoint` - The ability to read file viewpoints.
|
|
2716
2893
|
* - `createViewpoint` - The ability to create file viewpoints.
|
|
@@ -2719,7 +2896,7 @@
|
|
|
2719
2896
|
* @param _public - Specifies whether all users have access to the file or not.
|
|
2720
2897
|
*/
|
|
2721
2898
|
createPermission(actions, grantedTo, _public) {
|
|
2722
|
-
return this.
|
|
2899
|
+
return this.post("/permissions", {
|
|
2723
2900
|
actions: Array.isArray(actions) ? actions : [actions],
|
|
2724
2901
|
grantedTo,
|
|
2725
2902
|
public: _public,
|
|
@@ -2735,7 +2912,7 @@
|
|
|
2735
2912
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud File Permissions API}.
|
|
2736
2913
|
*/
|
|
2737
2914
|
deletePermission(permissionId) {
|
|
2738
|
-
return
|
|
2915
|
+
return super.delete(`/permissions/${permissionId}`).then((response) => response.json());
|
|
2739
2916
|
}
|
|
2740
2917
|
/**
|
|
2741
2918
|
* Uploads the new version of the file to the server, convert the geometry data and extract
|
|
@@ -2763,7 +2940,9 @@
|
|
|
2763
2940
|
waitForDone: false,
|
|
2764
2941
|
}) {
|
|
2765
2942
|
const result = await this.httpClient
|
|
2766
|
-
.uploadFile(
|
|
2943
|
+
.uploadFile(this.getEndpointPath("/versions"), file, (progress) => { var _a; return (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file); }, {
|
|
2944
|
+
headers: this.headers,
|
|
2945
|
+
})
|
|
2767
2946
|
.then((xhr) => JSON.parse(xhr.responseText))
|
|
2768
2947
|
.then((data) => new File(data, this.httpClient));
|
|
2769
2948
|
let geometryType = "";
|
|
@@ -2793,7 +2972,7 @@
|
|
|
2793
2972
|
* Returns a list of version files.
|
|
2794
2973
|
*/
|
|
2795
2974
|
getVersions() {
|
|
2796
|
-
return this.
|
|
2975
|
+
return this.get("/versions")
|
|
2797
2976
|
.then((response) => response.json())
|
|
2798
2977
|
.then((files) => files.map((data) => new File(data, this.httpClient)))
|
|
2799
2978
|
.then((files) => files.map((file) => (file.id == file.originalFileId ? file.useVersion(0) : file)));
|
|
@@ -2804,7 +2983,7 @@
|
|
|
2804
2983
|
* @param version - Desired version.
|
|
2805
2984
|
*/
|
|
2806
2985
|
getVersion(version) {
|
|
2807
|
-
return this.
|
|
2986
|
+
return this.get(`/versions/${version}`)
|
|
2808
2987
|
.then((response) => response.json())
|
|
2809
2988
|
.then((data) => new File(data, this.httpClient))
|
|
2810
2989
|
.then((file) => (file.id == file.originalFileId ? file.useVersion(0) : file));
|
|
@@ -2817,7 +2996,7 @@
|
|
|
2817
2996
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Files | Open Cloud Files API}.
|
|
2818
2997
|
*/
|
|
2819
2998
|
async deleteVersion(version) {
|
|
2820
|
-
const response = await
|
|
2999
|
+
const response = await super.delete(`/versions/${version}`);
|
|
2821
3000
|
const data = await response.json();
|
|
2822
3001
|
await this.checkout();
|
|
2823
3002
|
return data;
|
|
@@ -2856,17 +3035,52 @@
|
|
|
2856
3035
|
* status fields to the version you selected.
|
|
2857
3036
|
*/
|
|
2858
3037
|
useVersion(version) {
|
|
2859
|
-
|
|
2860
|
-
return this;
|
|
3038
|
+
return super.useVersion(version);
|
|
2861
3039
|
}
|
|
2862
3040
|
/**
|
|
2863
3041
|
* Deletes the source file of the active file version from the server.
|
|
2864
3042
|
*/
|
|
2865
3043
|
async deleteSource() {
|
|
2866
|
-
const response = await
|
|
3044
|
+
const response = await super.delete("/source");
|
|
2867
3045
|
this.data = await response.json();
|
|
2868
3046
|
return this;
|
|
2869
3047
|
}
|
|
3048
|
+
/**
|
|
3049
|
+
* Creates a file shared link.
|
|
3050
|
+
*
|
|
3051
|
+
* @param permissions - Share permissions.
|
|
3052
|
+
*/
|
|
3053
|
+
async createSharedLink(permissions) {
|
|
3054
|
+
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
3055
|
+
const response = await shares.post("", { fileId: this.id, permissions });
|
|
3056
|
+
const data = await response.json();
|
|
3057
|
+
await this.checkout();
|
|
3058
|
+
return new SharedLink(data, this.httpClient);
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Returns information about the file shared link or `undefined` if file is not shared.
|
|
3062
|
+
*/
|
|
3063
|
+
async getSharedLink() {
|
|
3064
|
+
if (!this.sharedLinkToken)
|
|
3065
|
+
return Promise.resolve(undefined);
|
|
3066
|
+
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
3067
|
+
const response = await shares.get(`/${this.sharedLinkToken}`);
|
|
3068
|
+
const data = await response.json();
|
|
3069
|
+
return new SharedLink(data, this.httpClient);
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Deletes the file shared link.
|
|
3073
|
+
*
|
|
3074
|
+
* @returns Returns the raw data of a deleted shared link. For more information, see
|
|
3075
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
|
|
3076
|
+
*/
|
|
3077
|
+
async deleteSharedLink() {
|
|
3078
|
+
const shares = new Endpoint("/shares", this.httpClient, this.headers);
|
|
3079
|
+
const response = await shares.delete(`/${this.sharedLinkToken}`);
|
|
3080
|
+
const data = await response.json();
|
|
3081
|
+
await this.checkout();
|
|
3082
|
+
return data;
|
|
3083
|
+
}
|
|
2870
3084
|
}
|
|
2871
3085
|
|
|
2872
3086
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -2895,7 +3109,7 @@
|
|
|
2895
3109
|
* A role determines what actions allowed to be performed by {@link User | users} on a
|
|
2896
3110
|
* {@link Project | project}.
|
|
2897
3111
|
*/
|
|
2898
|
-
class Role {
|
|
3112
|
+
class Role extends Endpoint {
|
|
2899
3113
|
/**
|
|
2900
3114
|
* @param data - Raw role data received from the server. For more information, see
|
|
2901
3115
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
@@ -2903,19 +3117,10 @@
|
|
|
2903
3117
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
2904
3118
|
*/
|
|
2905
3119
|
constructor(data, projectId, httpClient) {
|
|
2906
|
-
|
|
3120
|
+
super("", httpClient);
|
|
2907
3121
|
this.projectId = projectId;
|
|
2908
3122
|
this.data = data;
|
|
2909
3123
|
}
|
|
2910
|
-
internalGet() {
|
|
2911
|
-
return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`);
|
|
2912
|
-
}
|
|
2913
|
-
internalPut(body) {
|
|
2914
|
-
return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`, body);
|
|
2915
|
-
}
|
|
2916
|
-
internalDelete() {
|
|
2917
|
-
return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`);
|
|
2918
|
-
}
|
|
2919
3124
|
/**
|
|
2920
3125
|
* Role description.
|
|
2921
3126
|
*/
|
|
@@ -2936,6 +3141,7 @@
|
|
|
2936
3141
|
}
|
|
2937
3142
|
set data(value) {
|
|
2938
3143
|
this._data = value;
|
|
3144
|
+
this.path = `/projects/${this.projectId}/roles/${value.name}`;
|
|
2939
3145
|
}
|
|
2940
3146
|
/**
|
|
2941
3147
|
* Role name.
|
|
@@ -2959,7 +3165,7 @@
|
|
|
2959
3165
|
* Reloads role data from the server.
|
|
2960
3166
|
*/
|
|
2961
3167
|
async checkout() {
|
|
2962
|
-
const response = await this.
|
|
3168
|
+
const response = await this.get("");
|
|
2963
3169
|
this.data = await response.json();
|
|
2964
3170
|
return this;
|
|
2965
3171
|
}
|
|
@@ -2970,7 +3176,7 @@
|
|
|
2970
3176
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
2971
3177
|
*/
|
|
2972
3178
|
async update(data) {
|
|
2973
|
-
const response = await this.
|
|
3179
|
+
const response = await this.put("", data);
|
|
2974
3180
|
this.data = await response.json();
|
|
2975
3181
|
return this;
|
|
2976
3182
|
}
|
|
@@ -2981,7 +3187,7 @@
|
|
|
2981
3187
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
2982
3188
|
*/
|
|
2983
3189
|
delete() {
|
|
2984
|
-
return
|
|
3190
|
+
return super.delete("").then((response) => response.json());
|
|
2985
3191
|
}
|
|
2986
3192
|
/**
|
|
2987
3193
|
* Saves role properties changes to the server. Call this method to update role data on the
|
|
@@ -3018,7 +3224,7 @@
|
|
|
3018
3224
|
* Provides properties and methods for obtaining information about a {@link User | user} who has
|
|
3019
3225
|
* access to the {@link Project | project}.
|
|
3020
3226
|
*/
|
|
3021
|
-
class Member {
|
|
3227
|
+
class Member extends Endpoint {
|
|
3022
3228
|
/**
|
|
3023
3229
|
* @param data - Raw member data received from the server. For more information, see
|
|
3024
3230
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
@@ -3026,19 +3232,9 @@
|
|
|
3026
3232
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
3027
3233
|
*/
|
|
3028
3234
|
constructor(data, projectId, httpClient) {
|
|
3029
|
-
|
|
3030
|
-
this.projectId = projectId;
|
|
3235
|
+
super(`/projects/${projectId}/members/${data.id}`, httpClient);
|
|
3031
3236
|
this.data = data;
|
|
3032
3237
|
}
|
|
3033
|
-
internalGet() {
|
|
3034
|
-
return this.httpClient.get(`/projects/${this.projectId}/members/${this.id}`);
|
|
3035
|
-
}
|
|
3036
|
-
internalPut(body) {
|
|
3037
|
-
return this.httpClient.put(`/projects/${this.projectId}/members/${this.id}`, body);
|
|
3038
|
-
}
|
|
3039
|
-
internalDelete() {
|
|
3040
|
-
return this.httpClient.delete(`/projects/${this.projectId}/members/${this.id}`);
|
|
3041
|
-
}
|
|
3042
3238
|
/**
|
|
3043
3239
|
* Raw member data received from the server. For more information, see
|
|
3044
3240
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
@@ -3092,7 +3288,7 @@
|
|
|
3092
3288
|
* Reloads member data from the server.
|
|
3093
3289
|
*/
|
|
3094
3290
|
async checkout() {
|
|
3095
|
-
const response = await this.
|
|
3291
|
+
const response = await this.get("");
|
|
3096
3292
|
this.data = await response.json();
|
|
3097
3293
|
return this;
|
|
3098
3294
|
}
|
|
@@ -3103,7 +3299,7 @@
|
|
|
3103
3299
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
3104
3300
|
*/
|
|
3105
3301
|
async update(data) {
|
|
3106
|
-
const response = await this.
|
|
3302
|
+
const response = await this.put("", data);
|
|
3107
3303
|
this.data = await response.json();
|
|
3108
3304
|
return this;
|
|
3109
3305
|
}
|
|
@@ -3114,7 +3310,7 @@
|
|
|
3114
3310
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
3115
3311
|
*/
|
|
3116
3312
|
delete() {
|
|
3117
|
-
return
|
|
3313
|
+
return super.delete("").then((response) => response.json());
|
|
3118
3314
|
}
|
|
3119
3315
|
/**
|
|
3120
3316
|
* Saves member properties changes to the server. Call this method to update member data on
|
|
@@ -3151,28 +3347,16 @@
|
|
|
3151
3347
|
* Provides properties and methods for obtaining information about a project on the Open Cloud
|
|
3152
3348
|
* Server and managing its {@link Role | roles}, {@link Member | members} and models.
|
|
3153
3349
|
*/
|
|
3154
|
-
class Project {
|
|
3350
|
+
class Project extends Endpoint {
|
|
3155
3351
|
/**
|
|
3156
3352
|
* @param data - Raw project data received from the server. For more information, see
|
|
3157
3353
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
3158
3354
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
3159
3355
|
*/
|
|
3160
3356
|
constructor(data, httpClient) {
|
|
3161
|
-
|
|
3357
|
+
super(`/projects/${data.id}`, httpClient);
|
|
3162
3358
|
this.data = data;
|
|
3163
3359
|
}
|
|
3164
|
-
internalGet(relativePath) {
|
|
3165
|
-
return this.httpClient.get(`/projects/${this.id}${relativePath}`);
|
|
3166
|
-
}
|
|
3167
|
-
internalPost(relativePath, body) {
|
|
3168
|
-
return this.httpClient.post(`/projects/${this.id}${relativePath}`, body);
|
|
3169
|
-
}
|
|
3170
|
-
internalPut(relativePath, body) {
|
|
3171
|
-
return this.httpClient.put(`/projects/${this.id}${relativePath}`, body);
|
|
3172
|
-
}
|
|
3173
|
-
internalDelete(relativePath) {
|
|
3174
|
-
return this.httpClient.delete(`/projects/${this.id}${relativePath}`);
|
|
3175
|
-
}
|
|
3176
3360
|
/**
|
|
3177
3361
|
* Project features the user has access to.
|
|
3178
3362
|
*
|
|
@@ -3326,7 +3510,7 @@
|
|
|
3326
3510
|
* Reloads project data from the server.
|
|
3327
3511
|
*/
|
|
3328
3512
|
async checkout() {
|
|
3329
|
-
const response = await this.
|
|
3513
|
+
const response = await this.get("");
|
|
3330
3514
|
this.data = await response.json();
|
|
3331
3515
|
return this;
|
|
3332
3516
|
}
|
|
@@ -3337,7 +3521,7 @@
|
|
|
3337
3521
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
3338
3522
|
*/
|
|
3339
3523
|
async update(data) {
|
|
3340
|
-
const response = await this.
|
|
3524
|
+
const response = await this.put("", data);
|
|
3341
3525
|
this.data = await response.json();
|
|
3342
3526
|
return this;
|
|
3343
3527
|
}
|
|
@@ -3348,7 +3532,8 @@
|
|
|
3348
3532
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
3349
3533
|
*/
|
|
3350
3534
|
delete() {
|
|
3351
|
-
return
|
|
3535
|
+
return super
|
|
3536
|
+
.delete("")
|
|
3352
3537
|
.then((response) => response.text())
|
|
3353
3538
|
.then((text) => {
|
|
3354
3539
|
// TODO fix for server 23.5 and below
|
|
@@ -3383,7 +3568,7 @@
|
|
|
3383
3568
|
await this.deletePreview();
|
|
3384
3569
|
}
|
|
3385
3570
|
else {
|
|
3386
|
-
const response = await this.
|
|
3571
|
+
const response = await this.post("/preview", image);
|
|
3387
3572
|
this.data = await response.json();
|
|
3388
3573
|
}
|
|
3389
3574
|
return this;
|
|
@@ -3392,7 +3577,7 @@
|
|
|
3392
3577
|
* Removes the project preview.
|
|
3393
3578
|
*/
|
|
3394
3579
|
async deletePreview() {
|
|
3395
|
-
const response = await
|
|
3580
|
+
const response = await super.delete("/preview");
|
|
3396
3581
|
this.data = await response.json();
|
|
3397
3582
|
return this;
|
|
3398
3583
|
}
|
|
@@ -3401,7 +3586,7 @@
|
|
|
3401
3586
|
* role they have in a project.
|
|
3402
3587
|
*/
|
|
3403
3588
|
getRoles() {
|
|
3404
|
-
return this.
|
|
3589
|
+
return this.get("/roles")
|
|
3405
3590
|
.then((response) => response.json())
|
|
3406
3591
|
.then((array) => array.map((data) => new Role(data, this.id, this.httpClient)));
|
|
3407
3592
|
}
|
|
@@ -3411,7 +3596,7 @@
|
|
|
3411
3596
|
* @param name - Role name.
|
|
3412
3597
|
*/
|
|
3413
3598
|
getRole(name) {
|
|
3414
|
-
return this.
|
|
3599
|
+
return this.get(`/roles/${name}`)
|
|
3415
3600
|
.then((response) => response.json())
|
|
3416
3601
|
.then((data) => new Role(data, this.id, this.httpClient));
|
|
3417
3602
|
}
|
|
@@ -3423,7 +3608,7 @@
|
|
|
3423
3608
|
* @param permissions - Actions are allowed to be performed for the role.
|
|
3424
3609
|
*/
|
|
3425
3610
|
createRole(name, description, permissions) {
|
|
3426
|
-
return this.
|
|
3611
|
+
return this.post("/roles", {
|
|
3427
3612
|
name,
|
|
3428
3613
|
description,
|
|
3429
3614
|
permissions: permissions || {},
|
|
@@ -3439,13 +3624,13 @@
|
|
|
3439
3624
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
3440
3625
|
*/
|
|
3441
3626
|
deleteRole(name) {
|
|
3442
|
-
return
|
|
3627
|
+
return super.delete(`/roles/${name}`).then((response) => response.json());
|
|
3443
3628
|
}
|
|
3444
3629
|
/**
|
|
3445
3630
|
* Returns a list of project members.
|
|
3446
3631
|
*/
|
|
3447
3632
|
getMembers() {
|
|
3448
|
-
return this.
|
|
3633
|
+
return this.get("/members")
|
|
3449
3634
|
.then((response) => response.json())
|
|
3450
3635
|
.then((array) => array.map((data) => new Member(data, this.id, this.httpClient)));
|
|
3451
3636
|
}
|
|
@@ -3455,7 +3640,7 @@
|
|
|
3455
3640
|
* @param memberId - Member ID.
|
|
3456
3641
|
*/
|
|
3457
3642
|
getMember(memberId) {
|
|
3458
|
-
return this.
|
|
3643
|
+
return this.get(`/members/${memberId}`)
|
|
3459
3644
|
.then((response) => response.json())
|
|
3460
3645
|
.then((data) => new Member(data, this.id, this.httpClient));
|
|
3461
3646
|
}
|
|
@@ -3466,7 +3651,7 @@
|
|
|
3466
3651
|
* @param role - Role name from the list of project {@link getRoles | roles}.
|
|
3467
3652
|
*/
|
|
3468
3653
|
addMember(userId, role) {
|
|
3469
|
-
return this.
|
|
3654
|
+
return this.post("/members", { userId, role })
|
|
3470
3655
|
.then((response) => response.json())
|
|
3471
3656
|
.then((data) => new Member(data, this.id, this.httpClient));
|
|
3472
3657
|
}
|
|
@@ -3478,7 +3663,7 @@
|
|
|
3478
3663
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
3479
3664
|
*/
|
|
3480
3665
|
removeMember(memberId) {
|
|
3481
|
-
return
|
|
3666
|
+
return super.delete(`/members/${memberId}`).then((response) => response.json());
|
|
3482
3667
|
}
|
|
3483
3668
|
/**
|
|
3484
3669
|
* Information about the file (model) that can be reference in the project topics.
|
|
@@ -3501,8 +3686,9 @@
|
|
|
3501
3686
|
* {@link File.createPermission | File.createPermission()}.
|
|
3502
3687
|
*/
|
|
3503
3688
|
getFilesInformation() {
|
|
3504
|
-
|
|
3505
|
-
|
|
3689
|
+
const bcfProjects = new Endpoint("/bcf/3.0/projects", this.httpClient, this.headers);
|
|
3690
|
+
return bcfProjects
|
|
3691
|
+
.get(`/${this.id}/files_information`)
|
|
3506
3692
|
.then((response) => response.json())
|
|
3507
3693
|
.then((items) => {
|
|
3508
3694
|
items.forEach((item) => {
|
|
@@ -3549,9 +3735,8 @@
|
|
|
3549
3735
|
return this.getFilesInformation()
|
|
3550
3736
|
.then((filesInformation) => filesInformation.map((item) => item.file.reference))
|
|
3551
3737
|
.then((ids) => {
|
|
3552
|
-
const
|
|
3553
|
-
|
|
3554
|
-
return this.httpClient.get(`/files?${searchParams.toString()}`);
|
|
3738
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
3739
|
+
return files.get(`?id=${ids.join("|")}`);
|
|
3555
3740
|
})
|
|
3556
3741
|
.then((response) => response.json())
|
|
3557
3742
|
.then((files) => files.result.map((data) => new File(data, this.httpClient)));
|
|
@@ -3565,7 +3750,7 @@
|
|
|
3565
3750
|
* @param actions - Actions are allowed to be performed on a file:
|
|
3566
3751
|
*
|
|
3567
3752
|
* - `read` - The ability to read file description, geometry data and properties.
|
|
3568
|
-
* - `readSourceFile` - The ability to
|
|
3753
|
+
* - `readSourceFile` - The ability to download source file.
|
|
3569
3754
|
* - `write` - The ability to modify file name, description and references.
|
|
3570
3755
|
* - `readViewpoint` - The ability to read file viewpoints.
|
|
3571
3756
|
* - `createViewpoint` - The ability to create file viewpoints.
|
|
@@ -3574,8 +3759,9 @@
|
|
|
3574
3759
|
* @returns Returns a file instance added to the project.
|
|
3575
3760
|
*/
|
|
3576
3761
|
async addModel(fileId, actions, _public) {
|
|
3577
|
-
const
|
|
3578
|
-
|
|
3762
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
3763
|
+
const file = await files
|
|
3764
|
+
.get(`/${fileId}`)
|
|
3579
3765
|
.then((response) => response.json())
|
|
3580
3766
|
.then((data) => new File(data, this.httpClient));
|
|
3581
3767
|
const grantedTo = [{ project: { id: this.id, name: this.name } }];
|
|
@@ -3589,8 +3775,9 @@
|
|
|
3589
3775
|
* @returns Returns a file instance removed from the project.
|
|
3590
3776
|
*/
|
|
3591
3777
|
async removeModel(fileId) {
|
|
3592
|
-
const
|
|
3593
|
-
|
|
3778
|
+
const files = new Endpoint("/files", this.httpClient, this.headers);
|
|
3779
|
+
const file = await files
|
|
3780
|
+
.get(`/${fileId}`)
|
|
3594
3781
|
.then((response) => response.json())
|
|
3595
3782
|
.then((data) => new File(data, this.httpClient));
|
|
3596
3783
|
const permissions = await file.getPermissions();
|
|
@@ -3627,14 +3814,14 @@
|
|
|
3627
3814
|
* Provides properties and methods for obtaining information about a Open Cloud Server user and
|
|
3628
3815
|
* manage its data.
|
|
3629
3816
|
*/
|
|
3630
|
-
class User {
|
|
3817
|
+
class User extends Endpoint {
|
|
3631
3818
|
/**
|
|
3632
3819
|
* @param data - Raw user data received from the server. For more information, see
|
|
3633
3820
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Users | Open Cloud Users API}.
|
|
3634
3821
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
3635
3822
|
*/
|
|
3636
3823
|
constructor(data, httpClient) {
|
|
3637
|
-
|
|
3824
|
+
super("", httpClient);
|
|
3638
3825
|
this.data = data;
|
|
3639
3826
|
}
|
|
3640
3827
|
/**
|
|
@@ -3854,12 +4041,12 @@
|
|
|
3854
4041
|
*/
|
|
3855
4042
|
async checkout() {
|
|
3856
4043
|
if (this.httpClient.signInUserIsAdmin) {
|
|
3857
|
-
const response = await this.
|
|
4044
|
+
const response = await this.get(`/users/${this.id}`);
|
|
3858
4045
|
const data = await response.json();
|
|
3859
4046
|
this.data = { id: data.id, ...data.userBrief };
|
|
3860
4047
|
}
|
|
3861
4048
|
else if (this.id === this.httpClient.signInUserId) {
|
|
3862
|
-
const response = await this.
|
|
4049
|
+
const response = await this.get("/user");
|
|
3863
4050
|
const data = await response.json();
|
|
3864
4051
|
this.data = { id: this.id, ...data };
|
|
3865
4052
|
}
|
|
@@ -3879,12 +4066,12 @@
|
|
|
3879
4066
|
*/
|
|
3880
4067
|
async update(data) {
|
|
3881
4068
|
if (this.httpClient.signInUserIsAdmin) {
|
|
3882
|
-
const response = await this.
|
|
4069
|
+
const response = await this.put(`/users/${this.id}`, { isAdmin: data.isAdmin, userBrief: data });
|
|
3883
4070
|
const newData = await response.json();
|
|
3884
4071
|
this.data = { id: newData.id, ...newData.userBrief };
|
|
3885
4072
|
}
|
|
3886
4073
|
else if (this.id === this.httpClient.signInUserId) {
|
|
3887
|
-
const response = await this.
|
|
4074
|
+
const response = await this.put("/user", data);
|
|
3888
4075
|
const newData = await response.json();
|
|
3889
4076
|
this.data = { id: this.id, ...newData };
|
|
3890
4077
|
}
|
|
@@ -3909,12 +4096,12 @@
|
|
|
3909
4096
|
*/
|
|
3910
4097
|
delete() {
|
|
3911
4098
|
if (this.httpClient.signInUserIsAdmin) {
|
|
3912
|
-
return
|
|
4099
|
+
return super
|
|
3913
4100
|
.delete(`/users/${this.id}`)
|
|
3914
4101
|
.then((response) => response.json())
|
|
3915
4102
|
.then((data) => {
|
|
3916
4103
|
if (this.id === this.httpClient.signInUserId) {
|
|
3917
|
-
this.httpClient.headers
|
|
4104
|
+
delete this.httpClient.headers["Authorization"];
|
|
3918
4105
|
this.httpClient.signInUserId = "";
|
|
3919
4106
|
this.httpClient.signInUserIsAdmin = false;
|
|
3920
4107
|
}
|
|
@@ -3951,12 +4138,12 @@
|
|
|
3951
4138
|
await this.deleteAvatar();
|
|
3952
4139
|
}
|
|
3953
4140
|
else if (this.httpClient.signInUserIsAdmin) {
|
|
3954
|
-
const response = await this.
|
|
4141
|
+
const response = await this.post(`/users/${this.id}/avatar`, image);
|
|
3955
4142
|
const data = await response.json();
|
|
3956
4143
|
this.data = { id: data.id, ...data.userBrief };
|
|
3957
4144
|
}
|
|
3958
4145
|
else if (this.id === this.httpClient.signInUserId) {
|
|
3959
|
-
const response = await this.
|
|
4146
|
+
const response = await this.post("/user/avatar", image);
|
|
3960
4147
|
const data = await response.json();
|
|
3961
4148
|
this.data = { id: this.id, ...data };
|
|
3962
4149
|
}
|
|
@@ -3973,12 +4160,12 @@
|
|
|
3973
4160
|
*/
|
|
3974
4161
|
async deleteAvatar() {
|
|
3975
4162
|
if (this.httpClient.signInUserIsAdmin) {
|
|
3976
|
-
const response = await
|
|
4163
|
+
const response = await super.delete(`/users/${this.id}/avatar`);
|
|
3977
4164
|
const data = await response.json();
|
|
3978
4165
|
this.data = { id: data.id, ...data.userBrief };
|
|
3979
4166
|
}
|
|
3980
4167
|
else if (this.id === this.httpClient.signInUserId) {
|
|
3981
|
-
const response = await
|
|
4168
|
+
const response = await super.delete("/user/avatar");
|
|
3982
4169
|
const data = await response.json();
|
|
3983
4170
|
this.data = { id: this.id, ...data };
|
|
3984
4171
|
}
|
|
@@ -4002,12 +4189,12 @@
|
|
|
4002
4189
|
*/
|
|
4003
4190
|
async changePassword(newPassword, oldPassword) {
|
|
4004
4191
|
if (this.httpClient.signInUserIsAdmin) {
|
|
4005
|
-
const response = await this.
|
|
4192
|
+
const response = await this.put(`/users/${this.id}/password`, { new: newPassword });
|
|
4006
4193
|
const data = await response.json();
|
|
4007
4194
|
this.data = { id: data.id, ...data.userBrief };
|
|
4008
4195
|
}
|
|
4009
4196
|
else if (this.id === this.httpClient.signInUserId) {
|
|
4010
|
-
const response = await this.
|
|
4197
|
+
const response = await this.put("/user/password", { old: oldPassword, new: newPassword });
|
|
4011
4198
|
const data = await response.json();
|
|
4012
4199
|
this.data = { id: this.id, ...data };
|
|
4013
4200
|
}
|
|
@@ -4044,28 +4231,16 @@
|
|
|
4044
4231
|
* Provides properties and methods for obtaining information about a OAuth 2.0 client that have
|
|
4045
4232
|
* access the Open Cloud Server API.
|
|
4046
4233
|
*/
|
|
4047
|
-
class OAuthClient {
|
|
4234
|
+
class OAuthClient extends Endpoint {
|
|
4048
4235
|
/**
|
|
4049
4236
|
* @param data - Raw client data received from the server. For more information, see
|
|
4050
4237
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
4051
4238
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
4052
4239
|
*/
|
|
4053
4240
|
constructor(data, httpClient) {
|
|
4054
|
-
|
|
4241
|
+
super(`/oauth/clients/${data.clientId}`, httpClient);
|
|
4055
4242
|
this.data = data;
|
|
4056
4243
|
}
|
|
4057
|
-
internalGet() {
|
|
4058
|
-
return this.httpClient.get(`/oauth/clients/${this.clientId}`);
|
|
4059
|
-
}
|
|
4060
|
-
internalPost(relativePath, body) {
|
|
4061
|
-
return this.httpClient.post(`/oauth/clients/${this.clientId}${relativePath}`, body);
|
|
4062
|
-
}
|
|
4063
|
-
internalPut(body) {
|
|
4064
|
-
return this.httpClient.put(`/oauth/clients/${this.clientId}`, body);
|
|
4065
|
-
}
|
|
4066
|
-
internalDelete() {
|
|
4067
|
-
return this.httpClient.delete(`/oauth/clients/${this.clientId}`);
|
|
4068
|
-
}
|
|
4069
4244
|
/**
|
|
4070
4245
|
* OAuth 2.0 server authorization endpoint.
|
|
4071
4246
|
*/
|
|
@@ -4151,7 +4326,7 @@
|
|
|
4151
4326
|
* Reloads clien data from the server.
|
|
4152
4327
|
*/
|
|
4153
4328
|
async checkout() {
|
|
4154
|
-
const response = await this.
|
|
4329
|
+
const response = await this.get("");
|
|
4155
4330
|
this.data = await response.json();
|
|
4156
4331
|
return this;
|
|
4157
4332
|
}
|
|
@@ -4165,7 +4340,7 @@
|
|
|
4165
4340
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
4166
4341
|
*/
|
|
4167
4342
|
async update(data) {
|
|
4168
|
-
const response = await this.
|
|
4343
|
+
const response = await this.put("", data);
|
|
4169
4344
|
this.data = await response.json();
|
|
4170
4345
|
return this;
|
|
4171
4346
|
}
|
|
@@ -4179,7 +4354,7 @@
|
|
|
4179
4354
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
4180
4355
|
*/
|
|
4181
4356
|
delete() {
|
|
4182
|
-
return
|
|
4357
|
+
return super.delete("").then((response) => response.json());
|
|
4183
4358
|
}
|
|
4184
4359
|
/**
|
|
4185
4360
|
* Saves client properties changes to the server. Call this method to update client data on
|
|
@@ -4195,7 +4370,54 @@
|
|
|
4195
4370
|
* Revokes the access tokens for all users of the client application.
|
|
4196
4371
|
*/
|
|
4197
4372
|
async revoke() {
|
|
4198
|
-
await this.
|
|
4373
|
+
await this.post("/revoke");
|
|
4374
|
+
return this;
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
|
|
4378
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
4379
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
4380
|
+
// All rights reserved.
|
|
4381
|
+
//
|
|
4382
|
+
// This software and its documentation and related materials are owned by
|
|
4383
|
+
// the Alliance. The software may only be incorporated into application
|
|
4384
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
4385
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
4386
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
4387
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
4388
|
+
// protected by copyright law and international treaty provisions. Application
|
|
4389
|
+
// programs incorporating this software must include the following statement
|
|
4390
|
+
// with their copyright notices:
|
|
4391
|
+
//
|
|
4392
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
4393
|
+
// license agreement with Open Design Alliance.
|
|
4394
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
4395
|
+
// All rights reserved.
|
|
4396
|
+
//
|
|
4397
|
+
// By use of this software, its documentation or related materials, you
|
|
4398
|
+
// acknowledge and accept the above terms.
|
|
4399
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
4400
|
+
class SharedFile extends File {
|
|
4401
|
+
constructor(data, password, httpClient) {
|
|
4402
|
+
super(data.file, httpClient);
|
|
4403
|
+
this.path = `/shares/${data.file.sharedLinkToken}`;
|
|
4404
|
+
this.headers = { "InWeb-Password": password };
|
|
4405
|
+
}
|
|
4406
|
+
async checkout() {
|
|
4407
|
+
const response = await this.get("/info");
|
|
4408
|
+
const data = await response.json();
|
|
4409
|
+
this.data = data.file;
|
|
4410
|
+
return this;
|
|
4411
|
+
}
|
|
4412
|
+
async update(data) {
|
|
4413
|
+
const response = await this.put("/info", data);
|
|
4414
|
+
this.data = await response.json();
|
|
4415
|
+
return this;
|
|
4416
|
+
}
|
|
4417
|
+
getVersions() {
|
|
4418
|
+
return Promise.resolve(undefined);
|
|
4419
|
+
}
|
|
4420
|
+
useVersion(version) {
|
|
4199
4421
|
return this;
|
|
4200
4422
|
}
|
|
4201
4423
|
}
|
|
@@ -4229,7 +4451,7 @@
|
|
|
4229
4451
|
class Client extends EventEmitter2 {
|
|
4230
4452
|
/**
|
|
4231
4453
|
* @param params - An object containing client configuration parameters.
|
|
4232
|
-
* @param params.serverUrl - Open Cloud
|
|
4454
|
+
* @param params.serverUrl - Open Cloud REST API server URL.
|
|
4233
4455
|
* @param params.url - Deprecated since `25.8`. Use `serverUrl` instead.
|
|
4234
4456
|
*/
|
|
4235
4457
|
constructor(params = {}) {
|
|
@@ -4241,7 +4463,7 @@
|
|
|
4241
4463
|
this.configure(params);
|
|
4242
4464
|
}
|
|
4243
4465
|
/**
|
|
4244
|
-
* Open Cloud REST API server
|
|
4466
|
+
* Open Cloud REST API server URL. Use {@link configure | configure()} to change server URL.
|
|
4245
4467
|
*
|
|
4246
4468
|
* @readonly
|
|
4247
4469
|
*/
|
|
@@ -4304,7 +4526,7 @@
|
|
|
4304
4526
|
* After changing the parameters, you must re-login.
|
|
4305
4527
|
*
|
|
4306
4528
|
* @param params - An object containing new parameters.
|
|
4307
|
-
* @param params.serverUrl - Open Cloud
|
|
4529
|
+
* @param params.serverUrl - Open Cloud REST API server URL.
|
|
4308
4530
|
*/
|
|
4309
4531
|
configure(params) {
|
|
4310
4532
|
this._serverUrl = (params.serverUrl || "").replace(/\/+$/, "");
|
|
@@ -4324,7 +4546,7 @@
|
|
|
4324
4546
|
.then((data) => ({
|
|
4325
4547
|
...data,
|
|
4326
4548
|
server: data.version,
|
|
4327
|
-
client: "
|
|
4549
|
+
client: "26.1.0",
|
|
4328
4550
|
}));
|
|
4329
4551
|
}
|
|
4330
4552
|
/**
|
|
@@ -4378,7 +4600,7 @@
|
|
|
4378
4600
|
*/
|
|
4379
4601
|
async signInWithEmail(email, password) {
|
|
4380
4602
|
const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
|
|
4381
|
-
this.httpClient.headers =
|
|
4603
|
+
this.httpClient.headers["Authorization"] = "Basic " + credentials;
|
|
4382
4604
|
const response = await this.httpClient.get("/token");
|
|
4383
4605
|
const data = await response.json();
|
|
4384
4606
|
return this.setCurrentUser(data);
|
|
@@ -4389,22 +4611,31 @@
|
|
|
4389
4611
|
* @param token - An access token for authentication request. See {@link User.token} for more details.
|
|
4390
4612
|
*/
|
|
4391
4613
|
async signInWithToken(token) {
|
|
4392
|
-
this.httpClient.headers =
|
|
4614
|
+
this.httpClient.headers["Authorization"] = token;
|
|
4393
4615
|
const response = await this.httpClient.get("/user");
|
|
4394
4616
|
const data = await response.json();
|
|
4395
4617
|
return this.setCurrentUser(data);
|
|
4396
4618
|
}
|
|
4619
|
+
/**
|
|
4620
|
+
* Log out.
|
|
4621
|
+
*
|
|
4622
|
+
* You must log in again using {@link signInWithEmail} or {@link signInWithToken} to continue
|
|
4623
|
+
* making requests to the server
|
|
4624
|
+
*/
|
|
4625
|
+
signOut() {
|
|
4626
|
+
this.clearCurrentUser();
|
|
4627
|
+
}
|
|
4397
4628
|
// Save the current logged in user information for internal use.
|
|
4398
4629
|
setCurrentUser(data) {
|
|
4399
4630
|
this._user = new User(data, this.httpClient);
|
|
4400
|
-
this.httpClient.headers =
|
|
4631
|
+
this.httpClient.headers["Authorization"] = data.tokenInfo.token;
|
|
4401
4632
|
this.httpClient.signInUserId = this._user.id;
|
|
4402
4633
|
this.httpClient.signInUserIsAdmin = this._user.isAdmin;
|
|
4403
4634
|
return this._user;
|
|
4404
4635
|
}
|
|
4405
4636
|
clearCurrentUser() {
|
|
4406
4637
|
this._user = null;
|
|
4407
|
-
this.httpClient.headers
|
|
4638
|
+
delete this.httpClient.headers["Authorization"];
|
|
4408
4639
|
this.httpClient.signInUserId = "";
|
|
4409
4640
|
this.httpClient.signInUserIsAdmin = false;
|
|
4410
4641
|
}
|
|
@@ -4660,8 +4891,9 @@
|
|
|
4660
4891
|
* @param sortByDesc - Allows to specify the descending order of the result. By default,
|
|
4661
4892
|
* files are sorted by name in ascending order.
|
|
4662
4893
|
* @param sortField - Allows to specify sort field.
|
|
4894
|
+
* @param shared - Returns shared files only.
|
|
4663
4895
|
*/
|
|
4664
|
-
getFiles(start, limit, name, ext, ids, sortByDesc, sortField) {
|
|
4896
|
+
getFiles(start, limit, name, ext, ids, sortByDesc, sortField, shared) {
|
|
4665
4897
|
const searchParams = new URLSearchParams();
|
|
4666
4898
|
if (start > 0)
|
|
4667
4899
|
searchParams.set("start", start.toString());
|
|
@@ -4686,6 +4918,8 @@
|
|
|
4686
4918
|
searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
4687
4919
|
if (sortField)
|
|
4688
4920
|
searchParams.set("sortField", sortField);
|
|
4921
|
+
if (shared)
|
|
4922
|
+
searchParams.set("shared", "true");
|
|
4689
4923
|
let queryString = searchParams.toString();
|
|
4690
4924
|
if (queryString)
|
|
4691
4925
|
queryString = "?" + queryString;
|
|
@@ -4789,7 +5023,7 @@
|
|
|
4789
5023
|
*/
|
|
4790
5024
|
downloadFile(fileId, onProgress, signal) {
|
|
4791
5025
|
return this.httpClient
|
|
4792
|
-
.downloadFile(`/files/${fileId}/downloads`, onProgress, signal)
|
|
5026
|
+
.downloadFile(`/files/${fileId}/downloads`, onProgress, { signal })
|
|
4793
5027
|
.then((response) => response.arrayBuffer());
|
|
4794
5028
|
}
|
|
4795
5029
|
/**
|
|
@@ -5115,6 +5349,65 @@
|
|
|
5115
5349
|
}
|
|
5116
5350
|
});
|
|
5117
5351
|
}
|
|
5352
|
+
/**
|
|
5353
|
+
* Returns information about the specified file shared link.
|
|
5354
|
+
*
|
|
5355
|
+
* @param token - Shared link token.
|
|
5356
|
+
*/
|
|
5357
|
+
getSharedLink(token) {
|
|
5358
|
+
return this.httpClient
|
|
5359
|
+
.get(`/shares/${token}`)
|
|
5360
|
+
.then((response) => response.json())
|
|
5361
|
+
.then((data) => new SharedLink(data, this.httpClient));
|
|
5362
|
+
}
|
|
5363
|
+
/**
|
|
5364
|
+
* Creates a shared link for the specified file.
|
|
5365
|
+
*
|
|
5366
|
+
* @param fileId - File ID.
|
|
5367
|
+
* @param permissions - Share permissions.
|
|
5368
|
+
*/
|
|
5369
|
+
createSharedLink(fileId, permissions) {
|
|
5370
|
+
return this.httpClient
|
|
5371
|
+
.post("/shares", {
|
|
5372
|
+
fileId,
|
|
5373
|
+
permissions,
|
|
5374
|
+
})
|
|
5375
|
+
.then((response) => response.json())
|
|
5376
|
+
.then((data) => new SharedLink(data, this.httpClient));
|
|
5377
|
+
}
|
|
5378
|
+
/**
|
|
5379
|
+
* Deletes the specified shared link.
|
|
5380
|
+
*
|
|
5381
|
+
* Only file owner can delete shared link. If the current logged in user is not a file owner,
|
|
5382
|
+
* an exception will be thrown.
|
|
5383
|
+
*
|
|
5384
|
+
* @param token - Shared link token.
|
|
5385
|
+
* @returns Returns the raw data of a deleted shared link. For more information, see
|
|
5386
|
+
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
|
|
5387
|
+
*/
|
|
5388
|
+
deleteSharedLink(token) {
|
|
5389
|
+
return this.httpClient.delete(`/shares/${token}`).then((response) => response.json());
|
|
5390
|
+
}
|
|
5391
|
+
/**
|
|
5392
|
+
* Returns information about a file from a shared link.
|
|
5393
|
+
*
|
|
5394
|
+
* Some file features are not available via shared link:
|
|
5395
|
+
*
|
|
5396
|
+
* - Updating file properties, preview, and viewpoints
|
|
5397
|
+
* - Running file jobs
|
|
5398
|
+
* - Managing file permissions
|
|
5399
|
+
* - Managing file versions
|
|
5400
|
+
* - Deleting file
|
|
5401
|
+
*
|
|
5402
|
+
* @param token - Shared link token.
|
|
5403
|
+
* @param password - Password to get access to the file.
|
|
5404
|
+
*/
|
|
5405
|
+
getSharedFile(token, password) {
|
|
5406
|
+
return this.httpClient
|
|
5407
|
+
.get(`/shares/${token}/info`, { headers: { "InWeb-Password": password } })
|
|
5408
|
+
.then((response) => response.json())
|
|
5409
|
+
.then((data) => new SharedFile(data, password, this.httpClient));
|
|
5410
|
+
}
|
|
5118
5411
|
}
|
|
5119
5412
|
|
|
5120
5413
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -5139,11 +5432,12 @@
|
|
|
5139
5432
|
// By use of this software, its documentation or related materials, you
|
|
5140
5433
|
// acknowledge and accept the above terms.
|
|
5141
5434
|
///////////////////////////////////////////////////////////////////////////////
|
|
5142
|
-
const version = "
|
|
5435
|
+
const version = "26.1.0";
|
|
5143
5436
|
|
|
5144
5437
|
exports.Assembly = Assembly;
|
|
5145
5438
|
exports.ClashTest = ClashTest;
|
|
5146
5439
|
exports.Client = Client;
|
|
5440
|
+
exports.Endpoint = Endpoint;
|
|
5147
5441
|
exports.FetchError = FetchError;
|
|
5148
5442
|
exports.File = File;
|
|
5149
5443
|
exports.Job = Job;
|
|
@@ -5153,6 +5447,8 @@
|
|
|
5153
5447
|
exports.Permission = Permission;
|
|
5154
5448
|
exports.Project = Project;
|
|
5155
5449
|
exports.Role = Role;
|
|
5450
|
+
exports.SharedFile = SharedFile;
|
|
5451
|
+
exports.SharedLink = SharedLink;
|
|
5156
5452
|
exports.User = User;
|
|
5157
5453
|
exports.parseArgs = parseArgs;
|
|
5158
5454
|
exports.statusText = statusText;
|