@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.
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy } from '@nestjs/common';
2
- import { U as UserConfig } from '../index-DgIAN5k5.cjs';
2
+ import { U as UserConfig } from '../index-CxkGbILp.cjs';
3
3
  import 'ts-morph';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy } from '@nestjs/common';
2
- import { U as UserConfig } from '../index-DgIAN5k5.js';
2
+ import { U as UserConfig } from '../index-CxkGbILp.js';
3
3
  import 'ts-morph';
4
4
 
5
5
  /**
@@ -95,6 +95,7 @@ function applyDefaults(userConfig, cwd) {
95
95
  };
96
96
  }
97
97
  return {
98
+ debug: userConfig.debug ?? false,
98
99
  extensions: userConfig.extensions ?? [],
99
100
  // Non-null: validateUserConfig() above throws when `validation` is absent.
100
101
  validation: resolveAdapter(userConfig.validation),
@@ -160,6 +161,15 @@ import {
160
161
  Node as Node2
161
162
  } from "ts-morph";
162
163
 
164
+ // src/util/debug-log.ts
165
+ var debugEnabled = false;
166
+ function setCodegenDebug(enabled) {
167
+ debugEnabled = enabled;
168
+ }
169
+ function debugWarn(message) {
170
+ if (debugEnabled) console.warn(`[nestjs-codegen] ${message}`);
171
+ }
172
+
163
173
  // src/discovery/type-ref-resolution.ts
164
174
  import { readFileSync } from "fs";
165
175
  import { dirname, resolve as resolve2 } from "path";
@@ -678,7 +688,7 @@ function buildProperty(prop, classFile, ctx) {
678
688
  ctx.warnedDecorators.add(name);
679
689
  const msg = `@${name} is not translatable to a client validation schema and was skipped (server-only validation).`;
680
690
  ctx.warnings.push(msg);
681
- console.warn(`[nestjs-codegen] ${msg}`);
691
+ debugWarn(msg);
682
692
  }
683
693
  }
684
694
  }
@@ -729,7 +739,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
729
739
  ctx.warnedDecorators.add(`recursive:${reserved}`);
730
740
  const msg = `${className} is a recursive type; the generated schema validates it via a lazy self-reference.`;
731
741
  ctx.warnings.push(msg);
732
- console.warn(`[nestjs-codegen] ${msg}`);
742
+ debugWarn(msg);
733
743
  }
734
744
  return { kind: "lazyRef", name: reserved };
735
745
  }
@@ -738,7 +748,7 @@ function buildNestedReference(className, fromFile, ctx, typeArgs = []) {
738
748
  ctx.warnedDecorators.add(`deep:${className}`);
739
749
  const msg = `${className} nesting is too deep to expand; the generated schema uses unknown for it.`;
740
750
  ctx.warnings.push(msg);
741
- console.warn(`[nestjs-codegen] ${msg}`);
751
+ debugWarn(msg);
742
752
  }
743
753
  return { kind: "unknown", note: "nesting too deep \u2014 not expanded" };
744
754
  }
@@ -879,7 +889,7 @@ function enumSchemaFromDecorator(decorator, classFile, ctx) {
879
889
  if (!ctx.warnedDecorators.has(`IsEnum:${name}`)) {
880
890
  ctx.warnedDecorators.add(`IsEnum:${name}`);
881
891
  ctx.warnings.push(msg);
882
- console.warn(`[nestjs-codegen] ${msg}`);
892
+ debugWarn(msg);
883
893
  }
884
894
  return { kind: "unknown", note: `@IsEnum(${name}): enum not resolvable to literals` };
885
895
  }
@@ -4178,6 +4188,7 @@ function buildEmpty() {
4178
4188
 
4179
4189
  // src/generate.ts
4180
4190
  async function generate(config, inputRoutes = []) {
4191
+ setCodegenDebug(config.debug);
4181
4192
  const extensions = config.extensions ?? [];
4182
4193
  let routes = inputRoutes;
4183
4194
  const ctx = createExtensionContext(config, () => routes);