@inweb/client 25.9.3 → 25.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +117 -108
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +30 -3
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +5 -13
- package/lib/Api/ClashTest.d.ts +3 -11
- package/lib/Api/Client.d.ts +4 -3
- package/lib/Api/FetchError.d.ts +8 -2
- package/lib/Api/File.d.ts +20 -26
- package/lib/Api/HttpClient.d.ts +1 -1
- package/lib/Api/IFile.d.ts +72 -0
- package/lib/Api/IHttpClient.d.ts +82 -1
- package/lib/Api/IRole.d.ts +59 -0
- package/lib/Api/IUser.d.ts +30 -1
- package/lib/Api/Job.d.ts +2 -2
- package/lib/Api/Member.d.ts +5 -12
- package/lib/Api/Permission.d.ts +16 -16
- package/lib/Api/Project.d.ts +46 -21
- package/lib/Api/Role.d.ts +4 -17
- package/lib/Api/User.d.ts +3 -2
- package/lib/index.d.ts +4 -0
- package/package.json +2 -2
- package/src/Api/Assembly.ts +5 -13
- package/src/Api/ClashTest.ts +3 -11
- package/src/Api/Client.ts +4 -3
- package/src/Api/FetchError.ts +9 -2
- package/src/Api/File.ts +20 -26
- package/src/Api/HttpClient.ts +1 -1
- package/src/Api/IFile.ts +84 -0
- package/src/Api/IHttpClient.ts +85 -1
- package/src/Api/IRole.ts +88 -0
- package/src/Api/IUser.ts +37 -1
- package/src/Api/Job.ts +2 -2
- package/src/Api/Member.ts +5 -12
- package/src/Api/Permission.ts +16 -17
- package/src/Api/Project.ts +83 -21
- package/src/Api/Role.ts +4 -17
- package/src/Api/User.ts +3 -2
- package/src/index.ts +4 -0
package/lib/Api/Project.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { IHttpClient } from "./IHttpClient";
|
|
2
|
-
import {
|
|
2
|
+
import { IShortUserDesc } from "./IUser";
|
|
3
3
|
import { Role } from "./Role";
|
|
4
|
+
import { IRoleActions } from "./IRole";
|
|
4
5
|
import { Member } from "./Member";
|
|
6
|
+
import { File } from "./File";
|
|
5
7
|
/**
|
|
6
|
-
* Provides properties and methods for obtaining information about a project on the
|
|
7
|
-
* managing its {@link Role | roles}, {@link Member | members} and models.
|
|
8
|
+
* Provides properties and methods for obtaining information about a project on the Open Cloud
|
|
9
|
+
* Server and managing its {@link Role | roles}, {@link Member | members} and models.
|
|
8
10
|
*/
|
|
9
11
|
export declare class Project {
|
|
10
12
|
private _data;
|
|
11
13
|
httpClient: IHttpClient;
|
|
12
14
|
/**
|
|
13
15
|
* @param data - Raw project data received from the server.
|
|
14
|
-
* @param httpClient - HTTP client instance used to send
|
|
16
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
15
17
|
*/
|
|
16
18
|
constructor(data: any, httpClient: IHttpClient);
|
|
17
19
|
protected internalGet(relativePath: string): Promise<Response>;
|
|
@@ -89,17 +91,9 @@ export declare class Project {
|
|
|
89
91
|
/**
|
|
90
92
|
* Project owner information.
|
|
91
93
|
*
|
|
92
|
-
* @property {string} userId - User ID.
|
|
93
|
-
* @property {string} userName - User name.
|
|
94
|
-
* @property {string} name - First name.
|
|
95
|
-
* @property {string} lastName - Last name.
|
|
96
|
-
* @property {string} fullName - Full name.
|
|
97
|
-
* @property {string} initials - Initials.
|
|
98
|
-
* @property {string} email - User email.
|
|
99
|
-
* @property {string} avatarUrl - User avatar image URL.
|
|
100
94
|
* @readonly
|
|
101
95
|
*/
|
|
102
|
-
get owner():
|
|
96
|
+
get owner(): IShortUserDesc;
|
|
103
97
|
/**
|
|
104
98
|
* Project preview image URL or empty string if the project does not have a preview. Use
|
|
105
99
|
* {@link Project.setPreview | setPreview()} to change preview image.
|
|
@@ -184,10 +178,9 @@ export declare class Project {
|
|
|
184
178
|
*
|
|
185
179
|
* @param name - Role name.
|
|
186
180
|
* @param description - Role description.
|
|
187
|
-
* @param permissions - Actions are allowed to be performed
|
|
188
|
-
* more details.
|
|
181
|
+
* @param permissions - Actions are allowed to be performed for the role.
|
|
189
182
|
*/
|
|
190
|
-
createRole(name: string, description: string, permissions:
|
|
183
|
+
createRole(name: string, description: string, permissions: IRoleActions): Promise<Role>;
|
|
191
184
|
/**
|
|
192
185
|
* Deletes the specified project role.
|
|
193
186
|
*
|
|
@@ -206,14 +199,14 @@ export declare class Project {
|
|
|
206
199
|
*/
|
|
207
200
|
getMember(memberId: string): Promise<Member>;
|
|
208
201
|
/**
|
|
209
|
-
*
|
|
202
|
+
* Adds a user to the project to become a member and have permission to perform actions.
|
|
210
203
|
*
|
|
211
204
|
* @param userId - User ID.
|
|
212
|
-
* @param role - Role name from the list of project roles.
|
|
205
|
+
* @param role - Role name from the list of project {@link getRoles | roles}.
|
|
213
206
|
*/
|
|
214
207
|
addMember(userId: string, role: string): Promise<Member>;
|
|
215
208
|
/**
|
|
216
|
-
*
|
|
209
|
+
* Removes the specified member from a project.
|
|
217
210
|
*
|
|
218
211
|
* @param memberId - Member ID.
|
|
219
212
|
* @returns Returns the raw data of a deleted member.
|
|
@@ -232,8 +225,40 @@ export declare class Project {
|
|
|
232
225
|
* @property {string} file.reference - File ID.
|
|
233
226
|
*/
|
|
234
227
|
/**
|
|
235
|
-
* Returns a list of project files.
|
|
236
|
-
*
|
|
228
|
+
* Returns a list of project files.
|
|
229
|
+
*
|
|
230
|
+
* This list contains all files that the project has access to. To add a file to this list,
|
|
231
|
+
* create a {@link IGrantedTo.project | project} permission on the file using
|
|
232
|
+
* {@link File.createPermission | File.createPermission()}.
|
|
237
233
|
*/
|
|
238
234
|
getFilesInformation(): Promise<any[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Returns a list of project models.
|
|
237
|
+
*/
|
|
238
|
+
getModels(): Promise<File[]>;
|
|
239
|
+
/**
|
|
240
|
+
* Adds a file to the project with specified permissions.
|
|
241
|
+
*
|
|
242
|
+
* To change file permissions for the project use {@link Permission.update | Permissions.update()}.
|
|
243
|
+
*
|
|
244
|
+
* @param fileId - File ID.
|
|
245
|
+
* @param actions - Actions are allowed to be performed on a file:
|
|
246
|
+
*
|
|
247
|
+
* - `read` - The ability to read file description, geometry data and properties.
|
|
248
|
+
* - `readSourceFile` - The ability to read source file.
|
|
249
|
+
* - `write` - The ability to modify file name, description and references.
|
|
250
|
+
* - `readViewpoint` - The ability to read file viewpoints.
|
|
251
|
+
* - `createViewpoint` - The ability to create file viewpoints.
|
|
252
|
+
*
|
|
253
|
+
* @param _public - Specifies whether all users have access to the file or not.
|
|
254
|
+
* @returns Returns a file instance added to the project.
|
|
255
|
+
*/
|
|
256
|
+
addModel(fileId: string, actions: string | string[], _public: boolean): Promise<File>;
|
|
257
|
+
/**
|
|
258
|
+
* Removes the specified file from a project.
|
|
259
|
+
*
|
|
260
|
+
* @param fileId - File ID.
|
|
261
|
+
* @returns Returns a file instance removed from the project.
|
|
262
|
+
*/
|
|
263
|
+
removeModel(fileId: string): Promise<File>;
|
|
239
264
|
}
|
package/lib/Api/Role.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IHttpClient } from "./IHttpClient";
|
|
2
|
+
import { IRoleActions } from "./IRole";
|
|
2
3
|
/**
|
|
3
4
|
* A role determines what actions allowed to be performed by {@link User | users} on a
|
|
4
5
|
* {@link Project | project}.
|
|
@@ -10,7 +11,7 @@ export declare class Role {
|
|
|
10
11
|
/**
|
|
11
12
|
* @param data - Raw role data received from the server.
|
|
12
13
|
* @param projectId - Owner project ID.
|
|
13
|
-
* @param httpClient - HTTP client instance used to send
|
|
14
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
14
15
|
*/
|
|
15
16
|
constructor(data: any, projectId: string, httpClient: IHttpClient);
|
|
16
17
|
private internalGet;
|
|
@@ -35,23 +36,9 @@ export declare class Role {
|
|
|
35
36
|
set name(value: string);
|
|
36
37
|
/**
|
|
37
38
|
* Role actions are allowed to be performed.
|
|
38
|
-
*
|
|
39
|
-
* @property {string[]} projectActions - Actions are allowed to be performed at the project
|
|
40
|
-
* level: `update`, `createTopic`, `createDocument`.
|
|
41
|
-
* @property {string[]} topicActions - Actions are allowed to be performed at the topic
|
|
42
|
-
* level: `update`, `updateBimSnippet`, `updateRelatedTopics`, `updateDocumentReferences`,
|
|
43
|
-
* `updateFiles`, `createComment`, `createViewpoint`, `delete`.
|
|
44
|
-
* @property {string[]} commentActions - Actions are allowed to be performed at the comment
|
|
45
|
-
* level: `update`, `delete`.
|
|
46
|
-
* @property {string[]} viewpointActions - Actions are allowed to be performed at the
|
|
47
|
-
* viewpoint level: `delete`.
|
|
48
|
-
* @property {string[]} odaGroupActions - Actions are allowed to be performed at the members
|
|
49
|
-
* level: `update`, `delete`.
|
|
50
|
-
* @property {string[]} odaRoleActions - Actions are allowed to be performed at the roles
|
|
51
|
-
* level: `update`, `delete`.
|
|
52
39
|
*/
|
|
53
|
-
get permissions():
|
|
54
|
-
set permissions(value:
|
|
40
|
+
get permissions(): IRoleActions;
|
|
41
|
+
set permissions(value: IRoleActions);
|
|
55
42
|
/**
|
|
56
43
|
* Reloads role data from the server.
|
|
57
44
|
*/
|
package/lib/Api/User.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { IHttpClient } from "./IHttpClient";
|
|
2
2
|
/**
|
|
3
|
-
* Provides properties and methods for obtaining information about a
|
|
3
|
+
* Provides properties and methods for obtaining information about a Open Cloud Server user and
|
|
4
|
+
* manage its data.
|
|
4
5
|
*/
|
|
5
6
|
export declare class User {
|
|
6
7
|
private _data;
|
|
7
8
|
httpClient: IHttpClient;
|
|
8
9
|
/**
|
|
9
10
|
* @param data - Raw user data received from the server.
|
|
10
|
-
* @param httpClient - HTTP client instance used to send
|
|
11
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
11
12
|
*/
|
|
12
13
|
constructor(data: any, httpClient: IHttpClient);
|
|
13
14
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ export * from "./Api/ClientEvents";
|
|
|
5
5
|
export { File } from "./Api/File";
|
|
6
6
|
export { FetchError, statusText } from "./Api/FetchError";
|
|
7
7
|
export { Job } from "./Api/Job";
|
|
8
|
+
export { IHttpClient } from "./Api/IHttpClient";
|
|
8
9
|
export { IModelTransformMatrix } from "./Api/IAssembly";
|
|
10
|
+
export { IFileDataStatus, IFileReference, IFileReferences, IFileStatus, IGrantedTo } from "./Api/IFile";
|
|
11
|
+
export { IRoleActions } from "./Api/IRole";
|
|
12
|
+
export { IShortUserDesc } from "./Api/IUser";
|
|
9
13
|
export { Member } from "./Api/Member";
|
|
10
14
|
export { Model } from "./Api/Model";
|
|
11
15
|
export { Permission } from "./Api/Permission";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/client",
|
|
3
|
-
"version": "25.9.
|
|
3
|
+
"version": "25.9.5",
|
|
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.9.
|
|
29
|
+
"@inweb/eventemitter2": "~25.9.5"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/Api/Assembly.ts
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
25
|
import { FetchError } from "./FetchError";
|
|
26
26
|
import { IAssociatedFileData, IAssemblyVersionInfo, IModelTransformMatrix } from "./IAssembly";
|
|
27
|
-
import {
|
|
27
|
+
import { IShortUserDesc } from "./IUser";
|
|
28
28
|
import { Model } from "./Model";
|
|
29
29
|
import { ClashTest } from "./ClashTest";
|
|
30
30
|
import { waitFor, userFullName, userInitials } from "./Utils";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Provides properties and methods for obtaining information about an assembly on the
|
|
34
|
-
* and managing its data.
|
|
33
|
+
* Provides properties and methods for obtaining information about an assembly on the Open
|
|
34
|
+
* Cloud Server and managing its data.
|
|
35
35
|
*/
|
|
36
36
|
export class Assembly {
|
|
37
37
|
private _data: any;
|
|
@@ -41,7 +41,7 @@ export class Assembly {
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @param data - Raw assembly data received from the server.
|
|
44
|
-
* @param httpClient - HTTP client instance used to send
|
|
44
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server..
|
|
45
45
|
*/
|
|
46
46
|
constructor(data: any, httpClient: IHttpClient) {
|
|
47
47
|
this.path = `/assemblies/${data.id}`;
|
|
@@ -168,17 +168,9 @@ export class Assembly {
|
|
|
168
168
|
/**
|
|
169
169
|
* Assembly owner information.
|
|
170
170
|
*
|
|
171
|
-
* @property {string} userId - User ID.
|
|
172
|
-
* @property {string} userName - User name.
|
|
173
|
-
* @property {string} name - First name.
|
|
174
|
-
* @property {string} lastName - Last name.
|
|
175
|
-
* @property {string} fullName - Full name.
|
|
176
|
-
* @property {string} initials - Initials.
|
|
177
|
-
* @property {string} email - User email.
|
|
178
|
-
* @property {string} avatarUrl - User avatar image URL.
|
|
179
171
|
* @readonly
|
|
180
172
|
*/
|
|
181
|
-
get owner():
|
|
173
|
+
get owner(): IShortUserDesc {
|
|
182
174
|
return this.data.owner;
|
|
183
175
|
}
|
|
184
176
|
|
package/src/Api/ClashTest.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
-
import {
|
|
25
|
+
import { IShortUserDesc } from "./IUser";
|
|
26
26
|
import { waitFor, userFullName, userInitials } from "./Utils";
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -36,7 +36,7 @@ export class ClashTest {
|
|
|
36
36
|
/**
|
|
37
37
|
* @param data - Raw test data received from the server.
|
|
38
38
|
* @param basePath - The clash test API base path of the file/assembly that owns the test.
|
|
39
|
-
* @param httpClient - HTTP client instance used to send
|
|
39
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
40
40
|
*/
|
|
41
41
|
constructor(data: any, basePath: string, httpClient: IHttpClient) {
|
|
42
42
|
this.httpClient = httpClient;
|
|
@@ -129,17 +129,9 @@ export class ClashTest {
|
|
|
129
129
|
/**
|
|
130
130
|
* Test owner information.
|
|
131
131
|
*
|
|
132
|
-
* @property {string} userId - User ID.
|
|
133
|
-
* @property {string} userName - User name.
|
|
134
|
-
* @property {string} name - First name.
|
|
135
|
-
* @property {string} lastName - Last name.
|
|
136
|
-
* @property {string} fullName - Full name.
|
|
137
|
-
* @property {string} initials - Initials.
|
|
138
|
-
* @property {string} email - User email.
|
|
139
|
-
* @property {string} avatarUrl - User avatar image URL.
|
|
140
132
|
* @readonly
|
|
141
133
|
*/
|
|
142
|
-
get owner():
|
|
134
|
+
get owner(): IShortUserDesc {
|
|
143
135
|
return this.data.owner;
|
|
144
136
|
}
|
|
145
137
|
|
package/src/Api/Client.ts
CHANGED
|
@@ -35,7 +35,8 @@ import { User } from "./User";
|
|
|
35
35
|
import { parseArgs } from "./Utils";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Provides methods for managing
|
|
38
|
+
* Provides methods for managing Open Cloud Server resources such as users, files, assemblies,
|
|
39
|
+
* jobs, projects, etc.
|
|
39
40
|
*/
|
|
40
41
|
export class Client extends EventEmitter2<ClientEventMap> {
|
|
41
42
|
private _serverUrl = "";
|
|
@@ -54,7 +55,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
|
-
* Open Cloud
|
|
58
|
+
* Open Cloud REST API server base URL. Use {@link configure | configure()} to change server URL.
|
|
58
59
|
*
|
|
59
60
|
* @readonly
|
|
60
61
|
*/
|
|
@@ -63,7 +64,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
|
-
* HTTP client instance used to send
|
|
67
|
+
* HTTP client instance used to send requests to the REST API server.
|
|
67
68
|
*
|
|
68
69
|
* @readonly
|
|
69
70
|
*/
|
package/src/Api/FetchError.ts
CHANGED
|
@@ -106,8 +106,15 @@ export function error400(text: string, _default = "400"): string {
|
|
|
106
106
|
*/
|
|
107
107
|
|
|
108
108
|
export class FetchError extends Error {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
/**
|
|
110
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Status | HTTP status code} of the response.
|
|
111
|
+
*/
|
|
112
|
+
public status: number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Status message corresponding to the {@link status | status code}.
|
|
116
|
+
*/
|
|
117
|
+
public statusText: string;
|
|
111
118
|
|
|
112
119
|
/**
|
|
113
120
|
* @property status - The
|
package/src/Api/File.ts
CHANGED
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
-
import { IFileStatus, IFileReferences, IFileVersionInfo } from "./IFile";
|
|
26
|
-
import {
|
|
25
|
+
import { IFileStatus, IFileReferences, IFileVersionInfo, IGrantedTo } from "./IFile";
|
|
26
|
+
import { IShortUserDesc } from "./IUser";
|
|
27
27
|
import { Model } from "./Model";
|
|
28
28
|
import { Permission } from "./Permission";
|
|
29
29
|
import { Job } from "./Job";
|
|
30
30
|
import { waitFor, parseArgs, userFullName, userInitials } from "./Utils";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Provides properties and methods for obtaining information about a file on the
|
|
34
|
-
* managing its data and versions.
|
|
33
|
+
* Provides properties and methods for obtaining information about a file on the Open Cloud
|
|
34
|
+
* Server and managing its data and versions.
|
|
35
35
|
*/
|
|
36
36
|
export class File {
|
|
37
37
|
private _data: any;
|
|
@@ -41,7 +41,7 @@ export class File {
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @param data - Raw file data received from the server.
|
|
44
|
-
* @param httpClient - HTTP client instance used to send
|
|
44
|
+
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
45
45
|
*/
|
|
46
46
|
constructor(data: any, httpClient: IHttpClient) {
|
|
47
47
|
this.path = `/files/${data.id}`;
|
|
@@ -217,17 +217,9 @@ export class File {
|
|
|
217
217
|
/**
|
|
218
218
|
* File owner information.
|
|
219
219
|
*
|
|
220
|
-
* @property {string} userId - User ID.
|
|
221
|
-
* @property {string} userName - User name.
|
|
222
|
-
* @property {string} name - First name.
|
|
223
|
-
* @property {string} lastName - Last name.
|
|
224
|
-
* @property {string} fullName - Full name.
|
|
225
|
-
* @property {string} initials - Initials.
|
|
226
|
-
* @property {string} email - User email.
|
|
227
|
-
* @property {string} avatarUrl - User avatar image URL.
|
|
228
220
|
* @readonly
|
|
229
221
|
*/
|
|
230
|
-
get owner():
|
|
222
|
+
get owner(): IShortUserDesc {
|
|
231
223
|
return this.data.owner;
|
|
232
224
|
}
|
|
233
225
|
|
|
@@ -300,17 +292,9 @@ export class File {
|
|
|
300
292
|
/**
|
|
301
293
|
* Information about the user who made the last update.
|
|
302
294
|
*
|
|
303
|
-
* @property {string} userId - User ID.
|
|
304
|
-
* @property {string} userName - User name.
|
|
305
|
-
* @property {string} name - First name.
|
|
306
|
-
* @property {string} lastName - Last name.
|
|
307
|
-
* @property {string} fullName - Full name.
|
|
308
|
-
* @property {string} initials - Initials.
|
|
309
|
-
* @property {string} email - User email.
|
|
310
|
-
* @property {string} avatarUrl - User avatar image URL.
|
|
311
295
|
* @readonly
|
|
312
296
|
*/
|
|
313
|
-
get updatedBy():
|
|
297
|
+
get updatedBy(): IShortUserDesc {
|
|
314
298
|
return this.data.updatedBy;
|
|
315
299
|
}
|
|
316
300
|
|
|
@@ -806,7 +790,17 @@ export class File {
|
|
|
806
790
|
}
|
|
807
791
|
|
|
808
792
|
/**
|
|
809
|
-
* Creates a new file permission.
|
|
793
|
+
* Creates a new file permission for a user, project, or group.
|
|
794
|
+
*
|
|
795
|
+
* @example <caption>Grant the specified user permission to "update" the file.</caption>
|
|
796
|
+
* const action = "update";
|
|
797
|
+
* const grantedTo = [{ user: { id: myUser.id, email: myUser.email } }];
|
|
798
|
+
* await file.createPermission(action, grantedTo);
|
|
799
|
+
*
|
|
800
|
+
* @example <caption>Add a file to the specified project in `read-only` mode.</caption>
|
|
801
|
+
* const actions = ["read", "readSourceFile"];
|
|
802
|
+
* const grantedTo = [{ project: { id: myProject.id, name: myProject.name } }];
|
|
803
|
+
* await file.createPermission(actions, grantedTo);
|
|
810
804
|
*
|
|
811
805
|
* @param actions - Actions are allowed to be performed on a file with this permission:
|
|
812
806
|
*
|
|
@@ -816,10 +810,10 @@ export class File {
|
|
|
816
810
|
* - `readViewpoint` - The ability to read file viewpoints.
|
|
817
811
|
* - `createViewpoint` - The ability to create file viewpoints.
|
|
818
812
|
*
|
|
819
|
-
* @param grantedTo - A list of
|
|
813
|
+
* @param grantedTo - A list of entities that will get access to the file.
|
|
820
814
|
* @param _public - Specifies whether all users have access to the file or not.
|
|
821
815
|
*/
|
|
822
|
-
createPermission(actions: string | string[], grantedTo:
|
|
816
|
+
createPermission(actions: string | string[], grantedTo: IGrantedTo[], _public: boolean): Promise<Permission> {
|
|
823
817
|
return this.internalPost("/permissions", {
|
|
824
818
|
actions: Array.isArray(actions) ? actions : [actions],
|
|
825
819
|
grantedTo,
|
package/src/Api/HttpClient.ts
CHANGED
|
@@ -112,7 +112,7 @@ export class HttpClient implements IHttpClient {
|
|
|
112
112
|
|
|
113
113
|
async downloadFileRange(
|
|
114
114
|
relativePath: string,
|
|
115
|
-
|
|
115
|
+
reserved: number,
|
|
116
116
|
ranges: Array<{ begin: number; end: number; requestId: number }>,
|
|
117
117
|
onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void,
|
|
118
118
|
signal?: AbortSignal
|
package/src/Api/IFile.ts
CHANGED
|
@@ -21,16 +21,45 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Defines the data status.
|
|
26
|
+
*/
|
|
24
27
|
export interface IFileDataStatus {
|
|
28
|
+
/**
|
|
29
|
+
* Data state. Can be `none`, `waiting`, `inprogress`, `done` or `failed`.
|
|
30
|
+
*/
|
|
25
31
|
state: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Unique ID of the data job.
|
|
35
|
+
*/
|
|
26
36
|
jobId?: string;
|
|
37
|
+
|
|
27
38
|
jobUrl?: string;
|
|
28
39
|
}
|
|
29
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Defines the file status.
|
|
43
|
+
*/
|
|
30
44
|
export interface IFileStatus {
|
|
45
|
+
/**
|
|
46
|
+
* Status of geometry data of `vsfx` type.
|
|
47
|
+
*/
|
|
31
48
|
geometry: IFileDataStatus;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Status of geometry data of `gltf` type.
|
|
52
|
+
*/
|
|
32
53
|
geometryGltf: IFileDataStatus;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Status of the properties.
|
|
57
|
+
*/
|
|
33
58
|
properties: IFileDataStatus;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Status of the validation.
|
|
62
|
+
*/
|
|
34
63
|
validation: IFileDataStatus;
|
|
35
64
|
}
|
|
36
65
|
|
|
@@ -72,3 +101,58 @@ export interface IFileVersionInfo {
|
|
|
72
101
|
size: number;
|
|
73
102
|
ownerId: string;
|
|
74
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Defines the entity, that will have access to the {@link File | file}.
|
|
107
|
+
*/
|
|
108
|
+
export interface IGrantedTo {
|
|
109
|
+
/**
|
|
110
|
+
* The user that has access to the file.
|
|
111
|
+
*/
|
|
112
|
+
user?: {
|
|
113
|
+
/**
|
|
114
|
+
* User ID.
|
|
115
|
+
*/
|
|
116
|
+
id: string;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* User email.
|
|
120
|
+
*/
|
|
121
|
+
email: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The project that has access to the file.
|
|
126
|
+
*/
|
|
127
|
+
project?: {
|
|
128
|
+
/**
|
|
129
|
+
* Project ID.
|
|
130
|
+
*/
|
|
131
|
+
id: string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Project name.
|
|
135
|
+
*/
|
|
136
|
+
name: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The group that has access to the file.
|
|
141
|
+
*/
|
|
142
|
+
group?: {
|
|
143
|
+
/**
|
|
144
|
+
* Project ID.
|
|
145
|
+
*/
|
|
146
|
+
projectId: string;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Group ID.
|
|
150
|
+
*/
|
|
151
|
+
groupId: string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Group name.
|
|
155
|
+
*/
|
|
156
|
+
name: string;
|
|
157
|
+
};
|
|
158
|
+
}
|
package/src/Api/IHttpClient.ts
CHANGED
|
@@ -21,35 +21,119 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Defines the HTTP client used to send requests to the REST API server.
|
|
26
|
+
*/
|
|
24
27
|
export interface IHttpClient {
|
|
28
|
+
/**
|
|
29
|
+
* REST API server base URL.
|
|
30
|
+
*/
|
|
25
31
|
serverUrl: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Request HTTP headers. You can add specific headers after user log in.
|
|
35
|
+
*
|
|
36
|
+
* The following headers are added automatically:
|
|
37
|
+
*
|
|
38
|
+
* - `Authorization`- Added after user log in.
|
|
39
|
+
* - `Content-Type` - Added before sending `POST` and `PUT` request according the request body.
|
|
40
|
+
*/
|
|
26
41
|
headers: HeadersInit;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Current logged in user ID.
|
|
45
|
+
*/
|
|
27
46
|
signInUserId: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `True` if the current logged in user is and administrator.
|
|
50
|
+
*/
|
|
28
51
|
signInUserIsAdmin: boolean;
|
|
29
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Sends the GET request to the specified endpoint.
|
|
55
|
+
*
|
|
56
|
+
* @param relativePath - Endpoint relative path.
|
|
57
|
+
* @param signal - An
|
|
58
|
+
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
|
|
59
|
+
* signal, which can be used to abort waiting as desired.
|
|
60
|
+
*/
|
|
30
61
|
get(relativePath: string, signal?: AbortSignal): Promise<Response>;
|
|
31
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Sends the POST request to the specified endpoint.
|
|
65
|
+
*
|
|
66
|
+
* @param relativePath - Endpoint relative path.
|
|
67
|
+
* @param body - Request body. Can be
|
|
68
|
+
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
|
|
69
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
70
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
|
|
71
|
+
*/
|
|
32
72
|
post(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
|
33
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Sends the PUT request to the specified endpoint.
|
|
76
|
+
*
|
|
77
|
+
* @param relativePath - Endpoint relative path.
|
|
78
|
+
* @param body - Request body. Can be
|
|
79
|
+
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
|
|
80
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
81
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
|
|
82
|
+
*/
|
|
34
83
|
put(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
|
35
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Sends the DELETE request to the specified endpoint.
|
|
87
|
+
*
|
|
88
|
+
* @param relativePath - Endpoint relative path.
|
|
89
|
+
*/
|
|
36
90
|
delete(relativePath: string): Promise<Response>;
|
|
37
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Upload a file to the server.
|
|
94
|
+
*
|
|
95
|
+
* @param relativePath - File relative path.
|
|
96
|
+
* @param file - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
97
|
+
* are generally retrieved from a
|
|
98
|
+
* {@link https://developer.mozilla.org/docs/Web/API/FileList | FileList} object returned as
|
|
99
|
+
* a result of a user selecting files using the HTML `<input>` element.
|
|
100
|
+
* @param onProgress - Upload progress callback.
|
|
101
|
+
*/
|
|
38
102
|
uploadFile(
|
|
39
103
|
relativePath: string,
|
|
40
104
|
file: globalThis.File,
|
|
41
105
|
onProgress?: (progress: number) => void
|
|
42
106
|
): Promise<XMLHttpRequest>;
|
|
43
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Downloads the specified file from the server.
|
|
110
|
+
*
|
|
111
|
+
* @param relativePath - File relative path.
|
|
112
|
+
* @param onProgress - Download progress callback.
|
|
113
|
+
* @param signal - An
|
|
114
|
+
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
|
|
115
|
+
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
116
|
+
*/
|
|
44
117
|
downloadFile(
|
|
45
118
|
relativePath: string,
|
|
46
119
|
onProgress?: (progress: number, chunk: Uint8Array) => void,
|
|
47
120
|
signal?: AbortSignal
|
|
48
121
|
): Promise<Response>;
|
|
49
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Downloads a part of file from the server.
|
|
125
|
+
*
|
|
126
|
+
* @param relativePath - File relative path.
|
|
127
|
+
* @param reserved - Reserved, do not use.
|
|
128
|
+
* @param ranges - A range of resource file contents to download.
|
|
129
|
+
* @param onProgress - Download progress callback.
|
|
130
|
+
* @param signal - An
|
|
131
|
+
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
|
|
132
|
+
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
133
|
+
*/
|
|
50
134
|
downloadFileRange(
|
|
51
135
|
relativePath: string,
|
|
52
|
-
|
|
136
|
+
reserved: number,
|
|
53
137
|
ranges: Array<{ begin: number; end: number; requestId: number }>,
|
|
54
138
|
onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void,
|
|
55
139
|
signal?: AbortSignal
|