@fern-api/fern-api-dev 5.92.1 → 5.92.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 +152 -79
  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;
@@ -453722,6 +453774,47 @@ function findInlineCodeEnd(content5, start2) {
453722
453774
  }
453723
453775
  return null;
453724
453776
  }
453777
+ function findLabelEnd(content5, start2) {
453778
+ const limit = findScanLimit(content5, start2);
453779
+ let depth = 0;
453780
+ let i5 = start2;
453781
+ while (i5 < limit) {
453782
+ if (content5[i5] === "\\") {
453783
+ i5 += 2;
453784
+ continue;
453785
+ }
453786
+ if (content5[i5] === "[") {
453787
+ depth++;
453788
+ } else if (content5[i5] === "]") {
453789
+ depth--;
453790
+ if (depth === 0) {
453791
+ if (content5[i5 + 1] === "(") {
453792
+ return i5;
453793
+ }
453794
+ return findLabelEndBeforeNextBracket(content5, i5 + 1, limit);
453795
+ }
453796
+ }
453797
+ i5++;
453798
+ }
453799
+ return null;
453800
+ }
453801
+ function findLabelEndBeforeNextBracket(content5, start2, limit) {
453802
+ let i5 = start2;
453803
+ while (i5 < limit) {
453804
+ if (content5[i5] === "\\") {
453805
+ i5 += 2;
453806
+ continue;
453807
+ }
453808
+ if (content5[i5] === "[") {
453809
+ return null;
453810
+ }
453811
+ if (content5[i5] === "]" && content5[i5 + 1] === "(") {
453812
+ return i5;
453813
+ }
453814
+ i5++;
453815
+ }
453816
+ return null;
453817
+ }
453725
453818
  function streamingScanForImages(content5, metadata) {
453726
453819
  const filepaths = /* @__PURE__ */ new Set();
453727
453820
  const edits = [];
@@ -453770,19 +453863,12 @@ function streamingScanForImages(content5, metadata) {
453770
453863
  return { filepaths, edits };
453771
453864
  }
453772
453865
  function parseMarkdownImage(content5, start2, metadata) {
453773
- let i5 = start2 + 2;
453774
453866
  const len = content5.length;
453775
- while (i5 < len && content5[i5] !== "]") {
453776
- if (content5[i5] === "\\") {
453777
- i5 += 2;
453778
- } else {
453779
- i5++;
453780
- }
453781
- }
453782
- if (i5 >= len || content5[i5] !== "]" || content5[i5 + 1] !== "(") {
453867
+ const labelEnd2 = findLabelEnd(content5, start2 + 1);
453868
+ if (labelEnd2 == null || content5[labelEnd2 + 1] !== "(") {
453783
453869
  return null;
453784
453870
  }
453785
- i5 += 2;
453871
+ let i5 = labelEnd2 + 2;
453786
453872
  const urlStart = i5;
453787
453873
  let parenDepth = 1;
453788
453874
  while (i5 < len && parenDepth > 0) {
@@ -453841,19 +453927,12 @@ function splitDestinationAndTitle(url3) {
453841
453927
  return isTitle ? url3.slice(0, i5) : url3;
453842
453928
  }
453843
453929
  function parseMarkdownLink(content5, start2, metadata) {
453844
- let i5 = start2 + 1;
453845
453930
  const len = content5.length;
453846
- while (i5 < len && content5[i5] !== "]") {
453847
- if (content5[i5] === "\\") {
453848
- i5 += 2;
453849
- } else {
453850
- i5++;
453851
- }
453852
- }
453853
- if (i5 >= len || content5[i5] !== "]" || content5[i5 + 1] !== "(") {
453931
+ const labelEnd2 = findLabelEnd(content5, start2);
453932
+ if (labelEnd2 == null || content5[labelEnd2 + 1] !== "(") {
453854
453933
  return null;
453855
453934
  }
453856
- i5 += 2;
453935
+ let i5 = labelEnd2 + 2;
453857
453936
  let parenDepth = 1;
453858
453937
  while (i5 < len && parenDepth > 0) {
453859
453938
  if (content5[i5] === "\\") {
@@ -454264,16 +454343,10 @@ function replaceImagePathsAndUrls(markdown, fileIdsMap, markdownFilesToPathName,
454264
454343
  continue;
454265
454344
  }
454266
454345
  } else if (content5[i5] === "[" && content5[i5 - 1] !== "!") {
454267
- let j5 = i5 + 1;
454268
- while (j5 < len && content5[j5] !== "]") {
454269
- if (content5[j5] === "\\") {
454270
- j5 += 2;
454271
- } else {
454272
- j5++;
454273
- }
454274
- }
454275
- if (j5 < len && content5[j5] === "]" && content5[j5 + 1] === "(") {
454276
- j5 += 2;
454346
+ const labelEnd2 = findLabelEnd(content5, i5);
454347
+ let j5 = labelEnd2 ?? len;
454348
+ if (labelEnd2 != null && content5[labelEnd2 + 1] === "(") {
454349
+ j5 = labelEnd2 + 2;
454277
454350
  const urlStart = j5;
454278
454351
  let parenDepth = 1;
454279
454352
  while (j5 < len && parenDepth > 0) {
@@ -702677,7 +702750,7 @@ var AccessTokenPosthogManager = class {
702677
702750
  properties: {
702678
702751
  ...event,
702679
702752
  ...event.properties,
702680
- version: "5.92.1",
702753
+ version: "5.92.3",
702681
702754
  usingAccessToken: true,
702682
702755
  ...getRunIdProperties()
702683
702756
  }
@@ -702743,7 +702816,7 @@ var UserPosthogManager = class {
702743
702816
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
702744
702817
  event: "CLI",
702745
702818
  properties: {
702746
- version: "5.92.1",
702819
+ version: "5.92.3",
702747
702820
  ...event,
702748
702821
  ...event.properties,
702749
702822
  usingAccessToken: false,
@@ -883909,7 +883982,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
883909
883982
  var LOGS_FOLDER_NAME = "logs";
883910
883983
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
883911
883984
  function getCliSource() {
883912
- const version7 = "5.92.1";
883985
+ const version7 = "5.92.3";
883913
883986
  return `cli@${version7}`;
883914
883987
  }
883915
883988
  var DebugLogger = class {
@@ -909225,7 +909298,7 @@ var LegacyDocsPublisher = class {
909225
909298
  previewId,
909226
909299
  disableTemplates: void 0,
909227
909300
  skipUpload,
909228
- cliVersion: "5.92.1",
909301
+ cliVersion: "5.92.3",
909229
909302
  loginCommand: "fern auth login"
909230
909303
  });
909231
909304
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -976141,7 +976214,7 @@ function getAutomationContextFromEnv() {
976141
976214
  config_branch: process.env.FERN_CONFIG_BRANCH,
976142
976215
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
976143
976216
  trigger: process.env.GITHUB_EVENT_NAME,
976144
- cli_version: "5.92.1"
976217
+ cli_version: "5.92.3"
976145
976218
  };
976146
976219
  }
976147
976220
  function isAutomationMode() {
@@ -976973,7 +977046,7 @@ var CliContext = class _CliContext {
976973
977046
  if (false) {
976974
977047
  this.logger.error("CLI_VERSION is not defined");
976975
977048
  }
976976
- return "5.92.1";
977049
+ return "5.92.3";
976977
977050
  }
976978
977051
  getCliName() {
976979
977052
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.92.1",
2
+ "version": "5.92.3",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",