fern-api 0.34.0 → 0.35.0-rc0
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 +53 -31
- package/package.json +1 -1
package/bundle.cjs
CHANGED
|
@@ -1189910,7 +1189910,7 @@ var AccessTokenPosthogManager = class {
|
|
|
1189910
1189910
|
properties: {
|
|
1189911
1189911
|
...event,
|
|
1189912
1189912
|
...event.properties,
|
|
1189913
|
-
version: "0.
|
|
1189913
|
+
version: "0.35.0-rc0",
|
|
1189914
1189914
|
usingAccessToken: true
|
|
1189915
1189915
|
}
|
|
1189916
1189916
|
});
|
|
@@ -1189972,7 +1189972,7 @@ var UserPosthogManager = class {
|
|
|
1189972
1189972
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
1189973
1189973
|
event: "CLI",
|
|
1189974
1189974
|
properties: {
|
|
1189975
|
-
version: "0.
|
|
1189975
|
+
version: "0.35.0-rc0",
|
|
1189976
1189976
|
...event,
|
|
1189977
1189977
|
...event.properties
|
|
1189978
1189978
|
}
|
|
@@ -1191569,6 +1191569,7 @@ async function parseYamlFiles(files) {
|
|
|
1191569
1191569
|
function parseFilePath(file) {
|
|
1191570
1191570
|
try {
|
|
1191571
1191571
|
parsedFiles[file.relativeFilepath] = {
|
|
1191572
|
+
defaultUrl: void 0,
|
|
1191572
1191573
|
contents: js_yaml_default.load(file.fileContents, {
|
|
1191573
1191574
|
schema: js_yaml_default.CORE_SCHEMA
|
|
1191574
1191575
|
}),
|
|
@@ -1192728,7 +1192729,7 @@ async function visitPackageMarkerYamlAst(contents, visitor) {
|
|
|
1192728
1192729
|
channel: noop,
|
|
1192729
1192730
|
export: async (export_) => {
|
|
1192730
1192731
|
var _a5;
|
|
1192731
|
-
await ((_a5 = visitor.export) == null ? void 0 : _a5.call(visitor, export_, ["export"]));
|
|
1192732
|
+
await ((_a5 = visitor.export) == null ? void 0 : _a5.call(visitor, typeof export_ === "string" ? export_ : export_ == null ? void 0 : export_.dependency, ["export"]));
|
|
1192732
1192733
|
},
|
|
1192733
1192734
|
navigation: async (navigation) => {
|
|
1192734
1192735
|
var _a5;
|
|
@@ -1192744,6 +1192745,7 @@ async function visitRootApiFileYamlAst(contents, visitor) {
|
|
|
1192744
1192745
|
await visitObject(contents, {
|
|
1192745
1192746
|
version: noop,
|
|
1192746
1192747
|
name: noop,
|
|
1192748
|
+
"default-url": noop,
|
|
1192747
1192749
|
"display-name": noop,
|
|
1192748
1192750
|
imports: noop,
|
|
1192749
1192751
|
auth: noop,
|
|
@@ -1203290,8 +1203292,12 @@ var DefinitionFileSchema = z.strictObject({
|
|
|
1203290
1203292
|
});
|
|
1203291
1203293
|
|
|
1203292
1203294
|
// pnp:/home/runner/work/fern/fern/packages/cli/yaml/yaml-schema/lib/schemas/file-schemas/PackageMarkerFileSchema.js
|
|
1203295
|
+
var ExportSchema = z.object({
|
|
1203296
|
+
dependency: z.string(),
|
|
1203297
|
+
url: z.optional(z.string())
|
|
1203298
|
+
});
|
|
1203293
1203299
|
var PackageMarkerFileSchema = DefinitionFileSchema.extend({
|
|
1203294
|
-
export: z.optional(z.string()),
|
|
1203300
|
+
export: z.optional(z.union([z.string(), ExportSchema])),
|
|
1203295
1203301
|
navigation: z.optional(z.union([z.string(), z.array(z.string())]))
|
|
1203296
1203302
|
});
|
|
1203297
1203303
|
|
|
@@ -1203323,6 +1203329,7 @@ var RootApiFileSchema = z.strictObject({
|
|
|
1203323
1203329
|
auth: z.optional(ApiAuthSchema),
|
|
1203324
1203330
|
"auth-schemes": z.optional(z.record(AuthSchemeDeclarationSchema)),
|
|
1203325
1203331
|
headers: z.optional(z.record(z.string(), HttpHeaderSchema)),
|
|
1203332
|
+
"default-url": z.optional(z.string()),
|
|
1203326
1203333
|
"default-environment": z.optional(z.string().or(z.null())),
|
|
1203327
1203334
|
environments: z.optional(z.record(z.string(), EnvironmentSchema)),
|
|
1203328
1203335
|
"error-discrimination": z.optional(ErrorDiscriminationSchema),
|
|
@@ -1203923,14 +1203930,17 @@ async function processPackageMarkers({ dependenciesConfiguration, structuralVali
|
|
|
1203923
1203930
|
};
|
|
1203924
1203931
|
} else {
|
|
1203925
1203932
|
const loadDependencyResult = await loadDependency({
|
|
1203926
|
-
dependencyName: packageMarker.contents.export,
|
|
1203933
|
+
dependencyName: typeof packageMarker.contents.export === "string" ? packageMarker.contents.export : packageMarker.contents.export.dependency,
|
|
1203927
1203934
|
dependenciesConfiguration,
|
|
1203928
1203935
|
context,
|
|
1203929
1203936
|
rootApiFile: structuralValidationResult.rootApiFile.contents,
|
|
1203930
1203937
|
cliVersion
|
|
1203931
1203938
|
});
|
|
1203932
1203939
|
if (loadDependencyResult.didSucceed) {
|
|
1203933
|
-
importedDefinitions[dirname(pathOfPackageMarker)] =
|
|
1203940
|
+
importedDefinitions[dirname(pathOfPackageMarker)] = {
|
|
1203941
|
+
definition: loadDependencyResult.definition,
|
|
1203942
|
+
url: typeof packageMarker.contents.export === "object" ? packageMarker.contents.export.url : void 0
|
|
1203943
|
+
};
|
|
1203934
1203944
|
} else {
|
|
1203935
1203945
|
failures[pathOfPackageMarker] = loadDependencyResult.failure;
|
|
1203936
1203946
|
}
|
|
@@ -1203971,6 +1203981,7 @@ function validateStructureOfYamlFiles({ files, absolutePathToDefinition }) {
|
|
|
1203971
1203981
|
const maybeValidFileContents = RootApiFileSchema.safeParse(parsedFileContents);
|
|
1203972
1203982
|
if (maybeValidFileContents.success) {
|
|
1203973
1203983
|
rootApiFile = {
|
|
1203984
|
+
defaultUrl: maybeValidFileContents.data["default-url"],
|
|
1203974
1203985
|
contents: maybeValidFileContents.data,
|
|
1203975
1203986
|
rawContents: file.rawContents
|
|
1203976
1203987
|
};
|
|
@@ -1203981,6 +1203992,7 @@ function validateStructureOfYamlFiles({ files, absolutePathToDefinition }) {
|
|
|
1203981
1203992
|
const maybeValidFileContents = PackageMarkerFileSchema.safeParse(parsedFileContents);
|
|
1203982
1203993
|
if (maybeValidFileContents.success) {
|
|
1203983
1203994
|
packageMarkers[relativeFilepath] = {
|
|
1203995
|
+
defaultUrl: typeof maybeValidFileContents.data.export === "object" ? maybeValidFileContents.data.export.url : void 0,
|
|
1203984
1203996
|
contents: maybeValidFileContents.data,
|
|
1203985
1203997
|
rawContents: file.rawContents
|
|
1203986
1203998
|
};
|
|
@@ -1203991,6 +1204003,7 @@ function validateStructureOfYamlFiles({ files, absolutePathToDefinition }) {
|
|
|
1203991
1204003
|
const maybeValidFileContents = DefinitionFileSchema.safeParse(parsedFileContents);
|
|
1203992
1204004
|
if (maybeValidFileContents.success) {
|
|
1203993
1204005
|
namesDefinitionFiles[relativeFilepath] = {
|
|
1204006
|
+
defaultUrl: void 0,
|
|
1203994
1204007
|
contents: maybeValidFileContents.data,
|
|
1203995
1204008
|
rawContents: file.rawContents,
|
|
1203996
1204009
|
absoluteFilepath: join(absolutePathToDefinition, relativeFilepath)
|
|
@@ -1214291,6 +1214304,7 @@ var OSSWorkspace = class extends AbstractAPIWorkspace {
|
|
|
1214291
1214304
|
return {
|
|
1214292
1214305
|
absoluteFilepath: AbsoluteFilePath.of("/DUMMY_PATH"),
|
|
1214293
1214306
|
rootApiFile: {
|
|
1214307
|
+
defaultUrl: definition3.rootApiFile["default-url"],
|
|
1214294
1214308
|
contents: definition3.rootApiFile,
|
|
1214295
1214309
|
rawContents: js_yaml_default.dump(definition3.rootApiFile)
|
|
1214296
1214310
|
},
|
|
@@ -1214554,26 +1214568,30 @@ async function validateSchema2({ value, context, filepathBeingParsed }) {
|
|
|
1214554
1214568
|
}
|
|
1214555
1214569
|
|
|
1214556
1214570
|
// pnp:/home/runner/work/fern/fern/packages/cli/workspace-loader/lib/utils/getAllNamedDefinitionFiles.js
|
|
1214557
|
-
function getAllNamedDefinitionFiles(definition3) {
|
|
1214571
|
+
function getAllNamedDefinitionFiles(definition3, opts = {}) {
|
|
1214558
1214572
|
return {
|
|
1214559
|
-
...definition3.namedDefinitionFiles,
|
|
1214573
|
+
...Object.fromEntries(entries(definition3.namedDefinitionFiles).map(([path44, file]) => {
|
|
1214574
|
+
return [path44, { ...file, defaultUrl: opts.defaultURL }];
|
|
1214575
|
+
})),
|
|
1214560
1214576
|
...entries(definition3.importedDefinitions).reduce((acc, [pathToImportedDefinition, definition4]) => {
|
|
1214561
1214577
|
return {
|
|
1214562
1214578
|
...acc,
|
|
1214563
|
-
...mapKeys_default(getAllNamedDefinitionFiles(definition4), (_file, path44) => join(pathToImportedDefinition, RelativeFilePath.of(path44)))
|
|
1214579
|
+
...mapKeys_default(getAllNamedDefinitionFiles(definition4.definition, { defaultURL: definition4.url }), (_file, path44) => join(pathToImportedDefinition, RelativeFilePath.of(path44)))
|
|
1214564
1214580
|
};
|
|
1214565
1214581
|
}, {})
|
|
1214566
1214582
|
};
|
|
1214567
1214583
|
}
|
|
1214568
1214584
|
|
|
1214569
1214585
|
// pnp:/home/runner/work/fern/fern/packages/cli/workspace-loader/lib/utils/getAllPackageMarkers.js
|
|
1214570
|
-
function getAllPackageMarkers(definition3) {
|
|
1214586
|
+
function getAllPackageMarkers(definition3, opts = {}) {
|
|
1214571
1214587
|
return {
|
|
1214572
|
-
...definition3.packageMarkers,
|
|
1214588
|
+
...Object.fromEntries(entries(definition3.packageMarkers).map(([path44, file]) => {
|
|
1214589
|
+
return [path44, { ...file, defaultUrl: opts.defaultURL }];
|
|
1214590
|
+
})),
|
|
1214573
1214591
|
...entries(definition3.importedDefinitions).reduce((acc, [pathToImportedDefinition, definition4]) => {
|
|
1214574
1214592
|
return {
|
|
1214575
1214593
|
...acc,
|
|
1214576
|
-
...mapKeys_default(getAllPackageMarkers(definition4), (_file, path44) => join(pathToImportedDefinition, RelativeFilePath.of(path44)))
|
|
1214594
|
+
...mapKeys_default(getAllPackageMarkers(definition4.definition, { defaultURL: definition4.url }), (_file, path44) => join(pathToImportedDefinition, RelativeFilePath.of(path44)))
|
|
1214577
1214595
|
};
|
|
1214578
1214596
|
}, {})
|
|
1214579
1214597
|
};
|
|
@@ -1214598,7 +1214616,8 @@ var import_path22 = __toESM(require("path"));
|
|
|
1214598
1214616
|
async function visitAllDefinitionFiles(workspace, visitor) {
|
|
1214599
1214617
|
for (const [relativeFilepath, file] of entries(getAllDefinitionFiles(workspace.definition))) {
|
|
1214600
1214618
|
await visitor(relativeFilepath, file.contents, {
|
|
1214601
|
-
isPackageMarker: import_path22.default.basename(relativeFilepath) === FERN_PACKAGE_MARKER_FILENAME
|
|
1214619
|
+
isPackageMarker: import_path22.default.basename(relativeFilepath) === FERN_PACKAGE_MARKER_FILENAME,
|
|
1214620
|
+
defaultUrl: file.defaultUrl
|
|
1214602
1214621
|
});
|
|
1214603
1214622
|
}
|
|
1214604
1214623
|
}
|
|
@@ -1218195,10 +1218214,10 @@ var CliContext = class {
|
|
|
1218195
1218214
|
return "fern-api";
|
|
1218196
1218215
|
}
|
|
1218197
1218216
|
getPackageVersion() {
|
|
1218198
|
-
if ("0.
|
|
1218217
|
+
if ("0.35.0-rc0" == null) {
|
|
1218199
1218218
|
this.logger.error("CLI_VERSION is not defined");
|
|
1218200
1218219
|
}
|
|
1218201
|
-
return "0.
|
|
1218220
|
+
return "0.35.0-rc0";
|
|
1218202
1218221
|
}
|
|
1218203
1218222
|
getCliName() {
|
|
1218204
1218223
|
if ("fern" == null) {
|
|
@@ -1219736,8 +1219755,9 @@ function constructRootApiFileContext({ casingsGenerator, rootApiFile }) {
|
|
|
1219736
1219755
|
rootApiFile
|
|
1219737
1219756
|
});
|
|
1219738
1219757
|
}
|
|
1219739
|
-
function constructFernFileContext({ relativeFilepath, definitionFile, casingsGenerator, rootApiFile }) {
|
|
1219758
|
+
function constructFernFileContext({ defaultUrl, relativeFilepath, definitionFile, casingsGenerator, rootApiFile }) {
|
|
1219740
1219759
|
const file = {
|
|
1219760
|
+
defaultUrl,
|
|
1219741
1219761
|
relativeFilepath,
|
|
1219742
1219762
|
fernFilepath: convertToFernFilepath({ relativeFilepath, casingsGenerator }),
|
|
1219743
1219763
|
imports: mapValues_default2(definitionFile.imports ?? {}, RelativeFilePath.of),
|
|
@@ -1221727,7 +1221747,7 @@ function convertResponseErrors({ errors, file }) {
|
|
|
1221727
1221747
|
}
|
|
1221728
1221748
|
|
|
1221729
1221749
|
// pnp:/home/runner/work/fern/fern/packages/cli/generation/ir-generator/lib/converters/services/convertHttpService.js
|
|
1221730
|
-
async function convertHttpService({ rootPathParameters, serviceDefinition, file, errorResolver, typeResolver, propertyResolver, exampleResolver, variableResolver, globalErrors, workspace }) {
|
|
1221750
|
+
async function convertHttpService({ rootDefaultUrl, rootPathParameters, serviceDefinition, file, errorResolver, typeResolver, propertyResolver, exampleResolver, variableResolver, globalErrors, workspace }) {
|
|
1221731
1221751
|
const servicePathParameters = await convertPathParameters2({
|
|
1221732
1221752
|
pathParameters: serviceDefinition["path-parameters"],
|
|
1221733
1221753
|
location: PathParameterLocation.Service,
|
|
@@ -1221757,7 +1221777,7 @@ async function convertHttpService({ rootPathParameters, serviceDefinition, file,
|
|
|
1221757
1221777
|
displayName: endpoint["display-name"],
|
|
1221758
1221778
|
auth: endpoint.auth ?? serviceDefinition.auth,
|
|
1221759
1221779
|
idempotent: endpoint.idempotent ?? serviceDefinition.idempotent ?? false,
|
|
1221760
|
-
baseUrl: endpoint.url ?? serviceDefinition.url,
|
|
1221780
|
+
baseUrl: endpoint.url ?? serviceDefinition.url ?? rootDefaultUrl,
|
|
1221761
1221781
|
method: endpoint.method != null ? convertHttpMethod(endpoint.method) : HttpMethod4.Post,
|
|
1221762
1221782
|
path: constructHttpPath(endpoint.path),
|
|
1221763
1221783
|
fullPath: constructHttpPath(file.rootApiFile["base-path"] != null ? urlJoin(file.rootApiFile["base-path"], serviceDefinition["base-path"], endpoint.path) : urlJoin(serviceDefinition["base-path"], endpoint.path)),
|
|
@@ -1225587,6 +1225607,7 @@ async function generateIntermediateRepresentation({ workspace, generationLanguag
|
|
|
1225587
1225607
|
return;
|
|
1225588
1225608
|
}
|
|
1225589
1225609
|
const convertedHttpService = await convertHttpService({
|
|
1225610
|
+
rootDefaultUrl: file.defaultUrl ?? workspace.definition.rootApiFile.contents["default-url"],
|
|
1225590
1225611
|
rootPathParameters: intermediateRepresentation.pathParameters,
|
|
1225591
1225612
|
serviceDefinition: service,
|
|
1225592
1225613
|
file,
|
|
@@ -1225669,12 +1225690,13 @@ async function generateIntermediateRepresentation({ workspace, generationLanguag
|
|
|
1225669
1225690
|
}
|
|
1225670
1225691
|
});
|
|
1225671
1225692
|
};
|
|
1225672
|
-
await visitAllDefinitionFiles(workspace, async (relativeFilepath, file) => {
|
|
1225693
|
+
await visitAllDefinitionFiles(workspace, async (relativeFilepath, file, metadata) => {
|
|
1225673
1225694
|
await visitDefinitionFile(constructFernFileContext({
|
|
1225674
1225695
|
relativeFilepath,
|
|
1225675
1225696
|
definitionFile: file,
|
|
1225676
1225697
|
casingsGenerator,
|
|
1225677
|
-
rootApiFile: workspace.definition.rootApiFile.contents
|
|
1225698
|
+
rootApiFile: workspace.definition.rootApiFile.contents,
|
|
1225699
|
+
defaultUrl: metadata.defaultUrl
|
|
1225678
1225700
|
}));
|
|
1225679
1225701
|
});
|
|
1225680
1225702
|
await visitAllPackageMarkers(workspace, async (relativeFilepath, packageMarker) => {
|
|
@@ -1259132,9 +1259154,13 @@ var ValidServiceUrlsRule = {
|
|
|
1259132
1259154
|
create: ({ workspace }) => {
|
|
1259133
1259155
|
const urlIds = getAllEnvironmentUrlIds(workspace);
|
|
1259134
1259156
|
const validateBaseUrl = (url) => {
|
|
1259157
|
+
var _a5;
|
|
1259135
1259158
|
if (urlIds.includes(url)) {
|
|
1259136
1259159
|
return [];
|
|
1259137
1259160
|
}
|
|
1259161
|
+
if (urlIds.length === 0 && ((_a5 = workspace.definition.rootApiFile.contents) == null ? void 0 : _a5["default-url"]) != null) {
|
|
1259162
|
+
return [];
|
|
1259163
|
+
}
|
|
1259138
1259164
|
if (urlIds.length === 0) {
|
|
1259139
1259165
|
return [
|
|
1259140
1259166
|
{
|
|
@@ -1259162,6 +1259188,10 @@ var ValidServiceUrlsRule = {
|
|
|
1259162
1259188
|
return validateBaseUrl(url);
|
|
1259163
1259189
|
},
|
|
1259164
1259190
|
endpointBaseUrl: ({ baseUrl, service }) => {
|
|
1259191
|
+
var _a5;
|
|
1259192
|
+
if ((_a5 = workspace.definition.rootApiFile.contents) == null ? void 0 : _a5["default-url"]) {
|
|
1259193
|
+
return [];
|
|
1259194
|
+
}
|
|
1259165
1259195
|
if (baseUrl == null) {
|
|
1259166
1259196
|
if (urlIds.length === 0 || service.url != null) {
|
|
1259167
1259197
|
return [];
|
|
@@ -1259176,14 +1259206,6 @@ var ValidServiceUrlsRule = {
|
|
|
1259176
1259206
|
}
|
|
1259177
1259207
|
];
|
|
1259178
1259208
|
}
|
|
1259179
|
-
if (service.url != null) {
|
|
1259180
|
-
return [
|
|
1259181
|
-
{
|
|
1259182
|
-
severity: "error",
|
|
1259183
|
-
message: '"url" cannot be specified on both the service and endpoint'
|
|
1259184
|
-
}
|
|
1259185
|
-
];
|
|
1259186
|
-
}
|
|
1259187
1259209
|
return validateBaseUrl(baseUrl);
|
|
1259188
1259210
|
}
|
|
1259189
1259211
|
}
|
|
@@ -1270429,7 +1270451,7 @@ async function writeFernDefinition({ absolutePathToDefinitionDirectory, definiti
|
|
|
1270429
1270451
|
for (const [relativePath, importedDefinition] of Object.entries(definition3.importedDefinitions)) {
|
|
1270430
1270452
|
await writeFernDefinition({
|
|
1270431
1270453
|
absolutePathToDefinitionDirectory: join(absolutePathToDefinitionDirectory, RelativeFilePath.of(relativePath)),
|
|
1270432
|
-
definition: importedDefinition
|
|
1270454
|
+
definition: importedDefinition.definition
|
|
1270433
1270455
|
});
|
|
1270434
1270456
|
}
|
|
1270435
1270457
|
}
|
|
@@ -1274444,7 +1274466,7 @@ async function writeDefinitionForFernWorkspace({
|
|
|
1274444
1274466
|
workspace,
|
|
1274445
1274467
|
context
|
|
1274446
1274468
|
}) {
|
|
1274447
|
-
for (const [relativePath,
|
|
1274469
|
+
for (const [relativePath, importedDefinition] of Object.entries(workspace.definition.importedDefinitions)) {
|
|
1274448
1274470
|
const absolutePathToOutputDirectory = join(
|
|
1274449
1274471
|
workspace.absoluteFilepath,
|
|
1274450
1274472
|
RelativeFilePath.of(DEFINITION_DIRECTORY),
|
|
@@ -1274452,7 +1274474,7 @@ async function writeDefinitionForFernWorkspace({
|
|
|
1274452
1274474
|
RelativeFilePath.of(`.${DEFINITION_DIRECTORY}`)
|
|
1274453
1274475
|
);
|
|
1274454
1274476
|
await writeFernDefinition2({
|
|
1274455
|
-
definition:
|
|
1274477
|
+
definition: importedDefinition.definition,
|
|
1274456
1274478
|
absolutePathToOutputDirectory
|
|
1274457
1274479
|
});
|
|
1274458
1274480
|
context.logger.info(
|