@dudousxd/nestjs-codegen 0.5.2 → 0.6.1

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/index.d.cts CHANGED
@@ -289,6 +289,6 @@ interface FastDiscoveryOptions {
289
289
  }
290
290
  declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
291
291
 
292
- declare const VERSION = "0.5.2";
292
+ declare const VERSION = "0.6.1";
293
293
 
294
294
  export { type ChainModuleRendererOptions, CodegenError, ConfigError, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type Watcher, acquireLock, buildMocksFile, buildOpenApiSpec, createChainModuleRenderer, defineConfig, discoverContractsFast, emitApi, emitForms, emitMocks, emitOpenApi, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, schemaModuleToJsonSchema, schemaNodeToJsonSchema, toObjectKey, typeNameFor, watch };
package/dist/index.d.ts CHANGED
@@ -289,6 +289,6 @@ interface FastDiscoveryOptions {
289
289
  }
290
290
  declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
291
291
 
292
- declare const VERSION = "0.5.2";
292
+ declare const VERSION = "0.6.1";
293
293
 
294
294
  export { type ChainModuleRendererOptions, CodegenError, ConfigError, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type Watcher, acquireLock, buildMocksFile, buildOpenApiSpec, createChainModuleRenderer, defineConfig, discoverContractsFast, emitApi, emitForms, emitMocks, emitOpenApi, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, schemaModuleToJsonSchema, schemaNodeToJsonSchema, toObjectKey, typeNameFor, watch };
package/dist/index.js CHANGED
@@ -2254,7 +2254,6 @@ function resolveImportedType(name, sourceFile, project) {
2254
2254
  if (!namedImport) continue;
2255
2255
  const moduleSpecifier = importDecl.getModuleSpecifierValue();
2256
2256
  const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
2257
- if (candidates.length === 0) continue;
2258
2257
  for (const candidate of candidates) {
2259
2258
  let importedFile = project.getSourceFile(candidate);
2260
2259
  if (!importedFile) {
@@ -2269,9 +2268,25 @@ function resolveImportedType(name, sourceFile, project) {
2269
2268
  const viaReExport = resolveReExportedType(name, importedFile, project, /* @__PURE__ */ new Set());
2270
2269
  if (viaReExport) return viaReExport;
2271
2270
  }
2271
+ if (candidates.length === 0) {
2272
+ const viaCompiler = resolveBareSpecifierType(name, importDecl, project);
2273
+ if (viaCompiler) return viaCompiler;
2274
+ }
2272
2275
  }
2273
2276
  return resolveReExportedType(name, sourceFile, project, /* @__PURE__ */ new Set());
2274
2277
  }
2278
+ function resolveBareSpecifierType(name, importDecl, project) {
2279
+ let target;
2280
+ try {
2281
+ target = importDecl.getModuleSpecifierSourceFile();
2282
+ } catch {
2283
+ return null;
2284
+ }
2285
+ if (!target) return null;
2286
+ const direct = findTypeInFile(name, target);
2287
+ if (direct) return direct;
2288
+ return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
2289
+ }
2275
2290
  function resolveReExportedType(name, file, project, seen) {
2276
2291
  const filePath = file.getFilePath();
2277
2292
  if (seen.has(filePath)) return null;
@@ -4329,6 +4344,7 @@ async function watch(config, onChange) {
4329
4344
  return NO_OP_WATCHER;
4330
4345
  }
4331
4346
  let discovery = null;
4347
+ let lastRoutes = [];
4332
4348
  async function getDiscovery() {
4333
4349
  if (discovery === null) {
4334
4350
  discovery = await PersistentDiscovery.create({
@@ -4342,13 +4358,14 @@ async function watch(config, onChange) {
4342
4358
  }
4343
4359
  try {
4344
4360
  const initialRoutes = (await getDiscovery()).discover();
4361
+ lastRoutes = initialRoutes;
4345
4362
  await generate(config, initialRoutes);
4346
4363
  } catch (err) {
4347
4364
  console.warn(
4348
4365
  `[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
4349
4366
  );
4350
4367
  try {
4351
- await generate(config);
4368
+ await generate(config, lastRoutes);
4352
4369
  } catch {
4353
4370
  }
4354
4371
  }
@@ -4366,7 +4383,7 @@ async function watch(config, onChange) {
4366
4383
  pagesDebounceTimer = setTimeout(async () => {
4367
4384
  pagesDebounceTimer = void 0;
4368
4385
  try {
4369
- await generate(config);
4386
+ await generate(config, lastRoutes);
4370
4387
  } catch (err) {
4371
4388
  console.error(
4372
4389
  "[nestjs-codegen] Pages generation failed:",
@@ -4397,6 +4414,7 @@ async function watch(config, onChange) {
4397
4414
  pendingChangedPaths.clear();
4398
4415
  try {
4399
4416
  const routes = await (await getDiscovery()).rediscover(changed);
4417
+ lastRoutes = routes;
4400
4418
  await generate(config, routes);
4401
4419
  } catch (err) {
4402
4420
  console.error(
@@ -4520,7 +4538,7 @@ function createChainModuleRenderer(opts) {
4520
4538
  }
4521
4539
 
4522
4540
  // src/index.ts
4523
- var VERSION = "0.5.2";
4541
+ var VERSION = "0.6.1";
4524
4542
  export {
4525
4543
  CodegenError,
4526
4544
  ConfigError,