@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.
- package/dist/client.js +618 -322
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +393 -312
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +7 -10
- package/lib/Api/ClashTest.d.ts +4 -8
- package/lib/Api/Client.d.ts +53 -4
- package/lib/Api/Endpoint.d.ts +73 -0
- package/lib/Api/Fetch.d.ts +3 -3
- package/lib/Api/File.d.ts +32 -14
- package/lib/Api/HttpClient.d.ts +7 -7
- package/lib/Api/IFile.d.ts +1 -1
- package/lib/Api/IHttpClient.d.ts +31 -26
- package/lib/Api/ISharedLink.d.ts +36 -0
- package/lib/Api/Job.d.ts +2 -5
- package/lib/Api/Member.d.ts +2 -6
- package/lib/Api/Model.d.ts +2 -4
- package/lib/Api/OAuthClient.d.ts +2 -6
- package/lib/Api/Permission.d.ts +3 -7
- package/lib/Api/Project.d.ts +3 -7
- package/lib/Api/Role.d.ts +2 -5
- package/lib/Api/SharedFile.d.ts +9 -0
- package/lib/Api/SharedLink.d.ts +70 -0
- package/lib/Api/User.d.ts +2 -2
- package/lib/Api/XMLHttp.d.ts +1 -1
- package/lib/index.d.ts +5 -1
- package/package.json +2 -2
- package/src/Api/Assembly.ts +45 -58
- package/src/Api/ClashTest.ts +10 -24
- package/src/Api/Client.ts +88 -9
- package/src/Api/Endpoint.ts +130 -0
- package/src/Api/Fetch.ts +20 -20
- package/src/Api/File.ts +101 -75
- package/src/Api/HttpClient.ts +40 -17
- package/src/Api/IFile.ts +1 -1
- package/src/Api/IHttpClient.ts +32 -26
- package/src/Api/ISharedLink.ts +63 -0
- package/src/Api/Job.ts +7 -19
- package/src/Api/Member.ts +7 -21
- package/src/Api/Model.ts +4 -7
- package/src/Api/OAuthClient.ts +8 -24
- package/src/Api/Permission.ts +8 -22
- package/src/Api/Project.ts +30 -43
- package/src/Api/Role.ts +8 -19
- package/src/Api/SharedFile.ts +54 -0
- package/src/Api/SharedLink.ts +135 -0
- package/src/Api/User.ts +16 -16
- package/src/Api/XMLHttp.ts +1 -1
- package/src/index.ts +5 -9
package/src/Api/IHttpClient.ts
CHANGED
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
*/
|
|
27
27
|
export interface IHttpClient {
|
|
28
28
|
/**
|
|
29
|
-
* REST API server
|
|
29
|
+
* REST API server URL.
|
|
30
30
|
*/
|
|
31
31
|
serverUrl: string;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Default HTTP headers for all requests. You can add specific headers at any time.
|
|
35
35
|
*
|
|
36
36
|
* The following headers are added automatically:
|
|
37
37
|
*
|
|
@@ -51,91 +51,97 @@ export interface IHttpClient {
|
|
|
51
51
|
signInUserIsAdmin: boolean;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Sends the GET request to the specified endpoint.
|
|
54
|
+
* Sends the `GET` request to the specified endpoint.
|
|
55
55
|
*
|
|
56
56
|
* @param relativePath - Endpoint relative path.
|
|
57
|
-
* @param
|
|
58
|
-
* {@link https://developer.mozilla.org/docs/Web/API/
|
|
59
|
-
* signal, which can be used to abort waiting as desired.
|
|
57
|
+
* @param init - A set of options that can be used to configure a fetch request. See
|
|
58
|
+
* {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
|
|
60
59
|
*/
|
|
61
|
-
get(relativePath: string,
|
|
60
|
+
get(relativePath: string, init?: RequestInit): Promise<Response>;
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
|
-
* Sends the POST request to the specified endpoint.
|
|
63
|
+
* Sends the `POST` request to the specified endpoint.
|
|
65
64
|
*
|
|
66
65
|
* @param relativePath - Endpoint relative path.
|
|
67
66
|
* @param body - Request body. Can be
|
|
68
67
|
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
|
|
69
68
|
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
70
69
|
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
|
|
70
|
+
* @param init - A set of options that can be used to configure a fetch request. See
|
|
71
|
+
* {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
|
|
71
72
|
*/
|
|
72
|
-
post(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
|
73
|
+
post(relativePath: string, body?: BodyInit | object, init?: RequestInit): Promise<Response>;
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
|
-
* Sends the PUT request to the specified endpoint.
|
|
76
|
+
* Sends the `PUT` request to the specified endpoint.
|
|
76
77
|
*
|
|
77
78
|
* @param relativePath - Endpoint relative path.
|
|
78
79
|
* @param body - Request body. Can be
|
|
79
80
|
* {@link https://developer.mozilla.org/docs/Web/API/FormData | FormData},
|
|
80
81
|
* {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
|
|
81
82
|
* {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob}, JSON object or plain text.
|
|
83
|
+
* @param init - A set of options that can be used to configure a fetch request. See
|
|
84
|
+
* {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
|
|
82
85
|
*/
|
|
83
|
-
put(relativePath: string, body?: BodyInit | object): Promise<Response>;
|
|
86
|
+
put(relativePath: string, body?: BodyInit | object, init?: RequestInit): Promise<Response>;
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
|
-
* Sends the DELETE request to the specified endpoint.
|
|
89
|
+
* Sends the `DELETE` request to the specified endpoint.
|
|
87
90
|
*
|
|
88
91
|
* @param relativePath - Endpoint relative path.
|
|
92
|
+
* @param init - A set of options that can be used to configure a fetch request. See
|
|
93
|
+
* {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
|
|
89
94
|
*/
|
|
90
|
-
delete(relativePath: string): Promise<Response>;
|
|
95
|
+
delete(relativePath: string, init?: RequestInit): Promise<Response>;
|
|
91
96
|
|
|
92
97
|
/**
|
|
93
98
|
* Upload a file to the server.
|
|
94
99
|
*
|
|
95
|
-
* @param relativePath -
|
|
100
|
+
* @param relativePath - Upload endpoint relative path.
|
|
96
101
|
* @param file - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
|
|
97
102
|
* are generally retrieved from a
|
|
98
103
|
* {@link https://developer.mozilla.org/docs/Web/API/FileList | FileList} object returned as
|
|
99
104
|
* a result of a user selecting files using the HTML `<input>` element.
|
|
100
105
|
* @param onProgress - Upload progress callback.
|
|
106
|
+
* @param init - A set of options that can be used to configure a fetch request. See
|
|
107
|
+
* {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
|
|
101
108
|
*/
|
|
102
109
|
uploadFile(
|
|
103
110
|
relativePath: string,
|
|
104
111
|
file: globalThis.File,
|
|
105
|
-
onProgress?: (progress: number) => void
|
|
112
|
+
onProgress?: (progress: number) => void,
|
|
113
|
+
init?: RequestInit
|
|
106
114
|
): Promise<XMLHttpRequest>;
|
|
107
115
|
|
|
108
116
|
/**
|
|
109
117
|
* Downloads the specified file from the server.
|
|
110
118
|
*
|
|
111
|
-
* @param relativePath -
|
|
119
|
+
* @param relativePath - Download endpoint relative path.
|
|
112
120
|
* @param onProgress - Download progress callback.
|
|
113
|
-
* @param
|
|
114
|
-
* {@link https://developer.mozilla.org/docs/Web/API/
|
|
115
|
-
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
121
|
+
* @param init - A set of options that can be used to configure a fetch request. See
|
|
122
|
+
* {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
|
|
116
123
|
*/
|
|
117
124
|
downloadFile(
|
|
118
125
|
relativePath: string,
|
|
119
126
|
onProgress?: (progress: number, chunk: Uint8Array) => void,
|
|
120
|
-
|
|
127
|
+
init?: RequestInit
|
|
121
128
|
): Promise<Response>;
|
|
122
129
|
|
|
123
130
|
/**
|
|
124
131
|
* Downloads a part of file from the server.
|
|
125
132
|
*
|
|
126
|
-
* @param relativePath -
|
|
133
|
+
* @param relativePath - Download endpoint relative path.
|
|
127
134
|
* @param reserved - Reserved, do not use.
|
|
128
|
-
* @param ranges - A
|
|
135
|
+
* @param ranges - A ranges of resource file contents to download.
|
|
129
136
|
* @param onProgress - Download progress callback.
|
|
130
|
-
* @param
|
|
131
|
-
* {@link https://developer.mozilla.org/docs/Web/API/
|
|
132
|
-
* signal. Allows to communicate with a fetch request and abort it if desired.
|
|
137
|
+
* @param init - A set of options that can be used to configure a fetch request. See
|
|
138
|
+
* {@link https://developer.mozilla.org/docs/Web/API/RequestInit | RequestInit} for more details.
|
|
133
139
|
*/
|
|
134
140
|
downloadFileRange(
|
|
135
141
|
relativePath: string,
|
|
136
142
|
reserved: number,
|
|
137
143
|
ranges: Array<{ begin: number; end: number; requestId: number }>,
|
|
138
144
|
onProgress?: (progress: number, chunk: Uint8Array, requestId: number) => void,
|
|
139
|
-
|
|
145
|
+
init?: RequestInit
|
|
140
146
|
): Promise<Response>;
|
|
141
147
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Defines what actions are allowed to be performed on a file from shared link:
|
|
26
|
+
*
|
|
27
|
+
* - `read` - The ability to read file description, geometry data and properties.
|
|
28
|
+
* - `readSourceFile` - The ability to download source file.
|
|
29
|
+
* - `readViewpoint` - The ability to read file viewpoints.
|
|
30
|
+
*/
|
|
31
|
+
export type SharedLinkAction = "read" | "readSourceFile" | "readViewpoint";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Defines the shared link permissions.
|
|
35
|
+
*/
|
|
36
|
+
export interface ISharedLinkPermissions {
|
|
37
|
+
/**
|
|
38
|
+
* Defines what actions are allowed to be performed on a file from shared link:
|
|
39
|
+
*
|
|
40
|
+
* - `read` - The ability to read file description, geometry data and properties.
|
|
41
|
+
* - `readSourceFile` - The ability to download source file.
|
|
42
|
+
* - `readViewpoint` - The ability to read file viewpoints.
|
|
43
|
+
*
|
|
44
|
+
* At least one action must be defined.
|
|
45
|
+
*/
|
|
46
|
+
actions: SharedLinkAction[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Password to get access to the file.
|
|
50
|
+
*/
|
|
51
|
+
password?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* true if the shared link is password protected.
|
|
55
|
+
*/
|
|
56
|
+
readonly passwordProtected?: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Link expiration time (UTC) in the format specified in
|
|
60
|
+
* {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
|
|
61
|
+
*/
|
|
62
|
+
expiresAt?: string;
|
|
63
|
+
}
|
package/src/Api/Job.ts
CHANGED
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
+
import { Endpoint } from "./Endpoint";
|
|
25
26
|
import { waitFor } from "./Utils";
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Provides properties and methods for obtaining information about a job on the Open Cloud Server.
|
|
29
30
|
*/
|
|
30
|
-
export class Job {
|
|
31
|
+
export class Job extends Endpoint {
|
|
31
32
|
private _data: any;
|
|
32
|
-
public httpClient: IHttpClient;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @param data - Raw job data received from the server. For more information, see
|
|
@@ -37,22 +37,10 @@ export class Job {
|
|
|
37
37
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
38
38
|
*/
|
|
39
39
|
constructor(data: any, httpClient: IHttpClient) {
|
|
40
|
-
|
|
40
|
+
super(`/jobs/${data.id}`, httpClient);
|
|
41
41
|
this.data = data;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
protected internalGet(): Promise<Response> {
|
|
45
|
-
return this.httpClient.get(`/jobs/${this.data.id}`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected internalPut(body?: BodyInit | object): Promise<Response> {
|
|
49
|
-
return this.httpClient.put(`/jobs/${this.data.id}`, body);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected internalDelete(): Promise<Response> {
|
|
53
|
-
return this.httpClient.delete(`/jobs/${this.data.id}`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
44
|
/**
|
|
57
45
|
* The ID of the assembly the job is working on (internal).
|
|
58
46
|
*
|
|
@@ -184,7 +172,7 @@ export class Job {
|
|
|
184
172
|
* Reloads job data from the server.
|
|
185
173
|
*/
|
|
186
174
|
async checkout(): Promise<this> {
|
|
187
|
-
const response = await this.
|
|
175
|
+
const response = await this.get("");
|
|
188
176
|
this.data = await response.json();
|
|
189
177
|
return this;
|
|
190
178
|
}
|
|
@@ -199,7 +187,7 @@ export class Job {
|
|
|
199
187
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Jobs | Open Cloud Jobs API}.
|
|
200
188
|
*/
|
|
201
189
|
async update(data: any): Promise<this> {
|
|
202
|
-
const response = await this.
|
|
190
|
+
const response = await this.put("", data);
|
|
203
191
|
this.data = await response.json();
|
|
204
192
|
return this;
|
|
205
193
|
}
|
|
@@ -211,8 +199,8 @@ export class Job {
|
|
|
211
199
|
* @returns Returns the raw data of a deleted job. For more information, see
|
|
212
200
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Jobs | Open Cloud Jobs API}.
|
|
213
201
|
*/
|
|
214
|
-
delete(): Promise<any> {
|
|
215
|
-
return
|
|
202
|
+
override delete(): Promise<any> {
|
|
203
|
+
return super.delete("").then((response) => response.json());
|
|
216
204
|
}
|
|
217
205
|
|
|
218
206
|
// /**
|
package/src/Api/Member.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
+
import { Endpoint } from "./Endpoint";
|
|
25
26
|
import { IShortUserDesc } from "./IUser";
|
|
26
27
|
import { userFullName, userInitials } from "./Utils";
|
|
27
28
|
|
|
@@ -29,10 +30,8 @@ import { userFullName, userInitials } from "./Utils";
|
|
|
29
30
|
* Provides properties and methods for obtaining information about a {@link User | user} who has
|
|
30
31
|
* access to the {@link Project | project}.
|
|
31
32
|
*/
|
|
32
|
-
export class Member {
|
|
33
|
+
export class Member extends Endpoint {
|
|
33
34
|
private _data: any;
|
|
34
|
-
public projectId: string;
|
|
35
|
-
public httpClient: IHttpClient;
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* @param data - Raw member data received from the server. For more information, see
|
|
@@ -41,23 +40,10 @@ export class Member {
|
|
|
41
40
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
42
41
|
*/
|
|
43
42
|
constructor(data: any, projectId: string, httpClient: IHttpClient) {
|
|
44
|
-
|
|
45
|
-
this.projectId = projectId;
|
|
43
|
+
super(`/projects/${projectId}/members/${data.id}`, httpClient);
|
|
46
44
|
this.data = data;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
private internalGet(): Promise<Response> {
|
|
50
|
-
return this.httpClient.get(`/projects/${this.projectId}/members/${this.id}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private internalPut(body?: BodyInit | object): Promise<Response> {
|
|
54
|
-
return this.httpClient.put(`/projects/${this.projectId}/members/${this.id}`, body);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private internalDelete(): Promise<Response> {
|
|
58
|
-
return this.httpClient.delete(`/projects/${this.projectId}/members/${this.id}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
47
|
/**
|
|
62
48
|
* Raw member data received from the server. For more information, see
|
|
63
49
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
@@ -118,7 +104,7 @@ export class Member {
|
|
|
118
104
|
* Reloads member data from the server.
|
|
119
105
|
*/
|
|
120
106
|
async checkout(): Promise<this> {
|
|
121
|
-
const response = await this.
|
|
107
|
+
const response = await this.get("");
|
|
122
108
|
this.data = await response.json();
|
|
123
109
|
return this;
|
|
124
110
|
}
|
|
@@ -130,7 +116,7 @@ export class Member {
|
|
|
130
116
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
131
117
|
*/
|
|
132
118
|
async update(data: any): Promise<this> {
|
|
133
|
-
const response = await this.
|
|
119
|
+
const response = await this.put("", data);
|
|
134
120
|
this.data = await response.json();
|
|
135
121
|
return this;
|
|
136
122
|
}
|
|
@@ -141,8 +127,8 @@ export class Member {
|
|
|
141
127
|
* @returns Returns the raw data of a deleted member. For more information, see
|
|
142
128
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Project | Open Cloud Projects API}.
|
|
143
129
|
*/
|
|
144
|
-
delete(): Promise<any> {
|
|
145
|
-
return
|
|
130
|
+
override delete(): Promise<any> {
|
|
131
|
+
return super.delete("").then((response) => response.json());
|
|
146
132
|
}
|
|
147
133
|
|
|
148
134
|
/**
|
package/src/Api/Model.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { Endpoint } from "./Endpoint";
|
|
25
25
|
import type { File } from "./File";
|
|
26
26
|
import type { Assembly } from "./Assembly";
|
|
27
27
|
import type { IFileReferences } from "./IFile";
|
|
@@ -32,21 +32,18 @@ import type { IModelTransformMatrix } from "./IAssembly";
|
|
|
32
32
|
* {@link Assembly| assembly}. For example, for `dwg` it is a `Model` space or layout, and for
|
|
33
33
|
* `rvt` files it is a `3D` view.
|
|
34
34
|
*/
|
|
35
|
-
export class Model {
|
|
35
|
+
export class Model extends Endpoint {
|
|
36
36
|
private _data: any;
|
|
37
37
|
private _file: File | Assembly;
|
|
38
|
-
public httpClient: IHttpClient;
|
|
39
|
-
public path: string;
|
|
40
38
|
|
|
41
39
|
/**
|
|
42
40
|
* @param data - Raw model data received from the server.
|
|
43
41
|
* @param file - The file/assembly instance that owns the model.
|
|
44
42
|
*/
|
|
45
43
|
constructor(data: any, file: File | Assembly) {
|
|
46
|
-
|
|
47
|
-
this.httpClient = file.httpClient;
|
|
48
|
-
this._file = file;
|
|
44
|
+
super(`${file.path}/downloads`, file.httpClient);
|
|
49
45
|
this._data = data;
|
|
46
|
+
this._file = file;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
/**
|
package/src/Api/OAuthClient.ts
CHANGED
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
+
import { Endpoint } from "./Endpoint";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Provides properties and methods for obtaining information about a OAuth 2.0 client that have
|
|
28
29
|
* access the Open Cloud Server API.
|
|
29
30
|
*/
|
|
30
|
-
export class OAuthClient {
|
|
31
|
+
export class OAuthClient extends Endpoint {
|
|
31
32
|
private _data: any;
|
|
32
|
-
public httpClient: IHttpClient;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* @param data - Raw client data received from the server. For more information, see
|
|
@@ -37,26 +37,10 @@ export class OAuthClient {
|
|
|
37
37
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
38
38
|
*/
|
|
39
39
|
constructor(data: any, httpClient: IHttpClient) {
|
|
40
|
-
|
|
40
|
+
super(`/oauth/clients/${data.clientId}`, httpClient);
|
|
41
41
|
this.data = data;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
private internalGet(): Promise<Response> {
|
|
45
|
-
return this.httpClient.get(`/oauth/clients/${this.clientId}`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response> {
|
|
49
|
-
return this.httpClient.post(`/oauth/clients/${this.clientId}${relativePath}`, body);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private internalPut(body?: BodyInit | object): Promise<Response> {
|
|
53
|
-
return this.httpClient.put(`/oauth/clients/${this.clientId}`, body);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private internalDelete(): Promise<Response> {
|
|
57
|
-
return this.httpClient.delete(`/oauth/clients/${this.clientId}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
44
|
/**
|
|
61
45
|
* OAuth 2.0 server authorization endpoint.
|
|
62
46
|
*/
|
|
@@ -156,7 +140,7 @@ export class OAuthClient {
|
|
|
156
140
|
* Reloads clien data from the server.
|
|
157
141
|
*/
|
|
158
142
|
async checkout(): Promise<this> {
|
|
159
|
-
const response = await this.
|
|
143
|
+
const response = await this.get("");
|
|
160
144
|
this.data = await response.json();
|
|
161
145
|
return this;
|
|
162
146
|
}
|
|
@@ -171,7 +155,7 @@ export class OAuthClient {
|
|
|
171
155
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
172
156
|
*/
|
|
173
157
|
async update(data: any): Promise<this> {
|
|
174
|
-
const response = await this.
|
|
158
|
+
const response = await this.put("", data);
|
|
175
159
|
this.data = await response.json();
|
|
176
160
|
return this;
|
|
177
161
|
}
|
|
@@ -185,8 +169,8 @@ export class OAuthClient {
|
|
|
185
169
|
* @returns Returns the raw data of a deleted client. For more information, see
|
|
186
170
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
|
|
187
171
|
*/
|
|
188
|
-
delete(): Promise<any> {
|
|
189
|
-
return
|
|
172
|
+
override delete(): Promise<any> {
|
|
173
|
+
return super.delete("").then((response) => response.json());
|
|
190
174
|
}
|
|
191
175
|
|
|
192
176
|
/**
|
|
@@ -204,7 +188,7 @@ export class OAuthClient {
|
|
|
204
188
|
* Revokes the access tokens for all users of the client application.
|
|
205
189
|
*/
|
|
206
190
|
async revoke(): Promise<this> {
|
|
207
|
-
await this.
|
|
191
|
+
await this.post("/revoke");
|
|
208
192
|
return this;
|
|
209
193
|
}
|
|
210
194
|
}
|
package/src/Api/Permission.ts
CHANGED
|
@@ -22,16 +22,15 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IHttpClient } from "./IHttpClient";
|
|
25
|
+
import { Endpoint } from "./Endpoint";
|
|
25
26
|
import { IGrantedTo } from "./IFile";
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Provides properties and methods for obtaining information about {@link File | file} actions
|
|
29
30
|
* granted to a specific user, project, or group.
|
|
30
31
|
*/
|
|
31
|
-
export class Permission {
|
|
32
|
+
export class Permission extends Endpoint {
|
|
32
33
|
private _data: any;
|
|
33
|
-
public fileId: string;
|
|
34
|
-
public httpClient: IHttpClient;
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* @param data - Raw permission data received from the server. For more information, see
|
|
@@ -40,28 +39,15 @@ export class Permission {
|
|
|
40
39
|
* @param httpClient - HTTP client instance used to send requests to the REST API server.
|
|
41
40
|
*/
|
|
42
41
|
constructor(data: any, fileId: string, httpClient: IHttpClient) {
|
|
43
|
-
|
|
44
|
-
this.fileId = fileId;
|
|
42
|
+
super(`/files/${fileId}/permissions/${data.id}`, httpClient);
|
|
45
43
|
this.data = data;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
private internalGet(): Promise<Response> {
|
|
49
|
-
return this.httpClient.get(`/files/${this.fileId}/permissions/${this.id}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private internalPut(body?: BodyInit | object): Promise<Response> {
|
|
53
|
-
return this.httpClient.put(`/files/${this.fileId}/permissions/${this.id}`, body);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private internalDelete(): Promise<Response> {
|
|
57
|
-
return this.httpClient.delete(`/files/${this.fileId}/permissions/${this.id}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
46
|
/**
|
|
61
47
|
* Defines what actions are allowed to be performed on a file with this permission:
|
|
62
48
|
*
|
|
63
49
|
* - `read` - The ability to read file description, geometry data and properties.
|
|
64
|
-
* - `readSourceFile` - The ability to
|
|
50
|
+
* - `readSourceFile` - The ability to download source file.
|
|
65
51
|
* - `write` - The ability to modify file name, description and references.
|
|
66
52
|
* - `readViewpoint` - The ability to read file viewpoints.
|
|
67
53
|
* - `createViewpoint` - The ability to create file viewpoints.
|
|
@@ -137,7 +123,7 @@ export class Permission {
|
|
|
137
123
|
* Reloads permission data from the server.
|
|
138
124
|
*/
|
|
139
125
|
async checkout(): Promise<this> {
|
|
140
|
-
const response = await this.
|
|
126
|
+
const response = await this.get("");
|
|
141
127
|
this.data = await response.json();
|
|
142
128
|
return this;
|
|
143
129
|
}
|
|
@@ -149,7 +135,7 @@ export class Permission {
|
|
|
149
135
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}.
|
|
150
136
|
*/
|
|
151
137
|
async update(data: any): Promise<this> {
|
|
152
|
-
const response = await this.
|
|
138
|
+
const response = await this.put("", data);
|
|
153
139
|
this.data = await response.json();
|
|
154
140
|
return this;
|
|
155
141
|
}
|
|
@@ -160,8 +146,8 @@ export class Permission {
|
|
|
160
146
|
* @returns Returns the raw data of a deleted permission. For more information, see
|
|
161
147
|
* {@link https://cloud.opendesign.com/docs//pages/server/api.html#Permission | Open Cloud Permissions API}.
|
|
162
148
|
*/
|
|
163
|
-
delete(): Promise<any> {
|
|
164
|
-
return
|
|
149
|
+
override delete(): Promise<any> {
|
|
150
|
+
return super.delete("").then((response) => response.json());
|
|
165
151
|
}
|
|
166
152
|
|
|
167
153
|
/**
|