fern-api 0.19.23 → 0.19.24-rc2

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 +329 -24
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -827033,7 +827033,7 @@ var AccessTokenPosthogManager = class {
827033
827033
  properties: {
827034
827034
  ...event,
827035
827035
  ...event.properties,
827036
- version: "0.19.23",
827036
+ version: "0.19.24-rc2",
827037
827037
  usingAccessToken: true
827038
827038
  }
827039
827039
  });
@@ -827095,7 +827095,7 @@ var UserPosthogManager = class {
827095
827095
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
827096
827096
  event: "CLI",
827097
827097
  properties: {
827098
- version: "0.19.23",
827098
+ version: "0.19.24-rc2",
827099
827099
  ...event,
827100
827100
  ...event.properties
827101
827101
  }
@@ -839474,9 +839474,21 @@ function buildEnumTypeDeclaration(schema2) {
839474
839474
  if (schema2.description != null) {
839475
839475
  enumSchema.docs = schema2.description;
839476
839476
  }
839477
+ const uniqueEnumName = /* @__PURE__ */ new Set();
839478
+ const uniqueEnumSchema = {
839479
+ ...enumSchema,
839480
+ enum: []
839481
+ };
839482
+ for (const enumValue of enumSchema.enum) {
839483
+ const name2 = typeof enumValue === "string" ? enumValue : enumValue.name ?? enumValue.value;
839484
+ if (!uniqueEnumName.has(name2)) {
839485
+ uniqueEnumSchema.enum.push(enumValue);
839486
+ uniqueEnumName.add(name2);
839487
+ }
839488
+ }
839477
839489
  return {
839478
839490
  name: schema2.nameOverride ?? schema2.generatedName,
839479
- schema: enumSchema
839491
+ schema: uniqueEnumSchema
839480
839492
  };
839481
839493
  }
839482
839494
  function buildReferenceTypeDeclaration({ schema: schema2, context, declarationFile }) {
@@ -842499,6 +842511,191 @@ function enumContainsValue({ schema: schema2, value }) {
842499
842511
  }).includes(value);
842500
842512
  }
842501
842513
 
842514
+ // pnp:/home/circleci/project/packages/cli/openapi-parser/lib/schema/utils/convertSchemaToSchemaWithExample.js
842515
+ function convertSchemaToSchemaWithExample(schema2) {
842516
+ switch (schema2.type) {
842517
+ case "object":
842518
+ return SchemaWithExample.object({
842519
+ allOf: schema2.allOf,
842520
+ properties: schema2.properties.map((objectProperty) => convertToObjectProperty2(objectProperty)),
842521
+ allOfPropertyConflicts: schema2.allOfPropertyConflicts,
842522
+ description: schema2.description,
842523
+ generatedName: schema2.generatedName,
842524
+ nameOverride: schema2.nameOverride,
842525
+ groupName: schema2.groupName,
842526
+ fullExamples: void 0
842527
+ });
842528
+ case "array":
842529
+ return SchemaWithExample.array({
842530
+ description: schema2.description,
842531
+ value: convertSchemaToSchemaWithExample(schema2.value),
842532
+ generatedName: schema2.generatedName,
842533
+ nameOverride: schema2.nameOverride,
842534
+ groupName: schema2.groupName
842535
+ });
842536
+ case "enum":
842537
+ return SchemaWithExample.enum({
842538
+ description: schema2.description,
842539
+ generatedName: schema2.generatedName,
842540
+ nameOverride: schema2.nameOverride,
842541
+ values: schema2.values,
842542
+ groupName: schema2.groupName,
842543
+ example: void 0
842544
+ });
842545
+ case "literal":
842546
+ return SchemaWithExample.literal({
842547
+ description: schema2.description,
842548
+ value: schema2.value,
842549
+ generatedName: schema2.generatedName,
842550
+ nameOverride: schema2.nameOverride,
842551
+ groupName: schema2.groupName
842552
+ });
842553
+ case "nullable":
842554
+ return SchemaWithExample.nullable({
842555
+ generatedName: schema2.generatedName,
842556
+ nameOverride: schema2.nameOverride,
842557
+ description: schema2.description,
842558
+ value: convertSchemaToSchemaWithExample(schema2.value),
842559
+ groupName: schema2.groupName
842560
+ });
842561
+ case "optional":
842562
+ return SchemaWithExample.optional({
842563
+ generatedName: schema2.generatedName,
842564
+ nameOverride: schema2.nameOverride,
842565
+ description: schema2.description,
842566
+ value: convertSchemaToSchemaWithExample(schema2.value),
842567
+ groupName: schema2.groupName
842568
+ });
842569
+ case "primitive":
842570
+ return SchemaWithExample.primitive({
842571
+ description: schema2.description,
842572
+ schema: convertToPrimitiveSchemaValue2(schema2.schema),
842573
+ generatedName: schema2.generatedName,
842574
+ nameOverride: schema2.nameOverride,
842575
+ groupName: schema2.groupName
842576
+ });
842577
+ case "map":
842578
+ return SchemaWithExample.map({
842579
+ description: schema2.description,
842580
+ key: SchemaWithExample.primitive({
842581
+ description: schema2.key.description,
842582
+ schema: convertToPrimitiveSchemaValue2(schema2.key.schema),
842583
+ generatedName: schema2.key.generatedName,
842584
+ nameOverride: schema2.key.nameOverride,
842585
+ groupName: schema2.groupName
842586
+ }),
842587
+ value: convertSchemaToSchemaWithExample(schema2.value),
842588
+ generatedName: schema2.generatedName,
842589
+ nameOverride: schema2.nameOverride,
842590
+ groupName: schema2.groupName
842591
+ });
842592
+ case "reference":
842593
+ return SchemaWithExample.reference({
842594
+ description: schema2.description,
842595
+ generatedName: schema2.generatedName,
842596
+ nameOverride: schema2.nameOverride,
842597
+ schema: schema2.schema,
842598
+ groupName: schema2.groupName
842599
+ });
842600
+ case "oneOf":
842601
+ return SchemaWithExample.oneOf(convertToOneOf2(schema2.value));
842602
+ case "unknown":
842603
+ return SchemaWithExample.unknown({
842604
+ nameOverride: schema2.nameOverride,
842605
+ generatedName: schema2.generatedName,
842606
+ example: void 0,
842607
+ groupName: void 0,
842608
+ description: void 0
842609
+ });
842610
+ default:
842611
+ assertNever(schema2);
842612
+ }
842613
+ }
842614
+ function convertToOneOf2(oneOfSchema) {
842615
+ switch (oneOfSchema.type) {
842616
+ case "discriminated":
842617
+ return OneOfSchemaWithExample.discriminated({
842618
+ commonProperties: oneOfSchema.commonProperties.map((commonProperty) => {
842619
+ return {
842620
+ key: commonProperty.key,
842621
+ schema: convertSchemaToSchemaWithExample(commonProperty.schema)
842622
+ };
842623
+ }),
842624
+ description: oneOfSchema.description,
842625
+ discriminantProperty: oneOfSchema.discriminantProperty,
842626
+ generatedName: oneOfSchema.generatedName,
842627
+ nameOverride: oneOfSchema.nameOverride,
842628
+ schemas: Object.fromEntries(Object.entries(oneOfSchema.schemas).map(([discriminantValue, schemaWithExample]) => {
842629
+ return [discriminantValue, convertSchemaToSchemaWithExample(schemaWithExample)];
842630
+ })),
842631
+ groupName: oneOfSchema.groupName
842632
+ });
842633
+ case "undisciminated":
842634
+ return OneOfSchemaWithExample.undisciminated({
842635
+ description: oneOfSchema.description,
842636
+ generatedName: oneOfSchema.generatedName,
842637
+ nameOverride: oneOfSchema.nameOverride,
842638
+ schemas: oneOfSchema.schemas.map((oneOfSchema2) => convertSchemaToSchemaWithExample(oneOfSchema2)),
842639
+ groupName: oneOfSchema.groupName
842640
+ });
842641
+ default:
842642
+ assertNever(oneOfSchema);
842643
+ }
842644
+ }
842645
+ function convertToPrimitiveSchemaValue2(primitiveSchema) {
842646
+ switch (primitiveSchema.type) {
842647
+ case "string":
842648
+ return PrimitiveSchemaValueWithExample.string({
842649
+ maxLength: primitiveSchema.maxLength,
842650
+ minLength: primitiveSchema.minLength,
842651
+ example: void 0
842652
+ });
842653
+ case "base64":
842654
+ return PrimitiveSchemaValueWithExample.base64({
842655
+ example: void 0
842656
+ });
842657
+ case "boolean":
842658
+ return PrimitiveSchemaValueWithExample.boolean({
842659
+ example: void 0
842660
+ });
842661
+ case "date":
842662
+ return PrimitiveSchemaValueWithExample.date({
842663
+ example: void 0
842664
+ });
842665
+ case "datetime":
842666
+ return PrimitiveSchemaValueWithExample.datetime({
842667
+ example: void 0
842668
+ });
842669
+ case "double":
842670
+ return PrimitiveSchemaValueWithExample.double({
842671
+ example: void 0
842672
+ });
842673
+ case "float":
842674
+ return PrimitiveSchemaValueWithExample.float({
842675
+ example: void 0
842676
+ });
842677
+ case "int":
842678
+ return PrimitiveSchemaValueWithExample.int({
842679
+ example: void 0
842680
+ });
842681
+ case "int64":
842682
+ return PrimitiveSchemaValueWithExample.int64({
842683
+ example: void 0
842684
+ });
842685
+ default:
842686
+ assertNever(primitiveSchema);
842687
+ }
842688
+ }
842689
+ function convertToObjectProperty2(objectProperty) {
842690
+ return {
842691
+ conflict: objectProperty.conflict,
842692
+ generatedName: objectProperty.generatedName,
842693
+ key: objectProperty.key,
842694
+ schema: convertSchemaToSchemaWithExample(objectProperty.schema),
842695
+ audiences: objectProperty.audiences
842696
+ };
842697
+ }
842698
+
842502
842699
  // pnp:/home/circleci/project/packages/cli/openapi-parser/lib/schema/utils/isSchemaRequired.js
842503
842700
  function isSchemaRequired4(schema2) {
842504
842701
  return schema2.type !== "optional" && schema2.type !== "nullable";
@@ -842524,11 +842721,8 @@ var ExampleEndpointFactory = class {
842524
842721
  this.logger.debug(`Building endpoint example for ${endpoint.method.toUpperCase()} ${endpoint.path}`);
842525
842722
  const requestSchemaIdResponse = getRequestSchema(endpoint.request);
842526
842723
  const responseSchemaIdResponse = getResponseSchema(endpoint.response);
842527
- if ((requestSchemaIdResponse == null ? void 0 : requestSchemaIdResponse.type) === "unsupported" || (responseSchemaIdResponse == null ? void 0 : responseSchemaIdResponse.type) === "unsupported") {
842528
- return void 0;
842529
- }
842530
842724
  let requestExample = void 0;
842531
- if (requestSchemaIdResponse != null) {
842725
+ if (requestSchemaIdResponse != null && requestSchemaIdResponse.type === "present") {
842532
842726
  const required = this.isSchemaRequired(requestSchemaIdResponse.schema);
842533
842727
  requestExample = this.exampleTypeFactory.buildExample({
842534
842728
  schema: requestSchemaIdResponse.schema,
@@ -842543,7 +842737,7 @@ var ExampleEndpointFactory = class {
842543
842737
  }
842544
842738
  }
842545
842739
  let responseExample = void 0;
842546
- if (responseSchemaIdResponse != null) {
842740
+ if (responseSchemaIdResponse != null && responseSchemaIdResponse.type === "present") {
842547
842741
  const required = this.isSchemaRequired(responseSchemaIdResponse.schema);
842548
842742
  responseExample = this.exampleTypeFactory.buildExample({
842549
842743
  schema: responseSchemaIdResponse.schema,
@@ -842630,9 +842824,12 @@ var ExampleEndpointFactory = class {
842630
842824
  });
842631
842825
  }
842632
842826
  }
842633
- let exampleName = (_c3 = requestSchemaIdResponse == null ? void 0 : requestSchemaIdResponse.example) == null ? void 0 : _c3.name;
842634
- if (exampleName == null && (requestSchemaIdResponse == null ? void 0 : requestSchemaIdResponse.schema) != null) {
842635
- exampleName = getNameFromSchemaWithExample(requestSchemaIdResponse.schema);
842827
+ let exampleName = void 0;
842828
+ if ((requestSchemaIdResponse == null ? void 0 : requestSchemaIdResponse.type) === "present") {
842829
+ exampleName = (_c3 = requestSchemaIdResponse == null ? void 0 : requestSchemaIdResponse.example) == null ? void 0 : _c3.name;
842830
+ if (exampleName == null && (requestSchemaIdResponse == null ? void 0 : requestSchemaIdResponse.schema) != null) {
842831
+ exampleName = getNameFromSchemaWithExample(requestSchemaIdResponse.schema);
842832
+ }
842636
842833
  }
842637
842834
  const codeSamples = endpoint.examples.filter(hasIncompleteExample).flatMap((example) => example.codeSamples);
842638
842835
  return {
@@ -842665,10 +842862,17 @@ function getRequestSchema(request) {
842665
842862
  if (request == null) {
842666
842863
  return void 0;
842667
842864
  }
842668
- if (request.type !== "json") {
842669
- return { type: "unsupported" };
842865
+ if (request.type === "multipart") {
842866
+ return {
842867
+ type: "present",
842868
+ schema: convertMultipartRequestToSchema(request),
842869
+ example: void 0
842870
+ };
842670
842871
  }
842671
- return { type: "present", schema: request.schema, example: ((_a4 = request.fullExamples) == null ? void 0 : _a4[0]) ?? void 0 };
842872
+ if (request.type === "json") {
842873
+ return { type: "present", schema: request.schema, example: ((_a4 = request.fullExamples) == null ? void 0 : _a4[0]) ?? void 0 };
842874
+ }
842875
+ return { type: "unsupported" };
842672
842876
  }
842673
842877
  function getResponseSchema(response) {
842674
842878
  var _a4;
@@ -842733,6 +842937,60 @@ function getNameFromSchemaWithExample(schema2) {
842733
842937
  assertNever(schema2);
842734
842938
  }
842735
842939
  }
842940
+ function convertMultipartRequestToSchema(request) {
842941
+ return SchemaWithExample.object({
842942
+ properties: request.properties.map((property5) => {
842943
+ if (property5.schema.type === "file") {
842944
+ const innerSchema = SchemaWithExample.primitive({
842945
+ schema: api_exports5.PrimitiveSchemaValueWithExample.string({
842946
+ minLength: void 0,
842947
+ maxLength: void 0,
842948
+ example: void 0
842949
+ }),
842950
+ description: property5.description,
842951
+ nameOverride: void 0,
842952
+ generatedName: "",
842953
+ groupName: void 0
842954
+ });
842955
+ const maybeArraySchema = property5.schema.isArray ? SchemaWithExample.array({
842956
+ value: innerSchema,
842957
+ groupName: void 0,
842958
+ nameOverride: void 0,
842959
+ generatedName: "",
842960
+ description: void 0
842961
+ }) : innerSchema;
842962
+ const maybeOptionalSchema = property5.schema.isOptional ? SchemaWithExample.optional({
842963
+ value: maybeArraySchema,
842964
+ groupName: void 0,
842965
+ nameOverride: void 0,
842966
+ generatedName: "",
842967
+ description: void 0
842968
+ }) : maybeArraySchema;
842969
+ return {
842970
+ key: property5.key,
842971
+ schema: maybeOptionalSchema,
842972
+ audiences: [],
842973
+ conflict: {},
842974
+ generatedName: property5.key
842975
+ };
842976
+ }
842977
+ return {
842978
+ key: property5.key,
842979
+ schema: convertSchemaToSchemaWithExample(property5.schema.value),
842980
+ audiences: [],
842981
+ conflict: {},
842982
+ generatedName: property5.key
842983
+ };
842984
+ }).filter(isNonNullish),
842985
+ allOf: [],
842986
+ allOfPropertyConflicts: [],
842987
+ fullExamples: void 0,
842988
+ description: request.description,
842989
+ nameOverride: void 0,
842990
+ generatedName: "",
842991
+ groupName: void 0
842992
+ });
842993
+ }
842736
842994
 
842737
842995
  // pnp:/home/circleci/project/packages/cli/openapi-parser/lib/asyncapi/ExampleWebsocketSessionFactory.js
842738
842996
  var ExampleWebsocketSessionFactory = class {
@@ -846170,7 +846428,8 @@ function getRequest({ declarationFile, context, request, requestNameOverride, ge
846170
846428
  headers,
846171
846429
  body: {
846172
846430
  properties
846173
- }
846431
+ },
846432
+ "content-type": "multipart/form-data"
846174
846433
  }
846175
846434
  };
846176
846435
  }
@@ -850865,10 +851124,10 @@ var CliContext = class {
850865
851124
  return "fern-api";
850866
851125
  }
850867
851126
  getPackageVersion() {
850868
- if ("0.19.23" == null) {
851127
+ if ("0.19.24-rc2" == null) {
850869
851128
  this.logger.error("CLI_VERSION is not defined");
850870
851129
  }
850871
- return "0.19.23";
851130
+ return "0.19.24-rc2";
850872
851131
  }
850873
851132
  getCliName() {
850874
851133
  if ("fern" == null) {
@@ -851476,7 +851735,7 @@ function convertService(irService, ir) {
851476
851735
  response: irEndpoint.response != null ? convertResponse2(irEndpoint.response) : void 0,
851477
851736
  errors: convertResponseErrors(irEndpoint.errors, ir),
851478
851737
  errorsV2: convertResponseErrorsV2(irEndpoint.errors, ir),
851479
- examples: irEndpoint.examples.filter((example) => example.exampleType === "userProvided").map((example) => convertHttpEndpointExample(example, ir))
851738
+ examples: irEndpoint.examples.filter((example) => example.exampleType === "userProvided").map((example) => convertHttpEndpointExample(example, irEndpoint, ir))
851480
851739
  };
851481
851740
  });
851482
851741
  }
@@ -851816,8 +852075,8 @@ function convertResponseErrorsV2(irResponseErrors, ir) {
851816
852075
  }
851817
852076
  return errors;
851818
852077
  }
851819
- function convertHttpEndpointExample(irExample, ir) {
851820
- var _a4, _b3, _c3, _d;
852078
+ function convertHttpEndpointExample(irExample, irEndpoint, ir) {
852079
+ var _a4, _b3, _c3, _d, _e;
851821
852080
  return {
851822
852081
  name: (_a4 = irExample.name) == null ? void 0 : _a4.originalName,
851823
852082
  description: irExample.docs ?? void 0,
@@ -851835,7 +852094,46 @@ function convertHttpEndpointExample(irExample, ir) {
851835
852094
  return headers;
851836
852095
  }, {}),
851837
852096
  requestBody: (_b3 = irExample.request) == null ? void 0 : _b3.jsonExample,
851838
- requestBodyV3: irExample.request != null ? { type: "json", value: irExample.request.jsonExample } : void 0,
852097
+ requestBodyV3: (_c3 = irEndpoint.requestBody) == null ? void 0 : _c3._visit({
852098
+ inlinedRequestBody: () => irExample.request != null ? { type: "json", value: irExample.request.jsonExample } : void 0,
852099
+ reference: () => irExample.request != null ? { type: "json", value: irExample.request.jsonExample } : void 0,
852100
+ fileUpload: (fileUploadSchema) => {
852101
+ if (irExample.request == null) {
852102
+ return void 0;
852103
+ }
852104
+ const value = {};
852105
+ if (isPlainObject(irExample.request.jsonExample)) {
852106
+ const fullExample = irExample.request.jsonExample;
852107
+ for (const property5 of fileUploadSchema.properties) {
852108
+ property5._visit({
852109
+ file: (file) => {
852110
+ if (file.type === "file") {
852111
+ value[file.key.wireValue] = {
852112
+ type: "filename",
852113
+ value: "<file1>"
852114
+ };
852115
+ } else if (file.type === "fileArray") {
852116
+ value[file.key.wireValue] = {
852117
+ type: "filename",
852118
+ value: "<file1>"
852119
+ };
852120
+ }
852121
+ },
852122
+ bodyProperty: (bodyProperty) => {
852123
+ value[bodyProperty.name.wireValue] = {
852124
+ type: "json",
852125
+ value: fullExample[bodyProperty.name.wireValue]
852126
+ };
852127
+ },
852128
+ _other: noop_default
852129
+ });
852130
+ }
852131
+ }
852132
+ return { type: "form", value };
852133
+ },
852134
+ bytes: () => void 0,
852135
+ _other: () => void 0
852136
+ }),
851839
852137
  responseStatusCode: api_exports4.http.ExampleResponse._visit(irExample.response, {
851840
852138
  ok: ({ body }) => body != null ? 200 : 204,
851841
852139
  error: ({ error: errorName }) => {
@@ -851849,9 +852147,9 @@ function convertHttpEndpointExample(irExample, ir) {
851849
852147
  throw new Error("Unknown ExampleResponse: " + irExample.response.type);
851850
852148
  }
851851
852149
  }),
851852
- responseBody: (_c3 = irExample.response.body) == null ? void 0 : _c3.jsonExample,
852150
+ responseBody: (_d = irExample.response.body) == null ? void 0 : _d.jsonExample,
851853
852151
  responseBodyV3: irExample.response.body != null ? { type: "json", value: irExample.response.body.jsonExample } : void 0,
851854
- codeSamples: (_d = irExample.codeSamples) == null ? void 0 : _d.map((codeSample) => ExampleCodeSample._visit(codeSample, {
852152
+ codeSamples: (_e = irExample.codeSamples) == null ? void 0 : _e.map((codeSample) => ExampleCodeSample._visit(codeSample, {
851855
852153
  language: (value) => {
851856
852154
  var _a5;
851857
852155
  return {
@@ -854347,6 +854645,9 @@ function convertExampleRequestBody({ endpoint, example, typeResolver, exampleRes
854347
854645
  if (requestType == null) {
854348
854646
  return void 0;
854349
854647
  }
854648
+ if (typeof requestType === "string" && parseBytesRequest(requestType) != null) {
854649
+ return void 0;
854650
+ }
854350
854651
  if (!isInlineRequestBody(requestType)) {
854351
854652
  return ExampleRequestBody.reference(convertTypeReferenceExample({
854352
854653
  example: example.request,
@@ -854367,6 +854668,10 @@ function convertExampleRequestBody({ endpoint, example, typeResolver, exampleRes
854367
854668
  const exampleProperties = [];
854368
854669
  for (const [wireKey, propertyExample] of Object.entries(example.request)) {
854369
854670
  const inlinedRequestPropertyDeclaration = (_b3 = requestType.properties) == null ? void 0 : _b3[wireKey];
854671
+ const inilnedRequestPropertyType = typeof inlinedRequestPropertyDeclaration === "string" ? inlinedRequestPropertyDeclaration : inlinedRequestPropertyDeclaration == null ? void 0 : inlinedRequestPropertyDeclaration.type;
854672
+ if (inilnedRequestPropertyType != null && parseRawFileType(inilnedRequestPropertyType) != null) {
854673
+ continue;
854674
+ }
854370
854675
  if (inlinedRequestPropertyDeclaration != null) {
854371
854676
  exampleProperties.push({
854372
854677
  name: file.casingsGenerator.generateNameAndWireValue({
@@ -857089,7 +857394,7 @@ var TypeResolverImpl = class {
857089
857394
  resolveTypeOrThrow({ type: type2, file }) {
857090
857395
  const resolvedType = this.resolveType({ type: type2, file });
857091
857396
  if (resolvedType == null) {
857092
- throw new Error("Cannot resolve type: " + type2);
857397
+ throw new Error("Cannot resolve type: " + type2 + " in file " + file.relativeFilepath);
857093
857398
  }
857094
857399
  return resolvedType;
857095
857400
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.19.23",
3
+ "version": "0.19.24-rc2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",