fern-api 0.41.1 → 0.41.2

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 +46 -15
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -1205586,6 +1205586,7 @@ __export(schemas_exports3, {
1205586
1205586
  WebhookPayloadSchema: () => WebhookPayloadSchema,
1205587
1205587
  WebhookReferencedPayloadSchema: () => WebhookReferencedPayloadSchema,
1205588
1205588
  WebhookSchema: () => WebhookSchema,
1205589
+ WithAuthSchema: () => WithAuthSchema,
1205589
1205590
  WithDocsSchema: () => WithDocsSchema,
1205590
1205591
  WithEnvironmentsSchema: () => WithEnvironmentsSchema,
1205591
1205592
  WithNameAndDocsSchema: () => WithNameAndDocsSchema,
@@ -1206306,12 +1206307,14 @@ var WithEnvironmentsSchema = z.strictObject({
1206306
1206307
  "default-environment": z.optional(z.string().or(z.null())),
1206307
1206308
  environments: z.optional(z.record(z.string(), EnvironmentSchema))
1206308
1206309
  });
1206309
- var RootApiFileSchema = WithEnvironmentsSchema.extend({
1206310
+ var WithAuthSchema = z.strictObject({
1206311
+ auth: z.optional(ApiAuthSchema),
1206312
+ "auth-schemes": z.optional(z.record(AuthSchemeDeclarationSchema))
1206313
+ });
1206314
+ var RootApiFileSchema = z.strictObject({
1206310
1206315
  name: z.string(),
1206311
1206316
  "display-name": z.optional(z.string()),
1206312
1206317
  imports: z.optional(z.record(z.string())),
1206313
- auth: z.optional(ApiAuthSchema),
1206314
- "auth-schemes": z.optional(z.record(AuthSchemeDeclarationSchema)),
1206315
1206318
  headers: z.optional(z.record(z.string(), HttpHeaderSchema)),
1206316
1206319
  "error-discrimination": z.optional(ErrorDiscriminationSchema),
1206317
1206320
  audiences: z.optional(z.array(z.string())),
@@ -1206323,7 +1206326,7 @@ var RootApiFileSchema = WithEnvironmentsSchema.extend({
1206323
1206326
  variables: z.optional(z.record(VariableDeclarationSchema)),
1206324
1206327
  pagination: z.optional(PaginationSchema),
1206325
1206328
  version: z.optional(VersionDeclarationSchema)
1206326
- });
1206329
+ }).extend(WithEnvironmentsSchema.shape).extend(WithAuthSchema.shape);
1206327
1206330
 
1206328
1206331
  // ../fern-definition/schema/lib/utils/RawContainerType.js
1206329
1206332
  var RawContainerType = {
@@ -1213485,6 +1213488,7 @@ var AsyncAPISchema = z.strictObject({
1213485
1213488
  });
1213486
1213489
  var SpecSchema = z.union([OpenAPISpecSchema, AsyncAPISchema]);
1213487
1213490
  var APIConfigurationV2Schema = schemas_exports3.WithEnvironmentsSchema.extend({
1213491
+ auth: z.optional(schemas_exports3.ApiAuthSchema),
1213488
1213492
  specs: z.array(SpecSchema)
1213489
1213493
  });
1213490
1213494
 
@@ -1213759,6 +1213763,7 @@ var API_ORIGIN_LOCATION_KEY = "spec-origin";
1213759
1213763
  var ASYNC_API_LOCATION_KEY = "async-api";
1213760
1213764
  var API_SETTINGS_KEY = "api-settings";
1213761
1213765
  var GeneratorsConfigurationSchema = z.strictObject({
1213766
+ "auth-schemes": z.optional(z.record(schemas_exports3.AuthSchemeDeclarationSchema)),
1213762
1213767
  api: z.optional(APIConfigurationSchema),
1213763
1213768
  whitelabel: z.optional(WhitelabelConfigurationSchema),
1213764
1213769
  metadata: z.optional(OutputMetadataSchema),
@@ -1213961,6 +1213966,19 @@ async function parseAPIConfiguration(rawGeneratorsConfiguration) {
1213961
1213966
  if (apiConfiguration != null && isApiConfigurationV2Schema(apiConfiguration)) {
1213962
1213967
  return {
1213963
1213968
  type: "singleNamespace",
1213969
+ "auth-schemes": apiConfiguration.auth != null ? Object.fromEntries(Object.entries(rawGeneratorsConfiguration["auth-schemes"] ?? {}).filter(([name2, _4]) => {
1213970
+ if (apiConfiguration.auth == null) {
1213971
+ return false;
1213972
+ }
1213973
+ return visitRawApiAuth(apiConfiguration.auth, {
1213974
+ any: (any4) => {
1213975
+ return any4.any.includes(name2);
1213976
+ },
1213977
+ single: (single) => {
1213978
+ return single === name2;
1213979
+ }
1213980
+ });
1213981
+ })) : void 0,
1213964
1213982
  ...apiConfiguration,
1213965
1213983
  definitions: apiConfiguration.specs.map((spec) => {
1213966
1213984
  if (isOpenAPISchema(spec)) {
@@ -1216775,7 +1216793,7 @@ var AccessTokenPosthogManager = class {
1216775
1216793
  properties: {
1216776
1216794
  ...event,
1216777
1216795
  ...event.properties,
1216778
- version: "0.41.1",
1216796
+ version: "0.41.2",
1216779
1216797
  usingAccessToken: true
1216780
1216798
  }
1216781
1216799
  });
@@ -1216837,7 +1216855,7 @@ var UserPosthogManager = class {
1216837
1216855
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
1216838
1216856
  event: "CLI",
1216839
1216857
  properties: {
1216840
- version: "0.41.1",
1216858
+ version: "0.41.2",
1216841
1216859
  ...event,
1216842
1216860
  ...event.properties
1216843
1216861
  }
@@ -1221927,10 +1221945,10 @@ var CliContext = class {
1221927
1221945
  return "fern-api";
1221928
1221946
  }
1221929
1221947
  getPackageVersion() {
1221930
- if ("0.41.1" == null) {
1221948
+ if ("0.41.2" == null) {
1221931
1221949
  this.logger.error("CLI_VERSION is not defined");
1221932
1221950
  }
1221933
- return "0.41.1";
1221951
+ return "0.41.2";
1221934
1221952
  }
1221935
1221953
  getCliName() {
1221936
1221954
  if ("fern" == null) {
@@ -1228059,6 +1228077,18 @@ function getHeaderName(headerWireKey) {
1228059
1228077
  var BASIC_AUTH_SCHEME = "BasicAuthScheme";
1228060
1228078
  var BEARER_AUTH_SCHEME = "BearerAuthScheme";
1228061
1228079
  function buildAuthSchemes(context) {
1228080
+ if (context.authOverrides != null) {
1228081
+ for (const [name2, declaration] of Object.entries(context.authOverrides["auth-schemes"] ?? {})) {
1228082
+ context.builder.addAuthScheme({
1228083
+ name: name2,
1228084
+ schema: declaration
1228085
+ });
1228086
+ }
1228087
+ if (context.authOverrides.auth != null) {
1228088
+ context.builder.setAuth(context.authOverrides.auth);
1228089
+ }
1228090
+ return;
1228091
+ }
1228062
1228092
  let setAuth = false;
1228063
1228093
  for (const [id, securityScheme] of Object.entries(context.ir.securitySchemes)) {
1228064
1228094
  if (securityScheme.type === "basic") {
@@ -1237325,8 +1237355,8 @@ var FernDefinitionBuilderImpl = class {
1237325
1237355
  }
1237326
1237356
  this.rootApiFile.audiences.push(name2);
1237327
1237357
  }
1237328
- setAuth(name2) {
1237329
- this.rootApiFile.auth = name2;
1237358
+ setAuth(auth) {
1237359
+ this.rootApiFile.auth = auth;
1237330
1237360
  }
1237331
1237361
  addAuthScheme({ name: name2, schema: schema2 }) {
1237332
1237362
  if (this.rootApiFile["auth-schemes"] == null) {
@@ -1237698,15 +1237728,17 @@ var OpenApiIrConverterContext = class {
1237698
1237728
  ir;
1237699
1237729
  builder;
1237700
1237730
  environmentOverrides;
1237731
+ authOverrides;
1237701
1237732
  detectGlobalHeaders;
1237702
1237733
  defaultServerName = void 0;
1237703
- constructor({ taskContext, ir, enableUniqueErrorsPerEndpoint, detectGlobalHeaders, environmentOverrides }) {
1237734
+ constructor({ taskContext, ir, enableUniqueErrorsPerEndpoint, detectGlobalHeaders, environmentOverrides, authOverrides }) {
1237704
1237735
  this.logger = taskContext.logger;
1237705
1237736
  this.taskContext = taskContext;
1237706
1237737
  this.ir = ir;
1237707
1237738
  this.builder = new FernDefinitionBuilderImpl(ir, false, enableUniqueErrorsPerEndpoint);
1237708
1237739
  this.detectGlobalHeaders = detectGlobalHeaders;
1237709
1237740
  this.environmentOverrides = environmentOverrides;
1237741
+ this.authOverrides = authOverrides;
1237710
1237742
  }
1237711
1237743
  getSchema(id) {
1237712
1237744
  const schema2 = this.ir.schemas[id];
@@ -1237874,7 +1237906,7 @@ var OSSWorkspace = class extends AbstractAPIWorkspace {
1237874
1237906
  this.sources = this.convertSpecsToIdentifiableSources(specs);
1237875
1237907
  }
1237876
1237908
  async getDefinition({ context, relativePathToDependency }, settings) {
1237877
- var _a6;
1237909
+ var _a6, _b4, _c4, _d2, _e, _f;
1237878
1237910
  const openApiSpecs = await getAllOpenAPISpecs({ context, specs: this.specs, relativePathToDependency });
1237879
1237911
  const openApiIr = await parse3({
1237880
1237912
  absoluteFilePathToWorkspace: this.absoluteFilepath,
@@ -1237883,9 +1237915,8 @@ var OSSWorkspace = class extends AbstractAPIWorkspace {
1237883
1237915
  optionOverrides: getOptionsOverridesFromSettings(settings)
1237884
1237916
  });
1237885
1237917
  const definition3 = convert({
1237886
- environmentOverrides: {
1237887
- ...(_a6 = this.generatorsConfiguration) == null ? void 0 : _a6.api
1237888
- },
1237918
+ authOverrides: ((_b4 = (_a6 = this.generatorsConfiguration) == null ? void 0 : _a6.api) == null ? void 0 : _b4.auth) != null ? { ...(_c4 = this.generatorsConfiguration) == null ? void 0 : _c4.api } : void 0,
1237919
+ environmentOverrides: ((_e = (_d2 = this.generatorsConfiguration) == null ? void 0 : _d2.api) == null ? void 0 : _e.environments) != null ? { ...(_f = this.generatorsConfiguration) == null ? void 0 : _f.api } : void 0,
1237889
1237920
  taskContext: context,
1237890
1237921
  ir: openApiIr,
1237891
1237922
  enableUniqueErrorsPerEndpoint: (settings == null ? void 0 : settings.enableUniqueErrorsPerEndpoint) ?? false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.41.1",
3
+ "version": "0.41.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",