@dudousxd/nestjs-codegen 0.8.0 → 0.9.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,23 @@
1
1
  # @dudousxd/nestjs-codegen
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ff9e27b: feat(core): gate schema-translation advisories behind a new `debug` config flag (default off).
8
+
9
+ On every codegen pass the discovery layer logged a `[nestjs-codegen]` line to the
10
+ terminal for each schema-translation advisory — `@X is not translatable to a client
11
+ validation schema and was skipped`, `T is a recursive type; ... lazy self-reference`,
12
+ over-deep nesting, and unresolvable `@IsEnum`. On a real project these fire dozens of
13
+ times per run and are pure noise.
14
+
15
+ These advisories are already preserved where they matter: in the returned
16
+ `SchemaModule.warnings` array and as `// warning:` comments in the generated output.
17
+ The terminal copy is now opt-in: add `debug: true` to `nestjs-codegen.config.ts`
18
+ (or `NestjsCodegenModule.forRoot({ debug: true })`) to print them again. Default is
19
+ `false`, so a normal run is quiet. No effect on generated artifacts.
20
+
3
21
  ## 0.8.0
4
22
 
5
23
  ### Minor Changes
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.9.0";
4504
4515
 
4505
4516
  // src/cli/codegen.ts
4506
4517
  async function runCodegen(opts = {}) {