TypeScript Types
TypeScript type definitions for the VertaaUX SDK
TypeScript Types
The VertaaUX SDK includes complete TypeScript type definitions for all methods, requests, and responses. Types are auto-generated from the OpenAPI specification to ensure accuracy.
Type Imports
Import types directly from the SDK:
import type {
AuditRequest,
AuditCreatedResponse,
AuditStatusResponse,
QuotaResponse,
WebhookRequest,
WebhookResponse,
Issue,
Scores,
} from '@vertaaux/sdk';Request Types
AuditRequest
Parameters for creating an audit:
interface AuditRequest {
/**
* Website URL to audit (http or https)
* @example "https://example.com"
*/
url: string;
/**
* Audit depth:
* - `basic`: Core accessibility & UX checks (~30s)
* - `standard`: Full WCAG 2.1 AA analysis (~2min)
* - `deep`: Multi-page crawl + performance metrics (~5min)
* @default "basic"
*/
mode?: 'basic' | 'standard' | 'deep';
/**
* Optional key-value data attached to audit
* @example { project: "ecommerce-redesign", environment: "staging" }
*/
metadata?: Record<string, unknown>;
}Usage:
import { VertaaUX } from '@vertaaux/sdk';
import type { AuditRequest } from '@vertaaux/sdk';
const params: AuditRequest = {
url: 'https://example.com',
mode: 'standard',
metadata: {
project: 'website-redesign',
sprint: 42,
},
};
const client = new VertaaUX({ apiKey: process.env.VERTAA_API_KEY! });
const job = await client.audits.create(params);WebhookRequest
Parameters for registering a webhook:
interface WebhookRequest {
/**
* HTTPS endpoint URL for webhook delivery
* @example "https://api.example.com/webhooks/vertaaux"
*/
url: string;
/**
* Secret for HMAC-SHA256 signature verification
* @example "wh_sec_abc123xyz789"
*/
secret: string;
}Response Types
AuditCreatedResponse
Response from creating an audit:
interface AuditCreatedResponse {
/**
* Unique job identifier for polling
* @example "clu1a2b3c4d5e6f7g8h9i0j1"
*/
job_id: string;
/**
* Initial status (always "queued")
*/
status: 'queued';
/**
* Job creation timestamp (ISO 8601)
* @example "2024-01-15T10:30:00Z"
*/
created_at: string;
/**
* Version of the audit ruleset used
* @example "1.0.0"
*/
ruleset_version: string;
}AuditStatusResponse
Response from polling audit status:
interface AuditStatusResponse {
job_id: string;
/**
* Current status:
* - `queued`: Waiting for worker
* - `running`: Analysis in progress
* - `completed`: Results available
* - `failed`: Error occurred
*/
status: 'queued' | 'running' | 'completed' | 'failed';
created_at: string;
/** When analysis began (present if running/completed/failed) */
started_at?: string;
/** When analysis finished (present if completed) */
completed_at?: string;
/** When error occurred (present if failed) */
failed_at?: string;
/** Completion percentage (0-100) */
progress: number;
ruleset_version: string;
/** Audit scores (present if completed) */
scores?: Scores;
/** Found issues (present if completed) */
issues?: Issue[];
/** Custom metadata */
metadata?: Record<string, unknown>;
/** Error message (present if failed) */
error?: string;
}Usage:
import type { AuditStatusResponse } from '@vertaaux/sdk';
function handleResult(result: AuditStatusResponse) {
switch (result.status) {
case 'completed':
console.log('Score:', result.scores?.overall);
result.issues?.forEach((issue) => {
console.log(`[${issue.severity}] ${issue.description}`);
});
break;
case 'failed':
console.error('Error:', result.error);
break;
default:
console.log('Progress:', result.progress + '%');
}
}QuotaResponse
Response from quota endpoint:
interface QuotaResponse {
/**
* Current subscription tier
*/
plan: 'free' | 'pro' | 'agency' | 'enterprise';
/**
* Total credits in current period
* @example 1000
*/
credits_total: number;
/**
* Credits consumed
* @example 234
*/
credits_used: number;
/**
* Credits available
* @example 766
*/
credits_remaining: number;
/**
* When quota resets (ISO 8601)
* @example "2024-02-01T00:00:00Z"
*/
reset_date: string;
}WebhookResponse
Response from webhook operations:
interface WebhookResponse {
/**
* Webhook identifier
* @example "wh_def456ghi012"
*/
id: string;
/**
* Registered endpoint URL
*/
url: string;
/**
* Registration timestamp (ISO 8601)
*/
created_at: string;
}Data Types
Scores
Audit score breakdown:
interface Scores {
/** Overall score 0-100 */
overall?: number;
/** UX score 0-100 */
ux?: number;
/** Accessibility score 0-100 */
accessibility?: number;
/** Information architecture score 0-100 */
information_architecture?: number;
/** Performance score 0-100 */
performance?: number;
}Usage:
function displayScores(scores?: Scores) {
if (!scores) return;
console.log('Scores:');
console.log(` Overall: ${scores.overall ?? 'N/A'}/100`);
console.log(` UX: ${scores.ux ?? 'N/A'}/100`);
console.log(` Accessibility: ${scores.accessibility ?? 'N/A'}/100`);
console.log(` IA: ${scores.information_architecture ?? 'N/A'}/100`);
console.log(` Performance: ${scores.performance ?? 'N/A'}/100`);
}Issue
Audit issue structure:
interface Issue {
/**
* Unique issue identifier
* @example "iss_color_contrast_001"
*/
id: string;
/**
* Issue severity:
* - `error`: Blocks accessibility or core UX
* - `warning`: Degrades experience
* - `info`: Improvement opportunity
*/
severity: 'error' | 'warning' | 'info';
/**
* Issue domain
*/
category: 'accessibility' | 'ux' | 'information_architecture' | 'performance';
/**
* What's wrong
* @example "Text has insufficient contrast (3.2:1 ratio)"
*/
description: string;
/**
* How to fix
* @example "Increase contrast to at least 4.5:1 for body text"
*/
recommendation: string;
/**
* WCAG guideline (if accessibility issue)
* @example "WCAG 2.1 SC 1.4.3 (AA)"
*/
wcag_reference?: string;
/**
* CSS selector for affected element
* @example ".footer-text"
*/
selector?: string;
/**
* HTML snippet
* @example "<p class=\"footer-text\">Contact Us</p>"
*/
element?: string;
}Usage:
function categorizeIssues(issues: Issue[]) {
const bySeverity = {
error: issues.filter((i) => i.severity === 'error'),
warning: issues.filter((i) => i.severity === 'warning'),
info: issues.filter((i) => i.severity === 'info'),
};
const byCategory = {
accessibility: issues.filter((i) => i.category === 'accessibility'),
ux: issues.filter((i) => i.category === 'ux'),
ia: issues.filter((i) => i.category === 'information_architecture'),
performance: issues.filter((i) => i.category === 'performance'),
};
return { bySeverity, byCategory };
}WebhookPayload
Payload sent to webhook endpoints:
interface WebhookPayload {
job_id: string;
status: 'completed' | 'failed';
/** ISO 8601 timestamp */
completed_at: string;
/** Present if status=completed */
scores?: Scores;
/** Present if status=completed */
issues?: Issue[];
/** Present if status=failed */
error?: string;
}Configuration Types
ApiClientConfig
Client configuration options:
interface ApiClientConfig {
/** Your VertaaUX API key */
apiKey: string;
/** API base URL (default: "https://vertaaux.ai/api/v1") */
baseUrl?: string;
/** Custom fetch implementation */
fetchFn?: typeof fetch;
/** Idempotency key for request deduplication */
idempotencyKey?: string;
/** Retry configuration */
retry?: RetryConfig;
}RetryConfig
Retry behavior configuration:
interface RetryConfig {
/**
* Number of retry attempts
* @default 2
*/
retries?: number;
/**
* Initial delay in milliseconds (doubles each retry)
* @default 300
*/
baseDelayMs?: number;
}Error Types
VertaaError
Error thrown by SDK methods:
class VertaaError extends Error {
/** Error code from API */
code: string;
/** Human-readable message */
message: string;
/** HTTP status code */
statusCode: number;
/** Request ID for support */
requestId?: string;
}Usage:
import { VertaaUX, VertaaError } from '@vertaaux/sdk';
try {
await client.audits.create({ url: 'invalid' });
} catch (error) {
if (error instanceof VertaaError) {
// Type-safe error handling
console.log(error.code); // e.g., "invalid_url"
console.log(error.statusCode); // e.g., 400
console.log(error.requestId); // For support
}
}Using Generics
The SDK supports TypeScript generics for custom metadata:
interface MyMetadata {
project: string;
environment: 'development' | 'staging' | 'production';
buildNumber: number;
}
// Type-safe metadata
const job = await client.audits.create({
url: 'https://example.com',
metadata: {
project: 'ecommerce',
environment: 'staging',
buildNumber: 1234,
} satisfies MyMetadata,
});Strict Mode Recommendations
For the best TypeScript experience, use strict mode in your tsconfig.json:
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"noImplicitAny": true
}
}This ensures:
- Proper handling of optional fields (
scores?,issues?) - Null checks before accessing nested properties
- Type safety throughout your codebase
Type Generation
SDK types are auto-generated from the VertaaUX OpenAPI specification using openapi-typescript. This ensures types always match the actual API behavior.
To view the full type definitions, see:
Related
- Client Setup - Configuration types
- Audit Methods - Request/response types
- Error Handling - Error types
Was this page helpful?