@dudousxd/nestjs-codegen 0.4.0 → 0.4.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/CHANGELOG.md +6 -0
- package/dist/cli/main.cjs +55 -12
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +55 -12
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +55 -12
- 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 +55 -12
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +54 -11
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +54 -11
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/nest/index.js
CHANGED
|
@@ -310,10 +310,19 @@ function followModuleForType(name, moduleSpecifier, fromFile, project, seen) {
|
|
|
310
310
|
}
|
|
311
311
|
return null;
|
|
312
312
|
}
|
|
313
|
+
var _findTypeCache = /* @__PURE__ */ new WeakMap();
|
|
313
314
|
function findType(name, sourceFile, project) {
|
|
315
|
+
let byKey = _findTypeCache.get(project);
|
|
316
|
+
if (byKey === void 0) {
|
|
317
|
+
byKey = /* @__PURE__ */ new Map();
|
|
318
|
+
_findTypeCache.set(project, byKey);
|
|
319
|
+
}
|
|
320
|
+
const key = `${sourceFile.getFilePath()}\0${name}`;
|
|
321
|
+
if (byKey.has(key)) return byKey.get(key) ?? null;
|
|
314
322
|
const local = findTypeInFile(name, sourceFile);
|
|
315
|
-
|
|
316
|
-
|
|
323
|
+
const result = local ?? resolveImportedType(name, sourceFile, project);
|
|
324
|
+
byKey.set(key, result);
|
|
325
|
+
return result;
|
|
317
326
|
}
|
|
318
327
|
var _NON_REF_NAMES = /* @__PURE__ */ new Set(["string", "number", "boolean", "void", "unknown", "any", "Date"]);
|
|
319
328
|
function _localDeclForKinds(name, file, kinds) {
|
|
@@ -350,6 +359,26 @@ function resolveTypeRef(nodeOrName, sourceFile, project, opts) {
|
|
|
350
359
|
if (_NON_REF_NAMES.has(refName)) return null;
|
|
351
360
|
name = refName;
|
|
352
361
|
}
|
|
362
|
+
return _resolveNamedRef(name, sourceFile, project, opts);
|
|
363
|
+
}
|
|
364
|
+
var _resolveNamedRefCache = /* @__PURE__ */ new WeakMap();
|
|
365
|
+
function _resolveNamedRef(name, sourceFile, project, opts) {
|
|
366
|
+
let byKey = _resolveNamedRefCache.get(project);
|
|
367
|
+
if (byKey === void 0) {
|
|
368
|
+
byKey = /* @__PURE__ */ new Map();
|
|
369
|
+
_resolveNamedRefCache.set(project, byKey);
|
|
370
|
+
}
|
|
371
|
+
const kindsKey = [...opts.kinds].sort().join(",");
|
|
372
|
+
const key = `${sourceFile.getFilePath()}\0${name}\0${kindsKey}\0${opts.allowBareSpecifier ? 1 : 0}`;
|
|
373
|
+
if (byKey.has(key)) {
|
|
374
|
+
const cached = byKey.get(key) ?? null;
|
|
375
|
+
return cached ? { ...cached } : null;
|
|
376
|
+
}
|
|
377
|
+
const computed = _computeNamedRef(name, sourceFile, project, opts);
|
|
378
|
+
byKey.set(key, computed);
|
|
379
|
+
return computed ? { ...computed } : null;
|
|
380
|
+
}
|
|
381
|
+
function _computeNamedRef(name, sourceFile, project, opts) {
|
|
353
382
|
if (_localDeclForKinds(name, sourceFile, opts.kinds)) {
|
|
354
383
|
return { name, filePath: sourceFile.getFilePath() };
|
|
355
384
|
}
|
|
@@ -729,17 +758,31 @@ import {
|
|
|
729
758
|
} from "ts-morph";
|
|
730
759
|
|
|
731
760
|
// src/discovery/enum-resolution.ts
|
|
761
|
+
var _enumCache = /* @__PURE__ */ new WeakMap();
|
|
732
762
|
function resolveEnumValues(name, sourceFile, project) {
|
|
763
|
+
let byKey = _enumCache.get(project);
|
|
764
|
+
if (byKey === void 0) {
|
|
765
|
+
byKey = /* @__PURE__ */ new Map();
|
|
766
|
+
_enumCache.set(project, byKey);
|
|
767
|
+
}
|
|
768
|
+
const key = `${sourceFile.getFilePath()}\0${name}`;
|
|
769
|
+
if (byKey.has(key)) {
|
|
770
|
+
const cached = byKey.get(key) ?? null;
|
|
771
|
+
return cached ? { values: [...cached.values], numeric: cached.numeric } : null;
|
|
772
|
+
}
|
|
733
773
|
const resolved = findType(name, sourceFile, project);
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
774
|
+
let result = null;
|
|
775
|
+
if (resolved && resolved.kind === "enum") {
|
|
776
|
+
let numeric = true;
|
|
777
|
+
const values = resolved.members.map((m) => {
|
|
778
|
+
const parsed = JSON.parse(m);
|
|
779
|
+
if (typeof parsed === "string") numeric = false;
|
|
780
|
+
return String(parsed);
|
|
781
|
+
});
|
|
782
|
+
if (values.length > 0) result = { values, numeric };
|
|
783
|
+
}
|
|
784
|
+
byKey.set(key, result);
|
|
785
|
+
return result ? { values: [...result.values], numeric: result.numeric } : null;
|
|
743
786
|
}
|
|
744
787
|
|
|
745
788
|
// src/discovery/filter-field-types.ts
|