@fern-api/fdr-sdk 1.2.101-ea4b27b4b2 → 1.2.102-07ddc01b9b

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 (63) hide show
  1. package/dist/js/api-definition/index.js +33 -3
  2. package/dist/js/api-definition/index.js.map +1 -1
  3. package/dist/js/api-definition/index.mjs +32 -3
  4. package/dist/js/api-definition/index.mjs.map +1 -1
  5. package/dist/js/client/FdrClient.js +28 -1
  6. package/dist/js/client/FdrClient.js.map +1 -1
  7. package/dist/js/client/FdrClient.mjs +28 -1
  8. package/dist/js/client/FdrClient.mjs.map +1 -1
  9. package/dist/js/client/types.js.map +1 -1
  10. package/dist/js/client/types.mjs.map +1 -1
  11. package/dist/js/converters/index.js +120 -5
  12. package/dist/js/converters/index.js.map +1 -1
  13. package/dist/js/converters/index.mjs +120 -5
  14. package/dist/js/converters/index.mjs.map +1 -1
  15. package/dist/js/index.js +148 -6
  16. package/dist/js/index.js.map +1 -1
  17. package/dist/js/index.mjs +148 -6
  18. package/dist/js/index.mjs.map +1 -1
  19. package/dist/js/navigation/index.js +120 -5
  20. package/dist/js/navigation/index.js.map +1 -1
  21. package/dist/js/navigation/index.mjs +120 -5
  22. package/dist/js/navigation/index.mjs.map +1 -1
  23. package/dist/js/navigation/ledger-root-builder.js +40 -1
  24. package/dist/js/navigation/ledger-root-builder.js.map +1 -1
  25. package/dist/js/navigation/ledger-root-builder.mjs +40 -1
  26. package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
  27. package/dist/js/navigation/types/v1.js.map +1 -1
  28. package/dist/js/navigation/types/v1.mjs.map +1 -1
  29. package/dist/js/orpc-client.js +31 -1
  30. package/dist/js/orpc-client.js.map +1 -1
  31. package/dist/js/orpc-client.mjs +30 -1
  32. package/dist/js/orpc-client.mjs.map +1 -1
  33. package/dist/types/api-definition/__test__/type-back-references.test.d.ts +2 -0
  34. package/dist/types/api-definition/__test__/type-back-references.test.d.ts.map +1 -0
  35. package/dist/types/api-definition/index.d.ts +1 -0
  36. package/dist/types/api-definition/index.d.ts.map +1 -1
  37. package/dist/types/api-definition/prune.d.ts +3 -0
  38. package/dist/types/api-definition/prune.d.ts.map +1 -1
  39. package/dist/types/api-definition/type-back-references.d.ts +23 -0
  40. package/dist/types/api-definition/type-back-references.d.ts.map +1 -0
  41. package/dist/types/navigation/NodeCollector.d.ts +41 -0
  42. package/dist/types/navigation/NodeCollector.d.ts.map +1 -1
  43. package/dist/types/navigation/__test__/NodeCollector.graphqlTypeIndex.test.d.ts +2 -0
  44. package/dist/types/navigation/__test__/NodeCollector.graphqlTypeIndex.test.d.ts.map +1 -0
  45. package/dist/types/navigation/ledger-root-builder.d.ts +1 -1
  46. package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
  47. package/dist/types/navigation/migrators/__test__/graphqlType.test.d.ts +2 -0
  48. package/dist/types/navigation/migrators/__test__/graphqlType.test.d.ts.map +1 -0
  49. package/dist/types/navigation/migrators/v1ToV2.d.ts +1 -0
  50. package/dist/types/navigation/migrators/v1ToV2.d.ts.map +1 -1
  51. package/dist/types/navigation/types/v1.d.ts +14 -2
  52. package/dist/types/navigation/types/v1.d.ts.map +1 -1
  53. package/dist/types/navigation/versions/v1/NavigationNode.d.ts +1 -1
  54. package/dist/types/navigation/versions/v1/NavigationNode.d.ts.map +1 -1
  55. package/dist/types/navigation/versions/v1/NavigationNodeApiLeaf.d.ts +2 -2
  56. package/dist/types/navigation/versions/v1/NavigationNodeApiLeaf.d.ts.map +1 -1
  57. package/dist/types/navigation/versions/v1/followRedirect.d.ts.map +1 -1
  58. package/dist/types/navigation/versions/v1/getPageId.d.ts.map +1 -1
  59. package/dist/types/orpc-client/docs-ledger/contract.d.ts +4258 -948
  60. package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
  61. package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts +2792 -232
  62. package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts.map +1 -1
  63. package/package.json +1 -1
@@ -2365,6 +2365,7 @@ __export(api_definition_exports, {
2365
2365
  buildSdkSnippetRequest: () => buildSdkSnippetRequest,
2366
2366
  cleanLanguage: () => cleanLanguage,
2367
2367
  collectReferencedTypeIds: () => collectReferencedTypeIds,
2368
+ collectReferencingTypeIdsByTypeId: () => collectReferencingTypeIdsByTypeId,
2368
2369
  collectTypeDefinitionTree: () => collectTypeDefinitionTree,
2369
2370
  collectTypeDefinitionTreeForObjectProperty: () => collectTypeDefinitionTreeForObjectProperty,
2370
2371
  convertToCurl: () => convertToCurl,
@@ -3992,6 +3993,7 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
3992
3993
  };
3993
3994
  const namespaces = /* @__PURE__ */ new Set();
3994
3995
  const authSchemes = /* @__PURE__ */ new Set();
3996
+ const seedTypeIds = /* @__PURE__ */ new Set();
3995
3997
  for (const node of nodes) {
3996
3998
  if (node.type === "endpoint") {
3997
3999
  const found = this.api.endpoints[node.endpointId];
@@ -4028,9 +4030,14 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
4028
4030
  found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
4029
4031
  }
4030
4032
  }
4033
+ } else if (node.type === "graphqlType") {
4034
+ const found = this.api.types[node.typeId];
4035
+ if (found) {
4036
+ seedTypeIds.add(node.typeId);
4037
+ }
4031
4038
  }
4032
4039
  }
4033
- toRet.types = this.pruneTypes(toRet);
4040
+ toRet.types = this.pruneTypes(toRet, seedTypeIds);
4034
4041
  namespaces.forEach((subpackageId) => {
4035
4042
  const subpackage = this.api.subpackages[subpackageId];
4036
4043
  if (subpackage) {
@@ -4045,8 +4052,8 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
4045
4052
  });
4046
4053
  return toRet;
4047
4054
  }
4048
- pruneTypes(partiallyPrunedApi) {
4049
- let typeIds = /* @__PURE__ */ new Set();
4055
+ pruneTypes(partiallyPrunedApi, seedTypeIds = /* @__PURE__ */ new Set()) {
4056
+ let typeIds = new Set(seedTypeIds);
4050
4057
  partiallyPrunedApi.globalHeaders?.forEach((header) => {
4051
4058
  ApiTypeIdVisitor2.visitTypeShape(header.valueShape, (typeId) => typeIds.add(typeId));
4052
4059
  });
@@ -7558,6 +7565,28 @@ var Transformer = class _Transformer {
7558
7565
  };
7559
7566
  };
7560
7567
 
7568
+ // src/api-definition/type-back-references.ts
7569
+ function collectReferencingTypeIdsByTypeId(api2) {
7570
+ const byTypeId = /* @__PURE__ */ new Map();
7571
+ for (const [rawId, definition] of Object.entries(api2.types)) {
7572
+ const from = rawId;
7573
+ const seen = /* @__PURE__ */ new Set();
7574
+ ApiTypeIdVisitor2.visitTypeDefinition(definition, (to) => {
7575
+ if (to === from || seen.has(to) || api2.types[to] == null) {
7576
+ return;
7577
+ }
7578
+ seen.add(to);
7579
+ const existing = byTypeId.get(to);
7580
+ if (existing == null) {
7581
+ byTypeId.set(to, [from]);
7582
+ } else {
7583
+ existing.push(from);
7584
+ }
7585
+ });
7586
+ }
7587
+ return byTypeId;
7588
+ }
7589
+
7561
7590
  // src/orpc-client/api/contract-read.ts
7562
7591
  import * as z5 from "zod";
7563
7592
  var ReadUndiscriminatedUnionVariantSchema = z5.object({
@@ -13088,6 +13117,7 @@ function followRedirect(nodeToFollow) {
13088
13117
  webhook: (node) => node.slug,
13089
13118
  grpc: (node) => node.slug,
13090
13119
  graphql: (node) => node.slug,
13120
+ graphqlType: (node) => node.slug,
13091
13121
  landingPage: (node) => node.slug,
13092
13122
  // nodes with overview
13093
13123
  apiPackage: (node) => node.overviewPageId != null ? node.slug : followRedirects(node.children),
@@ -13142,6 +13172,7 @@ function getPageId2(node) {
13142
13172
  webhook: RETURN_UNDEFINED2,
13143
13173
  grpc: RETURN_UNDEFINED2,
13144
13174
  graphql: RETURN_UNDEFINED2,
13175
+ graphqlType: RETURN_UNDEFINED2,
13145
13176
  changelogYear: RETURN_UNDEFINED2,
13146
13177
  changelogMonth: RETURN_UNDEFINED2
13147
13178
  });
@@ -13149,7 +13180,7 @@ function getPageId2(node) {
13149
13180
 
13150
13181
  // src/navigation/versions/v1/NavigationNodeApiLeaf.ts
13151
13182
  function isApiLeaf2(node) {
13152
- return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql";
13183
+ return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql" || node.type === "graphqlType";
13153
13184
  }
13154
13185
 
13155
13186
  // src/navigation/versions/v1/NavigationNodePageLeaf.ts
@@ -13268,6 +13299,18 @@ function withCanonicalLookup(map) {
13268
13299
  map.has = (key) => originalHas(key) || originalHas(canonicalSlugKey(key));
13269
13300
  return map;
13270
13301
  }
13302
+ function graphQlTypeKey(apiDefinitionId, typeId, versionId) {
13303
+ return `${apiDefinitionId}:${versionId ?? ""}:${typeId}`;
13304
+ }
13305
+ function versionIdOf(parents) {
13306
+ for (let i = parents.length - 1; i >= 0; i--) {
13307
+ const parent = parents[i];
13308
+ if (parent?.type === "version") {
13309
+ return parent.versionId;
13310
+ }
13311
+ }
13312
+ return void 0;
13313
+ }
13271
13314
  var NodeCollectorInstances = /* @__PURE__ */ new WeakMap();
13272
13315
  var NodeCollector = class _NodeCollector {
13273
13316
  static EMPTY = new _NodeCollector(void 0);
@@ -13275,6 +13318,8 @@ var NodeCollector = class _NodeCollector {
13275
13318
  idToNode = /* @__PURE__ */ new Map();
13276
13319
  idToNodeParents = /* @__PURE__ */ new Map();
13277
13320
  slugToNode = /* @__PURE__ */ new Map();
13321
+ /** Keyed by {@link graphQlTypeKey} -- `typeId` alone is only unique within one API definition. */
13322
+ typeIdToGraphQlTypeNode = /* @__PURE__ */ new Map();
13278
13323
  orphanedNodes = [];
13279
13324
  static collect(rootNode) {
13280
13325
  if (rootNode == null) {
@@ -13344,6 +13389,13 @@ var NodeCollector = class _NodeCollector {
13344
13389
  this.idToNodeParents.set(node.id, parents);
13345
13390
  this.nodesInOrder.push(node);
13346
13391
  }
13392
+ if (node.type === "graphqlType") {
13393
+ const key = graphQlTypeKey(node.apiDefinitionId, node.typeId, versionIdOf(parents));
13394
+ const existingTypeNode = this.typeIdToGraphQlTypeNode.get(key);
13395
+ if (existingTypeNode == null || existingTypeNode.hidden === true && node.hidden !== true) {
13396
+ this.typeIdToGraphQlTypeNode.set(key, node);
13397
+ }
13398
+ }
13347
13399
  if (node.type === "sidebarRoot") {
13348
13400
  this.#last = void 0;
13349
13401
  this.#lastNeighboringNode = void 0;
@@ -13374,6 +13426,38 @@ var NodeCollector = class _NodeCollector {
13374
13426
  get slugMap() {
13375
13427
  return this.getSlugMap();
13376
13428
  }
13429
+ /**
13430
+ * GraphQL schema types that have their own page, keyed by
13431
+ * {@link graphQlTypeKey} -- `apiDefinitionId` *and* `typeId`.
13432
+ *
13433
+ * Exists so that a field whose value is `Product` can be rendered as a link
13434
+ * to `Product`'s page without every consumer re-walking the tree and picking
13435
+ * its own winner when a type appears under multiple versions or products.
13436
+ *
13437
+ * The key includes the API definition because `typeId` is only unique within
13438
+ * one definition: a docs site with several GraphQL APIs can legitimately have
13439
+ * a `Product` in each, and keying on `typeId` alone would link an operation in
13440
+ * one API to a type page in another.
13441
+ */
13442
+ getGraphQlTypeNodes = once(() => {
13443
+ return this.typeIdToGraphQlTypeNode;
13444
+ });
13445
+ /**
13446
+ * The type node documenting `typeId` within `apiDefinitionId` and `versionId`,
13447
+ * if one exists. Pass the version the caller is rendering in; undefined on an
13448
+ * unversioned site.
13449
+ *
13450
+ * There is deliberately no cross-version fallback: sending a reader in one
13451
+ * version to another version's type page is worse than not linking at all,
13452
+ * since the type may differ between versions.
13453
+ */
13454
+ getGraphQlTypeNode = (apiDefinitionId, typeId, versionId) => {
13455
+ return this.typeIdToGraphQlTypeNode.get(graphQlTypeKey(apiDefinitionId, typeId, versionId));
13456
+ };
13457
+ /** Slug of the page documenting `typeId`, if one exists. See {@link getGraphQlTypeNode}. */
13458
+ getGraphQlTypeSlug = (apiDefinitionId, typeId, versionId) => {
13459
+ return this.getGraphQlTypeNode(apiDefinitionId, typeId, versionId)?.slug;
13460
+ };
13377
13461
  get defaultVersionNode() {
13378
13462
  return this.defaultVersion;
13379
13463
  }
@@ -14323,6 +14407,36 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
14323
14407
  };
14324
14408
  return latest;
14325
14409
  };
14410
+ graphqlType = (node, parents) => {
14411
+ const apiDisambiguation = this.#createApiDisambiguationKey(parents);
14412
+ const slug = navigation_exports.Slug(node.slug);
14413
+ const canonicalSlug = this.#getAndSetCanonicalSlug(
14414
+ [
14415
+ `${apiDisambiguation}:api:graphqlType:${node.typeCategory}:${node.typeId}`,
14416
+ this.#createTitleDisambiguationKey(node, parents)
14417
+ ],
14418
+ slug
14419
+ );
14420
+ const latest = {
14421
+ type: "graphqlType",
14422
+ id: navigation_exports.NodeId(node.id),
14423
+ title: node.title,
14424
+ slug,
14425
+ canonicalSlug,
14426
+ icon: node.icon,
14427
+ hidden: node.hidden,
14428
+ authed: node.authed,
14429
+ collapsed: node.collapsed,
14430
+ apiDefinitionId: node.apiDefinitionId,
14431
+ typeId: node.typeId,
14432
+ typeCategory: node.typeCategory,
14433
+ availability: this.#availability(node.availability),
14434
+ viewers: node.viewers,
14435
+ orphaned: node.orphaned,
14436
+ featureFlags: node.featureFlags
14437
+ };
14438
+ return latest;
14439
+ };
14326
14440
  #variantChild = (child, parents) => {
14327
14441
  return visitDiscriminatedUnion_default(child)._visit({
14328
14442
  apiReference: (value) => this.apiReference(value, parents),
@@ -14353,7 +14467,8 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
14353
14467
  webSocket: (value) => this.webSocket(value, parents),
14354
14468
  webhook: (value) => this.webhook(value, parents),
14355
14469
  grpc: (value) => this.grpc(value, parents),
14356
- graphql: (value) => this.graphql(value, parents)
14470
+ graphql: (value) => this.graphql(value, parents),
14471
+ graphqlType: (value) => this.graphqlType(value, parents)
14357
14472
  });
14358
14473
  };
14359
14474
  /**