@fern-api/fern-api-dev 4.46.2 → 4.46.3-8-g7a60c0cd67d

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 +240 -11
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -509587,14 +509587,21 @@ function buildOneOfTypeDeclaration({ schema: schema2, context: context3, declara
509587
509587
  return {
509588
509588
  name: schema2.nameOverride ?? schema2.generatedName,
509589
509589
  schema: {
509590
- discriminant: schema2.discriminantPropertyNameOverride != null ? { name: schema2.discriminantPropertyNameOverride, value: schema2.discriminantProperty } : schema2.discriminantProperty,
509590
+ discriminant: schema2.discriminantPropertyNameOverride != null || schema2.discriminatorContext != null ? {
509591
+ ...schema2.discriminantPropertyNameOverride != null && {
509592
+ name: schema2.discriminantPropertyNameOverride
509593
+ },
509594
+ value: schema2.discriminantProperty,
509595
+ ...schema2.discriminatorContext != null && {
509596
+ context: schema2.discriminatorContext
509597
+ }
509598
+ } : schema2.discriminantProperty,
509591
509599
  "base-properties": baseProperties,
509592
509600
  docs: schema2.description ?? void 0,
509593
509601
  availability: schema2.availability != null ? convertAvailability(schema2.availability) : void 0,
509594
509602
  union: union21,
509595
509603
  encoding,
509596
- source: schema2.source != null ? convertToSourceSchema(schema2.source) : void 0,
509597
- ...schema2.discriminatorContext && { context: schema2.discriminatorContext }
509604
+ source: schema2.source != null ? convertToSourceSchema(schema2.source) : void 0
509598
509605
  }
509599
509606
  };
509600
509607
  }
@@ -590881,6 +590888,228 @@ var OpenAPIConverterContext3_1 = class extends AbstractConverterContext {
590881
590888
  }
590882
590889
  };
590883
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
+
590884
591113
  // ../api-importers/openrpc-to-ir/lib/1.x/extensions/x-fern-parameters.js
590885
591114
  init_lib4();
590886
591115
  var ParameterBaseObjectSchema = external_exports2.object({
@@ -592737,9 +592966,6 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
592737
592966
  const specs = await this.getOpenAPISpecsCached({ context: context3 });
592738
592967
  const documents = await this.loader.loadDocuments({ context: context3, specs });
592739
592968
  const authOverrides = this.generatorsConfiguration?.api?.auth != null ? { ...this.generatorsConfiguration?.api } : void 0;
592740
- if (authOverrides) {
592741
- context3.logger.trace("Using auth overrides from generators configuration");
592742
- }
592743
592969
  const environmentOverrides = this.generatorsConfiguration?.api?.environments != null ? { ...this.generatorsConfiguration?.api } : void 0;
592744
592970
  if (environmentOverrides) {
592745
592971
  context3.logger.trace("Using environment overrides from generators configuration");
@@ -592874,6 +593100,9 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
592874
593100
  if (mergedIr === void 0) {
592875
593101
  throw new Error("Failed to generate intermediate representation");
592876
593102
  }
593103
+ if (authOverrides != null) {
593104
+ mergedIr = resolveOAuthEndpointReferences({ ir: mergedIr, authOverrides });
593105
+ }
592877
593106
  return mergedIr;
592878
593107
  }
592879
593108
  async generateAllProtobufIRs({ context: context3 }) {
@@ -601761,7 +601990,7 @@ var AccessTokenPosthogManager = class {
601761
601990
  properties: {
601762
601991
  ...event,
601763
601992
  ...event.properties,
601764
- version: "4.46.2",
601993
+ version: "4.46.3-8-g7a60c0cd67d",
601765
601994
  usingAccessToken: true
601766
601995
  }
601767
601996
  });
@@ -601812,7 +602041,7 @@ var UserPosthogManager = class {
601812
602041
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
601813
602042
  event: "CLI",
601814
602043
  properties: {
601815
- version: "4.46.2",
602044
+ version: "4.46.3-8-g7a60c0cd67d",
601816
602045
  ...event,
601817
602046
  ...event.properties,
601818
602047
  usingAccessToken: false,
@@ -825666,7 +825895,7 @@ var import_path54 = __toESM(require("path"), 1);
825666
825895
  var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
825667
825896
  var LOGS_FOLDER_NAME = "logs";
825668
825897
  function getCliSource() {
825669
- const version7 = "4.46.2";
825898
+ const version7 = "4.46.3-8-g7a60c0cd67d";
825670
825899
  return `cli@${version7}`;
825671
825900
  }
825672
825901
  var DebugLogger = class {
@@ -836633,7 +836862,7 @@ var LegacyDocsPublisher = class {
836633
836862
  previewId: void 0,
836634
836863
  disableTemplates: void 0,
836635
836864
  skipUpload,
836636
- cliVersion: "4.46.2"
836865
+ cliVersion: "4.46.3-8-g7a60c0cd67d"
836637
836866
  });
836638
836867
  if (taskContext.getResult() === TaskResult.Failure) {
836639
836868
  return { success: false };
@@ -909483,7 +909712,7 @@ var CliContext = class {
909483
909712
  if (false) {
909484
909713
  this.logger.error("CLI_VERSION is not defined");
909485
909714
  }
909486
- return "4.46.2";
909715
+ return "4.46.3-8-g7a60c0cd67d";
909487
909716
  }
909488
909717
  getCliName() {
909489
909718
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.46.2",
2
+ "version": "4.46.3-8-g7a60c0cd67d",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",