@dudousxd/nestjs-codegen 0.22.1 → 0.23.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @dudousxd/nestjs-codegen
2
2
 
3
+ ## 0.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4b13eef: Classify through transparent type brands, so a MikroORM entity's columns stop coming back `unknown`.
8
+
9
+ `Opt<T>` is how MikroORM marks a column optional on insert, and it is how nearly every nullable column in a MikroORM entity is written. It is a compile-time marker with no runtime shape of its own — an `Opt<string>` column holds a string — but the classifier saw a type reference it did not recognise and answered `unknown`. On a real entity that meant 31 of 35 fields unclassified, including plain `Opt<string>` names; the four that worked were the two written as bare primitives and the two written `Date & Opt<Date>`, where the intersection happens to expose a type the classifier already knew.
10
+
11
+ That is not a cosmetic gap. `unknown` is indistinguishable from "the classifier could not tell", so every consumer that reads a kind — operator sets, a number/date gate, a UI picking a filter control from the column's type — has to fall back to permissive for an entity that had in fact declared its types perfectly well.
12
+
13
+ `Opt<T>` and `Hidden<T>` are now unwrapped to their argument, recursively, so `Opt<Hidden<number>>` is a number.
14
+
15
+ Deliberately a short allowlist rather than "unwrap any single-argument reference". `Ref<T>`, `Rel<T>`, `Collection<T>` and `IdentifiedReference<T>` are **not** transparent: their runtime value is a reference or a collection, not a `T`. Unwrapping those would classify a relation as whatever its target's shape happens to be — silently, and only visibly far downstream.
16
+
3
17
  ## 0.22.1
4
18
 
5
19
  ### Patch Changes
package/dist/cli/main.cjs CHANGED
@@ -1369,6 +1369,7 @@ function classifyTypeKeyword(raw) {
1369
1369
  function markNullable(r, nullable) {
1370
1370
  return nullable ? { ...r, nullable: true } : r;
1371
1371
  }
1372
+ var TRANSPARENT_TYPE_BRANDS = /* @__PURE__ */ new Set(["Opt", "Hidden"]);
1372
1373
  function classifyTypeNode(typeNode, sourceFile, project, opts) {
1373
1374
  if (import_ts_morph4.Node.isUnionTypeNode(typeNode)) {
1374
1375
  let nullable = false;
@@ -1427,6 +1428,11 @@ function classifyTypeNode(typeNode, sourceFile, project, opts) {
1427
1428
  const refName = typeNode.getTypeName().getText();
1428
1429
  if (refName === "Date") return { kind: "date" };
1429
1430
  if (refName === "Record" || refName === "Object") return { kind: "json" };
1431
+ const unwrapped = TRANSPARENT_TYPE_BRANDS.has(refName) ? typeNode.getTypeArguments()[0] : void 0;
1432
+ if (unwrapped) {
1433
+ const inner = classifyTypeNode(unwrapped, sourceFile, project, opts);
1434
+ return inner;
1435
+ }
1430
1436
  const typeRef = opts?.resolveRef?.(refName) ?? null;
1431
1437
  const en = resolveEnumValues(refName, sourceFile, project);
1432
1438
  if (en) {
@@ -5253,7 +5259,7 @@ async function watch(config, onChange, options = {}) {
5253
5259
  }
5254
5260
 
5255
5261
  // src/index.ts
5256
- var VERSION = "0.22.1";
5262
+ var VERSION = "0.23.0";
5257
5263
 
5258
5264
  // src/cli/codegen.ts
5259
5265
  async function runCodegen(opts = {}) {