@typeslayer/validate 0.0.0 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @typeslayer/validate
2
+
3
+ Validation schemas and utilities for TypeScript compiler trace analysis. This package provides comprehensive Zod-based schema validation (and types!!) for trace events, type metrics, and analysis results.
4
+
5
+ ## Usage
6
+
7
+ ### Trace JSON Validation
8
+
9
+ ```ts
10
+ import { traceJsonSchema, type TraceEvent } from '@typeslayer/validate';
11
+
12
+ // Validate trace.json output from TypeScript compiler
13
+ const events: TraceEvent[] = traceJsonSchema.parse(jsonData);
14
+
15
+ // Or use with Node.js streams
16
+ import { createReadStream } from 'fs';
17
+ import { validateTraceJson } from '@typeslayer/validate/node';
18
+
19
+ const stream = createReadStream('trace.json');
20
+ const events = await validateTraceJson(stream);
21
+ ```
22
+
23
+ ### Types JSON Validation
24
+
25
+ ```ts
26
+ import { typesJsonSchema, type TypesJsonSchema } from '@typeslayer/validate';
27
+
28
+ const types: TypesJsonSchema = typesJsonSchema.parse(jsonData);
29
+ ```
30
+
31
+ ### CPU Profile Validation
32
+
33
+ ```ts
34
+ import { tscCpuProfileSchema } from '@typeslayer/validate';
35
+
36
+ const profile = tscCpuProfileSchema.parse(jsonData);
37
+ ```
38
+
39
+ ## Exports
40
+
41
+ - **Main export (`@typeslayer/validate`)**: Browser-compatible validation schemas
42
+ - `traceJsonSchema` - Validates TypeScript trace events
43
+ - `typesJsonSchema` - Validates type information
44
+ - `tscCpuProfileSchema` - Validates CPU profile data
45
+
46
+ - **Node export (`@typeslayer/validate/node`)**: Node.js-specific utilities
47
+ - `validateTraceJson()` - Stream-based trace validation
48
+ - `readTraceJson()` - Read and parse trace.json files
49
+
50
+ ## TypeScript Support
51
+
52
+ Full TypeScript support with type inference from schemas:
53
+
54
+ ```ts
55
+ import type { TraceEvent } from '@typeslayer/validate';
56
+
57
+ // Type-safe event handling
58
+ function processEvent(event: TraceEvent) {
59
+ switch (event.name) {
60
+ case 'createSourceFile':
61
+ console.log('Creating source file:', event.args.path);
62
+ break;
63
+ // ... other event types
64
+ }
65
+ }
66
+ ```