@elevasis/core 0.11.2 → 0.13.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/dist/index.d.ts +2 -1
- package/dist/index.js +8 -1
- package/dist/organization-model/index.d.ts +2 -1
- package/dist/organization-model/index.js +8 -1
- package/dist/test-utils/index.d.ts +27 -15
- package/dist/test-utils/index.js +25 -0
- package/package.json +1 -1
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +27 -270
- package/src/auth/multi-tenancy/credentials/__tests__/encryption.test.ts +217 -216
- package/src/auth/multi-tenancy/credentials/server/encryption.ts +69 -39
- package/src/auth/multi-tenancy/credentials/server/kek-loader.ts +37 -0
- package/src/auth/multi-tenancy/index.ts +3 -0
- package/src/auth/multi-tenancy/invitations/api-schemas.ts +104 -107
- package/src/auth/multi-tenancy/memberships/api-schemas.ts +6 -5
- package/src/auth/multi-tenancy/memberships/membership.ts +130 -138
- package/src/auth/multi-tenancy/permissions.ts +12 -5
- package/src/auth/multi-tenancy/role-management/api-schemas.ts +78 -0
- package/src/auth/multi-tenancy/role-management/index.ts +16 -0
- package/src/business/acquisition/activity-events.ts +142 -0
- package/src/business/acquisition/api-schemas.ts +694 -689
- package/src/business/acquisition/derive-actions.ts +90 -0
- package/src/business/acquisition/index.ts +111 -109
- package/src/execution/engine/index.ts +434 -434
- package/src/execution/engine/tools/integration/server/adapters/apify/__tests__/apify-run-actor.integration.test.ts +298 -293
- package/src/execution/engine/tools/integration/server/adapters/attio/__tests__/attio-crud.integration.test.ts +0 -1
- package/src/execution/engine/tools/integration/service.test.ts +214 -0
- package/src/execution/engine/tools/integration/service.ts +169 -161
- package/src/execution/engine/tools/lead-service-types.ts +882 -879
- package/src/execution/engine/tools/registry.ts +699 -700
- package/src/execution/engine/tools/tool-maps.ts +777 -780
- package/src/integrations/credentials/__tests__/api-schemas.test.ts +420 -496
- package/src/integrations/credentials/api-schemas.ts +127 -143
- package/src/integrations/webhook-endpoints/__tests__/api-schemas.test.ts +327 -318
- package/src/integrations/webhook-endpoints/api-schemas.ts +103 -102
- package/src/integrations/webhook-endpoints/types.ts +58 -51
- package/src/operations/activities/api-schemas.ts +80 -79
- package/src/operations/activities/types.ts +64 -63
- package/src/organization-model/contracts.ts +1 -0
- package/src/organization-model/defaults.ts +6 -0
- package/src/organization-model/domains/navigation.ts +37 -23
- package/src/organization-model/organization-graph.mdx +2 -2
- package/src/organization-model/published.ts +2 -1
- package/src/platform/constants/versions.ts +1 -1
- package/src/reference/_generated/contracts.md +27 -270
- package/src/scaffold-registry/__tests__/index.test.ts +72 -7
- package/src/scaffold-registry/index.ts +163 -29
- package/src/scaffold-registry/schema.ts +68 -62
- package/src/server.ts +281 -272
- package/src/supabase/database.types.ts +16 -10
- package/src/test-utils/rls/RLSTestContext.ts +585 -553
|
@@ -1,293 +1,298 @@
|
|
|
1
|
-
import { describe, it, expect, beforeAll, vi } from 'vitest'
|
|
2
|
-
import { ApifyAdapter } from '../apify-adapter'
|
|
3
|
-
import type { ExecutionContext } from '../../../../../../base/types'
|
|
4
|
-
import { createClient } from '@supabase/supabase-js'
|
|
5
|
-
import type { Database } from '../../../../../../../../supabase/database.types'
|
|
6
|
-
import { decryptCredentialValue } from '../../../../../../../../auth/multi-tenancy/credentials/server/service'
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* -
|
|
21
|
-
* -
|
|
22
|
-
* -
|
|
23
|
-
* -
|
|
24
|
-
* - Apify account accessible with provided credentials
|
|
25
|
-
*
|
|
26
|
-
* Run: pnpm test apify-run-actor.integration.test.ts
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
const SKIP_TESTS = !process.env.SUPABASE_URL || !process.env.SUPABASE_SERVICE_KEY
|
|
30
|
-
|
|
31
|
-
describe.skipIf(SKIP_TESTS)('Apify Run Actor Integration Tests', () => {
|
|
32
|
-
const adapter = new ApifyAdapter()
|
|
33
|
-
const organizationId = 'f9aa5a56-8c13-4cd1-9161-8827ae7b452b'
|
|
34
|
-
const credentialName = 'elevasis-apify'
|
|
35
|
-
|
|
36
|
-
const context: ExecutionContext = {
|
|
37
|
-
organizationId,
|
|
38
|
-
executionId: 'apify-integration-test',
|
|
39
|
-
resourceId: 'apify-test-agent',
|
|
40
|
-
resourceType: 'agent',
|
|
41
|
-
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), child: vi.fn().mockReturnThis() }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let supabase: ReturnType<typeof createClient<Database>>
|
|
45
|
-
let credentials: Record<string, unknown>
|
|
46
|
-
|
|
47
|
-
beforeAll(async () => {
|
|
48
|
-
console.log('\n=== Apify Actor Integration Test Suite ===')
|
|
49
|
-
console.log(`Organization: ${organizationId}`)
|
|
50
|
-
console.log(`Credential: ${credentialName}\n`)
|
|
51
|
-
|
|
52
|
-
// Initialize Supabase
|
|
53
|
-
supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
console.log('
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
expect(result
|
|
124
|
-
expect(result.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
1
|
+
import { describe, it, expect, beforeAll, vi } from 'vitest'
|
|
2
|
+
import { ApifyAdapter } from '../apify-adapter'
|
|
3
|
+
import type { ExecutionContext } from '../../../../../../base/types'
|
|
4
|
+
import { createClient } from '@supabase/supabase-js'
|
|
5
|
+
import type { Database } from '../../../../../../../../supabase/database.types'
|
|
6
|
+
import { decryptCredentialValue } from '../../../../../../../../auth/multi-tenancy/credentials/server/service'
|
|
7
|
+
import { loadCredentialKEKs } from '../../../../../../../../auth/multi-tenancy/credentials/server/kek-loader'
|
|
8
|
+
import type { RunActorResult } from '../fetch/run-actor'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Apify Actor Integration Test Suite
|
|
12
|
+
*
|
|
13
|
+
* Tests the complete runActor flow:
|
|
14
|
+
* 1. Start actor with input
|
|
15
|
+
* 2. Poll for completion
|
|
16
|
+
* 3. Fetch dataset results
|
|
17
|
+
* 4. Handle various actor statuses
|
|
18
|
+
*
|
|
19
|
+
* Prerequisites:
|
|
20
|
+
* - Supabase database with credentials table
|
|
21
|
+
* - Credential 'elevasis-apify' with valid Apify API token
|
|
22
|
+
* - Organization ID: f9aa5a56-8c13-4cd1-9161-8827ae7b452b
|
|
23
|
+
* - SUPABASE_URL and SUPABASE_SERVICE_KEY env vars set
|
|
24
|
+
* - Apify account accessible with provided credentials
|
|
25
|
+
*
|
|
26
|
+
* Run: pnpm test apify-run-actor.integration.test.ts
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const SKIP_TESTS = !process.env.SUPABASE_URL || !process.env.SUPABASE_SERVICE_KEY
|
|
30
|
+
|
|
31
|
+
describe.skipIf(SKIP_TESTS)('Apify Run Actor Integration Tests', () => {
|
|
32
|
+
const adapter = new ApifyAdapter()
|
|
33
|
+
const organizationId = 'f9aa5a56-8c13-4cd1-9161-8827ae7b452b'
|
|
34
|
+
const credentialName = 'elevasis-apify'
|
|
35
|
+
|
|
36
|
+
const context: ExecutionContext = {
|
|
37
|
+
organizationId,
|
|
38
|
+
executionId: 'apify-integration-test',
|
|
39
|
+
resourceId: 'apify-test-agent',
|
|
40
|
+
resourceType: 'agent',
|
|
41
|
+
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), child: vi.fn().mockReturnThis() }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let supabase: ReturnType<typeof createClient<Database>>
|
|
45
|
+
let credentials: Record<string, unknown>
|
|
46
|
+
|
|
47
|
+
beforeAll(async () => {
|
|
48
|
+
console.log('\n=== Apify Actor Integration Test Suite ===')
|
|
49
|
+
console.log(`Organization: ${organizationId}`)
|
|
50
|
+
console.log(`Credential: ${credentialName}\n`)
|
|
51
|
+
|
|
52
|
+
// Initialize Supabase
|
|
53
|
+
supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
|
|
54
|
+
|
|
55
|
+
// Load Vault KEK so platform-v1 ciphertext (post-Wave-B4 re-encrypted rows)
|
|
56
|
+
// decrypts. Without this, the env-fallback would register the legacy key
|
|
57
|
+
// under platform-v1 and AES-GCM auth-tag verification would fail.
|
|
58
|
+
await loadCredentialKEKs()
|
|
59
|
+
|
|
60
|
+
// Fetch credential from database
|
|
61
|
+
const { data: credRow, error } = await supabase
|
|
62
|
+
.from('credentials')
|
|
63
|
+
.select('encrypted_value')
|
|
64
|
+
.eq('organization_id', organizationId)
|
|
65
|
+
.eq('name', credentialName)
|
|
66
|
+
.single()
|
|
67
|
+
|
|
68
|
+
if (error || !credRow) {
|
|
69
|
+
throw new Error(`Credential '${credentialName}' not found for org ${organizationId}. Error: ${error?.message}`)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Decrypt credentials
|
|
73
|
+
credentials = decryptCredentialValue(credRow.encrypted_value)
|
|
74
|
+
|
|
75
|
+
console.log('✓ Credentials loaded and decrypted')
|
|
76
|
+
console.log('Credential fields:', Object.keys(credentials))
|
|
77
|
+
console.log(
|
|
78
|
+
'Credential values (masked):',
|
|
79
|
+
Object.keys(credentials).reduce(
|
|
80
|
+
(acc, key) => {
|
|
81
|
+
acc[key] = typeof credentials[key] === 'string' ? credentials[key].substring(0, 10) + '...' : credentials[key]
|
|
82
|
+
return acc
|
|
83
|
+
},
|
|
84
|
+
{} as Record<string, unknown>
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
const tokenPresent = !!(credentials.apiToken || credentials.apiKey || credentials.api_token || credentials.token)
|
|
88
|
+
console.log(`✓ API Token present: ${tokenPresent}`)
|
|
89
|
+
|
|
90
|
+
// Validate credentials
|
|
91
|
+
const isValid = adapter.validateCredentials(credentials)
|
|
92
|
+
if (!isValid) {
|
|
93
|
+
throw new Error('Credential validation failed')
|
|
94
|
+
}
|
|
95
|
+
console.log('✓ Credentials validated')
|
|
96
|
+
console.log('\n✓ Ready to run tests')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should run a simple actor and return results', { timeout: 60000 }, async () => {
|
|
100
|
+
console.log('\n[Test] Run simple hello-world actor')
|
|
101
|
+
|
|
102
|
+
// Using apify/hello-world - a simple actor that runs quickly
|
|
103
|
+
const result = (await adapter.call(
|
|
104
|
+
'runActor',
|
|
105
|
+
{
|
|
106
|
+
actorId: 'apify/hello-world',
|
|
107
|
+
input: {
|
|
108
|
+
message: 'Integration test from Elevasis'
|
|
109
|
+
},
|
|
110
|
+
timeoutSecs: 60,
|
|
111
|
+
pollIntervalSecs: 5
|
|
112
|
+
},
|
|
113
|
+
credentials,
|
|
114
|
+
context
|
|
115
|
+
)) as RunActorResult
|
|
116
|
+
|
|
117
|
+
console.log(`✓ Actor completed with status: ${result.status}`)
|
|
118
|
+
console.log(`✓ Run ID: ${result.runId}`)
|
|
119
|
+
console.log(`✓ Dataset ID: ${result.datasetId}`)
|
|
120
|
+
console.log(`✓ Items returned: ${result.totalCount}`)
|
|
121
|
+
console.log(`✓ Execution time: ${result.executionTimeMs}ms`)
|
|
122
|
+
|
|
123
|
+
expect(result).toBeDefined()
|
|
124
|
+
expect(result.status).toBe('SUCCEEDED')
|
|
125
|
+
expect(result.runId).toBeDefined()
|
|
126
|
+
expect(result.datasetId).toBeDefined()
|
|
127
|
+
expect(result.items).toBeInstanceOf(Array)
|
|
128
|
+
expect(result.totalCount).toBeGreaterThanOrEqual(0)
|
|
129
|
+
expect(result.executionTimeMs).toBeGreaterThan(0)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('should handle actor with custom input', { timeout: 60000 }, async () => {
|
|
133
|
+
console.log('\n[Test] Run actor with custom input')
|
|
134
|
+
|
|
135
|
+
const result = (await adapter.call(
|
|
136
|
+
'runActor',
|
|
137
|
+
{
|
|
138
|
+
actorId: 'apify/hello-world',
|
|
139
|
+
input: {
|
|
140
|
+
message: 'Custom test message',
|
|
141
|
+
outputDatasetItems: 5
|
|
142
|
+
},
|
|
143
|
+
timeoutSecs: 60,
|
|
144
|
+
pollIntervalSecs: 5
|
|
145
|
+
},
|
|
146
|
+
credentials,
|
|
147
|
+
context
|
|
148
|
+
)) as RunActorResult
|
|
149
|
+
|
|
150
|
+
console.log(`✓ Actor completed: ${result.status}`)
|
|
151
|
+
console.log(`✓ Items in dataset: ${result.totalCount}`)
|
|
152
|
+
|
|
153
|
+
expect(result).toBeDefined()
|
|
154
|
+
expect(result.status).toBe('SUCCEEDED')
|
|
155
|
+
expect(result.items).toBeInstanceOf(Array)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('should handle maxItems parameter', { timeout: 60000 }, async () => {
|
|
159
|
+
console.log('\n[Test] Run actor with maxItems limit')
|
|
160
|
+
|
|
161
|
+
const maxItems = 3
|
|
162
|
+
|
|
163
|
+
const result = (await adapter.call(
|
|
164
|
+
'runActor',
|
|
165
|
+
{
|
|
166
|
+
actorId: 'apify/hello-world',
|
|
167
|
+
input: {
|
|
168
|
+
outputDatasetItems: 10
|
|
169
|
+
},
|
|
170
|
+
maxItems: maxItems,
|
|
171
|
+
timeoutSecs: 60,
|
|
172
|
+
pollIntervalSecs: 5
|
|
173
|
+
},
|
|
174
|
+
credentials,
|
|
175
|
+
context
|
|
176
|
+
)) as RunActorResult
|
|
177
|
+
|
|
178
|
+
console.log(`✓ Actor completed: ${result.status}`)
|
|
179
|
+
console.log(`✓ Items returned (limited): ${result.totalCount}`)
|
|
180
|
+
|
|
181
|
+
expect(result).toBeDefined()
|
|
182
|
+
expect(result.status).toBe('SUCCEEDED')
|
|
183
|
+
expect(result.items).toBeInstanceOf(Array)
|
|
184
|
+
expect(result.items.length).toBeLessThanOrEqual(maxItems)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('should handle timeout gracefully', { timeout: 15000 }, async () => {
|
|
188
|
+
console.log('\n[Test] Handle actor timeout')
|
|
189
|
+
|
|
190
|
+
// Use very short timeout to trigger TIMED_OUT status
|
|
191
|
+
const result = (await adapter.call(
|
|
192
|
+
'runActor',
|
|
193
|
+
{
|
|
194
|
+
actorId: 'apify/hello-world',
|
|
195
|
+
input: {},
|
|
196
|
+
timeoutSecs: 1, // Very short timeout
|
|
197
|
+
pollIntervalSecs: 1
|
|
198
|
+
},
|
|
199
|
+
credentials,
|
|
200
|
+
context
|
|
201
|
+
)) as RunActorResult
|
|
202
|
+
|
|
203
|
+
console.log(`✓ Actor status: ${result.status}`)
|
|
204
|
+
console.log(`✓ Timeout handled gracefully`)
|
|
205
|
+
|
|
206
|
+
expect(result).toBeDefined()
|
|
207
|
+
// Actor might succeed, timeout, or fail depending on external state
|
|
208
|
+
expect(['SUCCEEDED', 'TIMED_OUT', 'FAILED']).toContain(result.status)
|
|
209
|
+
|
|
210
|
+
if (result.status === 'TIMED_OUT') {
|
|
211
|
+
expect(result.items).toEqual([])
|
|
212
|
+
expect(result.totalCount).toBe(0)
|
|
213
|
+
console.log('✓ TIMED_OUT status returns empty items as expected')
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('should handle invalid actor ID gracefully', async () => {
|
|
218
|
+
console.log('\n[Test] Handle invalid actor ID')
|
|
219
|
+
|
|
220
|
+
await expect(
|
|
221
|
+
adapter.call(
|
|
222
|
+
'runActor',
|
|
223
|
+
{
|
|
224
|
+
actorId: 'invalid/nonexistent-actor-xyz-123',
|
|
225
|
+
input: {},
|
|
226
|
+
timeoutSecs: 30,
|
|
227
|
+
pollIntervalSecs: 5
|
|
228
|
+
},
|
|
229
|
+
credentials,
|
|
230
|
+
context
|
|
231
|
+
)
|
|
232
|
+
).rejects.toThrow()
|
|
233
|
+
|
|
234
|
+
console.log('✓ Invalid actor ID rejected as expected')
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it('should handle missing actorId parameter', async () => {
|
|
238
|
+
console.log('\n[Test] Handle missing actorId')
|
|
239
|
+
|
|
240
|
+
await expect(
|
|
241
|
+
adapter.call(
|
|
242
|
+
'runActor',
|
|
243
|
+
{
|
|
244
|
+
// Missing actorId
|
|
245
|
+
input: {},
|
|
246
|
+
timeoutSecs: 30
|
|
247
|
+
},
|
|
248
|
+
credentials,
|
|
249
|
+
context
|
|
250
|
+
)
|
|
251
|
+
).rejects.toThrow('Missing required parameter: actorId')
|
|
252
|
+
|
|
253
|
+
console.log('✓ Missing actorId parameter rejected as expected')
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('should handle invalid credentials gracefully', async () => {
|
|
257
|
+
console.log('\n[Test] Handle invalid credentials')
|
|
258
|
+
|
|
259
|
+
const invalidCreds = { apiToken: 'invalid-token-12345' }
|
|
260
|
+
|
|
261
|
+
await expect(
|
|
262
|
+
adapter.call(
|
|
263
|
+
'runActor',
|
|
264
|
+
{
|
|
265
|
+
actorId: 'apify/hello-world',
|
|
266
|
+
input: {},
|
|
267
|
+
timeoutSecs: 30
|
|
268
|
+
},
|
|
269
|
+
invalidCreds,
|
|
270
|
+
context
|
|
271
|
+
)
|
|
272
|
+
).rejects.toThrow()
|
|
273
|
+
|
|
274
|
+
console.log('✓ Invalid credentials rejected as expected')
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
it('should validate credentials correctly', () => {
|
|
278
|
+
console.log('\n[Test] Validate credentials')
|
|
279
|
+
|
|
280
|
+
// Valid credentials
|
|
281
|
+
const validCreds = { apiToken: 'test-token' }
|
|
282
|
+
expect(adapter.validateCredentials(validCreds)).toBe(true)
|
|
283
|
+
|
|
284
|
+
// Invalid credentials (missing apiToken)
|
|
285
|
+
const invalidCreds1 = {}
|
|
286
|
+
expect(adapter.validateCredentials(invalidCreds1)).toBe(false)
|
|
287
|
+
|
|
288
|
+
// Invalid credentials (empty apiToken)
|
|
289
|
+
const invalidCreds2 = { apiToken: '' }
|
|
290
|
+
expect(adapter.validateCredentials(invalidCreds2)).toBe(false)
|
|
291
|
+
|
|
292
|
+
// Invalid credentials (wrong type)
|
|
293
|
+
const invalidCreds3 = { apiToken: 123 }
|
|
294
|
+
expect(adapter.validateCredentials(invalidCreds3)).toBe(false)
|
|
295
|
+
|
|
296
|
+
console.log('✓ Credential validation working correctly')
|
|
297
|
+
})
|
|
298
|
+
})
|
|
@@ -28,7 +28,6 @@ import type {
|
|
|
28
28
|
* - Credential 'elevasis-attio' with valid Attio API Key
|
|
29
29
|
* - Organization ID: f9aa5a56-8c13-4cd1-9161-8827ae7b452b
|
|
30
30
|
* - SUPABASE_URL and SUPABASE_SERVICE_KEY env vars set
|
|
31
|
-
* - SECRETS_ENCRYPTION_KEY env var set
|
|
32
31
|
* - Attio workspace accessible with provided credentials
|
|
33
32
|
*
|
|
34
33
|
* Run: pnpm test attio-crud.integration.test.ts
|