Files
telemetry-client-js/scripts/validate-schema.ts
Jason Woltje 177720e523 feat: TypeScript telemetry client SDK v0.1.0
Standalone npm package (@mosaicstack/telemetry-client) for reporting
task-completion telemetry and querying predictions from the Mosaic
Stack Telemetry server.

- TelemetryClient with setInterval-based background flush
- EventQueue (bounded FIFO array)
- BatchSubmitter with native fetch, exponential backoff, Retry-After
- PredictionCache (Map + TTL)
- EventBuilder with auto-generated event_id/timestamp
- Zero runtime dependencies (Node 18+ native APIs)
- 43 tests, 86% branch coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 23:25:31 -06:00

66 lines
2.0 KiB
TypeScript

/**
* Validates that the TypeScript types match the expected server schema.
* This script is meant to be run manually when the server schema changes.
*/
import {
TaskType,
Complexity,
Harness,
Provider,
QualityGate,
Outcome,
RepoSizeCategory,
} from '../src/types/events.js';
function validateEnum(name: string, enumObj: Record<string, string>, expected: string[]): boolean {
const values = Object.values(enumObj);
const missing = expected.filter((v) => !values.includes(v));
const extra = values.filter((v) => !expected.includes(v));
if (missing.length > 0 || extra.length > 0) {
console.error(`${name} mismatch:`);
if (missing.length) console.error(` Missing: ${missing.join(', ')}`);
if (extra.length) console.error(` Extra: ${extra.join(', ')}`);
return false;
}
console.log(`${name}: OK (${values.length} values)`);
return true;
}
let allValid = true;
allValid = validateEnum('TaskType', TaskType, [
'planning', 'implementation', 'code_review', 'testing', 'debugging',
'refactoring', 'documentation', 'configuration', 'security_audit', 'unknown',
]) && allValid;
allValid = validateEnum('Complexity', Complexity, ['low', 'medium', 'high', 'critical']) && allValid;
allValid = validateEnum('Harness', Harness, [
'claude_code', 'opencode', 'kilo_code', 'aider', 'api_direct',
'ollama_local', 'custom', 'unknown',
]) && allValid;
allValid = validateEnum('Provider', Provider, [
'anthropic', 'openai', 'openrouter', 'ollama', 'google', 'mistral', 'custom', 'unknown',
]) && allValid;
allValid = validateEnum('QualityGate', QualityGate, [
'build', 'lint', 'test', 'coverage', 'typecheck', 'security',
]) && allValid;
allValid = validateEnum('Outcome', Outcome, ['success', 'failure', 'partial', 'timeout']) && allValid;
allValid = validateEnum('RepoSizeCategory', RepoSizeCategory, [
'tiny', 'small', 'medium', 'large', 'huge',
]) && allValid;
if (allValid) {
console.log('\nAll enums validated successfully.');
} else {
console.error('\nSchema validation failed.');
process.exit(1);
}