@scalekit-sdk/node 2.2.0 → 2.2.2
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/{reference.md → REFERENCE.md} +530 -77
- package/lib/core.js +1 -1
- package/package.json +9 -3
- package/.github/dependabot.yml +0 -10
- package/.nvmrc +0 -1
- package/buf.gen.yaml +0 -20
- package/jest.config.js +0 -15
- package/src/auth.ts +0 -99
- package/src/connect.ts +0 -32
- package/src/connection.ts +0 -267
- package/src/constants/user.ts +0 -22
- package/src/core.ts +0 -139
- package/src/directory.ts +0 -431
- package/src/domain.ts +0 -273
- package/src/errors/base-exception.ts +0 -263
- package/src/errors/index.ts +0 -3
- package/src/errors/specific-exceptions.ts +0 -88
- package/src/index.ts +0 -10
- package/src/organization.ts +0 -571
- package/src/passwordless.ts +0 -139
- package/src/permission.ts +0 -310
- package/src/pkg/grpc/buf/validate/validate_pb.ts +0 -28
- package/src/pkg/grpc/google/api/annotations_pb.ts +0 -28
- package/src/pkg/grpc/google/api/field_behavior_pb.ts +0 -28
- package/src/pkg/grpc/google/api/visibility_pb.ts +0 -28
- package/src/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.ts +0 -28
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.ts +0 -257
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +0 -836
- package/src/pkg/grpc/scalekit/v1/auth/passwordless_pb.ts +0 -264
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +0 -794
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +0 -452
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +0 -2645
- package/src/pkg/grpc/scalekit/v1/directories/directories_pb.ts +0 -1393
- package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +0 -599
- package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +0 -311
- package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +0 -200
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +0 -1141
- package/src/pkg/grpc/scalekit/v1/roles/roles_pb.ts +0 -1491
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_pb.ts +0 -497
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +0 -1404
- package/src/role.ts +0 -463
- package/src/scalekit.ts +0 -800
- package/src/session.ts +0 -323
- package/src/types/auth.ts +0 -73
- package/src/types/organization.ts +0 -12
- package/src/types/scalekit.ts +0 -50
- package/src/types/user.ts +0 -21
- package/src/user.ts +0 -829
- package/src/webauthn.ts +0 -99
- package/tests/README.md +0 -25
- package/tests/connection.test.ts +0 -42
- package/tests/directory.test.ts +0 -46
- package/tests/domain.test.ts +0 -293
- package/tests/organization.test.ts +0 -81
- package/tests/passwordless.test.ts +0 -108
- package/tests/permission.test.ts +0 -399
- package/tests/role.test.ts +0 -323
- package/tests/scalekit.test.ts +0 -104
- package/tests/setup.ts +0 -34
- package/tests/users.test.ts +0 -168
- package/tests/utils/test-data.ts +0 -490
- package/tsconfig.json +0 -19
package/tests/utils/test-data.ts
DELETED
|
@@ -1,490 +0,0 @@
|
|
|
1
|
-
import { create } from '@bufbuild/protobuf';
|
|
2
|
-
import { CreateUserRequest, UpdateUserRequest } from '../../src/types/user';
|
|
3
|
-
import { TemplateType } from '../../src/pkg/grpc/scalekit/v1/auth/passwordless_pb';
|
|
4
|
-
import { DomainType } from '../../src/pkg/grpc/scalekit/v1/domains/domains_pb';
|
|
5
|
-
import {
|
|
6
|
-
CreateRole,
|
|
7
|
-
UpdateRole,
|
|
8
|
-
CreateOrganizationRole,
|
|
9
|
-
CreatePermission,
|
|
10
|
-
CreateRoleSchema,
|
|
11
|
-
UpdateRoleSchema,
|
|
12
|
-
CreateOrganizationRoleSchema,
|
|
13
|
-
CreatePermissionSchema,
|
|
14
|
-
} from '../../src/pkg/grpc/scalekit/v1/roles/roles_pb';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Test data generation utilities to reduce redundancy across test files
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export class TestDataGenerator {
|
|
21
|
-
/**
|
|
22
|
-
* Generate a unique timestamp-based identifier
|
|
23
|
-
*/
|
|
24
|
-
static generateUniqueId(): string {
|
|
25
|
-
// Alphanumeric only (no hyphens), to satisfy backend regex constraints
|
|
26
|
-
const ts = Date.now().toString(36);
|
|
27
|
-
const rnd = Math.random().toString(36).substr(2, 9);
|
|
28
|
-
return `${ts}${rnd}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Generate a unique email address for testing
|
|
33
|
-
*/
|
|
34
|
-
static generateUniqueEmail(): string {
|
|
35
|
-
return `test.user.${this.generateUniqueId()}@example.com`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Generate test organization data
|
|
40
|
-
*/
|
|
41
|
-
static generateOrganizationData() {
|
|
42
|
-
const uniqueId = this.generateUniqueId();
|
|
43
|
-
return {
|
|
44
|
-
name: `Test Org ${uniqueId}`,
|
|
45
|
-
externalId: `ext_org_${uniqueId}`
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Generate test user data
|
|
51
|
-
*/
|
|
52
|
-
static generateUserData(overrides: Partial<CreateUserRequest> = {}): CreateUserRequest {
|
|
53
|
-
const uniqueEmail = this.generateUniqueEmail();
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
email: uniqueEmail,
|
|
57
|
-
userProfile: {
|
|
58
|
-
firstName: 'Test',
|
|
59
|
-
lastName: 'User'
|
|
60
|
-
},
|
|
61
|
-
metadata: {
|
|
62
|
-
source: 'test'
|
|
63
|
-
},
|
|
64
|
-
...overrides
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Generate test user update data
|
|
70
|
-
*/
|
|
71
|
-
static generateUserUpdateData(overrides: Partial<UpdateUserRequest> = {}): UpdateUserRequest {
|
|
72
|
-
return {
|
|
73
|
-
userProfile: {
|
|
74
|
-
firstName: 'Updated',
|
|
75
|
-
lastName: 'Name'
|
|
76
|
-
},
|
|
77
|
-
...overrides
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Generate test passwordless email data
|
|
83
|
-
*/
|
|
84
|
-
static generatePasswordlessEmailData(overrides: any = {}) {
|
|
85
|
-
return {
|
|
86
|
-
template: TemplateType.SIGNIN,
|
|
87
|
-
state: 'test-state',
|
|
88
|
-
expiresIn: 3600,
|
|
89
|
-
magiclinkAuthUri: 'https://example.com/auth/callback',
|
|
90
|
-
...overrides
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Generate test passwordless email with template variables
|
|
96
|
-
*/
|
|
97
|
-
static generatePasswordlessEmailWithTemplateData(overrides: any = {}) {
|
|
98
|
-
return {
|
|
99
|
-
template: TemplateType.SIGNUP,
|
|
100
|
-
templateVariables: {
|
|
101
|
-
companyName: 'Test Company',
|
|
102
|
-
appName: 'Test App'
|
|
103
|
-
},
|
|
104
|
-
magiclinkAuthUri: 'https://example.com/auth/callback',
|
|
105
|
-
...overrides
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Generate test webhook data for verification
|
|
111
|
-
*/
|
|
112
|
-
static generateWebhookData() {
|
|
113
|
-
const secret = 'whsec_test-secret';
|
|
114
|
-
const payload = '{"test": "data"}';
|
|
115
|
-
const timestamp = Math.floor(Date.now() / 1000).toString();
|
|
116
|
-
const webhookId = 'msg_test_webhook_id';
|
|
117
|
-
|
|
118
|
-
// Generate valid signature for testing
|
|
119
|
-
const crypto = require('crypto');
|
|
120
|
-
const data = `${webhookId}.${timestamp}.${payload}`;
|
|
121
|
-
const hmac = crypto.createHmac('sha256', Buffer.from('test-secret', 'base64'));
|
|
122
|
-
hmac.update(data);
|
|
123
|
-
const computedSignature = hmac.digest('base64');
|
|
124
|
-
const signature = `v1,${computedSignature}`;
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
secret,
|
|
128
|
-
payload,
|
|
129
|
-
timestamp,
|
|
130
|
-
webhookId,
|
|
131
|
-
signature,
|
|
132
|
-
headers: {
|
|
133
|
-
'webhook-id': webhookId,
|
|
134
|
-
'webhook-timestamp': timestamp,
|
|
135
|
-
'webhook-signature': signature
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Generate test authorization URL options
|
|
142
|
-
*/
|
|
143
|
-
static generateAuthorizationUrlOptions(overrides: any = {}) {
|
|
144
|
-
return {
|
|
145
|
-
scopes: ['openid', 'profile'],
|
|
146
|
-
state: 'test-state',
|
|
147
|
-
nonce: 'test-nonce',
|
|
148
|
-
prompt: 'login',
|
|
149
|
-
...overrides
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Generate test PKCE parameters
|
|
155
|
-
*/
|
|
156
|
-
static generatePKCEParams() {
|
|
157
|
-
return {
|
|
158
|
-
codeChallenge: 'test-challenge',
|
|
159
|
-
codeChallengeMethod: 'S256'
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Generate test pagination parameters
|
|
165
|
-
*/
|
|
166
|
-
static generatePaginationParams(pageSize: number = 10) {
|
|
167
|
-
return {
|
|
168
|
-
pageSize,
|
|
169
|
-
pageToken: ''
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Generate test credential data for passwordless verification
|
|
175
|
-
*/
|
|
176
|
-
static generateCredentialData(type: 'code' | 'linkToken' = 'code') {
|
|
177
|
-
if (type === 'code') {
|
|
178
|
-
return { code: 'mock-code' };
|
|
179
|
-
} else {
|
|
180
|
-
return { linkToken: 'mock-link-token' };
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Generate test domain data
|
|
186
|
-
*/
|
|
187
|
-
static generateDomainData(domainType?: 'allowed' | 'organization') {
|
|
188
|
-
const uniqueId = this.generateUniqueId();
|
|
189
|
-
const baseDomain = `test-domain-${uniqueId}.com`;
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
domain: baseDomain,
|
|
193
|
-
domainType: domainType === 'allowed' ? 'ALLOWED_EMAIL_DOMAIN' :
|
|
194
|
-
domainType === 'organization' ? 'ORGANIZATION_DOMAIN' : undefined
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Generate unique domain name for testing
|
|
200
|
-
*/
|
|
201
|
-
static generateUniqueDomainName(prefix: string = 'test'): string {
|
|
202
|
-
const uniqueId = this.generateUniqueId();
|
|
203
|
-
return `${prefix}-${uniqueId}.com`;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Generate test role data
|
|
208
|
-
*/
|
|
209
|
-
static generateRoleData(overrides: Partial<CreateRole> = {}): CreateRole {
|
|
210
|
-
const uniqueId = this.generateUniqueId();
|
|
211
|
-
|
|
212
|
-
return create(CreateRoleSchema, {
|
|
213
|
-
name: `test_role_${uniqueId}`,
|
|
214
|
-
displayName: `Test Role ${uniqueId}`,
|
|
215
|
-
description: `Test role description ${uniqueId}`,
|
|
216
|
-
permissions: [], // Initialize empty permissions array
|
|
217
|
-
...overrides
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Generate test role update data
|
|
223
|
-
*/
|
|
224
|
-
static generateRoleUpdateData(overrides: Partial<UpdateRole> = {}): UpdateRole {
|
|
225
|
-
const uniqueId = this.generateUniqueId();
|
|
226
|
-
const init = {
|
|
227
|
-
displayName: `Updated Role ${uniqueId}`,
|
|
228
|
-
description: `Updated role description ${uniqueId}`,
|
|
229
|
-
...overrides
|
|
230
|
-
};
|
|
231
|
-
return create(UpdateRoleSchema, init as Parameters<typeof create>[1]);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Generate test organization role data
|
|
236
|
-
*/
|
|
237
|
-
static generateOrganizationRoleData(overrides: Partial<CreateOrganizationRole> = {}): CreateOrganizationRole {
|
|
238
|
-
const uniqueId = this.generateUniqueId();
|
|
239
|
-
|
|
240
|
-
return create(CreateOrganizationRoleSchema, {
|
|
241
|
-
name: `test_org_role_${uniqueId}`,
|
|
242
|
-
displayName: `Test Organization Role ${uniqueId}`,
|
|
243
|
-
description: `Test organization role description ${uniqueId}`,
|
|
244
|
-
permissions: [], // Initialize empty permissions array
|
|
245
|
-
...overrides
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Generate test permission data
|
|
251
|
-
*/
|
|
252
|
-
static generatePermissionData(overrides: Partial<CreatePermission> = {}): CreatePermission {
|
|
253
|
-
const uniqueId = this.generateUniqueId();
|
|
254
|
-
|
|
255
|
-
return create(CreatePermissionSchema, {
|
|
256
|
-
name: `test_permission_${uniqueId}`,
|
|
257
|
-
description: `Test permission description ${uniqueId}`,
|
|
258
|
-
...overrides
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Test organization management utilities
|
|
265
|
-
*/
|
|
266
|
-
export class TestOrganizationManager {
|
|
267
|
-
/**
|
|
268
|
-
* Create a test organization and return its ID
|
|
269
|
-
*/
|
|
270
|
-
static async createTestOrganization(client: any): Promise<string> {
|
|
271
|
-
const orgData = TestDataGenerator.generateOrganizationData();
|
|
272
|
-
const orgResponse = await client.organization.createOrganization(
|
|
273
|
-
orgData.name,
|
|
274
|
-
{ externalId: orgData.externalId }
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
const testOrg = orgResponse.organization?.id || '';
|
|
278
|
-
if (!testOrg) {
|
|
279
|
-
throw new Error('Failed to create test organization');
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return testOrg;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Clean up a test organization
|
|
287
|
-
*/
|
|
288
|
-
static async cleanupTestOrganization(client: any, testOrg: string): Promise<void> {
|
|
289
|
-
if (testOrg) {
|
|
290
|
-
try {
|
|
291
|
-
await client.organization.deleteOrganization(testOrg);
|
|
292
|
-
} catch (error) {
|
|
293
|
-
// Organization may already be deleted
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Test user management utilities
|
|
301
|
-
*/
|
|
302
|
-
export class TestUserManager {
|
|
303
|
-
/**
|
|
304
|
-
* Create a test user and return user data
|
|
305
|
-
*/
|
|
306
|
-
static async createTestUser(client: any, testOrg: string, overrides: Partial<CreateUserRequest> = {}) {
|
|
307
|
-
const userData = TestDataGenerator.generateUserData(overrides);
|
|
308
|
-
const createResponse = await client.user.createUserAndMembership(testOrg, userData);
|
|
309
|
-
const createdUserId = createResponse.user?.id;
|
|
310
|
-
|
|
311
|
-
if (!createdUserId) {
|
|
312
|
-
throw new Error('Failed to create test user');
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return {
|
|
316
|
-
userId: createdUserId,
|
|
317
|
-
userData,
|
|
318
|
-
response: createResponse
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Clean up a test user
|
|
324
|
-
*/
|
|
325
|
-
static async cleanupTestUser(client: any, testOrg: string, userId: string): Promise<void> {
|
|
326
|
-
if (userId) {
|
|
327
|
-
try {
|
|
328
|
-
// Remove membership if it exists
|
|
329
|
-
await client.user.deleteMembership(testOrg, userId);
|
|
330
|
-
} catch (error) {
|
|
331
|
-
// Membership may not exist
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
try {
|
|
335
|
-
await client.user.deleteUser(userId);
|
|
336
|
-
} catch (error) {
|
|
337
|
-
// User may already be deleted
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Test domain management utilities
|
|
345
|
-
*/
|
|
346
|
-
export class TestDomainManager {
|
|
347
|
-
/**
|
|
348
|
-
* Create a test domain and return domain data
|
|
349
|
-
*/
|
|
350
|
-
static async createTestDomain(client: any, testOrg: string, domainType?: 'allowed' | 'organization') {
|
|
351
|
-
const domainName = TestDataGenerator.generateUniqueDomainName();
|
|
352
|
-
const options = domainType ? {
|
|
353
|
-
domainType: domainType === 'allowed' ? DomainType.ALLOWED_EMAIL_DOMAIN : DomainType.ORGANIZATION_DOMAIN
|
|
354
|
-
} : undefined;
|
|
355
|
-
|
|
356
|
-
const response = await client.domain.createDomain(testOrg, domainName, options);
|
|
357
|
-
const createdDomainId = response.domain?.id;
|
|
358
|
-
|
|
359
|
-
if (!createdDomainId) {
|
|
360
|
-
throw new Error('Failed to create test domain');
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return {
|
|
364
|
-
domainId: createdDomainId,
|
|
365
|
-
domainName,
|
|
366
|
-
domainType: response.domain?.domainType,
|
|
367
|
-
response
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Clean up a test domain (if domain deletion is supported)
|
|
373
|
-
*/
|
|
374
|
-
static async cleanupTestDomain(client: any, testOrg: string, domainId: string): Promise<void> {
|
|
375
|
-
if (domainId) {
|
|
376
|
-
try {
|
|
377
|
-
// Note: Domain deletion may not be implemented yet
|
|
378
|
-
// await client.domain.deleteDomain(testOrg, domainId);
|
|
379
|
-
} catch (error) {
|
|
380
|
-
// Domain may already be deleted or deletion not supported
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Test role management utilities
|
|
388
|
-
*/
|
|
389
|
-
export class TestRoleManager {
|
|
390
|
-
/**
|
|
391
|
-
* Create a test role and return role data
|
|
392
|
-
*/
|
|
393
|
-
static async createTestRole(client: any, overrides: Partial<CreateRole> = {}) {
|
|
394
|
-
const roleData = TestDataGenerator.generateRoleData(overrides);
|
|
395
|
-
const response = await client.role.createRole(roleData);
|
|
396
|
-
const createdRoleName = response.role?.name;
|
|
397
|
-
|
|
398
|
-
if (!createdRoleName) {
|
|
399
|
-
throw new Error('Failed to create test role');
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return {
|
|
403
|
-
roleName: createdRoleName,
|
|
404
|
-
roleData,
|
|
405
|
-
response
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Clean up a test role
|
|
411
|
-
*/
|
|
412
|
-
static async cleanupTestRole(client: any, roleName: string): Promise<void> {
|
|
413
|
-
if (roleName) {
|
|
414
|
-
try {
|
|
415
|
-
await client.role.deleteRole(roleName);
|
|
416
|
-
} catch (error) {
|
|
417
|
-
// Role may already be deleted
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Create a test organization role and return role data
|
|
424
|
-
*/
|
|
425
|
-
static async createTestOrganizationRole(client: any, testOrg: string, overrides: Partial<CreateOrganizationRole> = {}) {
|
|
426
|
-
const roleData = TestDataGenerator.generateOrganizationRoleData(overrides);
|
|
427
|
-
const response = await client.role.createOrganizationRole(testOrg, roleData);
|
|
428
|
-
const createdRoleName = response.role?.name;
|
|
429
|
-
|
|
430
|
-
if (!createdRoleName) {
|
|
431
|
-
throw new Error('Failed to create test organization role');
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return {
|
|
435
|
-
roleName: createdRoleName,
|
|
436
|
-
roleData,
|
|
437
|
-
response
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Clean up a test organization role
|
|
443
|
-
*/
|
|
444
|
-
static async cleanupTestOrganizationRole(client: any, testOrg: string, roleName: string): Promise<void> {
|
|
445
|
-
if (roleName) {
|
|
446
|
-
try {
|
|
447
|
-
await client.role.deleteOrganizationRole(testOrg, roleName);
|
|
448
|
-
} catch (error) {
|
|
449
|
-
// Role may already be deleted
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Test permission management utilities
|
|
457
|
-
*/
|
|
458
|
-
export class TestPermissionManager {
|
|
459
|
-
/**
|
|
460
|
-
* Create a test permission and return permission data
|
|
461
|
-
*/
|
|
462
|
-
static async createTestPermission(client: any, overrides: Partial<CreatePermission> = {}) {
|
|
463
|
-
const permissionData = TestDataGenerator.generatePermissionData(overrides);
|
|
464
|
-
const response = await client.permission.createPermission(permissionData);
|
|
465
|
-
const createdPermissionName = response.permission?.name;
|
|
466
|
-
|
|
467
|
-
if (!createdPermissionName) {
|
|
468
|
-
throw new Error('Failed to create test permission');
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
return {
|
|
472
|
-
permissionName: createdPermissionName,
|
|
473
|
-
permissionData,
|
|
474
|
-
response
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Clean up a test permission
|
|
480
|
-
*/
|
|
481
|
-
static async cleanupTestPermission(client: any, permissionName: string): Promise<void> {
|
|
482
|
-
if (permissionName) {
|
|
483
|
-
try {
|
|
484
|
-
await client.permission.deletePermission(permissionName);
|
|
485
|
-
} catch (error) {
|
|
486
|
-
// Permission may already be deleted
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"noImplicitAny": false,
|
|
4
|
-
"target": "ES6",
|
|
5
|
-
"lib": ["ES2020"],
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"strictNullChecks": true,
|
|
9
|
-
"strictPropertyInitialization": true,
|
|
10
|
-
"outDir": "lib",
|
|
11
|
-
"strict": true,
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"typeRoots": ["src/types", "node_modules/@types"],
|
|
16
|
-
"moduleResolution": "Node"
|
|
17
|
-
},
|
|
18
|
-
"include": ["src"],
|
|
19
|
-
}
|