@fern-api/fern-api-dev 5.47.3 → 5.47.4

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 +176 -63
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -237620,6 +237620,11 @@ var init_GraphQLConverter = __esm({
237620
237620
  }
237621
237621
  return true;
237622
237622
  }
237623
+ // NOTE: This heuristic treats a type as a namespace (operation-grouping type) when ALL
237624
+ // of its fields accept arguments. This can produce a false positive for regular data
237625
+ // types where every field happens to be parameterized. If that becomes a problem,
237626
+ // introduce an explicit config option (e.g. namespacedRootTypes: [...]) rather than
237627
+ // relying on field-arg counts alone.
237623
237628
  isNamespaceType(type8) {
237624
237629
  const fields = Object.values(type8.getFields());
237625
237630
  if (fields.length === 0) {
@@ -237627,29 +237632,81 @@ var init_GraphQLConverter = __esm({
237627
237632
  }
237628
237633
  return fields.every((f4) => f4.args.length > 0);
237629
237634
  }
237635
+ // Returns the names of object types that will be consumed as namespace groupings by
237636
+ // convertOperations — i.e. types that appear as the return type of a zero-arg root
237637
+ // field whose own fields all accept arguments. These types must be excluded from the
237638
+ // type registry in collectTypeDefinitions to prevent their fields from showing up
237639
+ // both as object properties and as standalone operations.
237640
+ collectNamespaceTypeNames() {
237641
+ if (!this.schema) {
237642
+ return /* @__PURE__ */ new Set();
237643
+ }
237644
+ const namespaceTypeNames = /* @__PURE__ */ new Set();
237645
+ const rootTypes = [];
237646
+ const queryType = this.schema.getQueryType();
237647
+ if (queryType) {
237648
+ rootTypes.push(queryType);
237649
+ }
237650
+ const mutationType = this.schema.getMutationType();
237651
+ if (mutationType) {
237652
+ rootTypes.push(mutationType);
237653
+ }
237654
+ const subscriptionType = this.schema.getSubscriptionType();
237655
+ if (subscriptionType && this.isActualSubscriptionRootType(subscriptionType)) {
237656
+ rootTypes.push(subscriptionType);
237657
+ }
237658
+ for (const rootType of rootTypes) {
237659
+ for (const field5 of Object.values(rootType.getFields())) {
237660
+ const returnRawType = this.unwrapNonNull(field5.type);
237661
+ if (returnRawType instanceof GraphQLObjectType && field5.args.length === 0 && this.isNamespaceType(returnRawType)) {
237662
+ namespaceTypeNames.add(returnRawType.name);
237663
+ }
237664
+ }
237665
+ }
237666
+ return namespaceTypeNames;
237667
+ }
237630
237668
  async convert() {
237631
237669
  const sdlContent = await (0, import_promises38.readFile)(this.filePath, "utf-8");
237632
237670
  this.schema = buildSchema(sdlContent);
237633
237671
  this.collectTypeDefinitions();
237634
- const graphqlOperations = {};
237672
+ const pendingOperations = [];
237635
237673
  const queryType = this.schema.getQueryType();
237636
237674
  if (queryType) {
237637
- this.convertOperations(queryType, "QUERY", graphqlOperations);
237675
+ this.convertOperations(queryType, "QUERY", pendingOperations);
237638
237676
  }
237639
237677
  const mutationType = this.schema.getMutationType();
237640
237678
  if (mutationType) {
237641
- this.convertOperations(mutationType, "MUTATION", graphqlOperations);
237679
+ this.convertOperations(mutationType, "MUTATION", pendingOperations);
237642
237680
  }
237643
237681
  const subscriptionType = this.schema.getSubscriptionType();
237644
237682
  if (subscriptionType && this.isActualSubscriptionRootType(subscriptionType)) {
237645
- this.convertOperations(subscriptionType, "SUBSCRIPTION", graphqlOperations);
237683
+ this.convertOperations(subscriptionType, "SUBSCRIPTION", pendingOperations);
237646
237684
  }
237685
+ const graphqlOperations = this.resolveOperationIds(pendingOperations);
237647
237686
  return { graphqlOperations, types: this.types };
237648
237687
  }
237688
+ resolveOperationIds(pending) {
237689
+ const flatIdCounts = /* @__PURE__ */ new Map();
237690
+ for (const op4 of pending) {
237691
+ flatIdCounts.set(op4.flatId, (flatIdCounts.get(op4.flatId) ?? 0) + 1);
237692
+ }
237693
+ const result = {};
237694
+ for (const op4 of pending) {
237695
+ const hasCollision = (flatIdCounts.get(op4.flatId) ?? 0) > 1;
237696
+ const finalId = hasCollision ? op4.namespacedId : op4.flatId;
237697
+ const operationId = this.getNamespacedOperationId(finalId);
237698
+ result[operationId] = {
237699
+ ...op4.operation,
237700
+ id: operationId
237701
+ };
237702
+ }
237703
+ return result;
237704
+ }
237649
237705
  collectTypeDefinitions() {
237650
237706
  if (!this.schema) {
237651
237707
  return;
237652
237708
  }
237709
+ const namespaceTypeNames = this.collectNamespaceTypeNames();
237653
237710
  const typeMap = this.schema.getTypeMap();
237654
237711
  for (const [typeName, type8] of Object.entries(typeMap)) {
237655
237712
  if (typeName.startsWith("__")) {
@@ -237661,6 +237718,9 @@ var init_GraphQLConverter = __esm({
237661
237718
  if (type8 === this.schema.getSubscriptionType() && type8 instanceof GraphQLObjectType && this.isActualSubscriptionRootType(type8)) {
237662
237719
  continue;
237663
237720
  }
237721
+ if (type8 instanceof GraphQLObjectType && namespaceTypeNames.has(typeName)) {
237722
+ continue;
237723
+ }
237664
237724
  if (type8 instanceof GraphQLScalarType && this.isBuiltInScalar(typeName)) {
237665
237725
  continue;
237666
237726
  }
@@ -237746,23 +237806,32 @@ var init_GraphQLConverter = __esm({
237746
237806
  }
237747
237807
  }
237748
237808
  }
237749
- convertOperations(type8, operationType, operations) {
237809
+ convertOperations(type8, operationType, pending) {
237750
237810
  const fields = type8.getFields();
237751
237811
  for (const [fieldName, field5] of Object.entries(fields)) {
237752
237812
  const returnRawType = this.unwrapNonNull(field5.type);
237753
237813
  if (returnRawType instanceof GraphQLObjectType && field5.args.length === 0 && this.isNamespaceType(returnRawType)) {
237754
- this.convertNamespaceOperations(returnRawType, fieldName, operationType, operations);
237814
+ this.convertNamespaceOperations(returnRawType, operationType, pending, [fieldName]);
237755
237815
  } else {
237756
- const operationId = this.getNamespacedOperationId(`${operationType.toLowerCase()}_${fieldName}`);
237757
- operations[operationId] = this.convertField(field5, fieldName, operationType);
237816
+ const flatId = `${operationType.toLowerCase()}_${fieldName}`;
237817
+ pending.push({
237818
+ flatId,
237819
+ namespacedId: flatId,
237820
+ operation: this.convertField(field5, fieldName, operationType)
237821
+ });
237758
237822
  }
237759
237823
  }
237760
237824
  }
237761
- convertNamespaceOperations(namespaceType, _parentName, operationType, operations) {
237825
+ convertNamespaceOperations(namespaceType, operationType, pending, fieldPath) {
237762
237826
  const fields = namespaceType.getFields();
237763
237827
  for (const [fieldName, field5] of Object.entries(fields)) {
237764
- const operationId = this.getNamespacedOperationId(`${operationType.toLowerCase()}_${fieldName}`);
237765
- operations[operationId] = this.convertField(field5, fieldName, operationType);
237828
+ const flatId = `${operationType.toLowerCase()}_${fieldName}`;
237829
+ const namespacedId = `${operationType.toLowerCase()}_${[...fieldPath, fieldName].join(".")}`;
237830
+ pending.push({
237831
+ flatId,
237832
+ namespacedId,
237833
+ operation: this.convertField(field5, fieldName, operationType, fieldPath)
237834
+ });
237766
237835
  }
237767
237836
  }
237768
237837
  unwrapNonNull(type8) {
@@ -237771,16 +237840,18 @@ var init_GraphQLConverter = __esm({
237771
237840
  }
237772
237841
  return type8;
237773
237842
  }
237774
- convertField(field5, name2, operationType) {
237843
+ convertField(field5, name2, operationType, fieldPath) {
237775
237844
  const args = field5.args.map((arg) => this.convertArgument(arg));
237776
237845
  const examples = this.examplesByOperation.get(`${operationType.toLowerCase()}:${name2}`) ?? this.examplesByOperation.get(name2);
237777
237846
  return {
237778
- id: this.getNamespacedOperationId(`${operationType.toLowerCase()}_${name2}`),
237847
+ id: FdrAPI_exports.GraphQlOperationId(""),
237848
+ // placeholder, resolved in resolveOperationIds
237779
237849
  operationType,
237780
237850
  name: name2,
237781
237851
  displayName: void 0,
237782
237852
  description: field5.description ?? void 0,
237783
237853
  availability: void 0,
237854
+ fieldPath: fieldPath != null && fieldPath.length > 0 ? fieldPath : void 0,
237784
237855
  arguments: args.length > 0 ? args : void 0,
237785
237856
  returnType: this.convertOutputType(field5.type),
237786
237857
  examples: examples != null && examples.length > 0 ? examples : void 0,
@@ -237974,7 +238045,8 @@ var init_GraphQLConverter = __esm({
237974
238045
  valueType: this.convertOutputType(field5.type),
237975
238046
  description: field5.description ?? void 0,
237976
238047
  availability: void 0,
237977
- propertyAccess: void 0
238048
+ propertyAccess: void 0,
238049
+ arguments: field5.args.length > 0 ? field5.args.map((arg) => this.convertArgument(arg)) : void 0
237978
238050
  }));
237979
238051
  const interfaces = type8.getInterfaces();
237980
238052
  const extendsIds = interfaces.filter((iface) => {
@@ -238021,7 +238093,8 @@ var init_GraphQLConverter = __esm({
238021
238093
  valueType: this.convertOutputType(field5.type),
238022
238094
  description: field5.description ?? void 0,
238023
238095
  availability: void 0,
238024
- propertyAccess: void 0
238096
+ propertyAccess: void 0,
238097
+ arguments: field5.args.length > 0 ? field5.args.map((arg) => this.convertArgument(arg)) : void 0
238025
238098
  }));
238026
238099
  return {
238027
238100
  type: "object",
@@ -670391,7 +670464,7 @@ var AccessTokenPosthogManager = class {
670391
670464
  properties: {
670392
670465
  ...event,
670393
670466
  ...event.properties,
670394
- version: "5.47.3",
670467
+ version: "5.47.4",
670395
670468
  usingAccessToken: true,
670396
670469
  ...getRunIdProperties()
670397
670470
  }
@@ -670455,7 +670528,7 @@ var UserPosthogManager = class {
670455
670528
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
670456
670529
  event: "CLI",
670457
670530
  properties: {
670458
- version: "5.47.3",
670531
+ version: "5.47.4",
670459
670532
  ...event,
670460
670533
  ...event.properties,
670461
670534
  usingAccessToken: false,
@@ -821724,6 +821797,9 @@ function toPageNode({ docsWorkspace, page, parentSlug, idgen, markdownFilesToFul
821724
821797
  }
821725
821798
 
821726
821799
  // ../docs-resolver/lib/ApiReferenceNodeConverter.js
821800
+ function getFieldPath(operation) {
821801
+ return operation.fieldPath;
821802
+ }
821727
821803
  var ApiReferenceNodeConverter = class {
821728
821804
  apiSection;
821729
821805
  docsWorkspace;
@@ -822505,27 +822581,7 @@ ${tagInfo.description}`;
822505
822581
  }
822506
822582
  const sectionTitle = operationTypeLabels[operationType];
822507
822583
  const sectionSlug = namespaceSlug.append(kebabCase_default(sectionTitle));
822508
- const children2 = operations.map((operation) => {
822509
- const operationSlug = sectionSlug.append(operation.name ?? operation.id);
822510
- return {
822511
- id: navigation_exports.V1.NodeId(`${this.apiDefinitionId}:${operation.id}`),
822512
- type: "graphql",
822513
- collapsed: void 0,
822514
- operationType: operation.operationType,
822515
- graphqlOperationId: APIV1Read_exports.GraphQlOperationId(operation.id),
822516
- apiDefinitionId: this.apiDefinitionId,
822517
- availability: convertDocsAvailability(parentAvailability),
822518
- title: operation.displayName ?? operation.name ?? operation.id,
822519
- slug: operationSlug.get(),
822520
- icon: void 0,
822521
- hidden: this.hideChildren,
822522
- playground: void 0,
822523
- authed: void 0,
822524
- viewers: void 0,
822525
- orphaned: void 0,
822526
- featureFlags: void 0
822527
- };
822528
- });
822584
+ const children2 = this.#buildFieldPathGroupedChildren(operations, sectionSlug, parentAvailability, operationType);
822529
822585
  const sectionNode = {
822530
822586
  id: this.#idgen.get(`${this.apiDefinitionId}:graphql:${namespace}:${operationType}`),
822531
822587
  type: "apiPackage",
@@ -822581,27 +822637,7 @@ ${tagInfo.description}`;
822581
822637
  }
822582
822638
  const sectionTitle = operationTypeLabels[operationType];
822583
822639
  const sectionSlug = parentSlug.append(kebabCase_default(sectionTitle));
822584
- const children2 = operations.map((operation) => {
822585
- const operationSlug = sectionSlug.append(operation.name ?? operation.id);
822586
- return {
822587
- id: navigation_exports.V1.NodeId(`${this.apiDefinitionId}:${operation.id}`),
822588
- type: "graphql",
822589
- collapsed: void 0,
822590
- operationType: operation.operationType,
822591
- graphqlOperationId: APIV1Read_exports.GraphQlOperationId(operation.id),
822592
- apiDefinitionId: this.apiDefinitionId,
822593
- availability: convertDocsAvailability(parentAvailability),
822594
- title: operation.displayName ?? operation.name ?? operation.id,
822595
- slug: operationSlug.get(),
822596
- icon: void 0,
822597
- hidden: this.hideChildren,
822598
- playground: void 0,
822599
- authed: void 0,
822600
- viewers: void 0,
822601
- orphaned: void 0,
822602
- featureFlags: void 0
822603
- };
822604
- });
822640
+ const children2 = this.#buildFieldPathGroupedChildren(operations, sectionSlug, parentAvailability, operationType);
822605
822641
  const sectionNode = {
822606
822642
  id: this.#idgen.get(`${this.apiDefinitionId}:graphql:${operationType}`),
822607
822643
  type: "apiPackage",
@@ -822628,6 +822664,83 @@ ${tagInfo.description}`;
822628
822664
  }
822629
822665
  return sections;
822630
822666
  }
822667
+ #buildFieldPathGroupedChildren(operations, parentSlug, parentAvailability, operationType) {
822668
+ const shouldGroup = operationType === "QUERY";
822669
+ const groupedByParent = /* @__PURE__ */ new Map();
822670
+ const insertionOrder = [];
822671
+ for (const operation of operations) {
822672
+ const parentField = getFieldPath(operation)?.[0];
822673
+ if (shouldGroup && parentField != null) {
822674
+ const group = groupedByParent.get(parentField);
822675
+ if (group != null) {
822676
+ group.push(operation);
822677
+ } else {
822678
+ groupedByParent.set(parentField, [operation]);
822679
+ insertionOrder.push({ type: "group", parentField });
822680
+ }
822681
+ } else {
822682
+ insertionOrder.push({ type: "flat", operation });
822683
+ }
822684
+ }
822685
+ const children2 = [];
822686
+ for (const entry of insertionOrder) {
822687
+ if (entry.type === "flat") {
822688
+ const fieldPath = getFieldPath(entry.operation);
822689
+ const leafName = entry.operation.name ?? entry.operation.id;
822690
+ let operationSlug = parentSlug;
822691
+ if (fieldPath != null && fieldPath.length > 0) {
822692
+ for (const segment of fieldPath) {
822693
+ operationSlug = operationSlug.append(kebabCase_default(segment));
822694
+ }
822695
+ }
822696
+ operationSlug = operationSlug.append(kebabCase_default(leafName));
822697
+ children2.push({
822698
+ id: navigation_exports.V1.NodeId(`${this.apiDefinitionId}:${entry.operation.id}`),
822699
+ type: "graphql",
822700
+ collapsed: void 0,
822701
+ operationType: entry.operation.operationType,
822702
+ graphqlOperationId: APIV1Read_exports.GraphQlOperationId(entry.operation.id),
822703
+ apiDefinitionId: this.apiDefinitionId,
822704
+ availability: convertDocsAvailability(parentAvailability),
822705
+ title: entry.operation.displayName ?? entry.operation.name ?? entry.operation.id,
822706
+ slug: operationSlug.get(),
822707
+ icon: void 0,
822708
+ hidden: this.hideChildren,
822709
+ playground: void 0,
822710
+ authed: void 0,
822711
+ viewers: void 0,
822712
+ orphaned: void 0,
822713
+ featureFlags: void 0
822714
+ });
822715
+ } else {
822716
+ const groupOps = groupedByParent.get(entry.parentField) ?? [];
822717
+ const firstOp = groupOps[0];
822718
+ if (firstOp == null) {
822719
+ continue;
822720
+ }
822721
+ const fieldSlug = parentSlug.append(kebabCase_default(entry.parentField));
822722
+ children2.push({
822723
+ id: navigation_exports.V1.NodeId(`${this.apiDefinitionId}:${firstOp.id}`),
822724
+ type: "graphql",
822725
+ collapsed: void 0,
822726
+ operationType: firstOp.operationType,
822727
+ graphqlOperationId: APIV1Read_exports.GraphQlOperationId(firstOp.id),
822728
+ apiDefinitionId: this.apiDefinitionId,
822729
+ availability: convertDocsAvailability(parentAvailability),
822730
+ title: entry.parentField,
822731
+ slug: fieldSlug.get(),
822732
+ icon: void 0,
822733
+ hidden: this.hideChildren,
822734
+ playground: void 0,
822735
+ authed: void 0,
822736
+ viewers: void 0,
822737
+ orphaned: void 0,
822738
+ featureFlags: void 0
822739
+ });
822740
+ }
822741
+ }
822742
+ return children2;
822743
+ }
822631
822744
  #convertApiDefinitionPackageId(packageId, parentSlug, parentAvailability) {
822632
822745
  const pkg2 = packageId != null ? this.#holder.resolveSubpackage(this.#holder.getSubpackageByIdOrLocator(packageId)) : void 0;
822633
822746
  if (pkg2 == null) {
@@ -862424,7 +862537,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
862424
862537
  var LOGS_FOLDER_NAME = "logs";
862425
862538
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
862426
862539
  function getCliSource() {
862427
- const version7 = "5.47.3";
862540
+ const version7 = "5.47.4";
862428
862541
  return `cli@${version7}`;
862429
862542
  }
862430
862543
  var DebugLogger = class {
@@ -893653,7 +893766,7 @@ var LegacyDocsPublisher = class {
893653
893766
  previewId,
893654
893767
  disableTemplates: void 0,
893655
893768
  skipUpload,
893656
- cliVersion: "5.47.3",
893769
+ cliVersion: "5.47.4",
893657
893770
  loginCommand: "fern auth login"
893658
893771
  });
893659
893772
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -959034,7 +959147,7 @@ function getAutomationContextFromEnv() {
959034
959147
  config_branch: process.env.FERN_CONFIG_BRANCH,
959035
959148
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
959036
959149
  trigger: process.env.GITHUB_EVENT_NAME,
959037
- cli_version: "5.47.3"
959150
+ cli_version: "5.47.4"
959038
959151
  };
959039
959152
  }
959040
959153
  function isAutomationMode() {
@@ -959860,7 +959973,7 @@ var CliContext = class _CliContext {
959860
959973
  if (false) {
959861
959974
  this.logger.error("CLI_VERSION is not defined");
959862
959975
  }
959863
- return "5.47.3";
959976
+ return "5.47.4";
959864
959977
  }
959865
959978
  getCliName() {
959866
959979
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.47.3",
2
+ "version": "5.47.4",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",