fern-api 0.23.1-rc2 → 0.23.1-rc3
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 +81 -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-rc3",
|
|
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-rc3",
|
|
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,
|
|
@@ -908790,6 +908838,7 @@ async function parse3({ workspace, taskContext }) {
|
|
|
908790
908838
|
globalHeaders: [],
|
|
908791
908839
|
groups: {}
|
|
908792
908840
|
};
|
|
908841
|
+
console.log("workspace.specs", JSON.stringify(workspace.specs));
|
|
908793
908842
|
for (const spec of workspace.specs) {
|
|
908794
908843
|
const contents = (await (0, import_promises25.readFile)(spec.absoluteFilepath)).toString();
|
|
908795
908844
|
if (contents.includes("openapi") || contents.includes("swagger")) {
|
|
@@ -908802,14 +908851,16 @@ async function parse3({ workspace, taskContext }) {
|
|
|
908802
908851
|
const openapiIr = generateIr({
|
|
908803
908852
|
openApi: openApiDocument,
|
|
908804
908853
|
taskContext,
|
|
908805
|
-
disableExamples: false
|
|
908854
|
+
disableExamples: false,
|
|
908855
|
+
audiences: ((_a5 = spec.settings) == null ? void 0 : _a5.audiences) ?? []
|
|
908806
908856
|
});
|
|
908807
908857
|
ir = merge3(ir, openapiIr);
|
|
908808
908858
|
} else if (isOpenApiV2(openApiDocument)) {
|
|
908809
908859
|
const openapiIr = await generateIr2({
|
|
908810
908860
|
openApi: openApiDocument,
|
|
908811
908861
|
taskContext,
|
|
908812
|
-
disableExamples: false
|
|
908862
|
+
disableExamples: false,
|
|
908863
|
+
audiences: ((_b4 = spec.settings) == null ? void 0 : _b4.audiences) ?? []
|
|
908813
908864
|
});
|
|
908814
908865
|
ir = merge3(ir, openapiIr);
|
|
908815
908866
|
}
|
|
@@ -908926,7 +908977,9 @@ function buildQueryParameter({ queryParameter, context, fileContainingReference
|
|
|
908926
908977
|
function getQueryParameterTypeReference({ schema: schema2, context, fileContainingReference }) {
|
|
908927
908978
|
if (schema2.type === "reference") {
|
|
908928
908979
|
const resolvedSchema = context.getSchema(schema2.schema);
|
|
908929
|
-
if (resolvedSchema
|
|
908980
|
+
if (resolvedSchema == null) {
|
|
908981
|
+
return void 0;
|
|
908982
|
+
} else if (resolvedSchema.type === "array") {
|
|
908930
908983
|
return {
|
|
908931
908984
|
value: buildTypeReference({
|
|
908932
908985
|
schema: Schema2.optional({
|
|
@@ -908980,7 +909033,9 @@ function getQueryParameterTypeReference({ schema: schema2, context, fileContaini
|
|
|
908980
909033
|
if (schema2.type === "optional" || schema2.type === "nullable") {
|
|
908981
909034
|
if (schema2.value.type === "reference") {
|
|
908982
909035
|
const resolvedSchema = context.getSchema(schema2.value.schema);
|
|
908983
|
-
if (resolvedSchema
|
|
909036
|
+
if (resolvedSchema == null) {
|
|
909037
|
+
return void 0;
|
|
909038
|
+
} else if (resolvedSchema.type === "array") {
|
|
908984
909039
|
return {
|
|
908985
909040
|
value: buildTypeReference({
|
|
908986
909041
|
schema: Schema2.optional({
|
|
@@ -909909,7 +909964,7 @@ function getRequest({ declarationFile, context, request, requestNameOverride, ge
|
|
|
909909
909964
|
if (request.type === "json") {
|
|
909910
909965
|
const maybeSchemaId = request.schema.type === "reference" ? request.schema.schema : void 0;
|
|
909911
909966
|
const resolvedSchema = request.schema.type === "reference" ? context.getSchema(request.schema.schema) : request.schema;
|
|
909912
|
-
if (resolvedSchema.type !== "object" || maybeSchemaId != null && nonRequestReferencedSchemas.includes(maybeSchemaId)) {
|
|
909967
|
+
if ((resolvedSchema == null ? void 0 : resolvedSchema.type) !== "object" || maybeSchemaId != null && nonRequestReferencedSchemas.includes(maybeSchemaId)) {
|
|
909913
909968
|
const requestTypeReference = buildTypeReference({
|
|
909914
909969
|
schema: request.schema,
|
|
909915
909970
|
fileContainingReference: declarationFile,
|
|
@@ -910693,13 +910748,6 @@ var OpenApiIrConverterContext = class {
|
|
|
910693
910748
|
}
|
|
910694
910749
|
getSchema(id) {
|
|
910695
910750
|
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
910751
|
return schema2;
|
|
910704
910752
|
}
|
|
910705
910753
|
getOrThrowDefaultServerName() {
|
|
@@ -911058,7 +911106,10 @@ async function loadAPIWorkspace({ absolutePathToWorkspace, context, cliVersion,
|
|
|
911058
911106
|
for (const definition2 of generatorsConfiguration.api.definitions) {
|
|
911059
911107
|
specs.push({
|
|
911060
911108
|
absoluteFilepath: join(absolutePathToWorkspace, RelativeFilePath.of(definition2.path)),
|
|
911061
|
-
absoluteFilepathToOverrides: definition2.overrides != null ? join(absolutePathToWorkspace, RelativeFilePath.of(definition2.overrides)) : void 0
|
|
911109
|
+
absoluteFilepathToOverrides: definition2.overrides != null ? join(absolutePathToWorkspace, RelativeFilePath.of(definition2.overrides)) : void 0,
|
|
911110
|
+
settings: {
|
|
911111
|
+
audiences: definition2.audiences ?? []
|
|
911112
|
+
}
|
|
911062
911113
|
});
|
|
911063
911114
|
}
|
|
911064
911115
|
return {
|
|
@@ -914729,10 +914780,10 @@ var CliContext = class {
|
|
|
914729
914780
|
return "fern-api";
|
|
914730
914781
|
}
|
|
914731
914782
|
getPackageVersion() {
|
|
914732
|
-
if ("0.23.1-
|
|
914783
|
+
if ("0.23.1-rc3" == null) {
|
|
914733
914784
|
this.logger.error("CLI_VERSION is not defined");
|
|
914734
914785
|
}
|
|
914735
|
-
return "0.23.1-
|
|
914786
|
+
return "0.23.1-rc3";
|
|
914736
914787
|
}
|
|
914737
914788
|
getCliName() {
|
|
914738
914789
|
if ("fern" == null) {
|
|
@@ -916531,7 +916582,7 @@ function convertAvailability(availability) {
|
|
|
916531
916582
|
message: typeof availability !== "string" ? availability.message : void 0
|
|
916532
916583
|
};
|
|
916533
916584
|
}
|
|
916534
|
-
function
|
|
916585
|
+
function getAudiences2(schema2) {
|
|
916535
916586
|
if (typeof schema2 === "string") {
|
|
916536
916587
|
return [];
|
|
916537
916588
|
}
|
|
@@ -922028,7 +922079,7 @@ async function generateIntermediateRepresentation({ workspace, generationLanguag
|
|
|
922028
922079
|
propertiesByAudience: convertedTypeDeclarationWithFilepaths.propertiesByAudience,
|
|
922029
922080
|
descendantFilepaths: subpackageFilepaths
|
|
922030
922081
|
});
|
|
922031
|
-
irGraph.markTypeForAudiences(convertedTypeDeclaration.name,
|
|
922082
|
+
irGraph.markTypeForAudiences(convertedTypeDeclaration.name, getAudiences2(typeDeclaration));
|
|
922032
922083
|
}
|
|
922033
922084
|
},
|
|
922034
922085
|
errors: (errors) => {
|