fern-api 0.19.0-rc1 → 0.19.0-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 +82 -28
- package/package.json +1 -1
package/bundle.cjs
CHANGED
|
@@ -795422,6 +795422,17 @@ var GeneratorGroupSchema = z.strictObject({
|
|
|
795422
795422
|
generators: z.array(GeneratorInvocationSchema)
|
|
795423
795423
|
});
|
|
795424
795424
|
|
|
795425
|
+
// pnp:/home/circleci/project/packages/cli/config-management/generators-configuration/lib/schemas/GeneratorsOpenAPIObjectSchema.js
|
|
795426
|
+
var OPENAPI_DISABLE_EXAMPLES_KEY = "disable-examples";
|
|
795427
|
+
var GeneratorsOpenAPIObjectSchema = z.strictObject({
|
|
795428
|
+
path: z.optional(z.string()),
|
|
795429
|
+
overrides: z.optional(z.string()),
|
|
795430
|
+
[OPENAPI_DISABLE_EXAMPLES_KEY]: z.optional(z.boolean())
|
|
795431
|
+
});
|
|
795432
|
+
|
|
795433
|
+
// pnp:/home/circleci/project/packages/cli/config-management/generators-configuration/lib/schemas/GeneratorsOpenAPISchema.js
|
|
795434
|
+
var GeneratorsOpenAPISchema = z.union([GeneratorsOpenAPIObjectSchema, z.string()]);
|
|
795435
|
+
|
|
795425
795436
|
// pnp:/home/circleci/project/packages/cli/config-management/generators-configuration/lib/schemas/WhitelabelGithubConfigurationSchema.js
|
|
795426
795437
|
var WhitelabelGithubConfigurationSchema = z.strictObject({
|
|
795427
795438
|
username: z.string(),
|
|
@@ -795441,8 +795452,8 @@ var OPENAPI_OVERRIDES_LOCATION_KEY = "openapi-overrides";
|
|
|
795441
795452
|
var ASYNC_API_LOCATION_KEY = "async-api";
|
|
795442
795453
|
var GeneratorsConfigurationSchema = z.strictObject({
|
|
795443
795454
|
[DEFAULT_GROUP_GENERATORS_CONFIG_KEY]: z.optional(z.string()),
|
|
795444
|
-
[OPENAPI_LOCATION_KEY]: z.optional(
|
|
795445
|
-
[OPENAPI_OVERRIDES_LOCATION_KEY]: z.optional(z.string()),
|
|
795455
|
+
[OPENAPI_LOCATION_KEY]: z.optional(GeneratorsOpenAPISchema),
|
|
795456
|
+
[OPENAPI_OVERRIDES_LOCATION_KEY]: z.optional(z.string()).describe("Deprecated; use openapi.overrides instead."),
|
|
795446
795457
|
[ASYNC_API_LOCATION_KEY]: z.optional(z.string()),
|
|
795447
795458
|
whitelabel: z.optional(WhitelabelConfigurationSchema),
|
|
795448
795459
|
groups: z.optional(z.record(GeneratorGroupSchema))
|
|
@@ -795450,14 +795461,14 @@ var GeneratorsConfigurationSchema = z.strictObject({
|
|
|
795450
795461
|
|
|
795451
795462
|
// pnp:/home/circleci/project/packages/cli/config-management/generators-configuration/lib/convertGeneratorsConfiguration.js
|
|
795452
795463
|
async function convertGeneratorsConfiguration({ absolutePathToGeneratorsConfiguration, rawGeneratorsConfiguration }) {
|
|
795453
|
-
const
|
|
795464
|
+
const openAPI = await parseOpenAPIConfiguration(rawGeneratorsConfiguration);
|
|
795454
795465
|
const pathToAsyncAPI = rawGeneratorsConfiguration[ASYNC_API_LOCATION_KEY];
|
|
795455
|
-
const pathToOpenAPIOverrides = rawGeneratorsConfiguration[OPENAPI_OVERRIDES_LOCATION_KEY];
|
|
795456
795466
|
return {
|
|
795457
795467
|
absolutePathToConfiguration: absolutePathToGeneratorsConfiguration,
|
|
795458
795468
|
absolutePathToAsyncAPI: pathToAsyncAPI != null ? join(dirname(absolutePathToGeneratorsConfiguration), RelativeFilePath.of(pathToAsyncAPI)) : void 0,
|
|
795459
|
-
absolutePathToOpenAPI:
|
|
795460
|
-
absolutePathToOpenAPIOverrides:
|
|
795469
|
+
absolutePathToOpenAPI: openAPI.path != null ? join(dirname(absolutePathToGeneratorsConfiguration), RelativeFilePath.of(openAPI.path)) : void 0,
|
|
795470
|
+
absolutePathToOpenAPIOverrides: openAPI.overrides != null ? join(dirname(absolutePathToGeneratorsConfiguration), RelativeFilePath.of(openAPI.overrides)) : void 0,
|
|
795471
|
+
disableOpenAPIExamples: openAPI.disableExamples,
|
|
795461
795472
|
rawConfiguration: rawGeneratorsConfiguration,
|
|
795462
795473
|
defaultGroup: rawGeneratorsConfiguration["default-group"],
|
|
795463
795474
|
groups: rawGeneratorsConfiguration.groups != null ? await Promise.all(Object.entries(rawGeneratorsConfiguration.groups).map(([groupName, group]) => convertGroup({
|
|
@@ -795470,6 +795481,21 @@ async function convertGeneratorsConfiguration({ absolutePathToGeneratorsConfigur
|
|
|
795470
795481
|
} : void 0
|
|
795471
795482
|
};
|
|
795472
795483
|
}
|
|
795484
|
+
async function parseOpenAPIConfiguration(rawGeneratorsConfiguration) {
|
|
795485
|
+
const openAPI = rawGeneratorsConfiguration[OPENAPI_LOCATION_KEY];
|
|
795486
|
+
if (typeof openAPI === "string") {
|
|
795487
|
+
return {
|
|
795488
|
+
path: openAPI,
|
|
795489
|
+
overrides: rawGeneratorsConfiguration[OPENAPI_OVERRIDES_LOCATION_KEY],
|
|
795490
|
+
disableExamples: void 0
|
|
795491
|
+
};
|
|
795492
|
+
}
|
|
795493
|
+
return {
|
|
795494
|
+
path: openAPI == null ? void 0 : openAPI.path,
|
|
795495
|
+
overrides: (openAPI == null ? void 0 : openAPI.overrides) ?? rawGeneratorsConfiguration[OPENAPI_OVERRIDES_LOCATION_KEY],
|
|
795496
|
+
disableExamples: openAPI == null ? void 0 : openAPI[OPENAPI_DISABLE_EXAMPLES_KEY]
|
|
795497
|
+
};
|
|
795498
|
+
}
|
|
795473
795499
|
async function convertGroup({ absolutePathToGeneratorsConfiguration, groupName, group }) {
|
|
795474
795500
|
return {
|
|
795475
795501
|
groupName,
|
|
@@ -799111,7 +799137,7 @@ var AccessTokenPosthogManager = class {
|
|
|
799111
799137
|
properties: {
|
|
799112
799138
|
...event,
|
|
799113
799139
|
...event.properties,
|
|
799114
|
-
version: "0.19.0-
|
|
799140
|
+
version: "0.19.0-rc3",
|
|
799115
799141
|
usingAccessToken: true
|
|
799116
799142
|
}
|
|
799117
799143
|
});
|
|
@@ -799173,7 +799199,7 @@ var UserPosthogManager = class {
|
|
|
799173
799199
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
799174
799200
|
event: "CLI",
|
|
799175
799201
|
properties: {
|
|
799176
|
-
version: "0.19.0-
|
|
799202
|
+
version: "0.19.0-rc3",
|
|
799177
799203
|
...event,
|
|
799178
799204
|
...event.properties
|
|
799179
799205
|
}
|
|
@@ -814027,7 +814053,13 @@ var ExampleTypeFactory = class {
|
|
|
814027
814053
|
this.schemas = schemas;
|
|
814028
814054
|
}
|
|
814029
814055
|
buildExample({ schema: schema2, example, options }) {
|
|
814030
|
-
return this.buildExampleHelper({
|
|
814056
|
+
return this.buildExampleHelper({
|
|
814057
|
+
schema: schema2,
|
|
814058
|
+
visitedSchemaIds: /* @__PURE__ */ new Set(),
|
|
814059
|
+
example,
|
|
814060
|
+
options: { ...options, maxCheckerDepth: options.maxCheckerDepth ?? 5 },
|
|
814061
|
+
depth: 0
|
|
814062
|
+
});
|
|
814031
814063
|
}
|
|
814032
814064
|
buildExampleHelper({ example, schema: schema2, depth, visitedSchemaIds, options }) {
|
|
814033
814065
|
var _a2, _b2;
|
|
@@ -814040,7 +814072,7 @@ var ExampleTypeFactory = class {
|
|
|
814040
814072
|
case "literal":
|
|
814041
814073
|
return FullExample.literal(schema2.value);
|
|
814042
814074
|
case "nullable": {
|
|
814043
|
-
if (example == null && !this.hasExample(schema2.value) && (options.ignoreOptionals || this.exceedsMaxDepth(depth, options))) {
|
|
814075
|
+
if (example == null && !this.hasExample(schema2.value, 0, visitedSchemaIds, options) && (options.ignoreOptionals || this.exceedsMaxDepth(depth, options))) {
|
|
814044
814076
|
return void 0;
|
|
814045
814077
|
}
|
|
814046
814078
|
const result2 = this.buildExampleHelper({
|
|
@@ -814062,7 +814094,7 @@ var ExampleTypeFactory = class {
|
|
|
814062
814094
|
return result2;
|
|
814063
814095
|
}
|
|
814064
814096
|
case "optional": {
|
|
814065
|
-
if (example == null && !this.hasExample(schema2.value) && (options.ignoreOptionals || this.exceedsMaxDepth(depth, options))) {
|
|
814097
|
+
if (example == null && !this.hasExample(schema2.value, 0, visitedSchemaIds, options) && (options.ignoreOptionals || this.exceedsMaxDepth(depth, options))) {
|
|
814066
814098
|
return void 0;
|
|
814067
814099
|
}
|
|
814068
814100
|
const result2 = this.buildExampleHelper({
|
|
@@ -814317,23 +814349,26 @@ var ExampleTypeFactory = class {
|
|
|
814317
814349
|
assertNever(schema2);
|
|
814318
814350
|
}
|
|
814319
814351
|
}
|
|
814320
|
-
hasExample(schema2) {
|
|
814352
|
+
hasExample(schema2, depth, visitedSchemaIds = /* @__PURE__ */ new Set(), options) {
|
|
814353
|
+
if (this.exceedsMaxCheckerDepth(depth, options)) {
|
|
814354
|
+
return false;
|
|
814355
|
+
}
|
|
814321
814356
|
switch (schema2.type) {
|
|
814322
814357
|
case "array":
|
|
814323
|
-
return this.hasExample(schema2.value);
|
|
814358
|
+
return this.hasExample(schema2.value, depth + 1, visitedSchemaIds, options);
|
|
814324
814359
|
case "enum":
|
|
814325
814360
|
return schema2.example != null;
|
|
814326
814361
|
case "literal":
|
|
814327
814362
|
return false;
|
|
814328
814363
|
case "map":
|
|
814329
|
-
return schema2.key.schema.example != null && this.hasExample(schema2.value);
|
|
814364
|
+
return schema2.key.schema.example != null && this.hasExample(schema2.value, depth + 1, visitedSchemaIds, options);
|
|
814330
814365
|
case "object": {
|
|
814331
814366
|
const objectExample = schema2.fullExamples != null && schema2.fullExamples.length > 0;
|
|
814332
814367
|
if (objectExample) {
|
|
814333
814368
|
return true;
|
|
814334
814369
|
}
|
|
814335
814370
|
for (const property5 of schema2.properties) {
|
|
814336
|
-
if (this.hasExample(property5.schema)) {
|
|
814371
|
+
if (this.hasExample(property5.schema, depth + 1, visitedSchemaIds, options)) {
|
|
814337
814372
|
return true;
|
|
814338
814373
|
}
|
|
814339
814374
|
}
|
|
@@ -814343,19 +814378,25 @@ var ExampleTypeFactory = class {
|
|
|
814343
814378
|
return schema2.schema.example != null;
|
|
814344
814379
|
case "reference": {
|
|
814345
814380
|
const resolvedSchema = this.schemas[schema2.schema];
|
|
814346
|
-
if (resolvedSchema != null) {
|
|
814347
|
-
|
|
814381
|
+
if (resolvedSchema != null && !visitedSchemaIds.has(schema2.schema)) {
|
|
814382
|
+
visitedSchemaIds.add(schema2.schema);
|
|
814383
|
+
const hasExample = this.hasExample(resolvedSchema, depth, visitedSchemaIds, options);
|
|
814384
|
+
visitedSchemaIds.delete(schema2.schema);
|
|
814385
|
+
return hasExample;
|
|
814348
814386
|
}
|
|
814349
814387
|
return false;
|
|
814350
814388
|
}
|
|
814351
814389
|
case "unknown":
|
|
814352
814390
|
return schema2.example != null;
|
|
814353
814391
|
case "oneOf":
|
|
814354
|
-
return Object.values(schema2.value.schemas).some((schema3) => this.hasExample(schema3));
|
|
814392
|
+
return Object.values(schema2.value.schemas).some((schema3) => this.hasExample(schema3, depth, visitedSchemaIds, options));
|
|
814355
814393
|
default:
|
|
814356
814394
|
return false;
|
|
814357
814395
|
}
|
|
814358
814396
|
}
|
|
814397
|
+
exceedsMaxCheckerDepth(depth, options) {
|
|
814398
|
+
return depth > (options.maxCheckerDepth ?? 0);
|
|
814399
|
+
}
|
|
814359
814400
|
exceedsMaxDepth(depth, options) {
|
|
814360
814401
|
return depth > (options.maxDepth ?? 0);
|
|
814361
814402
|
}
|
|
@@ -816610,7 +816651,7 @@ function replaceWithSchemaReference({ openapi, replaceReference, schemaReference
|
|
|
816610
816651
|
}
|
|
816611
816652
|
|
|
816612
816653
|
// pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/v3/generateIr.js
|
|
816613
|
-
function generateIr(openApi, taskContext) {
|
|
816654
|
+
function generateIr({ openApi, taskContext, disableExamples }) {
|
|
816614
816655
|
var _a2, _b2, _c2;
|
|
816615
816656
|
openApi = runResolutions({ openapi: openApi });
|
|
816616
816657
|
const securitySchemes = Object.fromEntries(Object.entries(((_a2 = openApi.components) == null ? void 0 : _a2.securitySchemes) ?? {}).map(([key2, securityScheme]) => {
|
|
@@ -816686,7 +816727,7 @@ function generateIr(openApi, taskContext) {
|
|
|
816686
816727
|
const exampleEndpointFactory = new ExampleEndpointFactory(schemasWithExample, context.logger);
|
|
816687
816728
|
const endpoints = endpointsWithExample.map((endpointWithExample) => {
|
|
816688
816729
|
let examples = endpointWithExample.examples;
|
|
816689
|
-
if (examples.length === 0 || examples.every(hasIncompleteExample)) {
|
|
816730
|
+
if (!disableExamples && (examples.length === 0 || examples.every(hasIncompleteExample))) {
|
|
816690
816731
|
const endpointExample = exampleEndpointFactory.buildEndpointExample(endpointWithExample);
|
|
816691
816732
|
if (endpointExample != null) {
|
|
816692
816733
|
examples = [endpointExample, ...endpointWithExample.examples];
|
|
@@ -816822,13 +816863,17 @@ function hasIncompleteExample(example) {
|
|
|
816822
816863
|
}
|
|
816823
816864
|
|
|
816824
816865
|
// pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/v2/generateIr.js
|
|
816825
|
-
async function generateIr2(openApi, taskContext) {
|
|
816866
|
+
async function generateIr2({ openApi, taskContext, disableExamples }) {
|
|
816826
816867
|
const conversionResult = await (0, import_swagger2openapi.convertObj)(openApi, {});
|
|
816827
|
-
return generateIr(
|
|
816868
|
+
return generateIr({
|
|
816869
|
+
openApi: conversionResult.openapi,
|
|
816870
|
+
taskContext,
|
|
816871
|
+
disableExamples
|
|
816872
|
+
});
|
|
816828
816873
|
}
|
|
816829
816874
|
|
|
816830
816875
|
// pnp:/home/circleci/project/packages/cli/openapi-parser/lib/openapi/parse.js
|
|
816831
|
-
async function parse2({ absolutePathToAsyncAPI, absolutePathToOpenAPI, absolutePathToOpenAPIOverrides, taskContext }) {
|
|
816876
|
+
async function parse2({ absolutePathToAsyncAPI, absolutePathToOpenAPI, absolutePathToOpenAPIOverrides, disableExamples, taskContext }) {
|
|
816832
816877
|
let parsedAsyncAPI = {
|
|
816833
816878
|
schemas: {},
|
|
816834
816879
|
channel: void 0
|
|
@@ -816844,9 +816889,17 @@ async function parse2({ absolutePathToAsyncAPI, absolutePathToOpenAPI, absoluteP
|
|
|
816844
816889
|
});
|
|
816845
816890
|
let openApiIr = void 0;
|
|
816846
816891
|
if (isOpenApiV3(openApiDocument)) {
|
|
816847
|
-
openApiIr = generateIr(
|
|
816892
|
+
openApiIr = generateIr({
|
|
816893
|
+
openApi: openApiDocument,
|
|
816894
|
+
taskContext,
|
|
816895
|
+
disableExamples
|
|
816896
|
+
});
|
|
816848
816897
|
} else if (isOpenApiV2(openApiDocument)) {
|
|
816849
|
-
openApiIr = await generateIr2(
|
|
816898
|
+
openApiIr = await generateIr2({
|
|
816899
|
+
openApi: openApiDocument,
|
|
816900
|
+
taskContext,
|
|
816901
|
+
disableExamples
|
|
816902
|
+
});
|
|
816850
816903
|
}
|
|
816851
816904
|
if (openApiIr != null) {
|
|
816852
816905
|
return {
|
|
@@ -818589,11 +818642,12 @@ function convert2({ openApiIr, taskContext }) {
|
|
|
818589
818642
|
|
|
818590
818643
|
// pnp:/home/circleci/project/packages/cli/workspace-loader/lib/utils/convertOpenApiWorkspaceToFernWorkspace.js
|
|
818591
818644
|
async function getOpenAPIIRFromOpenAPIWorkspace(openapiWorkspace, context) {
|
|
818592
|
-
var _a2;
|
|
818645
|
+
var _a2, _b2;
|
|
818593
818646
|
return await parse2({
|
|
818594
818647
|
absolutePathToAsyncAPI: openapiWorkspace.absolutePathToAsyncAPI,
|
|
818595
818648
|
absolutePathToOpenAPI: openapiWorkspace.absolutePathToOpenAPI,
|
|
818596
818649
|
absolutePathToOpenAPIOverrides: (_a2 = openapiWorkspace.generatorsConfiguration) == null ? void 0 : _a2.absolutePathToOpenAPIOverrides,
|
|
818650
|
+
disableExamples: (_b2 = openapiWorkspace.generatorsConfiguration) == null ? void 0 : _b2.disableOpenAPIExamples,
|
|
818597
818651
|
taskContext: context
|
|
818598
818652
|
});
|
|
818599
818653
|
}
|
|
@@ -825852,10 +825906,10 @@ var CliContext = class {
|
|
|
825852
825906
|
return "fern-api";
|
|
825853
825907
|
}
|
|
825854
825908
|
getPackageVersion() {
|
|
825855
|
-
if ("0.19.0-
|
|
825909
|
+
if ("0.19.0-rc3" == null) {
|
|
825856
825910
|
this.logger.error("CLI_VERSION is not defined");
|
|
825857
825911
|
}
|
|
825858
|
-
return "0.19.0-
|
|
825912
|
+
return "0.19.0-rc3";
|
|
825859
825913
|
}
|
|
825860
825914
|
getCliName() {
|
|
825861
825915
|
if ("fern" == null) {
|