@scalekit-sdk/node 2.1.2 → 2.1.3
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/README.md +47 -11
- package/buf.gen.yaml +1 -0
- package/lib/core.js +1 -1
- package/lib/permission.d.ts +68 -0
- package/lib/permission.js +131 -0
- package/lib/permission.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +2 -2
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +16 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +4 -0
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.d.ts +0 -8
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +0 -6
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.d.ts +250 -0
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js +258 -0
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.d.ts +1157 -0
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js +1799 -0
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js.map +1 -0
- 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 +104 -0
- package/lib/role.js +205 -0
- package/lib/role.js.map +1 -0
- package/lib/scalekit.d.ts +4 -0
- package/lib/scalekit.js +4 -0
- package/lib/scalekit.js.map +1 -1
- package/package.json +1 -1
- package/src/core.ts +1 -1
- package/src/permission.ts +164 -0
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +3 -3
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +24 -0
- package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +0 -12
- package/src/pkg/grpc/scalekit/v1/roles/roles_connect.ts +257 -0
- package/src/pkg/grpc/scalekit/v1/roles/roles_pb.ts +2357 -0
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +3 -3
- package/src/role.ts +261 -0
- package/src/scalekit.ts +12 -0
- package/tests/permission.test.ts +399 -0
- package/tests/role.test.ts +323 -0
- package/tests/utils/test-data.ts +168 -1
|
@@ -1459,9 +1459,9 @@ export class Invite extends Message<Invite> {
|
|
|
1459
1459
|
userId = "";
|
|
1460
1460
|
|
|
1461
1461
|
/**
|
|
1462
|
-
* @generated from field: optional string
|
|
1462
|
+
* @generated from field: optional string inviter_email = 3;
|
|
1463
1463
|
*/
|
|
1464
|
-
|
|
1464
|
+
inviterEmail?: string;
|
|
1465
1465
|
|
|
1466
1466
|
/**
|
|
1467
1467
|
* @generated from field: string status = 4;
|
|
@@ -1498,7 +1498,7 @@ export class Invite extends Message<Invite> {
|
|
|
1498
1498
|
static readonly fields: FieldList = proto3.util.newFieldList(() => [
|
|
1499
1499
|
{ no: 1, name: "organization_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
1500
1500
|
{ no: 2, name: "user_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
1501
|
-
{ no: 3, name: "
|
|
1501
|
+
{ no: 3, name: "inviter_email", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
|
|
1502
1502
|
{ no: 4, name: "status", kind: "scalar", T: 9 /* ScalarType.STRING */ },
|
|
1503
1503
|
{ no: 5, name: "created_at", kind: "message", T: Timestamp },
|
|
1504
1504
|
{ no: 6, name: "expires_at", kind: "message", T: Timestamp },
|
package/src/role.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
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
|
+
export default class RoleClient {
|
|
38
|
+
private client: PromiseClient<typeof RolesService>;
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
private readonly grpcConnect: GrpcConnect,
|
|
42
|
+
private readonly coreClient: CoreClient
|
|
43
|
+
) {
|
|
44
|
+
this.client = this.grpcConnect.createClient(RolesService);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create a new role
|
|
49
|
+
* @param {CreateRole} role The role creation object
|
|
50
|
+
* @returns {Promise<CreateRoleResponse>} The created role
|
|
51
|
+
*/
|
|
52
|
+
async createRole(role: CreateRole): Promise<CreateRoleResponse> {
|
|
53
|
+
return this.coreClient.connectExec(
|
|
54
|
+
this.client.createRole,
|
|
55
|
+
{ role }
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get role by name
|
|
61
|
+
* @param {string} roleName The role name
|
|
62
|
+
* @returns {Promise<GetRoleResponse>} The role details
|
|
63
|
+
*/
|
|
64
|
+
async getRole(roleName: string): Promise<GetRoleResponse> {
|
|
65
|
+
return this.coreClient.connectExec(
|
|
66
|
+
this.client.getRole,
|
|
67
|
+
{ roleName }
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* List all roles
|
|
73
|
+
* @returns {Promise<ListRolesResponse>} List of roles
|
|
74
|
+
*/
|
|
75
|
+
async listRoles(): Promise<ListRolesResponse> {
|
|
76
|
+
return this.coreClient.connectExec(
|
|
77
|
+
this.client.listRoles,
|
|
78
|
+
{}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
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
|
|
87
|
+
*/
|
|
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
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
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
|
|
103
|
+
*/
|
|
104
|
+
async deleteRole(roleName: string, reassignRoleName?: string): Promise<Empty> {
|
|
105
|
+
const request: PartialMessage<DeleteRoleRequest> = { roleName };
|
|
106
|
+
if (reassignRoleName) {
|
|
107
|
+
request.reassignRoleName = reassignRoleName;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return this.coreClient.connectExec(
|
|
111
|
+
this.client.deleteRole,
|
|
112
|
+
request
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
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
|
|
120
|
+
*/
|
|
121
|
+
async getRoleUsersCount(roleName: string): Promise<GetRoleUsersCountResponse> {
|
|
122
|
+
return this.coreClient.connectExec(
|
|
123
|
+
this.client.getRoleUsersCount,
|
|
124
|
+
{ roleName }
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Organization Role CRUD Methods
|
|
129
|
+
|
|
130
|
+
/**
|
|
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
|
|
135
|
+
*/
|
|
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
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
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
|
|
151
|
+
*/
|
|
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
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* List all organization roles
|
|
164
|
+
* @param {string} orgId The organization ID
|
|
165
|
+
* @returns {Promise<ListOrganizationRolesResponse>} List of organization roles
|
|
166
|
+
*/
|
|
167
|
+
async listOrganizationRoles(orgId: string): Promise<ListOrganizationRolesResponse> {
|
|
168
|
+
return this.coreClient.connectExec(
|
|
169
|
+
this.client.listOrganizationRoles,
|
|
170
|
+
{ orgId }
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
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
|
|
180
|
+
*/
|
|
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
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
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
|
|
198
|
+
*/
|
|
199
|
+
async deleteOrganizationRole(orgId: string, roleName: string, reassignRoleName?: string): Promise<Empty> {
|
|
200
|
+
const request: PartialMessage<DeleteOrganizationRoleRequest> = {
|
|
201
|
+
orgId,
|
|
202
|
+
roleName
|
|
203
|
+
};
|
|
204
|
+
if (reassignRoleName) {
|
|
205
|
+
request.reassignRoleName = reassignRoleName;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return this.coreClient.connectExec(
|
|
209
|
+
this.client.deleteOrganizationRole,
|
|
210
|
+
request
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
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
|
|
219
|
+
*/
|
|
220
|
+
async getOrganizationRoleUsersCount(orgId: string, roleName: string): Promise<GetOrganizationRoleUsersCountResponse> {
|
|
221
|
+
return this.coreClient.connectExec(
|
|
222
|
+
this.client.getOrganizationRoleUsersCount,
|
|
223
|
+
{
|
|
224
|
+
orgId,
|
|
225
|
+
roleName
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
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
|
|
235
|
+
*/
|
|
236
|
+
async updateDefaultOrganizationRoles(orgId: string, defaultMemberRole: string): Promise<UpdateDefaultOrganizationRolesResponse> {
|
|
237
|
+
return this.coreClient.connectExec(
|
|
238
|
+
this.client.updateDefaultOrganizationRoles,
|
|
239
|
+
{
|
|
240
|
+
orgId,
|
|
241
|
+
defaultMemberRole
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
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
|
|
251
|
+
*/
|
|
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
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
package/src/scalekit.ts
CHANGED
|
@@ -10,6 +10,8 @@ import DomainClient from './domain';
|
|
|
10
10
|
import OrganizationClient from './organization';
|
|
11
11
|
import PasswordlessClient from './passwordless';
|
|
12
12
|
import UserClient from './user';
|
|
13
|
+
import RoleClient from './role';
|
|
14
|
+
import PermissionClient from './permission';
|
|
13
15
|
import { IdpInitiatedLoginClaims, IdTokenClaim, User } from './types/auth';
|
|
14
16
|
import { AuthenticationOptions, AuthenticationResponse, AuthorizationUrlOptions, GrantType, LogoutUrlOptions, RefreshTokenResponse ,TokenValidationOptions } from './types/scalekit';
|
|
15
17
|
import { WebhookVerificationError, ScalekitValidateTokenFailureException } from './errors/base-exception';
|
|
@@ -37,6 +39,8 @@ export default class ScalekitClient {
|
|
|
37
39
|
readonly directory: DirectoryClient;
|
|
38
40
|
readonly passwordless: PasswordlessClient;
|
|
39
41
|
readonly user: UserClient;
|
|
42
|
+
readonly role: RoleClient;
|
|
43
|
+
readonly permission: PermissionClient;
|
|
40
44
|
constructor(
|
|
41
45
|
envUrl: string,
|
|
42
46
|
clientId: string,
|
|
@@ -75,6 +79,14 @@ export default class ScalekitClient {
|
|
|
75
79
|
this.grpcConnect,
|
|
76
80
|
this.coreClient
|
|
77
81
|
);
|
|
82
|
+
this.role = new RoleClient(
|
|
83
|
+
this.grpcConnect,
|
|
84
|
+
this.coreClient
|
|
85
|
+
);
|
|
86
|
+
this.permission = new PermissionClient(
|
|
87
|
+
this.grpcConnect,
|
|
88
|
+
this.coreClient
|
|
89
|
+
);
|
|
78
90
|
}
|
|
79
91
|
|
|
80
92
|
/**
|