@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.
@@ -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-BsptKWwz.cjs';
3
+ import { U as UserConfig } from '../index-Ce3YnfwS.cjs';
4
4
  import 'ts-morph';
5
5
 
6
6
  /**
@@ -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-BsptKWwz.js';
3
+ import { U as UserConfig } from '../index-Ce3YnfwS.js';
4
4
  import 'ts-morph';
5
5
 
6
6
  /**
@@ -1109,12 +1109,19 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
1109
1109
  return { kind: "string" };
1110
1110
  }
1111
1111
  }
1112
- const typeProp = arg.getProperty("type");
1113
- if (typeProp && Node3.isPropertyAssignment(typeProp)) {
1112
+ for (const key of ["columnType", "type"]) {
1113
+ const typeProp = arg.getProperty(key);
1114
+ if (!typeProp || !Node3.isPropertyAssignment(typeProp)) continue;
1114
1115
  const init = typeProp.getInitializer();
1115
- if (init && Node3.isStringLiteral(init)) {
1116
+ if (!init) continue;
1117
+ if (Node3.isStringLiteral(init)) {
1116
1118
  const kind = classifyTypeKeyword(init.getLiteralValue());
1117
1119
  if (kind) return { kind };
1120
+ continue;
1121
+ }
1122
+ if (Node3.isIdentifier(init)) {
1123
+ const kind = classifyTypeKeyword(init.getText());
1124
+ if (kind) return { kind };
1118
1125
  }
1119
1126
  }
1120
1127
  }
@@ -1126,12 +1133,18 @@ function classifyFromColumnDecorator(prop, sourceFile, project) {
1126
1133
  function classifyFieldType(prop, sourceFile, project) {
1127
1134
  let nullable = prop.hasQuestionToken();
1128
1135
  const typeNode = prop.getTypeNode();
1136
+ const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
1129
1137
  if (typeNode) {
1130
1138
  const r = classifyTypeNode(typeNode, sourceFile, project);
1131
1139
  if (r.nullable) nullable = true;
1132
- if (r.kind !== "unknown") return markNullable(r, nullable);
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
+ }
1133
1147
  }
1134
- const fromDecorator = classifyFromColumnDecorator(prop, sourceFile, project);
1135
1148
  if (fromDecorator) {
1136
1149
  return markNullable(fromDecorator, nullable || fromDecorator.nullable === true);
1137
1150
  }
@@ -1139,6 +1152,7 @@ function classifyFieldType(prop, sourceFile, project) {
1139
1152
  }
1140
1153
  function toFilterFieldType(name, r) {
1141
1154
  const ft = { name, kind: r.kind };
1155
+ if (r.valueKind && r.valueKind !== r.kind) ft.valueKind = r.valueKind;
1142
1156
  if (r.enumValues && r.enumValues.length > 0) ft.enumValues = r.enumValues;
1143
1157
  if (r.nullable) ft.nullable = true;
1144
1158
  if (r.numericEnum) ft.numericEnum = true;
@@ -3259,7 +3273,7 @@ function kindToTs(kind, enumValues, numericEnum) {
3259
3273
  }
3260
3274
  function emitFieldTypesLiteral(fts) {
3261
3275
  const entries = fts.map((f) => {
3262
- 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);
3263
3277
  if (f.nullable) t = `${t} | null`;
3264
3278
  return `${JSON.stringify(f.name)}: ${t}`;
3265
3279
  });
@@ -5022,7 +5036,7 @@ async function watch(config, onChange, options = {}) {
5022
5036
  }
5023
5037
 
5024
5038
  // src/index.ts
5025
- var VERSION = "0.23.0";
5039
+ var VERSION = "0.24.0";
5026
5040
 
5027
5041
  // src/generate-manifest.ts
5028
5042
  var MANIFEST_FILE = ".codegen-manifest.json";