@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/dist/cli/main.js CHANGED
@@ -1485,12 +1485,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
1485
1485
  return { kind: "string" };
1486
1486
  }
1487
1487
  }
1488
- const typeProp = arg.getProperty("type");
1489
- if (typeProp && Node4.isPropertyAssignment(typeProp)) {
1488
+ for (const key of ["columnType", "type"]) {
1489
+ const typeProp = arg.getProperty(key);
1490
+ if (!typeProp || !Node4.isPropertyAssignment(typeProp)) continue;
1490
1491
  const init = typeProp.getInitializer();
1491
- if (init && Node4.isStringLiteral(init)) {
1492
+ if (!init) continue;
1493
+ if (Node4.isStringLiteral(init)) {
1492
1494
  const kind = classifyTypeKeyword(init.getLiteralValue());
1493
1495
  if (kind) return { kind };
1496
+ continue;
1497
+ }
1498
+ if (Node4.isIdentifier(init)) {
1499
+ const kind = classifyTypeKeyword(init.getText());
1500
+ if (kind) return { kind };
1494
1501
  }
1495
1502
  }
1496
1503
  }
@@ -1502,12 +1509,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
1502
1509
  function classifyFieldType(prop, sourceFile, project) {
1503
1510
  let nullable = prop.hasQuestionToken();
1504
1511
  const typeNode = prop.getTypeNode();
1512
+ const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
1505
1513
  if (typeNode) {
1506
1514
  const r = classifyTypeNode(typeNode, sourceFile, project);
1507
1515
  if (r.nullable) nullable = true;
1508
- if (r.kind !== "unknown") return markNullable(r, nullable);
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
+ }
1509
1523
  }
1510
- const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
1511
1524
  if (fromDecorator) {
1512
1525
  return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
1513
1526
  }
@@ -1515,6 +1528,7 @@ function classifyFieldType(prop, sourceFile, project) {
1515
1528
  }
1516
1529
  function toFilterFieldType(name, r) {
1517
1530
  const ft = { name, kind: r.kind };
1531
+ if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
1518
1532
  if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
1519
1533
  if (r.nullable) ft.nullable = true;
1520
1534
  if (r.numericEnum) ft.numericEnum = true;
@@ -3320,7 +3334,7 @@ function kindToTs(kind, enumValues, numericEnum) {
3320
3334
  }
3321
3335
  function emitFieldTypesLiteral(fts) {
3322
3336
  const entries = fts.map((f) => {
3323
- 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);
3324
3338
  if (f.nullable) t = `${t} | null`;
3325
3339
  return `${JSON.stringify(f.name)}: ${t}`;
3326
3340
  });
@@ -5241,7 +5255,7 @@ async function watch(config, onChange, options = {}) {
5241
5255
  }
5242
5256
 
5243
5257
  // src/index.ts
5244
- var VERSION = "0.23.0";
5258
+ var VERSION = "0.24.0";
5245
5259
 
5246
5260
  // src/cli/codegen.ts
5247
5261
  async function runCodegen(opts = {}) {