@fern-api/fern-api-dev 4.46.3 → 4.46.4-33-g6b05e678505

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 +230 -8
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -590888,6 +590888,228 @@ var OpenAPIConverterContext3_1 = class extends AbstractConverterContext {
590888
590888
  }
590889
590889
  };
590890
590890
 
590891
+ // ../api-importers/openapi-to-ir/lib/resolveOAuthEndpointReferences.js
590892
+ var HTTP_METHOD_MAP = {
590893
+ GET: HttpMethod2.Get,
590894
+ POST: HttpMethod2.Post,
590895
+ PUT: HttpMethod2.Put,
590896
+ PATCH: HttpMethod2.Patch,
590897
+ DELETE: HttpMethod2.Delete
590898
+ };
590899
+ function resolveOAuthEndpointReferences({ ir: ir15, authOverrides }) {
590900
+ if (!authOverrides["auth-schemes"] || !ir15.auth) {
590901
+ return ir15;
590902
+ }
590903
+ const authSchemes = authOverrides["auth-schemes"];
590904
+ const updatedSchemes = [];
590905
+ for (const scheme of ir15.auth.schemes) {
590906
+ if (scheme.type !== "bearer") {
590907
+ updatedSchemes.push(scheme);
590908
+ continue;
590909
+ }
590910
+ const rawDeclaration = authSchemes[scheme.key];
590911
+ if (rawDeclaration == null) {
590912
+ updatedSchemes.push(scheme);
590913
+ continue;
590914
+ }
590915
+ const resolvedScheme = visitRawAuthSchemeDeclaration(rawDeclaration, {
590916
+ header: () => void 0,
590917
+ basic: () => void 0,
590918
+ tokenBearer: () => void 0,
590919
+ inferredBearer: () => void 0,
590920
+ oauth: (oauthScheme) => resolveOAuthScheme({ ir: ir15, key: scheme.key, oauthScheme })
590921
+ });
590922
+ updatedSchemes.push(resolvedScheme ?? scheme);
590923
+ }
590924
+ return { ...ir15, auth: { ...ir15.auth, schemes: updatedSchemes } };
590925
+ }
590926
+ function resolveOAuthScheme({ ir: ir15, key: key2, oauthScheme }) {
590927
+ if (oauthScheme.type !== "client-credentials") {
590928
+ return void 0;
590929
+ }
590930
+ const tokenEndpointConfig = oauthScheme["get-token"];
590931
+ const resolved = resolveEndpointFromReference({ ir: ir15, endpointRef: tokenEndpointConfig.endpoint });
590932
+ if (resolved == null) {
590933
+ return void 0;
590934
+ }
590935
+ const { endpoint: endpoint3, serviceId, subpackageId } = resolved;
590936
+ const reqProps = tokenEndpointConfig["request-properties"];
590937
+ const resProps = tokenEndpointConfig["response-properties"];
590938
+ const clientIdProp = findRequestBodyProperty({
590939
+ ir: ir15,
590940
+ endpoint: endpoint3,
590941
+ wireValue: extractWireName(reqProps?.["client-id"], "client_id")
590942
+ });
590943
+ const clientSecretProp = findRequestBodyProperty({
590944
+ ir: ir15,
590945
+ endpoint: endpoint3,
590946
+ wireValue: extractWireName(reqProps?.["client-secret"], "client_secret")
590947
+ });
590948
+ const accessTokenProp = findResponseProperty({
590949
+ ir: ir15,
590950
+ endpoint: endpoint3,
590951
+ wireValue: extractWireName(resProps?.["access-token"], "access_token")
590952
+ });
590953
+ if (clientIdProp == null || clientSecretProp == null || accessTokenProp == null) {
590954
+ return void 0;
590955
+ }
590956
+ return AuthScheme.oauth({
590957
+ key: key2,
590958
+ docs: oauthScheme.docs,
590959
+ configuration: OAuthConfiguration.clientCredentials({
590960
+ clientIdEnvVar: oauthScheme["client-id-env"],
590961
+ clientSecretEnvVar: oauthScheme["client-secret-env"],
590962
+ tokenPrefix: oauthScheme["token-prefix"],
590963
+ tokenHeader: oauthScheme["token-header"],
590964
+ scopes: oauthScheme.scopes,
590965
+ tokenEndpoint: {
590966
+ endpointReference: { endpointId: endpoint3.id, serviceId, subpackageId },
590967
+ requestProperties: {
590968
+ clientId: clientIdProp,
590969
+ clientSecret: clientSecretProp,
590970
+ scopes: void 0,
590971
+ customProperties: void 0
590972
+ },
590973
+ responseProperties: {
590974
+ accessToken: accessTokenProp,
590975
+ expiresIn: findResponseProperty({
590976
+ ir: ir15,
590977
+ endpoint: endpoint3,
590978
+ wireValue: extractWireName(resProps?.["expires-in"], "expires_in")
590979
+ }),
590980
+ refreshToken: findResponseProperty({
590981
+ ir: ir15,
590982
+ endpoint: endpoint3,
590983
+ wireValue: extractWireName(resProps?.["refresh-token"], "refresh_token")
590984
+ })
590985
+ }
590986
+ },
590987
+ refreshEndpoint: oauthScheme["refresh-token"] != null ? resolveRefreshEndpoint({ ir: ir15, refreshTokenConfig: oauthScheme["refresh-token"] }) : void 0
590988
+ })
590989
+ });
590990
+ }
590991
+ function resolveRefreshEndpoint({ ir: ir15, refreshTokenConfig }) {
590992
+ const resolved = resolveEndpointFromReference({ ir: ir15, endpointRef: refreshTokenConfig.endpoint });
590993
+ if (resolved == null) {
590994
+ return void 0;
590995
+ }
590996
+ const { endpoint: endpoint3, serviceId, subpackageId } = resolved;
590997
+ const reqProps = refreshTokenConfig["request-properties"];
590998
+ const resProps = refreshTokenConfig["response-properties"];
590999
+ const refreshTokenReqProp = findRequestBodyProperty({
591000
+ ir: ir15,
591001
+ endpoint: endpoint3,
591002
+ wireValue: extractWireName(reqProps?.["refresh-token"], "refresh_token")
591003
+ });
591004
+ const accessTokenProp = findResponseProperty({
591005
+ ir: ir15,
591006
+ endpoint: endpoint3,
591007
+ wireValue: extractWireName(resProps?.["access-token"], "access_token")
591008
+ });
591009
+ if (refreshTokenReqProp == null || accessTokenProp == null) {
591010
+ return void 0;
591011
+ }
591012
+ return {
591013
+ endpointReference: { endpointId: endpoint3.id, serviceId, subpackageId },
591014
+ requestProperties: { refreshToken: refreshTokenReqProp },
591015
+ responseProperties: {
591016
+ accessToken: accessTokenProp,
591017
+ expiresIn: findResponseProperty({
591018
+ ir: ir15,
591019
+ endpoint: endpoint3,
591020
+ wireValue: extractWireName(resProps?.["expires-in"], "expires_in")
591021
+ }),
591022
+ refreshToken: findResponseProperty({
591023
+ ir: ir15,
591024
+ endpoint: endpoint3,
591025
+ wireValue: extractWireName(resProps?.["refresh-token"], "refresh_token")
591026
+ })
591027
+ }
591028
+ };
591029
+ }
591030
+ function resolveEndpointFromReference({ ir: ir15, endpointRef }) {
591031
+ const parts = endpointRef.trim().split(/\s+/);
591032
+ if (parts.length !== 2) {
591033
+ return void 0;
591034
+ }
591035
+ const method8 = HTTP_METHOD_MAP[parts[0]?.toUpperCase() ?? ""];
591036
+ const targetPath = parts[1]?.replace(/\/+$/, "");
591037
+ if (method8 == null || targetPath == null) {
591038
+ return void 0;
591039
+ }
591040
+ for (const [serviceId, service] of Object.entries(ir15.services)) {
591041
+ for (const endpoint3 of service.endpoints) {
591042
+ if (endpoint3.method !== method8) {
591043
+ continue;
591044
+ }
591045
+ const endpointPath = reconstructPath(endpoint3.fullPath);
591046
+ if (endpointPath === targetPath) {
591047
+ const subpackageId = Object.entries(ir15.subpackages).find(([, sp4]) => sp4.service === serviceId)?.[0];
591048
+ return { endpoint: endpoint3, serviceId, subpackageId };
591049
+ }
591050
+ }
591051
+ }
591052
+ return void 0;
591053
+ }
591054
+ function reconstructPath(httpPath) {
591055
+ let result = httpPath.head;
591056
+ for (const part of httpPath.parts) {
591057
+ result += `{${part.pathParameter}}${part.tail}`;
591058
+ }
591059
+ return result.replace(/\/+$/, "");
591060
+ }
591061
+ function extractWireName(value, defaultName) {
591062
+ if (value == null) {
591063
+ return defaultName;
591064
+ }
591065
+ const match3 = value.match(/^\$(?:request|response)\.(.+)$/);
591066
+ return match3?.[1] ?? value;
591067
+ }
591068
+ function findObjectPropertyByWireValue(properties7, wireValue) {
591069
+ return properties7.find((prop) => prop.name.wireValue === wireValue);
591070
+ }
591071
+ function getObjectPropertiesForNamedType(ir15, typeId) {
591072
+ const typeDecl = ir15.types[typeId];
591073
+ if (typeDecl?.shape.type === "object") {
591074
+ return typeDecl.shape.properties;
591075
+ }
591076
+ return void 0;
591077
+ }
591078
+ function findRequestBodyProperty({ ir: ir15, endpoint: endpoint3, wireValue }) {
591079
+ if (endpoint3.requestBody == null) {
591080
+ return void 0;
591081
+ }
591082
+ let properties7;
591083
+ if (endpoint3.requestBody.type === "inlinedRequestBody") {
591084
+ properties7 = endpoint3.requestBody.properties;
591085
+ } else if (endpoint3.requestBody.type === "reference" && endpoint3.requestBody.requestBodyType.type === "named") {
591086
+ properties7 = getObjectPropertiesForNamedType(ir15, endpoint3.requestBody.requestBodyType.typeId);
591087
+ }
591088
+ const prop = properties7 != null ? findObjectPropertyByWireValue(properties7, wireValue) : void 0;
591089
+ if (prop == null) {
591090
+ return void 0;
591091
+ }
591092
+ return {
591093
+ propertyPath: void 0,
591094
+ property: RequestPropertyValue.body({ ...prop })
591095
+ };
591096
+ }
591097
+ function findResponseProperty({ ir: ir15, endpoint: endpoint3, wireValue }) {
591098
+ if (endpoint3.response?.body?.type !== "json") {
591099
+ return void 0;
591100
+ }
591101
+ const responseBodyType = endpoint3.response.body.value.responseBodyType;
591102
+ if (responseBodyType.type !== "named") {
591103
+ return void 0;
591104
+ }
591105
+ const properties7 = getObjectPropertiesForNamedType(ir15, responseBodyType.typeId);
591106
+ const prop = properties7 != null ? findObjectPropertyByWireValue(properties7, wireValue) : void 0;
591107
+ if (prop == null) {
591108
+ return void 0;
591109
+ }
591110
+ return { propertyPath: void 0, property: prop };
591111
+ }
591112
+
590891
591113
  // ../api-importers/openrpc-to-ir/lib/1.x/extensions/x-fern-parameters.js
590892
591114
  init_lib4();
590893
591115
  var ParameterBaseObjectSchema = external_exports2.object({
@@ -592744,9 +592966,6 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
592744
592966
  const specs = await this.getOpenAPISpecsCached({ context: context3 });
592745
592967
  const documents = await this.loader.loadDocuments({ context: context3, specs });
592746
592968
  const authOverrides = this.generatorsConfiguration?.api?.auth != null ? { ...this.generatorsConfiguration?.api } : void 0;
592747
- if (authOverrides) {
592748
- context3.logger.trace("Using auth overrides from generators configuration");
592749
- }
592750
592969
  const environmentOverrides = this.generatorsConfiguration?.api?.environments != null ? { ...this.generatorsConfiguration?.api } : void 0;
592751
592970
  if (environmentOverrides) {
592752
592971
  context3.logger.trace("Using environment overrides from generators configuration");
@@ -592881,6 +593100,9 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
592881
593100
  if (mergedIr === void 0) {
592882
593101
  throw new Error("Failed to generate intermediate representation");
592883
593102
  }
593103
+ if (authOverrides != null) {
593104
+ mergedIr = resolveOAuthEndpointReferences({ ir: mergedIr, authOverrides });
593105
+ }
592884
593106
  return mergedIr;
592885
593107
  }
592886
593108
  async generateAllProtobufIRs({ context: context3 }) {
@@ -601768,7 +601990,7 @@ var AccessTokenPosthogManager = class {
601768
601990
  properties: {
601769
601991
  ...event,
601770
601992
  ...event.properties,
601771
- version: "4.46.3",
601993
+ version: "4.46.4-33-g6b05e678505",
601772
601994
  usingAccessToken: true
601773
601995
  }
601774
601996
  });
@@ -601819,7 +602041,7 @@ var UserPosthogManager = class {
601819
602041
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
601820
602042
  event: "CLI",
601821
602043
  properties: {
601822
- version: "4.46.3",
602044
+ version: "4.46.4-33-g6b05e678505",
601823
602045
  ...event,
601824
602046
  ...event.properties,
601825
602047
  usingAccessToken: false,
@@ -825673,7 +825895,7 @@ var import_path54 = __toESM(require("path"), 1);
825673
825895
  var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
825674
825896
  var LOGS_FOLDER_NAME = "logs";
825675
825897
  function getCliSource() {
825676
- const version7 = "4.46.3";
825898
+ const version7 = "4.46.4-33-g6b05e678505";
825677
825899
  return `cli@${version7}`;
825678
825900
  }
825679
825901
  var DebugLogger = class {
@@ -836640,7 +836862,7 @@ var LegacyDocsPublisher = class {
836640
836862
  previewId: void 0,
836641
836863
  disableTemplates: void 0,
836642
836864
  skipUpload,
836643
- cliVersion: "4.46.3"
836865
+ cliVersion: "4.46.4-33-g6b05e678505"
836644
836866
  });
836645
836867
  if (taskContext.getResult() === TaskResult.Failure) {
836646
836868
  return { success: false };
@@ -909490,7 +909712,7 @@ var CliContext = class {
909490
909712
  if (false) {
909491
909713
  this.logger.error("CLI_VERSION is not defined");
909492
909714
  }
909493
- return "4.46.3";
909715
+ return "4.46.4-33-g6b05e678505";
909494
909716
  }
909495
909717
  getCliName() {
909496
909718
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.46.3",
2
+ "version": "4.46.4-33-g6b05e678505",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",