@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/nest/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nestjs_common from '@nestjs/common';
|
|
2
2
|
import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy, ExecutionContext } from '@nestjs/common';
|
|
3
|
-
import { U as UserConfig } from '../index-
|
|
3
|
+
import { U as UserConfig } from '../index-Ce3YnfwS.cjs';
|
|
4
4
|
import 'ts-morph';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/nest/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nestjs_common from '@nestjs/common';
|
|
2
2
|
import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy, ExecutionContext } from '@nestjs/common';
|
|
3
|
-
import { U as UserConfig } from '../index-
|
|
3
|
+
import { U as UserConfig } from '../index-Ce3YnfwS.js';
|
|
4
4
|
import 'ts-morph';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/nest/index.js
CHANGED
|
@@ -975,6 +975,7 @@ function classifyTypeKeyword(raw) {
|
|
|
975
975
|
function markNullable(r, nullable) {
|
|
976
976
|
return nullable ? { ...r, nullable: true } : r;
|
|
977
977
|
}
|
|
978
|
+
var TRANSPARENT_TYPE_BRANDS = /* @__PURE__ */ new Set(["Opt", "Hidden"]);
|
|
978
979
|
function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
979
980
|
if (Node3.isUnionTypeNode(typeNode)) {
|
|
980
981
|
let nullable = false;
|
|
@@ -1033,6 +1034,11 @@ function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
|
1033
1034
|
const refName = typeNode.getTypeName().getText();
|
|
1034
1035
|
if (refName === "Date") return { kind: "date" };
|
|
1035
1036
|
if (refName === "Record" || refName === "Object") return { kind: "json" };
|
|
1037
|
+
const unwrapped = TRANSPARENT_TYPE_BRANDS.has(refName) ? typeNode.getTypeArguments()[0] : void 0;
|
|
1038
|
+
if (unwrapped) {
|
|
1039
|
+
const inner = classifyTypeNode(unwrapped, sourceFile, project, opts);
|
|
1040
|
+
return inner;
|
|
1041
|
+
}
|
|
1036
1042
|
const typeRef = opts?.resolveRef?.(refName) ?? null;
|
|
1037
1043
|
const en = resolveEnumValues(refName, sourceFile, project);
|
|
1038
1044
|
if (en) {
|
|
@@ -1103,12 +1109,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1103
1109
|
return { kind: "string" };
|
|
1104
1110
|
}
|
|
1105
1111
|
}
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1112
|
+
for (const key of ["columnType", "type"]) {
|
|
1113
|
+
const typeProp = arg.getProperty(key);
|
|
1114
|
+
if (!typeProp || !Node3.isPropertyAssignment(typeProp)) continue;
|
|
1108
1115
|
const init = typeProp.getInitializer();
|
|
1109
|
-
if (init
|
|
1116
|
+
if (!init) continue;
|
|
1117
|
+
if (Node3.isStringLiteral(init)) {
|
|
1110
1118
|
const kind = classifyTypeKeyword(init.getLiteralValue());
|
|
1111
1119
|
if (kind) return { kind };
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
if (Node3.isIdentifier(init)) {
|
|
1123
|
+
const kind = classifyTypeKeyword(init.getText());
|
|
1124
|
+
if (kind) return { kind };
|
|
1112
1125
|
}
|
|
1113
1126
|
}
|
|
1114
1127
|
}
|
|
@@ -1120,12 +1133,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1120
1133
|
function classifyFieldType(prop, sourceFile, project) {
|
|
1121
1134
|
let nullable = prop.hasQuestionToken();
|
|
1122
1135
|
const typeNode = prop.getTypeNode();
|
|
1136
|
+
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1123
1137
|
if (typeNode) {
|
|
1124
1138
|
const r = classifyTypeNode(typeNode, sourceFile, project);
|
|
1125
1139
|
if (r.nullable) nullable = true;
|
|
1126
|
-
if (r.kind !== "unknown")
|
|
1140
|
+
if (r.kind !== "unknown") {
|
|
1141
|
+
const conflicts = fromDecorator !== null && fromDecorator.kind !== "unknown" && fromDecorator.kind !== r.kind;
|
|
1142
|
+
if (conflicts) {
|
|
1143
|
+
return markNullable({ ...fromDecorator, valueKind: r.kind }, nullable);
|
|
1144
|
+
}
|
|
1145
|
+
return markNullable(r, nullable);
|
|
1146
|
+
}
|
|
1127
1147
|
}
|
|
1128
|
-
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1129
1148
|
if (fromDecorator) {
|
|
1130
1149
|
return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
|
|
1131
1150
|
}
|
|
@@ -1133,6 +1152,7 @@ function classifyFieldType(prop, sourceFile, project) {
|
|
|
1133
1152
|
}
|
|
1134
1153
|
function toFilterFieldType(name, r) {
|
|
1135
1154
|
const ft = { name, kind: r.kind };
|
|
1155
|
+
if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
|
|
1136
1156
|
if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
|
|
1137
1157
|
if (r.nullable) ft.nullable = true;
|
|
1138
1158
|
if (r.numericEnum) ft.numericEnum = true;
|
|
@@ -3253,7 +3273,7 @@ function kindToTs(kind, enumValues, numericEnum) {
|
|
|
3253
3273
|
}
|
|
3254
3274
|
function emitFieldTypesLiteral(fts) {
|
|
3255
3275
|
const entries = fts.map((f) => {
|
|
3256
|
-
let t = f.typeRef ? f.typeRef.name : kindToTs(f.kind, f.enumValues, f.numericEnum);
|
|
3276
|
+
let t = f.typeRef ? f.typeRef.name : kindToTs(f.valueKind ?? f.kind, f.enumValues, f.numericEnum);
|
|
3257
3277
|
if (f.nullable) t = `${t} | null`;
|
|
3258
3278
|
return `${JSON.stringify(f.name)}: ${t}`;
|
|
3259
3279
|
});
|
|
@@ -5016,7 +5036,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5016
5036
|
}
|
|
5017
5037
|
|
|
5018
5038
|
// src/index.ts
|
|
5019
|
-
var VERSION = "0.
|
|
5039
|
+
var VERSION = "0.24.0";
|
|
5020
5040
|
|
|
5021
5041
|
// src/generate-manifest.ts
|
|
5022
5042
|
var MANIFEST_FILE = ".codegen-manifest.json";
|