@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.
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy } from '@nestjs/common';
2
- import { U as UserConfig } from '../index-B0mS84Jj.cjs';
2
+ import { U as UserConfig } from '../index-_qRai4M3.cjs';
3
3
  import 'ts-morph';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule, OnApplicationBootstrap, OnModuleDestroy } from '@nestjs/common';
2
- import { U as UserConfig } from '../index-B0mS84Jj.js';
2
+ import { U as UserConfig } from '../index-_qRai4M3.js';
3
3
  import 'ts-morph';
4
4
 
5
5
  /**
@@ -558,37 +558,28 @@ function buildProperty(prop, classFile, ctx) {
558
558
  const typeNode = prop.getTypeNode();
559
559
  const typeText = typeNode?.getText() ?? "unknown";
560
560
  const isArrayType = !!typeNode && Node2.isArrayTypeNode(typeNode);
561
+ const asField = (child) => applyPresence(
562
+ has("IsArray") || isArrayType ? { kind: "array", element: child } : child,
563
+ decorators
564
+ );
561
565
  const discriminator = resolveDiscriminator(dec("Type"));
562
566
  if (discriminator) {
563
567
  const options = discriminator.subTypes.map(
564
568
  (name) => buildNestedReference(name, classFile, ctx)
565
569
  );
566
- const unionNode = {
567
- kind: "union",
568
- options,
569
- discriminator: discriminator.property
570
- };
571
- const wrapArray = has("IsArray") || isArrayType;
572
- const node2 = wrapArray ? { kind: "array", element: unionNode } : unionNode;
573
- return applyPresence(node2, decorators);
570
+ return asField({ kind: "union", options, discriminator: discriminator.property });
574
571
  }
575
572
  const propTypeParam = singularClassName(typeText);
576
573
  if (propTypeParam && ctx.typeBindings.has(propTypeParam)) {
577
574
  const bound = ctx.typeBindings.get(propTypeParam);
578
- const childNode = buildNestedReference(bound, classFile, ctx);
579
- const wrapArray = has("IsArray") || isArrayType;
580
- const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
581
- return applyPresence(node2, decorators);
575
+ return asField(buildNestedReference(bound, classFile, ctx));
582
576
  }
583
577
  const typeRefName = resolveTypeFactoryName(dec("Type"));
584
578
  if (has("ValidateNested") || typeRefName) {
585
579
  const typeArgs = genericTypeArgNames(typeNode);
586
580
  const childName = typeRefName ?? singularClassName(typeText);
587
581
  if (childName) {
588
- const childNode = buildNestedReference(childName, classFile, ctx, typeArgs);
589
- const wrapArray = has("IsArray") || isArrayType;
590
- const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
591
- return applyPresence(node2, decorators);
582
+ return asField(buildNestedReference(childName, classFile, ctx, typeArgs));
592
583
  }
593
584
  }
594
585
  let base = baseFromType(typeText, isArrayType);