ts-runtime-validation 1.6.16 → 1.7.0

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.
Files changed (79) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/CONTRIBUTING.md +430 -0
  3. package/README.md +444 -64
  4. package/dist/ICommandOptions.js +3 -0
  5. package/dist/ICommandOptions.js.map +1 -0
  6. package/dist/SchemaGenerator.integration.test.js +323 -0
  7. package/dist/SchemaGenerator.integration.test.js.map +1 -0
  8. package/dist/SchemaGenerator.js +120 -0
  9. package/dist/SchemaGenerator.js.map +1 -0
  10. package/dist/SchemaGenerator.test.js +132 -0
  11. package/dist/SchemaGenerator.test.js.map +1 -0
  12. package/dist/errors/index.js +95 -0
  13. package/dist/errors/index.js.map +1 -0
  14. package/dist/errors/index.test.js +232 -0
  15. package/dist/errors/index.test.js.map +1 -0
  16. package/dist/getPosixPath.js +13 -0
  17. package/dist/getPosixPath.js.map +1 -0
  18. package/dist/index.js +27 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/lib.js.map +1 -0
  21. package/dist/services/CodeGenerator.js +305 -0
  22. package/dist/services/CodeGenerator.js.map +1 -0
  23. package/dist/services/FileDiscovery.js +121 -0
  24. package/dist/services/FileDiscovery.js.map +1 -0
  25. package/dist/services/FileDiscovery.test.js +184 -0
  26. package/dist/services/FileDiscovery.test.js.map +1 -0
  27. package/dist/services/SchemaProcessor.js +182 -0
  28. package/dist/services/SchemaProcessor.js.map +1 -0
  29. package/dist/services/SchemaProcessor.test.js +395 -0
  30. package/dist/services/SchemaProcessor.test.js.map +1 -0
  31. package/dist/services/SchemaWriter.js +76 -0
  32. package/dist/services/SchemaWriter.js.map +1 -0
  33. package/dist/services/SchemaWriter.test.js +255 -0
  34. package/dist/services/SchemaWriter.test.js.map +1 -0
  35. package/dist/test/basic-scenario/types.jsonschema.js +3 -0
  36. package/dist/test/basic-scenario/types.jsonschema.js.map +1 -0
  37. package/dist/test/duplicate-symbols-different-implementation/IBaseType.js +3 -0
  38. package/dist/test/duplicate-symbols-different-implementation/IBaseType.js.map +1 -0
  39. package/dist/test/duplicate-symbols-different-implementation/IBaseTypeDefinitionReplicated.js +3 -0
  40. package/dist/test/duplicate-symbols-different-implementation/IBaseTypeDefinitionReplicated.js.map +1 -0
  41. package/dist/test/duplicate-symbols-different-implementation/IBasicTypesA.jsonschema.js +3 -0
  42. package/dist/test/duplicate-symbols-different-implementation/IBasicTypesA.jsonschema.js.map +1 -0
  43. package/dist/test/duplicate-symbols-different-implementation/IBasicTypesB.jsonschema.js +3 -0
  44. package/dist/test/duplicate-symbols-different-implementation/IBasicTypesB.jsonschema.js.map +1 -0
  45. package/dist/test/duplicate-symbols-identitcal-implementation/IBaseType.js +3 -0
  46. package/dist/test/duplicate-symbols-identitcal-implementation/IBaseType.js.map +1 -0
  47. package/dist/test/duplicate-symbols-identitcal-implementation/IBaseTypeDefinitionReplicated.js +3 -0
  48. package/dist/test/duplicate-symbols-identitcal-implementation/IBaseTypeDefinitionReplicated.js.map +1 -0
  49. package/dist/test/duplicate-symbols-identitcal-implementation/IBasicTypesA.jsonschema.js +3 -0
  50. package/dist/test/duplicate-symbols-identitcal-implementation/IBasicTypesA.jsonschema.js.map +1 -0
  51. package/dist/test/duplicate-symbols-identitcal-implementation/IBasicTypesB.jsonschema.js +3 -0
  52. package/dist/test/duplicate-symbols-identitcal-implementation/IBasicTypesB.jsonschema.js.map +1 -0
  53. package/dist/test/output/duplicate-symbols-identitcal-implementation/ValidationType.js +3 -0
  54. package/dist/test/output/duplicate-symbols-identitcal-implementation/ValidationType.js.map +1 -0
  55. package/dist/test/output/duplicate-symbols-identitcal-implementation/isValidSchema.js +49 -0
  56. package/dist/test/output/duplicate-symbols-identitcal-implementation/isValidSchema.js.map +1 -0
  57. package/dist/utils/ProgressReporter.js +67 -0
  58. package/dist/utils/ProgressReporter.js.map +1 -0
  59. package/dist/utils/ProgressReporter.test.js +267 -0
  60. package/dist/utils/ProgressReporter.test.js.map +1 -0
  61. package/dist/writeLine.js +12 -0
  62. package/dist/writeLine.js.map +1 -0
  63. package/package.json +2 -2
  64. package/src/ICommandOptions.ts +7 -0
  65. package/src/SchemaGenerator.integration.test.ts +411 -0
  66. package/src/SchemaGenerator.test.ts +7 -0
  67. package/src/SchemaGenerator.ts +112 -298
  68. package/src/errors/index.test.ts +319 -0
  69. package/src/errors/index.ts +92 -0
  70. package/src/index.ts +7 -0
  71. package/src/services/CodeGenerator.ts +352 -0
  72. package/src/services/FileDiscovery.test.ts +216 -0
  73. package/src/services/FileDiscovery.ts +137 -0
  74. package/src/services/SchemaProcessor.test.ts +464 -0
  75. package/src/services/SchemaProcessor.ts +173 -0
  76. package/src/services/SchemaWriter.test.ts +304 -0
  77. package/src/services/SchemaWriter.ts +75 -0
  78. package/src/utils/ProgressReporter.test.ts +357 -0
  79. package/src/utils/ProgressReporter.ts +76 -0
package/README.md CHANGED
@@ -1,110 +1,490 @@
1
1
  # ts-runtime-validation
2
2
 
3
- ## Why?
3
+ [![npm version](https://badge.fury.io/js/ts-runtime-validation.svg)](https://www.npmjs.com/package/ts-runtime-validation)
4
4
 
5
- Get bulletproof type validation based off typescript interfaces without any extra work. This package will ingest your existing types and generate the code for you.
5
+ Generate bulletproof runtime type validation from your TypeScript interfaces and type aliases. No manual schema writing, no decorators, just your existing TypeScript types.
6
6
 
7
- ## How?
7
+ ## ✨ Features
8
8
 
9
- This is a code generator that is designed to run as a yarn / npm script. By default scans your source directory for files ending in the provided glob pattern. It will generate types based off exported type aliases and typescript interfaces. By default: `*.jsonschema.{ts,tsx}`. The output will create three files:
9
+ ### Core Features
10
+ - 🚀 **Zero-effort validation** - Automatically generates JSON Schema validators from TypeScript interfaces
11
+ - 🔒 **Type-safe** - Full TypeScript support with type inference and type guards
12
+ - 📦 **Lightweight** - Minimal dependencies, can be installed as a dev dependency
13
+ - 🛠️ **CLI & Programmatic API** - Use as a CLI tool or integrate into your build process
14
+ - 🎯 **Selective generation** - Control which types to validate using file naming conventions
15
+ - 📝 **JSDoc annotations** - Add validation rules (min/max length, patterns, formats) directly in your TypeScript code
10
16
 
11
- 1. `./src/ts-runtime-validation/validation.schema.json` - containing the [jsonschema](http://json-schema.org/) types
12
- 1. `./src/SchemaDefinition.ts` - containing the typescript.
13
- 1. `./src/isValidSchema.ts` - containing a type guard type inferring helper method (intended for consumption in your code base - examples below)
14
- 1. `./src/ValidationType.ts` - containing an exported namespace containing every single exported validation type
17
+ ### Performance & Optimization
18
+ - **Incremental builds** - File-based caching for faster subsequent builds
19
+ - 🔄 **Parallel processing** - Concurrent file processing for improved performance
20
+ - 📊 **Progress reporting** - Visual feedback for long-running operations
21
+ - 🌳 **Tree-shaking friendly** - Generate optimized exports for smaller bundles
22
+ - 💤 **Lazy loading** - Optional deferred validator initialization
23
+ - 📦 **Minified output** - Compressed JSON schemas for production
24
+ - 🔧 **Verbose logging** - Detailed debugging information when needed
15
25
 
16
- ## Limitations
26
+ ## 📋 Prerequisites
17
27
 
18
- The schema generator does not allow multiple interfaces / types to share the same name.
28
+ - Node.js >= 12
29
+ - TypeScript >= 4.0
30
+ - `ajv` >= 8.11.0 (peer dependency for runtime validation)
19
31
 
20
- ## Footnote
32
+ ## 📦 Installation
21
33
 
22
- The helper file assumes you have [ajv-validator](https://github.com/ajv-validator/ajv) peer dependency installed. Since this is only a code generation tool this package can be installed as a dev dependency.
34
+ ```bash
35
+ # Using yarn (recommended)
36
+ yarn add --dev ts-runtime-validation
37
+ yarn add ajv # Required peer dependency
38
+
39
+ # Using npm
40
+ npm install --save-dev ts-runtime-validation
41
+ npm install ajv # Required peer dependency
42
+ ```
43
+
44
+ ## 🚀 Quick Start
45
+
46
+ ### 1. Mark your types for validation
47
+
48
+ Create files ending with `.jsonschema.ts` for types you want to validate:
49
+
50
+ ```typescript
51
+ // user.jsonschema.ts
52
+ export interface IUser {
53
+ id: string;
54
+ email: string;
55
+ name?: string;
56
+ age: number;
57
+ roles: string[];
58
+ }
59
+
60
+ export type UserRole = "admin" | "user" | "guest";
61
+ ```
62
+
63
+ #### JSDoc Annotations for Validation Rules
64
+
65
+ You can add validation constraints using JSDoc annotations that will be converted to JSON Schema properties:
66
+
67
+ ```typescript
68
+ // api.jsonschema.ts
69
+ export interface IGetUserFormsPathParams {
70
+ /**
71
+ * User ID to get forms for
72
+ * @minLength 24
73
+ * @maxLength 24
74
+ * @pattern ^[a-fA-F0-9]{24}$
75
+ */
76
+ readonly userId: string;
77
+ }
78
+
79
+ export interface IProduct {
80
+ /**
81
+ * Product name
82
+ * @minLength 1
83
+ * @maxLength 100
84
+ */
85
+ name: string;
86
+
87
+ /**
88
+ * Product price in cents
89
+ * @minimum 0
90
+ * @maximum 1000000
91
+ * @multipleOf 1
92
+ */
93
+ price: number;
94
+
95
+ /**
96
+ * Product tags
97
+ * @minItems 1
98
+ * @maxItems 10
99
+ * @uniqueItems true
100
+ */
101
+ tags: string[];
102
+
103
+ /**
104
+ * Email for support
105
+ * @format email
106
+ */
107
+ supportEmail?: string;
108
+
109
+ /**
110
+ * Product website
111
+ * @format uri
112
+ * @pattern ^https://
113
+ */
114
+ website?: string;
115
+ }
116
+ ```
117
+
118
+ Supported JSDoc annotations include:
119
+
120
+ - **Strings**: `@minLength`, `@maxLength`, `@pattern`, `@format` (email, uri, uuid, date-time, etc.)
121
+ - **Numbers**: `@minimum`, `@maximum`, `@exclusiveMinimum`, `@exclusiveMaximum`, `@multipleOf`
122
+ - **Arrays**: `@minItems`, `@maxItems`, `@uniqueItems`
123
+ - **Objects**: `@minProperties`, `@maxProperties`
124
+ - **General**: `@description`, `@default`, `@examples`
125
+
126
+ ### 2. Add to your package.json scripts
127
+
128
+ ```json
129
+ { "scripts": { "generate-types": "ts-runtime-validation" } }
130
+ ```
23
131
 
24
- ## Installation
132
+ ### 3. Generate validators
25
133
 
26
134
  ```bash
27
- # yarn
28
- yarn add --dev ts-runtime-validation
29
- # npm
30
- npm install --dev ts-runtime-validation
135
+ yarn generate-types
31
136
  ```
32
137
 
33
- ## CLI usage
138
+ ### 4. Use the generated validators
34
139
 
35
- Ensure your project files containing the schemas you want to validate end with the prefix `.jsonschema.ts`
140
+ ```typescript
141
+ import { isValidSchema } from "./.ts-runtime-validation/isValidSchema";
142
+ import { IUser } from "./user.jsonschema";
36
143
 
144
+ const userData = await fetch("/api/user").then((r) => r.json());
145
+
146
+ if (isValidSchema(userData, "#/definitions/IUser")) {
147
+ // userData is now typed as IUser
148
+ console.log(userData.email); // TypeScript knows this is a string
149
+ } else {
150
+ console.error("Invalid user data received");
151
+ }
37
152
  ```
38
- Usage: ts-runtime-validation [options]
39
153
 
40
- Options:
41
- --glob Glob file path of typescript files to generate ts-interface -> json-schema validations - default: *.jsonschema.{ts,tsx}
42
- --rootPath <rootFolder> RootPath of source (default: "./src")
43
- --output <outputFolder> Code generation output directory (relative to root path) (default: "./.ts-runtime-validation")
44
- --tsconfigPath <tsconfigPath> Path to customt tsconfig (relative to root path) (default: "")
45
- --generate-helpers Only generate JSON schema without typescript helper files (default: true)
46
- --additionalProperties Allow additional properties to pass validation (default: false)
47
- -h, --help display help for command
48
- Done in 0.44s.
154
+ ## 📖 Usage
155
+
156
+ ### CLI Options
157
+
158
+ ```bash
159
+ ts-runtime-validation [options]
160
+
161
+ Core Options:
162
+ --glob <pattern> Glob pattern for schema files
163
+ (default: "*.jsonschema.{ts,tsx}")
164
+ --rootPath <rootFolder> Source directory root
165
+ (default: "./src")
166
+ --output <outputFolder> Output directory for generated files
167
+ (default: "./.ts-runtime-validation")
168
+ --tsconfigPath <path> Path to tsconfig.json
169
+ (default: "")
170
+ --generate-helpers Generate TypeScript helper files
171
+ (default: true)
172
+ --additionalProperties Allow additional properties in validation
173
+ (default: false)
174
+
175
+ Performance Options:
176
+ --cache Enable file caching for incremental builds
177
+ --no-parallel Disable parallel processing (enabled by default)
178
+ --verbose Enable detailed logging and debugging info
179
+ --progress Show progress bars and status updates
180
+
181
+ Output Optimization:
182
+ --minify Minify generated JSON schemas
183
+ --tree-shaking Generate tree-shaking friendly exports
184
+ --lazy-load Generate lazy-loaded validators
185
+
186
+ General:
187
+ -h, --help Display help information
49
188
  ```
50
189
 
51
- ## npm script usage
190
+ ### Generated Files
191
+
192
+ The tool generates optimized files in your output directory:
52
193
 
53
- The intended use for ts-runtime-validation is as a npm script. Here it can also be tweaked to watch (eg. using nodemon)
194
+ | File | Description | Optimizations |
195
+ | ------------------------ | ----------------------------------------------------- | -------------------------------- |
196
+ | `validation.schema.json` | JSON Schema definitions for all your types | Minification with `--minify` |
197
+ | `SchemaDefinition.ts` | TypeScript interface mapping schema paths to types | Tree-shaking ready imports |
198
+ | `isValidSchema.ts` | Type guard helper with runtime validation | Lazy loading with `--lazy-load` |
199
+ | `ValidationType.ts` | Centralized type exports | Individual exports or namespace |
200
+
201
+ ### Programmatic API
202
+
203
+ ```typescript
204
+ import { SchemaGenerator } from "ts-runtime-validation";
205
+
206
+ // Basic usage
207
+ const generator = new SchemaGenerator({
208
+ glob: "**/*.jsonschema.ts",
209
+ rootPath: "./src",
210
+ output: "./validation",
211
+ helpers: true,
212
+ additionalProperties: false,
213
+ tsconfigPath: ""
214
+ });
215
+
216
+ await generator.Generate();
217
+
218
+ // Development configuration (fast iterations)
219
+ const devGenerator = new SchemaGenerator({
220
+ glob: "**/*.jsonschema.ts",
221
+ rootPath: "./src",
222
+ output: "./.ts-runtime-validation",
223
+ helpers: true,
224
+ additionalProperties: false,
225
+ tsconfigPath: "",
226
+ // Development optimizations
227
+ cache: true, // Enable incremental builds
228
+ progress: true, // Show progress feedback
229
+ verbose: true, // Detailed logging
230
+ parallel: true // Faster processing
231
+ });
232
+
233
+ // Production configuration (optimized output)
234
+ const prodGenerator = new SchemaGenerator({
235
+ glob: "**/*.jsonschema.ts",
236
+ rootPath: "./src",
237
+ output: "./dist/validation",
238
+ helpers: true,
239
+ additionalProperties: false,
240
+ tsconfigPath: "./tsconfig.json",
241
+ // Production optimizations
242
+ cache: true, // Faster builds
243
+ minify: true, // Smaller output files
244
+ treeShaking: true, // Bundle optimization
245
+ lazyLoad: false, // Eager loading for performance
246
+ parallel: true // Maximum speed
247
+ });
248
+
249
+ // Large project configuration (memory efficient)
250
+ const largeProjectGenerator = new SchemaGenerator({
251
+ glob: "**/*.jsonschema.ts",
252
+ rootPath: "./src",
253
+ output: "./validation",
254
+ helpers: true,
255
+ additionalProperties: false,
256
+ tsconfigPath: "",
257
+ // Large project optimizations
258
+ cache: true, // Essential for large projects
259
+ progress: true, // Track long operations
260
+ lazyLoad: true, // Reduce initial memory usage
261
+ treeShaking: true, // Optimize bundle size
262
+ minify: true // Reduce file size
263
+ });
264
+
265
+ // Execute generation
266
+ try {
267
+ await generator.Generate();
268
+ console.log('Schema generation completed successfully!');
269
+ } catch (error) {
270
+ console.error('Generation failed:', error.message);
271
+ }
272
+
273
+ // Utility methods
274
+ generator.clearCache(); // Clear file cache
275
+ await generator.cleanOutput(); // Remove generated files
276
+ ```
277
+
278
+ ### Watch Mode & Development Workflows
54
279
 
55
280
  ```json
56
281
  {
57
282
  "scripts": {
58
- "generate-types": "ts-runtime-validation"
59
- },
60
- "devDependencies": {
61
- "ts-runtime-validation": "^1.4.1"
283
+ "generate-types": "ts-runtime-validation --cache --progress",
284
+ "generate-types:watch": "nodemon --watch 'src/**/*.jsonschema.ts' --exec 'yarn generate-types'",
285
+ "generate-types:dev": "ts-runtime-validation --cache --verbose --progress",
286
+ "generate-types:prod": "ts-runtime-validation --cache --minify --tree-shaking",
287
+ "generate-types:clean": "rimraf .ts-runtime-validation-cache && yarn generate-types"
62
288
  }
63
289
  }
64
290
  ```
65
291
 
66
- ## Example snippets
292
+ ### Custom File Patterns
293
+
294
+ ```bash
295
+ # Basic usage
296
+ ts-runtime-validation
297
+
298
+ # Custom file patterns
299
+ ts-runtime-validation --glob "**/*.types.ts"
300
+ ts-runtime-validation --glob "**/*.{types,schemas}.ts"
301
+
302
+ # Development workflow (fast iterations)
303
+ ts-runtime-validation --cache --progress --verbose
304
+
305
+ # Production build (optimized output)
306
+ ts-runtime-validation --cache --minify --tree-shaking
307
+
308
+ # Large projects (performance focused)
309
+ ts-runtime-validation --cache --progress --lazy-load
310
+
311
+ # Specific directories
312
+ ts-runtime-validation --rootPath "./src/api" --output "./api-validation"
313
+
314
+ # CI/CD optimized
315
+ ts-runtime-validation --cache --minify --no-parallel
316
+
317
+ # Debug mode (maximum verbosity)
318
+ ts-runtime-validation --verbose --progress --no-parallel
319
+ ```
320
+
321
+ ## 🚀 Performance & Optimization
67
322
 
68
- ### Type guard
323
+ ### Caching System
69
324
 
70
- ```typescript
71
- import { isValidSchema } from "./.ts-runtime-validation/isValidSchema"; // this is autogenerated by the CLI as a helper file
325
+ ts-runtime-validation includes an intelligent caching system for faster incremental builds:
72
326
 
73
- if (isValidSchema(data, "#/definitions/ITypeA")) {
74
- // variable: data in this block will have typings for ITypeA
75
- } else {
76
- // type is invalid and not known here
77
- throw new Error("Failed to validate payload");
78
- }
327
+ ```bash
328
+ # Enable caching (recommended for development)
329
+ ts-runtime-validation --cache
79
330
  ```
80
331
 
81
- ### Type assertion
332
+ **How it works:**
333
+ - Generates MD5 hashes of source files to detect changes
334
+ - Stores cache in `.ts-runtime-validation-cache/`
335
+ - Only processes files that have been modified
336
+ - Provides significant speedup for large projects
82
337
 
338
+ ### Performance Tips
339
+
340
+ **Development Workflow:**
341
+ ```bash
342
+ # Fast iterations with caching and progress
343
+ ts-runtime-validation --cache --progress --verbose
344
+ ```
345
+
346
+ **Production Builds:**
347
+ ```bash
348
+ # Optimized output for deployment
349
+ ts-runtime-validation --cache --minify --tree-shaking
350
+ ```
351
+
352
+ **Large Projects:**
353
+ ```bash
354
+ # Memory efficient processing
355
+ ts-runtime-validation --cache --lazy-load --progress
83
356
  ```
84
- import * as schema from "../runtime-validation/validation.schema.json";
85
- import Ajv from "ajv";
86
- import { ISchema, schemas } from "../runtime-validation/SchemaDefinition";
87
357
 
88
- const validator = new Ajv({ allErrors: true });
89
- validator.compile(schema);
358
+ ### Bundle Optimization
359
+
360
+ **Tree-shaking friendly exports:**
361
+ ```typescript
362
+ // With --tree-shaking flag
363
+ export type IUser = _IUser; // Individual exports
364
+ export type IProduct = _IProduct;
90
365
 
91
- export const assertValidSchema = <T extends keyof typeof schemas>(data: unknown, schemaKeyRef: T): data is ISchema[T] => {
92
- validator.validate(schemaKeyRef as string, data);
93
- if (validator.errors || Boolean(validator.errors)) {
94
- const error = { schemaKeyRef, errors: validator.errorsText(), data };
95
- if (process.env.ENVIRONMENT === "dev") {
96
- console.log(error);
97
- }
98
- throw new Error(JSON.stringify(error));
366
+ // Default behavior
367
+ namespace ValidationType { // Namespace exports
368
+ export type IUser = _IUser;
369
+ }
370
+ ```
371
+
372
+ **Lazy-loaded validators:**
373
+ ```typescript
374
+ // With --lazy-load flag
375
+ let validator: any = null;
376
+ const getValidator = () => {
377
+ if (!validator) {
378
+ const Ajv = require("ajv");
379
+ validator = new Ajv({ allErrors: true });
380
+ validator.compile(schema);
99
381
  }
100
- return true;
382
+ return validator;
101
383
  };
102
384
  ```
103
385
 
104
- ## Contributing
386
+ ## ⚠️ Limitations
387
+
388
+ - **No duplicate type names** - Each interface/type must have a unique name across all schema files
389
+ - **TypeScript-only constructs** - Some advanced TypeScript features (like conditional types) may not be fully supported
390
+ - **Circular references** - Limited support for circular type references
391
+
392
+ ## 🤝 Contributing
393
+
394
+ We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
395
+
396
+ ### Development Setup
397
+
398
+ ```bash
399
+ # Clone the repository
400
+ git clone https://github.com/thegalah/ts-runtime-validation.git
401
+ cd ts-runtime-validation
402
+
403
+ # Install dependencies
404
+ yarn install
405
+
406
+ # Build the project
407
+ yarn build
408
+
409
+ # Run comprehensive test suite (103+ tests)
410
+ yarn test
411
+
412
+ # Link for local development
413
+ yarn link
414
+ ```
415
+
416
+ ### Architecture
417
+
418
+ ts-runtime-validation uses a modern service-oriented architecture:
419
+
420
+ - **FileDiscovery**: File system operations and intelligent caching
421
+ - **SchemaProcessor**: TypeScript AST processing with parallel execution
422
+ - **CodeGenerator**: Optimized TypeScript file generation
423
+ - **SchemaWriter**: Efficient file writing with minification
424
+ - **ProgressReporter**: User-friendly progress tracking
425
+
426
+ ### Contributing Guidelines
427
+
428
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed information about:
429
+ - Service-oriented architecture patterns
430
+ - Error handling strategies
431
+ - Performance optimization techniques
432
+ - Testing approaches and best practices
433
+
434
+ ## 🙏 Acknowledgments
435
+
436
+ Built with modern tools and optimized for performance:
437
+
438
+ - [ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) - TypeScript to JSON Schema conversion
439
+ - [ajv](https://github.com/ajv-validator/ajv) - Runtime JSON Schema validation
440
+ - [ts-morph](https://github.com/dsherret/ts-morph) - TypeScript AST manipulation and code generation
441
+ - [fdir](https://github.com/thecodrr/fdir) - Fast file system traversal
442
+ - [picomatch](https://github.com/micromatch/picomatch) - Efficient glob pattern matching
443
+
444
+ ## 📚 Related Projects & Comparisons
445
+
446
+ ### How ts-runtime-validation differs from alternatives:
447
+
448
+ | Library | Approach | When to Use |
449
+ | -------------------------------------------- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
450
+ | **ts-runtime-validation** | Generates validators from existing TypeScript interfaces via CLI/build step | You already have TypeScript interfaces and want automatic validation without runtime dependencies or API changes |
451
+ | **[zod](https://github.com/colinhacks/zod)** | Define schemas in code that create both types and validators | You want to define your schema once and derive TypeScript types from it, with a runtime validation library |
452
+ | **[io-ts](https://github.com/gcanti/io-ts)** | Functional programming approach with codecs for encoding/decoding | You need bidirectional transformations and prefer functional programming patterns |
453
+ | **[yup](https://github.com/jquense/yup)** | Runtime schema builder with fluent API | You're working with forms/frontend validation and want a battle-tested solution with built-in error messages |
454
+
455
+ ### Key Differences:
456
+
457
+ **ts-runtime-validation**:
458
+
459
+ - ✅ **Zero runtime API** - Works with your existing TypeScript interfaces
460
+ - ✅ **Build-time generation** - No runtime overhead for schema creation
461
+ - ✅ **JSDoc validation rules** - Add constraints via comments
462
+ - ✅ **Intelligent caching** - Fast incremental builds with change detection
463
+ - ✅ **Performance optimized** - Parallel processing and bundle optimization
464
+ - ❌ **Requires build step** - Must regenerate when types change
465
+ - ❌ **No runtime schema composition** - Can't dynamically create schemas
466
+
467
+ **zod/io-ts/yup**:
468
+
469
+ - ✅ **Runtime flexibility** - Create and compose schemas dynamically
470
+ - ✅ **Single source of truth** - Schema and type defined together
471
+ - ✅ **No build step** - Works immediately in your code
472
+ - ❌ **Runtime overhead** - Schemas created at runtime
473
+ - ❌ **Duplicate type definitions** - Can't reuse existing TypeScript interfaces
474
+
475
+ Choose **ts-runtime-validation** when you:
105
476
 
106
- Submit a PR
477
+ - Have existing TypeScript interfaces you want to validate
478
+ - Prefer build-time code generation over runtime libraries
479
+ - Want to keep validation rules close to your type definitions via JSDoc
480
+ - Need minimal runtime dependencies
481
+ - Require high performance with caching and parallel processing
482
+ - Want bundle optimization (tree-shaking, lazy loading)
483
+ - Need incremental builds for large projects
107
484
 
108
- ## License
485
+ Choose **alternatives** when you:
109
486
 
110
- MIT
487
+ - Want to define schemas at runtime dynamically
488
+ - Prefer schema-first design (define validation, derive types)
489
+ - Need complex runtime transformations or coercions
490
+ - Want extensive built-in validation methods and error messages
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ICommandOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICommandOptions.js","sourceRoot":"","sources":["../src/ICommandOptions.ts"],"names":[],"mappings":""}