fern-api 0.41.2 → 0.41.3

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 +242 -245
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -445660,88 +445660,6 @@ var require_xml2js = __commonJS({
445660
445660
  }
445661
445661
  });
445662
445662
 
445663
- // ../../../node_modules/.pnpm/supports-hyperlinks@2.3.0/node_modules/supports-hyperlinks/index.js
445664
- var require_supports_hyperlinks = __commonJS({
445665
- "../../../node_modules/.pnpm/supports-hyperlinks@2.3.0/node_modules/supports-hyperlinks/index.js"(exports2, module2) {
445666
- "use strict";
445667
- var supportsColor2 = require_supports_color();
445668
- var hasFlag2 = require_has_flag();
445669
- function parseVersion2(versionString) {
445670
- if (/^\d{3,4}$/.test(versionString)) {
445671
- const m = /(\d{1,2})(\d{2})/.exec(versionString);
445672
- return {
445673
- major: 0,
445674
- minor: parseInt(m[1], 10),
445675
- patch: parseInt(m[2], 10)
445676
- };
445677
- }
445678
- const versions = (versionString || "").split(".").map((n2) => parseInt(n2, 10));
445679
- return {
445680
- major: versions[0],
445681
- minor: versions[1],
445682
- patch: versions[2]
445683
- };
445684
- }
445685
- function supportsHyperlink(stream) {
445686
- const { env: env4 } = process;
445687
- if ("FORCE_HYPERLINK" in env4) {
445688
- return !(env4.FORCE_HYPERLINK.length > 0 && parseInt(env4.FORCE_HYPERLINK, 10) === 0);
445689
- }
445690
- if (hasFlag2("no-hyperlink") || hasFlag2("no-hyperlinks") || hasFlag2("hyperlink=false") || hasFlag2("hyperlink=never")) {
445691
- return false;
445692
- }
445693
- if (hasFlag2("hyperlink=true") || hasFlag2("hyperlink=always")) {
445694
- return true;
445695
- }
445696
- if ("NETLIFY" in env4) {
445697
- return true;
445698
- }
445699
- if (!supportsColor2.supportsColor(stream)) {
445700
- return false;
445701
- }
445702
- if (stream && !stream.isTTY) {
445703
- return false;
445704
- }
445705
- if (process.platform === "win32") {
445706
- return false;
445707
- }
445708
- if ("CI" in env4) {
445709
- return false;
445710
- }
445711
- if ("TEAMCITY_VERSION" in env4) {
445712
- return false;
445713
- }
445714
- if ("TERM_PROGRAM" in env4) {
445715
- const version3 = parseVersion2(env4.TERM_PROGRAM_VERSION);
445716
- switch (env4.TERM_PROGRAM) {
445717
- case "iTerm.app":
445718
- if (version3.major === 3) {
445719
- return version3.minor >= 1;
445720
- }
445721
- return version3.major > 3;
445722
- case "WezTerm":
445723
- return version3.major >= 20200620;
445724
- case "vscode":
445725
- return version3.major > 1 || version3.major === 1 && version3.minor >= 72;
445726
- }
445727
- }
445728
- if ("VTE_VERSION" in env4) {
445729
- if (env4.VTE_VERSION === "0.50.0") {
445730
- return false;
445731
- }
445732
- const version3 = parseVersion2(env4.VTE_VERSION);
445733
- return version3.major > 0 || version3.minor >= 50;
445734
- }
445735
- return false;
445736
- }
445737
- module2.exports = {
445738
- supportsHyperlink,
445739
- stdout: supportsHyperlink(process.stdout),
445740
- stderr: supportsHyperlink(process.stderr)
445741
- };
445742
- }
445743
- });
445744
-
445745
445663
  // ../../../node_modules/.pnpm/validate-npm-package-name@5.0.1/node_modules/validate-npm-package-name/lib/index.js
445746
445664
  var require_lib22 = __commonJS({
445747
445665
  "../../../node_modules/.pnpm/validate-npm-package-name@5.0.1/node_modules/validate-npm-package-name/lib/index.js"(exports2, module2) {
@@ -1187522,6 +1187440,88 @@ var require_docker = __commonJS({
1187522
1187440
  }
1187523
1187441
  });
1187524
1187442
 
1187443
+ // ../../../node_modules/.pnpm/supports-hyperlinks@2.3.0/node_modules/supports-hyperlinks/index.js
1187444
+ var require_supports_hyperlinks = __commonJS({
1187445
+ "../../../node_modules/.pnpm/supports-hyperlinks@2.3.0/node_modules/supports-hyperlinks/index.js"(exports2, module2) {
1187446
+ "use strict";
1187447
+ var supportsColor2 = require_supports_color();
1187448
+ var hasFlag2 = require_has_flag();
1187449
+ function parseVersion2(versionString) {
1187450
+ if (/^\d{3,4}$/.test(versionString)) {
1187451
+ const m = /(\d{1,2})(\d{2})/.exec(versionString);
1187452
+ return {
1187453
+ major: 0,
1187454
+ minor: parseInt(m[1], 10),
1187455
+ patch: parseInt(m[2], 10)
1187456
+ };
1187457
+ }
1187458
+ const versions = (versionString || "").split(".").map((n2) => parseInt(n2, 10));
1187459
+ return {
1187460
+ major: versions[0],
1187461
+ minor: versions[1],
1187462
+ patch: versions[2]
1187463
+ };
1187464
+ }
1187465
+ function supportsHyperlink(stream) {
1187466
+ const { env: env4 } = process;
1187467
+ if ("FORCE_HYPERLINK" in env4) {
1187468
+ return !(env4.FORCE_HYPERLINK.length > 0 && parseInt(env4.FORCE_HYPERLINK, 10) === 0);
1187469
+ }
1187470
+ if (hasFlag2("no-hyperlink") || hasFlag2("no-hyperlinks") || hasFlag2("hyperlink=false") || hasFlag2("hyperlink=never")) {
1187471
+ return false;
1187472
+ }
1187473
+ if (hasFlag2("hyperlink=true") || hasFlag2("hyperlink=always")) {
1187474
+ return true;
1187475
+ }
1187476
+ if ("NETLIFY" in env4) {
1187477
+ return true;
1187478
+ }
1187479
+ if (!supportsColor2.supportsColor(stream)) {
1187480
+ return false;
1187481
+ }
1187482
+ if (stream && !stream.isTTY) {
1187483
+ return false;
1187484
+ }
1187485
+ if (process.platform === "win32") {
1187486
+ return false;
1187487
+ }
1187488
+ if ("CI" in env4) {
1187489
+ return false;
1187490
+ }
1187491
+ if ("TEAMCITY_VERSION" in env4) {
1187492
+ return false;
1187493
+ }
1187494
+ if ("TERM_PROGRAM" in env4) {
1187495
+ const version3 = parseVersion2(env4.TERM_PROGRAM_VERSION);
1187496
+ switch (env4.TERM_PROGRAM) {
1187497
+ case "iTerm.app":
1187498
+ if (version3.major === 3) {
1187499
+ return version3.minor >= 1;
1187500
+ }
1187501
+ return version3.major > 3;
1187502
+ case "WezTerm":
1187503
+ return version3.major >= 20200620;
1187504
+ case "vscode":
1187505
+ return version3.major > 1 || version3.major === 1 && version3.minor >= 72;
1187506
+ }
1187507
+ }
1187508
+ if ("VTE_VERSION" in env4) {
1187509
+ if (env4.VTE_VERSION === "0.50.0") {
1187510
+ return false;
1187511
+ }
1187512
+ const version3 = parseVersion2(env4.VTE_VERSION);
1187513
+ return version3.major > 0 || version3.minor >= 50;
1187514
+ }
1187515
+ return false;
1187516
+ }
1187517
+ module2.exports = {
1187518
+ supportsHyperlink,
1187519
+ stdout: supportsHyperlink(process.stdout),
1187520
+ stderr: supportsHyperlink(process.stderr)
1187521
+ };
1187522
+ }
1187523
+ });
1187524
+
1187525
1187525
  // ../../../node_modules/.pnpm/queue@6.0.2/node_modules/queue/index.js
1187526
1187526
  var require_queue2 = __commonJS({
1187527
1187527
  "../../../node_modules/.pnpm/queue@6.0.2/node_modules/queue/index.js"(exports2, module2) {
@@ -1205054,11 +1205054,6 @@ async function convertFilepathOrUrl(value, absoluteFilepathToDocsConfig) {
1205054
1205054
  return { type: "url", value };
1205055
1205055
  }
1205056
1205056
 
1205057
- // ../configuration/lib/DocsLinks.js
1205058
- var DocsLinks = {
1205059
- oauth: "https://buildwithfern.com/learn/api-definition/fern/api-yml-reference#authentication"
1205060
- };
1205061
-
1205062
1205057
  // ../configuration/lib/fern-config-json/index.js
1205063
1205058
  var fern_config_json_exports = {};
1205064
1205059
  __export(fern_config_json_exports, {
@@ -1206105,8 +1206100,9 @@ var PaginationSchema = z.union([CursorPaginationSchema, OffsetPaginationSchema])
1206105
1206100
  var ResponseErrorsSchema = z.array(z.union([z.string(), ErrorReferenceSchema]));
1206106
1206101
 
1206107
1206102
  // ../fern-definition/schema/lib/schemas/HttpEndpointSchema.js
1206103
+ var HttpMethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
1206108
1206104
  var HttpEndpointSchema = DeclarationSchema.extend({
1206109
- method: z.optional(z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"])),
1206105
+ method: z.optional(HttpMethodSchema),
1206110
1206106
  "display-name": z.optional(z.string()),
1206111
1206107
  path: z.string(),
1206112
1206108
  url: z.optional(z.string()),
@@ -1206121,7 +1206117,6 @@ var HttpEndpointSchema = DeclarationSchema.extend({
1206121
1206117
  examples: z.optional(z.array(ExampleEndpointCallSchema)),
1206122
1206118
  pagination: z.optional(z.union([PaginationSchema, z.boolean()]))
1206123
1206119
  });
1206124
- var HttpMethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
1206125
1206120
 
1206126
1206121
  // ../fern-definition/schema/lib/schemas/GrpcSchema.js
1206127
1206122
  var GrpcSchema = z.strictObject({
@@ -1206355,6 +1206350,11 @@ function isGeneric(name2) {
1206355
1206350
  return parseGeneric(name2) != null;
1206356
1206351
  }
1206357
1206352
 
1206353
+ // ../fern-definition/schema/lib/utils/auth/isOauthScheme.js
1206354
+ function isOAuthScheme(rawOAuthSchemeSchema) {
1206355
+ return rawOAuthSchemeSchema.scheme === "oauth";
1206356
+ }
1206357
+
1206358
1206358
  // ../fern-definition/schema/lib/utils/getRequestBody.js
1206359
1206359
  function getRequestBody(endpoint) {
1206360
1206360
  if (endpoint.request == null) {
@@ -1213475,6 +1213475,32 @@ function isRawEnumDefinition(rawTypeDeclaration) {
1213475
1213475
  return rawTypeDeclaration.enum != null;
1213476
1213476
  }
1213477
1213477
 
1213478
+ // ../fern-definition/schema/lib/utils/HttpEndpointReferenceParser.js
1213479
+ var HttpEndpointReferenceParser = class {
1213480
+ REFERENCE_REGEX = /^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/]*)$/;
1213481
+ validate(reference) {
1213482
+ const validFormat = this.REFERENCE_REGEX.test(reference);
1213483
+ if (!validFormat) {
1213484
+ return { type: "invalid" };
1213485
+ }
1213486
+ return { type: "valid" };
1213487
+ }
1213488
+ tryParse(reference) {
1213489
+ const validationResponse = this.validate(reference);
1213490
+ if (validationResponse.type === "invalid") {
1213491
+ return void 0;
1213492
+ }
1213493
+ const match = reference.match(this.REFERENCE_REGEX);
1213494
+ if (match == null || match[1] == null || match[2] == null) {
1213495
+ return void 0;
1213496
+ }
1213497
+ return {
1213498
+ method: match[1],
1213499
+ path: match[2]
1213500
+ };
1213501
+ }
1213502
+ };
1213503
+
1213478
1213504
  // ../configuration/lib/generators-yml/schemas/APIConfigurationV2Schema.js
1213479
1213505
  var OpenAPISpecSchema = z.strictObject({
1213480
1213506
  openapi: z.string(),
@@ -1216793,7 +1216819,7 @@ var AccessTokenPosthogManager = class {
1216793
1216819
  properties: {
1216794
1216820
  ...event,
1216795
1216821
  ...event.properties,
1216796
- version: "0.41.2",
1216822
+ version: "0.41.3",
1216797
1216823
  usingAccessToken: true
1216798
1216824
  }
1216799
1216825
  });
@@ -1216855,7 +1216881,7 @@ var UserPosthogManager = class {
1216855
1216881
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
1216856
1216882
  event: "CLI",
1216857
1216883
  properties: {
1216858
- version: "0.41.2",
1216884
+ version: "0.41.3",
1216859
1216885
  ...event,
1216860
1216886
  ...event.properties
1216861
1216887
  }
@@ -1221945,10 +1221971,10 @@ var CliContext = class {
1221945
1221971
  return "fern-api";
1221946
1221972
  }
1221947
1221973
  getPackageVersion() {
1221948
- if ("0.41.2" == null) {
1221974
+ if ("0.41.3" == null) {
1221949
1221975
  this.logger.error("CLI_VERSION is not defined");
1221950
1221976
  }
1221951
- return "0.41.2";
1221977
+ return "0.41.3";
1221952
1221978
  }
1221953
1221979
  getCliName() {
1221954
1221980
  if ("fern" == null) {
@@ -1256390,7 +1256416,7 @@ function isRootFernFilepath({ fernFilePath }) {
1256390
1256416
 
1256391
1256417
  // ../generation/ir-generator/lib/converters/convertOAuthRefreshEndpoint.js
1256392
1256418
  async function convertOAuthRefreshEndpoint({ endpointResolver, propertyResolver, file, refreshTokenEndpoint }) {
1256393
- const resolvedEndpoint = endpointResolver.resolveEndpointOrThrow({
1256419
+ const resolvedEndpoint = await endpointResolver.resolveEndpointOrThrow({
1256394
1256420
  endpoint: refreshTokenEndpoint.endpoint,
1256395
1256421
  file
1256396
1256422
  });
@@ -1256429,7 +1256455,7 @@ async function convertOAuthRefreshEndpoint({ endpointResolver, propertyResolver,
1256429
1256455
 
1256430
1256456
  // ../generation/ir-generator/lib/converters/convertOAuthTokenEndpoint.js
1256431
1256457
  async function convertOAuthTokenEndpoint({ endpointResolver, propertyResolver, file, tokenEndpoint }) {
1256432
- const resolvedEndpoint = endpointResolver.resolveEndpointOrThrow({
1256458
+ const resolvedEndpoint = await endpointResolver.resolveEndpointOrThrow({
1256433
1256459
  endpoint: tokenEndpoint.endpoint,
1256434
1256460
  file
1256435
1256461
  });
@@ -1259632,15 +1259658,61 @@ var EndpointResolverImpl = class {
1259632
1259658
  constructor(workspace) {
1259633
1259659
  this.workspace = workspace;
1259634
1259660
  }
1259635
- resolveEndpointOrThrow({ endpoint, file }) {
1259636
- const resolvedEndpoint = this.resolveEndpoint({ endpoint, file });
1259661
+ async resolveEndpointOrThrow({ endpoint, file }) {
1259662
+ const resolvedEndpoint = await this.resolveEndpoint({ endpoint, file });
1259637
1259663
  if (resolvedEndpoint == null) {
1259638
1259664
  throw new Error("Cannot resolve endpoint: " + endpoint + " in file " + file.relativeFilepath);
1259639
1259665
  }
1259640
1259666
  return resolvedEndpoint;
1259641
1259667
  }
1259642
- resolveEndpoint({ endpoint, file }) {
1259668
+ async resolveEndpointByMethodAndPath({ method, path: path45 }) {
1259669
+ let result = void 0;
1259670
+ await visitAllDefinitionFiles(this.workspace, async (relativeFilepath, file, metadata) => {
1259671
+ var _a6;
1259672
+ const context = constructFernFileContext({
1259673
+ relativeFilepath,
1259674
+ definitionFile: file,
1259675
+ casingsGenerator: CASINGS_GENERATOR,
1259676
+ rootApiFile: this.workspace.definition.rootApiFile.contents,
1259677
+ defaultUrl: metadata.defaultUrl
1259678
+ });
1259679
+ for (const [endpointId, endpointDeclaration] of Object.entries(((_a6 = file.service) == null ? void 0 : _a6.endpoints) ?? {})) {
1259680
+ if (endpointDeclaration.method === method && endpointDeclaration.path === path45) {
1259681
+ result = {
1259682
+ endpointId,
1259683
+ endpoint: endpointDeclaration,
1259684
+ file: context
1259685
+ };
1259686
+ }
1259687
+ }
1259688
+ });
1259689
+ await visitAllPackageMarkers(this.workspace, async (relativeFilepath, packageMarker) => {
1259690
+ var _a6;
1259691
+ const context = constructFernFileContext({
1259692
+ relativeFilepath,
1259693
+ definitionFile: packageMarker,
1259694
+ casingsGenerator: CASINGS_GENERATOR,
1259695
+ rootApiFile: this.workspace.definition.rootApiFile.contents
1259696
+ });
1259697
+ for (const [endpointId, endpointDeclaration] of Object.entries(((_a6 = packageMarker.service) == null ? void 0 : _a6.endpoints) ?? {})) {
1259698
+ if (endpointDeclaration.method === method && endpointDeclaration.path === path45) {
1259699
+ result = {
1259700
+ endpointId,
1259701
+ endpoint: endpointDeclaration,
1259702
+ file: context
1259703
+ };
1259704
+ }
1259705
+ }
1259706
+ });
1259707
+ return result;
1259708
+ }
1259709
+ async resolveEndpoint({ endpoint, file }) {
1259643
1259710
  var _a6, _b4;
1259711
+ const referenceParser = new HttpEndpointReferenceParser();
1259712
+ const parsedEndpointReference = referenceParser.tryParse(endpoint);
1259713
+ if (parsedEndpointReference != null) {
1259714
+ return await this.resolveEndpointByMethodAndPath(parsedEndpointReference);
1259715
+ }
1259644
1259716
  const maybeDeclaration = this.getDeclarationOfEndpoint({
1259645
1259717
  referenceToEndpoint: endpoint,
1259646
1259718
  file
@@ -1259859,7 +1259931,7 @@ var PropertyResolverImpl = class {
1259859
1259931
  return resolvedRequestProperty;
1259860
1259932
  }
1259861
1259933
  async resolveRequestProperty({ file, endpoint, propertyComponents }) {
1259862
- const resolvedEndpoint = this.endpointResolver.resolveEndpointOrThrow({
1259934
+ const resolvedEndpoint = await this.endpointResolver.resolveEndpointOrThrow({
1259863
1259935
  endpoint,
1259864
1259936
  file
1259865
1259937
  });
@@ -1259899,7 +1259971,7 @@ var PropertyResolverImpl = class {
1259899
1259971
  }
1259900
1259972
  async resolveResponseProperty({ file, endpoint, propertyComponents }) {
1259901
1259973
  var _a6;
1259902
- const resolvedEndpoint = this.endpointResolver.resolveEndpointOrThrow({
1259974
+ const resolvedEndpoint = await this.endpointResolver.resolveEndpointOrThrow({
1259903
1259975
  endpoint,
1259904
1259976
  file
1259905
1259977
  });
@@ -1266371,7 +1266443,17 @@ async function visitRootApiFileYamlAst(contents, visitor) {
1266371
1266443
  imports: noop,
1266372
1266444
  auth: noop,
1266373
1266445
  "idempotency-headers": noop,
1266374
- "auth-schemes": noop,
1266446
+ "auth-schemes": async (authSchemes) => {
1266447
+ await Promise.all(Object.entries(authSchemes ?? {}).map(async ([authScheme, authSchemeDeclaration]) => {
1266448
+ var _a7;
1266449
+ if (isOAuthScheme(authSchemeDeclaration)) {
1266450
+ await ((_a7 = visitor.oauth) == null ? void 0 : _a7.call(visitor, { name: authScheme, oauth: authSchemeDeclaration }, [
1266451
+ "auth-scheme",
1266452
+ authScheme
1266453
+ ]));
1266454
+ }
1266455
+ }));
1266456
+ },
1266375
1266457
  pagination: noop,
1266376
1266458
  "default-environment": async (defaultEnvironment) => {
1266377
1266459
  var _a7;
@@ -1266525,6 +1266607,7 @@ function createRootApiFileAstVisitorForRules({ relativeFilepath, contents, allRu
1266525
1266607
  }
1266526
1266608
  return {
1266527
1266609
  ...createAstNodeVisitor("file"),
1266610
+ ...createAstNodeVisitor("oauth"),
1266528
1266611
  ...createAstNodeVisitor("defaultEnvironment"),
1266529
1266612
  ...createAstNodeVisitor("environment"),
1266530
1266613
  ...createAstNodeVisitor("errorDiscrimination"),
@@ -1269134,21 +1269217,6 @@ var ValidNavigationRule = {
1269134
1269217
  }
1269135
1269218
  };
1269136
1269219
 
1269137
- // ../../../node_modules/.pnpm/terminal-link@3.0.0/node_modules/terminal-link/index.js
1269138
- var import_supports_hyperlinks = __toESM(require_supports_hyperlinks(), 1);
1269139
- function terminalLink(text8, url, { target = "stdout", ...options2 } = {}) {
1269140
- if (!import_supports_hyperlinks.default[target]) {
1269141
- if (options2.fallback === false) {
1269142
- return text8;
1269143
- }
1269144
- return typeof options2.fallback === "function" ? options2.fallback(text8, url) : `${text8} (\u200B${url}\u200B)`;
1269145
- }
1269146
- return ansi_escapes_default.link(text8, url);
1269147
- }
1269148
- terminalLink.isSupported = import_supports_hyperlinks.default.stdout;
1269149
- terminalLink.stderr = (text8, url, options2 = {}) => terminalLink(text8, url, { target: "stderr", ...options2 });
1269150
- terminalLink.stderr.isSupported = import_supports_hyperlinks.default.stderr;
1269151
-
1269152
1269220
  // ../fern-definition/validator/lib/utils/propertyValidatorUtils.js
1269153
1269221
  var REQUEST_PREFIX2 = "$request.";
1269154
1269222
  var RESPONSE_PREFIX = "$response.";
@@ -1269761,155 +1269829,67 @@ function validateTokenEndpoint({ endpointId, endpoint, typeResolver, file, token
1269761
1269829
  return violations;
1269762
1269830
  }
1269763
1269831
 
1269764
- // ../fern-definition/validator/lib/rules/valid-oauth/validateClientCredentials.js
1269765
- function validateClientCredentials({ endpointId, endpoint, typeResolver, file, resolvedTokenEndpoint, resolvedRefreshEndpoint, clientCredentials: oauthScheme }) {
1269766
- const violations = [];
1269767
- if (endpointId === resolvedTokenEndpoint.endpointId) {
1269768
- violations.push(...validateTokenEndpoint({
1269769
- endpointId,
1269770
- endpoint,
1269771
- typeResolver,
1269772
- file,
1269773
- tokenEndpoint: oauthScheme["get-token"]
1269774
- }));
1269775
- }
1269776
- if (oauthScheme["refresh-token"] != null && endpointId === (resolvedRefreshEndpoint == null ? void 0 : resolvedRefreshEndpoint.endpointId)) {
1269777
- violations.push(...validateRefreshTokenEndpoint({
1269778
- endpointId,
1269779
- endpoint,
1269780
- typeResolver,
1269781
- file,
1269782
- refreshEndpoint: oauthScheme["refresh-token"]
1269783
- }));
1269784
- }
1269785
- return violations;
1269786
- }
1269787
-
1269788
1269832
  // ../fern-definition/validator/lib/rules/valid-oauth/valid-oauth.js
1269789
- var DOCS_LINK_MESSAGE = `For details, see the ${terminalLink("docs", DocsLinks.oauth, {
1269790
- fallback: (text8, url) => `${text8}: ${url}`
1269791
- })}.`;
1269792
1269833
  var ValidOauthRule = {
1269793
1269834
  name: "valid-oauth",
1269794
1269835
  create: ({ workspace }) => {
1269795
- const oauthScheme = maybeGetOAuthScheme({ workspace });
1269796
- if (oauthScheme == null) {
1269797
- return {};
1269798
- }
1269799
- const oauthSchema = oauthScheme.schema;
1269800
1269836
  const typeResolver = new TypeResolverImpl(workspace);
1269801
1269837
  const endpointResolver = new EndpointResolverImpl(workspace);
1269802
- const imports = workspace.definition.rootApiFile.contents.imports;
1269803
- if (imports == null) {
1269804
- return {
1269805
- rootApiFile: {
1269806
- file: (_4) => {
1269807
- return [
1269808
- {
1269809
- severity: "error",
1269810
- message: `File declares oauth scheme '${oauthScheme.name}', but no imports are declared to reference the required token endpoint(s). ${DOCS_LINK_MESSAGE}`
1269811
- }
1269812
- ];
1269813
- }
1269814
- }
1269815
- };
1269816
- }
1269817
1269838
  const apiFile = constructRootApiFileContext({
1269818
1269839
  casingsGenerator: CASINGS_GENERATOR2,
1269819
1269840
  rootApiFile: workspace.definition.rootApiFile.contents
1269820
1269841
  });
1269821
- const resolvedTokenEndpoint = endpointResolver.resolveEndpoint({
1269822
- endpoint: oauthSchema["get-token"].endpoint,
1269823
- file: apiFile
1269824
- });
1269825
- if (resolvedTokenEndpoint == null) {
1269826
- return {
1269827
- rootApiFile: {
1269828
- file: (_4) => {
1269829
- return [
1269830
- {
1269831
- severity: "error",
1269832
- message: `File declares oauth scheme '${oauthScheme.name}', but the OAuth 'get-token' endpoint could not be resolved. ${DOCS_LINK_MESSAGE}`
1269833
- }
1269834
- ];
1269835
- }
1269836
- }
1269837
- };
1269838
- }
1269839
- const resolvedRefreshEndpoint = oauthSchema["refresh-token"] != null ? endpointResolver.resolveEndpoint({
1269840
- endpoint: oauthSchema["refresh-token"].endpoint,
1269841
- file: apiFile
1269842
- }) : void 0;
1269843
- if (oauthSchema["refresh-token"] != null && resolvedRefreshEndpoint == null) {
1269844
- return {
1269845
- rootApiFile: {
1269846
- file: (_4) => {
1269847
- return [
1269848
- {
1269849
- severity: "error",
1269850
- message: `File declares oauth scheme '${oauthScheme.name}', but the OAuth 'refresh-token' endpoint could not be resolved. ${DOCS_LINK_MESSAGE}`
1269851
- }
1269852
- ];
1269853
- }
1269854
- }
1269855
- };
1269856
- }
1269857
1269842
  return {
1269858
- definitionFile: {
1269859
- httpEndpoint: ({ endpointId, endpoint }, { relativeFilepath, contents: definitionFile }) => {
1269860
- if (endpointId !== resolvedTokenEndpoint.endpointId && endpointId !== (resolvedRefreshEndpoint == null ? void 0 : resolvedRefreshEndpoint.endpointId)) {
1269861
- return [];
1269862
- }
1269863
- const file = constructFernFileContext({
1269864
- relativeFilepath,
1269865
- definitionFile,
1269866
- casingsGenerator: CASINGS_GENERATOR2,
1269867
- rootApiFile: workspace.definition.rootApiFile.contents
1269843
+ rootApiFile: {
1269844
+ oauth: async ({ name: name2, oauth }, { relativeFilepath }) => {
1269845
+ var _a6;
1269846
+ const violations = [];
1269847
+ const tokenEndpointReference = oauth["get-token"].endpoint;
1269848
+ const resolvedTokenEndpoint = await endpointResolver.resolveEndpoint({
1269849
+ endpoint: tokenEndpointReference,
1269850
+ file: apiFile
1269868
1269851
  });
1269869
- switch (oauthSchema.type) {
1269870
- case "client-credentials": {
1269871
- const violations = validateClientCredentials({
1269872
- endpointId,
1269873
- endpoint,
1269874
- typeResolver,
1269875
- file,
1269876
- resolvedTokenEndpoint,
1269877
- resolvedRefreshEndpoint,
1269878
- clientCredentials: oauthSchema
1269852
+ if (resolvedTokenEndpoint == null) {
1269853
+ violations.push({
1269854
+ severity: "error",
1269855
+ message: `Failed to resolve endpoint ${tokenEndpointReference}`
1269856
+ });
1269857
+ } else {
1269858
+ violations.push(...validateTokenEndpoint({
1269859
+ endpointId: resolvedTokenEndpoint.endpointId,
1269860
+ endpoint: resolvedTokenEndpoint.endpoint,
1269861
+ typeResolver,
1269862
+ file: resolvedTokenEndpoint.file,
1269863
+ tokenEndpoint: oauth["get-token"]
1269864
+ }));
1269865
+ }
1269866
+ const refreshEndpointReference = (_a6 = oauth["refresh-token"]) == null ? void 0 : _a6.endpoint;
1269867
+ if (oauth["refresh-token"] != null && refreshEndpointReference != null) {
1269868
+ const resolvedRefreshEndpoint = await endpointResolver.resolveEndpoint({
1269869
+ endpoint: refreshEndpointReference,
1269870
+ file: apiFile
1269871
+ });
1269872
+ if (resolvedRefreshEndpoint == null) {
1269873
+ violations.push({
1269874
+ severity: "error",
1269875
+ message: `Failed to resolve endpoint ${tokenEndpointReference}`
1269879
1269876
  });
1269880
- if (violations.length > 0) {
1269881
- return violations.map((violation) => ({
1269882
- severity: violation.severity,
1269883
- message: violation.message + ` ${DOCS_LINK_MESSAGE}`
1269884
- }));
1269885
- }
1269886
- return [];
1269877
+ } else {
1269878
+ violations.push(...validateRefreshTokenEndpoint({
1269879
+ endpointId: resolvedRefreshEndpoint.endpointId,
1269880
+ endpoint: resolvedRefreshEndpoint.endpoint,
1269881
+ typeResolver,
1269882
+ file: resolvedRefreshEndpoint.file,
1269883
+ refreshEndpoint: oauth["refresh-token"]
1269884
+ }));
1269887
1269885
  }
1269888
- default:
1269889
- assertNever(oauthSchema.type);
1269890
1269886
  }
1269887
+ return violations;
1269891
1269888
  }
1269892
1269889
  }
1269893
1269890
  };
1269894
1269891
  }
1269895
1269892
  };
1269896
- function maybeGetOAuthScheme({ workspace }) {
1269897
- const authSchemes = workspace.definition.rootApiFile.contents["auth-schemes"];
1269898
- if (authSchemes == null) {
1269899
- return void 0;
1269900
- }
1269901
- const oauthSchemePair = Object.entries(authSchemes).find(([_4, value]) => isRawOAuthSchemeSchema(value));
1269902
- if (oauthSchemePair == null) {
1269903
- return void 0;
1269904
- }
1269905
- return {
1269906
- name: oauthSchemePair[0],
1269907
- schema: oauthSchemePair[1]
1269908
- };
1269909
- }
1269910
- function isRawOAuthSchemeSchema(rawOAuthSchemeSchema) {
1269911
- return rawOAuthSchemeSchema.scheme === "oauth" && rawOAuthSchemeSchema.type != null && rawOAuthSchemeSchema["get-token"] != null;
1269912
- }
1269913
1269893
 
1269914
1269894
  // ../fern-definition/validator/lib/rules/valid-pagination/validateUtils.js
1269915
1269895
  function validateResultsProperty({ endpointId, typeResolver, file, resolvedResponseType, resultsProperty }) {
@@ -1323730,6 +1323710,23 @@ var import_fs9 = require("fs");
1323730
1323710
  var import_promises50 = require("fs/promises");
1323731
1323711
  var import_path41 = __toESM(require("path"), 1);
1323732
1323712
  var import_promises51 = require("stream/promises");
1323713
+
1323714
+ // ../../../node_modules/.pnpm/terminal-link@3.0.0/node_modules/terminal-link/index.js
1323715
+ var import_supports_hyperlinks = __toESM(require_supports_hyperlinks(), 1);
1323716
+ function terminalLink(text8, url, { target = "stdout", ...options2 } = {}) {
1323717
+ if (!import_supports_hyperlinks.default[target]) {
1323718
+ if (options2.fallback === false) {
1323719
+ return text8;
1323720
+ }
1323721
+ return typeof options2.fallback === "function" ? options2.fallback(text8, url) : `${text8} (\u200B${url}\u200B)`;
1323722
+ }
1323723
+ return ansi_escapes_default.link(text8, url);
1323724
+ }
1323725
+ terminalLink.isSupported = import_supports_hyperlinks.default.stdout;
1323726
+ terminalLink.stderr = (text8, url, options2 = {}) => terminalLink(text8, url, { target: "stderr", ...options2 });
1323727
+ terminalLink.stderr.isSupported = import_supports_hyperlinks.default.stderr;
1323728
+
1323729
+ // ../generation/remote-generation/remote-workspace-runner/lib/RemoteTaskHandler.js
1323733
1323730
  var import_tmp_promise11 = __toESM(require_tmp_promise(), 1);
1323734
1323731
  var _isFinished, _createdSnippets, _snippetsS3PreSignedReadUrl;
1323735
1323732
  var RemoteTaskHandler = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.41.2",
3
+ "version": "0.41.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",