@itwin/access-control-client 0.1.0 → 1.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 (51) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/CONTRIBUTING.md +90 -0
  3. package/GETTINGSTARTED.md +33 -0
  4. package/README.md +321 -1
  5. package/lib/cjs/AccessControlClient.d.ts +2 -0
  6. package/lib/cjs/AccessControlClient.d.ts.map +1 -1
  7. package/lib/cjs/AccessControlClient.js +5 -4
  8. package/lib/cjs/AccessControlClient.js.map +1 -1
  9. package/lib/cjs/accessControlTypes.d.ts +11 -15
  10. package/lib/cjs/accessControlTypes.d.ts.map +1 -1
  11. package/lib/cjs/accessControlTypes.js.map +1 -1
  12. package/lib/cjs/subClients/BaseClient.d.ts +1 -1
  13. package/lib/cjs/subClients/BaseClient.d.ts.map +1 -1
  14. package/lib/cjs/subClients/BaseClient.js +11 -6
  15. package/lib/cjs/subClients/BaseClient.js.map +1 -1
  16. package/lib/cjs/subClients/MembersClient.d.ts +3 -2
  17. package/lib/cjs/subClients/MembersClient.d.ts.map +1 -1
  18. package/lib/cjs/subClients/MembersClient.js +3 -0
  19. package/lib/cjs/subClients/MembersClient.js.map +1 -1
  20. package/lib/cjs/subClients/PermissionsClient.d.ts +1 -0
  21. package/lib/cjs/subClients/PermissionsClient.d.ts.map +1 -1
  22. package/lib/cjs/subClients/PermissionsClient.js +3 -0
  23. package/lib/cjs/subClients/PermissionsClient.js.map +1 -1
  24. package/lib/cjs/subClients/RolesClient.d.ts +4 -3
  25. package/lib/cjs/subClients/RolesClient.d.ts.map +1 -1
  26. package/lib/cjs/subClients/RolesClient.js +4 -1
  27. package/lib/cjs/subClients/RolesClient.js.map +1 -1
  28. package/lib/esm/AccessControlClient.d.ts +2 -0
  29. package/lib/esm/AccessControlClient.d.ts.map +1 -1
  30. package/lib/esm/AccessControlClient.js +5 -4
  31. package/lib/esm/AccessControlClient.js.map +1 -1
  32. package/lib/esm/accessControlTypes.d.ts +11 -15
  33. package/lib/esm/accessControlTypes.d.ts.map +1 -1
  34. package/lib/esm/accessControlTypes.js.map +1 -1
  35. package/lib/esm/subClients/BaseClient.d.ts +1 -1
  36. package/lib/esm/subClients/BaseClient.d.ts.map +1 -1
  37. package/lib/esm/subClients/BaseClient.js +11 -6
  38. package/lib/esm/subClients/BaseClient.js.map +1 -1
  39. package/lib/esm/subClients/MembersClient.d.ts +3 -2
  40. package/lib/esm/subClients/MembersClient.d.ts.map +1 -1
  41. package/lib/esm/subClients/MembersClient.js +3 -0
  42. package/lib/esm/subClients/MembersClient.js.map +1 -1
  43. package/lib/esm/subClients/PermissionsClient.d.ts +1 -0
  44. package/lib/esm/subClients/PermissionsClient.d.ts.map +1 -1
  45. package/lib/esm/subClients/PermissionsClient.js +3 -0
  46. package/lib/esm/subClients/PermissionsClient.js.map +1 -1
  47. package/lib/esm/subClients/RolesClient.d.ts +4 -3
  48. package/lib/esm/subClients/RolesClient.d.ts.map +1 -1
  49. package/lib/esm/subClients/RolesClient.js +4 -1
  50. package/lib/esm/subClients/RolesClient.js.map +1 -1
  51. package/package.json +2 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Change Log - @itwin/access-control-client
2
+
3
+ ## 1.1.0
4
+
5
+ - Added constructor parameter to AccessControlClient for custom url.
6
+
7
+ ## 1.0.0
8
+
9
+ - Intial commit.
@@ -0,0 +1,90 @@
1
+ # Contributing
2
+
3
+ This project accepts contributions from other teams at Bentley.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Creating Issues and Enhancements](#creating-issues-and-enhancements)
8
+ - [Writing Good Bug Reports and Feature Requests](#writing-good-bug-reports-and-feature-requests)
9
+ - [Final Checklist](#final-checklist)
10
+ - [Pull Requests](#pull-requests)
11
+ - [Submitting Pull Requests](#submitting-pull-requests)
12
+ - [File Headers](#file-headers)
13
+ - [Editor Config](#editor-config)
14
+ - [VS Code](#vs-code)
15
+ - [Visual Studio](#visual-studio)
16
+
17
+ ## Creating Issues and Enhancements
18
+
19
+ Have you identified a reproducible problem in this code? Have a feature requests? Please enter a Bug or Product Backlog Item, but first make sure that you search the work items to make sure that it has not been entered yet. If you find your issue already exists, make relevant comments.
20
+
21
+ All work in this repository and every pull request must have a linked work item.
22
+
23
+ ### Writing Good Bug Reports and Feature Requests
24
+
25
+ File a single issue per problem and feature request. Do not enumerate multiple bugs or feature requests in the same issue.
26
+
27
+ Do not add your issue as a comment to an existing issue unless it's for the identical input. Many issues look similar, but have different causes.
28
+
29
+ The more information you can provide, the more likely someone will be successful at reproducing the issue and finding a fix.
30
+
31
+ Please include the following with each issue:
32
+
33
+ * Version of the code
34
+ * Your operating system
35
+ * Reproducible steps (1... 2... 3...) that cause the issue
36
+ * What you expected to see, versus what you actually saw
37
+ * Images, animations, or a link to a video showing the issue occurring
38
+ * A code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally
39
+
40
+ ### Final Checklist
41
+
42
+ Please remember to do the following:
43
+
44
+ * [ ] Search work items to ensure your report is a new issue
45
+ * [ ] Simplify your code around the issue to better isolate the problem
46
+
47
+ ## Pull Requests
48
+
49
+ We follow a [feature branch and pull request workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) to ensure that all code changes in this repository are code reviewed and all tests pass. This means that there will be a number of reviewers that formally review and sign off for changes. Reviewers should check for redundancy, optimization, stylization, and standardization in each changeset. While we will try to keep this repository as collaborative and open-source as possible, it must also be reliable.
50
+
51
+ Every change must be tested with proper unit tests. Integration tests are highly encouraged in libraries with critical workflows to ensure end-to-end consistency.
52
+
53
+ ### Submitting Pull Requests
54
+
55
+ - **DO** ensure you have added unit tests for your changes.
56
+ - **DO** run all unit tests before you submit your pull request.
57
+ - **DO** link the pull request to a Work Item.
58
+ - **DO** ensure submissions pass all Continuous Integration and are merge conflict free.
59
+ - **DO** follow the [.editorconfig](http://editorconfig.org/) settings for each directory.
60
+ - **DON'T** submit large code formatting changes without discussing with the team first.
61
+ - **DON'T** surprise us with big pull requests. Instead, file an issue and start a discussion so we can agree on a direction before you invest a large amount of time.
62
+ - **DON'T** fix merge conflicts using a merge commit. Prefer `git rebase`.
63
+ - **DON'T** mix independent, unrelated changes in one PR.
64
+
65
+ If you are unfamiliar with creating pull requests, please read [PULL_REQUESTS.md](PULL_REQUESTS.md).
66
+
67
+ These two blogs posts on contributing code to open source projects are good too: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don’t “Push” Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik.
68
+
69
+ ## File Headers
70
+
71
+ The following file headers are used in this project. Please use it for new files.
72
+
73
+ ```typescript
74
+ /*---------------------------------------------------------------------------------------------
75
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
76
+ * See LICENSE.md in the project root for license terms and full copyright notice.
77
+ *--------------------------------------------------------------------------------------------*/
78
+ ```
79
+
80
+ ## Editor Config
81
+
82
+ This project uses an `.editorconfig` file to maintain a consistent style standard (braces, tabs, etc.) across all files in the solution. For more information or to find extensions for code editors other than VS Code and Visual Studio, see the [EditorConfig](https://editorconfig.org/) website.
83
+
84
+ ### VS Code
85
+
86
+ Download the [EditorConfig for VSCode](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) to override your user/workspace settings with settings found in this repository's `.editorconfig` files.
87
+
88
+ ### Visual Studio
89
+
90
+ Visual Studio 2017 and newer comes with EditorConfig support built in. Older versions of Visual Studio will need to install the [EditorConfig extension](https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig).
@@ -0,0 +1,33 @@
1
+ ## Integration Test Setup
2
+
3
+ Make sure an `.env` file is created in the root folder. The following are the keys without the values:
4
+ ```
5
+ IMJS_AUTH_AUTHORITY=""
6
+ IMJS_URL_PREFIX=""
7
+ IMJS_OIDC_AUTHING_BROWSER_TEST_AUTHORITY=""
8
+ IMJS_OIDC_BROWSER_TEST_CLIENT_ID=""
9
+ IMJS_OIDC_BROWSER_TEST_REDIRECT_URI=""
10
+ IMJS_OIDC_BROWSER_TEST_SCOPES=""
11
+ IMJS_OIDC_AUTHING_BROWSER_TEST_SCOPES=""
12
+ IMJS_TEST_REGULAR_USER_NAME=""
13
+ IMJS_TEST_REGULAR_USER_PASSWORD=""
14
+ IMJS_TEST_REGULAR_USER_ID=""
15
+ IMJS_TEST_ASSET_ID=""
16
+ IMJS_TEST_PROJECT_ID=""
17
+ IMJS_TEST_IMODEL_ID=""
18
+ IMJS_TEST_PERMANENT_ROLE_ID1=""
19
+ IMJS_TEST_PERMANENT_ROLE_NAME1=""
20
+ IMJS_TEST_PERMANENT_ROLE_ID2=""
21
+ IMJS_TEST_PERMANENT_ROLE_NAME2=""
22
+ IMJS_TEST_TEMP_USER_EMAIL=""
23
+ IMJS_TEST_TEMP_USER_ID=""
24
+ ```
25
+
26
+ Run the following npm commands from the root folder in order.
27
+ ```
28
+ npm i
29
+ npm run build
30
+ npm run test
31
+ ```
32
+
33
+ `npm run test` runs a script defined in `package.json`.
package/README.md CHANGED
@@ -8,7 +8,327 @@ If you have questions, or wish to contribute to iTwin.js, see our [Contributing
8
8
 
9
9
  ## About this Repository
10
10
 
11
- Contains the __@itwin/access-control-client__ package that wraps sending requests to the access control service. Visit the [iTwins API](https://developer.bentley.com/apis/access-control/) for more documentation on the iTwins service.
11
+ Contains the **@itwin/access-control-client** package that wraps sending requests to the access control service. Visit the [Access Control API](https://developer.bentley.com/apis/access-control/) for more documentation on the Access Control service.
12
+
13
+ ## Usage examples
14
+
15
+ ### Get list of Roles for an iTwin
16
+
17
+ ```typescript
18
+ import type { AccessToken } from "@itwin/core-bentley";
19
+ import {
20
+ AccessControlClient,
21
+ IAccessControlClient,
22
+ Role,
23
+ AccessControlAPIResponse,
24
+ } from "@itwin/access-control-client";
25
+
26
+ /** Function that queries all Roles for a given iTwin and prints their ids to the console. */
27
+ async function printiTwinRoleIds(): Promise<void> {
28
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
29
+ const accessToken: AccessToken = { get_access_token_logic_here };
30
+
31
+ const iTwinsResponse: AccessControlAPIResponse<Role[]> =
32
+ await accessControlClient.roles.getITwinRolesAsync(
33
+ accessToken,
34
+ "2f981e83-47e4-4f36-8ee9-4264453688a1"
35
+ );
36
+
37
+ iTwinsResponse.data!.forEach((actualRole: Role) => {
38
+ console.log(actualRole.id);
39
+ });
40
+ }
41
+ ```
42
+
43
+ ### Get list of Roles for an iTwin (with custom url)
44
+
45
+ ```typescript
46
+ import type { AccessToken } from "@itwin/core-bentley";
47
+ import {
48
+ AccessControlClient,
49
+ IAccessControlClient,
50
+ Role,
51
+ AccessControlAPIResponse,
52
+ } from "@itwin/access-control-client";
53
+
54
+ /** Function that queries all Roles for a given iTwin and prints their ids to the console. */
55
+ async function printiTwinRoleIds(): Promise<void> {
56
+ const accessControlClient: IAccessControlClient = new AccessControlClient("https://api.bentley.com/accesscontrol/itwins");
57
+ const accessToken: AccessToken = { get_access_token_logic_here };
58
+
59
+ const iTwinsResponse: AccessControlAPIResponse<Role[]> =
60
+ await accessControlClient.roles.getITwinRolesAsync(
61
+ accessToken,
62
+ "2f981e83-47e4-4f36-8ee9-4264453688a1"
63
+ );
64
+
65
+ iTwinsResponse.data!.forEach((actualRole: Role) => {
66
+ console.log(actualRole.id);
67
+ });
68
+ }
69
+ ```
70
+
71
+ ### Get specific role for an iTwin
72
+
73
+ ```typescript
74
+ import type { AccessToken } from "@itwin/core-bentley";
75
+ import {
76
+ AccessControlClient,
77
+ IAccessControlClient,
78
+ Role,
79
+ AccessControlAPIResponse,
80
+ } from "@itwin/access-control-client";
81
+
82
+ /** Function that gets a specific role for an iTwin and then prints the id and displayName to the console. */
83
+ async function printiTwinRole(): Promise<void> {
84
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
85
+ const accessToken: AccessToken = { get_access_token_logic_here };
86
+
87
+ const iTwinsResponse: AccessControlAPIResponse<Role> =
88
+ await accessControlClient.roles.getITwinRoleAsync(
89
+ accessToken,
90
+ "2f981e83-47e4-4f36-8ee9-4264453688a1",
91
+ "2d593231-db14-4c1f-9db4-96f2b91b0bde"
92
+ );
93
+
94
+ const actualRole = iTwinsResponse.data!;
95
+ console.log(actualRole.id, actualRole.displayName);
96
+ }
97
+ ```
98
+
99
+ ### Create, update, and delete a Role
100
+
101
+ ```typescript
102
+ import type { AccessToken } from "@itwin/core-bentley";
103
+ import {
104
+ AccessControlClient,
105
+ IAccessControlClient,
106
+ Role,
107
+ AccessControlAPIResponse,
108
+ } from "@itwin/access-control-client";
109
+
110
+ /** Function that creates, updates, and deletes a role. */
111
+ async function printiTwinRole(): Promise<void> {
112
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
113
+ const accessToken: AccessToken = { get_access_token_logic_here };
114
+
115
+ // Create role
116
+ const createResponse: AccessControlAPIResponse<Role> =
117
+ await accessControlClient.roles.createITwinRoleAsync(
118
+ accessToken,
119
+ "71fd32ed-5ee4-4e22-bc4d-b8e973e0b7b7",
120
+ "d8215a6b-465d-44ff-910b-40d4541d1ebf"
121
+ );
122
+
123
+ // Update role
124
+ const updatedRole: Role = {
125
+ displayName: "Some new role name",
126
+ description: "UPDATED ROLE DESCRIPTION",
127
+ permissions: [],
128
+ };
129
+ const updateResponse: AccessControlAPIResponse<Role> =
130
+ await accessControlClient.roles.updateITwinRoleAsync(
131
+ accessToken,
132
+ "71fd32ed-5ee4-4e22-bc4d-b8e973e0b7b7",
133
+ createResponse.data!.id,
134
+ updatedRole
135
+ );
136
+
137
+ // Delete Role
138
+ const deleteResponse: AccessControlAPIResponse<undefined> =
139
+ await accessControlClient.roles.deleteITwinRoleAsync(
140
+ accessToken,
141
+ "71fd32ed-5ee4-4e22-bc4d-b8e973e0b7b7",
142
+ createResponse.data!.id
143
+ );
144
+ }
145
+ ```
146
+
147
+ ### Get list of Members for an iTwin
148
+
149
+ ```typescript
150
+ import type { AccessToken } from "@itwin/core-bentley";
151
+ import {
152
+ AccessControlClient,
153
+ IAccessControlClient,
154
+ Member,
155
+ AccessControlAPIResponse,
156
+ } from "@itwin/access-control-client";
157
+
158
+ /** Function that queries all Members for a given iTwin and prints their ids to the console. */
159
+ async function printiTwinMemberIds(): Promise<void> {
160
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
161
+ const accessToken: AccessToken = { get_access_token_logic_here };
162
+
163
+ const iTwinsResponse: AccessControlAPIResponse<Member[]> =
164
+ await accessControlClient.members.queryITwinMembersAsync(
165
+ accessToken,
166
+ "9bd7d24d-1508-4dba-99ab-23b3166401a0"
167
+ );
168
+
169
+ iTwinsResponse.data!.forEach((actualMember: Member) => {
170
+ console.log(actualMember.id);
171
+ });
172
+ }
173
+ ```
174
+
175
+ ### Get a filtered list of Members for an iTwin using $top/$skip
176
+
177
+ ```typescript
178
+ import type { AccessToken } from "@itwin/core-bentley";
179
+ import {
180
+ AccessControlClient,
181
+ IAccessControlClient,
182
+ Member,
183
+ AccessControlAPIResponse,
184
+ } from "@itwin/access-control-client";
185
+
186
+ /** Function that queries all Members for a given iTwin and prints their ids to the console. */
187
+ async function printiTwinMemberIds(): Promise<void> {
188
+ const skipAmmount = 5;
189
+ const topAmount = 3;
190
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
191
+ const accessToken: AccessToken = { get_access_token_logic_here };
192
+
193
+ const iTwinsResponse: AccessControlAPIResponse<Member[]> =
194
+ await accessControlClient.members.queryITwinMembersAsync(
195
+ accessToken,
196
+ "9bd7d24d-1508-4dba-99ab-23b3166401a0",
197
+ { skip: skipAmmount, top: topAmount }
198
+ );
199
+
200
+ iTwinsResponse.data!.forEach((actualMember: Member) => {
201
+ console.log(actualMember.id);
202
+ });
203
+ }
204
+ ```
205
+
206
+ ### Get a specific Member of an iTwin
207
+
208
+ ```typescript
209
+ import type { AccessToken } from "@itwin/core-bentley";
210
+ import {
211
+ AccessControlClient,
212
+ IAccessControlClient,
213
+ Member,
214
+ AccessControlAPIResponse,
215
+ } from "@itwin/access-control-client";
216
+
217
+ /** Function that gets a member of an iTwin prints the id and email to the console. */
218
+ async function printiTwinMemberIds(): Promise<void> {
219
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
220
+ const accessToken: AccessToken = { get_access_token_logic_here };
221
+
222
+ const iTwinsResponse: AccessControlAPIResponse<Member> =
223
+ await accessControlClient.members.getITwinMemberAsync(
224
+ accessToken,
225
+ "9bd7d24d-1508-4dba-99ab-23b3166401a0",
226
+ "a083cc1c-f51a-4c52-8614-5774ab79eca1"
227
+ );
228
+
229
+ const actualMember = iTwinsResponse.data!;
230
+ console.log(actualMember.id, actualMember.email);
231
+ }
232
+ ```
233
+
234
+ ### Create, update, and delete a Member
235
+
236
+ ```typescript
237
+ import type { AccessToken } from "@itwin/core-bentley";
238
+ import {
239
+ AccessControlClient,
240
+ IAccessControlClient,
241
+ Member,
242
+ AccessControlAPIResponse,
243
+ } from "@itwin/access-control-client";
244
+
245
+ /** Function that creates, updates, and deletes a member. */
246
+ async function printiTwinRole(): Promise<void> {
247
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
248
+ const accessToken: AccessToken = { get_access_token_logic_here };
249
+
250
+ // Create member
251
+ const createResponse: AccessControlAPIResponse<Role> =
252
+ await accessControlClient.members.addITwinMembersAsync(
253
+ accessToken,
254
+ "71fd32ed-5ee4-4e22-bc4d-b8e973e0b7b7",
255
+ "d8215a6b-465d-44ff-910b-40d4541d1ebf"
256
+ );
257
+
258
+ // Update member's role
259
+ const updatedMemberResponse: AccessControlAPIResponse<Member> =
260
+ await accessControlClient.members.updateITwinMemberAsync(
261
+ accessToken,
262
+ "b1803a0c-d440-4902-b527-54bf7f72500f",
263
+ "6401109c-75d7-46b8-8dbd-182d02155141",
264
+ [
265
+ "25162c0c-dce7-419e-bb51-fd13efd5b54a",
266
+ "10e3d778-0d35-4c4d-bf77-547bb366cb14",
267
+ ]
268
+ );
269
+
270
+ // Delete member
271
+ const removeMemberResponse: AccessControlAPIResponse<undefined> =
272
+ await accessControlClient.members.removeITwinMemberAsync(
273
+ accessToken,
274
+ "b1803a0c-d440-4902-b527-54bf7f72500f",
275
+ "6401109c-75d7-46b8-8dbd-182d02155141"
276
+ );
277
+ }
278
+ ```
279
+
280
+ ### Get a list of Permissions
281
+
282
+ ```typescript
283
+ import type { AccessToken } from "@itwin/core-bentley";
284
+ import {
285
+ AccessControlClient,
286
+ IAccessControlClient,
287
+ Permission,
288
+ AccessControlAPIResponse,
289
+ } from "@itwin/access-control-client";
290
+
291
+ /** Function that queries all Permissions and prints the ids to the console. */
292
+ async function printiTwinPermissionIds(): Promise<void> {
293
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
294
+ const accessToken: AccessToken = { get_access_token_logic_here };
295
+
296
+ const iTwinsResponse: AccessControlAPIResponse<Permission[]> =
297
+ await accessControlClient.permissions.getPermissionsAsync(accessToken);
298
+
299
+ iTwinsResponse.data!.forEach((actualPermission: Permission) => {
300
+ console.log(actualPermission.id);
301
+ });
302
+ }
303
+ ```
304
+
305
+ ### Get a list of Permissions for an iTwin
306
+
307
+ ```typescript
308
+ import type { AccessToken } from "@itwin/core-bentley";
309
+ import {
310
+ AccessControlClient,
311
+ IAccessControlClient,
312
+ Permission,
313
+ AccessControlAPIResponse,
314
+ } from "@itwin/access-control-client";
315
+
316
+ /** Function that queries Permissions for a given iTwin and prints the ids to the console. */
317
+ async function printiTwinPermissionIds(): Promise<void> {
318
+ const accessControlClient: IAccessControlClient = new AccessControlClient();
319
+ const accessToken: AccessToken = { get_access_token_logic_here };
320
+
321
+ const iTwinsResponse: AccessControlAPIResponse<Permission[]> =
322
+ await accessControlClient.permissions.getITwinPermissionsAsync(
323
+ accessToken,
324
+ "6c704296-9028-4a1e-ae67-c0104a11402a"
325
+ );
326
+
327
+ iTwinsResponse.data!.forEach((actualPermission: Permission) => {
328
+ console.log(actualPermission.id);
329
+ });
330
+ }
331
+ ```
12
332
 
13
333
  ## Contributing to this Repository
14
334
 
@@ -3,6 +3,8 @@
3
3
  */
4
4
  import type { IAccessControlClient, IMembersClient, IPermissionsClient, IRolesClient } from "./accessControlTypes";
5
5
  export declare class AccessControlClient implements IAccessControlClient {
6
+ private _baseUrl?;
7
+ constructor(url?: string);
6
8
  permissions: IPermissionsClient;
7
9
  roles: IRolesClient;
8
10
  members: IMembersClient;
@@ -1 +1 @@
1
- {"version":3,"file":"AccessControlClient.d.ts","sourceRoot":"","sources":["../../src/AccessControlClient.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKnH,qBAAa,mBAAoB,YAAW,oBAAoB;IACvD,WAAW,EAAE,kBAAkB,CAA2B;IAC1D,KAAK,EAAE,YAAY,CAAqB;IACxC,OAAO,EAAE,cAAc,CAAuB;CACtD"}
1
+ {"version":3,"file":"AccessControlClient.d.ts","sourceRoot":"","sources":["../../src/AccessControlClient.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKnH,qBAAa,mBAAoB,YAAW,oBAAoB;IAC9D,OAAO,CAAC,QAAQ,CAAC,CAAS;gBAEP,GAAG,CAAC,EAAE,MAAM;IAIxB,WAAW,EAAE,kBAAkB,CAAwC;IACvE,KAAK,EAAE,YAAY,CAAkC;IACrD,OAAO,EAAE,cAAc,CAAoC;CACnE"}
@@ -5,10 +5,11 @@ const MembersClient_1 = require("./subClients/MembersClient");
5
5
  const PermissionsClient_1 = require("./subClients/PermissionsClient");
6
6
  const RolesClient_1 = require("./subClients/RolesClient");
7
7
  class AccessControlClient {
8
- constructor() {
9
- this.permissions = new PermissionsClient_1.PermissionsClient();
10
- this.roles = new RolesClient_1.RolesClient();
11
- this.members = new MembersClient_1.MembersClient();
8
+ constructor(url) {
9
+ this.permissions = new PermissionsClient_1.PermissionsClient(this._baseUrl);
10
+ this.roles = new RolesClient_1.RolesClient(this._baseUrl);
11
+ this.members = new MembersClient_1.MembersClient(this._baseUrl);
12
+ this._baseUrl = url;
12
13
  }
13
14
  }
14
15
  exports.AccessControlClient = AccessControlClient;
@@ -1 +1 @@
1
- {"version":3,"file":"AccessControlClient.js","sourceRoot":"","sources":["../../src/AccessControlClient.ts"],"names":[],"mappings":";;;AAQA,8DAA2D;AAC3D,sEAAmE;AACnE,0DAAuD;AAEvD,MAAa,mBAAmB;IAAhC;QACS,gBAAW,GAAuB,IAAI,qCAAiB,EAAE,CAAC;QAC1D,UAAK,GAAiB,IAAI,yBAAW,EAAE,CAAC;QACxC,YAAO,GAAmB,IAAI,6BAAa,EAAE,CAAC;IACvD,CAAC;CAAA;AAJD,kDAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module AccessControlClient\r\n */\r\nimport type { IAccessControlClient, IMembersClient, IPermissionsClient, IRolesClient } from \"./accessControlTypes\";\r\nimport { MembersClient } from \"./subClients/MembersClient\";\r\nimport { PermissionsClient } from \"./subClients/PermissionsClient\";\r\nimport { RolesClient } from \"./subClients/RolesClient\";\r\n\r\nexport class AccessControlClient implements IAccessControlClient {\r\n public permissions: IPermissionsClient = new PermissionsClient();\r\n public roles: IRolesClient = new RolesClient();\r\n public members: IMembersClient = new MembersClient();\r\n}\r\n"]}
1
+ {"version":3,"file":"AccessControlClient.js","sourceRoot":"","sources":["../../src/AccessControlClient.ts"],"names":[],"mappings":";;;AAQA,8DAA2D;AAC3D,sEAAmE;AACnE,0DAAuD;AAEvD,MAAa,mBAAmB;IAG9B,YAAmB,GAAY;QAIxB,gBAAW,GAAuB,IAAI,qCAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvE,UAAK,GAAiB,IAAI,yBAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrD,YAAO,GAAmB,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QALhE,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;IACtB,CAAC;CAKF;AAVD,kDAUC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module AccessControlClient\r\n */\r\nimport type { IAccessControlClient, IMembersClient, IPermissionsClient, IRolesClient } from \"./accessControlTypes\";\r\nimport { MembersClient } from \"./subClients/MembersClient\";\r\nimport { PermissionsClient } from \"./subClients/PermissionsClient\";\r\nimport { RolesClient } from \"./subClients/RolesClient\";\r\n\r\nexport class AccessControlClient implements IAccessControlClient {\r\n private _baseUrl?: string;\r\n\r\n public constructor(url?: string){\r\n this._baseUrl = url;\r\n }\r\n\r\n public permissions: IPermissionsClient = new PermissionsClient(this._baseUrl);\r\n public roles: IRolesClient = new RolesClient(this._baseUrl);\r\n public members: IMembersClient = new MembersClient(this._baseUrl);\r\n}\r\n"]}
@@ -19,7 +19,7 @@ export interface IMembersClient {
19
19
  /** Retrieves a specific member for a specified iTwin. */
20
20
  getITwinMemberAsync(accessToken: AccessToken, iTwinId: string, memberId: string): Promise<AccessControlAPIResponse<Member>>;
21
21
  /** Add new iTwin members */
22
- addITwinMembersAsync(accessToken: AccessToken, iTwinId: string, newMembers: NewMember[]): Promise<AccessControlAPIResponse<undefined>>;
22
+ addITwinMembersAsync(accessToken: AccessToken, iTwinId: string, newMembers: Member[]): Promise<AccessControlAPIResponse<undefined>>;
23
23
  /** Remove the specified iTwin member */
24
24
  removeITwinMemberAsync(accessToken: AccessToken, iTwinId: string, memberId: string): Promise<AccessControlAPIResponse<undefined>>;
25
25
  /** Update iTwin team member roles */
@@ -31,11 +31,11 @@ export interface IRolesClient {
31
31
  /** Retrieves a role for a specified iTwin */
32
32
  getITwinRoleAsync(accessToken: AccessToken, iTwinId: string, roleId: string): Promise<AccessControlAPIResponse<Role>>;
33
33
  /** Creates a new iTwin Role */
34
- createITwinRoleAsync(accessToken: AccessToken, iTwinId: string, role: NewRole): Promise<AccessControlAPIResponse<Role>>;
34
+ createITwinRoleAsync(accessToken: AccessToken, iTwinId: string, role: Role): Promise<AccessControlAPIResponse<Role>>;
35
35
  /** Removes an existing iTwin Role */
36
36
  deleteITwinRoleAsync(accessToken: AccessToken, iTwinId: string, roleId: string): Promise<AccessControlAPIResponse<undefined>>;
37
37
  /** Updates an existing iTwin Role */
38
- updateITwinRoleAsync(accessToken: AccessToken, iTwinId: string, roleId: string, role: NewRole): Promise<AccessControlAPIResponse<Role>>;
38
+ updateITwinRoleAsync(accessToken: AccessToken, iTwinId: string, roleId: string, role: Role): Promise<AccessControlAPIResponse<Role>>;
39
39
  }
40
40
  export interface AccessControlQueryArg {
41
41
  top?: number;
@@ -59,22 +59,18 @@ export interface ErrorDetail {
59
59
  }
60
60
  export declare type Permission = string;
61
61
  export interface Member {
62
- id: string;
63
- email: string;
64
- givenName: string;
65
- surname: string;
66
- organization: string;
67
- roles: Omit<Role, "permissions">[];
68
- }
69
- export interface NewMember {
70
- email: string;
71
- roleId: string;
62
+ id?: string;
63
+ roleid?: string;
64
+ email?: string;
65
+ givenName?: string;
66
+ surname?: string;
67
+ organization?: string;
68
+ roles?: Omit<Role, "permissions">[];
72
69
  }
73
70
  export interface Role {
74
- id: string;
71
+ id?: string;
75
72
  displayName: string;
76
73
  description: string;
77
74
  permissions: Permission[];
78
75
  }
79
- export declare type NewRole = Omit<Role, "id">;
80
76
  //# sourceMappingURL=accessControlTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessControlTypes.d.ts","sourceRoot":"","sources":["../../src/accessControlTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,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,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"accessControlTypes.js","sourceRoot":"","sources":["../../src/accessControlTypes.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module AccessControlClient\r\n */\r\n\r\nimport type { AccessToken } from \"@itwin/core-bentley\";\r\n\r\nexport interface IAccessControlClient {\r\n permissions: IPermissionsClient;\r\n roles: IRolesClient;\r\n members: IMembersClient;\r\n}\r\n\r\nexport interface IPermissionsClient {\r\n /** Retrieves the list of all available permissions **/\r\n getPermissionsAsync(\r\n accessToken: AccessToken,\r\n ): Promise<AccessControlAPIResponse<Permission[]>>;\r\n\r\n /** Retrieves a list of permissions the identity has for a specified iTwin */\r\n getITwinPermissionsAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string\r\n ): Promise<AccessControlAPIResponse<Permission[]>>;\r\n}\r\n\r\nexport interface IMembersClient{\r\n /** Retrieves a list of team members and their roles assigned to a specified iTwin. */\r\n queryITwinMembersAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n arg?: AccessControlQueryArg\r\n ): Promise<AccessControlAPIResponse<Member[]>>;\r\n\r\n /** Retrieves a specific member for a specified iTwin. */\r\n getITwinMemberAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n memberId: string\r\n ): Promise<AccessControlAPIResponse<Member>>;\r\n\r\n /** Add new iTwin members */\r\n addITwinMembersAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n newMembers: NewMember[]\r\n ): Promise<AccessControlAPIResponse<undefined>>;\r\n\r\n /** Remove the specified iTwin member */\r\n removeITwinMemberAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n memberId: string\r\n ): Promise<AccessControlAPIResponse<undefined>>;\r\n\r\n /** Update iTwin team member roles */\r\n updateITwinMemberAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n memberId: string,\r\n roleIds: string[]\r\n ): Promise<AccessControlAPIResponse<Member>>;\r\n}\r\n\r\nexport interface IRolesClient {\r\n /** Retrieves a list of roles the for a specified iTwin */\r\n getITwinRolesAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n ): Promise<AccessControlAPIResponse<Role[]>>;\r\n\r\n /** Retrieves a role for a specified iTwin */\r\n getITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n ): Promise<AccessControlAPIResponse<Role>>;\r\n\r\n /** Creates a new iTwin Role */\r\n createITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n role: NewRole\r\n ): Promise<AccessControlAPIResponse<Role>>;\r\n\r\n /** Removes an existing iTwin Role */\r\n deleteITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n ): Promise<AccessControlAPIResponse<undefined>>;\r\n\r\n /** Updates an existing iTwin Role */\r\n updateITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n role: NewRole\r\n ): Promise<AccessControlAPIResponse<Role>>;\r\n}\r\n\r\nexport interface AccessControlQueryArg {\r\n top?: number;\r\n skip?: number;\r\n}\r\n\r\nexport interface AccessControlAPIResponse<T> {\r\n data?: T;\r\n status: number;\r\n error?: Error;\r\n}\r\n\r\nexport interface Error {\r\n code: string;\r\n message: string;\r\n details?: ErrorDetail[];\r\n target?: string;\r\n}\r\n\r\nexport interface ErrorDetail {\r\n code: string;\r\n message: string;\r\n target?: string;\r\n}\r\n\r\nexport type Permission = string;\r\n\r\nexport interface Member {\r\n id: string;\r\n email: string;\r\n givenName: string;\r\n surname: string;\r\n organization: string;\r\n roles: Omit<Role, \"permissions\">[];\r\n}\r\n\r\nexport interface NewMember {\r\n email: string;\r\n roleId: string;\r\n}\r\n\r\nexport interface Role {\r\n id: string;\r\n displayName: string;\r\n description: string;\r\n permissions: Permission[];\r\n}\r\n\r\nexport type NewRole = Omit<Role, \"id\">;\r\n"]}
1
+ {"version":3,"file":"accessControlTypes.js","sourceRoot":"","sources":["../../src/accessControlTypes.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module AccessControlClient\r\n */\r\n\r\nimport type { AccessToken } from \"@itwin/core-bentley\";\r\n\r\nexport interface IAccessControlClient {\r\n permissions: IPermissionsClient;\r\n roles: IRolesClient;\r\n members: IMembersClient;\r\n}\r\n\r\nexport interface IPermissionsClient {\r\n /** Retrieves the list of all available permissions **/\r\n getPermissionsAsync(\r\n accessToken: AccessToken,\r\n ): Promise<AccessControlAPIResponse<Permission[]>>;\r\n\r\n /** Retrieves a list of permissions the identity has for a specified iTwin */\r\n getITwinPermissionsAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string\r\n ): Promise<AccessControlAPIResponse<Permission[]>>;\r\n}\r\n\r\nexport interface IMembersClient{\r\n /** Retrieves a list of team members and their roles assigned to a specified iTwin. */\r\n queryITwinMembersAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n arg?: AccessControlQueryArg\r\n ): Promise<AccessControlAPIResponse<Member[]>>;\r\n\r\n /** Retrieves a specific member for a specified iTwin. */\r\n getITwinMemberAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n memberId: string\r\n ): Promise<AccessControlAPIResponse<Member>>;\r\n\r\n /** Add new iTwin members */\r\n addITwinMembersAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n newMembers: Member[]\r\n ): Promise<AccessControlAPIResponse<undefined>>;\r\n\r\n /** Remove the specified iTwin member */\r\n removeITwinMemberAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n memberId: string\r\n ): Promise<AccessControlAPIResponse<undefined>>;\r\n\r\n /** Update iTwin team member roles */\r\n updateITwinMemberAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n memberId: string,\r\n roleIds: string[]\r\n ): Promise<AccessControlAPIResponse<Member>>;\r\n}\r\n\r\nexport interface IRolesClient {\r\n /** Retrieves a list of roles the for a specified iTwin */\r\n getITwinRolesAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n ): Promise<AccessControlAPIResponse<Role[]>>;\r\n\r\n /** Retrieves a role for a specified iTwin */\r\n getITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n ): Promise<AccessControlAPIResponse<Role>>;\r\n\r\n /** Creates a new iTwin Role */\r\n createITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n role: Role\r\n ): Promise<AccessControlAPIResponse<Role>>;\r\n\r\n /** Removes an existing iTwin Role */\r\n deleteITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n ): Promise<AccessControlAPIResponse<undefined>>;\r\n\r\n /** Updates an existing iTwin Role */\r\n updateITwinRoleAsync(\r\n accessToken: AccessToken,\r\n iTwinId: string,\r\n roleId: string,\r\n role: Role\r\n ): Promise<AccessControlAPIResponse<Role>>;\r\n}\r\n\r\nexport interface AccessControlQueryArg {\r\n top?: number;\r\n skip?: number;\r\n}\r\n\r\nexport interface AccessControlAPIResponse<T> {\r\n data?: T;\r\n status: number;\r\n error?: Error;\r\n}\r\n\r\nexport interface Error {\r\n code: string;\r\n message: string;\r\n details?: ErrorDetail[];\r\n target?: string;\r\n}\r\n\r\nexport interface ErrorDetail {\r\n code: string;\r\n message: string;\r\n target?: string;\r\n}\r\n\r\nexport type Permission = string;\r\n\r\nexport interface Member {\r\n id?: string;\r\n roleid?: string;\r\n email?: string;\r\n givenName?: string;\r\n surname?: string;\r\n organization?: string;\r\n roles?: Omit<Role, \"permissions\">[];\r\n}\r\n\r\nexport interface Role {\r\n id?: string;\r\n displayName: string;\r\n description: string;\r\n permissions: Permission[];\r\n}\r\n"]}
@@ -7,7 +7,7 @@ import type { AxiosRequestConfig } from "axios";
7
7
  import type { AccessControlAPIResponse, AccessControlQueryArg } from "../accessControlTypes";
8
8
  export declare class BaseClient {
9
9
  protected _baseUrl: string;
10
- constructor();
10
+ constructor(url?: string);
11
11
  /**
12
12
  * Sends a basic API request
13
13
  * @param accessTokenString The client access token string
@@ -1 +1 @@
1
- {"version":3,"file":"BaseClient.d.ts","sourceRoot":"","sources":["../../../src/subClients/BaseClient.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,wBAAwB,EAAE,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAE5F,qBAAa,UAAU;IACrB,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAkD;;IAW5E;;;;;QAKI;cACY,qBAAqB,CACnC,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd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QAAQ,EAAE,qBAAqB,GAAG,MAAM;CAgBlE"}
@@ -3,13 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseClient = void 0;
4
4
  const axios_1 = require("axios");
5
5
  class BaseClient {
6
- constructor() {
6
+ constructor(url) {
7
7
  this._baseUrl = "https://api.bentley.com/accesscontrol/itwins";
8
- const urlPrefix = process.env.IMJS_URL_PREFIX;
9
- if (urlPrefix) {
10
- const baseUrl = new URL(this._baseUrl);
11
- baseUrl.hostname = urlPrefix + baseUrl.hostname;
12
- this._baseUrl = baseUrl.href;
8
+ if (url !== undefined) {
9
+ this._baseUrl = url;
10
+ }
11
+ else {
12
+ const urlPrefix = process.env.IMJS_URL_PREFIX;
13
+ if (urlPrefix) {
14
+ const baseUrl = new URL(this._baseUrl);
15
+ baseUrl.hostname = urlPrefix + baseUrl.hostname;
16
+ this._baseUrl = baseUrl.href;
17
+ }
13
18
  }
14
19
  }
15
20
  /**