@dudousxd/nestjs-codegen 0.22.0 → 0.23.0
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 +38 -0
- package/dist/cli/main.cjs +15 -3
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +15 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +15 -3
- 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 +15 -3
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +14 -2
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +14 -2
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -382,6 +382,6 @@ interface FastDiscoveryOptions {
|
|
|
382
382
|
}
|
|
383
383
|
declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
|
|
384
384
|
|
|
385
|
-
declare const VERSION = "0.
|
|
385
|
+
declare const VERSION = "0.23.0";
|
|
386
386
|
|
|
387
387
|
export { type ChainModuleRendererOptions, CodegenError, type CodegenManifest, ConfigError, DriftGuardError, type EntryPoint, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type WatchOptions, type Watcher, acquireLock, buildMocksFile, buildOpenApiSpec, createChainModuleRenderer, defineConfig, discoverContractsFast, emitApi, emitForms, emitMocks, emitOpenApi, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, schemaModuleToJsonSchema, schemaNodeToJsonSchema, toObjectKey, typeNameFor, watch };
|
package/dist/index.d.ts
CHANGED
|
@@ -382,6 +382,6 @@ interface FastDiscoveryOptions {
|
|
|
382
382
|
}
|
|
383
383
|
declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
|
|
384
384
|
|
|
385
|
-
declare const VERSION = "0.
|
|
385
|
+
declare const VERSION = "0.23.0";
|
|
386
386
|
|
|
387
387
|
export { type ChainModuleRendererOptions, CodegenError, type CodegenManifest, ConfigError, DriftGuardError, type EntryPoint, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type WatchOptions, type Watcher, acquireLock, buildMocksFile, buildOpenApiSpec, createChainModuleRenderer, defineConfig, discoverContractsFast, emitApi, emitForms, emitMocks, emitOpenApi, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, schemaModuleToJsonSchema, schemaNodeToJsonSchema, toObjectKey, typeNameFor, watch };
|
package/dist/index.js
CHANGED
|
@@ -1356,6 +1356,7 @@ function classifyTypeKeyword(raw) {
|
|
|
1356
1356
|
function markNullable(r, nullable) {
|
|
1357
1357
|
return nullable ? { ...r, nullable: true } : r;
|
|
1358
1358
|
}
|
|
1359
|
+
var TRANSPARENT_TYPE_BRANDS = /* @__PURE__ */ new Set(["Opt", "Hidden"]);
|
|
1359
1360
|
function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
1360
1361
|
if (Node4.isUnionTypeNode(typeNode)) {
|
|
1361
1362
|
let nullable = false;
|
|
@@ -1414,6 +1415,11 @@ function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
|
1414
1415
|
const refName = typeNode.getTypeName().getText();
|
|
1415
1416
|
if (refName === "Date") return { kind: "date" };
|
|
1416
1417
|
if (refName === "Record" || refName === "Object") return { kind: "json" };
|
|
1418
|
+
const unwrapped = TRANSPARENT_TYPE_BRANDS.has(refName) ? typeNode.getTypeArguments()[0] : void 0;
|
|
1419
|
+
if (unwrapped) {
|
|
1420
|
+
const inner = classifyTypeNode(unwrapped, sourceFile, project, opts);
|
|
1421
|
+
return inner;
|
|
1422
|
+
}
|
|
1417
1423
|
const typeRef = opts?.resolveRef?.(refName) ?? null;
|
|
1418
1424
|
const en = resolveEnumValues(refName, sourceFile, project);
|
|
1419
1425
|
if (en) {
|
|
@@ -2741,7 +2747,7 @@ function bindDiscoveryContext(project, cwd, tsconfigPath, tsconfig = loadDiscove
|
|
|
2741
2747
|
}
|
|
2742
2748
|
function extractRoutesFrom(project, controllerPaths) {
|
|
2743
2749
|
const routes = [];
|
|
2744
|
-
for (const path of controllerPaths) {
|
|
2750
|
+
for (const path of byPath([...controllerPaths])) {
|
|
2745
2751
|
const sourceFile = project.getSourceFile(path);
|
|
2746
2752
|
if (sourceFile) routes.push(...extractFromSourceFile(sourceFile, project));
|
|
2747
2753
|
}
|
|
@@ -2749,11 +2755,17 @@ function extractRoutesFrom(project, controllerPaths) {
|
|
|
2749
2755
|
}
|
|
2750
2756
|
function extractAllRoutes(project) {
|
|
2751
2757
|
const routes = [];
|
|
2752
|
-
for (const sourceFile of project.getSourceFiles()) {
|
|
2758
|
+
for (const sourceFile of byPath(project.getSourceFiles(), (f) => f.getFilePath())) {
|
|
2753
2759
|
routes.push(...extractFromSourceFile(sourceFile, project));
|
|
2754
2760
|
}
|
|
2755
2761
|
return routes;
|
|
2756
2762
|
}
|
|
2763
|
+
function byPath(items, path = String) {
|
|
2764
|
+
return [...items].sort((a, b) => {
|
|
2765
|
+
const [x, y] = [path(a), path(b)];
|
|
2766
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2757
2769
|
var PersistentDiscovery = class _PersistentDiscovery {
|
|
2758
2770
|
project;
|
|
2759
2771
|
cwd;
|
|
@@ -5320,7 +5332,7 @@ function createChainModuleRenderer(opts) {
|
|
|
5320
5332
|
}
|
|
5321
5333
|
|
|
5322
5334
|
// src/index.ts
|
|
5323
|
-
var VERSION = "0.
|
|
5335
|
+
var VERSION = "0.23.0";
|
|
5324
5336
|
export {
|
|
5325
5337
|
CodegenError,
|
|
5326
5338
|
ConfigError,
|