fern-api 0.19.0-rc3 → 0.19.0-rc4

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 +114 -106
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -799137,7 +799137,7 @@ var AccessTokenPosthogManager = class {
799137
799137
  properties: {
799138
799138
  ...event,
799139
799139
  ...event.properties,
799140
- version: "0.19.0-rc3",
799140
+ version: "0.19.0-rc4",
799141
799141
  usingAccessToken: true
799142
799142
  }
799143
799143
  });
@@ -799199,7 +799199,7 @@ var UserPosthogManager = class {
799199
799199
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
799200
799200
  event: "CLI",
799201
799201
  properties: {
799202
- version: "0.19.0-rc3",
799202
+ version: "0.19.0-rc4",
799203
799203
  ...event,
799204
799204
  ...event.properties
799205
799205
  }
@@ -817404,6 +817404,107 @@ function buildEnvironments(context) {
817404
817404
  }
817405
817405
  }
817406
817406
 
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
+
817407
817508
  // pnp:/home/circleci/project/packages/cli/openapi-ir-to-fern/lib/utils/wrapTypeReferenceAsOptional.js
817408
817509
  function wrapTypeReferenceAsOptional(typeReference) {
817409
817510
  const type2 = getTypeFromTypeReference(typeReference);
@@ -817437,11 +817538,12 @@ function buildGlobalHeaders(context) {
817437
817538
  if (HEADERS_TO_IGNORE.has(header.name)) {
817438
817539
  continue;
817439
817540
  }
817541
+ const { file } = getEndpointLocation(endpoint);
817440
817542
  let headerWithCount = globalHeaders[header.name];
817441
817543
  if (headerWithCount == null) {
817442
817544
  const convertedHeader = buildHeader({
817443
817545
  header,
817444
- fileContainingReference: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
817546
+ fileContainingReference: RelativeFilePath.of(ROOT_API_FILENAME),
817445
817547
  context
817446
817548
  });
817447
817549
  headerWithCount = new HeaderWithCount(convertedHeader);
@@ -817991,107 +818093,6 @@ function getRequest({ declarationFile, context, request, requestNameOverride, ge
817991
818093
  }
817992
818094
  }
817993
818095
 
817994
- // pnp:/home/circleci/project/packages/cli/openapi-ir-to-fern/lib/utils/getEndpointLocation.js
817995
- function getEndpointLocation(endpoint) {
817996
- if (endpoint.sdkName != null) {
817997
- const filename = endpoint.sdkName.groupName.length === 0 ? "__package__.yml" : `${endpoint.sdkName.groupName.map((part) => camelCase_default(part)).join("/")}.yml`;
817998
- return {
817999
- file: RelativeFilePath.of(filename),
818000
- endpointId: endpoint.sdkName.methodName
818001
- };
818002
- }
818003
- const tag = endpoint.tags[0];
818004
- const operationId = endpoint.operationId;
818005
- if (operationId == null) {
818006
- if (tag != null) {
818007
- return {
818008
- file: RelativeFilePath.of(`${camelCase_default(tag)}.yml`),
818009
- endpointId: endpoint.summary != null ? camelCase_default(endpoint.summary) : camelCase_default(`${endpoint.method}_${endpoint.path.split("/").join("_")}`)
818010
- };
818011
- }
818012
- if (endpoint.summary != null) {
818013
- return {
818014
- file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
818015
- endpointId: camelCase_default(endpoint.summary)
818016
- };
818017
- }
818018
- return {
818019
- file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
818020
- endpointId: camelCase_default(`${endpoint.method}_${endpoint.path.split("/").join("_")}`)
818021
- };
818022
- }
818023
- if (tag == null) {
818024
- return {
818025
- file: RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME),
818026
- endpointId: operationId
818027
- };
818028
- }
818029
- const tagTokens = tokenizeString(tag);
818030
- const operationIdTokens = tokenizeString(operationId);
818031
- if (isEqual_default(tagTokens, operationIdTokens)) {
818032
- return {
818033
- file: RelativeFilePath.of("__package__.yml"),
818034
- endpointId: tag
818035
- };
818036
- }
818037
- const fastapiEndpointLocation = maybeGetFastApiEndpointLocation({
818038
- operationId,
818039
- tag,
818040
- path: endpoint.path,
818041
- method: endpoint.method
818042
- });
818043
- if (fastapiEndpointLocation != null) {
818044
- return fastapiEndpointLocation;
818045
- }
818046
- const fileParts = [];
818047
- for (let i2 = 0; i2 < tagTokens.length; ++i2) {
818048
- const tagElement = tagTokens[i2];
818049
- if (tagElement != null && tagElement === operationIdTokens[i2]) {
818050
- fileParts.push(tagElement);
818051
- } else {
818052
- const camelCasedTag = camelCase_default(tag);
818053
- return {
818054
- file: RelativeFilePath.of(`${camelCasedTag}.yml`),
818055
- endpointId: operationId,
818056
- tag
818057
- };
818058
- }
818059
- }
818060
- if (fileParts.length >= operationIdTokens.length) {
818061
- throw new Error(`Cannot get file for endpoint ${JSON.stringify(endpoint)}`);
818062
- }
818063
- return {
818064
- file: RelativeFilePath.of(camelCase_default(fileParts.join("_")) + ".yml"),
818065
- endpointId: camelCase_default(operationIdTokens.slice(fileParts.length).join("_")),
818066
- tag
818067
- };
818068
- }
818069
- function tokenizeString(input) {
818070
- let tokens;
818071
- if (/^[a-z]+(?:[A-Z][a-z]+)*$/.test(input)) {
818072
- tokens = input.split(/(?=[A-Z])/);
818073
- } else {
818074
- tokens = input.split(/[^a-zA-Z0-9]+/);
818075
- }
818076
- tokens = tokens.map((token) => token.toLowerCase());
818077
- tokens = compact_default(tokens);
818078
- return tokens;
818079
- }
818080
- var NON_ALPHANUMERIC_EXCEPT_BRACES_REGEX = new RegExp("[^a-zA-Z0-9{}]+");
818081
- var BRACE_REGEX = new RegExp("[{}]", "g");
818082
- function maybeGetFastApiEndpointLocation({ operationId, tag, path: path33, method: method2 }) {
818083
- const pathSegment = path33.split(NON_ALPHANUMERIC_EXCEPT_BRACES_REGEX).join("_").replaceAll(BRACE_REGEX, "_");
818084
- const operationIdSuffix = `${pathSegment}_${method2.toLowerCase()}`;
818085
- if (operationId.endsWith(operationIdSuffix)) {
818086
- return {
818087
- file: RelativeFilePath.of(camelCase_default(tag) + ".yml"),
818088
- endpointId: camelCase_default(operationId.slice(0, -1 * operationIdSuffix.length)),
818089
- tag
818090
- };
818091
- }
818092
- return void 0;
818093
- }
818094
-
818095
818096
  // pnp:/home/circleci/project/packages/cli/openapi-ir-to-fern/lib/buildServices.js
818096
818097
  function buildServices(context) {
818097
818098
  const sdkGroups = /* @__PURE__ */ new Set();
@@ -818412,6 +818413,13 @@ var FernDefinitionBuilderImpl = class {
818412
818413
  return void 0;
818413
818414
  }
818414
818415
  const importPrefix = camelCase_default((0, import_path16.basename)(fileToImport, (0, import_path16.extname)(fileToImport)).replaceAll("__package__", "root"));
818416
+ if (file === RelativeFilePath.of(ROOT_API_FILENAME)) {
818417
+ if (this.rootApiFile.imports == null) {
818418
+ this.rootApiFile.imports = {};
818419
+ }
818420
+ this.rootApiFile.imports[importPrefix] = relative(dirname(AbsoluteFilePath.of(`/${file}`)), AbsoluteFilePath.of(`/${fileToImport}`));
818421
+ return importPrefix;
818422
+ }
818415
818423
  const fernFile = this.getOrCreateFile(file);
818416
818424
  if (fernFile.imports == null) {
818417
818425
  fernFile.imports = {};
@@ -825906,10 +825914,10 @@ var CliContext = class {
825906
825914
  return "fern-api";
825907
825915
  }
825908
825916
  getPackageVersion() {
825909
- if ("0.19.0-rc3" == null) {
825917
+ if ("0.19.0-rc4" == null) {
825910
825918
  this.logger.error("CLI_VERSION is not defined");
825911
825919
  }
825912
- return "0.19.0-rc3";
825920
+ return "0.19.0-rc4";
825913
825921
  }
825914
825922
  getCliName() {
825915
825923
  if ("fern" == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.19.0-rc3",
3
+ "version": "0.19.0-rc4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",