@fern-api/fern-api-dev 5.23.3-832-gfa15174fbb2 → 5.23.3-836-gfbf7d534981

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.
Files changed (2) hide show
  1. package/cli.cjs +341 -76
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -685536,7 +685536,7 @@ var AccessTokenPosthogManager = class {
685536
685536
  properties: {
685537
685537
  ...event,
685538
685538
  ...event.properties,
685539
- version: "5.23.3-832-gfa15174fbb2",
685539
+ version: "5.23.3-836-gfbf7d534981",
685540
685540
  usingAccessToken: true,
685541
685541
  ...getRunIdProperties()
685542
685542
  }
@@ -685602,7 +685602,7 @@ var UserPosthogManager = class {
685602
685602
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
685603
685603
  event: "CLI",
685604
685604
  properties: {
685605
- version: "5.23.3-832-gfa15174fbb2",
685605
+ version: "5.23.3-836-gfbf7d534981",
685606
685606
  ...event,
685607
685607
  ...event.properties,
685608
685608
  usingAccessToken: false,
@@ -866664,7 +866664,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
866664
866664
  var LOGS_FOLDER_NAME = "logs";
866665
866665
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
866666
866666
  function getCliSource() {
866667
- const version7 = "5.23.3-832-gfa15174fbb2";
866667
+ const version7 = "5.23.3-836-gfbf7d534981";
866668
866668
  return `cli@${version7}`;
866669
866669
  }
866670
866670
  var DebugLogger = class {
@@ -898891,7 +898891,7 @@ var LegacyDocsPublisher = class {
898891
898891
  previewId,
898892
898892
  disableTemplates: void 0,
898893
898893
  skipUpload,
898894
- cliVersion: "5.23.3-832-gfa15174fbb2",
898894
+ cliVersion: "5.23.3-836-gfbf7d534981",
898895
898895
  loginCommand: "fern auth login"
898896
898896
  });
898897
898897
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -924995,19 +924995,23 @@ var ClassReference2 = class extends AstNode3 {
924995
924995
  name;
924996
924996
  packageName;
924997
924997
  fullyQualified;
924998
- constructor({ name: name2, packageName, fullyQualified }) {
924998
+ enclosingClasses;
924999
+ constructor({ name: name2, packageName, fullyQualified, enclosingClasses }) {
924999
925000
  super();
925000
925001
  this.name = name2;
925001
925002
  this.packageName = packageName;
925002
925003
  this.fullyQualified = fullyQualified ?? false;
925004
+ this.enclosingClasses = enclosingClasses ?? [];
925003
925005
  }
925004
925006
  write(writer2) {
925005
- writer2.addImport(`${this.packageName}.${this.name}`);
925007
+ const topLevelClassName = this.enclosingClasses[0] ?? this.name;
925008
+ const qualifiedName = [...this.enclosingClasses, this.name].join(".");
925009
+ writer2.addImport(`${this.packageName}.${topLevelClassName}`);
925006
925010
  if (this.fullyQualified) {
925007
- writer2.write(`${this.packageName}.${this.name}`);
925011
+ writer2.write(`${this.packageName}.${qualifiedName}`);
925008
925012
  return;
925009
925013
  }
925010
- writer2.write(this.name);
925014
+ writer2.write(qualifiedName);
925011
925015
  }
925012
925016
  };
925013
925017
 
@@ -926212,11 +926216,21 @@ var DynamicTypeLiteralMapper = class {
926212
926216
  }
926213
926217
  switch (args.typeReference.type) {
926214
926218
  case "list":
926215
- return this.convertList({ list: args.typeReference.value, value: args.value, as: args.as });
926219
+ return this.convertList({
926220
+ list: args.typeReference.value,
926221
+ value: args.value,
926222
+ as: args.as,
926223
+ nestedClassReference: args.nestedClassReference
926224
+ });
926216
926225
  case "literal":
926217
926226
  return this.convertLiteral({ literal: args.typeReference.value, value: args.value });
926218
926227
  case "map":
926219
- return this.convertMap({ map: args.typeReference, value: args.value, as: args.as });
926228
+ return this.convertMap({
926229
+ map: args.typeReference,
926230
+ value: args.value,
926231
+ as: args.as,
926232
+ nestedClassReference: args.nestedClassReference
926233
+ });
926220
926234
  case "named": {
926221
926235
  const named = this.context.resolveNamedType({ typeId: args.typeReference.value });
926222
926236
  if (named == null) {
@@ -926226,7 +926240,8 @@ var DynamicTypeLiteralMapper = class {
926226
926240
  named,
926227
926241
  value: args.value,
926228
926242
  as: args.as,
926229
- inUndiscriminatedUnion: args.inUndiscriminatedUnion
926243
+ inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926244
+ nestedClassReference: args.nestedClassReference
926230
926245
  });
926231
926246
  }
926232
926247
  case "nullable":
@@ -926255,11 +926270,16 @@ var DynamicTypeLiteralMapper = class {
926255
926270
  value: args.value,
926256
926271
  as: args.as,
926257
926272
  inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926258
- isCollapsedOptionalNullable: true
926273
+ isCollapsedOptionalNullable: true,
926274
+ nestedClassReference: args.nestedClassReference
926259
926275
  });
926260
926276
  }
926261
926277
  if (inner2.type === "list") {
926262
- const listLiteral = this.convertList({ list: inner2.value, value: args.value });
926278
+ const listLiteral = this.convertList({
926279
+ list: inner2.value,
926280
+ value: args.value,
926281
+ nestedClassReference: args.nestedClassReference
926282
+ });
926263
926283
  return this.wrapNullableOrOptionalValue({
926264
926284
  value: listLiteral,
926265
926285
  wrapperType,
@@ -926271,7 +926291,8 @@ var DynamicTypeLiteralMapper = class {
926271
926291
  typeReference: inner2,
926272
926292
  value: args.value,
926273
926293
  as: args.as,
926274
- inUndiscriminatedUnion: args.inUndiscriminatedUnion
926294
+ inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926295
+ nestedClassReference: args.nestedClassReference
926275
926296
  });
926276
926297
  const useOf = args.as === "mapValue" || args.inUndiscriminatedUnion === true;
926277
926298
  return this.wrapNullableOrOptionalValue({
@@ -926284,14 +926305,19 @@ var DynamicTypeLiteralMapper = class {
926284
926305
  case "primitive":
926285
926306
  return this.convertPrimitive({ primitive: args.typeReference.value, value: args.value, as: args.as });
926286
926307
  case "set":
926287
- return this.convertSet({ set: args.typeReference.value, value: args.value, as: args.as });
926308
+ return this.convertSet({
926309
+ set: args.typeReference.value,
926310
+ value: args.value,
926311
+ as: args.as,
926312
+ nestedClassReference: args.nestedClassReference
926313
+ });
926288
926314
  case "unknown":
926289
926315
  return this.convertUnknown({ value: args.value });
926290
926316
  default:
926291
926317
  assertNever(args.typeReference);
926292
926318
  }
926293
926319
  }
926294
- convertList({ list: list29, value: value2, as: as2 }) {
926320
+ convertList({ list: list29, value: value2, as: as2, nestedClassReference }) {
926295
926321
  if (!Array.isArray(value2)) {
926296
926322
  this.context.errors.add({
926297
926323
  severity: Severity.Critical,
@@ -926306,7 +926332,12 @@ var DynamicTypeLiteralMapper = class {
926306
926332
  this.context.errors.scope({ index: index3 });
926307
926333
  try {
926308
926334
  if (isItemOptional && (list29.type === "optional" || list29.type === "nullable")) {
926309
- const itemValue = this.convert({ typeReference: list29.value, value: v3, as: as2 });
926335
+ const itemValue = this.convert({
926336
+ typeReference: list29.value,
926337
+ value: v3,
926338
+ as: as2,
926339
+ nestedClassReference
926340
+ });
926310
926341
  return this.wrapNullableOrOptionalValue({
926311
926342
  value: itemValue,
926312
926343
  wrapperType: list29.type,
@@ -926314,7 +926345,7 @@ var DynamicTypeLiteralMapper = class {
926314
926345
  propagatedCollapse: false
926315
926346
  });
926316
926347
  }
926317
- return this.convert({ typeReference: list29, value: v3, as: as2 });
926348
+ return this.convert({ typeReference: list29, value: v3, as: as2, nestedClassReference });
926318
926349
  } finally {
926319
926350
  this.context.errors.unscope();
926320
926351
  }
@@ -926343,7 +926374,7 @@ var DynamicTypeLiteralMapper = class {
926343
926374
  assertNever(literal3);
926344
926375
  }
926345
926376
  }
926346
- convertSet({ set: set26, value: value2, as: as2 }) {
926377
+ convertSet({ set: set26, value: value2, as: as2, nestedClassReference }) {
926347
926378
  if (!Array.isArray(value2)) {
926348
926379
  this.context.errors.add({
926349
926380
  severity: Severity.Critical,
@@ -926356,14 +926387,14 @@ var DynamicTypeLiteralMapper = class {
926356
926387
  values: value2.map((v3, index3) => {
926357
926388
  this.context.errors.scope({ index: index3 });
926358
926389
  try {
926359
- return this.convert({ typeReference: set26, value: v3, as: as2 });
926390
+ return this.convert({ typeReference: set26, value: v3, as: as2, nestedClassReference });
926360
926391
  } finally {
926361
926392
  this.context.errors.unscope();
926362
926393
  }
926363
926394
  })
926364
926395
  });
926365
926396
  }
926366
- convertMap({ map: map15, value: value2, as: as2 }) {
926397
+ convertMap({ map: map15, value: value2, as: as2, nestedClassReference }) {
926367
926398
  if (typeof value2 !== "object" || value2 == null) {
926368
926399
  this.context.errors.add({
926369
926400
  severity: Severity.Critical,
@@ -926382,7 +926413,8 @@ var DynamicTypeLiteralMapper = class {
926382
926413
  value: this.convert({
926383
926414
  typeReference: map15.value,
926384
926415
  value: value3,
926385
- as: "mapValue"
926416
+ as: "mapValue",
926417
+ nestedClassReference
926386
926418
  })
926387
926419
  };
926388
926420
  } finally {
@@ -926391,7 +926423,7 @@ var DynamicTypeLiteralMapper = class {
926391
926423
  })
926392
926424
  });
926393
926425
  }
926394
- convertNamed({ named, value: value2, as: as2, inUndiscriminatedUnion }) {
926426
+ convertNamed({ named, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference }) {
926395
926427
  switch (named.type) {
926396
926428
  case "alias":
926397
926429
  if (named.typeReference.type === "unknown") {
@@ -926402,32 +926434,44 @@ var DynamicTypeLiteralMapper = class {
926402
926434
  inUndiscriminatedUnion
926403
926435
  });
926404
926436
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926405
- on: this.context.getJavaClassReferenceFromDeclaration({
926437
+ on: nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926406
926438
  declaration: named.declaration
926407
926439
  }),
926408
926440
  method: "of",
926409
926441
  arguments_: [convertedValue]
926410
926442
  }));
926411
926443
  }
926412
- return this.convert({ typeReference: named.typeReference, value: value2, as: as2, inUndiscriminatedUnion });
926444
+ return this.convert({
926445
+ typeReference: named.typeReference,
926446
+ value: value2,
926447
+ as: as2,
926448
+ inUndiscriminatedUnion,
926449
+ nestedClassReference
926450
+ });
926413
926451
  case "discriminatedUnion":
926414
926452
  return this.convertDiscriminatedUnion({
926415
926453
  discriminatedUnion: named,
926416
926454
  value: value2,
926417
- as: as2
926455
+ as: as2,
926456
+ nestedClassReference
926418
926457
  });
926419
926458
  case "enum":
926420
- return this.convertEnum({ enum_: named, value: value2 });
926459
+ return this.convertEnum({ enum_: named, value: value2, nestedClassReference });
926421
926460
  case "object":
926422
- return this.convertObject({ object_: named, value: value2, as: as2, inUndiscriminatedUnion });
926461
+ return this.convertObject({ object_: named, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference });
926423
926462
  case "undiscriminatedUnion":
926424
- return this.convertUndiscriminatedUnion({ undiscriminatedUnion: named, value: value2, as: as2 });
926463
+ return this.convertUndiscriminatedUnion({
926464
+ undiscriminatedUnion: named,
926465
+ value: value2,
926466
+ as: as2,
926467
+ nestedClassReference
926468
+ });
926425
926469
  default:
926426
926470
  assertNever(named);
926427
926471
  }
926428
926472
  }
926429
- convertDiscriminatedUnion({ discriminatedUnion: discriminatedUnion2, value: value2, as: as2 }) {
926430
- const classReference4 = this.context.getJavaClassReferenceFromDeclaration({
926473
+ convertDiscriminatedUnion({ discriminatedUnion: discriminatedUnion2, value: value2, as: as2, nestedClassReference }) {
926474
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926431
926475
  declaration: discriminatedUnion2.declaration
926432
926476
  });
926433
926477
  const discriminatedUnionTypeInstance = this.context.resolveDiscriminatedUnionTypeInstance({
@@ -926438,6 +926482,8 @@ var DynamicTypeLiteralMapper = class {
926438
926482
  return java_exports.TypeLiteral.nop();
926439
926483
  }
926440
926484
  const unionVariant = discriminatedUnionTypeInstance.singleDiscriminatedUnionType;
926485
+ const reservedNames = /* @__PURE__ */ new Set([...classReference4.enclosingClasses, classReference4.name]);
926486
+ const siblingDiscriminantNames = new Set(Object.values(discriminatedUnion2.types).map((variant) => this.context.getClassName(variant.discriminantValue.name)));
926441
926487
  switch (unionVariant.type) {
926442
926488
  case "samePropertiesAsObject": {
926443
926489
  const named = this.context.resolveNamedType({
@@ -926446,10 +926492,24 @@ var DynamicTypeLiteralMapper = class {
926446
926492
  if (named == null) {
926447
926493
  return java_exports.TypeLiteral.nop();
926448
926494
  }
926495
+ const variantNestedClassReference = this.resolveInlineNestedClassReference({
926496
+ enclosing: classReference4,
926497
+ baseName: this.context.getClassName(unionVariant.discriminantValue.name),
926498
+ typeReference: { type: "named", value: unionVariant.typeId },
926499
+ reservedNames,
926500
+ siblingPropertyNames: siblingDiscriminantNames
926501
+ });
926449
926502
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926450
926503
  on: classReference4,
926451
926504
  method: this.context.getPropertyName(unionVariant.discriminantValue.name),
926452
- arguments_: [this.convertNamed({ named, value: discriminatedUnionTypeInstance.value, as: as2 })]
926505
+ arguments_: [
926506
+ this.convertNamed({
926507
+ named,
926508
+ value: discriminatedUnionTypeInstance.value,
926509
+ as: as2,
926510
+ nestedClassReference: variantNestedClassReference
926511
+ })
926512
+ ]
926453
926513
  }));
926454
926514
  }
926455
926515
  case "singleProperty": {
@@ -926460,6 +926520,13 @@ var DynamicTypeLiteralMapper = class {
926460
926520
  try {
926461
926521
  this.context.errors.scope(unionVariant.discriminantValue.wireValue);
926462
926522
  const propertyKey = "value";
926523
+ const variantNestedClassReference = this.resolveInlineNestedClassReference({
926524
+ enclosing: classReference4,
926525
+ baseName: this.context.getClassName(unionVariant.discriminantValue.name),
926526
+ typeReference: unionVariant.typeReference,
926527
+ reservedNames,
926528
+ siblingPropertyNames: siblingDiscriminantNames
926529
+ });
926463
926530
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926464
926531
  on: classReference4,
926465
926532
  method: this.context.getPropertyName(unionVariant.discriminantValue.name),
@@ -926467,7 +926534,8 @@ var DynamicTypeLiteralMapper = class {
926467
926534
  this.convert({
926468
926535
  typeReference: unionVariant.typeReference,
926469
926536
  value: record23[propertyKey],
926470
- as: as2
926537
+ as: as2,
926538
+ nestedClassReference: variantNestedClassReference
926471
926539
  })
926472
926540
  ]
926473
926541
  }));
@@ -926485,7 +926553,10 @@ var DynamicTypeLiteralMapper = class {
926485
926553
  assertNever(unionVariant);
926486
926554
  }
926487
926555
  }
926488
- convertObject({ object_, value: value2, as: as2, inUndiscriminatedUnion }) {
926556
+ convertObject({ object_, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference }) {
926557
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926558
+ declaration: object_.declaration
926559
+ });
926489
926560
  const valueRecord = this.context.getRecord(value2) ?? {};
926490
926561
  const properties7 = this.context.associateByWireValue({
926491
926562
  parameters: object_.properties,
@@ -926515,6 +926586,8 @@ var DynamicTypeLiteralMapper = class {
926515
926586
  });
926516
926587
  properties7.sort((a3, b5) => (paramOrderMap.get(a3.name.wireValue) ?? 0) - (paramOrderMap.get(b5.name.wireValue) ?? 0));
926517
926588
  const filteredProperties = as2 === "request" ? properties7.filter((property24) => !this.context.isDirectLiteral(property24.typeReference)) : properties7;
926589
+ const reservedNames = /* @__PURE__ */ new Set([...classReference4.enclosingClasses, classReference4.name]);
926590
+ const siblingPropertyNames = new Set(object_.properties.map((property24) => this.context.getClassName(property24.name.name)));
926518
926591
  const builderParameters = [];
926519
926592
  for (const property24 of filteredProperties) {
926520
926593
  this.context.errors.scope(property24.name.wireValue);
@@ -926523,7 +926596,14 @@ var DynamicTypeLiteralMapper = class {
926523
926596
  typeReference: property24.typeReference,
926524
926597
  value: property24.value,
926525
926598
  as: as2,
926526
- inUndiscriminatedUnion
926599
+ inUndiscriminatedUnion,
926600
+ nestedClassReference: this.resolveInlineNestedClassReference({
926601
+ enclosing: classReference4,
926602
+ baseName: this.context.getClassName(property24.name.name),
926603
+ typeReference: property24.typeReference,
926604
+ reservedNames,
926605
+ siblingPropertyNames
926606
+ })
926527
926607
  });
926528
926608
  if (java_exports.TypeLiteral.isNop(convertedValue) && !this.context.isOptional(property24.typeReference)) {
926529
926609
  if (inUndiscriminatedUnion === true) {
@@ -926553,12 +926633,146 @@ var DynamicTypeLiteralMapper = class {
926553
926633
  }
926554
926634
  }
926555
926635
  return java_exports.TypeLiteral.builder({
926556
- classReference: this.context.getJavaClassReferenceFromDeclaration({
926557
- declaration: object_.declaration
926558
- }),
926636
+ classReference: classReference4,
926559
926637
  parameters: builderParameters
926560
926638
  });
926561
926639
  }
926640
+ /**
926641
+ * Mirrors the v1 generator's inline-type naming (see ObjectGenerator / InlineTypeIdResolver):
926642
+ * when a property's type resolves to an inline named type, v1 emits it as a class nested within
926643
+ * the enclosing object. This walks the property's type reference (descending through container
926644
+ * wrappers, applying the same name suffixes as v1) and, if it terminates in an inline named type,
926645
+ * returns the nested class reference to use. Returns undefined for non-inline types, which fall
926646
+ * back to the standalone top-level class name.
926647
+ */
926648
+ resolveInlineNestedClassReference({ enclosing, baseName, typeReference: typeReference2, reservedNames, siblingPropertyNames }) {
926649
+ if (!this.context.enableInlineTypes()) {
926650
+ return void 0;
926651
+ }
926652
+ switch (typeReference2.type) {
926653
+ case "optional":
926654
+ case "nullable":
926655
+ return this.resolveInlineNestedClassReference({
926656
+ enclosing,
926657
+ baseName,
926658
+ typeReference: typeReference2.value,
926659
+ reservedNames,
926660
+ siblingPropertyNames
926661
+ });
926662
+ case "list":
926663
+ case "set":
926664
+ return this.resolveInlineNestedClassReference({
926665
+ enclosing,
926666
+ baseName: `${baseName}Item`,
926667
+ typeReference: typeReference2.value,
926668
+ reservedNames,
926669
+ siblingPropertyNames
926670
+ });
926671
+ case "map":
926672
+ return this.resolveInlineNestedClassReference({
926673
+ enclosing,
926674
+ baseName: `${baseName}Value`,
926675
+ typeReference: typeReference2.value,
926676
+ reservedNames,
926677
+ siblingPropertyNames
926678
+ });
926679
+ case "named": {
926680
+ const typeId = typeReference2.value;
926681
+ const named = this.context.resolveNamedType({ typeId });
926682
+ if (named == null) {
926683
+ return void 0;
926684
+ }
926685
+ if (named.type === "alias" && !this.context.wrappedAliases()) {
926686
+ return this.resolveInlineNestedClassReference({
926687
+ enclosing,
926688
+ baseName,
926689
+ typeReference: named.typeReference,
926690
+ reservedNames,
926691
+ siblingPropertyNames
926692
+ });
926693
+ }
926694
+ if (!this.context.isInlineType(typeId)) {
926695
+ return void 0;
926696
+ }
926697
+ let name2 = baseName;
926698
+ while (reservedNames.has(name2) || siblingPropertyNames.has(name2) && name2 !== baseName) {
926699
+ name2 = `${name2}_`;
926700
+ }
926701
+ reservedNames.add(name2);
926702
+ return this.context.getNestedInlineClassReference({ enclosing, name: name2 });
926703
+ }
926704
+ case "primitive":
926705
+ case "literal":
926706
+ case "unknown":
926707
+ return void 0;
926708
+ default:
926709
+ assertNever(typeReference2);
926710
+ }
926711
+ }
926712
+ /**
926713
+ * Resolves the nested class reference for an inline member of an undiscriminated union.
926714
+ * Unlike object properties and discriminated-union variants (whose nested name is derived
926715
+ * from the property/discriminant name), v1 names an undiscriminated union's inline members
926716
+ * after the member type's own name, with the union's name stripped as a prefix (see
926717
+ * UndiscriminatedUnionGenerator). Descends through container wrappers to the terminal named
926718
+ * type.
926719
+ */
926720
+ resolveUndiscriminatedInlineNestedClassReference({ enclosing, typeReference: typeReference2, reservedNames, unionPrefix }) {
926721
+ if (!this.context.enableInlineTypes()) {
926722
+ return void 0;
926723
+ }
926724
+ switch (typeReference2.type) {
926725
+ case "optional":
926726
+ case "nullable":
926727
+ case "list":
926728
+ case "set":
926729
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926730
+ enclosing,
926731
+ typeReference: typeReference2.value,
926732
+ reservedNames,
926733
+ unionPrefix
926734
+ });
926735
+ case "map":
926736
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926737
+ enclosing,
926738
+ typeReference: typeReference2.value,
926739
+ reservedNames,
926740
+ unionPrefix
926741
+ });
926742
+ case "named": {
926743
+ const typeId = typeReference2.value;
926744
+ const named = this.context.resolveNamedType({ typeId });
926745
+ if (named == null) {
926746
+ return void 0;
926747
+ }
926748
+ if (named.type === "alias" && !this.context.wrappedAliases()) {
926749
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926750
+ enclosing,
926751
+ typeReference: named.typeReference,
926752
+ reservedNames,
926753
+ unionPrefix
926754
+ });
926755
+ }
926756
+ if (!this.context.isInlineType(typeId)) {
926757
+ return void 0;
926758
+ }
926759
+ let name2 = this.context.getClassName(named.declaration.name);
926760
+ if (name2.startsWith(unionPrefix) && name2 !== unionPrefix) {
926761
+ name2 = name2.substring(unionPrefix.length);
926762
+ }
926763
+ while (reservedNames.has(name2)) {
926764
+ name2 = `${name2}_`;
926765
+ }
926766
+ return this.context.getNestedInlineClassReference({ enclosing, name: name2 });
926767
+ }
926768
+ case "primitive":
926769
+ case "literal":
926770
+ case "unknown":
926771
+ return void 0;
926772
+ default:
926773
+ assertNever(typeReference2);
926774
+ }
926775
+ }
926562
926776
  /**
926563
926777
  * Returns true when a property becomes a required stage in v1's staged builder. v1 stages
926564
926778
  * fields that are neither optional, nullable, nor collections (list/set/map); those are all
@@ -926676,13 +926890,13 @@ var DynamicTypeLiteralMapper = class {
926676
926890
  return "string";
926677
926891
  }
926678
926892
  }
926679
- convertEnum({ enum_: enum_25, value: value2 }) {
926893
+ convertEnum({ enum_: enum_25, value: value2, nestedClassReference }) {
926680
926894
  const name2 = this.getEnumValueName({ enum_: enum_25, value: value2 });
926681
926895
  if (name2 == null) {
926682
926896
  return java_exports.TypeLiteral.nop();
926683
926897
  }
926684
926898
  return java_exports.TypeLiteral.enum_({
926685
- classReference: this.context.getJavaClassReferenceFromDeclaration({
926899
+ classReference: nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926686
926900
  declaration: enum_25.declaration
926687
926901
  }),
926688
926902
  value: name2
@@ -926706,33 +926920,28 @@ var DynamicTypeLiteralMapper = class {
926706
926920
  }
926707
926921
  return this.context.getEnumName(enumValue.name);
926708
926922
  }
926709
- convertUndiscriminatedUnion({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2 }) {
926923
+ convertUndiscriminatedUnion({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2, nestedClassReference }) {
926924
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926925
+ declaration: undiscriminatedUnion22.declaration
926926
+ });
926710
926927
  const result = this.findMatchingUndiscriminatedUnionType({
926711
926928
  undiscriminatedUnion: undiscriminatedUnion22,
926712
926929
  value: value2,
926713
- as: as2
926930
+ as: as2,
926931
+ enclosing: classReference4
926714
926932
  });
926715
926933
  if (result == null) {
926716
926934
  return java_exports.TypeLiteral.nop();
926717
926935
  }
926718
- if (this.context.isPrimitive(result.valueTypeReference)) {
926719
- return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926720
- on: this.context.getJavaClassReferenceFromDeclaration({
926721
- declaration: undiscriminatedUnion22.declaration
926722
- }),
926723
- method: "of",
926724
- arguments_: [result.typeInstantiation]
926725
- }));
926726
- }
926727
926936
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926728
- on: this.context.getJavaClassReferenceFromDeclaration({
926729
- declaration: undiscriminatedUnion22.declaration
926730
- }),
926937
+ on: classReference4,
926731
926938
  method: "of",
926732
926939
  arguments_: [result.typeInstantiation]
926733
926940
  }));
926734
926941
  }
926735
- findMatchingUndiscriminatedUnionType({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2 }) {
926942
+ findMatchingUndiscriminatedUnionType({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2, enclosing }) {
926943
+ const reservedNames = /* @__PURE__ */ new Set([...enclosing.enclosingClasses, enclosing.name]);
926944
+ const unionPrefix = this.context.getClassName(undiscriminatedUnion22.declaration.name);
926736
926945
  for (const typeReference2 of undiscriminatedUnion22.types) {
926737
926946
  const errorsBefore = this.context.errors.size();
926738
926947
  try {
@@ -926740,7 +926949,13 @@ var DynamicTypeLiteralMapper = class {
926740
926949
  typeReference: typeReference2,
926741
926950
  value: value2,
926742
926951
  as: as2,
926743
- inUndiscriminatedUnion: true
926952
+ inUndiscriminatedUnion: true,
926953
+ nestedClassReference: this.resolveUndiscriminatedInlineNestedClassReference({
926954
+ enclosing,
926955
+ typeReference: typeReference2,
926956
+ reservedNames: new Set(reservedNames),
926957
+ unionPrefix
926958
+ })
926744
926959
  });
926745
926960
  if (java_exports.TypeLiteral.isNop(typeInstantiation) || this.context.errors.size() > errorsBefore) {
926746
926961
  this.context.errors.truncate(errorsBefore);
@@ -927064,7 +927279,7 @@ var DynamicTypeMapper3 = class {
927064
927279
  }
927065
927280
  case "optional": {
927066
927281
  const inner2 = args.typeReference.value;
927067
- if (this.context.usesOptionalNullable() && inner2.type === "nullable") {
927282
+ if (this.context.usesOptionalNullable() && (inner2.type === "nullable" || inner2.type === "optional")) {
927068
927283
  return java_exports.Type.generic(this.context.getOptionalNullableClassReference(), [
927069
927284
  this.convert({ typeReference: inner2.value })
927070
927285
  ]);
@@ -927077,8 +927292,9 @@ var DynamicTypeMapper3 = class {
927077
927292
  return this.convert({ typeReference: inner2 });
927078
927293
  }
927079
927294
  if (this.context.usesOptionalNullable()) {
927295
+ const collapsed = inner2.type === "optional" || inner2.type === "nullable" ? inner2.value : inner2;
927080
927296
  return java_exports.Type.generic(this.context.getOptionalNullableClassReference(), [
927081
- this.convert({ typeReference: inner2 })
927297
+ this.convert({ typeReference: collapsed })
927082
927298
  ]);
927083
927299
  }
927084
927300
  return java_exports.Type.optional(this.convert({ typeReference: inner2 }));
@@ -927258,22 +927474,51 @@ var DynamicSnippetsGeneratorContext3 = class _DynamicSnippetsGeneratorContext ex
927258
927474
  dynamicTypeMapper;
927259
927475
  dynamicTypeLiteralMapper;
927260
927476
  filePropertyMapper;
927261
- constructor({ ir: ir3, config: config5, options: options2, sharedCustomConfig }) {
927477
+ /**
927478
+ * The set of type IDs that the v1 generator emits as nested (inline) classes rather than
927479
+ * top-level types. The dynamic IR does not carry the `inline` flag, so the v2 SDK generator
927480
+ * computes this from the full IR and threads it through. Used to mirror v1's nested-class
927481
+ * naming when referencing inline types in snippets.
927482
+ */
927483
+ inlineTypeIds;
927484
+ constructor({ ir: ir3, config: config5, options: options2, sharedCustomConfig, inlineTypeIds }) {
927262
927485
  super({ ir: ir3, config: config5, options: options2 });
927263
927486
  this.ir = ir3;
927264
927487
  this.customConfig = sharedCustomConfig ?? BaseJavaCustomConfigSchema.parse(config5.customConfig ?? {});
927265
927488
  this.dynamicTypeMapper = new DynamicTypeMapper3({ context: this });
927266
927489
  this.dynamicTypeLiteralMapper = new DynamicTypeLiteralMapper({ context: this });
927267
927490
  this.filePropertyMapper = new FilePropertyMapper3({ context: this });
927491
+ this.inlineTypeIds = inlineTypeIds ?? /* @__PURE__ */ new Set();
927268
927492
  }
927269
927493
  clone() {
927270
927494
  return new _DynamicSnippetsGeneratorContext({
927271
927495
  ir: this.ir,
927272
927496
  config: this.config,
927273
927497
  options: this.options,
927274
- sharedCustomConfig: this.customConfig
927498
+ sharedCustomConfig: this.customConfig,
927499
+ inlineTypeIds: this.inlineTypeIds
927275
927500
  });
927276
927501
  }
927502
+ isInlineType(typeId) {
927503
+ return this.inlineTypeIds.has(typeId);
927504
+ }
927505
+ /**
927506
+ * Builds a reference to a class nested within `enclosing`. The resulting reference imports the
927507
+ * outermost enclosing class and is written using the dotted path (e.g. `PostRootRequest.Bar`).
927508
+ */
927509
+ getNestedInlineClassReference({ enclosing, name: name2 }) {
927510
+ return java_exports.classReference({
927511
+ name: name2,
927512
+ packageName: enclosing.packageName,
927513
+ enclosingClasses: [...enclosing.enclosingClasses, enclosing.name]
927514
+ });
927515
+ }
927516
+ wrappedAliases() {
927517
+ return this.customConfig?.["wrapped-aliases"] ?? false;
927518
+ }
927519
+ enableInlineTypes() {
927520
+ return this.customConfig?.["enable-inline-types"] ?? false;
927521
+ }
927277
927522
  getClassName(name2) {
927278
927523
  return this.getName(name2.pascalCase.safeName);
927279
927524
  }
@@ -928178,18 +928423,20 @@ var EndpointSnippetGenerator3 = class {
928178
928423
  })
928179
928424
  }));
928180
928425
  this.context.errors.unscope();
928426
+ const requestClassReference = java_exports.classReference({
928427
+ name: this.context.getClassName(request7.declaration.name),
928428
+ packageName: this.context.getRequestsPackageName(request7.declaration.fernFilepath)
928429
+ });
928181
928430
  this.context.errors.scope(Scope4.RequestBody);
928182
928431
  const requestBodyFields = request7.body != null ? this.getInlinedRequestBodyBuilderParameters({
928183
928432
  body: request7.body,
928184
928433
  value: snippet.requestBody,
928185
- filePropertyInfo
928434
+ filePropertyInfo,
928435
+ enclosing: requestClassReference
928186
928436
  }) : [];
928187
928437
  this.context.errors.unscope();
928188
928438
  return java_exports.TypeLiteral.builder({
928189
- classReference: java_exports.classReference({
928190
- name: this.context.getClassName(request7.declaration.name),
928191
- packageName: this.context.getRequestsPackageName(request7.declaration.fernFilepath)
928192
- }),
928439
+ classReference: requestClassReference,
928193
928440
  parameters: [...pathParameterFields, ...headerFields, ...queryParameterFields, ...requestBodyFields]
928194
928441
  });
928195
928442
  }
@@ -928233,10 +928480,14 @@ var EndpointSnippetGenerator3 = class {
928233
928480
  });
928234
928481
  return java_exports.TypeLiteral.reference(buildMethodCall);
928235
928482
  }
928236
- getInlinedRequestBodyBuilderParameters({ body, value: value2, filePropertyInfo }) {
928483
+ getInlinedRequestBodyBuilderParameters({ body, value: value2, filePropertyInfo, enclosing }) {
928237
928484
  switch (body.type) {
928238
928485
  case "properties":
928239
- return this.getInlinedRequestBodyPropertyBuilderParameters({ parameters: body.value, value: value2 });
928486
+ return this.getInlinedRequestBodyPropertyBuilderParameters({
928487
+ parameters: body.value,
928488
+ value: value2,
928489
+ enclosing
928490
+ });
928240
928491
  case "referenced":
928241
928492
  return [this.getReferencedRequestBodyPropertyBuilderParameter({ body, value: value2 })];
928242
928493
  case "fileUpload":
@@ -928271,19 +928522,28 @@ var EndpointSnippetGenerator3 = class {
928271
928522
  assertNever(body);
928272
928523
  }
928273
928524
  }
928274
- getInlinedRequestBodyPropertyBuilderParameters({ parameters: parameters2, value: value2 }) {
928525
+ getInlinedRequestBodyPropertyBuilderParameters({ parameters: parameters2, value: value2, enclosing }) {
928275
928526
  const bodyProperties = this.context.associateByWireValue({
928276
928527
  parameters: parameters2,
928277
928528
  values: this.context.getRecord(value2) ?? {}
928278
928529
  });
928279
928530
  const filteredProperties = bodyProperties.filter((parameter6) => !this.context.isDirectLiteral(parameter6.typeReference));
928280
928531
  const sortedProperties = this.context.sortTypeInstancesByRequiredFirst(filteredProperties, parameters2);
928532
+ const reservedNames = /* @__PURE__ */ new Set([...enclosing.enclosingClasses, enclosing.name]);
928533
+ const siblingPropertyNames = new Set(parameters2.map((parameter6) => this.context.getClassName(parameter6.name.name)));
928281
928534
  return sortedProperties.map((parameter6) => ({
928282
928535
  name: this.context.getMethodName(parameter6.name.name),
928283
928536
  value: this.context.dynamicTypeLiteralMapper.convert({
928284
928537
  typeReference: parameter6.typeReference,
928285
928538
  value: parameter6.value,
928286
- as: "request"
928539
+ as: "request",
928540
+ nestedClassReference: this.context.dynamicTypeLiteralMapper.resolveInlineNestedClassReference({
928541
+ enclosing,
928542
+ baseName: this.context.getClassName(parameter6.name.name),
928543
+ typeReference: parameter6.typeReference,
928544
+ reservedNames,
928545
+ siblingPropertyNames
928546
+ })
928287
928547
  })
928288
928548
  }));
928289
928549
  }
@@ -928318,8 +928578,8 @@ var EndpointSnippetGenerator3 = class {
928318
928578
 
928319
928579
  // ../../../generators/java-v2/dynamic-snippets/lib/DynamicSnippetsGenerator.js
928320
928580
  var DynamicSnippetsGenerator3 = class extends AbstractDynamicSnippetsGenerator {
928321
- constructor({ ir: ir3, config: config5, options: options2 = {} }) {
928322
- super(new DynamicSnippetsGeneratorContext3({ ir: ir3, config: config5, options: options2 }));
928581
+ constructor({ ir: ir3, config: config5, options: options2 = {}, inlineTypeIds }) {
928582
+ super(new DynamicSnippetsGeneratorContext3({ ir: ir3, config: config5, options: options2, inlineTypeIds }));
928323
928583
  }
928324
928584
  async generate(request7, options2 = {}) {
928325
928585
  return super.generate(request7, options2);
@@ -928344,15 +928604,18 @@ var DynamicSnippetsJavaTestGenerator = class {
928344
928604
  context;
928345
928605
  ir;
928346
928606
  generatorConfig;
928607
+ inlineTypeIds;
928347
928608
  dynamicSnippetsGenerator;
928348
- constructor(context3, ir3, generatorConfig) {
928609
+ constructor(context3, ir3, generatorConfig, inlineTypeIds) {
928349
928610
  this.context = context3;
928350
928611
  this.ir = ir3;
928351
928612
  this.generatorConfig = generatorConfig;
928613
+ this.inlineTypeIds = inlineTypeIds;
928352
928614
  this.dynamicSnippetsGenerator = new DynamicSnippetsGenerator3({
928353
928615
  // biome-ignore lint/suspicious/noExplicitAny: workaround for version incompatibility - see note above
928354
928616
  ir: convertIr(this.ir),
928355
- config: this.generatorConfig
928617
+ config: this.generatorConfig,
928618
+ inlineTypeIds: this.inlineTypeIds
928356
928619
  });
928357
928620
  }
928358
928621
  async generateTests({ outputDir, requests: requests3 }) {
@@ -950663,7 +950926,7 @@ var DynamicSnippetsTestGenerator = class _DynamicSnippetsTestGenerator {
950663
950926
  this.context.logger.debug(`Skipping dynamic snippets test generation for language "${language}"`);
950664
950927
  return;
950665
950928
  }
950666
- return new config5.generator(this.context, this.testSuite.ir, this.testSuite.config).generateTests({
950929
+ return new config5.generator(this.context, this.testSuite.ir, this.testSuite.config, this.testSuite.inlineTypeIds).generateTests({
950667
950930
  outputDir,
950668
950931
  requests: this.testSuite.requests
950669
950932
  });
@@ -950679,9 +950942,11 @@ async function generateDynamicSnippetsTestSuite({ ir: ir3, config: config5 }) {
950679
950942
  code: CliError.Code.InternalError
950680
950943
  });
950681
950944
  }
950945
+ const inlineTypeIds = new Set(Object.values(ir3.types).filter((typeDeclaration2) => typeDeclaration2.inline === true).map((typeDeclaration2) => typeDeclaration2.name.typeId));
950682
950946
  return {
950683
950947
  ir: ir3.dynamic,
950684
950948
  config: config5,
950949
+ inlineTypeIds,
950685
950950
  requests: Object.entries(ir3.dynamic.endpoints).flatMap(([endpointId, endpoint3]) => (endpoint3.examples ?? []).map((example) => ({
950686
950951
  endpointId,
950687
950952
  request: {
@@ -964670,7 +964935,7 @@ function getAutomationContextFromEnv() {
964670
964935
  config_branch: process.env.FERN_CONFIG_BRANCH,
964671
964936
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
964672
964937
  trigger: process.env.GITHUB_EVENT_NAME,
964673
- cli_version: "5.23.3-832-gfa15174fbb2"
964938
+ cli_version: "5.23.3-836-gfbf7d534981"
964674
964939
  };
964675
964940
  }
964676
964941
  function isAutomationMode() {
@@ -965502,7 +965767,7 @@ var CliContext = class _CliContext {
965502
965767
  if (false) {
965503
965768
  this.logger.error("CLI_VERSION is not defined");
965504
965769
  }
965505
- return "5.23.3-832-gfa15174fbb2";
965770
+ return "5.23.3-836-gfbf7d534981";
965506
965771
  }
965507
965772
  getCliName() {
965508
965773
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.23.3-832-gfa15174fbb2",
2
+ "version": "5.23.3-836-gfbf7d534981",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",