@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/cli/main.js
CHANGED
|
@@ -685,12 +685,18 @@ function findTypeInFile(name, file) {
|
|
|
685
685
|
function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
686
686
|
if (moduleSpecifier.startsWith(".")) {
|
|
687
687
|
const dir = dirname(sourceFile.getFilePath());
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
688
|
+
const ext = /\.(c|m)?(j|t)sx?$/.exec(moduleSpecifier)?.[0];
|
|
689
|
+
const base = ext ? moduleSpecifier.slice(0, -ext.length) : moduleSpecifier;
|
|
690
|
+
const flavour = ext?.startsWith(".c") ? "c" : ext?.startsWith(".m") ? "m" : "";
|
|
691
|
+
const candidates = [
|
|
692
|
+
resolve2(dir, `${base}.${flavour}ts`),
|
|
693
|
+
...flavour === "" ? [resolve2(dir, `${base}.tsx`)] : [],
|
|
691
694
|
resolve2(dir, `${moduleSpecifier}.ts`),
|
|
692
|
-
resolve2(dir, moduleSpecifier, "index.ts")
|
|
695
|
+
resolve2(dir, moduleSpecifier, "index.ts"),
|
|
696
|
+
resolve2(dir, `${base}.d.${flavour}ts`),
|
|
697
|
+
...ext === void 0 ? [resolve2(dir, moduleSpecifier, "index.d.ts")] : []
|
|
693
698
|
];
|
|
699
|
+
return [...new Set(candidates)];
|
|
694
700
|
}
|
|
695
701
|
const ctx = _ctxFor(project);
|
|
696
702
|
const baseUrl = ctx.pathsBase ?? ctx.projectRoot;
|
|
@@ -720,10 +726,11 @@ function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
|
720
726
|
}
|
|
721
727
|
return [];
|
|
722
728
|
}
|
|
723
|
-
function resolveImportedType(name, sourceFile, project) {
|
|
729
|
+
function resolveImportedType(name, sourceFile, project, seen = /* @__PURE__ */ new Set()) {
|
|
724
730
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
725
|
-
const namedImport = importDecl.getNamedImports().find((n) => n.getName() === name);
|
|
731
|
+
const namedImport = importDecl.getNamedImports().find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name);
|
|
726
732
|
if (!namedImport) continue;
|
|
733
|
+
const sourceName = namedImport.getName();
|
|
727
734
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
728
735
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
729
736
|
for (const candidate of candidates) {
|
|
@@ -735,17 +742,17 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
735
742
|
continue;
|
|
736
743
|
}
|
|
737
744
|
}
|
|
738
|
-
const result = findTypeInFile(
|
|
745
|
+
const result = findTypeInFile(sourceName, importedFile);
|
|
739
746
|
if (result) return result;
|
|
740
|
-
const viaReExport = resolveReExportedType(
|
|
747
|
+
const viaReExport = resolveReExportedType(sourceName, importedFile, project, /* @__PURE__ */ new Set());
|
|
741
748
|
if (viaReExport) return viaReExport;
|
|
742
749
|
}
|
|
743
750
|
if (candidates.length === 0) {
|
|
744
|
-
const viaCompiler = resolveBareSpecifierType(
|
|
751
|
+
const viaCompiler = resolveBareSpecifierType(sourceName, importDecl, project);
|
|
745
752
|
if (viaCompiler) return viaCompiler;
|
|
746
753
|
}
|
|
747
754
|
}
|
|
748
|
-
return resolveReExportedType(name, sourceFile, project,
|
|
755
|
+
return resolveReExportedType(name, sourceFile, project, seen);
|
|
749
756
|
}
|
|
750
757
|
function resolveBareSpecifierType(name, importDecl, project) {
|
|
751
758
|
let target;
|
|
@@ -760,9 +767,9 @@ function resolveBareSpecifierType(name, importDecl, project) {
|
|
|
760
767
|
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
761
768
|
}
|
|
762
769
|
function resolveReExportedType(name, file, project, seen) {
|
|
763
|
-
const
|
|
764
|
-
if (seen.has(
|
|
765
|
-
seen.add(
|
|
770
|
+
const visit = `${file.getFilePath()}#${name}`;
|
|
771
|
+
if (seen.has(visit)) return null;
|
|
772
|
+
seen.add(visit);
|
|
766
773
|
for (const exportDecl of file.getExportDeclarations()) {
|
|
767
774
|
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
768
775
|
const namedExports = exportDecl.getNamedExports();
|
|
@@ -784,7 +791,7 @@ function resolveReExportedType(name, file, project, seen) {
|
|
|
784
791
|
const sourceName = namedExports.find((n) => (n.getAliasNode()?.getText() ?? n.getName()) === name)?.getName() ?? name;
|
|
785
792
|
const local = findTypeInFile(sourceName, file);
|
|
786
793
|
if (local) return local;
|
|
787
|
-
const imported = resolveImportedType(sourceName, file, project);
|
|
794
|
+
const imported = resolveImportedType(sourceName, file, project, seen);
|
|
788
795
|
if (imported) return imported;
|
|
789
796
|
}
|
|
790
797
|
return null;
|
|
@@ -6004,7 +6011,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
6004
6011
|
}
|
|
6005
6012
|
|
|
6006
6013
|
// src/index.ts
|
|
6007
|
-
var VERSION = "0.27.
|
|
6014
|
+
var VERSION = "0.27.2";
|
|
6008
6015
|
|
|
6009
6016
|
// src/cli/codegen.ts
|
|
6010
6017
|
async function runCodegen(opts = {}) {
|