@elevasis/core 0.13.0 → 0.15.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.
Files changed (42) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +9 -2
  3. package/dist/organization-model/index.d.ts +1 -1
  4. package/dist/organization-model/index.js +9 -2
  5. package/dist/test-utils/index.d.ts +463 -377
  6. package/dist/test-utils/index.js +9 -2
  7. package/package.json +1 -1
  8. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +2336 -0
  9. package/src/business/acquisition/activity-events.test.ts +250 -0
  10. package/src/business/acquisition/activity-events.ts +7 -65
  11. package/src/business/acquisition/api-schemas.test.ts +1180 -0
  12. package/src/business/acquisition/api-schemas.ts +317 -73
  13. package/src/business/acquisition/crm-state-actions.test.ts +160 -0
  14. package/src/business/acquisition/derive-actions.test.ts +518 -0
  15. package/src/business/acquisition/derive-actions.ts +101 -78
  16. package/src/business/acquisition/index.ts +51 -9
  17. package/src/business/acquisition/stateful.ts +30 -0
  18. package/src/business/acquisition/types.ts +48 -80
  19. package/src/execution/engine/index.ts +437 -434
  20. package/src/execution/engine/tools/integration/server/adapters/attio/__tests__/attio-crud.integration.test.ts +363 -360
  21. package/src/execution/engine/tools/integration/server/adapters/attio/fetch/get-record/index.test.ts +162 -186
  22. package/src/execution/engine/tools/integration/server/adapters/attio/fetch/list-records/index.test.ts +316 -338
  23. package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-adapter.ts +204 -210
  24. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.test.ts +88 -0
  25. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.ts +141 -134
  26. package/src/execution/engine/tools/integration/server/adapters/resend/fetch/utils/types.ts +76 -75
  27. package/src/execution/engine/tools/integration/service.test.ts +34 -9
  28. package/src/execution/engine/tools/integration/service.ts +6 -3
  29. package/src/execution/engine/tools/lead-service-types.ts +934 -874
  30. package/src/execution/engine/tools/platform/acquisition/types.ts +266 -260
  31. package/src/execution/engine/tools/registry.ts +701 -699
  32. package/src/execution/engine/tools/tool-maps.ts +30 -2
  33. package/src/execution/engine/workflow/types.ts +11 -0
  34. package/src/organization-model/contracts.ts +4 -4
  35. package/src/organization-model/domains/navigation.ts +62 -62
  36. package/src/organization-model/domains/sales.test.ts +189 -0
  37. package/src/organization-model/domains/sales.ts +456 -94
  38. package/src/organization-model/published.ts +21 -21
  39. package/src/organization-model/resolve.ts +21 -8
  40. package/src/platform/constants/versions.ts +1 -1
  41. package/src/reference/_generated/contracts.md +2336 -0
  42. package/src/supabase/database.types.ts +2958 -2886
@@ -1,360 +1,363 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
2
- import { AttioAdapter } from '../attio-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 type {
8
- CreateRecordResult,
9
- UpdateRecordResult,
10
- GetRecordResult,
11
- QueryRecordsResult,
12
- DeleteRecordResult
13
- } from '../fetch/utils/types'
14
-
15
- /**
16
- * Comprehensive CRUD Integration Test Suite for Attio
17
- *
18
- * Tests the complete lifecycle:
19
- * 1. List records (people)
20
- * 2. Create person record
21
- * 3. Get record by ID
22
- * 4. Update record
23
- * 5. List records with filters
24
- * 6. Error handling
25
- *
26
- * Prerequisites:
27
- * - Supabase database with credentials table
28
- * - Credential 'elevasis-attio' with valid Attio API Key
29
- * - Organization ID: f9aa5a56-8c13-4cd1-9161-8827ae7b452b
30
- * - SUPABASE_URL and SUPABASE_SERVICE_KEY env vars set
31
- * - Attio workspace accessible with provided credentials
32
- *
33
- * Run: pnpm test attio-crud.integration.test.ts
34
- */
35
-
36
- // Attio integration currently unused -- tests skipped unconditionally.
37
- describe.skip('Attio CRUD Integration Tests', () => {
38
- const adapter = new AttioAdapter()
39
- const organizationId = 'f9aa5a56-8c13-4cd1-9161-8827ae7b452b'
40
- const credentialName = 'elevasis-attio'
41
-
42
- const context: ExecutionContext = {
43
- organizationId,
44
- executionId: 'crud-integration-test',
45
- resourceId: 'crud-test-agent',
46
- resourceType: 'agent',
47
- logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), child: vi.fn().mockReturnThis() }
48
- }
49
-
50
- let supabase: ReturnType<typeof createClient<Database>>
51
- let credentials: Record<string, unknown>
52
- let createdRecordId: string
53
-
54
- beforeAll(async () => {
55
- console.log('\n=== Attio CRUD Integration Test Suite ===')
56
- console.log(`Organization: ${organizationId}`)
57
- console.log(`Credential: ${credentialName}\n`)
58
-
59
- // Initialize Supabase
60
- supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
61
-
62
- // Fetch credential from database
63
- const { data: credRow, error } = await supabase
64
- .from('credentials')
65
- .select('encrypted_value')
66
- .eq('organization_id', organizationId)
67
- .eq('name', credentialName)
68
- .single()
69
-
70
- if (error || !credRow) {
71
- throw new Error(`Credential '${credentialName}' not found for org ${organizationId}. Error: ${error?.message}`)
72
- }
73
-
74
- // Decrypt credentials
75
- credentials = decryptCredentialValue(credRow.encrypted_value)
76
-
77
- console.log('✓ Credentials loaded and decrypted')
78
- console.log(`✓ API Key present: ${!!credentials.apiKey}`)
79
-
80
- // Validate credentials
81
- const isValid = adapter.validateCredentials(credentials)
82
- if (!isValid) {
83
- throw new Error('Credential validation failed')
84
- }
85
- console.log('✓ Credentials validated')
86
- console.log('\n✓ Ready to run tests')
87
- })
88
-
89
- it('should list people records', { timeout: 30000 }, async () => {
90
- console.log('\n[Test] List people records')
91
-
92
- const result = (await adapter.call(
93
- 'listRecords',
94
- {
95
- object: 'people',
96
- limit: 10,
97
- offset: 0
98
- },
99
- credentials,
100
- context
101
- )) as QueryRecordsResult
102
-
103
- console.log(`✓ Listed ${result.records.length} people`)
104
-
105
- expect(result).toBeDefined()
106
- expect(result.records).toBeInstanceOf(Array)
107
- expect(result.hasMore).toBeDefined()
108
- })
109
-
110
- it('should create a person record', async () => {
111
- console.log('\n[Test] Create person record')
112
-
113
- const testEmail = `test-${Date.now()}@example.com`
114
-
115
- const result = (await adapter.call(
116
- 'createRecord',
117
- {
118
- object: 'people',
119
- values: {
120
- name: {
121
- first_name: 'Test',
122
- last_name: 'User',
123
- full_name: 'Test User'
124
- },
125
- email_addresses: [
126
- {
127
- email_address: testEmail
128
- }
129
- ]
130
- }
131
- },
132
- credentials,
133
- context
134
- )) as CreateRecordResult
135
-
136
- console.log(`✓ Created person: ${result.recordId}`)
137
-
138
- expect(result).toBeDefined()
139
- expect(result.recordId).toBeDefined()
140
- expect(result.success).toBe(true)
141
-
142
- // Store for later tests
143
- createdRecordId = result.recordId
144
- })
145
-
146
- it('should get the created record by ID', async () => {
147
- console.log('\n[Test] Get record by ID')
148
-
149
- expect(createdRecordId).toBeDefined()
150
-
151
- const result = (await adapter.call(
152
- 'getRecord',
153
- {
154
- object: 'people',
155
- recordId: createdRecordId
156
- },
157
- credentials,
158
- context
159
- )) as GetRecordResult
160
-
161
- console.log(`✓ Retrieved record: ${result.id}`)
162
-
163
- expect(result).toBeDefined()
164
- expect(result.id).toBe(createdRecordId)
165
- expect(result.values).toBeDefined()
166
- expect(result.createdAt).toBeDefined()
167
- })
168
-
169
- it('should update the created record', async () => {
170
- console.log('\n[Test] Update record')
171
-
172
- expect(createdRecordId).toBeDefined()
173
-
174
- const result = (await adapter.call(
175
- 'updateRecord',
176
- {
177
- object: 'people',
178
- recordId: createdRecordId,
179
- values: {
180
- description: 'Updated via integration test'
181
- }
182
- },
183
- credentials,
184
- context
185
- )) as UpdateRecordResult
186
-
187
- console.log(`✓ Updated record: ${result.recordId}`)
188
-
189
- expect(result).toBeDefined()
190
- expect(result.recordId).toBe(createdRecordId)
191
- expect(result.success).toBe(true)
192
- })
193
-
194
- it('should list records with custom limit', async () => {
195
- console.log('\n[Test] List records with custom limit')
196
-
197
- const result = (await adapter.call(
198
- 'listRecords',
199
- {
200
- object: 'people',
201
- limit: 5,
202
- offset: 0
203
- },
204
- credentials,
205
- context
206
- )) as QueryRecordsResult
207
-
208
- console.log(`✓ Listed ${result.records.length} people (limit: 5)`)
209
-
210
- expect(result).toBeDefined()
211
- expect(result.records).toBeInstanceOf(Array)
212
- expect(result.records.length).toBeLessThanOrEqual(5)
213
- })
214
-
215
- it('should list records with pagination', { timeout: 30000 }, async () => {
216
- console.log('\n[Test] List records with pagination')
217
-
218
- const page1 = (await adapter.call(
219
- 'listRecords',
220
- {
221
- object: 'people',
222
- limit: 2,
223
- offset: 0
224
- },
225
- credentials,
226
- context
227
- )) as QueryRecordsResult
228
-
229
- const page2 = (await adapter.call(
230
- 'listRecords',
231
- {
232
- object: 'people',
233
- limit: 2,
234
- offset: 2
235
- },
236
- credentials,
237
- context
238
- )) as QueryRecordsResult
239
-
240
- console.log(`✓ Page 1: ${page1.records.length} records`)
241
- console.log(`✓ Page 2: ${page2.records.length} records`)
242
-
243
- expect(page1).toBeDefined()
244
- expect(page2).toBeDefined()
245
- expect(page1.records).toBeInstanceOf(Array)
246
- expect(page2.records).toBeInstanceOf(Array)
247
- })
248
-
249
- it('should list records with sorting', async () => {
250
- console.log('\n[Test] List records with sorting')
251
-
252
- const result = (await adapter.call(
253
- 'listRecords',
254
- {
255
- object: 'people',
256
- sorts: [
257
- {
258
- attribute: 'name',
259
- field: 'last_name',
260
- direction: 'asc'
261
- }
262
- ],
263
- limit: 10
264
- },
265
- credentials,
266
- context
267
- )) as QueryRecordsResult
268
-
269
- console.log(`✓ Listed ${result.records.length} people (sorted by name)`)
270
-
271
- expect(result).toBeDefined()
272
- expect(result.records).toBeInstanceOf(Array)
273
- })
274
-
275
- it('should handle invalid record ID gracefully', async () => {
276
- console.log('\n[Test] Handle invalid record ID')
277
-
278
- await expect(
279
- adapter.call(
280
- 'getRecord',
281
- {
282
- object: 'people',
283
- recordId: 'invalid-uuid-12345'
284
- },
285
- credentials,
286
- context
287
- )
288
- ).rejects.toThrow()
289
-
290
- console.log('✓ Invalid record ID rejected as expected')
291
- })
292
-
293
- it('should handle invalid credentials gracefully', async () => {
294
- console.log('\n[Test] Handle invalid credentials')
295
-
296
- const invalidCreds = { apiKey: 'invalid-key-12345' }
297
-
298
- await expect(
299
- adapter.call(
300
- 'listRecords',
301
- {
302
- object: 'people',
303
- limit: 10
304
- },
305
- invalidCreds,
306
- context
307
- )
308
- ).rejects.toThrow()
309
-
310
- console.log('✓ Invalid credentials rejected as expected')
311
- })
312
-
313
- it('should work with companies object type', async () => {
314
- console.log('\n[Test] List companies')
315
-
316
- const result = (await adapter.call(
317
- 'listRecords',
318
- {
319
- object: 'companies',
320
- limit: 5
321
- },
322
- credentials,
323
- context
324
- )) as QueryRecordsResult
325
-
326
- console.log(`✓ Listed ${result.records.length} companies`)
327
-
328
- expect(result).toBeDefined()
329
- expect(result.records).toBeInstanceOf(Array)
330
- })
331
-
332
- afterAll(async () => {
333
- // Clean up test data
334
- if (createdRecordId) {
335
- console.log('\n=== Cleanup ===')
336
- console.log(`Deleting test record: ${createdRecordId}`)
337
-
338
- try {
339
- const result = (await adapter.call(
340
- 'deleteRecord',
341
- {
342
- object: 'people',
343
- recordId: createdRecordId
344
- },
345
- credentials,
346
- context
347
- )) as DeleteRecordResult
348
-
349
- if (result.success) {
350
- console.log(`✓ Test record deleted: ${createdRecordId}`)
351
- } else {
352
- console.log(`⚠️ Delete returned success=false for record: ${createdRecordId}`)
353
- }
354
- } catch (error) {
355
- console.warn('⚠️ Cleanup failed:', error)
356
- console.warn(` Manual cleanup may be needed for record: ${createdRecordId}`)
357
- }
358
- }
359
- })
360
- })
1
+ import { describe as _describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
2
+
3
+ // Attio integration not in use; suite skipped per project decision (2026-04-29).
4
+ const describe = _describe.skip
5
+ import { AttioAdapter } from '../attio-adapter'
6
+ import type { ExecutionContext } from '../../../../../../base/types'
7
+ import { createClient } from '@supabase/supabase-js'
8
+ import type { Database } from '../../../../../../../../supabase/database.types'
9
+ import { decryptCredentialValue } from '../../../../../../../../auth/multi-tenancy/credentials/server/service'
10
+ import type {
11
+ CreateRecordResult,
12
+ UpdateRecordResult,
13
+ GetRecordResult,
14
+ QueryRecordsResult,
15
+ DeleteRecordResult
16
+ } from '../fetch/utils/types'
17
+
18
+ /**
19
+ * Comprehensive CRUD Integration Test Suite for Attio
20
+ *
21
+ * Tests the complete lifecycle:
22
+ * 1. List records (people)
23
+ * 2. Create person record
24
+ * 3. Get record by ID
25
+ * 4. Update record
26
+ * 5. List records with filters
27
+ * 6. Error handling
28
+ *
29
+ * Prerequisites:
30
+ * - Supabase database with credentials table
31
+ * - Credential 'elevasis-attio' with valid Attio API Key
32
+ * - Organization ID: f9aa5a56-8c13-4cd1-9161-8827ae7b452b
33
+ * - SUPABASE_URL and SUPABASE_SERVICE_KEY env vars set
34
+ * - Attio workspace accessible with provided credentials
35
+ *
36
+ * Run: pnpm test attio-crud.integration.test.ts
37
+ */
38
+
39
+ // Attio integration currently unused -- tests skipped unconditionally.
40
+ describe.skip('Attio CRUD Integration Tests', () => {
41
+ const adapter = new AttioAdapter()
42
+ const organizationId = 'f9aa5a56-8c13-4cd1-9161-8827ae7b452b'
43
+ const credentialName = 'elevasis-attio'
44
+
45
+ const context: ExecutionContext = {
46
+ organizationId,
47
+ executionId: 'crud-integration-test',
48
+ resourceId: 'crud-test-agent',
49
+ resourceType: 'agent',
50
+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), child: vi.fn().mockReturnThis() }
51
+ }
52
+
53
+ let supabase: ReturnType<typeof createClient<Database>>
54
+ let credentials: Record<string, unknown>
55
+ let createdRecordId: string
56
+
57
+ beforeAll(async () => {
58
+ console.log('\n=== Attio CRUD Integration Test Suite ===')
59
+ console.log(`Organization: ${organizationId}`)
60
+ console.log(`Credential: ${credentialName}\n`)
61
+
62
+ // Initialize Supabase
63
+ supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
64
+
65
+ // Fetch credential from database
66
+ const { data: credRow, error } = await supabase
67
+ .from('credentials')
68
+ .select('encrypted_value')
69
+ .eq('organization_id', organizationId)
70
+ .eq('name', credentialName)
71
+ .single()
72
+
73
+ if (error || !credRow) {
74
+ throw new Error(`Credential '${credentialName}' not found for org ${organizationId}. Error: ${error?.message}`)
75
+ }
76
+
77
+ // Decrypt credentials
78
+ credentials = decryptCredentialValue(credRow.encrypted_value)
79
+
80
+ console.log('✓ Credentials loaded and decrypted')
81
+ console.log(`✓ API Key present: ${!!credentials.apiKey}`)
82
+
83
+ // Validate credentials
84
+ const isValid = adapter.validateCredentials(credentials)
85
+ if (!isValid) {
86
+ throw new Error('Credential validation failed')
87
+ }
88
+ console.log('✓ Credentials validated')
89
+ console.log('\n✓ Ready to run tests')
90
+ })
91
+
92
+ it('should list people records', { timeout: 30000 }, async () => {
93
+ console.log('\n[Test] List people records')
94
+
95
+ const result = (await adapter.call(
96
+ 'listRecords',
97
+ {
98
+ object: 'people',
99
+ limit: 10,
100
+ offset: 0
101
+ },
102
+ credentials,
103
+ context
104
+ )) as QueryRecordsResult
105
+
106
+ console.log(`✓ Listed ${result.records.length} people`)
107
+
108
+ expect(result).toBeDefined()
109
+ expect(result.records).toBeInstanceOf(Array)
110
+ expect(result.hasMore).toBeDefined()
111
+ })
112
+
113
+ it('should create a person record', async () => {
114
+ console.log('\n[Test] Create person record')
115
+
116
+ const testEmail = `test-${Date.now()}@example.com`
117
+
118
+ const result = (await adapter.call(
119
+ 'createRecord',
120
+ {
121
+ object: 'people',
122
+ values: {
123
+ name: {
124
+ first_name: 'Test',
125
+ last_name: 'User',
126
+ full_name: 'Test User'
127
+ },
128
+ email_addresses: [
129
+ {
130
+ email_address: testEmail
131
+ }
132
+ ]
133
+ }
134
+ },
135
+ credentials,
136
+ context
137
+ )) as CreateRecordResult
138
+
139
+ console.log(`✓ Created person: ${result.recordId}`)
140
+
141
+ expect(result).toBeDefined()
142
+ expect(result.recordId).toBeDefined()
143
+ expect(result.success).toBe(true)
144
+
145
+ // Store for later tests
146
+ createdRecordId = result.recordId
147
+ })
148
+
149
+ it('should get the created record by ID', async () => {
150
+ console.log('\n[Test] Get record by ID')
151
+
152
+ expect(createdRecordId).toBeDefined()
153
+
154
+ const result = (await adapter.call(
155
+ 'getRecord',
156
+ {
157
+ object: 'people',
158
+ recordId: createdRecordId
159
+ },
160
+ credentials,
161
+ context
162
+ )) as GetRecordResult
163
+
164
+ console.log(`✓ Retrieved record: ${result.id}`)
165
+
166
+ expect(result).toBeDefined()
167
+ expect(result.id).toBe(createdRecordId)
168
+ expect(result.values).toBeDefined()
169
+ expect(result.createdAt).toBeDefined()
170
+ })
171
+
172
+ it('should update the created record', async () => {
173
+ console.log('\n[Test] Update record')
174
+
175
+ expect(createdRecordId).toBeDefined()
176
+
177
+ const result = (await adapter.call(
178
+ 'updateRecord',
179
+ {
180
+ object: 'people',
181
+ recordId: createdRecordId,
182
+ values: {
183
+ description: 'Updated via integration test'
184
+ }
185
+ },
186
+ credentials,
187
+ context
188
+ )) as UpdateRecordResult
189
+
190
+ console.log(`✓ Updated record: ${result.recordId}`)
191
+
192
+ expect(result).toBeDefined()
193
+ expect(result.recordId).toBe(createdRecordId)
194
+ expect(result.success).toBe(true)
195
+ })
196
+
197
+ it('should list records with custom limit', async () => {
198
+ console.log('\n[Test] List records with custom limit')
199
+
200
+ const result = (await adapter.call(
201
+ 'listRecords',
202
+ {
203
+ object: 'people',
204
+ limit: 5,
205
+ offset: 0
206
+ },
207
+ credentials,
208
+ context
209
+ )) as QueryRecordsResult
210
+
211
+ console.log(`✓ Listed ${result.records.length} people (limit: 5)`)
212
+
213
+ expect(result).toBeDefined()
214
+ expect(result.records).toBeInstanceOf(Array)
215
+ expect(result.records.length).toBeLessThanOrEqual(5)
216
+ })
217
+
218
+ it('should list records with pagination', { timeout: 30000 }, async () => {
219
+ console.log('\n[Test] List records with pagination')
220
+
221
+ const page1 = (await adapter.call(
222
+ 'listRecords',
223
+ {
224
+ object: 'people',
225
+ limit: 2,
226
+ offset: 0
227
+ },
228
+ credentials,
229
+ context
230
+ )) as QueryRecordsResult
231
+
232
+ const page2 = (await adapter.call(
233
+ 'listRecords',
234
+ {
235
+ object: 'people',
236
+ limit: 2,
237
+ offset: 2
238
+ },
239
+ credentials,
240
+ context
241
+ )) as QueryRecordsResult
242
+
243
+ console.log(`✓ Page 1: ${page1.records.length} records`)
244
+ console.log(`✓ Page 2: ${page2.records.length} records`)
245
+
246
+ expect(page1).toBeDefined()
247
+ expect(page2).toBeDefined()
248
+ expect(page1.records).toBeInstanceOf(Array)
249
+ expect(page2.records).toBeInstanceOf(Array)
250
+ })
251
+
252
+ it('should list records with sorting', async () => {
253
+ console.log('\n[Test] List records with sorting')
254
+
255
+ const result = (await adapter.call(
256
+ 'listRecords',
257
+ {
258
+ object: 'people',
259
+ sorts: [
260
+ {
261
+ attribute: 'name',
262
+ field: 'last_name',
263
+ direction: 'asc'
264
+ }
265
+ ],
266
+ limit: 10
267
+ },
268
+ credentials,
269
+ context
270
+ )) as QueryRecordsResult
271
+
272
+ console.log(`✓ Listed ${result.records.length} people (sorted by name)`)
273
+
274
+ expect(result).toBeDefined()
275
+ expect(result.records).toBeInstanceOf(Array)
276
+ })
277
+
278
+ it('should handle invalid record ID gracefully', async () => {
279
+ console.log('\n[Test] Handle invalid record ID')
280
+
281
+ await expect(
282
+ adapter.call(
283
+ 'getRecord',
284
+ {
285
+ object: 'people',
286
+ recordId: 'invalid-uuid-12345'
287
+ },
288
+ credentials,
289
+ context
290
+ )
291
+ ).rejects.toThrow()
292
+
293
+ console.log(' Invalid record ID rejected as expected')
294
+ })
295
+
296
+ it('should handle invalid credentials gracefully', async () => {
297
+ console.log('\n[Test] Handle invalid credentials')
298
+
299
+ const invalidCreds = { apiKey: 'invalid-key-12345' }
300
+
301
+ await expect(
302
+ adapter.call(
303
+ 'listRecords',
304
+ {
305
+ object: 'people',
306
+ limit: 10
307
+ },
308
+ invalidCreds,
309
+ context
310
+ )
311
+ ).rejects.toThrow()
312
+
313
+ console.log(' Invalid credentials rejected as expected')
314
+ })
315
+
316
+ it('should work with companies object type', async () => {
317
+ console.log('\n[Test] List companies')
318
+
319
+ const result = (await adapter.call(
320
+ 'listRecords',
321
+ {
322
+ object: 'companies',
323
+ limit: 5
324
+ },
325
+ credentials,
326
+ context
327
+ )) as QueryRecordsResult
328
+
329
+ console.log(`✓ Listed ${result.records.length} companies`)
330
+
331
+ expect(result).toBeDefined()
332
+ expect(result.records).toBeInstanceOf(Array)
333
+ })
334
+
335
+ afterAll(async () => {
336
+ // Clean up test data
337
+ if (createdRecordId) {
338
+ console.log('\n=== Cleanup ===')
339
+ console.log(`Deleting test record: ${createdRecordId}`)
340
+
341
+ try {
342
+ const result = (await adapter.call(
343
+ 'deleteRecord',
344
+ {
345
+ object: 'people',
346
+ recordId: createdRecordId
347
+ },
348
+ credentials,
349
+ context
350
+ )) as DeleteRecordResult
351
+
352
+ if (result.success) {
353
+ console.log(`✓ Test record deleted: ${createdRecordId}`)
354
+ } else {
355
+ console.log(`⚠️ Delete returned success=false for record: ${createdRecordId}`)
356
+ }
357
+ } catch (error) {
358
+ console.warn('⚠️ Cleanup failed:', error)
359
+ console.warn(` Manual cleanup may be needed for record: ${createdRecordId}`)
360
+ }
361
+ }
362
+ })
363
+ })