@inweb/client 25.2.2

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.
Files changed (218) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +70 -0
  3. package/dist/client.js +21126 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/client.min.js +1 -0
  6. package/dist/client.module.js +7151 -0
  7. package/dist/client.module.js.map +1 -0
  8. package/lib/Api/Assembly.d.ts +339 -0
  9. package/lib/Api/ClashTest.d.ts +176 -0
  10. package/lib/Api/Client.d.ts +452 -0
  11. package/lib/Api/ClientEvents.d.ts +29 -0
  12. package/lib/Api/File.d.ts +568 -0
  13. package/lib/Api/HttpClient.d.ts +13 -0
  14. package/lib/Api/IAssembly.d.ts +14 -0
  15. package/lib/Api/IFile.d.ts +46 -0
  16. package/lib/Api/IHttpClient.d.ts +11 -0
  17. package/lib/Api/IUser.d.ts +11 -0
  18. package/lib/Api/Job.d.ts +142 -0
  19. package/lib/Api/Member.d.ts +85 -0
  20. package/lib/Api/Model.d.ts +147 -0
  21. package/lib/Api/Permission.d.ts +93 -0
  22. package/lib/Api/Project.d.ts +247 -0
  23. package/lib/Api/Role.d.ts +82 -0
  24. package/lib/Api/User.d.ts +197 -0
  25. package/lib/Api/impl/FetchError.d.ts +18 -0
  26. package/lib/Api/impl/Utils.d.ts +33 -0
  27. package/lib/Api/impl/http.d.ts +67 -0
  28. package/lib/ConvetMath.d.ts +29 -0
  29. package/lib/Viewer/CanvasEvents.d.ts +2 -0
  30. package/lib/Viewer/Commands/ApplyModelTransform.d.ts +2 -0
  31. package/lib/Viewer/Commands/ClearMarkup.d.ts +2 -0
  32. package/lib/Viewer/Commands/ClearSlices.d.ts +2 -0
  33. package/lib/Viewer/Commands/CreatePreview.d.ts +2 -0
  34. package/lib/Viewer/Commands/Explode.d.ts +2 -0
  35. package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +2 -0
  36. package/lib/Viewer/Commands/GetModels.d.ts +2 -0
  37. package/lib/Viewer/Commands/GetSelected.d.ts +2 -0
  38. package/lib/Viewer/Commands/HideSelected.d.ts +2 -0
  39. package/lib/Viewer/Commands/IsolateSelected.d.ts +2 -0
  40. package/lib/Viewer/Commands/RegenerateAll.d.ts +2 -0
  41. package/lib/Viewer/Commands/ResetView.d.ts +2 -0
  42. package/lib/Viewer/Commands/SelectModel.d.ts +2 -0
  43. package/lib/Viewer/Commands/SetActiveDragger.d.ts +2 -0
  44. package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +2 -0
  45. package/lib/Viewer/Commands/SetMarkupColor.d.ts +2 -0
  46. package/lib/Viewer/Commands/SetSelected.d.ts +2 -0
  47. package/lib/Viewer/Commands/ShowAll.d.ts +2 -0
  48. package/lib/Viewer/Commands/Unselect.d.ts +2 -0
  49. package/lib/Viewer/Commands/ZoomToExtents.d.ts +2 -0
  50. package/lib/Viewer/Commands/ZoomToObjects.d.ts +2 -0
  51. package/lib/Viewer/Commands/ZoomToSelected.d.ts +2 -0
  52. package/lib/Viewer/Commands.d.ts +3 -0
  53. package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +22 -0
  54. package/lib/Viewer/Draggers/Actions/PanAction.d.ts +18 -0
  55. package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +8 -0
  56. package/lib/Viewer/Draggers/Common/Geometry.d.ts +115 -0
  57. package/lib/Viewer/Draggers/Common/GestureManager.d.ts +41 -0
  58. package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +54 -0
  59. package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +30 -0
  60. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +31 -0
  61. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +20 -0
  62. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +24 -0
  63. package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +27 -0
  64. package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +8 -0
  65. package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +8 -0
  66. package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +8 -0
  67. package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +15 -0
  68. package/lib/Viewer/Draggers/OdPanDragger.d.ts +12 -0
  69. package/lib/Viewer/Draggers/OdZoomDragger.d.ts +12 -0
  70. package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +11 -0
  71. package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +19 -0
  72. package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +14 -0
  73. package/lib/Viewer/Draggers/OdaLineDragger.d.ts +15 -0
  74. package/lib/Viewer/Draggers/OdaTextDragger.d.ts +16 -0
  75. package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +30 -0
  76. package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +19 -0
  77. package/lib/Viewer/EventEmitter2.d.ts +54 -0
  78. package/lib/Viewer/ICommands.d.ts +25 -0
  79. package/lib/Viewer/IEventEmitter2.d.ts +13 -0
  80. package/lib/Viewer/IViewer.d.ts +27 -0
  81. package/lib/Viewer/Loaders/BaseLoader.d.ts +11 -0
  82. package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -0
  83. package/lib/Viewer/Loaders/TCSLoader.d.ts +5 -0
  84. package/lib/Viewer/Loaders/UpdaterController.d.ts +15 -0
  85. package/lib/Viewer/Loaders/VsfXLoader.d.ts +5 -0
  86. package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +5 -0
  87. package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +12 -0
  88. package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +5 -0
  89. package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +15 -0
  90. package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +15 -0
  91. package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +11 -0
  92. package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +12 -0
  93. package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +15 -0
  94. package/lib/Viewer/Markup/Api/IMarkupText.d.ts +13 -0
  95. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +32 -0
  96. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -0
  97. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -0
  98. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +32 -0
  99. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -0
  100. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -0
  101. package/lib/Viewer/Markup/IMarkup.d.ts +38 -0
  102. package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +63 -0
  103. package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +19 -0
  104. package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -0
  105. package/lib/Viewer/Markup/MarkupFactory.d.ts +7 -0
  106. package/lib/Viewer/Options.d.ts +228 -0
  107. package/lib/Viewer/OptionsEvents.d.ts +26 -0
  108. package/lib/Viewer/Viewer.d.ts +353 -0
  109. package/lib/Viewer/ViewerCommands.d.ts +23 -0
  110. package/lib/Viewer/ViewerEvents.d.ts +601 -0
  111. package/lib/Viewer/utils.d.ts +4 -0
  112. package/lib/index.d.ts +24 -0
  113. package/package.json +32 -0
  114. package/src/Api/Assembly.ts +678 -0
  115. package/src/Api/ClashTest.ts +290 -0
  116. package/src/Api/Client.ts +816 -0
  117. package/src/Api/ClientEvents.ts +31 -0
  118. package/src/Api/File.ts +962 -0
  119. package/src/Api/HttpClient.ts +73 -0
  120. package/src/Api/IAssembly.ts +37 -0
  121. package/src/Api/IFile.ts +74 -0
  122. package/src/Api/IHttpClient.ts +50 -0
  123. package/src/Api/IUser.ts +33 -0
  124. package/src/Api/Job.ts +253 -0
  125. package/src/Api/Member.ts +161 -0
  126. package/src/Api/Model.ts +259 -0
  127. package/src/Api/Permission.ts +173 -0
  128. package/src/Api/Project.ts +479 -0
  129. package/src/Api/Role.ts +158 -0
  130. package/src/Api/User.ts +357 -0
  131. package/src/Api/impl/FetchError.ts +48 -0
  132. package/src/Api/impl/Utils.ts +367 -0
  133. package/src/Api/impl/http.ts +92 -0
  134. package/src/ConvetMath.ts +372 -0
  135. package/src/Viewer/CanvasEvents.ts +41 -0
  136. package/src/Viewer/Commands/ApplyModelTransform.ts +70 -0
  137. package/src/Viewer/Commands/ClearMarkup.ts +28 -0
  138. package/src/Viewer/Commands/ClearSlices.ts +27 -0
  139. package/src/Viewer/Commands/CreatePreview.ts +33 -0
  140. package/src/Viewer/Commands/Explode.ts +38 -0
  141. package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -0
  142. package/src/Viewer/Commands/GetModels.ts +43 -0
  143. package/src/Viewer/Commands/GetSelected.ts +58 -0
  144. package/src/Viewer/Commands/HideSelected.ts +37 -0
  145. package/src/Viewer/Commands/IsolateSelected.ts +37 -0
  146. package/src/Viewer/Commands/RegenerateAll.ts +37 -0
  147. package/src/Viewer/Commands/ResetView.ts +43 -0
  148. package/src/Viewer/Commands/SelectModel.ts +52 -0
  149. package/src/Viewer/Commands/SetActiveDragger.ts +29 -0
  150. package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -0
  151. package/src/Viewer/Commands/SetMarkupColor.ts +29 -0
  152. package/src/Viewer/Commands/SetSelected.ts +47 -0
  153. package/src/Viewer/Commands/ShowAll.ts +37 -0
  154. package/src/Viewer/Commands/Unselect.ts +37 -0
  155. package/src/Viewer/Commands/ZoomToExtents.ts +43 -0
  156. package/src/Viewer/Commands/ZoomToObjects.ts +47 -0
  157. package/src/Viewer/Commands/ZoomToSelected.ts +39 -0
  158. package/src/Viewer/Commands.ts +81 -0
  159. package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -0
  160. package/src/Viewer/Draggers/Actions/PanAction.ts +102 -0
  161. package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -0
  162. package/src/Viewer/Draggers/Common/Geometry.ts +152 -0
  163. package/src/Viewer/Draggers/Common/GestureManager.ts +263 -0
  164. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -0
  165. package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -0
  166. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -0
  167. package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -0
  168. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -0
  169. package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -0
  170. package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -0
  171. package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -0
  172. package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -0
  173. package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -0
  174. package/src/Viewer/Draggers/OdPanDragger.ts +62 -0
  175. package/src/Viewer/Draggers/OdZoomDragger.ts +59 -0
  176. package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -0
  177. package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -0
  178. package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -0
  179. package/src/Viewer/Draggers/OdaLineDragger.ts +80 -0
  180. package/src/Viewer/Draggers/OdaTextDragger.ts +118 -0
  181. package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -0
  182. package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -0
  183. package/src/Viewer/EventEmitter2.ts +116 -0
  184. package/src/Viewer/ICommands.ts +53 -0
  185. package/src/Viewer/IEventEmitter2.ts +36 -0
  186. package/src/Viewer/IViewer.ts +55 -0
  187. package/src/Viewer/Loaders/BaseLoader.ts +40 -0
  188. package/src/Viewer/Loaders/LoaderFactory.ts +44 -0
  189. package/src/Viewer/Loaders/TCSLoader.ts +82 -0
  190. package/src/Viewer/Loaders/UpdaterController.ts +36 -0
  191. package/src/Viewer/Loaders/VsfXLoader.ts +87 -0
  192. package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -0
  193. package/src/Viewer/Markup/Api/IMarkupArrow.ts +15 -0
  194. package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -0
  195. package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -0
  196. package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -0
  197. package/src/Viewer/Markup/Api/IMarkupLine.ts +10 -0
  198. package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -0
  199. package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -0
  200. package/src/Viewer/Markup/Api/IMarkupText.ts +12 -0
  201. package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +119 -0
  202. package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +113 -0
  203. package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +121 -0
  204. package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +99 -0
  205. package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +113 -0
  206. package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +104 -0
  207. package/src/Viewer/Markup/IMarkup.ts +39 -0
  208. package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +872 -0
  209. package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -0
  210. package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +273 -0
  211. package/src/Viewer/Markup/MarkupFactory.ts +32 -0
  212. package/src/Viewer/Options.ts +502 -0
  213. package/src/Viewer/OptionsEvents.ts +28 -0
  214. package/src/Viewer/Viewer.ts +1109 -0
  215. package/src/Viewer/ViewerCommands.ts +45 -0
  216. package/src/Viewer/ViewerEvents.ts +700 -0
  217. package/src/Viewer/utils.ts +74 -0
  218. package/src/index.ts +48 -0
@@ -0,0 +1,816 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { EventEmitter2 } from "../Viewer/EventEmitter2";
25
+ import { IHttpClient } from "./IHttpClient";
26
+ import { HttpClient } from "./HttpClient";
27
+ import { ClientEventMap } from "./ClientEvents";
28
+ import { Options } from "../Viewer/Options";
29
+ import { OptionsEventMap } from "../Viewer/OptionsEvents";
30
+ import { Assembly } from "./Assembly";
31
+ import { File } from "./File";
32
+ import { Job } from "./Job";
33
+ import { Project } from "./Project";
34
+ import { User } from "./User";
35
+ import { downloadProgress, json, text, parseArgs } from "./impl/Utils";
36
+
37
+ /**
38
+ * The `Client.js` library class that provides methods to access the [Open Cloud
39
+ * Server](https://cloud.opendesign.com/docs/index.html#/opencloud_server) resources like
40
+ * Projects, Files, Issues etc.
41
+ */
42
+ export class Client extends EventEmitter2<ClientEventMap & OptionsEventMap> {
43
+ private _options: Options;
44
+ private _serverUrl: string;
45
+
46
+ private _httpClient: IHttpClient;
47
+ private _user: User | null;
48
+
49
+ public eventEmitter: EventEmitter2;
50
+
51
+ /**
52
+ * @param params - An object containing client configuration parameters.
53
+ * @param params.serverUrl - Open Cloud Server URL.
54
+ */
55
+ constructor(params: { serverUrl?: string; url?: string } = {}) {
56
+ super();
57
+ this.configure(params);
58
+ this.eventEmitter = this;
59
+ this._options = new Options(this);
60
+ this._user = null;
61
+ }
62
+
63
+ /**
64
+ * Open Cloud Server URL. Use {@link Client#configure | configure()} to change server URL.
65
+ *
66
+ * @readonly
67
+ */
68
+ get serverUrl(): string {
69
+ return this._serverUrl;
70
+ }
71
+
72
+ /**
73
+ * `VisualizeJS` parameters. Changes to these parameters are automatically applied to
74
+ * `Viewer` instances associated with that client.
75
+ */
76
+ get options(): Options {
77
+ return this._options;
78
+ }
79
+
80
+ /**
81
+ * Change the client configuration parameters.
82
+ *
83
+ * @param params - An object containing new configuration parameters.
84
+ * @param params.serverUrl - Open Cloud Server URL.
85
+ * @returns Returns a reference to the `Client`.
86
+ */
87
+ configure(params: { serverUrl?: string }): this {
88
+ this._serverUrl = (params.serverUrl || "").replace(/\/+$/, "");
89
+ this._httpClient = new HttpClient(this.serverUrl);
90
+ this._user = null;
91
+ return this;
92
+ }
93
+
94
+ /**
95
+ * The Object represents server version information.
96
+ *
97
+ * @typedef {any} VersionResult
98
+ * @property {string} version - The server version.
99
+ * @property {string} hash - Build hash.
100
+ */
101
+
102
+ /**
103
+ * Returns server version.
104
+ *
105
+ * @async
106
+ */
107
+ version(): Promise<any> {
108
+ return this._httpClient
109
+ .get("/version")
110
+ .then((response) => response.json())
111
+ .then((data) => ({
112
+ ...data,
113
+ server: data.version,
114
+ client: "CLIENT_JS_VERSION",
115
+ }));
116
+ }
117
+
118
+ /**
119
+ * Register a new user with the specified email and password.
120
+ *
121
+ * @async
122
+ * @param email - User email. Cannot be empty.
123
+ * @param password - User password. Cannot be empty. Password can only contain letters (a-z,
124
+ * A-Z), numbers (0-9), and special characters (~!@#$%^&*()_-+={}[]:;"'`<>,.?|/\ ).
125
+ * @param userName - User name. Cannot be empty or blank if defined. Leave undefined to use
126
+ * `username` from email.
127
+ */
128
+ registerUser(email: string, password: string, userName?: string): Promise<any> {
129
+ return this._httpClient
130
+ .post("/register", {
131
+ email,
132
+ password,
133
+ userName: userName ?? (email + "").split("@").at(0),
134
+ })
135
+ .then((response) => response.json());
136
+ }
137
+
138
+ /**
139
+ * Resend the Confirmation Email to new user. If the user's email is already confirmed, an
140
+ * exception will be thrown.
141
+ *
142
+ * @async
143
+ * @param email - User email.
144
+ * @param password - User password.
145
+ */
146
+ resendConfirmationEmail(email: string, password: string): Promise<any> {
147
+ return this._httpClient
148
+ .post("/register/email-confirmation", { email, password })
149
+ .then((response) => response.json());
150
+ }
151
+
152
+ /**
153
+ * Confirm the user's email. If the user's email is already confirmed, an exception will be thrown.
154
+ *
155
+ * @async
156
+ * @param emailConfirmationId - Confirmation code from the Confirmation Email.
157
+ */
158
+ confirmUserEmail(emailConfirmationId: string): Promise<any> {
159
+ return this._httpClient
160
+ .get(`/register/email-confirmation/${emailConfirmationId}`)
161
+ .then((response) => response.json());
162
+ }
163
+
164
+ /**
165
+ * Log in an existing user using email or user name.
166
+ *
167
+ * @async
168
+ * @param email - An email or user name for authentication request.
169
+ * @param password - Password for authentication request.
170
+ */
171
+ async signInWithEmail(email: string, password: string): Promise<User> {
172
+ const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
173
+ this._httpClient.headers = { Authorization: "Basic " + credentials };
174
+ const data = await json(this._httpClient.get("/token"));
175
+ return this.setCurrentUser(data);
176
+ }
177
+
178
+ /**
179
+ * Log in an existing user using API Key.
180
+ *
181
+ * @async
182
+ * @param token - An access token for authentication request. See
183
+ * {@link User#token | User.token} for more details.
184
+ */
185
+ async signInWithToken(token: string): Promise<User> {
186
+ this._httpClient.headers = { Authorization: token };
187
+ const data = await json(this._httpClient.get("/user"));
188
+ return this.setCurrentUser(data);
189
+ }
190
+
191
+ // Save the current logged in user information for internal use.
192
+
193
+ private setCurrentUser(data: any): User {
194
+ this._user = new User(data, this._httpClient);
195
+ this._httpClient.headers = { Authorization: data.tokenInfo.token };
196
+ this._httpClient.signInUserId = this._user.id;
197
+ return this._user;
198
+ }
199
+
200
+ private clearCurrentUser(): void {
201
+ this._user = null;
202
+ this._httpClient.headers = {};
203
+ this._httpClient.signInUserId = "";
204
+ }
205
+
206
+ /**
207
+ * Returns the current logged in user information. Returns `null` if the user is not logged
208
+ * in or the logged in user has deleted himself.
209
+ */
210
+ getCurrentUser(): User | null {
211
+ if (this._user && !this._httpClient.signInUserId) this._user = null;
212
+ return this._user;
213
+ }
214
+
215
+ /**
216
+ * Returns a list of server users. Only admins can get a list of users, if the current logged
217
+ * in user does not have administrator rights, an exception will be thrown.
218
+ *
219
+ * @async
220
+ */
221
+ getUsers(): Promise<User[]> {
222
+ return json(this._httpClient.get("/users"))
223
+ .then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
224
+ .then((array) => array.map((data) => new User(data, this._httpClient)));
225
+ }
226
+
227
+ /**
228
+ * Returns the user information. Only admins can get other users, if the current logged in
229
+ * user does not have administrator rights, hi can only get himself, otherwise an exception
230
+ * will be thrown.
231
+ *
232
+ * @async
233
+ * @param userId - User ID.
234
+ */
235
+ getUser(userId: string): Promise<User> {
236
+ if (userId === this._httpClient.signInUserId) {
237
+ return json(this._httpClient.get("/user"))
238
+ .then((data) => ({ id: userId, ...data }))
239
+ .then((data) => new User(data, this._httpClient));
240
+ } else {
241
+ return json(this._httpClient.get(`/users/${userId}`))
242
+ .then((data) => ({ id: data.id, ...data.userBrief }))
243
+ .then((data) => new User(data, this._httpClient));
244
+ }
245
+ }
246
+
247
+ /**
248
+ * Create a new user. Only admins can create users, if the current logged in user does not
249
+ * have administrator rights, an exception will be thrown.
250
+ *
251
+ * @async
252
+ * @param email - User email. Cannot be empty.
253
+ * @param password - User password. Cannot be empty. Password can only contain latin letters
254
+ * (a-z, A-Z), numbers (0-9), and special characters (~!@#$%^&*()_-+={}[]:;"'`<>,.?|/\ ).
255
+ * @param params - Additional user data.
256
+ * @param params.isAdmin - `true` if user is an administrator.
257
+ * @param params.userName - User name. Cannot be empty or blank if defined. Leave undefined
258
+ * to use `username` from email.
259
+ * @param params.firstName - First name.
260
+ * @param params.lastName - Last name.
261
+ * @param params.canCreateProject - `true` if user is allowed to create a project.
262
+ * @param params.projectsLimit - The maximum number of projects that the user can create.
263
+ * @param params.storageLimit - The size of the file storage available to the user.
264
+ */
265
+ createUser(
266
+ email: string,
267
+ password: string,
268
+ params: {
269
+ isAdmin?: boolean;
270
+ userName?: string;
271
+ firstName?: string;
272
+ lastName?: string;
273
+ canCreateProject?: boolean;
274
+ projectsLimit?: number;
275
+ storageLimit?: number;
276
+ } = {}
277
+ ): Promise<User> {
278
+ const { isAdmin, userName, ...rest } = params;
279
+ return json(
280
+ this._httpClient.post("/users", {
281
+ isAdmin,
282
+ userBrief: {
283
+ ...rest,
284
+ email,
285
+ userName: userName ?? (email + "").split("@").at(0),
286
+ },
287
+ password,
288
+ })
289
+ )
290
+ .then((data) => ({ id: data.id, ...data.userBrief }))
291
+ .then((data) => new User(data, this._httpClient));
292
+ }
293
+
294
+ /**
295
+ * Delete a user from the server. Only admins can delete users, if the current logged in user
296
+ * does not have administrator rights, an exception will be thrown.
297
+ *
298
+ * Admins can delete themselves or other admins. An admin can only delete himself if he is
299
+ * not the last administrator.
300
+ *
301
+ * You need to re-login to continue working after deleting the current logged in user.
302
+ *
303
+ * @async
304
+ * @param userId - User ID.
305
+ * @returns Returns the raw data of a deleted user.
306
+ */
307
+ deleteUser(userId: string): Promise<any> {
308
+ return json(this._httpClient.delete(`/users/${userId}`)).then((data) => {
309
+ if (userId === this._httpClient.signInUserId) {
310
+ this.clearCurrentUser();
311
+ }
312
+ return data;
313
+ });
314
+ }
315
+
316
+ /**
317
+ * Result for file list.
318
+ *
319
+ * @typedef {any} FilesResult
320
+ * @property {number} allSize - Total number of files the user has access to.
321
+ * @property {number} start - The starting index in the file list in the request.
322
+ * @property {number} limit - The maximum number of requested files.
323
+ * @property {File[]} result - Result file list.
324
+ * @property {number} size - The number of files in the result list.
325
+ */
326
+
327
+ /**
328
+ * Returns a list of files the user has access to.
329
+ *
330
+ * @async
331
+ * @param start - The starting index in the file list. Used for paging.
332
+ * @param limit - The maximum number of files that should be returned per request. Used for paging.
333
+ * @param name - Filter the files by part of the name.
334
+ * @param ext - Filter the files by extension. Extension can be `dgn`, `dwf`, `dwg`, `dxf`,
335
+ * `ifc`, `ifczip`, `nwc`, `nwd`, `obj`, `rcs`, `rfa`, `rvt`, `step`, `stl`, `stp`, `vsf`,
336
+ * or any other drawing or reference file type extension. You can specify multiple
337
+ * extensions on one `string` by separating them with a "|".
338
+ * @param ids - List of file IDs to return. You can specify multiple IDs on one `string` by
339
+ * separating them with a "|".
340
+ * @param sortByDesc - Allows to specify the descending order of the result. By default,
341
+ * files are sorted by name in ascending order.
342
+ * @param {string} sortField - Allows to specify sort field.
343
+ */
344
+ getFiles(
345
+ start?: number,
346
+ limit?: number,
347
+ name?: string,
348
+ ext?: string | string[],
349
+ ids?: string | string[],
350
+ sortByDesc?: boolean,
351
+ sortField?: string
352
+ ): Promise<{ allSize: number; start: number; limit: number; result: File[]; size: number }> {
353
+ const searchParams = new URLSearchParams();
354
+ if (start > 0) searchParams.set("start", start.toString());
355
+ if (limit > 0) searchParams.set("limit", limit.toString());
356
+ if (name) searchParams.set("name", name);
357
+ if (ext) {
358
+ if (Array.isArray(ext)) ext = ext.join("|");
359
+ if (typeof ext === "string") ext = ext.toLowerCase();
360
+ if (ext) searchParams.set("ext", ext);
361
+ }
362
+ if (ids) {
363
+ if (Array.isArray(ids)) ids = ids.join("|");
364
+ searchParams.set("id", ids);
365
+ }
366
+ if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
367
+ if (sortField) searchParams.set("sortField", sortField);
368
+
369
+ let queryString = searchParams.toString();
370
+ if (queryString) queryString = "?" + queryString;
371
+
372
+ return json(this._httpClient.get(`/files${queryString}`)).then((files) => {
373
+ return {
374
+ ...files,
375
+ result: files.result.map((data) => new File(data, this._httpClient)),
376
+ };
377
+ });
378
+ }
379
+
380
+ /**
381
+ * Returns the file information.
382
+ *
383
+ * @async
384
+ * @param fileId - File ID.
385
+ */
386
+ getFile(fileId: string): Promise<File> {
387
+ return json(this._httpClient.get(`/files/${fileId}`)).then((data) => new File(data, this._httpClient));
388
+ }
389
+
390
+ /**
391
+ * Upload a drawing or reference file to the server.
392
+ *
393
+ * Fires:
394
+ *
395
+ * - {@link UploadProgressEvent | uploadprogress}
396
+ *
397
+ * @async
398
+ * @param file - Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
399
+ * target="_blank">File</a> object are generally retrieved from a <a
400
+ * href="https://developer.mozilla.org/docs/Web/API/FileList" target="_blank">FileList</a>
401
+ * object returned as a result of a user selecting files using the HTML `<input>` element.
402
+ * @param params - An object containing upload parameters.
403
+ * @param params.geometry=true - Create job to extract file geometry data. Can be:
404
+ *
405
+ * - `true` - Extract file geometry data into type, defined by [options]{@link Client#options}.
406
+ * - `vsfx` - Extract file geometry data into `VSFX` to open the file in `VisualizeJS` viewer.
407
+ * - `gltf` - Extract file geometry data into `glTF` to open the file in `Three.js` viewer.
408
+ *
409
+ * @param params.properties=false - Create job to extract file properties.
410
+ * @param params.waitForDone=false - Wait for geometry and properties jobs to complete.
411
+ * @param params.timeout - The time, in milliseconds that the function should wait jobs. If
412
+ * no one jobs are done during this time, the `TimeoutError` exception will be thrown.
413
+ * @param params.interval - The time, in milliseconds, the function should delay in between
414
+ * checking jobs status.
415
+ * @param params.signal - An <a
416
+ * href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
417
+ * signal object instance, which can be used to abort waiting as desired.
418
+ * @param params.onProgress - Upload progress callback.
419
+ */
420
+ async uploadFile(
421
+ file: globalThis.File,
422
+ params: {
423
+ geometry?: boolean | string;
424
+ properties?: boolean;
425
+ waitForDone?: boolean;
426
+ timeout?: number;
427
+ interval?: number;
428
+ signal?: AbortSignal;
429
+ onProgress?: (progress: number, file: globalThis.File) => void;
430
+ } = {
431
+ geometry: true,
432
+ properties: false,
433
+ waitForDone: false,
434
+ }
435
+ ): Promise<File> {
436
+ const result = await this._httpClient
437
+ .postFile("/files", file, (progress) => {
438
+ this.emitEvent({ type: "uploadprogress", data: progress, file });
439
+ params.onProgress?.(progress, file);
440
+ })
441
+ .then((xhr: XMLHttpRequest) => JSON.parse(xhr.responseText))
442
+ .then((data) => new File(data, this._httpClient));
443
+
444
+ const geometryType = typeof params.geometry === "string" ? params.geometry : this.options.geometryType;
445
+
446
+ const jobs: string[] = [];
447
+ if (params.geometry) jobs.push((await result.extractGeometry(geometryType)).outputFormat);
448
+ if (params.properties) jobs.push((await result.extractProperties()).outputFormat);
449
+ if (params.waitForDone && jobs.length > 0) await result.waitForDone(jobs, true, params);
450
+
451
+ return result;
452
+ }
453
+
454
+ /**
455
+ * Delete the drawing or reference file from the server.
456
+ *
457
+ * @async
458
+ * @param fileId - File ID.
459
+ * @returns Returns the raw data of a deleted file.
460
+ */
461
+ deleteFile(fileId: string): Promise<any> {
462
+ return json(this._httpClient.delete(`/files/${fileId}`));
463
+ }
464
+
465
+ /**
466
+ * Download the drawing or reference file.
467
+ *
468
+ * @async
469
+ * @param fileId - File ID.
470
+ * @param onProgress - Download progress callback.
471
+ * @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
472
+ * ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
473
+ * and abort it if desired.
474
+ */
475
+ downloadFile(fileId: string, onProgress?: (progress: number) => void, signal?: AbortSignal): Promise<ArrayBuffer> {
476
+ return this._httpClient
477
+ .get(`/files/${fileId}/downloads`, signal)
478
+ .then((response) => downloadProgress(response, onProgress))
479
+ .then((response) => response.arrayBuffer());
480
+ }
481
+
482
+ /**
483
+ * Result for job list.
484
+ *
485
+ * @typedef {any} JobsResult
486
+ * @property {number} allSize - Total number of jobs created by the user.
487
+ * @property {number} start - The starting index in the job list in the request.
488
+ * @property {number} limit - The maximum number of requested jobs.
489
+ * @property {Job[]} result - Result job list.
490
+ * @property {number} size - The number of jobs in the result list.
491
+ */
492
+
493
+ /**
494
+ * Returns a list of jobs created by current user.
495
+ *
496
+ * @async
497
+ * @param status - Filter the jobs by status. Status can be `waiting`, `inpogress`, `done` or
498
+ * `failed`. You can specify multiple statuses on one `string` by separating them with a "|".
499
+ * @param limit - The maximum number of jobs that should be returned per request. Used for paging.
500
+ * @param start - The starting index in the job list. Used for paging.
501
+ * @param sortByDesc - Allows to specify the descending order of the result. By default, jobs
502
+ * are sorted by creation time in ascending order.
503
+ * @param {boolean} sortField - Allows to specify sort field.
504
+ */
505
+ getJobs(
506
+ status?: string | string[],
507
+ limit?: number,
508
+ start?: number,
509
+ sortByDesc?: boolean,
510
+ sortField?: string
511
+ ): Promise<{ allSize: number; start: number; limit: number; result: Job[]; size: number }> {
512
+ const searchParams = new URLSearchParams();
513
+ if (start > 0) searchParams.set("start", start.toString());
514
+ if (limit > 0) searchParams.set("limit", limit.toString());
515
+ if (status) {
516
+ if (Array.isArray(status)) status = status.join("|");
517
+ if (typeof status === "string") status = status.trim().toLowerCase();
518
+ if (status) searchParams.set("status", status);
519
+ }
520
+ if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
521
+ if (sortField) searchParams.set("sortField", sortField);
522
+
523
+ let queryString = searchParams.toString();
524
+ if (queryString) queryString = "?" + queryString;
525
+
526
+ return json(this._httpClient.get(`/jobs${queryString}`)).then((jobs) => ({
527
+ ...jobs,
528
+ result: jobs.result.map((data) => new Job(data, this._httpClient)),
529
+ }));
530
+ }
531
+
532
+ /**
533
+ * Returns the job information.
534
+ *
535
+ * @async
536
+ * @param jobId - Job ID.
537
+ */
538
+ getJob(jobId: string): Promise<Job> {
539
+ return json(this._httpClient.get(`/jobs/${jobId}`)).then((data) => new Job(data, this._httpClient));
540
+ }
541
+
542
+ /**
543
+ * Create a new job.
544
+ *
545
+ * @async
546
+ * @param fileId - File ID.
547
+ * @param outputFormat - The job type. Can be one of:
548
+ *
549
+ * - `geometry` - Extract file geometry data into `VSFX`.
550
+ * - `geometryGltf` - Extract file geometry data into `glTF`.
551
+ * - `properties` - Extract file properties.
552
+ * - `validation` - Validate the file. Only for `IFC`.
553
+ * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the one of the supported format.
554
+ * - Other custom job name. Custom job runner must be registered in the job templates table
555
+ * before creating a job.
556
+ *
557
+ * @param parameters - Parameters for the job runner. Can be given as command line arguments
558
+ * for the File Converter tool in form "--arg=value".
559
+ */
560
+ createJob(fileId: string, outputFormat: string, parameters?: string | object): Promise<Job> {
561
+ return this._httpClient
562
+ .post("/jobs", {
563
+ fileId,
564
+ outputFormat,
565
+ parameters: parseArgs(parameters),
566
+ })
567
+ .then((response) => response.json())
568
+ .then((data) => new Job(data, this._httpClient));
569
+ }
570
+
571
+ /**
572
+ * Remove a job from the server job list. The method does not delete or stop jobs that are
573
+ * already being executed.
574
+ *
575
+ * @async
576
+ * @param jobId - Job ID.
577
+ * @returns Returns the raw data of a deleted job.
578
+ */
579
+ deleteJob(jobId: string): Promise<any> {
580
+ return json(this._httpClient.delete(`/jobs/${jobId}`));
581
+ }
582
+
583
+ /**
584
+ * Result for assembly list.
585
+ *
586
+ * @typedef {any} AssembliesResult
587
+ * @property {number} allSize - Total number of assemblies the user has access to.
588
+ * @property {number} start - The starting index in the assembly list in the request.
589
+ * @property {number} limit - The maximum number of requested assemblies.
590
+ * @property {Assembly[]} result - Result assembly list.
591
+ * @property {number} size - The number of assemblies in the result list.
592
+ */
593
+
594
+ /**
595
+ * Returns a list of assemblies the user has access to.
596
+ *
597
+ * @async
598
+ * @param start - The starting index in the assembly list. Used for paging.
599
+ * @param limit - The maximum number of assemblies that should be returned per request. Used
600
+ * for paging.
601
+ * @param name - Filter the assemblies by part of the name.
602
+ * @param ids - List of assembly IDs to return. You can specify multiple IDs on one `string`
603
+ * by separating them with a "|".
604
+ * @param sortByDesc - Allows to specify the descending order of the result. By default
605
+ * assemblies are sorted by name in ascending order.
606
+ * @param sortField - Allows to specify sort field.
607
+ */
608
+ getAssemblies(
609
+ start?: number,
610
+ limit?: number,
611
+ name?: string,
612
+ ids?: string | string[],
613
+ sortByDesc?: boolean,
614
+ sortField?: string
615
+ ): Promise<{ allSize: number; start: number; limit: number; result: Assembly[]; size: number }> {
616
+ const searchParams = new URLSearchParams();
617
+ if (start > 0) searchParams.set("start", start.toString());
618
+ if (limit > 0) searchParams.set("limit", limit.toString());
619
+ if (name) searchParams.set("name", name);
620
+ if (ids) {
621
+ if (Array.isArray(ids)) ids = ids.join("|");
622
+ if (typeof ids === "string") ids = ids.trim();
623
+ if (ids) searchParams.set("id", ids);
624
+ }
625
+ if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
626
+ if (sortField) searchParams.set("sortField", sortField);
627
+
628
+ let queryString = searchParams.toString();
629
+ if (queryString) queryString = "?" + queryString;
630
+
631
+ return json(this._httpClient.get(`/assemblies${queryString}`)).then((assemblies) => {
632
+ return {
633
+ ...assemblies,
634
+ result: assemblies.result.map((data) => new Assembly(data, this._httpClient)),
635
+ };
636
+ });
637
+ }
638
+
639
+ /**
640
+ * Get assembly information.
641
+ *
642
+ * @async
643
+ * @param assemblyId - Assembly ID.
644
+ */
645
+ getAssembly(assemblyId: string): Promise<Assembly> {
646
+ return json(this._httpClient.get(`/assemblies/${assemblyId}`)).then((data) => new Assembly(data, this._httpClient));
647
+ }
648
+
649
+ /**
650
+ * Create a new assembly.
651
+ *
652
+ * @async
653
+ * @param files - List of file IDs.
654
+ * @param name - Assembly name.
655
+ * @param params - An object containing upload parameters.
656
+ * @param params.waitForDone=false - Wait for assembly to be created.
657
+ */
658
+ createAssembly(
659
+ files: string[],
660
+ name: string,
661
+ params?: {
662
+ waitForDone?: boolean;
663
+ timeout?: number;
664
+ interval?: number;
665
+ signal?: AbortSignal;
666
+ }
667
+ ): Promise<Assembly> {
668
+ const { waitForDone } = params ?? {};
669
+ return this._httpClient
670
+ .post("/assemblies", { name, files })
671
+ .then((response) => response.json())
672
+ .then((data) => new Assembly(data, this._httpClient))
673
+ .then((result) => (waitForDone ? result.waitForDone(params) : result));
674
+ }
675
+
676
+ /**
677
+ * Delete the assembly from the server.
678
+ *
679
+ * @async
680
+ * @param assemblyId - Assembly ID.
681
+ * @returns Returns the raw data of a deleted assembly.
682
+ */
683
+ deleteAssembly(assemblyId: string): Promise<any> {
684
+ return json(this._httpClient.delete(`/assemblies/${assemblyId}`));
685
+ }
686
+
687
+ /**
688
+ * Result for project list.
689
+ *
690
+ * @typedef {any} ProjectsResult
691
+ * @property {number} allSize - Total number of projects the user has access to.
692
+ * @property {number} start - The starting index in the project list in the request.
693
+ * @property {number} limit - The maximum number of requested projects.
694
+ * @property {Project[]} result - Result project list.
695
+ * @property {number} size - The number of projects in the result list.
696
+ */
697
+
698
+ /**
699
+ * Returns a list of projects the user has access to.
700
+ *
701
+ * @async
702
+ * @param start - The starting index in the project list. Used for paging.
703
+ * @param limit - The maximum number of projects that should be returned per request. Used for paging.
704
+ * @param name - Filter the projects by part of the name.
705
+ * @param ids - List of project IDs to return. You can specify multiple IDs on one `string`
706
+ * by separating them with a "|".
707
+ * @param sortByDesc - Allows to specify the descending order of the result. By default
708
+ * projects are sorted by name in ascending order.
709
+ */
710
+ getProjects(
711
+ start?: number,
712
+ limit?: number,
713
+ name?: string,
714
+ ids?: string | string[],
715
+ sortByDesc?: boolean
716
+ ): Promise<{ allSize: number; start: number; limit: number; result: Project[]; size: number }> {
717
+ const searchParams = new URLSearchParams();
718
+ if (start > 0) searchParams.set("start", start.toString());
719
+ if (limit > 0) searchParams.set("limit", limit.toString());
720
+ if (name) searchParams.set("name", name);
721
+ if (ids) {
722
+ if (Array.isArray(ids)) ids = ids.join("|");
723
+ if (typeof ids === "string") ids = ids.trim();
724
+ if (ids) searchParams.set("id", ids);
725
+ }
726
+ if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
727
+
728
+ let queryString = searchParams.toString();
729
+ if (queryString) queryString = "?" + queryString;
730
+ return json(this._httpClient.get(`/projects${queryString}`))
731
+ .then((projects) => {
732
+ // fix for server 23.5 and below
733
+ if (Array.isArray(projects)) {
734
+ let result = projects;
735
+ if (ids) result = result.filter((x) => ids.includes(x.id));
736
+ if (name) result = result.filter((x) => x.name.includes(name));
737
+ if (limit > 0) {
738
+ const begin = start > 0 ? start : 0;
739
+ result = result.slice(begin, begin + limit);
740
+ }
741
+ return {
742
+ allSize: projects.length,
743
+ start,
744
+ limit,
745
+ result,
746
+ size: result.length,
747
+ };
748
+ }
749
+ return projects;
750
+ })
751
+ .then((projects) => {
752
+ return {
753
+ ...projects,
754
+ result: projects.result.map((data) => new Project(data, this._httpClient)),
755
+ };
756
+ });
757
+ }
758
+
759
+ /**
760
+ * Returns the project information.
761
+ *
762
+ * @async
763
+ * @param projectId - Project ID.
764
+ */
765
+ getProject(projectId: string): Promise<Project> {
766
+ return json(this._httpClient.get(`/projects/${projectId}`)).then((data) => new Project(data, this._httpClient));
767
+ }
768
+
769
+ /**
770
+ * Create a new project.
771
+ *
772
+ * @async
773
+ * @param name - Project name.
774
+ * @param description - Project description.
775
+ * @param startDate - Project start date.
776
+ * @param endDate - Project end date.
777
+ * @param avatarUrl - Project preview image URL. Can be <a
778
+ * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
779
+ * target="_blank">Data URL</a>.
780
+ */
781
+ createProject(
782
+ name: string,
783
+ description?: string,
784
+ startDate?: Date | string,
785
+ endDate?: Date | string,
786
+ avatarUrl?: string
787
+ ): Promise<Project> {
788
+ return json(
789
+ this._httpClient.post("/projects", {
790
+ name,
791
+ description,
792
+ startDate: startDate instanceof Date ? startDate.toISOString() : startDate,
793
+ endDate: endDate instanceof Date ? endDate.toISOString() : endDate,
794
+ avatarUrl,
795
+ })
796
+ ).then((data) => new Project(data, this._httpClient));
797
+ }
798
+
799
+ /**
800
+ * Delete the project from the server.
801
+ *
802
+ * @async
803
+ * @param projectId - Project ID.
804
+ * @returns Returns the raw data of a deleted project.
805
+ */
806
+ deleteProject(projectId: string): Promise<any> {
807
+ return text(this._httpClient.delete(`/projects/${projectId}`)).then((text) => {
808
+ // fix for server 23.5 and below
809
+ try {
810
+ return JSON.parse(text);
811
+ } catch {
812
+ return { id: projectId };
813
+ }
814
+ });
815
+ }
816
+ }