@elevasis/core 0.8.3 → 0.9.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/package.json +3 -3
- package/src/business/projects/types.ts +1 -1
- package/src/execution/engine/tools/integration/server/adapters/google-sheets/__tests__/google-sheets.integration.test.ts +261 -261
- package/src/platform/constants/versions.ts +1 -1
- package/src/projects/api-schemas.test.ts +39 -0
- package/src/projects/api-schemas.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elevasis/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Minimal shared constants across Elevasis monorepo",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"rollup-plugin-dts": "^6.3.0",
|
|
38
38
|
"tsup": "^8.0.0",
|
|
39
39
|
"typescript": "5.9.2",
|
|
40
|
-
"@repo/
|
|
41
|
-
"@repo/
|
|
40
|
+
"@repo/typescript-config": "0.0.0",
|
|
41
|
+
"@repo/eslint-config": "0.0.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@anthropic-ai/sdk": "^0.62.0",
|
|
@@ -36,7 +36,7 @@ export type TaskStatus =
|
|
|
36
36
|
|
|
37
37
|
export type TaskType = 'documentation' | 'code' | 'report' | 'design' | 'other'
|
|
38
38
|
|
|
39
|
-
export type NoteType = 'call_note' | 'status_update' | 'issue' | 'blocker'
|
|
39
|
+
export type NoteType = 'call_note' | 'status_update' | 'issue' | 'blocker' | 'agent_learning'
|
|
40
40
|
|
|
41
41
|
// Filter types
|
|
42
42
|
export interface ProjectFilters {
|
|
@@ -1,261 +1,261 @@
|
|
|
1
|
-
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
|
2
|
-
import { GoogleSheetsAdapter } from '../google-sheets-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
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Google Sheets Integration Tests
|
|
10
|
-
*
|
|
11
|
-
* Consolidated test suite covering:
|
|
12
|
-
* - Basic CRUD operations (read, write, append, batch update, clear)
|
|
13
|
-
* - Workflow-friendly methods (getHeaders, getRowByValue, upsertRow, etc.)
|
|
14
|
-
* - Error handling
|
|
15
|
-
*
|
|
16
|
-
* Rate limit: Google Sheets API allows 60 requests/minute/user
|
|
17
|
-
* Tests are grouped to minimize API calls.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const SKIP_TESTS =
|
|
21
|
-
|
|
22
|
-
describe.skipIf(SKIP_TESTS)('Google Sheets Integration Tests', () => {
|
|
23
|
-
const adapter = new GoogleSheetsAdapter()
|
|
24
|
-
const organizationId = 'f9aa5a56-8c13-4cd1-9161-8827ae7b452b'
|
|
25
|
-
const credentialName = 'elevasis-google-sheets'
|
|
26
|
-
const spreadsheetId = '1cgrLVPE0bpq4GAqo8RvRh3VkP49Ut-osuNKL-hNx44Y'
|
|
27
|
-
|
|
28
|
-
const context: ExecutionContext = {
|
|
29
|
-
organizationId,
|
|
30
|
-
executionId: 'sheets-integration-test',
|
|
31
|
-
resourceId: 'sheets-test-agent',
|
|
32
|
-
resourceType: 'agent',
|
|
33
|
-
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), child: vi.fn().mockReturnThis() }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let credentials: Record<string, unknown>
|
|
37
|
-
let testSheetName: string
|
|
38
|
-
|
|
39
|
-
beforeAll(async () => {
|
|
40
|
-
console.log('\n=== Google Sheets Integration Tests ===')
|
|
41
|
-
const supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
|
|
42
|
-
|
|
43
|
-
const { data: credRow, error } = await supabase
|
|
44
|
-
.from('credentials')
|
|
45
|
-
.select('encrypted_value')
|
|
46
|
-
.eq('organization_id', organizationId)
|
|
47
|
-
.eq('name', credentialName)
|
|
48
|
-
.single()
|
|
49
|
-
|
|
50
|
-
if (error || !credRow) {
|
|
51
|
-
throw new Error(`Credential not found: ${error?.message}`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
credentials = decryptCredentialValue(credRow.encrypted_value)
|
|
55
|
-
console.log('✓ Credentials loaded\n')
|
|
56
|
-
}, 15000)
|
|
57
|
-
|
|
58
|
-
afterAll(async () => {
|
|
59
|
-
// Clean up test data
|
|
60
|
-
const rangesToClean = ['Test!A100:C105', 'Test!A200:C210', 'Test!A300:C302']
|
|
61
|
-
for (const range of rangesToClean) {
|
|
62
|
-
try {
|
|
63
|
-
await adapter.call('clearRange', { spreadsheetId, range }, credentials, context)
|
|
64
|
-
} catch {
|
|
65
|
-
// Ignore cleanup errors
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
console.log('\n=== Tests Complete ===\n')
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
// ============================================
|
|
72
|
-
// 1. Basic CRUD Operations
|
|
73
|
-
// ============================================
|
|
74
|
-
|
|
75
|
-
describe('Basic CRUD Operations', () => {
|
|
76
|
-
it('should get spreadsheet metadata', async () => {
|
|
77
|
-
const result = (await adapter.call('getSpreadsheetMetadata', { spreadsheetId }, credentials, context)) as {
|
|
78
|
-
title: string
|
|
79
|
-
sheets: Array<{ sheetId: number; title: string; index: number }>
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
expect(result.title).toBeTruthy()
|
|
83
|
-
expect(result.sheets.length).toBeGreaterThan(0)
|
|
84
|
-
testSheetName = result.sheets[0].title
|
|
85
|
-
console.log(`Using sheet: ${testSheetName}`)
|
|
86
|
-
}, 15000)
|
|
87
|
-
|
|
88
|
-
it('should read, write, and clear data', async () => {
|
|
89
|
-
const range = 'Test!A100:C101'
|
|
90
|
-
const testData = [
|
|
91
|
-
['TestName', '101', 'Test description'],
|
|
92
|
-
['TestName2', '102', 'Another description']
|
|
93
|
-
]
|
|
94
|
-
|
|
95
|
-
// Write
|
|
96
|
-
const writeResult = (await adapter.call(
|
|
97
|
-
'writeSheet',
|
|
98
|
-
{ spreadsheetId, range, values: testData },
|
|
99
|
-
credentials,
|
|
100
|
-
context
|
|
101
|
-
)) as { updatedCells: number }
|
|
102
|
-
expect(writeResult.updatedCells).toBe(6)
|
|
103
|
-
|
|
104
|
-
// Read back
|
|
105
|
-
const readResult = (await adapter.call('readSheet', { spreadsheetId, range }, credentials, context)) as {
|
|
106
|
-
values: string[][]
|
|
107
|
-
}
|
|
108
|
-
expect(readResult.values[0][0]).toBe('TestName')
|
|
109
|
-
expect(readResult.values[1][0]).toBe('TestName2')
|
|
110
|
-
|
|
111
|
-
// Clear
|
|
112
|
-
const clearResult = (await adapter.call('clearRange', { spreadsheetId, range }, credentials, context)) as {
|
|
113
|
-
clearedRange: string
|
|
114
|
-
}
|
|
115
|
-
expect(clearResult.clearedRange).toContain('A100')
|
|
116
|
-
|
|
117
|
-
// Verify cleared
|
|
118
|
-
const verifyResult = (await adapter.call('readSheet', { spreadsheetId, range }, credentials, context)) as {
|
|
119
|
-
values: string[][]
|
|
120
|
-
}
|
|
121
|
-
expect(verifyResult.values.length).toBe(0)
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
it('should append rows and batch update', async () => {
|
|
125
|
-
// Append
|
|
126
|
-
const appendResult = (await adapter.call(
|
|
127
|
-
'appendRows',
|
|
128
|
-
{
|
|
129
|
-
spreadsheetId,
|
|
130
|
-
range: 'Test!A200:C200',
|
|
131
|
-
values: [['Appended1', '201', 'Appended row']]
|
|
132
|
-
},
|
|
133
|
-
credentials,
|
|
134
|
-
context
|
|
135
|
-
)) as { updatedRows: number }
|
|
136
|
-
expect(appendResult.updatedRows).toBe(1)
|
|
137
|
-
|
|
138
|
-
// Batch update
|
|
139
|
-
const batchResult = (await adapter.call(
|
|
140
|
-
'batchUpdate',
|
|
141
|
-
{
|
|
142
|
-
spreadsheetId,
|
|
143
|
-
data: [
|
|
144
|
-
{ range: 'Test!A202:C202', values: [['Batch1', '202', 'Batch row 1']] },
|
|
145
|
-
{ range: 'Test!A203:C203', values: [['Batch2', '203', 'Batch row 2']] }
|
|
146
|
-
]
|
|
147
|
-
},
|
|
148
|
-
credentials,
|
|
149
|
-
context
|
|
150
|
-
)) as { totalUpdatedCells: number; totalUpdatedRows: number }
|
|
151
|
-
expect(batchResult.totalUpdatedRows).toBe(2)
|
|
152
|
-
}, 20000)
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
// ============================================
|
|
156
|
-
// 2. Workflow-Friendly Methods
|
|
157
|
-
// ============================================
|
|
158
|
-
|
|
159
|
-
describe('Workflow-Friendly Methods', () => {
|
|
160
|
-
it('should get headers and find row by value', async () => {
|
|
161
|
-
// Setup: Write test data with headers
|
|
162
|
-
await adapter.call(
|
|
163
|
-
'writeSheet',
|
|
164
|
-
{
|
|
165
|
-
spreadsheetId,
|
|
166
|
-
range: 'Test!A1:C2',
|
|
167
|
-
values: [
|
|
168
|
-
['Name', 'Id', 'Description'],
|
|
169
|
-
['FindMe', '999', 'Test row for lookup']
|
|
170
|
-
]
|
|
171
|
-
},
|
|
172
|
-
credentials,
|
|
173
|
-
context
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
// Get headers
|
|
177
|
-
const headersResult = (await adapter.call(
|
|
178
|
-
'getHeaders',
|
|
179
|
-
{ spreadsheetId, sheetName: 'Test' },
|
|
180
|
-
credentials,
|
|
181
|
-
context
|
|
182
|
-
)) as { headers: string[]; columnMap: Record<string, string> }
|
|
183
|
-
expect(headersResult.headers).toContain('Name')
|
|
184
|
-
expect(headersResult.columnMap.Name).toBe('A')
|
|
185
|
-
|
|
186
|
-
// Find row by value
|
|
187
|
-
const findResult = (await adapter.call(
|
|
188
|
-
'getRowByValue',
|
|
189
|
-
{ spreadsheetId, sheetName: 'Test', searchColumn: 'A', searchValue: 'FindMe' },
|
|
190
|
-
credentials,
|
|
191
|
-
context
|
|
192
|
-
)) as { found: boolean; rowNumber: number | null; rowData: string[] | null }
|
|
193
|
-
expect(findResult.found).toBe(true)
|
|
194
|
-
expect(findResult.rowData?.[0]).toBe('FindMe')
|
|
195
|
-
}, 20000)
|
|
196
|
-
|
|
197
|
-
it('should upsert and update rows by value', async () => {
|
|
198
|
-
const uniqueKey = `UpsertTest_${Date.now()}`
|
|
199
|
-
|
|
200
|
-
// Upsert (insert)
|
|
201
|
-
const insertResult = (await adapter.call(
|
|
202
|
-
'upsertRow',
|
|
203
|
-
{
|
|
204
|
-
spreadsheetId,
|
|
205
|
-
sheetName: 'Test',
|
|
206
|
-
keyColumn: 'A',
|
|
207
|
-
keyValue: uniqueKey,
|
|
208
|
-
rowData: { Name: uniqueKey, Id: '888', Description: 'Inserted via upsert' }
|
|
209
|
-
},
|
|
210
|
-
credentials,
|
|
211
|
-
context
|
|
212
|
-
)) as { action: 'inserted' | 'updated' }
|
|
213
|
-
expect(insertResult.action).toBe('inserted')
|
|
214
|
-
|
|
215
|
-
// Upsert (update)
|
|
216
|
-
const updateResult = (await adapter.call(
|
|
217
|
-
'upsertRow',
|
|
218
|
-
{
|
|
219
|
-
spreadsheetId,
|
|
220
|
-
sheetName: 'Test',
|
|
221
|
-
keyColumn: 'A',
|
|
222
|
-
keyValue: uniqueKey,
|
|
223
|
-
rowData: { Name: uniqueKey, Id: '888', Description: 'Updated via upsert' }
|
|
224
|
-
},
|
|
225
|
-
credentials,
|
|
226
|
-
context
|
|
227
|
-
)) as { action: 'inserted' | 'updated' }
|
|
228
|
-
expect(updateResult.action).toBe('updated')
|
|
229
|
-
|
|
230
|
-
// Clean up
|
|
231
|
-
await adapter.call(
|
|
232
|
-
'deleteRowByValue',
|
|
233
|
-
{ spreadsheetId, sheetName: 'Test', searchColumn: 'A', searchValue: uniqueKey },
|
|
234
|
-
credentials,
|
|
235
|
-
context
|
|
236
|
-
)
|
|
237
|
-
}, 25000)
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
// ============================================
|
|
241
|
-
// 3. Error Handling
|
|
242
|
-
// ============================================
|
|
243
|
-
|
|
244
|
-
describe('Error Handling', () => {
|
|
245
|
-
it('should handle invalid spreadsheet ID', async () => {
|
|
246
|
-
await expect(
|
|
247
|
-
adapter.call('readSheet', { spreadsheetId: 'invalid-id', range: 'Sheet1!A1' }, credentials, context)
|
|
248
|
-
).rejects.toThrow()
|
|
249
|
-
}, 15000)
|
|
250
|
-
|
|
251
|
-
it('should validate required fields', async () => {
|
|
252
|
-
await expect(adapter.call('readSheet', { spreadsheetId: '', range: 'A1' }, credentials, context)).rejects.toThrow(
|
|
253
|
-
'Missing required field: spreadsheetId'
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
await expect(
|
|
257
|
-
adapter.call('writeSheet', { spreadsheetId, range: 'A1', values: null }, credentials, context)
|
|
258
|
-
).rejects.toThrow('Missing required field: values')
|
|
259
|
-
}, 15000)
|
|
260
|
-
})
|
|
261
|
-
})
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
|
2
|
+
import { GoogleSheetsAdapter } from '../google-sheets-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
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Google Sheets Integration Tests
|
|
10
|
+
*
|
|
11
|
+
* Consolidated test suite covering:
|
|
12
|
+
* - Basic CRUD operations (read, write, append, batch update, clear)
|
|
13
|
+
* - Workflow-friendly methods (getHeaders, getRowByValue, upsertRow, etc.)
|
|
14
|
+
* - Error handling
|
|
15
|
+
*
|
|
16
|
+
* Rate limit: Google Sheets API allows 60 requests/minute/user
|
|
17
|
+
* Tests are grouped to minimize API calls.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const SKIP_TESTS = true
|
|
21
|
+
|
|
22
|
+
describe.skipIf(SKIP_TESTS)('Google Sheets Integration Tests', () => {
|
|
23
|
+
const adapter = new GoogleSheetsAdapter()
|
|
24
|
+
const organizationId = 'f9aa5a56-8c13-4cd1-9161-8827ae7b452b'
|
|
25
|
+
const credentialName = 'elevasis-google-sheets'
|
|
26
|
+
const spreadsheetId = '1cgrLVPE0bpq4GAqo8RvRh3VkP49Ut-osuNKL-hNx44Y'
|
|
27
|
+
|
|
28
|
+
const context: ExecutionContext = {
|
|
29
|
+
organizationId,
|
|
30
|
+
executionId: 'sheets-integration-test',
|
|
31
|
+
resourceId: 'sheets-test-agent',
|
|
32
|
+
resourceType: 'agent',
|
|
33
|
+
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn(), child: vi.fn().mockReturnThis() }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let credentials: Record<string, unknown>
|
|
37
|
+
let testSheetName: string
|
|
38
|
+
|
|
39
|
+
beforeAll(async () => {
|
|
40
|
+
console.log('\n=== Google Sheets Integration Tests ===')
|
|
41
|
+
const supabase = createClient<Database>(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
|
|
42
|
+
|
|
43
|
+
const { data: credRow, error } = await supabase
|
|
44
|
+
.from('credentials')
|
|
45
|
+
.select('encrypted_value')
|
|
46
|
+
.eq('organization_id', organizationId)
|
|
47
|
+
.eq('name', credentialName)
|
|
48
|
+
.single()
|
|
49
|
+
|
|
50
|
+
if (error || !credRow) {
|
|
51
|
+
throw new Error(`Credential not found: ${error?.message}`)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
credentials = decryptCredentialValue(credRow.encrypted_value)
|
|
55
|
+
console.log('✓ Credentials loaded\n')
|
|
56
|
+
}, 15000)
|
|
57
|
+
|
|
58
|
+
afterAll(async () => {
|
|
59
|
+
// Clean up test data
|
|
60
|
+
const rangesToClean = ['Test!A100:C105', 'Test!A200:C210', 'Test!A300:C302']
|
|
61
|
+
for (const range of rangesToClean) {
|
|
62
|
+
try {
|
|
63
|
+
await adapter.call('clearRange', { spreadsheetId, range }, credentials, context)
|
|
64
|
+
} catch {
|
|
65
|
+
// Ignore cleanup errors
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
console.log('\n=== Tests Complete ===\n')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// ============================================
|
|
72
|
+
// 1. Basic CRUD Operations
|
|
73
|
+
// ============================================
|
|
74
|
+
|
|
75
|
+
describe('Basic CRUD Operations', () => {
|
|
76
|
+
it('should get spreadsheet metadata', async () => {
|
|
77
|
+
const result = (await adapter.call('getSpreadsheetMetadata', { spreadsheetId }, credentials, context)) as {
|
|
78
|
+
title: string
|
|
79
|
+
sheets: Array<{ sheetId: number; title: string; index: number }>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
expect(result.title).toBeTruthy()
|
|
83
|
+
expect(result.sheets.length).toBeGreaterThan(0)
|
|
84
|
+
testSheetName = result.sheets[0].title
|
|
85
|
+
console.log(`Using sheet: ${testSheetName}`)
|
|
86
|
+
}, 15000)
|
|
87
|
+
|
|
88
|
+
it('should read, write, and clear data', async () => {
|
|
89
|
+
const range = 'Test!A100:C101'
|
|
90
|
+
const testData = [
|
|
91
|
+
['TestName', '101', 'Test description'],
|
|
92
|
+
['TestName2', '102', 'Another description']
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
// Write
|
|
96
|
+
const writeResult = (await adapter.call(
|
|
97
|
+
'writeSheet',
|
|
98
|
+
{ spreadsheetId, range, values: testData },
|
|
99
|
+
credentials,
|
|
100
|
+
context
|
|
101
|
+
)) as { updatedCells: number }
|
|
102
|
+
expect(writeResult.updatedCells).toBe(6)
|
|
103
|
+
|
|
104
|
+
// Read back
|
|
105
|
+
const readResult = (await adapter.call('readSheet', { spreadsheetId, range }, credentials, context)) as {
|
|
106
|
+
values: string[][]
|
|
107
|
+
}
|
|
108
|
+
expect(readResult.values[0][0]).toBe('TestName')
|
|
109
|
+
expect(readResult.values[1][0]).toBe('TestName2')
|
|
110
|
+
|
|
111
|
+
// Clear
|
|
112
|
+
const clearResult = (await adapter.call('clearRange', { spreadsheetId, range }, credentials, context)) as {
|
|
113
|
+
clearedRange: string
|
|
114
|
+
}
|
|
115
|
+
expect(clearResult.clearedRange).toContain('A100')
|
|
116
|
+
|
|
117
|
+
// Verify cleared
|
|
118
|
+
const verifyResult = (await adapter.call('readSheet', { spreadsheetId, range }, credentials, context)) as {
|
|
119
|
+
values: string[][]
|
|
120
|
+
}
|
|
121
|
+
expect(verifyResult.values.length).toBe(0)
|
|
122
|
+
}, 15000)
|
|
123
|
+
|
|
124
|
+
it('should append rows and batch update', async () => {
|
|
125
|
+
// Append
|
|
126
|
+
const appendResult = (await adapter.call(
|
|
127
|
+
'appendRows',
|
|
128
|
+
{
|
|
129
|
+
spreadsheetId,
|
|
130
|
+
range: 'Test!A200:C200',
|
|
131
|
+
values: [['Appended1', '201', 'Appended row']]
|
|
132
|
+
},
|
|
133
|
+
credentials,
|
|
134
|
+
context
|
|
135
|
+
)) as { updatedRows: number }
|
|
136
|
+
expect(appendResult.updatedRows).toBe(1)
|
|
137
|
+
|
|
138
|
+
// Batch update
|
|
139
|
+
const batchResult = (await adapter.call(
|
|
140
|
+
'batchUpdate',
|
|
141
|
+
{
|
|
142
|
+
spreadsheetId,
|
|
143
|
+
data: [
|
|
144
|
+
{ range: 'Test!A202:C202', values: [['Batch1', '202', 'Batch row 1']] },
|
|
145
|
+
{ range: 'Test!A203:C203', values: [['Batch2', '203', 'Batch row 2']] }
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
credentials,
|
|
149
|
+
context
|
|
150
|
+
)) as { totalUpdatedCells: number; totalUpdatedRows: number }
|
|
151
|
+
expect(batchResult.totalUpdatedRows).toBe(2)
|
|
152
|
+
}, 20000)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
// ============================================
|
|
156
|
+
// 2. Workflow-Friendly Methods
|
|
157
|
+
// ============================================
|
|
158
|
+
|
|
159
|
+
describe('Workflow-Friendly Methods', () => {
|
|
160
|
+
it('should get headers and find row by value', async () => {
|
|
161
|
+
// Setup: Write test data with headers
|
|
162
|
+
await adapter.call(
|
|
163
|
+
'writeSheet',
|
|
164
|
+
{
|
|
165
|
+
spreadsheetId,
|
|
166
|
+
range: 'Test!A1:C2',
|
|
167
|
+
values: [
|
|
168
|
+
['Name', 'Id', 'Description'],
|
|
169
|
+
['FindMe', '999', 'Test row for lookup']
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
credentials,
|
|
173
|
+
context
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
// Get headers
|
|
177
|
+
const headersResult = (await adapter.call(
|
|
178
|
+
'getHeaders',
|
|
179
|
+
{ spreadsheetId, sheetName: 'Test' },
|
|
180
|
+
credentials,
|
|
181
|
+
context
|
|
182
|
+
)) as { headers: string[]; columnMap: Record<string, string> }
|
|
183
|
+
expect(headersResult.headers).toContain('Name')
|
|
184
|
+
expect(headersResult.columnMap.Name).toBe('A')
|
|
185
|
+
|
|
186
|
+
// Find row by value
|
|
187
|
+
const findResult = (await adapter.call(
|
|
188
|
+
'getRowByValue',
|
|
189
|
+
{ spreadsheetId, sheetName: 'Test', searchColumn: 'A', searchValue: 'FindMe' },
|
|
190
|
+
credentials,
|
|
191
|
+
context
|
|
192
|
+
)) as { found: boolean; rowNumber: number | null; rowData: string[] | null }
|
|
193
|
+
expect(findResult.found).toBe(true)
|
|
194
|
+
expect(findResult.rowData?.[0]).toBe('FindMe')
|
|
195
|
+
}, 20000)
|
|
196
|
+
|
|
197
|
+
it('should upsert and update rows by value', async () => {
|
|
198
|
+
const uniqueKey = `UpsertTest_${Date.now()}`
|
|
199
|
+
|
|
200
|
+
// Upsert (insert)
|
|
201
|
+
const insertResult = (await adapter.call(
|
|
202
|
+
'upsertRow',
|
|
203
|
+
{
|
|
204
|
+
spreadsheetId,
|
|
205
|
+
sheetName: 'Test',
|
|
206
|
+
keyColumn: 'A',
|
|
207
|
+
keyValue: uniqueKey,
|
|
208
|
+
rowData: { Name: uniqueKey, Id: '888', Description: 'Inserted via upsert' }
|
|
209
|
+
},
|
|
210
|
+
credentials,
|
|
211
|
+
context
|
|
212
|
+
)) as { action: 'inserted' | 'updated' }
|
|
213
|
+
expect(insertResult.action).toBe('inserted')
|
|
214
|
+
|
|
215
|
+
// Upsert (update)
|
|
216
|
+
const updateResult = (await adapter.call(
|
|
217
|
+
'upsertRow',
|
|
218
|
+
{
|
|
219
|
+
spreadsheetId,
|
|
220
|
+
sheetName: 'Test',
|
|
221
|
+
keyColumn: 'A',
|
|
222
|
+
keyValue: uniqueKey,
|
|
223
|
+
rowData: { Name: uniqueKey, Id: '888', Description: 'Updated via upsert' }
|
|
224
|
+
},
|
|
225
|
+
credentials,
|
|
226
|
+
context
|
|
227
|
+
)) as { action: 'inserted' | 'updated' }
|
|
228
|
+
expect(updateResult.action).toBe('updated')
|
|
229
|
+
|
|
230
|
+
// Clean up
|
|
231
|
+
await adapter.call(
|
|
232
|
+
'deleteRowByValue',
|
|
233
|
+
{ spreadsheetId, sheetName: 'Test', searchColumn: 'A', searchValue: uniqueKey },
|
|
234
|
+
credentials,
|
|
235
|
+
context
|
|
236
|
+
)
|
|
237
|
+
}, 25000)
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
// ============================================
|
|
241
|
+
// 3. Error Handling
|
|
242
|
+
// ============================================
|
|
243
|
+
|
|
244
|
+
describe('Error Handling', () => {
|
|
245
|
+
it('should handle invalid spreadsheet ID', async () => {
|
|
246
|
+
await expect(
|
|
247
|
+
adapter.call('readSheet', { spreadsheetId: 'invalid-id', range: 'Sheet1!A1' }, credentials, context)
|
|
248
|
+
).rejects.toThrow()
|
|
249
|
+
}, 15000)
|
|
250
|
+
|
|
251
|
+
it('should validate required fields', async () => {
|
|
252
|
+
await expect(adapter.call('readSheet', { spreadsheetId: '', range: 'A1' }, credentials, context)).rejects.toThrow(
|
|
253
|
+
'Missing required field: spreadsheetId'
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
await expect(
|
|
257
|
+
adapter.call('writeSheet', { spreadsheetId, range: 'A1', values: null }, credentials, context)
|
|
258
|
+
).rejects.toThrow('Missing required field: values')
|
|
259
|
+
}, 15000)
|
|
260
|
+
})
|
|
261
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
CreateNoteRequestSchema,
|
|
4
|
+
NoteTypeSchema,
|
|
5
|
+
UpdateMilestoneRequestSchema
|
|
6
|
+
} from './api-schemas'
|
|
7
|
+
|
|
8
|
+
describe('NoteTypeSchema', () => {
|
|
9
|
+
it('accepts agent_learning', () => {
|
|
10
|
+
expect(NoteTypeSchema.safeParse('agent_learning').success).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('CreateNoteRequestSchema', () => {
|
|
15
|
+
it('accepts agent_learning notes', () => {
|
|
16
|
+
const result = CreateNoteRequestSchema.safeParse({
|
|
17
|
+
project_id: '123e4567-e89b-12d3-a456-426614174000',
|
|
18
|
+
type: 'agent_learning',
|
|
19
|
+
content: 'Capture a reusable implementation lesson for this project.'
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
expect(result.success).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe('UpdateMilestoneRequestSchema', () => {
|
|
27
|
+
it('accepts description-only updates', () => {
|
|
28
|
+
const result = UpdateMilestoneRequestSchema.safeParse({
|
|
29
|
+
description: ''
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
expect(result.success).toBe(true)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('rejects empty payloads', () => {
|
|
36
|
+
const result = UpdateMilestoneRequestSchema.safeParse({})
|
|
37
|
+
expect(result.success).toBe(false)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -43,7 +43,7 @@ export const TaskTypeSchema = z.enum([
|
|
|
43
43
|
'research',
|
|
44
44
|
'other'
|
|
45
45
|
])
|
|
46
|
-
export const NoteTypeSchema = z.enum(['call_note', 'status_update', 'issue', 'blocker'])
|
|
46
|
+
export const NoteTypeSchema = z.enum(['call_note', 'status_update', 'issue', 'blocker', 'agent_learning'])
|
|
47
47
|
|
|
48
48
|
// ---------------------------------------------------------------------------
|
|
49
49
|
// Checklist item shape (JSONB array stored on prj_tasks)
|