@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/cli/main.js
CHANGED
|
@@ -1351,6 +1351,7 @@ function classifyTypeKeyword(raw) {
|
|
|
1351
1351
|
function markNullable(r, nullable) {
|
|
1352
1352
|
return nullable ? { ...r, nullable: true } : r;
|
|
1353
1353
|
}
|
|
1354
|
+
var TRANSPARENT_TYPE_BRANDS = /* @__PURE__ */ new Set(["Opt", "Hidden"]);
|
|
1354
1355
|
function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
1355
1356
|
if (Node4.isUnionTypeNode(typeNode)) {
|
|
1356
1357
|
let nullable = false;
|
|
@@ -1409,6 +1410,11 @@ function classifyTypeNode(typeNode, sourceFile, project, opts) {
|
|
|
1409
1410
|
const refName = typeNode.getTypeName().getText();
|
|
1410
1411
|
if (refName === "Date") return { kind: "date" };
|
|
1411
1412
|
if (refName === "Record" || refName === "Object") return { kind: "json" };
|
|
1413
|
+
const unwrapped = TRANSPARENT_TYPE_BRANDS.has(refName) ? typeNode.getTypeArguments()[0] : void 0;
|
|
1414
|
+
if (unwrapped) {
|
|
1415
|
+
const inner = classifyTypeNode(unwrapped, sourceFile, project, opts);
|
|
1416
|
+
return inner;
|
|
1417
|
+
}
|
|
1412
1418
|
const typeRef = opts?.resolveRef?.(refName) ?? null;
|
|
1413
1419
|
const en = resolveEnumValues(refName, sourceFile, project);
|
|
1414
1420
|
if (en) {
|
|
@@ -1479,12 +1485,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1479
1485
|
return { kind: "string" };
|
|
1480
1486
|
}
|
|
1481
1487
|
}
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1488
|
+
for (const key of ["columnType", "type"]) {
|
|
1489
|
+
const typeProp = arg.getProperty(key);
|
|
1490
|
+
if (!typeProp || !Node4.isPropertyAssignment(typeProp)) continue;
|
|
1484
1491
|
const init = typeProp.getInitializer();
|
|
1485
|
-
if (init
|
|
1492
|
+
if (!init) continue;
|
|
1493
|
+
if (Node4.isStringLiteral(init)) {
|
|
1486
1494
|
const kind = classifyTypeKeyword(init.getLiteralValue());
|
|
1487
1495
|
if (kind) return { kind };
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1498
|
+
if (Node4.isIdentifier(init)) {
|
|
1499
|
+
const kind = classifyTypeKeyword(init.getText());
|
|
1500
|
+
if (kind) return { kind };
|
|
1488
1501
|
}
|
|
1489
1502
|
}
|
|
1490
1503
|
}
|
|
@@ -1496,12 +1509,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
|
|
|
1496
1509
|
function classifyFieldType(prop, sourceFile, project) {
|
|
1497
1510
|
let nullable = prop.hasQuestionToken();
|
|
1498
1511
|
const typeNode = prop.getTypeNode();
|
|
1512
|
+
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1499
1513
|
if (typeNode) {
|
|
1500
1514
|
const r = classifyTypeNode(typeNode, sourceFile, project);
|
|
1501
1515
|
if (r.nullable) nullable = true;
|
|
1502
|
-
if (r.kind !== "unknown")
|
|
1516
|
+
if (r.kind !== "unknown") {
|
|
1517
|
+
const conflicts = fromDecorator !== null && fromDecorator.kind !== "unknown" && fromDecorator.kind !== r.kind;
|
|
1518
|
+
if (conflicts) {
|
|
1519
|
+
return markNullable({ ...fromDecorator, valueKind: r.kind }, nullable);
|
|
1520
|
+
}
|
|
1521
|
+
return markNullable(r, nullable);
|
|
1522
|
+
}
|
|
1503
1523
|
}
|
|
1504
|
-
const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
|
|
1505
1524
|
if (fromDecorator) {
|
|
1506
1525
|
return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
|
|
1507
1526
|
}
|
|
@@ -1509,6 +1528,7 @@ function classifyFieldType(prop, sourceFile, project) {
|
|
|
1509
1528
|
}
|
|
1510
1529
|
function toFilterFieldType(name, r) {
|
|
1511
1530
|
const ft = { name, kind: r.kind };
|
|
1531
|
+
if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
|
|
1512
1532
|
if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
|
|
1513
1533
|
if (r.nullable) ft.nullable = true;
|
|
1514
1534
|
if (r.numericEnum) ft.numericEnum = true;
|
|
@@ -3314,7 +3334,7 @@ function kindToTs(kind, enumValues, numericEnum) {
|
|
|
3314
3334
|
}
|
|
3315
3335
|
function emitFieldTypesLiteral(fts) {
|
|
3316
3336
|
const entries = fts.map((f) => {
|
|
3317
|
-
let t = f.typeRef ? f.typeRef.name : kindToTs(f.kind, f.enumValues, f.numericEnum);
|
|
3337
|
+
let t = f.typeRef ? f.typeRef.name : kindToTs(f.valueKind ?? f.kind, f.enumValues, f.numericEnum);
|
|
3318
3338
|
if (f.nullable) t = `${t} | null`;
|
|
3319
3339
|
return `${JSON.stringify(f.name)}: ${t}`;
|
|
3320
3340
|
});
|
|
@@ -5235,7 +5255,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5235
5255
|
}
|
|
5236
5256
|
|
|
5237
5257
|
// src/index.ts
|
|
5238
|
-
var VERSION = "0.
|
|
5258
|
+
var VERSION = "0.24.0";
|
|
5239
5259
|
|
|
5240
5260
|
// src/cli/codegen.ts
|
|
5241
5261
|
async function runCodegen(opts = {}) {
|