@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/dist/cli/main.js CHANGED
@@ -108,6 +108,7 @@ function applyDefaults(userConfig, cwd) {
108
108
  };
109
109
  }
110
110
  return {
111
+ debug: userConfig.debug ?? false,
111
112
  extensions: userConfig.extensions ?? [],
112
113
  // Non-null: validateUserConfig() above throws when `validation` is absent.
113
114
  validation: resolveAdapter(userConfig.validation),
@@ -2074,8 +2075,18 @@ function buildEmpty() {
2074
2075
  ].join("\n");
2075
2076
  }
2076
2077
 
2078
+ // src/util/debug-log.ts
2079
+ var debugEnabled = false;
2080
+ function setCodegenDebug(enabled) {
2081
+ debugEnabled = enabled;
2082
+ }
2083
+ function debugWarn(message) {
2084
+ if (debugEnabled) console.warn(`[nestjs-codegen] ${message}`);
2085
+ }
2086
+
2077
2087
  // src/generate.ts
2078
2088
  async function generate(config, inputRoutes = []) {
2089
+ setCodegenDebug(config.debug);
2079
2090
  const extensions = config.extensions ?? [];
2080
2091
  let routes = inputRoutes;
2081
2092
  const ctx = createExtensionContext(config, () => routes);
@@ -2681,7 +2692,7 @@ function buildProperty(prop, classFile, ctx) {
2681
2692
  ctx.warnedDecorators.add(name);
2682
2693
  const msg = `@${name} is not translatable to a client validation schema and was skipped (server-only validation).`;
2683
2694
  ctx.warnings.push(msg);
2684
- console.warn(`[nestjs-codegen] ${msg}`);
2695
+ debugWarn(msg);
2685
2696
  }
2686
2697
  }
2687
2698
  }
@@ -2732,7 +2743,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
2732
2743
  ctx.warnedDecorators.add(`recursive:${reserved}`);
2733
2744
  const msg = `${className} is a recursive type; the generated schema validates it via a lazy self-reference.`;
2734
2745
  ctx.warnings.push(msg);
2735
- console.warn(`[nestjs-codegen] ${msg}`);
2746
+ debugWarn(msg);
2736
2747
  }
2737
2748
  return { kind: "lazyRef", name: reserved };
2738
2749
  }
@@ -2741,7 +2752,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
2741
2752
  ctx.warnedDecorators.add(`deep:${className}`);
2742
2753
  const msg = `${className} nesting is too deep to expand; the generated schema uses unknown for it.`;
2743
2754
  ctx.warnings.push(msg);
2744
- console.warn(`[nestjs-codegen] ${msg}`);
2755
+ debugWarn(msg);
2745
2756
  }
2746
2757
  return { kind: "unknown", note: "nesting too deep \u2014 not expanded" };
2747
2758
  }
@@ -2882,7 +2893,7 @@ function enumSchemaFromDecorator(decorator, classFile, ctx) {
2882
2893
  if (!ctx.warnedDecorators.has(`IsEnum:${name}`)) {
2883
2894
  ctx.warnedDecorators.add(`IsEnum:${name}`);
2884
2895
  ctx.warnings.push(msg);
2885
- console.warn(`[nestjs-codegen] ${msg}`);
2896
+ debugWarn(msg);
2886
2897
  }
2887
2898
  return { kind: "unknown", note: `@IsEnum(${name}): enum not resolvable to literals` };
2888
2899
  }
@@ -4481,7 +4492,7 @@ async function watch(config, onChange) {
4481
4492
  }
4482
4493
 
4483
4494
  // src/index.ts
4484
- var VERSION = "0.8.0";
4495
+ var VERSION = "0.10.0";
4485
4496
 
4486
4497
  // src/cli/codegen.ts
4487
4498
  async function runCodegen(opts = {}) {