@fern-api/fern-api-dev 4.79.1 → 4.79.2-1-g5b81c6143bc

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 +106 -41
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -529060,6 +529060,9 @@ function variantMatchesSseSpec(schema2, context3) {
529060
529060
  }
529061
529061
  return hasEvent;
529062
529062
  }
529063
+ function resolveDiscriminatorContext({ discriminator, context: context3 }) {
529064
+ return getExtension(discriminator, FernOpenAPIExtension.DISCRIMINATOR_CONTEXT) ?? inferDiscriminatorContext({ discriminator, context: context3 });
529065
+ }
529063
529066
  function inferDiscriminatorContext({ discriminator, context: context3 }) {
529064
529067
  const mapping = discriminator.mapping;
529065
529068
  if (mapping == null || Object.keys(mapping).length === 0) {
@@ -529099,7 +529102,7 @@ function inferDiscriminatorContextFromVariants({ variants, context: context3 })
529099
529102
  function convertDiscriminatedOneOf({ nameOverride, generatedName, title: title3, breadcrumbs, properties: properties7, description, availability, required: required6, wrapAsOptional, wrapAsNullable, discriminator, context: context3, namespace, groupName, encoding, source: source2 }) {
529100
529103
  const discriminant21 = discriminator.propertyName;
529101
529104
  const discriminantNameOverride = getExtension(discriminator, FernOpenAPIExtension.FERN_PROPERTY_NAME);
529102
- const discriminatorContext = getExtension(discriminator, FernOpenAPIExtension.DISCRIMINATOR_CONTEXT) ?? inferDiscriminatorContext({ discriminator, context: context3 });
529105
+ const discriminatorContext = resolveDiscriminatorContext({ discriminator, context: context3 });
529103
529106
  const unionSubTypes = Object.fromEntries(Object.entries(discriminator.mapping ?? {}).map(([discriminantValue, schema2]) => {
529104
529107
  const subtypeReference = convertReferenceObject({
529105
529108
  $ref: schema2
@@ -531309,7 +531312,11 @@ function convertSchemaObject(schema2, wrapAsOptional, wrapAsNullable, context3,
531309
531312
  }
531310
531313
  }
531311
531314
  if (schema2.type === "object" && schema2.discriminator != null && schema2.discriminator.mapping != null) {
531312
- if (!context3.options.discriminatedUnionV2) {
531315
+ const objectDiscriminatorContext = resolveDiscriminatorContext({
531316
+ discriminator: schema2.discriminator,
531317
+ context: context3
531318
+ });
531319
+ if (!context3.options.discriminatedUnionV2 || objectDiscriminatorContext === "protocol") {
531313
531320
  return convertDiscriminatedOneOf({
531314
531321
  nameOverride,
531315
531322
  generatedName,
@@ -531349,7 +531356,11 @@ function convertSchemaObject(schema2, wrapAsOptional, wrapAsNullable, context3,
531349
531356
  if (schema2.oneOf != null && schema2.oneOf.length > 0) {
531350
531357
  const isUndiscriminated = getExtension(schema2, FernOpenAPIExtension.IS_UNDISCRIMINATED);
531351
531358
  if (schema2.discriminator != null && schema2.discriminator.mapping != null && Object.keys(schema2.discriminator.mapping).length > 0) {
531352
- if (context3.options.discriminatedUnionV2 || isUndiscriminated) {
531359
+ const discriminatorContext = resolveDiscriminatorContext({
531360
+ discriminator: schema2.discriminator,
531361
+ context: context3
531362
+ });
531363
+ if ((context3.options.discriminatedUnionV2 || isUndiscriminated) && discriminatorContext !== "protocol") {
531353
531364
  return convertUndiscriminatedOneOfWithDiscriminant({
531354
531365
  nameOverride,
531355
531366
  generatedName,
@@ -600386,6 +600397,42 @@ function isExternalRefValue(value) {
600386
600397
  const ref2 = value["$ref"];
600387
600398
  return typeof ref2 === "string" && ref2.length > 0 && !ref2.startsWith("#") && !isUrlRef(ref2);
600388
600399
  }
600400
+ function collectSiblingProperties(record22) {
600401
+ const siblingProperties = {};
600402
+ let hasSiblings = false;
600403
+ for (const [key2, value] of Object.entries(record22)) {
600404
+ if (key2 !== "$ref") {
600405
+ siblingProperties[key2] = value;
600406
+ hasSiblings = true;
600407
+ }
600408
+ }
600409
+ return { siblingProperties, hasSiblings };
600410
+ }
600411
+ function navigateJsonPointer(root6, pointer2, filePath) {
600412
+ if (pointer2 === "") {
600413
+ return root6;
600414
+ }
600415
+ const segments = pointer2.split("/").filter((k19) => k19 !== "");
600416
+ let current3 = root6;
600417
+ for (const segment of segments) {
600418
+ const decodedKey = segment.replace(/~1/g, "/").replace(/~0/g, "~");
600419
+ if (typeof current3 !== "object" || current3 == null) {
600420
+ throw new Error(`Cannot navigate JSON Pointer "${pointer2}" in "${filePath}": expected an object but found ${typeof current3} at key "${decodedKey}"`);
600421
+ }
600422
+ const next2 = current3[decodedKey];
600423
+ if (next2 === void 0) {
600424
+ throw new Error(`Cannot navigate JSON Pointer "${pointer2}" in "${filePath}": key "${decodedKey}" not found`);
600425
+ }
600426
+ current3 = next2;
600427
+ }
600428
+ return current3;
600429
+ }
600430
+ function mergeWithSiblings(resolved, siblingProperties, hasSiblings) {
600431
+ if (hasSiblings && resolved != null && typeof resolved === "object" && !Array.isArray(resolved)) {
600432
+ return { ...resolved, ...siblingProperties };
600433
+ }
600434
+ return resolved;
600435
+ }
600389
600436
  function findInternalRef(absRefPath, jsonPointer, mainFileAbsPath, registry2) {
600390
600437
  if (absRefPath === mainFileAbsPath) {
600391
600438
  return "#" + jsonPointer;
@@ -600406,24 +600453,37 @@ function findInternalRef(absRefPath, jsonPointer, mainFileAbsPath, registry2) {
600406
600453
  }
600407
600454
  return null;
600408
600455
  }
600409
- async function resolveExternalRefs(obj, baseDir, mainFileAbsPath, registry2, applyRegistry = false, visited = /* @__PURE__ */ new Set(), fileCache = /* @__PURE__ */ new Map()) {
600456
+ async function resolveExternalRefs(obj, baseDir, mainFileAbsPath, registry2, applyRegistry = false, visited = /* @__PURE__ */ new Set(), fileCache = /* @__PURE__ */ new Map(), sourceFileAbsPath) {
600410
600457
  if (obj == null || typeof obj !== "object") {
600411
600458
  return obj;
600412
600459
  }
600413
600460
  if (Array.isArray(obj)) {
600414
- return Promise.all(obj.map((item) => resolveExternalRefs(item, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache)));
600461
+ return Promise.all(obj.map((item) => resolveExternalRefs(item, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache, sourceFileAbsPath)));
600415
600462
  }
600416
600463
  const record22 = obj;
600417
600464
  const ref2 = record22["$ref"];
600465
+ if (typeof ref2 === "string" && ref2.startsWith("#") && sourceFileAbsPath != null) {
600466
+ const pointer2 = ref2.substring(1);
600467
+ const { siblingProperties, hasSiblings } = collectSiblingProperties(record22);
600468
+ const internalRef = findInternalRef(sourceFileAbsPath, pointer2, mainFileAbsPath, registry2);
600469
+ if (internalRef !== null) {
600470
+ return hasSiblings ? { $ref: internalRef, ...siblingProperties } : { $ref: internalRef };
600471
+ }
600472
+ const cacheKey = `${sourceFileAbsPath}#${pointer2}`;
600473
+ if (visited.has(cacheKey)) {
600474
+ throw new Error(`Circular $ref detected: "${ref2}" (resolved to "${cacheKey}")`);
600475
+ }
600476
+ const newVisited = new Set(visited);
600477
+ newVisited.add(cacheKey);
600478
+ const fileContent = await readAndParseFile(sourceFileAbsPath, fileCache);
600479
+ const parsed = navigateJsonPointer(fileContent, pointer2, sourceFileAbsPath);
600480
+ const refDir = (0, import_path33.dirname)(sourceFileAbsPath);
600481
+ const resolved = await resolveExternalRefs(parsed, refDir, mainFileAbsPath, registry2, true, newVisited, fileCache, sourceFileAbsPath);
600482
+ return mergeWithSiblings(resolved, siblingProperties, hasSiblings);
600483
+ }
600418
600484
  if (typeof ref2 === "string" && !ref2.startsWith("#") && !isUrlRef(ref2)) {
600419
600485
  const { jsonPointer, absolutePath: absoluteRefPath } = parseExternalRef(ref2, baseDir);
600420
- const siblingProperties = {};
600421
- for (const [key2, value] of Object.entries(record22)) {
600422
- if (key2 !== "$ref") {
600423
- siblingProperties[key2] = value;
600424
- }
600425
- }
600426
- const hasSiblings = Object.keys(siblingProperties).length > 0;
600486
+ const { siblingProperties, hasSiblings } = collectSiblingProperties(record22);
600427
600487
  if (applyRegistry) {
600428
600488
  const internalRef = findInternalRef(absoluteRefPath, jsonPointer, mainFileAbsPath, registry2);
600429
600489
  if (internalRef !== null) {
@@ -600436,33 +600496,15 @@ async function resolveExternalRefs(obj, baseDir, mainFileAbsPath, registry2, app
600436
600496
  }
600437
600497
  const newVisited = new Set(visited);
600438
600498
  newVisited.add(cacheKey);
600439
- let parsed = await readAndParseFile(absoluteRefPath, fileCache);
600440
- if (jsonPointer !== "") {
600441
- const keys24 = jsonPointer.split("/").filter((k19) => k19 !== "");
600442
- let current3 = parsed;
600443
- for (const key2 of keys24) {
600444
- const decodedKey = key2.replace(/~1/g, "/").replace(/~0/g, "~");
600445
- if (typeof current3 !== "object" || current3 == null) {
600446
- throw new Error(`Cannot navigate JSON Pointer "${jsonPointer}" in "${absoluteRefPath}": expected an object but found ${typeof current3} at key "${decodedKey}"`);
600447
- }
600448
- const next2 = current3[decodedKey];
600449
- if (next2 === void 0) {
600450
- throw new Error(`Cannot navigate JSON Pointer "${jsonPointer}" in "${absoluteRefPath}": key "${decodedKey}" not found`);
600451
- }
600452
- current3 = next2;
600453
- }
600454
- parsed = current3;
600455
- }
600499
+ const fileContent = await readAndParseFile(absoluteRefPath, fileCache);
600500
+ const parsed = navigateJsonPointer(fileContent, jsonPointer, absoluteRefPath);
600456
600501
  const refDir = (0, import_path33.dirname)(absoluteRefPath);
600457
- const resolved = await resolveExternalRefs(parsed, refDir, mainFileAbsPath, registry2, true, newVisited, fileCache);
600458
- if (hasSiblings && resolved != null && typeof resolved === "object" && !Array.isArray(resolved)) {
600459
- return { ...resolved, ...siblingProperties };
600460
- }
600461
- return resolved;
600502
+ const resolved = await resolveExternalRefs(parsed, refDir, mainFileAbsPath, registry2, true, newVisited, fileCache, absoluteRefPath);
600503
+ return mergeWithSiblings(resolved, siblingProperties, hasSiblings);
600462
600504
  }
600463
600505
  const result = {};
600464
600506
  for (const [key2, value] of Object.entries(record22)) {
600465
- result[key2] = await resolveExternalRefs(value, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache);
600507
+ result[key2] = await resolveExternalRefs(value, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache, sourceFileAbsPath);
600466
600508
  }
600467
600509
  return result;
600468
600510
  }
@@ -601840,6 +601882,7 @@ var extensions_exports = {};
601840
601882
  __export(extensions_exports, {
601841
601883
  AudienceExtension: () => AudienceExtension,
601842
601884
  FernAvailabilityExtension: () => FernAvailabilityExtension,
601885
+ FernDiscriminatorContextExtension: () => FernDiscriminatorContextExtension,
601843
601886
  FernEnumExtension: () => FernEnumExtension,
601844
601887
  FernIgnoreExtension: () => FernIgnoreExtension,
601845
601888
  FernOptionalExtension: () => FernOptionalExtension,
@@ -601907,6 +601950,23 @@ var FernAvailabilityExtension = class extends AbstractExtension {
601907
601950
  }
601908
601951
  };
601909
601952
 
601953
+ // ../api-importers/v3-importer-commons/lib/extensions/x-fern-discriminator-context.js
601954
+ var FernDiscriminatorContextExtension = class extends AbstractExtension {
601955
+ node;
601956
+ key = "x-fern-discriminator-context";
601957
+ constructor({ breadcrumbs, node: node4, context: context3 }) {
601958
+ super({ breadcrumbs, context: context3 });
601959
+ this.node = node4;
601960
+ }
601961
+ convert() {
601962
+ const extensionValue = this.getExtensionValue(this.node);
601963
+ if (extensionValue === "data" || extensionValue === "protocol") {
601964
+ return extensionValue;
601965
+ }
601966
+ return void 0;
601967
+ }
601968
+ };
601969
+
601910
601970
  // ../api-importers/v3-importer-commons/lib/schemas/EnumSchema.js
601911
601971
  var CasingConfigSchema = external_exports2.object({
601912
601972
  snake: external_exports2.string().optional(),
@@ -604587,6 +604647,11 @@ var OneOfSchemaConverter = class extends AbstractConverter {
604587
604647
  for (const typeId of Object.keys({ ...inlinedTypes, ...inlinedTypesFromProperties })) {
604588
604648
  referencedTypes.add(typeId);
604589
604649
  }
604650
+ const discriminatorContextExtension = new FernDiscriminatorContextExtension({
604651
+ context: this.context,
604652
+ breadcrumbs: [...this.breadcrumbs, "discriminator"],
604653
+ node: this.schema.discriminator
604654
+ });
604590
604655
  return {
604591
604656
  type: Type.union({
604592
604657
  baseProperties,
@@ -604597,7 +604662,7 @@ var OneOfSchemaConverter = class extends AbstractConverter {
604597
604662
  extends: extends_,
604598
604663
  types: unionTypes,
604599
604664
  default: void 0,
604600
- discriminatorContext: void 0
604665
+ discriminatorContext: discriminatorContextExtension.convert()
604601
604666
  }),
604602
604667
  referencedTypes,
604603
604668
  inlinedTypes: {
@@ -622228,7 +622293,7 @@ var AccessTokenPosthogManager = class {
622228
622293
  properties: {
622229
622294
  ...event,
622230
622295
  ...event.properties,
622231
- version: "4.79.1",
622296
+ version: "4.79.2-1-g5b81c6143bc",
622232
622297
  usingAccessToken: true
622233
622298
  }
622234
622299
  });
@@ -622282,7 +622347,7 @@ var UserPosthogManager = class {
622282
622347
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
622283
622348
  event: "CLI",
622284
622349
  properties: {
622285
- version: "4.79.1",
622350
+ version: "4.79.2-1-g5b81c6143bc",
622286
622351
  ...event,
622287
622352
  ...event.properties,
622288
622353
  usingAccessToken: false,
@@ -839509,7 +839574,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
839509
839574
  var LOGS_FOLDER_NAME = "logs";
839510
839575
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
839511
839576
  function getCliSource() {
839512
- const version7 = "4.79.1";
839577
+ const version7 = "4.79.2-1-g5b81c6143bc";
839513
839578
  return `cli@${version7}`;
839514
839579
  }
839515
839580
  var DebugLogger = class {
@@ -850838,7 +850903,7 @@ var LegacyDocsPublisher = class {
850838
850903
  previewId,
850839
850904
  disableTemplates: void 0,
850840
850905
  skipUpload,
850841
- cliVersion: "4.79.1"
850906
+ cliVersion: "4.79.2-1-g5b81c6143bc"
850842
850907
  });
850843
850908
  if (taskContext.getResult() === TaskResult.Failure) {
850844
850909
  return { success: false };
@@ -925911,7 +925976,7 @@ var CliContext = class _CliContext {
925911
925976
  if (false) {
925912
925977
  this.logger.error("CLI_VERSION is not defined");
925913
925978
  }
925914
- return "4.79.1";
925979
+ return "4.79.2-1-g5b81c6143bc";
925915
925980
  }
925916
925981
  getCliName() {
925917
925982
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.79.1",
2
+ "version": "4.79.2-1-g5b81c6143bc",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",