fern-api 0.37.9 → 0.37.11

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/bundle.cjs +57 -26
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -1215398,7 +1215398,7 @@ var AccessTokenPosthogManager = class {
1215398
1215398
  properties: {
1215399
1215399
  ...event,
1215400
1215400
  ...event.properties,
1215401
- version: "0.37.9",
1215401
+ version: "0.37.11",
1215402
1215402
  usingAccessToken: true
1215403
1215403
  }
1215404
1215404
  });
@@ -1215460,7 +1215460,7 @@ var UserPosthogManager = class {
1215460
1215460
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
1215461
1215461
  event: "CLI",
1215462
1215462
  properties: {
1215463
- version: "0.37.9",
1215463
+ version: "0.37.11",
1215464
1215464
  ...event,
1215465
1215465
  ...event.properties
1215466
1215466
  }
@@ -1216988,6 +1216988,7 @@ var WorkspaceLoaderFailureType;
1216988
1216988
  WorkspaceLoaderFailureType2["FAILED_TO_LOAD_DEPENDENCY"] = "FAILED_TO_LOAD_DEPENDENCY";
1216989
1216989
  WorkspaceLoaderFailureType2["EXPORTING_PACKAGE_MARKER_OTHER_KEYS"] = "EXPORTING_PACKAGE_MARKER_OTHER_KEYS";
1216990
1216990
  WorkspaceLoaderFailureType2["EXPORT_PACKAGE_HAS_DEFINITIONS"] = "EXPORT_PACKAGE_HAS_DEFINITIONS";
1216991
+ WorkspaceLoaderFailureType2["MISCONFIGURED_DIRECTORY"] = "MISCONFIGURED_DIRECTORY";
1216991
1216992
  })(WorkspaceLoaderFailureType || (WorkspaceLoaderFailureType = {}));
1216992
1216993
 
1216993
1216994
  // pnp:/home/runner/work/fern/fern/packages/cli/workspace-loader/lib/handleFailedWorkspaceParserResult.js
@@ -1217003,6 +1217004,9 @@ function handleFailedWorkspaceParserResultRaw(failures, logger) {
1217003
1217004
  }
1217004
1217005
  function handleWorkspaceParserFailureForFile({ relativeFilepath, failure, logger }) {
1217005
1217006
  switch (failure.type) {
1217007
+ case WorkspaceLoaderFailureType.MISCONFIGURED_DIRECTORY:
1217008
+ logger.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");
1217009
+ break;
1217006
1217010
  case WorkspaceLoaderFailureType.FILE_READ:
1217007
1217011
  logger.error("Failed to open file: " + relativeFilepath);
1217008
1217012
  break;
@@ -1240319,17 +1240323,27 @@ async function loadAPIWorkspace({ absolutePathToWorkspace, context, cliVersion,
1240319
1240323
  })
1240320
1240324
  };
1240321
1240325
  }
1240322
- const fernWorkspace = new LazyFernWorkspace({
1240323
- absoluteFilepath: absolutePathToWorkspace,
1240324
- generatorsConfiguration,
1240325
- workspaceName,
1240326
- changelog,
1240327
- context,
1240328
- cliVersion
1240329
- });
1240326
+ if (await doesPathExist(join(absolutePathToWorkspace, RelativeFilePath.of(DEFINITION_DIRECTORY)))) {
1240327
+ const fernWorkspace = new LazyFernWorkspace({
1240328
+ absoluteFilepath: absolutePathToWorkspace,
1240329
+ generatorsConfiguration,
1240330
+ workspaceName,
1240331
+ changelog,
1240332
+ context,
1240333
+ cliVersion
1240334
+ });
1240335
+ return {
1240336
+ didSucceed: true,
1240337
+ workspace: fernWorkspace
1240338
+ };
1240339
+ }
1240330
1240340
  return {
1240331
- didSucceed: true,
1240332
- workspace: fernWorkspace
1240341
+ didSucceed: false,
1240342
+ failures: {
1240343
+ [RelativeFilePath.of(OPENAPI_DIRECTORY)]: {
1240344
+ type: WorkspaceLoaderFailureType.MISCONFIGURED_DIRECTORY
1240345
+ }
1240346
+ }
1240333
1240347
  };
1240334
1240348
  }
1240335
1240349
 
@@ -1240460,14 +1240474,17 @@ async function loadProject({ cliName, cliVersion, commandLineApiWorkspace, defau
1240460
1240474
  if (fernDirectory == null) {
1240461
1240475
  return context.failAndThrow(`Directory "${nameOverride ?? FERN_DIRECTORY}" not found.`);
1240462
1240476
  }
1240463
- const apiWorkspaces = await loadApis({
1240464
- cliName,
1240465
- fernDirectory,
1240466
- cliVersion,
1240467
- context,
1240468
- commandLineApiWorkspace,
1240469
- defaultToAllApiWorkspaces
1240470
- });
1240477
+ let apiWorkspaces = [];
1240478
+ if (await doesPathExist(join(fernDirectory, RelativeFilePath.of(APIS_DIRECTORY))) || doesPathExist(join(fernDirectory, RelativeFilePath.of(DEFINITION_DIRECTORY))) || doesPathExist(join(fernDirectory, RelativeFilePath.of(GENERATORS_CONFIGURATION_FILENAME))) || doesPathExist(join(fernDirectory, RelativeFilePath.of(OPENAPI_DIRECTORY))) || doesPathExist(join(fernDirectory, RelativeFilePath.of(ASYNCAPI_DIRECTORY)))) {
1240479
+ apiWorkspaces = await loadApis({
1240480
+ cliName,
1240481
+ fernDirectory,
1240482
+ cliVersion,
1240483
+ context,
1240484
+ commandLineApiWorkspace,
1240485
+ defaultToAllApiWorkspaces
1240486
+ });
1240487
+ }
1240471
1240488
  return {
1240472
1240489
  config: await fern_config_json_exports.loadProjectConfig({ directory: fernDirectory, context }),
1240473
1240490
  apiWorkspaces,
@@ -1244417,10 +1244434,10 @@ var CliContext = class {
1244417
1244434
  return "fern-api";
1244418
1244435
  }
1244419
1244436
  getPackageVersion() {
1244420
- if ("0.37.9" == null) {
1244437
+ if ("0.37.11" == null) {
1244421
1244438
  this.logger.error("CLI_VERSION is not defined");
1244422
1244439
  }
1244423
- return "0.37.9";
1244440
+ return "0.37.11";
1244424
1244441
  }
1244425
1244442
  getCliName() {
1244426
1244443
  if ("fern" == null) {
@@ -1250261,9 +1250278,9 @@ var IrGraph = class {
1250261
1250278
  });
1250262
1250279
  }
1250263
1250280
  }
1250264
- markEnvironmentForAudiences(environment, audiences) {
1250281
+ markEnvironmentForAudiences(environment, audiences, ignoreAudiences) {
1250265
1250282
  if (environment) {
1250266
- if (this.hasAudience(audiences)) {
1250283
+ if (this.hasAudience(audiences) || ignoreAudiences) {
1250267
1250284
  this.environmentsNeededForAudience.add(environment.id);
1250268
1250285
  }
1250269
1250286
  }
@@ -1252090,12 +1252107,26 @@ async function generateIntermediateRepresentation({ fdrApiDefinitionId, workspac
1252090
1252107
  });
1252091
1252108
  intermediateRepresentation.serviceTypeReferenceInfo = computeServiceTypeReferenceInfo(irGraph);
1252092
1252109
  const intermediateRepresentationWithGeneratedExamples = new ExampleGenerator(intermediateRepresentation).enrichWithAutogeneratedExamples();
1252110
+ const workspaceDefinitionRootApiFileContents = workspace.definition.rootApiFile.contents;
1252093
1252111
  const environments = convertEnvironments({
1252094
1252112
  casingsGenerator,
1252095
- rawApiFileSchema: workspace.definition.rootApiFile.contents
1252113
+ rawApiFileSchema: workspaceDefinitionRootApiFileContents
1252114
+ });
1252115
+ const ignoreAudiences = environments == null ? void 0 : environments.environments._visit({
1252116
+ singleBaseUrl: (value) => {
1252117
+ return value.environments.filter((environment) => {
1252118
+ return getAudienceForEnvironment(environment.id, workspaceDefinitionRootApiFileContents.environments) != null;
1252119
+ }).length === 0;
1252120
+ },
1252121
+ multipleBaseUrls: (value) => {
1252122
+ return value.environments.filter((environment) => {
1252123
+ return getAudienceForEnvironment(environment.id, workspaceDefinitionRootApiFileContents.environments) != null;
1252124
+ }).length === 0;
1252125
+ },
1252126
+ _other: () => false
1252096
1252127
  });
1252097
1252128
  environments == null ? void 0 : environments.environments.environments.forEach((environment) => {
1252098
- irGraph.markEnvironmentForAudiences(environment, getAudienceForEnvironment(environment.id, workspace.definition.rootApiFile.contents.environments) ?? []);
1252129
+ irGraph.markEnvironmentForAudiences(environment, getAudienceForEnvironment(environment.id, workspaceDefinitionRootApiFileContents.environments) ?? [], ignoreAudiences);
1252099
1252130
  });
1252100
1252131
  const filteredIr = !irGraph.hasNoAudiences() ? irGraph.build() : void 0;
1252101
1252132
  const intermediateRepresentationForAudiences = filterIntermediateRepresentationForAudiences(intermediateRepresentationWithGeneratedExamples, filteredIr);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.37.9",
3
+ "version": "0.37.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",