@dudousxd/nestjs-codegen 0.17.1 → 0.17.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.
@@ -2257,7 +2257,7 @@ import {
2257
2257
 
2258
2258
  // src/discovery/dto-type-resolver.ts
2259
2259
  import {
2260
- Node as Node6,
2260
+ Node as Node7,
2261
2261
  SyntaxKind as SyntaxKind3
2262
2262
  } from "ts-morph";
2263
2263
 
@@ -3020,7 +3020,7 @@ function inSchemaFromDecorator(decorator) {
3020
3020
 
3021
3021
  // src/discovery/filter-for.ts
3022
3022
  import {
3023
- Node as Node5
3023
+ Node as Node6
3024
3024
  } from "ts-morph";
3025
3025
 
3026
3026
  // src/discovery/filter-field-types.ts
@@ -3243,6 +3243,123 @@ function toFilterFieldType(name, r) {
3243
3243
  return ft;
3244
3244
  }
3245
3245
 
3246
+ // src/discovery/heritage.ts
3247
+ import { Node as Node5, Project as Project3 } from "ts-morph";
3248
+ function resolveHeritageCall(node) {
3249
+ if (!node) return void 0;
3250
+ const expr = unwrapExpression(node);
3251
+ if (Node5.isCallExpression(expr)) return expr;
3252
+ if (!Node5.isIdentifier(expr)) return void 0;
3253
+ const decl = expr.getDefinitions().map((d) => d.getDeclarationNode()).find(
3254
+ (n) => n !== void 0 && Node5.isVariableDeclaration(n)
3255
+ );
3256
+ const init = decl?.getInitializer();
3257
+ if (!init) return void 0;
3258
+ const unwrapped = unwrapExpression(init);
3259
+ return Node5.isCallExpression(unwrapped) ? unwrapped : void 0;
3260
+ }
3261
+ function unwrapExpression(node) {
3262
+ let current = node;
3263
+ while (Node5.isAsExpression(current) || Node5.isSatisfiesExpression(current) || Node5.isParenthesizedExpression(current) || Node5.isTypeAssertion(current)) {
3264
+ current = current.getExpression();
3265
+ }
3266
+ return current;
3267
+ }
3268
+ function resolveReturnedClass(factoryDecl) {
3269
+ const body = factoryDecl.getBody();
3270
+ if (!body) return void 0;
3271
+ const returns = body.getDescendants().filter((n) => Node5.isReturnStatement(n));
3272
+ for (const ret of returns) {
3273
+ const expr = ret.getExpression();
3274
+ if (!expr) continue;
3275
+ const inner = unwrapExpression(expr);
3276
+ if (Node5.isClassExpression(inner)) {
3277
+ return inner;
3278
+ }
3279
+ if (Node5.isIdentifier(inner)) {
3280
+ const name = inner.getText();
3281
+ const decl = body.getDescendants().find((n) => Node5.isClassDeclaration(n) && n.getName() === name);
3282
+ if (decl) return decl;
3283
+ }
3284
+ }
3285
+ return void 0;
3286
+ }
3287
+ function resolveFactoryDeclaration(call) {
3288
+ const callee = call.getExpression();
3289
+ if (!Node5.isIdentifier(callee)) return void 0;
3290
+ return callee.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => Node5.isFunctionDeclaration(n));
3291
+ }
3292
+ function resolveFactoryStaticClass(node) {
3293
+ if (!Node5.isPropertyAccessExpression(node)) return void 0;
3294
+ const call = resolveHeritageCall(node.getExpression());
3295
+ if (!call) return void 0;
3296
+ const factoryDecl = resolveFactoryDeclaration(call);
3297
+ if (!factoryDecl) return void 0;
3298
+ const returnedClass = resolveReturnedClass(factoryDecl);
3299
+ if (!returnedClass) return void 0;
3300
+ const staticProp = returnedClass.getStaticProperties().find((p) => p.getName() === node.getName());
3301
+ if (!staticProp || !Node5.isPropertyDeclaration(staticProp)) return void 0;
3302
+ const init = staticProp.getInitializer();
3303
+ if (!init) return void 0;
3304
+ const inner = unwrapExpression(init);
3305
+ if (Node5.isClassExpression(inner)) return inner;
3306
+ if (!Node5.isIdentifier(inner)) return void 0;
3307
+ return inner.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && Node5.isClassDeclaration(n));
3308
+ }
3309
+ function resolveInheritedMethods(cls) {
3310
+ const expr = resolveHeritageCall(cls.getExtends()?.getExpression());
3311
+ if (!expr) return void 0;
3312
+ const callee = expr.getExpression();
3313
+ if (!Node5.isIdentifier(callee)) return void 0;
3314
+ const factoryDecl = resolveFactoryDeclaration(expr);
3315
+ if (!factoryDecl) return void 0;
3316
+ const returnedClass = resolveReturnedClass(factoryDecl);
3317
+ if (!returnedClass) return void 0;
3318
+ const classArgs = [];
3319
+ for (const arg of expr.getArguments()) {
3320
+ if (!Node5.isIdentifier(arg)) continue;
3321
+ const decl = arg.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => Node5.isClassDeclaration(n));
3322
+ if (decl) {
3323
+ classArgs.push({
3324
+ name: decl.getName() ?? arg.getText(),
3325
+ filePath: decl.getSourceFile().getFilePath()
3326
+ });
3327
+ }
3328
+ }
3329
+ return {
3330
+ methods: returnedClass.getMethods(),
3331
+ factoryName: callee.getText(),
3332
+ factoryFilePath: factoryDecl.getSourceFile().getFilePath(),
3333
+ classArgs
3334
+ };
3335
+ }
3336
+ var mixinTypeProject;
3337
+ function getMixinTypeProject() {
3338
+ mixinTypeProject ??= new Project3({
3339
+ skipAddingFilesFromTsConfig: true,
3340
+ compilerOptions: { strict: true }
3341
+ });
3342
+ return mixinTypeProject;
3343
+ }
3344
+ function clearMixinTypeProject() {
3345
+ mixinTypeProject = void 0;
3346
+ }
3347
+ function resolveInstantiatedReturnType(cls, methodName) {
3348
+ const filePath = cls.getSourceFile().getFilePath();
3349
+ const className = cls.getName();
3350
+ if (!className) return void 0;
3351
+ const project = getMixinTypeProject();
3352
+ const sourceFile = project.getSourceFile(filePath) ?? project.addSourceFileAtPathIfExists(filePath);
3353
+ const typedCls = sourceFile?.getClass(className);
3354
+ if (!typedCls) return void 0;
3355
+ const prop = typedCls.getType().getProperty(methodName);
3356
+ if (!prop) return void 0;
3357
+ const returnType = prop.getTypeAtLocation(typedCls).getCallSignatures()[0]?.getReturnType();
3358
+ if (!returnType) return void 0;
3359
+ const unwrapped = returnType.getSymbol()?.getName() === "Promise" ? returnType.getTypeArguments()[0] ?? returnType : returnType;
3360
+ return unwrapped.getText(typedCls);
3361
+ }
3362
+
3246
3363
  // src/discovery/filter-for.ts
3247
3364
  function resolveMixinEntityClass(mixin, project) {
3248
3365
  const entityArg = mixin?.classArgs[0];
@@ -3251,7 +3368,7 @@ function resolveMixinEntityClass(mixin, project) {
3251
3368
  return file?.getClass(entityArg.name);
3252
3369
  }
3253
3370
  function classifyFilterForHint(typeInit) {
3254
- if (Node5.isStringLiteral(typeInit)) {
3371
+ if (Node6.isStringLiteral(typeInit)) {
3255
3372
  switch (typeInit.getLiteralValue()) {
3256
3373
  case "string":
3257
3374
  return { kind: "string" };
@@ -3265,10 +3382,10 @@ function classifyFilterForHint(typeInit) {
3265
3382
  return null;
3266
3383
  }
3267
3384
  }
3268
- if (Node5.isArrayLiteralExpression(typeInit)) {
3385
+ if (Node6.isArrayLiteralExpression(typeInit)) {
3269
3386
  const values = [];
3270
3387
  for (const el of typeInit.getElements()) {
3271
- if (!Node5.isStringLiteral(el)) return null;
3388
+ if (!Node6.isStringLiteral(el)) return null;
3272
3389
  values.push(el.getLiteralValue());
3273
3390
  }
3274
3391
  if (values.length === 0) return null;
@@ -3303,11 +3420,11 @@ function extractFilterForHints(classDecl, project) {
3303
3420
  if (!filterForDec) continue;
3304
3421
  const args = filterForDec.getArguments();
3305
3422
  const keyArg = args[0];
3306
- const inputKey = keyArg && Node5.isStringLiteral(keyArg) ? keyArg.getLiteralValue() : method.getName();
3423
+ const inputKey = keyArg && Node6.isStringLiteral(keyArg) ? keyArg.getLiteralValue() : method.getName();
3307
3424
  const optsArg = args[1];
3308
- if (optsArg && Node5.isObjectLiteralExpression(optsArg)) {
3425
+ if (optsArg && Node6.isObjectLiteralExpression(optsArg)) {
3309
3426
  const typeProp = optsArg.getProperty("type");
3310
- if (typeProp && Node5.isPropertyAssignment(typeProp)) {
3427
+ if (typeProp && Node6.isPropertyAssignment(typeProp)) {
3311
3428
  const typeInit = typeProp.getInitializer();
3312
3429
  if (typeInit) {
3313
3430
  const classified = classifyFilterForHint(typeInit);
@@ -3332,21 +3449,23 @@ function extractApplyFilterInfo(method, sourceFile, project, mixin) {
3332
3449
  const args = filterDecorator.getArguments();
3333
3450
  if (args.length === 0) continue;
3334
3451
  const filterClassArg = args[0];
3335
- if (!filterClassArg || !Node5.isIdentifier(filterClassArg)) continue;
3452
+ if (!filterClassArg) continue;
3453
+ const factoryStaticClass = resolveFactoryStaticClass(filterClassArg);
3454
+ if (!factoryStaticClass && !Node6.isIdentifier(filterClassArg)) continue;
3336
3455
  let source = "query";
3337
3456
  const optionsArg = args[1];
3338
- if (optionsArg && Node5.isObjectLiteralExpression(optionsArg)) {
3457
+ if (optionsArg && Node6.isObjectLiteralExpression(optionsArg)) {
3339
3458
  const sourceProp = optionsArg.getProperty("source");
3340
- if (sourceProp && Node5.isPropertyAssignment(sourceProp)) {
3459
+ if (sourceProp && Node6.isPropertyAssignment(sourceProp)) {
3341
3460
  const init = sourceProp.getInitializer();
3342
- if (init && Node5.isStringLiteral(init) && init.getLiteralValue() === "body") {
3461
+ if (init && Node6.isStringLiteral(init) && init.getLiteralValue() === "body") {
3343
3462
  source = "body";
3344
3463
  }
3345
3464
  }
3346
3465
  }
3347
3466
  const filterClassName = filterClassArg.getText();
3348
- const resolved = findType(filterClassName, declFile, project);
3349
- const classDecl = resolved?.kind === "class" ? resolved.decl : resolveLocalClassDeclaration(filterClassArg);
3467
+ const resolved = factoryStaticClass ? void 0 : findType(filterClassName, declFile, project);
3468
+ const classDecl = factoryStaticClass ?? (resolved?.kind === "class" ? resolved.decl : resolveLocalClassDeclaration(filterClassArg));
3350
3469
  if (classDecl) {
3351
3470
  let fieldTypes = extractClassPropertyTypes(classDecl, project);
3352
3471
  if (fieldTypes.length === 0) {
@@ -3402,22 +3521,22 @@ function resolveRelationEntity(prop, sourceFile, project) {
3402
3521
  const args = dec.getArguments();
3403
3522
  if (args.length === 0) continue;
3404
3523
  const arg = args[0];
3405
- if (Node5.isObjectLiteralExpression(arg)) {
3524
+ if (Node6.isObjectLiteralExpression(arg)) {
3406
3525
  const entityProp = arg.getProperty("entity");
3407
- if (entityProp && Node5.isPropertyAssignment(entityProp)) {
3526
+ if (entityProp && Node6.isPropertyAssignment(entityProp)) {
3408
3527
  const init = entityProp.getInitializer();
3409
- if (init && Node5.isArrowFunction(init)) {
3528
+ if (init && Node6.isArrowFunction(init)) {
3410
3529
  const body = init.getBody();
3411
- if (Node5.isIdentifier(body)) {
3530
+ if (Node6.isIdentifier(body)) {
3412
3531
  const resolved = findType(body.getText(), prop.getSourceFile(), project);
3413
3532
  if (resolved?.kind === "class") return resolved.decl;
3414
3533
  }
3415
3534
  }
3416
3535
  }
3417
3536
  }
3418
- if (Node5.isArrowFunction(arg)) {
3537
+ if (Node6.isArrowFunction(arg)) {
3419
3538
  const body = arg.getBody();
3420
- if (Node5.isIdentifier(body)) {
3539
+ if (Node6.isIdentifier(body)) {
3421
3540
  const resolved = findType(body.getText(), prop.getSourceFile(), project);
3422
3541
  if (resolved?.kind === "class") return resolved.decl;
3423
3542
  }
@@ -3436,15 +3555,15 @@ function extractClassPropertyTypes(classDecl, project) {
3436
3555
  return fields;
3437
3556
  }
3438
3557
  function resolveLocalClassDeclaration(identifier) {
3439
- if (!Node5.isIdentifier(identifier)) return void 0;
3440
- return identifier.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && Node5.isClassDeclaration(n));
3558
+ if (!Node6.isIdentifier(identifier)) return void 0;
3559
+ return identifier.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && Node6.isClassDeclaration(n));
3441
3560
  }
3442
3561
  function resolveDeclaredEntity(optionsArg, filterClass, project) {
3443
- if (!Node5.isObjectLiteralExpression(optionsArg)) return void 0;
3562
+ if (!Node6.isObjectLiteralExpression(optionsArg)) return void 0;
3444
3563
  const entityProp = optionsArg.getProperty("entity");
3445
- if (!entityProp || !Node5.isPropertyAssignment(entityProp)) return void 0;
3564
+ if (!entityProp || !Node6.isPropertyAssignment(entityProp)) return void 0;
3446
3565
  const entityInit = entityProp.getInitializer();
3447
- if (!entityInit || !Node5.isIdentifier(entityInit)) return void 0;
3566
+ if (!entityInit || !Node6.isIdentifier(entityInit)) return void 0;
3448
3567
  const resolved = findType(entityInit.getText(), filterClass.getSourceFile(), project);
3449
3568
  if (!resolved || resolved.kind !== "class") return void 0;
3450
3569
  return resolved.decl;
@@ -3455,7 +3574,7 @@ function extractFilterableEntityFields(filterClass, project, entityOverride) {
3455
3574
  const args = filterableDecorator.getArguments();
3456
3575
  if (args.length === 0) return [];
3457
3576
  const optionsArg = args[0];
3458
- if (!Node5.isObjectLiteralExpression(optionsArg)) return [];
3577
+ if (!Node6.isObjectLiteralExpression(optionsArg)) return [];
3459
3578
  const entityDecl = entityOverride ?? resolveDeclaredEntity(optionsArg, filterClass, project);
3460
3579
  if (!entityDecl) return [];
3461
3580
  const fields = collectEntityFields(
@@ -3468,17 +3587,17 @@ function extractFilterableEntityFields(filterClass, project, entityOverride) {
3468
3587
  const relationsDecorator = filterClass.getDecorators().find((d) => d.getName() === "Relations");
3469
3588
  if (relationsDecorator) {
3470
3589
  const relArgs = relationsDecorator.getArguments();
3471
- if (relArgs.length > 0 && Node5.isObjectLiteralExpression(relArgs[0])) {
3590
+ if (relArgs.length > 0 && Node6.isObjectLiteralExpression(relArgs[0])) {
3472
3591
  for (const relProp of relArgs[0].getProperties()) {
3473
- if (!Node5.isPropertyAssignment(relProp)) continue;
3592
+ if (!Node6.isPropertyAssignment(relProp)) continue;
3474
3593
  const relInit = relProp.getInitializer();
3475
- if (!relInit || !Node5.isObjectLiteralExpression(relInit)) continue;
3594
+ if (!relInit || !Node6.isObjectLiteralExpression(relInit)) continue;
3476
3595
  const keysProp = relInit.getProperty("keys");
3477
- if (!keysProp || !Node5.isPropertyAssignment(keysProp)) continue;
3596
+ if (!keysProp || !Node6.isPropertyAssignment(keysProp)) continue;
3478
3597
  const keysInit = keysProp.getInitializer();
3479
- if (!keysInit || !Node5.isArrayLiteralExpression(keysInit)) continue;
3598
+ if (!keysInit || !Node6.isArrayLiteralExpression(keysInit)) continue;
3480
3599
  for (const el of keysInit.getElements()) {
3481
- if (Node5.isStringLiteral(el)) {
3600
+ if (Node6.isStringLiteral(el)) {
3482
3601
  fields.push(toFilterFieldType(el.getLiteralValue(), { kind: "unknown" }));
3483
3602
  }
3484
3603
  }
@@ -3519,22 +3638,22 @@ var PASSTHROUGH_UTILITY = /* @__PURE__ */ new Set([
3519
3638
  ]);
3520
3639
  function resolveTypeNodeToString(typeNode, sourceFile, project, depth, subst = /* @__PURE__ */ new Map()) {
3521
3640
  if (depth <= 0) return "unknown";
3522
- if (Node6.isArrayTypeNode(typeNode)) {
3641
+ if (Node7.isArrayTypeNode(typeNode)) {
3523
3642
  const elementType = typeNode.getElementTypeNode();
3524
3643
  return `Array<${resolveTypeNodeToString(elementType, sourceFile, project, depth, subst)}>`;
3525
3644
  }
3526
- if (Node6.isUnionTypeNode(typeNode)) {
3645
+ if (Node7.isUnionTypeNode(typeNode)) {
3527
3646
  return typeNode.getTypeNodes().map((t) => resolveTypeNodeToString(t, sourceFile, project, depth, subst)).join(" | ");
3528
3647
  }
3529
- if (Node6.isIntersectionTypeNode(typeNode)) {
3648
+ if (Node7.isIntersectionTypeNode(typeNode)) {
3530
3649
  return typeNode.getTypeNodes().map((t) => resolveTypeNodeToString(t, sourceFile, project, depth, subst)).join(" & ");
3531
3650
  }
3532
- if (Node6.isParenthesizedTypeNode(typeNode)) {
3651
+ if (Node7.isParenthesizedTypeNode(typeNode)) {
3533
3652
  return `(${resolveTypeNodeToString(typeNode.getTypeNode(), sourceFile, project, depth, subst)})`;
3534
3653
  }
3535
- if (Node6.isTypeReference(typeNode)) {
3654
+ if (Node7.isTypeReference(typeNode)) {
3536
3655
  const typeName = typeNode.getTypeName();
3537
- const name = Node6.isIdentifier(typeName) ? typeName.getText() : typeNode.getText();
3656
+ const name = Node7.isIdentifier(typeName) ? typeName.getText() : typeNode.getText();
3538
3657
  const bound = subst.get(name);
3539
3658
  if (bound !== void 0) return bound;
3540
3659
  if (name === "string" || name === "number" || name === "boolean") return name;
@@ -3557,10 +3676,10 @@ function resolveTypeNodeToString(typeNode, sourceFile, project, depth, subst = /
3557
3676
  dbg("unresolvable type:", name, "in", sourceFile.getFilePath());
3558
3677
  return "unknown";
3559
3678
  }
3560
- if (Node6.isTypeLiteral(typeNode)) {
3679
+ if (Node7.isTypeLiteral(typeNode)) {
3561
3680
  const members = [];
3562
3681
  for (const member of typeNode.getMembers()) {
3563
- if (Node6.isPropertySignature(member)) {
3682
+ if (Node7.isPropertySignature(member)) {
3564
3683
  const memberTypeNode = member.getTypeNode();
3565
3684
  const memberType = memberTypeNode ? resolveTypeNodeToString(memberTypeNode, sourceFile, project, depth, subst) : "unknown";
3566
3685
  members.push(`${member.getName()}${member.hasQuestionToken() ? "?" : ""}: ${memberType}`);
@@ -3660,7 +3779,7 @@ function extractQueryType(method, sourceFile, project) {
3660
3779
  if (!queryDecorator) continue;
3661
3780
  const queryArgs = queryDecorator.getArguments();
3662
3781
  const nameArg = queryArgs[0];
3663
- if (!nameArg || !Node6.isStringLiteral(nameArg)) continue;
3782
+ if (!nameArg || !Node7.isStringLiteral(nameArg)) continue;
3664
3783
  const queryName = nameArg.getLiteralValue();
3665
3784
  const typeNode = param.getTypeNode();
3666
3785
  const queryType = typeNode ? resolveTypeNodeToString(typeNode, sourceFile, project, 3) : "string";
@@ -3671,7 +3790,7 @@ function extractQueryType(method, sourceFile, project) {
3671
3790
  function isParamOptional(param) {
3672
3791
  if (param.hasQuestionToken() || param.hasInitializer()) return true;
3673
3792
  const typeNode = param.getTypeNode();
3674
- if (typeNode && Node6.isUnionTypeNode(typeNode)) {
3793
+ if (typeNode && Node7.isUnionTypeNode(typeNode)) {
3675
3794
  return typeNode.getTypeNodes().some((t) => t.getKind() === SyntaxKind3.UndefinedKeyword);
3676
3795
  }
3677
3796
  return false;
@@ -3684,7 +3803,7 @@ function extractParamsType(method, sourceFile, project) {
3684
3803
  const paramArgs = paramDecorator.getArguments();
3685
3804
  if (paramArgs.length === 0) continue;
3686
3805
  const nameArg = paramArgs[0];
3687
- if (!Node6.isStringLiteral(nameArg)) continue;
3806
+ if (!Node7.isStringLiteral(nameArg)) continue;
3688
3807
  const paramName = nameArg.getLiteralValue();
3689
3808
  const typeNode = param.getTypeNode();
3690
3809
  const paramType = typeNode ? resolveTypeNodeToString(typeNode, sourceFile, project, 3) : "string";
@@ -3705,28 +3824,28 @@ function extractUploadedFiles(method) {
3705
3824
  for (const decorator of method.getDecorators()) {
3706
3825
  if (decorator.getName() !== "UseInterceptors") continue;
3707
3826
  for (const arg of decorator.getArguments()) {
3708
- if (!Node6.isCallExpression(arg)) continue;
3827
+ if (!Node7.isCallExpression(arg)) continue;
3709
3828
  const interceptor = arg.getExpression().getText();
3710
3829
  const callArgs = arg.getArguments();
3711
3830
  const firstArg2 = callArgs[0];
3712
3831
  if (interceptor === "FileInterceptor") {
3713
- if (firstArg2 && Node6.isStringLiteral(firstArg2)) {
3832
+ if (firstArg2 && Node7.isStringLiteral(firstArg2)) {
3714
3833
  entries.push(`${firstArg2.getLiteralValue()}: ${FILE}`);
3715
3834
  multipart = true;
3716
3835
  }
3717
3836
  } else if (interceptor === "FilesInterceptor") {
3718
- if (firstArg2 && Node6.isStringLiteral(firstArg2)) {
3837
+ if (firstArg2 && Node7.isStringLiteral(firstArg2)) {
3719
3838
  entries.push(`${firstArg2.getLiteralValue()}: Array<${FILE}>`);
3720
3839
  multipart = true;
3721
3840
  }
3722
3841
  } else if (interceptor === "FileFieldsInterceptor") {
3723
- if (firstArg2 && Node6.isArrayLiteralExpression(firstArg2)) {
3842
+ if (firstArg2 && Node7.isArrayLiteralExpression(firstArg2)) {
3724
3843
  for (const el of firstArg2.getElements()) {
3725
- if (!Node6.isObjectLiteralExpression(el)) continue;
3844
+ if (!Node7.isObjectLiteralExpression(el)) continue;
3726
3845
  const nameProp = el.getProperty("name");
3727
- if (nameProp && Node6.isPropertyAssignment(nameProp)) {
3846
+ if (nameProp && Node7.isPropertyAssignment(nameProp)) {
3728
3847
  const init = nameProp.getInitializer();
3729
- if (init && Node6.isStringLiteral(init)) {
3848
+ if (init && Node7.isStringLiteral(init)) {
3730
3849
  entries.push(`${init.getLiteralValue()}: Array<${FILE}>`);
3731
3850
  }
3732
3851
  }
@@ -3746,13 +3865,13 @@ function extractResponseType(method, sourceFile, project) {
3746
3865
  if (apiResponseDecorator) {
3747
3866
  const args = apiResponseDecorator.getArguments();
3748
3867
  const optsArg = args[0];
3749
- if (optsArg && Node6.isObjectLiteralExpression(optsArg)) {
3868
+ if (optsArg && Node7.isObjectLiteralExpression(optsArg)) {
3750
3869
  for (const prop of optsArg.getProperties()) {
3751
- if (!Node6.isPropertyAssignment(prop)) continue;
3870
+ if (!Node7.isPropertyAssignment(prop)) continue;
3752
3871
  if (prop.getName() !== "type") continue;
3753
3872
  const val = prop.getInitializer();
3754
3873
  if (!val) continue;
3755
- if (Node6.isArrayLiteralExpression(val)) {
3874
+ if (Node7.isArrayLiteralExpression(val)) {
3756
3875
  const elements = val.getElements();
3757
3876
  const firstEl = elements[0];
3758
3877
  if (elements.length > 0 && firstEl !== void 0) {
@@ -3773,24 +3892,24 @@ function extractResponseType(method, sourceFile, project) {
3773
3892
  }
3774
3893
  function apiResponseStatus(decorator) {
3775
3894
  const optsArg = decorator.getArguments()[0];
3776
- if (!optsArg || !Node6.isObjectLiteralExpression(optsArg)) return null;
3895
+ if (!optsArg || !Node7.isObjectLiteralExpression(optsArg)) return null;
3777
3896
  for (const prop of optsArg.getProperties()) {
3778
- if (!Node6.isPropertyAssignment(prop)) continue;
3897
+ if (!Node7.isPropertyAssignment(prop)) continue;
3779
3898
  if (prop.getName() !== "status") continue;
3780
3899
  const val = prop.getInitializer();
3781
- if (val && Node6.isNumericLiteral(val)) return Number(val.getLiteralValue());
3900
+ if (val && Node7.isNumericLiteral(val)) return Number(val.getLiteralValue());
3782
3901
  }
3783
3902
  return null;
3784
3903
  }
3785
3904
  function apiResponseTypeNode(decorator) {
3786
3905
  const optsArg = decorator.getArguments()[0];
3787
- if (!optsArg || !Node6.isObjectLiteralExpression(optsArg)) return null;
3906
+ if (!optsArg || !Node7.isObjectLiteralExpression(optsArg)) return null;
3788
3907
  for (const prop of optsArg.getProperties()) {
3789
- if (!Node6.isPropertyAssignment(prop)) continue;
3908
+ if (!Node7.isPropertyAssignment(prop)) continue;
3790
3909
  if (prop.getName() !== "type") continue;
3791
3910
  const val = prop.getInitializer();
3792
3911
  if (!val) return null;
3793
- if (Node6.isArrayLiteralExpression(val)) {
3912
+ if (Node7.isArrayLiteralExpression(val)) {
3794
3913
  const first = val.getElements()[0];
3795
3914
  return first ? { node: first, isArray: true } : null;
3796
3915
  }
@@ -3808,7 +3927,7 @@ function extractErrorType(method, sourceFile, project) {
3808
3927
  const inner = resolveIdentifierToClassType(typeInfo.node, sourceFile, project, 3);
3809
3928
  const type = typeInfo.isArray ? `Array<${inner}>` : inner;
3810
3929
  let ref = null;
3811
- if (Node6.isIdentifier(typeInfo.node)) {
3930
+ if (Node7.isIdentifier(typeInfo.node)) {
3812
3931
  const name = typeInfo.node.getText();
3813
3932
  const localDecl = sourceFile.getInterface(name) || sourceFile.getClass(name) || sourceFile.getTypeAlias(name);
3814
3933
  if (localDecl?.isExported()) {
@@ -3825,7 +3944,7 @@ function extractErrorType(method, sourceFile, project) {
3825
3944
  return null;
3826
3945
  }
3827
3946
  function resolveIdentifierToClassType(node, sourceFile, project, depth) {
3828
- if (!Node6.isIdentifier(node)) return "unknown";
3947
+ if (!Node7.isIdentifier(node)) return "unknown";
3829
3948
  const name = node.getText();
3830
3949
  const resolved = findType(name, sourceFile, project);
3831
3950
  if (resolved) {
@@ -3845,9 +3964,9 @@ var STREAM_ENVELOPES = /* @__PURE__ */ new Set(["MessageEvent", "MessageEventLik
3845
3964
  var BINARY_RESPONSE_TYPES = /* @__PURE__ */ new Set(["StreamableFile", "Buffer"]);
3846
3965
  function detectBinaryResponse(method) {
3847
3966
  const node = unwrapNamedContainer(method.getReturnTypeNode(), /* @__PURE__ */ new Set(["Promise"]));
3848
- if (!node || !Node6.isTypeReference(node)) return false;
3967
+ if (!node || !Node7.isTypeReference(node)) return false;
3849
3968
  const typeName = node.getTypeName();
3850
- const name = Node6.isIdentifier(typeName) ? typeName.getText() : "";
3969
+ const name = Node7.isIdentifier(typeName) ? typeName.getText() : "";
3851
3970
  return BINARY_RESPONSE_TYPES.has(name);
3852
3971
  }
3853
3972
  function detectStreamElement(method) {
@@ -3862,9 +3981,9 @@ function detectStreamElement(method) {
3862
3981
  return null;
3863
3982
  }
3864
3983
  function streamContainerElement(node) {
3865
- if (!node || !Node6.isTypeReference(node)) return null;
3984
+ if (!node || !Node7.isTypeReference(node)) return null;
3866
3985
  const typeName = node.getTypeName();
3867
- const name = Node6.isIdentifier(typeName) ? typeName.getText() : "";
3986
+ const name = Node7.isIdentifier(typeName) ? typeName.getText() : "";
3868
3987
  if (STREAM_CONTAINERS.has(name) || STREAM_CONTAINERS_GENERATOR.has(name)) {
3869
3988
  return node.getTypeArguments()[0] ?? null;
3870
3989
  }
@@ -3874,9 +3993,9 @@ function hasAsQueryDecorator(method) {
3874
3993
  return method.getDecorators().some((d) => d.getName() === "AsQuery");
3875
3994
  }
3876
3995
  function unwrapNamedContainer(node, names) {
3877
- if (!node || !Node6.isTypeReference(node)) return node;
3996
+ if (!node || !Node7.isTypeReference(node)) return node;
3878
3997
  const typeName = node.getTypeName();
3879
- const name = Node6.isIdentifier(typeName) ? typeName.getText() : "";
3998
+ const name = Node7.isIdentifier(typeName) ? typeName.getText() : "";
3880
3999
  if (names.has(name)) {
3881
4000
  return node.getTypeArguments()[0] ?? node;
3882
4001
  }
@@ -3922,11 +4041,11 @@ function extractDtoContract(method, sourceFile, project, mixin) {
3922
4041
  if (apiResp) {
3923
4042
  const args = apiResp.getArguments();
3924
4043
  const optsArg = args[0];
3925
- if (optsArg && Node6.isObjectLiteralExpression(optsArg)) {
4044
+ if (optsArg && Node7.isObjectLiteralExpression(optsArg)) {
3926
4045
  for (const prop of optsArg.getProperties()) {
3927
- if (Node6.isPropertyAssignment(prop) && prop.getName() === "type") {
4046
+ if (Node7.isPropertyAssignment(prop) && prop.getName() === "type") {
3928
4047
  const val = prop.getInitializer();
3929
- if (val && Node6.isIdentifier(val)) {
4048
+ if (val && Node7.isIdentifier(val)) {
3930
4049
  const name = val.getText();
3931
4050
  const localDecl = sourceFile.getInterface(name) || sourceFile.getClass(name) || sourceFile.getTypeAlias(name);
3932
4051
  if (localDecl?.isExported()) {
@@ -3994,101 +4113,6 @@ function resolveParamClass(method, decoratorName, sourceFile, project) {
3994
4113
  return null;
3995
4114
  }
3996
4115
 
3997
- // src/discovery/heritage.ts
3998
- import { Node as Node7, Project as Project3 } from "ts-morph";
3999
- function resolveHeritageCall(node) {
4000
- if (!node) return void 0;
4001
- const expr = unwrapExpression(node);
4002
- if (Node7.isCallExpression(expr)) return expr;
4003
- if (!Node7.isIdentifier(expr)) return void 0;
4004
- const decl = expr.getDefinitions().map((d) => d.getDeclarationNode()).find(
4005
- (n) => n !== void 0 && Node7.isVariableDeclaration(n)
4006
- );
4007
- const init = decl?.getInitializer();
4008
- if (!init) return void 0;
4009
- const unwrapped = unwrapExpression(init);
4010
- return Node7.isCallExpression(unwrapped) ? unwrapped : void 0;
4011
- }
4012
- function unwrapExpression(node) {
4013
- let current = node;
4014
- while (Node7.isAsExpression(current) || Node7.isSatisfiesExpression(current) || Node7.isParenthesizedExpression(current) || Node7.isTypeAssertion(current)) {
4015
- current = current.getExpression();
4016
- }
4017
- return current;
4018
- }
4019
- function resolveReturnedClass(factoryDecl) {
4020
- const body = factoryDecl.getBody();
4021
- if (!body) return void 0;
4022
- const returns = body.getDescendants().filter((n) => Node7.isReturnStatement(n));
4023
- for (const ret of returns) {
4024
- const expr = ret.getExpression();
4025
- if (!expr) continue;
4026
- const inner = unwrapExpression(expr);
4027
- if (Node7.isClassExpression(inner)) {
4028
- return inner;
4029
- }
4030
- if (Node7.isIdentifier(inner)) {
4031
- const name = inner.getText();
4032
- const decl = body.getDescendants().find((n) => Node7.isClassDeclaration(n) && n.getName() === name);
4033
- if (decl) return decl;
4034
- }
4035
- }
4036
- return void 0;
4037
- }
4038
- function resolveInheritedMethods(cls) {
4039
- const expr = resolveHeritageCall(cls.getExtends()?.getExpression());
4040
- if (!expr) return void 0;
4041
- const callee = expr.getExpression();
4042
- if (!Node7.isIdentifier(callee)) return void 0;
4043
- const factoryDecl = callee.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => Node7.isFunctionDeclaration(n));
4044
- if (!factoryDecl) return void 0;
4045
- const returnedClass = resolveReturnedClass(factoryDecl);
4046
- if (!returnedClass) return void 0;
4047
- const classArgs = [];
4048
- for (const arg of expr.getArguments()) {
4049
- if (!Node7.isIdentifier(arg)) continue;
4050
- const decl = arg.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => Node7.isClassDeclaration(n));
4051
- if (decl) {
4052
- classArgs.push({
4053
- name: decl.getName() ?? arg.getText(),
4054
- filePath: decl.getSourceFile().getFilePath()
4055
- });
4056
- }
4057
- }
4058
- return {
4059
- methods: returnedClass.getMethods(),
4060
- factoryName: callee.getText(),
4061
- factoryFilePath: factoryDecl.getSourceFile().getFilePath(),
4062
- classArgs
4063
- };
4064
- }
4065
- var mixinTypeProject;
4066
- function getMixinTypeProject() {
4067
- mixinTypeProject ??= new Project3({
4068
- skipAddingFilesFromTsConfig: true,
4069
- compilerOptions: { strict: true }
4070
- });
4071
- return mixinTypeProject;
4072
- }
4073
- function clearMixinTypeProject() {
4074
- mixinTypeProject = void 0;
4075
- }
4076
- function resolveInstantiatedReturnType(cls, methodName) {
4077
- const filePath = cls.getSourceFile().getFilePath();
4078
- const className = cls.getName();
4079
- if (!className) return void 0;
4080
- const project = getMixinTypeProject();
4081
- const sourceFile = project.getSourceFile(filePath) ?? project.addSourceFileAtPathIfExists(filePath);
4082
- const typedCls = sourceFile?.getClass(className);
4083
- if (!typedCls) return void 0;
4084
- const prop = typedCls.getType().getProperty(methodName);
4085
- if (!prop) return void 0;
4086
- const returnType = prop.getTypeAtLocation(typedCls).getCallSignatures()[0]?.getReturnType();
4087
- if (!returnType) return void 0;
4088
- const unwrapped = returnType.getSymbol()?.getName() === "Promise" ? returnType.getTypeArguments()[0] ?? returnType : returnType;
4089
- return unwrapped.getText(typedCls);
4090
- }
4091
-
4092
4116
  // src/discovery/zod-ast-to-ts.ts
4093
4117
  import { Node as Node8, SyntaxKind as SyntaxKind4 } from "ts-morph";
4094
4118
  function zodAstToTs(node) {
@@ -4803,7 +4827,7 @@ async function watch(config, onChange, options = {}) {
4803
4827
  }
4804
4828
 
4805
4829
  // src/index.ts
4806
- var VERSION = "0.17.1";
4830
+ var VERSION = "0.17.2";
4807
4831
 
4808
4832
  // src/generate-manifest.ts
4809
4833
  var MANIFEST_FILE = ".codegen-manifest.json";