@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.
Files changed (82) hide show
  1. package/buf.gen.yaml +1 -0
  2. package/lib/auth.d.ts +41 -9
  3. package/lib/auth.js +44 -12
  4. package/lib/auth.js.map +1 -1
  5. package/lib/connection.d.ts +195 -21
  6. package/lib/connection.js +197 -23
  7. package/lib/connection.js.map +1 -1
  8. package/lib/core.d.ts +2 -2
  9. package/lib/core.js +13 -12
  10. package/lib/core.js.map +1 -1
  11. package/lib/directory.d.ts +293 -40
  12. package/lib/directory.js +308 -44
  13. package/lib/directory.js.map +1 -1
  14. package/lib/domain.d.ts +166 -18
  15. package/lib/domain.js +178 -29
  16. package/lib/domain.js.map +1 -1
  17. package/lib/organization.d.ts +404 -44
  18. package/lib/organization.js +419 -54
  19. package/lib/organization.js.map +1 -1
  20. package/lib/permission.d.ts +179 -35
  21. package/lib/permission.js +190 -38
  22. package/lib/permission.js.map +1 -1
  23. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +3 -3
  24. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +2 -2
  25. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +1 -1
  26. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +16 -16
  27. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +21 -21
  28. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
  29. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +82 -0
  30. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +90 -0
  31. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +1 -0
  32. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +647 -0
  33. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +993 -0
  34. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -0
  35. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +142 -0
  36. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +165 -1
  37. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
  38. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +1 -10
  39. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -9
  40. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
  41. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +28 -63
  42. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +9 -90
  43. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
  44. package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +2 -2
  45. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +1 -1
  46. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
  47. package/lib/role.d.ts +252 -56
  48. package/lib/role.js +262 -62
  49. package/lib/role.js.map +1 -1
  50. package/lib/scalekit.d.ts +323 -54
  51. package/lib/scalekit.js +354 -76
  52. package/lib/scalekit.js.map +1 -1
  53. package/lib/session.d.ts +235 -22
  54. package/lib/session.js +237 -24
  55. package/lib/session.js.map +1 -1
  56. package/lib/user.d.ts +571 -53
  57. package/lib/user.js +598 -89
  58. package/lib/user.js.map +1 -1
  59. package/lib/webauthn.d.ts +33 -0
  60. package/lib/webauthn.js +80 -0
  61. package/lib/webauthn.js.map +1 -0
  62. package/package.json +2 -2
  63. package/src/auth.ts +53 -19
  64. package/src/connection.ts +237 -62
  65. package/src/core.ts +39 -33
  66. package/src/directory.ts +356 -98
  67. package/src/domain.ts +215 -68
  68. package/src/organization.ts +490 -112
  69. package/src/permission.ts +234 -88
  70. package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +3 -3
  71. package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +24 -24
  72. package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +89 -0
  73. package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +1263 -0
  74. package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +217 -0
  75. package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +1 -10
  76. package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +42 -129
  77. package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +3 -3
  78. package/src/role.ts +336 -136
  79. package/src/scalekit.ts +478 -149
  80. package/src/session.ts +266 -63
  81. package/src/user.ts +675 -168
  82. package/src/webauthn.ts +98 -0
package/src/role.ts CHANGED
@@ -1,9 +1,9 @@
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 {
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 './pkg/grpc/scalekit/v1/roles/roles_pb';
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
- * Create a new role
49
- * @param {CreateRole} role The role creation object
50
- * @returns {Promise<CreateRoleResponse>} The created role
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
- * Get role by name
61
- * @param {string} roleName The role name
62
- * @returns {Promise<GetRoleResponse>} The role details
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
- * List all roles
73
- * @returns {Promise<ListRolesResponse>} List of roles
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
- * Update an existing role by name
84
- * @param {string} roleName The role name to update
85
- * @param {UpdateRole} role The role update object
86
- * @returns {Promise<UpdateRoleResponse>} The updated role
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(roleName: string, role: UpdateRole): Promise<UpdateRoleResponse> {
89
- return this.coreClient.connectExec(
90
- this.client.updateRole,
91
- {
92
- roleName,
93
- role
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
- * Delete role by name
100
- * @param {string} roleName The role name to be deleted
101
- * @param {string} [reassignRoleName] The role name to reassign users to when deleting this role
102
- * @returns {Promise<Empty>} Empty response
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(roleName: string, reassignRoleName?: string): Promise<Empty> {
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
- * Get the count of users associated with a role
118
- * @param {string} roleName The role name to get user count for
119
- * @returns {Promise<GetRoleUsersCountResponse>} The user count response
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(roleName: string): Promise<GetRoleUsersCountResponse> {
122
- return this.coreClient.connectExec(
123
- this.client.getRoleUsersCount,
124
- { roleName }
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
- * Create a new organization role
132
- * @param {string} orgId The organization ID
133
- * @param {CreateOrganizationRole} role The organization role creation object
134
- * @returns {Promise<CreateOrganizationRoleResponse>} The created organization role
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(orgId: string, role: CreateOrganizationRole): Promise<CreateOrganizationRoleResponse> {
137
- return this.coreClient.connectExec(
138
- this.client.createOrganizationRole,
139
- {
140
- orgId,
141
- role
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
- * Get organization role by name
148
- * @param {string} orgId The organization ID
149
- * @param {string} roleName The role name
150
- * @returns {Promise<GetOrganizationRoleResponse>} The organization role details
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(orgId: string, roleName: string): Promise<GetOrganizationRoleResponse> {
153
- return this.coreClient.connectExec(
154
- this.client.getOrganizationRole,
155
- {
156
- orgId,
157
- roleName
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
- * List all organization roles
164
- * @param {string} orgId The organization ID
165
- * @returns {Promise<ListOrganizationRolesResponse>} List of organization roles
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(orgId: string): Promise<ListOrganizationRolesResponse> {
168
- return this.coreClient.connectExec(
169
- this.client.listOrganizationRoles,
170
- { orgId }
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
- * Update an existing organization role by name
176
- * @param {string} orgId The organization ID
177
- * @param {string} roleName The role name to update
178
- * @param {UpdateRole} role The organization role update object
179
- * @returns {Promise<UpdateOrganizationRoleResponse>} The updated organization role
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(orgId: string, roleName: string, role: UpdateRole): Promise<UpdateOrganizationRoleResponse> {
182
- return this.coreClient.connectExec(
183
- this.client.updateOrganizationRole,
184
- {
185
- orgId,
186
- roleName,
187
- role
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
- * Delete organization role by name
194
- * @param {string} orgId The organization ID
195
- * @param {string} roleName The role name to be deleted
196
- * @param {string} [reassignRoleName] The role name to reassign users to when deleting this role
197
- * @returns {Promise<Empty>} Empty response
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(orgId: string, roleName: string, reassignRoleName?: string): Promise<Empty> {
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
- * Get the count of users associated with an organization role
216
- * @param {string} orgId The organization ID
217
- * @param {string} roleName The role name to get user count for
218
- * @returns {Promise<GetOrganizationRoleUsersCountResponse>} The user count response
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(orgId: string, roleName: string): Promise<GetOrganizationRoleUsersCountResponse> {
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
- * Update default organization roles
232
- * @param {string} orgId The organization ID
233
- * @param {string} defaultMemberRole The default member role name
234
- * @returns {Promise<UpdateDefaultOrganizationRolesResponse>} The updated default roles response
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(orgId: string, defaultMemberRole: string): Promise<UpdateDefaultOrganizationRolesResponse> {
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
- * Delete organization role base relationship
248
- * @param {string} orgId The organization ID
249
- * @param {string} roleName The role name to remove base relationship for
250
- * @returns {Promise<Empty>} Empty response
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(orgId: string, roleName: string): Promise<Empty> {
253
- return this.coreClient.connectExec(
254
- this.client.deleteOrganizationRoleBase,
255
- {
256
- orgId,
257
- roleName
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
  }