@dudousxd/nestjs-codegen 0.22.1 → 0.24.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 +32 -0
- package/dist/cli/main.cjs +27 -7
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +27 -7
- package/dist/cli/main.js.map +1 -1
- package/dist/extension/index.d.cts +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/{index-BsptKWwz.d.cts → index-Ce3YnfwS.d.cts} +19 -0
- package/dist/{index-BsptKWwz.d.ts → index-Ce3YnfwS.d.ts} +19 -0
- package/dist/index.cjs +27 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +27 -7
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.d.cts +1 -1
- package/dist/nest/index.d.ts +1 -1
- package/dist/nest/index.js +27 -7
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-
|
|
2
|
-
export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-
|
|
1
|
+
import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-Ce3YnfwS.cjs';
|
|
2
|
+
export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-Ce3YnfwS.cjs';
|
|
3
3
|
import { ClassDeclaration, SourceFile, Project } from 'ts-morph';
|
|
4
4
|
|
|
5
5
|
declare function defineConfig(c: UserConfig): UserConfig;
|
|
@@ -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.24.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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-
|
|
2
|
-
export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-
|
|
1
|
+
import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-Ce3YnfwS.js';
|
|
2
|
+
export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-Ce3YnfwS.js';
|
|
3
3
|
import { ClassDeclaration, SourceFile, Project } from 'ts-morph';
|
|
4
4
|
|
|
5
5
|
declare function defineConfig(c: UserConfig): UserConfig;
|
|
@@ -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.24.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) {
|
|
@@ -1484,12 +1490,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1484
1490
|
return { kind: "string" };
|
|
1485
1491
|
}
|
|
1486
1492
|
}
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1493
|
+
for (const key of ["columnType", "type"]) {
|
|
1494
|
+
const typeProp = arg.getProperty(key);
|
|
1495
|
+
if (!typeProp || !Node4.isPropertyAssignment(typeProp)) continue;
|
|
1489
1496
|
const init = typeProp.getInitializer();
|
|
1490
|
-
if (init
|
|
1497
|
+
if (!init) continue;
|
|
1498
|
+
if (Node4.isStringLiteral(init)) {
|
|
1491
1499
|
const kind = classifyTypeKeyword(init.getLiteralValue());
|
|
1492
1500
|
if (kind) return { kind };
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
if (Node4.isIdentifier(init)) {
|
|
1504
|
+
const kind = classifyTypeKeyword(init.getText());
|
|
1505
|
+
if (kind) return { kind };
|
|
1493
1506
|
}
|
|
1494
1507
|
}
|
|
1495
1508
|
}
|
|
@@ -1501,12 +1514,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1501
1514
|
function classifyFieldType(prop, sourceFile, project) {
|
|
1502
1515
|
let nullable = prop.hasQuestionToken();
|
|
1503
1516
|
const typeNode = prop.getTypeNode();
|
|
1517
|
+
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1504
1518
|
if (typeNode) {
|
|
1505
1519
|
const r = classifyTypeNode(typeNode, sourceFile, project);
|
|
1506
1520
|
if (r.nullable) nullable = true;
|
|
1507
|
-
if (r.kind !== "unknown")
|
|
1521
|
+
if (r.kind !== "unknown") {
|
|
1522
|
+
const conflicts = fromDecorator !== null && fromDecorator.kind !== "unknown" && fromDecorator.kind !== r.kind;
|
|
1523
|
+
if (conflicts) {
|
|
1524
|
+
return markNullable({ ...fromDecorator, valueKind: r.kind }, nullable);
|
|
1525
|
+
}
|
|
1526
|
+
return markNullable(r, nullable);
|
|
1527
|
+
}
|
|
1508
1528
|
}
|
|
1509
|
-
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1510
1529
|
if (fromDecorator) {
|
|
1511
1530
|
return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
|
|
1512
1531
|
}
|
|
@@ -1514,6 +1533,7 @@ function classifyFieldType(prop, sourceFile, project) {
|
|
|
1514
1533
|
}
|
|
1515
1534
|
function toFilterFieldType(name, r) {
|
|
1516
1535
|
const ft = { name, kind: r.kind };
|
|
1536
|
+
if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
|
|
1517
1537
|
if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
|
|
1518
1538
|
if (r.nullable) ft.nullable = true;
|
|
1519
1539
|
if (r.numericEnum) ft.numericEnum = true;
|
|
@@ -3319,7 +3339,7 @@ function kindToTs(kind, enumValues, numericEnum) {
|
|
|
3319
3339
|
}
|
|
3320
3340
|
function emitFieldTypesLiteral(fts) {
|
|
3321
3341
|
const entries = fts.map((f) => {
|
|
3322
|
-
let t = f.typeRef ? f.typeRef.name : kindToTs(f.kind, f.enumValues, f.numericEnum);
|
|
3342
|
+
let t = f.typeRef ? f.typeRef.name : kindToTs(f.valueKind ?? f.kind, f.enumValues, f.numericEnum);
|
|
3323
3343
|
if (f.nullable) t = `${t} | null`;
|
|
3324
3344
|
return `${JSON.stringify(f.name)}: ${t}`;
|
|
3325
3345
|
});
|
|
@@ -5326,7 +5346,7 @@ function createChainModuleRenderer(opts) {
|
|
|
5326
5346
|
}
|
|
5327
5347
|
|
|
5328
5348
|
// src/index.ts
|
|
5329
|
-
var VERSION = "0.
|
|
5349
|
+
var VERSION = "0.24.0";
|
|
5330
5350
|
export {
|
|
5331
5351
|
CodegenError,
|
|
5332
5352
|
ConfigError,
|