@fern-api/fern-api-dev 4.79.1-5-g9a03471cd52 → 4.79.1-6-g3bfff4ddf55

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 +68 -37
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -600386,6 +600386,42 @@ function isExternalRefValue(value) {
600386
600386
  const ref2 = value["$ref"];
600387
600387
  return typeof ref2 === "string" && ref2.length > 0 && !ref2.startsWith("#") && !isUrlRef(ref2);
600388
600388
  }
600389
+ function collectSiblingProperties(record22) {
600390
+ const siblingProperties = {};
600391
+ let hasSiblings = false;
600392
+ for (const [key2, value] of Object.entries(record22)) {
600393
+ if (key2 !== "$ref") {
600394
+ siblingProperties[key2] = value;
600395
+ hasSiblings = true;
600396
+ }
600397
+ }
600398
+ return { siblingProperties, hasSiblings };
600399
+ }
600400
+ function navigateJsonPointer(root6, pointer2, filePath) {
600401
+ if (pointer2 === "") {
600402
+ return root6;
600403
+ }
600404
+ const segments = pointer2.split("/").filter((k19) => k19 !== "");
600405
+ let current3 = root6;
600406
+ for (const segment of segments) {
600407
+ const decodedKey = segment.replace(/~1/g, "/").replace(/~0/g, "~");
600408
+ if (typeof current3 !== "object" || current3 == null) {
600409
+ throw new Error(`Cannot navigate JSON Pointer "${pointer2}" in "${filePath}": expected an object but found ${typeof current3} at key "${decodedKey}"`);
600410
+ }
600411
+ const next2 = current3[decodedKey];
600412
+ if (next2 === void 0) {
600413
+ throw new Error(`Cannot navigate JSON Pointer "${pointer2}" in "${filePath}": key "${decodedKey}" not found`);
600414
+ }
600415
+ current3 = next2;
600416
+ }
600417
+ return current3;
600418
+ }
600419
+ function mergeWithSiblings(resolved, siblingProperties, hasSiblings) {
600420
+ if (hasSiblings && resolved != null && typeof resolved === "object" && !Array.isArray(resolved)) {
600421
+ return { ...resolved, ...siblingProperties };
600422
+ }
600423
+ return resolved;
600424
+ }
600389
600425
  function findInternalRef(absRefPath, jsonPointer, mainFileAbsPath, registry2) {
600390
600426
  if (absRefPath === mainFileAbsPath) {
600391
600427
  return "#" + jsonPointer;
@@ -600406,24 +600442,37 @@ function findInternalRef(absRefPath, jsonPointer, mainFileAbsPath, registry2) {
600406
600442
  }
600407
600443
  return null;
600408
600444
  }
600409
- async function resolveExternalRefs(obj, baseDir, mainFileAbsPath, registry2, applyRegistry = false, visited = /* @__PURE__ */ new Set(), fileCache = /* @__PURE__ */ new Map()) {
600445
+ async function resolveExternalRefs(obj, baseDir, mainFileAbsPath, registry2, applyRegistry = false, visited = /* @__PURE__ */ new Set(), fileCache = /* @__PURE__ */ new Map(), sourceFileAbsPath) {
600410
600446
  if (obj == null || typeof obj !== "object") {
600411
600447
  return obj;
600412
600448
  }
600413
600449
  if (Array.isArray(obj)) {
600414
- return Promise.all(obj.map((item) => resolveExternalRefs(item, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache)));
600450
+ return Promise.all(obj.map((item) => resolveExternalRefs(item, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache, sourceFileAbsPath)));
600415
600451
  }
600416
600452
  const record22 = obj;
600417
600453
  const ref2 = record22["$ref"];
600454
+ if (typeof ref2 === "string" && ref2.startsWith("#") && sourceFileAbsPath != null) {
600455
+ const pointer2 = ref2.substring(1);
600456
+ const { siblingProperties, hasSiblings } = collectSiblingProperties(record22);
600457
+ const internalRef = findInternalRef(sourceFileAbsPath, pointer2, mainFileAbsPath, registry2);
600458
+ if (internalRef !== null) {
600459
+ return hasSiblings ? { $ref: internalRef, ...siblingProperties } : { $ref: internalRef };
600460
+ }
600461
+ const cacheKey = `${sourceFileAbsPath}#${pointer2}`;
600462
+ if (visited.has(cacheKey)) {
600463
+ throw new Error(`Circular $ref detected: "${ref2}" (resolved to "${cacheKey}")`);
600464
+ }
600465
+ const newVisited = new Set(visited);
600466
+ newVisited.add(cacheKey);
600467
+ const fileContent = await readAndParseFile(sourceFileAbsPath, fileCache);
600468
+ const parsed = navigateJsonPointer(fileContent, pointer2, sourceFileAbsPath);
600469
+ const refDir = (0, import_path33.dirname)(sourceFileAbsPath);
600470
+ const resolved = await resolveExternalRefs(parsed, refDir, mainFileAbsPath, registry2, true, newVisited, fileCache, sourceFileAbsPath);
600471
+ return mergeWithSiblings(resolved, siblingProperties, hasSiblings);
600472
+ }
600418
600473
  if (typeof ref2 === "string" && !ref2.startsWith("#") && !isUrlRef(ref2)) {
600419
600474
  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;
600475
+ const { siblingProperties, hasSiblings } = collectSiblingProperties(record22);
600427
600476
  if (applyRegistry) {
600428
600477
  const internalRef = findInternalRef(absoluteRefPath, jsonPointer, mainFileAbsPath, registry2);
600429
600478
  if (internalRef !== null) {
@@ -600436,33 +600485,15 @@ async function resolveExternalRefs(obj, baseDir, mainFileAbsPath, registry2, app
600436
600485
  }
600437
600486
  const newVisited = new Set(visited);
600438
600487
  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
- }
600488
+ const fileContent = await readAndParseFile(absoluteRefPath, fileCache);
600489
+ const parsed = navigateJsonPointer(fileContent, jsonPointer, absoluteRefPath);
600456
600490
  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;
600491
+ const resolved = await resolveExternalRefs(parsed, refDir, mainFileAbsPath, registry2, true, newVisited, fileCache, absoluteRefPath);
600492
+ return mergeWithSiblings(resolved, siblingProperties, hasSiblings);
600462
600493
  }
600463
600494
  const result = {};
600464
600495
  for (const [key2, value] of Object.entries(record22)) {
600465
- result[key2] = await resolveExternalRefs(value, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache);
600496
+ result[key2] = await resolveExternalRefs(value, baseDir, mainFileAbsPath, registry2, applyRegistry, visited, fileCache, sourceFileAbsPath);
600466
600497
  }
600467
600498
  return result;
600468
600499
  }
@@ -622228,7 +622259,7 @@ var AccessTokenPosthogManager = class {
622228
622259
  properties: {
622229
622260
  ...event,
622230
622261
  ...event.properties,
622231
- version: "4.79.1-5-g9a03471cd52",
622262
+ version: "4.79.1-6-g3bfff4ddf55",
622232
622263
  usingAccessToken: true
622233
622264
  }
622234
622265
  });
@@ -622282,7 +622313,7 @@ var UserPosthogManager = class {
622282
622313
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
622283
622314
  event: "CLI",
622284
622315
  properties: {
622285
- version: "4.79.1-5-g9a03471cd52",
622316
+ version: "4.79.1-6-g3bfff4ddf55",
622286
622317
  ...event,
622287
622318
  ...event.properties,
622288
622319
  usingAccessToken: false,
@@ -839509,7 +839540,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
839509
839540
  var LOGS_FOLDER_NAME = "logs";
839510
839541
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
839511
839542
  function getCliSource() {
839512
- const version7 = "4.79.1-5-g9a03471cd52";
839543
+ const version7 = "4.79.1-6-g3bfff4ddf55";
839513
839544
  return `cli@${version7}`;
839514
839545
  }
839515
839546
  var DebugLogger = class {
@@ -850838,7 +850869,7 @@ var LegacyDocsPublisher = class {
850838
850869
  previewId,
850839
850870
  disableTemplates: void 0,
850840
850871
  skipUpload,
850841
- cliVersion: "4.79.1-5-g9a03471cd52"
850872
+ cliVersion: "4.79.1-6-g3bfff4ddf55"
850842
850873
  });
850843
850874
  if (taskContext.getResult() === TaskResult.Failure) {
850844
850875
  return { success: false };
@@ -925911,7 +925942,7 @@ var CliContext = class _CliContext {
925911
925942
  if (false) {
925912
925943
  this.logger.error("CLI_VERSION is not defined");
925913
925944
  }
925914
- return "4.79.1-5-g9a03471cd52";
925945
+ return "4.79.1-6-g3bfff4ddf55";
925915
925946
  }
925916
925947
  getCliName() {
925917
925948
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.79.1-5-g9a03471cd52",
2
+ "version": "4.79.1-6-g3bfff4ddf55",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",