@xano/developer-mcp 1.0.26 → 1.0.28
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 +1 -1
- package/dist/meta_api_docs/topics/workspace.js +45 -2
- package/dist/xanoscript_docs/README.md +71 -67
- package/dist/xanoscript_docs/apis.md +81 -27
- package/dist/xanoscript_docs/branch.md +13 -13
- package/dist/xanoscript_docs/database.md +57 -17
- package/dist/xanoscript_docs/functions.md +29 -78
- package/dist/xanoscript_docs/integrations.md +0 -10
- package/dist/xanoscript_docs/performance.md +15 -33
- package/dist/xanoscript_docs/realtime.md +1 -48
- package/dist/xanoscript_docs/security.md +2 -0
- package/dist/xanoscript_docs/tables.md +47 -1
- package/dist/xanoscript_docs/tools.md +2 -19
- package/dist/xanoscript_docs/triggers.md +2 -27
- package/dist/xanoscript_docs/types.md +12 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ This MCP server acts as a bridge between AI models and Xano's developer ecosyste
|
|
|
40
40
|
### Claude Code (Recommended)
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
claude mcp add xano
|
|
43
|
+
claude mcp add xano -- npx -y @xano/developer-mcp
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
That's it! The MCP server will be automatically installed and configured.
|
|
@@ -4,7 +4,7 @@ export const workspaceDoc = {
|
|
|
4
4
|
description: `Workspaces are the top-level container for all Xano resources. Each workspace contains databases, APIs, functions, tasks, agents, and more.
|
|
5
5
|
|
|
6
6
|
## Key Operations
|
|
7
|
-
-
|
|
7
|
+
- Create/list/get/update/delete workspaces
|
|
8
8
|
- Export/import workspace data
|
|
9
9
|
- Generate workspace context for AI
|
|
10
10
|
- Get OpenAPI specifications
|
|
@@ -13,7 +13,9 @@ export const workspaceDoc = {
|
|
|
13
13
|
- Export before making major changes (backup)
|
|
14
14
|
- Check branch before modifying (prod vs dev)
|
|
15
15
|
- \`export-schema\` is lighter than \`export\` (schema only vs full data)
|
|
16
|
-
- OpenAPI spec useful for understanding available endpoints
|
|
16
|
+
- OpenAPI spec useful for understanding available endpoints
|
|
17
|
+
- \`deleteWorkspace\` requires user confirmation - workspaces with active tenants cannot be deleted
|
|
18
|
+
- Workspace creation is limited by the package tier`,
|
|
17
19
|
endpoints: [
|
|
18
20
|
{
|
|
19
21
|
method: "GET",
|
|
@@ -37,6 +39,38 @@ export const workspaceDoc = {
|
|
|
37
39
|
{ name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" }
|
|
38
40
|
]
|
|
39
41
|
},
|
|
42
|
+
{
|
|
43
|
+
method: "POST",
|
|
44
|
+
path: "/workspace",
|
|
45
|
+
tool_name: "addWorkspace",
|
|
46
|
+
description: "Create a new workspace. Respects the instance workspace limit based on the package tier.",
|
|
47
|
+
parameters: [
|
|
48
|
+
{ name: "name", type: "string", required: true, description: "Name of the workspace" },
|
|
49
|
+
{ name: "description", type: "string", description: "Description for the workspace" }
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
method: "PUT",
|
|
54
|
+
path: "/workspace/{workspace_id}",
|
|
55
|
+
tool_name: "updateWorkspace",
|
|
56
|
+
description: "Update an existing workspace's settings.",
|
|
57
|
+
parameters: [
|
|
58
|
+
{ name: "workspace_id", type: "integer", required: true, in: "path", description: "ID of the workspace to update" },
|
|
59
|
+
{ name: "name", type: "string", description: "New name for the workspace" },
|
|
60
|
+
{ name: "description", type: "string", description: "New description for the workspace" },
|
|
61
|
+
{ name: "swagger", type: "boolean", description: "Enable or disable swagger documentation" },
|
|
62
|
+
{ name: "documentation.require_token", type: "boolean", description: "Whether to require a token for documentation access" }
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
method: "DELETE",
|
|
67
|
+
path: "/workspace/{workspace_id}",
|
|
68
|
+
tool_name: "deleteWorkspace",
|
|
69
|
+
description: "Delete a workspace and all its data permanently. Cannot delete a workspace that has active tenants.",
|
|
70
|
+
parameters: [
|
|
71
|
+
{ name: "workspace_id", type: "integer", required: true, in: "path", description: "ID of the workspace to delete" }
|
|
72
|
+
]
|
|
73
|
+
},
|
|
40
74
|
{
|
|
41
75
|
method: "POST",
|
|
42
76
|
path: "/workspace/{workspace_id}/export-schema",
|
|
@@ -144,6 +178,15 @@ export const workspaceDoc = {
|
|
|
144
178
|
id: { type: "integer", description: "Unique workspace ID" },
|
|
145
179
|
name: { type: "string", description: "Workspace name" },
|
|
146
180
|
description: { type: "string", description: "Workspace description" },
|
|
181
|
+
swagger: { type: "boolean", description: "Whether swagger documentation is enabled" },
|
|
182
|
+
documentation: {
|
|
183
|
+
type: "object",
|
|
184
|
+
properties: {
|
|
185
|
+
link: { type: "string", description: "Link to the documentation" },
|
|
186
|
+
require_token: { type: "boolean", description: "Whether a token is required for documentation access" }
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
branch: { type: "string", description: "Current branch label" },
|
|
147
190
|
created_at: { type: "string", format: "date-time" },
|
|
148
191
|
updated_at: { type: "string", format: "date-time" }
|
|
149
192
|
}
|
|
@@ -4,21 +4,21 @@ XanoScript is the declarative scripting language for [Xano](https://xano.com), a
|
|
|
4
4
|
|
|
5
5
|
## Quick Reference
|
|
6
6
|
|
|
7
|
-
| Construct
|
|
8
|
-
|
|
9
|
-
| `table`
|
|
10
|
-
| `function`
|
|
11
|
-
| `query`
|
|
12
|
-
| `task`
|
|
13
|
-
| `*_trigger`
|
|
14
|
-
| `agent`
|
|
15
|
-
| `tool`
|
|
16
|
-
| `mcp_server`
|
|
17
|
-
| `addon`
|
|
18
|
-
| `middleware`
|
|
19
|
-
| `branch`
|
|
20
|
-
| `workspace`
|
|
21
|
-
| `realtime_channel` | Configuration
|
|
7
|
+
| Construct | File Location | Purpose |
|
|
8
|
+
| ------------------ | --------------------- | ----------------------------- |
|
|
9
|
+
| `table` | `tables/*.xs` | Database schema definition |
|
|
10
|
+
| `function` | `functions/**/*.xs` | Reusable logic blocks |
|
|
11
|
+
| `query` | `apis/<group>/*.xs` | HTTP API endpoints |
|
|
12
|
+
| `task` | `tasks/*.xs` | Scheduled/cron jobs |
|
|
13
|
+
| `*_trigger` | `triggers/**/*.xs` | Event-driven handlers |
|
|
14
|
+
| `agent` | `agents/**/*.xs` | AI-powered agents |
|
|
15
|
+
| `tool` | `tools/**/*.xs` | Tools for AI agents |
|
|
16
|
+
| `mcp_server` | `mcp_servers/**/*.xs` | MCP server definitions |
|
|
17
|
+
| `addon` | `addons/*.xs` | Subqueries for related data |
|
|
18
|
+
| `middleware` | `middleware/**/*.xs` | Request/response interceptors |
|
|
19
|
+
| `branch` | `branch.xs` | Branch-level configuration |
|
|
20
|
+
| `workspace` | `workspace.xs` | Workspace-level configuration |
|
|
21
|
+
| `realtime_channel` | Configuration | Realtime channel settings |
|
|
22
22
|
|
|
23
23
|
**Important:** Each `.xs` file must contain exactly one definition. You cannot define multiple tables, functions, queries, or other constructs in a single file.
|
|
24
24
|
|
|
@@ -45,23 +45,14 @@ project/
|
|
|
45
45
|
|
|
46
46
|
## Environment Variables
|
|
47
47
|
|
|
48
|
-
Access with `$env.<name>`.
|
|
48
|
+
Access with `$env.<name>`. Common built-in variables include `$env.$remote_ip`, `$env.$http_headers`, `$env.$request_method`, `$env.$datasource`, and `$env.$branch`. Custom environment variables are set in the Xano dashboard and accessed as `$env.MY_VAR`.
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|----------|-------------|
|
|
52
|
-
| `$env.$remote_ip` | Client IP address |
|
|
53
|
-
| `$env.$http_headers` | Request headers array |
|
|
54
|
-
| `$env.$request_uri` | Request URI |
|
|
55
|
-
| `$env.$request_method` | HTTP method (GET, POST, etc.) |
|
|
56
|
-
| `$env.$request_querystring` | Query string |
|
|
57
|
-
| `$env.$datasource` | Current datasource |
|
|
58
|
-
| `$env.$branch` | Current branch |
|
|
59
|
-
|
|
60
|
-
Custom environment variables are set in the Xano dashboard and accessed as `$env.MY_VAR`.
|
|
50
|
+
For the complete list of system variables, see `xanoscript_docs({ topic: "syntax" })`.
|
|
61
51
|
|
|
62
52
|
## Core Syntax Patterns
|
|
63
53
|
|
|
64
54
|
### Block Structure
|
|
55
|
+
|
|
65
56
|
```xs
|
|
66
57
|
<construct> "<name>" {
|
|
67
58
|
input { ... } // Parameters (optional)
|
|
@@ -71,6 +62,7 @@ Custom environment variables are set in the Xano dashboard and accessed as `$env
|
|
|
71
62
|
```
|
|
72
63
|
|
|
73
64
|
### Variable Access
|
|
65
|
+
|
|
74
66
|
```xs
|
|
75
67
|
$input.field // Input parameters
|
|
76
68
|
$var.field // Stack variables
|
|
@@ -83,14 +75,18 @@ $this // Current item in loops/maps
|
|
|
83
75
|
**Note:** `$response` is a reserved word and cannot be used as a variable name.
|
|
84
76
|
|
|
85
77
|
### Comments
|
|
78
|
+
|
|
86
79
|
```xs
|
|
87
80
|
// Single-line comment
|
|
88
|
-
var $total {
|
|
81
|
+
var $total {
|
|
82
|
+
value = 0
|
|
83
|
+
}
|
|
89
84
|
```
|
|
90
85
|
|
|
91
86
|
**Note:** XanoScript only supports `//` for comments. Other comment styles like `#` are not supported.
|
|
92
87
|
|
|
93
88
|
### Filters (Pipe Syntax)
|
|
89
|
+
|
|
94
90
|
```xs
|
|
95
91
|
$value|trim|lower // Chain filters
|
|
96
92
|
$input.name|strlen // Get length
|
|
@@ -115,58 +111,66 @@ This helps AI tools apply the correct documentation based on the file being edit
|
|
|
115
111
|
Use `xanoscript_docs({ topic: "<topic>" })` to retrieve documentation.
|
|
116
112
|
|
|
117
113
|
### Core Language
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
114
|
+
|
|
115
|
+
| Topic | Description |
|
|
116
|
+
| ----------- | ------------------------------------------------- |
|
|
117
|
+
| `syntax` | Expressions, operators, filters, system variables |
|
|
118
|
+
| `types` | Data types, validation, input blocks |
|
|
119
|
+
| `functions` | Reusable function stacks, async, loops |
|
|
120
|
+
| `schema` | Runtime schema parsing and validation |
|
|
124
121
|
|
|
125
122
|
### Data
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
123
|
+
|
|
124
|
+
| Topic | Description |
|
|
125
|
+
| ----------- | ---------------------------------------------------------- |
|
|
126
|
+
| `tables` | Database schema definitions with indexes and relationships |
|
|
127
|
+
| `database` | All db.\* operations: query, get, add, edit, patch, delete |
|
|
128
|
+
| `addons` | Reusable subqueries for fetching related data |
|
|
129
|
+
| `streaming` | Streaming data from files, requests, and responses |
|
|
132
130
|
|
|
133
131
|
### APIs & Endpoints
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
139
|
-
| `
|
|
132
|
+
|
|
133
|
+
| Topic | Description |
|
|
134
|
+
| ---------- | --------------------------------------------------------------- |
|
|
135
|
+
| `apis` | HTTP endpoint definitions with authentication and CRUD patterns |
|
|
136
|
+
| `tasks` | Scheduled and cron jobs |
|
|
137
|
+
| `triggers` | Event-driven handlers (table, realtime, workspace, agent, MCP) |
|
|
138
|
+
| `realtime` | Real-time channels and events for push updates |
|
|
140
139
|
|
|
141
140
|
### AI & Agents
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
141
|
+
|
|
142
|
+
| Topic | Description |
|
|
143
|
+
| ------------- | --------------------------------------------------- |
|
|
144
|
+
| `agents` | AI agent configuration with LLM providers and tools |
|
|
145
|
+
| `tools` | AI tools for agents and MCP servers |
|
|
146
|
+
| `mcp-servers` | MCP server definitions exposing tools |
|
|
147
147
|
|
|
148
148
|
### Integrations
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
|
|
150
|
+
| Topic | Description |
|
|
151
|
+
| -------------- | ------------------------------------------------- |
|
|
151
152
|
| `integrations` | Cloud storage, Redis, security, and external APIs |
|
|
152
153
|
|
|
153
154
|
### Configuration
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
|
157
|
-
| `
|
|
155
|
+
|
|
156
|
+
| Topic | Description |
|
|
157
|
+
| ------------ | ---------------------------------------------------------------------- |
|
|
158
|
+
| `workspace` | Workspace-level settings: environment variables, preferences, realtime |
|
|
159
|
+
| `branch` | Branch-level settings: middleware, history retention, visual styling |
|
|
158
160
|
| `middleware` | Request/response interceptors for functions, queries, tasks, and tools |
|
|
159
161
|
|
|
160
162
|
### Development
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
163
|
+
|
|
164
|
+
| Topic | Description |
|
|
165
|
+
| ----------- | ---------------------------------------------------------- |
|
|
166
|
+
| `testing` | Unit tests, mocks, and assertions |
|
|
167
|
+
| `debugging` | Logging, inspecting, and debugging XanoScript execution |
|
|
168
|
+
| `frontend` | Static frontend development and deployment |
|
|
169
|
+
| `run` | Run job and service configurations for the Xano Job Runner |
|
|
167
170
|
|
|
168
171
|
### Best Practices
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
|
172
|
-
| `
|
|
172
|
+
|
|
173
|
+
| Topic | Description |
|
|
174
|
+
| ------------- | ------------------------------------------------------------ |
|
|
175
|
+
| `performance` | Performance optimization best practices |
|
|
176
|
+
| `security` | Security best practices for authentication and authorization |
|
|
@@ -12,7 +12,7 @@ HTTP endpoint definitions in XanoScript.
|
|
|
12
12
|
query "endpoint-path" verb=<METHOD> {
|
|
13
13
|
api_group = "<GroupName>" // Required: API group for organization
|
|
14
14
|
description = "What this endpoint does"
|
|
15
|
-
auth = "<table>" // Optional:
|
|
15
|
+
auth = "<table>" // Optional: table with auth = true (usually "user")
|
|
16
16
|
input { ... }
|
|
17
17
|
stack { ... }
|
|
18
18
|
response = $result
|
|
@@ -24,16 +24,19 @@ query "endpoint-path" verb=<METHOD> {
|
|
|
24
24
|
The query name is **required** and **must be a non-empty string**. Empty names (`query "" verb=...`) are invalid. The name defines the endpoint path after the API group canonical.
|
|
25
25
|
|
|
26
26
|
**Full URL path structure:**
|
|
27
|
+
|
|
27
28
|
```
|
|
28
29
|
/<api_group canonical>/<query name>
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
The query name can include slashes for nested paths:
|
|
33
|
+
|
|
32
34
|
- `query "list" verb=GET` → `/<canonical>/list`
|
|
33
35
|
- `query "users/{id}" verb=GET` → `/<canonical>/users/{id}`
|
|
34
36
|
- `query "admin/reports/daily" verb=GET` → `/<canonical>/admin/reports/daily`
|
|
35
37
|
|
|
36
38
|
### HTTP Methods
|
|
39
|
+
|
|
37
40
|
`GET`, `POST`, `PUT`, `PATCH`, `DELETE`
|
|
38
41
|
|
|
39
42
|
### API Groups (Required)
|
|
@@ -41,25 +44,50 @@ The query name can include slashes for nested paths:
|
|
|
41
44
|
Every endpoint must belong to an API group. Each group is a folder with an `api_group.xs` file:
|
|
42
45
|
|
|
43
46
|
```xs
|
|
47
|
+
// Minimal definition
|
|
44
48
|
api_group "users" {
|
|
45
|
-
canonical = "users"
|
|
49
|
+
canonical = "myapp-users" // Required: URL path segment (unique at instance level)
|
|
46
50
|
description = "User management" // Optional
|
|
47
51
|
}
|
|
48
52
|
```
|
|
49
53
|
|
|
54
|
+
**Full definition with all options:**
|
|
55
|
+
|
|
56
|
+
```xs
|
|
57
|
+
api_group Authentication {
|
|
58
|
+
active = false // Disable group (cannot be externally invoked)
|
|
59
|
+
canonical = "plmgzl-s" // Required: unique at instance level
|
|
60
|
+
swagger = {token: "cbO83nMTt7BVgq3QcQgKikDfHeo"} // Protect Swagger docs behind a token (plain text)
|
|
61
|
+
tags = ["auth", "security", "encrypted"] // Tags for organization
|
|
62
|
+
history = 100 // Request history: up to 100 statements per request
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Property | Type | Required | Description |
|
|
67
|
+
| ------------- | ------ | -------- | --------------------------------------------------------------------------- |
|
|
68
|
+
| `canonical` | text | Yes | URL path segment, must be unique at the instance level |
|
|
69
|
+
| `description` | text | No | Human-readable description |
|
|
70
|
+
| `active` | bool | No | Whether the group accepts external requests (default: `true`) |
|
|
71
|
+
| `swagger` | object | No | Swagger documentation settings. `token` protects access (stored plain text) |
|
|
72
|
+
| `tags` | list | No | Tags for organization and filtering |
|
|
73
|
+
| `history` | int | No | Max number of statements recorded per request for debugging |
|
|
74
|
+
|
|
75
|
+
**Canonical uniqueness:** A Xano instance can host multiple workspaces. The `canonical` is used to route requests between workspaces and must be **unique at the instance level**, not just within your workspace. Use a descriptive, project-specific prefix to avoid collisions (e.g., `myapp-users` instead of `users`). A generic name like `user` is likely to conflict with another workspace's canonical on the same instance.
|
|
76
|
+
|
|
50
77
|
### File Structure
|
|
78
|
+
|
|
51
79
|
```
|
|
52
80
|
apis/
|
|
53
81
|
├── users/
|
|
54
|
-
│ ├── api_group.xs // Defines group (canonical = "users")
|
|
55
|
-
│ ├── list.xs // GET /users/list
|
|
56
|
-
│ └── by-id.xs // GET/PATCH/DELETE /users/{id}
|
|
82
|
+
│ ├── api_group.xs // Defines group (canonical = "myapp-users")
|
|
83
|
+
│ ├── list.xs // GET /myapp-users/list
|
|
84
|
+
│ └── by-id.xs // GET/PATCH/DELETE /myapp-users/{id}
|
|
57
85
|
└── products/
|
|
58
|
-
├── api_group.xs // Defines group (canonical = "products")
|
|
59
|
-
└── search.xs // GET /products/search
|
|
86
|
+
├── api_group.xs // Defines group (canonical = "myapp-products")
|
|
87
|
+
└── search.xs // GET /myapp-products/search
|
|
60
88
|
```
|
|
61
89
|
|
|
62
|
-
Full URL: `/<canonical>/<query name>` (e.g., `/users/profile`)
|
|
90
|
+
Full URL: `/<canonical>/<query name>` (e.g., `/myapp-users/profile`)
|
|
63
91
|
|
|
64
92
|
---
|
|
65
93
|
|
|
@@ -88,22 +116,24 @@ query "products" verb=GET {
|
|
|
88
116
|
|
|
89
117
|
For complete type and filter reference, use `xanoscript_docs({ topic: "types" })`.
|
|
90
118
|
|
|
91
|
-
### Empty Input Blocks
|
|
119
|
+
### Empty and Single-Input Blocks
|
|
92
120
|
|
|
93
|
-
|
|
121
|
+
Empty input blocks and single-input blocks can be written as one-liners. When there are two or more inputs, each must be on its own line.
|
|
94
122
|
|
|
95
123
|
```xs
|
|
96
|
-
//
|
|
124
|
+
// OK - empty input
|
|
97
125
|
query "health" verb=GET {
|
|
98
126
|
api_group = "System"
|
|
99
|
-
input {
|
|
100
|
-
}
|
|
127
|
+
input {}
|
|
101
128
|
stack { ... }
|
|
102
129
|
response = { status: "ok" }
|
|
103
130
|
}
|
|
104
131
|
|
|
105
|
-
//
|
|
106
|
-
input {}
|
|
132
|
+
// OK - single input as one-liner
|
|
133
|
+
input { text query filters=trim }
|
|
134
|
+
|
|
135
|
+
// WRONG - multiple inputs on one line will cause parsing errors
|
|
136
|
+
input { text query filters=trim int limit }
|
|
107
137
|
```
|
|
108
138
|
|
|
109
139
|
---
|
|
@@ -111,6 +141,7 @@ input {}
|
|
|
111
141
|
## Authentication
|
|
112
142
|
|
|
113
143
|
### Public Endpoint (default)
|
|
144
|
+
|
|
114
145
|
```xs
|
|
115
146
|
query "status" verb=GET {
|
|
116
147
|
api_group = "System"
|
|
@@ -120,10 +151,13 @@ query "status" verb=GET {
|
|
|
120
151
|
```
|
|
121
152
|
|
|
122
153
|
### Authenticated Endpoint
|
|
154
|
+
|
|
155
|
+
The `auth` attribute references a table that has `auth = true` in its definition (see [tables.md](tables.md)). This is typically the `user` table. While multiple auth tables are supported, it's recommended to use a single auth table and control access levels with a role flag or RBAC pattern.
|
|
156
|
+
|
|
123
157
|
```xs
|
|
124
158
|
query "profile" verb=GET {
|
|
125
159
|
api_group = "Users"
|
|
126
|
-
auth = "user" //
|
|
160
|
+
auth = "user" // Must reference a table with auth = true
|
|
127
161
|
stack {
|
|
128
162
|
db.get "user" {
|
|
129
163
|
field_name = "id"
|
|
@@ -135,6 +169,8 @@ query "profile" verb=GET {
|
|
|
135
169
|
```
|
|
136
170
|
|
|
137
171
|
When `auth` is set:
|
|
172
|
+
|
|
173
|
+
- The referenced table must have `auth = true` in its table definition
|
|
138
174
|
- Endpoint requires Bearer token in `Authorization` header
|
|
139
175
|
- `$auth.id` contains authenticated user's ID
|
|
140
176
|
- Invalid/missing token returns 401
|
|
@@ -143,21 +179,26 @@ When `auth` is set:
|
|
|
143
179
|
|
|
144
180
|
## Path Parameters
|
|
145
181
|
|
|
146
|
-
Use `{param}` in the path:
|
|
182
|
+
Use `{param}` in the path and capture its value in the input block:
|
|
147
183
|
|
|
148
184
|
```xs
|
|
149
185
|
query "users/{user_id}" verb=GET {
|
|
150
|
-
api_group = "
|
|
186
|
+
api_group = "Authentication"
|
|
151
187
|
auth = "user"
|
|
188
|
+
|
|
152
189
|
input {
|
|
153
|
-
int user_id {
|
|
190
|
+
int user_id {
|
|
191
|
+
table = "user"
|
|
192
|
+
}
|
|
154
193
|
}
|
|
194
|
+
|
|
155
195
|
stack {
|
|
156
196
|
db.get "user" {
|
|
157
197
|
field_name = "id"
|
|
158
198
|
field_value = $input.user_id
|
|
159
199
|
} as $user
|
|
160
200
|
}
|
|
201
|
+
|
|
161
202
|
response = $user
|
|
162
203
|
}
|
|
163
204
|
```
|
|
@@ -167,6 +208,7 @@ query "users/{user_id}" verb=GET {
|
|
|
167
208
|
## CRUD Examples
|
|
168
209
|
|
|
169
210
|
### List (GET)
|
|
211
|
+
|
|
170
212
|
```xs
|
|
171
213
|
query "products" verb=GET {
|
|
172
214
|
api_group = "Products"
|
|
@@ -187,6 +229,7 @@ query "products" verb=GET {
|
|
|
187
229
|
```
|
|
188
230
|
|
|
189
231
|
### Create (POST)
|
|
232
|
+
|
|
190
233
|
```xs
|
|
191
234
|
query "products" verb=POST {
|
|
192
235
|
api_group = "Products"
|
|
@@ -213,6 +256,7 @@ query "products" verb=POST {
|
|
|
213
256
|
```
|
|
214
257
|
|
|
215
258
|
### Read (GET with ID)
|
|
259
|
+
|
|
216
260
|
```xs
|
|
217
261
|
query "products/{product_id}" verb=GET {
|
|
218
262
|
api_group = "Products"
|
|
@@ -235,6 +279,7 @@ query "products/{product_id}" verb=GET {
|
|
|
235
279
|
```
|
|
236
280
|
|
|
237
281
|
### Update (PATCH)
|
|
282
|
+
|
|
238
283
|
```xs
|
|
239
284
|
query "products/{product_id}" verb=PATCH {
|
|
240
285
|
api_group = "Products"
|
|
@@ -250,15 +295,19 @@ query "products/{product_id}" verb=PATCH {
|
|
|
250
295
|
|
|
251
296
|
conditional {
|
|
252
297
|
if ($input.name != null) {
|
|
253
|
-
var.update $updates { value = $
|
|
298
|
+
var.update $updates.name { value = $input.name }
|
|
254
299
|
}
|
|
255
300
|
}
|
|
256
301
|
conditional {
|
|
257
302
|
if ($input.price != null) {
|
|
258
|
-
var.update $updates { value = $
|
|
303
|
+
var.update $updates.price { value = $input.price }
|
|
259
304
|
}
|
|
260
305
|
}
|
|
261
306
|
|
|
307
|
+
precondition (($updates|is_empty) == false) {
|
|
308
|
+
error = "No updates provided"
|
|
309
|
+
}
|
|
310
|
+
|
|
262
311
|
db.patch "product" {
|
|
263
312
|
field_name = "id"
|
|
264
313
|
field_value = $input.product_id
|
|
@@ -270,6 +319,7 @@ query "products/{product_id}" verb=PATCH {
|
|
|
270
319
|
```
|
|
271
320
|
|
|
272
321
|
### Delete (DELETE)
|
|
322
|
+
|
|
273
323
|
```xs
|
|
274
324
|
query "products/{product_id}" verb=DELETE {
|
|
275
325
|
api_group = "Products"
|
|
@@ -292,11 +342,13 @@ query "products/{product_id}" verb=DELETE {
|
|
|
292
342
|
## Response Types
|
|
293
343
|
|
|
294
344
|
### JSON (default)
|
|
345
|
+
|
|
295
346
|
```xs
|
|
296
347
|
response = $data
|
|
297
348
|
```
|
|
298
349
|
|
|
299
350
|
### HTML
|
|
351
|
+
|
|
300
352
|
```xs
|
|
301
353
|
stack {
|
|
302
354
|
util.set_header {
|
|
@@ -316,6 +368,7 @@ response = $html
|
|
|
316
368
|
```
|
|
317
369
|
|
|
318
370
|
### Streaming
|
|
371
|
+
|
|
319
372
|
```xs
|
|
320
373
|
stack {
|
|
321
374
|
api.stream { value = $processed_data }
|
|
@@ -347,12 +400,12 @@ stack {
|
|
|
347
400
|
|
|
348
401
|
For complete error handling reference, use `xanoscript_docs({ topic: "syntax" })`.
|
|
349
402
|
|
|
350
|
-
| Type
|
|
351
|
-
|
|
352
|
-
| `inputerror`
|
|
353
|
-
| `accessdenied` | 403
|
|
354
|
-
| `notfound`
|
|
355
|
-
| `standard`
|
|
403
|
+
| Type | HTTP Status |
|
|
404
|
+
| -------------- | ----------- |
|
|
405
|
+
| `inputerror` | 400 |
|
|
406
|
+
| `accessdenied` | 403 |
|
|
407
|
+
| `notfound` | 404 |
|
|
408
|
+
| `standard` | 500 |
|
|
356
409
|
|
|
357
410
|
---
|
|
358
411
|
|
|
@@ -381,3 +434,4 @@ When using `return = { type: "list", paging: {...} }`:
|
|
|
381
434
|
3. **Authenticate writes** - Always require auth for POST/PATCH/DELETE
|
|
382
435
|
4. **Paginate lists** - Never return unbounded result sets
|
|
383
436
|
5. **Group by resource** - Organize endpoints in logical api groups
|
|
437
|
+
6. **Use specific canonicals** - Prefix canonicals to avoid instance-level collisions (e.g., `myapp-users` not `users`)
|
|
@@ -89,7 +89,7 @@ branch "production" {
|
|
|
89
89
|
|
|
90
90
|
## History Configuration
|
|
91
91
|
|
|
92
|
-
Control how many
|
|
92
|
+
Control how many statements from the execution trace are retained per request. Execution traces are kept for 24 hours; this setting limits how many stack statements are recorded in each trace.
|
|
93
93
|
|
|
94
94
|
### Syntax
|
|
95
95
|
|
|
@@ -112,23 +112,23 @@ branch "production" {
|
|
|
112
112
|
|
|
113
113
|
| Value | Description |
|
|
114
114
|
|-------|-------------|
|
|
115
|
-
| `false` | Disable history (no
|
|
116
|
-
| `10` |
|
|
117
|
-
| `100` |
|
|
118
|
-
| `1000` |
|
|
119
|
-
| `10000` |
|
|
120
|
-
| `"all"` |
|
|
115
|
+
| `false` | Disable history (no statements recorded) |
|
|
116
|
+
| `10` | Record up to 10 statements per trace |
|
|
117
|
+
| `100` | Record up to 100 statements per trace |
|
|
118
|
+
| `1000` | Record up to 1000 statements per trace |
|
|
119
|
+
| `10000` | Record up to 10000 statements per trace |
|
|
120
|
+
| `"all"` | Record all statements (use with caution) |
|
|
121
121
|
|
|
122
122
|
### History Targets
|
|
123
123
|
|
|
124
124
|
| Target | Description |
|
|
125
125
|
|--------|-------------|
|
|
126
|
-
| `function` |
|
|
127
|
-
| `query` | API endpoint
|
|
128
|
-
| `task` |
|
|
129
|
-
| `tool` | AI tool
|
|
130
|
-
| `trigger` |
|
|
131
|
-
| `middleware` |
|
|
126
|
+
| `function` | Statement limit for function traces |
|
|
127
|
+
| `query` | Statement limit for API endpoint traces |
|
|
128
|
+
| `task` | Statement limit for scheduled task traces |
|
|
129
|
+
| `tool` | Statement limit for AI tool traces |
|
|
130
|
+
| `trigger` | Statement limit for trigger traces |
|
|
131
|
+
| `middleware` | Statement limit for middleware traces |
|
|
132
132
|
|
|
133
133
|
---
|
|
134
134
|
|