toolcraft-openapi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/api-command.d.ts +7 -0
- package/dist/api-command.js +4 -0
- package/dist/auth/bearer-token-auth.d.ts +8 -0
- package/dist/auth/bearer-token-auth.js +216 -0
- package/dist/auth/types.d.ts +9 -0
- package/dist/auth/types.js +1 -0
- package/dist/bin/generate.d.ts +40 -0
- package/dist/bin/generate.js +248 -0
- package/dist/define-client.d.ts +20 -0
- package/dist/define-client.js +148 -0
- package/dist/generate.d.ts +210 -0
- package/dist/generate.js +1131 -0
- package/dist/group-by-noun.d.ts +6 -0
- package/dist/group-by-noun.js +17 -0
- package/dist/http.d.ts +26 -0
- package/dist/http.js +123 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -0
- package/dist/interpreter.d.ts +6 -0
- package/dist/interpreter.js +289 -0
- package/dist/lock.d.ts +14 -0
- package/dist/lock.js +48 -0
- package/dist/naming.d.ts +24 -0
- package/dist/naming.js +218 -0
- package/dist/request-shape.d.ts +15 -0
- package/dist/request-shape.js +5 -0
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.js +94 -0
- package/dist/spec-source.d.ts +11 -0
- package/dist/spec-source.js +63 -0
- package/node_modules/@poe-code/design-system/dist/acp/components.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/acp/components.js +121 -0
- package/node_modules/@poe-code/design-system/dist/acp/index.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/acp/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/acp/writer.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/acp/writer.js +21 -0
- package/node_modules/@poe-code/design-system/dist/components/command-errors.d.ts +16 -0
- package/node_modules/@poe-code/design-system/dist/components/command-errors.js +22 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.d.ts +20 -0
- package/node_modules/@poe-code/design-system/dist/components/help-formatter.js +27 -0
- package/node_modules/@poe-code/design-system/dist/components/index.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/components/index.js +7 -0
- package/node_modules/@poe-code/design-system/dist/components/logger.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/components/logger.js +60 -0
- package/node_modules/@poe-code/design-system/dist/components/symbols.d.ts +12 -0
- package/node_modules/@poe-code/design-system/dist/components/symbols.js +71 -0
- package/node_modules/@poe-code/design-system/dist/components/table.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/components/table.js +74 -0
- package/node_modules/@poe-code/design-system/dist/components/text.d.ts +14 -0
- package/node_modules/@poe-code/design-system/dist/components/text.js +104 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.d.ts +18 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/ansi.js +298 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.d.ts +25 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.js +189 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/border.d.ts +9 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/border.js +123 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/footer.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/footer.js +57 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/output-pane.d.ts +12 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/output-pane.js +254 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/components/stats-pane.js +121 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/dashboard.d.ts +20 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/dashboard.js +167 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/demo.d.ts +13 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/demo.js +145 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/index.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/index.js +4 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.d.ts +3 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/keymap.js +99 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/layout.d.ts +25 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/layout.js +79 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/should-use-dashboard.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/should-use-dashboard.js +7 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/snapshot.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/snapshot.js +68 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/store.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/store.js +51 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal.d.ts +37 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/terminal.js +233 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.d.ts +36 -0
- package/node_modules/@poe-code/design-system/dist/dashboard/types.js +1 -0
- package/node_modules/@poe-code/design-system/dist/index.d.ts +33 -0
- package/node_modules/@poe-code/design-system/dist/index.js +31 -0
- package/node_modules/@poe-code/design-system/dist/internal/output-format.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/internal/output-format.js +22 -0
- package/node_modules/@poe-code/design-system/dist/internal/strip-ansi.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/internal/strip-ansi.js +3 -0
- package/node_modules/@poe-code/design-system/dist/internal/theme-detect.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/internal/theme-detect.js +49 -0
- package/node_modules/@poe-code/design-system/dist/prompts/index.d.ts +66 -0
- package/node_modules/@poe-code/design-system/dist/prompts/index.js +132 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/cancel.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/cancel.js +9 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.js +15 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.d.ts +18 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.js +101 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.js +39 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/outro.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/outro.js +16 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/spinner.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/spinner.js +74 -0
- package/node_modules/@poe-code/design-system/dist/prompts/theme.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/prompts/theme.js +12 -0
- package/node_modules/@poe-code/design-system/dist/static/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/static/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/static/menu.d.ts +11 -0
- package/node_modules/@poe-code/design-system/dist/static/menu.js +36 -0
- package/node_modules/@poe-code/design-system/dist/static/spinner.d.ts +14 -0
- package/node_modules/@poe-code/design-system/dist/static/spinner.js +46 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/ast.d.ts +92 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/ast.js +1 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/demo-content.js +139 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/index.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/index.js +8 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/block.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/block.js +1495 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/frontmatter.js +412 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/inline.d.ts +10 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser/inline.js +1166 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser.d.ts +5 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/parser.js +42 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/renderer.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/renderer.js +572 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/node_modules/@poe-code/design-system/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/node_modules/@poe-code/design-system/dist/tokens/colors.d.ts +35 -0
- package/node_modules/@poe-code/design-system/dist/tokens/colors.js +34 -0
- package/node_modules/@poe-code/design-system/dist/tokens/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/tokens/index.js +4 -0
- package/node_modules/@poe-code/design-system/dist/tokens/spacing.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/tokens/spacing.js +6 -0
- package/node_modules/@poe-code/design-system/dist/tokens/typography.d.ts +7 -0
- package/node_modules/@poe-code/design-system/dist/tokens/typography.js +8 -0
- package/node_modules/@poe-code/design-system/dist/tokens/widths.d.ts +5 -0
- package/node_modules/@poe-code/design-system/dist/tokens/widths.js +5 -0
- package/node_modules/@poe-code/design-system/package.json +25 -0
- package/node_modules/auth-store/README.md +47 -0
- package/node_modules/auth-store/dist/create-secret-store.d.ts +2 -0
- package/node_modules/auth-store/dist/create-secret-store.js +35 -0
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +39 -0
- package/node_modules/auth-store/dist/encrypted-file-store.js +156 -0
- package/node_modules/auth-store/dist/index.d.ts +7 -0
- package/node_modules/auth-store/dist/index.js +4 -0
- package/node_modules/auth-store/dist/keychain-store.d.ts +22 -0
- package/node_modules/auth-store/dist/keychain-store.js +111 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +10 -0
- package/node_modules/auth-store/dist/provider-store.js +28 -0
- package/node_modules/auth-store/dist/types.d.ts +20 -0
- package/node_modules/auth-store/dist/types.js +1 -0
- package/node_modules/auth-store/package.json +25 -0
- package/package.json +48 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { defineCommand, defineGroup, UserError } from "agent-kit";
|
|
2
|
+
import { toMcpPrefix } from "./naming.js";
|
|
3
|
+
const CLI_SCOPE = ["cli"];
|
|
4
|
+
export function defineClient(options) {
|
|
5
|
+
validateClientName(options.name);
|
|
6
|
+
if (options.auth === undefined) {
|
|
7
|
+
throw new UserError("defineClient requires an auth provider.");
|
|
8
|
+
}
|
|
9
|
+
const mergedChildren = mergeChildren([
|
|
10
|
+
{ nodes: options.commands, source: "generated" },
|
|
11
|
+
{ nodes: options.handwrittenCommands ?? [], source: "handwritten" },
|
|
12
|
+
{ nodes: options.auth.commands.map((command) => cloneNode(command, CLI_SCOPE)), source: "auth" }
|
|
13
|
+
]);
|
|
14
|
+
return {
|
|
15
|
+
name: options.name,
|
|
16
|
+
mcpPrefix: toMcpPrefix(options.name),
|
|
17
|
+
root: defineGroup({
|
|
18
|
+
name: options.name,
|
|
19
|
+
children: mergedChildren
|
|
20
|
+
}),
|
|
21
|
+
services: {
|
|
22
|
+
baseUrl: options.baseUrl,
|
|
23
|
+
tokenSource: options.auth
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function mergeChildren(entries) {
|
|
28
|
+
const nodeSources = new Map();
|
|
29
|
+
const merged = [];
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
mergeInto(merged, entry.nodes, [], entry.source, nodeSources);
|
|
32
|
+
}
|
|
33
|
+
// defineGroup snapshots its children at construction time, while mergeInto mutates an
|
|
34
|
+
// existing group's children after that snapshot. Re-cloning here re-materializes each
|
|
35
|
+
// merged group so nesting client.root under another group preserves the merged children.
|
|
36
|
+
return merged.map((node) => cloneNode(node));
|
|
37
|
+
}
|
|
38
|
+
function mergeInto(target, incoming, path, source, nodeSources) {
|
|
39
|
+
for (const candidate of incoming) {
|
|
40
|
+
const nextNode = cloneNode(candidate);
|
|
41
|
+
registerSource(nextNode, source, nodeSources);
|
|
42
|
+
const existing = target.find((node) => node.name === nextNode.name);
|
|
43
|
+
if (existing === undefined) {
|
|
44
|
+
target.push(nextNode);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (existing.kind !== "group" || nextNode.kind !== "group") {
|
|
48
|
+
throw createCollisionError([...path, nextNode.name], getRegisteredSource(nodeSources, existing), source);
|
|
49
|
+
}
|
|
50
|
+
mergeInto(existing.children, nextNode.children, [...path, nextNode.name], source, nodeSources);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function registerSource(node, source, nodeSources) {
|
|
54
|
+
nodeSources.set(node, source);
|
|
55
|
+
if (node.kind === "group") {
|
|
56
|
+
for (const child of node.children) {
|
|
57
|
+
registerSource(child, source, nodeSources);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function getRegisteredSource(nodeSources, node) {
|
|
62
|
+
const source = nodeSources.get(node);
|
|
63
|
+
if (source === undefined) {
|
|
64
|
+
throw new Error("Bug: merged command node is missing source metadata.");
|
|
65
|
+
}
|
|
66
|
+
return source;
|
|
67
|
+
}
|
|
68
|
+
function createCollisionError(path, left, right) {
|
|
69
|
+
return new UserError(`Command path ${JSON.stringify(path.join(" "))} is defined more than once (${left} and ${right}).`);
|
|
70
|
+
}
|
|
71
|
+
function cloneNode(node, scopeOverride) {
|
|
72
|
+
if (node.kind === "command") {
|
|
73
|
+
return cloneCommand(node, scopeOverride);
|
|
74
|
+
}
|
|
75
|
+
return cloneGroup(node, scopeOverride);
|
|
76
|
+
}
|
|
77
|
+
function cloneCommand(command, scopeOverride) {
|
|
78
|
+
return defineCommand({
|
|
79
|
+
name: command.name,
|
|
80
|
+
description: command.description,
|
|
81
|
+
aliases: [...command.aliases],
|
|
82
|
+
positional: [...command.positional],
|
|
83
|
+
params: command.params,
|
|
84
|
+
secrets: { ...command.secrets },
|
|
85
|
+
scope: [...(scopeOverride ?? command.scope)],
|
|
86
|
+
confirm: command.confirm,
|
|
87
|
+
requires: command.requires,
|
|
88
|
+
handler: command.handler,
|
|
89
|
+
render: command.render
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function cloneGroup(group, scopeOverride) {
|
|
93
|
+
const children = group.children.map((child) => cloneNode(child, scopeOverride));
|
|
94
|
+
const defaultCommand = findCommand(children, group.default?.name);
|
|
95
|
+
return defineGroup({
|
|
96
|
+
name: group.name,
|
|
97
|
+
description: group.description,
|
|
98
|
+
aliases: [...group.aliases],
|
|
99
|
+
scope: cloneScope(group.scope, scopeOverride),
|
|
100
|
+
secrets: { ...group.secrets },
|
|
101
|
+
requires: group.requires,
|
|
102
|
+
children,
|
|
103
|
+
default: defaultCommand
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function validateClientName(name) {
|
|
107
|
+
if (!isValidClientName(name)) {
|
|
108
|
+
throw new UserError(`Client name ${JSON.stringify(name)} must use lowercase letters, numbers, and hyphens only.`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function isValidClientName(name) {
|
|
112
|
+
if (name.length === 0 || name.startsWith("-") || name.endsWith("-")) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
for (const character of name) {
|
|
116
|
+
if (character === "-") {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (character >= "a" && character <= "z") {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (character >= "0" && character <= "9") {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
function cloneScope(scope, scopeOverride) {
|
|
130
|
+
if (scopeOverride !== undefined) {
|
|
131
|
+
return [...scopeOverride];
|
|
132
|
+
}
|
|
133
|
+
if (scope === undefined) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
return [...scope];
|
|
137
|
+
}
|
|
138
|
+
function findCommand(nodes, name) {
|
|
139
|
+
if (name === undefined) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
for (const node of nodes) {
|
|
143
|
+
if (node.kind === "command" && node.name === name) {
|
|
144
|
+
return node;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { type HttpMethod } from "./naming.js";
|
|
2
|
+
type OpenApiOperation = OpenApiOperationObject | OpenApiReferenceObject;
|
|
3
|
+
type OpenApiOperationMap = Partial<Record<HttpMethod, OpenApiOperation>>;
|
|
4
|
+
type OpenApiParameterLocation = "path" | "query" | "header" | "cookie";
|
|
5
|
+
export type GeneratedRequestLocation = Exclude<GeneratedParam["location"], "transport">;
|
|
6
|
+
export interface OpenApiDocument {
|
|
7
|
+
openapi?: string;
|
|
8
|
+
info?: {
|
|
9
|
+
title?: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
};
|
|
12
|
+
security?: OpenApiSecurityRequirementObject[];
|
|
13
|
+
paths?: Record<string, OpenApiPathItemObject | undefined>;
|
|
14
|
+
components?: {
|
|
15
|
+
securitySchemes?: Record<string, unknown>;
|
|
16
|
+
parameters?: Record<string, OpenApiParameterObject | OpenApiReferenceObject>;
|
|
17
|
+
requestBodies?: Record<string, OpenApiRequestBodyObject | OpenApiReferenceObject>;
|
|
18
|
+
responses?: Record<string, OpenApiResponseObject | OpenApiReferenceObject>;
|
|
19
|
+
schemas?: Record<string, OpenApiSchemaObject | OpenApiReferenceObject>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface OpenApiPathItemObject extends OpenApiOperationMap {
|
|
23
|
+
parameters?: OpenApiParameter[];
|
|
24
|
+
}
|
|
25
|
+
export interface OpenApiOperationObject {
|
|
26
|
+
tags?: string[];
|
|
27
|
+
summary?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
operationId?: string;
|
|
30
|
+
security?: OpenApiSecurityRequirementObject[];
|
|
31
|
+
servers?: OpenApiServerObject[];
|
|
32
|
+
parameters?: OpenApiParameter[];
|
|
33
|
+
requestBody?: OpenApiRequestBodyObject | OpenApiReferenceObject;
|
|
34
|
+
responses?: Record<string, OpenApiResponseObject | OpenApiReferenceObject>;
|
|
35
|
+
}
|
|
36
|
+
export type OpenApiParameter = OpenApiParameterObject | OpenApiReferenceObject;
|
|
37
|
+
export interface OpenApiParameterObject {
|
|
38
|
+
name: string;
|
|
39
|
+
in: OpenApiParameterLocation;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
description?: string;
|
|
42
|
+
content?: Record<string, OpenApiMediaTypeObject | undefined>;
|
|
43
|
+
explode?: boolean;
|
|
44
|
+
schema?: OpenApiSchemaObject | OpenApiReferenceObject;
|
|
45
|
+
style?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface OpenApiRequestBodyObject {
|
|
48
|
+
description?: string;
|
|
49
|
+
required?: boolean;
|
|
50
|
+
content?: Record<string, OpenApiMediaTypeObject | undefined>;
|
|
51
|
+
}
|
|
52
|
+
export interface OpenApiResponseObject {
|
|
53
|
+
description?: string;
|
|
54
|
+
content?: Record<string, OpenApiMediaTypeObject | undefined>;
|
|
55
|
+
}
|
|
56
|
+
export interface OpenApiMediaTypeObject {
|
|
57
|
+
schema?: OpenApiSchemaObject | OpenApiReferenceObject;
|
|
58
|
+
}
|
|
59
|
+
export interface OpenApiSchemaObject {
|
|
60
|
+
type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
|
|
61
|
+
additionalProperties?: boolean | OpenApiSchemaObject | OpenApiReferenceObject;
|
|
62
|
+
allOf?: Array<OpenApiSchemaObject | OpenApiReferenceObject>;
|
|
63
|
+
anyOf?: Array<OpenApiSchemaObject | OpenApiReferenceObject>;
|
|
64
|
+
description?: string;
|
|
65
|
+
default?: unknown;
|
|
66
|
+
enum?: unknown[];
|
|
67
|
+
format?: string;
|
|
68
|
+
items?: OpenApiSchemaObject | OpenApiReferenceObject;
|
|
69
|
+
maxItems?: number;
|
|
70
|
+
maximum?: number;
|
|
71
|
+
maxLength?: number;
|
|
72
|
+
minItems?: number;
|
|
73
|
+
minimum?: number;
|
|
74
|
+
minLength?: number;
|
|
75
|
+
nullable?: boolean;
|
|
76
|
+
oneOf?: Array<OpenApiSchemaObject | OpenApiReferenceObject>;
|
|
77
|
+
pattern?: string;
|
|
78
|
+
required?: string[];
|
|
79
|
+
properties?: Record<string, OpenApiSchemaObject | OpenApiReferenceObject>;
|
|
80
|
+
readOnly?: boolean;
|
|
81
|
+
writeOnly?: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface OpenApiReferenceObject {
|
|
84
|
+
$ref: string;
|
|
85
|
+
}
|
|
86
|
+
interface OpenApiServerObject {
|
|
87
|
+
url: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
}
|
|
90
|
+
type OpenApiSecurityRequirementObject = Record<string, string[]>;
|
|
91
|
+
export interface GenerateOptions {
|
|
92
|
+
specSha: string;
|
|
93
|
+
}
|
|
94
|
+
export interface GeneratedFile {
|
|
95
|
+
path: string;
|
|
96
|
+
contents: string;
|
|
97
|
+
}
|
|
98
|
+
export interface GeneratedCommand {
|
|
99
|
+
noun: string;
|
|
100
|
+
verb: string;
|
|
101
|
+
exportName: string;
|
|
102
|
+
filePath: string;
|
|
103
|
+
operationId: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
method: string;
|
|
106
|
+
path: string;
|
|
107
|
+
auth: "required" | "none";
|
|
108
|
+
confirm: boolean;
|
|
109
|
+
params: GeneratedParam[];
|
|
110
|
+
paramsSchemaOptions?: GeneratedObjectSchemaOptions;
|
|
111
|
+
preflightBlocks: GeneratedPreflightBlock[];
|
|
112
|
+
requestFields: GeneratedRequestField[];
|
|
113
|
+
sectionRenders: GeneratedRequestSectionRenders;
|
|
114
|
+
optionalSections: ReadonlySet<Exclude<GeneratedParam["location"], "transport">>;
|
|
115
|
+
}
|
|
116
|
+
export interface GeneratedParam {
|
|
117
|
+
paramName: string;
|
|
118
|
+
sourceName: string;
|
|
119
|
+
location: "path" | "query" | "body" | "transport";
|
|
120
|
+
description?: string;
|
|
121
|
+
shortFlag?: string;
|
|
122
|
+
scope?: readonly [GeneratedParamScope, ...GeneratedParamScope[]];
|
|
123
|
+
optional: boolean;
|
|
124
|
+
definition: GeneratedParamDefinition;
|
|
125
|
+
}
|
|
126
|
+
interface GeneratedParamDefinitionMetadata {
|
|
127
|
+
defaultValue?: unknown;
|
|
128
|
+
format?: string;
|
|
129
|
+
jsonType?: "integer";
|
|
130
|
+
maxItems?: number;
|
|
131
|
+
maximum?: number;
|
|
132
|
+
maxLength?: number;
|
|
133
|
+
minItems?: number;
|
|
134
|
+
minimum?: number;
|
|
135
|
+
minLength?: number;
|
|
136
|
+
nullable?: boolean;
|
|
137
|
+
pattern?: string;
|
|
138
|
+
requiredScopes?: readonly [GeneratedParamScope, ...GeneratedParamScope[]];
|
|
139
|
+
}
|
|
140
|
+
interface GeneratedScalarParamDefinition extends GeneratedParamDefinitionMetadata {
|
|
141
|
+
kind: "string" | "number" | "boolean";
|
|
142
|
+
}
|
|
143
|
+
interface GeneratedEnumParamDefinition extends GeneratedParamDefinitionMetadata {
|
|
144
|
+
kind: "enum";
|
|
145
|
+
enumValues: readonly [GeneratedEnumValue, ...GeneratedEnumValue[]];
|
|
146
|
+
}
|
|
147
|
+
interface GeneratedArrayParamDefinition extends GeneratedParamDefinitionMetadata {
|
|
148
|
+
kind: "array";
|
|
149
|
+
itemDefinition: GeneratedParamDefinition;
|
|
150
|
+
}
|
|
151
|
+
export type GeneratedParamDefinition = GeneratedScalarParamDefinition | GeneratedEnumParamDefinition | GeneratedArrayParamDefinition;
|
|
152
|
+
type GeneratedParamScope = "cli" | "mcp" | "sdk";
|
|
153
|
+
type GeneratedEnumValue = string | number | boolean;
|
|
154
|
+
export type GeneratedValueReference = {
|
|
155
|
+
kind: "param";
|
|
156
|
+
paramName: string;
|
|
157
|
+
} | {
|
|
158
|
+
kind: "resolved";
|
|
159
|
+
resolvedName: string;
|
|
160
|
+
};
|
|
161
|
+
export type GeneratedValueExpression = {
|
|
162
|
+
kind: "reference";
|
|
163
|
+
reference: GeneratedValueReference;
|
|
164
|
+
} | {
|
|
165
|
+
kind: "queryArray";
|
|
166
|
+
reference: GeneratedValueReference;
|
|
167
|
+
serialization: QueryArraySerialization;
|
|
168
|
+
};
|
|
169
|
+
export interface GeneratedRequestField {
|
|
170
|
+
location: Exclude<GeneratedParam["location"], "transport">;
|
|
171
|
+
omitWhenUndefinedReference: GeneratedValueReference;
|
|
172
|
+
wireName: string;
|
|
173
|
+
value: GeneratedValueExpression;
|
|
174
|
+
}
|
|
175
|
+
export type GeneratedRequestSectionRender = "inline" | "wrapped";
|
|
176
|
+
export type GeneratedRequestSectionRenders = Partial<{
|
|
177
|
+
[K in GeneratedRequestLocation]: K extends "body" ? GeneratedRequestSectionRender : "wrapped";
|
|
178
|
+
}>;
|
|
179
|
+
export interface GeneratedObjectSchemaOptions {
|
|
180
|
+
additionalProperties?: boolean;
|
|
181
|
+
}
|
|
182
|
+
interface RenderSchemaOptionsInput {
|
|
183
|
+
definition: GeneratedParamDefinition;
|
|
184
|
+
description?: string;
|
|
185
|
+
shortFlag?: string;
|
|
186
|
+
scope?: readonly [GeneratedParamScope, ...GeneratedParamScope[]];
|
|
187
|
+
}
|
|
188
|
+
export type GeneratedPreflightBlock = {
|
|
189
|
+
kind: "scalar-null";
|
|
190
|
+
paramName: string;
|
|
191
|
+
nullParamName: string;
|
|
192
|
+
resolvedName: string;
|
|
193
|
+
required: boolean;
|
|
194
|
+
} | {
|
|
195
|
+
kind: "array";
|
|
196
|
+
paramName: string;
|
|
197
|
+
jsonParamName: string;
|
|
198
|
+
nullParamName?: string;
|
|
199
|
+
resolvedName: string;
|
|
200
|
+
required: boolean;
|
|
201
|
+
};
|
|
202
|
+
interface SchemaOptionEntry {
|
|
203
|
+
key: string;
|
|
204
|
+
value: unknown;
|
|
205
|
+
}
|
|
206
|
+
type QueryArraySerialization = "repeat" | "comma" | "pipe";
|
|
207
|
+
export declare function generate(document: OpenApiDocument, options: GenerateOptions): GeneratedFile[];
|
|
208
|
+
export declare function collectGeneratedCommands(document: OpenApiDocument): GeneratedCommand[];
|
|
209
|
+
export declare function collectSchemaOptionEntries(param: RenderSchemaOptionsInput): SchemaOptionEntry[];
|
|
210
|
+
export {};
|