@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/index.d.cts
CHANGED
|
@@ -164,6 +164,6 @@ interface FastDiscoveryOptions {
|
|
|
164
164
|
}
|
|
165
165
|
declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
|
|
166
166
|
|
|
167
|
-
declare const VERSION = "0.4.
|
|
167
|
+
declare const VERSION = "0.4.1";
|
|
168
168
|
|
|
169
169
|
export { CodegenError, ConfigError, type FastDiscoveryOptions, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type Watcher, acquireLock, defineConfig, discoverContractsFast, emitApi, emitForms, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, watch };
|
package/dist/index.d.ts
CHANGED
|
@@ -164,6 +164,6 @@ interface FastDiscoveryOptions {
|
|
|
164
164
|
}
|
|
165
165
|
declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
|
|
166
166
|
|
|
167
|
-
declare const VERSION = "0.4.
|
|
167
|
+
declare const VERSION = "0.4.1";
|
|
168
168
|
|
|
169
169
|
export { CodegenError, ConfigError, type FastDiscoveryOptions, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type Watcher, acquireLock, defineConfig, discoverContractsFast, emitApi, emitForms, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, watch };
|
package/dist/index.js
CHANGED
|
@@ -1781,10 +1781,19 @@ function followModuleForType(name, moduleSpecifier, fromFile, project, seen) {
|
|
|
1781
1781
|
}
|
|
1782
1782
|
return null;
|
|
1783
1783
|
}
|
|
1784
|
+
var _findTypeCache = /* @__PURE__ */ new WeakMap();
|
|
1784
1785
|
function findType(name, sourceFile, project) {
|
|
1786
|
+
let byKey = _findTypeCache.get(project);
|
|
1787
|
+
if (byKey === void 0) {
|
|
1788
|
+
byKey = /* @__PURE__ */ new Map();
|
|
1789
|
+
_findTypeCache.set(project, byKey);
|
|
1790
|
+
}
|
|
1791
|
+
const key = `${sourceFile.getFilePath()}\0${name}`;
|
|
1792
|
+
if (byKey.has(key)) return byKey.get(key) ?? null;
|
|
1785
1793
|
const local = findTypeInFile(name, sourceFile);
|
|
1786
|
-
|
|
1787
|
-
|
|
1794
|
+
const result = local ?? resolveImportedType(name, sourceFile, project);
|
|
1795
|
+
byKey.set(key, result);
|
|
1796
|
+
return result;
|
|
1788
1797
|
}
|
|
1789
1798
|
var _NON_REF_NAMES = /* @__PURE__ */ new Set(["string", "number", "boolean", "void", "unknown", "any", "Date"]);
|
|
1790
1799
|
function _localDeclForKinds(name, file, kinds) {
|
|
@@ -1821,6 +1830,26 @@ function resolveTypeRef(nodeOrName, sourceFile, project, opts) {
|
|
|
1821
1830
|
if (_NON_REF_NAMES.has(refName)) return null;
|
|
1822
1831
|
name = refName;
|
|
1823
1832
|
}
|
|
1833
|
+
return _resolveNamedRef(name, sourceFile, project, opts);
|
|
1834
|
+
}
|
|
1835
|
+
var _resolveNamedRefCache = /* @__PURE__ */ new WeakMap();
|
|
1836
|
+
function _resolveNamedRef(name, sourceFile, project, opts) {
|
|
1837
|
+
let byKey = _resolveNamedRefCache.get(project);
|
|
1838
|
+
if (byKey === void 0) {
|
|
1839
|
+
byKey = /* @__PURE__ */ new Map();
|
|
1840
|
+
_resolveNamedRefCache.set(project, byKey);
|
|
1841
|
+
}
|
|
1842
|
+
const kindsKey = [...opts.kinds].sort().join(",");
|
|
1843
|
+
const key = `${sourceFile.getFilePath()}\0${name}\0${kindsKey}\0${opts.allowBareSpecifier ? 1 : 0}`;
|
|
1844
|
+
if (byKey.has(key)) {
|
|
1845
|
+
const cached = byKey.get(key) ?? null;
|
|
1846
|
+
return cached ? { ...cached } : null;
|
|
1847
|
+
}
|
|
1848
|
+
const computed = _computeNamedRef(name, sourceFile, project, opts);
|
|
1849
|
+
byKey.set(key, computed);
|
|
1850
|
+
return computed ? { ...computed } : null;
|
|
1851
|
+
}
|
|
1852
|
+
function _computeNamedRef(name, sourceFile, project, opts) {
|
|
1824
1853
|
if (_localDeclForKinds(name, sourceFile, opts.kinds)) {
|
|
1825
1854
|
return { name, filePath: sourceFile.getFilePath() };
|
|
1826
1855
|
}
|
|
@@ -2200,17 +2229,31 @@ import {
|
|
|
2200
2229
|
} from "ts-morph";
|
|
2201
2230
|
|
|
2202
2231
|
// src/discovery/enum-resolution.ts
|
|
2232
|
+
var _enumCache = /* @__PURE__ */ new WeakMap();
|
|
2203
2233
|
function resolveEnumValues(name, sourceFile, project) {
|
|
2234
|
+
let byKey = _enumCache.get(project);
|
|
2235
|
+
if (byKey === void 0) {
|
|
2236
|
+
byKey = /* @__PURE__ */ new Map();
|
|
2237
|
+
_enumCache.set(project, byKey);
|
|
2238
|
+
}
|
|
2239
|
+
const key = `${sourceFile.getFilePath()}\0${name}`;
|
|
2240
|
+
if (byKey.has(key)) {
|
|
2241
|
+
const cached = byKey.get(key) ?? null;
|
|
2242
|
+
return cached ? { values: [...cached.values], numeric: cached.numeric } : null;
|
|
2243
|
+
}
|
|
2204
2244
|
const resolved = findType(name, sourceFile, project);
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2245
|
+
let result = null;
|
|
2246
|
+
if (resolved && resolved.kind === "enum") {
|
|
2247
|
+
let numeric = true;
|
|
2248
|
+
const values = resolved.members.map((m) => {
|
|
2249
|
+
const parsed = JSON.parse(m);
|
|
2250
|
+
if (typeof parsed === "string") numeric = false;
|
|
2251
|
+
return String(parsed);
|
|
2252
|
+
});
|
|
2253
|
+
if (values.length > 0) result = { values, numeric };
|
|
2254
|
+
}
|
|
2255
|
+
byKey.set(key, result);
|
|
2256
|
+
return result ? { values: [...result.values], numeric: result.numeric } : null;
|
|
2214
2257
|
}
|
|
2215
2258
|
|
|
2216
2259
|
// src/discovery/filter-field-types.ts
|
|
@@ -3529,7 +3572,7 @@ function renderTsType(node, ctx) {
|
|
|
3529
3572
|
}
|
|
3530
3573
|
|
|
3531
3574
|
// src/index.ts
|
|
3532
|
-
var VERSION = "0.4.
|
|
3575
|
+
var VERSION = "0.4.1";
|
|
3533
3576
|
export {
|
|
3534
3577
|
CodegenError,
|
|
3535
3578
|
ConfigError,
|