@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/nest/index.cjs
CHANGED
|
@@ -1132,12 +1132,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1132
1132
|
return { kind: "string" };
|
|
1133
1133
|
}
|
|
1134
1134
|
}
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1135
|
+
for (const key of ["columnType", "type"]) {
|
|
1136
|
+
const typeProp = arg.getProperty(key);
|
|
1137
|
+
if (!typeProp || !import_ts_morph3.Node.isPropertyAssignment(typeProp)) continue;
|
|
1137
1138
|
const init = typeProp.getInitializer();
|
|
1138
|
-
if (init
|
|
1139
|
+
if (!init) continue;
|
|
1140
|
+
if (import_ts_morph3.Node.isStringLiteral(init)) {
|
|
1139
1141
|
const kind = classifyTypeKeyword(init.getLiteralValue());
|
|
1140
1142
|
if (kind) return { kind };
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
if (import_ts_morph3.Node.isIdentifier(init)) {
|
|
1146
|
+
const kind = classifyTypeKeyword(init.getText());
|
|
1147
|
+
if (kind) return { kind };
|
|
1141
1148
|
}
|
|
1142
1149
|
}
|
|
1143
1150
|
}
|
|
@@ -1149,12 +1156,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1149
1156
|
function classifyFieldType(prop, sourceFile, project) {
|
|
1150
1157
|
let nullable = prop.hasQuestionToken();
|
|
1151
1158
|
const typeNode = prop.getTypeNode();
|
|
1159
|
+
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1152
1160
|
if (typeNode) {
|
|
1153
1161
|
const r = classifyTypeNode(typeNode, sourceFile, project);
|
|
1154
1162
|
if (r.nullable) nullable = true;
|
|
1155
|
-
if (r.kind !== "unknown")
|
|
1163
|
+
if (r.kind !== "unknown") {
|
|
1164
|
+
const conflicts = fromDecorator !== null && fromDecorator.kind !== "unknown" && fromDecorator.kind !== r.kind;
|
|
1165
|
+
if (conflicts) {
|
|
1166
|
+
return markNullable({ ...fromDecorator, valueKind: r.kind }, nullable);
|
|
1167
|
+
}
|
|
1168
|
+
return markNullable(r, nullable);
|
|
1169
|
+
}
|
|
1156
1170
|
}
|
|
1157
|
-
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1158
1171
|
if (fromDecorator) {
|
|
1159
1172
|
return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
|
|
1160
1173
|
}
|
|
@@ -1162,6 +1175,7 @@ function classifyFieldType(prop, sourceFile, project) {
|
|
|
1162
1175
|
}
|
|
1163
1176
|
function toFilterFieldType(name, r) {
|
|
1164
1177
|
const ft = { name, kind: r.kind };
|
|
1178
|
+
if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
|
|
1165
1179
|
if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
|
|
1166
1180
|
if (r.nullable) ft.nullable = true;
|
|
1167
1181
|
if (r.numericEnum) ft.numericEnum = true;
|
|
@@ -3282,7 +3296,7 @@ function kindToTs(kind, enumValues, numericEnum) {
|
|
|
3282
3296
|
}
|
|
3283
3297
|
function emitFieldTypesLiteral(fts) {
|
|
3284
3298
|
const entries = fts.map((f) => {
|
|
3285
|
-
let t = f.typeRef ? f.typeRef.name : kindToTs(f.kind, f.enumValues, f.numericEnum);
|
|
3299
|
+
let t = f.typeRef ? f.typeRef.name : kindToTs(f.valueKind ?? f.kind, f.enumValues, f.numericEnum);
|
|
3286
3300
|
if (f.nullable) t = `${t} | null`;
|
|
3287
3301
|
return `${JSON.stringify(f.name)}: ${t}`;
|
|
3288
3302
|
});
|
|
@@ -5045,7 +5059,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5045
5059
|
}
|
|
5046
5060
|
|
|
5047
5061
|
// src/index.ts
|
|
5048
|
-
var VERSION = "0.
|
|
5062
|
+
var VERSION = "0.24.0";
|
|
5049
5063
|
|
|
5050
5064
|
// src/generate-manifest.ts
|
|
5051
5065
|
var MANIFEST_FILE = ".codegen-manifest.json";
|