@fern-api/fern-api-dev 5.23.3-832-gfa15174fbb2 → 5.23.3-839-gd570dc5b08c

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 +346 -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-839-gd570dc5b08c",
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-839-gd570dc5b08c",
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-839-gd570dc5b08c";
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-839-gd570dc5b08c",
898895
898895
  loginCommand: "fern auth login"
898896
898896
  });
898897
898897
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -924875,6 +924875,11 @@ var BaseJavaCustomConfigSchema = external_exports2.object({
924875
924875
  "enable-extensible-builders": external_exports2.boolean().optional(),
924876
924876
  "use-default-request-parameter-values": external_exports2.boolean().optional(),
924877
924877
  "enable-wire-tests": external_exports2.boolean().default(false),
924878
+ // Nullable/optional representation options (mutually exclusive):
924879
+ // collapse-optional-nullable: optional<nullable<T>> (and standalone nullable<T>) collapses to
924880
+ // a single OptionalNullable<T> wrapper.
924881
+ // use-nullable-annotation: nullable<T> is emitted as the raw type T annotated with @Nullable
924882
+ // (no Optional wrapper). Mirrors v1 behaviour when the Java @Nullable annotation is preferred.
924878
924883
  "collapse-optional-nullable": external_exports2.boolean().optional(),
924879
924884
  "use-nullable-annotation": external_exports2.boolean().optional(),
924880
924885
  "custom-readme-sections": external_exports2.array(CustomReadmeSectionSchema).optional(),
@@ -924995,19 +925000,23 @@ var ClassReference2 = class extends AstNode3 {
924995
925000
  name;
924996
925001
  packageName;
924997
925002
  fullyQualified;
924998
- constructor({ name: name2, packageName, fullyQualified }) {
925003
+ enclosingClasses;
925004
+ constructor({ name: name2, packageName, fullyQualified, enclosingClasses }) {
924999
925005
  super();
925000
925006
  this.name = name2;
925001
925007
  this.packageName = packageName;
925002
925008
  this.fullyQualified = fullyQualified ?? false;
925009
+ this.enclosingClasses = enclosingClasses ?? [];
925003
925010
  }
925004
925011
  write(writer2) {
925005
- writer2.addImport(`${this.packageName}.${this.name}`);
925012
+ const topLevelClassName = this.enclosingClasses[0] ?? this.name;
925013
+ const qualifiedName = [...this.enclosingClasses, this.name].join(".");
925014
+ writer2.addImport(`${this.packageName}.${topLevelClassName}`);
925006
925015
  if (this.fullyQualified) {
925007
- writer2.write(`${this.packageName}.${this.name}`);
925016
+ writer2.write(`${this.packageName}.${qualifiedName}`);
925008
925017
  return;
925009
925018
  }
925010
- writer2.write(this.name);
925019
+ writer2.write(qualifiedName);
925011
925020
  }
925012
925021
  };
925013
925022
 
@@ -926212,11 +926221,21 @@ var DynamicTypeLiteralMapper = class {
926212
926221
  }
926213
926222
  switch (args.typeReference.type) {
926214
926223
  case "list":
926215
- return this.convertList({ list: args.typeReference.value, value: args.value, as: args.as });
926224
+ return this.convertList({
926225
+ list: args.typeReference.value,
926226
+ value: args.value,
926227
+ as: args.as,
926228
+ nestedClassReference: args.nestedClassReference
926229
+ });
926216
926230
  case "literal":
926217
926231
  return this.convertLiteral({ literal: args.typeReference.value, value: args.value });
926218
926232
  case "map":
926219
- return this.convertMap({ map: args.typeReference, value: args.value, as: args.as });
926233
+ return this.convertMap({
926234
+ map: args.typeReference,
926235
+ value: args.value,
926236
+ as: args.as,
926237
+ nestedClassReference: args.nestedClassReference
926238
+ });
926220
926239
  case "named": {
926221
926240
  const named = this.context.resolveNamedType({ typeId: args.typeReference.value });
926222
926241
  if (named == null) {
@@ -926226,7 +926245,8 @@ var DynamicTypeLiteralMapper = class {
926226
926245
  named,
926227
926246
  value: args.value,
926228
926247
  as: args.as,
926229
- inUndiscriminatedUnion: args.inUndiscriminatedUnion
926248
+ inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926249
+ nestedClassReference: args.nestedClassReference
926230
926250
  });
926231
926251
  }
926232
926252
  case "nullable":
@@ -926255,11 +926275,16 @@ var DynamicTypeLiteralMapper = class {
926255
926275
  value: args.value,
926256
926276
  as: args.as,
926257
926277
  inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926258
- isCollapsedOptionalNullable: true
926278
+ isCollapsedOptionalNullable: true,
926279
+ nestedClassReference: args.nestedClassReference
926259
926280
  });
926260
926281
  }
926261
926282
  if (inner2.type === "list") {
926262
- const listLiteral = this.convertList({ list: inner2.value, value: args.value });
926283
+ const listLiteral = this.convertList({
926284
+ list: inner2.value,
926285
+ value: args.value,
926286
+ nestedClassReference: args.nestedClassReference
926287
+ });
926263
926288
  return this.wrapNullableOrOptionalValue({
926264
926289
  value: listLiteral,
926265
926290
  wrapperType,
@@ -926271,7 +926296,8 @@ var DynamicTypeLiteralMapper = class {
926271
926296
  typeReference: inner2,
926272
926297
  value: args.value,
926273
926298
  as: args.as,
926274
- inUndiscriminatedUnion: args.inUndiscriminatedUnion
926299
+ inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926300
+ nestedClassReference: args.nestedClassReference
926275
926301
  });
926276
926302
  const useOf = args.as === "mapValue" || args.inUndiscriminatedUnion === true;
926277
926303
  return this.wrapNullableOrOptionalValue({
@@ -926284,14 +926310,19 @@ var DynamicTypeLiteralMapper = class {
926284
926310
  case "primitive":
926285
926311
  return this.convertPrimitive({ primitive: args.typeReference.value, value: args.value, as: args.as });
926286
926312
  case "set":
926287
- return this.convertSet({ set: args.typeReference.value, value: args.value, as: args.as });
926313
+ return this.convertSet({
926314
+ set: args.typeReference.value,
926315
+ value: args.value,
926316
+ as: args.as,
926317
+ nestedClassReference: args.nestedClassReference
926318
+ });
926288
926319
  case "unknown":
926289
926320
  return this.convertUnknown({ value: args.value });
926290
926321
  default:
926291
926322
  assertNever(args.typeReference);
926292
926323
  }
926293
926324
  }
926294
- convertList({ list: list29, value: value2, as: as2 }) {
926325
+ convertList({ list: list29, value: value2, as: as2, nestedClassReference }) {
926295
926326
  if (!Array.isArray(value2)) {
926296
926327
  this.context.errors.add({
926297
926328
  severity: Severity.Critical,
@@ -926306,7 +926337,12 @@ var DynamicTypeLiteralMapper = class {
926306
926337
  this.context.errors.scope({ index: index3 });
926307
926338
  try {
926308
926339
  if (isItemOptional && (list29.type === "optional" || list29.type === "nullable")) {
926309
- const itemValue = this.convert({ typeReference: list29.value, value: v3, as: as2 });
926340
+ const itemValue = this.convert({
926341
+ typeReference: list29.value,
926342
+ value: v3,
926343
+ as: as2,
926344
+ nestedClassReference
926345
+ });
926310
926346
  return this.wrapNullableOrOptionalValue({
926311
926347
  value: itemValue,
926312
926348
  wrapperType: list29.type,
@@ -926314,7 +926350,7 @@ var DynamicTypeLiteralMapper = class {
926314
926350
  propagatedCollapse: false
926315
926351
  });
926316
926352
  }
926317
- return this.convert({ typeReference: list29, value: v3, as: as2 });
926353
+ return this.convert({ typeReference: list29, value: v3, as: as2, nestedClassReference });
926318
926354
  } finally {
926319
926355
  this.context.errors.unscope();
926320
926356
  }
@@ -926343,7 +926379,7 @@ var DynamicTypeLiteralMapper = class {
926343
926379
  assertNever(literal3);
926344
926380
  }
926345
926381
  }
926346
- convertSet({ set: set26, value: value2, as: as2 }) {
926382
+ convertSet({ set: set26, value: value2, as: as2, nestedClassReference }) {
926347
926383
  if (!Array.isArray(value2)) {
926348
926384
  this.context.errors.add({
926349
926385
  severity: Severity.Critical,
@@ -926356,14 +926392,14 @@ var DynamicTypeLiteralMapper = class {
926356
926392
  values: value2.map((v3, index3) => {
926357
926393
  this.context.errors.scope({ index: index3 });
926358
926394
  try {
926359
- return this.convert({ typeReference: set26, value: v3, as: as2 });
926395
+ return this.convert({ typeReference: set26, value: v3, as: as2, nestedClassReference });
926360
926396
  } finally {
926361
926397
  this.context.errors.unscope();
926362
926398
  }
926363
926399
  })
926364
926400
  });
926365
926401
  }
926366
- convertMap({ map: map15, value: value2, as: as2 }) {
926402
+ convertMap({ map: map15, value: value2, as: as2, nestedClassReference }) {
926367
926403
  if (typeof value2 !== "object" || value2 == null) {
926368
926404
  this.context.errors.add({
926369
926405
  severity: Severity.Critical,
@@ -926382,7 +926418,8 @@ var DynamicTypeLiteralMapper = class {
926382
926418
  value: this.convert({
926383
926419
  typeReference: map15.value,
926384
926420
  value: value3,
926385
- as: "mapValue"
926421
+ as: "mapValue",
926422
+ nestedClassReference
926386
926423
  })
926387
926424
  };
926388
926425
  } finally {
@@ -926391,7 +926428,7 @@ var DynamicTypeLiteralMapper = class {
926391
926428
  })
926392
926429
  });
926393
926430
  }
926394
- convertNamed({ named, value: value2, as: as2, inUndiscriminatedUnion }) {
926431
+ convertNamed({ named, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference }) {
926395
926432
  switch (named.type) {
926396
926433
  case "alias":
926397
926434
  if (named.typeReference.type === "unknown") {
@@ -926402,32 +926439,44 @@ var DynamicTypeLiteralMapper = class {
926402
926439
  inUndiscriminatedUnion
926403
926440
  });
926404
926441
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926405
- on: this.context.getJavaClassReferenceFromDeclaration({
926442
+ on: nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926406
926443
  declaration: named.declaration
926407
926444
  }),
926408
926445
  method: "of",
926409
926446
  arguments_: [convertedValue]
926410
926447
  }));
926411
926448
  }
926412
- return this.convert({ typeReference: named.typeReference, value: value2, as: as2, inUndiscriminatedUnion });
926449
+ return this.convert({
926450
+ typeReference: named.typeReference,
926451
+ value: value2,
926452
+ as: as2,
926453
+ inUndiscriminatedUnion,
926454
+ nestedClassReference
926455
+ });
926413
926456
  case "discriminatedUnion":
926414
926457
  return this.convertDiscriminatedUnion({
926415
926458
  discriminatedUnion: named,
926416
926459
  value: value2,
926417
- as: as2
926460
+ as: as2,
926461
+ nestedClassReference
926418
926462
  });
926419
926463
  case "enum":
926420
- return this.convertEnum({ enum_: named, value: value2 });
926464
+ return this.convertEnum({ enum_: named, value: value2, nestedClassReference });
926421
926465
  case "object":
926422
- return this.convertObject({ object_: named, value: value2, as: as2, inUndiscriminatedUnion });
926466
+ return this.convertObject({ object_: named, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference });
926423
926467
  case "undiscriminatedUnion":
926424
- return this.convertUndiscriminatedUnion({ undiscriminatedUnion: named, value: value2, as: as2 });
926468
+ return this.convertUndiscriminatedUnion({
926469
+ undiscriminatedUnion: named,
926470
+ value: value2,
926471
+ as: as2,
926472
+ nestedClassReference
926473
+ });
926425
926474
  default:
926426
926475
  assertNever(named);
926427
926476
  }
926428
926477
  }
926429
- convertDiscriminatedUnion({ discriminatedUnion: discriminatedUnion2, value: value2, as: as2 }) {
926430
- const classReference4 = this.context.getJavaClassReferenceFromDeclaration({
926478
+ convertDiscriminatedUnion({ discriminatedUnion: discriminatedUnion2, value: value2, as: as2, nestedClassReference }) {
926479
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926431
926480
  declaration: discriminatedUnion2.declaration
926432
926481
  });
926433
926482
  const discriminatedUnionTypeInstance = this.context.resolveDiscriminatedUnionTypeInstance({
@@ -926438,6 +926487,8 @@ var DynamicTypeLiteralMapper = class {
926438
926487
  return java_exports.TypeLiteral.nop();
926439
926488
  }
926440
926489
  const unionVariant = discriminatedUnionTypeInstance.singleDiscriminatedUnionType;
926490
+ const reservedNames = /* @__PURE__ */ new Set([...classReference4.enclosingClasses, classReference4.name]);
926491
+ const siblingDiscriminantNames = new Set(Object.values(discriminatedUnion2.types).map((variant) => this.context.getClassName(variant.discriminantValue.name)));
926441
926492
  switch (unionVariant.type) {
926442
926493
  case "samePropertiesAsObject": {
926443
926494
  const named = this.context.resolveNamedType({
@@ -926446,10 +926497,24 @@ var DynamicTypeLiteralMapper = class {
926446
926497
  if (named == null) {
926447
926498
  return java_exports.TypeLiteral.nop();
926448
926499
  }
926500
+ const variantNestedClassReference = this.resolveInlineNestedClassReference({
926501
+ enclosing: classReference4,
926502
+ baseName: this.context.getClassName(unionVariant.discriminantValue.name),
926503
+ typeReference: { type: "named", value: unionVariant.typeId },
926504
+ reservedNames,
926505
+ siblingPropertyNames: siblingDiscriminantNames
926506
+ });
926449
926507
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926450
926508
  on: classReference4,
926451
926509
  method: this.context.getPropertyName(unionVariant.discriminantValue.name),
926452
- arguments_: [this.convertNamed({ named, value: discriminatedUnionTypeInstance.value, as: as2 })]
926510
+ arguments_: [
926511
+ this.convertNamed({
926512
+ named,
926513
+ value: discriminatedUnionTypeInstance.value,
926514
+ as: as2,
926515
+ nestedClassReference: variantNestedClassReference
926516
+ })
926517
+ ]
926453
926518
  }));
926454
926519
  }
926455
926520
  case "singleProperty": {
@@ -926460,6 +926525,13 @@ var DynamicTypeLiteralMapper = class {
926460
926525
  try {
926461
926526
  this.context.errors.scope(unionVariant.discriminantValue.wireValue);
926462
926527
  const propertyKey = "value";
926528
+ const variantNestedClassReference = this.resolveInlineNestedClassReference({
926529
+ enclosing: classReference4,
926530
+ baseName: this.context.getClassName(unionVariant.discriminantValue.name),
926531
+ typeReference: unionVariant.typeReference,
926532
+ reservedNames,
926533
+ siblingPropertyNames: siblingDiscriminantNames
926534
+ });
926463
926535
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926464
926536
  on: classReference4,
926465
926537
  method: this.context.getPropertyName(unionVariant.discriminantValue.name),
@@ -926467,7 +926539,8 @@ var DynamicTypeLiteralMapper = class {
926467
926539
  this.convert({
926468
926540
  typeReference: unionVariant.typeReference,
926469
926541
  value: record23[propertyKey],
926470
- as: as2
926542
+ as: as2,
926543
+ nestedClassReference: variantNestedClassReference
926471
926544
  })
926472
926545
  ]
926473
926546
  }));
@@ -926485,7 +926558,10 @@ var DynamicTypeLiteralMapper = class {
926485
926558
  assertNever(unionVariant);
926486
926559
  }
926487
926560
  }
926488
- convertObject({ object_, value: value2, as: as2, inUndiscriminatedUnion }) {
926561
+ convertObject({ object_, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference }) {
926562
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926563
+ declaration: object_.declaration
926564
+ });
926489
926565
  const valueRecord = this.context.getRecord(value2) ?? {};
926490
926566
  const properties7 = this.context.associateByWireValue({
926491
926567
  parameters: object_.properties,
@@ -926515,6 +926591,8 @@ var DynamicTypeLiteralMapper = class {
926515
926591
  });
926516
926592
  properties7.sort((a3, b5) => (paramOrderMap.get(a3.name.wireValue) ?? 0) - (paramOrderMap.get(b5.name.wireValue) ?? 0));
926517
926593
  const filteredProperties = as2 === "request" ? properties7.filter((property24) => !this.context.isDirectLiteral(property24.typeReference)) : properties7;
926594
+ const reservedNames = /* @__PURE__ */ new Set([...classReference4.enclosingClasses, classReference4.name]);
926595
+ const siblingPropertyNames = new Set(object_.properties.map((property24) => this.context.getClassName(property24.name.name)));
926518
926596
  const builderParameters = [];
926519
926597
  for (const property24 of filteredProperties) {
926520
926598
  this.context.errors.scope(property24.name.wireValue);
@@ -926523,7 +926601,14 @@ var DynamicTypeLiteralMapper = class {
926523
926601
  typeReference: property24.typeReference,
926524
926602
  value: property24.value,
926525
926603
  as: as2,
926526
- inUndiscriminatedUnion
926604
+ inUndiscriminatedUnion,
926605
+ nestedClassReference: this.resolveInlineNestedClassReference({
926606
+ enclosing: classReference4,
926607
+ baseName: this.context.getClassName(property24.name.name),
926608
+ typeReference: property24.typeReference,
926609
+ reservedNames,
926610
+ siblingPropertyNames
926611
+ })
926527
926612
  });
926528
926613
  if (java_exports.TypeLiteral.isNop(convertedValue) && !this.context.isOptional(property24.typeReference)) {
926529
926614
  if (inUndiscriminatedUnion === true) {
@@ -926553,12 +926638,146 @@ var DynamicTypeLiteralMapper = class {
926553
926638
  }
926554
926639
  }
926555
926640
  return java_exports.TypeLiteral.builder({
926556
- classReference: this.context.getJavaClassReferenceFromDeclaration({
926557
- declaration: object_.declaration
926558
- }),
926641
+ classReference: classReference4,
926559
926642
  parameters: builderParameters
926560
926643
  });
926561
926644
  }
926645
+ /**
926646
+ * Mirrors the v1 generator's inline-type naming (see ObjectGenerator / InlineTypeIdResolver):
926647
+ * when a property's type resolves to an inline named type, v1 emits it as a class nested within
926648
+ * the enclosing object. This walks the property's type reference (descending through container
926649
+ * wrappers, applying the same name suffixes as v1) and, if it terminates in an inline named type,
926650
+ * returns the nested class reference to use. Returns undefined for non-inline types, which fall
926651
+ * back to the standalone top-level class name.
926652
+ */
926653
+ resolveInlineNestedClassReference({ enclosing, baseName, typeReference: typeReference2, reservedNames, siblingPropertyNames }) {
926654
+ if (!this.context.enableInlineTypes()) {
926655
+ return void 0;
926656
+ }
926657
+ switch (typeReference2.type) {
926658
+ case "optional":
926659
+ case "nullable":
926660
+ return this.resolveInlineNestedClassReference({
926661
+ enclosing,
926662
+ baseName,
926663
+ typeReference: typeReference2.value,
926664
+ reservedNames,
926665
+ siblingPropertyNames
926666
+ });
926667
+ case "list":
926668
+ case "set":
926669
+ return this.resolveInlineNestedClassReference({
926670
+ enclosing,
926671
+ baseName: `${baseName}Item`,
926672
+ typeReference: typeReference2.value,
926673
+ reservedNames,
926674
+ siblingPropertyNames
926675
+ });
926676
+ case "map":
926677
+ return this.resolveInlineNestedClassReference({
926678
+ enclosing,
926679
+ baseName: `${baseName}Value`,
926680
+ typeReference: typeReference2.value,
926681
+ reservedNames,
926682
+ siblingPropertyNames
926683
+ });
926684
+ case "named": {
926685
+ const typeId = typeReference2.value;
926686
+ const named = this.context.resolveNamedType({ typeId });
926687
+ if (named == null) {
926688
+ return void 0;
926689
+ }
926690
+ if (named.type === "alias" && !this.context.wrappedAliases()) {
926691
+ return this.resolveInlineNestedClassReference({
926692
+ enclosing,
926693
+ baseName,
926694
+ typeReference: named.typeReference,
926695
+ reservedNames,
926696
+ siblingPropertyNames
926697
+ });
926698
+ }
926699
+ if (!this.context.isInlineType(typeId)) {
926700
+ return void 0;
926701
+ }
926702
+ let name2 = baseName;
926703
+ while (reservedNames.has(name2) || siblingPropertyNames.has(name2) && name2 !== baseName) {
926704
+ name2 = `${name2}_`;
926705
+ }
926706
+ reservedNames.add(name2);
926707
+ return this.context.getNestedInlineClassReference({ enclosing, name: name2 });
926708
+ }
926709
+ case "primitive":
926710
+ case "literal":
926711
+ case "unknown":
926712
+ return void 0;
926713
+ default:
926714
+ assertNever(typeReference2);
926715
+ }
926716
+ }
926717
+ /**
926718
+ * Resolves the nested class reference for an inline member of an undiscriminated union.
926719
+ * Unlike object properties and discriminated-union variants (whose nested name is derived
926720
+ * from the property/discriminant name), v1 names an undiscriminated union's inline members
926721
+ * after the member type's own name, with the union's name stripped as a prefix (see
926722
+ * UndiscriminatedUnionGenerator). Descends through container wrappers to the terminal named
926723
+ * type.
926724
+ */
926725
+ resolveUndiscriminatedInlineNestedClassReference({ enclosing, typeReference: typeReference2, reservedNames, unionPrefix }) {
926726
+ if (!this.context.enableInlineTypes()) {
926727
+ return void 0;
926728
+ }
926729
+ switch (typeReference2.type) {
926730
+ case "optional":
926731
+ case "nullable":
926732
+ case "list":
926733
+ case "set":
926734
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926735
+ enclosing,
926736
+ typeReference: typeReference2.value,
926737
+ reservedNames,
926738
+ unionPrefix
926739
+ });
926740
+ case "map":
926741
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926742
+ enclosing,
926743
+ typeReference: typeReference2.value,
926744
+ reservedNames,
926745
+ unionPrefix
926746
+ });
926747
+ case "named": {
926748
+ const typeId = typeReference2.value;
926749
+ const named = this.context.resolveNamedType({ typeId });
926750
+ if (named == null) {
926751
+ return void 0;
926752
+ }
926753
+ if (named.type === "alias" && !this.context.wrappedAliases()) {
926754
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926755
+ enclosing,
926756
+ typeReference: named.typeReference,
926757
+ reservedNames,
926758
+ unionPrefix
926759
+ });
926760
+ }
926761
+ if (!this.context.isInlineType(typeId)) {
926762
+ return void 0;
926763
+ }
926764
+ let name2 = this.context.getClassName(named.declaration.name);
926765
+ if (name2.startsWith(unionPrefix) && name2 !== unionPrefix) {
926766
+ name2 = name2.substring(unionPrefix.length);
926767
+ }
926768
+ while (reservedNames.has(name2)) {
926769
+ name2 = `${name2}_`;
926770
+ }
926771
+ return this.context.getNestedInlineClassReference({ enclosing, name: name2 });
926772
+ }
926773
+ case "primitive":
926774
+ case "literal":
926775
+ case "unknown":
926776
+ return void 0;
926777
+ default:
926778
+ assertNever(typeReference2);
926779
+ }
926780
+ }
926562
926781
  /**
926563
926782
  * Returns true when a property becomes a required stage in v1's staged builder. v1 stages
926564
926783
  * fields that are neither optional, nullable, nor collections (list/set/map); those are all
@@ -926676,13 +926895,13 @@ var DynamicTypeLiteralMapper = class {
926676
926895
  return "string";
926677
926896
  }
926678
926897
  }
926679
- convertEnum({ enum_: enum_25, value: value2 }) {
926898
+ convertEnum({ enum_: enum_25, value: value2, nestedClassReference }) {
926680
926899
  const name2 = this.getEnumValueName({ enum_: enum_25, value: value2 });
926681
926900
  if (name2 == null) {
926682
926901
  return java_exports.TypeLiteral.nop();
926683
926902
  }
926684
926903
  return java_exports.TypeLiteral.enum_({
926685
- classReference: this.context.getJavaClassReferenceFromDeclaration({
926904
+ classReference: nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926686
926905
  declaration: enum_25.declaration
926687
926906
  }),
926688
926907
  value: name2
@@ -926706,33 +926925,28 @@ var DynamicTypeLiteralMapper = class {
926706
926925
  }
926707
926926
  return this.context.getEnumName(enumValue.name);
926708
926927
  }
926709
- convertUndiscriminatedUnion({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2 }) {
926928
+ convertUndiscriminatedUnion({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2, nestedClassReference }) {
926929
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926930
+ declaration: undiscriminatedUnion22.declaration
926931
+ });
926710
926932
  const result = this.findMatchingUndiscriminatedUnionType({
926711
926933
  undiscriminatedUnion: undiscriminatedUnion22,
926712
926934
  value: value2,
926713
- as: as2
926935
+ as: as2,
926936
+ enclosing: classReference4
926714
926937
  });
926715
926938
  if (result == null) {
926716
926939
  return java_exports.TypeLiteral.nop();
926717
926940
  }
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
926941
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926728
- on: this.context.getJavaClassReferenceFromDeclaration({
926729
- declaration: undiscriminatedUnion22.declaration
926730
- }),
926942
+ on: classReference4,
926731
926943
  method: "of",
926732
926944
  arguments_: [result.typeInstantiation]
926733
926945
  }));
926734
926946
  }
926735
- findMatchingUndiscriminatedUnionType({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2 }) {
926947
+ findMatchingUndiscriminatedUnionType({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2, enclosing }) {
926948
+ const reservedNames = /* @__PURE__ */ new Set([...enclosing.enclosingClasses, enclosing.name]);
926949
+ const unionPrefix = this.context.getClassName(undiscriminatedUnion22.declaration.name);
926736
926950
  for (const typeReference2 of undiscriminatedUnion22.types) {
926737
926951
  const errorsBefore = this.context.errors.size();
926738
926952
  try {
@@ -926740,7 +926954,13 @@ var DynamicTypeLiteralMapper = class {
926740
926954
  typeReference: typeReference2,
926741
926955
  value: value2,
926742
926956
  as: as2,
926743
- inUndiscriminatedUnion: true
926957
+ inUndiscriminatedUnion: true,
926958
+ nestedClassReference: this.resolveUndiscriminatedInlineNestedClassReference({
926959
+ enclosing,
926960
+ typeReference: typeReference2,
926961
+ reservedNames: new Set(reservedNames),
926962
+ unionPrefix
926963
+ })
926744
926964
  });
926745
926965
  if (java_exports.TypeLiteral.isNop(typeInstantiation) || this.context.errors.size() > errorsBefore) {
926746
926966
  this.context.errors.truncate(errorsBefore);
@@ -927064,7 +927284,7 @@ var DynamicTypeMapper3 = class {
927064
927284
  }
927065
927285
  case "optional": {
927066
927286
  const inner2 = args.typeReference.value;
927067
- if (this.context.usesOptionalNullable() && inner2.type === "nullable") {
927287
+ if (this.context.usesOptionalNullable() && (inner2.type === "nullable" || inner2.type === "optional")) {
927068
927288
  return java_exports.Type.generic(this.context.getOptionalNullableClassReference(), [
927069
927289
  this.convert({ typeReference: inner2.value })
927070
927290
  ]);
@@ -927077,8 +927297,9 @@ var DynamicTypeMapper3 = class {
927077
927297
  return this.convert({ typeReference: inner2 });
927078
927298
  }
927079
927299
  if (this.context.usesOptionalNullable()) {
927300
+ const collapsed = inner2.type === "optional" || inner2.type === "nullable" ? inner2.value : inner2;
927080
927301
  return java_exports.Type.generic(this.context.getOptionalNullableClassReference(), [
927081
- this.convert({ typeReference: inner2 })
927302
+ this.convert({ typeReference: collapsed })
927082
927303
  ]);
927083
927304
  }
927084
927305
  return java_exports.Type.optional(this.convert({ typeReference: inner2 }));
@@ -927258,22 +927479,51 @@ var DynamicSnippetsGeneratorContext3 = class _DynamicSnippetsGeneratorContext ex
927258
927479
  dynamicTypeMapper;
927259
927480
  dynamicTypeLiteralMapper;
927260
927481
  filePropertyMapper;
927261
- constructor({ ir: ir3, config: config5, options: options2, sharedCustomConfig }) {
927482
+ /**
927483
+ * The set of type IDs that the v1 generator emits as nested (inline) classes rather than
927484
+ * top-level types. The dynamic IR does not carry the `inline` flag, so the v2 SDK generator
927485
+ * computes this from the full IR and threads it through. Used to mirror v1's nested-class
927486
+ * naming when referencing inline types in snippets.
927487
+ */
927488
+ inlineTypeIds;
927489
+ constructor({ ir: ir3, config: config5, options: options2, sharedCustomConfig, inlineTypeIds }) {
927262
927490
  super({ ir: ir3, config: config5, options: options2 });
927263
927491
  this.ir = ir3;
927264
927492
  this.customConfig = sharedCustomConfig ?? BaseJavaCustomConfigSchema.parse(config5.customConfig ?? {});
927265
927493
  this.dynamicTypeMapper = new DynamicTypeMapper3({ context: this });
927266
927494
  this.dynamicTypeLiteralMapper = new DynamicTypeLiteralMapper({ context: this });
927267
927495
  this.filePropertyMapper = new FilePropertyMapper3({ context: this });
927496
+ this.inlineTypeIds = inlineTypeIds ?? /* @__PURE__ */ new Set();
927268
927497
  }
927269
927498
  clone() {
927270
927499
  return new _DynamicSnippetsGeneratorContext({
927271
927500
  ir: this.ir,
927272
927501
  config: this.config,
927273
927502
  options: this.options,
927274
- sharedCustomConfig: this.customConfig
927503
+ sharedCustomConfig: this.customConfig,
927504
+ inlineTypeIds: this.inlineTypeIds
927275
927505
  });
927276
927506
  }
927507
+ isInlineType(typeId) {
927508
+ return this.inlineTypeIds.has(typeId);
927509
+ }
927510
+ /**
927511
+ * Builds a reference to a class nested within `enclosing`. The resulting reference imports the
927512
+ * outermost enclosing class and is written using the dotted path (e.g. `PostRootRequest.Bar`).
927513
+ */
927514
+ getNestedInlineClassReference({ enclosing, name: name2 }) {
927515
+ return java_exports.classReference({
927516
+ name: name2,
927517
+ packageName: enclosing.packageName,
927518
+ enclosingClasses: [...enclosing.enclosingClasses, enclosing.name]
927519
+ });
927520
+ }
927521
+ wrappedAliases() {
927522
+ return this.customConfig?.["wrapped-aliases"] ?? false;
927523
+ }
927524
+ enableInlineTypes() {
927525
+ return this.customConfig?.["enable-inline-types"] ?? false;
927526
+ }
927277
927527
  getClassName(name2) {
927278
927528
  return this.getName(name2.pascalCase.safeName);
927279
927529
  }
@@ -928178,18 +928428,20 @@ var EndpointSnippetGenerator3 = class {
928178
928428
  })
928179
928429
  }));
928180
928430
  this.context.errors.unscope();
928431
+ const requestClassReference = java_exports.classReference({
928432
+ name: this.context.getClassName(request7.declaration.name),
928433
+ packageName: this.context.getRequestsPackageName(request7.declaration.fernFilepath)
928434
+ });
928181
928435
  this.context.errors.scope(Scope4.RequestBody);
928182
928436
  const requestBodyFields = request7.body != null ? this.getInlinedRequestBodyBuilderParameters({
928183
928437
  body: request7.body,
928184
928438
  value: snippet.requestBody,
928185
- filePropertyInfo
928439
+ filePropertyInfo,
928440
+ enclosing: requestClassReference
928186
928441
  }) : [];
928187
928442
  this.context.errors.unscope();
928188
928443
  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
- }),
928444
+ classReference: requestClassReference,
928193
928445
  parameters: [...pathParameterFields, ...headerFields, ...queryParameterFields, ...requestBodyFields]
928194
928446
  });
928195
928447
  }
@@ -928233,10 +928485,14 @@ var EndpointSnippetGenerator3 = class {
928233
928485
  });
928234
928486
  return java_exports.TypeLiteral.reference(buildMethodCall);
928235
928487
  }
928236
- getInlinedRequestBodyBuilderParameters({ body, value: value2, filePropertyInfo }) {
928488
+ getInlinedRequestBodyBuilderParameters({ body, value: value2, filePropertyInfo, enclosing }) {
928237
928489
  switch (body.type) {
928238
928490
  case "properties":
928239
- return this.getInlinedRequestBodyPropertyBuilderParameters({ parameters: body.value, value: value2 });
928491
+ return this.getInlinedRequestBodyPropertyBuilderParameters({
928492
+ parameters: body.value,
928493
+ value: value2,
928494
+ enclosing
928495
+ });
928240
928496
  case "referenced":
928241
928497
  return [this.getReferencedRequestBodyPropertyBuilderParameter({ body, value: value2 })];
928242
928498
  case "fileUpload":
@@ -928271,19 +928527,28 @@ var EndpointSnippetGenerator3 = class {
928271
928527
  assertNever(body);
928272
928528
  }
928273
928529
  }
928274
- getInlinedRequestBodyPropertyBuilderParameters({ parameters: parameters2, value: value2 }) {
928530
+ getInlinedRequestBodyPropertyBuilderParameters({ parameters: parameters2, value: value2, enclosing }) {
928275
928531
  const bodyProperties = this.context.associateByWireValue({
928276
928532
  parameters: parameters2,
928277
928533
  values: this.context.getRecord(value2) ?? {}
928278
928534
  });
928279
928535
  const filteredProperties = bodyProperties.filter((parameter6) => !this.context.isDirectLiteral(parameter6.typeReference));
928280
928536
  const sortedProperties = this.context.sortTypeInstancesByRequiredFirst(filteredProperties, parameters2);
928537
+ const reservedNames = /* @__PURE__ */ new Set([...enclosing.enclosingClasses, enclosing.name]);
928538
+ const siblingPropertyNames = new Set(parameters2.map((parameter6) => this.context.getClassName(parameter6.name.name)));
928281
928539
  return sortedProperties.map((parameter6) => ({
928282
928540
  name: this.context.getMethodName(parameter6.name.name),
928283
928541
  value: this.context.dynamicTypeLiteralMapper.convert({
928284
928542
  typeReference: parameter6.typeReference,
928285
928543
  value: parameter6.value,
928286
- as: "request"
928544
+ as: "request",
928545
+ nestedClassReference: this.context.dynamicTypeLiteralMapper.resolveInlineNestedClassReference({
928546
+ enclosing,
928547
+ baseName: this.context.getClassName(parameter6.name.name),
928548
+ typeReference: parameter6.typeReference,
928549
+ reservedNames,
928550
+ siblingPropertyNames
928551
+ })
928287
928552
  })
928288
928553
  }));
928289
928554
  }
@@ -928318,8 +928583,8 @@ var EndpointSnippetGenerator3 = class {
928318
928583
 
928319
928584
  // ../../../generators/java-v2/dynamic-snippets/lib/DynamicSnippetsGenerator.js
928320
928585
  var DynamicSnippetsGenerator3 = class extends AbstractDynamicSnippetsGenerator {
928321
- constructor({ ir: ir3, config: config5, options: options2 = {} }) {
928322
- super(new DynamicSnippetsGeneratorContext3({ ir: ir3, config: config5, options: options2 }));
928586
+ constructor({ ir: ir3, config: config5, options: options2 = {}, inlineTypeIds }) {
928587
+ super(new DynamicSnippetsGeneratorContext3({ ir: ir3, config: config5, options: options2, inlineTypeIds }));
928323
928588
  }
928324
928589
  async generate(request7, options2 = {}) {
928325
928590
  return super.generate(request7, options2);
@@ -928344,15 +928609,18 @@ var DynamicSnippetsJavaTestGenerator = class {
928344
928609
  context;
928345
928610
  ir;
928346
928611
  generatorConfig;
928612
+ inlineTypeIds;
928347
928613
  dynamicSnippetsGenerator;
928348
- constructor(context3, ir3, generatorConfig) {
928614
+ constructor(context3, ir3, generatorConfig, inlineTypeIds) {
928349
928615
  this.context = context3;
928350
928616
  this.ir = ir3;
928351
928617
  this.generatorConfig = generatorConfig;
928618
+ this.inlineTypeIds = inlineTypeIds;
928352
928619
  this.dynamicSnippetsGenerator = new DynamicSnippetsGenerator3({
928353
928620
  // biome-ignore lint/suspicious/noExplicitAny: workaround for version incompatibility - see note above
928354
928621
  ir: convertIr(this.ir),
928355
- config: this.generatorConfig
928622
+ config: this.generatorConfig,
928623
+ inlineTypeIds: this.inlineTypeIds
928356
928624
  });
928357
928625
  }
928358
928626
  async generateTests({ outputDir, requests: requests3 }) {
@@ -950663,7 +950931,7 @@ var DynamicSnippetsTestGenerator = class _DynamicSnippetsTestGenerator {
950663
950931
  this.context.logger.debug(`Skipping dynamic snippets test generation for language "${language}"`);
950664
950932
  return;
950665
950933
  }
950666
- return new config5.generator(this.context, this.testSuite.ir, this.testSuite.config).generateTests({
950934
+ return new config5.generator(this.context, this.testSuite.ir, this.testSuite.config, this.testSuite.inlineTypeIds).generateTests({
950667
950935
  outputDir,
950668
950936
  requests: this.testSuite.requests
950669
950937
  });
@@ -950679,9 +950947,11 @@ async function generateDynamicSnippetsTestSuite({ ir: ir3, config: config5 }) {
950679
950947
  code: CliError.Code.InternalError
950680
950948
  });
950681
950949
  }
950950
+ const inlineTypeIds = new Set(Object.values(ir3.types).filter((typeDeclaration2) => typeDeclaration2.inline === true).map((typeDeclaration2) => typeDeclaration2.name.typeId));
950682
950951
  return {
950683
950952
  ir: ir3.dynamic,
950684
950953
  config: config5,
950954
+ inlineTypeIds,
950685
950955
  requests: Object.entries(ir3.dynamic.endpoints).flatMap(([endpointId, endpoint3]) => (endpoint3.examples ?? []).map((example) => ({
950686
950956
  endpointId,
950687
950957
  request: {
@@ -964670,7 +964940,7 @@ function getAutomationContextFromEnv() {
964670
964940
  config_branch: process.env.FERN_CONFIG_BRANCH,
964671
964941
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
964672
964942
  trigger: process.env.GITHUB_EVENT_NAME,
964673
- cli_version: "5.23.3-832-gfa15174fbb2"
964943
+ cli_version: "5.23.3-839-gd570dc5b08c"
964674
964944
  };
964675
964945
  }
964676
964946
  function isAutomationMode() {
@@ -965502,7 +965772,7 @@ var CliContext = class _CliContext {
965502
965772
  if (false) {
965503
965773
  this.logger.error("CLI_VERSION is not defined");
965504
965774
  }
965505
- return "5.23.3-832-gfa15174fbb2";
965775
+ return "5.23.3-839-gd570dc5b08c";
965506
965776
  }
965507
965777
  getCliName() {
965508
965778
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.23.3-832-gfa15174fbb2",
2
+ "version": "5.23.3-839-gd570dc5b08c",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",