Skip to content
← Public packages

@kody/integrations-sh

Client for the public integrations.sh registry: search, detect, cached surface, and live discover.

src/smoke-test.ts

44 lines · 1.3 KB · TypeScript
import search from './search.ts'
import surface from './surface.ts'
import { normalizeProviderDomain } from './domain.ts'
import { buildDetectUrl, buildDiscoverUrl, buildSearchUrl } from './urls.ts'

/**
 * Prove catalog search and cached surface for github.com.
 * Skips live detect/discover so publish stays within the check budget.
 *
 * @returns ok plus the sample domain and surface count
 *
 * @example
 * import smokeTest from 'kody:@<username>/integrations-sh/smoke-test'
 * const result = await smokeTest()
 */
export default async function smokeTest(): Promise<{
	ok: boolean
	sampleDomain: string | null
	surfaceCount: number
	searchUrl: string
}> {
	const domain = normalizeProviderDomain('GitHub.com')
	const searchUrl = buildSearchUrl({
		query: 'github',
		kind: 'openapi',
		limit: 3,
	})
	const registry = await search({ query: 'github', kind: 'openapi', limit: 3 })
	const cached = await surface({ domain })
	const ok =
		domain === 'github.com' &&
		searchUrl.includes('/search?') &&
		buildDetectUrl(domain).endsWith('/github.com/detect') &&
		buildDiscoverUrl(domain).endsWith('/github.com/discover') &&
		registry.results.some((result) => result.domain === 'github.com') &&
		cached.surfaces.length > 0

	return {
		ok,
		sampleDomain: registry.results[0]?.domain ?? null,
		surfaceCount: cached.surfaces.length,
		searchUrl,
	}
}