@scalekit-sdk/node 2.1.7 → 2.1.8
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/buf.gen.yaml +1 -0
- package/lib/auth.d.ts +41 -9
- package/lib/auth.js +44 -12
- package/lib/auth.js.map +1 -1
- package/lib/connection.d.ts +195 -21
- package/lib/connection.js +197 -23
- package/lib/connection.js.map +1 -1
- package/lib/core.d.ts +2 -2
- package/lib/core.js +13 -12
- package/lib/core.js.map +1 -1
- package/lib/directory.d.ts +293 -40
- package/lib/directory.js +308 -44
- package/lib/directory.js.map +1 -1
- package/lib/domain.d.ts +166 -18
- package/lib/domain.js +178 -29
- package/lib/domain.js.map +1 -1
- package/lib/organization.d.ts +404 -44
- package/lib/organization.js +419 -54
- package/lib/organization.js.map +1 -1
- package/lib/permission.d.ts +179 -35
- package/lib/permission.js +190 -38
- package/lib/permission.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +3 -3
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +2 -2
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +16 -16
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +21 -21
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +82 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +90 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +647 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +993 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +142 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +165 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +1 -10
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -9
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +28 -63
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +9 -90
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +2 -2
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/role.d.ts +252 -56
- package/lib/role.js +262 -62
- package/lib/role.js.map +1 -1
- package/lib/scalekit.d.ts +323 -54
- package/lib/scalekit.js +354 -76
- package/lib/scalekit.js.map +1 -1
- package/lib/session.d.ts +235 -22
- package/lib/session.js +237 -24
- package/lib/session.js.map +1 -1
- package/lib/user.d.ts +571 -53
- package/lib/user.js +598 -89
- package/lib/user.js.map +1 -1
- package/lib/webauthn.d.ts +33 -0
- package/lib/webauthn.js +80 -0
- package/lib/webauthn.js.map +1 -0
- package/package.json +2 -2
- package/src/auth.ts +53 -19
- package/src/connection.ts +237 -62
- package/src/core.ts +39 -33
- package/src/directory.ts +356 -98
- package/src/domain.ts +215 -68
- package/src/organization.ts +490 -112
- package/src/permission.ts +234 -88
- package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +3 -3
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +24 -24
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +89 -0
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +1263 -0
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +217 -0
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +1 -10
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +42 -129
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +3 -3
- package/src/role.ts +336 -136
- package/src/scalekit.ts +478 -149
- package/src/session.ts +266 -63
- package/src/user.ts +675 -168
- package/src/webauthn.ts +98 -0
package/src/role.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Empty, PartialMessage } from
|
|
2
|
-
import { PromiseClient } from
|
|
3
|
-
import GrpcConnect from
|
|
4
|
-
import CoreClient from
|
|
5
|
-
import { RolesService } from
|
|
6
|
-
import {
|
|
1
|
+
import { Empty, PartialMessage } from "@bufbuild/protobuf";
|
|
2
|
+
import { PromiseClient } from "@connectrpc/connect";
|
|
3
|
+
import GrpcConnect from "./connect";
|
|
4
|
+
import CoreClient from "./core";
|
|
5
|
+
import { RolesService } from "./pkg/grpc/scalekit/v1/roles/roles_connect";
|
|
6
|
+
import {
|
|
7
7
|
CreateRoleRequest,
|
|
8
8
|
CreateRoleResponse,
|
|
9
9
|
UpdateRoleRequest,
|
|
@@ -31,9 +31,26 @@ import {
|
|
|
31
31
|
DeleteOrganizationRoleBaseRequest,
|
|
32
32
|
CreateRole,
|
|
33
33
|
UpdateRole,
|
|
34
|
-
CreateOrganizationRole
|
|
35
|
-
} from
|
|
34
|
+
CreateOrganizationRole,
|
|
35
|
+
} from "./pkg/grpc/scalekit/v1/roles/roles_pb";
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Client for managing roles at both environment and organization levels.
|
|
39
|
+
*
|
|
40
|
+
* Roles define sets of permissions that control user access to resources and operations.
|
|
41
|
+
* This client provides comprehensive role management including role hierarchies, permission
|
|
42
|
+
* inheritance, and both environment-wide and organization-specific roles.
|
|
43
|
+
*
|
|
44
|
+
* **Environment Roles**: Available across your entire Scalekit environment, shared by all organizations
|
|
45
|
+
* **Organization Roles**: Scoped to specific organizations for multi-tenant isolation. These are additional custom roles
|
|
46
|
+
* that are only applicable for that organization beyond the Environment Roles that are applicable for all organizations.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const scalekitClient = new ScalekitClient(envUrl, clientId, clientSecret);
|
|
50
|
+
* const roleClient = scalekitClient.role;
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Role API Documentation}
|
|
53
|
+
*/
|
|
37
54
|
export default class RoleClient {
|
|
38
55
|
private client: PromiseClient<typeof RolesService>;
|
|
39
56
|
|
|
@@ -45,166 +62,313 @@ export default class RoleClient {
|
|
|
45
62
|
}
|
|
46
63
|
|
|
47
64
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
65
|
+
* Creates a new environment-level role with specified permissions.
|
|
66
|
+
*
|
|
67
|
+
* Environment roles are available across all organizations in your environment. Use this to
|
|
68
|
+
* establish foundational access control structures, create role hierarchies, or define granular
|
|
69
|
+
* permission sets that can be reused across organizations.
|
|
70
|
+
*
|
|
71
|
+
* @param {CreateRole} role - Role creation object containing:
|
|
72
|
+
* - name: Unique role identifier (alphanumeric with underscores, 1-64 chars)
|
|
73
|
+
* - displayName: Human-readable name for display
|
|
74
|
+
* - description: Purpose and scope of the role
|
|
75
|
+
* - permissions: Array of permission strings
|
|
76
|
+
* - baseRole?: Optional parent role for permission inheritance
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise<CreateRoleResponse>} The created role with metadata
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Create a basic role
|
|
82
|
+
* const response = await scalekitClient.role.createRole({
|
|
83
|
+
* name: 'content_editor',
|
|
84
|
+
* displayName: 'Content Editor',
|
|
85
|
+
* description: 'Can create and edit content',
|
|
86
|
+
* permissions: ['content:read', 'content:write', 'content:edit']
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // Create role with inheritance
|
|
91
|
+
* await scalekitClient.role.createRole({
|
|
92
|
+
* name: 'senior_editor',
|
|
93
|
+
* displayName: 'Senior Editor',
|
|
94
|
+
* description: 'Editor with publishing rights',
|
|
95
|
+
* baseRole: 'content_editor',
|
|
96
|
+
* permissions: ['content:publish', 'content:delete']
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Create Role API}
|
|
51
100
|
*/
|
|
52
101
|
async createRole(role: CreateRole): Promise<CreateRoleResponse> {
|
|
53
|
-
return this.coreClient.connectExec(
|
|
54
|
-
this.client.createRole,
|
|
55
|
-
{ role }
|
|
56
|
-
);
|
|
102
|
+
return this.coreClient.connectExec(this.client.createRole, { role });
|
|
57
103
|
}
|
|
58
104
|
|
|
59
105
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
106
|
+
* Retrieves complete information for a specific environment role.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} roleName - Unique role identifier (alphanumeric with underscores, 1-64 chars)
|
|
109
|
+
*
|
|
110
|
+
* @returns {Promise<GetRoleResponse>} Role details including permissions and inheritance
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* const response = await scalekitClient.role.getRole('content_editor');
|
|
114
|
+
* console.log('Role:', response.role.displayName);
|
|
115
|
+
* console.log('Permissions:', response.role.permissions);
|
|
116
|
+
*
|
|
117
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Get Role API}
|
|
63
118
|
*/
|
|
64
119
|
async getRole(roleName: string): Promise<GetRoleResponse> {
|
|
65
|
-
return this.coreClient.connectExec(
|
|
66
|
-
this.client.getRole,
|
|
67
|
-
{ roleName }
|
|
68
|
-
);
|
|
120
|
+
return this.coreClient.connectExec(this.client.getRole, { roleName });
|
|
69
121
|
}
|
|
70
122
|
|
|
71
123
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
124
|
+
* Lists all environment-level roles available in your Scalekit environment.
|
|
125
|
+
*
|
|
126
|
+
* @returns {Promise<ListRolesResponse>} Array of all roles with their metadata
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* const response = await scalekitClient.role.listRoles();
|
|
130
|
+
* response.roles.forEach(role => {
|
|
131
|
+
* console.log(`${role.displayName}: ${role.permissions.length} permissions`);
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | List Roles API}
|
|
74
135
|
*/
|
|
75
136
|
async listRoles(): Promise<ListRolesResponse> {
|
|
76
|
-
return this.coreClient.connectExec(
|
|
77
|
-
this.client.listRoles,
|
|
78
|
-
{}
|
|
79
|
-
);
|
|
137
|
+
return this.coreClient.connectExec(this.client.listRoles, {});
|
|
80
138
|
}
|
|
81
139
|
|
|
82
140
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
141
|
+
* Updates an existing environment role's properties and permissions.
|
|
142
|
+
*
|
|
143
|
+
* Only specified fields are updated. The new permission list replaces existing permissions.
|
|
144
|
+
*
|
|
145
|
+
* @param {string} roleName - Role to update
|
|
146
|
+
* @param {UpdateRole} role - Updated role properties
|
|
147
|
+
*
|
|
148
|
+
* @returns {Promise<UpdateRoleResponse>} Updated role details
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* await scalekitClient.role.updateRole('content_editor', {
|
|
152
|
+
* displayName: 'Content Editor (Updated)',
|
|
153
|
+
* permissions: ['content:read', 'content:write', 'content:edit', 'content:review']
|
|
154
|
+
* });
|
|
155
|
+
*
|
|
156
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Update Role API}
|
|
87
157
|
*/
|
|
88
|
-
async updateRole(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
);
|
|
158
|
+
async updateRole(
|
|
159
|
+
roleName: string,
|
|
160
|
+
role: UpdateRole
|
|
161
|
+
): Promise<UpdateRoleResponse> {
|
|
162
|
+
return this.coreClient.connectExec(this.client.updateRole, {
|
|
163
|
+
roleName,
|
|
164
|
+
role,
|
|
165
|
+
});
|
|
96
166
|
}
|
|
97
167
|
|
|
98
168
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
169
|
+
* Deletes an environment role and reassigns its users to another role.
|
|
170
|
+
*
|
|
171
|
+
* Cannot delete if dependent roles exist. Users must be reassigned before deletion.
|
|
172
|
+
* This operation is irreversible.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} roleName - Role to delete
|
|
175
|
+
* @param {string} [reassignRoleName] - Target role for user migration
|
|
176
|
+
*
|
|
177
|
+
* @returns {Promise<Empty>} Empty response on success
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* await scalekitClient.role.deleteRole('old_role', 'new_role');
|
|
181
|
+
*
|
|
182
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Delete Role API}
|
|
103
183
|
*/
|
|
104
|
-
async deleteRole(
|
|
184
|
+
async deleteRole(
|
|
185
|
+
roleName: string,
|
|
186
|
+
reassignRoleName?: string
|
|
187
|
+
): Promise<Empty> {
|
|
105
188
|
const request: PartialMessage<DeleteRoleRequest> = { roleName };
|
|
106
189
|
if (reassignRoleName) {
|
|
107
190
|
request.reassignRoleName = reassignRoleName;
|
|
108
191
|
}
|
|
109
|
-
|
|
110
|
-
return this.coreClient.connectExec(
|
|
111
|
-
this.client.deleteRole,
|
|
112
|
-
request
|
|
113
|
-
);
|
|
192
|
+
|
|
193
|
+
return this.coreClient.connectExec(this.client.deleteRole, request);
|
|
114
194
|
}
|
|
115
195
|
|
|
116
196
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
197
|
+
* Gets the number of users assigned to an environment role.
|
|
198
|
+
*
|
|
199
|
+
* Useful for capacity planning, security auditing, and impact assessment before role changes.
|
|
200
|
+
*
|
|
201
|
+
* @param {string} roleName - Role to count users for
|
|
202
|
+
*
|
|
203
|
+
* @returns {Promise<GetRoleUsersCountResponse>} Total user count (direct and inherited)
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* const response = await scalekitClient.role.getRoleUsersCount('admin');
|
|
207
|
+
* console.log(`${response.count} users have admin role`);
|
|
208
|
+
*
|
|
209
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Get Role User Count API}
|
|
120
210
|
*/
|
|
121
|
-
async getRoleUsersCount(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
211
|
+
async getRoleUsersCount(
|
|
212
|
+
roleName: string
|
|
213
|
+
): Promise<GetRoleUsersCountResponse> {
|
|
214
|
+
return this.coreClient.connectExec(this.client.getRoleUsersCount, {
|
|
215
|
+
roleName,
|
|
216
|
+
});
|
|
126
217
|
}
|
|
127
218
|
|
|
128
219
|
// Organization Role CRUD Methods
|
|
129
220
|
|
|
130
221
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
222
|
+
* Creates a new organization-specific role with custom permissions.
|
|
223
|
+
*
|
|
224
|
+
* Organization roles are scoped to a specific organization for multi-tenant isolation.
|
|
225
|
+
* Use this for organization-specific access control and compartmentalized role management.
|
|
226
|
+
*
|
|
227
|
+
* @param {string} orgId - Organization identifier (format: "org_...")
|
|
228
|
+
* @param {CreateOrganizationRole} role - Role configuration containing:
|
|
229
|
+
* - name: Unique role identifier within the organization
|
|
230
|
+
* - displayName: Human-readable name
|
|
231
|
+
* - description: Purpose and scope
|
|
232
|
+
* - permissions: Organization-specific permission array
|
|
233
|
+
* - baseRole?: Parent role for inheritance
|
|
234
|
+
*
|
|
235
|
+
* @returns {Promise<CreateOrganizationRoleResponse>} Created organization role
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* await scalekitClient.role.createOrganizationRole('org_123456', {
|
|
239
|
+
* name: 'department_lead',
|
|
240
|
+
* displayName: 'Department Lead',
|
|
241
|
+
* description: 'Manages department members',
|
|
242
|
+
* permissions: ['dept:members:read', 'dept:members:invite']
|
|
243
|
+
* });
|
|
244
|
+
*
|
|
245
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Create Organization Role API}
|
|
135
246
|
*/
|
|
136
|
-
async createOrganizationRole(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
);
|
|
247
|
+
async createOrganizationRole(
|
|
248
|
+
orgId: string,
|
|
249
|
+
role: CreateOrganizationRole
|
|
250
|
+
): Promise<CreateOrganizationRoleResponse> {
|
|
251
|
+
return this.coreClient.connectExec(this.client.createOrganizationRole, {
|
|
252
|
+
orgId,
|
|
253
|
+
role,
|
|
254
|
+
});
|
|
144
255
|
}
|
|
145
256
|
|
|
146
257
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* @param {string}
|
|
150
|
-
* @
|
|
258
|
+
* Retrieves details for a specific organization role.
|
|
259
|
+
*
|
|
260
|
+
* @param {string} orgId - Organization identifier
|
|
261
|
+
* @param {string} roleName - Role name to retrieve
|
|
262
|
+
*
|
|
263
|
+
* @returns {Promise<GetOrganizationRoleResponse>} Organization role details
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* const response = await scalekitClient.role.getOrganizationRole(
|
|
267
|
+
* 'org_123456',
|
|
268
|
+
* 'department_lead'
|
|
269
|
+
* );
|
|
270
|
+
* console.log('Permissions:', response.role.permissions);
|
|
271
|
+
*
|
|
272
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Get Organization Role API}
|
|
151
273
|
*/
|
|
152
|
-
async getOrganizationRole(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
274
|
+
async getOrganizationRole(
|
|
275
|
+
orgId: string,
|
|
276
|
+
roleName: string
|
|
277
|
+
): Promise<GetOrganizationRoleResponse> {
|
|
278
|
+
return this.coreClient.connectExec(this.client.getOrganizationRole, {
|
|
279
|
+
orgId,
|
|
280
|
+
roleName,
|
|
281
|
+
});
|
|
160
282
|
}
|
|
161
283
|
|
|
162
284
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
285
|
+
* Lists all roles available to an organization (environment + organization-specific).
|
|
286
|
+
*
|
|
287
|
+
* Returns both environment-level roles and organization-scoped roles.
|
|
288
|
+
*
|
|
289
|
+
* @param {string} orgId - Organization identifier
|
|
290
|
+
*
|
|
291
|
+
* @returns {Promise<ListOrganizationRolesResponse>} Array of available roles
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* const response = await scalekitClient.role.listOrganizationRoles('org_123456');
|
|
295
|
+
* response.roles.forEach(role => {
|
|
296
|
+
* console.log(`${role.displayName} (${role.scope})`);
|
|
297
|
+
* });
|
|
298
|
+
*
|
|
299
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | List Organization Roles API}
|
|
166
300
|
*/
|
|
167
|
-
async listOrganizationRoles(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
301
|
+
async listOrganizationRoles(
|
|
302
|
+
orgId: string
|
|
303
|
+
): Promise<ListOrganizationRolesResponse> {
|
|
304
|
+
return this.coreClient.connectExec(this.client.listOrganizationRoles, {
|
|
305
|
+
orgId,
|
|
306
|
+
});
|
|
172
307
|
}
|
|
173
308
|
|
|
174
309
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* @
|
|
310
|
+
* Updates an organization role's properties and permissions.
|
|
311
|
+
*
|
|
312
|
+
* Only specified fields are updated. New permissions replace existing ones.
|
|
313
|
+
*
|
|
314
|
+
* @param {string} orgId - Organization identifier
|
|
315
|
+
* @param {string} roleName - Role to update
|
|
316
|
+
* @param {UpdateRole} role - Updated role properties
|
|
317
|
+
*
|
|
318
|
+
* @returns {Promise<UpdateOrganizationRoleResponse>} Updated role
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* await scalekitClient.role.updateOrganizationRole('org_123456', 'department_lead', {
|
|
322
|
+
* permissions: ['dept:members:read', 'dept:members:invite', 'dept:members:remove']
|
|
323
|
+
* });
|
|
324
|
+
*
|
|
325
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Update Organization Role API}
|
|
180
326
|
*/
|
|
181
|
-
async updateOrganizationRole(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
327
|
+
async updateOrganizationRole(
|
|
328
|
+
orgId: string,
|
|
329
|
+
roleName: string,
|
|
330
|
+
role: UpdateRole
|
|
331
|
+
): Promise<UpdateOrganizationRoleResponse> {
|
|
332
|
+
return this.coreClient.connectExec(this.client.updateOrganizationRole, {
|
|
333
|
+
orgId,
|
|
334
|
+
roleName,
|
|
335
|
+
role,
|
|
336
|
+
});
|
|
190
337
|
}
|
|
191
338
|
|
|
192
339
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* @
|
|
340
|
+
* Deletes an organization role and reassigns its users.
|
|
341
|
+
*
|
|
342
|
+
* Cannot delete if dependent roles exist. Users must be reassigned. Operation is irreversible.
|
|
343
|
+
*
|
|
344
|
+
* @param {string} orgId - Organization identifier
|
|
345
|
+
* @param {string} roleName - Role to delete
|
|
346
|
+
* @param {string} [reassignRoleName] - Target role for user migration
|
|
347
|
+
*
|
|
348
|
+
* @returns {Promise<Empty>} Empty response on success
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* await scalekitClient.role.deleteOrganizationRole(
|
|
352
|
+
* 'org_123456',
|
|
353
|
+
* 'old_role',
|
|
354
|
+
* 'new_role'
|
|
355
|
+
* );
|
|
356
|
+
*
|
|
357
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Delete Organization Role API}
|
|
198
358
|
*/
|
|
199
|
-
async deleteOrganizationRole(
|
|
359
|
+
async deleteOrganizationRole(
|
|
360
|
+
orgId: string,
|
|
361
|
+
roleName: string,
|
|
362
|
+
reassignRoleName?: string
|
|
363
|
+
): Promise<Empty> {
|
|
200
364
|
const request: PartialMessage<DeleteOrganizationRoleRequest> = {
|
|
201
365
|
orgId,
|
|
202
|
-
roleName
|
|
366
|
+
roleName,
|
|
203
367
|
};
|
|
204
368
|
if (reassignRoleName) {
|
|
205
369
|
request.reassignRoleName = reassignRoleName;
|
|
206
370
|
}
|
|
207
|
-
|
|
371
|
+
|
|
208
372
|
return this.coreClient.connectExec(
|
|
209
373
|
this.client.deleteOrganizationRole,
|
|
210
374
|
request
|
|
@@ -212,50 +376,86 @@ export default class RoleClient {
|
|
|
212
376
|
}
|
|
213
377
|
|
|
214
378
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* @param {string}
|
|
218
|
-
* @
|
|
379
|
+
* Gets the number of users assigned to an organization role.
|
|
380
|
+
*
|
|
381
|
+
* @param {string} orgId - Organization identifier
|
|
382
|
+
* @param {string} roleName - Role to count users for
|
|
383
|
+
*
|
|
384
|
+
* @returns {Promise<GetOrganizationRoleUsersCountResponse>} User count
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* const response = await scalekitClient.role.getOrganizationRoleUsersCount(
|
|
388
|
+
* 'org_123456',
|
|
389
|
+
* 'admin'
|
|
390
|
+
* );
|
|
391
|
+
* console.log(`${response.count} admins in this organization`);
|
|
392
|
+
*
|
|
393
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Get Organization Role User Count API}
|
|
219
394
|
*/
|
|
220
|
-
async getOrganizationRoleUsersCount(
|
|
395
|
+
async getOrganizationRoleUsersCount(
|
|
396
|
+
orgId: string,
|
|
397
|
+
roleName: string
|
|
398
|
+
): Promise<GetOrganizationRoleUsersCountResponse> {
|
|
221
399
|
return this.coreClient.connectExec(
|
|
222
400
|
this.client.getOrganizationRoleUsersCount,
|
|
223
401
|
{
|
|
224
402
|
orgId,
|
|
225
|
-
roleName
|
|
403
|
+
roleName,
|
|
226
404
|
}
|
|
227
405
|
);
|
|
228
406
|
}
|
|
229
407
|
|
|
230
408
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
409
|
+
* Sets the default role automatically assigned to new organization members.
|
|
410
|
+
* This is the role that is by default assigned to every new user added to this organization.
|
|
411
|
+
*
|
|
412
|
+
* Affects all new user invitations and memberships within the organization.
|
|
413
|
+
*
|
|
414
|
+
* @param {string} orgId - Organization identifier
|
|
415
|
+
* @param {string} defaultMemberRole - Role name to assign by default
|
|
416
|
+
*
|
|
417
|
+
* @returns {Promise<UpdateDefaultOrganizationRolesResponse>} Updated configuration
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* await scalekitClient.role.updateDefaultOrganizationRoles('org_123456', 'member');
|
|
421
|
+
*
|
|
422
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Update Default Organization Roles API}
|
|
235
423
|
*/
|
|
236
|
-
async updateDefaultOrganizationRoles(
|
|
424
|
+
async updateDefaultOrganizationRoles(
|
|
425
|
+
orgId: string,
|
|
426
|
+
defaultMemberRole: string
|
|
427
|
+
): Promise<UpdateDefaultOrganizationRolesResponse> {
|
|
237
428
|
return this.coreClient.connectExec(
|
|
238
429
|
this.client.updateDefaultOrganizationRoles,
|
|
239
430
|
{
|
|
240
431
|
orgId,
|
|
241
|
-
defaultMemberRole
|
|
432
|
+
defaultMemberRole,
|
|
242
433
|
}
|
|
243
434
|
);
|
|
244
435
|
}
|
|
245
436
|
|
|
246
437
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
438
|
+
* Removes a role's inheritance relationship, eliminating inherited permissions from base role.
|
|
439
|
+
*
|
|
440
|
+
* Role retains only directly assigned permissions after removal. This action cannot be undone.
|
|
441
|
+
*
|
|
442
|
+
* @param {string} orgId - Organization identifier
|
|
443
|
+
* @param {string} roleName - Role to remove inheritance from
|
|
444
|
+
*
|
|
445
|
+
* @returns {Promise<Empty>} Empty response on success
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* await scalekitClient.role.deleteOrganizationRoleBase('org_123456', 'custom_role');
|
|
449
|
+
*
|
|
450
|
+
* @see {@link https://docs.scalekit.com/apis/#tag/roles | Delete Organization Role Base API}
|
|
251
451
|
*/
|
|
252
|
-
async deleteOrganizationRoleBase(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
);
|
|
452
|
+
async deleteOrganizationRoleBase(
|
|
453
|
+
orgId: string,
|
|
454
|
+
roleName: string
|
|
455
|
+
): Promise<Empty> {
|
|
456
|
+
return this.coreClient.connectExec(this.client.deleteOrganizationRoleBase, {
|
|
457
|
+
orgId,
|
|
458
|
+
roleName,
|
|
459
|
+
});
|
|
260
460
|
}
|
|
261
461
|
}
|