@dudousxd/nestjs-codegen 0.27.0 → 0.27.2
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 +12 -0
- package/dist/cli/main.cjs +22 -15
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +22 -15
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +22 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -15
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +22 -15
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +22 -15
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -382,6 +382,6 @@ interface FastDiscoveryOptions {
|
|
|
382
382
|
}
|
|
383
383
|
declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
|
|
384
384
|
|
|
385
|
-
declare const VERSION = "0.27.
|
|
385
|
+
declare const VERSION = "0.27.2";
|
|
386
386
|
|
|
387
387
|
export { type ChainModuleRendererOptions, CodegenError, type CodegenManifest, ConfigError, DriftGuardError, type EntryPoint, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type WatchOptions, 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
|
@@ -382,6 +382,6 @@ interface FastDiscoveryOptions {
|
|
|
382
382
|
}
|
|
383
383
|
declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
|
|
384
384
|
|
|
385
|
-
declare const VERSION = "0.27.
|
|
385
|
+
declare const VERSION = "0.27.2";
|
|
386
386
|
|
|
387
387
|
export { type ChainModuleRendererOptions, CodegenError, type CodegenManifest, ConfigError, DriftGuardError, type EntryPoint, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type WatchOptions, 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
|
@@ -690,12 +690,18 @@ function findTypeInFile(name, file) {
|
|
|
690
690
|
function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
691
691
|
if (moduleSpecifier.startsWith(".")) {
|
|
692
692
|
const dir = dirname(sourceFile.getFilePath());
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
|
|
693
|
+
const ext = /\.(c|m)?(j|t)sx?$/.exec(moduleSpecifier)?.[0];
|
|
694
|
+
const base = ext ? moduleSpecifier.slice(0, -ext.length) : moduleSpecifier;
|
|
695
|
+
const flavour = ext?.startsWith(".c") ? "c" : ext?.startsWith(".m") ? "m" : "";
|
|
696
|
+
const candidates = [
|
|
697
|
+
resolve2(dir, `${base}.${flavour}ts`),
|
|
698
|
+
...flavour === "" ? [resolve2(dir, `${base}.tsx`)] : [],
|
|
696
699
|
resolve2(dir, `${moduleSpecifier}.ts`),
|
|
697
|
-
resolve2(dir, moduleSpecifier, "index.ts")
|
|
700
|
+
resolve2(dir, moduleSpecifier, "index.ts"),
|
|
701
|
+
resolve2(dir, `${base}.d.${flavour}ts`),
|
|
702
|
+
...ext === void 0 ? [resolve2(dir, moduleSpecifier, "index.d.ts")] : []
|
|
698
703
|
];
|
|
704
|
+
return [...new Set(candidates)];
|
|
699
705
|
}
|
|
700
706
|
const ctx = _ctxFor(project);
|
|
701
707
|
const baseUrl = ctx.pathsBase ?? ctx.projectRoot;
|
|
@@ -725,10 +731,11 @@ function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
|
725
731
|
}
|
|
726
732
|
return [];
|
|
727
733
|
}
|
|
728
|
-
function resolveImportedType(name, sourceFile, project) {
|
|
734
|
+
function resolveImportedType(name, sourceFile, project, seen = /* @__PURE__ */ new Set()) {
|
|
729
735
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
730
|
-
const namedImport = importDecl.getNamedImports().find((n) => n.getName() === name);
|
|
736
|
+
const namedImport = importDecl.getNamedImports().find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name);
|
|
731
737
|
if (!namedImport) continue;
|
|
738
|
+
const sourceName = namedImport.getName();
|
|
732
739
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
733
740
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
734
741
|
for (const candidate of candidates) {
|
|
@@ -740,17 +747,17 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
740
747
|
continue;
|
|
741
748
|
}
|
|
742
749
|
}
|
|
743
|
-
const result = findTypeInFile(
|
|
750
|
+
const result = findTypeInFile(sourceName, importedFile);
|
|
744
751
|
if (result) return result;
|
|
745
|
-
const viaReExport = resolveReExportedType(
|
|
752
|
+
const viaReExport = resolveReExportedType(sourceName, importedFile, project, /* @__PURE__ */ new Set());
|
|
746
753
|
if (viaReExport) return viaReExport;
|
|
747
754
|
}
|
|
748
755
|
if (candidates.length === 0) {
|
|
749
|
-
const viaCompiler = resolveBareSpecifierType(
|
|
756
|
+
const viaCompiler = resolveBareSpecifierType(sourceName, importDecl, project);
|
|
750
757
|
if (viaCompiler) return viaCompiler;
|
|
751
758
|
}
|
|
752
759
|
}
|
|
753
|
-
return resolveReExportedType(name, sourceFile, project,
|
|
760
|
+
return resolveReExportedType(name, sourceFile, project, seen);
|
|
754
761
|
}
|
|
755
762
|
function resolveBareSpecifierType(name, importDecl, project) {
|
|
756
763
|
let target;
|
|
@@ -765,9 +772,9 @@ function resolveBareSpecifierType(name, importDecl, project) {
|
|
|
765
772
|
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
766
773
|
}
|
|
767
774
|
function resolveReExportedType(name, file, project, seen) {
|
|
768
|
-
const
|
|
769
|
-
if (seen.has(
|
|
770
|
-
seen.add(
|
|
775
|
+
const visit = `${file.getFilePath()}#${name}`;
|
|
776
|
+
if (seen.has(visit)) return null;
|
|
777
|
+
seen.add(visit);
|
|
771
778
|
for (const exportDecl of file.getExportDeclarations()) {
|
|
772
779
|
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
773
780
|
const namedExports = exportDecl.getNamedExports();
|
|
@@ -789,7 +796,7 @@ function resolveReExportedType(name, file, project, seen) {
|
|
|
789
796
|
const sourceName = namedExports.find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name)?.getName() ?? name;
|
|
790
797
|
const local = findTypeInFile(sourceName, file);
|
|
791
798
|
if (local) return local;
|
|
792
|
-
const imported = resolveImportedType(sourceName, file, project);
|
|
799
|
+
const imported = resolveImportedType(sourceName, file, project, seen);
|
|
793
800
|
if (imported) return imported;
|
|
794
801
|
}
|
|
795
802
|
return null;
|
|
@@ -6095,7 +6102,7 @@ function createChainModuleRenderer(opts) {
|
|
|
6095
6102
|
}
|
|
6096
6103
|
|
|
6097
6104
|
// src/index.ts
|
|
6098
|
-
var VERSION = "0.27.
|
|
6105
|
+
var VERSION = "0.27.2";
|
|
6099
6106
|
export {
|
|
6100
6107
|
CodegenError,
|
|
6101
6108
|
ConfigError,
|