@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.
@@ -131,6 +131,7 @@ function applyDefaults(userConfig, cwd) {
131
131
  };
132
132
  }
133
133
  return {
134
+ debug: userConfig.debug ?? false,
134
135
  extensions: userConfig.extensions ?? [],
135
136
  // Non-null: validateUserConfig() above throws when `validation` is absent.
136
137
  validation: resolveAdapter(userConfig.validation),
@@ -188,6 +189,15 @@ var import_ts_morph5 = require("ts-morph");
188
189
  // src/discovery/dto-to-ir.ts
189
190
  var import_ts_morph2 = require("ts-morph");
190
191
 
192
+ // src/util/debug-log.ts
193
+ var debugEnabled = false;
194
+ function setCodegenDebug(enabled) {
195
+ debugEnabled = enabled;
196
+ }
197
+ function debugWarn(message) {
198
+ if (debugEnabled) console.warn(`[nestjs-codegen] ${message}`);
199
+ }
200
+
191
201
  // src/discovery/type-ref-resolution.ts
192
202
  var import_node_fs = require("fs");
193
203
  var import_node_path2 = require("path");
@@ -704,7 +714,7 @@ function buildProperty(prop, classFile, ctx) {
704
714
  ctx.warnedDecorators.add(name);
705
715
  const msg = `@${name} is not translatable to a client validation schema and was skipped (server-only validation).`;
706
716
  ctx.warnings.push(msg);
707
- console.warn(`[nestjs-codegen] ${msg}`);
717
+ debugWarn(msg);
708
718
  }
709
719
  }
710
720
  }
@@ -755,7 +765,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
755
765
  ctx.warnedDecorators.add(`recursive:${reserved}`);
756
766
  const msg = `${className} is a recursive type; the generated schema validates it via a lazy self-reference.`;
757
767
  ctx.warnings.push(msg);
758
- console.warn(`[nestjs-codegen] ${msg}`);
768
+ debugWarn(msg);
759
769
  }
760
770
  return { kind: "lazyRef", name: reserved };
761
771
  }
@@ -764,7 +774,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
764
774
  ctx.warnedDecorators.add(`deep:${className}`);
765
775
  const msg = `${className} nesting is too deep to expand; the generated schema uses unknown for it.`;
766
776
  ctx.warnings.push(msg);
767
- console.warn(`[nestjs-codegen] ${msg}`);
777
+ debugWarn(msg);
768
778
  }
769
779
  return { kind: "unknown", note: "nesting too deep \u2014 not expanded" };
770
780
  }
@@ -905,7 +915,7 @@ function enumSchemaFromDecorator(decorator, classFile, ctx) {
905
915
  if (!ctx.warnedDecorators.has(`IsEnum:${name}`)) {
906
916
  ctx.warnedDecorators.add(`IsEnum:${name}`);
907
917
  ctx.warnings.push(msg);
908
- console.warn(`[nestjs-codegen] ${msg}`);
918
+ debugWarn(msg);
909
919
  }
910
920
  return { kind: "unknown", note: `@IsEnum(${name}): enum not resolvable to literals` };
911
921
  }
@@ -4199,6 +4209,7 @@ function buildEmpty() {
4199
4209
 
4200
4210
  // src/generate.ts
4201
4211
  async function generate(config, inputRoutes = []) {
4212
+ setCodegenDebug(config.debug);
4202
4213
  const extensions = config.extensions ?? [];
4203
4214
  let routes = inputRoutes;
4204
4215
  const ctx = createExtensionContext(config, () => routes);