@scalekit-sdk/node 2.2.0-beta.1 → 2.2.1

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 (226) hide show
  1. package/README.md +5 -5
  2. package/{reference.md → REFERENCE.md} +530 -748
  3. package/lib/auth.d.ts +9 -6
  4. package/lib/auth.js +4 -20
  5. package/lib/auth.js.map +1 -1
  6. package/lib/connect.d.ts +3 -3
  7. package/lib/connect.js +1 -2
  8. package/lib/connect.js.map +1 -1
  9. package/lib/connection.d.ts +2 -2
  10. package/lib/connection.js +4 -4
  11. package/lib/connection.js.map +1 -1
  12. package/lib/core.js +2 -2
  13. package/lib/core.js.map +1 -1
  14. package/lib/directory.d.ts +2 -2
  15. package/lib/directory.js +7 -7
  16. package/lib/directory.js.map +1 -1
  17. package/lib/domain.d.ts +6 -5
  18. package/lib/domain.js +4 -5
  19. package/lib/domain.js.map +1 -1
  20. package/lib/errors/base-exception.d.ts +1 -1
  21. package/lib/errors/base-exception.js +1 -1
  22. package/lib/errors/base-exception.js.map +1 -1
  23. package/lib/organization.d.ts +10 -9
  24. package/lib/organization.js +11 -9
  25. package/lib/organization.js.map +1 -1
  26. package/lib/passwordless.d.ts +2 -2
  27. package/lib/passwordless.js +8 -7
  28. package/lib/passwordless.js.map +1 -1
  29. package/lib/permission.d.ts +6 -5
  30. package/lib/permission.js +10 -11
  31. package/lib/permission.js.map +1 -1
  32. package/lib/pkg/grpc/buf/validate/validate_pb.d.ts +7 -0
  33. package/lib/pkg/grpc/buf/validate/validate_pb.js +25 -0
  34. package/lib/pkg/grpc/buf/validate/validate_pb.js.map +1 -0
  35. package/lib/pkg/grpc/google/api/annotations_pb.d.ts +7 -0
  36. package/lib/pkg/grpc/google/api/annotations_pb.js +25 -0
  37. package/lib/pkg/grpc/google/api/annotations_pb.js.map +1 -0
  38. package/lib/pkg/grpc/google/api/field_behavior_pb.d.ts +7 -0
  39. package/lib/pkg/grpc/google/api/field_behavior_pb.js +25 -0
  40. package/lib/pkg/grpc/google/api/field_behavior_pb.js.map +1 -0
  41. package/lib/pkg/grpc/google/api/visibility_pb.d.ts +7 -0
  42. package/lib/pkg/grpc/google/api/visibility_pb.js +25 -0
  43. package/lib/pkg/grpc/google/api/visibility_pb.js.map +1 -0
  44. package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.d.ts +7 -0
  45. package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.js +25 -0
  46. package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.js.map +1 -0
  47. package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.d.ts +48 -42
  48. package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js +27 -263
  49. package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js.map +1 -1
  50. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +371 -325
  51. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +132 -835
  52. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
  53. package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.d.ts +113 -87
  54. package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.js +45 -201
  55. package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.js.map +1 -1
  56. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +262 -265
  57. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +92 -938
  58. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -1
  59. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +162 -157
  60. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +42 -313
  61. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
  62. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +1488 -1459
  63. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +353 -2362
  64. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
  65. package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.d.ts +520 -483
  66. package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.js +224 -1555
  67. package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.js.map +1 -1
  68. package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.d.ts +219 -191
  69. package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +96 -553
  70. package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js.map +1 -1
  71. package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.d.ts +76 -102
  72. package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +37 -393
  73. package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js.map +1 -1
  74. package/lib/pkg/grpc/scalekit/v1/options/options_pb.d.ts +36 -26
  75. package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +20 -69
  76. package/lib/pkg/grpc/scalekit/v1/options/options_pb.js.map +1 -1
  77. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +447 -400
  78. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +163 -1238
  79. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -1
  80. package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.d.ts +622 -556
  81. package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js +201 -1718
  82. package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js.map +1 -1
  83. package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.d.ts +135 -132
  84. package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js +55 -518
  85. package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js.map +1 -1
  86. package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +445 -413
  87. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +142 -1490
  88. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
  89. package/lib/role.d.ts +8 -7
  90. package/lib/role.js +14 -14
  91. package/lib/role.js.map +1 -1
  92. package/lib/scalekit.d.ts +0 -4
  93. package/lib/scalekit.js +0 -4
  94. package/lib/scalekit.js.map +1 -1
  95. package/lib/session.js +15 -24
  96. package/lib/session.js.map +1 -1
  97. package/lib/user.d.ts +6 -5
  98. package/lib/user.js +17 -20
  99. package/lib/user.js.map +1 -1
  100. package/lib/webauthn.js +6 -5
  101. package/lib/webauthn.js.map +1 -1
  102. package/package.json +12 -10
  103. package/.github/dependabot.yml +0 -10
  104. package/.nvmrc +0 -1
  105. package/buf.gen.yaml +0 -24
  106. package/jest.config.js +0 -15
  107. package/lib/connected-accounts.d.ts +0 -119
  108. package/lib/connected-accounts.js +0 -241
  109. package/lib/connected-accounts.js.map +0 -1
  110. package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.d.ts +0 -19
  111. package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.js +0 -27
  112. package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.js.map +0 -1
  113. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +0 -118
  114. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +0 -126
  115. package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +0 -1
  116. package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.d.ts +0 -37
  117. package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.js +0 -45
  118. package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.js.map +0 -1
  119. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +0 -82
  120. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +0 -90
  121. package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +0 -1
  122. package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.d.ts +0 -87
  123. package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js +0 -95
  124. package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js.map +0 -1
  125. package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.d.ts +0 -718
  126. package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js +0 -893
  127. package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js.map +0 -1
  128. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +0 -172
  129. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -180
  130. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +0 -1
  131. package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.d.ts +0 -154
  132. package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.js +0 -162
  133. package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.js.map +0 -1
  134. package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.d.ts +0 -73
  135. package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js +0 -81
  136. package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js.map +0 -1
  137. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +0 -171
  138. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +0 -179
  139. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js.map +0 -1
  140. package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.d.ts +0 -250
  141. package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js +0 -258
  142. package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js.map +0 -1
  143. package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.d.ts +0 -46
  144. package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.js +0 -54
  145. package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.js.map +0 -1
  146. package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.d.ts +0 -75
  147. package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js +0 -83
  148. package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js.map +0 -1
  149. package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.d.ts +0 -431
  150. package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js +0 -627
  151. package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js.map +0 -1
  152. package/lib/pkg/grpc/scalekit/v1/users/users_connect.d.ts +0 -173
  153. package/lib/pkg/grpc/scalekit/v1/users/users_connect.js +0 -181
  154. package/lib/pkg/grpc/scalekit/v1/users/users_connect.js.map +0 -1
  155. package/lib/tools.d.ts +0 -75
  156. package/lib/tools.js +0 -127
  157. package/lib/tools.js.map +0 -1
  158. package/src/auth.ts +0 -99
  159. package/src/connect.ts +0 -33
  160. package/src/connected-accounts.ts +0 -358
  161. package/src/connection.ts +0 -267
  162. package/src/constants/user.ts +0 -22
  163. package/src/core.ts +0 -139
  164. package/src/directory.ts +0 -431
  165. package/src/domain.ts +0 -272
  166. package/src/errors/base-exception.ts +0 -262
  167. package/src/errors/index.ts +0 -3
  168. package/src/errors/specific-exceptions.ts +0 -88
  169. package/src/index.ts +0 -10
  170. package/src/organization.ts +0 -568
  171. package/src/passwordless.ts +0 -138
  172. package/src/permission.ts +0 -310
  173. package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.ts +0 -26
  174. package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.ts +0 -342
  175. package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +0 -125
  176. package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +0 -1213
  177. package/src/pkg/grpc/scalekit/v1/auth/passwordless_connect.ts +0 -44
  178. package/src/pkg/grpc/scalekit/v1/auth/passwordless_pb.ts +0 -336
  179. package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +0 -89
  180. package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +0 -1263
  181. package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +0 -573
  182. package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.ts +0 -94
  183. package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.ts +0 -1294
  184. package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +0 -179
  185. package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +0 -3846
  186. package/src/pkg/grpc/scalekit/v1/directories/directories_connect.ts +0 -161
  187. package/src/pkg/grpc/scalekit/v1/directories/directories_pb.ts +0 -2119
  188. package/src/pkg/grpc/scalekit/v1/domains/domains_connect.ts +0 -80
  189. package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +0 -855
  190. package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +0 -524
  191. package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +0 -230
  192. package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +0 -178
  193. package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +0 -1766
  194. package/src/pkg/grpc/scalekit/v1/roles/roles_connect.ts +0 -257
  195. package/src/pkg/grpc/scalekit/v1/roles/roles_pb.ts +0 -2395
  196. package/src/pkg/grpc/scalekit/v1/sessions/sessions_connect.ts +0 -53
  197. package/src/pkg/grpc/scalekit/v1/sessions/sessions_pb.ts +0 -749
  198. package/src/pkg/grpc/scalekit/v1/tools/tools_connect.ts +0 -82
  199. package/src/pkg/grpc/scalekit/v1/tools/tools_pb.ts +0 -847
  200. package/src/pkg/grpc/scalekit/v1/users/users_connect.ts +0 -180
  201. package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +0 -2151
  202. package/src/role.ts +0 -461
  203. package/src/scalekit.ts +0 -809
  204. package/src/session.ts +0 -337
  205. package/src/tools.ts +0 -166
  206. package/src/types/auth.ts +0 -73
  207. package/src/types/organization.ts +0 -12
  208. package/src/types/scalekit.ts +0 -50
  209. package/src/types/user.ts +0 -21
  210. package/src/user.ts +0 -825
  211. package/src/webauthn.ts +0 -98
  212. package/tests/README.md +0 -25
  213. package/tests/connected-accounts.test.ts +0 -472
  214. package/tests/connection.test.ts +0 -42
  215. package/tests/directory.test.ts +0 -46
  216. package/tests/domain.test.ts +0 -293
  217. package/tests/organization.test.ts +0 -81
  218. package/tests/passwordless.test.ts +0 -108
  219. package/tests/permission.test.ts +0 -399
  220. package/tests/role.test.ts +0 -323
  221. package/tests/scalekit.test.ts +0 -104
  222. package/tests/setup.ts +0 -34
  223. package/tests/tools.test.ts +0 -239
  224. package/tests/users.test.ts +0 -168
  225. package/tests/utils/test-data.ts +0 -481
  226. package/tsconfig.json +0 -19
package/src/role.ts DELETED
@@ -1,461 +0,0 @@
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
- CreateRoleRequest,
8
- CreateRoleResponse,
9
- UpdateRoleRequest,
10
- UpdateRoleResponse,
11
- GetRoleRequest,
12
- GetRoleResponse,
13
- ListRolesRequest,
14
- ListRolesResponse,
15
- DeleteRoleRequest,
16
- CreateOrganizationRoleRequest,
17
- CreateOrganizationRoleResponse,
18
- UpdateOrganizationRoleRequest,
19
- UpdateOrganizationRoleResponse,
20
- GetOrganizationRoleRequest,
21
- GetOrganizationRoleResponse,
22
- ListOrganizationRolesRequest,
23
- ListOrganizationRolesResponse,
24
- DeleteOrganizationRoleRequest,
25
- GetRoleUsersCountRequest,
26
- GetRoleUsersCountResponse,
27
- GetOrganizationRoleUsersCountRequest,
28
- GetOrganizationRoleUsersCountResponse,
29
- UpdateDefaultOrganizationRolesRequest,
30
- UpdateDefaultOrganizationRolesResponse,
31
- DeleteOrganizationRoleBaseRequest,
32
- CreateRole,
33
- UpdateRole,
34
- CreateOrganizationRole,
35
- } from "./pkg/grpc/scalekit/v1/roles/roles_pb";
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
- */
54
- export default class RoleClient {
55
- private client: PromiseClient<typeof RolesService>;
56
-
57
- constructor(
58
- private readonly grpcConnect: GrpcConnect,
59
- private readonly coreClient: CoreClient
60
- ) {
61
- this.client = this.grpcConnect.createClient(RolesService);
62
- }
63
-
64
- /**
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}
100
- */
101
- async createRole(role: CreateRole): Promise<CreateRoleResponse> {
102
- return this.coreClient.connectExec(this.client.createRole, { role });
103
- }
104
-
105
- /**
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}
118
- */
119
- async getRole(roleName: string): Promise<GetRoleResponse> {
120
- return this.coreClient.connectExec(this.client.getRole, { roleName });
121
- }
122
-
123
- /**
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}
135
- */
136
- async listRoles(): Promise<ListRolesResponse> {
137
- return this.coreClient.connectExec(this.client.listRoles, {});
138
- }
139
-
140
- /**
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}
157
- */
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
- });
166
- }
167
-
168
- /**
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}
183
- */
184
- async deleteRole(
185
- roleName: string,
186
- reassignRoleName?: string
187
- ): Promise<Empty> {
188
- const request: PartialMessage<DeleteRoleRequest> = { roleName };
189
- if (reassignRoleName) {
190
- request.reassignRoleName = reassignRoleName;
191
- }
192
-
193
- return this.coreClient.connectExec(this.client.deleteRole, request);
194
- }
195
-
196
- /**
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}
210
- */
211
- async getRoleUsersCount(
212
- roleName: string
213
- ): Promise<GetRoleUsersCountResponse> {
214
- return this.coreClient.connectExec(this.client.getRoleUsersCount, {
215
- roleName,
216
- });
217
- }
218
-
219
- // Organization Role CRUD Methods
220
-
221
- /**
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}
246
- */
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
- });
255
- }
256
-
257
- /**
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}
273
- */
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
- });
282
- }
283
-
284
- /**
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}
300
- */
301
- async listOrganizationRoles(
302
- orgId: string
303
- ): Promise<ListOrganizationRolesResponse> {
304
- return this.coreClient.connectExec(this.client.listOrganizationRoles, {
305
- orgId,
306
- });
307
- }
308
-
309
- /**
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}
326
- */
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
- });
337
- }
338
-
339
- /**
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}
358
- */
359
- async deleteOrganizationRole(
360
- orgId: string,
361
- roleName: string,
362
- reassignRoleName?: string
363
- ): Promise<Empty> {
364
- const request: PartialMessage<DeleteOrganizationRoleRequest> = {
365
- orgId,
366
- roleName,
367
- };
368
- if (reassignRoleName) {
369
- request.reassignRoleName = reassignRoleName;
370
- }
371
-
372
- return this.coreClient.connectExec(
373
- this.client.deleteOrganizationRole,
374
- request
375
- );
376
- }
377
-
378
- /**
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}
394
- */
395
- async getOrganizationRoleUsersCount(
396
- orgId: string,
397
- roleName: string
398
- ): Promise<GetOrganizationRoleUsersCountResponse> {
399
- return this.coreClient.connectExec(
400
- this.client.getOrganizationRoleUsersCount,
401
- {
402
- orgId,
403
- roleName,
404
- }
405
- );
406
- }
407
-
408
- /**
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}
423
- */
424
- async updateDefaultOrganizationRoles(
425
- orgId: string,
426
- defaultMemberRole: string
427
- ): Promise<UpdateDefaultOrganizationRolesResponse> {
428
- return this.coreClient.connectExec(
429
- this.client.updateDefaultOrganizationRoles,
430
- {
431
- orgId,
432
- defaultMemberRole,
433
- }
434
- );
435
- }
436
-
437
- /**
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}
451
- */
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
- });
460
- }
461
- }