@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.
Files changed (50) hide show
  1. package/dist/client.js +618 -322
  2. package/dist/client.js.map +1 -1
  3. package/dist/client.min.js +1 -1
  4. package/dist/client.module.js +393 -312
  5. package/dist/client.module.js.map +1 -1
  6. package/lib/Api/Assembly.d.ts +7 -10
  7. package/lib/Api/ClashTest.d.ts +4 -8
  8. package/lib/Api/Client.d.ts +53 -4
  9. package/lib/Api/Endpoint.d.ts +73 -0
  10. package/lib/Api/Fetch.d.ts +3 -3
  11. package/lib/Api/File.d.ts +32 -14
  12. package/lib/Api/HttpClient.d.ts +7 -7
  13. package/lib/Api/IFile.d.ts +1 -1
  14. package/lib/Api/IHttpClient.d.ts +31 -26
  15. package/lib/Api/ISharedLink.d.ts +36 -0
  16. package/lib/Api/Job.d.ts +2 -5
  17. package/lib/Api/Member.d.ts +2 -6
  18. package/lib/Api/Model.d.ts +2 -4
  19. package/lib/Api/OAuthClient.d.ts +2 -6
  20. package/lib/Api/Permission.d.ts +3 -7
  21. package/lib/Api/Project.d.ts +3 -7
  22. package/lib/Api/Role.d.ts +2 -5
  23. package/lib/Api/SharedFile.d.ts +9 -0
  24. package/lib/Api/SharedLink.d.ts +70 -0
  25. package/lib/Api/User.d.ts +2 -2
  26. package/lib/Api/XMLHttp.d.ts +1 -1
  27. package/lib/index.d.ts +5 -1
  28. package/package.json +2 -2
  29. package/src/Api/Assembly.ts +45 -58
  30. package/src/Api/ClashTest.ts +10 -24
  31. package/src/Api/Client.ts +88 -9
  32. package/src/Api/Endpoint.ts +130 -0
  33. package/src/Api/Fetch.ts +20 -20
  34. package/src/Api/File.ts +101 -75
  35. package/src/Api/HttpClient.ts +40 -17
  36. package/src/Api/IFile.ts +1 -1
  37. package/src/Api/IHttpClient.ts +32 -26
  38. package/src/Api/ISharedLink.ts +63 -0
  39. package/src/Api/Job.ts +7 -19
  40. package/src/Api/Member.ts +7 -21
  41. package/src/Api/Model.ts +4 -7
  42. package/src/Api/OAuthClient.ts +8 -24
  43. package/src/Api/Permission.ts +8 -22
  44. package/src/Api/Project.ts +30 -43
  45. package/src/Api/Role.ts +8 -19
  46. package/src/Api/SharedFile.ts +54 -0
  47. package/src/Api/SharedLink.ts +135 -0
  48. package/src/Api/User.ts +16 -16
  49. package/src/Api/XMLHttp.ts +1 -1
  50. package/src/index.ts +5 -9
@@ -22,6 +22,7 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import { IHttpClient } from "./IHttpClient";
25
+ import { Endpoint } from "./Endpoint";
25
26
  import { IShortUserDesc } from "./IUser";
26
27
  import { Role } from "./Role";
27
28
  import { IRoleActions } from "./IRole";
@@ -33,9 +34,8 @@ import { userFullName, userInitials } from "./Utils";
33
34
  * Provides properties and methods for obtaining information about a project on the Open Cloud
34
35
  * Server and managing its {@link Role | roles}, {@link Member | members} and models.
35
36
  */
36
- export class Project {
37
+ export class Project extends Endpoint {
37
38
  private _data: any;
38
- public httpClient: IHttpClient;
39
39
 
40
40
  /**
41
41
  * @param data - Raw project data received from the server. For more information, see
@@ -43,26 +43,10 @@ export class Project {
43
43
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
44
44
  */
45
45
  constructor(data: any, httpClient: IHttpClient) {
46
- this.httpClient = httpClient;
46
+ super(`/projects/${data.id}`, httpClient);
47
47
  this.data = data;
48
48
  }
49
49
 
50
- protected internalGet(relativePath: string): Promise<Response> {
51
- return this.httpClient.get(`/projects/${this.id}${relativePath}`);
52
- }
53
-
54
- protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response> {
55
- return this.httpClient.post(`/projects/${this.id}${relativePath}`, body);
56
- }
57
-
58
- protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response> {
59
- return this.httpClient.put(`/projects/${this.id}${relativePath}`, body);
60
- }
61
-
62
- protected internalDelete(relativePath: string): Promise<Response> {
63
- return this.httpClient.delete(`/projects/${this.id}${relativePath}`);
64
- }
65
-
66
50
  /**
67
51
  * Project features the user has access to.
68
52
  *
@@ -248,7 +232,7 @@ export class Project {
248
232
  * Reloads project data from the server.
249
233
  */
250
234
  async checkout(): Promise<this> {
251
- const response = await this.internalGet("");
235
+ const response = await this.get("");
252
236
  this.data = await response.json();
253
237
  return this;
254
238
  }
@@ -260,7 +244,7 @@ export class Project {
260
244
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
261
245
  */
262
246
  async update(data: any): Promise<this> {
263
- const response = await this.internalPut("", data);
247
+ const response = await this.put("", data);
264
248
  this.data = await response.json();
265
249
  return this;
266
250
  }
@@ -271,8 +255,9 @@ export class Project {
271
255
  * @returns Returns the raw data of a deleted project. For more information, see
272
256
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
273
257
  */
274
- delete(): Promise<any> {
275
- return this.internalDelete("")
258
+ override delete(): Promise<any> {
259
+ return super
260
+ .delete("")
276
261
  .then((response) => response.text())
277
262
  .then((text) => {
278
263
  // TODO fix for server 23.5 and below
@@ -308,7 +293,7 @@ export class Project {
308
293
  if (!image) {
309
294
  await this.deletePreview();
310
295
  } else {
311
- const response = await this.internalPost("/preview", image);
296
+ const response = await this.post("/preview", image);
312
297
  this.data = await response.json();
313
298
  }
314
299
  return this;
@@ -318,7 +303,7 @@ export class Project {
318
303
  * Removes the project preview.
319
304
  */
320
305
  async deletePreview(): Promise<this> {
321
- const response = await this.internalDelete("/preview");
306
+ const response = await super.delete("/preview");
322
307
  this.data = await response.json();
323
308
  return this;
324
309
  }
@@ -328,7 +313,7 @@ export class Project {
328
313
  * role they have in a project.
329
314
  */
330
315
  getRoles(): Promise<Role[]> {
331
- return this.internalGet("/roles")
316
+ return this.get("/roles")
332
317
  .then((response) => response.json())
333
318
  .then((array) => array.map((data) => new Role(data, this.id, this.httpClient)));
334
319
  }
@@ -339,7 +324,7 @@ export class Project {
339
324
  * @param name - Role name.
340
325
  */
341
326
  getRole(name: string): Promise<Role> {
342
- return this.internalGet(`/roles/${name}`)
327
+ return this.get(`/roles/${name}`)
343
328
  .then((response) => response.json())
344
329
  .then((data) => new Role(data, this.id, this.httpClient));
345
330
  }
@@ -352,7 +337,7 @@ export class Project {
352
337
  * @param permissions - Actions are allowed to be performed for the role.
353
338
  */
354
339
  createRole(name: string, description: string, permissions: IRoleActions): Promise<Role> {
355
- return this.internalPost("/roles", {
340
+ return this.post("/roles", {
356
341
  name,
357
342
  description,
358
343
  permissions: permissions || {},
@@ -369,14 +354,14 @@ export class Project {
369
354
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
370
355
  */
371
356
  deleteRole(name: string): Promise<any> {
372
- return this.internalDelete(`/roles/${name}`).then((response) => response.json());
357
+ return super.delete(`/roles/${name}`).then((response) => response.json());
373
358
  }
374
359
 
375
360
  /**
376
361
  * Returns a list of project members.
377
362
  */
378
363
  getMembers(): Promise<Member[]> {
379
- return this.internalGet("/members")
364
+ return this.get("/members")
380
365
  .then((response) => response.json())
381
366
  .then((array) => array.map((data) => new Member(data, this.id, this.httpClient)));
382
367
  }
@@ -387,7 +372,7 @@ export class Project {
387
372
  * @param memberId - Member ID.
388
373
  */
389
374
  getMember(memberId: string): Promise<Member> {
390
- return this.internalGet(`/members/${memberId}`)
375
+ return this.get(`/members/${memberId}`)
391
376
  .then((response) => response.json())
392
377
  .then((data) => new Member(data, this.id, this.httpClient));
393
378
  }
@@ -399,7 +384,7 @@ export class Project {
399
384
  * @param role - Role name from the list of project {@link getRoles | roles}.
400
385
  */
401
386
  addMember(userId: string, role: string): Promise<Member> {
402
- return this.internalPost("/members", { userId, role })
387
+ return this.post("/members", { userId, role })
403
388
  .then((response) => response.json())
404
389
  .then((data) => new Member(data, this.id, this.httpClient));
405
390
  }
@@ -412,7 +397,7 @@ export class Project {
412
397
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
413
398
  */
414
399
  removeMember(memberId: string): Promise<any> {
415
- return this.internalDelete(`/members/${memberId}`).then((response) => response.json());
400
+ return super.delete(`/members/${memberId}`).then((response) => response.json());
416
401
  }
417
402
 
418
403
  /**
@@ -437,8 +422,9 @@ export class Project {
437
422
  * {@link File.createPermission | File.createPermission()}.
438
423
  */
439
424
  getFilesInformation(): Promise<any[]> {
440
- return this.httpClient
441
- .get(`/bcf/3.0/projects/${this.data.id}/files_information`)
425
+ const bcfProjects = new Endpoint("/bcf/3.0/projects", this.httpClient, this.headers);
426
+ return bcfProjects
427
+ .get(`/${this.id}/files_information`)
442
428
  .then((response) => response.json())
443
429
  .then((items) => {
444
430
  items.forEach((item) => {
@@ -496,9 +482,8 @@ export class Project {
496
482
  return this.getFilesInformation()
497
483
  .then((filesInformation) => filesInformation.map((item) => item.file.reference))
498
484
  .then((ids) => {
499
- const searchParams = new URLSearchParams();
500
- searchParams.set("id", ids.join("|"));
501
- return this.httpClient.get(`/files?${searchParams.toString()}`);
485
+ const files = new Endpoint("/files", this.httpClient, this.headers);
486
+ return files.get(`?id=${ids.join("|")}`);
502
487
  })
503
488
  .then((response) => response.json())
504
489
  .then((files) => files.result.map((data) => new File(data, this.httpClient)));
@@ -513,7 +498,7 @@ export class Project {
513
498
  * @param actions - Actions are allowed to be performed on a file:
514
499
  *
515
500
  * - `read` - The ability to read file description, geometry data and properties.
516
- * - `readSourceFile` - The ability to read source file.
501
+ * - `readSourceFile` - The ability to download source file.
517
502
  * - `write` - The ability to modify file name, description and references.
518
503
  * - `readViewpoint` - The ability to read file viewpoints.
519
504
  * - `createViewpoint` - The ability to create file viewpoints.
@@ -522,8 +507,9 @@ export class Project {
522
507
  * @returns Returns a file instance added to the project.
523
508
  */
524
509
  async addModel(fileId: string, actions: string | string[], _public: boolean): Promise<File> {
525
- const file = await this.httpClient
526
- .get(`/files/${fileId}`)
510
+ const files = new Endpoint("/files", this.httpClient, this.headers);
511
+ const file = await files
512
+ .get(`/${fileId}`)
527
513
  .then((response) => response.json())
528
514
  .then((data) => new File(data, this.httpClient));
529
515
 
@@ -540,8 +526,9 @@ export class Project {
540
526
  * @returns Returns a file instance removed from the project.
541
527
  */
542
528
  async removeModel(fileId: string): Promise<File> {
543
- const file = await this.httpClient
544
- .get(`/files/${fileId}`)
529
+ const files = new Endpoint("/files", this.httpClient, this.headers);
530
+ const file = await files
531
+ .get(`/${fileId}`)
545
532
  .then((response) => response.json())
546
533
  .then((data) => new File(data, this.httpClient));
547
534
 
package/src/Api/Role.ts CHANGED
@@ -22,16 +22,16 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import { IHttpClient } from "./IHttpClient";
25
+ import { Endpoint } from "./Endpoint";
25
26
  import { IRoleActions } from "./IRole";
26
27
 
27
28
  /**
28
29
  * A role determines what actions allowed to be performed by {@link User | users} on a
29
30
  * {@link Project | project}.
30
31
  */
31
- export class Role {
32
+ export class Role extends Endpoint {
32
33
  private _data: any;
33
34
  public projectId: string;
34
- public httpClient: IHttpClient;
35
35
 
36
36
  /**
37
37
  * @param data - Raw role data received from the server. For more information, see
@@ -40,23 +40,11 @@ export class Role {
40
40
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
41
41
  */
42
42
  constructor(data: any, projectId: string, httpClient: IHttpClient) {
43
- this.httpClient = httpClient;
43
+ super("", httpClient);
44
44
  this.projectId = projectId;
45
45
  this.data = data;
46
46
  }
47
47
 
48
- private internalGet(): Promise<Response> {
49
- return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`);
50
- }
51
-
52
- private internalPut(body?: BodyInit | object): Promise<Response> {
53
- return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`, body);
54
- }
55
-
56
- private internalDelete(): Promise<Response> {
57
- return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`);
58
- }
59
-
60
48
  /**
61
49
  * Role description.
62
50
  */
@@ -80,6 +68,7 @@ export class Role {
80
68
 
81
69
  set data(value: any) {
82
70
  this._data = value;
71
+ this.path = `/projects/${this.projectId}/roles/${value.name}`;
83
72
  }
84
73
 
85
74
  /**
@@ -108,7 +97,7 @@ export class Role {
108
97
  * Reloads role data from the server.
109
98
  */
110
99
  async checkout(): Promise<this> {
111
- const response = await this.internalGet();
100
+ const response = await this.get("");
112
101
  this.data = await response.json();
113
102
  return this;
114
103
  }
@@ -120,7 +109,7 @@ export class Role {
120
109
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
121
110
  */
122
111
  async update(data: any): Promise<this> {
123
- const response = await this.internalPut(data);
112
+ const response = await this.put("", data);
124
113
  this.data = await response.json();
125
114
  return this;
126
115
  }
@@ -131,8 +120,8 @@ export class Role {
131
120
  * @returns Returns the raw data of a deleted role. For more information, see
132
121
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
133
122
  */
134
- delete(): Promise<any> {
135
- return this.internalDelete().then((response) => response.json());
123
+ override delete(): Promise<any> {
124
+ return super.delete("").then((response) => response.json());
136
125
  }
137
126
 
138
127
  /**
@@ -0,0 +1,54 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { IHttpClient } from "./IHttpClient";
25
+ import { File } from "./File";
26
+
27
+ export class SharedFile extends File {
28
+ constructor(data: any, password: string, httpClient: IHttpClient) {
29
+ super(data.file, httpClient);
30
+ this.path = `/shares/${data.file.sharedLinkToken}`;
31
+ this.headers = { "InWeb-Password": password };
32
+ }
33
+
34
+ override async checkout(): Promise<this> {
35
+ const response = await this.get("/info");
36
+ const data = await response.json();
37
+ this.data = data.file;
38
+ return this;
39
+ }
40
+
41
+ override async update(data: any): Promise<this> {
42
+ const response = await this.put("/info", data);
43
+ this.data = await response.json();
44
+ return this;
45
+ }
46
+
47
+ override getVersions(): Promise<undefined> {
48
+ return Promise.resolve(undefined);
49
+ }
50
+
51
+ override useVersion(version?: number): this {
52
+ return this;
53
+ }
54
+ }
@@ -0,0 +1,135 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2024, 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-2024 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 { IHttpClient } from "./IHttpClient";
25
+ import { Endpoint } from "./Endpoint";
26
+ import { ISharedLinkPermissions } from "./ISharedLink";
27
+
28
+ /**
29
+ * Provides properties and methods for obtaining information about a file shared link.
30
+ */
31
+ export class SharedLink extends Endpoint {
32
+ private _data: any;
33
+
34
+ /**
35
+ * @param data - Raw shared link data received from the server. For more information, see
36
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
37
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
38
+ */
39
+ constructor(data: any, httpClient: IHttpClient) {
40
+ super(`/shares/${data.token}`, httpClient);
41
+ this.data = data;
42
+ }
43
+
44
+ /**
45
+ * Shared link creation time (UTC) in the format specified in
46
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
47
+ *
48
+ * @readonly
49
+ */
50
+ get createdAt(): string {
51
+ return this.data.createdAt;
52
+ }
53
+
54
+ /**
55
+ * Raw shared link data received from the server. For more information, see
56
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
57
+ *
58
+ * @readonly
59
+ */
60
+ get data(): any {
61
+ return this._data;
62
+ }
63
+
64
+ private set data(value: any) {
65
+ this._data = value;
66
+ }
67
+
68
+ /**
69
+ * Share permissions.
70
+ */
71
+ get permissions(): ISharedLinkPermissions {
72
+ return this.data.permissions;
73
+ }
74
+
75
+ set permissions(value: ISharedLinkPermissions) {
76
+ this.data.permissions = { ...this.data.permissions, ...value };
77
+ }
78
+
79
+ /**
80
+ * Unique shared link token.
81
+ *
82
+ * @readonly
83
+ */
84
+ get token(): string {
85
+ return this.data.token;
86
+ }
87
+
88
+ /**
89
+ * URL to open shared file in the viewer.
90
+ *
91
+ * @readonly
92
+ */
93
+ get url(): string {
94
+ return this.data.url;
95
+ }
96
+
97
+ /**
98
+ * Reloads shared link data from the server.
99
+ */
100
+ async checkout(): Promise<this> {
101
+ const response = await this.get("");
102
+ this.data = await response.json();
103
+ return this;
104
+ }
105
+
106
+ /**
107
+ * Updates shared link data on the server.
108
+ *
109
+ * @param data - Raw shared link data. For more information, see
110
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
111
+ */
112
+ async update(data: any): Promise<this> {
113
+ const response = await this.put("", data);
114
+ this.data = await response.json();
115
+ return this;
116
+ }
117
+
118
+ /**
119
+ * Deletes a shared link from the server.
120
+ *
121
+ * @returns Returns the raw data of a deleted shared link. For more information, see
122
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#SharedLinks | Open Cloud SharedLinks API}.
123
+ */
124
+ override delete(): Promise<any> {
125
+ return super.delete("").then((response) => response.json());
126
+ }
127
+
128
+ /**
129
+ * Saves shared link properties changes to the server. Call this method to update shared link
130
+ * data on the server after any property changes.
131
+ */
132
+ save(): Promise<this> {
133
+ return this.update(this.data);
134
+ }
135
+ }
package/src/Api/User.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import { IHttpClient } from "./IHttpClient";
25
+ import { Endpoint } from "./Endpoint";
25
26
  import { FetchError } from "./FetchError";
26
27
  import { userFullName, userInitials } from "./Utils";
27
28
 
@@ -29,9 +30,8 @@ import { userFullName, userInitials } from "./Utils";
29
30
  * Provides properties and methods for obtaining information about a Open Cloud Server user and
30
31
  * manage its data.
31
32
  */
32
- export class User {
33
+ export class User extends Endpoint {
33
34
  private _data: any;
34
- public httpClient: IHttpClient;
35
35
 
36
36
  /**
37
37
  * @param data - Raw user data received from the server. For more information, see
@@ -39,7 +39,7 @@ export class User {
39
39
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
40
40
  */
41
41
  constructor(data: any, httpClient: IHttpClient) {
42
- this.httpClient = httpClient;
42
+ super("", httpClient);
43
43
  this.data = data;
44
44
  }
45
45
 
@@ -293,11 +293,11 @@ export class User {
293
293
  */
294
294
  async checkout(): Promise<this> {
295
295
  if (this.httpClient.signInUserIsAdmin) {
296
- const response = await this.httpClient.get(`/users/${this.id}`);
296
+ const response = await this.get(`/users/${this.id}`);
297
297
  const data = await response.json();
298
298
  this.data = { id: data.id, ...data.userBrief };
299
299
  } else if (this.id === this.httpClient.signInUserId) {
300
- const response = await this.httpClient.get("/user");
300
+ const response = await this.get("/user");
301
301
  const data = await response.json();
302
302
  this.data = { id: this.id, ...data };
303
303
  } else {
@@ -317,11 +317,11 @@ export class User {
317
317
  */
318
318
  async update(data: any): Promise<this> {
319
319
  if (this.httpClient.signInUserIsAdmin) {
320
- const response = await this.httpClient.put(`/users/${this.id}`, { isAdmin: data.isAdmin, userBrief: data });
320
+ const response = await this.put(`/users/${this.id}`, { isAdmin: data.isAdmin, userBrief: data });
321
321
  const newData = await response.json();
322
322
  this.data = { id: newData.id, ...newData.userBrief };
323
323
  } else if (this.id === this.httpClient.signInUserId) {
324
- const response = await this.httpClient.put("/user", data);
324
+ const response = await this.put("/user", data);
325
325
  const newData = await response.json();
326
326
  this.data = { id: this.id, ...newData };
327
327
  } else {
@@ -344,14 +344,14 @@ export class User {
344
344
  * @returns Returns the raw data of a deleted user. For more information, see
345
345
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Users | Open Cloud Users API}.
346
346
  */
347
- delete(): Promise<any> {
347
+ override delete(): Promise<any> {
348
348
  if (this.httpClient.signInUserIsAdmin) {
349
- return this.httpClient
349
+ return super
350
350
  .delete(`/users/${this.id}`)
351
351
  .then((response) => response.json())
352
352
  .then((data) => {
353
353
  if (this.id === this.httpClient.signInUserId) {
354
- this.httpClient.headers = {};
354
+ delete this.httpClient.headers["Authorization"];
355
355
  this.httpClient.signInUserId = "";
356
356
  this.httpClient.signInUserIsAdmin = false;
357
357
  }
@@ -388,11 +388,11 @@ export class User {
388
388
  if (!image) {
389
389
  await this.deleteAvatar();
390
390
  } else if (this.httpClient.signInUserIsAdmin) {
391
- const response = await this.httpClient.post(`/users/${this.id}/avatar`, image);
391
+ const response = await this.post(`/users/${this.id}/avatar`, image);
392
392
  const data = await response.json();
393
393
  this.data = { id: data.id, ...data.userBrief };
394
394
  } else if (this.id === this.httpClient.signInUserId) {
395
- const response = await this.httpClient.post("/user/avatar", image);
395
+ const response = await this.post("/user/avatar", image);
396
396
  const data = await response.json();
397
397
  this.data = { id: this.id, ...data };
398
398
  } else {
@@ -409,11 +409,11 @@ export class User {
409
409
  */
410
410
  async deleteAvatar(): Promise<this> {
411
411
  if (this.httpClient.signInUserIsAdmin) {
412
- const response = await this.httpClient.delete(`/users/${this.id}/avatar`);
412
+ const response = await super.delete(`/users/${this.id}/avatar`);
413
413
  const data = await response.json();
414
414
  this.data = { id: data.id, ...data.userBrief };
415
415
  } else if (this.id === this.httpClient.signInUserId) {
416
- const response = await this.httpClient.delete("/user/avatar");
416
+ const response = await super.delete("/user/avatar");
417
417
  const data = await response.json();
418
418
  this.data = { id: this.id, ...data };
419
419
  } else {
@@ -437,11 +437,11 @@ export class User {
437
437
  */
438
438
  async changePassword(newPassword: string, oldPassword?: string): Promise<this> {
439
439
  if (this.httpClient.signInUserIsAdmin) {
440
- const response = await this.httpClient.put(`/users/${this.id}/password`, { new: newPassword });
440
+ const response = await this.put(`/users/${this.id}/password`, { new: newPassword });
441
441
  const data = await response.json();
442
442
  this.data = { id: data.id, ...data.userBrief };
443
443
  } else if (this.id === this.httpClient.signInUserId) {
444
- const response = await this.httpClient.put("/user/password", { old: oldPassword, new: newPassword });
444
+ const response = await this.put("/user/password", { old: oldPassword, new: newPassword });
445
445
  const data = await response.json();
446
446
  this.data = { id: this.id, ...data };
447
447
  } else {
@@ -48,7 +48,7 @@ function handleXMLHttpError(xhr: XMLHttpRequest): Promise<XMLHttpRequest> {
48
48
  export function $xmlhttp(
49
49
  url: string,
50
50
  params: {
51
- method: "GET" | "POST" | "PUT" | "DELETE";
51
+ method: "GET" | "POST" | "PUT" | "DELETE" | "HEAD";
52
52
  headers?: HeadersInit;
53
53
  body?: XMLHttpRequestBodyInit;
54
54
  uploadProgress?: (progress: number) => void;
package/src/index.ts CHANGED
@@ -30,23 +30,19 @@ export { FetchError, statusText } from "./Api/FetchError";
30
30
  export { Job } from "./Api/Job";
31
31
  export { IHttpClient } from "./Api/IHttpClient";
32
32
  export { IAssociatedFileData, IClashItem, IModelTransformMatrix } from "./Api/IAssembly";
33
- export {
34
- ICdaNode,
35
- IFileDataStatus,
36
- IFileReference,
37
- IFileReferences,
38
- IFileStatus,
39
- IFileVersionInfo,
40
- IGrantedTo,
41
- } from "./Api/IFile";
33
+ export * from "./Api/IFile";
42
34
  export { IRoleActions } from "./Api/IRole";
35
+ export * from "./Api/ISharedLink";
43
36
  export { IShortUserDesc } from "./Api/IUser";
44
37
  export { Member } from "./Api/Member";
45
38
  export { Model } from "./Api/Model";
46
39
  export { OAuthClient } from "./Api/OAuthClient";
47
40
  export { Permission } from "./Api/Permission";
48
41
  export { Project } from "./Api/Project";
42
+ export * from "./Api/Endpoint";
49
43
  export { Role } from "./Api/Role";
44
+ export * from "./Api/SharedLink";
45
+ export * from "./Api/SharedFile";
50
46
  export { User } from "./Api/User";
51
47
  export { parseArgs, userFullName, userInitials, waitFor } from "./Api/Utils";
52
48