@dudousxd/nestjs-codegen 0.8.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @dudousxd/nestjs-codegen
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 152a2ab: Narrow the public `ValidationOption` type to `ValidationAdapter` only. The string
8
+ shortcuts (`'zod'` / `'valibot'` / `'arktype'`) were advertised by the type but
9
+ `resolveAdapter` always threw a `ConfigError` for any string, so they never worked
10
+ at runtime. The type now guides TypeScript users to import and pass an adapter
11
+ instance (e.g. `zodAdapter` from `@dudousxd/nestjs-codegen-zod`).
12
+
13
+ The runtime guard is retained: `resolveAdapter` still accepts a `string` and throws
14
+ the helpful "install + import the adapter package" error, so JS callers and untyped
15
+ configs that pass a removed string shortcut get the same actionable message.
16
+
17
+ This is a compile-time-only breaking change for anyone still typing `validation:
18
+ 'zod'` — it never produced working output at runtime, so the bump is minor.
19
+
20
+ ### Patch Changes
21
+
22
+ - 81ba774: Ship TanStack Intent agent skills (SKILL.md) inside the package.
23
+
24
+ ## 0.9.0
25
+
26
+ ### Minor Changes
27
+
28
+ - ff9e27b: feat(core): gate schema-translation advisories behind a new `debug` config flag (default off).
29
+
30
+ On every codegen pass the discovery layer logged a `[nestjs-codegen]` line to the
31
+ terminal for each schema-translation advisory — `@X is not translatable to a client
32
+ validation schema and was skipped`, `T is a recursive type; ... lazy self-reference`,
33
+ over-deep nesting, and unresolvable `@IsEnum`. On a real project these fire dozens of
34
+ times per run and are pure noise.
35
+
36
+ These advisories are already preserved where they matter: in the returned
37
+ `SchemaModule.warnings` array and as `// warning:` comments in the generated output.
38
+ The terminal copy is now opt-in: add `debug: true` to `nestjs-codegen.config.ts`
39
+ (or `NestjsCodegenModule.forRoot({ debug: true })`) to print them again. Default is
40
+ `false`, so a normal run is quiet. No effect on generated artifacts.
41
+
3
42
  ## 0.8.0
4
43
 
5
44
  ### Minor Changes
package/README.md CHANGED
@@ -15,6 +15,8 @@ layer.
15
15
 
16
16
  ```bash
17
17
  pnpm add -D @dudousxd/nestjs-codegen
18
+ # a validation adapter (no adapter is bundled in core) — zod shown; or -valibot / -arktype:
19
+ pnpm add -D @dudousxd/nestjs-codegen-zod
18
20
  # the runtime the generated client imports its Fetcher type from:
19
21
  pnpm add @dudousxd/nestjs-client
20
22
  ```
@@ -33,6 +35,7 @@ The watcher is a dev/CI concern, so the module skips itself automatically when
33
35
  ```ts title="src/app.module.ts"
34
36
  import { Module } from '@nestjs/common';
35
37
  import { NestjsCodegenModule } from '@dudousxd/nestjs-codegen/nest';
38
+ import { zodAdapter } from '@dudousxd/nestjs-codegen-zod';
36
39
 
37
40
  @Module({
38
41
  imports: [
@@ -42,7 +45,7 @@ import { NestjsCodegenModule } from '@dudousxd/nestjs-codegen/nest';
42
45
  // output directory for the generated files
43
46
  codegen: { outDir: 'src/generated' },
44
47
 
45
- validation: 'zod', // 'zod' (bundled) | valibotAdapter | arktypeAdapter
48
+ validation: zodAdapter, // zodAdapter | valibotAdapter | arktypeAdapter
46
49
  }),
47
50
  ],
48
51
  })
@@ -87,7 +90,7 @@ import { arktypeAdapter } from '@dudousxd/nestjs-codegen-arktype';
87
90
  NestjsCodegenModule.forRoot({
88
91
  contracts: { glob: 'src/**/*.controller.ts' },
89
92
  codegen: { outDir: 'src/generated' },
90
- validation: arktypeAdapter, // render the IR as arktype instead of the bundled zod
93
+ validation: arktypeAdapter, // render the IR as arktype instead of zod
91
94
  extensions: [tanstackQuery(), nestjsFilterCodegen(), nestjsInertiaCodegen()],
92
95
  });
93
96
  ```
@@ -136,11 +139,12 @@ with `defineConfig` and importing them into `forRoot()`:
136
139
 
137
140
  ```ts title="nestjs-codegen.config.ts"
138
141
  import { defineConfig } from '@dudousxd/nestjs-codegen';
142
+ import { zodAdapter } from '@dudousxd/nestjs-codegen-zod';
139
143
 
140
144
  export default defineConfig({
141
145
  contracts: { glob: 'src/**/*.controller.ts' },
142
146
  codegen: { outDir: 'src/generated' },
143
- validation: 'zod',
147
+ validation: zodAdapter,
144
148
  });
145
149
  ```
146
150
 
package/dist/cli/main.cjs CHANGED
@@ -142,6 +142,7 @@ function applyDefaults(userConfig, cwd) {
142
142
  };
143
143
  }
144
144
  return {
145
+ debug: userConfig.debug ?? false,
145
146
  extensions: userConfig.extensions ?? [],
146
147
  // Non-null: validateUserConfig() above throws when `validation` is absent.
147
148
  validation: resolveAdapter(userConfig.validation),
@@ -2108,8 +2109,18 @@ function buildEmpty() {
2108
2109
  ].join("\n");
2109
2110
  }
2110
2111
 
2112
+ // src/util/debug-log.ts
2113
+ var debugEnabled = false;
2114
+ function setCodegenDebug(enabled) {
2115
+ debugEnabled = enabled;
2116
+ }
2117
+ function debugWarn(message) {
2118
+ if (debugEnabled) console.warn(`[nestjs-codegen] ${message}`);
2119
+ }
2120
+
2111
2121
  // src/generate.ts
2112
2122
  async function generate(config, inputRoutes = []) {
2123
+ setCodegenDebug(config.debug);
2113
2124
  const extensions = config.extensions ?? [];
2114
2125
  let routes = inputRoutes;
2115
2126
  const ctx = createExtensionContext(config, () => routes);
@@ -2705,7 +2716,7 @@ function buildProperty(prop, classFile, ctx) {
2705
2716
  ctx.warnedDecorators.add(name);
2706
2717
  const msg = `@${name} is not translatable to a client validation schema and was skipped (server-only validation).`;
2707
2718
  ctx.warnings.push(msg);
2708
- console.warn(`[nestjs-codegen] ${msg}`);
2719
+ debugWarn(msg);
2709
2720
  }
2710
2721
  }
2711
2722
  }
@@ -2756,7 +2767,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
2756
2767
  ctx.warnedDecorators.add(`recursive:${reserved}`);
2757
2768
  const msg = `${className} is a recursive type; the generated schema validates it via a lazy self-reference.`;
2758
2769
  ctx.warnings.push(msg);
2759
- console.warn(`[nestjs-codegen] ${msg}`);
2770
+ debugWarn(msg);
2760
2771
  }
2761
2772
  return { kind: "lazyRef", name: reserved };
2762
2773
  }
@@ -2765,7 +2776,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
2765
2776
  ctx.warnedDecorators.add(`deep:${className}`);
2766
2777
  const msg = `${className} nesting is too deep to expand; the generated schema uses unknown for it.`;
2767
2778
  ctx.warnings.push(msg);
2768
- console.warn(`[nestjs-codegen] ${msg}`);
2779
+ debugWarn(msg);
2769
2780
  }
2770
2781
  return { kind: "unknown", note: "nesting too deep \u2014 not expanded" };
2771
2782
  }
@@ -2906,7 +2917,7 @@ function enumSchemaFromDecorator(decorator, classFile, ctx) {
2906
2917
  if (!ctx.warnedDecorators.has(`IsEnum:${name}`)) {
2907
2918
  ctx.warnedDecorators.add(`IsEnum:${name}`);
2908
2919
  ctx.warnings.push(msg);
2909
- console.warn(`[nestjs-codegen] ${msg}`);
2920
+ debugWarn(msg);
2910
2921
  }
2911
2922
  return { kind: "unknown", note: `@IsEnum(${name}): enum not resolvable to literals` };
2912
2923
  }
@@ -4500,7 +4511,7 @@ async function watch(config, onChange) {
4500
4511
  }
4501
4512
 
4502
4513
  // src/index.ts
4503
- var VERSION = "0.8.0";
4514
+ var VERSION = "0.10.0";
4504
4515
 
4505
4516
  // src/cli/codegen.ts
4506
4517
  async function runCodegen(opts = {}) {