@dudousxd/nestjs-codegen 0.23.0 → 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 +18 -0
- package/dist/cli/main.cjs +21 -7
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +21 -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 +21 -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 +21 -7
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +21 -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 +21 -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
|
@@ -1490,12 +1490,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1490
1490
|
return { kind: "string" };
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1493
|
+
for (const key of ["columnType", "type"]) {
|
|
1494
|
+
const typeProp = arg.getProperty(key);
|
|
1495
|
+
if (!typeProp || !Node4.isPropertyAssignment(typeProp)) continue;
|
|
1495
1496
|
const init = typeProp.getInitializer();
|
|
1496
|
-
if (init
|
|
1497
|
+
if (!init) continue;
|
|
1498
|
+
if (Node4.isStringLiteral(init)) {
|
|
1497
1499
|
const kind = classifyTypeKeyword(init.getLiteralValue());
|
|
1498
1500
|
if (kind) return { kind };
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
if (Node4.isIdentifier(init)) {
|
|
1504
|
+
const kind = classifyTypeKeyword(init.getText());
|
|
1505
|
+
if (kind) return { kind };
|
|
1499
1506
|
}
|
|
1500
1507
|
}
|
|
1501
1508
|
}
|
|
@@ -1507,12 +1514,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1507
1514
|
function classifyFieldType(prop, sourceFile, project) {
|
|
1508
1515
|
let nullable = prop.hasQuestionToken();
|
|
1509
1516
|
const typeNode = prop.getTypeNode();
|
|
1517
|
+
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1510
1518
|
if (typeNode) {
|
|
1511
1519
|
const r = classifyTypeNode(typeNode, sourceFile, project);
|
|
1512
1520
|
if (r.nullable) nullable = true;
|
|
1513
|
-
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
|
+
}
|
|
1514
1528
|
}
|
|
1515
|
-
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1516
1529
|
if (fromDecorator) {
|
|
1517
1530
|
return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
|
|
1518
1531
|
}
|
|
@@ -1520,6 +1533,7 @@ function classifyFieldType(prop, sourceFile, project) {
|
|
|
1520
1533
|
}
|
|
1521
1534
|
function toFilterFieldType(name, r) {
|
|
1522
1535
|
const ft = { name, kind: r.kind };
|
|
1536
|
+
if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
|
|
1523
1537
|
if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
|
|
1524
1538
|
if (r.nullable) ft.nullable = true;
|
|
1525
1539
|
if (r.numericEnum) ft.numericEnum = true;
|
|
@@ -3325,7 +3339,7 @@ function kindToTs(kind, enumValues, numericEnum) {
|
|
|
3325
3339
|
}
|
|
3326
3340
|
function emitFieldTypesLiteral(fts) {
|
|
3327
3341
|
const entries = fts.map((f) => {
|
|
3328
|
-
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);
|
|
3329
3343
|
if (f.nullable) t = `${t} | null`;
|
|
3330
3344
|
return `${JSON.stringify(f.name)}: ${t}`;
|
|
3331
3345
|
});
|
|
@@ -5332,7 +5346,7 @@ function createChainModuleRenderer(opts) {
|
|
|
5332
5346
|
}
|
|
5333
5347
|
|
|
5334
5348
|
// src/index.ts
|
|
5335
|
-
var VERSION = "0.
|
|
5349
|
+
var VERSION = "0.24.0";
|
|
5336
5350
|
export {
|
|
5337
5351
|
CodegenError,
|
|
5338
5352
|
ConfigError,
|