@@ -2,6 +2,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
22import type { ConnectorResolver , Message , SourceStateMessage } from '../lib/index.js'
33import { sourceTest , destinationTest , collectFirst } from '../lib/index.js'
44import { createApp } from './app.js'
5+ import { z } from 'zod'
6+
7+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8+ type Json = Record < string , any >
59
610// ---------------------------------------------------------------------------
711// Helpers
@@ -33,7 +37,7 @@ beforeAll(async () => {
3337 'test' ,
3438 {
3539 connector : sourceTest ,
36- configSchema : { } as any ,
40+ configSchema : z . object ( { } ) ,
3741 rawConfigJsonSchema : srcConfigSchema ,
3842 } ,
3943 ] ,
@@ -44,7 +48,7 @@ beforeAll(async () => {
4448 'test' ,
4549 {
4650 connector : destinationTest ,
47- configSchema : { } as any ,
51+ configSchema : z . object ( { } ) ,
4852 rawConfigJsonSchema : destConfigSchema ,
4953 } ,
5054 ] ,
@@ -131,7 +135,7 @@ describe('GET /openapi.json', () => {
131135 it ( 'has typed connector schemas in components (auto-generated from Zod)' , async ( ) => {
132136 const app = await createApp ( resolver )
133137 const res = await app . request ( '/openapi.json' )
134- const spec = ( await res . json ( ) ) as any
138+ const spec = ( await res . json ( ) ) as Json
135139 const schemaNames = Object . keys ( spec . components ?. schemas ?? { } )
136140
137141 expect ( schemaNames ) . toContain ( 'SourceTestConfig' )
@@ -150,7 +154,7 @@ describe('GET /openapi.json', () => {
150154 it ( 'defines NDJSON message schemas with discriminated unions' , async ( ) => {
151155 const app = await createApp ( resolver )
152156 const res = await app . request ( '/openapi.json' )
153- const spec = ( await res . json ( ) ) as any
157+ const spec = ( await res . json ( ) ) as Json
154158 const schemas = spec . components . schemas
155159
156160 // Individual message types — zod-openapi uses const for z.literal() in OpenAPI 3.1
@@ -187,18 +191,18 @@ describe('GET /openapi.json', () => {
187191 it ( 'ControlMessage source_config/destination_config reference typed connector schemas' , async ( ) => {
188192 const app = await createApp ( resolver )
189193 const res = await app . request ( '/openapi.json' )
190- const spec = ( await res . json ( ) ) as any
194+ const spec = ( await res . json ( ) ) as Json
191195 const control = spec . components . schemas . ControlMessage . properties . control
192196
193197 const sourceVariant = control . oneOf . find (
194- ( v : any ) => v . properties ?. control_type ?. const === 'source_config'
198+ ( v : Json ) => v . properties ?. control_type ?. const === 'source_config'
195199 )
196200 expect ( sourceVariant . properties . source_config . $ref ) . toBe (
197201 '#/components/schemas/SourceTestConfig'
198202 )
199203
200204 const destVariant = control . oneOf . find (
201- ( v : any ) => v . properties ?. control_type ?. const === 'destination_config'
205+ ( v : Json ) => v . properties ?. control_type ?. const === 'destination_config'
202206 )
203207 expect ( destVariant . properties . destination_config . $ref ) . toBe (
204208 '#/components/schemas/DestinationTestConfig'
@@ -208,7 +212,7 @@ describe('GET /openapi.json', () => {
208212 it ( '/setup spec documents 200 response (not 204)' , async ( ) => {
209213 const app = await createApp ( resolver )
210214 const res = await app . request ( '/openapi.json' )
211- const spec = ( await res . json ( ) ) as any
215+ const spec = ( await res . json ( ) ) as Json
212216 const setupOp = spec . paths [ '/pipeline_setup' ] ?. post
213217 expect ( setupOp ) . toBeDefined ( )
214218 expect ( setupOp . responses [ '200' ] ) . toBeDefined ( )
@@ -218,7 +222,7 @@ describe('GET /openapi.json', () => {
218222 it ( '/write spec documents a required NDJSON request body' , async ( ) => {
219223 const app = await createApp ( resolver )
220224 const res = await app . request ( '/openapi.json' )
221- const spec = ( await res . json ( ) ) as any
225+ const spec = ( await res . json ( ) ) as Json
222226 const writeOp = spec . paths [ '/pipeline_write' ] ?. post
223227 expect ( writeOp ) . toBeDefined ( )
224228 const body = writeOp . requestBody
@@ -232,7 +236,7 @@ describe('GET /openapi.json', () => {
232236 it ( '/read and /sync spec documents an optional NDJSON request body' , async ( ) => {
233237 const app = await createApp ( resolver )
234238 const res = await app . request ( '/openapi.json' )
235- const spec = ( await res . json ( ) ) as any
239+ const spec = ( await res . json ( ) ) as Json
236240
237241 for ( const path of [ '/pipeline_read' , '/pipeline_sync' ] as const ) {
238242 const op = spec . paths [ path ] ?. post
@@ -247,13 +251,13 @@ describe('GET /openapi.json', () => {
247251 it ( 'documents the X-Pipeline header on sync routes' , async ( ) => {
248252 const app = await createApp ( resolver )
249253 const res = await app . request ( '/openapi.json' )
250- const spec = ( await res . json ( ) ) as any
254+ const spec = ( await res . json ( ) ) as Json
251255
252256 // /check is a POST with X-Pipeline header
253257 const checkOp = spec . paths [ '/pipeline_check' ] ?. post
254258 expect ( checkOp ) . toBeDefined ( )
255259 const headerParam = checkOp . parameters ?. find (
256- ( p : any ) => p . in === 'header' && p . name === 'x-pipeline'
260+ ( p : Json ) => p . in === 'header' && p . name === 'x-pipeline'
257261 )
258262 expect ( headerParam ) . toBeDefined ( )
259263 } )
@@ -264,9 +268,9 @@ describe('GET /meta/sources', () => {
264268 const app = await createApp ( resolver )
265269 const res = await app . request ( '/meta/sources' )
266270 expect ( res . status ) . toBe ( 200 )
267- const body = ( await res . json ( ) ) as any
271+ const body = ( await res . json ( ) ) as Json
268272 expect ( Array . isArray ( body . items ) ) . toBe ( true )
269- expect ( body . items . find ( ( c : any ) => c . type === 'test' ) ?. config_schema ) . toBeDefined ( )
273+ expect ( body . items . find ( ( c : Json ) => c . type === 'test' ) ?. config_schema ) . toBeDefined ( )
270274 } )
271275} )
272276
@@ -275,7 +279,7 @@ describe('GET /meta/sources/:type', () => {
275279 const app = await createApp ( resolver )
276280 const res = await app . request ( '/meta/sources/test' )
277281 expect ( res . status ) . toBe ( 200 )
278- const body = ( await res . json ( ) ) as any
282+ const body = ( await res . json ( ) ) as Json
279283 expect ( body . config_schema ) . toBeDefined ( )
280284 } )
281285
@@ -291,9 +295,9 @@ describe('GET /meta/destinations', () => {
291295 const app = await createApp ( resolver )
292296 const res = await app . request ( '/meta/destinations' )
293297 expect ( res . status ) . toBe ( 200 )
294- const body = ( await res . json ( ) ) as any
298+ const body = ( await res . json ( ) ) as Json
295299 expect ( Array . isArray ( body . items ) ) . toBe ( true )
296- expect ( body . items . find ( ( c : any ) => c . type === 'test' ) ?. config_schema ) . toBeDefined ( )
300+ expect ( body . items . find ( ( c : Json ) => c . type === 'test' ) ?. config_schema ) . toBeDefined ( )
297301 } )
298302} )
299303
@@ -302,7 +306,7 @@ describe('GET /meta/destinations/:type', () => {
302306 const app = await createApp ( resolver )
303307 const res = await app . request ( '/meta/destinations/test' )
304308 expect ( res . status ) . toBe ( 200 )
305- const body = ( await res . json ( ) ) as any
309+ const body = ( await res . json ( ) ) as Json
306310 expect ( body . config_schema ) . toBeDefined ( )
307311 } )
308312
@@ -372,7 +376,7 @@ describe('POST /check', () => {
372376 const events = await readNdjson < Record < string , unknown > > ( res )
373377 const statuses = events . filter ( ( e ) => e . type === 'connection_status' )
374378 expect ( statuses ) . toHaveLength ( 2 )
375- expect ( statuses . every ( ( s : any ) => s . connection_status . status === 'succeeded' ) ) . toBe ( true )
379+ expect ( statuses . every ( ( s : Json ) => s . connection_status . status === 'succeeded' ) ) . toBe ( true )
376380 } )
377381} )
378382
@@ -436,7 +440,7 @@ describe('POST /read', () => {
436440 'test' ,
437441 {
438442 connector : sourceTest ,
439- configSchema : { } as any ,
443+ configSchema : z . object ( { } ) ,
440444 rawConfigJsonSchema : srcConfigSchema ,
441445 rawInputJsonSchema : inputSchema ,
442446 } ,
@@ -448,7 +452,7 @@ describe('POST /read', () => {
448452 'test' ,
449453 {
450454 connector : destinationTest ,
451- configSchema : { } as any ,
455+ configSchema : z . object ( { } ) ,
452456 rawConfigJsonSchema : destConfigSchema ,
453457 } ,
454458 ] ,
@@ -459,7 +463,7 @@ describe('POST /read', () => {
459463
460464 it ( 'spec uses SourceInputMessage schema for /read and /sync request body when source has input schema' , async ( ) => {
461465 const res = await inputApp . request ( '/openapi.json' )
462- const spec = ( await res . json ( ) ) as any
466+ const spec = ( await res . json ( ) ) as Json
463467
464468 for ( const path of [ '/pipeline_read' , '/pipeline_sync' ] as const ) {
465469 const body = spec . paths [ path ] ?. post ?. requestBody
@@ -794,8 +798,8 @@ describe('POST /source_discover', () => {
794798 const events = await readNdjson < Record < string , unknown > > ( res )
795799 const catalogs = events . filter ( ( e ) => e . type === 'catalog' )
796800 expect ( catalogs ) . toHaveLength ( 1 )
797- const catalog = ( catalogs [ 0 ] as any ) . catalog
798- const streamNames = catalog . streams . map ( ( s : any ) => s . name )
801+ const catalog = ( catalogs [ 0 ] as Json ) . catalog
802+ const streamNames = catalog . streams . map ( ( s : Json ) => s . name )
799803 expect ( streamNames ) . toContain ( 'customers' )
800804 expect ( streamNames ) . toContain ( 'products' )
801805 } )
@@ -824,7 +828,7 @@ describe('POST /source_discover', () => {
824828 const events = await readNdjson < Record < string , unknown > > ( res )
825829 const traces = events . filter ( ( e ) => e . type === 'trace' )
826830 expect ( traces ) . toHaveLength ( 1 )
827- const trace = ( traces [ 0 ] as any ) . trace
831+ const trace = ( traces [ 0 ] as Json ) . trace
828832 expect ( trace . trace_type ) . toBe ( 'error' )
829833 expect ( trace . error . failure_type ) . toBe ( 'system_error' )
830834 expect ( trace . error . message ) . toContain ( 'network unreachable' )
0 commit comments