@amritk/mjst 0.1.0 → 0.3.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.
package/README.md CHANGED
@@ -68,7 +68,9 @@ npx mjst --config ./mjst.config.json
68
68
  | 🏷️ | `typesOnly` | `--types-only` | `boolean` | — | `false` | Generate only TypeScript type definitions without parser functions. Useful when you only need the type shapes and do not need runtime validation. |
69
69
  | 🔨 | `build` | `--build` | `boolean` | — | `false` | Compile the generated TypeScript files to .js and .d.ts output. A temporary tsconfig is written to the output directory, tsc is invoked, and the intermediate .ts source files are removed when compilation succeeds. |
70
70
  | ⚠️ | `logWarnings` | `--log-warnings` | `boolean` | — | `false` | Emit a console.warn in the generated parsers for every input key that is not declared in the schema's properties. Useful for detecting schema drift or unexpected data shapes at runtime. |
71
- | ⚙️ | `config` | `--config <path>` | `string` | — | — | Path to a JSON config file. Keys match the option names in this schema (schema, outDir, typesOnly, build, logWarnings). CLI flags take precedence over config file values. |
71
+ | 🚫 | `strict` | `--strict` | `boolean` | — | `false` | Generate parsers that throw on type/shape mismatches (wrong type, missing required property, enum/pattern/min/max violations) instead of coercing invalid input to default values. Unknown extra keys are still allowed. |
72
+ | 🧰 | `helpers` | `--helpers <mode>` | `string` | — | — | Controls how generated parsers reference their runtime helpers. 'package' emits imports from @amritk/helpers (requires it to be installed in the consumer project). 'embedded' ships the helper source under outDir/_helpers/ so the output is self-contained. When omitted, the CLI auto-detects: it picks 'package' if @amritk/helpers resolves from outDir, otherwise 'embedded'. |
73
+ | ⚙️ | `config` | `--config <path>` | `string` | — | — | Path to a JSON config file. Keys match the option names in this schema (schema, outDir, typesOnly, build, logWarnings, strict, helpers). CLI flags take precedence over config file values. |
72
74
  <!-- config-table-end -->
73
75
 
74
76
  ---
@@ -22,4 +22,20 @@ export type CliConfig = {
22
22
  * that is not declared in the schema's properties.
23
23
  */
24
24
  readonly logWarnings?: boolean;
25
+ /**
26
+ * When true, the generated parsers throw on type/shape mismatches
27
+ * (wrong type, missing required property, enum/pattern/min/max violations)
28
+ * instead of coercing invalid input to default values.
29
+ */
30
+ readonly strict?: boolean;
31
+ /**
32
+ * Controls how generated parsers reference their runtime helpers.
33
+ * - `'package'`: emit `import ... from '@amritk/helpers/...'`.
34
+ * - `'embedded'`: ship the helper source under `outDir/_helpers/` and emit
35
+ * relative imports so the output directory is self-contained.
36
+ *
37
+ * When omitted, the CLI auto-detects: it picks `'package'` if `@amritk/helpers`
38
+ * resolves from outDir, otherwise falls back to `'embedded'`.
39
+ */
40
+ readonly helpers?: 'package' | 'embedded';
25
41
  };