@fern-api/fern-api-dev 5.92.1 → 5.92.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +101 -49
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -350095,6 +350095,23 @@ var init_x_fern_discriminated = __esm({
350095
350095
  });
350096
350096
 
350097
350097
  // ../api-importers/v3-importer-commons/lib/converters/schema/OneOfSchemaConverter.js
350098
+ function isUnionWithoutVariants(type7) {
350099
+ return type7.type === "union" && type7.types.length === 0;
350100
+ }
350101
+ function getLiteralDiscriminant({ schema, discriminantProperty }) {
350102
+ const discriminantSchema = schema.properties?.[discriminantProperty];
350103
+ if (discriminantSchema == null || "$ref" in discriminantSchema) {
350104
+ return void 0;
350105
+ }
350106
+ const constValue = discriminantSchema.const;
350107
+ if (typeof constValue === "string") {
350108
+ return constValue;
350109
+ }
350110
+ if (discriminantSchema.enum?.length === 1 && typeof discriminantSchema.enum[0] === "string") {
350111
+ return discriminantSchema.enum[0];
350112
+ }
350113
+ return void 0;
350114
+ }
350098
350115
  var OneOfSchemaConverter;
350099
350116
  var init_OneOfSchemaConverter = __esm({
350100
350117
  "../api-importers/v3-importer-commons/lib/converters/schema/OneOfSchemaConverter.js"() {
@@ -350130,7 +350147,11 @@ var init_OneOfSchemaConverter = __esm({
350130
350147
  return this.convertAsUndiscriminatedUnion();
350131
350148
  }
350132
350149
  if (this.schema.discriminator != null) {
350133
- return this.convertAsDiscriminatedUnion();
350150
+ const discriminatedUnion2 = this.convertAsDiscriminatedUnion();
350151
+ if (discriminatedUnion2 != null && !isUnionWithoutVariants(discriminatedUnion2.type)) {
350152
+ return discriminatedUnion2;
350153
+ }
350154
+ return this.convertAsUndiscriminatedUnion() ?? discriminatedUnion2;
350134
350155
  }
350135
350156
  if (this.context.settings.inferForwardCompatible) {
350136
350157
  const openEndedEnum = this.convertAsOpenEndedEnum();
@@ -350217,44 +350238,80 @@ var init_OneOfSchemaConverter = __esm({
350217
350238
  };
350218
350239
  }
350219
350240
  /**
350220
- * When `discriminator.mapping` is absent, infers the mapping from the `oneOf`/`anyOf` $ref schemas.
350241
+ * The variants of the union, from `discriminator.mapping` when it is declared and otherwise
350242
+ * inferred from the `oneOf`/`anyOf` members.
350221
350243
  *
350222
350244
  * Per the OpenAPI 3.x spec, if no mapping is provided the discriminant values are derived from
350223
- * the schema names in the $ref paths. We also check the resolved schema's discriminant property
350224
- * for `const` or single-element `enum` values, which take precedence over the schema name.
350225
- */
350226
- inferDiscriminatorMapping(discriminantProperty) {
350245
+ * the schema names in the $ref paths. We also check the discriminant property of each member
350246
+ * for `const` or single-element `enum` values, which take precedence over the schema name and
350247
+ * are the only way to name a member that is inlined rather than $ref'd.
350248
+ *
350249
+ * Returns no variants when a member's discriminant value cannot be determined, since a union
350250
+ * missing that member is worse than an undiscriminated one.
350251
+ */
350252
+ getVariants(discriminantProperty) {
350253
+ const mapping = this.schema.discriminator?.mapping;
350254
+ if (mapping != null) {
350255
+ const variants2 = [];
350256
+ for (const [discriminant22, ref2] of Object.entries(mapping)) {
350257
+ const typeId = this.context.getTypeIdFromSchemaReference({ $ref: ref2 });
350258
+ if (typeId == null) {
350259
+ continue;
350260
+ }
350261
+ variants2.push({
350262
+ discriminant: discriminant22,
350263
+ typeId,
350264
+ ref: ref2,
350265
+ schema: this.resolveVariantSchema({ $ref: ref2 }),
350266
+ breadcrumbs: [...this.breadcrumbs, "discriminator", "mapping", discriminant22]
350267
+ });
350268
+ }
350269
+ return variants2;
350270
+ }
350227
350271
  const subSchemas = this.schema.oneOf ?? this.schema.anyOf ?? [];
350228
- const mapping = {};
350229
- for (const subSchema of subSchemas) {
350272
+ const variants = [];
350273
+ for (const [index3, subSchema] of subSchemas.entries()) {
350274
+ const schema = this.resolveVariantSchema(subSchema);
350275
+ const literalDiscriminant = schema != null ? getLiteralDiscriminant({ schema, discriminantProperty }) : void 0;
350230
350276
  if (!this.context.isReferenceObject(subSchema)) {
350277
+ if (literalDiscriminant == null) {
350278
+ return [];
350279
+ }
350280
+ variants.push({
350281
+ discriminant: literalDiscriminant,
350282
+ typeId: this.context.convertBreadcrumbsToName([`${this.id}_${index3}`]),
350283
+ schema,
350284
+ breadcrumbs: [...this.breadcrumbs, `oneOf[${index3}]`]
350285
+ });
350231
350286
  continue;
350232
350287
  }
350233
350288
  const ref2 = subSchema.$ref;
350234
350289
  const schemaName = ref2.split("/").pop();
350235
- if (schemaName == null) {
350236
- continue;
350290
+ const typeId = this.context.getTypeIdFromSchemaReference(subSchema);
350291
+ const discriminant22 = literalDiscriminant ?? schemaName;
350292
+ if (typeId == null || discriminant22 == null) {
350293
+ return [];
350237
350294
  }
350238
- const resolved = this.context.resolveReference({
350239
- reference: subSchema,
350240
- breadcrumbs: this.breadcrumbs,
350241
- skipErrorCollector: true
350295
+ variants.push({
350296
+ discriminant: discriminant22,
350297
+ typeId,
350298
+ ref: ref2,
350299
+ schema,
350300
+ breadcrumbs: [...this.breadcrumbs, "discriminator", "mapping", discriminant22]
350242
350301
  });
350243
- let discriminantValue = schemaName;
350244
- if (resolved.resolved) {
350245
- const discriminantPropSchema = resolved.value.properties?.[discriminantProperty];
350246
- if (discriminantPropSchema != null && !this.context.isReferenceObject(discriminantPropSchema)) {
350247
- const constValue = discriminantPropSchema.const;
350248
- if (typeof constValue === "string") {
350249
- discriminantValue = constValue;
350250
- } else if (discriminantPropSchema.enum != null && discriminantPropSchema.enum.length === 1 && typeof discriminantPropSchema.enum[0] === "string") {
350251
- discriminantValue = discriminantPropSchema.enum[0];
350252
- }
350253
- }
350254
- }
350255
- mapping[discriminantValue] = ref2;
350256
350302
  }
350257
- return mapping;
350303
+ return variants;
350304
+ }
350305
+ resolveVariantSchema(schemaOrReference) {
350306
+ if (!this.context.isReferenceObject(schemaOrReference)) {
350307
+ return schemaOrReference;
350308
+ }
350309
+ const resolved = this.context.resolveReference({
350310
+ reference: schemaOrReference,
350311
+ breadcrumbs: this.breadcrumbs,
350312
+ skipErrorCollector: true
350313
+ });
350314
+ return resolved.resolved ? resolved.value : void 0;
350258
350315
  }
350259
350316
  convertAsDiscriminatedUnion() {
350260
350317
  if (this.schema.discriminator == null) {
@@ -350264,18 +350321,13 @@ var init_OneOfSchemaConverter = __esm({
350264
350321
  const unionTypes = [];
350265
350322
  let referencedTypes = /* @__PURE__ */ new Set();
350266
350323
  let inlinedTypes = {};
350267
- const effectiveMapping = this.schema.discriminator.mapping ?? this.inferDiscriminatorMapping(discriminantProperty);
350268
- for (const [discriminant22, reference4] of Object.entries(effectiveMapping)) {
350269
- const typeId = this.context.getTypeIdFromSchemaReference({ $ref: reference4 });
350270
- const breadcrumbs = [...this.breadcrumbs, "discriminator", "mapping", discriminant22];
350271
- const resolvedSchema = this.context.resolveReference({
350272
- reference: { $ref: reference4 },
350273
- breadcrumbs
350274
- });
350275
- let schemaOrReference = { $ref: reference4 };
350276
- if (resolvedSchema.resolved && resolvedSchema.value.properties != null && discriminantProperty in resolvedSchema.value.properties) {
350277
- const filteredSchema = this.filterDiscriminantFromSchema(resolvedSchema.value, discriminantProperty);
350278
- schemaOrReference = filteredSchema;
350324
+ for (const { discriminant: discriminant22, typeId, ref: ref2, schema: variantSchema, breadcrumbs } of this.getVariants(discriminantProperty)) {
350325
+ let schemaOrReference = ref2 != null ? { $ref: ref2 } : variantSchema;
350326
+ if (variantSchema?.properties != null && discriminantProperty in variantSchema.properties) {
350327
+ schemaOrReference = this.filterDiscriminantFromSchema(variantSchema, discriminantProperty);
350328
+ }
350329
+ if (schemaOrReference == null) {
350330
+ continue;
350279
350331
  }
350280
350332
  const singleUnionTypeSchemaConverter = new SchemaOrReferenceConverter({
350281
350333
  context: this.context,
@@ -350298,9 +350350,9 @@ var init_OneOfSchemaConverter = __esm({
350298
350350
  name: discriminant22,
350299
350351
  wireValue: discriminant22
350300
350352
  });
350301
- const rawSchemaName = reference4.split("/").pop() ?? typeId;
350302
- const schemaTitle = resolvedSchema.resolved ? resolvedSchema.value.title : void 0;
350303
- const schemaDescription = resolvedSchema.resolved ? resolvedSchema.value.description : void 0;
350353
+ const rawSchemaName = ref2?.split("/").pop() ?? typeId;
350354
+ const schemaTitle = variantSchema?.title;
350355
+ const schemaDescription = variantSchema?.description;
350304
350356
  const variantDisplayName = schemaTitle ?? discriminant22 ?? rawSchemaName;
350305
350357
  if (convertedSchema.schema?.typeDeclaration != null && schemaTitle != null) {
350306
350358
  convertedSchema.schema.typeDeclaration.name.displayName = schemaTitle;
@@ -702677,7 +702729,7 @@ var AccessTokenPosthogManager = class {
702677
702729
  properties: {
702678
702730
  ...event,
702679
702731
  ...event.properties,
702680
- version: "5.92.1",
702732
+ version: "5.92.2",
702681
702733
  usingAccessToken: true,
702682
702734
  ...getRunIdProperties()
702683
702735
  }
@@ -702743,7 +702795,7 @@ var UserPosthogManager = class {
702743
702795
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
702744
702796
  event: "CLI",
702745
702797
  properties: {
702746
- version: "5.92.1",
702798
+ version: "5.92.2",
702747
702799
  ...event,
702748
702800
  ...event.properties,
702749
702801
  usingAccessToken: false,
@@ -883909,7 +883961,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
883909
883961
  var LOGS_FOLDER_NAME = "logs";
883910
883962
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
883911
883963
  function getCliSource() {
883912
- const version7 = "5.92.1";
883964
+ const version7 = "5.92.2";
883913
883965
  return `cli@${version7}`;
883914
883966
  }
883915
883967
  var DebugLogger = class {
@@ -909225,7 +909277,7 @@ var LegacyDocsPublisher = class {
909225
909277
  previewId,
909226
909278
  disableTemplates: void 0,
909227
909279
  skipUpload,
909228
- cliVersion: "5.92.1",
909280
+ cliVersion: "5.92.2",
909229
909281
  loginCommand: "fern auth login"
909230
909282
  });
909231
909283
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -976141,7 +976193,7 @@ function getAutomationContextFromEnv() {
976141
976193
  config_branch: process.env.FERN_CONFIG_BRANCH,
976142
976194
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
976143
976195
  trigger: process.env.GITHUB_EVENT_NAME,
976144
- cli_version: "5.92.1"
976196
+ cli_version: "5.92.2"
976145
976197
  };
976146
976198
  }
976147
976199
  function isAutomationMode() {
@@ -976973,7 +977025,7 @@ var CliContext = class _CliContext {
976973
977025
  if (false) {
976974
977026
  this.logger.error("CLI_VERSION is not defined");
976975
977027
  }
976976
- return "5.92.1";
977028
+ return "5.92.2";
976977
977029
  }
976978
977030
  getCliName() {
976979
977031
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.92.1",
2
+ "version": "5.92.2",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",