@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
@@ -1,13 +1,12 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  import { IGrantedTo } from "./IFile";
3
4
  /**
4
5
  * Provides properties and methods for obtaining information about {@link File | file} actions
5
6
  * granted to a specific user, project, or group.
6
7
  */
7
- export declare class Permission {
8
+ export declare class Permission extends Endpoint {
8
9
  private _data;
9
- fileId: string;
10
- httpClient: IHttpClient;
11
10
  /**
12
11
  * @param data - Raw permission data received from the server. For more information, see
13
12
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}.
@@ -15,14 +14,11 @@ export declare class Permission {
15
14
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
16
15
  */
17
16
  constructor(data: any, fileId: string, httpClient: IHttpClient);
18
- private internalGet;
19
- private internalPut;
20
- private internalDelete;
21
17
  /**
22
18
  * Defines what actions are allowed to be performed on a file with this permission:
23
19
  *
24
20
  * - `read` - The ability to read file description, geometry data and properties.
25
- * - `readSourceFile` - The ability to read source file.
21
+ * - `readSourceFile` - The ability to download source file.
26
22
  * - `write` - The ability to modify file name, description and references.
27
23
  * - `readViewpoint` - The ability to read file viewpoints.
28
24
  * - `createViewpoint` - The ability to create file viewpoints.
@@ -1,4 +1,5 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  import { IShortUserDesc } from "./IUser";
3
4
  import { Role } from "./Role";
4
5
  import { IRoleActions } from "./IRole";
@@ -8,19 +9,14 @@ import { File } from "./File";
8
9
  * Provides properties and methods for obtaining information about a project on the Open Cloud
9
10
  * Server and managing its {@link Role | roles}, {@link Member | members} and models.
10
11
  */
11
- export declare class Project {
12
+ export declare class Project extends Endpoint {
12
13
  private _data;
13
- httpClient: IHttpClient;
14
14
  /**
15
15
  * @param data - Raw project data received from the server. For more information, see
16
16
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
17
17
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
18
18
  */
19
19
  constructor(data: any, httpClient: IHttpClient);
20
- protected internalGet(relativePath: string): Promise<Response>;
21
- protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response>;
22
- protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response>;
23
- protected internalDelete(relativePath: string): Promise<Response>;
24
20
  /**
25
21
  * Project features the user has access to.
26
22
  *
@@ -252,7 +248,7 @@ export declare class Project {
252
248
  * @param actions - Actions are allowed to be performed on a file:
253
249
  *
254
250
  * - `read` - The ability to read file description, geometry data and properties.
255
- * - `readSourceFile` - The ability to read source file.
251
+ * - `readSourceFile` - The ability to download source file.
256
252
  * - `write` - The ability to modify file name, description and references.
257
253
  * - `readViewpoint` - The ability to read file viewpoints.
258
254
  * - `createViewpoint` - The ability to create file viewpoints.
package/lib/Api/Role.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  import { IRoleActions } from "./IRole";
3
4
  /**
4
5
  * A role determines what actions allowed to be performed by {@link User | users} on a
5
6
  * {@link Project | project}.
6
7
  */
7
- export declare class Role {
8
+ export declare class Role extends Endpoint {
8
9
  private _data;
9
10
  projectId: string;
10
- httpClient: IHttpClient;
11
11
  /**
12
12
  * @param data - Raw role data received from the server. For more information, see
13
13
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
@@ -15,9 +15,6 @@ export declare class Role {
15
15
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
16
16
  */
17
17
  constructor(data: any, projectId: string, httpClient: IHttpClient);
18
- private internalGet;
19
- private internalPut;
20
- private internalDelete;
21
18
  /**
22
19
  * Role description.
23
20
  */
@@ -0,0 +1,9 @@
1
+ import { IHttpClient } from "./IHttpClient";
2
+ import { File } from "./File";
3
+ export declare class SharedFile extends File {
4
+ constructor(data: any, password: string, httpClient: IHttpClient);
5
+ checkout(): Promise<this>;
6
+ update(data: any): Promise<this>;
7
+ getVersions(): Promise<undefined>;
8
+ useVersion(version?: number): this;
9
+ }
@@ -0,0 +1,70 @@
1
+ import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
3
+ import { ISharedLinkPermissions } from "./ISharedLink";
4
+ /**
5
+ * Provides properties and methods for obtaining information about a file shared link.
6
+ */
7
+ export declare class SharedLink extends Endpoint {
8
+ private _data;
9
+ /**
10
+ * @param data - Raw shared link data received from the server. For more information, see
11
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
12
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
13
+ */
14
+ constructor(data: any, httpClient: IHttpClient);
15
+ /**
16
+ * Shared link creation time (UTC) in the format specified in
17
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
18
+ *
19
+ * @readonly
20
+ */
21
+ get createdAt(): string;
22
+ /**
23
+ * Raw shared link data received from the server. For more information, see
24
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
25
+ *
26
+ * @readonly
27
+ */
28
+ get data(): any;
29
+ private set data(value);
30
+ /**
31
+ * Share permissions.
32
+ */
33
+ get permissions(): ISharedLinkPermissions;
34
+ set permissions(value: ISharedLinkPermissions);
35
+ /**
36
+ * Unique shared link token.
37
+ *
38
+ * @readonly
39
+ */
40
+ get token(): string;
41
+ /**
42
+ * URL to open shared file in the viewer.
43
+ *
44
+ * @readonly
45
+ */
46
+ get url(): string;
47
+ /**
48
+ * Reloads shared link data from the server.
49
+ */
50
+ checkout(): Promise<this>;
51
+ /**
52
+ * Updates shared link data on the server.
53
+ *
54
+ * @param data - Raw shared link data. For more information, see
55
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
56
+ */
57
+ update(data: any): Promise<this>;
58
+ /**
59
+ * Deletes a shared link from the server.
60
+ *
61
+ * @returns Returns the raw data of a deleted shared link. For more information, see
62
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#SharedLinks | Open Cloud SharedLinks API}.
63
+ */
64
+ delete(): Promise<any>;
65
+ /**
66
+ * Saves shared link properties changes to the server. Call this method to update shared link
67
+ * data on the server after any property changes.
68
+ */
69
+ save(): Promise<this>;
70
+ }
package/lib/Api/User.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  /**
3
4
  * Provides properties and methods for obtaining information about a Open Cloud Server user and
4
5
  * manage its data.
5
6
  */
6
- export declare class User {
7
+ export declare class User extends Endpoint {
7
8
  private _data;
8
- httpClient: IHttpClient;
9
9
  /**
10
10
  * @param data - Raw user data received from the server. For more information, see
11
11
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Users | Open Cloud Users API}.
@@ -1,5 +1,5 @@
1
1
  export declare function $xmlhttp(url: string, params?: {
2
- method: "GET" | "POST" | "PUT" | "DELETE";
2
+ method: "GET" | "POST" | "PUT" | "DELETE" | "HEAD";
3
3
  headers?: HeadersInit;
4
4
  body?: XMLHttpRequestBodyInit;
5
5
  uploadProgress?: (progress: number) => void;
package/lib/index.d.ts CHANGED
@@ -7,15 +7,19 @@ export { FetchError, statusText } from "./Api/FetchError";
7
7
  export { Job } from "./Api/Job";
8
8
  export { IHttpClient } from "./Api/IHttpClient";
9
9
  export { IAssociatedFileData, IClashItem, IModelTransformMatrix } from "./Api/IAssembly";
10
- export { ICdaNode, IFileDataStatus, IFileReference, IFileReferences, IFileStatus, IFileVersionInfo, IGrantedTo, } from "./Api/IFile";
10
+ export * from "./Api/IFile";
11
11
  export { IRoleActions } from "./Api/IRole";
12
+ export * from "./Api/ISharedLink";
12
13
  export { IShortUserDesc } from "./Api/IUser";
13
14
  export { Member } from "./Api/Member";
14
15
  export { Model } from "./Api/Model";
15
16
  export { OAuthClient } from "./Api/OAuthClient";
16
17
  export { Permission } from "./Api/Permission";
17
18
  export { Project } from "./Api/Project";
19
+ export * from "./Api/Endpoint";
18
20
  export { Role } from "./Api/Role";
21
+ export * from "./Api/SharedLink";
22
+ export * from "./Api/SharedFile";
19
23
  export { User } from "./Api/User";
20
24
  export { parseArgs, userFullName, userInitials, waitFor } from "./Api/Utils";
21
25
  export declare const version = "CLIENT_JS_VERSION";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/client",
3
- "version": "25.12.0",
3
+ "version": "26.1.0",
4
4
  "description": "JavaScript REST API client for the Open Cloud Server",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -26,6 +26,6 @@
26
26
  "docs": "typedoc"
27
27
  },
28
28
  "dependencies": {
29
- "@inweb/eventemitter2": "~25.12.0"
29
+ "@inweb/eventemitter2": "~26.1.0"
30
30
  }
31
31
  }
@@ -22,23 +22,23 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import { IHttpClient } from "./IHttpClient";
25
+ import { Endpoint } from "./Endpoint";
25
26
  import { FetchError } from "./FetchError";
26
27
  import { ICdaNode, IFileReferences } from "./IFile";
27
28
  import { IAssociatedFileData, IAssemblyVersionInfo, IModelTransformMatrix } from "./IAssembly";
28
29
  import { IShortUserDesc } from "./IUser";
29
30
  import { Model } from "./Model";
30
31
  import { ClashTest } from "./ClashTest";
32
+ import { ISharedLinkPermissions } from "./ISharedLink";
33
+ import { SharedLink } from "./SharedLink";
31
34
  import { waitFor, userFullName, userInitials } from "./Utils";
32
35
 
33
36
  /**
34
37
  * Provides properties and methods for obtaining information about an assembly on the Open
35
38
  * Cloud Server and managing its data.
36
39
  */
37
- export class Assembly {
40
+ export class Assembly extends Endpoint {
38
41
  private _data: any;
39
- private _useVersion: number | undefined;
40
- public httpClient: IHttpClient;
41
- public path: string;
42
42
 
43
43
  /**
44
44
  * @param data - Raw assembly data received from the server. For more information, see
@@ -46,37 +46,10 @@ export class Assembly {
46
46
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
47
47
  */
48
48
  constructor(data: any, httpClient: IHttpClient) {
49
- this.path = `/assemblies/${data.id}`;
50
- this.httpClient = httpClient;
49
+ super(`/assemblies/${data.id}`, httpClient);
51
50
  this.data = data;
52
51
  }
53
52
 
54
- public appendVersionParam(relativePath: string): string {
55
- if (this._useVersion === undefined) return relativePath;
56
- const delimiter = relativePath.includes("?") ? "&" : "?";
57
- return `${relativePath}${delimiter}version=${this._useVersion}`;
58
- }
59
-
60
- protected internalGet(relativePath: string, signal?: AbortSignal): Promise<Response> {
61
- relativePath = this.appendVersionParam(relativePath);
62
- return this.httpClient.get(`${this.path}${relativePath}`, signal);
63
- }
64
-
65
- protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response> {
66
- relativePath = this.appendVersionParam(relativePath);
67
- return this.httpClient.post(`${this.path}${relativePath}`, body);
68
- }
69
-
70
- protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response> {
71
- relativePath = this.appendVersionParam(relativePath);
72
- return this.httpClient.put(`${this.path}${relativePath}`, body);
73
- }
74
-
75
- protected internalDelete(relativePath: string): Promise<Response> {
76
- relativePath = this.appendVersionParam(relativePath);
77
- return this.httpClient.delete(`${this.path}${relativePath}`);
78
- }
79
-
80
53
  // Reserved for future use
81
54
 
82
55
  get activeVersion(): number {
@@ -224,7 +197,7 @@ export class Assembly {
224
197
  * Reloads assembly data from the server.
225
198
  */
226
199
  async checkout(): Promise<this> {
227
- const response = await this.internalGet("");
200
+ const response = await this.get("");
228
201
  this.data = await response.json();
229
202
  return this;
230
203
  }
@@ -236,7 +209,7 @@ export class Assembly {
236
209
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
237
210
  */
238
211
  async update(data: any): Promise<this> {
239
- const response = await this.internalPut("", data);
212
+ const response = await this.put("", data);
240
213
  this.data = await response.json();
241
214
  return this;
242
215
  }
@@ -247,8 +220,8 @@ export class Assembly {
247
220
  * @returns Returns the raw data of a deleted assembly. For more information, see
248
221
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
249
222
  */
250
- delete(): Promise<any> {
251
- return this.internalDelete("").then((response) => response.json());
223
+ override delete(): Promise<any> {
224
+ return super.delete("").then((response) => response.json());
252
225
  }
253
226
 
254
227
  /**
@@ -275,7 +248,7 @@ export class Assembly {
275
248
  * Returns list of assembly models.
276
249
  */
277
250
  getModels(): Promise<Model[]> {
278
- return this.internalGet("/geometry")
251
+ return this.get("/geometry")
279
252
  .then((response) => response.json())
280
253
  .then((array) => array.map((data: any) => new Model(data, this)));
281
254
  }
@@ -317,7 +290,7 @@ export class Assembly {
317
290
  */
318
291
  getProperties(handles?: string | string[]): Promise<any[]> {
319
292
  const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
320
- return this.internalGet(relativePath).then((response) => response.json());
293
+ return this.get(relativePath).then((response) => response.json());
321
294
  }
322
295
 
323
296
  /**
@@ -346,14 +319,14 @@ export class Assembly {
346
319
  * @param searchPattern - Search pattern or combination of the patterns, see example below.
347
320
  */
348
321
  searchProperties(searchPattern: any): Promise<any[]> {
349
- return this.internalPost("/properties/search", searchPattern).then((response) => response.json());
322
+ return this.post("/properties/search", searchPattern).then((response) => response.json());
350
323
  }
351
324
 
352
325
  /**
353
326
  * Returns the CDA tree for an assembly.
354
327
  */
355
328
  getCdaTree(): Promise<ICdaNode[]> {
356
- return this.internalGet(`/properties/tree`).then((response) => response.json());
329
+ return this.get(`/properties/tree`).then((response) => response.json());
357
330
  }
358
331
 
359
332
  /**
@@ -361,7 +334,7 @@ export class Assembly {
361
334
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}.
362
335
  */
363
336
  getViewpoints(): Promise<any[]> {
364
- return this.internalGet("/viewpoints")
337
+ return this.get("/viewpoints")
365
338
  .then((response) => response.json())
366
339
  .then((viewpoints) => viewpoints.result);
367
340
  }
@@ -373,7 +346,7 @@ export class Assembly {
373
346
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}.
374
347
  */
375
348
  saveViewpoint(viewpoint: any): Promise<any> {
376
- return this.internalPost("/viewpoints", viewpoint).then((response) => response.json());
349
+ return this.post("/viewpoints", viewpoint).then((response) => response.json());
377
350
  }
378
351
 
379
352
  /**
@@ -384,7 +357,7 @@ export class Assembly {
384
357
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#AssemblyViewpoints | Open Cloud Assembly Viewpoints API}.
385
358
  */
386
359
  deleteViewpoint(guid: string): Promise<any> {
387
- return this.internalDelete(`/viewpoints/${guid}`).then((response) => response.json());
360
+ return super.delete(`/viewpoints/${guid}`).then((response) => response.json());
388
361
  }
389
362
 
390
363
  /**
@@ -394,7 +367,7 @@ export class Assembly {
394
367
  * @param guid - Viewpoint GUID.
395
368
  */
396
369
  getSnapshot(guid: string): Promise<string> {
397
- return this.internalGet(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
370
+ return this.get(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
398
371
  }
399
372
 
400
373
  /**
@@ -404,7 +377,7 @@ export class Assembly {
404
377
  * @param bitmapGuid - Bitmap GUID.
405
378
  */
406
379
  getSnapshotData(guid: string, bitmapGuid: string): Promise<string> {
407
- return this.internalGet(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
380
+ return this.get(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
408
381
  }
409
382
 
410
383
  /**
@@ -422,9 +395,8 @@ export class Assembly {
422
395
  onProgress?: (progress: number, chunk: Uint8Array) => void,
423
396
  signal?: AbortSignal
424
397
  ): Promise<ArrayBuffer> {
425
- const relativePath = this.appendVersionParam(`/downloads/${dataId}`);
426
398
  return this.httpClient
427
- .downloadFile(`${this.path}${relativePath}`, onProgress, signal)
399
+ .downloadFile(this.getEndpointPath(`/downloads/${dataId}`), onProgress, { signal, headers: this.headers })
428
400
  .then((response) => response.arrayBuffer());
429
401
  }
430
402
 
@@ -447,9 +419,14 @@ export class Assembly {
447
419
  onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void,
448
420
  signal?: AbortSignal
449
421
  ): Promise<ArrayBuffer> {
450
- const relativePath = this.appendVersionParam(`/downloads/${dataId}?requestId=${requestId}`);
451
422
  return this.httpClient
452
- .downloadFileRange(`${this.path}${relativePath}`, requestId, ranges, onProgress, signal)
423
+ .downloadFileRange(
424
+ this.getEndpointPath(`/downloads/${dataId}?requestId=${requestId}`),
425
+ requestId,
426
+ ranges,
427
+ onProgress,
428
+ { signal, headers: this.headers }
429
+ )
453
430
  .then((response) => response.arrayBuffer());
454
431
  }
455
432
 
@@ -493,10 +470,11 @@ export class Assembly {
493
470
  * signal, which can be used to abort waiting as desired.
494
471
  */
495
472
  async getReferences(signal?: AbortSignal): Promise<IFileReferences> {
473
+ const files = new Endpoint("/files", this.httpClient, this.headers);
496
474
  const references = await Promise.all(
497
475
  this.associatedFiles
498
- .map((file) => `/files/${file.fileId}/references`)
499
- .map((link) => this.httpClient.get(link, signal).then((response) => response.json()))
476
+ .map((file) => `/${file.fileId}/references`)
477
+ .map((link) => files.get(link, signal).then((response) => response.json()))
500
478
  )
501
479
  .then((references) => references.map((x) => x.references))
502
480
  .then((references) => references.reduce((x, v) => [...v, ...x], []))
@@ -567,7 +545,7 @@ export class Assembly {
567
545
  let queryString = searchParams.toString();
568
546
  if (queryString) queryString = "?" + queryString;
569
547
 
570
- return this.internalGet(`/clashes${queryString}`)
548
+ return this.get(`/clashes${queryString}`)
571
549
  .then((response) => response.json())
572
550
  .then((tests) => {
573
551
  return {
@@ -583,7 +561,7 @@ export class Assembly {
583
561
  * @param testId - Test ID.
584
562
  */
585
563
  getClashTest(testId: string): Promise<ClashTest> {
586
- return this.internalGet(`/clashes/${testId}`)
564
+ return this.get(`/clashes/${testId}`)
587
565
  .then((response) => response.json())
588
566
  .then((data) => new ClashTest(data, this.path, this.httpClient));
589
567
  }
@@ -650,7 +628,7 @@ export class Assembly {
650
628
  if (!Array.isArray(selectionSetA)) selectionSetA = [selectionSetA];
651
629
  if (!Array.isArray(selectionSetB)) selectionSetB = [selectionSetB];
652
630
 
653
- return this.internalPost("/clashes", {
631
+ return this.post("/clashes", {
654
632
  name,
655
633
  selectionTypeA,
656
634
  selectionTypeB,
@@ -672,7 +650,7 @@ export class Assembly {
672
650
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
673
651
  */
674
652
  deleteClashTest(testId: string): Promise<any> {
675
- return this.internalDelete(`/clashes/${testId}`).then((response) => response.json());
653
+ return super.delete(`/clashes/${testId}`).then((response) => response.json());
676
654
  }
677
655
 
678
656
  // Reserved for future use
@@ -708,8 +686,17 @@ export class Assembly {
708
686
  return this.update({ activeVersion: version });
709
687
  }
710
688
 
711
- useVersion(version?: number): this {
712
- this._useVersion = undefined;
713
- return this;
689
+ // Reserved for future use
690
+
691
+ async createSharedLink(permissions?: ISharedLinkPermissions): Promise<SharedLink> {
692
+ return Promise.reject(new Error("Assembly shared link will be implemeted in a future release"));
693
+ }
694
+
695
+ async getSharedLink(): Promise<SharedLink> {
696
+ return Promise.resolve(undefined);
697
+ }
698
+
699
+ async deleteSharedLink(): Promise<any> {
700
+ return Promise.reject(new FetchError(404));
714
701
  }
715
702
  }
@@ -22,6 +22,7 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  import { IHttpClient } from "./IHttpClient";
25
+ import { Endpoint } from "./Endpoint";
25
26
  import { IClashItem } from "./IAssembly";
26
27
  import { IShortUserDesc } from "./IUser";
27
28
  import { waitFor, userFullName, userInitials } from "./Utils";
@@ -29,35 +30,20 @@ import { waitFor, userFullName, userInitials } from "./Utils";
29
30
  /**
30
31
  * Provides properties and methods for obtaining information about a file/assembly clash detection test.
31
32
  */
32
- export class ClashTest {
33
+ export class ClashTest extends Endpoint {
33
34
  private _data: any;
34
- public basePath: string;
35
- public httpClient: IHttpClient;
36
35
 
37
36
  /**
38
37
  * @param data - Raw test data received from the server. For more information, see
39
38
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
40
- * @param basePath - The clash test API base path of the file/assembly that owns the test.
39
+ * @param path - The clash test API path of the file/assembly that owns the test.
41
40
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
42
41
  */
43
- constructor(data: any, basePath: string, httpClient: IHttpClient) {
44
- this.httpClient = httpClient;
45
- this.basePath = basePath;
42
+ constructor(data: any, path: string, httpClient: IHttpClient) {
43
+ super(`${path}/clashes/${data.id}`, httpClient);
46
44
  this.data = data;
47
45
  }
48
46
 
49
- protected internalGet(relativePath: string): Promise<Response> {
50
- return this.httpClient.get(`${this.basePath}/clashes/${this.id}${relativePath}`);
51
- }
52
-
53
- protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response> {
54
- return this.httpClient.put(`${this.basePath}/clashes/${this.id}${relativePath}`, body);
55
- }
56
-
57
- protected internalDelete(relativePath: string): Promise<Response> {
58
- return this.httpClient.delete(`${this.basePath}/clashes/${this.id}${relativePath}`);
59
- }
60
-
61
47
  /**
62
48
  * The type of the clashes that the test detects:
63
49
  *
@@ -208,7 +194,7 @@ export class ClashTest {
208
194
  * Reloads test data from the server.
209
195
  */
210
196
  async checkout(): Promise<this> {
211
- const response = await this.internalGet("");
197
+ const response = await this.get("");
212
198
  this.data = await response.json();
213
199
  return this;
214
200
  }
@@ -220,7 +206,7 @@ export class ClashTest {
220
206
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
221
207
  */
222
208
  async update(data: any): Promise<this> {
223
- const response = await this.internalPut("", data);
209
+ const response = await this.put("", data);
224
210
  this.data = await response.json();
225
211
  return this;
226
212
  }
@@ -231,8 +217,8 @@ export class ClashTest {
231
217
  * @returns Returns the raw data of a deleted test. For more information, see
232
218
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
233
219
  */
234
- delete(): Promise<any> {
235
- return this.internalDelete("").then((response) => response.json());
220
+ override delete(): Promise<any> {
221
+ return super.delete("").then((response) => response.json());
236
222
  }
237
223
 
238
224
  /**
@@ -275,6 +261,6 @@ export class ClashTest {
275
261
  * Returns a list of detected clashes for this test.
276
262
  */
277
263
  getReport(): Promise<IClashItem[]> {
278
- return this.internalGet("/report").then((response) => response.json());
264
+ return this.get("/report").then((response) => response.json());
279
265
  }
280
266
  }