Skip to content
← Public packages

@kody/canva

Create, organize, collaborate on, import, and export Canva content through the Connect API.

src/smoke-test.ts

31 lines · 799 B · TypeScript
import { runCanvaOperation } from './client.ts'

/**
 * Verify the saved `canva` OAuth integration with two cheap read-only requests.
 * The result reports response shape only and does not expose profile data.
 */
export default async function smokeTest() {
	const [profile, capabilities] = await Promise.all([
		runCanvaOperation('getuserprofile'),
		runCanvaOperation('getusercapabilities'),
	])

	if ('dryRun' in profile || 'dryRun' in capabilities) {
		throw new Error('Unexpected dry-run response from a read-only Canva operation.')
	}

	return {
		ok: true,
		integration: 'canva',
		checks: {
			profile: {
				status: profile.status,
				responseType: typeof profile.body,
			},
			capabilities: {
				status: capabilities.status,
				responseType: typeof capabilities.body,
			},
		},
	}
}