@fern-api/fern-api-dev 5.50.1 → 5.50.3

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 +593 -190
  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.50.1",
685539
+ version: "5.50.3",
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.50.1",
685605
+ version: "5.50.3",
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.50.1";
866667
+ const version7 = "5.50.3";
866668
866668
  return `cli@${version7}`;
866669
866669
  }
866670
866670
  var DebugLogger = class {
@@ -897373,8 +897373,6 @@ async function buildAllTranslationInputs({ docsDefinition, git, apiDefinitions,
897373
897373
 
897374
897374
  // ../generation/remote-generation/remote-workspace-runner/lib/publishDocsLedgerPreview.js
897375
897375
  init_orpc_client();
897376
- init_buildTranslatedDocsDefinition();
897377
- var TRANSLATION_BUILD_CONCURRENCY2 = 4;
897378
897376
  async function publishDocsViaLedgerPreview({ docsDefinition, organization, basePath, previewId, git, token, fdrOrigin, headers: headers2, context: context3, apiDefinitions, fileManifest, filePaths, fileIdToPath, resolver: resolver2 }) {
897379
897377
  const { localeEntry: baseLocale, blobs } = buildLedgerInput({
897380
897378
  docsDefinition,
@@ -897383,28 +897381,21 @@ async function publishDocsViaLedgerPreview({ docsDefinition, organization, baseP
897383
897381
  fileManifest,
897384
897382
  fileIdToPath
897385
897383
  });
897386
- const builtTranslationDefs = await buildAllTranslationDefinitions({
897384
+ const builtTranslations = await buildAllTranslationInputs({
897387
897385
  docsDefinition,
897386
+ git,
897387
+ apiDefinitions,
897388
+ fileManifest,
897389
+ fileIdToPath,
897388
897390
  resolver: resolver2,
897389
897391
  context: context3
897390
897392
  });
897391
- const translationInputs = builtTranslationDefs.map((t3) => {
897392
- const { localeEntry, blobs: translationBlobs } = buildLedgerInput({
897393
- docsDefinition: t3.translatedDefinition,
897394
- git,
897395
- apiDefinitions,
897396
- fileManifest,
897397
- fileIdToPath,
897398
- locale: t3.locale
897399
- });
897400
- return { ...t3, localeEntry, blobs: translationBlobs };
897401
- });
897402
- for (const t3 of translationInputs) {
897393
+ for (const t3 of builtTranslations) {
897403
897394
  for (const [hash5, buf] of t3.blobs) {
897404
897395
  blobs.set(hash5, buf);
897405
897396
  }
897406
897397
  }
897407
- const locales = [baseLocale, ...translationInputs.map((t3) => t3.localeEntry)];
897398
+ const locales = [baseLocale, ...builtTranslations.map((t3) => t3.localeEntry)];
897408
897399
  const client3 = createDocsLedgerClient2({ baseUrl: fdrOrigin, token, headers: headers2 });
897409
897400
  context3.logger.debug("[ledger-preview] Registering preview deployment...");
897410
897401
  const registerStart = performance.now();
@@ -897428,12 +897419,7 @@ async function publishDocsViaLedgerPreview({ docsDefinition, organization, baseP
897428
897419
  repo: baseLocale.repo,
897429
897420
  git
897430
897421
  };
897431
- const registerResult = await previewRegisterWithLocales({
897432
- fdrOrigin,
897433
- token,
897434
- headers: headers2,
897435
- input: previewRegisterInput
897436
- });
897422
+ const registerResult = await client3.previewRegister(previewRegisterInput);
897437
897423
  const registerTime = performance.now() - registerStart;
897438
897424
  context3.logger.debug(`[ledger-preview] Registered in ${registerTime.toFixed(0)}ms \u2014 hash=${registerResult.deploymentHash}, preview=${registerResult.previewUrl}, missing=${registerResult.missingContent.length} blobs`);
897439
897425
  await uploadMissingBlobs(registerResult.missingContent, blobs, context3, filePaths);
@@ -897460,50 +897446,36 @@ async function publishDocsViaLedgerPreview({ docsDefinition, organization, baseP
897460
897446
  deploymentId: finishResult.deploymentId
897461
897447
  };
897462
897448
  }
897463
- async function buildAllTranslationDefinitions({ docsDefinition, resolver: resolver2, context: context3 }) {
897464
- if (resolver2 == null) {
897465
- return [];
897466
- }
897467
- const translationPages = resolver2.getTranslationPages();
897468
- const translationNavigationOverlays = resolver2.getTranslationNavigationOverlays();
897469
- if (translationPages == null || Object.keys(translationPages).length === 0) {
897470
- return [];
897471
- }
897472
- const localeEntries = Object.entries(translationPages);
897473
- context3.logger.info(`[ledger-preview] Building ${localeEntries.length} translation locale(s)...`);
897474
- return asyncPool2(TRANSLATION_BUILD_CONCURRENCY2, localeEntries, async ([locale, localePages]) => {
897475
- const translatedDefinition = await buildTranslatedDocsDefinition({
897476
- docsDefinition,
897477
- locale,
897478
- localePages,
897479
- translationNavigationOverlays,
897480
- resolver: resolver2,
897481
- context: context3
897482
- });
897483
- return { locale, localePages, translatedDefinition };
897484
- });
897485
- }
897486
- async function previewRegisterWithLocales({ fdrOrigin, token, headers: headers2, input: input3 }) {
897487
- const response = await fetch(`${fdrOrigin.replace(/\/+$/, "")}/docs-ledger/preview/init`, {
897488
- method: "POST",
897489
- headers: {
897490
- "Content-Type": "application/json",
897491
- Authorization: `Bearer ${token}`,
897492
- ...headers2
897493
- },
897494
- body: JSON.stringify(input3)
897495
- });
897496
- if (!response.ok) {
897497
- const body = await response.text();
897498
- throw new Error(`[ledger-preview] Preview register failed: HTTP ${response.status}: ${body}`);
897449
+
897450
+ // ../generation/remote-generation/remote-workspace-runner/lib/retryWithBackoff.js
897451
+ async function retryWithBackoff({ fn: fn2, maxRetries, baseDelayMs, jitterFactor = 0, isRetryable = () => true, logger: logger4, label, delayFn = (ms2) => new Promise((resolve15) => setTimeout(resolve15, ms2)) }) {
897452
+ let lastError;
897453
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
897454
+ try {
897455
+ return await fn2();
897456
+ } catch (error50) {
897457
+ lastError = error50;
897458
+ if (!isRetryable(error50) || attempt >= maxRetries) {
897459
+ throw error50;
897460
+ }
897461
+ const jitter = jitterFactor > 0 ? 1 + (Math.random() - 0.5) * jitterFactor : 1;
897462
+ const delayMs = Math.round(baseDelayMs * 2 ** attempt * jitter);
897463
+ if (label != null) {
897464
+ logger4.warn(`${label} (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delayMs}ms...`);
897465
+ }
897466
+ await delayFn(delayMs);
897467
+ }
897499
897468
  }
897500
- return await response.json();
897469
+ throw lastError;
897501
897470
  }
897502
897471
 
897503
897472
  // ../generation/remote-generation/remote-workspace-runner/lib/publishDocs.js
897504
897473
  var MEASURE_IMAGE_BATCH_SIZE = 10;
897505
897474
  var UPLOAD_FILE_BATCH_SIZE = 10;
897506
897475
  var HASH_CONCURRENCY = parseInt(process.env.FERN_DOCS_ASSET_HASH_CONCURRENCY ?? "32", 10);
897476
+ var REGISTER_MAX_RETRIES = 3;
897477
+ var REGISTER_BASE_DELAY_MS = 1e3;
897478
+ var REGISTER_JITTER_FACTOR = 0.5;
897507
897479
  function sanitizePreviewId2(id) {
897508
897480
  const sanitized = id.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
897509
897481
  if (sanitized.length === 0) {
@@ -897678,13 +897650,22 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain3
897678
897650
  };
897679
897651
  }
897680
897652
  }
897653
+ const effectiveApiName = apiName ?? getOriginalName(ir3.apiName);
897681
897654
  let response;
897682
897655
  try {
897683
- response = await fdr.api.register.registerApiDefinition({
897684
- orgId: FdrAPI_exports.OrgId(organization),
897685
- apiId: FdrAPI_exports.ApiId(apiName ?? getOriginalName(ir3.apiName)),
897686
- definition: apiDefinition,
897687
- dynamicIRs: dynamicIRsByLanguage
897656
+ response = await retryWithBackoff({
897657
+ fn: () => fdr.api.register.registerApiDefinition({
897658
+ orgId: FdrAPI_exports.OrgId(organization),
897659
+ apiId: FdrAPI_exports.ApiId(effectiveApiName),
897660
+ definition: apiDefinition,
897661
+ dynamicIRs: dynamicIRsByLanguage
897662
+ }),
897663
+ maxRetries: REGISTER_MAX_RETRIES,
897664
+ baseDelayMs: REGISTER_BASE_DELAY_MS,
897665
+ jitterFactor: REGISTER_JITTER_FACTOR,
897666
+ isRetryable: isTransientError,
897667
+ logger: context3.logger,
897668
+ label: `registerApiDefinition failed for ${effectiveApiName}`
897688
897669
  });
897689
897670
  } catch (error50) {
897690
897671
  const errorDetails = extractErrorDetails(error50);
@@ -898705,6 +898686,15 @@ function getAIEnhancerConfig(withAiExamples, styleInstructions) {
898705
898686
  styleInstructions
898706
898687
  };
898707
898688
  }
898689
+ function isTransientError(error50) {
898690
+ const errorObj = error50;
898691
+ const content5 = errorObj?.content;
898692
+ const status = errorObj?.statusCode ?? content5?.statusCode;
898693
+ if (status == null) {
898694
+ return true;
898695
+ }
898696
+ return status === 429 || status >= 500;
898697
+ }
898708
898698
  function extractErrorDetails(error50) {
898709
898699
  const errorObj = error50;
898710
898700
  const content5 = errorObj?.content;
@@ -898848,7 +898838,7 @@ var LegacyDocsPublisher = class {
898848
898838
  previewId,
898849
898839
  disableTemplates: void 0,
898850
898840
  skipUpload,
898851
- cliVersion: "5.50.1",
898841
+ cliVersion: "5.50.3",
898852
898842
  loginCommand: "fern auth login"
898853
898843
  });
898854
898844
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -920442,6 +920432,7 @@ var DynamicSnippetsGeneratorContext = class _DynamicSnippetsGeneratorContext ext
920442
920432
  // ../../../generators/csharp/dynamic-snippets/lib/EndpointSnippetGenerator.js
920443
920433
  init_lib4();
920444
920434
  init_lodash();
920435
+ var REQUEST_PARAMETER_NAME = "request";
920445
920436
  var EndpointSnippetGenerator = class extends WithGeneration {
920446
920437
  context;
920447
920438
  constructor({ context: context3 }) {
@@ -920818,33 +920809,31 @@ var EndpointSnippetGenerator = class extends WithGeneration {
920818
920809
  }
920819
920810
  }
920820
920811
  getMethodArgsForInlinedRequest({ request: request7, snippet }) {
920821
- const args = [];
920822
920812
  this.context.errors.scope(Scope4.PathParameters);
920823
- const pathParameterFields = [];
920824
920813
  const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
920825
- if (pathParameters.length > 0) {
920826
- pathParameterFields.push(...this.getPathParameters({ namedParameters: pathParameters, snippet }));
920827
- }
920814
+ const includePathParameters = this.context.includePathParametersInWrappedRequest({
920815
+ request: request7,
920816
+ inlinePathParameters: this.settings.shouldInlinePathParameters
920817
+ });
920818
+ const pathParameterFields = includePathParameters ? this.getPathParameters({ namedParameters: pathParameters, snippet }) : [];
920819
+ const separatePathParameterArgs = includePathParameters ? [] : this.getPathParameterArguments({ namedParameters: pathParameters, snippet });
920828
920820
  this.context.errors.unscope();
920829
920821
  this.context.errors.scope(Scope4.RequestBody);
920830
920822
  const filePropertyInfo = this.getFilePropertyInfo({ request: request7, snippet });
920831
920823
  this.context.errors.unscope();
920832
- if (!this.context.includePathParametersInWrappedRequest({
920833
- request: request7,
920834
- inlinePathParameters: this.settings.shouldInlinePathParameters
920835
- })) {
920836
- args.push(...pathParameterFields.map((field5) => field5.value));
920837
- }
920838
- args.push(this.getInlinedRequestArg({
920824
+ const requestArg = this.getInlinedRequestArg({
920839
920825
  request: request7,
920840
920826
  snippet,
920841
- pathParameterFields: this.context.includePathParametersInWrappedRequest({
920842
- request: request7,
920843
- inlinePathParameters: this.settings.shouldInlinePathParameters
920844
- }) ? pathParameterFields : [],
920827
+ pathParameterFields,
920845
920828
  filePropertyInfo
920846
- }));
920847
- return args;
920829
+ });
920830
+ if (separatePathParameterArgs.length > 0) {
920831
+ return [
920832
+ ...separatePathParameterArgs.map((arg) => this.namedArgument({ name: arg.name, value: arg.value })),
920833
+ this.namedArgument({ name: REQUEST_PARAMETER_NAME, value: requestArg })
920834
+ ];
920835
+ }
920836
+ return [requestArg];
920848
920837
  }
920849
920838
  getFilePropertyInfo({ request: request7, snippet }) {
920850
920839
  if (request7.body == null || !this.context.isFileUploadRequestBody(request7.body)) {
@@ -920956,20 +920945,44 @@ var EndpointSnippetGenerator = class extends WithGeneration {
920956
920945
  }
920957
920946
  }
920958
920947
  getMethodArgsForBodyRequest({ request: request7, snippet }) {
920959
- const args = [];
920960
920948
  this.context.errors.scope(Scope4.PathParameters);
920961
920949
  const pathParameters = [...this.context.ir.pathParameters ?? [], ...request7.pathParameters ?? []];
920962
- if (pathParameters.length > 0) {
920963
- args.push(...this.getPathParameters({ namedParameters: pathParameters, snippet }).map((field5) => field5.value));
920964
- }
920950
+ const pathParameterArgs = this.getPathParameterArguments({ namedParameters: pathParameters, snippet });
920965
920951
  this.context.errors.unscope();
920966
920952
  this.context.errors.scope(Scope4.RequestBody);
920967
- if (request7.body != null) {
920968
- args.push(this.getBodyRequestArg({ body: request7.body, value: snippet.requestBody }));
920969
- }
920953
+ const bodyArg = request7.body != null ? this.getBodyRequestArg({ body: request7.body, value: snippet.requestBody }) : void 0;
920970
920954
  this.context.errors.unscope();
920955
+ if (pathParameterArgs.length > 0 && bodyArg != null) {
920956
+ return [
920957
+ ...pathParameterArgs.map((arg) => this.namedArgument({ name: arg.name, value: arg.value })),
920958
+ this.namedArgument({ name: REQUEST_PARAMETER_NAME, value: bodyArg })
920959
+ ];
920960
+ }
920961
+ const args = pathParameterArgs.map((arg) => arg.value);
920962
+ if (bodyArg != null) {
920963
+ args.push(bodyArg);
920964
+ }
920971
920965
  return args;
920972
920966
  }
920967
+ getPathParameterArguments({ namedParameters, snippet }) {
920968
+ const pathParameters = this.context.associateByWireValueOrDefault({
920969
+ parameters: namedParameters,
920970
+ values: snippet.pathParameters ?? {}
920971
+ });
920972
+ return pathParameters.map((parameter6) => ({
920973
+ name: this.context.getParameterName(parameter6.name.name),
920974
+ value: this.context.dynamicLiteralMapper.convert({
920975
+ ...parameter6,
920976
+ fallbackToDefault: parameter6.name.wireValue
920977
+ })
920978
+ }));
920979
+ }
920980
+ namedArgument({ name: name2, value: value2 }) {
920981
+ return this.csharp.codeblock((writer2) => {
920982
+ writer2.write(`${name2}: `);
920983
+ writer2.writeNode(value2);
920984
+ });
920985
+ }
920973
920986
  getBodyRequestArg({ body, value: value2 }) {
920974
920987
  switch (body.type) {
920975
920988
  case "bytes": {
@@ -924832,7 +924845,13 @@ var BaseJavaCustomConfigSchema = external_exports2.object({
924832
924845
  "enable-extensible-builders": external_exports2.boolean().optional(),
924833
924846
  "use-default-request-parameter-values": external_exports2.boolean().optional(),
924834
924847
  "enable-wire-tests": external_exports2.boolean().default(false),
924848
+ // Nullable/optional representation options (mutually exclusive):
924849
+ // collapse-optional-nullable: optional<nullable<T>> (and standalone nullable<T>) collapses to
924850
+ // a single OptionalNullable<T> wrapper.
924851
+ // use-nullable-annotation: nullable<T> is emitted as the raw type T annotated with @Nullable
924852
+ // (no Optional wrapper). Mirrors v1 behaviour when the Java @Nullable annotation is preferred.
924835
924853
  "collapse-optional-nullable": external_exports2.boolean().optional(),
924854
+ "use-nullable-annotation": external_exports2.boolean().optional(),
924836
924855
  "custom-readme-sections": external_exports2.array(CustomReadmeSectionSchema).optional(),
924837
924856
  "custom-pager-name": external_exports2.string().optional(),
924838
924857
  "offset-semantics": external_exports2.enum(["item-index", "page-index"]).optional(),
@@ -924951,19 +924970,23 @@ var ClassReference2 = class extends AstNode3 {
924951
924970
  name;
924952
924971
  packageName;
924953
924972
  fullyQualified;
924954
- constructor({ name: name2, packageName, fullyQualified }) {
924973
+ enclosingClasses;
924974
+ constructor({ name: name2, packageName, fullyQualified, enclosingClasses }) {
924955
924975
  super();
924956
924976
  this.name = name2;
924957
924977
  this.packageName = packageName;
924958
924978
  this.fullyQualified = fullyQualified ?? false;
924979
+ this.enclosingClasses = enclosingClasses ?? [];
924959
924980
  }
924960
924981
  write(writer2) {
924961
- writer2.addImport(`${this.packageName}.${this.name}`);
924982
+ const topLevelClassName = this.enclosingClasses[0] ?? this.name;
924983
+ const qualifiedName = [...this.enclosingClasses, this.name].join(".");
924984
+ writer2.addImport(`${this.packageName}.${topLevelClassName}`);
924962
924985
  if (this.fullyQualified) {
924963
- writer2.write(`${this.packageName}.${this.name}`);
924986
+ writer2.write(`${this.packageName}.${qualifiedName}`);
924964
924987
  return;
924965
924988
  }
924966
- writer2.write(this.name);
924989
+ writer2.write(qualifiedName);
924967
924990
  }
924968
924991
  };
924969
924992
 
@@ -925576,7 +925599,7 @@ var TypeLiteral = class _TypeLiteral extends AstNode3 {
925576
925599
  writer2.write(".build()");
925577
925600
  }
925578
925601
  orderBuilderParameters(parameters2) {
925579
- const hasRequiredFields = parameters2.some((p6) => !p6.value.isOptional() && !this.isCollection(p6.value));
925602
+ const hasRequiredFields = parameters2.some((p6) => this.isRequiredBuilderParameter(p6));
925580
925603
  if (!hasRequiredFields) {
925581
925604
  return parameters2.sort((a3, b5) => {
925582
925605
  const aIsOptional = a3.value.isOptional();
@@ -925591,8 +925614,8 @@ var TypeLiteral = class _TypeLiteral extends AstNode3 {
925591
925614
  });
925592
925615
  }
925593
925616
  return parameters2.sort((a3, b5) => {
925594
- const aIsNonRequired = this.isNonRequired(a3.value);
925595
- const bIsNonRequired = this.isNonRequired(b5.value);
925617
+ const aIsNonRequired = !this.isRequiredBuilderParameter(a3);
925618
+ const bIsNonRequired = !this.isRequiredBuilderParameter(b5);
925596
925619
  if (aIsNonRequired && !bIsNonRequired) {
925597
925620
  return 1;
925598
925621
  }
@@ -925606,6 +925629,12 @@ var TypeLiteral = class _TypeLiteral extends AstNode3 {
925606
925629
  const internalType = value2.internalType.type;
925607
925630
  return internalType === "list" || internalType === "set" || internalType === "map";
925608
925631
  }
925632
+ isRequiredBuilderParameter(parameter6) {
925633
+ if (parameter6.isRequired != null) {
925634
+ return parameter6.isRequired;
925635
+ }
925636
+ return !this.isNonRequired(parameter6.value);
925637
+ }
925609
925638
  isNonRequired(value2) {
925610
925639
  return value2.isOptional() || this.isCollection(value2);
925611
925640
  }
@@ -926116,7 +926145,10 @@ var DynamicTypeLiteralMapper = class {
926116
926145
  this.context = context3;
926117
926146
  }
926118
926147
  usesOptionalNullable() {
926119
- return this.context.customConfig?.["collapse-optional-nullable"] === true;
926148
+ return this.context.usesOptionalNullable();
926149
+ }
926150
+ usesNullableAnnotation() {
926151
+ return this.context.usesNullableAnnotation();
926120
926152
  }
926121
926153
  wrapInOptionalIfNotNop(value2, useOf = false, isCollapsedOptionalNullable = false) {
926122
926154
  if (java_exports.TypeLiteral.isNop(value2)) {
@@ -926127,6 +926159,22 @@ var DynamicTypeLiteralMapper = class {
926127
926159
  }
926128
926160
  return java_exports.TypeLiteral.optional({ value: value2, useOf });
926129
926161
  }
926162
+ // Wraps an already-converted inner value for an `optional`/`nullable` wrapper type, honoring
926163
+ // the `use-nullable-annotation` (raw, no wrapper) and `collapse-optional-nullable`
926164
+ // (OptionalNullable<T>) configs. `propagatedCollapse` is set when an outer optional+nullable
926165
+ // collapsed into this node.
926166
+ wrapNullableOrOptionalValue({ value: value2, wrapperType, useOf, propagatedCollapse }) {
926167
+ if (java_exports.TypeLiteral.isNop(value2)) {
926168
+ return value2;
926169
+ }
926170
+ if (wrapperType === "nullable" && this.usesNullableAnnotation()) {
926171
+ return value2;
926172
+ }
926173
+ if (propagatedCollapse || this.usesOptionalNullable() && wrapperType === "nullable") {
926174
+ return this.context.getOptionalNullableOf(value2);
926175
+ }
926176
+ return java_exports.TypeLiteral.optional({ value: value2, useOf });
926177
+ }
926130
926178
  convert(args) {
926131
926179
  if (args.value === null) {
926132
926180
  if (this.context.isNullable(args.typeReference)) {
@@ -926143,11 +926191,21 @@ var DynamicTypeLiteralMapper = class {
926143
926191
  }
926144
926192
  switch (args.typeReference.type) {
926145
926193
  case "list":
926146
- return this.convertList({ list: args.typeReference.value, value: args.value, as: args.as });
926194
+ return this.convertList({
926195
+ list: args.typeReference.value,
926196
+ value: args.value,
926197
+ as: args.as,
926198
+ nestedClassReference: args.nestedClassReference
926199
+ });
926147
926200
  case "literal":
926148
926201
  return this.convertLiteral({ literal: args.typeReference.value, value: args.value });
926149
926202
  case "map":
926150
- return this.convertMap({ map: args.typeReference, value: args.value, as: args.as });
926203
+ return this.convertMap({
926204
+ map: args.typeReference,
926205
+ value: args.value,
926206
+ as: args.as,
926207
+ nestedClassReference: args.nestedClassReference
926208
+ });
926151
926209
  case "named": {
926152
926210
  const named = this.context.resolveNamedType({ typeId: args.typeReference.value });
926153
926211
  if (named == null) {
@@ -926157,16 +926215,20 @@ var DynamicTypeLiteralMapper = class {
926157
926215
  named,
926158
926216
  value: args.value,
926159
926217
  as: args.as,
926160
- inUndiscriminatedUnion: args.inUndiscriminatedUnion
926218
+ inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926219
+ nestedClassReference: args.nestedClassReference
926161
926220
  });
926162
926221
  }
926163
926222
  case "nullable":
926164
926223
  case "optional": {
926165
- if (args.value === void 0 || typeof args.value === "object" && args.value !== null && Object.keys(args.value).length === 0 && args.typeReference.value.type === "named") {
926166
- const isCollapsed = args.isCollapsedOptionalNullable || this.usesOptionalNullable() && (args.typeReference.value.type === "optional" || args.typeReference.value.type === "nullable");
926167
- if (isCollapsed) {
926168
- return this.context.getOptionalNullableAbsent();
926169
- } else {
926224
+ const wrapperType = args.typeReference.type;
926225
+ const inner2 = args.typeReference.value;
926226
+ if (args.value === void 0 || typeof args.value === "object" && args.value !== null && Object.keys(args.value).length === 0 && inner2.type === "named") {
926227
+ if (!(wrapperType === "nullable" && this.usesNullableAnnotation())) {
926228
+ const isCollapsed = args.isCollapsedOptionalNullable || this.usesOptionalNullable() && (wrapperType === "nullable" || inner2.type === "optional" || inner2.type === "nullable");
926229
+ if (isCollapsed) {
926230
+ return this.context.getOptionalNullableAbsent();
926231
+ }
926170
926232
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926171
926233
  on: java_exports.classReference({
926172
926234
  name: "Optional",
@@ -926177,39 +926239,60 @@ var DynamicTypeLiteralMapper = class {
926177
926239
  }));
926178
926240
  }
926179
926241
  }
926180
- if (args.typeReference.value.type === "list") {
926181
- const listLiteral = this.convertList({ list: args.typeReference.value.value, value: args.value });
926182
- return this.wrapInOptionalIfNotNop(listLiteral, true, args.isCollapsedOptionalNullable === true);
926183
- }
926184
- if (this.usesOptionalNullable() && (args.typeReference.value.type === "optional" || args.typeReference.value.type === "nullable")) {
926242
+ if (this.usesOptionalNullable() && (inner2.type === "optional" || inner2.type === "nullable")) {
926185
926243
  return this.convert({
926186
- typeReference: args.typeReference.value,
926244
+ typeReference: inner2,
926187
926245
  value: args.value,
926188
926246
  as: args.as,
926189
926247
  inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926190
- isCollapsedOptionalNullable: true
926248
+ isCollapsedOptionalNullable: true,
926249
+ nestedClassReference: args.nestedClassReference
926250
+ });
926251
+ }
926252
+ if (inner2.type === "list") {
926253
+ const listLiteral = this.convertList({
926254
+ list: inner2.value,
926255
+ value: args.value,
926256
+ nestedClassReference: args.nestedClassReference
926257
+ });
926258
+ return this.wrapNullableOrOptionalValue({
926259
+ value: listLiteral,
926260
+ wrapperType,
926261
+ useOf: true,
926262
+ propagatedCollapse: args.isCollapsedOptionalNullable === true
926191
926263
  });
926192
926264
  }
926193
926265
  const convertedValue = this.convert({
926194
- typeReference: args.typeReference.value,
926266
+ typeReference: inner2,
926195
926267
  value: args.value,
926196
926268
  as: args.as,
926197
- inUndiscriminatedUnion: args.inUndiscriminatedUnion
926269
+ inUndiscriminatedUnion: args.inUndiscriminatedUnion,
926270
+ nestedClassReference: args.nestedClassReference
926198
926271
  });
926199
926272
  const useOf = args.as === "mapValue" || args.inUndiscriminatedUnion === true;
926200
- return this.wrapInOptionalIfNotNop(convertedValue, useOf, args.isCollapsedOptionalNullable === true);
926273
+ return this.wrapNullableOrOptionalValue({
926274
+ value: convertedValue,
926275
+ wrapperType,
926276
+ useOf,
926277
+ propagatedCollapse: args.isCollapsedOptionalNullable === true
926278
+ });
926201
926279
  }
926202
926280
  case "primitive":
926203
926281
  return this.convertPrimitive({ primitive: args.typeReference.value, value: args.value, as: args.as });
926204
926282
  case "set":
926205
- return this.convertSet({ set: args.typeReference.value, value: args.value, as: args.as });
926283
+ return this.convertSet({
926284
+ set: args.typeReference.value,
926285
+ value: args.value,
926286
+ as: args.as,
926287
+ nestedClassReference: args.nestedClassReference
926288
+ });
926206
926289
  case "unknown":
926207
926290
  return this.convertUnknown({ value: args.value });
926208
926291
  default:
926209
926292
  assertNever(args.typeReference);
926210
926293
  }
926211
926294
  }
926212
- convertList({ list: list29, value: value2, as: as2 }) {
926295
+ convertList({ list: list29, value: value2, as: as2, nestedClassReference }) {
926213
926296
  if (!Array.isArray(value2)) {
926214
926297
  this.context.errors.add({
926215
926298
  severity: Severity.Critical,
@@ -926223,11 +926306,21 @@ var DynamicTypeLiteralMapper = class {
926223
926306
  values: value2.map((v3, index3) => {
926224
926307
  this.context.errors.scope({ index: index3 });
926225
926308
  try {
926226
- if (isItemOptional) {
926227
- const itemValue = this.convert({ typeReference: list29.value, value: v3, as: as2 });
926228
- return this.wrapInOptionalIfNotNop(itemValue, true);
926309
+ if (isItemOptional && (list29.type === "optional" || list29.type === "nullable")) {
926310
+ const itemValue = this.convert({
926311
+ typeReference: list29.value,
926312
+ value: v3,
926313
+ as: as2,
926314
+ nestedClassReference
926315
+ });
926316
+ return this.wrapNullableOrOptionalValue({
926317
+ value: itemValue,
926318
+ wrapperType: list29.type,
926319
+ useOf: true,
926320
+ propagatedCollapse: false
926321
+ });
926229
926322
  }
926230
- return this.convert({ typeReference: list29, value: v3, as: as2 });
926323
+ return this.convert({ typeReference: list29, value: v3, as: as2, nestedClassReference });
926231
926324
  } finally {
926232
926325
  this.context.errors.unscope();
926233
926326
  }
@@ -926256,7 +926349,7 @@ var DynamicTypeLiteralMapper = class {
926256
926349
  assertNever(literal3);
926257
926350
  }
926258
926351
  }
926259
- convertSet({ set: set26, value: value2, as: as2 }) {
926352
+ convertSet({ set: set26, value: value2, as: as2, nestedClassReference }) {
926260
926353
  if (!Array.isArray(value2)) {
926261
926354
  this.context.errors.add({
926262
926355
  severity: Severity.Critical,
@@ -926269,14 +926362,14 @@ var DynamicTypeLiteralMapper = class {
926269
926362
  values: value2.map((v3, index3) => {
926270
926363
  this.context.errors.scope({ index: index3 });
926271
926364
  try {
926272
- return this.convert({ typeReference: set26, value: v3, as: as2 });
926365
+ return this.convert({ typeReference: set26, value: v3, as: as2, nestedClassReference });
926273
926366
  } finally {
926274
926367
  this.context.errors.unscope();
926275
926368
  }
926276
926369
  })
926277
926370
  });
926278
926371
  }
926279
- convertMap({ map: map15, value: value2, as: as2 }) {
926372
+ convertMap({ map: map15, value: value2, as: as2, nestedClassReference }) {
926280
926373
  if (typeof value2 !== "object" || value2 == null) {
926281
926374
  this.context.errors.add({
926282
926375
  severity: Severity.Critical,
@@ -926295,7 +926388,8 @@ var DynamicTypeLiteralMapper = class {
926295
926388
  value: this.convert({
926296
926389
  typeReference: map15.value,
926297
926390
  value: value3,
926298
- as: "mapValue"
926391
+ as: "mapValue",
926392
+ nestedClassReference
926299
926393
  })
926300
926394
  };
926301
926395
  } finally {
@@ -926304,7 +926398,7 @@ var DynamicTypeLiteralMapper = class {
926304
926398
  })
926305
926399
  });
926306
926400
  }
926307
- convertNamed({ named, value: value2, as: as2, inUndiscriminatedUnion }) {
926401
+ convertNamed({ named, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference }) {
926308
926402
  switch (named.type) {
926309
926403
  case "alias":
926310
926404
  if (named.typeReference.type === "unknown") {
@@ -926315,32 +926409,44 @@ var DynamicTypeLiteralMapper = class {
926315
926409
  inUndiscriminatedUnion
926316
926410
  });
926317
926411
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926318
- on: this.context.getJavaClassReferenceFromDeclaration({
926412
+ on: nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926319
926413
  declaration: named.declaration
926320
926414
  }),
926321
926415
  method: "of",
926322
926416
  arguments_: [convertedValue]
926323
926417
  }));
926324
926418
  }
926325
- return this.convert({ typeReference: named.typeReference, value: value2, as: as2, inUndiscriminatedUnion });
926419
+ return this.convert({
926420
+ typeReference: named.typeReference,
926421
+ value: value2,
926422
+ as: as2,
926423
+ inUndiscriminatedUnion,
926424
+ nestedClassReference
926425
+ });
926326
926426
  case "discriminatedUnion":
926327
926427
  return this.convertDiscriminatedUnion({
926328
926428
  discriminatedUnion: named,
926329
926429
  value: value2,
926330
- as: as2
926430
+ as: as2,
926431
+ nestedClassReference
926331
926432
  });
926332
926433
  case "enum":
926333
- return this.convertEnum({ enum_: named, value: value2 });
926434
+ return this.convertEnum({ enum_: named, value: value2, nestedClassReference });
926334
926435
  case "object":
926335
- return this.convertObject({ object_: named, value: value2, as: as2, inUndiscriminatedUnion });
926436
+ return this.convertObject({ object_: named, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference });
926336
926437
  case "undiscriminatedUnion":
926337
- return this.convertUndiscriminatedUnion({ undiscriminatedUnion: named, value: value2, as: as2 });
926438
+ return this.convertUndiscriminatedUnion({
926439
+ undiscriminatedUnion: named,
926440
+ value: value2,
926441
+ as: as2,
926442
+ nestedClassReference
926443
+ });
926338
926444
  default:
926339
926445
  assertNever(named);
926340
926446
  }
926341
926447
  }
926342
- convertDiscriminatedUnion({ discriminatedUnion: discriminatedUnion2, value: value2, as: as2 }) {
926343
- const classReference4 = this.context.getJavaClassReferenceFromDeclaration({
926448
+ convertDiscriminatedUnion({ discriminatedUnion: discriminatedUnion2, value: value2, as: as2, nestedClassReference }) {
926449
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926344
926450
  declaration: discriminatedUnion2.declaration
926345
926451
  });
926346
926452
  const discriminatedUnionTypeInstance = this.context.resolveDiscriminatedUnionTypeInstance({
@@ -926351,6 +926457,8 @@ var DynamicTypeLiteralMapper = class {
926351
926457
  return java_exports.TypeLiteral.nop();
926352
926458
  }
926353
926459
  const unionVariant = discriminatedUnionTypeInstance.singleDiscriminatedUnionType;
926460
+ const reservedNames = /* @__PURE__ */ new Set([...classReference4.enclosingClasses, classReference4.name]);
926461
+ const siblingDiscriminantNames = new Set(Object.values(discriminatedUnion2.types).map((variant) => this.context.getClassName(variant.discriminantValue.name)));
926354
926462
  switch (unionVariant.type) {
926355
926463
  case "samePropertiesAsObject": {
926356
926464
  const named = this.context.resolveNamedType({
@@ -926359,10 +926467,24 @@ var DynamicTypeLiteralMapper = class {
926359
926467
  if (named == null) {
926360
926468
  return java_exports.TypeLiteral.nop();
926361
926469
  }
926470
+ const variantNestedClassReference = this.resolveInlineNestedClassReference({
926471
+ enclosing: classReference4,
926472
+ baseName: this.context.getClassName(unionVariant.discriminantValue.name),
926473
+ typeReference: { type: "named", value: unionVariant.typeId },
926474
+ reservedNames,
926475
+ siblingPropertyNames: siblingDiscriminantNames
926476
+ });
926362
926477
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926363
926478
  on: classReference4,
926364
926479
  method: this.context.getPropertyName(unionVariant.discriminantValue.name),
926365
- arguments_: [this.convertNamed({ named, value: discriminatedUnionTypeInstance.value, as: as2 })]
926480
+ arguments_: [
926481
+ this.convertNamed({
926482
+ named,
926483
+ value: discriminatedUnionTypeInstance.value,
926484
+ as: as2,
926485
+ nestedClassReference: variantNestedClassReference
926486
+ })
926487
+ ]
926366
926488
  }));
926367
926489
  }
926368
926490
  case "singleProperty": {
@@ -926373,6 +926495,13 @@ var DynamicTypeLiteralMapper = class {
926373
926495
  try {
926374
926496
  this.context.errors.scope(unionVariant.discriminantValue.wireValue);
926375
926497
  const propertyKey = "value";
926498
+ const variantNestedClassReference = this.resolveInlineNestedClassReference({
926499
+ enclosing: classReference4,
926500
+ baseName: this.context.getClassName(unionVariant.discriminantValue.name),
926501
+ typeReference: unionVariant.typeReference,
926502
+ reservedNames,
926503
+ siblingPropertyNames: siblingDiscriminantNames
926504
+ });
926376
926505
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926377
926506
  on: classReference4,
926378
926507
  method: this.context.getPropertyName(unionVariant.discriminantValue.name),
@@ -926380,7 +926509,8 @@ var DynamicTypeLiteralMapper = class {
926380
926509
  this.convert({
926381
926510
  typeReference: unionVariant.typeReference,
926382
926511
  value: record23[propertyKey],
926383
- as: as2
926512
+ as: as2,
926513
+ nestedClassReference: variantNestedClassReference
926384
926514
  })
926385
926515
  ]
926386
926516
  }));
@@ -926398,7 +926528,10 @@ var DynamicTypeLiteralMapper = class {
926398
926528
  assertNever(unionVariant);
926399
926529
  }
926400
926530
  }
926401
- convertObject({ object_, value: value2, as: as2, inUndiscriminatedUnion }) {
926531
+ convertObject({ object_, value: value2, as: as2, inUndiscriminatedUnion, nestedClassReference }) {
926532
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926533
+ declaration: object_.declaration
926534
+ });
926402
926535
  const valueRecord = this.context.getRecord(value2) ?? {};
926403
926536
  const properties7 = this.context.associateByWireValue({
926404
926537
  parameters: object_.properties,
@@ -926428,6 +926561,8 @@ var DynamicTypeLiteralMapper = class {
926428
926561
  });
926429
926562
  properties7.sort((a3, b5) => (paramOrderMap.get(a3.name.wireValue) ?? 0) - (paramOrderMap.get(b5.name.wireValue) ?? 0));
926430
926563
  const filteredProperties = as2 === "request" ? properties7.filter((property24) => !this.context.isDirectLiteral(property24.typeReference)) : properties7;
926564
+ const reservedNames = /* @__PURE__ */ new Set([...classReference4.enclosingClasses, classReference4.name]);
926565
+ const siblingPropertyNames = new Set(object_.properties.map((property24) => this.context.getClassName(property24.name.name)));
926431
926566
  const builderParameters = [];
926432
926567
  for (const property24 of filteredProperties) {
926433
926568
  this.context.errors.scope(property24.name.wireValue);
@@ -926436,7 +926571,14 @@ var DynamicTypeLiteralMapper = class {
926436
926571
  typeReference: property24.typeReference,
926437
926572
  value: property24.value,
926438
926573
  as: as2,
926439
- inUndiscriminatedUnion
926574
+ inUndiscriminatedUnion,
926575
+ nestedClassReference: this.resolveInlineNestedClassReference({
926576
+ enclosing: classReference4,
926577
+ baseName: this.context.getClassName(property24.name.name),
926578
+ typeReference: property24.typeReference,
926579
+ reservedNames,
926580
+ siblingPropertyNames
926581
+ })
926440
926582
  });
926441
926583
  if (java_exports.TypeLiteral.isNop(convertedValue) && !this.context.isOptional(property24.typeReference)) {
926442
926584
  if (inUndiscriminatedUnion === true) {
@@ -926446,7 +926588,8 @@ var DynamicTypeLiteralMapper = class {
926446
926588
  }
926447
926589
  builderParameters.push({
926448
926590
  name: this.context.getMethodName(property24.name.name),
926449
- value: convertedValue
926591
+ value: convertedValue,
926592
+ isRequired: this.isStagedBuilderProperty(property24.typeReference)
926450
926593
  });
926451
926594
  } finally {
926452
926595
  this.context.errors.unscope();
@@ -926458,18 +926601,178 @@ var DynamicTypeLiteralMapper = class {
926458
926601
  if (rawValue != null) {
926459
926602
  builderParameters.push({
926460
926603
  name: "additionalProperty",
926461
- value: java_exports.TypeLiteral.raw(`"${this.escapeJavaString(key2)}", ${rawValue}`)
926604
+ value: java_exports.TypeLiteral.raw(`"${this.escapeJavaString(key2)}", ${rawValue}`),
926605
+ isRequired: false
926462
926606
  });
926463
926607
  }
926464
926608
  }
926465
926609
  }
926466
926610
  return java_exports.TypeLiteral.builder({
926467
- classReference: this.context.getJavaClassReferenceFromDeclaration({
926468
- declaration: object_.declaration
926469
- }),
926611
+ classReference: classReference4,
926470
926612
  parameters: builderParameters
926471
926613
  });
926472
926614
  }
926615
+ /**
926616
+ * Mirrors the v1 generator's inline-type naming (see ObjectGenerator / InlineTypeIdResolver):
926617
+ * when a property's type resolves to an inline named type, v1 emits it as a class nested within
926618
+ * the enclosing object. This walks the property's type reference (descending through container
926619
+ * wrappers, applying the same name suffixes as v1) and, if it terminates in an inline named type,
926620
+ * returns the nested class reference to use. Returns undefined for non-inline types, which fall
926621
+ * back to the standalone top-level class name.
926622
+ */
926623
+ resolveInlineNestedClassReference({ enclosing, baseName, typeReference: typeReference2, reservedNames, siblingPropertyNames }) {
926624
+ if (!this.context.enableInlineTypes()) {
926625
+ return void 0;
926626
+ }
926627
+ switch (typeReference2.type) {
926628
+ case "optional":
926629
+ case "nullable":
926630
+ return this.resolveInlineNestedClassReference({
926631
+ enclosing,
926632
+ baseName,
926633
+ typeReference: typeReference2.value,
926634
+ reservedNames,
926635
+ siblingPropertyNames
926636
+ });
926637
+ case "list":
926638
+ case "set":
926639
+ return this.resolveInlineNestedClassReference({
926640
+ enclosing,
926641
+ baseName: `${baseName}Item`,
926642
+ typeReference: typeReference2.value,
926643
+ reservedNames,
926644
+ siblingPropertyNames
926645
+ });
926646
+ case "map":
926647
+ return this.resolveInlineNestedClassReference({
926648
+ enclosing,
926649
+ baseName: `${baseName}Value`,
926650
+ typeReference: typeReference2.value,
926651
+ reservedNames,
926652
+ siblingPropertyNames
926653
+ });
926654
+ case "named": {
926655
+ const typeId = typeReference2.value;
926656
+ const named = this.context.resolveNamedType({ typeId });
926657
+ if (named == null) {
926658
+ return void 0;
926659
+ }
926660
+ if (named.type === "alias" && !this.context.wrappedAliases()) {
926661
+ return this.resolveInlineNestedClassReference({
926662
+ enclosing,
926663
+ baseName,
926664
+ typeReference: named.typeReference,
926665
+ reservedNames,
926666
+ siblingPropertyNames
926667
+ });
926668
+ }
926669
+ if (!this.context.isInlineType(typeId)) {
926670
+ return void 0;
926671
+ }
926672
+ let name2 = baseName;
926673
+ while (reservedNames.has(name2) || siblingPropertyNames.has(name2) && name2 !== baseName) {
926674
+ name2 = `${name2}_`;
926675
+ }
926676
+ reservedNames.add(name2);
926677
+ return this.context.getNestedInlineClassReference({ enclosing, name: name2 });
926678
+ }
926679
+ case "primitive":
926680
+ case "literal":
926681
+ case "unknown":
926682
+ return void 0;
926683
+ default:
926684
+ assertNever(typeReference2);
926685
+ }
926686
+ }
926687
+ /**
926688
+ * Resolves the nested class reference for an inline member of an undiscriminated union.
926689
+ * Unlike object properties and discriminated-union variants (whose nested name is derived
926690
+ * from the property/discriminant name), v1 names an undiscriminated union's inline members
926691
+ * after the member type's own name, with the union's name stripped as a prefix (see
926692
+ * UndiscriminatedUnionGenerator). Descends through container wrappers to the terminal named
926693
+ * type.
926694
+ */
926695
+ resolveUndiscriminatedInlineNestedClassReference({ enclosing, typeReference: typeReference2, reservedNames, unionPrefix }) {
926696
+ if (!this.context.enableInlineTypes()) {
926697
+ return void 0;
926698
+ }
926699
+ switch (typeReference2.type) {
926700
+ case "optional":
926701
+ case "nullable":
926702
+ case "list":
926703
+ case "set":
926704
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926705
+ enclosing,
926706
+ typeReference: typeReference2.value,
926707
+ reservedNames,
926708
+ unionPrefix
926709
+ });
926710
+ case "map":
926711
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926712
+ enclosing,
926713
+ typeReference: typeReference2.value,
926714
+ reservedNames,
926715
+ unionPrefix
926716
+ });
926717
+ case "named": {
926718
+ const typeId = typeReference2.value;
926719
+ const named = this.context.resolveNamedType({ typeId });
926720
+ if (named == null) {
926721
+ return void 0;
926722
+ }
926723
+ if (named.type === "alias" && !this.context.wrappedAliases()) {
926724
+ return this.resolveUndiscriminatedInlineNestedClassReference({
926725
+ enclosing,
926726
+ typeReference: named.typeReference,
926727
+ reservedNames,
926728
+ unionPrefix
926729
+ });
926730
+ }
926731
+ if (!this.context.isInlineType(typeId)) {
926732
+ return void 0;
926733
+ }
926734
+ let name2 = this.context.getClassName(named.declaration.name);
926735
+ if (name2.startsWith(unionPrefix) && name2 !== unionPrefix) {
926736
+ name2 = name2.substring(unionPrefix.length);
926737
+ }
926738
+ while (reservedNames.has(name2)) {
926739
+ name2 = `${name2}_`;
926740
+ }
926741
+ return this.context.getNestedInlineClassReference({ enclosing, name: name2 });
926742
+ }
926743
+ case "primitive":
926744
+ case "literal":
926745
+ case "unknown":
926746
+ return void 0;
926747
+ default:
926748
+ assertNever(typeReference2);
926749
+ }
926750
+ }
926751
+ /**
926752
+ * Returns true when a property becomes a required stage in v1's staged builder. v1 stages
926753
+ * fields that are neither optional, nullable, nor collections (list/set/map); those are all
926754
+ * exposed on the final stage instead. This intentionally resolves aliases itself because the
926755
+ * shared `isOptional` helper does not treat an alias to an optional type as optional.
926756
+ */
926757
+ isStagedBuilderProperty(typeReference2) {
926758
+ switch (typeReference2.type) {
926759
+ case "optional":
926760
+ case "nullable":
926761
+ case "list":
926762
+ case "set":
926763
+ case "map":
926764
+ return false;
926765
+ case "named": {
926766
+ const resolvedType = this.context.resolveNamedType({ typeId: typeReference2.value });
926767
+ if (resolvedType != null && resolvedType.type === "alias") {
926768
+ return this.isStagedBuilderProperty(resolvedType.typeReference);
926769
+ }
926770
+ return true;
926771
+ }
926772
+ default:
926773
+ return true;
926774
+ }
926775
+ }
926473
926776
  convertToRawJavaLiteral(value2) {
926474
926777
  if (typeof value2 === "string") {
926475
926778
  return `"${this.escapeJavaString(value2)}"`;
@@ -926562,13 +926865,13 @@ var DynamicTypeLiteralMapper = class {
926562
926865
  return "string";
926563
926866
  }
926564
926867
  }
926565
- convertEnum({ enum_: enum_25, value: value2 }) {
926868
+ convertEnum({ enum_: enum_25, value: value2, nestedClassReference }) {
926566
926869
  const name2 = this.getEnumValueName({ enum_: enum_25, value: value2 });
926567
926870
  if (name2 == null) {
926568
926871
  return java_exports.TypeLiteral.nop();
926569
926872
  }
926570
926873
  return java_exports.TypeLiteral.enum_({
926571
- classReference: this.context.getJavaClassReferenceFromDeclaration({
926874
+ classReference: nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926572
926875
  declaration: enum_25.declaration
926573
926876
  }),
926574
926877
  value: name2
@@ -926592,33 +926895,28 @@ var DynamicTypeLiteralMapper = class {
926592
926895
  }
926593
926896
  return this.context.getEnumName(enumValue.name);
926594
926897
  }
926595
- convertUndiscriminatedUnion({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2 }) {
926898
+ convertUndiscriminatedUnion({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2, nestedClassReference }) {
926899
+ const classReference4 = nestedClassReference ?? this.context.getJavaClassReferenceFromDeclaration({
926900
+ declaration: undiscriminatedUnion22.declaration
926901
+ });
926596
926902
  const result = this.findMatchingUndiscriminatedUnionType({
926597
926903
  undiscriminatedUnion: undiscriminatedUnion22,
926598
926904
  value: value2,
926599
- as: as2
926905
+ as: as2,
926906
+ enclosing: classReference4
926600
926907
  });
926601
926908
  if (result == null) {
926602
926909
  return java_exports.TypeLiteral.nop();
926603
926910
  }
926604
- if (this.context.isPrimitive(result.valueTypeReference)) {
926605
- return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926606
- on: this.context.getJavaClassReferenceFromDeclaration({
926607
- declaration: undiscriminatedUnion22.declaration
926608
- }),
926609
- method: "of",
926610
- arguments_: [result.typeInstantiation]
926611
- }));
926612
- }
926613
926911
  return java_exports.TypeLiteral.reference(java_exports.invokeMethod({
926614
- on: this.context.getJavaClassReferenceFromDeclaration({
926615
- declaration: undiscriminatedUnion22.declaration
926616
- }),
926912
+ on: classReference4,
926617
926913
  method: "of",
926618
926914
  arguments_: [result.typeInstantiation]
926619
926915
  }));
926620
926916
  }
926621
- findMatchingUndiscriminatedUnionType({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2 }) {
926917
+ findMatchingUndiscriminatedUnionType({ undiscriminatedUnion: undiscriminatedUnion22, value: value2, as: as2, enclosing }) {
926918
+ const reservedNames = /* @__PURE__ */ new Set([...enclosing.enclosingClasses, enclosing.name]);
926919
+ const unionPrefix = this.context.getClassName(undiscriminatedUnion22.declaration.name);
926622
926920
  for (const typeReference2 of undiscriminatedUnion22.types) {
926623
926921
  const errorsBefore = this.context.errors.size();
926624
926922
  try {
@@ -926626,7 +926924,13 @@ var DynamicTypeLiteralMapper = class {
926626
926924
  typeReference: typeReference2,
926627
926925
  value: value2,
926628
926926
  as: as2,
926629
- inUndiscriminatedUnion: true
926927
+ inUndiscriminatedUnion: true,
926928
+ nestedClassReference: this.resolveUndiscriminatedInlineNestedClassReference({
926929
+ enclosing,
926930
+ typeReference: typeReference2,
926931
+ reservedNames: new Set(reservedNames),
926932
+ unionPrefix
926933
+ })
926630
926934
  });
926631
926935
  if (java_exports.TypeLiteral.isNop(typeInstantiation) || this.context.errors.size() > errorsBefore) {
926632
926936
  this.context.errors.truncate(errorsBefore);
@@ -926948,9 +927252,27 @@ var DynamicTypeMapper3 = class {
926948
927252
  }
926949
927253
  return this.convertNamed({ named });
926950
927254
  }
926951
- case "optional":
927255
+ case "optional": {
927256
+ const inner2 = args.typeReference.value;
927257
+ if (this.context.usesOptionalNullable() && (inner2.type === "nullable" || inner2.type === "optional")) {
927258
+ return java_exports.Type.generic(this.context.getOptionalNullableClassReference(), [
927259
+ this.convert({ typeReference: inner2.value })
927260
+ ]);
927261
+ }
927262
+ return java_exports.Type.optional(this.convert({ typeReference: inner2 }));
927263
+ }
926952
927264
  case "nullable": {
926953
- return java_exports.Type.optional(this.convert({ typeReference: args.typeReference.value }));
927265
+ const inner2 = args.typeReference.value;
927266
+ if (this.context.usesNullableAnnotation()) {
927267
+ return this.convert({ typeReference: inner2 });
927268
+ }
927269
+ if (this.context.usesOptionalNullable()) {
927270
+ const collapsed = inner2.type === "optional" || inner2.type === "nullable" ? inner2.value : inner2;
927271
+ return java_exports.Type.generic(this.context.getOptionalNullableClassReference(), [
927272
+ this.convert({ typeReference: collapsed })
927273
+ ]);
927274
+ }
927275
+ return java_exports.Type.optional(this.convert({ typeReference: inner2 }));
926954
927276
  }
926955
927277
  case "primitive":
926956
927278
  return this.convertPrimitive({ primitive: args.typeReference.value });
@@ -927071,6 +927393,9 @@ var FilePropertyMapper3 = class {
927071
927393
  }
927072
927394
  getSingleFileProperty({ property: property24, record: record23 }) {
927073
927395
  const fileValue = this.context.getSingleFileValue({ property: property24, record: record23 });
927396
+ if (this.context.shouldInlineFileProperties()) {
927397
+ return this.context.getJavaIoFileFromString(fileValue ?? "path/to/file");
927398
+ }
927074
927399
  if (fileValue == null) {
927075
927400
  return java_exports.TypeLiteral.nop();
927076
927401
  }
@@ -927078,6 +927403,10 @@ var FilePropertyMapper3 = class {
927078
927403
  }
927079
927404
  getArrayFileProperty({ property: property24, record: record23 }) {
927080
927405
  const fileValues = this.context.getFileArrayValues({ property: property24, record: record23 });
927406
+ if (this.context.shouldInlineFileProperties()) {
927407
+ const fileValue = fileValues?.[0] ?? "path/to/file";
927408
+ return this.context.getJavaIoFileFromString(fileValue);
927409
+ }
927081
927410
  if (fileValues == null) {
927082
927411
  return java_exports.TypeLiteral.nop();
927083
927412
  }
@@ -927120,22 +927449,51 @@ var DynamicSnippetsGeneratorContext3 = class _DynamicSnippetsGeneratorContext ex
927120
927449
  dynamicTypeMapper;
927121
927450
  dynamicTypeLiteralMapper;
927122
927451
  filePropertyMapper;
927123
- constructor({ ir: ir3, config: config5, options: options2, sharedCustomConfig }) {
927452
+ /**
927453
+ * The set of type IDs that the v1 generator emits as nested (inline) classes rather than
927454
+ * top-level types. The dynamic IR does not carry the `inline` flag, so the v2 SDK generator
927455
+ * computes this from the full IR and threads it through. Used to mirror v1's nested-class
927456
+ * naming when referencing inline types in snippets.
927457
+ */
927458
+ inlineTypeIds;
927459
+ constructor({ ir: ir3, config: config5, options: options2, sharedCustomConfig, inlineTypeIds }) {
927124
927460
  super({ ir: ir3, config: config5, options: options2 });
927125
927461
  this.ir = ir3;
927126
927462
  this.customConfig = sharedCustomConfig ?? BaseJavaCustomConfigSchema.parse(config5.customConfig ?? {});
927127
927463
  this.dynamicTypeMapper = new DynamicTypeMapper3({ context: this });
927128
927464
  this.dynamicTypeLiteralMapper = new DynamicTypeLiteralMapper({ context: this });
927129
927465
  this.filePropertyMapper = new FilePropertyMapper3({ context: this });
927466
+ this.inlineTypeIds = inlineTypeIds ?? /* @__PURE__ */ new Set();
927130
927467
  }
927131
927468
  clone() {
927132
927469
  return new _DynamicSnippetsGeneratorContext({
927133
927470
  ir: this.ir,
927134
927471
  config: this.config,
927135
927472
  options: this.options,
927136
- sharedCustomConfig: this.customConfig
927473
+ sharedCustomConfig: this.customConfig,
927474
+ inlineTypeIds: this.inlineTypeIds
927475
+ });
927476
+ }
927477
+ isInlineType(typeId) {
927478
+ return this.inlineTypeIds.has(typeId);
927479
+ }
927480
+ /**
927481
+ * Builds a reference to a class nested within `enclosing`. The resulting reference imports the
927482
+ * outermost enclosing class and is written using the dotted path (e.g. `PostRootRequest.Bar`).
927483
+ */
927484
+ getNestedInlineClassReference({ enclosing, name: name2 }) {
927485
+ return java_exports.classReference({
927486
+ name: name2,
927487
+ packageName: enclosing.packageName,
927488
+ enclosingClasses: [...enclosing.enclosingClasses, enclosing.name]
927137
927489
  });
927138
927490
  }
927491
+ wrappedAliases() {
927492
+ return this.customConfig?.["wrapped-aliases"] ?? false;
927493
+ }
927494
+ enableInlineTypes() {
927495
+ return this.customConfig?.["enable-inline-types"] ?? false;
927496
+ }
927139
927497
  getClassName(name2) {
927140
927498
  return this.getName(name2.pascalCase.safeName);
927141
927499
  }
@@ -927233,7 +927591,7 @@ var DynamicSnippetsGeneratorContext3 = class _DynamicSnippetsGeneratorContext ex
927233
927591
  return java_exports.TypeLiteral.reference(java_exports.codeblock((writer2) => {
927234
927592
  writer2.write("new ");
927235
927593
  writer2.writeNode(this.getFileStreamClassReference());
927236
- writer2.write("(");
927594
+ writer2.write("(new ");
927237
927595
  writer2.writeNode(this.getByteArrayInputStreamClassReference());
927238
927596
  writer2.write("(");
927239
927597
  writer2.writeNode(java_exports.TypeLiteral.string(content5));
@@ -927242,6 +927600,21 @@ var DynamicSnippetsGeneratorContext3 = class _DynamicSnippetsGeneratorContext ex
927242
927600
  writer2.write(".UTF_8)))");
927243
927601
  }));
927244
927602
  }
927603
+ getJavaIoFileFromString(content5) {
927604
+ return java_exports.TypeLiteral.reference(java_exports.codeblock((writer2) => {
927605
+ writer2.write("new ");
927606
+ writer2.writeNode(this.getJavaIoFileClassReference());
927607
+ writer2.write("(");
927608
+ writer2.writeNode(java_exports.TypeLiteral.string(content5));
927609
+ writer2.write(")");
927610
+ }));
927611
+ }
927612
+ getJavaIoFileClassReference() {
927613
+ return java_exports.classReference({
927614
+ name: "File",
927615
+ packageName: "java.io"
927616
+ });
927617
+ }
927245
927618
  getFileStreamClassReference() {
927246
927619
  return java_exports.classReference({
927247
927620
  name: "FileStream",
@@ -927394,6 +927767,12 @@ var DynamicSnippetsGeneratorContext3 = class _DynamicSnippetsGeneratorContext ex
927394
927767
  shouldInlineFileProperties() {
927395
927768
  return this.customConfig?.["inline-file-properties"] ?? false;
927396
927769
  }
927770
+ usesNullableAnnotation() {
927771
+ return this.customConfig?.["use-nullable-annotation"] === true;
927772
+ }
927773
+ usesOptionalNullable() {
927774
+ return this.customConfig?.["collapse-optional-nullable"] === true;
927775
+ }
927397
927776
  getPackageNameSegments(fernFilepath) {
927398
927777
  return fernFilepath.packagePath.map((segment) => this.getPackageNameSegment(segment));
927399
927778
  }
@@ -927906,7 +928285,11 @@ var EndpointSnippetGenerator3 = class {
927906
928285
  return this.context.getOptionalNullableOf(convertedValue);
927907
928286
  } else {
927908
928287
  return java_exports.TypeLiteral.optional({
927909
- value: convertedValue,
928288
+ value: this.context.dynamicTypeLiteralMapper.convert({
928289
+ typeReference: stripOptionalAndNullable(body.value),
928290
+ value: value2,
928291
+ as: "request"
928292
+ }),
927910
928293
  useOf: true
927911
928294
  });
927912
928295
  }
@@ -928015,18 +928398,20 @@ var EndpointSnippetGenerator3 = class {
928015
928398
  })
928016
928399
  }));
928017
928400
  this.context.errors.unscope();
928401
+ const requestClassReference = java_exports.classReference({
928402
+ name: this.context.getClassName(request7.declaration.name),
928403
+ packageName: this.context.getRequestsPackageName(request7.declaration.fernFilepath)
928404
+ });
928018
928405
  this.context.errors.scope(Scope4.RequestBody);
928019
928406
  const requestBodyFields = request7.body != null ? this.getInlinedRequestBodyBuilderParameters({
928020
928407
  body: request7.body,
928021
928408
  value: snippet.requestBody,
928022
- filePropertyInfo
928409
+ filePropertyInfo,
928410
+ enclosing: requestClassReference
928023
928411
  }) : [];
928024
928412
  this.context.errors.unscope();
928025
928413
  return java_exports.TypeLiteral.builder({
928026
- classReference: java_exports.classReference({
928027
- name: this.context.getClassName(request7.declaration.name),
928028
- packageName: this.context.getRequestsPackageName(request7.declaration.fernFilepath)
928029
- }),
928414
+ classReference: requestClassReference,
928030
928415
  parameters: [...pathParameterFields, ...headerFields, ...queryParameterFields, ...requestBodyFields]
928031
928416
  });
928032
928417
  }
@@ -928070,10 +928455,14 @@ var EndpointSnippetGenerator3 = class {
928070
928455
  });
928071
928456
  return java_exports.TypeLiteral.reference(buildMethodCall);
928072
928457
  }
928073
- getInlinedRequestBodyBuilderParameters({ body, value: value2, filePropertyInfo }) {
928458
+ getInlinedRequestBodyBuilderParameters({ body, value: value2, filePropertyInfo, enclosing }) {
928074
928459
  switch (body.type) {
928075
928460
  case "properties":
928076
- return this.getInlinedRequestBodyPropertyBuilderParameters({ parameters: body.value, value: value2 });
928461
+ return this.getInlinedRequestBodyPropertyBuilderParameters({
928462
+ parameters: body.value,
928463
+ value: value2,
928464
+ enclosing
928465
+ });
928077
928466
  case "referenced":
928078
928467
  return [this.getReferencedRequestBodyPropertyBuilderParameter({ body, value: value2 })];
928079
928468
  case "fileUpload":
@@ -928084,7 +928473,7 @@ var EndpointSnippetGenerator3 = class {
928084
928473
  }
928085
928474
  getFileUploadRequestBodyBuilderParameters({ filePropertyInfo }) {
928086
928475
  if (this.context.shouldInlineFileProperties()) {
928087
- return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];
928476
+ return [...filePropertyInfo.bodyPropertyFields, ...filePropertyInfo.fileFields];
928088
928477
  }
928089
928478
  return filePropertyInfo.bodyPropertyFields;
928090
928479
  }
@@ -928108,19 +928497,28 @@ var EndpointSnippetGenerator3 = class {
928108
928497
  assertNever(body);
928109
928498
  }
928110
928499
  }
928111
- getInlinedRequestBodyPropertyBuilderParameters({ parameters: parameters2, value: value2 }) {
928500
+ getInlinedRequestBodyPropertyBuilderParameters({ parameters: parameters2, value: value2, enclosing }) {
928112
928501
  const bodyProperties = this.context.associateByWireValue({
928113
928502
  parameters: parameters2,
928114
928503
  values: this.context.getRecord(value2) ?? {}
928115
928504
  });
928116
928505
  const filteredProperties = bodyProperties.filter((parameter6) => !this.context.isDirectLiteral(parameter6.typeReference));
928117
928506
  const sortedProperties = this.context.sortTypeInstancesByRequiredFirst(filteredProperties, parameters2);
928507
+ const reservedNames = /* @__PURE__ */ new Set([...enclosing.enclosingClasses, enclosing.name]);
928508
+ const siblingPropertyNames = new Set(parameters2.map((parameter6) => this.context.getClassName(parameter6.name.name)));
928118
928509
  return sortedProperties.map((parameter6) => ({
928119
928510
  name: this.context.getMethodName(parameter6.name.name),
928120
928511
  value: this.context.dynamicTypeLiteralMapper.convert({
928121
928512
  typeReference: parameter6.typeReference,
928122
928513
  value: parameter6.value,
928123
- as: "request"
928514
+ as: "request",
928515
+ nestedClassReference: this.context.dynamicTypeLiteralMapper.resolveInlineNestedClassReference({
928516
+ enclosing,
928517
+ baseName: this.context.getClassName(parameter6.name.name),
928518
+ typeReference: parameter6.typeReference,
928519
+ reservedNames,
928520
+ siblingPropertyNames
928521
+ })
928124
928522
  })
928125
928523
  }));
928126
928524
  }
@@ -928155,8 +928553,8 @@ var EndpointSnippetGenerator3 = class {
928155
928553
 
928156
928554
  // ../../../generators/java-v2/dynamic-snippets/lib/DynamicSnippetsGenerator.js
928157
928555
  var DynamicSnippetsGenerator3 = class extends AbstractDynamicSnippetsGenerator {
928158
- constructor({ ir: ir3, config: config5, options: options2 = {} }) {
928159
- super(new DynamicSnippetsGeneratorContext3({ ir: ir3, config: config5, options: options2 }));
928556
+ constructor({ ir: ir3, config: config5, options: options2 = {}, inlineTypeIds }) {
928557
+ super(new DynamicSnippetsGeneratorContext3({ ir: ir3, config: config5, options: options2, inlineTypeIds }));
928160
928558
  }
928161
928559
  async generate(request7, options2 = {}) {
928162
928560
  return super.generate(request7, options2);
@@ -928181,15 +928579,18 @@ var DynamicSnippetsJavaTestGenerator = class {
928181
928579
  context;
928182
928580
  ir;
928183
928581
  generatorConfig;
928582
+ inlineTypeIds;
928184
928583
  dynamicSnippetsGenerator;
928185
- constructor(context3, ir3, generatorConfig) {
928584
+ constructor(context3, ir3, generatorConfig, inlineTypeIds) {
928186
928585
  this.context = context3;
928187
928586
  this.ir = ir3;
928188
928587
  this.generatorConfig = generatorConfig;
928588
+ this.inlineTypeIds = inlineTypeIds;
928189
928589
  this.dynamicSnippetsGenerator = new DynamicSnippetsGenerator3({
928190
928590
  // biome-ignore lint/suspicious/noExplicitAny: workaround for version incompatibility - see note above
928191
928591
  ir: convertIr(this.ir),
928192
- config: this.generatorConfig
928592
+ config: this.generatorConfig,
928593
+ inlineTypeIds: this.inlineTypeIds
928193
928594
  });
928194
928595
  }
928195
928596
  async generateTests({ outputDir, requests: requests3 }) {
@@ -947643,9 +948044,9 @@ var EndpointSnippetGenerator8 = class {
947643
948044
  return args;
947644
948045
  }
947645
948046
  getEndpointMethodPathParameters({ namedParameters, snippet }) {
947646
- return this.context.getExampleObjectProperties({
948047
+ return this.context.associateByWireValueOrDefault({
947647
948048
  parameters: namedParameters,
947648
- snippetObject: snippet.pathParameters ?? {}
948049
+ values: snippet.pathParameters ?? {}
947649
948050
  }).map((parameter6) => {
947650
948051
  return swift_exports.functionArgument({
947651
948052
  label: parameter6.name.name.camelCase.unsafeName,
@@ -950500,7 +950901,7 @@ var DynamicSnippetsTestGenerator = class _DynamicSnippetsTestGenerator {
950500
950901
  this.context.logger.debug(`Skipping dynamic snippets test generation for language "${language}"`);
950501
950902
  return;
950502
950903
  }
950503
- return new config5.generator(this.context, this.testSuite.ir, this.testSuite.config).generateTests({
950904
+ return new config5.generator(this.context, this.testSuite.ir, this.testSuite.config, this.testSuite.inlineTypeIds).generateTests({
950504
950905
  outputDir,
950505
950906
  requests: this.testSuite.requests
950506
950907
  });
@@ -950516,9 +950917,11 @@ async function generateDynamicSnippetsTestSuite({ ir: ir3, config: config5 }) {
950516
950917
  code: CliError.Code.InternalError
950517
950918
  });
950518
950919
  }
950920
+ const inlineTypeIds = new Set(Object.values(ir3.types).filter((typeDeclaration2) => typeDeclaration2.inline === true).map((typeDeclaration2) => typeDeclaration2.name.typeId));
950519
950921
  return {
950520
950922
  ir: ir3.dynamic,
950521
950923
  config: config5,
950924
+ inlineTypeIds,
950522
950925
  requests: Object.entries(ir3.dynamic.endpoints).flatMap(([endpointId, endpoint3]) => (endpoint3.examples ?? []).map((example) => ({
950523
950926
  endpointId,
950524
950927
  request: {
@@ -964507,7 +964910,7 @@ function getAutomationContextFromEnv() {
964507
964910
  config_branch: process.env.FERN_CONFIG_BRANCH,
964508
964911
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
964509
964912
  trigger: process.env.GITHUB_EVENT_NAME,
964510
- cli_version: "5.50.1"
964913
+ cli_version: "5.50.3"
964511
964914
  };
964512
964915
  }
964513
964916
  function isAutomationMode() {
@@ -965339,7 +965742,7 @@ var CliContext = class _CliContext {
965339
965742
  if (false) {
965340
965743
  this.logger.error("CLI_VERSION is not defined");
965341
965744
  }
965342
- return "5.50.1";
965745
+ return "5.50.3";
965343
965746
  }
965344
965747
  getCliName() {
965345
965748
  if (false) {