@dudousxd/nestjs-codegen 0.5.1 → 0.5.2

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
@@ -2547,37 +2547,28 @@ function buildProperty(prop, classFile, ctx) {
2547
2547
  const typeNode = prop.getTypeNode();
2548
2548
  const typeText = typeNode?.getText() ?? "unknown";
2549
2549
  const isArrayType = !!typeNode && Node3.isArrayTypeNode(typeNode);
2550
+ const asField = (child) => applyPresence(
2551
+ has("IsArray") || isArrayType ? { kind: "array", element: child } : child,
2552
+ decorators
2553
+ );
2550
2554
  const discriminator = resolveDiscriminator(dec("Type"));
2551
2555
  if (discriminator) {
2552
2556
  const options = discriminator.subTypes.map(
2553
2557
  (name) => buildNestedReference(name, classFile, ctx)
2554
2558
  );
2555
- const unionNode = {
2556
- kind: "union",
2557
- options,
2558
- discriminator: discriminator.property
2559
- };
2560
- const wrapArray = has("IsArray") || isArrayType;
2561
- const node2 = wrapArray ? { kind: "array", element: unionNode } : unionNode;
2562
- return applyPresence(node2, decorators);
2559
+ return asField({ kind: "union", options, discriminator: discriminator.property });
2563
2560
  }
2564
2561
  const propTypeParam = singularClassName(typeText);
2565
2562
  if (propTypeParam && ctx.typeBindings.has(propTypeParam)) {
2566
2563
  const bound = ctx.typeBindings.get(propTypeParam);
2567
- const childNode = buildNestedReference(bound, classFile, ctx);
2568
- const wrapArray = has("IsArray") || isArrayType;
2569
- const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
2570
- return applyPresence(node2, decorators);
2564
+ return asField(buildNestedReference(bound, classFile, ctx));
2571
2565
  }
2572
2566
  const typeRefName = resolveTypeFactoryName(dec("Type"));
2573
2567
  if (has("ValidateNested") || typeRefName) {
2574
2568
  const typeArgs = genericTypeArgNames(typeNode);
2575
2569
  const childName = typeRefName ?? singularClassName(typeText);
2576
2570
  if (childName) {
2577
- const childNode = buildNestedReference(childName, classFile, ctx, typeArgs);
2578
- const wrapArray = has("IsArray") || isArrayType;
2579
- const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
2580
- return applyPresence(node2, decorators);
2571
+ return asField(buildNestedReference(childName, classFile, ctx, typeArgs));
2581
2572
  }
2582
2573
  }
2583
2574
  let base = baseFromType(typeText, isArrayType);
@@ -4438,7 +4429,7 @@ async function watch(config, onChange) {
4438
4429
  }
4439
4430
 
4440
4431
  // src/index.ts
4441
- var VERSION = "0.5.1";
4432
+ var VERSION = "0.5.2";
4442
4433
 
4443
4434
  // src/cli/codegen.ts
4444
4435
  async function runCodegen(opts = {}) {