@fern-api/fern-api-dev 5.113.3 → 5.114.0

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 +109 -35
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -131246,7 +131246,8 @@ var init_OpenApiSettingsSchema2 = __esm({
131246
131246
  "disambiguate-request-names": schemas_exports8.boolean().optional(),
131247
131247
  "ignore-tags": schemas_exports8.boolean().optional(),
131248
131248
  "respect-parameter-content": schemas_exports8.boolean().optional(),
131249
- "respect-per-spec-base-path": schemas_exports8.boolean().optional()
131249
+ "respect-per-spec-base-path": schemas_exports8.boolean().optional(),
131250
+ "namespaced-errors": schemas_exports8.boolean().optional()
131250
131251
  }).extend(BaseApiSettingsSchema);
131251
131252
  }
131252
131253
  });
@@ -132773,7 +132774,8 @@ var init_ConvertOpenAPIOptions = __esm({
132773
132774
  groupEnvironmentsByHost: false,
132774
132775
  multiServerStrategy: generators_yml_exports.MultiServerStrategy.EnvironmentPerServer,
132775
132776
  removeDiscriminantsFromSchemas: generators_yml_exports.RemoveDiscriminantsFromSchemas.Always,
132776
- inferDefaultEnvironment: true
132777
+ inferDefaultEnvironment: true,
132778
+ namespacedErrors: false
132777
132779
  };
132778
132780
  }
132779
132781
  });
@@ -139927,7 +139929,8 @@ var init_HttpError2 = __esm({
139927
139929
  init_ErrorExample2();
139928
139930
  HttpError = schemas_exports9.objectWithoutOptionalProperties({
139929
139931
  schema: schemas_exports9.lazy(() => Schema2).optional(),
139930
- examples: schemas_exports9.list(ErrorExample).optional()
139932
+ examples: schemas_exports9.list(ErrorExample).optional(),
139933
+ namespace: schemas_exports9.string().optional()
139931
139934
  }).extend(WithDescription).extend(WithName3).extend(WithSource);
139932
139935
  }
139933
139936
  });
@@ -141767,7 +141770,8 @@ var init_HttpErrorWithExample2 = __esm({
141767
141770
  HttpErrorWithExample = schemas_exports9.objectWithoutOptionalProperties({
141768
141771
  statusCode: StatusCode,
141769
141772
  schema: schemas_exports9.lazy(() => SchemaWithExample2),
141770
- fullExamples: schemas_exports9.list(NamedFullExample).optional()
141773
+ fullExamples: schemas_exports9.list(NamedFullExample).optional(),
141774
+ namespace: schemas_exports9.string().optional()
141771
141775
  }).extend(WithDescription).extend(WithName3).extend(WithSource);
141772
141776
  }
141773
141777
  });
@@ -143067,18 +143071,16 @@ function isOneOfEqual(a3, b5) {
143067
143071
  return false;
143068
143072
  }
143069
143073
  function isObjectEqual(a3, b5) {
143070
- if (Object.keys(a3.properties).length !== Object.keys(b5.properties).length) {
143074
+ if (a3.properties.length !== b5.properties.length) {
143071
143075
  return false;
143072
143076
  }
143073
- const aPropertyMap = Object.fromEntries(a3.properties.map((property24) => {
143074
- return [property24.key, property24.schema];
143075
- }));
143076
- return Object.entries(b5.properties).every(([bPropertyName, bPropertySchema]) => {
143077
- const aProperty = aPropertyMap[bPropertyName];
143078
- if (aProperty == null) {
143077
+ const aPropertyMap = new Map(a3.properties.map((property24) => [property24.key, property24.schema]));
143078
+ return b5.properties.every((bProperty) => {
143079
+ const aPropertySchema = aPropertyMap.get(bProperty.key);
143080
+ if (aPropertySchema == null) {
143079
143081
  return false;
143080
143082
  }
143081
- return isSchemaEqual(aProperty, bPropertySchema.schema);
143083
+ return isSchemaEqual(aPropertySchema, bProperty.schema);
143082
143084
  });
143083
143085
  }
143084
143086
  var init_isSchemaEqual = __esm({
@@ -145655,6 +145657,38 @@ function getNamespaceFromGroup(groupName) {
145655
145657
  function getEndpointNamespace(sdkName, namespaceOverride) {
145656
145658
  return namespaceOverride != null ? namespaceOverride : sdkName?.groupName != null ? getNamespaceFromGroup(sdkName.groupName) : void 0;
145657
145659
  }
145660
+ function getErrorNamespace({ endpointNamespace, error: error50, namespacedErrors }) {
145661
+ if (namespacedErrors) {
145662
+ if (error50.namespace != null) {
145663
+ return error50.namespace;
145664
+ }
145665
+ const referenced = unwrapReferencedSchema(error50.schema);
145666
+ if (referenced?.namespace != null) {
145667
+ return referenced.namespace;
145668
+ }
145669
+ }
145670
+ return endpointNamespace;
145671
+ }
145672
+ function getErrorConflictNamespace({ endpointNamespace, error: error50, namespacedErrors }) {
145673
+ if (!namespacedErrors) {
145674
+ return void 0;
145675
+ }
145676
+ return getErrorNamespace({ endpointNamespace, error: error50, namespacedErrors });
145677
+ }
145678
+ function unwrapReferencedSchema(schema) {
145679
+ if (schema == null) {
145680
+ return void 0;
145681
+ }
145682
+ switch (schema.type) {
145683
+ case "reference":
145684
+ return schema;
145685
+ case "nullable":
145686
+ case "optional":
145687
+ return unwrapReferencedSchema(schema.value);
145688
+ default:
145689
+ return void 0;
145690
+ }
145691
+ }
145658
145692
  var init_getNamespaceFromGroup = __esm({
145659
145693
  "../api-importers/openapi/openapi-ir-to-fern/lib/utils/getNamespaceFromGroup.js"() {
145660
145694
  "use strict";
@@ -147362,9 +147396,14 @@ function buildEndpoint({ endpoint: endpoint3, declarationFile, context: context3
147362
147396
  const errorDeclaration = {
147363
147397
  "status-code": parseInt(statusCode)
147364
147398
  };
147399
+ const errorNamespace = getErrorNamespace({
147400
+ endpointNamespace: maybeEndpointNamespace,
147401
+ error: httpError,
147402
+ namespacedErrors: context3.options.namespacedErrors
147403
+ });
147365
147404
  const errorDeclarationFile = resolveLocationWithNamespace({
147366
147405
  location: ERROR_DECLARATIONS_FILENAME,
147367
- namespaceOverride: maybeEndpointNamespace
147406
+ namespaceOverride: errorNamespace
147368
147407
  });
147369
147408
  if (httpError.schema != null) {
147370
147409
  const typeReference2 = buildTypeReference({
@@ -147372,7 +147411,7 @@ function buildEndpoint({ endpoint: endpoint3, declarationFile, context: context3
147372
147411
  context: context3,
147373
147412
  fileContainingReference: errorDeclarationFile,
147374
147413
  declarationFile: errorDeclarationFile,
147375
- namespace: maybeEndpointNamespace,
147414
+ namespace: errorNamespace,
147376
147415
  declarationDepth: 0
147377
147416
  });
147378
147417
  errorDeclaration.type = getTypeFromTypeReference(typeReference2);
@@ -147380,7 +147419,14 @@ function buildEndpoint({ endpoint: endpoint3, declarationFile, context: context3
147380
147419
  }
147381
147420
  context3.builder.addError(errorDeclarationFile, {
147382
147421
  name: errorName,
147383
- schema: context3.isErrorUnknownSchema(parseInt(statusCode)) ? { ...errorDeclaration, type: "unknown" } : errorDeclaration
147422
+ schema: context3.isErrorUnknownSchema({
147423
+ statusCode: parseInt(statusCode),
147424
+ namespace: getErrorConflictNamespace({
147425
+ endpointNamespace: maybeEndpointNamespace,
147426
+ error: httpError,
147427
+ namespacedErrors: context3.options.namespacedErrors
147428
+ })
147429
+ }) ? { ...errorDeclaration, type: "unknown" } : errorDeclaration
147384
147430
  });
147385
147431
  if (convertedEndpoint.errors == null) {
147386
147432
  convertedEndpoint.errors = [];
@@ -149305,6 +149351,9 @@ var init_lib14 = __esm({
149305
149351
  });
149306
149352
 
149307
149353
  // ../api-importers/openapi/openapi-ir-to-fern/lib/OpenApiIrConverterContext.js
149354
+ function getErrorKey({ statusCode, namespace }) {
149355
+ return namespace != null ? `${namespace}:${statusCode}` : `${statusCode}`;
149356
+ }
149308
149357
  var OpenApiIrConverterContext;
149309
149358
  var init_OpenApiIrConverterContext = __esm({
149310
149359
  "../api-importers/openapi/openapi-ir-to-fern/lib/OpenApiIrConverterContext.js"() {
@@ -149314,6 +149363,7 @@ var init_OpenApiIrConverterContext = __esm({
149314
149363
  init_lib13();
149315
149364
  init_ConvertOpenAPIOptions();
149316
149365
  init_State();
149366
+ init_getNamespaceFromGroup();
149317
149367
  OpenApiIrConverterContext = class {
149318
149368
  logger;
149319
149369
  taskContext;
@@ -149379,17 +149429,24 @@ var init_OpenApiIrConverterContext = __esm({
149379
149429
  if (ir3.title != null) {
149380
149430
  this.builder.setDisplayName({ displayName: ir3.title });
149381
149431
  }
149382
- const schemaByStatusCode = {};
149432
+ const schemaByErrorKey = {};
149383
149433
  if (!this.enableUniqueErrorsPerEndpoint) {
149384
149434
  for (const endpoint3 of ir3.endpoints) {
149435
+ const endpointNamespace = getEndpointNamespace(endpoint3.sdkName, endpoint3.namespace);
149385
149436
  for (const [statusCodeString, error50] of Object.entries(endpoint3.errors)) {
149386
149437
  const statusCode = parseInt(statusCodeString);
149387
- const existingSchema = schemaByStatusCode[statusCode];
149438
+ const namespace = getErrorConflictNamespace({
149439
+ endpointNamespace,
149440
+ error: error50,
149441
+ namespacedErrors: this.options.namespacedErrors
149442
+ });
149443
+ const key2 = getErrorKey({ statusCode, namespace });
149444
+ const existingSchema = schemaByErrorKey[key2];
149388
149445
  if (existingSchema == null && error50.schema != null) {
149389
- schemaByStatusCode[statusCode] = error50.schema;
149446
+ schemaByErrorKey[key2] = error50.schema;
149390
149447
  } else if (existingSchema != null && error50.schema != null && isSchemaEqual(existingSchema, error50.schema)) {
149391
149448
  } else {
149392
- this.unknownSchema.add(statusCode);
149449
+ this.unknownSchema.add(key2);
149393
149450
  }
149394
149451
  }
149395
149452
  }
@@ -149434,8 +149491,8 @@ var init_OpenApiIrConverterContext = __esm({
149434
149491
  /**
149435
149492
  * Is error an unknown schema
149436
149493
  */
149437
- isErrorUnknownSchema(statusCode) {
149438
- return this.unknownSchema.has(statusCode);
149494
+ isErrorUnknownSchema({ statusCode, namespace }) {
149495
+ return this.unknownSchema.has(getErrorKey({ statusCode, namespace }));
149439
149496
  }
149440
149497
  /**
149441
149498
  * Returns the current endpoint method being processed
@@ -152169,6 +152226,7 @@ var init_BaseOpenAPIWorkspace = __esm({
152169
152226
  defaultIntegerFormat;
152170
152227
  pathParameterOrder;
152171
152228
  coerceConstsTo;
152229
+ namespacedErrors;
152172
152230
  converter;
152173
152231
  constructor(args) {
152174
152232
  super(args);
@@ -152194,6 +152252,7 @@ var init_BaseOpenAPIWorkspace = __esm({
152194
152252
  this.defaultIntegerFormat = args.defaultIntegerFormat;
152195
152253
  this.pathParameterOrder = args.pathParameterOrder;
152196
152254
  this.coerceConstsTo = args.coerceConstsTo;
152255
+ this.namespacedErrors = args.namespacedErrors;
152197
152256
  this.converter = new FernDefinitionConverter(args);
152198
152257
  }
152199
152258
  async getDefinition({ context: context3, absoluteFilePath, relativePathToDependency }, settings) {
@@ -167060,13 +167119,15 @@ function markErrorSchemas({ responses, context: context3, source: source2, names
167060
167119
  context3.logger.warn(`No error name found for status code ${statusCode}`);
167061
167120
  continue;
167062
167121
  }
167122
+ const responseNamespace = getExtension(resolvedResponse, FernOpenAPIExtension.SDK_NAMESPACE);
167063
167123
  errors4[parsedStatusCode] = {
167064
167124
  statusCode: parsedStatusCode,
167065
167125
  nameOverride: void 0,
167066
167126
  generatedName: errorName,
167067
167127
  description: resolvedResponse.description,
167068
- schema: convertSchema2(mediaObject?.schema ?? {}, false, false, context3, [errorName, "Body"], source2, namespace),
167128
+ schema: convertSchema2(mediaObject?.schema ?? {}, false, false, context3, [errorName, "Body"], source2, responseNamespace ?? namespace),
167069
167129
  fullExamples: mediaObject?.examples,
167130
+ namespace: responseNamespace,
167070
167131
  source: source2
167071
167132
  };
167072
167133
  }
@@ -169148,7 +169209,8 @@ function generateIr({ openApi, taskContext, options: options2, source: source2,
169148
169209
  schema: convertSchemaWithExampleToSchema(error50.schema),
169149
169210
  description: error50.description,
169150
169211
  source: error50.source,
169151
- examples: examples2
169212
+ examples: examples2,
169213
+ namespace: error50.namespace
169152
169214
  };
169153
169215
  }),
169154
169216
  retries: endpointWithExample.retries,
@@ -200343,7 +200405,8 @@ var init_getAPIDefinitionSettings = __esm({
200343
200405
  disambiguateRequestNames: "disambiguateRequestNames",
200344
200406
  ignoreTags: "ignoreTags",
200345
200407
  respectParameterContent: "respectParameterContent",
200346
- respectPerSpecBasePath: "respectPerSpecBasePath"
200408
+ respectPerSpecBasePath: "respectPerSpecBasePath",
200409
+ namespacedErrors: "namespacedErrors"
200347
200410
  };
200348
200411
  }
200349
200412
  });
@@ -264966,7 +265029,8 @@ function parseOpenApiDefinitionSettingsSchema(settings) {
264966
265029
  disambiguateRequestNames: settings?.["disambiguate-request-names"],
264967
265030
  ignoreTags: settings?.["ignore-tags"],
264968
265031
  respectParameterContent: settings?.["respect-parameter-content"],
264969
- respectPerSpecBasePath: settings?.["respect-per-spec-base-path"]
265032
+ respectPerSpecBasePath: settings?.["respect-per-spec-base-path"],
265033
+ namespacedErrors: settings?.["namespaced-errors"]
264970
265034
  };
264971
265035
  }
264972
265036
  function parseAsyncApiDefinitionSettingsSchema(settings) {
@@ -265836,7 +265900,8 @@ var init_convertGeneratorsConfiguration = __esm({
265836
265900
  disambiguateRequestNames: void 0,
265837
265901
  ignoreTags: void 0,
265838
265902
  respectParameterContent: void 0,
265839
- respectPerSpecBasePath: void 0
265903
+ respectPerSpecBasePath: void 0,
265904
+ namespacedErrors: void 0
265840
265905
  };
265841
265906
  }
265842
265907
  });
@@ -374357,7 +374422,8 @@ var init_OSSWorkspace = __esm({
374357
374422
  inferDefaultEnvironment: collapseSpecBooleanSetting(specs, (s5) => s5?.inferDefaultEnvironment),
374358
374423
  defaultIntegerFormat: specs[0]?.settings?.defaultIntegerFormat,
374359
374424
  pathParameterOrder: specs[0]?.settings?.pathParameterOrder,
374360
- coerceConstsTo: specs[0]?.settings?.coerceConstsTo
374425
+ coerceConstsTo: specs[0]?.settings?.coerceConstsTo,
374426
+ namespacedErrors: specs.some((spec) => spec.settings?.namespacedErrors)
374361
374427
  });
374362
374428
  this.specs = specs;
374363
374429
  this.allSpecs = allSpecs;
@@ -696945,7 +697011,13 @@ var OpenApiSettingsSchema2 = BaseApiSettingsSchema2.extend({
696945
697011
  * If true, apply each OpenAPI document's plain `x-fern-base-path` to that document's endpoints.
696946
697012
  * Defaults to false.
696947
697013
  */
696948
- "respect-per-spec-base-path": external_exports.boolean().optional()
697014
+ "respect-per-spec-base-path": external_exports.boolean().optional(),
697015
+ /**
697016
+ * If true, an error whose body schema carries `x-fern-sdk-namespace` is declared in, and shared
697017
+ * within, that namespace instead of the endpoint's namespace.
697018
+ * Defaults to false.
697019
+ */
697020
+ "namespaced-errors": external_exports.boolean().optional()
696949
697021
  });
696950
697022
 
696951
697023
  // ../config/lib/schemas/specs/OpenApiSpecSchema.js
@@ -705536,7 +705608,7 @@ var AccessTokenPosthogManager = class {
705536
705608
  properties: {
705537
705609
  ...event,
705538
705610
  ...event.properties,
705539
- version: "5.113.3",
705611
+ version: "5.114.0",
705540
705612
  usingAccessToken: true,
705541
705613
  ...getRunIdProperties()
705542
705614
  }
@@ -705602,7 +705674,7 @@ var UserPosthogManager = class {
705602
705674
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
705603
705675
  event: "CLI",
705604
705676
  properties: {
705605
- version: "5.113.3",
705677
+ version: "5.114.0",
705606
705678
  ...event,
705607
705679
  ...event.properties,
705608
705680
  usingAccessToken: false,
@@ -712421,7 +712493,8 @@ var LegacyApiSpecAdapter = class {
712421
712493
  disambiguateRequestNames: settings["disambiguate-request-names"],
712422
712494
  ignoreTags: settings["ignore-tags"],
712423
712495
  respectParameterContent: settings["respect-parameter-content"],
712424
- respectPerSpecBasePath: settings["respect-per-spec-base-path"]
712496
+ respectPerSpecBasePath: settings["respect-per-spec-base-path"],
712497
+ namespacedErrors: settings["namespaced-errors"]
712425
712498
  };
712426
712499
  const hasSettings = Object.values(result).some((v3) => v3 != null);
712427
712500
  return hasSettings ? result : void 0;
@@ -885358,6 +885431,7 @@ var SETTINGS_KEY_MAP = {
885358
885431
  "prefer-undiscriminated-unions-with-literals": "preferUndiscriminatedUnionsWithLiterals",
885359
885432
  "object-query-parameters": "objectQueryParameters",
885360
885433
  "respect-readonly-schemas": "respectReadonlySchemas",
885434
+ "namespaced-errors": "namespacedErrors",
885361
885435
  "use-read-variant-for-responses": "useReadVariantForResponses",
885362
885436
  "respect-forward-compatible-enums": "respectForwardCompatibleEnums",
885363
885437
  "respect-optional-request-body": "respectOptionalRequestBody",
@@ -887278,7 +887352,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
887278
887352
  var LOGS_FOLDER_NAME = "logs";
887279
887353
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
887280
887354
  function getCliSource() {
887281
- const version7 = "5.113.3";
887355
+ const version7 = "5.114.0";
887282
887356
  return `cli@${version7}`;
887283
887357
  }
887284
887358
  var DebugLogger = class {
@@ -914591,7 +914665,7 @@ var LegacyDocsPublisher = class {
914591
914665
  previewId,
914592
914666
  disableTemplates: void 0,
914593
914667
  skipUpload,
914594
- cliVersion: "5.113.3",
914668
+ cliVersion: "5.114.0",
914595
914669
  loginCommand: "fern auth login"
914596
914670
  });
914597
914671
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -981847,7 +981921,7 @@ function getAutomationContextFromEnv() {
981847
981921
  config_branch: process.env.FERN_CONFIG_BRANCH,
981848
981922
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
981849
981923
  trigger: process.env.GITHUB_EVENT_NAME,
981850
- cli_version: "5.113.3"
981924
+ cli_version: "5.114.0"
981851
981925
  };
981852
981926
  }
981853
981927
  function isAutomationMode() {
@@ -982679,7 +982753,7 @@ var CliContext = class _CliContext {
982679
982753
  if (false) {
982680
982754
  this.logger.error("CLI_VERSION is not defined");
982681
982755
  }
982682
- return "5.113.3";
982756
+ return "5.114.0";
982683
982757
  }
982684
982758
  getCliName() {
982685
982759
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.113.3",
2
+ "version": "5.114.0",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",