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

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
package/dist/js/index.js CHANGED
@@ -225,6 +225,7 @@ __export(api_definition_exports, {
225
225
  buildSdkSnippetRequest: () => buildSdkSnippetRequest,
226
226
  cleanLanguage: () => cleanLanguage,
227
227
  collectReferencedTypeIds: () => collectReferencedTypeIds,
228
+ collectReferencingTypeIdsByTypeId: () => collectReferencingTypeIdsByTypeId,
228
229
  collectTypeDefinitionTree: () => collectTypeDefinitionTree,
229
230
  collectTypeDefinitionTreeForObjectProperty: () => collectTypeDefinitionTreeForObjectProperty,
230
231
  convertToCurl: () => convertToCurl,
@@ -3230,6 +3231,7 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
3230
3231
  };
3231
3232
  const namespaces = /* @__PURE__ */ new Set();
3232
3233
  const authSchemes = /* @__PURE__ */ new Set();
3234
+ const seedTypeIds = /* @__PURE__ */ new Set();
3233
3235
  for (const node of nodes) {
3234
3236
  if (node.type === "endpoint") {
3235
3237
  const found = this.api.endpoints[node.endpointId];
@@ -3266,9 +3268,14 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
3266
3268
  found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
3267
3269
  }
3268
3270
  }
3271
+ } else if (node.type === "graphqlType") {
3272
+ const found = this.api.types[node.typeId];
3273
+ if (found) {
3274
+ seedTypeIds.add(node.typeId);
3275
+ }
3269
3276
  }
3270
3277
  }
3271
- toRet.types = this.pruneTypes(toRet);
3278
+ toRet.types = this.pruneTypes(toRet, seedTypeIds);
3272
3279
  namespaces.forEach((subpackageId) => {
3273
3280
  const subpackage = this.api.subpackages[subpackageId];
3274
3281
  if (subpackage) {
@@ -3283,8 +3290,8 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
3283
3290
  });
3284
3291
  return toRet;
3285
3292
  }
3286
- pruneTypes(partiallyPrunedApi) {
3287
- let typeIds = /* @__PURE__ */ new Set();
3293
+ pruneTypes(partiallyPrunedApi, seedTypeIds = /* @__PURE__ */ new Set()) {
3294
+ let typeIds = new Set(seedTypeIds);
3288
3295
  partiallyPrunedApi.globalHeaders?.forEach((header) => {
3289
3296
  ApiTypeIdVisitor.visitTypeShape(header.valueShape, (typeId) => typeIds.add(typeId));
3290
3297
  });
@@ -6799,6 +6806,28 @@ var Transformer = class _Transformer {
6799
6806
  };
6800
6807
  };
6801
6808
 
6809
+ // src/api-definition/type-back-references.ts
6810
+ function collectReferencingTypeIdsByTypeId(api2) {
6811
+ const byTypeId = /* @__PURE__ */ new Map();
6812
+ for (const [rawId, definition] of Object.entries(api2.types)) {
6813
+ const from = rawId;
6814
+ const seen = /* @__PURE__ */ new Set();
6815
+ ApiTypeIdVisitor.visitTypeDefinition(definition, (to) => {
6816
+ if (to === from || seen.has(to) || api2.types[to] == null) {
6817
+ return;
6818
+ }
6819
+ seen.add(to);
6820
+ const existing = byTypeId.get(to);
6821
+ if (existing == null) {
6822
+ byTypeId.set(to, [from]);
6823
+ } else {
6824
+ existing.push(from);
6825
+ }
6826
+ });
6827
+ }
6828
+ return byTypeId;
6829
+ }
6830
+
6802
6831
  // src/orpc-client/api/client.ts
6803
6832
  var import_client = require("@orpc/client");
6804
6833
  var import_contract = require("@orpc/contract");
@@ -9612,6 +9641,7 @@ var LedgerArtifactTypeSchema = z21.enum([
9612
9641
  "webhook",
9613
9642
  "grpc",
9614
9643
  "graphql",
9644
+ "graphqlType",
9615
9645
  "changelog",
9616
9646
  "link",
9617
9647
  "file",
@@ -9759,6 +9789,28 @@ var LedgerGraphQlMetadataSchema = LedgerMetadataBaseSchema.extend({
9759
9789
  graphqlOperationId: z21.string(),
9760
9790
  operationType: GraphQlOperationTypeSchema
9761
9791
  });
9792
+ var LedgerGraphQlTypeMetadataSchema = LedgerMetadataBaseSchema.extend({
9793
+ ...ApiNodeMetadataFields,
9794
+ typeId: z21.string(),
9795
+ typeCategory: GraphQlTypeCategorySchema,
9796
+ /**
9797
+ * Ids of the types that reference this one directly, for the "referenced by"
9798
+ * section of a type page.
9799
+ *
9800
+ * Computed at publish, because it cannot be derived on the read side: a type
9801
+ * page's pruned definition contains what the type reaches, not what reaches
9802
+ * it, and the navigation tree carries no field-level type references.
9803
+ *
9804
+ * Types rather than operations: where a schema namespaces its operations
9805
+ * behind hub types, almost no operation names a leaf type directly, so an
9806
+ * operation-keyed list is empty for most types. The type graph has the edge
9807
+ * that exists, and it is small -- single digits for the large majority.
9808
+ *
9809
+ * Optional: absent on artifacts written before this field existed, and
9810
+ * omitted entirely when nothing references the type.
9811
+ */
9812
+ referencedByTypeIds: z21.array(z21.string()).optional()
9813
+ });
9762
9814
  var LedgerChangelogEntryMetadataSchema = LedgerMetadataBaseSchema.extend({
9763
9815
  ...NodeMetadataFields,
9764
9816
  pageId: z21.string(),
@@ -9803,6 +9855,7 @@ var LedgerArtifactMetadataSchema = z21.union([
9803
9855
  LedgerWebhookMetadataSchema,
9804
9856
  LedgerGrpcMetadataSchema,
9805
9857
  LedgerGraphQlMetadataSchema,
9858
+ LedgerGraphQlTypeMetadataSchema,
9806
9859
  LedgerChangelogEntryMetadataSchema,
9807
9860
  LedgerLinkMetadataSchema,
9808
9861
  LedgerFileArtifactMetadataSchema,
@@ -9816,6 +9869,7 @@ var LEDGER_ARTIFACT_METADATA_SCHEMAS = {
9816
9869
  webhook: LedgerWebhookMetadataSchema,
9817
9870
  grpc: LedgerGrpcMetadataSchema,
9818
9871
  graphql: LedgerGraphQlMetadataSchema,
9872
+ graphqlType: LedgerGraphQlTypeMetadataSchema,
9819
9873
  changelog: LedgerChangelogEntryMetadataSchema,
9820
9874
  link: LedgerLinkMetadataSchema,
9821
9875
  file: LedgerFileArtifactMetadataSchema,
@@ -9848,6 +9902,7 @@ var LedgerNavRouteSchema = z21.discriminatedUnion("type", [
9848
9902
  navRouteVariant("webhook"),
9849
9903
  navRouteVariant("grpc"),
9850
9904
  navRouteVariant("graphql"),
9905
+ navRouteVariant("graphqlType"),
9851
9906
  navRouteVariant("changelog"),
9852
9907
  navRouteVariant("link"),
9853
9908
  navRouteVariant("file"),
@@ -10163,6 +10218,7 @@ var RouteContextResponseSchema = z21.discriminatedUnion("artifactType", [
10163
10218
  artifactTypeVariant(RouteContextResponseBaseSchema, "webhook"),
10164
10219
  artifactTypeVariant(RouteContextResponseBaseSchema, "grpc"),
10165
10220
  artifactTypeVariant(RouteContextResponseBaseSchema, "graphql"),
10221
+ artifactTypeVariant(RouteContextResponseBaseSchema, "graphqlType"),
10166
10222
  artifactTypeVariant(RouteContextResponseBaseSchema, "changelog"),
10167
10223
  artifactTypeVariant(RouteContextResponseBaseSchema, "link"),
10168
10224
  artifactTypeVariant(RouteContextResponseBaseSchema, "file"),
@@ -10210,7 +10266,7 @@ var PrunedApiDefinitionInputSchema = z21.object({
10210
10266
  deploymentId: z21.string(),
10211
10267
  apiDefinitionId: z21.string(),
10212
10268
  /** Discriminator matching PruningNodeType.type → artifact metadata field. */
10213
- nodeType: z21.enum(["endpoint", "webSocket", "webhook", "grpc", "graphql"]),
10269
+ nodeType: z21.enum(["endpoint", "webSocket", "webhook", "grpc", "graphql", "graphqlType"]),
10214
10270
  /** The node ID value (endpointId, webSocketId, etc.). */
10215
10271
  nodeId: z21.string()
10216
10272
  });
@@ -18523,6 +18579,7 @@ function followRedirect(nodeToFollow) {
18523
18579
  webhook: (node) => node.slug,
18524
18580
  grpc: (node) => node.slug,
18525
18581
  graphql: (node) => node.slug,
18582
+ graphqlType: (node) => node.slug,
18526
18583
  landingPage: (node) => node.slug,
18527
18584
  // nodes with overview
18528
18585
  apiPackage: (node) => node.overviewPageId != null ? node.slug : followRedirects(node.children),
@@ -18577,6 +18634,7 @@ function getPageId2(node) {
18577
18634
  webhook: RETURN_UNDEFINED2,
18578
18635
  grpc: RETURN_UNDEFINED2,
18579
18636
  graphql: RETURN_UNDEFINED2,
18637
+ graphqlType: RETURN_UNDEFINED2,
18580
18638
  changelogYear: RETURN_UNDEFINED2,
18581
18639
  changelogMonth: RETURN_UNDEFINED2
18582
18640
  });
@@ -18584,7 +18642,7 @@ function getPageId2(node) {
18584
18642
 
18585
18643
  // src/navigation/versions/v1/NavigationNodeApiLeaf.ts
18586
18644
  function isApiLeaf2(node) {
18587
- return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql";
18645
+ return node.type === "endpoint" || node.type === "webSocket" || node.type === "webhook" || node.type === "grpc" || node.type === "graphql" || node.type === "graphqlType";
18588
18646
  }
18589
18647
 
18590
18648
  // src/navigation/versions/v1/NavigationNodePageLeaf.ts
@@ -18703,6 +18761,18 @@ function withCanonicalLookup(map) {
18703
18761
  map.has = (key) => originalHas(key) || originalHas(canonicalSlugKey(key));
18704
18762
  return map;
18705
18763
  }
18764
+ function graphQlTypeKey(apiDefinitionId, typeId, versionId) {
18765
+ return `${apiDefinitionId}:${versionId ?? ""}:${typeId}`;
18766
+ }
18767
+ function versionIdOf(parents) {
18768
+ for (let i = parents.length - 1; i >= 0; i--) {
18769
+ const parent = parents[i];
18770
+ if (parent?.type === "version") {
18771
+ return parent.versionId;
18772
+ }
18773
+ }
18774
+ return void 0;
18775
+ }
18706
18776
  var NodeCollectorInstances = /* @__PURE__ */ new WeakMap();
18707
18777
  var NodeCollector = class _NodeCollector {
18708
18778
  static EMPTY = new _NodeCollector(void 0);
@@ -18710,6 +18780,8 @@ var NodeCollector = class _NodeCollector {
18710
18780
  idToNode = /* @__PURE__ */ new Map();
18711
18781
  idToNodeParents = /* @__PURE__ */ new Map();
18712
18782
  slugToNode = /* @__PURE__ */ new Map();
18783
+ /** Keyed by {@link graphQlTypeKey} -- `typeId` alone is only unique within one API definition. */
18784
+ typeIdToGraphQlTypeNode = /* @__PURE__ */ new Map();
18713
18785
  orphanedNodes = [];
18714
18786
  static collect(rootNode) {
18715
18787
  if (rootNode == null) {
@@ -18779,6 +18851,13 @@ var NodeCollector = class _NodeCollector {
18779
18851
  this.idToNodeParents.set(node.id, parents);
18780
18852
  this.nodesInOrder.push(node);
18781
18853
  }
18854
+ if (node.type === "graphqlType") {
18855
+ const key = graphQlTypeKey(node.apiDefinitionId, node.typeId, versionIdOf(parents));
18856
+ const existingTypeNode = this.typeIdToGraphQlTypeNode.get(key);
18857
+ if (existingTypeNode == null || existingTypeNode.hidden === true && node.hidden !== true) {
18858
+ this.typeIdToGraphQlTypeNode.set(key, node);
18859
+ }
18860
+ }
18782
18861
  if (node.type === "sidebarRoot") {
18783
18862
  this.#last = void 0;
18784
18863
  this.#lastNeighboringNode = void 0;
@@ -18809,6 +18888,38 @@ var NodeCollector = class _NodeCollector {
18809
18888
  get slugMap() {
18810
18889
  return this.getSlugMap();
18811
18890
  }
18891
+ /**
18892
+ * GraphQL schema types that have their own page, keyed by
18893
+ * {@link graphQlTypeKey} -- `apiDefinitionId` *and* `typeId`.
18894
+ *
18895
+ * Exists so that a field whose value is `Product` can be rendered as a link
18896
+ * to `Product`'s page without every consumer re-walking the tree and picking
18897
+ * its own winner when a type appears under multiple versions or products.
18898
+ *
18899
+ * The key includes the API definition because `typeId` is only unique within
18900
+ * one definition: a docs site with several GraphQL APIs can legitimately have
18901
+ * a `Product` in each, and keying on `typeId` alone would link an operation in
18902
+ * one API to a type page in another.
18903
+ */
18904
+ getGraphQlTypeNodes = (0, import_function.once)(() => {
18905
+ return this.typeIdToGraphQlTypeNode;
18906
+ });
18907
+ /**
18908
+ * The type node documenting `typeId` within `apiDefinitionId` and `versionId`,
18909
+ * if one exists. Pass the version the caller is rendering in; undefined on an
18910
+ * unversioned site.
18911
+ *
18912
+ * There is deliberately no cross-version fallback: sending a reader in one
18913
+ * version to another version's type page is worse than not linking at all,
18914
+ * since the type may differ between versions.
18915
+ */
18916
+ getGraphQlTypeNode = (apiDefinitionId, typeId, versionId) => {
18917
+ return this.typeIdToGraphQlTypeNode.get(graphQlTypeKey(apiDefinitionId, typeId, versionId));
18918
+ };
18919
+ /** Slug of the page documenting `typeId`, if one exists. See {@link getGraphQlTypeNode}. */
18920
+ getGraphQlTypeSlug = (apiDefinitionId, typeId, versionId) => {
18921
+ return this.getGraphQlTypeNode(apiDefinitionId, typeId, versionId)?.slug;
18922
+ };
18812
18923
  get defaultVersionNode() {
18813
18924
  return this.defaultVersion;
18814
18925
  }
@@ -19758,6 +19869,36 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
19758
19869
  };
19759
19870
  return latest;
19760
19871
  };
19872
+ graphqlType = (node, parents) => {
19873
+ const apiDisambiguation = this.#createApiDisambiguationKey(parents);
19874
+ const slug = navigation_exports.Slug(node.slug);
19875
+ const canonicalSlug = this.#getAndSetCanonicalSlug(
19876
+ [
19877
+ `${apiDisambiguation}:api:graphqlType:${node.typeCategory}:${node.typeId}`,
19878
+ this.#createTitleDisambiguationKey(node, parents)
19879
+ ],
19880
+ slug
19881
+ );
19882
+ const latest = {
19883
+ type: "graphqlType",
19884
+ id: navigation_exports.NodeId(node.id),
19885
+ title: node.title,
19886
+ slug,
19887
+ canonicalSlug,
19888
+ icon: node.icon,
19889
+ hidden: node.hidden,
19890
+ authed: node.authed,
19891
+ collapsed: node.collapsed,
19892
+ apiDefinitionId: node.apiDefinitionId,
19893
+ typeId: node.typeId,
19894
+ typeCategory: node.typeCategory,
19895
+ availability: this.#availability(node.availability),
19896
+ viewers: node.viewers,
19897
+ orphaned: node.orphaned,
19898
+ featureFlags: node.featureFlags
19899
+ };
19900
+ return latest;
19901
+ };
19761
19902
  #variantChild = (child, parents) => {
19762
19903
  return visitDiscriminatedUnion_default(child)._visit({
19763
19904
  apiReference: (value) => this.apiReference(value, parents),
@@ -19788,7 +19929,8 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
19788
19929
  webSocket: (value) => this.webSocket(value, parents),
19789
19930
  webhook: (value) => this.webhook(value, parents),
19790
19931
  grpc: (value) => this.grpc(value, parents),
19791
- graphql: (value) => this.graphql(value, parents)
19932
+ graphql: (value) => this.graphql(value, parents),
19933
+ graphqlType: (value) => this.graphqlType(value, parents)
19792
19934
  });
19793
19935
  };
19794
19936
  /**