@inweb/client 25.4.11 → 25.6.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.
- package/dist/client.js +307 -234
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +189 -155
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Client.d.ts +39 -18
- package/lib/Api/HttpClient.d.ts +1 -0
- package/lib/Api/IHttpClient.d.ts +1 -0
- package/lib/Api/Job.d.ts +5 -2
- package/lib/Api/Model.d.ts +2 -8
- package/lib/Api/User.d.ts +45 -27
- package/package.json +2 -2
- package/src/Api/Assembly.ts +1 -1
- package/src/Api/Client.ts +79 -43
- package/src/Api/FetchError.ts +1 -0
- package/src/Api/HttpClient.ts +1 -0
- package/src/Api/IHttpClient.ts +1 -0
- package/src/Api/Job.ts +5 -2
- package/src/Api/Model.ts +2 -8
- package/src/Api/User.ts +100 -63
package/lib/Api/Client.d.ts
CHANGED
|
@@ -99,6 +99,13 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
99
99
|
* @param token - An access token for authentication request. See {@link User.token} for more details.
|
|
100
100
|
*/
|
|
101
101
|
signInWithToken(token: string): Promise<User>;
|
|
102
|
+
private setCurrentUser;
|
|
103
|
+
private clearCurrentUser;
|
|
104
|
+
/**
|
|
105
|
+
* Returns the current logged in user information. Returns `null` if the user is not logged
|
|
106
|
+
* in or the logged in user has deleted himself.
|
|
107
|
+
*/
|
|
108
|
+
getCurrentUser(): User | null;
|
|
102
109
|
/**
|
|
103
110
|
* Get the list of server indentity providers.
|
|
104
111
|
*
|
|
@@ -111,32 +118,45 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
111
118
|
* @async
|
|
112
119
|
*/
|
|
113
120
|
getIdentityProviders(): Promise<any>;
|
|
114
|
-
private setCurrentUser;
|
|
115
|
-
private clearCurrentUser;
|
|
116
121
|
/**
|
|
117
|
-
* Returns the current
|
|
118
|
-
*
|
|
122
|
+
* Returns the current server settings.
|
|
123
|
+
*
|
|
124
|
+
* @async
|
|
119
125
|
*/
|
|
120
|
-
|
|
126
|
+
getServerSettings(): Promise<any>;
|
|
121
127
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
128
|
+
* Change server settings.
|
|
129
|
+
*
|
|
130
|
+
* Only admins can change server settings, if the current logged in user does not have
|
|
131
|
+
* administrator rights, an exception will be thrown.
|
|
132
|
+
*
|
|
133
|
+
* @async
|
|
134
|
+
*/
|
|
135
|
+
updateServerSettings(settings: any): Promise<any>;
|
|
136
|
+
/**
|
|
137
|
+
* Returns a list of server users.
|
|
138
|
+
*
|
|
139
|
+
* Only admins can get a list of users, if the current logged in user does not have
|
|
140
|
+
* administrator rights, an exception will be thrown.
|
|
124
141
|
*
|
|
125
142
|
* @async
|
|
126
143
|
*/
|
|
127
144
|
getUsers(): Promise<User[]>;
|
|
128
145
|
/**
|
|
129
|
-
* Returns the user information.
|
|
130
|
-
*
|
|
131
|
-
*
|
|
146
|
+
* Returns the user information.
|
|
147
|
+
*
|
|
148
|
+
* Only admins can get other users, if the current logged in user does not have administrator
|
|
149
|
+
* rights, hi can only get himself, otherwise an exception will be thrown.
|
|
132
150
|
*
|
|
133
151
|
* @async
|
|
134
152
|
* @param userId - User ID.
|
|
135
153
|
*/
|
|
136
154
|
getUser(userId: string): Promise<User>;
|
|
137
155
|
/**
|
|
138
|
-
* Create a new user.
|
|
139
|
-
*
|
|
156
|
+
* Create a new user.
|
|
157
|
+
*
|
|
158
|
+
* Only admins can create users, if the current logged in user does not have administrator
|
|
159
|
+
* rights, an exception will be thrown.
|
|
140
160
|
*
|
|
141
161
|
* @async
|
|
142
162
|
* @param email - User email. Cannot be empty.
|
|
@@ -150,7 +170,7 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
150
170
|
* @param params.lastName - Last name.
|
|
151
171
|
* @param params.canCreateProject - `true` if user is allowed to create a project.
|
|
152
172
|
* @param params.projectsLimit - The maximum number of projects that the user can create.
|
|
153
|
-
* @param params.storageLimit - The size of the file storage available to the user.
|
|
173
|
+
* @param params.storageLimit - The size of the file storage available to the user in bytes.
|
|
154
174
|
*/
|
|
155
175
|
createUser(email: string, password: string, params?: {
|
|
156
176
|
isAdmin?: boolean;
|
|
@@ -162,8 +182,10 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
162
182
|
storageLimit?: number;
|
|
163
183
|
}): Promise<User>;
|
|
164
184
|
/**
|
|
165
|
-
* Delete a user from the server.
|
|
166
|
-
*
|
|
185
|
+
* Delete a user from the server.
|
|
186
|
+
*
|
|
187
|
+
* Only admins can delete users, if the current logged in user does not have administrator
|
|
188
|
+
* rights, an exception will be thrown.
|
|
167
189
|
*
|
|
168
190
|
* Admins can delete themselves or other admins. An admin can only delete himself if he is
|
|
169
191
|
* not the last administrator.
|
|
@@ -443,9 +465,8 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
|
|
|
443
465
|
* @param description - Project description.
|
|
444
466
|
* @param startDate - Project start date.
|
|
445
467
|
* @param endDate - Project end date.
|
|
446
|
-
* @param avatarUrl - Project preview image URL. Can be
|
|
447
|
-
*
|
|
448
|
-
* target="_blank">Data URL</a>.
|
|
468
|
+
* @param avatarUrl - Project preview image URL. Can be
|
|
469
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
|
|
449
470
|
*/
|
|
450
471
|
createProject(name: string, description?: string, startDate?: Date | string, endDate?: Date | string, avatarUrl?: string): Promise<Project>;
|
|
451
472
|
/**
|
package/lib/Api/HttpClient.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare class HttpClient implements IHttpClient {
|
|
|
3
3
|
serverUrl: string;
|
|
4
4
|
headers: HeadersInit;
|
|
5
5
|
signInUserId: string;
|
|
6
|
+
signInUserIsAdmin: boolean;
|
|
6
7
|
constructor(serverUrl: string);
|
|
7
8
|
get(relativePath: string, signal?: AbortSignal): Promise<Response>;
|
|
8
9
|
post(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
package/lib/Api/IHttpClient.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface IHttpClient {
|
|
|
2
2
|
serverUrl: string;
|
|
3
3
|
headers: HeadersInit;
|
|
4
4
|
signInUserId: string;
|
|
5
|
+
signInUserIsAdmin: boolean;
|
|
5
6
|
get(relativePath: string, signal?: AbortSignal): Promise<Response>;
|
|
6
7
|
post(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
|
7
8
|
put(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
package/lib/Api/Job.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare class Job {
|
|
|
67
67
|
get lastUpdate(): string;
|
|
68
68
|
/**
|
|
69
69
|
* Job type. Can be `properties`, `geomerty`, `geomertyGltf`, `validation`, `clash`, `dwg`,
|
|
70
|
-
* `obj`, `gltf`, `glb`, `vsf`, `pdf` or
|
|
70
|
+
* `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` or custom job name.
|
|
71
71
|
*
|
|
72
72
|
* @readonly
|
|
73
73
|
*/
|
|
@@ -104,7 +104,10 @@ export declare class Job {
|
|
|
104
104
|
*/
|
|
105
105
|
checkout(): Promise<this>;
|
|
106
106
|
/**
|
|
107
|
-
* Update job data on the server.
|
|
107
|
+
* Update job data on the server.
|
|
108
|
+
*
|
|
109
|
+
* Only admins can update job data, if the current logged in user does not have administrator
|
|
110
|
+
* rights, an exception will be thrown.
|
|
108
111
|
*
|
|
109
112
|
* @async
|
|
110
113
|
* @param data - Raw job data.
|
package/lib/Api/Model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IHttpClient } from "./IHttpClient";
|
|
2
|
-
import { File } from "./File";
|
|
3
|
-
import { Assembly } from "./Assembly";
|
|
2
|
+
import type { File } from "./File";
|
|
3
|
+
import type { Assembly } from "./Assembly";
|
|
4
4
|
/**
|
|
5
5
|
* The class representing the is a description of view of the file or assembly. For example,
|
|
6
6
|
* for `dwg` it is a `Model` space or layout, and for `rvt` files it is a `3D` view.
|
|
@@ -103,16 +103,12 @@ export declare class Model {
|
|
|
103
103
|
/**
|
|
104
104
|
* Returns model viewpoint list.
|
|
105
105
|
*
|
|
106
|
-
* _**Note**: Assemblу models do not support viewpoints_.
|
|
107
|
-
*
|
|
108
106
|
* @async
|
|
109
107
|
*/
|
|
110
108
|
getViewpoints(): Promise<any[]>;
|
|
111
109
|
/**
|
|
112
110
|
* Add new model viewpoint. To create a new viewpoint use `Viewer.createViewpoint()`.
|
|
113
111
|
*
|
|
114
|
-
* _**Note**: Assemblу models do not support viewpoints_.
|
|
115
|
-
*
|
|
116
112
|
* @async
|
|
117
113
|
* @param viewpoint - Viewpoint.
|
|
118
114
|
*/
|
|
@@ -120,8 +116,6 @@ export declare class Model {
|
|
|
120
116
|
/**
|
|
121
117
|
* Delete model viewpoint.
|
|
122
118
|
*
|
|
123
|
-
* _**Note**: Assemblу models do not support viewpoints_.
|
|
124
|
-
*
|
|
125
119
|
* @async
|
|
126
120
|
* @param guid - Viewpoint GUID.
|
|
127
121
|
* @returns Returns the raw data of a deleted viewpoint.
|
package/lib/Api/User.d.ts
CHANGED
|
@@ -23,8 +23,8 @@ export declare class User {
|
|
|
23
23
|
*/
|
|
24
24
|
get canCreateProject(): boolean;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Account registration time (UTC) in the format specified in
|
|
27
|
+
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
|
|
28
28
|
*
|
|
29
29
|
* @readonly
|
|
30
30
|
*/
|
|
@@ -85,8 +85,8 @@ export declare class User {
|
|
|
85
85
|
*/
|
|
86
86
|
get isEmailConfirmed(): boolean;
|
|
87
87
|
/**
|
|
88
|
-
* User last update time (UTC) in the format specified in
|
|
89
|
-
*
|
|
88
|
+
* User last update time (UTC) in the format specified in
|
|
89
|
+
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
|
|
90
90
|
*/
|
|
91
91
|
get lastModified(): string;
|
|
92
92
|
/**
|
|
@@ -95,8 +95,8 @@ export declare class User {
|
|
|
95
95
|
get lastName(): string;
|
|
96
96
|
set lastName(value: string);
|
|
97
97
|
/**
|
|
98
|
-
* User last sign in time (UTC) in the format specified in
|
|
99
|
-
*
|
|
98
|
+
* User last sign in time (UTC) in the format specified in
|
|
99
|
+
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
|
|
100
100
|
*/
|
|
101
101
|
get lastSignIn(): string;
|
|
102
102
|
/**
|
|
@@ -105,6 +105,10 @@ export declare class User {
|
|
|
105
105
|
* @readonly
|
|
106
106
|
*/
|
|
107
107
|
get projectsLimit(): number;
|
|
108
|
+
/**
|
|
109
|
+
* The identity provider used to create the account. Can be `ldap`, `oauth`, `saml` or empty.
|
|
110
|
+
*/
|
|
111
|
+
get providerType(): string;
|
|
108
112
|
/**
|
|
109
113
|
* The user's access token (API key). Use {@link Client.signInWithToken()} to log in using token.
|
|
110
114
|
*
|
|
@@ -117,23 +121,27 @@ export declare class User {
|
|
|
117
121
|
get userName(): string;
|
|
118
122
|
set userName(value: string);
|
|
119
123
|
/**
|
|
120
|
-
* Refresh user data.
|
|
121
|
-
*
|
|
122
|
-
*
|
|
124
|
+
* Refresh user data.
|
|
125
|
+
*
|
|
126
|
+
* Only admins can checkout other users, if the current logged in user does not have
|
|
127
|
+
* administrator rights, hi can only checkout himself, otherwise an exception will be thrown.
|
|
123
128
|
*/
|
|
124
129
|
checkout(): Promise<this>;
|
|
125
130
|
/**
|
|
126
|
-
* Update user data on the server.
|
|
127
|
-
*
|
|
128
|
-
*
|
|
131
|
+
* Update user data on the server.
|
|
132
|
+
*
|
|
133
|
+
* Only admins can update other users, if the current logged in user does not have
|
|
134
|
+
* administrator rights, hi can only update himself, otherwise an exception will be thrown.
|
|
129
135
|
*
|
|
130
136
|
* @async
|
|
131
137
|
* @param data - Raw user data.
|
|
132
138
|
*/
|
|
133
139
|
update(data: any): Promise<this>;
|
|
134
140
|
/**
|
|
135
|
-
* Delete a user from the server.
|
|
136
|
-
*
|
|
141
|
+
* Delete a user from the server.
|
|
142
|
+
*
|
|
143
|
+
* Only admins can delete users, if the current logged in user does not have administrator
|
|
144
|
+
* rights, an exception will be thrown.
|
|
137
145
|
*
|
|
138
146
|
* Admins can delete themselves or other admins. An admin can only delete himself if he is
|
|
139
147
|
* not the last administrator.
|
|
@@ -152,19 +160,29 @@ export declare class User {
|
|
|
152
160
|
*/
|
|
153
161
|
save(): Promise<this>;
|
|
154
162
|
/**
|
|
155
|
-
* Set or remove the user avatar.
|
|
156
|
-
*
|
|
157
|
-
*
|
|
163
|
+
* Set or remove the user avatar.
|
|
164
|
+
*
|
|
165
|
+
* Only admins can set the avatar of other users, if the current logged in user does not have
|
|
166
|
+
* administrator rights, he can only set his own avatar, otherwise an exception will be thrown.
|
|
167
|
+
*
|
|
168
|
+
* @async
|
|
169
|
+
* @param image - Avatar image. Can be a
|
|
170
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}
|
|
171
|
+
* string,
|
|
172
|
+
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
173
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob} or Web API
|
|
174
|
+
* {@link https://developer.mozilla.org/docs/Web/API/File | File} object. Setting the
|
|
175
|
+
* `image` to `null` will remove the avatar.
|
|
176
|
+
*/
|
|
177
|
+
setAvatar(image?: BodyInit | null): Promise<this>;
|
|
178
|
+
/**
|
|
179
|
+
* Remove the user avatar.
|
|
180
|
+
*
|
|
181
|
+
* Only admins can remove the avatar of other users, if the current logged in user does not
|
|
182
|
+
* have administrator rights, they can only remove their own avatar, otherwise an exception
|
|
183
|
+
* will be thrown.
|
|
158
184
|
*
|
|
159
185
|
* @async
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
* target="_blank">Data URL</a> string, <a
|
|
163
|
-
* href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"
|
|
164
|
-
* target="_blank">ArrayBuffer</a>, <a
|
|
165
|
-
* href="https://developer.mozilla.org/docs/Web/API/Blob/Blob" target="_blank">Blob</a> or
|
|
166
|
-
* Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
|
|
167
|
-
* target="_blank">File</a> object. Setting the `image` to `null` will remove the avatar.
|
|
168
|
-
*/
|
|
169
|
-
setAvatar(image: BodyInit | null): Promise<this>;
|
|
186
|
+
*/
|
|
187
|
+
deleteAvatar(): Promise<this>;
|
|
170
188
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/client",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.6.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
|
"ts-docs": "typedoc"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inweb/eventemitter2": "~25.
|
|
29
|
+
"@inweb/eventemitter2": "~25.6.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/src/Api/Assembly.ts
CHANGED
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
+
import { FetchError } from "./FetchError";
|
|
25
26
|
import { IAssociatedFileData, IAssemblyVersionInfo } from "./IAssembly";
|
|
26
27
|
import { IShortUserDescription } from "./IUser";
|
|
27
28
|
import { Model } from "./Model";
|
|
28
29
|
import { ClashTest } from "./ClashTest";
|
|
29
30
|
import { waitFor, userFullName, userInitials } from "./Utils";
|
|
30
|
-
import { FetchError } from "./FetchError";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* The class representing a `assembly` entity.
|
package/src/Api/Client.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { EventEmitter2 } from "@inweb/eventemitter2";
|
|
|
25
25
|
|
|
26
26
|
import { IHttpClient } from "./IHttpClient";
|
|
27
27
|
import { HttpClient } from "./HttpClient";
|
|
28
|
+
import { FetchError } from "./FetchError";
|
|
28
29
|
import { ClientEventMap } from "./ClientEvents";
|
|
29
30
|
import { Assembly } from "./Assembly";
|
|
30
31
|
import { File } from "./File";
|
|
@@ -217,27 +218,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
217
218
|
return this.setCurrentUser(data);
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
/**
|
|
221
|
-
* Get the list of server indentity providers.
|
|
222
|
-
*
|
|
223
|
-
* To sign in with the provider in your web application:
|
|
224
|
-
*
|
|
225
|
-
* - Open the `provider.url` link using `window.open()`.
|
|
226
|
-
* - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
|
|
227
|
-
* message if the `error` search parameter is present, or log in with the `token` search parameter.
|
|
228
|
-
*
|
|
229
|
-
* @async
|
|
230
|
-
*/
|
|
231
|
-
getIdentityProviders(): Promise<any> {
|
|
232
|
-
return this.httpClient.get("/identity").then((response) => response.json());
|
|
233
|
-
}
|
|
234
|
-
|
|
235
221
|
// Save the current logged in user information for internal use.
|
|
236
222
|
|
|
237
223
|
private setCurrentUser(data: any): User {
|
|
238
224
|
this._user = new User(data, this.httpClient);
|
|
239
225
|
this.httpClient.headers = { Authorization: data.tokenInfo.token };
|
|
240
226
|
this.httpClient.signInUserId = this._user.id;
|
|
227
|
+
this.httpClient.signInUserIsAdmin = this._user.isAdmin;
|
|
241
228
|
return this._user;
|
|
242
229
|
}
|
|
243
230
|
|
|
@@ -245,6 +232,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
245
232
|
this._user = null;
|
|
246
233
|
this.httpClient.headers = {};
|
|
247
234
|
this.httpClient.signInUserId = "";
|
|
235
|
+
this.httpClient.signInUserIsAdmin = false;
|
|
248
236
|
}
|
|
249
237
|
|
|
250
238
|
/**
|
|
@@ -257,8 +245,46 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
257
245
|
}
|
|
258
246
|
|
|
259
247
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
248
|
+
* Get the list of server indentity providers.
|
|
249
|
+
*
|
|
250
|
+
* To sign in with the provider in your web application:
|
|
251
|
+
*
|
|
252
|
+
* - Open the `provider.url` link using `window.open()`.
|
|
253
|
+
* - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
|
|
254
|
+
* message if the `error` search parameter is present, or log in with the `token` search parameter.
|
|
255
|
+
*
|
|
256
|
+
* @async
|
|
257
|
+
*/
|
|
258
|
+
getIdentityProviders(): Promise<any> {
|
|
259
|
+
return this.httpClient.get("/identity").then((response) => response.json());
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Returns the current server settings.
|
|
264
|
+
*
|
|
265
|
+
* @async
|
|
266
|
+
*/
|
|
267
|
+
getServerSettings(): Promise<any> {
|
|
268
|
+
return this.httpClient.get("/settings").then((response) => response.json());
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Change server settings.
|
|
273
|
+
*
|
|
274
|
+
* Only admins can change server settings, if the current logged in user does not have
|
|
275
|
+
* administrator rights, an exception will be thrown.
|
|
276
|
+
*
|
|
277
|
+
* @async
|
|
278
|
+
*/
|
|
279
|
+
updateServerSettings(settings: any): Promise<any> {
|
|
280
|
+
return this.httpClient.put("/settings", settings).then((response) => response.json());
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Returns a list of server users.
|
|
285
|
+
*
|
|
286
|
+
* Only admins can get a list of users, if the current logged in user does not have
|
|
287
|
+
* administrator rights, an exception will be thrown.
|
|
262
288
|
*
|
|
263
289
|
* @async
|
|
264
290
|
*/
|
|
@@ -271,32 +297,37 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
271
297
|
}
|
|
272
298
|
|
|
273
299
|
/**
|
|
274
|
-
* Returns the user information.
|
|
275
|
-
*
|
|
276
|
-
*
|
|
300
|
+
* Returns the user information.
|
|
301
|
+
*
|
|
302
|
+
* Only admins can get other users, if the current logged in user does not have administrator
|
|
303
|
+
* rights, hi can only get himself, otherwise an exception will be thrown.
|
|
277
304
|
*
|
|
278
305
|
* @async
|
|
279
306
|
* @param userId - User ID.
|
|
280
307
|
*/
|
|
281
308
|
getUser(userId: string): Promise<User> {
|
|
282
|
-
if (
|
|
309
|
+
if (this.httpClient.signInUserIsAdmin) {
|
|
283
310
|
return this.httpClient
|
|
284
|
-
.get(
|
|
311
|
+
.get(`/users/${userId}`)
|
|
285
312
|
.then((response) => response.json())
|
|
286
|
-
.then((data) => ({ id:
|
|
313
|
+
.then((data) => ({ id: data.id, ...data.userBrief }))
|
|
287
314
|
.then((data) => new User(data, this.httpClient));
|
|
288
|
-
} else {
|
|
315
|
+
} else if (userId === this.httpClient.signInUserId) {
|
|
289
316
|
return this.httpClient
|
|
290
|
-
.get(
|
|
317
|
+
.get("/user")
|
|
291
318
|
.then((response) => response.json())
|
|
292
|
-
.then((data) => ({ id:
|
|
319
|
+
.then((data) => ({ id: userId, ...data }))
|
|
293
320
|
.then((data) => new User(data, this.httpClient));
|
|
321
|
+
} else {
|
|
322
|
+
return Promise.reject(new FetchError(403));
|
|
294
323
|
}
|
|
295
324
|
}
|
|
296
325
|
|
|
297
326
|
/**
|
|
298
|
-
* Create a new user.
|
|
299
|
-
*
|
|
327
|
+
* Create a new user.
|
|
328
|
+
*
|
|
329
|
+
* Only admins can create users, if the current logged in user does not have administrator
|
|
330
|
+
* rights, an exception will be thrown.
|
|
300
331
|
*
|
|
301
332
|
* @async
|
|
302
333
|
* @param email - User email. Cannot be empty.
|
|
@@ -310,7 +341,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
310
341
|
* @param params.lastName - Last name.
|
|
311
342
|
* @param params.canCreateProject - `true` if user is allowed to create a project.
|
|
312
343
|
* @param params.projectsLimit - The maximum number of projects that the user can create.
|
|
313
|
-
* @param params.storageLimit - The size of the file storage available to the user.
|
|
344
|
+
* @param params.storageLimit - The size of the file storage available to the user in bytes.
|
|
314
345
|
*/
|
|
315
346
|
createUser(
|
|
316
347
|
email: string,
|
|
@@ -342,8 +373,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
342
373
|
}
|
|
343
374
|
|
|
344
375
|
/**
|
|
345
|
-
* Delete a user from the server.
|
|
346
|
-
*
|
|
376
|
+
* Delete a user from the server.
|
|
377
|
+
*
|
|
378
|
+
* Only admins can delete users, if the current logged in user does not have administrator
|
|
379
|
+
* rights, an exception will be thrown.
|
|
347
380
|
*
|
|
348
381
|
* Admins can delete themselves or other admins. An admin can only delete himself if he is
|
|
349
382
|
* not the last administrator.
|
|
@@ -355,15 +388,19 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
355
388
|
* @returns Returns the raw data of a deleted user.
|
|
356
389
|
*/
|
|
357
390
|
deleteUser(userId: string): Promise<any> {
|
|
358
|
-
|
|
359
|
-
.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this.
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
391
|
+
if (this.httpClient.signInUserIsAdmin) {
|
|
392
|
+
return this.httpClient
|
|
393
|
+
.delete(`/users/${userId}`)
|
|
394
|
+
.then((response) => response.json())
|
|
395
|
+
.then((data) => {
|
|
396
|
+
if (userId === this.httpClient.signInUserId) {
|
|
397
|
+
this.clearCurrentUser();
|
|
398
|
+
}
|
|
399
|
+
return data;
|
|
400
|
+
});
|
|
401
|
+
} else {
|
|
402
|
+
return Promise.reject(new FetchError(403));
|
|
403
|
+
}
|
|
367
404
|
}
|
|
368
405
|
|
|
369
406
|
/**
|
|
@@ -851,9 +888,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
|
|
|
851
888
|
* @param description - Project description.
|
|
852
889
|
* @param startDate - Project start date.
|
|
853
890
|
* @param endDate - Project end date.
|
|
854
|
-
* @param avatarUrl - Project preview image URL. Can be
|
|
855
|
-
*
|
|
856
|
-
* target="_blank">Data URL</a>.
|
|
891
|
+
* @param avatarUrl - Project preview image URL. Can be
|
|
892
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
|
|
857
893
|
*/
|
|
858
894
|
createProject(
|
|
859
895
|
name: string,
|
package/src/Api/FetchError.ts
CHANGED
package/src/Api/HttpClient.ts
CHANGED
package/src/Api/IHttpClient.ts
CHANGED
package/src/Api/Job.ts
CHANGED
|
@@ -133,7 +133,7 @@ export class Job {
|
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Job type. Can be `properties`, `geomerty`, `geomertyGltf`, `validation`, `clash`, `dwg`,
|
|
136
|
-
* `obj`, `gltf`, `glb`, `vsf`, `pdf` or
|
|
136
|
+
* `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` or custom job name.
|
|
137
137
|
*
|
|
138
138
|
* @readonly
|
|
139
139
|
*/
|
|
@@ -190,7 +190,10 @@ export class Job {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
|
-
* Update job data on the server.
|
|
193
|
+
* Update job data on the server.
|
|
194
|
+
*
|
|
195
|
+
* Only admins can update job data, if the current logged in user does not have administrator
|
|
196
|
+
* rights, an exception will be thrown.
|
|
194
197
|
*
|
|
195
198
|
* @async
|
|
196
199
|
* @param data - Raw job data.
|
package/src/Api/Model.ts
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
-
import { File } from "./File";
|
|
26
|
-
import { Assembly } from "./Assembly";
|
|
25
|
+
import type { File } from "./File";
|
|
26
|
+
import type { Assembly } from "./Assembly";
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* The class representing the is a description of view of the file or assembly. For example,
|
|
@@ -180,8 +180,6 @@ export class Model {
|
|
|
180
180
|
/**
|
|
181
181
|
* Returns model viewpoint list.
|
|
182
182
|
*
|
|
183
|
-
* _**Note**: Assemblу models do not support viewpoints_.
|
|
184
|
-
*
|
|
185
183
|
* @async
|
|
186
184
|
*/
|
|
187
185
|
getViewpoints(): Promise<any[]> {
|
|
@@ -197,8 +195,6 @@ export class Model {
|
|
|
197
195
|
/**
|
|
198
196
|
* Add new model viewpoint. To create a new viewpoint use `Viewer.createViewpoint()`.
|
|
199
197
|
*
|
|
200
|
-
* _**Note**: Assemblу models do not support viewpoints_.
|
|
201
|
-
*
|
|
202
198
|
* @async
|
|
203
199
|
* @param viewpoint - Viewpoint.
|
|
204
200
|
*/
|
|
@@ -212,8 +208,6 @@ export class Model {
|
|
|
212
208
|
/**
|
|
213
209
|
* Delete model viewpoint.
|
|
214
210
|
*
|
|
215
|
-
* _**Note**: Assemblу models do not support viewpoints_.
|
|
216
|
-
*
|
|
217
211
|
* @async
|
|
218
212
|
* @param guid - Viewpoint GUID.
|
|
219
213
|
* @returns Returns the raw data of a deleted viewpoint.
|