@fern-api/fern-api-dev 4.108.0 → 4.109.0

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 +161 -45
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -614192,6 +614192,7 @@ __export(schemas_exports13, {
614192
614192
  GitOutputSchema: () => GitOutputSchema,
614193
614193
  GitSelfHostedOutputModeSchema: () => GitSelfHostedOutputModeSchema,
614194
614194
  GitSelfHostedOutputSchema: () => GitSelfHostedOutputSchema,
614195
+ GraphQlSpecSchema: () => GraphQlSpecSchema2,
614195
614196
  HeaderConfigSchema: () => HeaderConfigSchema,
614196
614197
  HeaderSchema: () => HeaderSchema2,
614197
614198
  IntegrationsConfigSchema: () => IntegrationsConfigSchema2,
@@ -614391,6 +614392,18 @@ var FernSpecSchema = external_exports.object({
614391
614392
  settings: FernSettingsSchema.optional()
614392
614393
  });
614393
614394
 
614395
+ // ../config/lib/schemas/specs/GraphQlSpecSchema.js
614396
+ var GraphQlSpecSchema2 = external_exports.object({
614397
+ /** Path to the GraphQL schema file. */
614398
+ graphql: external_exports.string(),
614399
+ /** URL origin for the GraphQL endpoint. */
614400
+ origin: external_exports.string().optional(),
614401
+ /** Path to overrides file for the GraphQL spec. */
614402
+ overrides: external_exports.union([external_exports.string(), external_exports.array(external_exports.string()).nonempty()]).optional(),
614403
+ /** Name used to group this GraphQL spec in the docs (rendered as a top-level section). */
614404
+ name: external_exports.string().optional()
614405
+ });
614406
+
614394
614407
  // ../config/lib/schemas/settings/DefaultIntegerFormatSchema.js
614395
614408
  var DefaultIntegerFormatSchema = external_exports.enum(["int32", "int64", "uint32", "uint64"]);
614396
614409
 
@@ -614540,7 +614553,8 @@ var ApiSpecSchema = external_exports.union([
614540
614553
  ProtobufSpecSchema2,
614541
614554
  FernSpecSchema,
614542
614555
  ConjureSpecSchema,
614543
- OpenRpcSpecSchema2
614556
+ OpenRpcSpecSchema2,
614557
+ GraphQlSpecSchema2
614544
614558
  ]);
614545
614559
 
614546
614560
  // ../config/lib/schemas/AuthSchemesSchema.js
@@ -621372,7 +621386,7 @@ var AccessTokenPosthogManager = class {
621372
621386
  properties: {
621373
621387
  ...event,
621374
621388
  ...event.properties,
621375
- version: "4.108.0",
621389
+ version: "4.109.0",
621376
621390
  usingAccessToken: true
621377
621391
  }
621378
621392
  });
@@ -621426,7 +621440,7 @@ var UserPosthogManager = class {
621426
621440
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
621427
621441
  event: "CLI",
621428
621442
  properties: {
621429
- version: "4.108.0",
621443
+ version: "4.109.0",
621430
621444
  ...event,
621431
621445
  ...event.properties,
621432
621446
  usingAccessToken: false,
@@ -625252,6 +625266,13 @@ var ApiDefinitionConverter = class {
625252
625266
  sourced
625253
625267
  });
625254
625268
  }
625269
+ if ("graphql" in spec && "graphql" in sourced) {
625270
+ return await this.convertGraphQlSpec({
625271
+ absoluteFernYmlPath,
625272
+ spec,
625273
+ sourced
625274
+ });
625275
+ }
625255
625276
  throw new CliError({
625256
625277
  message: `Unknown spec type: ${JSON.stringify(spec)}`,
625257
625278
  code: CliError.Code.InternalError
@@ -625361,6 +625382,25 @@ var ApiDefinitionConverter = class {
625361
625382
  }
625362
625383
  return result;
625363
625384
  }
625385
+ async convertGraphQlSpec({ absoluteFernYmlPath, spec, sourced }) {
625386
+ const result = {
625387
+ graphql: await this.resolvePath({ absoluteFernYmlPath, path: spec.graphql, sourced: sourced.graphql })
625388
+ };
625389
+ if (spec.origin != null) {
625390
+ result.origin = spec.origin;
625391
+ }
625392
+ if (spec.overrides != null && !isNullish2(sourced.overrides)) {
625393
+ result.overrides = await this.resolvePathOrPaths({
625394
+ absoluteFernYmlPath,
625395
+ paths: spec.overrides,
625396
+ sourced: sourced.overrides
625397
+ });
625398
+ }
625399
+ if (spec.name != null) {
625400
+ result.name = spec.name;
625401
+ }
625402
+ return result;
625403
+ }
625364
625404
  async convertOpenRpcSpec({ absoluteFernYmlPath, spec, sourced }) {
625365
625405
  const result = {
625366
625406
  openrpc: await this.resolvePath({ absoluteFernYmlPath, path: spec.openrpc, sourced: sourced.openrpc })
@@ -626639,6 +626679,11 @@ var TaskContextAdapter = class {
626639
626679
  // ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
626640
626680
  init_lib6();
626641
626681
 
626682
+ // ../cli-v2/lib/api/config/GraphQlSpec.js
626683
+ function isGraphQlSpec(spec) {
626684
+ return "graphql" in spec;
626685
+ }
626686
+
626642
626687
  // ../cli-v2/lib/api/config/OpenRpcSpec.js
626643
626688
  function isOpenRpcSpec(spec) {
626644
626689
  return "openrpc" in spec;
@@ -626650,6 +626695,24 @@ function isProtobufSpec(spec) {
626650
626695
  }
626651
626696
 
626652
626697
  // ../cli-v2/lib/api/adapter/LegacyApiSpecAdapter.js
626698
+ function partitionV1Specs(v1Specs) {
626699
+ const filteredSpecs = v1Specs.filter((spec) => {
626700
+ if (spec.type === "openrpc" || spec.type === "graphql") {
626701
+ return false;
626702
+ }
626703
+ if (spec.type === "protobuf" && !spec.fromOpenAPI) {
626704
+ return false;
626705
+ }
626706
+ return true;
626707
+ });
626708
+ const allSpecs = v1Specs.filter((spec) => {
626709
+ if (spec.type === "protobuf" && spec.fromOpenAPI) {
626710
+ return false;
626711
+ }
626712
+ return true;
626713
+ });
626714
+ return { filteredSpecs, allSpecs };
626715
+ }
626653
626716
  var LegacyApiSpecAdapter = class {
626654
626717
  context;
626655
626718
  constructor(config5) {
@@ -626668,6 +626731,9 @@ var LegacyApiSpecAdapter = class {
626668
626731
  if (isOpenRpcSpec(spec)) {
626669
626732
  return this.adaptOpenRpcSpec(spec);
626670
626733
  }
626734
+ if (isGraphQlSpec(spec)) {
626735
+ return this.adaptGraphQlSpec(spec);
626736
+ }
626671
626737
  throw new CliError({
626672
626738
  message: `Unsupported spec type: ${JSON.stringify(spec)}`,
626673
626739
  code: CliError.Code.InternalError
@@ -626726,6 +626792,14 @@ var LegacyApiSpecAdapter = class {
626726
626792
  namespace: void 0
626727
626793
  };
626728
626794
  }
626795
+ adaptGraphQlSpec(spec) {
626796
+ return {
626797
+ type: "graphql",
626798
+ absoluteFilepath: spec.graphql,
626799
+ absoluteFilepathToOverrides: spec.overrides,
626800
+ namespace: spec.name
626801
+ };
626802
+ }
626729
626803
  adaptOpenApiSettings(settings) {
626730
626804
  if (settings == null) {
626731
626805
  return void 0;
@@ -626938,21 +627012,10 @@ var ApiDefinitionValidator = class {
626938
627012
  }
626939
627013
  const specAdapter = new LegacyApiSpecAdapter({ context: this.context });
626940
627014
  const v1Specs = specAdapter.convertAll(ossSpecs);
626941
- const filteredSpecs = v1Specs.filter((spec) => {
626942
- if (spec.type === "openrpc") {
626943
- return false;
626944
- }
626945
- if (spec.type === "protobuf" && !spec.fromOpenAPI) {
626946
- return false;
626947
- }
626948
- return true;
626949
- });
626950
- const allSpecs = v1Specs.filter((spec) => {
626951
- if (spec.type === "protobuf" && spec.fromOpenAPI) {
626952
- return false;
626953
- }
626954
- return true;
626955
- });
627015
+ const { filteredSpecs, allSpecs } = partitionV1Specs(v1Specs);
627016
+ if (filteredSpecs.length === 0) {
627017
+ return violations;
627018
+ }
626956
627019
  const ossWorkspace = new OSSWorkspace({
626957
627020
  specs: filteredSpecs,
626958
627021
  allSpecs,
@@ -753778,22 +753841,9 @@ var LegacyOSSWorkspaceAdapter = class {
753778
753841
  return void 0;
753779
753842
  }
753780
753843
  const v1Specs = this.specAdapter.convertAll(ossSpecs);
753781
- const filteredSpecs = v1Specs.filter((spec) => {
753782
- if (spec.type === "openrpc") {
753783
- return false;
753784
- }
753785
- if (spec.type === "protobuf" && !spec.fromOpenAPI) {
753786
- return false;
753787
- }
753788
- return true;
753789
- });
753790
- const allSpecs = v1Specs.filter((spec) => {
753791
- if (spec.type === "protobuf" && spec.fromOpenAPI) {
753792
- return false;
753793
- }
753794
- return true;
753795
- });
753796
- if (filteredSpecs.length === 0) {
753844
+ const { filteredSpecs, allSpecs } = partitionV1Specs(v1Specs);
753845
+ const hasGraphQlSpec = allSpecs.some((spec) => spec.type === "graphql");
753846
+ if (filteredSpecs.length === 0 && !hasGraphQlSpec) {
753797
753847
  return void 0;
753798
753848
  }
753799
753849
  return new OSSWorkspace({
@@ -829157,8 +829207,8 @@ var LegacyProjectAdapter = class {
829157
829207
  this.context = context3;
829158
829208
  this.ossAdapter = new LegacyOSSWorkspaceAdapter({ context: context3 });
829159
829209
  }
829160
- adapt(workspace) {
829161
- const apiWorkspaces = this.buildApiWorkspaces(workspace);
829210
+ async adapt(workspace) {
829211
+ const apiWorkspaces = await this.buildApiWorkspaces(workspace);
829162
829212
  const docsWorkspace = workspace.docs != null ? this.docsAdapter.adapt({
829163
829213
  docsConfig: workspace.docs,
829164
829214
  absoluteFilePath: workspace.docs.absoluteFilePath ?? workspace.absoluteFilePath ?? this.context.cwd
@@ -829186,8 +829236,9 @@ var LegacyProjectAdapter = class {
829186
829236
  /**
829187
829237
  * Bridges API definitions to legacy AbstractAPIWorkspace instances.
829188
829238
  */
829189
- buildApiWorkspaces(workspace) {
829239
+ async buildApiWorkspaces(workspace) {
829190
829240
  const workspaces = [];
829241
+ const taskContext = new TaskContextAdapter({ context: this.context });
829191
829242
  for (const [apiName, apiDef] of Object.entries(workspace.apis)) {
829192
829243
  const ossWorkspace = this.ossAdapter.build({
829193
829244
  definition: apiDef,
@@ -829196,6 +829247,7 @@ var LegacyProjectAdapter = class {
829196
829247
  absoluteFilePath: this.context.cwd
829197
829248
  });
829198
829249
  if (ossWorkspace != null) {
829250
+ await ossWorkspace.processGraphQLSpecs(taskContext);
829199
829251
  workspaces.push(ossWorkspace);
829200
829252
  }
829201
829253
  }
@@ -829258,7 +829310,7 @@ var DocsChecker = class {
829258
829310
  };
829259
829311
  }
829260
829312
  const adapter2 = new LegacyProjectAdapter({ context: this.context });
829261
- const project = adapter2.adapt(workspace);
829313
+ const project = await adapter2.adapt(workspace);
829262
829314
  const docsWorkspace = project.docsWorkspaces;
829263
829315
  if (docsWorkspace == null) {
829264
829316
  throw new CliError({
@@ -829365,6 +829417,7 @@ var SdkChecker = class {
829365
829417
  this.validateTargetApiReferences({ workspace, sdks: sdks2, violations });
829366
829418
  this.validateDefaultGroup({ sdks: sdks2, fernYmlRelativePath, violations });
829367
829419
  this.validateEmptyVersions({ sdks: sdks2, violations });
829420
+ this.validateGraphQlSpecs({ workspace, sdks: sdks2, violations });
829368
829421
  await this.validateVersions({ sdks: sdks2, violations });
829369
829422
  return {
829370
829423
  violations,
@@ -829446,6 +829499,31 @@ var SdkChecker = class {
829446
829499
  }
829447
829500
  }
829448
829501
  }
829502
+ /**
829503
+ * Emits a warning for any target whose referenced API contains a GraphQL spec.
829504
+ * GraphQL SDKs are not supported; the graphql specs will be skipped during generation.
829505
+ */
829506
+ validateGraphQlSpecs({ workspace, sdks: sdks2, violations }) {
829507
+ for (const target of sdks2.targets) {
829508
+ const api2 = workspace.apis[target.api];
829509
+ if (api2 == null) {
829510
+ continue;
829511
+ }
829512
+ const hasGraphQl = api2.specs.some(isGraphQlSpec);
829513
+ if (!hasGraphQl) {
829514
+ continue;
829515
+ }
829516
+ violations.push({
829517
+ severity: "warning",
829518
+ relativeFilepath: target.sourceLocation.relativeFilePath,
829519
+ nodePath: ["sdks", "targets", target.name, "api"],
829520
+ message: `API '${target.api}' contains a GraphQL spec. GraphQL SDKs are not supported and graphql specs will be skipped for this target.`,
829521
+ displayRelativeFilepath: target.sourceLocation.relativeFilePath,
829522
+ line: target.sourceLocation.line,
829523
+ column: target.sourceLocation.column
829524
+ });
829525
+ }
829526
+ }
829449
829527
  /**
829450
829528
  * Checks that pinned versions exist in the registry.
829451
829529
  */
@@ -829851,6 +829929,13 @@ function adjustSpecPaths(specs, apiName) {
829851
829929
  overrides: spec.overrides != null ? adjustPathOrPaths(spec.overrides, apiName) : void 0
829852
829930
  };
829853
829931
  }
829932
+ if ("graphql" in spec) {
829933
+ return {
829934
+ ...spec,
829935
+ graphql: adjustPath(spec.graphql, apiName),
829936
+ overrides: spec.overrides != null ? adjustPathOrPaths(spec.overrides, apiName) : void 0
829937
+ };
829938
+ }
829854
829939
  if ("proto" in spec) {
829855
829940
  return {
829856
829941
  ...spec,
@@ -830001,6 +830086,22 @@ function convertSpec(spec, warnings) {
830001
830086
  }
830002
830087
  return result;
830003
830088
  }
830089
+ if ("graphql" in spec) {
830090
+ const graphqlSpec = spec;
830091
+ const result = {
830092
+ graphql: graphqlSpec.graphql
830093
+ };
830094
+ if (graphqlSpec.origin != null) {
830095
+ result.origin = graphqlSpec.origin;
830096
+ }
830097
+ if (graphqlSpec.overrides != null) {
830098
+ result.overrides = graphqlSpec.overrides;
830099
+ }
830100
+ if (graphqlSpec.name != null) {
830101
+ result.name = graphqlSpec.name;
830102
+ }
830103
+ return result;
830104
+ }
830004
830105
  warnings.push({
830005
830106
  type: "unsupported",
830006
830107
  message: `Unknown spec type: ${JSON.stringify(Object.keys(spec))}`
@@ -830016,6 +830117,8 @@ function convertNamespacedSpecs(config5, warnings) {
830016
830117
  specs.push({ ...spec, namespace });
830017
830118
  } else if ("asyncapi" in spec) {
830018
830119
  specs.push({ ...spec, namespace });
830120
+ } else if ("graphql" in spec) {
830121
+ specs.push({ ...spec, name: spec.name ?? namespace });
830019
830122
  } else if ("fern" in spec) {
830020
830123
  warnings.push({
830021
830124
  type: "info",
@@ -833072,7 +833175,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
833072
833175
  var LOGS_FOLDER_NAME = "logs";
833073
833176
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
833074
833177
  function getCliSource() {
833075
- const version7 = "4.108.0";
833178
+ const version7 = "4.109.0";
833076
833179
  return `cli@${version7}`;
833077
833180
  }
833078
833181
  var DebugLogger = class {
@@ -835571,7 +835674,7 @@ var LegacyDevServer = class {
835571
835674
  */
835572
835675
  async start({ port, backendPort, forceDownload, bundlePath, logLevel }) {
835573
835676
  const workspace = await this.context.loadWorkspaceOrThrow();
835574
- const initialProject = this.adapter.adapt(workspace);
835677
+ const initialProject = await this.adapter.adapt(workspace);
835575
835678
  const taskContext = new TaskContextAdapter({ context: this.context, logLevel });
835576
835679
  this.context.stderr.info("Bootstrapping docs preview (this may take a few seconds)...");
835577
835680
  await runAppPreviewServer({
@@ -845490,7 +845593,7 @@ var LegacyDocsPublisher = class {
845490
845593
  previewId,
845491
845594
  disableTemplates: void 0,
845492
845595
  skipUpload,
845493
- cliVersion: "4.108.0",
845596
+ cliVersion: "4.109.0",
845494
845597
  loginCommand: "fern auth login"
845495
845598
  });
845496
845599
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -846134,7 +846237,7 @@ var PublishCommand = class {
846134
846237
  }
846135
846238
  }
846136
846239
  const adapter2 = new LegacyProjectAdapter({ context: context3 });
846137
- const project = adapter2.adapt(workspace);
846240
+ const project = await adapter2.adapt(workspace);
846138
846241
  const docsWorkspace = project.docsWorkspaces;
846139
846242
  if (docsWorkspace == null) {
846140
846243
  throw new CliError({
@@ -848773,8 +848876,12 @@ var import_path67 = __toESM(require("path"), 1);
848773
848876
  // ../cli-v2/lib/api/resolver/ApiSpecDetector.js
848774
848877
  init_js_yaml();
848775
848878
  var DETECTABLE_SPEC_TYPES = ["openapi", "asyncapi"];
848879
+ var GRAPHQL_EXTENSIONS = [".graphql", ".graphqls", ".gql"];
848776
848880
  var ApiSpecDetector = class {
848777
848881
  async detect({ absoluteFilePath, reference: reference4, content: content5 }) {
848882
+ if (this.hasGraphQlExtension(absoluteFilePath) || this.hasGraphQlExtension(reference4)) {
848883
+ return "graphql";
848884
+ }
848778
848885
  const parsed = this.parseOrThrow({ content: content5, reference: reference4 });
848779
848886
  if (typeof parsed !== "object" || parsed == null) {
848780
848887
  throw new CliError({
@@ -848792,6 +848899,10 @@ var ApiSpecDetector = class {
848792
848899
  code: CliError.Code.InternalError
848793
848900
  });
848794
848901
  }
848902
+ hasGraphQlExtension(path105) {
848903
+ const lower = path105.toLowerCase();
848904
+ return GRAPHQL_EXTENSIONS.some((ext2) => lower.endsWith(ext2));
848905
+ }
848795
848906
  parseOrThrow({ content: content5, reference: reference4 }) {
848796
848907
  try {
848797
848908
  return jsYaml.load(content5);
@@ -848869,7 +848980,10 @@ var ApiSpecResolver = class {
848869
848980
  return { content: content5, contentType };
848870
848981
  }
848871
848982
  inferExtension({ url: url3, contentType }) {
848872
- const urlPath = new URL(url3).pathname;
848983
+ const urlPath = new URL(url3).pathname.toLowerCase();
848984
+ if (urlPath.endsWith(".graphql") || urlPath.endsWith(".graphqls") || urlPath.endsWith(".gql")) {
848985
+ return ".graphql";
848986
+ }
848873
848987
  if (urlPath.endsWith(".json")) {
848874
848988
  return ".json";
848875
848989
  }
@@ -848887,9 +849001,11 @@ var ApiSpecResolver = class {
848887
849001
  return { openapi: absoluteFilePath, origin: origin2 };
848888
849002
  case "asyncapi":
848889
849003
  return { asyncapi: absoluteFilePath, origin: origin2 };
849004
+ case "graphql":
849005
+ return { graphql: absoluteFilePath, origin: origin2 };
848890
849006
  default:
848891
849007
  throw new CliError({
848892
- message: `Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi`,
849008
+ message: `Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi, graphql`,
848893
849009
  code: CliError.Code.ConfigError
848894
849010
  });
848895
849011
  }
@@ -919725,7 +919841,7 @@ var CliContext = class _CliContext {
919725
919841
  if (false) {
919726
919842
  this.logger.error("CLI_VERSION is not defined");
919727
919843
  }
919728
- return "4.108.0";
919844
+ return "4.109.0";
919729
919845
  }
919730
919846
  getCliName() {
919731
919847
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.108.0",
2
+ "version": "4.109.0",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",