fern-api 0.23.1-rc2 → 0.23.1-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.
- package/bundle.cjs +85 -30
- package/package.json +1 -1
package/bundle.cjs
CHANGED
|
@@ -886399,7 +886399,8 @@ var APIDefinitionPathSchema = z.string().describe("Path to the OpenAPI, AsyncAPI
|
|
|
886399
886399
|
var APIDefintionWithOverridesSchema = z.object({
|
|
886400
886400
|
path: APIDefinitionPathSchema,
|
|
886401
886401
|
origin: z.optional(z.string()).describe("The URL of the API definition origin, from which the file should be polled."),
|
|
886402
|
-
overrides: z.optional(z.string()).describe("Path to the OpenAPI or AsyncAPI overrides")
|
|
886402
|
+
overrides: z.optional(z.string()).describe("Path to the OpenAPI or AsyncAPI overrides"),
|
|
886403
|
+
audiences: z.optional(z.array(z.string())).describe("Audiences that you would like to filter to")
|
|
886403
886404
|
});
|
|
886404
886405
|
var APIDefinitionList = z.array(z.union([APIDefinitionPathSchema, APIDefintionWithOverridesSchema]));
|
|
886405
886406
|
var APIConfigurationSchema = z.union([
|
|
@@ -886620,7 +886621,8 @@ async function parseAPIConfiguration(rawGeneratorsConfiguration) {
|
|
|
886620
886621
|
apiDefinitions.push({
|
|
886621
886622
|
path: apiConfiguration,
|
|
886622
886623
|
origin: void 0,
|
|
886623
|
-
overrides: void 0
|
|
886624
|
+
overrides: void 0,
|
|
886625
|
+
audiences: []
|
|
886624
886626
|
});
|
|
886625
886627
|
} else if (Array.isArray(apiConfiguration)) {
|
|
886626
886628
|
for (const definition2 of apiConfiguration) {
|
|
@@ -886628,13 +886630,15 @@ async function parseAPIConfiguration(rawGeneratorsConfiguration) {
|
|
|
886628
886630
|
apiDefinitions.push({
|
|
886629
886631
|
path: definition2,
|
|
886630
886632
|
origin: void 0,
|
|
886631
|
-
overrides: void 0
|
|
886633
|
+
overrides: void 0,
|
|
886634
|
+
audiences: []
|
|
886632
886635
|
});
|
|
886633
886636
|
} else {
|
|
886634
886637
|
apiDefinitions.push({
|
|
886635
886638
|
path: definition2.path,
|
|
886636
886639
|
origin: definition2.origin,
|
|
886637
|
-
overrides: definition2.overrides
|
|
886640
|
+
overrides: definition2.overrides,
|
|
886641
|
+
audiences: definition2.audiences
|
|
886638
886642
|
});
|
|
886639
886643
|
}
|
|
886640
886644
|
}
|
|
@@ -886642,7 +886646,8 @@ async function parseAPIConfiguration(rawGeneratorsConfiguration) {
|
|
|
886642
886646
|
apiDefinitions.push({
|
|
886643
886647
|
path: apiConfiguration.path,
|
|
886644
886648
|
origin: apiConfiguration.origin,
|
|
886645
|
-
overrides: apiConfiguration.overrides
|
|
886649
|
+
overrides: apiConfiguration.overrides,
|
|
886650
|
+
audiences: apiConfiguration.audiences
|
|
886646
886651
|
});
|
|
886647
886652
|
}
|
|
886648
886653
|
} else {
|
|
@@ -886654,20 +886659,23 @@ async function parseAPIConfiguration(rawGeneratorsConfiguration) {
|
|
|
886654
886659
|
apiDefinitions.push({
|
|
886655
886660
|
path: openapi,
|
|
886656
886661
|
origin: apiOrigin,
|
|
886657
|
-
overrides: openapiOverrides
|
|
886662
|
+
overrides: openapiOverrides,
|
|
886663
|
+
audiences: []
|
|
886658
886664
|
});
|
|
886659
886665
|
} else if (openapi != null) {
|
|
886660
886666
|
apiDefinitions.push({
|
|
886661
886667
|
path: openapi.path,
|
|
886662
886668
|
origin: openapi.origin,
|
|
886663
|
-
overrides: openapi.overrides
|
|
886669
|
+
overrides: openapi.overrides,
|
|
886670
|
+
audiences: []
|
|
886664
886671
|
});
|
|
886665
886672
|
}
|
|
886666
886673
|
if (asyncapi != null) {
|
|
886667
886674
|
apiDefinitions.push({
|
|
886668
886675
|
path: asyncapi,
|
|
886669
886676
|
origin: apiOrigin,
|
|
886670
|
-
overrides: void 0
|
|
886677
|
+
overrides: void 0,
|
|
886678
|
+
audiences: []
|
|
886671
886679
|
});
|
|
886672
886680
|
}
|
|
886673
886681
|
}
|
|
@@ -890242,7 +890250,7 @@ var AccessTokenPosthogManager = class {
|
|
|
890242
890250
|
properties: {
|
|
890243
890251
|
...event,
|
|
890244
890252
|
...event.properties,
|
|
890245
|
-
version: "0.23.1-
|
|
890253
|
+
version: "0.23.1-rc4",
|
|
890246
890254
|
usingAccessToken: true
|
|
890247
890255
|
}
|
|
890248
890256
|
});
|
|
@@ -890304,7 +890312,7 @@ var UserPosthogManager = class {
|
|
|
890304
890312
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
890305
890313
|
event: "CLI",
|
|
890306
890314
|
properties: {
|
|
890307
|
-
version: "0.23.1-
|
|
890315
|
+
version: "0.23.1-rc4",
|
|
890308
890316
|
...event,
|
|
890309
890317
|
...event.properties
|
|
890310
890318
|
}
|
|
@@ -902347,6 +902355,9 @@ function buildPrimitiveTypeReference(primitiveSchema) {
|
|
|
902347
902355
|
}
|
|
902348
902356
|
function buildReferenceTypeReference({ schema: schema2, fileContainingReference, context }) {
|
|
902349
902357
|
const resolvedSchema = context.getSchema(schema2.schema);
|
|
902358
|
+
if (resolvedSchema == null) {
|
|
902359
|
+
return "unknown";
|
|
902360
|
+
}
|
|
902350
902361
|
const schemaName = getSchemaName(resolvedSchema) ?? schema2.schema;
|
|
902351
902362
|
const groupName = getGroupNameForSchema(resolvedSchema);
|
|
902352
902363
|
const typeWithPrefix = getPrefixedType({
|
|
@@ -902578,6 +902589,9 @@ function buildObjectTypeDeclaration({ schema: schema2, context, declarationFile
|
|
|
902578
902589
|
const extendedSchemas = [];
|
|
902579
902590
|
for (const allOf of schema2.allOf) {
|
|
902580
902591
|
const resolvedSchemaId = getSchemaIdOfResolvedType({ schema: allOf.schema, context });
|
|
902592
|
+
if (resolvedSchemaId == null) {
|
|
902593
|
+
continue;
|
|
902594
|
+
}
|
|
902581
902595
|
if (schemasToInline.has(allOf.schema) || schemasToInline.has(resolvedSchemaId)) {
|
|
902582
902596
|
continue;
|
|
902583
902597
|
}
|
|
@@ -902642,6 +902656,9 @@ function buildObjectTypeDeclaration({ schema: schema2, context, declarationFile
|
|
|
902642
902656
|
}
|
|
902643
902657
|
function getAllParentSchemasToInline({ property: property5, schemaId, context }) {
|
|
902644
902658
|
const schema2 = context.getSchema(schemaId);
|
|
902659
|
+
if (schema2 == null) {
|
|
902660
|
+
return [];
|
|
902661
|
+
}
|
|
902645
902662
|
if (schema2.type === "reference") {
|
|
902646
902663
|
return getAllParentSchemasToInline({ property: property5, schemaId: schema2.schema, context });
|
|
902647
902664
|
}
|
|
@@ -902663,6 +902680,9 @@ function getAllParentSchemasToInline({ property: property5, schemaId, context })
|
|
|
902663
902680
|
}
|
|
902664
902681
|
function getProperties(context, schemaId) {
|
|
902665
902682
|
const schema2 = context.getSchema(schemaId);
|
|
902683
|
+
if (schema2 == null) {
|
|
902684
|
+
return { properties: [], allOf: [] };
|
|
902685
|
+
}
|
|
902666
902686
|
if (schema2.type === "object") {
|
|
902667
902687
|
return { properties: schema2.properties, allOf: schema2.allOf };
|
|
902668
902688
|
} else if (schema2.type === "reference") {
|
|
@@ -902834,6 +902854,9 @@ function startsWithNumber(str3) {
|
|
|
902834
902854
|
}
|
|
902835
902855
|
function getSchemaIdOfResolvedType({ schema: schema2, context }) {
|
|
902836
902856
|
const resolvedSchema = context.getSchema(schema2);
|
|
902857
|
+
if (resolvedSchema == null) {
|
|
902858
|
+
return void 0;
|
|
902859
|
+
}
|
|
902837
902860
|
if (resolvedSchema.type === "reference") {
|
|
902838
902861
|
return getSchemaIdOfResolvedType({ context, schema: resolvedSchema.schema });
|
|
902839
902862
|
}
|
|
@@ -908520,7 +908543,7 @@ function replaceWithSchemaReference({ openapi, replaceReference, schemaReference
|
|
|
908520
908543
|
}
|
|
908521
908544
|
|
|
908522
908545
|
// pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/v3/generateIr.js
|
|
908523
|
-
function generateIr({ openApi, taskContext, disableExamples }) {
|
|
908546
|
+
function generateIr({ openApi, taskContext, disableExamples, audiences }) {
|
|
908524
908547
|
var _a5, _b4, _c4;
|
|
908525
908548
|
openApi = runResolutions({ openapi: openApi });
|
|
908526
908549
|
const securitySchemes = Object.fromEntries(Object.entries(((_a5 = openApi.components) == null ? void 0 : _a5.securitySchemes) ?? {}).map(([key2, securityScheme]) => {
|
|
@@ -908550,6 +908573,10 @@ function generateIr({ openApi, taskContext, disableExamples }) {
|
|
|
908550
908573
|
taskContext.logger.debug(`Converting path ${path34}`);
|
|
908551
908574
|
const convertedOperations = convertPathItem(path34, pathItem, openApi, context);
|
|
908552
908575
|
for (const operation of convertedOperations) {
|
|
908576
|
+
const operationAudiences = getAudiences({ operation });
|
|
908577
|
+
if (audiences.length > 0 && !audiences.some((audience) => operationAudiences.includes(audience))) {
|
|
908578
|
+
continue;
|
|
908579
|
+
}
|
|
908553
908580
|
switch (operation.type) {
|
|
908554
908581
|
case "async":
|
|
908555
908582
|
endpointsWithExample.push(operation.sync);
|
|
@@ -908758,19 +908785,40 @@ function getAllParentSchemaIds({ schema: schema2, schemas }) {
|
|
|
908758
908785
|
}
|
|
908759
908786
|
return result2;
|
|
908760
908787
|
}
|
|
908788
|
+
function getAudiences({ operation }) {
|
|
908789
|
+
let endpointAudiences = [];
|
|
908790
|
+
switch (operation.type) {
|
|
908791
|
+
case "async":
|
|
908792
|
+
endpointAudiences = operation.async.audiences;
|
|
908793
|
+
break;
|
|
908794
|
+
case "http":
|
|
908795
|
+
endpointAudiences = operation.value.audiences;
|
|
908796
|
+
break;
|
|
908797
|
+
case "streaming":
|
|
908798
|
+
endpointAudiences = operation.streaming.audiences;
|
|
908799
|
+
break;
|
|
908800
|
+
case "webhook":
|
|
908801
|
+
break;
|
|
908802
|
+
default:
|
|
908803
|
+
assertNever(operation);
|
|
908804
|
+
}
|
|
908805
|
+
return endpointAudiences;
|
|
908806
|
+
}
|
|
908761
908807
|
|
|
908762
908808
|
// pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/v2/generateIr.js
|
|
908763
|
-
async function generateIr2({ openApi, taskContext, disableExamples }) {
|
|
908809
|
+
async function generateIr2({ openApi, taskContext, disableExamples, audiences }) {
|
|
908764
908810
|
const conversionResult = await (0, import_swagger2openapi.convertObj)(openApi, {});
|
|
908765
908811
|
return generateIr({
|
|
908766
908812
|
openApi: conversionResult.openapi,
|
|
908767
908813
|
taskContext,
|
|
908768
|
-
disableExamples
|
|
908814
|
+
disableExamples,
|
|
908815
|
+
audiences
|
|
908769
908816
|
});
|
|
908770
908817
|
}
|
|
908771
908818
|
|
|
908772
908819
|
// pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/parse.js
|
|
908773
908820
|
async function parse3({ workspace, taskContext }) {
|
|
908821
|
+
var _a5, _b4;
|
|
908774
908822
|
let ir = {
|
|
908775
908823
|
title: void 0,
|
|
908776
908824
|
description: void 0,
|
|
@@ -908802,14 +908850,16 @@ async function parse3({ workspace, taskContext }) {
|
|
|
908802
908850
|
const openapiIr = generateIr({
|
|
908803
908851
|
openApi: openApiDocument,
|
|
908804
908852
|
taskContext,
|
|
908805
|
-
disableExamples: false
|
|
908853
|
+
disableExamples: false,
|
|
908854
|
+
audiences: ((_a5 = spec.settings) == null ? void 0 : _a5.audiences) ?? []
|
|
908806
908855
|
});
|
|
908807
908856
|
ir = merge3(ir, openapiIr);
|
|
908808
908857
|
} else if (isOpenApiV2(openApiDocument)) {
|
|
908809
908858
|
const openapiIr = await generateIr2({
|
|
908810
908859
|
openApi: openApiDocument,
|
|
908811
908860
|
taskContext,
|
|
908812
|
-
disableExamples: false
|
|
908861
|
+
disableExamples: false,
|
|
908862
|
+
audiences: ((_b4 = spec.settings) == null ? void 0 : _b4.audiences) ?? []
|
|
908813
908863
|
});
|
|
908814
908864
|
ir = merge3(ir, openapiIr);
|
|
908815
908865
|
}
|
|
@@ -908926,7 +908976,9 @@ function buildQueryParameter({ queryParameter, context, fileContainingReference
|
|
|
908926
908976
|
function getQueryParameterTypeReference({ schema: schema2, context, fileContainingReference }) {
|
|
908927
908977
|
if (schema2.type === "reference") {
|
|
908928
908978
|
const resolvedSchema = context.getSchema(schema2.schema);
|
|
908929
|
-
if (resolvedSchema
|
|
908979
|
+
if (resolvedSchema == null) {
|
|
908980
|
+
return void 0;
|
|
908981
|
+
} else if (resolvedSchema.type === "array") {
|
|
908930
908982
|
return {
|
|
908931
908983
|
value: buildTypeReference({
|
|
908932
908984
|
schema: Schema2.optional({
|
|
@@ -908980,7 +909032,9 @@ function getQueryParameterTypeReference({ schema: schema2, context, fileContaini
|
|
|
908980
909032
|
if (schema2.type === "optional" || schema2.type === "nullable") {
|
|
908981
909033
|
if (schema2.value.type === "reference") {
|
|
908982
909034
|
const resolvedSchema = context.getSchema(schema2.value.schema);
|
|
908983
|
-
if (resolvedSchema
|
|
909035
|
+
if (resolvedSchema == null) {
|
|
909036
|
+
return void 0;
|
|
909037
|
+
} else if (resolvedSchema.type === "array") {
|
|
908984
909038
|
return {
|
|
908985
909039
|
value: buildTypeReference({
|
|
908986
909040
|
schema: Schema2.optional({
|
|
@@ -909909,7 +909963,7 @@ function getRequest({ declarationFile, context, request, requestNameOverride, ge
|
|
|
909909
909963
|
if (request.type === "json") {
|
|
909910
909964
|
const maybeSchemaId = request.schema.type === "reference" ? request.schema.schema : void 0;
|
|
909911
909965
|
const resolvedSchema = request.schema.type === "reference" ? context.getSchema(request.schema.schema) : request.schema;
|
|
909912
|
-
if (resolvedSchema.type !== "object" || maybeSchemaId != null && nonRequestReferencedSchemas.includes(maybeSchemaId)) {
|
|
909966
|
+
if ((resolvedSchema == null ? void 0 : resolvedSchema.type) !== "object" || maybeSchemaId != null && nonRequestReferencedSchemas.includes(maybeSchemaId)) {
|
|
909913
909967
|
const requestTypeReference = buildTypeReference({
|
|
909914
909968
|
schema: request.schema,
|
|
909915
909969
|
fileContainingReference: declarationFile,
|
|
@@ -910693,13 +910747,6 @@ var OpenApiIrConverterContext = class {
|
|
|
910693
910747
|
}
|
|
910694
910748
|
getSchema(id) {
|
|
910695
910749
|
const schema2 = this.ir.schemas[id];
|
|
910696
|
-
if (schema2 == null) {
|
|
910697
|
-
this.logger.warn(`Schema with id ${id} not found. Treating as unknown.`);
|
|
910698
|
-
return Schema2.unknown({
|
|
910699
|
-
generatedName: "",
|
|
910700
|
-
nameOverride: void 0
|
|
910701
|
-
});
|
|
910702
|
-
}
|
|
910703
910750
|
return schema2;
|
|
910704
910751
|
}
|
|
910705
910752
|
getOrThrowDefaultServerName() {
|
|
@@ -911058,7 +911105,10 @@ async function loadAPIWorkspace({ absolutePathToWorkspace, context, cliVersion,
|
|
|
911058
911105
|
for (const definition2 of generatorsConfiguration.api.definitions) {
|
|
911059
911106
|
specs.push({
|
|
911060
911107
|
absoluteFilepath: join(absolutePathToWorkspace, RelativeFilePath.of(definition2.path)),
|
|
911061
|
-
absoluteFilepathToOverrides: definition2.overrides != null ? join(absolutePathToWorkspace, RelativeFilePath.of(definition2.overrides)) : void 0
|
|
911108
|
+
absoluteFilepathToOverrides: definition2.overrides != null ? join(absolutePathToWorkspace, RelativeFilePath.of(definition2.overrides)) : void 0,
|
|
911109
|
+
settings: {
|
|
911110
|
+
audiences: definition2.audiences ?? []
|
|
911111
|
+
}
|
|
911062
911112
|
});
|
|
911063
911113
|
}
|
|
911064
911114
|
return {
|
|
@@ -914729,10 +914779,10 @@ var CliContext = class {
|
|
|
914729
914779
|
return "fern-api";
|
|
914730
914780
|
}
|
|
914731
914781
|
getPackageVersion() {
|
|
914732
|
-
if ("0.23.1-
|
|
914782
|
+
if ("0.23.1-rc4" == null) {
|
|
914733
914783
|
this.logger.error("CLI_VERSION is not defined");
|
|
914734
914784
|
}
|
|
914735
|
-
return "0.23.1-
|
|
914785
|
+
return "0.23.1-rc4";
|
|
914736
914786
|
}
|
|
914737
914787
|
getCliName() {
|
|
914738
914788
|
if ("fern" == null) {
|
|
@@ -915510,6 +915560,11 @@ function convertResponse2(irResponse) {
|
|
|
915510
915560
|
type: "stream",
|
|
915511
915561
|
shape: { type: "reference", value: convertTypeReference(streamingResponse.payload) }
|
|
915512
915562
|
};
|
|
915563
|
+
} else if (streamingResponse.type === "sse") {
|
|
915564
|
+
return {
|
|
915565
|
+
type: "stream",
|
|
915566
|
+
shape: { type: "reference", value: convertTypeReference(streamingResponse.payload) }
|
|
915567
|
+
};
|
|
915513
915568
|
}
|
|
915514
915569
|
return void 0;
|
|
915515
915570
|
},
|
|
@@ -916531,7 +916586,7 @@ function convertAvailability(availability) {
|
|
|
916531
916586
|
message: typeof availability !== "string" ? availability.message : void 0
|
|
916532
916587
|
};
|
|
916533
916588
|
}
|
|
916534
|
-
function
|
|
916589
|
+
function getAudiences2(schema2) {
|
|
916535
916590
|
if (typeof schema2 === "string") {
|
|
916536
916591
|
return [];
|
|
916537
916592
|
}
|
|
@@ -922028,7 +922083,7 @@ async function generateIntermediateRepresentation({ workspace, generationLanguag
|
|
|
922028
922083
|
propertiesByAudience: convertedTypeDeclarationWithFilepaths.propertiesByAudience,
|
|
922029
922084
|
descendantFilepaths: subpackageFilepaths
|
|
922030
922085
|
});
|
|
922031
|
-
irGraph.markTypeForAudiences(convertedTypeDeclaration.name,
|
|
922086
|
+
irGraph.markTypeForAudiences(convertedTypeDeclaration.name, getAudiences2(typeDeclaration));
|
|
922032
922087
|
}
|
|
922033
922088
|
},
|
|
922034
922089
|
errors: (errors) => {
|