diff --git a/package.json b/package.json index 16a974adac5..dce7ca97635 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ "seed:build": "pnpm --filter @fern-api/seed-cli dist:cli && echo 'Run packages/seed/dist/cli.cjs'", "publish": "pnpm -r publish --access public --no-git-checks --loglevel=verbose", "jsonschema": "pnpm definition-yml:jsonschema && pnpm api-yml:jsonschema && pnpm package-yml:jsonschema && pnpm docs-yml:jsonschema && pnpm generators-yml:jsonschema", - "definition-yml:jsonschema": "fern jsonschema fern.schema.json --api fern-definition --type file.DefinitionFileSchema && fern jsonschema packages/cli/lazy-fern-workspace/src/fern.schema.json --api fern-definition --type file.DefinitionFileSchema", - "api-yml:jsonschema": "fern jsonschema api-yml.schema.json --api fern-definition --type file.RootApiFileSchema && fern jsonschema packages/cli/lazy-fern-workspace/src/api-yml.schema.json --api fern-definition --type file.RootApiFileSchema", - "package-yml:jsonschema": "fern jsonschema package-yml.schema.json --api fern-definition --type file.PackageMarkerFileSchema && fern jsonschema packages/cli/lazy-fern-workspace/src/package-yml.schema.json --api fern-definition --type file.PackageMarkerFileSchema", + "definition-yml:jsonschema": "fern jsonschema fern.schema.json --api fern-definition --type file.DefinitionFileSchema && fern jsonschema packages/cli/workspace/lazy-fern-workspace/src/fern.schema.json --api fern-definition --type file.DefinitionFileSchema", + "api-yml:jsonschema": "fern jsonschema api-yml.schema.json --api fern-definition --type file.RootApiFileSchema && fern jsonschema packages/cli/workspace/lazy-fern-workspace/src/api-yml.schema.json --api fern-definition --type file.RootApiFileSchema", + "package-yml:jsonschema": "fern jsonschema package-yml.schema.json --api fern-definition --type file.PackageMarkerFileSchema && fern jsonschema packages/cli/workspace/lazy-fern-workspace/src/package-yml.schema.json --api fern-definition --type file.PackageMarkerFileSchema", "docs-yml:jsonschema": "fern jsonschema docs-yml.schema.json --api docs-yml --type docs.DocsConfiguration", "generators-yml:jsonschema": "fern jsonschema generators-yml.schema.json --api generators-yml --type generators.GeneratorsConfigurationSchema", "check-cli-release-blockers": "pnpm fern-script check-cli-release-blockers", diff --git a/packages/cli/api-importers/conjure/conjure-to-fern-tests/tsconfig.json b/packages/cli/api-importers/conjure/conjure-to-fern-tests/tsconfig.json index 4e0c9b97320..fef2c7eebc7 100644 --- a/packages/cli/api-importers/conjure/conjure-to-fern-tests/tsconfig.json +++ b/packages/cli/api-importers/conjure/conjure-to-fern-tests/tsconfig.json @@ -6,6 +6,6 @@ "references": [ { "path": "../../../../commons/fs-utils" }, { "path": "../../../task-context" }, - { "path": "../../../workspace-loader" }, + { "path": "../../../workspace/loader" }, ] } diff --git a/packages/cli/api-importers/openapi/openapi-ir-parser/src/index.ts b/packages/cli/api-importers/openapi/openapi-ir-parser/src/index.ts index ffc43c11c51..a8be3e8bc17 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-parser/src/index.ts +++ b/packages/cli/api-importers/openapi/openapi-ir-parser/src/index.ts @@ -1,5 +1,4 @@ export { type ParseOpenAPIOptions } from "./options"; -export { parse, type Document } from "./parse"; -export { InMemoryOpenAPILoader } from "./openapi/InMemoryOpenAPILoader"; +export { parse, type Document, type OpenAPIDocument, type SpecImportSettings } from "./parse"; export { FernOpenAPIExtension, XFernStreaming, FERN_TYPE_EXTENSIONS } from "./openapi/v3/extensions/fernExtensions"; export * from "./asyncapi/v2"; diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/package.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/package.json index 65ce3d2cbee..5c7d6399abc 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/package.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/package.json @@ -28,10 +28,10 @@ "depcheck": "depcheck" }, "dependencies": { + "@fern-api/browser-compatible-fern-workspace": "workspace:*", "@fern-api/fs-utils": "workspace:*", "@fern-api/task-context": "workspace:*", "@fern-api/lazy-fern-workspace": "workspace:*", - "@fern-api/openapi-ir-parser": "workspace:*", "@fern-api/workspace-loader": "workspace:*", "js-yaml": "^4.1.0", "openapi-types": "^12.1.3" diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi-ir.test.ts b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi-ir.test.ts index f77383127b7..88acaf8ff41 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi-ir.test.ts +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi-ir.test.ts @@ -3,10 +3,11 @@ import { createMockTaskContext } from "@fern-api/task-context"; import { loadAPIWorkspace } from "@fern-api/workspace-loader"; import { readdir } from "fs/promises"; import { OSSWorkspace } from "@fern-api/lazy-fern-workspace"; -import { InMemoryOpenAPILoader } from "@fern-api/openapi-ir-parser"; +import { InMemoryOpenAPILoader } from "@fern-api/browser-compatible-fern-workspace"; import fs from "fs/promises"; import { OpenAPI } from "openapi-types"; import yaml from "js-yaml"; + const FIXTURES_DIR = join(AbsoluteFilePath.of(__dirname), RelativeFilePath.of("fixtures")); // eslint-disable-next-line @typescript-eslint/no-misused-promises diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi.test.ts b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi.test.ts index bc796e85301..0eee6c5f4a0 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi.test.ts +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapi.test.ts @@ -28,7 +28,11 @@ describe("openapi-ir-to-fern", async () => { `Failed to load OpenAPI fixture ${fixture.name}\n${JSON.stringify(workspace.failures)}` ); } - const definition = await workspace.workspace.getDefinition({ context }); + const definition = await workspace.workspace.getDefinition({ + context, + absoluteFilePath: AbsoluteFilePath.of("/DUMMY_PATH") + }); + // eslint-disable-next-line jest/no-standalone-expect expect(definition).toMatchFileSnapshot(`./__snapshots__/openapi/${fixture.name}.json`); }, diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapiDocs.test.ts b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapiDocs.test.ts index f6d70ce1ecb..d9f63dde975 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapiDocs.test.ts +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/openapiDocs.test.ts @@ -28,10 +28,15 @@ describe("openapi-ir-to-fern docs", async () => { `Failed to load OpenAPI fixture ${fixture.name}\n${JSON.stringify(workspace.failures)}` ); } + const definition = await workspace.workspace.getDefinition( - { context }, + { + context, + absoluteFilePath: AbsoluteFilePath.of("/DUMMY_PATH") + }, { enableUniqueErrorsPerEndpoint: true, preserveSchemaIds: true } ); + // eslint-disable-next-line jest/no-standalone-expect expect(definition).toMatchFileSnapshot(`./__snapshots__/openapi-docs/${fixture.name}.json`); }, diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/tsconfig.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/tsconfig.json index fc70f2258e0..c4641a0f677 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/tsconfig.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/tsconfig.json @@ -22,13 +22,13 @@ "path": "../../../task-context" }, { - "path": "../../../workspace-loader" + "path": "../../../workspace/browser-compatible-fern-workspace" }, { - "path": "../../../lazy-fern-workspace" + "path": "../../../workspace/loader" }, { - "path": "../openapi-ir-parser" + "path": "../../../workspace/lazy-fern-workspace" } ] } \ No newline at end of file diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern/tsconfig.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern/tsconfig.json index cf3454b414b..7ef4b807ef4 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern/tsconfig.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern/tsconfig.json @@ -30,9 +30,6 @@ { "path": "../../../task-context" }, - { - "path": "../../../workspace-commons" - }, { "path": "../../commons" }, diff --git a/packages/cli/cli-source-resolver/tsconfig.json b/packages/cli/cli-source-resolver/tsconfig.json index 0f2e6e9fda5..12044a57e80 100644 --- a/packages/cli/cli-source-resolver/tsconfig.json +++ b/packages/cli/cli-source-resolver/tsconfig.json @@ -25,7 +25,7 @@ "path": "../task-context" }, { - "path": "../workspace-commons" + "path": "../workspace/commons" } ] } \ No newline at end of file diff --git a/packages/cli/cli/tsconfig.json b/packages/cli/cli/tsconfig.json index 7bdf037c2e9..bf20e110091 100644 --- a/packages/cli/cli/tsconfig.json +++ b/packages/cli/cli/tsconfig.json @@ -88,13 +88,13 @@ "path": "../task-context" }, { - "path": "../workspace-loader" + "path": "../workspace/loader" }, { - "path": "../workspace-commons" + "path": "../workspace/commons" }, { - "path": "../lazy-fern-workspace" + "path": "../workspace/lazy-fern-workspace" }, { "path": "../yaml/docs-validator" diff --git a/packages/cli/docs-resolver/tsconfig.json b/packages/cli/docs-resolver/tsconfig.json index bacae7c13fe..d01de4bef32 100644 --- a/packages/cli/docs-resolver/tsconfig.json +++ b/packages/cli/docs-resolver/tsconfig.json @@ -37,7 +37,7 @@ "path": "../task-context" }, { - "path": "../workspace-loader" + "path": "../workspace/loader" } ] } \ No newline at end of file diff --git a/packages/cli/fern-definition/formatter/tsconfig.json b/packages/cli/fern-definition/formatter/tsconfig.json index 64cebae5a20..f8af1a19d52 100644 --- a/packages/cli/fern-definition/formatter/tsconfig.json +++ b/packages/cli/fern-definition/formatter/tsconfig.json @@ -6,7 +6,7 @@ { "path": "../../../commons/core-utils" }, { "path": "../../../commons/fs-utils" }, { "path": "../../task-context" }, - { "path": "../../workspace-commons" }, + { "path": "../../workspace/commons" }, { "path": "../schema" } ] } diff --git a/packages/cli/fern-definition/ir-to-jsonschema/tsconfig.json b/packages/cli/fern-definition/ir-to-jsonschema/tsconfig.json index 5220813a0e9..84cfb0922da 100644 --- a/packages/cli/fern-definition/ir-to-jsonschema/tsconfig.json +++ b/packages/cli/fern-definition/ir-to-jsonschema/tsconfig.json @@ -31,7 +31,7 @@ "path": "../../task-context" }, { - "path": "../../workspace-loader" + "path": "../../workspace/loader" }, ] } \ No newline at end of file diff --git a/packages/cli/fern-definition/validator/tsconfig.json b/packages/cli/fern-definition/validator/tsconfig.json index 271b55b717c..728387aae1d 100644 --- a/packages/cli/fern-definition/validator/tsconfig.json +++ b/packages/cli/fern-definition/validator/tsconfig.json @@ -31,10 +31,10 @@ "path": "../../task-context" }, { - "path": "../../workspace-commons" + "path": "../../workspace/commons" }, { - "path": "../../lazy-fern-workspace" + "path": "../../workspace/lazy-fern-workspace" }, { "path": "../schema" diff --git a/packages/cli/generation/ir-generator-tests/tsconfig.json b/packages/cli/generation/ir-generator-tests/tsconfig.json index d42aa2d6b23..c3eafb7b9e0 100644 --- a/packages/cli/generation/ir-generator-tests/tsconfig.json +++ b/packages/cli/generation/ir-generator-tests/tsconfig.json @@ -31,10 +31,10 @@ "path": "../../task-context" }, { - "path": "../../workspace-loader" + "path": "../../workspace/loader" }, { - "path": "../../workspace-commons" + "path": "../../workspace/commons" }, { "path": "../../fern-definition/schema" diff --git a/packages/cli/generation/ir-generator/tsconfig.json b/packages/cli/generation/ir-generator/tsconfig.json index d88b235faed..33546204d6a 100644 --- a/packages/cli/generation/ir-generator/tsconfig.json +++ b/packages/cli/generation/ir-generator/tsconfig.json @@ -25,7 +25,7 @@ "path": "../../task-context" }, { - "path": "../../workspace-commons" + "path": "../../workspace/commons" }, { "path": "../../fern-definition/schema" diff --git a/packages/cli/generation/ir-migrations/tsconfig.json b/packages/cli/generation/ir-migrations/tsconfig.json index 1a1aa90fe2a..6a67090c254 100644 --- a/packages/cli/generation/ir-migrations/tsconfig.json +++ b/packages/cli/generation/ir-migrations/tsconfig.json @@ -34,7 +34,7 @@ "path": "../../task-context" }, { - "path": "../../workspace-loader" + "path": "../../workspace/loader" }, { "path": "../ir-generator" diff --git a/packages/cli/generation/local-generation/local-workspace-runner/src/runLocalGenerationForWorkspace.ts b/packages/cli/generation/local-generation/local-workspace-runner/src/runLocalGenerationForWorkspace.ts index 6cf3beac118..13d0f5f37b4 100644 --- a/packages/cli/generation/local-generation/local-workspace-runner/src/runLocalGenerationForWorkspace.ts +++ b/packages/cli/generation/local-generation/local-workspace-runner/src/runLocalGenerationForWorkspace.ts @@ -1,6 +1,9 @@ import { fernConfigJson, generatorsYml } from "@fern-api/configuration"; import { TaskContext } from "@fern-api/task-context"; -import { AbstractAPIWorkspace, getOSSWorkspaceSettingsFromGeneratorInvocation } from "@fern-api/workspace-loader"; +import { + AbstractAPIWorkspace, + getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation +} from "@fern-api/workspace-loader"; import chalk from "chalk"; import os from "os"; import path from "path"; @@ -32,7 +35,7 @@ export async function runLocalGenerationForWorkspace({ } else { const fernWorkspace = await workspace.toFernWorkspace( { context }, - getOSSWorkspaceSettingsFromGeneratorInvocation(generatorInvocation) + getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation(generatorInvocation) ); await writeFilesToDiskAndRunGenerator({ diff --git a/packages/cli/generation/local-generation/local-workspace-runner/tsconfig.json b/packages/cli/generation/local-generation/local-workspace-runner/tsconfig.json index 62801b823f9..4c9e87dc705 100644 --- a/packages/cli/generation/local-generation/local-workspace-runner/tsconfig.json +++ b/packages/cli/generation/local-generation/local-workspace-runner/tsconfig.json @@ -34,10 +34,10 @@ "path": "../../../task-context" }, { - "path": "../../../workspace-loader" + "path": "../../../workspace/loader" }, { - "path": "../../../workspace-commons" + "path": "../../../workspace/commons" }, { "path": "../../ir-generator" diff --git a/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForAPIWorkspace.ts b/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForAPIWorkspace.ts index 5778ceb89fa..94ac0c44f4a 100644 --- a/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForAPIWorkspace.ts +++ b/packages/cli/generation/remote-generation/remote-workspace-runner/src/runRemoteGenerationForAPIWorkspace.ts @@ -2,7 +2,10 @@ import { FernToken } from "@fern-api/auth"; import { fernConfigJson, generatorsYml } from "@fern-api/configuration"; import { AbsoluteFilePath } from "@fern-api/fs-utils"; import { TaskContext } from "@fern-api/task-context"; -import { AbstractAPIWorkspace, getOSSWorkspaceSettingsFromGeneratorInvocation } from "@fern-api/workspace-loader"; +import { + AbstractAPIWorkspace, + getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation +} from "@fern-api/workspace-loader"; import { FernFiddle } from "@fern-fern/fiddle-sdk"; import { downloadSnippetsForTask } from "./downloadSnippetsForTask"; import { runRemoteGenerationForGenerator } from "./runRemoteGenerationForGenerator"; @@ -49,7 +52,7 @@ export async function runRemoteGenerationForAPIWorkspace({ context.runInteractiveTask({ name: generatorInvocation.name }, async (interactiveTaskContext) => { const fernWorkspace = await workspace.toFernWorkspace( { context }, - getOSSWorkspaceSettingsFromGeneratorInvocation(generatorInvocation) + getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation(generatorInvocation) ); const remoteTaskHandlerResponse = await runRemoteGenerationForGenerator({ diff --git a/packages/cli/generation/remote-generation/remote-workspace-runner/tsconfig.json b/packages/cli/generation/remote-generation/remote-workspace-runner/tsconfig.json index e45884153ac..575ed2f78e3 100644 --- a/packages/cli/generation/remote-generation/remote-workspace-runner/tsconfig.json +++ b/packages/cli/generation/remote-generation/remote-workspace-runner/tsconfig.json @@ -43,7 +43,7 @@ "path": "../../../task-context" }, { - "path": "../../../workspace-loader" + "path": "../../../workspace/loader" }, { "path": "../../ir-generator" diff --git a/packages/cli/lazy-fern-workspace/.prettierrc.cjs b/packages/cli/lazy-fern-workspace/.prettierrc.cjs deleted file mode 100644 index 39cf0d0b8c9..00000000000 --- a/packages/cli/lazy-fern-workspace/.prettierrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../../.prettierrc.json"); diff --git a/packages/cli/lazy-fern-workspace/src/OSSWorkspace.ts b/packages/cli/lazy-fern-workspace/src/OSSWorkspace.ts deleted file mode 100644 index 64b1ae86d34..00000000000 --- a/packages/cli/lazy-fern-workspace/src/OSSWorkspace.ts +++ /dev/null @@ -1,318 +0,0 @@ -import { FERN_PACKAGE_MARKER_FILENAME, generatorsYml } from "@fern-api/configuration-loader"; -import { isNonNullish, mergeWithOverrides } from "@fern-api/core-utils"; -import { AbsoluteFilePath, join, relative, RelativeFilePath } from "@fern-api/fs-utils"; -import { convert } from "@fern-api/openapi-ir-to-fern"; -import { parse, ParseOpenAPIOptions, Document } from "@fern-api/openapi-ir-parser"; -import { TaskContext } from "@fern-api/task-context"; -import yaml from "js-yaml"; -import { v4 as uuidv4 } from "uuid"; -import { getAllOpenAPISpecs } from "./utils/getAllOpenAPISpecs"; -import { - FernWorkspace, - AbstractAPIWorkspace, - FernDefinition, - IdentifiableSource -} from "@fern-api/api-workspace-commons"; -import { mapValues } from "./utils/mapValues"; -import { OpenApiIntermediateRepresentation, Source as OpenApiIrSource } from "@fern-api/openapi-ir"; -import { OpenAPILoader } from "./loaders/OpenAPILoader"; - -export type Spec = OpenAPISpec | ProtobufSpec; - -export interface OpenAPISpec { - type: "openapi"; - absoluteFilepath: AbsoluteFilePath; - absoluteFilepathToOverrides: AbsoluteFilePath | undefined; - source: Source; - namespace?: string; - settings?: SpecImportSettings; -} - -export interface ProtobufSpec { - type: "protobuf"; - absoluteFilepathToProtobufRoot: AbsoluteFilePath; - absoluteFilepathToProtobufTarget: AbsoluteFilePath; - absoluteFilepathToOverrides: AbsoluteFilePath | undefined; - generateLocally: boolean; - settings?: SpecImportSettings; -} - -export type Source = AsyncAPISource | OpenAPISource | ProtobufSource; - -export interface AsyncAPISource { - type: "asyncapi"; - relativePathToDependency?: RelativeFilePath; - file: AbsoluteFilePath; -} - -export interface OpenAPISource { - type: "openapi"; - relativePathToDependency?: RelativeFilePath; - file: AbsoluteFilePath; -} - -export interface ProtobufSource { - type: "protobuf"; - relativePathToDependency?: RelativeFilePath; - root: AbsoluteFilePath; - file: AbsoluteFilePath; -} - -export interface SpecImportSettings { - audiences: string[]; - shouldUseTitleAsName: boolean; - shouldUseUndiscriminatedUnionsWithLiterals: boolean; - optionalAdditionalProperties: boolean; - asyncApiNaming?: "v1" | "v2"; - cooerceEnumsToLiterals: boolean; - objectQueryParameters: boolean; - respectReadonlySchemas: boolean; - onlyIncludeReferencedSchemas: boolean; - inlinePathParameters: boolean; -} - -export declare namespace OSSWorkspace { - export interface Args extends AbstractAPIWorkspace.Args { - workspaceName: string | undefined; - specs: Spec[]; - cliVersion: string; - } - - export interface Settings { - /* - * Whether or not to parse unique errors for OpenAPI operation. This is - * an option that is typically enabled for docs generation. - */ - enableUniqueErrorsPerEndpoint?: boolean; - /* - * Whether or not to parse discriminated unions as undiscriminated unions with literals. - * Typically enabled for duck typed languages like Python / TypeScript. - */ - enableDiscriminatedUnionV2?: boolean; - /* - * Whether or not to extract frequently used headers out of the endpoints into a - * global header. This is primarily used for generating SDKs, but disabled for docs - * as it allows the documentation to more closely mirror the OpenAPI spec. - */ - detectGlobalHeaders?: boolean; - /* - * Whether or not to let additional property values in OpenAPI come through as - * optional. - */ - optionalAdditionalProperties?: boolean; - /* - * Whether or not to cooerce enums to undiscriminated union literals. - */ - cooerceEnumsToLiterals?: boolean; - /* - * Whether or not to parse object query parameters. - */ - objectQueryParameters?: boolean; - /* - * Whether or not to preserve original schema ids. - */ - preserveSchemaIds?: boolean; - } -} - -export class OSSWorkspace extends AbstractAPIWorkspace { - public specs: Spec[]; - public sources: IdentifiableSource[]; - - private loader: OpenAPILoader; - private respectReadonlySchemas: boolean; - private onlyIncludeReferencedSchemas: boolean; - private inlinePathParameters: boolean; - - constructor({ specs, ...superArgs }: OSSWorkspace.Args) { - super(superArgs); - this.specs = specs; - this.sources = this.convertSpecsToIdentifiableSources(specs); - this.loader = new OpenAPILoader(this.absoluteFilePath); - this.respectReadonlySchemas = this.specs.every((spec) => spec.settings?.respectReadonlySchemas ?? false); - this.onlyIncludeReferencedSchemas = this.specs.every( - (spec) => spec.settings?.onlyIncludeReferencedSchemas ?? false - ); - this.inlinePathParameters = this.specs.every((spec) => spec.settings?.inlinePathParameters ?? false); - } - - public async getOpenAPIIr( - { - context, - relativePathToDependency - }: { - context: TaskContext; - relativePathToDependency?: RelativeFilePath; - }, - settings?: OSSWorkspace.Settings - ): Promise { - const openApiSpecs = await getAllOpenAPISpecs({ context, specs: this.specs, relativePathToDependency }); - const optionOverrides = getOptionsOverridesFromSettings(settings); - return await parse({ - context, - documents: await this.loader.loadDocuments({ - context, - specs: openApiSpecs - }), - options: { - ...optionOverrides, - respectReadonlySchemas: this.respectReadonlySchemas, - onlyIncludeReferencedSchemas: this.onlyIncludeReferencedSchemas - } - }); - } - - public async getDefinition( - { - context, - relativePathToDependency - }: { - context: TaskContext; - relativePathToDependency?: RelativeFilePath; - }, - settings?: OSSWorkspace.Settings - ): Promise { - const openApiIr = await this.getOpenAPIIr({ context, relativePathToDependency }, settings); - - // Ideally you are still at the individual spec level here, so you can still modify the fern definition - // file paths with the inputted namespace, however given auth and other shared settings I think we have to - // resolve to the IR first, and namespace there. - const objectQueryParameters = this.specs.every((spec) => spec.settings?.objectQueryParameters); - const definition = convert({ - authOverrides: - this.generatorsConfiguration?.api?.auth != null ? { ...this.generatorsConfiguration?.api } : undefined, - environmentOverrides: - this.generatorsConfiguration?.api?.environments != null - ? { ...this.generatorsConfiguration?.api } - : undefined, - globalHeaderOverrides: - this.generatorsConfiguration?.api?.headers != null - ? { ...this.generatorsConfiguration?.api } - : undefined, - taskContext: context, - ir: openApiIr, - enableUniqueErrorsPerEndpoint: settings?.enableUniqueErrorsPerEndpoint ?? false, - detectGlobalHeaders: settings?.detectGlobalHeaders ?? true, - objectQueryParameters, - respectReadonlySchemas: this.respectReadonlySchemas, - onlyIncludeReferencedSchemas: this.onlyIncludeReferencedSchemas, - inlinePathParameters: this.inlinePathParameters - }); - - return { - // these files doesn't live on disk, so there's no absolute filepath - absoluteFilePath: AbsoluteFilePath.of("/DUMMY_PATH"), - rootApiFile: { - defaultUrl: definition.rootApiFile["default-url"], - contents: definition.rootApiFile, - rawContents: yaml.dump(definition.rootApiFile) - }, - namedDefinitionFiles: { - ...mapValues(definition.definitionFiles, (definitionFile) => ({ - // these files doesn't live on disk, so there's no absolute filepath - absoluteFilepath: AbsoluteFilePath.of("/DUMMY_PATH"), - rawContents: yaml.dump(definitionFile), - contents: definitionFile - })), - [RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME)]: { - // these files doesn't live on disk, so there's no absolute filepath - absoluteFilepath: AbsoluteFilePath.of("/DUMMY_PATH"), - rawContents: yaml.dump(definition.packageMarkerFile), - contents: definition.packageMarkerFile - } - }, - packageMarkers: {}, - importedDefinitions: {} - }; - } - - public async toFernWorkspace( - { context }: { context: TaskContext }, - settings?: OSSWorkspace.Settings - ): Promise { - const definition = await this.getDefinition({ context }, settings); - return new FernWorkspace({ - absoluteFilePath: this.absoluteFilePath, - workspaceName: this.workspaceName, - generatorsConfiguration: this.generatorsConfiguration, - dependenciesConfiguration: { - dependencies: {} - }, - definition, - cliVersion: this.cliVersion, - sources: this.sources - }); - } - - public getAbsoluteFilePaths(): AbsoluteFilePath[] { - return [ - this.absoluteFilePath, - ...this.specs - .flatMap((spec) => [ - spec.type === "protobuf" ? spec.absoluteFilepathToProtobufTarget : spec.absoluteFilepath, - spec.absoluteFilepathToOverrides - ]) - .filter(isNonNullish) - ]; - } - - public getSources(): IdentifiableSource[] { - return this.sources; - } - - private convertSpecsToIdentifiableSources(specs: Spec[]): IdentifiableSource[] { - const seen = new Set(); - const result: IdentifiableSource[] = []; - return specs.reduce((acc, spec) => { - const absoluteFilePath = - spec.type === "protobuf" ? spec.absoluteFilepathToProtobufRoot : spec.absoluteFilepath; - - if (!seen.has(absoluteFilePath)) { - seen.add(absoluteFilePath); - acc.push({ - type: spec.type, - id: uuidv4(), - absoluteFilePath - }); - } - - return acc; - }, result); - } -} - -export function getOSSWorkspaceSettingsFromGeneratorInvocation( - generatorInvocation: generatorsYml.GeneratorInvocation -): OSSWorkspace.Settings | undefined { - if (generatorInvocation.settings == null) { - return undefined; - } - const result: OSSWorkspace.Settings = { - detectGlobalHeaders: true - }; - if (generatorInvocation.settings.unions === "v1") { - result.enableDiscriminatedUnionV2 = true; - } - - return result; -} - -function getOptionsOverridesFromSettings(settings?: OSSWorkspace.Settings): Partial | undefined { - if (settings == null) { - return undefined; - } - const result: Partial = {}; - if (settings.enableDiscriminatedUnionV2) { - result.discriminatedUnionV2 = true; - } - if (settings.optionalAdditionalProperties) { - result.optionalAdditionalProperties = true; - } - if (settings.cooerceEnumsToLiterals) { - result.cooerceEnumsToLiterals = true; - } - if (settings.preserveSchemaIds) { - result.preserveSchemaIds = true; - } - return result; -} diff --git a/packages/cli/lazy-fern-workspace/tsconfig.json b/packages/cli/lazy-fern-workspace/tsconfig.json deleted file mode 100644 index bcccd58cd36..00000000000 --- a/packages/cli/lazy-fern-workspace/tsconfig.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "extends": "../../../shared/tsconfig.shared.json", - "compilerOptions": { - "composite": true, - "outDir": "lib", - "rootDir": "src" - }, - "include": [ - "./src/**/*", - "./src/*.json" - ], - "references": [ - { - "path": "../../commons/core-utils" - }, - { - "path": "../../commons/fs-utils" - }, - { - "path": "../../commons/logging-execa" - }, - { - "path": "../api-importers/conjure/conjure-to-fern" - }, - { - "path": "../../core" - }, - { - "path": "../configuration-loader" - }, - { - "path": "../cli-logger" - }, - { - "path": "../logger" - }, - { - "path": "../api-importers/openapi/openapi-ir-to-fern" - }, - { - "path": "../api-importers/openapi/openapi-ir-parser" - }, - { - "path": "../api-importers/openapi/openapi-ir" - }, - { - "path": "../semver-utils" - }, - { - "path": "../task-context" - }, - { - "path": "../workspace-commons" - }, - { - "path": "../fern-definition/schema" - } - ] -} \ No newline at end of file diff --git a/packages/cli/lazy-fern-workspace/vitest.config.ts b/packages/cli/lazy-fern-workspace/vitest.config.ts deleted file mode 100644 index fecc099c58a..00000000000 --- a/packages/cli/lazy-fern-workspace/vitest.config.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from "../../../shared/vitest.config"; diff --git a/packages/cli/project-loader/tsconfig.json b/packages/cli/project-loader/tsconfig.json index 512f919fbda..14686d76c6c 100644 --- a/packages/cli/project-loader/tsconfig.json +++ b/packages/cli/project-loader/tsconfig.json @@ -19,10 +19,10 @@ "path": "../task-context" }, { - "path": "../workspace-loader" + "path": "../workspace/loader" }, { - "path": "../workspace-commons" + "path": "../workspace/commons" } ] } \ No newline at end of file diff --git a/packages/cli/register/tsconfig.json b/packages/cli/register/tsconfig.json index bf861d464cb..ee5809cad0c 100644 --- a/packages/cli/register/tsconfig.json +++ b/packages/cli/register/tsconfig.json @@ -34,7 +34,7 @@ "path": "../task-context" }, { - "path": "../workspace-commons" + "path": "../workspace/commons" }, { "path": "../project-loader" diff --git a/packages/cli/workspace-commons/.prettierrc.cjs b/packages/cli/workspace-commons/.prettierrc.cjs deleted file mode 100644 index 39cf0d0b8c9..00000000000 --- a/packages/cli/workspace-commons/.prettierrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../../.prettierrc.json"); diff --git a/packages/cli/workspace-commons/tsconfig.json b/packages/cli/workspace-commons/tsconfig.json deleted file mode 100644 index bb100d3464e..00000000000 --- a/packages/cli/workspace-commons/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../../shared/tsconfig.shared.json", - "compilerOptions": { "composite": true, "outDir": "lib", "rootDir": "src" }, - "include": ["./src/**/*"], - "references": [ - { "path": "../../commons/path-utils" }, - { "path": "../configuration" }, - { "path": "../logger" }, - { "path": "../task-context" }, - { "path": "../fern-definition/schema" } - ] -} diff --git a/packages/cli/workspace-commons/vitest.config.ts b/packages/cli/workspace-commons/vitest.config.ts deleted file mode 100644 index fecc099c58a..00000000000 --- a/packages/cli/workspace-commons/vitest.config.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from "../../../shared/vitest.config"; diff --git a/packages/cli/workspace-loader/.prettierrc.cjs b/packages/cli/workspace-loader/.prettierrc.cjs deleted file mode 100644 index 39cf0d0b8c9..00000000000 --- a/packages/cli/workspace-loader/.prettierrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../../.prettierrc.json"); diff --git a/packages/cli/workspace-loader/src/index.ts b/packages/cli/workspace-loader/src/index.ts deleted file mode 100644 index d8b2e06ef0d..00000000000 --- a/packages/cli/workspace-loader/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -export * from "./handleFailedWorkspaceParserResult"; -export { loadAPIWorkspace } from "./loadAPIWorkspace"; -export { loadDocsWorkspace } from "./loadDocsWorkspace"; -export { getValidAbsolutePathToOpenAPI as loadOpenAPIFile } from "./loadOpenAPIFile"; -export { type FernFile, type ParsedFernFile } from "./types/FernFile"; -export { - type AsyncAPISource, - type DocsWorkspace, - type FernWorkspaceMetadata, - type IdentifiableSource, - type OpenAPISource, - type ProtobufSource, - type Source, - type Workspace -} from "./types/Workspace"; -export { AbstractAPIWorkspace, FernWorkspace, type FernDefinition } from "@fern-api/api-workspace-commons"; -export { getOSSWorkspaceSettingsFromGeneratorInvocation } from "@fern-api/lazy-fern-workspace"; diff --git a/packages/cli/workspace-loader/src/types/Workspace.ts b/packages/cli/workspace-loader/src/types/Workspace.ts deleted file mode 100644 index a2afec2b762..00000000000 --- a/packages/cli/workspace-loader/src/types/Workspace.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { docsYml, generatorsYml } from "@fern-api/configuration-loader"; -import { AbsoluteFilePath, RelativeFilePath } from "@fern-api/fs-utils"; -import { AbstractAPIWorkspace, FernWorkspace } from "@fern-api/api-workspace-commons"; - -export type Workspace = DocsWorkspace | AbstractAPIWorkspace; - -export interface DocsWorkspace { - type: "docs"; - workspaceName: string | undefined; - absoluteFilePath: AbsoluteFilePath; // path to the fern folder (dirname(absoluteFilepathToDocsConfig)) - absoluteFilepathToDocsConfig: AbsoluteFilePath; - config: docsYml.RawSchemas.DocsConfiguration; -} - -export type Spec = OpenAPISpec | ProtobufSpec; - -export interface OpenAPISpec { - type: "openapi"; - absoluteFilepath: AbsoluteFilePath; - absoluteFilepathToOverrides: AbsoluteFilePath | undefined; - source: Source; - namespace?: string; - settings?: SpecImportSettings; -} - -export interface ProtobufSpec { - type: "protobuf"; - absoluteFilepathToProtobufRoot: AbsoluteFilePath; - absoluteFilepathToProtobufTarget: AbsoluteFilePath; - absoluteFilepathToOverrides: AbsoluteFilePath | undefined; - generateLocally: boolean; - settings?: SpecImportSettings; -} - -export interface IdentifiableSource { - type: "asyncapi" | "openapi" | "protobuf"; - id: string; - absoluteFilePath: AbsoluteFilePath; -} - -export type Source = AsyncAPISource | OpenAPISource | ProtobufSource; - -export interface AsyncAPISource { - type: "asyncapi"; - relativePathToDependency?: RelativeFilePath; - file: AbsoluteFilePath; -} - -export interface OpenAPISource { - type: "openapi"; - relativePathToDependency?: RelativeFilePath; - file: AbsoluteFilePath; -} - -export interface ProtobufSource { - type: "protobuf"; - relativePathToDependency?: RelativeFilePath; - root: AbsoluteFilePath; - file: AbsoluteFilePath; -} - -export interface SpecImportSettings { - audiences: string[]; - shouldUseTitleAsName: boolean; - shouldUseUndiscriminatedUnionsWithLiterals: boolean; - optionalAdditionalProperties: boolean; - asyncApiNaming?: "v1" | "v2"; - cooerceEnumsToLiterals: boolean; - objectQueryParameters: boolean; - respectReadonlySchemas: boolean; - onlyIncludeReferencedSchemas: boolean; - inlinePathParameters: boolean; -} - -export interface OpenAPIFile { - absoluteFilepath: AbsoluteFilePath; - contents: string; -} - -export interface AsyncAPIFile { - absoluteFilepath: AbsoluteFilePath; - contents: string; -} - -export interface FernWorkspaceMetadata { - workspace: FernWorkspace; - absolutePathToPreview: AbsoluteFilePath | undefined; - group: generatorsYml.GeneratorGroup; -} diff --git a/packages/cli/workspace-loader/tsconfig.json b/packages/cli/workspace-loader/tsconfig.json deleted file mode 100644 index a4d2bf47f91..00000000000 --- a/packages/cli/workspace-loader/tsconfig.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "extends": "../../../shared/tsconfig.shared.json", - "compilerOptions": { - "composite": true, - "outDir": "lib", - "rootDir": "src" - }, - "include": [ - "./src/**/*" - ], - "references": [ - { - "path": "../../commons/core-utils" - }, - { - "path": "../../commons/fs-utils" - }, - { - "path": "../../commons/logging-execa" - }, - { - "path": "../../core" - }, - { - "path": "../configuration-loader" - }, - { - "path": "../cli-logger" - }, - { - "path": "../logger" - }, - { - "path": "../api-importers/openapi/openapi-ir-parser" - }, - { - "path": "../semver-utils" - }, - { - "path": "../task-context" - }, - { - "path": "../workspace-commons" - }, - { - "path": "../fern-definition/schema" - }, - { - "path": "../lazy-fern-workspace" - } - ] -} \ No newline at end of file diff --git a/packages/cli/workspace-loader/vitest.config.ts b/packages/cli/workspace-loader/vitest.config.ts deleted file mode 100644 index fecc099c58a..00000000000 --- a/packages/cli/workspace-loader/vitest.config.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from "../../../shared/vitest.config"; diff --git a/packages/cli/lazy-fern-workspace/.depcheckrc.json b/packages/cli/workspace/browser-compatible-fern-workspace/.depcheckrc.json similarity index 100% rename from packages/cli/lazy-fern-workspace/.depcheckrc.json rename to packages/cli/workspace/browser-compatible-fern-workspace/.depcheckrc.json diff --git a/packages/cli/workspace/browser-compatible-fern-workspace/.prettierrc.cjs b/packages/cli/workspace/browser-compatible-fern-workspace/.prettierrc.cjs new file mode 100644 index 00000000000..9b6214d5129 --- /dev/null +++ b/packages/cli/workspace/browser-compatible-fern-workspace/.prettierrc.cjs @@ -0,0 +1 @@ +module.exports = require("../../../../.prettierrc.json"); diff --git a/packages/cli/workspace/browser-compatible-fern-workspace/package.json b/packages/cli/workspace/browser-compatible-fern-workspace/package.json new file mode 100644 index 00000000000..5d9f6ace52f --- /dev/null +++ b/packages/cli/workspace/browser-compatible-fern-workspace/package.json @@ -0,0 +1,50 @@ +{ + "name": "@fern-api/browser-compatible-fern-workspace", + "version": "0.0.0", + "repository": { + "type": "git", + "url": "https://github.com/fern-api/fern.git", + "directory": "packages/cli/workspace/browser-compatible-fern-workspace" + }, + "private": true, + "files": [ + "lib" + ], + "type": "module", + "source": "src/index.ts", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "sideEffects": false, + "scripts": { + "clean": "rm -rf ./lib && tsc --build --clean", + "compile": "tsc --build", + "test": "vitest --passWithNoTests --run", + "test:update": "vitest --passWithNoTests --run -u", + "lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../../.eslintignore", + "lint:eslint:fix": "yarn lint:eslint --fix", + "format": "prettier --write --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"", + "format:check": "prettier --check --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"", + "organize-imports": "organize-imports-cli tsconfig.json", + "depcheck": "depcheck" + }, + "dependencies": { + "@fern-api/api-workspace-commons": "workspace:*", + "@fern-api/core-utils": "workspace:*", + "@fern-api/openapi-ir": "workspace:*", + "@fern-api/openapi-ir-parser": "workspace:*", + "@fern-api/path-utils": "workspace:*", + "@fern-api/task-context": "workspace:*", + "@redocly/openapi-core": "^1.4.1", + "openapi-types": "^12.1.3" + }, + "devDependencies": { + "@types/jest": "^29.5.12", + "@types/node": "18.7.18", + "depcheck": "^1.4.6", + "eslint": "^8.56.0", + "vitest": "^2.1.4", + "organize-imports-cli": "^0.10.0", + "prettier": "^2.7.1", + "typescript": "4.6.4" + } +} \ No newline at end of file diff --git a/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/InMemoryOpenAPILoader.ts b/packages/cli/workspace/browser-compatible-fern-workspace/src/InMemoryOpenAPILoader.ts similarity index 64% rename from packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/InMemoryOpenAPILoader.ts rename to packages/cli/workspace/browser-compatible-fern-workspace/src/InMemoryOpenAPILoader.ts index 6d29403c072..e43178e1f43 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/InMemoryOpenAPILoader.ts +++ b/packages/cli/workspace/browser-compatible-fern-workspace/src/InMemoryOpenAPILoader.ts @@ -1,9 +1,8 @@ -import { OpenAPIDocument, SpecImportSettings } from "../parse"; +import { OpenAPIDocument, SpecImportSettings } from "@fern-api/openapi-ir-parser"; import { OpenAPI } from "openapi-types"; -import { bundle, Config, Source } from "@redocly/openapi-core"; -import { BundleOptions } from "@redocly/openapi-core/lib/bundle"; +import { bundle, Source } from "@redocly/openapi-core"; +import { DEFAULT_OPENAPI_BUNDLE_OPTIONS } from "@fern-api/api-workspace-commons"; import { mergeWithOverrides as coreMergeWithOverrides } from "@fern-api/core-utils"; -import { FERN_TYPE_EXTENSIONS } from "./v3/extensions/fernExtensions"; export interface Spec { parsed: OpenAPI.Document; @@ -43,25 +42,8 @@ export class InMemoryOpenAPILoader { } private async parseOpenAPI({ parsed }: { parsed: OpenAPI.Document }): Promise { - const options: BundleOptions = { - config: new Config( - { - apis: {}, - styleguide: { - plugins: [FERN_TYPE_EXTENSIONS], - rules: { - spec: "warn" - } - } - }, - undefined - ), - dereference: false, - removeUnusedComponents: false, - keepUrlRefs: true - }; const result = await bundle({ - ...options, + ...DEFAULT_OPENAPI_BUNDLE_OPTIONS, doc: { source: new Source("", ""), parsed diff --git a/packages/cli/workspace/browser-compatible-fern-workspace/src/OpenAPIWorkspace.ts b/packages/cli/workspace/browser-compatible-fern-workspace/src/OpenAPIWorkspace.ts new file mode 100644 index 00000000000..b1fe62a0cdb --- /dev/null +++ b/packages/cli/workspace/browser-compatible-fern-workspace/src/OpenAPIWorkspace.ts @@ -0,0 +1,77 @@ +import { + AbstractAPIWorkspace, + BaseOpenAPIWorkspace, + getOptionsOverridesFromSettings +} from "@fern-api/api-workspace-commons"; +import { SpecImportSettings } from "@fern-api/openapi-ir-parser"; +import { OpenAPI } from "openapi-types"; +import { AbsoluteFilePath, RelativeFilePath } from "@fern-api/path-utils"; +import { TaskContext } from "@fern-api/task-context"; +import { OpenApiIntermediateRepresentation } from "@fern-api/openapi-ir"; +import { parse } from "@fern-api/openapi-ir-parser"; +import { InMemoryOpenAPILoader } from "./InMemoryOpenAPILoader"; + +const IN_MEMORY_ABSOLUTE_FILEPATH = AbsoluteFilePath.of("/"); + +const DEFAULT_WORKSPACE_ARGS = { + absoluteFilePath: IN_MEMORY_ABSOLUTE_FILEPATH, + cliVersion: "", + workspaceName: "anonymous" +}; + +export declare namespace OpenAPIWorkspace { + export interface Args extends AbstractAPIWorkspace.Args { + spec: Spec; + } + + export interface Spec { + parsed: OpenAPI.Document; + overrides?: OpenAPI.Document; + settings?: SpecImportSettings; + } + + export type Settings = BaseOpenAPIWorkspace.Settings; +} + +export class OpenAPIWorkspace extends BaseOpenAPIWorkspace { + private spec: OpenAPIWorkspace.Spec; + private loader: InMemoryOpenAPILoader; + + constructor({ spec, generatorsConfiguration }: OpenAPIWorkspace.Args) { + super({ + ...DEFAULT_WORKSPACE_ARGS, + generatorsConfiguration, + respectReadonlySchemas: spec.settings?.respectReadonlySchemas ?? false, + onlyIncludeReferencedSchemas: spec.settings?.onlyIncludeReferencedSchemas ?? false, + inlinePathParameters: spec.settings?.inlinePathParameters ?? false, + objectQueryParameters: spec.settings?.objectQueryParameters ?? false + }); + this.spec = spec; + this.loader = new InMemoryOpenAPILoader(); + } + + public async getOpenAPIIr( + { + context + }: { + context: TaskContext; + }, + settings?: OpenAPIWorkspace.Settings + ): Promise { + const optionOverrides = getOptionsOverridesFromSettings(settings); + const document = await this.loader.loadDocument(this.spec); + return await parse({ + context, + documents: [document], + options: { + ...optionOverrides, + respectReadonlySchemas: this.respectReadonlySchemas, + onlyIncludeReferencedSchemas: this.onlyIncludeReferencedSchemas + } + }); + } + + public getAbsoluteFilePaths(): AbsoluteFilePath[] { + return []; + } +} diff --git a/packages/cli/workspace/browser-compatible-fern-workspace/src/index.ts b/packages/cli/workspace/browser-compatible-fern-workspace/src/index.ts new file mode 100644 index 00000000000..61862e32c70 --- /dev/null +++ b/packages/cli/workspace/browser-compatible-fern-workspace/src/index.ts @@ -0,0 +1,2 @@ +export { InMemoryOpenAPILoader } from "./InMemoryOpenAPILoader"; +export { OpenAPIWorkspace } from "./OpenAPIWorkspace"; diff --git a/packages/cli/workspace/browser-compatible-fern-workspace/tsconfig.json b/packages/cli/workspace/browser-compatible-fern-workspace/tsconfig.json new file mode 100644 index 00000000000..e2ca38fd344 --- /dev/null +++ b/packages/cli/workspace/browser-compatible-fern-workspace/tsconfig.json @@ -0,0 +1,53 @@ +{ + "extends": "../../../../shared/tsconfig.shared.json", + "compilerOptions": { + "composite": true, + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "./src/**/*", + "./src/*.json" + ], + "references": [ + { + "path": "../../../commons/core-utils" + }, + { + "path": "../../../commons/path-utils" + }, + { + "path": "../../../commons/logging-execa" + }, + { + "path": "../../api-importers/conjure/conjure-to-fern" + }, + { + "path": "../../../core" + }, + { + "path": "../../configuration-loader" + }, + { + "path": "../../cli-logger" + }, + { + "path": "../../logger" + }, + { + "path": "../../api-importers/openapi/openapi-ir-parser" + }, + { + "path": "../../api-importers/openapi/openapi-ir" + }, + { + "path": "../../semver-utils" + }, + { + "path": "../../task-context" + }, + { + "path": "../commons" + } + ] +} \ No newline at end of file diff --git a/packages/cli/workspace/browser-compatible-fern-workspace/vitest.config.ts b/packages/cli/workspace/browser-compatible-fern-workspace/vitest.config.ts new file mode 100644 index 00000000000..d11017dc676 --- /dev/null +++ b/packages/cli/workspace/browser-compatible-fern-workspace/vitest.config.ts @@ -0,0 +1 @@ +export { default } from "../../../../shared/vitest.config"; diff --git a/packages/cli/workspace-commons/.depcheckrc.json b/packages/cli/workspace/commons/.depcheckrc.json similarity index 100% rename from packages/cli/workspace-commons/.depcheckrc.json rename to packages/cli/workspace/commons/.depcheckrc.json diff --git a/packages/cli/workspace/commons/.prettierrc.cjs b/packages/cli/workspace/commons/.prettierrc.cjs new file mode 100644 index 00000000000..9b6214d5129 --- /dev/null +++ b/packages/cli/workspace/commons/.prettierrc.cjs @@ -0,0 +1 @@ +module.exports = require("../../../../.prettierrc.json"); diff --git a/packages/cli/workspace-commons/package.json b/packages/cli/workspace/commons/package.json similarity index 84% rename from packages/cli/workspace-commons/package.json rename to packages/cli/workspace/commons/package.json index 900377f7a21..494138eb6f8 100644 --- a/packages/cli/workspace-commons/package.json +++ b/packages/cli/workspace/commons/package.json @@ -4,7 +4,7 @@ "repository": { "type": "git", "url": "https://github.com/fern-api/fern.git", - "directory": "packages/cli/workspace-loader" + "directory": "packages/cli/workspace/commons" }, "private": true, "files": [ @@ -30,13 +30,19 @@ "dependencies": { "@fern-api/configuration": "workspace:*", "@fern-api/core-utils": "workspace:*", + "@fern-api/openapi-ir": "workspace:*", + "@fern-api/openapi-ir-parser": "workspace:*", + "@fern-api/openapi-ir-to-fern": "workspace:*", "@fern-api/path-utils": "workspace:*", "@fern-api/task-context": "workspace:*", "@fern-api/fern-definition-schema": "workspace:*", + "@redocly/openapi-core": "^1.4.1", + "js-yaml": "^4.1.0", "lodash-es": "^4.17.21" }, "devDependencies": { "@types/jest": "^29.5.12", + "@types/js-yaml": "^4.0.8", "@types/lodash-es": "^4.17.12", "depcheck": "^1.4.6", "eslint": "^8.56.0", diff --git a/packages/cli/workspace-commons/src/APIChangelog.ts b/packages/cli/workspace/commons/src/APIChangelog.ts similarity index 100% rename from packages/cli/workspace-commons/src/APIChangelog.ts rename to packages/cli/workspace/commons/src/APIChangelog.ts diff --git a/packages/cli/workspace-commons/src/AbstractAPIWorkspace.ts b/packages/cli/workspace/commons/src/AbstractAPIWorkspace.ts similarity index 100% rename from packages/cli/workspace-commons/src/AbstractAPIWorkspace.ts rename to packages/cli/workspace/commons/src/AbstractAPIWorkspace.ts diff --git a/packages/cli/workspace-commons/src/FernFile.ts b/packages/cli/workspace/commons/src/FernFile.ts similarity index 100% rename from packages/cli/workspace-commons/src/FernFile.ts rename to packages/cli/workspace/commons/src/FernFile.ts diff --git a/packages/cli/workspace-commons/src/FernWorkspace.ts b/packages/cli/workspace/commons/src/FernWorkspace.ts similarity index 89% rename from packages/cli/workspace-commons/src/FernWorkspace.ts rename to packages/cli/workspace/commons/src/FernWorkspace.ts index 0abf5292e58..4f7058862d1 100644 --- a/packages/cli/workspace-commons/src/FernWorkspace.ts +++ b/packages/cli/workspace/commons/src/FernWorkspace.ts @@ -1,6 +1,7 @@ import { dependenciesYml } from "@fern-api/configuration"; import { AbsoluteFilePath } from "@fern-api/path-utils"; import { AbstractAPIWorkspace, FernDefinition } from "./AbstractAPIWorkspace"; +import { IdentifiableSource } from "./Source"; export declare namespace FernWorkspace { export interface Args extends AbstractAPIWorkspace.Args { @@ -10,12 +11,6 @@ export declare namespace FernWorkspace { } } -export interface IdentifiableSource { - type: "asyncapi" | "openapi" | "protobuf"; - id: string; - absoluteFilePath: AbsoluteFilePath; -} - export class FernWorkspace extends AbstractAPIWorkspace { public definition: FernDefinition; public sources: IdentifiableSource[]; diff --git a/packages/cli/workspace/commons/src/Source.ts b/packages/cli/workspace/commons/src/Source.ts new file mode 100644 index 00000000000..c6ed948d931 --- /dev/null +++ b/packages/cli/workspace/commons/src/Source.ts @@ -0,0 +1,28 @@ +import { AbsoluteFilePath, RelativeFilePath } from "@fern-api/path-utils"; + +export type Source = AsyncAPISource | OpenAPISource | ProtobufSource; + +export interface AsyncAPISource { + type: "asyncapi"; + relativePathToDependency?: RelativeFilePath; + file: AbsoluteFilePath; +} + +export interface OpenAPISource { + type: "openapi"; + relativePathToDependency?: RelativeFilePath; + file: AbsoluteFilePath; +} + +export interface ProtobufSource { + type: "protobuf"; + relativePathToDependency?: RelativeFilePath; + root: AbsoluteFilePath; + file: AbsoluteFilePath; +} + +export interface IdentifiableSource { + type: "asyncapi" | "openapi" | "protobuf"; + id: string; + absoluteFilePath: AbsoluteFilePath; +} diff --git a/packages/cli/workspace/commons/src/Spec.ts b/packages/cli/workspace/commons/src/Spec.ts new file mode 100644 index 00000000000..cf355538336 --- /dev/null +++ b/packages/cli/workspace/commons/src/Spec.ts @@ -0,0 +1,23 @@ +import { AbsoluteFilePath } from "@fern-api/path-utils"; +import { Source } from "./Source"; +import { SpecImportSettings } from "@fern-api/openapi-ir-parser"; + +export type Spec = OpenAPISpec | ProtobufSpec; + +export interface OpenAPISpec { + type: "openapi"; + absoluteFilepath: AbsoluteFilePath; + absoluteFilepathToOverrides: AbsoluteFilePath | undefined; + source: Source; + namespace?: string; + settings?: SpecImportSettings; +} + +export interface ProtobufSpec { + type: "protobuf"; + absoluteFilepathToProtobufRoot: AbsoluteFilePath; + absoluteFilepathToProtobufTarget: AbsoluteFilePath; + absoluteFilepathToOverrides: AbsoluteFilePath | undefined; + generateLocally: boolean; + settings?: SpecImportSettings; +} diff --git a/packages/cli/workspace-commons/src/index.ts b/packages/cli/workspace/commons/src/index.ts similarity index 67% rename from packages/cli/workspace-commons/src/index.ts rename to packages/cli/workspace/commons/src/index.ts index a368b2cf9b1..e24afb5cf94 100644 --- a/packages/cli/workspace-commons/src/index.ts +++ b/packages/cli/workspace/commons/src/index.ts @@ -1,5 +1,8 @@ export * from "./AbstractAPIWorkspace"; +export * from "./APIChangelog"; export * from "./FernFile"; export * from "./FernWorkspace"; +export * from "./openapi"; export * from "./utils"; -export * from "./APIChangelog"; +export * from "./Source"; +export * from "./Spec"; diff --git a/packages/cli/workspace/commons/src/openapi/BaseOpenAPIWorkspace.ts b/packages/cli/workspace/commons/src/openapi/BaseOpenAPIWorkspace.ts new file mode 100644 index 00000000000..a0c923eb0b4 --- /dev/null +++ b/packages/cli/workspace/commons/src/openapi/BaseOpenAPIWorkspace.ts @@ -0,0 +1,123 @@ +import { AbstractAPIWorkspace, FernDefinition, FernWorkspace } from ".."; +import { AbsoluteFilePath, RelativeFilePath } from "@fern-api/path-utils"; +import { TaskContext } from "@fern-api/task-context"; +import { OpenApiIntermediateRepresentation } from "@fern-api/openapi-ir"; +import { mapValues } from "lodash-es"; +import { convert } from "@fern-api/openapi-ir-to-fern"; +import { FERN_PACKAGE_MARKER_FILENAME } from "@fern-api/configuration"; +import { OpenAPISettings } from "./OpenAPISettings"; +import yaml from "js-yaml"; + +export declare namespace BaseOpenAPIWorkspace { + export interface Args extends AbstractAPIWorkspace.Args { + inlinePathParameters: boolean; + objectQueryParameters: boolean; + onlyIncludeReferencedSchemas: boolean; + respectReadonlySchemas: boolean; + } + + export type Settings = OpenAPISettings; +} + +export abstract class BaseOpenAPIWorkspace extends AbstractAPIWorkspace { + public inlinePathParameters: boolean; + public objectQueryParameters: boolean; + public onlyIncludeReferencedSchemas: boolean; + public respectReadonlySchemas: boolean; + + constructor(args: BaseOpenAPIWorkspace.Args) { + super(args); + this.inlinePathParameters = args.inlinePathParameters; + this.objectQueryParameters = args.objectQueryParameters; + this.onlyIncludeReferencedSchemas = args.onlyIncludeReferencedSchemas; + this.respectReadonlySchemas = args.respectReadonlySchemas; + } + + public async getDefinition( + { + context, + absoluteFilePath, + relativePathToDependency + }: { + context: TaskContext; + absoluteFilePath?: AbsoluteFilePath; + relativePathToDependency?: RelativeFilePath; + }, + settings?: BaseOpenAPIWorkspace.Settings + ): Promise { + const openApiIr = await this.getOpenAPIIr({ context, relativePathToDependency }, settings); + const definition = convert({ + authOverrides: + this.generatorsConfiguration?.api?.auth != null ? { ...this.generatorsConfiguration?.api } : undefined, + environmentOverrides: + this.generatorsConfiguration?.api?.environments != null + ? { ...this.generatorsConfiguration?.api } + : undefined, + globalHeaderOverrides: + this.generatorsConfiguration?.api?.headers != null + ? { ...this.generatorsConfiguration?.api } + : undefined, + taskContext: context, + ir: openApiIr, + enableUniqueErrorsPerEndpoint: settings?.enableUniqueErrorsPerEndpoint ?? false, + detectGlobalHeaders: settings?.detectGlobalHeaders ?? true, + objectQueryParameters: this.objectQueryParameters, + respectReadonlySchemas: this.respectReadonlySchemas, + onlyIncludeReferencedSchemas: this.onlyIncludeReferencedSchemas, + inlinePathParameters: this.inlinePathParameters + }); + + return { + absoluteFilePath: absoluteFilePath ?? this.absoluteFilePath, + rootApiFile: { + defaultUrl: definition.rootApiFile["default-url"], + contents: definition.rootApiFile, + rawContents: yaml.dump(definition.rootApiFile) + }, + namedDefinitionFiles: { + ...mapValues(definition.definitionFiles, (definitionFile) => ({ + absoluteFilepath: absoluteFilePath ?? this.absoluteFilePath, + rawContents: yaml.dump(definitionFile), + contents: definitionFile + })), + [RelativeFilePath.of(FERN_PACKAGE_MARKER_FILENAME)]: { + absoluteFilepath: absoluteFilePath ?? this.absoluteFilePath, + rawContents: yaml.dump(definition.packageMarkerFile), + contents: definition.packageMarkerFile + } + }, + packageMarkers: {}, + importedDefinitions: {} + }; + } + + public async toFernWorkspace( + { context }: { context: TaskContext }, + settings?: BaseOpenAPIWorkspace.Settings + ): Promise { + const definition = await this.getDefinition({ context }, settings); + return new FernWorkspace({ + absoluteFilePath: this.absoluteFilePath, + workspaceName: this.workspaceName, + generatorsConfiguration: this.generatorsConfiguration, + dependenciesConfiguration: { + dependencies: {} + }, + definition, + cliVersion: this.cliVersion + }); + } + + public abstract getOpenAPIIr( + { + context, + relativePathToDependency + }: { + context: TaskContext; + relativePathToDependency?: RelativeFilePath; + }, + settings?: BaseOpenAPIWorkspace.Settings + ): Promise; + + public abstract getAbsoluteFilePaths(): AbsoluteFilePath[]; +} diff --git a/packages/cli/workspace/commons/src/openapi/OpenAPISettings.ts b/packages/cli/workspace/commons/src/openapi/OpenAPISettings.ts new file mode 100644 index 00000000000..86a7157bd0c --- /dev/null +++ b/packages/cli/workspace/commons/src/openapi/OpenAPISettings.ts @@ -0,0 +1,35 @@ +export interface OpenAPISettings { + /* + * Whether or not to parse unique errors for OpenAPI operation. This is + * an option that is typically enabled for docs generation. + */ + enableUniqueErrorsPerEndpoint?: boolean; + /* + * Whether or not to parse discriminated unions as undiscriminated unions with literals. + * Typically enabled for duck typed languages like Python / TypeScript. + */ + enableDiscriminatedUnionV2?: boolean; + /* + * Whether or not to extract frequently used headers out of the endpoints into a + * global header. This is primarily used for generating SDKs, but disabled for docs + * as it allows the documentation to more closely mirror the OpenAPI spec. + */ + detectGlobalHeaders?: boolean; + /* + * Whether or not to let additional property values in OpenAPI come through as + * optional. + */ + optionalAdditionalProperties?: boolean; + /* + * Whether or not to cooerce enums to undiscriminated union literals. + */ + cooerceEnumsToLiterals?: boolean; + /* + * Whether or not to parse object query parameters. + */ + objectQueryParameters?: boolean; + /* + * Whether or not to preserve original schema ids. + */ + preserveSchemaIds?: boolean; +} diff --git a/packages/cli/workspace/commons/src/openapi/constants.ts b/packages/cli/workspace/commons/src/openapi/constants.ts new file mode 100644 index 00000000000..9506326a10e --- /dev/null +++ b/packages/cli/workspace/commons/src/openapi/constants.ts @@ -0,0 +1,21 @@ +import { FERN_TYPE_EXTENSIONS } from "@fern-api/openapi-ir-parser"; +import { BundleOptions } from "@redocly/openapi-core/lib/bundle"; +import { Config } from "@redocly/openapi-core"; + +export const DEFAULT_OPENAPI_BUNDLE_OPTIONS: BundleOptions = { + config: new Config( + { + apis: {}, + styleguide: { + plugins: [FERN_TYPE_EXTENSIONS], + rules: { + spec: "warn" + } + } + }, + undefined + ), + dereference: false, + removeUnusedComponents: false, + keepUrlRefs: true +}; diff --git a/packages/cli/workspace/commons/src/openapi/getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation.ts b/packages/cli/workspace/commons/src/openapi/getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation.ts new file mode 100644 index 00000000000..0f5207c9679 --- /dev/null +++ b/packages/cli/workspace/commons/src/openapi/getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation.ts @@ -0,0 +1,18 @@ +import { generatorsYml } from "@fern-api/configuration"; +import { type BaseOpenAPIWorkspace } from "./BaseOpenAPIWorkspace"; + +export function getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation( + generatorInvocation: generatorsYml.GeneratorInvocation +): BaseOpenAPIWorkspace.Settings | undefined { + if (generatorInvocation.settings == null) { + return undefined; + } + const result: BaseOpenAPIWorkspace.Settings = { + detectGlobalHeaders: true + }; + if (generatorInvocation.settings.unions === "v1") { + result.enableDiscriminatedUnionV2 = true; + } + + return result; +} diff --git a/packages/cli/workspace/commons/src/openapi/getOptionsOverridesFromSettings.ts b/packages/cli/workspace/commons/src/openapi/getOptionsOverridesFromSettings.ts new file mode 100644 index 00000000000..c423cc1196d --- /dev/null +++ b/packages/cli/workspace/commons/src/openapi/getOptionsOverridesFromSettings.ts @@ -0,0 +1,22 @@ +import { OpenAPISettings } from "./OpenAPISettings"; +import { ParseOpenAPIOptions } from "@fern-api/openapi-ir-parser"; + +export function getOptionsOverridesFromSettings(settings?: OpenAPISettings): Partial | undefined { + if (settings == null) { + return undefined; + } + const result: Partial = {}; + if (settings.enableDiscriminatedUnionV2) { + result.discriminatedUnionV2 = true; + } + if (settings.optionalAdditionalProperties) { + result.optionalAdditionalProperties = true; + } + if (settings.cooerceEnumsToLiterals) { + result.cooerceEnumsToLiterals = true; + } + if (settings.preserveSchemaIds) { + result.preserveSchemaIds = true; + } + return result; +} diff --git a/packages/cli/workspace/commons/src/openapi/index.ts b/packages/cli/workspace/commons/src/openapi/index.ts new file mode 100644 index 00000000000..4522072912c --- /dev/null +++ b/packages/cli/workspace/commons/src/openapi/index.ts @@ -0,0 +1,5 @@ +export { BaseOpenAPIWorkspace } from "./BaseOpenAPIWorkspace"; +export { getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation } from "./getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation"; +export { getOptionsOverridesFromSettings } from "./getOptionsOverridesFromSettings"; +export { type OpenAPISettings } from "./OpenAPISettings"; +export { DEFAULT_OPENAPI_BUNDLE_OPTIONS } from "./constants"; diff --git a/packages/cli/workspace-commons/src/utils/getAllDefinitionFiles.ts b/packages/cli/workspace/commons/src/utils/getAllDefinitionFiles.ts similarity index 100% rename from packages/cli/workspace-commons/src/utils/getAllDefinitionFiles.ts rename to packages/cli/workspace/commons/src/utils/getAllDefinitionFiles.ts diff --git a/packages/cli/workspace-commons/src/utils/getAllNamedDefinitionFiles.ts b/packages/cli/workspace/commons/src/utils/getAllNamedDefinitionFiles.ts similarity index 100% rename from packages/cli/workspace-commons/src/utils/getAllNamedDefinitionFiles.ts rename to packages/cli/workspace/commons/src/utils/getAllNamedDefinitionFiles.ts diff --git a/packages/cli/workspace-commons/src/utils/getAllPackageMarkers.ts b/packages/cli/workspace/commons/src/utils/getAllPackageMarkers.ts similarity index 100% rename from packages/cli/workspace-commons/src/utils/getAllPackageMarkers.ts rename to packages/cli/workspace/commons/src/utils/getAllPackageMarkers.ts diff --git a/packages/cli/workspace-commons/src/utils/getDefinitionFile.ts b/packages/cli/workspace/commons/src/utils/getDefinitionFile.ts similarity index 100% rename from packages/cli/workspace-commons/src/utils/getDefinitionFile.ts rename to packages/cli/workspace/commons/src/utils/getDefinitionFile.ts diff --git a/packages/cli/workspace-commons/src/utils/index.ts b/packages/cli/workspace/commons/src/utils/index.ts similarity index 100% rename from packages/cli/workspace-commons/src/utils/index.ts rename to packages/cli/workspace/commons/src/utils/index.ts diff --git a/packages/cli/workspace-commons/src/utils/visitAllDefinitionFiles.ts b/packages/cli/workspace/commons/src/utils/visitAllDefinitionFiles.ts similarity index 100% rename from packages/cli/workspace-commons/src/utils/visitAllDefinitionFiles.ts rename to packages/cli/workspace/commons/src/utils/visitAllDefinitionFiles.ts diff --git a/packages/cli/workspace-commons/src/utils/visitAllPackageMarkers.ts b/packages/cli/workspace/commons/src/utils/visitAllPackageMarkers.ts similarity index 100% rename from packages/cli/workspace-commons/src/utils/visitAllPackageMarkers.ts rename to packages/cli/workspace/commons/src/utils/visitAllPackageMarkers.ts diff --git a/packages/cli/workspace/commons/tsconfig.json b/packages/cli/workspace/commons/tsconfig.json new file mode 100644 index 00000000000..6fbfc218792 --- /dev/null +++ b/packages/cli/workspace/commons/tsconfig.json @@ -0,0 +1,37 @@ +{ + "extends": "../../../../shared/tsconfig.shared.json", + "compilerOptions": { + "composite": true, + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "./src/**/*" + ], + "references": [ + { + "path": "../../../commons/path-utils" + }, + { + "path": "../../api-importers/openapi/openapi-ir" + }, + { + "path": "../../api-importers/openapi/openapi-ir-parser" + }, + { + "path": "../../api-importers/openapi/openapi-ir-to-fern" + }, + { + "path": "../../configuration" + }, + { + "path": "../../logger" + }, + { + "path": "../../task-context" + }, + { + "path": "../../fern-definition/schema" + } + ] +} \ No newline at end of file diff --git a/packages/cli/workspace/commons/vitest.config.ts b/packages/cli/workspace/commons/vitest.config.ts new file mode 100644 index 00000000000..d11017dc676 --- /dev/null +++ b/packages/cli/workspace/commons/vitest.config.ts @@ -0,0 +1 @@ +export { default } from "../../../../shared/vitest.config"; diff --git a/packages/cli/workspace-loader/.depcheckrc.json b/packages/cli/workspace/lazy-fern-workspace/.depcheckrc.json similarity index 100% rename from packages/cli/workspace-loader/.depcheckrc.json rename to packages/cli/workspace/lazy-fern-workspace/.depcheckrc.json diff --git a/packages/cli/workspace/lazy-fern-workspace/.prettierrc.cjs b/packages/cli/workspace/lazy-fern-workspace/.prettierrc.cjs new file mode 100644 index 00000000000..9b6214d5129 --- /dev/null +++ b/packages/cli/workspace/lazy-fern-workspace/.prettierrc.cjs @@ -0,0 +1 @@ +module.exports = require("../../../../.prettierrc.json"); diff --git a/packages/cli/lazy-fern-workspace/package.json b/packages/cli/workspace/lazy-fern-workspace/package.json similarity index 95% rename from packages/cli/lazy-fern-workspace/package.json rename to packages/cli/workspace/lazy-fern-workspace/package.json index 4ff4bd95be0..fb405b0740a 100644 --- a/packages/cli/lazy-fern-workspace/package.json +++ b/packages/cli/workspace/lazy-fern-workspace/package.json @@ -4,7 +4,7 @@ "repository": { "type": "git", "url": "https://github.com/fern-api/fern.git", - "directory": "packages/cli/workspace-loader" + "directory": "packages/cli/workspace/lazy-fern-workspace" }, "private": true, "files": [ @@ -37,7 +37,6 @@ "@fern-api/logger": "workspace:*", "@fern-api/logging-execa": "workspace:*", "@fern-api/openapi-ir": "workspace:*", - "@fern-api/openapi-ir-to-fern": "workspace:*", "@fern-api/openapi-ir-parser": "workspace:*", "@fern-api/semver-utils": "workspace:*", "@fern-api/task-context": "workspace:*", diff --git a/packages/cli/lazy-fern-workspace/src/ConjureWorkspace.ts b/packages/cli/workspace/lazy-fern-workspace/src/ConjureWorkspace.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/ConjureWorkspace.ts rename to packages/cli/workspace/lazy-fern-workspace/src/ConjureWorkspace.ts diff --git a/packages/cli/lazy-fern-workspace/src/LazyFernWorkspace.ts b/packages/cli/workspace/lazy-fern-workspace/src/LazyFernWorkspace.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/LazyFernWorkspace.ts rename to packages/cli/workspace/lazy-fern-workspace/src/LazyFernWorkspace.ts diff --git a/packages/cli/workspace/lazy-fern-workspace/src/OSSWorkspace.ts b/packages/cli/workspace/lazy-fern-workspace/src/OSSWorkspace.ts new file mode 100644 index 00000000000..218dec1269d --- /dev/null +++ b/packages/cli/workspace/lazy-fern-workspace/src/OSSWorkspace.ts @@ -0,0 +1,124 @@ +import { isNonNullish } from "@fern-api/core-utils"; +import { AbsoluteFilePath, RelativeFilePath } from "@fern-api/fs-utils"; +import { parse, SpecImportSettings } from "@fern-api/openapi-ir-parser"; +import { TaskContext } from "@fern-api/task-context"; +import { v4 as uuidv4 } from "uuid"; +import { getAllOpenAPISpecs } from "./utils/getAllOpenAPISpecs"; +import { + AbstractAPIWorkspace, + BaseOpenAPIWorkspace, + FernWorkspace, + getOptionsOverridesFromSettings, + IdentifiableSource, + Spec +} from "@fern-api/api-workspace-commons"; +import { OpenApiIntermediateRepresentation } from "@fern-api/openapi-ir"; +import { OpenAPILoader } from "./loaders/OpenAPILoader"; + +export declare namespace OSSWorkspace { + export interface Args extends AbstractAPIWorkspace.Args { + specs: Spec[]; + } + + export type Settings = BaseOpenAPIWorkspace.Settings; +} + +export class OSSWorkspace extends BaseOpenAPIWorkspace { + public specs: Spec[]; + public sources: IdentifiableSource[]; + + private loader: OpenAPILoader; + + constructor({ specs, ...superArgs }: OSSWorkspace.Args) { + super({ + ...superArgs, + respectReadonlySchemas: specs.every((spec) => spec.settings?.respectReadonlySchemas ?? false), + onlyIncludeReferencedSchemas: specs.every((spec) => spec.settings?.onlyIncludeReferencedSchemas ?? false), + inlinePathParameters: specs.every((spec) => spec.settings?.inlinePathParameters ?? false), + objectQueryParameters: specs.every((spec) => spec.settings?.objectQueryParameters ?? false) + }); + this.specs = specs; + this.sources = this.convertSpecsToIdentifiableSources(specs); + this.loader = new OpenAPILoader(this.absoluteFilePath); + } + + public async getOpenAPIIr( + { + context, + relativePathToDependency + }: { + context: TaskContext; + relativePathToDependency?: RelativeFilePath; + }, + settings?: OSSWorkspace.Settings + ): Promise { + const openApiSpecs = await getAllOpenAPISpecs({ context, specs: this.specs, relativePathToDependency }); + const optionOverrides = getOptionsOverridesFromSettings(settings); + return await parse({ + context, + documents: await this.loader.loadDocuments({ + context, + specs: openApiSpecs + }), + options: { + ...optionOverrides, + respectReadonlySchemas: this.respectReadonlySchemas, + onlyIncludeReferencedSchemas: this.onlyIncludeReferencedSchemas + } + }); + } + + public async toFernWorkspace( + { context }: { context: TaskContext }, + settings?: OSSWorkspace.Settings + ): Promise { + const definition = await this.getDefinition({ context }, settings); + return new FernWorkspace({ + absoluteFilePath: this.absoluteFilePath, + workspaceName: this.workspaceName, + generatorsConfiguration: this.generatorsConfiguration, + dependenciesConfiguration: { + dependencies: {} + }, + definition, + cliVersion: this.cliVersion, + sources: this.sources + }); + } + + public getAbsoluteFilePaths(): AbsoluteFilePath[] { + return [ + this.absoluteFilePath, + ...this.specs + .flatMap((spec) => [ + spec.type === "protobuf" ? spec.absoluteFilepathToProtobufTarget : spec.absoluteFilepath, + spec.absoluteFilepathToOverrides + ]) + .filter(isNonNullish) + ]; + } + + public getSources(): IdentifiableSource[] { + return this.sources; + } + + private convertSpecsToIdentifiableSources(specs: Spec[]): IdentifiableSource[] { + const seen = new Set(); + const result: IdentifiableSource[] = []; + return specs.reduce((acc, spec) => { + const absoluteFilePath = + spec.type === "protobuf" ? spec.absoluteFilepathToProtobufRoot : spec.absoluteFilepath; + + if (!seen.has(absoluteFilePath)) { + seen.add(absoluteFilePath); + acc.push({ + type: spec.type, + id: uuidv4(), + absoluteFilePath + }); + } + + return acc; + }, result); + } +} diff --git a/packages/cli/lazy-fern-workspace/src/__test__/parseYamlFiles.test.ts b/packages/cli/workspace/lazy-fern-workspace/src/__test__/parseYamlFiles.test.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/__test__/parseYamlFiles.test.ts rename to packages/cli/workspace/lazy-fern-workspace/src/__test__/parseYamlFiles.test.ts diff --git a/packages/cli/lazy-fern-workspace/src/api-yml.schema.json b/packages/cli/workspace/lazy-fern-workspace/src/api-yml.schema.json similarity index 100% rename from packages/cli/lazy-fern-workspace/src/api-yml.schema.json rename to packages/cli/workspace/lazy-fern-workspace/src/api-yml.schema.json diff --git a/packages/cli/lazy-fern-workspace/src/fern.schema.json b/packages/cli/workspace/lazy-fern-workspace/src/fern.schema.json similarity index 100% rename from packages/cli/lazy-fern-workspace/src/fern.schema.json rename to packages/cli/workspace/lazy-fern-workspace/src/fern.schema.json diff --git a/packages/cli/lazy-fern-workspace/src/index.ts b/packages/cli/workspace/lazy-fern-workspace/src/index.ts similarity index 63% rename from packages/cli/lazy-fern-workspace/src/index.ts rename to packages/cli/workspace/lazy-fern-workspace/src/index.ts index e93313c2c99..d3729166812 100644 --- a/packages/cli/lazy-fern-workspace/src/index.ts +++ b/packages/cli/workspace/lazy-fern-workspace/src/index.ts @@ -1,4 +1,3 @@ -export { type AsyncAPISource, type OpenAPISource, type ProtobufSource, type Source } from "./OSSWorkspace"; export { OpenAPILoader } from "./loaders/OpenAPILoader"; export * from "./utils"; export * from "./LazyFernWorkspace"; diff --git a/packages/cli/lazy-fern-workspace/src/loaders/OpenAPILoader.ts b/packages/cli/workspace/lazy-fern-workspace/src/loaders/OpenAPILoader.ts similarity index 88% rename from packages/cli/lazy-fern-workspace/src/loaders/OpenAPILoader.ts rename to packages/cli/workspace/lazy-fern-workspace/src/loaders/OpenAPILoader.ts index c6d1a50dc11..a4093383b3b 100644 --- a/packages/cli/lazy-fern-workspace/src/loaders/OpenAPILoader.ts +++ b/packages/cli/workspace/lazy-fern-workspace/src/loaders/OpenAPILoader.ts @@ -5,10 +5,9 @@ import { AsyncAPIV2, Document, FernOpenAPIExtension, FERN_TYPE_EXTENSIONS } from import { Source as OpenApiIrSource } from "@fern-api/openapi-ir"; import { readFile } from "fs/promises"; import { OpenAPI } from "openapi-types"; -import { OpenAPISpec } from "../OSSWorkspace"; -import { bundle, Config, Source } from "@redocly/openapi-core"; -import { BundleOptions } from "@redocly/openapi-core/lib/bundle"; +import { bundle, Source } from "@redocly/openapi-core"; import yaml from "js-yaml"; +import { DEFAULT_OPENAPI_BUNDLE_OPTIONS, OpenAPISpec } from "@fern-api/api-workspace-commons"; export class OpenAPILoader { constructor(private readonly absoluteFilePath: AbsoluteFilePath) {} @@ -136,34 +135,17 @@ export class OpenAPILoader { absolutePathToOpenAPI: AbsoluteFilePath; parsed?: OpenAPI.Document; }): Promise { - const options: BundleOptions = { - config: new Config( - { - apis: {}, - styleguide: { - plugins: [FERN_TYPE_EXTENSIONS], - rules: { - spec: "warn" - } - } - }, - undefined - ), - dereference: false, - removeUnusedComponents: false, - keepUrlRefs: true - }; const result = parsed != null ? await bundle({ - ...options, + ...DEFAULT_OPENAPI_BUNDLE_OPTIONS, doc: { source: new Source(absolutePathToOpenAPI, ""), parsed } }) : await bundle({ - ...options, + ...DEFAULT_OPENAPI_BUNDLE_OPTIONS, ref: absolutePathToOpenAPI }); return result.bundle.parsed; diff --git a/packages/cli/lazy-fern-workspace/src/loaders/index.ts b/packages/cli/workspace/lazy-fern-workspace/src/loaders/index.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/loaders/index.ts rename to packages/cli/workspace/lazy-fern-workspace/src/loaders/index.ts diff --git a/packages/cli/lazy-fern-workspace/src/loaders/mergeWithOverrides.ts b/packages/cli/workspace/lazy-fern-workspace/src/loaders/mergeWithOverrides.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/loaders/mergeWithOverrides.ts rename to packages/cli/workspace/lazy-fern-workspace/src/loaders/mergeWithOverrides.ts diff --git a/packages/cli/lazy-fern-workspace/src/package-yml.schema.json b/packages/cli/workspace/lazy-fern-workspace/src/package-yml.schema.json similarity index 100% rename from packages/cli/lazy-fern-workspace/src/package-yml.schema.json rename to packages/cli/workspace/lazy-fern-workspace/src/package-yml.schema.json diff --git a/packages/cli/lazy-fern-workspace/src/protobuf/ProtobufOpenAPIGenerator.ts b/packages/cli/workspace/lazy-fern-workspace/src/protobuf/ProtobufOpenAPIGenerator.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/protobuf/ProtobufOpenAPIGenerator.ts rename to packages/cli/workspace/lazy-fern-workspace/src/protobuf/ProtobufOpenAPIGenerator.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/Result.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/Result.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/Result.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/Result.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/getAllOpenAPISpecs.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/getAllOpenAPISpecs.ts similarity index 96% rename from packages/cli/lazy-fern-workspace/src/utils/getAllOpenAPISpecs.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/getAllOpenAPISpecs.ts index b0e69d69511..c55cedf521b 100644 --- a/packages/cli/lazy-fern-workspace/src/utils/getAllOpenAPISpecs.ts +++ b/packages/cli/workspace/lazy-fern-workspace/src/utils/getAllOpenAPISpecs.ts @@ -1,7 +1,7 @@ import { RelativeFilePath, join } from "@fern-api/fs-utils"; import { TaskContext } from "@fern-api/task-context"; import { ProtobufOpenAPIGenerator } from "../protobuf/ProtobufOpenAPIGenerator"; -import { OpenAPISpec, ProtobufSpec, Spec } from "../OSSWorkspace"; +import { OpenAPISpec, ProtobufSpec, Spec } from "@fern-api/api-workspace-commons"; export async function getAllOpenAPISpecs({ context, diff --git a/packages/cli/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/index.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/index.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/index.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/index.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/listFernFiles.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/listFernFiles.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/listFernFiles.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/listFernFiles.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/loadAPIWorkspace.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/loadAPIWorkspace.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/loadAPIWorkspace.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/loadAPIWorkspace.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/loadDependency.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/loadDependency.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/loadDependency.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/loadDependency.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/mapValues.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/mapValues.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/mapValues.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/mapValues.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/parseYamlFiles.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/parseYamlFiles.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/parseYamlFiles.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/parseYamlFiles.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/processPackageMarkers.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/processPackageMarkers.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/processPackageMarkers.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/processPackageMarkers.ts diff --git a/packages/cli/lazy-fern-workspace/src/utils/validateStructureOfYamlFiles.ts b/packages/cli/workspace/lazy-fern-workspace/src/utils/validateStructureOfYamlFiles.ts similarity index 100% rename from packages/cli/lazy-fern-workspace/src/utils/validateStructureOfYamlFiles.ts rename to packages/cli/workspace/lazy-fern-workspace/src/utils/validateStructureOfYamlFiles.ts diff --git a/packages/cli/workspace/lazy-fern-workspace/tsconfig.json b/packages/cli/workspace/lazy-fern-workspace/tsconfig.json new file mode 100644 index 00000000000..75ddc89f107 --- /dev/null +++ b/packages/cli/workspace/lazy-fern-workspace/tsconfig.json @@ -0,0 +1,56 @@ +{ + "extends": "../../../../shared/tsconfig.shared.json", + "compilerOptions": { + "composite": true, + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "./src/**/*", + "./src/*.json" + ], + "references": [ + { + "path": "../../../commons/core-utils" + }, + { + "path": "../../../commons/fs-utils" + }, + { + "path": "../../../commons/logging-execa" + }, + { + "path": "../../../core" + }, + { + "path": "../../api-importers/conjure/conjure-to-fern" + }, + { + "path": "../../api-importers/openapi/openapi-ir-parser" + }, + { + "path": "../../api-importers/openapi/openapi-ir" + }, + { + "path": "../../configuration-loader" + }, + { + "path": "../../cli-logger" + }, + { + "path": "../../logger" + }, + { + "path": "../../semver-utils" + }, + { + "path": "../../task-context" + }, + { + "path": "../../fern-definition/schema" + }, + { + "path": "../commons" + }, + ] +} \ No newline at end of file diff --git a/packages/cli/workspace/lazy-fern-workspace/vitest.config.ts b/packages/cli/workspace/lazy-fern-workspace/vitest.config.ts new file mode 100644 index 00000000000..d11017dc676 --- /dev/null +++ b/packages/cli/workspace/lazy-fern-workspace/vitest.config.ts @@ -0,0 +1 @@ +export { default } from "../../../../shared/vitest.config"; diff --git a/packages/cli/workspace/loader/.depcheckrc.json b/packages/cli/workspace/loader/.depcheckrc.json new file mode 100644 index 00000000000..a3a4f43188c --- /dev/null +++ b/packages/cli/workspace/loader/.depcheckrc.json @@ -0,0 +1,10 @@ +{ + "ignores": [ + "@types/jest", + "globals", + "@types/node" + ], + "ignore-patterns": [ + "lib" + ] +} \ No newline at end of file diff --git a/packages/cli/workspace/loader/.prettierrc.cjs b/packages/cli/workspace/loader/.prettierrc.cjs new file mode 100644 index 00000000000..9b6214d5129 --- /dev/null +++ b/packages/cli/workspace/loader/.prettierrc.cjs @@ -0,0 +1 @@ +module.exports = require("../../../../.prettierrc.json"); diff --git a/packages/cli/workspace-loader/package.json b/packages/cli/workspace/loader/package.json similarity index 97% rename from packages/cli/workspace-loader/package.json rename to packages/cli/workspace/loader/package.json index 6f0f01ec573..7a2d28ac30d 100644 --- a/packages/cli/workspace-loader/package.json +++ b/packages/cli/workspace/loader/package.json @@ -4,7 +4,7 @@ "repository": { "type": "git", "url": "https://github.com/fern-api/fern.git", - "directory": "packages/cli/workspace-loader" + "directory": "packages/cli/workspace/loader" }, "private": true, "files": [ @@ -29,15 +29,15 @@ }, "dependencies": { "@fern-api/api-workspace-commons": "workspace:*", - "@fern-api/lazy-fern-workspace": "workspace:*", + "@fern-api/cli-logger": "workspace:*", "@fern-api/configuration-loader": "workspace:*", "@fern-api/core-utils": "workspace:*", + "@fern-api/fern-definition-schema": "workspace:*", "@fern-api/fs-utils": "workspace:*", - "@fern-api/cli-logger": "workspace:*", + "@fern-api/lazy-fern-workspace": "workspace:*", "@fern-api/logger": "workspace:*", "@fern-api/logging-execa": "workspace:*", "@fern-api/task-context": "workspace:*", - "@fern-api/fern-definition-schema": "workspace:*", "chalk": "^5.3.0", "js-yaml": "^4.1.0", "tmp-promise": "^3.0.3", diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-path/generators.yml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-path/generators.yml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-path/generators.yml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-path/generators.yml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-path/openapi.yml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-path/openapi.yml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-path/openapi.yml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-path/openapi.yml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/generators.yml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/generators.yml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/generators.yml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/generators.yml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/README.md b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/README.md similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/README.md rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/README.md diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/code_samples/C_sharp/echo/post.cs b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/code_samples/C_sharp/echo/post.cs similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/code_samples/C_sharp/echo/post.cs rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/code_samples/C_sharp/echo/post.cs diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/code_samples/PHP/echo/post.php b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/code_samples/PHP/echo/post.php similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/code_samples/PHP/echo/post.php rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/code_samples/PHP/echo/post.php diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/code_samples/README.md b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/code_samples/README.md similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/code_samples/README.md rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/code_samples/README.md diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/README.md b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/README.md similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/README.md rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/README.md diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/headers/ExpiresAfter.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/headers/ExpiresAfter.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/headers/ExpiresAfter.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/headers/ExpiresAfter.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/responses/Problem.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/responses/Problem.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/responses/Problem.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/responses/Problem.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Email.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Email.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Email.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Email.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Problem.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Problem.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Problem.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Problem.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Schema.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Schema.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Schema.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/Schema.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/User.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/User.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/User.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/components/schemas/User.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/openapi.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/openapi.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/openapi.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/openapi.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/README.md b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/README.md similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/README.md rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/README.md diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/echo.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/echo.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/echo.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/echo.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItem.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItem.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItem.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItem.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItemWithExamples.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItemWithExamples.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItemWithExamples.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/pathItemWithExamples.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/users_{username}.yaml b/packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/users_{username}.yaml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/openapi-split/openapi/paths/users_{username}.yaml rename to packages/cli/workspace/loader/src/__test__/fixtures/openapi-split/openapi/paths/users_{username}.yaml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/simple/definition/api.yml b/packages/cli/workspace/loader/src/__test__/fixtures/simple/definition/api.yml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/simple/definition/api.yml rename to packages/cli/workspace/loader/src/__test__/fixtures/simple/definition/api.yml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/simple/definition/simple.yml b/packages/cli/workspace/loader/src/__test__/fixtures/simple/definition/simple.yml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/simple/definition/simple.yml rename to packages/cli/workspace/loader/src/__test__/fixtures/simple/definition/simple.yml diff --git a/packages/cli/workspace-loader/src/__test__/fixtures/simple/generators.yml b/packages/cli/workspace/loader/src/__test__/fixtures/simple/generators.yml similarity index 100% rename from packages/cli/workspace-loader/src/__test__/fixtures/simple/generators.yml rename to packages/cli/workspace/loader/src/__test__/fixtures/simple/generators.yml diff --git a/packages/cli/workspace-loader/src/__test__/loadWorkspace.test.ts b/packages/cli/workspace/loader/src/__test__/loadWorkspace.test.ts similarity index 100% rename from packages/cli/workspace-loader/src/__test__/loadWorkspace.test.ts rename to packages/cli/workspace/loader/src/__test__/loadWorkspace.test.ts diff --git a/packages/cli/workspace-loader/src/handleFailedWorkspaceParserResult.ts b/packages/cli/workspace/loader/src/handleFailedWorkspaceParserResult.ts similarity index 100% rename from packages/cli/workspace-loader/src/handleFailedWorkspaceParserResult.ts rename to packages/cli/workspace/loader/src/handleFailedWorkspaceParserResult.ts diff --git a/packages/cli/workspace/loader/src/index.ts b/packages/cli/workspace/loader/src/index.ts new file mode 100644 index 00000000000..a90fb914e15 --- /dev/null +++ b/packages/cli/workspace/loader/src/index.ts @@ -0,0 +1,13 @@ +export * from "./handleFailedWorkspaceParserResult"; +export { loadAPIWorkspace } from "./loadAPIWorkspace"; +export { loadDocsWorkspace } from "./loadDocsWorkspace"; +export { getValidAbsolutePathToOpenAPI as loadOpenAPIFile } from "./loadOpenAPIFile"; +export { type FernFile, type ParsedFernFile } from "./types/FernFile"; +export { type DocsWorkspace, type Workspace } from "./types/Workspace"; +export { + AbstractAPIWorkspace, + FernWorkspace, + type FernDefinition, + getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation, + type IdentifiableSource +} from "@fern-api/api-workspace-commons"; diff --git a/packages/cli/workspace-loader/src/listFernFiles.ts b/packages/cli/workspace/loader/src/listFernFiles.ts similarity index 100% rename from packages/cli/workspace-loader/src/listFernFiles.ts rename to packages/cli/workspace/loader/src/listFernFiles.ts diff --git a/packages/cli/workspace-loader/src/loadAPIChangelog.ts b/packages/cli/workspace/loader/src/loadAPIChangelog.ts similarity index 100% rename from packages/cli/workspace-loader/src/loadAPIChangelog.ts rename to packages/cli/workspace/loader/src/loadAPIChangelog.ts diff --git a/packages/cli/workspace-loader/src/loadAPIWorkspace.ts b/packages/cli/workspace/loader/src/loadAPIWorkspace.ts similarity index 99% rename from packages/cli/workspace-loader/src/loadAPIWorkspace.ts rename to packages/cli/workspace/loader/src/loadAPIWorkspace.ts index 5a185b705ea..12898a7d96b 100644 --- a/packages/cli/workspace-loader/src/loadAPIWorkspace.ts +++ b/packages/cli/workspace/loader/src/loadAPIWorkspace.ts @@ -7,7 +7,7 @@ import { import { AbsoluteFilePath, doesPathExist, join, RelativeFilePath } from "@fern-api/fs-utils"; import { TaskContext } from "@fern-api/task-context"; import { loadAPIChangelog } from "./loadAPIChangelog"; -import { Spec } from "./types/Workspace"; +import { Spec } from "@fern-api/api-workspace-commons"; import { OSSWorkspace, LazyFernWorkspace, diff --git a/packages/cli/workspace-loader/src/loadAsyncAPIFile.ts b/packages/cli/workspace/loader/src/loadAsyncAPIFile.ts similarity index 100% rename from packages/cli/workspace-loader/src/loadAsyncAPIFile.ts rename to packages/cli/workspace/loader/src/loadAsyncAPIFile.ts diff --git a/packages/cli/workspace-loader/src/loadDocsWorkspace.ts b/packages/cli/workspace/loader/src/loadDocsWorkspace.ts similarity index 100% rename from packages/cli/workspace-loader/src/loadDocsWorkspace.ts rename to packages/cli/workspace/loader/src/loadDocsWorkspace.ts diff --git a/packages/cli/workspace-loader/src/loadOpenAPIFile.ts b/packages/cli/workspace/loader/src/loadOpenAPIFile.ts similarity index 100% rename from packages/cli/workspace-loader/src/loadOpenAPIFile.ts rename to packages/cli/workspace/loader/src/loadOpenAPIFile.ts diff --git a/packages/cli/workspace-loader/src/protobuf/ProtobufOpenAPIGenerator.ts b/packages/cli/workspace/loader/src/protobuf/ProtobufOpenAPIGenerator.ts similarity index 100% rename from packages/cli/workspace-loader/src/protobuf/ProtobufOpenAPIGenerator.ts rename to packages/cli/workspace/loader/src/protobuf/ProtobufOpenAPIGenerator.ts diff --git a/packages/cli/workspace-loader/src/types/FernFile.ts b/packages/cli/workspace/loader/src/types/FernFile.ts similarity index 100% rename from packages/cli/workspace-loader/src/types/FernFile.ts rename to packages/cli/workspace/loader/src/types/FernFile.ts diff --git a/packages/cli/workspace/loader/src/types/Workspace.ts b/packages/cli/workspace/loader/src/types/Workspace.ts new file mode 100644 index 00000000000..997d3b9ab76 --- /dev/null +++ b/packages/cli/workspace/loader/src/types/Workspace.ts @@ -0,0 +1,13 @@ +import { docsYml } from "@fern-api/configuration-loader"; +import { AbsoluteFilePath } from "@fern-api/fs-utils"; +import { AbstractAPIWorkspace } from "@fern-api/api-workspace-commons"; + +export type Workspace = DocsWorkspace | AbstractAPIWorkspace; + +export interface DocsWorkspace { + type: "docs"; + workspaceName: string | undefined; + absoluteFilePath: AbsoluteFilePath; // path to the fern folder (dirname(absoluteFilepathToDocsConfig)) + absoluteFilepathToDocsConfig: AbsoluteFilePath; + config: docsYml.RawSchemas.DocsConfiguration; +} diff --git a/packages/cli/workspace/loader/tsconfig.json b/packages/cli/workspace/loader/tsconfig.json new file mode 100644 index 00000000000..3bbcc410224 --- /dev/null +++ b/packages/cli/workspace/loader/tsconfig.json @@ -0,0 +1,49 @@ +{ + "extends": "../../../../shared/tsconfig.shared.json", + "compilerOptions": { + "composite": true, + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "./src/**/*" + ], + "references": [ + { + "path": "../../../commons/core-utils" + }, + { + "path": "../../../commons/fs-utils" + }, + { + "path": "../../../commons/logging-execa" + }, + { + "path": "../../../core" + }, + { + "path": "../../configuration-loader" + }, + { + "path": "../../cli-logger" + }, + { + "path": "../../logger" + }, + { + "path": "../../semver-utils" + }, + { + "path": "../../task-context" + }, + { + "path": "../../fern-definition/schema" + }, + { + "path": "../commons" + }, + { + "path": "../lazy-fern-workspace" + } + ] +} \ No newline at end of file diff --git a/packages/cli/workspace/loader/vitest.config.ts b/packages/cli/workspace/loader/vitest.config.ts new file mode 100644 index 00000000000..d11017dc676 --- /dev/null +++ b/packages/cli/workspace/loader/vitest.config.ts @@ -0,0 +1 @@ +export { default } from "../../../../shared/vitest.config"; diff --git a/packages/cli/yaml/docs-validator/tsconfig.json b/packages/cli/yaml/docs-validator/tsconfig.json index 26dddd694a6..d681a3bce3f 100644 --- a/packages/cli/yaml/docs-validator/tsconfig.json +++ b/packages/cli/yaml/docs-validator/tsconfig.json @@ -28,7 +28,7 @@ "path": "../../task-context" }, { - "path": "../../workspace-loader" + "path": "../../workspace/loader" }, { "path": "../../project-loader" diff --git a/packages/seed/src/commands/run/runWithCustomFixture.ts b/packages/seed/src/commands/run/runWithCustomFixture.ts index e48c7be1a11..9d16e27f5e0 100644 --- a/packages/seed/src/commands/run/runWithCustomFixture.ts +++ b/packages/seed/src/commands/run/runWithCustomFixture.ts @@ -4,7 +4,7 @@ import { LogLevel } from "@fern-api/logger"; import { AbstractAPIWorkspace, FernWorkspace, - getOSSWorkspaceSettingsFromGeneratorInvocation + getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation } from "@fern-api/workspace-loader"; import tmp from "tmp-promise"; import { GeneratorWorkspace } from "../../loadGeneratorWorkspaces"; @@ -69,7 +69,7 @@ export async function runWithCustomFixture({ try { const fernWorkspace: FernWorkspace = await apiWorkspace.toFernWorkspace( { context: taskContext }, - getOSSWorkspaceSettingsFromGeneratorInvocation(generatorGroup.invocation) + getBaseOpenAPIWorkspaceSettingsFromGeneratorInvocation(generatorGroup.invocation) ); await dockerGeneratorRunner.build(); diff --git a/packages/seed/tsconfig.json b/packages/seed/tsconfig.json index d8a33816e9c..a487cbd5642 100644 --- a/packages/seed/tsconfig.json +++ b/packages/seed/tsconfig.json @@ -1,18 +1,46 @@ { "extends": "../../shared/tsconfig.shared.json", - "compilerOptions": { "composite": true, "outDir": "lib", "rootDir": "src" }, - "include": ["./src/**/*"], + "compilerOptions": { + "composite": true, + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "./src/**/*" + ], "references": [ - { "path": "../cli/configuration" }, - { "path": "../cli/generation/local-generation/local-workspace-runner" }, - { "path": "../cli/logger" }, - { "path": "../cli/login" }, - { "path": "../cli/task-context" }, - { "path": "../cli/workspace-loader" }, - { "path": "../cli/workspace-commons" }, - { "path": "../commons/core-utils" }, - { "path": "../commons/fs-utils" }, - { "path": "../commons/logging-execa" }, - { "path": "../ir-sdk" } + { + "path": "../cli/configuration" + }, + { + "path": "../cli/generation/local-generation/local-workspace-runner" + }, + { + "path": "../cli/logger" + }, + { + "path": "../cli/login" + }, + { + "path": "../cli/task-context" + }, + { + "path": "../cli/workspace/loader" + }, + { + "path": "../cli/workspace/commons" + }, + { + "path": "../commons/core-utils" + }, + { + "path": "../commons/fs-utils" + }, + { + "path": "../commons/logging-execa" + }, + { + "path": "../ir-sdk" + } ] -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ff6983855db..545948cdeea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3500,7 +3500,7 @@ importers: version: link:../../../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../../../workspace-loader + version: link:../../../workspace/loader devDependencies: '@types/node': specifier: 18.7.18 @@ -3667,21 +3667,21 @@ importers: packages/cli/api-importers/openapi/openapi-ir-to-fern-tests: dependencies: + '@fern-api/browser-compatible-fern-workspace': + specifier: workspace:* + version: link:../../../workspace/browser-compatible-fern-workspace '@fern-api/fs-utils': specifier: workspace:* version: link:../../../../commons/fs-utils '@fern-api/lazy-fern-workspace': specifier: workspace:* - version: link:../../../lazy-fern-workspace - '@fern-api/openapi-ir-parser': - specifier: workspace:* - version: link:../openapi-ir-parser + version: link:../../../workspace/lazy-fern-workspace '@fern-api/task-context': specifier: workspace:* version: link:../../../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../../../workspace-loader + version: link:../../../workspace/loader js-yaml: specifier: ^4.1.0 version: 4.1.0 @@ -3770,7 +3770,7 @@ importers: devDependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../workspace-commons + version: link:../workspace/commons '@fern-api/auth': specifier: workspace:* version: link:../auth @@ -3830,7 +3830,7 @@ importers: version: link:../fern-definition/ir-to-jsonschema '@fern-api/lazy-fern-workspace': specifier: workspace:* - version: link:../lazy-fern-workspace + version: link:../workspace/lazy-fern-workspace '@fern-api/local-workspace-runner': specifier: workspace:* version: link:../generation/local-generation/local-workspace-runner @@ -3878,7 +3878,7 @@ importers: version: 0.10.2 '@fern-api/workspace-loader': specifier: workspace:* - version: link:../workspace-loader + version: link:../workspace/loader '@fern-fern/fiddle-sdk': specifier: 0.0.584 version: 0.0.584 @@ -4114,7 +4114,7 @@ importers: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../workspace-commons + version: link:../workspace/commons '@fern-api/fern-definition-schema': specifier: workspace:* version: link:../fern-definition/schema @@ -4575,7 +4575,7 @@ importers: devDependencies: '@fern-api/workspace-loader': specifier: workspace:* - version: link:../workspace-loader + version: link:../workspace/loader '@types/lodash-es': specifier: ^4.17.12 version: 4.17.12 @@ -4675,7 +4675,7 @@ importers: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../../workspace-commons + version: link:../../workspace/commons '@fern-api/core-utils': specifier: workspace:* version: link:../../../commons/core-utils @@ -4819,7 +4819,7 @@ importers: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../../workspace-commons + version: link:../../workspace/commons '@fern-api/configuration-loader': specifier: workspace:* version: link:../../configuration-loader @@ -4843,7 +4843,7 @@ importers: version: link:../../../ir-sdk '@fern-api/lazy-fern-workspace': specifier: workspace:* - version: link:../../lazy-fern-workspace + version: link:../../workspace/lazy-fern-workspace '@fern-api/logger': specifier: workspace:* version: link:../../logger @@ -4901,7 +4901,7 @@ importers: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../../workspace-commons + version: link:../../workspace/commons '@fern-api/configuration': specifier: workspace:* version: link:../../configuration @@ -4989,7 +4989,7 @@ importers: version: link:../../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../../workspace-loader + version: link:../../workspace/loader prettier: specifier: ^2.7.1 version: 2.7.1 @@ -5044,7 +5044,7 @@ importers: version: link:../../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../../workspace-loader + version: link:../../workspace/loader '@fern-fern/ir-v1-model': specifier: 0.0.2 version: 0.0.2 @@ -5274,7 +5274,7 @@ importers: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../../../workspace-commons + version: link:../../../workspace/commons '@fern-api/cli-source-resolver': specifier: workspace:* version: link:../../../cli-source-resolver @@ -5313,7 +5313,7 @@ importers: version: link:../../../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../../../workspace-loader + version: link:../../../workspace/loader '@fern-fern/fiddle-sdk': specifier: 0.0.584 version: 0.0.584 @@ -5413,7 +5413,7 @@ importers: version: link:../../../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../../../workspace-loader + version: link:../../../workspace/loader '@fern-fern/fdr-cjs-sdk': specifier: 0.126.1-444264056 version: 0.126.1-444264056 @@ -5607,130 +5607,6 @@ importers: specifier: ^2.1.4 version: 2.1.4(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) - packages/cli/lazy-fern-workspace: - dependencies: - '@fern-api/api-workspace-commons': - specifier: workspace:* - version: link:../workspace-commons - '@fern-api/cli-logger': - specifier: workspace:* - version: link:../cli-logger - '@fern-api/configuration-loader': - specifier: workspace:* - version: link:../configuration-loader - '@fern-api/conjure-to-fern': - specifier: workspace:* - version: link:../api-importers/conjure/conjure-to-fern - '@fern-api/core': - specifier: workspace:* - version: link:../../core - '@fern-api/core-utils': - specifier: workspace:* - version: link:../../commons/core-utils - '@fern-api/fern-definition-schema': - specifier: workspace:* - version: link:../fern-definition/schema - '@fern-api/fs-utils': - specifier: workspace:* - version: link:../../commons/fs-utils - '@fern-api/logger': - specifier: workspace:* - version: link:../logger - '@fern-api/logging-execa': - specifier: workspace:* - version: link:../../commons/logging-execa - '@fern-api/openapi-ir': - specifier: workspace:* - version: link:../api-importers/openapi/openapi-ir - '@fern-api/openapi-ir-parser': - specifier: workspace:* - version: link:../api-importers/openapi/openapi-ir-parser - '@fern-api/openapi-ir-to-fern': - specifier: workspace:* - version: link:../api-importers/openapi/openapi-ir-to-fern - '@fern-api/semver-utils': - specifier: workspace:* - version: link:../semver-utils - '@fern-api/task-context': - specifier: workspace:* - version: link:../task-context - '@fern-fern/fiddle-sdk': - specifier: 0.0.584 - version: 0.0.584 - '@redocly/openapi-core': - specifier: ^1.4.1 - version: 1.4.1 - '@types/uuid': - specifier: ^9.0.8 - version: 9.0.8 - axios: - specifier: ^1.7.7 - version: 1.7.7 - chalk: - specifier: ^5.3.0 - version: 5.3.0 - js-yaml: - specifier: ^4.1.0 - version: 4.1.0 - lodash-es: - specifier: ^4.17.21 - version: 4.17.21 - object-hash: - specifier: ^3.0.0 - version: 3.0.0 - openapi-types: - specifier: ^12.1.3 - version: 12.1.3 - tar: - specifier: ^6.2.1 - version: 6.2.1 - tmp-promise: - specifier: ^3.0.3 - version: 3.0.3 - uuid: - specifier: ^9.0.1 - version: 9.0.1 - zod: - specifier: ^3.22.3 - version: 3.22.4 - devDependencies: - '@types/jest': - specifier: ^29.5.12 - version: 29.5.12 - '@types/js-yaml': - specifier: ^4.0.8 - version: 4.0.8 - '@types/lodash-es': - specifier: ^4.17.12 - version: 4.17.12 - '@types/node': - specifier: 18.7.18 - version: 18.7.18 - '@types/object-hash': - specifier: ^3.0.6 - version: 3.0.6 - '@types/tar': - specifier: ^6.1.11 - version: 6.1.11 - depcheck: - specifier: ^1.4.6 - version: 1.4.6 - eslint: - specifier: ^8.56.0 - version: 8.56.0 - organize-imports-cli: - specifier: ^0.10.0 - version: 0.10.0 - prettier: - specifier: ^2.7.1 - version: 2.7.1 - typescript: - specifier: 4.6.4 - version: 4.6.4 - vitest: - specifier: ^2.1.4 - version: 2.1.4(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) - packages/cli/logger: dependencies: '@fern-api/core-utils': @@ -5931,7 +5807,7 @@ importers: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../workspace-commons + version: link:../workspace/commons '@fern-api/configuration-loader': specifier: workspace:* version: link:../configuration-loader @@ -5943,7 +5819,7 @@ importers: version: link:../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../workspace-loader + version: link:../workspace/loader chalk: specifier: ^5.3.0 version: 5.3.0 @@ -5977,7 +5853,7 @@ importers: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../workspace-commons + version: link:../workspace/commons '@fern-api/auth': specifier: workspace:* version: link:../auth @@ -6102,23 +5978,90 @@ importers: specifier: ^2.1.4 version: 2.1.4(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) - packages/cli/workspace-commons: + packages/cli/workspace/browser-compatible-fern-workspace: + dependencies: + '@fern-api/api-workspace-commons': + specifier: workspace:* + version: link:../commons + '@fern-api/core-utils': + specifier: workspace:* + version: link:../../../commons/core-utils + '@fern-api/openapi-ir': + specifier: workspace:* + version: link:../../api-importers/openapi/openapi-ir + '@fern-api/openapi-ir-parser': + specifier: workspace:* + version: link:../../api-importers/openapi/openapi-ir-parser + '@fern-api/path-utils': + specifier: workspace:* + version: link:../../../commons/path-utils + '@fern-api/task-context': + specifier: workspace:* + version: link:../../task-context + '@redocly/openapi-core': + specifier: ^1.4.1 + version: 1.4.1 + openapi-types: + specifier: ^12.1.3 + version: 12.1.3 + devDependencies: + '@types/jest': + specifier: ^29.5.12 + version: 29.5.12 + '@types/node': + specifier: 18.7.18 + version: 18.7.18 + depcheck: + specifier: ^1.4.6 + version: 1.4.6 + eslint: + specifier: ^8.56.0 + version: 8.56.0 + organize-imports-cli: + specifier: ^0.10.0 + version: 0.10.0 + prettier: + specifier: ^2.7.1 + version: 2.7.1 + typescript: + specifier: 4.6.4 + version: 4.6.4 + vitest: + specifier: ^2.1.4 + version: 2.1.4(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) + + packages/cli/workspace/commons: dependencies: '@fern-api/configuration': specifier: workspace:* - version: link:../configuration + version: link:../../configuration '@fern-api/core-utils': specifier: workspace:* - version: link:../../commons/core-utils + version: link:../../../commons/core-utils '@fern-api/fern-definition-schema': specifier: workspace:* - version: link:../fern-definition/schema + version: link:../../fern-definition/schema + '@fern-api/openapi-ir': + specifier: workspace:* + version: link:../../api-importers/openapi/openapi-ir + '@fern-api/openapi-ir-parser': + specifier: workspace:* + version: link:../../api-importers/openapi/openapi-ir-parser + '@fern-api/openapi-ir-to-fern': + specifier: workspace:* + version: link:../../api-importers/openapi/openapi-ir-to-fern '@fern-api/path-utils': specifier: workspace:* - version: link:../../commons/path-utils + version: link:../../../commons/path-utils '@fern-api/task-context': specifier: workspace:* - version: link:../task-context + version: link:../../task-context + '@redocly/openapi-core': + specifier: ^1.4.1 + version: 1.4.1 + js-yaml: + specifier: ^4.1.0 + version: 4.1.0 lodash-es: specifier: ^4.17.21 version: 4.17.21 @@ -6126,6 +6069,9 @@ importers: '@types/jest': specifier: ^29.5.12 version: 29.5.12 + '@types/js-yaml': + specifier: ^4.0.8 + version: 4.0.8 '@types/lodash-es': specifier: ^4.17.12 version: 4.17.12 @@ -6148,38 +6094,159 @@ importers: specifier: ^2.1.4 version: 2.1.4(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) - packages/cli/workspace-loader: + packages/cli/workspace/lazy-fern-workspace: dependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../workspace-commons + version: link:../commons '@fern-api/cli-logger': specifier: workspace:* - version: link:../cli-logger + version: link:../../cli-logger '@fern-api/configuration-loader': specifier: workspace:* - version: link:../configuration-loader + version: link:../../configuration-loader + '@fern-api/conjure-to-fern': + specifier: workspace:* + version: link:../../api-importers/conjure/conjure-to-fern + '@fern-api/core': + specifier: workspace:* + version: link:../../../core '@fern-api/core-utils': specifier: workspace:* - version: link:../../commons/core-utils + version: link:../../../commons/core-utils '@fern-api/fern-definition-schema': specifier: workspace:* - version: link:../fern-definition/schema + version: link:../../fern-definition/schema '@fern-api/fs-utils': specifier: workspace:* - version: link:../../commons/fs-utils + version: link:../../../commons/fs-utils + '@fern-api/logger': + specifier: workspace:* + version: link:../../logger + '@fern-api/logging-execa': + specifier: workspace:* + version: link:../../../commons/logging-execa + '@fern-api/openapi-ir': + specifier: workspace:* + version: link:../../api-importers/openapi/openapi-ir + '@fern-api/openapi-ir-parser': + specifier: workspace:* + version: link:../../api-importers/openapi/openapi-ir-parser + '@fern-api/semver-utils': + specifier: workspace:* + version: link:../../semver-utils + '@fern-api/task-context': + specifier: workspace:* + version: link:../../task-context + '@fern-fern/fiddle-sdk': + specifier: 0.0.584 + version: 0.0.584 + '@redocly/openapi-core': + specifier: ^1.4.1 + version: 1.4.1 + '@types/uuid': + specifier: ^9.0.8 + version: 9.0.8 + axios: + specifier: ^1.7.7 + version: 1.7.7 + chalk: + specifier: ^5.3.0 + version: 5.3.0 + js-yaml: + specifier: ^4.1.0 + version: 4.1.0 + lodash-es: + specifier: ^4.17.21 + version: 4.17.21 + object-hash: + specifier: ^3.0.0 + version: 3.0.0 + openapi-types: + specifier: ^12.1.3 + version: 12.1.3 + tar: + specifier: ^6.2.1 + version: 6.2.1 + tmp-promise: + specifier: ^3.0.3 + version: 3.0.3 + uuid: + specifier: ^9.0.1 + version: 9.0.1 + zod: + specifier: ^3.22.3 + version: 3.23.8 + devDependencies: + '@types/jest': + specifier: ^29.5.12 + version: 29.5.12 + '@types/js-yaml': + specifier: ^4.0.8 + version: 4.0.8 + '@types/lodash-es': + specifier: ^4.17.12 + version: 4.17.12 + '@types/node': + specifier: 18.7.18 + version: 18.7.18 + '@types/object-hash': + specifier: ^3.0.6 + version: 3.0.6 + '@types/tar': + specifier: ^6.1.11 + version: 6.1.11 + depcheck: + specifier: ^1.4.6 + version: 1.4.6 + eslint: + specifier: ^8.56.0 + version: 8.56.0 + organize-imports-cli: + specifier: ^0.10.0 + version: 0.10.0 + prettier: + specifier: ^2.7.1 + version: 2.7.1 + typescript: + specifier: 4.6.4 + version: 4.6.4 + vitest: + specifier: ^2.1.4 + version: 2.1.4(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) + + packages/cli/workspace/loader: + dependencies: + '@fern-api/api-workspace-commons': + specifier: workspace:* + version: link:../commons + '@fern-api/cli-logger': + specifier: workspace:* + version: link:../../cli-logger + '@fern-api/configuration-loader': + specifier: workspace:* + version: link:../../configuration-loader + '@fern-api/core-utils': + specifier: workspace:* + version: link:../../../commons/core-utils + '@fern-api/fern-definition-schema': + specifier: workspace:* + version: link:../../fern-definition/schema + '@fern-api/fs-utils': + specifier: workspace:* + version: link:../../../commons/fs-utils '@fern-api/lazy-fern-workspace': specifier: workspace:* version: link:../lazy-fern-workspace '@fern-api/logger': specifier: workspace:* - version: link:../logger + version: link:../../logger '@fern-api/logging-execa': specifier: workspace:* - version: link:../../commons/logging-execa + version: link:../../../commons/logging-execa '@fern-api/task-context': specifier: workspace:* - version: link:../task-context + version: link:../../task-context chalk: specifier: ^5.3.0 version: 5.3.0 @@ -6191,7 +6258,7 @@ importers: version: 3.0.3 zod: specifier: ^3.22.3 - version: 3.22.4 + version: 3.23.8 devDependencies: '@types/jest': specifier: ^29.5.12 @@ -6249,7 +6316,7 @@ importers: version: link:../../task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../../workspace-loader + version: link:../../workspace/loader '@types/tinycolor2': specifier: ^1.4.6 version: 1.4.6 @@ -6591,7 +6658,7 @@ importers: devDependencies: '@fern-api/api-workspace-commons': specifier: workspace:* - version: link:../cli/workspace-commons + version: link:../cli/workspace/commons '@fern-api/configuration': specifier: workspace:* version: link:../cli/configuration @@ -6621,7 +6688,7 @@ importers: version: link:../cli/task-context '@fern-api/workspace-loader': specifier: workspace:* - version: link:../cli/workspace-loader + version: link:../cli/workspace/loader '@fern-fern/fiddle-sdk': specifier: 0.0.584 version: 0.0.584