fern-api 0.19.0-rc4 → 0.19.0-rc6

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 +164 -128
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -103059,7 +103059,7 @@ var require_index_cjs = __commonJS({
103059
103059
  throw new Error(message);
103060
103060
  }
103061
103061
  }
103062
- function removeTrailingSlash(url) {
103062
+ function removeTrailingSlash2(url) {
103063
103063
  return url === null || url === void 0 ? void 0 : url.replace(/\/+$/, "");
103064
103064
  }
103065
103065
  function retriable(fn2, props) {
@@ -103590,7 +103590,7 @@ var require_index_cjs = __commonJS({
103590
103590
  this._events = new SimpleEventEmitter();
103591
103591
  assert3(apiKey, "You must pass your PostHog project's api key.");
103592
103592
  this.apiKey = apiKey;
103593
- this.host = removeTrailingSlash((options === null || options === void 0 ? void 0 : options.host) || "https://app.posthog.com");
103593
+ this.host = removeTrailingSlash2((options === null || options === void 0 ? void 0 : options.host) || "https://app.posthog.com");
103594
103594
  this.flushAt = (options === null || options === void 0 ? void 0 : options.flushAt) ? Math.max(options === null || options === void 0 ? void 0 : options.flushAt, 1) : 20;
103595
103595
  this.flushInterval = (_a2 = options === null || options === void 0 ? void 0 : options.flushInterval) !== null && _a2 !== void 0 ? _a2 : 1e4;
103596
103596
  this.captureMode = (options === null || options === void 0 ? void 0 : options.captureMode) || "form";
@@ -357355,7 +357355,8 @@ var init_GlobalHeader2 = __esm({
357355
357355
  header: schemas_exports4.string(),
357356
357356
  name: schemas_exports4.string().optional(),
357357
357357
  optional: schemas_exports4.boolean().optional(),
357358
- env: schemas_exports4.string().optional()
357358
+ env: schemas_exports4.string().optional(),
357359
+ schema: schemas_exports4.lazy(async () => (await Promise.resolve().then(() => (init_serialization3(), serialization_exports3))).Schema).optional()
357359
357360
  });
357360
357361
  }
357361
357362
  });
@@ -799137,7 +799138,7 @@ var AccessTokenPosthogManager = class {
799137
799138
  properties: {
799138
799139
  ...event,
799139
799140
  ...event.properties,
799140
- version: "0.19.0-rc4",
799141
+ version: "0.19.0-rc6",
799141
799142
  usingAccessToken: true
799142
799143
  }
799143
799144
  });
@@ -799199,7 +799200,7 @@ var UserPosthogManager = class {
799199
799200
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
799200
799201
  event: "CLI",
799201
799202
  properties: {
799202
- version: "0.19.0-rc4",
799203
+ version: "0.19.0-rc6",
799203
799204
  ...event,
799204
799205
  ...event.properties
799205
799206
  }
@@ -812057,11 +812058,20 @@ function getFernEnum(schema2) {
812057
812058
  // pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/v3/extensions/getFernTypeExtension.js
812058
812059
  function getFernTypeExtension({ nameOverride, generatedName, schema: schema2, description }) {
812059
812060
  const groupName = getExtension(schema2, FernOpenAPIExtension.SDK_GROUP_NAME);
812060
- const typeDefinition = getExtension(schema2, FernOpenAPIExtension.TYPE_DEFINITION);
812061
- if (typeDefinition == null) {
812061
+ const fernType = getExtension(schema2, FernOpenAPIExtension.TYPE_DEFINITION);
812062
+ if (fernType == null) {
812062
812063
  return;
812063
812064
  }
812064
- return recursivelyVisitRawTypeReference(typeDefinition, {
812065
+ return getSchemaFromFernType({
812066
+ fernType,
812067
+ nameOverride,
812068
+ generatedName,
812069
+ description,
812070
+ groupName
812071
+ });
812072
+ }
812073
+ function getSchemaFromFernType({ fernType, nameOverride, generatedName, description, groupName }) {
812074
+ return recursivelyVisitRawTypeReference(fernType, {
812065
812075
  primitive: (primitive) => {
812066
812076
  switch (primitive) {
812067
812077
  case "BASE_64":
@@ -816434,7 +816444,21 @@ function convertToError({ statusCode, errorBodyCollector, context }) {
816434
816444
 
816435
816445
  // pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/v3/extensions/getGlobalHeaders.js
816436
816446
  function getGlobalHeaders(document4) {
816437
- return getExtension(document4, FernOpenAPIExtension.FERN_GLOBAL_HEADERS);
816447
+ const globalHeaders = getExtension(document4, FernOpenAPIExtension.FERN_GLOBAL_HEADERS);
816448
+ const result2 = [];
816449
+ for (const header of globalHeaders ?? []) {
816450
+ result2.push({
816451
+ ...header,
816452
+ schema: header.type != null ? getSchemaFromFernType({
816453
+ fernType: header.type,
816454
+ description: void 0,
816455
+ generatedName: header.name ?? header.header,
816456
+ groupName: void 0,
816457
+ nameOverride: void 0
816458
+ }) : void 0
816459
+ });
816460
+ }
816461
+ return result2;
816438
816462
  }
816439
816463
 
816440
816464
  // pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/v3/extensions/getVariableDefinitions.js
@@ -817404,107 +817428,6 @@ function buildEnvironments(context) {
817404
817428
  }
817405
817429
  }
817406
817430
 
817407
- // pnp:/home/circleci/project/packages/cli/openapi-ir-to-fern/lib/utils/getEndpointLocation.js
817408
- function getEndpointLocation(endpoint) {
817409
- if (endpoint.sdkName != null) {
817410
- const filename = endpoint.sdkName.groupName.length === 0 ? "__package__.yml" : `${endpoint.sdkName.groupName.map((part) => camelCase_default(part)).join("/")}.yml`;
817411
- return {
817412
- file: RelativeFilePath.of(filename),
817413
- endpointId: endpoint.sdkName.methodName
817414
- };
817415
- }
817416
- const tag = endpoint.tags[0];
817417
- const operationId = endpoint.operationId;
817418
- if (operationId == null) {
817419
- if (tag != null) {
817420
- return {
817421
- file: RelativeFilePath.of(`${camelCase_default(tag)}.yml`),
817422
- endpointId: endpoint.summary != null ? camelCase_default(endpoint.summary) : camelCase_default(`${endpoint.method}_${endpoint.path.split("/").join("_")}`)
817423
- };
817424
- }
817425
- if (endpoint.summary != null) {
817426
- return {
817427
- file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
817428
- endpointId: camelCase_default(endpoint.summary)
817429
- };
817430
- }
817431
- return {
817432
- file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
817433
- endpointId: camelCase_default(`${endpoint.method}_${endpoint.path.split("/").join("_")}`)
817434
- };
817435
- }
817436
- if (tag == null) {
817437
- return {
817438
- file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
817439
- endpointId: operationId
817440
- };
817441
- }
817442
- const tagTokens = tokenizeString(tag);
817443
- const operationIdTokens = tokenizeString(operationId);
817444
- if (isEqual_default(tagTokens, operationIdTokens)) {
817445
- return {
817446
- file: RelativeFilePath.of("__package__.yml"),
817447
- endpointId: tag
817448
- };
817449
- }
817450
- const fastapiEndpointLocation = maybeGetFastApiEndpointLocation({
817451
- operationId,
817452
- tag,
817453
- path: endpoint.path,
817454
- method: endpoint.method
817455
- });
817456
- if (fastapiEndpointLocation != null) {
817457
- return fastapiEndpointLocation;
817458
- }
817459
- const fileParts = [];
817460
- for (let i2 = 0; i2 < tagTokens.length; ++i2) {
817461
- const tagElement = tagTokens[i2];
817462
- if (tagElement != null && tagElement === operationIdTokens[i2]) {
817463
- fileParts.push(tagElement);
817464
- } else {
817465
- const camelCasedTag = camelCase_default(tag);
817466
- return {
817467
- file: RelativeFilePath.of(`${camelCasedTag}.yml`),
817468
- endpointId: operationId,
817469
- tag
817470
- };
817471
- }
817472
- }
817473
- if (fileParts.length >= operationIdTokens.length) {
817474
- throw new Error(`Cannot get file for endpoint ${JSON.stringify(endpoint)}`);
817475
- }
817476
- return {
817477
- file: RelativeFilePath.of(camelCase_default(fileParts.join("_")) + ".yml"),
817478
- endpointId: camelCase_default(operationIdTokens.slice(fileParts.length).join("_")),
817479
- tag
817480
- };
817481
- }
817482
- function tokenizeString(input) {
817483
- let tokens;
817484
- if (/^[a-z]+(?:[A-Z][a-z]+)*$/.test(input)) {
817485
- tokens = input.split(/(?=[A-Z])/);
817486
- } else {
817487
- tokens = input.split(/[^a-zA-Z0-9]+/);
817488
- }
817489
- tokens = tokens.map((token) => token.toLowerCase());
817490
- tokens = compact_default(tokens);
817491
- return tokens;
817492
- }
817493
- var NON_ALPHANUMERIC_EXCEPT_BRACES_REGEX = new RegExp("[^a-zA-Z0-9{}]+");
817494
- var BRACE_REGEX = new RegExp("[{}]", "g");
817495
- function maybeGetFastApiEndpointLocation({ operationId, tag, path: path33, method: method2 }) {
817496
- const pathSegment = path33.split(NON_ALPHANUMERIC_EXCEPT_BRACES_REGEX).join("_").replaceAll(BRACE_REGEX, "_");
817497
- const operationIdSuffix = `${pathSegment}_${method2.toLowerCase()}`;
817498
- if (operationId.endsWith(operationIdSuffix)) {
817499
- return {
817500
- file: RelativeFilePath.of(camelCase_default(tag) + ".yml"),
817501
- endpointId: camelCase_default(operationId.slice(0, -1 * operationIdSuffix.length)),
817502
- tag
817503
- };
817504
- }
817505
- return void 0;
817506
- }
817507
-
817508
817431
  // pnp:/home/circleci/project/packages/cli/openapi-ir-to-fern/lib/utils/wrapTypeReferenceAsOptional.js
817509
817432
  function wrapTypeReferenceAsOptional(typeReference) {
817510
817433
  const type2 = getTypeFromTypeReference(typeReference);
@@ -817532,17 +817455,22 @@ var GLOBAL_HEADER_PERCENTAGE_THRESHOLD = 0.75;
817532
817455
  var HEADERS_TO_IGNORE = new Set(...["Authorization"]);
817533
817456
  function buildGlobalHeaders(context) {
817534
817457
  var _a2;
817458
+ const predefinedGlobalHeaders = new Map((_a2 = context.ir.globalHeaders) == null ? void 0 : _a2.map((header) => [header.header, header]));
817535
817459
  const globalHeaders = {};
817536
817460
  for (const endpoint of context.ir.endpoints) {
817537
817461
  for (const header of endpoint.headers) {
817538
817462
  if (HEADERS_TO_IGNORE.has(header.name)) {
817539
817463
  continue;
817540
817464
  }
817541
- const { file } = getEndpointLocation(endpoint);
817542
817465
  let headerWithCount = globalHeaders[header.name];
817543
817466
  if (headerWithCount == null) {
817467
+ const predefinedHeader = predefinedGlobalHeaders.get(header.name);
817544
817468
  const convertedHeader = buildHeader({
817545
- header,
817469
+ header: {
817470
+ ...header,
817471
+ schema: (predefinedHeader == null ? void 0 : predefinedHeader.schema) ?? header.schema,
817472
+ name: (predefinedHeader == null ? void 0 : predefinedHeader.name) ?? header.name
817473
+ },
817546
817474
  fileContainingReference: RelativeFilePath.of(ROOT_API_FILENAME),
817547
817475
  context
817548
817476
  });
@@ -817553,21 +817481,24 @@ function buildGlobalHeaders(context) {
817553
817481
  }
817554
817482
  }
817555
817483
  const globalHeaderThreshold = context.ir.endpoints.length * GLOBAL_HEADER_PERCENTAGE_THRESHOLD;
817556
- const predefinedGlobalHeaders = new Map((_a2 = context.ir.globalHeaders) == null ? void 0 : _a2.map((header) => [header.header, header]));
817557
817484
  for (const [headerName, header] of Object.entries(globalHeaders)) {
817558
817485
  const predefinedHeader = predefinedGlobalHeaders.get(headerName);
817559
817486
  let isRequired = header.count === context.ir.endpoints.length;
817560
817487
  const isOptional = header.count >= globalHeaderThreshold;
817561
- if (predefinedHeader !== void 0) {
817488
+ if (predefinedHeader != null) {
817562
817489
  isRequired = isRequired && predefinedHeader.optional !== true || predefinedHeader.optional === false;
817563
- const convertedHeaderSchema = typeof header.schema === "string" ? header.schema : {
817564
- ...header.schema,
817565
- name: predefinedHeader.name ?? header.schema.name,
817566
- env: predefinedHeader.env ?? header.schema.env
817567
- };
817490
+ let schema2;
817491
+ if (typeof header.schema === "string") {
817492
+ schema2 = header.schema;
817493
+ } else {
817494
+ schema2 = {
817495
+ ...header.schema,
817496
+ env: predefinedHeader.env ?? header.schema.env
817497
+ };
817498
+ }
817568
817499
  context.builder.addGlobalHeader({
817569
817500
  name: headerName,
817570
- schema: isRequired ? convertedHeaderSchema : wrapTypeReferenceAsOptional(convertedHeaderSchema)
817501
+ schema: isRequired ? schema2 : wrapTypeReferenceAsOptional(schema2)
817571
817502
  });
817572
817503
  } else if (isRequired) {
817573
817504
  context.builder.addGlobalHeader({
@@ -818093,6 +818024,107 @@ function getRequest({ declarationFile, context, request, requestNameOverride, ge
818093
818024
  }
818094
818025
  }
818095
818026
 
818027
+ // pnp:/home/circleci/project/packages/cli/openapi-ir-to-fern/lib/utils/getEndpointLocation.js
818028
+ function getEndpointLocation(endpoint) {
818029
+ if (endpoint.sdkName != null) {
818030
+ const filename = endpoint.sdkName.groupName.length === 0 ? "__package__.yml" : `${endpoint.sdkName.groupName.map((part) => camelCase_default(part)).join("/")}.yml`;
818031
+ return {
818032
+ file: RelativeFilePath.of(filename),
818033
+ endpointId: endpoint.sdkName.methodName
818034
+ };
818035
+ }
818036
+ const tag = endpoint.tags[0];
818037
+ const operationId = endpoint.operationId;
818038
+ if (operationId == null) {
818039
+ if (tag != null) {
818040
+ return {
818041
+ file: RelativeFilePath.of(`${camelCase_default(tag)}.yml`),
818042
+ endpointId: endpoint.summary != null ? camelCase_default(endpoint.summary) : camelCase_default(`${endpoint.method}_${endpoint.path.split("/").join("_")}`)
818043
+ };
818044
+ }
818045
+ if (endpoint.summary != null) {
818046
+ return {
818047
+ file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
818048
+ endpointId: camelCase_default(endpoint.summary)
818049
+ };
818050
+ }
818051
+ return {
818052
+ file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
818053
+ endpointId: camelCase_default(`${endpoint.method}_${endpoint.path.split("/").join("_")}`)
818054
+ };
818055
+ }
818056
+ if (tag == null) {
818057
+ return {
818058
+ file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
818059
+ endpointId: operationId
818060
+ };
818061
+ }
818062
+ const tagTokens = tokenizeString(tag);
818063
+ const operationIdTokens = tokenizeString(operationId);
818064
+ if (isEqual_default(tagTokens, operationIdTokens)) {
818065
+ return {
818066
+ file: RelativeFilePath.of("__package__.yml"),
818067
+ endpointId: tag
818068
+ };
818069
+ }
818070
+ const fastapiEndpointLocation = maybeGetFastApiEndpointLocation({
818071
+ operationId,
818072
+ tag,
818073
+ path: endpoint.path,
818074
+ method: endpoint.method
818075
+ });
818076
+ if (fastapiEndpointLocation != null) {
818077
+ return fastapiEndpointLocation;
818078
+ }
818079
+ const fileParts = [];
818080
+ for (let i2 = 0; i2 < tagTokens.length; ++i2) {
818081
+ const tagElement = tagTokens[i2];
818082
+ if (tagElement != null && tagElement === operationIdTokens[i2]) {
818083
+ fileParts.push(tagElement);
818084
+ } else {
818085
+ const camelCasedTag = camelCase_default(tag);
818086
+ return {
818087
+ file: RelativeFilePath.of(`${camelCasedTag}.yml`),
818088
+ endpointId: operationId,
818089
+ tag
818090
+ };
818091
+ }
818092
+ }
818093
+ if (fileParts.length >= operationIdTokens.length) {
818094
+ throw new Error(`Cannot get file for endpoint ${JSON.stringify(endpoint)}`);
818095
+ }
818096
+ return {
818097
+ file: RelativeFilePath.of(camelCase_default(fileParts.join("_")) + ".yml"),
818098
+ endpointId: camelCase_default(operationIdTokens.slice(fileParts.length).join("_")),
818099
+ tag
818100
+ };
818101
+ }
818102
+ function tokenizeString(input) {
818103
+ let tokens;
818104
+ if (/^[a-z]+(?:[A-Z][a-z]+)*$/.test(input)) {
818105
+ tokens = input.split(/(?=[A-Z])/);
818106
+ } else {
818107
+ tokens = input.split(/[^a-zA-Z0-9]+/);
818108
+ }
818109
+ tokens = tokens.map((token) => token.toLowerCase());
818110
+ tokens = compact_default(tokens);
818111
+ return tokens;
818112
+ }
818113
+ var NON_ALPHANUMERIC_EXCEPT_BRACES_REGEX = new RegExp("[^a-zA-Z0-9{}]+");
818114
+ var BRACE_REGEX = new RegExp("[{}]", "g");
818115
+ function maybeGetFastApiEndpointLocation({ operationId, tag, path: path33, method: method2 }) {
818116
+ const pathSegment = path33.split(NON_ALPHANUMERIC_EXCEPT_BRACES_REGEX).join("_").replaceAll(BRACE_REGEX, "_");
818117
+ const operationIdSuffix = `${pathSegment}_${method2.toLowerCase()}`;
818118
+ if (operationId.endsWith(operationIdSuffix)) {
818119
+ return {
818120
+ file: RelativeFilePath.of(camelCase_default(tag) + ".yml"),
818121
+ endpointId: camelCase_default(operationId.slice(0, -1 * operationIdSuffix.length)),
818122
+ tag
818123
+ };
818124
+ }
818125
+ return void 0;
818126
+ }
818127
+
818096
818128
  // pnp:/home/circleci/project/packages/cli/openapi-ir-to-fern/lib/buildServices.js
818097
818129
  function buildServices(context) {
818098
818130
  const sdkGroups = /* @__PURE__ */ new Set();
@@ -825914,10 +825946,10 @@ var CliContext = class {
825914
825946
  return "fern-api";
825915
825947
  }
825916
825948
  getPackageVersion() {
825917
- if ("0.19.0-rc4" == null) {
825949
+ if ("0.19.0-rc6" == null) {
825918
825950
  this.logger.error("CLI_VERSION is not defined");
825919
825951
  }
825920
- return "0.19.0-rc4";
825952
+ return "0.19.0-rc6";
825921
825953
  }
825922
825954
  getCliName() {
825923
825955
  if ("fern" == null) {
@@ -827235,7 +827267,8 @@ var RESERVED_KEYWORDS = {
827235
827267
  "float",
827236
827268
  "int",
827237
827269
  "complex",
827238
- "self"
827270
+ "self",
827271
+ "all"
827239
827272
  ]),
827240
827273
  [GenerationLanguage.GO]: /* @__PURE__ */ new Set([
827241
827274
  "break",
@@ -830281,7 +830314,7 @@ function convertSingleBaseUrlEnvironments({ environments, casingsGenerator }) {
830281
830314
  docs: typeof singleBaseUrlEnvironment === "string" ? void 0 : singleBaseUrlEnvironment.docs,
830282
830315
  id: environmentName,
830283
830316
  name: casingsGenerator.generateName(environmentName),
830284
- url: typeof singleBaseUrlEnvironment === "string" ? singleBaseUrlEnvironment : singleBaseUrlEnvironment.url
830317
+ url: removeTrailingSlash(typeof singleBaseUrlEnvironment === "string" ? singleBaseUrlEnvironment : singleBaseUrlEnvironment.url)
830285
830318
  }),
830286
830319
  multipleBaseUrls: () => {
830287
830320
  throw new Error(`Environment ${environmentName} has multiple base URLs`);
@@ -830300,7 +830333,7 @@ function convertMultipleBaseUrlEnvironments({ baseUrls, environments, casingsGen
830300
830333
  docs: multipleBaseUrlsEnvironment.docs,
830301
830334
  id: environmentName,
830302
830335
  name: casingsGenerator.generateName(environmentName),
830303
- urls: multipleBaseUrlsEnvironment.urls
830336
+ urls: mapValues_default(multipleBaseUrlsEnvironment.urls, (url) => removeTrailingSlash(url))
830304
830337
  }),
830305
830338
  singleBaseUrl: () => {
830306
830339
  throw new Error(`Environment ${environmentName} does not have multiple base URLs`);
@@ -830308,6 +830341,9 @@ function convertMultipleBaseUrlEnvironments({ baseUrls, environments, casingsGen
830308
830341
  }))
830309
830342
  };
830310
830343
  }
830344
+ function removeTrailingSlash(url) {
830345
+ return url.endsWith("/") ? url.slice(0, -1) : url;
830346
+ }
830311
830347
 
830312
830348
  // pnp:/home/circleci/project/packages/cli/generation/ir-generator/lib/converters/convertErrorDeclaration.js
830313
830349
  function convertErrorDeclaration({ errorName, errorDeclaration, file }) {
@@ -839347,9 +839383,9 @@ var V35_TO_V34_MIGRATION = {
839347
839383
  [GeneratorName.STOPLIGHT]: GeneratorWasNeverUpdatedToConsumeNewIR,
839348
839384
  [GeneratorName.POSTMAN]: GeneratorWasNeverUpdatedToConsumeNewIR,
839349
839385
  [GeneratorName.PYTHON_SDK]: "0.11.6",
839350
- [GeneratorName.GO_FIBER]: GeneratorWasNeverUpdatedToConsumeNewIR,
839351
- [GeneratorName.GO_MODEL]: GeneratorWasNeverUpdatedToConsumeNewIR,
839352
- [GeneratorName.GO_SDK]: GeneratorWasNeverUpdatedToConsumeNewIR,
839386
+ [GeneratorName.GO_FIBER]: "0.18.0",
839387
+ [GeneratorName.GO_MODEL]: "0.18.0",
839388
+ [GeneratorName.GO_SDK]: "0.18.0",
839353
839389
  [GeneratorName.RUBY_MODEL]: GeneratorWasNeverUpdatedToConsumeNewIR,
839354
839390
  [GeneratorName.RUBY_SDK]: GeneratorWasNeverUpdatedToConsumeNewIR,
839355
839391
  [GeneratorName.CSHARP_MODEL]: GeneratorWasNeverUpdatedToConsumeNewIR,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.19.0-rc4",
3
+ "version": "0.19.0-rc6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",