@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
package/dist/js/index.mjs CHANGED
@@ -162,6 +162,7 @@ __export(api_definition_exports, {
162
162
  buildSdkSnippetRequest: () => buildSdkSnippetRequest,
163
163
  cleanLanguage: () => cleanLanguage,
164
164
  collectReferencedTypeIds: () => collectReferencedTypeIds,
165
+ collectReferencingTypeIdsByTypeId: () => collectReferencingTypeIdsByTypeId,
165
166
  collectTypeDefinitionTree: () => collectTypeDefinitionTree,
166
167
  collectTypeDefinitionTreeForObjectProperty: () => collectTypeDefinitionTreeForObjectProperty,
167
168
  convertToCurl: () => convertToCurl,
@@ -3167,6 +3168,7 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
3167
3168
  };
3168
3169
  const namespaces = /* @__PURE__ */ new Set();
3169
3170
  const authSchemes = /* @__PURE__ */ new Set();
3171
+ const seedTypeIds = /* @__PURE__ */ new Set();
3170
3172
  for (const node of nodes) {
3171
3173
  if (node.type === "endpoint") {
3172
3174
  const found = this.api.endpoints[node.endpointId];
@@ -3203,9 +3205,14 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
3203
3205
  found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
3204
3206
  }
3205
3207
  }
3208
+ } else if (node.type === "graphqlType") {
3209
+ const found = this.api.types[node.typeId];
3210
+ if (found) {
3211
+ seedTypeIds.add(node.typeId);
3212
+ }
3206
3213
  }
3207
3214
  }
3208
- toRet.types = this.pruneTypes(toRet);
3215
+ toRet.types = this.pruneTypes(toRet, seedTypeIds);
3209
3216
  namespaces.forEach((subpackageId) => {
3210
3217
  const subpackage = this.api.subpackages[subpackageId];
3211
3218
  if (subpackage) {
@@ -3220,8 +3227,8 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
3220
3227
  });
3221
3228
  return toRet;
3222
3229
  }
3223
- pruneTypes(partiallyPrunedApi) {
3224
- let typeIds = /* @__PURE__ */ new Set();
3230
+ pruneTypes(partiallyPrunedApi, seedTypeIds = /* @__PURE__ */ new Set()) {
3231
+ let typeIds = new Set(seedTypeIds);
3225
3232
  partiallyPrunedApi.globalHeaders?.forEach((header) => {
3226
3233
  ApiTypeIdVisitor.visitTypeShape(header.valueShape, (typeId) => typeIds.add(typeId));
3227
3234
  });
@@ -6736,6 +6743,28 @@ var Transformer = class _Transformer {
6736
6743
  };
6737
6744
  };
6738
6745
 
6746
+ // src/api-definition/type-back-references.ts
6747
+ function collectReferencingTypeIdsByTypeId(api2) {
6748
+ const byTypeId = /* @__PURE__ */ new Map();
6749
+ for (const [rawId, definition] of Object.entries(api2.types)) {
6750
+ const from = rawId;
6751
+ const seen = /* @__PURE__ */ new Set();
6752
+ ApiTypeIdVisitor.visitTypeDefinition(definition, (to) => {
6753
+ if (to === from || seen.has(to) || api2.types[to] == null) {
6754
+ return;
6755
+ }
6756
+ seen.add(to);
6757
+ const existing = byTypeId.get(to);
6758
+ if (existing == null) {
6759
+ byTypeId.set(to, [from]);
6760
+ } else {
6761
+ existing.push(from);
6762
+ }
6763
+ });
6764
+ }
6765
+ return byTypeId;
6766
+ }
6767
+
6739
6768
  // src/orpc-client/api/client.ts
6740
6769
  import { createORPCClient } from "@orpc/client";
6741
6770
  import { oc } from "@orpc/contract";
@@ -9549,6 +9578,7 @@ var LedgerArtifactTypeSchema = z21.enum([
9549
9578
  "webhook",
9550
9579
  "grpc",
9551
9580
  "graphql",
9581
+ "graphqlType",
9552
9582
  "changelog",
9553
9583
  "link",
9554
9584
  "file",
@@ -9696,6 +9726,28 @@ var LedgerGraphQlMetadataSchema = LedgerMetadataBaseSchema.extend({
9696
9726
  graphqlOperationId: z21.string(),
9697
9727
  operationType: GraphQlOperationTypeSchema
9698
9728
  });
9729
+ var LedgerGraphQlTypeMetadataSchema = LedgerMetadataBaseSchema.extend({
9730
+ ...ApiNodeMetadataFields,
9731
+ typeId: z21.string(),
9732
+ typeCategory: GraphQlTypeCategorySchema,
9733
+ /**
9734
+ * Ids of the types that reference this one directly, for the "referenced by"
9735
+ * section of a type page.
9736
+ *
9737
+ * Computed at publish, because it cannot be derived on the read side: a type
9738
+ * page's pruned definition contains what the type reaches, not what reaches
9739
+ * it, and the navigation tree carries no field-level type references.
9740
+ *
9741
+ * Types rather than operations: where a schema namespaces its operations
9742
+ * behind hub types, almost no operation names a leaf type directly, so an
9743
+ * operation-keyed list is empty for most types. The type graph has the edge
9744
+ * that exists, and it is small -- single digits for the large majority.
9745
+ *
9746
+ * Optional: absent on artifacts written before this field existed, and
9747
+ * omitted entirely when nothing references the type.
9748
+ */
9749
+ referencedByTypeIds: z21.array(z21.string()).optional()
9750
+ });
9699
9751
  var LedgerChangelogEntryMetadataSchema = LedgerMetadataBaseSchema.extend({
9700
9752
  ...NodeMetadataFields,
9701
9753
  pageId: z21.string(),
@@ -9740,6 +9792,7 @@ var LedgerArtifactMetadataSchema = z21.union([
9740
9792
  LedgerWebhookMetadataSchema,
9741
9793
  LedgerGrpcMetadataSchema,
9742
9794
  LedgerGraphQlMetadataSchema,
9795
+ LedgerGraphQlTypeMetadataSchema,
9743
9796
  LedgerChangelogEntryMetadataSchema,
9744
9797
  LedgerLinkMetadataSchema,
9745
9798
  LedgerFileArtifactMetadataSchema,
@@ -9753,6 +9806,7 @@ var LEDGER_ARTIFACT_METADATA_SCHEMAS = {
9753
9806
  webhook: LedgerWebhookMetadataSchema,
9754
9807
  grpc: LedgerGrpcMetadataSchema,
9755
9808
  graphql: LedgerGraphQlMetadataSchema,
9809
+ graphqlType: LedgerGraphQlTypeMetadataSchema,
9756
9810
  changelog: LedgerChangelogEntryMetadataSchema,
9757
9811
  link: LedgerLinkMetadataSchema,
9758
9812
  file: LedgerFileArtifactMetadataSchema,
@@ -9785,6 +9839,7 @@ var LedgerNavRouteSchema = z21.discriminatedUnion("type", [
9785
9839
  navRouteVariant("webhook"),
9786
9840
  navRouteVariant("grpc"),
9787
9841
  navRouteVariant("graphql"),
9842
+ navRouteVariant("graphqlType"),
9788
9843
  navRouteVariant("changelog"),
9789
9844
  navRouteVariant("link"),
9790
9845
  navRouteVariant("file"),
@@ -10100,6 +10155,7 @@ var RouteContextResponseSchema = z21.discriminatedUnion("artifactType", [
10100
10155
  artifactTypeVariant(RouteContextResponseBaseSchema, "webhook"),
10101
10156
  artifactTypeVariant(RouteContextResponseBaseSchema, "grpc"),
10102
10157
  artifactTypeVariant(RouteContextResponseBaseSchema, "graphql"),
10158
+ artifactTypeVariant(RouteContextResponseBaseSchema, "graphqlType"),
10103
10159
  artifactTypeVariant(RouteContextResponseBaseSchema, "changelog"),
10104
10160
  artifactTypeVariant(RouteContextResponseBaseSchema, "link"),
10105
10161
  artifactTypeVariant(RouteContextResponseBaseSchema, "file"),
@@ -10147,7 +10203,7 @@ var PrunedApiDefinitionInputSchema = z21.object({
10147
10203
  deploymentId: z21.string(),
10148
10204
  apiDefinitionId: z21.string(),
10149
10205
  /** Discriminator matching PruningNodeType.type → artifact metadata field. */
10150
- nodeType: z21.enum(["endpoint", "webSocket", "webhook", "grpc", "graphql"]),
10206
+ nodeType: z21.enum(["endpoint", "webSocket", "webhook", "grpc", "graphql", "graphqlType"]),
10151
10207
  /** The node ID value (endpointId, webSocketId, etc.). */
10152
10208
  nodeId: z21.string()
10153
10209
  });
@@ -18460,6 +18516,7 @@ function followRedirect(nodeToFollow) {
18460
18516
  webhook: (node) => node.slug,
18461
18517
  grpc: (node) => node.slug,
18462
18518
  graphql: (node) => node.slug,
18519
+ graphqlType: (node) => node.slug,
18463
18520
  landingPage: (node) => node.slug,
18464
18521
  // nodes with overview
18465
18522
  apiPackage: (node) => node.overviewPageId != null ? node.slug : followRedirects(node.children),
@@ -18514,6 +18571,7 @@ function getPageId2(node) {
18514
18571
  webhook: RETURN_UNDEFINED2,
18515
18572
  grpc: RETURN_UNDEFINED2,
18516
18573
  graphql: RETURN_UNDEFINED2,
18574
+ graphqlType: RETURN_UNDEFINED2,
18517
18575
  changelogYear: RETURN_UNDEFINED2,
18518
18576
  changelogMonth: RETURN_UNDEFINED2
18519
18577
  });
@@ -18521,7 +18579,7 @@ function getPageId2(node) {
18521
18579
 
18522
18580
  // src/navigation/versions/v1/NavigationNodeApiLeaf.ts
18523
18581
  function isApiLeaf2(node) {
18524
- return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql";
18582
+ return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql" || node.type === "graphqlType";
18525
18583
  }
18526
18584
 
18527
18585
  // src/navigation/versions/v1/NavigationNodePageLeaf.ts
@@ -18640,6 +18698,18 @@ function withCanonicalLookup(map) {
18640
18698
  map.has = (key) => originalHas(key) || originalHas(canonicalSlugKey(key));
18641
18699
  return map;
18642
18700
  }
18701
+ function graphQlTypeKey(apiDefinitionId, typeId, versionId) {
18702
+ return `${apiDefinitionId}:${versionId ?? ""}:${typeId}`;
18703
+ }
18704
+ function versionIdOf(parents) {
18705
+ for (let i = parents.length - 1; i >= 0; i--) {
18706
+ const parent = parents[i];
18707
+ if (parent?.type === "version") {
18708
+ return parent.versionId;
18709
+ }
18710
+ }
18711
+ return void 0;
18712
+ }
18643
18713
  var NodeCollectorInstances = /* @__PURE__ */ new WeakMap();
18644
18714
  var NodeCollector = class _NodeCollector {
18645
18715
  static EMPTY = new _NodeCollector(void 0);
@@ -18647,6 +18717,8 @@ var NodeCollector = class _NodeCollector {
18647
18717
  idToNode = /* @__PURE__ */ new Map();
18648
18718
  idToNodeParents = /* @__PURE__ */ new Map();
18649
18719
  slugToNode = /* @__PURE__ */ new Map();
18720
+ /** Keyed by {@link graphQlTypeKey} -- `typeId` alone is only unique within one API definition. */
18721
+ typeIdToGraphQlTypeNode = /* @__PURE__ */ new Map();
18650
18722
  orphanedNodes = [];
18651
18723
  static collect(rootNode) {
18652
18724
  if (rootNode == null) {
@@ -18716,6 +18788,13 @@ var NodeCollector = class _NodeCollector {
18716
18788
  this.idToNodeParents.set(node.id, parents);
18717
18789
  this.nodesInOrder.push(node);
18718
18790
  }
18791
+ if (node.type === "graphqlType") {
18792
+ const key = graphQlTypeKey(node.apiDefinitionId, node.typeId, versionIdOf(parents));
18793
+ const existingTypeNode = this.typeIdToGraphQlTypeNode.get(key);
18794
+ if (existingTypeNode == null || existingTypeNode.hidden === true && node.hidden !== true) {
18795
+ this.typeIdToGraphQlTypeNode.set(key, node);
18796
+ }
18797
+ }
18719
18798
  if (node.type === "sidebarRoot") {
18720
18799
  this.#last = void 0;
18721
18800
  this.#lastNeighboringNode = void 0;
@@ -18746,6 +18825,38 @@ var NodeCollector = class _NodeCollector {
18746
18825
  get slugMap() {
18747
18826
  return this.getSlugMap();
18748
18827
  }
18828
+ /**
18829
+ * GraphQL schema types that have their own page, keyed by
18830
+ * {@link graphQlTypeKey} -- `apiDefinitionId` *and* `typeId`.
18831
+ *
18832
+ * Exists so that a field whose value is `Product` can be rendered as a link
18833
+ * to `Product`'s page without every consumer re-walking the tree and picking
18834
+ * its own winner when a type appears under multiple versions or products.
18835
+ *
18836
+ * The key includes the API definition because `typeId` is only unique within
18837
+ * one definition: a docs site with several GraphQL APIs can legitimately have
18838
+ * a `Product` in each, and keying on `typeId` alone would link an operation in
18839
+ * one API to a type page in another.
18840
+ */
18841
+ getGraphQlTypeNodes = once(() => {
18842
+ return this.typeIdToGraphQlTypeNode;
18843
+ });
18844
+ /**
18845
+ * The type node documenting `typeId` within `apiDefinitionId` and `versionId`,
18846
+ * if one exists. Pass the version the caller is rendering in; undefined on an
18847
+ * unversioned site.
18848
+ *
18849
+ * There is deliberately no cross-version fallback: sending a reader in one
18850
+ * version to another version's type page is worse than not linking at all,
18851
+ * since the type may differ between versions.
18852
+ */
18853
+ getGraphQlTypeNode = (apiDefinitionId, typeId, versionId) => {
18854
+ return this.typeIdToGraphQlTypeNode.get(graphQlTypeKey(apiDefinitionId, typeId, versionId));
18855
+ };
18856
+ /** Slug of the page documenting `typeId`, if one exists. See {@link getGraphQlTypeNode}. */
18857
+ getGraphQlTypeSlug = (apiDefinitionId, typeId, versionId) => {
18858
+ return this.getGraphQlTypeNode(apiDefinitionId, typeId, versionId)?.slug;
18859
+ };
18749
18860
  get defaultVersionNode() {
18750
18861
  return this.defaultVersion;
18751
18862
  }
@@ -19695,6 +19806,36 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
19695
19806
  };
19696
19807
  return latest;
19697
19808
  };
19809
+ graphqlType = (node, parents) => {
19810
+ const apiDisambiguation = this.#createApiDisambiguationKey(parents);
19811
+ const slug = navigation_exports.Slug(node.slug);
19812
+ const canonicalSlug = this.#getAndSetCanonicalSlug(
19813
+ [
19814
+ `${apiDisambiguation}:api:graphqlType:${node.typeCategory}:${node.typeId}`,
19815
+ this.#createTitleDisambiguationKey(node, parents)
19816
+ ],
19817
+ slug
19818
+ );
19819
+ const latest = {
19820
+ type: "graphqlType",
19821
+ id: navigation_exports.NodeId(node.id),
19822
+ title: node.title,
19823
+ slug,
19824
+ canonicalSlug,
19825
+ icon: node.icon,
19826
+ hidden: node.hidden,
19827
+ authed: node.authed,
19828
+ collapsed: node.collapsed,
19829
+ apiDefinitionId: node.apiDefinitionId,
19830
+ typeId: node.typeId,
19831
+ typeCategory: node.typeCategory,
19832
+ availability: this.#availability(node.availability),
19833
+ viewers: node.viewers,
19834
+ orphaned: node.orphaned,
19835
+ featureFlags: node.featureFlags
19836
+ };
19837
+ return latest;
19838
+ };
19698
19839
  #variantChild = (child, parents) => {
19699
19840
  return visitDiscriminatedUnion_default(child)._visit({
19700
19841
  apiReference: (value) => this.apiReference(value, parents),
@@ -19725,7 +19866,8 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
19725
19866
  webSocket: (value) => this.webSocket(value, parents),
19726
19867
  webhook: (value) => this.webhook(value, parents),
19727
19868
  grpc: (value) => this.grpc(value, parents),
19728
- graphql: (value) => this.graphql(value, parents)
19869
+ graphql: (value) => this.graphql(value, parents),
19870
+ graphqlType: (value) => this.graphqlType(value, parents)
19729
19871
  });
19730
19872
  };
19731
19873
  /**