@scalekit-sdk/node 2.1.8 → 2.2.0-beta.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/buf.gen.yaml +2 -0
- package/lib/connected-accounts.d.ts +96 -0
- package/lib/connected-accounts.js +186 -0
- package/lib/connected-accounts.js.map +1 -0
- package/lib/core.js +19 -9
- package/lib/core.js.map +1 -1
- package/lib/domain.d.ts +6 -1
- package/lib/domain.js +20 -8
- package/lib/domain.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.d.ts +24 -0
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js +30 -0
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +21 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +21 -0
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +9 -9
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +4 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +5 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.d.ts +87 -0
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js +95 -0
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.d.ts +718 -0
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js +893 -0
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.d.ts +10 -4
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +12 -5
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.d.ts +48 -5
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +61 -7
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.d.ts +25 -0
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js +36 -2
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.d.ts +27 -0
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js +44 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.d.ts +75 -0
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js +83 -0
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.d.ts +431 -0
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js +627 -0
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.d.ts +10 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js +9 -0
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +36 -0
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +60 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/scalekit.d.ts +4 -0
- package/lib/scalekit.js +21 -7
- package/lib/scalekit.js.map +1 -1
- package/lib/tools.d.ts +75 -0
- package/lib/tools.js +127 -0
- package/lib/tools.js.map +1 -0
- package/package.json +2 -2
- package/reference.md +5865 -0
- package/src/connected-accounts.ts +283 -0
- package/src/core.ts +2 -2
- package/src/domain.ts +29 -7
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.ts +36 -0
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +30 -0
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +6 -0
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.ts +94 -0
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.ts +1294 -0
- package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +14 -6
- package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +66 -6
- package/src/pkg/grpc/scalekit/v1/roles/roles_pb.ts +38 -0
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_pb.ts +51 -0
- package/src/pkg/grpc/scalekit/v1/tools/tools_connect.ts +82 -0
- package/src/pkg/grpc/scalekit/v1/tools/tools_pb.ts +847 -0
- package/src/pkg/grpc/scalekit/v1/users/users_connect.ts +10 -1
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +76 -0
- package/src/scalekit.ts +9 -0
- package/src/tools.ts +166 -0
- package/tests/connected-accounts.test.ts +434 -0
- package/tests/domain.test.ts +54 -0
- package/tests/tools.test.ts +239 -0
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"noImplicitAny": false,
|
|
4
4
|
"target": "ES6",
|
|
5
|
+
"lib": ["ES2020"],
|
|
5
6
|
"module": "commonjs",
|
|
6
7
|
"declaration": true,
|
|
7
8
|
"strictNullChecks": true,
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
"sourceMap": true,
|
|
12
13
|
"skipLibCheck": true,
|
|
13
14
|
"esModuleInterop": true,
|
|
14
|
-
"typeRoots": ["src/types"],
|
|
15
|
+
"typeRoots": ["src/types", "node_modules/@types"],
|
|
15
16
|
"moduleResolution": "Node"
|
|
16
17
|
},
|
|
17
18
|
"include": ["src"],
|