@xano/developer-mcp 1.0.74 → 2.0.0-beta.0

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.
Files changed (129) hide show
  1. package/README.md +104 -37
  2. package/dist/cli_docs/index.d.ts +13 -37
  3. package/dist/cli_docs/index.js +28 -39
  4. package/dist/cli_docs/topics/integration.js +1 -1
  5. package/dist/cli_docs/topics/workspace.js +1 -1
  6. package/dist/index.js +58 -55
  7. package/dist/lib.d.ts +3 -1
  8. package/dist/lib.js +1 -1
  9. package/dist/meta_api_docs/format.js +1 -1
  10. package/dist/meta_api_docs/index.d.ts +14 -42
  11. package/dist/meta_api_docs/index.js +34 -46
  12. package/dist/tools/cli_docs.d.ts +2 -3
  13. package/dist/tools/cli_docs.js +3 -5
  14. package/dist/tools/define_tool.d.ts +47 -0
  15. package/dist/tools/define_tool.js +36 -0
  16. package/dist/tools/index.d.ts +88 -221
  17. package/dist/tools/index.js +80 -109
  18. package/dist/tools/mcp_version.d.ts +4 -25
  19. package/dist/tools/mcp_version.js +12 -19
  20. package/dist/tools/meta_api_docs.d.ts +2 -3
  21. package/dist/tools/meta_api_docs.js +3 -5
  22. package/dist/tools/validate_xanoscript.d.ts +18 -65
  23. package/dist/tools/validate_xanoscript.js +56 -54
  24. package/dist/tools/xanoscript_docs.d.ts +25 -74
  25. package/dist/tools/xanoscript_docs.js +86 -83
  26. package/dist/xanoscript_docs/README.md +5 -5
  27. package/dist/xanoscript_docs/addons.md +1 -3
  28. package/dist/xanoscript_docs/apis.md +2 -2
  29. package/dist/xanoscript_docs/database.md +1 -1
  30. package/dist/xanoscript_docs/essentials.md +6 -6
  31. package/dist/xanoscript_docs/functions.md +3 -3
  32. package/dist/xanoscript_docs/integrations.md +5 -5
  33. package/dist/xanoscript_docs/middleware.md +1 -1
  34. package/dist/xanoscript_docs/performance.md +4 -4
  35. package/dist/xanoscript_docs/realtime.md +2 -2
  36. package/dist/xanoscript_docs/security.md +3 -6
  37. package/dist/xanoscript_docs/survival.md +1 -1
  38. package/dist/xanoscript_docs/syntax/string-filters.md +1 -1
  39. package/dist/xanoscript_docs/syntax.md +10 -12
  40. package/dist/xanoscript_docs/tasks.md +1 -2
  41. package/dist/xanoscript_docs/tools.md +3 -5
  42. package/dist/xanoscript_docs/types.md +2 -2
  43. package/dist/xanoscript_docs/unit-testing.md +1 -1
  44. package/dist/xanoscript_docs/workflow-tests.md +1 -1
  45. package/dist/xanoscript_docs/working.md +4 -4
  46. package/package.json +5 -4
  47. package/dist/api_docs/format.d.ts +0 -5
  48. package/dist/api_docs/format.js +0 -171
  49. package/dist/api_docs/index.d.ts +0 -52
  50. package/dist/api_docs/index.js +0 -111
  51. package/dist/api_docs/topics/agent.d.ts +0 -2
  52. package/dist/api_docs/topics/agent.js +0 -142
  53. package/dist/api_docs/topics/api.d.ts +0 -2
  54. package/dist/api_docs/topics/api.js +0 -176
  55. package/dist/api_docs/topics/apigroup.d.ts +0 -2
  56. package/dist/api_docs/topics/apigroup.js +0 -124
  57. package/dist/api_docs/topics/authentication.d.ts +0 -2
  58. package/dist/api_docs/topics/authentication.js +0 -61
  59. package/dist/api_docs/topics/branch.d.ts +0 -2
  60. package/dist/api_docs/topics/branch.js +0 -73
  61. package/dist/api_docs/topics/file.d.ts +0 -2
  62. package/dist/api_docs/topics/file.js +0 -70
  63. package/dist/api_docs/topics/function.d.ts +0 -2
  64. package/dist/api_docs/topics/function.js +0 -164
  65. package/dist/api_docs/topics/history.d.ts +0 -2
  66. package/dist/api_docs/topics/history.js +0 -149
  67. package/dist/api_docs/topics/mcp_server.d.ts +0 -2
  68. package/dist/api_docs/topics/mcp_server.js +0 -139
  69. package/dist/api_docs/topics/middleware.d.ts +0 -2
  70. package/dist/api_docs/topics/middleware.js +0 -156
  71. package/dist/api_docs/topics/realtime.d.ts +0 -2
  72. package/dist/api_docs/topics/realtime.js +0 -112
  73. package/dist/api_docs/topics/start.d.ts +0 -2
  74. package/dist/api_docs/topics/start.js +0 -107
  75. package/dist/api_docs/topics/table.d.ts +0 -2
  76. package/dist/api_docs/topics/table.js +0 -195
  77. package/dist/api_docs/topics/task.d.ts +0 -2
  78. package/dist/api_docs/topics/task.js +0 -165
  79. package/dist/api_docs/topics/tool.d.ts +0 -2
  80. package/dist/api_docs/topics/tool.js +0 -150
  81. package/dist/api_docs/topics/workflows.d.ts +0 -2
  82. package/dist/api_docs/topics/workflows.js +0 -131
  83. package/dist/api_docs/topics/workspace.d.ts +0 -2
  84. package/dist/api_docs/topics/workspace.js +0 -153
  85. package/dist/api_docs/types.d.ts +0 -79
  86. package/dist/api_docs/types.js +0 -4
  87. package/dist/cli_docs/topics/run.d.ts +0 -2
  88. package/dist/cli_docs/topics/run.js +0 -248
  89. package/dist/meta_api_docs/format.test.d.ts +0 -1
  90. package/dist/meta_api_docs/format.test.js +0 -272
  91. package/dist/meta_api_docs/index.test.d.ts +0 -1
  92. package/dist/meta_api_docs/index.test.js +0 -128
  93. package/dist/meta_api_docs/types.test.d.ts +0 -1
  94. package/dist/meta_api_docs/types.test.js +0 -132
  95. package/dist/templates/init-workspace.d.ts +0 -10
  96. package/dist/templates/init-workspace.js +0 -278
  97. package/dist/templates/xanoscript-index.d.ts +0 -11
  98. package/dist/templates/xanoscript-index.js +0 -72
  99. package/dist/tools/index.test.d.ts +0 -1
  100. package/dist/tools/index.test.js +0 -179
  101. package/dist/tools/xanoscript_docs.test.d.ts +0 -1
  102. package/dist/tools/xanoscript_docs.test.js +0 -197
  103. package/dist/xanoscript.test.d.ts +0 -1
  104. package/dist/xanoscript.test.js +0 -421
  105. package/dist/xanoscript_docs/cheatsheet.md +0 -287
  106. package/dist/xanoscript_docs/ephemeral.md +0 -330
  107. package/dist/xanoscript_docs/quickstart.md +0 -692
  108. package/dist/xanoscript_docs/run.md +0 -196
  109. package/dist/xanoscript_docs/schema.md +0 -300
  110. package/dist/xanoscript_docs_auto/README.md +0 -119
  111. package/dist/xanoscript_docs_auto/agents.md +0 -446
  112. package/dist/xanoscript_docs_auto/apis.md +0 -517
  113. package/dist/xanoscript_docs_auto/control-flow.md +0 -543
  114. package/dist/xanoscript_docs_auto/database.md +0 -551
  115. package/dist/xanoscript_docs_auto/debugging.md +0 -527
  116. package/dist/xanoscript_docs_auto/filters.md +0 -464
  117. package/dist/xanoscript_docs_auto/functions.md +0 -431
  118. package/dist/xanoscript_docs_auto/integrations.md +0 -657
  119. package/dist/xanoscript_docs_auto/mcp-servers.md +0 -408
  120. package/dist/xanoscript_docs_auto/operators.md +0 -368
  121. package/dist/xanoscript_docs_auto/syntax.md +0 -287
  122. package/dist/xanoscript_docs_auto/tables.md +0 -447
  123. package/dist/xanoscript_docs_auto/tasks.md +0 -479
  124. package/dist/xanoscript_docs_auto/testing.md +0 -574
  125. package/dist/xanoscript_docs_auto/tools.md +0 -485
  126. package/dist/xanoscript_docs_auto/triggers.md +0 -595
  127. package/dist/xanoscript_docs_auto/types.md +0 -323
  128. package/dist/xanoscript_docs_auto/variables.md +0 -462
  129. package/dist/xanoscript_docs_auto/version.json +0 -5
@@ -1,79 +0,0 @@
1
- /**
2
- * Type definitions for Xano Meta API documentation
3
- */
4
- export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
5
- export interface ParameterDoc {
6
- name: string;
7
- type: string;
8
- required?: boolean;
9
- default?: unknown;
10
- description: string;
11
- enum?: string[];
12
- in?: "path" | "query" | "header";
13
- }
14
- export interface RequestBodyDoc {
15
- type: string;
16
- description?: string;
17
- properties?: Record<string, {
18
- type: string;
19
- description?: string;
20
- required?: boolean;
21
- }>;
22
- example?: unknown;
23
- }
24
- export interface ResponseDoc {
25
- type: string;
26
- description?: string;
27
- properties?: Record<string, unknown>;
28
- }
29
- export interface RequestExampleDoc {
30
- method: string;
31
- path: string;
32
- headers?: Record<string, string>;
33
- body?: unknown;
34
- }
35
- export interface EndpointDoc {
36
- method: HttpMethod;
37
- path: string;
38
- tool_name?: string;
39
- description: string;
40
- tags?: string[];
41
- parameters?: ParameterDoc[];
42
- request_body?: RequestBodyDoc;
43
- response?: ResponseDoc;
44
- example?: RequestExampleDoc;
45
- }
46
- export interface ExampleDoc {
47
- title: string;
48
- description: string;
49
- request: {
50
- method: string;
51
- path: string;
52
- headers?: Record<string, string>;
53
- body?: unknown;
54
- };
55
- response?: unknown;
56
- }
57
- export interface PatternDoc {
58
- name: string;
59
- description?: string;
60
- steps: string[];
61
- example?: string;
62
- }
63
- export interface TopicDoc {
64
- topic: string;
65
- title: string;
66
- description: string;
67
- endpoints?: EndpointDoc[];
68
- examples?: ExampleDoc[];
69
- related_topics?: string[];
70
- schemas?: Record<string, unknown>;
71
- patterns?: PatternDoc[];
72
- ai_hints?: string;
73
- }
74
- export type DetailLevel = "overview" | "detailed" | "examples";
75
- export interface ApiDocsArgs {
76
- topic: string;
77
- detail_level?: DetailLevel;
78
- include_schemas?: boolean;
79
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Type definitions for Xano Meta API documentation
3
- */
4
- export {};
@@ -1,2 +0,0 @@
1
- import type { TopicDoc } from "../types.js";
2
- export declare const runDoc: TopicDoc;
@@ -1,248 +0,0 @@
1
- export const runDoc = {
2
- topic: "run",
3
- title: "Xano CLI - Run API Commands",
4
- description: `Run commands let you execute XanoScript code, manage Run projects, sessions, environment variables, and secrets. The Run API enables serverless execution of XanoScript.
5
-
6
- ## Run API Base URL
7
-
8
- \`https://app.dev.xano.com/api:run\`
9
-
10
- This is different from your instance URL used by the Meta API.`,
11
- ai_hints: `**Run vs Meta API:**
12
- - Run API: Execute code, manage runtime environment
13
- - Meta API: Manage workspace resources (tables, APIs, functions)
14
-
15
- **Project context:**
16
- - Most run commands require a project
17
- - Set project in profile or use \`-j\` flag
18
- - Projects isolate execution environments
19
-
20
- **Execution modes:**
21
- - Jobs: One-time execution, returns result
22
- - Services: Long-running, exposes endpoints
23
-
24
- **Environment variables:**
25
- - Stored per-project in Run API
26
- - Override at runtime with \`--env KEY=value\``,
27
- related_topics: ["function", "profile", "integration"],
28
- commands: [
29
- {
30
- name: "run:exec",
31
- description: "Execute XanoScript code",
32
- usage: "xano run:exec [path] [options]",
33
- args: [
34
- { name: "path", required: false, description: "Path to .xs file, directory, or URL" }
35
- ],
36
- flags: [
37
- { name: "project", short: "j", type: "string", required: false, description: "Run project ID" },
38
- { name: "args", short: "a", type: "string", required: false, description: "JSON file with input arguments" },
39
- { name: "env", type: "string", required: false, description: "Environment override KEY=value (repeatable)" },
40
- { name: "stdin", type: "boolean", required: false, description: "Read code from stdin" },
41
- { name: "edit", type: "boolean", required: false, description: "Open in $EDITOR before execution" }
42
- ],
43
- examples: [
44
- "xano run:exec ./job.xs",
45
- "xano run:exec ./job.xs -a inputs.json",
46
- "xano run:exec ./job.xs --env API_KEY=secret --env DEBUG=true",
47
- "echo 'var:x = 1 + 1' | xano run:exec --stdin",
48
- "xano run:exec ./scripts/ # executes all .xs files as multidoc"
49
- ]
50
- },
51
- {
52
- name: "run:info",
53
- description: "Analyze XanoScript without executing",
54
- usage: "xano run:info [path] [options]",
55
- args: [
56
- { name: "path", required: false, description: "Path to .xs file" }
57
- ],
58
- flags: [
59
- { name: "stdin", type: "boolean", required: false, description: "Read from stdin" }
60
- ],
61
- examples: [
62
- "xano run:info ./job.xs",
63
- "cat script.xs | xano run:info --stdin"
64
- ]
65
- },
66
- {
67
- name: "run:projects:list",
68
- description: "List all Run projects",
69
- usage: "xano run:projects:list",
70
- examples: ["xano run:projects:list"]
71
- },
72
- {
73
- name: "run:projects:create",
74
- description: "Create a new Run project",
75
- usage: "xano run:projects:create [options]",
76
- flags: [
77
- { name: "name", short: "n", type: "string", required: true, description: "Project name" },
78
- { name: "description", short: "d", type: "string", required: false, description: "Project description" }
79
- ],
80
- examples: ["xano run:projects:create -n 'My Project' -d 'Production jobs'"]
81
- },
82
- {
83
- name: "run:projects:update",
84
- description: "Update a Run project",
85
- usage: "xano run:projects:update <project_id> [options]",
86
- args: [
87
- { name: "project_id", required: true, description: "Project ID to update" }
88
- ],
89
- flags: [
90
- { name: "name", short: "n", type: "string", required: false, description: "New project name" },
91
- { name: "description", short: "d", type: "string", required: false, description: "New description" }
92
- ],
93
- examples: ["xano run:projects:update abc123 -n 'Updated Name'"]
94
- },
95
- {
96
- name: "run:projects:delete",
97
- description: "Delete a Run project",
98
- usage: "xano run:projects:delete <project_id> [--force]",
99
- args: [
100
- { name: "project_id", required: true, description: "Project ID to delete" }
101
- ],
102
- flags: [
103
- { name: "force", type: "boolean", required: false, description: "Skip confirmation" }
104
- ],
105
- examples: ["xano run:projects:delete abc123 --force"]
106
- },
107
- {
108
- name: "run:env:list",
109
- description: "List environment variables for project",
110
- usage: "xano run:env:list [-j <project>]",
111
- examples: ["xano run:env:list"]
112
- },
113
- {
114
- name: "run:env:set",
115
- description: "Set an environment variable",
116
- usage: "xano run:env:set <name> <value> [-j <project>]",
117
- args: [
118
- { name: "name", required: true, description: "Variable name" },
119
- { name: "value", required: true, description: "Variable value" }
120
- ],
121
- examples: ["xano run:env:set API_KEY sk-123456"]
122
- },
123
- {
124
- name: "run:env:get",
125
- description: "Get an environment variable value",
126
- usage: "xano run:env:get <name> [-j <project>]",
127
- args: [
128
- { name: "name", required: true, description: "Variable name" }
129
- ],
130
- examples: ["xano run:env:get API_KEY"]
131
- },
132
- {
133
- name: "run:env:delete",
134
- description: "Delete an environment variable",
135
- usage: "xano run:env:delete <name> [-j <project>]",
136
- args: [
137
- { name: "name", required: true, description: "Variable name" }
138
- ],
139
- examples: ["xano run:env:delete OLD_KEY"]
140
- },
141
- {
142
- name: "run:sessions:list",
143
- description: "List execution sessions",
144
- usage: "xano run:sessions:list [-j <project>]",
145
- examples: ["xano run:sessions:list"]
146
- },
147
- {
148
- name: "run:sessions:get",
149
- description: "Get session details",
150
- usage: "xano run:sessions:get <session_id>",
151
- args: [
152
- { name: "session_id", required: true, description: "Session ID" }
153
- ],
154
- examples: ["xano run:sessions:get sess_abc123"]
155
- },
156
- {
157
- name: "run:sessions:start",
158
- description: "Start a session",
159
- usage: "xano run:sessions:start <session_id>",
160
- args: [
161
- { name: "session_id", required: true, description: "Session ID" }
162
- ],
163
- examples: ["xano run:sessions:start sess_abc123"]
164
- },
165
- {
166
- name: "run:sessions:stop",
167
- description: "Stop a session",
168
- usage: "xano run:sessions:stop <session_id>",
169
- args: [
170
- { name: "session_id", required: true, description: "Session ID" }
171
- ],
172
- examples: ["xano run:sessions:stop sess_abc123"]
173
- },
174
- {
175
- name: "run:sessions:delete",
176
- description: "Delete a session",
177
- usage: "xano run:sessions:delete <session_id>",
178
- args: [
179
- { name: "session_id", required: true, description: "Session ID" }
180
- ],
181
- examples: ["xano run:sessions:delete sess_abc123"]
182
- },
183
- {
184
- name: "run:secrets:list",
185
- description: "List secrets",
186
- usage: "xano run:secrets:list [-j <project>]",
187
- examples: ["xano run:secrets:list"]
188
- },
189
- {
190
- name: "run:secrets:set",
191
- description: "Set a secret (docker registry or service account)",
192
- usage: "xano run:secrets:set <name> [options]",
193
- args: [
194
- { name: "name", required: true, description: "Secret name" }
195
- ],
196
- flags: [
197
- { name: "type", short: "t", type: "string", required: true, description: "Secret type: dockerconfigjson, service-account-token" }
198
- ],
199
- examples: ["xano run:secrets:set docker-creds -t dockerconfigjson"]
200
- },
201
- {
202
- name: "run:secrets:get",
203
- description: "Get a secret",
204
- usage: "xano run:secrets:get <name>",
205
- args: [
206
- { name: "name", required: true, description: "Secret name" }
207
- ],
208
- examples: ["xano run:secrets:get docker-creds"]
209
- },
210
- {
211
- name: "run:secrets:delete",
212
- description: "Delete a secret",
213
- usage: "xano run:secrets:delete <name>",
214
- args: [
215
- { name: "name", required: true, description: "Secret name" }
216
- ],
217
- examples: ["xano run:secrets:delete old-secret"]
218
- }
219
- ],
220
- workflows: [
221
- {
222
- name: "Execute a Job",
223
- description: "Run XanoScript code and get results",
224
- steps: [
225
- "Write your job in a .xs file",
226
- "Execute: `xano run:exec ./job.xs`",
227
- "View timing and response in output"
228
- ],
229
- example: `# job.xs
230
- job: my_job
231
- ---
232
- var:result = 1 + 1
233
- return = var:result
234
-
235
- # Execute
236
- xano run:exec ./job.xs`
237
- },
238
- {
239
- name: "Configure Environment",
240
- description: "Set up environment variables for a project",
241
- steps: [
242
- "List existing: `xano run:env:list`",
243
- "Set variables: `xano run:env:set KEY value`",
244
- "Execute with overrides: `xano run:exec job.xs --env KEY=override`"
245
- ]
246
- }
247
- ]
248
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,272 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { formatDocumentation, META_API_CONFIG, } from "./format.js";
3
- describe("meta_api_docs/format", () => {
4
- describe("META_API_CONFIG", () => {
5
- it("should have correct base URL info", () => {
6
- expect(META_API_CONFIG.baseUrlInfo).toContain("https://<your-instance-subdomain>.xano.io/api:meta/");
7
- expect(META_API_CONFIG.toolName).toBe("meta_api_docs");
8
- });
9
- });
10
- describe("formatDocumentation", () => {
11
- const minimalDoc = {
12
- topic: "test",
13
- title: "Test Topic",
14
- description: "A test topic description",
15
- };
16
- it("should format minimal documentation", () => {
17
- const result = formatDocumentation(minimalDoc);
18
- expect(result).toContain("# Test Topic");
19
- expect(result).toContain("A test topic description");
20
- });
21
- it("should include AI hints when present", () => {
22
- const docWithHints = {
23
- ...minimalDoc,
24
- ai_hints: "Use this for testing purposes",
25
- };
26
- const result = formatDocumentation(docWithHints);
27
- expect(result).toContain("## AI Usage Hints");
28
- expect(result).toContain("Use this for testing purposes");
29
- });
30
- it("should format endpoints correctly", () => {
31
- const docWithEndpoints = {
32
- ...minimalDoc,
33
- endpoints: [
34
- {
35
- method: "GET",
36
- path: "/test",
37
- description: "Get test data",
38
- },
39
- {
40
- method: "POST",
41
- path: "/test",
42
- description: "Create test data",
43
- tool_name: "create_test",
44
- },
45
- ],
46
- };
47
- const result = formatDocumentation(docWithEndpoints);
48
- expect(result).toContain("## Endpoints");
49
- expect(result).toContain("### GET /test");
50
- expect(result).toContain("### POST /test");
51
- expect(result).toContain("**Tool:** `create_test`");
52
- });
53
- it("should format endpoint parameters", () => {
54
- const docWithParams = {
55
- ...minimalDoc,
56
- endpoints: [
57
- {
58
- method: "GET",
59
- path: "/test/{id}",
60
- description: "Get test by ID",
61
- parameters: [
62
- {
63
- name: "id",
64
- type: "integer",
65
- required: true,
66
- description: "The test ID",
67
- },
68
- {
69
- name: "include_details",
70
- type: "boolean",
71
- required: false,
72
- default: false,
73
- description: "Include extra details",
74
- },
75
- {
76
- name: "format",
77
- type: "string",
78
- description: "Output format",
79
- enum: ["json", "xml", "csv"],
80
- },
81
- ],
82
- },
83
- ],
84
- };
85
- const result = formatDocumentation(docWithParams);
86
- expect(result).toContain("**Parameters:**");
87
- expect(result).toContain("`id`: integer (required)");
88
- expect(result).toContain("`include_details`: boolean [default: false]");
89
- expect(result).toContain("[options: json, xml, csv]");
90
- });
91
- it("should format request body", () => {
92
- const docWithBody = {
93
- ...minimalDoc,
94
- endpoints: [
95
- {
96
- method: "POST",
97
- path: "/test",
98
- description: "Create test",
99
- request_body: {
100
- type: "object",
101
- properties: {
102
- name: {
103
- type: "string",
104
- required: true,
105
- description: "The name",
106
- },
107
- value: {
108
- type: "number",
109
- description: "The value",
110
- },
111
- },
112
- },
113
- },
114
- ],
115
- };
116
- const result = formatDocumentation(docWithBody);
117
- expect(result).toContain("**Request Body:** `object`");
118
- expect(result).toContain("`name`: string (required)");
119
- expect(result).toContain("`value`: number");
120
- });
121
- it("should format examples in detailed mode", () => {
122
- const docWithExamples = {
123
- ...minimalDoc,
124
- examples: [
125
- {
126
- title: "Basic Example",
127
- description: "A simple example",
128
- request: {
129
- method: "GET",
130
- path: "/test",
131
- headers: { Authorization: "Bearer token" },
132
- },
133
- response: { data: "test" },
134
- },
135
- ],
136
- };
137
- const result = formatDocumentation(docWithExamples, "detailed");
138
- expect(result).toContain("## Examples");
139
- expect(result).toContain("### Basic Example");
140
- expect(result).toContain("**Request:**");
141
- expect(result).toContain("GET /test");
142
- expect(result).toContain("Authorization: Bearer token");
143
- expect(result).toContain("**Response:**");
144
- });
145
- it("should format examples with request body", () => {
146
- const docWithBodyExample = {
147
- ...minimalDoc,
148
- examples: [
149
- {
150
- title: "Create Example",
151
- description: "Creating data",
152
- request: {
153
- method: "POST",
154
- path: "/test",
155
- body: { name: "test", value: 42 },
156
- },
157
- },
158
- ],
159
- };
160
- const result = formatDocumentation(docWithBodyExample, "detailed");
161
- expect(result).toContain('"name": "test"');
162
- expect(result).toContain('"value": 42');
163
- });
164
- it("should format patterns/workflows", () => {
165
- const docWithPatterns = {
166
- ...minimalDoc,
167
- patterns: [
168
- {
169
- name: "Basic Workflow",
170
- description: "A simple workflow",
171
- steps: ["1. Do step 1", "2. Do step 2", "3. Do step 3"],
172
- example: "example code here",
173
- },
174
- ],
175
- };
176
- const result = formatDocumentation(docWithPatterns);
177
- expect(result).toContain("## Workflows");
178
- expect(result).toContain("### Basic Workflow");
179
- expect(result).toContain("A simple workflow");
180
- expect(result).toContain("**Steps:**");
181
- expect(result).toContain("1. Do step 1");
182
- expect(result).toContain("**Example:**");
183
- expect(result).toContain("example code here");
184
- });
185
- it("should include schemas when includeSchemas is true", () => {
186
- const docWithSchemas = {
187
- ...minimalDoc,
188
- schemas: {
189
- TestSchema: {
190
- type: "object",
191
- properties: {
192
- id: { type: "integer" },
193
- },
194
- },
195
- },
196
- };
197
- const result = formatDocumentation(docWithSchemas, "detailed", true);
198
- expect(result).toContain("## Schemas");
199
- expect(result).toContain('"TestSchema"');
200
- });
201
- it("should exclude schemas when includeSchemas is false", () => {
202
- const docWithSchemas = {
203
- ...minimalDoc,
204
- schemas: {
205
- TestSchema: { type: "object" },
206
- },
207
- };
208
- const result = formatDocumentation(docWithSchemas, "detailed", false);
209
- expect(result).not.toContain("## Schemas");
210
- });
211
- it("should include related topics", () => {
212
- const docWithRelated = {
213
- ...minimalDoc,
214
- related_topics: ["topic1", "topic2", "topic3"],
215
- };
216
- const result = formatDocumentation(docWithRelated);
217
- expect(result).toContain("## Related Topics");
218
- expect(result).toContain("topic1, topic2, topic3");
219
- expect(result).toContain("meta_api_docs");
220
- });
221
- it("should use custom config", () => {
222
- const customConfig = {
223
- baseUrlInfo: "## Base URL\nhttps://custom.example.com/api/",
224
- toolName: "custom_docs",
225
- };
226
- const result = formatDocumentation({ ...minimalDoc, patterns: [{ name: "Test", steps: ["step"] }] }, "detailed", true, customConfig);
227
- expect(result).toContain("https://custom.example.com/api/");
228
- });
229
- describe("detail levels", () => {
230
- const docWithAll = {
231
- ...minimalDoc,
232
- endpoints: [
233
- {
234
- method: "GET",
235
- path: "/test",
236
- description: "Test endpoint",
237
- parameters: [
238
- { name: "id", type: "integer", required: true, description: "ID" },
239
- ],
240
- example: {
241
- method: "GET",
242
- path: "/test/1",
243
- },
244
- },
245
- ],
246
- examples: [
247
- {
248
- title: "Example",
249
- description: "Test",
250
- request: { method: "GET", path: "/test" },
251
- },
252
- ],
253
- };
254
- it("overview should show minimal endpoint info", () => {
255
- const result = formatDocumentation(docWithAll, "overview");
256
- expect(result).toContain("### GET /test");
257
- expect(result).toContain("Test endpoint");
258
- expect(result).not.toContain("**Parameters:**");
259
- });
260
- it("detailed should show parameters but not inline examples", () => {
261
- const result = formatDocumentation(docWithAll, "detailed");
262
- expect(result).toContain("**Parameters:**");
263
- expect(result).toContain("## Examples");
264
- });
265
- it("examples should show inline examples in endpoints", () => {
266
- const result = formatDocumentation(docWithAll, "examples");
267
- expect(result).toContain("**Example:**");
268
- expect(result).toContain("GET /test/1");
269
- });
270
- });
271
- });
272
- });
@@ -1 +0,0 @@
1
- export {};