@scalekit-sdk/node 2.2.0-beta.0 → 2.2.0
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/.nvmrc +1 -1
- package/README.md +5 -5
- package/buf.gen.yaml +1 -5
- package/lib/auth.d.ts +9 -6
- package/lib/auth.js +4 -20
- package/lib/auth.js.map +1 -1
- package/lib/connect.d.ts +3 -3
- package/lib/connect.js +1 -2
- package/lib/connect.js.map +1 -1
- package/lib/connection.d.ts +2 -2
- package/lib/connection.js +4 -4
- package/lib/connection.js.map +1 -1
- package/lib/core.js +2 -2
- package/lib/core.js.map +1 -1
- package/lib/directory.d.ts +2 -2
- package/lib/directory.js +7 -7
- package/lib/directory.js.map +1 -1
- package/lib/domain.d.ts +6 -5
- package/lib/domain.js +4 -5
- package/lib/domain.js.map +1 -1
- package/lib/errors/base-exception.d.ts +1 -1
- package/lib/errors/base-exception.js +1 -1
- package/lib/errors/base-exception.js.map +1 -1
- package/lib/organization.d.ts +10 -9
- package/lib/organization.js +11 -9
- package/lib/organization.js.map +1 -1
- package/lib/passwordless.d.ts +2 -2
- package/lib/passwordless.js +8 -7
- package/lib/passwordless.js.map +1 -1
- package/lib/permission.d.ts +6 -5
- package/lib/permission.js +10 -11
- package/lib/permission.js.map +1 -1
- package/lib/pkg/grpc/buf/validate/validate_pb.d.ts +7 -0
- package/lib/pkg/grpc/buf/validate/validate_pb.js +25 -0
- package/lib/pkg/grpc/buf/validate/validate_pb.js.map +1 -0
- package/lib/pkg/grpc/google/api/annotations_pb.d.ts +7 -0
- package/lib/pkg/grpc/google/api/annotations_pb.js +25 -0
- package/lib/pkg/grpc/google/api/annotations_pb.js.map +1 -0
- package/lib/pkg/grpc/google/api/field_behavior_pb.d.ts +7 -0
- package/lib/pkg/grpc/google/api/field_behavior_pb.js +25 -0
- package/lib/pkg/grpc/google/api/field_behavior_pb.js.map +1 -0
- package/lib/pkg/grpc/google/api/visibility_pb.d.ts +7 -0
- package/lib/pkg/grpc/google/api/visibility_pb.js +25 -0
- package/lib/pkg/grpc/google/api/visibility_pb.js.map +1 -0
- package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.d.ts +7 -0
- package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.js +25 -0
- package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.d.ts +48 -42
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js +27 -263
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +371 -325
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +132 -835
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.d.ts +113 -87
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.js +45 -201
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +262 -265
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +92 -938
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +162 -157
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +42 -313
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +1488 -1459
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +353 -2362
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.d.ts +520 -483
- package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.js +224 -1555
- package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.d.ts +219 -191
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +96 -553
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.d.ts +76 -102
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +37 -393
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.d.ts +36 -26
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +20 -69
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +447 -400
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +163 -1238
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.d.ts +622 -556
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js +201 -1718
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.d.ts +135 -132
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js +55 -518
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +445 -413
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +142 -1490
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/role.d.ts +8 -7
- package/lib/role.js +14 -14
- package/lib/role.js.map +1 -1
- package/lib/scalekit.d.ts +0 -4
- package/lib/scalekit.js +0 -4
- package/lib/scalekit.js.map +1 -1
- package/lib/session.js +15 -24
- package/lib/session.js.map +1 -1
- package/lib/user.d.ts +6 -5
- package/lib/user.js +17 -20
- package/lib/user.js.map +1 -1
- package/lib/webauthn.js +6 -5
- package/lib/webauthn.js.map +1 -1
- package/package.json +6 -10
- package/reference.md +0 -671
- package/src/auth.ts +17 -17
- package/src/connect.ts +4 -5
- package/src/connection.ts +5 -5
- package/src/core.ts +2 -2
- package/src/directory.ts +8 -8
- package/src/domain.ts +9 -8
- package/src/errors/base-exception.ts +3 -2
- package/src/organization.ts +18 -15
- package/src/passwordless.ts +12 -11
- package/src/permission.ts +15 -15
- package/src/pkg/grpc/buf/validate/validate_pb.ts +28 -0
- package/src/pkg/grpc/google/api/annotations_pb.ts +28 -0
- package/src/pkg/grpc/google/api/field_behavior_pb.ts +28 -0
- package/src/pkg/grpc/google/api/visibility_pb.ts +28 -0
- package/src/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.ts +28 -0
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.ts +97 -182
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +473 -850
- package/src/pkg/grpc/scalekit/v1/auth/passwordless_pb.ts +153 -225
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +361 -830
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +237 -358
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +1625 -2826
- package/src/pkg/grpc/scalekit/v1/directories/directories_pb.ts +687 -1413
- package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +286 -542
- package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +115 -328
- package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +50 -80
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +558 -1183
- package/src/pkg/grpc/scalekit/v1/roles/roles_pb.ts +765 -1669
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_pb.ts +195 -447
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +592 -1339
- package/src/role.ts +21 -19
- package/src/scalekit.ts +0 -9
- package/src/session.ts +20 -34
- package/src/user.ts +30 -26
- package/src/webauthn.ts +10 -9
- package/tests/utils/test-data.ts +17 -8
- package/lib/connected-accounts.d.ts +0 -96
- package/lib/connected-accounts.js +0 -186
- package/lib/connected-accounts.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.d.ts +0 -19
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.js +0 -27
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +0 -118
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +0 -126
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.d.ts +0 -37
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.js +0 -45
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +0 -82
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +0 -90
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.d.ts +0 -87
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js +0 -95
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.d.ts +0 -718
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js +0 -893
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +0 -172
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -180
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.d.ts +0 -154
- package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.js +0 -162
- package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.d.ts +0 -73
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js +0 -81
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +0 -171
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +0 -179
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.d.ts +0 -250
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js +0 -258
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.d.ts +0 -46
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.js +0 -54
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.d.ts +0 -75
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js +0 -83
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.d.ts +0 -431
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js +0 -627
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.d.ts +0 -173
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js +0 -181
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js.map +0 -1
- package/lib/tools.d.ts +0 -75
- package/lib/tools.js +0 -127
- package/lib/tools.js.map +0 -1
- package/src/connected-accounts.ts +0 -283
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.ts +0 -26
- package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +0 -125
- package/src/pkg/grpc/scalekit/v1/auth/passwordless_connect.ts +0 -44
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +0 -89
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.ts +0 -94
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.ts +0 -1294
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +0 -179
- package/src/pkg/grpc/scalekit/v1/directories/directories_connect.ts +0 -161
- package/src/pkg/grpc/scalekit/v1/domains/domains_connect.ts +0 -80
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +0 -178
- package/src/pkg/grpc/scalekit/v1/roles/roles_connect.ts +0 -257
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_connect.ts +0 -53
- package/src/pkg/grpc/scalekit/v1/tools/tools_connect.ts +0 -82
- package/src/pkg/grpc/scalekit/v1/tools/tools_pb.ts +0 -847
- package/src/pkg/grpc/scalekit/v1/users/users_connect.ts +0 -180
- package/src/tools.ts +0 -166
- package/tests/connected-accounts.test.ts +0 -434
- package/tests/tools.test.ts +0 -239
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
import ScalekitClient from '../src/scalekit';
|
|
2
|
-
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
|
|
3
|
-
import { TestOrganizationManager } from './utils/test-data';
|
|
4
|
-
import {
|
|
5
|
-
CreateConnectedAccount,
|
|
6
|
-
UpdateConnectedAccount,
|
|
7
|
-
AuthorizationDetails,
|
|
8
|
-
OauthToken,
|
|
9
|
-
} from '../src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb';
|
|
10
|
-
|
|
11
|
-
describe('Connected Accounts', () => {
|
|
12
|
-
let client: ScalekitClient;
|
|
13
|
-
let testOrg: string;
|
|
14
|
-
let testConnectedAccountId: string | null = null;
|
|
15
|
-
let testConnector: string | null = null;
|
|
16
|
-
let testIdentifier: string | null = null;
|
|
17
|
-
|
|
18
|
-
beforeEach(async () => {
|
|
19
|
-
// Use global client
|
|
20
|
-
client = global.client;
|
|
21
|
-
|
|
22
|
-
// Create test organization for each test
|
|
23
|
-
testOrg = await TestOrganizationManager.createTestOrganization(client);
|
|
24
|
-
|
|
25
|
-
// Reset test state
|
|
26
|
-
testConnectedAccountId = null;
|
|
27
|
-
testConnector = null;
|
|
28
|
-
testIdentifier = null;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
afterEach(async () => {
|
|
32
|
-
// Clean up test connected account if created
|
|
33
|
-
if (testConnectedAccountId && testConnector && testIdentifier) {
|
|
34
|
-
try {
|
|
35
|
-
await client.connectedAccounts.deleteConnectedAccount({
|
|
36
|
-
connector: testConnector,
|
|
37
|
-
identifier: testIdentifier,
|
|
38
|
-
connectedAccountId: testConnectedAccountId,
|
|
39
|
-
});
|
|
40
|
-
} catch (error) {
|
|
41
|
-
// Account may already be deleted or not exist
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Reset test state
|
|
46
|
-
testConnectedAccountId = null;
|
|
47
|
-
testConnector = null;
|
|
48
|
-
testIdentifier = null;
|
|
49
|
-
|
|
50
|
-
// Clean up test organization
|
|
51
|
-
await TestOrganizationManager.cleanupTestOrganization(client, testOrg);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('listConnectedAccounts', () => {
|
|
55
|
-
it('should list connected accounts', async () => {
|
|
56
|
-
const response = await client.connectedAccounts.listConnectedAccounts();
|
|
57
|
-
|
|
58
|
-
expect(response).toBeDefined();
|
|
59
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
60
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
61
|
-
expect(response.totalSize).toBeDefined();
|
|
62
|
-
expect(typeof response.totalSize).toBe('number');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should list connected accounts with organization filter', async () => {
|
|
66
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
67
|
-
organizationId: testOrg,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(response).toBeDefined();
|
|
71
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
72
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should list connected accounts with connector filter', async () => {
|
|
76
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
77
|
-
connector: 'notion',
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
expect(response).toBeDefined();
|
|
81
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
82
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should list connected accounts with provider filter', async () => {
|
|
86
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
87
|
-
provider: 'google',
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(response).toBeDefined();
|
|
91
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
92
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should list connected accounts with pagination', async () => {
|
|
96
|
-
const firstPage = await client.connectedAccounts.listConnectedAccounts({
|
|
97
|
-
pageSize: 10,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
expect(firstPage).toBeDefined();
|
|
101
|
-
expect(firstPage.connectedAccounts).toBeDefined();
|
|
102
|
-
expect(firstPage.connectedAccounts.length).toBeLessThanOrEqual(10);
|
|
103
|
-
|
|
104
|
-
if (firstPage.nextPageToken) {
|
|
105
|
-
const secondPage = await client.connectedAccounts.listConnectedAccounts({
|
|
106
|
-
pageSize: 10,
|
|
107
|
-
pageToken: firstPage.nextPageToken,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
expect(secondPage).toBeDefined();
|
|
111
|
-
expect(secondPage.connectedAccounts).toBeDefined();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should list connected accounts with query search', async () => {
|
|
116
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
117
|
-
query: 'test',
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
expect(response).toBeDefined();
|
|
121
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
122
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('createConnectedAccount', () => {
|
|
127
|
-
it('should handle create connected account request', async () => {
|
|
128
|
-
const connector = 'test_connector';
|
|
129
|
-
const identifier = `test_${Date.now()}`;
|
|
130
|
-
|
|
131
|
-
const oauthToken = new OauthToken({
|
|
132
|
-
accessToken: 'test_access_token',
|
|
133
|
-
refreshToken: 'test_refresh_token',
|
|
134
|
-
scopes: ['read', 'write'],
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
138
|
-
details: {
|
|
139
|
-
case: 'oauthToken',
|
|
140
|
-
value: oauthToken,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const connectedAccount = new CreateConnectedAccount({
|
|
145
|
-
authorizationDetails,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
const response = await client.connectedAccounts.createConnectedAccount({
|
|
150
|
-
connector,
|
|
151
|
-
identifier,
|
|
152
|
-
connectedAccount,
|
|
153
|
-
organizationId: testOrg,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
expect(response).toBeDefined();
|
|
157
|
-
expect(response.connectedAccount).toBeDefined();
|
|
158
|
-
expect(response.connectedAccount?.id).toBeDefined();
|
|
159
|
-
|
|
160
|
-
if (response.connectedAccount?.id) {
|
|
161
|
-
testConnectedAccountId = response.connectedAccount.id;
|
|
162
|
-
testConnector = connector;
|
|
163
|
-
testIdentifier = identifier;
|
|
164
|
-
}
|
|
165
|
-
} catch (error: any) {
|
|
166
|
-
// Expected errors: connector not found, invalid credentials, etc.
|
|
167
|
-
expect(error).toBeDefined();
|
|
168
|
-
// Verify it's a proper error response, not a request structure issue
|
|
169
|
-
expect(error.message || error.toString()).toBeDefined();
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('should handle create connected account with user ID', async () => {
|
|
174
|
-
const connector = 'test_connector';
|
|
175
|
-
const identifier = `test_user_${Date.now()}`;
|
|
176
|
-
|
|
177
|
-
const oauthToken = new OauthToken({
|
|
178
|
-
accessToken: 'test_access_token',
|
|
179
|
-
refreshToken: 'test_refresh_token',
|
|
180
|
-
scopes: ['read'],
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
184
|
-
details: {
|
|
185
|
-
case: 'oauthToken',
|
|
186
|
-
value: oauthToken,
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const connectedAccount = new CreateConnectedAccount({
|
|
191
|
-
authorizationDetails,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
try {
|
|
195
|
-
const response = await client.connectedAccounts.createConnectedAccount({
|
|
196
|
-
connector,
|
|
197
|
-
identifier,
|
|
198
|
-
connectedAccount,
|
|
199
|
-
userId: 'usr_test123',
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
expect(response).toBeDefined();
|
|
203
|
-
if (response.connectedAccount?.id) {
|
|
204
|
-
testConnectedAccountId = response.connectedAccount.id;
|
|
205
|
-
testConnector = connector;
|
|
206
|
-
testIdentifier = identifier;
|
|
207
|
-
}
|
|
208
|
-
} catch (error: any) {
|
|
209
|
-
// Expected errors: connector not found, invalid credentials, etc.
|
|
210
|
-
expect(error).toBeDefined();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
describe('updateConnectedAccount', () => {
|
|
216
|
-
it('should handle update connected account request', async () => {
|
|
217
|
-
const connector = 'test_connector';
|
|
218
|
-
const identifier = 'test_identifier';
|
|
219
|
-
|
|
220
|
-
const oauthToken = new OauthToken({
|
|
221
|
-
accessToken: 'updated_access_token',
|
|
222
|
-
refreshToken: 'updated_refresh_token',
|
|
223
|
-
scopes: ['read', 'write', 'admin'],
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
227
|
-
details: {
|
|
228
|
-
case: 'oauthToken',
|
|
229
|
-
value: oauthToken,
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
const connectedAccount = new UpdateConnectedAccount({
|
|
234
|
-
authorizationDetails,
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
try {
|
|
238
|
-
const response = await client.connectedAccounts.updateConnectedAccount({
|
|
239
|
-
connector,
|
|
240
|
-
identifier,
|
|
241
|
-
connectedAccount,
|
|
242
|
-
organizationId: testOrg,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
expect(response).toBeDefined();
|
|
246
|
-
expect(response.connectedAccount).toBeDefined();
|
|
247
|
-
} catch (error: any) {
|
|
248
|
-
// Expected errors: connected account not found, invalid credentials, etc.
|
|
249
|
-
expect(error).toBeDefined();
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('should handle update connected account with ID', async () => {
|
|
254
|
-
const connector = 'test_connector';
|
|
255
|
-
const identifier = 'test_identifier';
|
|
256
|
-
|
|
257
|
-
const oauthToken = new OauthToken({
|
|
258
|
-
accessToken: 'updated_access_token',
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
262
|
-
details: {
|
|
263
|
-
case: 'oauthToken',
|
|
264
|
-
value: oauthToken,
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
const connectedAccount = new UpdateConnectedAccount({
|
|
269
|
-
authorizationDetails,
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
try {
|
|
273
|
-
const response = await client.connectedAccounts.updateConnectedAccount({
|
|
274
|
-
connector,
|
|
275
|
-
identifier,
|
|
276
|
-
connectedAccount,
|
|
277
|
-
connectedAccountId: 'ca_test123',
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
expect(response).toBeDefined();
|
|
281
|
-
} catch (error: any) {
|
|
282
|
-
// Expected errors: connected account not found, etc.
|
|
283
|
-
expect(error).toBeDefined();
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
describe('deleteConnectedAccount', () => {
|
|
289
|
-
it('should handle delete connected account request', async () => {
|
|
290
|
-
const connector = 'test_connector';
|
|
291
|
-
const identifier = 'test_identifier';
|
|
292
|
-
|
|
293
|
-
try {
|
|
294
|
-
const response = await client.connectedAccounts.deleteConnectedAccount({
|
|
295
|
-
connector,
|
|
296
|
-
identifier,
|
|
297
|
-
organizationId: testOrg,
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
expect(response).toBeDefined();
|
|
301
|
-
} catch (error: any) {
|
|
302
|
-
// Expected errors: connected account not found, etc.
|
|
303
|
-
expect(error).toBeDefined();
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it('should handle delete connected account with ID', async () => {
|
|
308
|
-
try {
|
|
309
|
-
const response = await client.connectedAccounts.deleteConnectedAccount({
|
|
310
|
-
connector: 'test_connector',
|
|
311
|
-
identifier: 'test_identifier',
|
|
312
|
-
connectedAccountId: 'ca_test123',
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
expect(response).toBeDefined();
|
|
316
|
-
} catch (error: any) {
|
|
317
|
-
// Expected errors: connected account not found, etc.
|
|
318
|
-
expect(error).toBeDefined();
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
describe('getMagicLinkForConnectedAccount', () => {
|
|
324
|
-
it('should handle get magic link request', async () => {
|
|
325
|
-
const connector = 'test_connector';
|
|
326
|
-
const identifier = 'test_identifier';
|
|
327
|
-
|
|
328
|
-
try {
|
|
329
|
-
const response = await client.connectedAccounts.getMagicLinkForConnectedAccount({
|
|
330
|
-
connector,
|
|
331
|
-
identifier,
|
|
332
|
-
organizationId: testOrg,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
expect(response).toBeDefined();
|
|
336
|
-
expect(response.link).toBeDefined();
|
|
337
|
-
expect(typeof response.link).toBe('string');
|
|
338
|
-
expect(response.expiry).toBeDefined();
|
|
339
|
-
} catch (error: any) {
|
|
340
|
-
// Expected errors: connector not found, invalid parameters, etc.
|
|
341
|
-
expect(error).toBeDefined();
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it('should handle get magic link with user ID', async () => {
|
|
346
|
-
try {
|
|
347
|
-
const response = await client.connectedAccounts.getMagicLinkForConnectedAccount({
|
|
348
|
-
connector: 'test_connector',
|
|
349
|
-
identifier: 'test_identifier',
|
|
350
|
-
userId: 'usr_test123',
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
expect(response).toBeDefined();
|
|
354
|
-
if (response.link) {
|
|
355
|
-
expect(typeof response.link).toBe('string');
|
|
356
|
-
}
|
|
357
|
-
} catch (error: any) {
|
|
358
|
-
// Expected errors: connector not found, etc.
|
|
359
|
-
expect(error).toBeDefined();
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it('should handle get magic link with connected account ID', async () => {
|
|
364
|
-
try {
|
|
365
|
-
const response = await client.connectedAccounts.getMagicLinkForConnectedAccount({
|
|
366
|
-
connector: 'test_connector',
|
|
367
|
-
identifier: 'test_identifier',
|
|
368
|
-
connectedAccountId: 'ca_test123',
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
expect(response).toBeDefined();
|
|
372
|
-
} catch (error: any) {
|
|
373
|
-
// Expected errors: connected account not found, etc.
|
|
374
|
-
expect(error).toBeDefined();
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
describe('getConnectedAccountByIdentifier', () => {
|
|
380
|
-
it('should handle get connected account by identifier request', async () => {
|
|
381
|
-
const connector = 'test_connector';
|
|
382
|
-
const identifier = 'test_identifier';
|
|
383
|
-
|
|
384
|
-
try {
|
|
385
|
-
const response = await client.connectedAccounts.getConnectedAccountByIdentifier({
|
|
386
|
-
connector,
|
|
387
|
-
identifier,
|
|
388
|
-
organizationId: testOrg,
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
expect(response).toBeDefined();
|
|
392
|
-
expect(response.connectedAccount).toBeDefined();
|
|
393
|
-
expect(response.connectedAccount?.id).toBeDefined();
|
|
394
|
-
expect(response.connectedAccount?.authorizationDetails).toBeDefined();
|
|
395
|
-
} catch (error: any) {
|
|
396
|
-
// Expected errors: connected account not found, etc.
|
|
397
|
-
expect(error).toBeDefined();
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('should handle get connected account with user ID', async () => {
|
|
402
|
-
try {
|
|
403
|
-
const response = await client.connectedAccounts.getConnectedAccountByIdentifier({
|
|
404
|
-
connector: 'test_connector',
|
|
405
|
-
identifier: 'test_identifier',
|
|
406
|
-
userId: 'usr_test123',
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
expect(response).toBeDefined();
|
|
410
|
-
if (response.connectedAccount) {
|
|
411
|
-
expect(response.connectedAccount.id).toBeDefined();
|
|
412
|
-
}
|
|
413
|
-
} catch (error: any) {
|
|
414
|
-
// Expected errors: connected account not found, etc.
|
|
415
|
-
expect(error).toBeDefined();
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
it('should handle get connected account with connected account ID', async () => {
|
|
420
|
-
try {
|
|
421
|
-
const response = await client.connectedAccounts.getConnectedAccountByIdentifier({
|
|
422
|
-
connector: 'test_connector',
|
|
423
|
-
identifier: 'test_identifier',
|
|
424
|
-
connectedAccountId: 'ca_test123',
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
expect(response).toBeDefined();
|
|
428
|
-
} catch (error: any) {
|
|
429
|
-
// Expected errors: connected account not found, etc.
|
|
430
|
-
expect(error).toBeDefined();
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
});
|
|
434
|
-
});
|
package/tests/tools.test.ts
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import ScalekitClient from '../src/scalekit';
|
|
2
|
-
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
|
|
3
|
-
import { TestOrganizationManager } from './utils/test-data';
|
|
4
|
-
|
|
5
|
-
describe('Tools', () => {
|
|
6
|
-
let client: ScalekitClient;
|
|
7
|
-
let testOrg: string;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
// Use global client
|
|
11
|
-
client = global.client;
|
|
12
|
-
|
|
13
|
-
// Create test organization for each test
|
|
14
|
-
testOrg = await TestOrganizationManager.createTestOrganization(client);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(async () => {
|
|
18
|
-
// Clean up test organization
|
|
19
|
-
await TestOrganizationManager.cleanupTestOrganization(client, testOrg);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('listTools', () => {
|
|
23
|
-
it('should list tools', async () => {
|
|
24
|
-
const response = await client.tools.listTools();
|
|
25
|
-
|
|
26
|
-
expect(response).toBeDefined();
|
|
27
|
-
expect(response.tools).toBeDefined();
|
|
28
|
-
expect(Array.isArray(response.tools)).toBe(true);
|
|
29
|
-
expect(response.totalSize).toBeDefined();
|
|
30
|
-
expect(typeof response.totalSize).toBe('number');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should list tools with filter', async () => {
|
|
34
|
-
const response = await client.tools.listTools({
|
|
35
|
-
filter: {
|
|
36
|
-
provider: 'GOOGLE',
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
expect(response).toBeDefined();
|
|
41
|
-
expect(response.tools).toBeDefined();
|
|
42
|
-
expect(Array.isArray(response.tools)).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should list tools with pagination', async () => {
|
|
46
|
-
const firstPage = await client.tools.listTools({
|
|
47
|
-
pageSize: 10,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
expect(firstPage).toBeDefined();
|
|
51
|
-
expect(firstPage.tools).toBeDefined();
|
|
52
|
-
expect(firstPage.tools.length).toBeLessThanOrEqual(10);
|
|
53
|
-
|
|
54
|
-
if (firstPage.nextPageToken) {
|
|
55
|
-
const secondPage = await client.tools.listTools({
|
|
56
|
-
pageSize: 10,
|
|
57
|
-
pageToken: firstPage.nextPageToken,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
expect(secondPage).toBeDefined();
|
|
61
|
-
expect(secondPage.tools).toBeDefined();
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should list tools with summary filter', async () => {
|
|
66
|
-
const response = await client.tools.listTools({
|
|
67
|
-
filter: {
|
|
68
|
-
summary: true,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
expect(response).toBeDefined();
|
|
73
|
-
expect(response.toolNames).toBeDefined();
|
|
74
|
-
expect(Array.isArray(response.toolNames)).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should list tools with tool name filter', async () => {
|
|
78
|
-
const response = await client.tools.listTools({
|
|
79
|
-
filter: {
|
|
80
|
-
toolName: ['gmail_send_email'],
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
expect(response).toBeDefined();
|
|
85
|
-
expect(response.tools).toBeDefined();
|
|
86
|
-
expect(Array.isArray(response.tools)).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('listScopedTools', () => {
|
|
91
|
-
it('should list scoped tools with identifier', async () => {
|
|
92
|
-
const identifier = 'test_identifier';
|
|
93
|
-
|
|
94
|
-
// Filter is required by the API and must have at least one non-empty array
|
|
95
|
-
try {
|
|
96
|
-
const response = await client.tools.listScopedTools(identifier, {
|
|
97
|
-
filter: {
|
|
98
|
-
providers: ['GOOGLE'],
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
expect(response).toBeDefined();
|
|
103
|
-
expect(response.tools).toBeDefined();
|
|
104
|
-
expect(Array.isArray(response.tools)).toBe(true);
|
|
105
|
-
expect(response.totalSize).toBeDefined();
|
|
106
|
-
expect(typeof response.totalSize).toBe('number');
|
|
107
|
-
} catch (error: any) {
|
|
108
|
-
// Expected errors: connected account not found, etc.
|
|
109
|
-
expect(error).toBeDefined();
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should list scoped tools with filter', async () => {
|
|
114
|
-
const identifier = 'test_identifier';
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
const response = await client.tools.listScopedTools(identifier, {
|
|
118
|
-
filter: {
|
|
119
|
-
providers: ['GOOGLE'],
|
|
120
|
-
toolNames: ['gmail_send_email'],
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
expect(response).toBeDefined();
|
|
125
|
-
expect(response.tools).toBeDefined();
|
|
126
|
-
expect(Array.isArray(response.tools)).toBe(true);
|
|
127
|
-
} catch (error: any) {
|
|
128
|
-
// Expected errors: connected account not found, etc.
|
|
129
|
-
expect(error).toBeDefined();
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should list scoped tools with pagination', async () => {
|
|
134
|
-
const identifier = 'test_identifier';
|
|
135
|
-
|
|
136
|
-
// Filter is required by the API and must have at least one non-empty array
|
|
137
|
-
try {
|
|
138
|
-
const firstPage = await client.tools.listScopedTools(identifier, {
|
|
139
|
-
filter: {
|
|
140
|
-
providers: ['GOOGLE'],
|
|
141
|
-
},
|
|
142
|
-
pageSize: 10,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
expect(firstPage).toBeDefined();
|
|
146
|
-
expect(firstPage.tools).toBeDefined();
|
|
147
|
-
expect(firstPage.tools.length).toBeLessThanOrEqual(10);
|
|
148
|
-
|
|
149
|
-
if (firstPage.nextPageToken) {
|
|
150
|
-
const secondPage = await client.tools.listScopedTools(identifier, {
|
|
151
|
-
filter: {
|
|
152
|
-
providers: ['GOOGLE'],
|
|
153
|
-
},
|
|
154
|
-
pageSize: 10,
|
|
155
|
-
pageToken: firstPage.nextPageToken,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
expect(secondPage).toBeDefined();
|
|
159
|
-
expect(secondPage.tools).toBeDefined();
|
|
160
|
-
}
|
|
161
|
-
} catch (error: any) {
|
|
162
|
-
// Expected errors: connected account not found, etc.
|
|
163
|
-
expect(error).toBeDefined();
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
describe('executeTool', () => {
|
|
169
|
-
it('should handle execute tool request with minimal params', async () => {
|
|
170
|
-
// This test expects an error since we don't have a real tool/connected account
|
|
171
|
-
// but it validates the request structure is correct
|
|
172
|
-
try {
|
|
173
|
-
await client.tools.executeTool({
|
|
174
|
-
toolName: 'test_tool',
|
|
175
|
-
params: {
|
|
176
|
-
test: 'value',
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
// If execution succeeds, that's fine too
|
|
180
|
-
} catch (error: any) {
|
|
181
|
-
// Expected errors: tool not found, connected account not found, etc.
|
|
182
|
-
expect(error).toBeDefined();
|
|
183
|
-
// Verify it's a proper error response, not a request structure issue
|
|
184
|
-
expect(error.message || error.toString()).toBeDefined();
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('should handle execute tool with connected account ID', async () => {
|
|
189
|
-
try {
|
|
190
|
-
await client.tools.executeTool({
|
|
191
|
-
toolName: 'test_tool',
|
|
192
|
-
connectedAccountId: 'ca_test123',
|
|
193
|
-
params: {
|
|
194
|
-
test: 'value',
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
} catch (error: any) {
|
|
198
|
-
// Expected errors: tool not found, connected account not found, etc.
|
|
199
|
-
expect(error).toBeDefined();
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('should handle execute tool with identifier and connector', async () => {
|
|
204
|
-
try {
|
|
205
|
-
await client.tools.executeTool({
|
|
206
|
-
toolName: 'test_tool',
|
|
207
|
-
identifier: 'test@example.com',
|
|
208
|
-
connector: 'google_workspace',
|
|
209
|
-
organizationId: testOrg,
|
|
210
|
-
params: {
|
|
211
|
-
test: 'value',
|
|
212
|
-
},
|
|
213
|
-
});
|
|
214
|
-
} catch (error: any) {
|
|
215
|
-
// Expected errors: tool not found, connected account not found, etc.
|
|
216
|
-
expect(error).toBeDefined();
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it('should handle execute tool with complex params', async () => {
|
|
221
|
-
try {
|
|
222
|
-
await client.tools.executeTool({
|
|
223
|
-
toolName: 'gmail_send_email',
|
|
224
|
-
identifier: 'test@example.com',
|
|
225
|
-
connector: 'google_workspace',
|
|
226
|
-
params: {
|
|
227
|
-
to: 'recipient@example.com',
|
|
228
|
-
subject: 'Test Subject',
|
|
229
|
-
body: 'Test Body',
|
|
230
|
-
attachments: [],
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
} catch (error: any) {
|
|
234
|
-
// Expected errors: tool not found, connected account not found, etc.
|
|
235
|
-
expect(error).toBeDefined();
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
});
|