@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/dist/cli/main.js CHANGED
@@ -1776,10 +1776,19 @@ function followModuleForType(name, moduleSpecifier, fromFile, project, seen) {
1776
1776
  }
1777
1777
  return null;
1778
1778
  }
1779
+ var _findTypeCache = /* @__PURE__ */ new WeakMap();
1779
1780
  function findType(name, sourceFile, project) {
1781
+ let byKey = _findTypeCache.get(project);
1782
+ if (byKey === void 0) {
1783
+ byKey = /* @__PURE__ */ new Map();
1784
+ _findTypeCache.set(project, byKey);
1785
+ }
1786
+ const key = `${sourceFile.getFilePath()}\0${name}`;
1787
+ if (byKey.has(key)) return byKey.get(key) ?? null;
1780
1788
  const local = findTypeInFile(name, sourceFile);
1781
- if (local) return local;
1782
- return resolveImportedType(name, sourceFile, project);
1789
+ const result = local ?? resolveImportedType(name, sourceFile, project);
1790
+ byKey.set(key, result);
1791
+ return result;
1783
1792
  }
1784
1793
  var _NON_REF_NAMES = /* @__PURE__ */ new Set(["string", "number", "boolean", "void", "unknown", "any", "Date"]);
1785
1794
  function _localDeclForKinds(name, file, kinds) {
@@ -1816,6 +1825,26 @@ function resolveTypeRef(nodeOrName, sourceFile, project, opts) {
1816
1825
  if (_NON_REF_NAMES.has(refName)) return null;
1817
1826
  name = refName;
1818
1827
  }
1828
+ return _resolveNamedRef(name, sourceFile, project, opts);
1829
+ }
1830
+ var _resolveNamedRefCache = /* @__PURE__ */ new WeakMap();
1831
+ function _resolveNamedRef(name, sourceFile, project, opts) {
1832
+ let byKey = _resolveNamedRefCache.get(project);
1833
+ if (byKey === void 0) {
1834
+ byKey = /* @__PURE__ */ new Map();
1835
+ _resolveNamedRefCache.set(project, byKey);
1836
+ }
1837
+ const kindsKey = [...opts.kinds].sort().join(",");
1838
+ const key = `${sourceFile.getFilePath()}\0${name}\0${kindsKey}\0${opts.allowBareSpecifier ? 1 : 0}`;
1839
+ if (byKey.has(key)) {
1840
+ const cached = byKey.get(key) ?? null;
1841
+ return cached ? { ...cached } : null;
1842
+ }
1843
+ const computed = _computeNamedRef(name, sourceFile, project, opts);
1844
+ byKey.set(key, computed);
1845
+ return computed ? { ...computed } : null;
1846
+ }
1847
+ function _computeNamedRef(name, sourceFile, project, opts) {
1819
1848
  if (_localDeclForKinds(name, sourceFile, opts.kinds)) {
1820
1849
  return { name, filePath: sourceFile.getFilePath() };
1821
1850
  }
@@ -2195,17 +2224,31 @@ import {
2195
2224
  } from "ts-morph";
2196
2225
 
2197
2226
  // src/discovery/enum-resolution.ts
2227
+ var _enumCache = /* @__PURE__ */ new WeakMap();
2198
2228
  function resolveEnumValues(name, sourceFile, project) {
2229
+ let byKey = _enumCache.get(project);
2230
+ if (byKey === void 0) {
2231
+ byKey = /* @__PURE__ */ new Map();
2232
+ _enumCache.set(project, byKey);
2233
+ }
2234
+ const key = `${sourceFile.getFilePath()}\0${name}`;
2235
+ if (byKey.has(key)) {
2236
+ const cached = byKey.get(key) ?? null;
2237
+ return cached ? { values: [...cached.values], numeric: cached.numeric } : null;
2238
+ }
2199
2239
  const resolved = findType(name, sourceFile, project);
2200
- if (!resolved || resolved.kind !== "enum") return null;
2201
- let numeric = true;
2202
- const values = resolved.members.map((m) => {
2203
- const parsed = JSON.parse(m);
2204
- if (typeof parsed === "string") numeric = false;
2205
- return String(parsed);
2206
- });
2207
- if (values.length === 0) return null;
2208
- return { values, numeric };
2240
+ let result = null;
2241
+ if (resolved && resolved.kind === "enum") {
2242
+ let numeric = true;
2243
+ const values = resolved.members.map((m) => {
2244
+ const parsed = JSON.parse(m);
2245
+ if (typeof parsed === "string") numeric = false;
2246
+ return String(parsed);
2247
+ });
2248
+ if (values.length > 0) result = { values, numeric };
2249
+ }
2250
+ byKey.set(key, result);
2251
+ return result ? { values: [...result.values], numeric: result.numeric } : null;
2209
2252
  }
2210
2253
 
2211
2254
  // src/discovery/filter-field-types.ts
@@ -3475,7 +3518,7 @@ async function watch(config, onChange) {
3475
3518
  }
3476
3519
 
3477
3520
  // src/index.ts
3478
- var VERSION = "0.4.0";
3521
+ var VERSION = "0.4.1";
3479
3522
 
3480
3523
  // src/cli/codegen.ts
3481
3524
  async function runCodegen(opts = {}) {