@fern-api/fdr-sdk 1.2.102-1e451b148c → 1.2.103-6f6c57cd35

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 +6 -6
@@ -2389,6 +2389,7 @@ __export(api_definition_exports, {
2389
2389
  buildSdkSnippetRequest: () => buildSdkSnippetRequest,
2390
2390
  cleanLanguage: () => cleanLanguage,
2391
2391
  collectReferencedTypeIds: () => collectReferencedTypeIds,
2392
+ collectReferencingTypeIdsByTypeId: () => collectReferencingTypeIdsByTypeId,
2392
2393
  collectTypeDefinitionTree: () => collectTypeDefinitionTree,
2393
2394
  collectTypeDefinitionTreeForObjectProperty: () => collectTypeDefinitionTreeForObjectProperty,
2394
2395
  convertToCurl: () => convertToCurl,
@@ -4016,6 +4017,7 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
4016
4017
  };
4017
4018
  const namespaces = /* @__PURE__ */ new Set();
4018
4019
  const authSchemes = /* @__PURE__ */ new Set();
4020
+ const seedTypeIds = /* @__PURE__ */ new Set();
4019
4021
  for (const node of nodes) {
4020
4022
  if (node.type === "endpoint") {
4021
4023
  const found = this.api.endpoints[node.endpointId];
@@ -4052,9 +4054,14 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
4052
4054
  found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
4053
4055
  }
4054
4056
  }
4057
+ } else if (node.type === "graphqlType") {
4058
+ const found = this.api.types[node.typeId];
4059
+ if (found) {
4060
+ seedTypeIds.add(node.typeId);
4061
+ }
4055
4062
  }
4056
4063
  }
4057
- toRet.types = this.pruneTypes(toRet);
4064
+ toRet.types = this.pruneTypes(toRet, seedTypeIds);
4058
4065
  namespaces.forEach((subpackageId) => {
4059
4066
  const subpackage = this.api.subpackages[subpackageId];
4060
4067
  if (subpackage) {
@@ -4069,8 +4076,8 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
4069
4076
  });
4070
4077
  return toRet;
4071
4078
  }
4072
- pruneTypes(partiallyPrunedApi) {
4073
- let typeIds = /* @__PURE__ */ new Set();
4079
+ pruneTypes(partiallyPrunedApi, seedTypeIds = /* @__PURE__ */ new Set()) {
4080
+ let typeIds = new Set(seedTypeIds);
4074
4081
  partiallyPrunedApi.globalHeaders?.forEach((header) => {
4075
4082
  ApiTypeIdVisitor2.visitTypeShape(header.valueShape, (typeId) => typeIds.add(typeId));
4076
4083
  });
@@ -7582,6 +7589,28 @@ var Transformer = class _Transformer {
7582
7589
  };
7583
7590
  };
7584
7591
 
7592
+ // src/api-definition/type-back-references.ts
7593
+ function collectReferencingTypeIdsByTypeId(api2) {
7594
+ const byTypeId = /* @__PURE__ */ new Map();
7595
+ for (const [rawId, definition] of Object.entries(api2.types)) {
7596
+ const from = rawId;
7597
+ const seen = /* @__PURE__ */ new Set();
7598
+ ApiTypeIdVisitor2.visitTypeDefinition(definition, (to) => {
7599
+ if (to === from || seen.has(to) || api2.types[to] == null) {
7600
+ return;
7601
+ }
7602
+ seen.add(to);
7603
+ const existing = byTypeId.get(to);
7604
+ if (existing == null) {
7605
+ byTypeId.set(to, [from]);
7606
+ } else {
7607
+ existing.push(from);
7608
+ }
7609
+ });
7610
+ }
7611
+ return byTypeId;
7612
+ }
7613
+
7585
7614
  // src/orpc-client/api/contract-read.ts
7586
7615
  var z5 = __toESM(require("zod"), 1);
7587
7616
  var ReadUndiscriminatedUnionVariantSchema = z5.object({
@@ -13112,6 +13141,7 @@ function followRedirect(nodeToFollow) {
13112
13141
  webhook: (node) => node.slug,
13113
13142
  grpc: (node) => node.slug,
13114
13143
  graphql: (node) => node.slug,
13144
+ graphqlType: (node) => node.slug,
13115
13145
  landingPage: (node) => node.slug,
13116
13146
  // nodes with overview
13117
13147
  apiPackage: (node) => node.overviewPageId != null ? node.slug : followRedirects(node.children),
@@ -13166,6 +13196,7 @@ function getPageId2(node) {
13166
13196
  webhook: RETURN_UNDEFINED2,
13167
13197
  grpc: RETURN_UNDEFINED2,
13168
13198
  graphql: RETURN_UNDEFINED2,
13199
+ graphqlType: RETURN_UNDEFINED2,
13169
13200
  changelogYear: RETURN_UNDEFINED2,
13170
13201
  changelogMonth: RETURN_UNDEFINED2
13171
13202
  });
@@ -13173,7 +13204,7 @@ function getPageId2(node) {
13173
13204
 
13174
13205
  // src/navigation/versions/v1/NavigationNodeApiLeaf.ts
13175
13206
  function isApiLeaf2(node) {
13176
- return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql";
13207
+ return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql" || node.type === "graphqlType";
13177
13208
  }
13178
13209
 
13179
13210
  // src/navigation/versions/v1/NavigationNodePageLeaf.ts
@@ -13292,6 +13323,18 @@ function withCanonicalLookup(map) {
13292
13323
  map.has = (key) => originalHas(key) || originalHas(canonicalSlugKey(key));
13293
13324
  return map;
13294
13325
  }
13326
+ function graphQlTypeKey(apiDefinitionId, typeId, versionId) {
13327
+ return `${apiDefinitionId}:${versionId ?? ""}:${typeId}`;
13328
+ }
13329
+ function versionIdOf(parents) {
13330
+ for (let i = parents.length - 1; i >= 0; i--) {
13331
+ const parent = parents[i];
13332
+ if (parent?.type === "version") {
13333
+ return parent.versionId;
13334
+ }
13335
+ }
13336
+ return void 0;
13337
+ }
13295
13338
  var NodeCollectorInstances = /* @__PURE__ */ new WeakMap();
13296
13339
  var NodeCollector = class _NodeCollector {
13297
13340
  static EMPTY = new _NodeCollector(void 0);
@@ -13299,6 +13342,8 @@ var NodeCollector = class _NodeCollector {
13299
13342
  idToNode = /* @__PURE__ */ new Map();
13300
13343
  idToNodeParents = /* @__PURE__ */ new Map();
13301
13344
  slugToNode = /* @__PURE__ */ new Map();
13345
+ /** Keyed by {@link graphQlTypeKey} -- `typeId` alone is only unique within one API definition. */
13346
+ typeIdToGraphQlTypeNode = /* @__PURE__ */ new Map();
13302
13347
  orphanedNodes = [];
13303
13348
  static collect(rootNode) {
13304
13349
  if (rootNode == null) {
@@ -13368,6 +13413,13 @@ var NodeCollector = class _NodeCollector {
13368
13413
  this.idToNodeParents.set(node.id, parents);
13369
13414
  this.nodesInOrder.push(node);
13370
13415
  }
13416
+ if (node.type === "graphqlType") {
13417
+ const key = graphQlTypeKey(node.apiDefinitionId, node.typeId, versionIdOf(parents));
13418
+ const existingTypeNode = this.typeIdToGraphQlTypeNode.get(key);
13419
+ if (existingTypeNode == null || existingTypeNode.hidden === true && node.hidden !== true) {
13420
+ this.typeIdToGraphQlTypeNode.set(key, node);
13421
+ }
13422
+ }
13371
13423
  if (node.type === "sidebarRoot") {
13372
13424
  this.#last = void 0;
13373
13425
  this.#lastNeighboringNode = void 0;
@@ -13398,6 +13450,38 @@ var NodeCollector = class _NodeCollector {
13398
13450
  get slugMap() {
13399
13451
  return this.getSlugMap();
13400
13452
  }
13453
+ /**
13454
+ * GraphQL schema types that have their own page, keyed by
13455
+ * {@link graphQlTypeKey} -- `apiDefinitionId` *and* `typeId`.
13456
+ *
13457
+ * Exists so that a field whose value is `Product` can be rendered as a link
13458
+ * to `Product`'s page without every consumer re-walking the tree and picking
13459
+ * its own winner when a type appears under multiple versions or products.
13460
+ *
13461
+ * The key includes the API definition because `typeId` is only unique within
13462
+ * one definition: a docs site with several GraphQL APIs can legitimately have
13463
+ * a `Product` in each, and keying on `typeId` alone would link an operation in
13464
+ * one API to a type page in another.
13465
+ */
13466
+ getGraphQlTypeNodes = (0, import_function.once)(() => {
13467
+ return this.typeIdToGraphQlTypeNode;
13468
+ });
13469
+ /**
13470
+ * The type node documenting `typeId` within `apiDefinitionId` and `versionId`,
13471
+ * if one exists. Pass the version the caller is rendering in; undefined on an
13472
+ * unversioned site.
13473
+ *
13474
+ * There is deliberately no cross-version fallback: sending a reader in one
13475
+ * version to another version's type page is worse than not linking at all,
13476
+ * since the type may differ between versions.
13477
+ */
13478
+ getGraphQlTypeNode = (apiDefinitionId, typeId, versionId) => {
13479
+ return this.typeIdToGraphQlTypeNode.get(graphQlTypeKey(apiDefinitionId, typeId, versionId));
13480
+ };
13481
+ /** Slug of the page documenting `typeId`, if one exists. See {@link getGraphQlTypeNode}. */
13482
+ getGraphQlTypeSlug = (apiDefinitionId, typeId, versionId) => {
13483
+ return this.getGraphQlTypeNode(apiDefinitionId, typeId, versionId)?.slug;
13484
+ };
13401
13485
  get defaultVersionNode() {
13402
13486
  return this.defaultVersion;
13403
13487
  }
@@ -14347,6 +14431,36 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
14347
14431
  };
14348
14432
  return latest;
14349
14433
  };
14434
+ graphqlType = (node, parents) => {
14435
+ const apiDisambiguation = this.#createApiDisambiguationKey(parents);
14436
+ const slug = navigation_exports.Slug(node.slug);
14437
+ const canonicalSlug = this.#getAndSetCanonicalSlug(
14438
+ [
14439
+ `${apiDisambiguation}:api:graphqlType:${node.typeCategory}:${node.typeId}`,
14440
+ this.#createTitleDisambiguationKey(node, parents)
14441
+ ],
14442
+ slug
14443
+ );
14444
+ const latest = {
14445
+ type: "graphqlType",
14446
+ id: navigation_exports.NodeId(node.id),
14447
+ title: node.title,
14448
+ slug,
14449
+ canonicalSlug,
14450
+ icon: node.icon,
14451
+ hidden: node.hidden,
14452
+ authed: node.authed,
14453
+ collapsed: node.collapsed,
14454
+ apiDefinitionId: node.apiDefinitionId,
14455
+ typeId: node.typeId,
14456
+ typeCategory: node.typeCategory,
14457
+ availability: this.#availability(node.availability),
14458
+ viewers: node.viewers,
14459
+ orphaned: node.orphaned,
14460
+ featureFlags: node.featureFlags
14461
+ };
14462
+ return latest;
14463
+ };
14350
14464
  #variantChild = (child, parents) => {
14351
14465
  return visitDiscriminatedUnion_default(child)._visit({
14352
14466
  apiReference: (value) => this.apiReference(value, parents),
@@ -14377,7 +14491,8 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
14377
14491
  webSocket: (value) => this.webSocket(value, parents),
14378
14492
  webhook: (value) => this.webhook(value, parents),
14379
14493
  grpc: (value) => this.grpc(value, parents),
14380
- graphql: (value) => this.graphql(value, parents)
14494
+ graphql: (value) => this.graphql(value, parents),
14495
+ graphqlType: (value) => this.graphqlType(value, parents)
14381
14496
  });
14382
14497
  };
14383
14498
  /**