@xano/developer-mcp 1.0.75 → 2.0.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.
- package/README.md +104 -37
- package/dist/cli_docs/index.d.ts +13 -37
- package/dist/cli_docs/index.js +28 -39
- package/dist/cli_docs/topics/integration.js +1 -1
- package/dist/cli_docs/topics/workspace.js +1 -1
- package/dist/index.js +58 -55
- package/dist/lib.d.ts +3 -1
- package/dist/lib.js +1 -1
- package/dist/meta_api_docs/format.js +1 -1
- package/dist/meta_api_docs/index.d.ts +14 -42
- package/dist/meta_api_docs/index.js +34 -46
- package/dist/tools/cli_docs.d.ts +2 -3
- package/dist/tools/cli_docs.js +3 -5
- package/dist/tools/define_tool.d.ts +47 -0
- package/dist/tools/define_tool.js +36 -0
- package/dist/tools/index.d.ts +88 -221
- package/dist/tools/index.js +80 -109
- package/dist/tools/mcp_version.d.ts +4 -25
- package/dist/tools/mcp_version.js +12 -19
- package/dist/tools/meta_api_docs.d.ts +2 -3
- package/dist/tools/meta_api_docs.js +3 -5
- package/dist/tools/validate_xanoscript.d.ts +18 -65
- package/dist/tools/validate_xanoscript.js +56 -54
- package/dist/tools/xanoscript_docs.d.ts +25 -74
- package/dist/tools/xanoscript_docs.js +86 -83
- package/dist/xanoscript_docs/README.md +5 -5
- package/dist/xanoscript_docs/apis.md +2 -2
- package/dist/xanoscript_docs/database.md +1 -1
- package/dist/xanoscript_docs/essentials.md +6 -6
- package/dist/xanoscript_docs/functions.md +3 -3
- package/dist/xanoscript_docs/integrations.md +5 -5
- package/dist/xanoscript_docs/middleware.md +1 -1
- package/dist/xanoscript_docs/performance.md +4 -4
- package/dist/xanoscript_docs/realtime.md +2 -2
- package/dist/xanoscript_docs/security.md +1 -1
- package/dist/xanoscript_docs/survival.md +1 -1
- package/dist/xanoscript_docs/syntax/string-filters.md +1 -1
- package/dist/xanoscript_docs/syntax.md +9 -9
- package/dist/xanoscript_docs/tools.md +2 -2
- package/dist/xanoscript_docs/types.md +2 -2
- package/dist/xanoscript_docs/unit-testing.md +1 -1
- package/dist/xanoscript_docs/workflow-tests.md +1 -1
- package/dist/xanoscript_docs/working.md +4 -4
- package/package.json +5 -4
- package/dist/api_docs/format.d.ts +0 -5
- package/dist/api_docs/format.js +0 -171
- package/dist/api_docs/index.d.ts +0 -52
- package/dist/api_docs/index.js +0 -111
- package/dist/api_docs/topics/agent.d.ts +0 -2
- package/dist/api_docs/topics/agent.js +0 -142
- package/dist/api_docs/topics/api.d.ts +0 -2
- package/dist/api_docs/topics/api.js +0 -176
- package/dist/api_docs/topics/apigroup.d.ts +0 -2
- package/dist/api_docs/topics/apigroup.js +0 -124
- package/dist/api_docs/topics/authentication.d.ts +0 -2
- package/dist/api_docs/topics/authentication.js +0 -61
- package/dist/api_docs/topics/branch.d.ts +0 -2
- package/dist/api_docs/topics/branch.js +0 -73
- package/dist/api_docs/topics/file.d.ts +0 -2
- package/dist/api_docs/topics/file.js +0 -70
- package/dist/api_docs/topics/function.d.ts +0 -2
- package/dist/api_docs/topics/function.js +0 -164
- package/dist/api_docs/topics/history.d.ts +0 -2
- package/dist/api_docs/topics/history.js +0 -149
- package/dist/api_docs/topics/mcp_server.d.ts +0 -2
- package/dist/api_docs/topics/mcp_server.js +0 -139
- package/dist/api_docs/topics/middleware.d.ts +0 -2
- package/dist/api_docs/topics/middleware.js +0 -156
- package/dist/api_docs/topics/realtime.d.ts +0 -2
- package/dist/api_docs/topics/realtime.js +0 -112
- package/dist/api_docs/topics/start.d.ts +0 -2
- package/dist/api_docs/topics/start.js +0 -107
- package/dist/api_docs/topics/table.d.ts +0 -2
- package/dist/api_docs/topics/table.js +0 -195
- package/dist/api_docs/topics/task.d.ts +0 -2
- package/dist/api_docs/topics/task.js +0 -165
- package/dist/api_docs/topics/tool.d.ts +0 -2
- package/dist/api_docs/topics/tool.js +0 -150
- package/dist/api_docs/topics/workflows.d.ts +0 -2
- package/dist/api_docs/topics/workflows.js +0 -131
- package/dist/api_docs/topics/workspace.d.ts +0 -2
- package/dist/api_docs/topics/workspace.js +0 -153
- package/dist/api_docs/types.d.ts +0 -79
- package/dist/api_docs/types.js +0 -4
- package/dist/cli_docs/topics/run.d.ts +0 -2
- package/dist/cli_docs/topics/run.js +0 -248
- package/dist/meta_api_docs/format.test.d.ts +0 -1
- package/dist/meta_api_docs/format.test.js +0 -272
- package/dist/meta_api_docs/index.test.d.ts +0 -1
- package/dist/meta_api_docs/index.test.js +0 -128
- package/dist/meta_api_docs/types.test.d.ts +0 -1
- package/dist/meta_api_docs/types.test.js +0 -132
- package/dist/templates/init-workspace.d.ts +0 -10
- package/dist/templates/init-workspace.js +0 -278
- package/dist/templates/xanoscript-index.d.ts +0 -11
- package/dist/templates/xanoscript-index.js +0 -72
- package/dist/tools/index.test.d.ts +0 -1
- package/dist/tools/index.test.js +0 -179
- package/dist/tools/xanoscript_docs.test.d.ts +0 -1
- package/dist/tools/xanoscript_docs.test.js +0 -197
- package/dist/xanoscript.test.d.ts +0 -1
- package/dist/xanoscript.test.js +0 -421
- package/dist/xanoscript_docs/cheatsheet.md +0 -287
- package/dist/xanoscript_docs/ephemeral.md +0 -330
- package/dist/xanoscript_docs/quickstart.md +0 -692
- package/dist/xanoscript_docs/run.md +0 -196
- package/dist/xanoscript_docs/schema.md +0 -300
- package/dist/xanoscript_docs_auto/README.md +0 -119
- package/dist/xanoscript_docs_auto/agents.md +0 -446
- package/dist/xanoscript_docs_auto/apis.md +0 -517
- package/dist/xanoscript_docs_auto/control-flow.md +0 -543
- package/dist/xanoscript_docs_auto/database.md +0 -551
- package/dist/xanoscript_docs_auto/debugging.md +0 -527
- package/dist/xanoscript_docs_auto/filters.md +0 -464
- package/dist/xanoscript_docs_auto/functions.md +0 -431
- package/dist/xanoscript_docs_auto/integrations.md +0 -657
- package/dist/xanoscript_docs_auto/mcp-servers.md +0 -408
- package/dist/xanoscript_docs_auto/operators.md +0 -368
- package/dist/xanoscript_docs_auto/syntax.md +0 -287
- package/dist/xanoscript_docs_auto/tables.md +0 -447
- package/dist/xanoscript_docs_auto/tasks.md +0 -479
- package/dist/xanoscript_docs_auto/testing.md +0 -574
- package/dist/xanoscript_docs_auto/tools.md +0 -485
- package/dist/xanoscript_docs_auto/triggers.md +0 -595
- package/dist/xanoscript_docs_auto/types.md +0 -323
- package/dist/xanoscript_docs_auto/variables.md +0 -462
- package/dist/xanoscript_docs_auto/version.json +0 -5
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "run/**/*.xs"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Run Configurations
|
|
6
|
-
|
|
7
|
-
Define job and service configurations for the Xano Job Runner.
|
|
8
|
-
|
|
9
|
-
## Quick Reference
|
|
10
|
-
|
|
11
|
-
| Type | Purpose | Lifecycle |
|
|
12
|
-
|------|---------|-----------|
|
|
13
|
-
| **run.job** | Execute a function once | Runs main function, then shuts down |
|
|
14
|
-
| **run.service** | Long-running background process | Runs pre initialization, then maintains service |
|
|
15
|
-
|
|
16
|
-
### Directory Structure
|
|
17
|
-
```
|
|
18
|
-
run.xs
|
|
19
|
-
table/
|
|
20
|
-
function/
|
|
21
|
-
api/
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## run.job
|
|
27
|
-
|
|
28
|
-
Execute a function as a standalone job in the Xano Job Runner.
|
|
29
|
-
|
|
30
|
-
### Syntax
|
|
31
|
-
```xs
|
|
32
|
-
run.job "Job Name" {
|
|
33
|
-
main = {
|
|
34
|
-
name: "function_name"
|
|
35
|
-
input: { key: value }
|
|
36
|
-
}
|
|
37
|
-
env = ["ENV_VAR1", "ENV_VAR2"]
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Properties
|
|
42
|
-
|
|
43
|
-
| Property | Type | Required | Description |
|
|
44
|
-
|----------|------|----------|-------------|
|
|
45
|
-
| `main` | Object | Yes | Function to execute |
|
|
46
|
-
| `main.name` | String | Yes | Name of the function to call |
|
|
47
|
-
| `main.input` | Object | No | Input parameters for the function |
|
|
48
|
-
| `env` | String[] | No | Environment variables required |
|
|
49
|
-
|
|
50
|
-
### Basic Example
|
|
51
|
-
```xs
|
|
52
|
-
run.job "Random Dad Joke" {
|
|
53
|
-
main = {
|
|
54
|
-
name: "fetch_dad_joke"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### With Input Parameters
|
|
60
|
-
```xs
|
|
61
|
-
run.job "Average of values" {
|
|
62
|
-
main = {
|
|
63
|
-
name: "avg_value"
|
|
64
|
-
input: {
|
|
65
|
-
left: 1
|
|
66
|
-
right: 2
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### With Environment Variables
|
|
73
|
-
```xs
|
|
74
|
-
run.job "Gemini Image Understanding" {
|
|
75
|
-
main = {
|
|
76
|
-
name: "analyze_image"
|
|
77
|
-
input: {
|
|
78
|
-
model: "gemini-1.5-flash"
|
|
79
|
-
prompt: "Describe what is happening in this image."
|
|
80
|
-
image: "(attach image file)"
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
env = ["gemini_api_key"]
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## run.service
|
|
90
|
-
|
|
91
|
-
Define a long-running background service with optional initialization.
|
|
92
|
-
|
|
93
|
-
### Syntax
|
|
94
|
-
```xs
|
|
95
|
-
run.service "Service Name" {
|
|
96
|
-
pre = {
|
|
97
|
-
name: "init_function"
|
|
98
|
-
input: { key: value }
|
|
99
|
-
}
|
|
100
|
-
env = ["ENV_VAR1", "ENV_VAR2"]
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Properties
|
|
105
|
-
|
|
106
|
-
| Property | Type | Required | Description |
|
|
107
|
-
|----------|------|----------|-------------|
|
|
108
|
-
| `pre` | Object | No | Initialization function |
|
|
109
|
-
| `pre.name` | String | Yes (if pre) | Name of the init function |
|
|
110
|
-
| `pre.input` | Object | No | Input parameters for init |
|
|
111
|
-
| `env` | String[] | No | Environment variables required |
|
|
112
|
-
|
|
113
|
-
### Minimal Form
|
|
114
|
-
```xs
|
|
115
|
-
run.service "email proxy"
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Basic Example
|
|
119
|
-
```xs
|
|
120
|
-
run.service "Random Dad Joke" {
|
|
121
|
-
pre = {
|
|
122
|
-
name: "fetch_dad_joke"
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### With Initialization
|
|
128
|
-
```xs
|
|
129
|
-
run.service "email proxy" {
|
|
130
|
-
pre = {
|
|
131
|
-
name: "email_proxy_init"
|
|
132
|
-
input: {
|
|
133
|
-
config: "default"
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### With Environment Variables
|
|
140
|
-
```xs
|
|
141
|
-
run.service "webhook listener" {
|
|
142
|
-
pre = {
|
|
143
|
-
name: "init_webhook_listener"
|
|
144
|
-
input: {
|
|
145
|
-
port: 8080
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
env = ["webhook_secret", "database_url"]
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## Supporting Files
|
|
155
|
-
|
|
156
|
-
Jobs and services can include supporting tables and functions in `table/` and `function/` subdirectories.
|
|
157
|
-
|
|
158
|
-
> See `xanoscript_docs({ topic: "tables" })` and `xanoscript_docs({ topic: "functions" })` for table/function syntax.
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Differences: run.job vs run.service
|
|
163
|
-
|
|
164
|
-
| Feature | run.job | run.service |
|
|
165
|
-
|---------|---------|-------------|
|
|
166
|
-
| Required attribute | `main` | None |
|
|
167
|
-
| Init function | N/A | `pre` (optional) |
|
|
168
|
-
| Lifecycle | Executes once | Long-running |
|
|
169
|
-
| Use case | One-time operations | Proxies, listeners, daemons |
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## Validation Rules
|
|
174
|
-
|
|
175
|
-
1. **run.job requires `main`** - Missing `main` causes an error
|
|
176
|
-
2. **run.service cannot use `main`** - Use `pre` for initialization
|
|
177
|
-
3. **`env` must be string array** - Cannot contain numbers or booleans
|
|
178
|
-
4. **Input values must be constants** - No variables like `$input` allowed
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## Best Practices
|
|
183
|
-
|
|
184
|
-
1. **Name clearly** - Indicate purpose: `data-migration`, `email-proxy`
|
|
185
|
-
2. **Use env for secrets** - Never hardcode API keys or credentials
|
|
186
|
-
3. **Keep self-contained** - Include all required tables and functions
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## Related Topics
|
|
191
|
-
|
|
192
|
-
| Topic | Description |
|
|
193
|
-
|-------|-------------|
|
|
194
|
-
| `functions` | Function stacks run by jobs |
|
|
195
|
-
| `tasks` | Scheduled task definitions |
|
|
196
|
-
| `tables` | Database tables accessed by jobs |
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "function/**/*.xs, api/**/*.xs"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Schema Operations
|
|
6
|
-
|
|
7
|
-
Runtime schema parsing and validation for dynamic data structures.
|
|
8
|
-
|
|
9
|
-
## Quick Reference
|
|
10
|
-
|
|
11
|
-
| Function | Purpose |
|
|
12
|
-
|----------|---------|
|
|
13
|
-
| `schema.parse` | Parse and validate any schema |
|
|
14
|
-
| `schema.parse.object` | Parse object schema |
|
|
15
|
-
| `schema.parse.array` | Parse array schema |
|
|
16
|
-
| `schema.parse.attribute` | Parse single attribute |
|
|
17
|
-
| `schema.parse.constant` | Parse constant value |
|
|
18
|
-
| `schema.parse.enum` | Parse enum value |
|
|
19
|
-
| `schema.parse.immutable` | Parse immutable structure |
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## schema.parse
|
|
24
|
-
|
|
25
|
-
Parse and validate data against a dynamic schema.
|
|
26
|
-
|
|
27
|
-
```xs
|
|
28
|
-
schema.parse {
|
|
29
|
-
data = $input.payload
|
|
30
|
-
schema = {
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: {
|
|
33
|
-
name: { type: "text", required: true },
|
|
34
|
-
email: { type: "email", filters: ["trim", "lower"] },
|
|
35
|
-
age: { type: "int", filters: ["min:0", "max:150"] }
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
} as $validated
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Schema Definition
|
|
42
|
-
|
|
43
|
-
| Property | Description |
|
|
44
|
-
|----------|-------------|
|
|
45
|
-
| `type` | Data type (text, int, decimal, bool, object, array, etc.) |
|
|
46
|
-
| `required` | Whether field is required (default: false) |
|
|
47
|
-
| `nullable` | Whether null is allowed (default: false) |
|
|
48
|
-
| `default` | Default value if not provided |
|
|
49
|
-
| `filters` | Array of validation filters |
|
|
50
|
-
| `properties` | Nested properties (for object type) |
|
|
51
|
-
| `items` | Item schema (for array type) |
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## schema.parse.object
|
|
56
|
-
|
|
57
|
-
Parse and validate an object structure.
|
|
58
|
-
|
|
59
|
-
```xs
|
|
60
|
-
schema.parse.object {
|
|
61
|
-
data = $input.user
|
|
62
|
-
schema = {
|
|
63
|
-
id: { type: "int", required: true },
|
|
64
|
-
profile: {
|
|
65
|
-
type: "object",
|
|
66
|
-
properties: {
|
|
67
|
-
name: { type: "text", required: true },
|
|
68
|
-
bio: { type: "text", nullable: true, filters: ["max:500"] }
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
roles: { type: "array", items: { type: "text" } }
|
|
72
|
-
}
|
|
73
|
-
} as $user
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### With Defaults
|
|
77
|
-
|
|
78
|
-
```xs
|
|
79
|
-
schema.parse.object {
|
|
80
|
-
data = $input.settings
|
|
81
|
-
schema = {
|
|
82
|
-
theme: { type: "text", default: "light" },
|
|
83
|
-
notifications: { type: "bool", default: true },
|
|
84
|
-
language: { type: "text", default: "en" }
|
|
85
|
-
}
|
|
86
|
-
} as $settings
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## schema.parse.array
|
|
92
|
-
|
|
93
|
-
Parse and validate an array structure.
|
|
94
|
-
|
|
95
|
-
```xs
|
|
96
|
-
schema.parse.array {
|
|
97
|
-
data = $input.items
|
|
98
|
-
schema = {
|
|
99
|
-
min_items: 1,
|
|
100
|
-
max_items: 100,
|
|
101
|
-
items: {
|
|
102
|
-
type: "object",
|
|
103
|
-
properties: {
|
|
104
|
-
product_id: { type: "int", required: true },
|
|
105
|
-
quantity: { type: "int", required: true, filters: ["min:1"] }
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
} as $items
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Flat Array
|
|
113
|
-
|
|
114
|
-
```xs
|
|
115
|
-
schema.parse.array {
|
|
116
|
-
data = $input.tags
|
|
117
|
-
schema = {
|
|
118
|
-
items: { type: "text", filters: ["trim", "lower"] },
|
|
119
|
-
unique: true
|
|
120
|
-
}
|
|
121
|
-
} as $tags
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## schema.parse.attribute
|
|
127
|
-
|
|
128
|
-
Parse a single attribute value.
|
|
129
|
-
|
|
130
|
-
```xs
|
|
131
|
-
schema.parse.attribute {
|
|
132
|
-
data = $input.email
|
|
133
|
-
schema = {
|
|
134
|
-
type: "email",
|
|
135
|
-
required: true,
|
|
136
|
-
filters: ["trim", "lower"]
|
|
137
|
-
}
|
|
138
|
-
} as $email
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### With Custom Validation
|
|
142
|
-
|
|
143
|
-
```xs
|
|
144
|
-
schema.parse.attribute {
|
|
145
|
-
data = $input.phone
|
|
146
|
-
schema = {
|
|
147
|
-
type: "text",
|
|
148
|
-
pattern: "^\\+?[1-9]\\d{1,14}$",
|
|
149
|
-
error_message: "Invalid phone number format"
|
|
150
|
-
}
|
|
151
|
-
} as $phone
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## schema.parse.constant
|
|
157
|
-
|
|
158
|
-
Validate that a value matches an expected constant.
|
|
159
|
-
|
|
160
|
-
```xs
|
|
161
|
-
schema.parse.constant {
|
|
162
|
-
data = $input.version
|
|
163
|
-
schema = {
|
|
164
|
-
value: "2.0",
|
|
165
|
-
error_message: "Only API version 2.0 is supported"
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## schema.parse.enum
|
|
173
|
-
|
|
174
|
-
Validate that a value is one of allowed options.
|
|
175
|
-
|
|
176
|
-
```xs
|
|
177
|
-
schema.parse.enum {
|
|
178
|
-
data = $input.status
|
|
179
|
-
schema = {
|
|
180
|
-
values: ["pending", "active", "suspended", "closed"],
|
|
181
|
-
error_message: "Invalid status value"
|
|
182
|
-
}
|
|
183
|
-
} as $status
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### With Default
|
|
187
|
-
|
|
188
|
-
```xs
|
|
189
|
-
schema.parse.enum {
|
|
190
|
-
data = $input.priority
|
|
191
|
-
schema = {
|
|
192
|
-
values: ["low", "medium", "high"],
|
|
193
|
-
default: "medium"
|
|
194
|
-
}
|
|
195
|
-
} as $priority
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## schema.parse.immutable
|
|
201
|
-
|
|
202
|
-
Parse a structure that cannot be modified after parsing.
|
|
203
|
-
|
|
204
|
-
```xs
|
|
205
|
-
schema.parse.immutable {
|
|
206
|
-
data = $input.config
|
|
207
|
-
schema = {
|
|
208
|
-
api_version: { type: "text", required: true },
|
|
209
|
-
features: { type: "array", items: { type: "text" } }
|
|
210
|
-
}
|
|
211
|
-
} as $config
|
|
212
|
-
|
|
213
|
-
// Attempting to modify $config will throw an error
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## Dynamic Schema Generation
|
|
219
|
-
|
|
220
|
-
Build schemas programmatically.
|
|
221
|
-
|
|
222
|
-
```xs
|
|
223
|
-
function "validate_dynamic_form" {
|
|
224
|
-
input {
|
|
225
|
-
object form_config
|
|
226
|
-
object form_data
|
|
227
|
-
}
|
|
228
|
-
stack {
|
|
229
|
-
// Build schema from configuration
|
|
230
|
-
var $schema { value = { type: "object", properties: {} } }
|
|
231
|
-
|
|
232
|
-
foreach ($input.form_config.fields) {
|
|
233
|
-
each as $field {
|
|
234
|
-
var.update $schema.properties {
|
|
235
|
-
value = $schema.properties|set:$field.name:{
|
|
236
|
-
type: $field.type,
|
|
237
|
-
required: $field.required,
|
|
238
|
-
filters: $field.filters
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Validate form data against dynamic schema
|
|
245
|
-
schema.parse.object {
|
|
246
|
-
data = $input.form_data
|
|
247
|
-
schema = $schema.properties
|
|
248
|
-
} as $validated
|
|
249
|
-
}
|
|
250
|
-
response = $validated
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
---
|
|
255
|
-
|
|
256
|
-
## Error Handling
|
|
257
|
-
|
|
258
|
-
Schema validation errors can be caught and handled.
|
|
259
|
-
|
|
260
|
-
```xs
|
|
261
|
-
try_catch {
|
|
262
|
-
try {
|
|
263
|
-
schema.parse.object {
|
|
264
|
-
data = $input.payload
|
|
265
|
-
schema = $expected_schema
|
|
266
|
-
} as $validated
|
|
267
|
-
}
|
|
268
|
-
catch {
|
|
269
|
-
// $error contains validation details
|
|
270
|
-
// $error.field - which field failed
|
|
271
|
-
// $error.message - validation error message
|
|
272
|
-
// $error.value - the invalid value
|
|
273
|
-
throw {
|
|
274
|
-
name = "ValidationError"
|
|
275
|
-
value = {
|
|
276
|
-
field: $error.field,
|
|
277
|
-
message: $error.message
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
---
|
|
285
|
-
|
|
286
|
-
## Best Practices
|
|
287
|
-
|
|
288
|
-
1. **Define schemas upfront** - Use input blocks when structure is known
|
|
289
|
-
2. **Use schema.parse for dynamic data** - External APIs, user-generated content
|
|
290
|
-
3. **Validate at boundaries** - Parse external input, trust internal data; provide clear error messages
|
|
291
|
-
|
|
292
|
-
---
|
|
293
|
-
|
|
294
|
-
## Related Topics
|
|
295
|
-
|
|
296
|
-
| Topic | Description |
|
|
297
|
-
|-------|-------------|
|
|
298
|
-
| `types` | Data types and input validation |
|
|
299
|
-
| `integrations/external-apis` | Parsing external API responses |
|
|
300
|
-
| `syntax` | Expressions and filters |
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# XanoScript Complete Reference
|
|
2
|
-
|
|
3
|
-
XanoScript is a declarative, statically-typed scripting language for [Xano](https://xano.com). It enables developers to build API endpoints, functions, scheduled tasks, database operations, and AI agents with structured, readable syntax.
|
|
4
|
-
|
|
5
|
-
## Quick Reference
|
|
6
|
-
|
|
7
|
-
### Top-Level Object Types
|
|
8
|
-
|
|
9
|
-
| Type | File Location | Purpose |
|
|
10
|
-
|------|---------------|---------|
|
|
11
|
-
| `query` | `apis/<group>/*.xs` | HTTP API endpoints with verbs, input, processing, response |
|
|
12
|
-
| `function` | `functions/**/*.xs` | Reusable logic blocks with optional testing |
|
|
13
|
-
| `task` | `tasks/*.xs` | Scheduled operations with cron-like triggers |
|
|
14
|
-
| `table` | `tables/*.xs` | Database schema definitions |
|
|
15
|
-
| `table_trigger` | `triggers/**/*.xs` | Trigger handlers for database events |
|
|
16
|
-
| `agent` | `agents/**/*.xs` | AI agent definitions |
|
|
17
|
-
| `tool` | `tools/**/*.xs` | Tool definitions for AI agents |
|
|
18
|
-
| `mcp_server` | `mcp_servers/**/*.xs` | Model Context Protocol server definitions |
|
|
19
|
-
| `middleware` | `middleware/**/*.xs` | Request/response interceptors |
|
|
20
|
-
| `addon` | `addons/*.xs` | Subqueries for related data |
|
|
21
|
-
| `branch` | `branch.xs` | Branch-level configuration |
|
|
22
|
-
| `workspace` | `workspace.xs` | Workspace-level settings |
|
|
23
|
-
| `realtime_channel` | Configuration | Real-time channel definitions |
|
|
24
|
-
| `api_group` | `apis/<group>/` | Collections of related API endpoints |
|
|
25
|
-
|
|
26
|
-
**Important:** Each `.xs` file must contain exactly one definition.
|
|
27
|
-
|
|
28
|
-
### Block Structure
|
|
29
|
-
|
|
30
|
-
```xs
|
|
31
|
-
<construct> "<name>" {
|
|
32
|
-
input { ... } // Parameters (optional)
|
|
33
|
-
stack { ... } // Logic
|
|
34
|
-
response = $var // Output
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Variable Access
|
|
39
|
-
|
|
40
|
-
```xs
|
|
41
|
-
$input.field // Input parameters
|
|
42
|
-
$var.name // Stack variables (in some contexts)
|
|
43
|
-
$auth.id // Authenticated user ID
|
|
44
|
-
$env.MY_VAR // Environment variable
|
|
45
|
-
$db.table.field // Database field reference (in queries)
|
|
46
|
-
$this // Current item in loops/maps
|
|
47
|
-
$error // Error information (in catch blocks)
|
|
48
|
-
now // Current timestamp
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Language Blocks (Clauses)
|
|
52
|
-
|
|
53
|
-
| Block | Purpose |
|
|
54
|
-
|-------|---------|
|
|
55
|
-
| `stack` | Container for sequential operations |
|
|
56
|
-
| `input` | Define parameters with types and validation |
|
|
57
|
-
| `schema` | Database table schema |
|
|
58
|
-
| `response` | Specify output data |
|
|
59
|
-
| `schedule` | Execution times for tasks |
|
|
60
|
-
| `security` | Authentication and permissions |
|
|
61
|
-
| `auth` | Authentication configuration |
|
|
62
|
-
| `cache` | Caching configuration |
|
|
63
|
-
| `history` | History tracking |
|
|
64
|
-
| `index` | Database index definitions |
|
|
65
|
-
| `test` | Test definitions |
|
|
66
|
-
| `view` | View definitions |
|
|
67
|
-
| `middleware` | Middleware configuration |
|
|
68
|
-
|
|
69
|
-
## Workspace Structure
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
project/
|
|
73
|
-
├── workspace.xs // Workspace configuration
|
|
74
|
-
├── branch.xs // Branch configuration
|
|
75
|
-
├── tables/ // Database table schemas
|
|
76
|
-
├── functions/ // Reusable functions (supports subfolders)
|
|
77
|
-
├── apis/
|
|
78
|
-
│ └── <api-group>/ // API endpoints grouped by domain
|
|
79
|
-
├── tasks/ // Scheduled jobs
|
|
80
|
-
├── triggers/ // Event-driven handlers
|
|
81
|
-
├── agents/ // AI agents
|
|
82
|
-
├── tools/ // AI tools
|
|
83
|
-
├── mcp_servers/ // MCP server definitions
|
|
84
|
-
├── middleware/ // Request/response interceptors
|
|
85
|
-
├── addons/ // Query addons
|
|
86
|
-
├── static/ // Frontend files
|
|
87
|
-
└── run/ // Job and service configurations
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Comments
|
|
91
|
-
|
|
92
|
-
```xs
|
|
93
|
-
// Single-line comment
|
|
94
|
-
/* Multi-line comment */
|
|
95
|
-
var $total { value = 0 } // Inline comment
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Documentation Topics
|
|
99
|
-
|
|
100
|
-
| Topic | Description |
|
|
101
|
-
|-------|-------------|
|
|
102
|
-
| `syntax` | Expressions, operators, filters |
|
|
103
|
-
| `types` | Data types and validation |
|
|
104
|
-
| `operators` | Comparison, logical, math operators |
|
|
105
|
-
| `filters` | Pipe filters for transformations |
|
|
106
|
-
| `control-flow` | Conditionals, loops, error handling |
|
|
107
|
-
| `functions` | Function definitions and calls |
|
|
108
|
-
| `database` | All db.* operations |
|
|
109
|
-
| `apis` | HTTP endpoint definitions |
|
|
110
|
-
| `tables` | Database schema definitions |
|
|
111
|
-
| `tasks` | Scheduled jobs |
|
|
112
|
-
| `triggers` | Event-driven handlers |
|
|
113
|
-
| `agents` | AI agent configuration |
|
|
114
|
-
| `tools` | AI tools for agents |
|
|
115
|
-
| `mcp-servers` | MCP server definitions |
|
|
116
|
-
| `integrations` | Cloud storage, Redis, external APIs |
|
|
117
|
-
| `security-functions` | Encryption, hashing, auth tokens |
|
|
118
|
-
| `testing` | Unit tests and assertions |
|
|
119
|
-
| `variables` | System and built-in variables |
|