@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,29 +1,24 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  import { ICdaNode, IFileReferences } from "./IFile";
3
4
  import { IAssociatedFileData, IAssemblyVersionInfo, IModelTransformMatrix } from "./IAssembly";
4
5
  import { IShortUserDesc } from "./IUser";
5
6
  import { Model } from "./Model";
6
7
  import { ClashTest } from "./ClashTest";
8
+ import { ISharedLinkPermissions } from "./ISharedLink";
9
+ import { SharedLink } from "./SharedLink";
7
10
  /**
8
11
  * Provides properties and methods for obtaining information about an assembly on the Open
9
12
  * Cloud Server and managing its data.
10
13
  */
11
- export declare class Assembly {
14
+ export declare class Assembly extends Endpoint {
12
15
  private _data;
13
- private _useVersion;
14
- httpClient: IHttpClient;
15
- path: string;
16
16
  /**
17
17
  * @param data - Raw assembly data received from the server. For more information, see
18
18
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
19
19
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
20
20
  */
21
21
  constructor(data: any, httpClient: IHttpClient);
22
- appendVersionParam(relativePath: string): string;
23
- protected internalGet(relativePath: string, signal?: AbortSignal): Promise<Response>;
24
- protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response>;
25
- protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response>;
26
- protected internalDelete(relativePath: string): Promise<Response>;
27
22
  get activeVersion(): number;
28
23
  /**
29
24
  * List of unique files from which the assembly was created.
@@ -381,5 +376,7 @@ export declare class Assembly {
381
376
  getVersion(version: number): Promise<Assembly>;
382
377
  deleteVersion(version: number): Promise<any>;
383
378
  setActiveVersion(version: number): Promise<this>;
384
- useVersion(version?: number): this;
379
+ createSharedLink(permissions?: ISharedLinkPermissions): Promise<SharedLink>;
380
+ getSharedLink(): Promise<SharedLink>;
381
+ deleteSharedLink(): Promise<any>;
385
382
  }
@@ -1,23 +1,19 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  import { IClashItem } from "./IAssembly";
3
4
  import { IShortUserDesc } from "./IUser";
4
5
  /**
5
6
  * Provides properties and methods for obtaining information about a file/assembly clash detection test.
6
7
  */
7
- export declare class ClashTest {
8
+ export declare class ClashTest extends Endpoint {
8
9
  private _data;
9
- basePath: string;
10
- httpClient: IHttpClient;
11
10
  /**
12
11
  * @param data - Raw test data received from the server. For more information, see
13
12
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Assemblies | Open Cloud Assemblies API}.
14
- * @param basePath - The clash test API base path of the file/assembly that owns the test.
13
+ * @param path - The clash test API path of the file/assembly that owns the test.
15
14
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
16
15
  */
17
- constructor(data: any, basePath: string, httpClient: IHttpClient);
18
- protected internalGet(relativePath: string): Promise<Response>;
19
- protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response>;
20
- protected internalDelete(relativePath: string): Promise<Response>;
16
+ constructor(data: any, path: string, httpClient: IHttpClient);
21
17
  /**
22
18
  * The type of the clashes that the test detects:
23
19
  *
@@ -7,6 +7,8 @@ import { Job } from "./Job";
7
7
  import { Project } from "./Project";
8
8
  import { User } from "./User";
9
9
  import { OAuthClient } from "./OAuthClient";
10
+ import { ISharedLinkPermissions } from "./ISharedLink";
11
+ import { SharedLink } from "./SharedLink";
10
12
  /**
11
13
  * Provides methods for managing Open Cloud Server resources such as users, files, assemblies,
12
14
  * jobs, projects, etc.
@@ -18,7 +20,7 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
18
20
  eventEmitter: EventEmitter2;
19
21
  /**
20
22
  * @param params - An object containing client configuration parameters.
21
- * @param params.serverUrl - Open Cloud Server REST API base URL.
23
+ * @param params.serverUrl - Open Cloud REST API server URL.
22
24
  * @param params.url - Deprecated since `25.8`. Use `serverUrl` instead.
23
25
  */
24
26
  constructor(params?: {
@@ -26,7 +28,7 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
26
28
  url?: string;
27
29
  });
28
30
  /**
29
- * Open Cloud REST API server base URL. Use {@link configure | configure()} to change server URL.
31
+ * Open Cloud REST API server URL. Use {@link configure | configure()} to change server URL.
30
32
  *
31
33
  * @readonly
32
34
  */
@@ -49,7 +51,7 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
49
51
  * After changing the parameters, you must re-login.
50
52
  *
51
53
  * @param params - An object containing new parameters.
52
- * @param params.serverUrl - Open Cloud Server REST API base URL.
54
+ * @param params.serverUrl - Open Cloud REST API server URL.
53
55
  */
54
56
  configure(params: {
55
57
  serverUrl?: string;
@@ -104,6 +106,13 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
104
106
  * @param token - An access token for authentication request. See {@link User.token} for more details.
105
107
  */
106
108
  signInWithToken(token: string): Promise<User>;
109
+ /**
110
+ * Log out.
111
+ *
112
+ * You must log in again using {@link signInWithEmail} or {@link signInWithToken} to continue
113
+ * making requests to the server
114
+ */
115
+ signOut(): void;
107
116
  private setCurrentUser;
108
117
  private clearCurrentUser;
109
118
  /**
@@ -277,8 +286,9 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
277
286
  * @param sortByDesc - Allows to specify the descending order of the result. By default,
278
287
  * files are sorted by name in ascending order.
279
288
  * @param sortField - Allows to specify sort field.
289
+ * @param shared - Returns shared files only.
280
290
  */
281
- getFiles(start?: number, limit?: number, name?: string, ext?: string | string[], ids?: string | string[], sortByDesc?: boolean, sortField?: string): Promise<{
291
+ getFiles(start?: number, limit?: number, name?: string, ext?: string | string[], ids?: string | string[], sortByDesc?: boolean, sortField?: string, shared?: boolean): Promise<{
282
292
  result: File[];
283
293
  start: number;
284
294
  limit: number;
@@ -527,4 +537,43 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
527
537
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
528
538
  */
529
539
  deleteProject(projectId: string): Promise<any>;
540
+ /**
541
+ * Returns information about the specified file shared link.
542
+ *
543
+ * @param token - Shared link token.
544
+ */
545
+ getSharedLink(token: string): Promise<SharedLink>;
546
+ /**
547
+ * Creates a shared link for the specified file.
548
+ *
549
+ * @param fileId - File ID.
550
+ * @param permissions - Share permissions.
551
+ */
552
+ createSharedLink(fileId: string, permissions?: ISharedLinkPermissions): Promise<SharedLink>;
553
+ /**
554
+ * Deletes the specified shared link.
555
+ *
556
+ * Only file owner can delete shared link. If the current logged in user is not a file owner,
557
+ * an exception will be thrown.
558
+ *
559
+ * @param token - Shared link token.
560
+ * @returns Returns the raw data of a deleted shared link. For more information, see
561
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
562
+ */
563
+ deleteSharedLink(token: string): Promise<any>;
564
+ /**
565
+ * Returns information about a file from a shared link.
566
+ *
567
+ * Some file features are not available via shared link:
568
+ *
569
+ * - Updating file properties, preview, and viewpoints
570
+ * - Running file jobs
571
+ * - Managing file permissions
572
+ * - Managing file versions
573
+ * - Deleting file
574
+ *
575
+ * @param token - Shared link token.
576
+ * @param password - Password to get access to the file.
577
+ */
578
+ getSharedFile(token: string, password?: string): Promise<File>;
530
579
  }
@@ -0,0 +1,73 @@
1
+ import { IHttpClient } from "./IHttpClient";
2
+ /**
3
+ * Base class for the REST API endpoints.
4
+ */
5
+ export declare class Endpoint {
6
+ /**
7
+ * Endpoint API path relative to the REST API server URL.
8
+ */
9
+ path: string;
10
+ /**
11
+ * Endpoint-specific HTTP headers for the `GET`, `POST`, `PUT` and `DELETE` requests. You can
12
+ * add custom headers at any time.
13
+ */
14
+ headers: HeadersInit;
15
+ httpClient: IHttpClient;
16
+ private _useVersion;
17
+ /**
18
+ * @ignore
19
+ * @param path - The API path of the endpoint relative to the REST API server URL of the
20
+ * specified HTTP client.
21
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
22
+ * @param headers - Endpoint-specific HTTP headers.
23
+ */
24
+ constructor(path: string, httpClient: IHttpClient, headers?: {});
25
+ appendVersionParam(relativePath: string): string;
26
+ /**
27
+ * Returns the endpoint API path.
28
+ *
29
+ * @ignore
30
+ * @param relativePath - Nested endpoint relative path.
31
+ */
32
+ getEndpointPath(relativePath: string): string;
33
+ /**
34
+ * Sends the `GET` request to the endpoint.
35
+ *
36
+ * @ignore
37
+ * @param relativePath - Nested endpoint relative path.
38
+ * @param signal - An
39
+ * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
40
+ * signal. Allows to communicate with a fetch request and abort it if desired.
41
+ */
42
+ get(relativePath: string, signal?: AbortSignal): Promise<Response>;
43
+ /**
44
+ * Sends the `POST` request to the endpoint.
45
+ *
46
+ * @ignore
47
+ * @param relativePath - Nested endpoint relative path.
48
+ * @param body - Request body. Can be
49
+ * {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
50
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
51
+ * {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
52
+ */
53
+ post(relativePath: string, body?: BodyInit | object): Promise<Response>;
54
+ /**
55
+ * Sends the `PUT` request to the endpoint.
56
+ *
57
+ * @ignore
58
+ * @param relativePath - Nested endpoint relative path.
59
+ * @param body - Request body. Can be
60
+ * {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
61
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
62
+ * {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
63
+ */
64
+ put(relativePath: string, body?: BodyInit | object): Promise<Response>;
65
+ /**
66
+ * Sends the `DELETE` request to the endpoint.
67
+ *
68
+ * @ignore
69
+ * @param relativePath - Nested endpoint relative path.
70
+ */
71
+ delete(relativePath: string): Promise<Response>;
72
+ useVersion(version?: number): this;
73
+ }
@@ -1,6 +1,6 @@
1
- export declare function $fetch(url: string, params?: {
2
- method: "GET" | "POST" | "PUT" | "DELETE";
1
+ export declare function $fetch(url: string, init?: {
2
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "HEAD";
3
3
  headers?: HeadersInit;
4
- body?: BodyInit | object;
4
+ body?: BodyInit | object | null;
5
5
  signal?: AbortSignal;
6
6
  }): Promise<Response>;
package/lib/Api/File.d.ts CHANGED
@@ -1,29 +1,24 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  import { ICdaNode, IFileStatus, IFileReferences, IFileVersionInfo, IGrantedTo } from "./IFile";
3
4
  import { IShortUserDesc } from "./IUser";
4
5
  import { Model } from "./Model";
5
6
  import { Permission } from "./Permission";
6
7
  import { Job } from "./Job";
8
+ import { SharedLink } from "./SharedLink";
9
+ import { ISharedLinkPermissions } from "./ISharedLink";
7
10
  /**
8
11
  * Provides properties and methods for obtaining information about a file on the Open Cloud
9
12
  * Server and managing its data and versions.
10
13
  */
11
- export declare class File {
14
+ export declare class File extends Endpoint {
12
15
  private _data;
13
- private _useVersion;
14
- httpClient: IHttpClient;
15
- path: string;
16
16
  /**
17
17
  * @param data - Raw file data received from the server. For more information, see
18
18
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Files | Open Cloud Files API}.
19
19
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
20
20
  */
21
21
  constructor(data: any, httpClient: IHttpClient);
22
- private appendVersionParam;
23
- private internalGet;
24
- private internalPost;
25
- private internalPut;
26
- private internalDelete;
27
22
  /**
28
23
  * Active version number of the file.
29
24
  *
@@ -39,8 +34,6 @@ export declare class File {
39
34
  get created(): string;
40
35
  /**
41
36
  * File custom fields object, to store custom data.
42
- *
43
- * @readonly
44
37
  */
45
38
  get customFields(): any;
46
39
  set customFields(value: any);
@@ -51,7 +44,7 @@ export declare class File {
51
44
  * @readonly
52
45
  */
53
46
  get data(): any;
54
- private set data(value);
47
+ set data(value: any);
55
48
  /**
56
49
  * Returns a list of file formats in which the active version of the file was exported.
57
50
  *
@@ -59,6 +52,8 @@ export declare class File {
59
52
  * {@link createJob | createJob()}. To download exported file use
60
53
  * {@link downloadResource | downloadResource()}.
61
54
  *
55
+ * For an example of exporting files to other formats, see the {@link downloadResource} help.
56
+ *
62
57
  * @readonly
63
58
  */
64
59
  get exports(): string[];
@@ -123,6 +118,12 @@ export declare class File {
123
118
  * @readonly
124
119
  */
125
120
  get sizeTotal(): number;
121
+ /**
122
+ * File shared link token or `null` if file is not shared yet.
123
+ *
124
+ * @readonly
125
+ */
126
+ get sharedLinkToken(): string;
126
127
  /**
127
128
  * Data status of the active version of the file. Contains:
128
129
  *
@@ -329,7 +330,7 @@ export declare class File {
329
330
  * const dwgFileName = file.exports.find((x) => x.endsWith(".dwg"));
330
331
  * const arrayBuffer = await file.downloadResource(dwgFileName);
331
332
  * const blob = new Blob([arrayBuffer]);
332
- * const fileName = file.name.replace(/\.[^.]+$/, "") + ".dwg";
333
+ * const fileName = file.name + ".dwg";
333
334
  * FileSaver.saveAs(blob, fileName);
334
335
  *
335
336
  * @param dataId - Resource file name.
@@ -488,7 +489,7 @@ export declare class File {
488
489
  * @param actions - Actions are allowed to be performed on a file with this permission:
489
490
  *
490
491
  * - `read` - The ability to read file description, geometry data and properties.
491
- * - `readSourceFile` - The ability to read source file.
492
+ * - `readSourceFile` - The ability to download source file.
492
493
  * - `write` - The ability to modify file name, description and references.
493
494
  * - `readViewpoint` - The ability to read file viewpoints.
494
495
  * - `createViewpoint` - The ability to create file viewpoints.
@@ -590,4 +591,21 @@ export declare class File {
590
591
  * Deletes the source file of the active file version from the server.
591
592
  */
592
593
  deleteSource(): Promise<this>;
594
+ /**
595
+ * Creates a file shared link.
596
+ *
597
+ * @param permissions - Share permissions.
598
+ */
599
+ createSharedLink(permissions?: ISharedLinkPermissions): Promise<SharedLink>;
600
+ /**
601
+ * Returns information about the file shared link or `undefined` if file is not shared.
602
+ */
603
+ getSharedLink(): Promise<SharedLink>;
604
+ /**
605
+ * Deletes the file shared link.
606
+ *
607
+ * @returns Returns the raw data of a deleted shared link. For more information, see
608
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#ShareLinks | Open Cloud SharedLinks API}.
609
+ */
610
+ deleteSharedLink(): Promise<any>;
593
611
  }
@@ -5,15 +5,15 @@ export declare class HttpClient implements IHttpClient {
5
5
  signInUserId: string;
6
6
  signInUserIsAdmin: boolean;
7
7
  constructor(serverUrl: string);
8
- get(relativePath: string, signal?: AbortSignal): Promise<Response>;
9
- post(relativePath: string, body?: BodyInit | object): Promise<Response>;
10
- put(relativePath: string, body?: BodyInit | object): Promise<Response>;
11
- delete(relativePath: string): Promise<Response>;
12
- uploadFile(relativePath: string, file: File, onProgress?: (progress: number) => void): Promise<XMLHttpRequest>;
13
- downloadFile(relativePath: string, onProgress?: (progress: number, chunk: Uint8Array) => void, signal?: AbortSignal): Promise<Response>;
8
+ get(relativePath: string, init?: RequestInit): Promise<Response>;
9
+ post(relativePath: string, body?: BodyInit | object, init?: RequestInit): Promise<Response>;
10
+ put(relativePath: string, body?: BodyInit | object, init?: RequestInit): Promise<Response>;
11
+ delete(relativePath: string, init?: RequestInit): Promise<Response>;
12
+ uploadFile(relativePath: string, file: File, onProgress?: (progress: number) => void, init?: RequestInit): Promise<XMLHttpRequest>;
13
+ downloadFile(relativePath: string, onProgress?: (progress: number, chunk: Uint8Array) => void, init?: RequestInit): Promise<Response>;
14
14
  downloadFileRange(relativePath: string, reserved: number, ranges: Array<{
15
15
  begin: number;
16
16
  end: number;
17
17
  requestId: number;
18
- }>, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise<Response>;
18
+ }>, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, init?: RequestInit): Promise<Response>;
19
19
  }
@@ -89,7 +89,7 @@ export interface IFileVersionInfo {
89
89
  ownerId: string;
90
90
  }
91
91
  /**
92
- * Defines the user, project, or group that will have access to the {@link File | file}.
92
+ * Defines the user, project, or group that will have access to the file.
93
93
  */
94
94
  export interface IGrantedTo {
95
95
  /**
@@ -3,11 +3,11 @@
3
3
  */
4
4
  export interface IHttpClient {
5
5
  /**
6
- * REST API server base URL.
6
+ * REST API server URL.
7
7
  */
8
8
  serverUrl: string;
9
9
  /**
10
- * Request HTTP headers. You can add specific headers after user log in.
10
+ * Default HTTP headers for all requests. You can add specific headers at any time.
11
11
  *
12
12
  * The following headers are added automatically:
13
13
  *
@@ -24,75 +24,80 @@ export interface IHttpClient {
24
24
  */
25
25
  signInUserIsAdmin: boolean;
26
26
  /**
27
- * Sends the GET request to the specified endpoint.
27
+ * Sends the `GET` request to the specified endpoint.
28
28
  *
29
29
  * @param relativePath - Endpoint relative path.
30
- * @param signal - An
31
- * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
32
- * signal, which can be used to abort waiting as desired.
30
+ * @param init - A set of options that can be used to configure a fetch request. See
31
+ * {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
33
32
  */
34
- get(relativePath: string, signal?: AbortSignal): Promise<Response>;
33
+ get(relativePath: string, init?: RequestInit): Promise<Response>;
35
34
  /**
36
- * Sends the POST request to the specified endpoint.
35
+ * Sends the `POST` request to the specified endpoint.
37
36
  *
38
37
  * @param relativePath - Endpoint relative path.
39
38
  * @param body - Request body. Can be
40
39
  * {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
41
40
  * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
42
41
  * {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
42
+ * @param init - A set of options that can be used to configure a fetch request. See
43
+ * {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
43
44
  */
44
- post(relativePath: string, body?: BodyInit | object): Promise<Response>;
45
+ post(relativePath: string, body?: BodyInit | object, init?: RequestInit): Promise<Response>;
45
46
  /**
46
- * Sends the PUT request to the specified endpoint.
47
+ * Sends the `PUT` request to the specified endpoint.
47
48
  *
48
49
  * @param relativePath - Endpoint relative path.
49
50
  * @param body - Request body. Can be
50
51
  * {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
51
52
  * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
52
53
  * {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
54
+ * @param init - A set of options that can be used to configure a fetch request. See
55
+ * {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
53
56
  */
54
- put(relativePath: string, body?: BodyInit | object): Promise<Response>;
57
+ put(relativePath: string, body?: BodyInit | object, init?: RequestInit): Promise<Response>;
55
58
  /**
56
- * Sends the DELETE request to the specified endpoint.
59
+ * Sends the `DELETE` request to the specified endpoint.
57
60
  *
58
61
  * @param relativePath - Endpoint relative path.
62
+ * @param init - A set of options that can be used to configure a fetch request. See
63
+ * {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
59
64
  */
60
- delete(relativePath: string): Promise<Response>;
65
+ delete(relativePath: string, init?: RequestInit): Promise<Response>;
61
66
  /**
62
67
  * Upload a file to the server.
63
68
  *
64
- * @param relativePath - File relative path.
69
+ * @param relativePath - Upload endpoint relative path.
65
70
  * @param file - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
66
71
  * are generally retrieved from a
67
72
  * {@link https://developer.mozilla.org/docs/Web/API/FileList | FileList} object returned as
68
73
  * a result of a user selecting files using the HTML `<input>` element.
69
74
  * @param onProgress - Upload progress callback.
75
+ * @param init - A set of options that can be used to configure a fetch request. See
76
+ * {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
70
77
  */
71
- uploadFile(relativePath: string, file: globalThis.File, onProgress?: (progress: number) => void): Promise<XMLHttpRequest>;
78
+ uploadFile(relativePath: string, file: globalThis.File, onProgress?: (progress: number) => void, init?: RequestInit): Promise<XMLHttpRequest>;
72
79
  /**
73
80
  * Downloads the specified file from the server.
74
81
  *
75
- * @param relativePath - File relative path.
82
+ * @param relativePath - Download endpoint relative path.
76
83
  * @param onProgress - Download progress callback.
77
- * @param signal - An
78
- * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
79
- * signal. Allows to communicate with a fetch request and abort it if desired.
84
+ * @param init - A set of options that can be used to configure a fetch request. See
85
+ * {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
80
86
  */
81
- downloadFile(relativePath: string, onProgress?: (progress: number, chunk: Uint8Array) => void, signal?: AbortSignal): Promise<Response>;
87
+ downloadFile(relativePath: string, onProgress?: (progress: number, chunk: Uint8Array) => void, init?: RequestInit): Promise<Response>;
82
88
  /**
83
89
  * Downloads a part of file from the server.
84
90
  *
85
- * @param relativePath - File relative path.
91
+ * @param relativePath - Download endpoint relative path.
86
92
  * @param reserved - Reserved, do not use.
87
- * @param ranges - A range of resource file contents to download.
93
+ * @param ranges - A ranges of resource file contents to download.
88
94
  * @param onProgress - Download progress callback.
89
- * @param signal - An
90
- * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
91
- * signal. Allows to communicate with a fetch request and abort it if desired.
95
+ * @param init - A set of options that can be used to configure a fetch request. See
96
+ * {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
92
97
  */
93
98
  downloadFileRange(relativePath: string, reserved: number, ranges: Array<{
94
99
  begin: number;
95
100
  end: number;
96
101
  requestId: number;
97
- }>, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, signal?: AbortSignal): Promise<Response>;
102
+ }>, onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void, init?: RequestInit): Promise<Response>;
98
103
  }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Defines what actions are allowed to be performed on a file from shared link:
3
+ *
4
+ * - `read` - The ability to read file description, geometry data and properties.
5
+ * - `readSourceFile` - The ability to download source file.
6
+ * - `readViewpoint` - The ability to read file viewpoints.
7
+ */
8
+ export type SharedLinkAction = "read" | "readSourceFile" | "readViewpoint";
9
+ /**
10
+ * Defines the shared link permissions.
11
+ */
12
+ export interface ISharedLinkPermissions {
13
+ /**
14
+ * Defines what actions are allowed to be performed on a file from shared link:
15
+ *
16
+ * - `read` - The ability to read file description, geometry data and properties.
17
+ * - `readSourceFile` - The ability to download source file.
18
+ * - `readViewpoint` - The ability to read file viewpoints.
19
+ *
20
+ * At least one action must be defined.
21
+ */
22
+ actions: SharedLinkAction[];
23
+ /**
24
+ * Password to get access to the file.
25
+ */
26
+ password?: string;
27
+ /**
28
+ * true if the shared link is password protected.
29
+ */
30
+ readonly passwordProtected?: string;
31
+ /**
32
+ * Link expiration time (UTC) in the format specified in
33
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
34
+ */
35
+ expiresAt?: string;
36
+ }
package/lib/Api/Job.d.ts CHANGED
@@ -1,19 +1,16 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  /**
3
4
  * Provides properties and methods for obtaining information about a job on the Open Cloud Server.
4
5
  */
5
- export declare class Job {
6
+ export declare class Job extends Endpoint {
6
7
  private _data;
7
- httpClient: IHttpClient;
8
8
  /**
9
9
  * @param data - Raw job data received from the server. For more information, see
10
10
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Jobs | Open Cloud Jobs API}.
11
11
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
12
12
  */
13
13
  constructor(data: any, httpClient: IHttpClient);
14
- protected internalGet(): Promise<Response>;
15
- protected internalPut(body?: BodyInit | object): Promise<Response>;
16
- protected internalDelete(): Promise<Response>;
17
14
  /**
18
15
  * The ID of the assembly the job is working on (internal).
19
16
  *
@@ -1,13 +1,12 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  import { IShortUserDesc } from "./IUser";
3
4
  /**
4
5
  * Provides properties and methods for obtaining information about a {@link User | user} who has
5
6
  * access to the {@link Project | project}.
6
7
  */
7
- export declare class Member {
8
+ export declare class Member extends Endpoint {
8
9
  private _data;
9
- projectId: string;
10
- httpClient: IHttpClient;
11
10
  /**
12
11
  * @param data - Raw member data received from the server. For more information, see
13
12
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
@@ -15,9 +14,6 @@ export declare class Member {
15
14
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
16
15
  */
17
16
  constructor(data: any, projectId: string, httpClient: IHttpClient);
18
- private internalGet;
19
- private internalPut;
20
- private internalDelete;
21
17
  /**
22
18
  * Raw member data received from the server. For more information, see
23
19
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
@@ -1,4 +1,4 @@
1
- import { IHttpClient } from "./IHttpClient";
1
+ import { Endpoint } from "./Endpoint";
2
2
  import type { File } from "./File";
3
3
  import type { Assembly } from "./Assembly";
4
4
  import type { IFileReferences } from "./IFile";
@@ -8,11 +8,9 @@ import type { IModelTransformMatrix } from "./IAssembly";
8
8
  * {@link Assembly| assembly}. For example, for `dwg` it is a `Model` space or layout, and for
9
9
  * `rvt` files it is a `3D` view.
10
10
  */
11
- export declare class Model {
11
+ export declare class Model extends Endpoint {
12
12
  private _data;
13
13
  private _file;
14
- httpClient: IHttpClient;
15
- path: string;
16
14
  /**
17
15
  * @param data - Raw model data received from the server.
18
16
  * @param file - The file/assembly instance that owns the model.
@@ -1,21 +1,17 @@
1
1
  import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
2
3
  /**
3
4
  * Provides properties and methods for obtaining information about a OAuth 2.0 client that have
4
5
  * access the Open Cloud Server API.
5
6
  */
6
- export declare class OAuthClient {
7
+ export declare class OAuthClient extends Endpoint {
7
8
  private _data;
8
- httpClient: IHttpClient;
9
9
  /**
10
10
  * @param data - Raw client data received from the server. For more information, see
11
11
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
12
12
  * @param httpClient - HTTP client instance used to send requests to the REST API server.
13
13
  */
14
14
  constructor(data: any, httpClient: IHttpClient);
15
- private internalGet;
16
- protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response>;
17
- private internalPut;
18
- private internalDelete;
19
15
  /**
20
16
  * OAuth 2.0 server authorization endpoint.
21
17
  */