Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions api/codegen-runtime.api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ApiServer · interface · enum?: readonly string[];
ApiServer · interface · description?: string;
ApiServer · interface · }>>;
ApiServer · interface · }
Binding · type · export type Binding = HttpBinding | RpcBinding | GraphqlBinding;
Confidence · type · export type Confidence = "contract" | "example" | "inferred" | "override";
Effect · type · export type Effect = "read" | "write" | "destructive";
GraphqlBinding · interface · export interface GraphqlBinding {
GraphqlBinding · interface · kind: "graphql";
Expand All @@ -16,6 +18,11 @@ GraphqlBinding · interface · field: string;
GraphqlBinding · interface · variables: Readonly<Record<string, string>>;
GraphqlBinding · interface · selection: string;
GraphqlBinding · interface · }
HttpBinding · interface · export interface HttpBinding {
HttpBinding · interface · kind: "http";
HttpBinding · interface · method: HttpMethod;
HttpBinding · interface · path: string;
HttpBinding · interface · }
ManifestOperation · interface · export interface ManifestOperation {
ManifestOperation · interface · id: string;
ManifestOperation · interface · command: string;
Expand Down Expand Up @@ -93,6 +100,10 @@ Pagination · type · style: "link";
Pagination · type · next: string;
Pagination · type · items?: string;
Pagination · type · };
RpcBinding · interface · export interface RpcBinding {
RpcBinding · interface · kind: "rpc";
RpcBinding · interface · name: string;
RpcBinding · interface · }
SchemaNode · type · export type SchemaNode = SchemaCommon & ({
SchemaNode · type · type: "ref";
SchemaNode · type · ref: string;
Expand Down
10 changes: 10 additions & 0 deletions changes/fix-codegen-runtime-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Added

- **`/codegen/runtime` exports `Binding`, `HttpBinding`, `RpcBinding` and `Confidence`.** A CLI that reads an
operation's binding or how far it is trusted no longer imports the experimental `/codegen` for the type.

### Changed — experimental

- **The generated manifest and definitions import their types from `@wirecat/cli-base/codegen/runtime`** when
`coreImport` is not given, not from `/codegen`. Every type they name is there, and `/codegen/runtime` is part of
the stable API, so a CLI no longer passes `coreImport` by hand. Regenerating changes that one import line.
4 changes: 2 additions & 2 deletions src/codegen/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const manifestGenerator =
).filter(([, , , value]) => value !== undefined)
const types = ["ManifestOperation", ...extras.map(([, type]) => type)].sort()
const content = [
`import type { ${types.join(", ")} } from "${options.coreImport ?? "@wirecat/cli-base/codegen"}"`,
`import type { ${types.join(", ")} } from "${options.coreImport ?? "@wirecat/cli-base/codegen/runtime"}"`,
"",
`export const operations: readonly ManifestOperation[] = ${JSON.stringify(operations, null, 2)}`,
...extras.flatMap(([name, , type, value]) => [
Expand All @@ -112,7 +112,7 @@ export const definitionsGenerator =
return [
{
path: options.path,
content: `import type { SchemaNode } from "${options.coreImport ?? "@wirecat/cli-base/codegen"}"\n\nexport const definitions: Readonly<Record<string, SchemaNode>> = ${JSON.stringify(definitions, null, 2)}\n`,
content: `import type { SchemaNode } from "${options.coreImport ?? "@wirecat/cli-base/codegen/runtime"}"\n\nexport const definitions: Readonly<Record<string, SchemaNode>> = ${JSON.stringify(definitions, null, 2)}\n`,
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/openapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ describe("adaptOpenApi reads what a CLI would otherwise write by hand", () => {
expect(model.operations.find((candidate) => candidate.id === "open")?.security).toEqual([])
const [manifest] = generate(model, [manifestGenerator({ path: "manifest.ts" })], { banner: [] })
expect(manifest?.content).toContain(
'import type { ApiServer, ManifestOperation, SecurityRequirement, SecurityScheme } from "@wirecat/cli-base/codegen"',
'import type { ApiServer, ManifestOperation, SecurityRequirement, SecurityScheme } from "@wirecat/cli-base/codegen/runtime"',
)
expect(manifest?.content).toContain('"security": []')
})
Expand Down
4 changes: 4 additions & 0 deletions src/codegen/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ export const unique = (items: readonly unknown[]): boolean =>
export type { ManifestOperation } from "./manifest.js"
export type {
ApiServer,
Binding,
Confidence,
Effect,
GraphqlBinding,
HttpBinding,
OAuthFlow,
OperationPermission,
PageParameter,
Pagination,
RpcBinding,
SchemaNode,
SecurityRequirement,
SecurityScheme,
Expand Down