@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.cjs
CHANGED
|
@@ -998,6 +998,7 @@ function classifyTypeKeyword(raw) {
|
|
|
998
998
|
function markNullable(r, nullable) {
|
|
999
999
|
return nullable ? { ...r, nullable: true } : r;
|
|
1000
1000
|
}
|
|
1001
|
+
var TRANSPARENT_TYPE_BRANDS = /* @__PURE__ */ new Set(["Opt", "Hidden"]);
|
|
1001
1002
|
function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
1002
1003
|
if (import_ts_morph3.Node.isUnionTypeNode(typeNode)) {
|
|
1003
1004
|
let nullable = false;
|
|
@@ -1056,6 +1057,11 @@ function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
|
1056
1057
|
const refName = typeNode.getTypeName().getText();
|
|
1057
1058
|
if (refName === "Date") return { kind: "date" };
|
|
1058
1059
|
if (refName === "Record" || refName === "Object") return { kind: "json" };
|
|
1060
|
+
const unwrapped = TRANSPARENT_TYPE_BRANDS.has(refName) ? typeNode.getTypeArguments()[0] : void 0;
|
|
1061
|
+
if (unwrapped) {
|
|
1062
|
+
const inner = classifyTypeNode(unwrapped, sourceFile, project, opts);
|
|
1063
|
+
return inner;
|
|
1064
|
+
}
|
|
1059
1065
|
const typeRef = opts?.resolveRef?.(refName) ?? null;
|
|
1060
1066
|
const en = resolveEnumValues(refName, sourceFile, project);
|
|
1061
1067
|
if (en) {
|
|
@@ -1126,12 +1132,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1126
1132
|
return { kind: "string" };
|
|
1127
1133
|
}
|
|
1128
1134
|
}
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1135
|
+
for (const key of ["columnType", "type"]) {
|
|
1136
|
+
const typeProp = arg.getProperty(key);
|
|
1137
|
+
if (!typeProp || !import_ts_morph3.Node.isPropertyAssignment(typeProp)) continue;
|
|
1131
1138
|
const init = typeProp.getInitializer();
|
|
1132
|
-
if (init
|
|
1139
|
+
if (!init) continue;
|
|
1140
|
+
if (import_ts_morph3.Node.isStringLiteral(init)) {
|
|
1133
1141
|
const kind = classifyTypeKeyword(init.getLiteralValue());
|
|
1134
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 };
|
|
1135
1148
|
}
|
|
1136
1149
|
}
|
|
1137
1150
|
}
|
|
@@ -1143,12 +1156,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1143
1156
|
function classifyFieldType(prop, sourceFile, project) {
|
|
1144
1157
|
let nullable = prop.hasQuestionToken();
|
|
1145
1158
|
const typeNode = prop.getTypeNode();
|
|
1159
|
+
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1146
1160
|
if (typeNode) {
|
|
1147
1161
|
const r = classifyTypeNode(typeNode, sourceFile, project);
|
|
1148
1162
|
if (r.nullable) nullable = true;
|
|
1149
|
-
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
|
+
}
|
|
1150
1170
|
}
|
|
1151
|
-
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1152
1171
|
if (fromDecorator) {
|
|
1153
1172
|
return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
|
|
1154
1173
|
}
|
|
@@ -1156,6 +1175,7 @@ function classifyFieldType(prop, sourceFile, project) {
|
|
|
1156
1175
|
}
|
|
1157
1176
|
function toFilterFieldType(name, r) {
|
|
1158
1177
|
const ft = { name, kind: r.kind };
|
|
1178
|
+
if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
|
|
1159
1179
|
if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
|
|
1160
1180
|
if (r.nullable) ft.nullable = true;
|
|
1161
1181
|
if (r.numericEnum) ft.numericEnum = true;
|
|
@@ -3276,7 +3296,7 @@ function kindToTs(kind, enumValues, numericEnum) {
|
|
|
3276
3296
|
}
|
|
3277
3297
|
function emitFieldTypesLiteral(fts) {
|
|
3278
3298
|
const entries = fts.map((f) => {
|
|
3279
|
-
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);
|
|
3280
3300
|
if (f.nullable) t = `${t} | null`;
|
|
3281
3301
|
return `${JSON.stringify(f.name)}: ${t}`;
|
|
3282
3302
|
});
|
|
@@ -5039,7 +5059,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5039
5059
|
}
|
|
5040
5060
|
|
|
5041
5061
|
// src/index.ts
|
|
5042
|
-
var VERSION = "0.
|
|
5062
|
+
var VERSION = "0.24.0";
|
|
5043
5063
|
|
|
5044
5064
|
// src/generate-manifest.ts
|
|
5045
5065
|
var MANIFEST_FILE = ".codegen-manifest.json";
|