@dudousxd/nestjs-codegen 0.5.2 → 0.6.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 +19 -0
- package/dist/cli/main.cjs +22 -4
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +22 -4
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +22 -4
- 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 -4
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +21 -3
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +21 -3
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @dudousxd/nestjs-codegen
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 95c744f: Fix watcher clobbering `api.ts` with an extension-only stub on page edits. The
|
|
8
|
+
pages fast path called `generate(config)` with no routes, so a route-injecting
|
|
9
|
+
extension (e.g. the notifications codegen) still emitted — overwriting the full
|
|
10
|
+
`api.ts` with just the injected namespace and dropping every contract-derived
|
|
11
|
+
route. The watcher now caches the last discovered routes (from the initial pass
|
|
12
|
+
and each contracts rediscovery) and reuses them for pages-only regenerations.
|
|
13
|
+
|
|
14
|
+
## 0.6.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- ece130c: Fix: resolve `@Filterable({ entity })` entities imported from external npm packages so the route is still classified as a filter route. Previously, when a filter's entity (e.g. a MikroORM entity from `@dudousxd/nestjs-durable-store-mikro-orm`) was imported from `node_modules` rather than an in-repo `*.entity.ts`, the discovery type resolver returned no candidates for the bare module specifier and bailed — degrading the route to a plain bodyless route (`body: never; filterFields: never`, no `queryOptions`) and breaking the generated client (`x.queryOptions is not a function`).
|
|
19
|
+
|
|
20
|
+
The type resolver now falls back to the TypeScript compiler's own module resolution (`getModuleSpecifierSourceFile()`) for bare node_modules specifiers, locating the package's `.d.ts` declaration file and enumerating the entity's columns from it. External-package filter entities now get the same full `filterFields` union + `body: FilterQueryResult` + TanStack `queryOptions` helper as in-repo entities.
|
|
21
|
+
|
|
3
22
|
## 0.5.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/cli/main.cjs
CHANGED
|
@@ -2270,7 +2270,6 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
2270
2270
|
if (!namedImport) continue;
|
|
2271
2271
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
2272
2272
|
const candidates = resolveModuleSpecifier(moduleSpecifier, sourceFile, project);
|
|
2273
|
-
if (candidates.length === 0) continue;
|
|
2274
2273
|
for (const candidate of candidates) {
|
|
2275
2274
|
let importedFile = project.getSourceFile(candidate);
|
|
2276
2275
|
if (!importedFile) {
|
|
@@ -2285,9 +2284,25 @@ function resolveImportedType(name, sourceFile, project) {
|
|
|
2285
2284
|
const viaReExport = resolveReExportedType(name, importedFile, project, /* @__PURE__ */ new Set());
|
|
2286
2285
|
if (viaReExport) return viaReExport;
|
|
2287
2286
|
}
|
|
2287
|
+
if (candidates.length === 0) {
|
|
2288
|
+
const viaCompiler = resolveBareSpecifierType(name, importDecl, project);
|
|
2289
|
+
if (viaCompiler) return viaCompiler;
|
|
2290
|
+
}
|
|
2288
2291
|
}
|
|
2289
2292
|
return resolveReExportedType(name, sourceFile, project, /* @__PURE__ */ new Set());
|
|
2290
2293
|
}
|
|
2294
|
+
function resolveBareSpecifierType(name, importDecl, project) {
|
|
2295
|
+
let target;
|
|
2296
|
+
try {
|
|
2297
|
+
target = importDecl.getModuleSpecifierSourceFile();
|
|
2298
|
+
} catch {
|
|
2299
|
+
return null;
|
|
2300
|
+
}
|
|
2301
|
+
if (!target) return null;
|
|
2302
|
+
const direct = findTypeInFile(name, target);
|
|
2303
|
+
if (direct) return direct;
|
|
2304
|
+
return resolveReExportedType(name, target, project, /* @__PURE__ */ new Set());
|
|
2305
|
+
}
|
|
2291
2306
|
function resolveReExportedType(name, file, project, seen) {
|
|
2292
2307
|
const filePath = file.getFilePath();
|
|
2293
2308
|
if (seen.has(filePath)) return null;
|
|
@@ -4340,6 +4355,7 @@ async function watch(config, onChange) {
|
|
|
4340
4355
|
return NO_OP_WATCHER;
|
|
4341
4356
|
}
|
|
4342
4357
|
let discovery = null;
|
|
4358
|
+
let lastRoutes = [];
|
|
4343
4359
|
async function getDiscovery() {
|
|
4344
4360
|
if (discovery === null) {
|
|
4345
4361
|
discovery = await PersistentDiscovery.create({
|
|
@@ -4353,13 +4369,14 @@ async function watch(config, onChange) {
|
|
|
4353
4369
|
}
|
|
4354
4370
|
try {
|
|
4355
4371
|
const initialRoutes = (await getDiscovery()).discover();
|
|
4372
|
+
lastRoutes = initialRoutes;
|
|
4356
4373
|
await generate(config, initialRoutes);
|
|
4357
4374
|
} catch (err) {
|
|
4358
4375
|
console.warn(
|
|
4359
4376
|
`[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
|
|
4360
4377
|
);
|
|
4361
4378
|
try {
|
|
4362
|
-
await generate(config);
|
|
4379
|
+
await generate(config, lastRoutes);
|
|
4363
4380
|
} catch {
|
|
4364
4381
|
}
|
|
4365
4382
|
}
|
|
@@ -4377,7 +4394,7 @@ async function watch(config, onChange) {
|
|
|
4377
4394
|
pagesDebounceTimer = setTimeout(async () => {
|
|
4378
4395
|
pagesDebounceTimer = void 0;
|
|
4379
4396
|
try {
|
|
4380
|
-
await generate(config);
|
|
4397
|
+
await generate(config, lastRoutes);
|
|
4381
4398
|
} catch (err) {
|
|
4382
4399
|
console.error(
|
|
4383
4400
|
"[nestjs-codegen] Pages generation failed:",
|
|
@@ -4408,6 +4425,7 @@ async function watch(config, onChange) {
|
|
|
4408
4425
|
pendingChangedPaths.clear();
|
|
4409
4426
|
try {
|
|
4410
4427
|
const routes = await (await getDiscovery()).rediscover(changed);
|
|
4428
|
+
lastRoutes = routes;
|
|
4411
4429
|
await generate(config, routes);
|
|
4412
4430
|
} catch (err) {
|
|
4413
4431
|
console.error(
|
|
@@ -4448,7 +4466,7 @@ async function watch(config, onChange) {
|
|
|
4448
4466
|
}
|
|
4449
4467
|
|
|
4450
4468
|
// src/index.ts
|
|
4451
|
-
var VERSION = "0.
|
|
4469
|
+
var VERSION = "0.6.1";
|
|
4452
4470
|
|
|
4453
4471
|
// src/cli/codegen.ts
|
|
4454
4472
|
async function runCodegen(opts = {}) {
|