@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.cjs
CHANGED
|
@@ -336,10 +336,19 @@ function followModuleForType(name, moduleSpecifier, fromFile, project, seen) {
|
|
|
336
336
|
}
|
|
337
337
|
return null;
|
|
338
338
|
}
|
|
339
|
+
var _findTypeCache = /* @__PURE__ */ new WeakMap();
|
|
339
340
|
function findType(name, sourceFile, project) {
|
|
341
|
+
let byKey = _findTypeCache.get(project);
|
|
342
|
+
if (byKey === void 0) {
|
|
343
|
+
byKey = /* @__PURE__ */ new Map();
|
|
344
|
+
_findTypeCache.set(project, byKey);
|
|
345
|
+
}
|
|
346
|
+
const key = `${sourceFile.getFilePath()}\0${name}`;
|
|
347
|
+
if (byKey.has(key)) return byKey.get(key) ?? null;
|
|
340
348
|
const local = findTypeInFile(name, sourceFile);
|
|
341
|
-
|
|
342
|
-
|
|
349
|
+
const result = local ?? resolveImportedType(name, sourceFile, project);
|
|
350
|
+
byKey.set(key, result);
|
|
351
|
+
return result;
|
|
343
352
|
}
|
|
344
353
|
var _NON_REF_NAMES = /* @__PURE__ */ new Set(["string", "number", "boolean", "void", "unknown", "any", "Date"]);
|
|
345
354
|
function _localDeclForKinds(name, file, kinds) {
|
|
@@ -376,6 +385,26 @@ function resolveTypeRef(nodeOrName, sourceFile, project, opts) {
|
|
|
376
385
|
if (_NON_REF_NAMES.has(refName)) return null;
|
|
377
386
|
name = refName;
|
|
378
387
|
}
|
|
388
|
+
return _resolveNamedRef(name, sourceFile, project, opts);
|
|
389
|
+
}
|
|
390
|
+
var _resolveNamedRefCache = /* @__PURE__ */ new WeakMap();
|
|
391
|
+
function _resolveNamedRef(name, sourceFile, project, opts) {
|
|
392
|
+
let byKey = _resolveNamedRefCache.get(project);
|
|
393
|
+
if (byKey === void 0) {
|
|
394
|
+
byKey = /* @__PURE__ */ new Map();
|
|
395
|
+
_resolveNamedRefCache.set(project, byKey);
|
|
396
|
+
}
|
|
397
|
+
const kindsKey = [...opts.kinds].sort().join(",");
|
|
398
|
+
const key = `${sourceFile.getFilePath()}\0${name}\0${kindsKey}\0${opts.allowBareSpecifier ? 1 : 0}`;
|
|
399
|
+
if (byKey.has(key)) {
|
|
400
|
+
const cached = byKey.get(key) ?? null;
|
|
401
|
+
return cached ? { ...cached } : null;
|
|
402
|
+
}
|
|
403
|
+
const computed = _computeNamedRef(name, sourceFile, project, opts);
|
|
404
|
+
byKey.set(key, computed);
|
|
405
|
+
return computed ? { ...computed } : null;
|
|
406
|
+
}
|
|
407
|
+
function _computeNamedRef(name, sourceFile, project, opts) {
|
|
379
408
|
if (_localDeclForKinds(name, sourceFile, opts.kinds)) {
|
|
380
409
|
return { name, filePath: sourceFile.getFilePath() };
|
|
381
410
|
}
|
|
@@ -750,17 +779,31 @@ var import_ts_morph4 = require("ts-morph");
|
|
|
750
779
|
var import_ts_morph3 = require("ts-morph");
|
|
751
780
|
|
|
752
781
|
// src/discovery/enum-resolution.ts
|
|
782
|
+
var _enumCache = /* @__PURE__ */ new WeakMap();
|
|
753
783
|
function resolveEnumValues(name, sourceFile, project) {
|
|
784
|
+
let byKey = _enumCache.get(project);
|
|
785
|
+
if (byKey === void 0) {
|
|
786
|
+
byKey = /* @__PURE__ */ new Map();
|
|
787
|
+
_enumCache.set(project, byKey);
|
|
788
|
+
}
|
|
789
|
+
const key = `${sourceFile.getFilePath()}\0${name}`;
|
|
790
|
+
if (byKey.has(key)) {
|
|
791
|
+
const cached = byKey.get(key) ?? null;
|
|
792
|
+
return cached ? { values: [...cached.values], numeric: cached.numeric } : null;
|
|
793
|
+
}
|
|
754
794
|
const resolved = findType(name, sourceFile, project);
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
795
|
+
let result = null;
|
|
796
|
+
if (resolved && resolved.kind === "enum") {
|
|
797
|
+
let numeric = true;
|
|
798
|
+
const values = resolved.members.map((m) => {
|
|
799
|
+
const parsed = JSON.parse(m);
|
|
800
|
+
if (typeof parsed === "string") numeric = false;
|
|
801
|
+
return String(parsed);
|
|
802
|
+
});
|
|
803
|
+
if (values.length > 0) result = { values, numeric };
|
|
804
|
+
}
|
|
805
|
+
byKey.set(key, result);
|
|
806
|
+
return result ? { values: [...result.values], numeric: result.numeric } : null;
|
|
764
807
|
}
|
|
765
808
|
|
|
766
809
|
// src/discovery/filter-field-types.ts
|