@xano/developer-mcp 1.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/LICENSE +21 -0
- package/README.md +261 -0
- package/api_docs/addon.md +193 -0
- package/api_docs/agent.md +154 -0
- package/api_docs/api_group.md +236 -0
- package/api_docs/authentication.md +68 -0
- package/api_docs/file.md +190 -0
- package/api_docs/function.md +217 -0
- package/api_docs/history.md +263 -0
- package/api_docs/index.md +104 -0
- package/api_docs/mcp_server.md +139 -0
- package/api_docs/middleware.md +205 -0
- package/api_docs/realtime.md +153 -0
- package/api_docs/table.md +151 -0
- package/api_docs/task.md +191 -0
- package/api_docs/tool.md +216 -0
- package/api_docs/triggers.md +344 -0
- package/api_docs/workspace.md +246 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +495 -0
- package/package.json +49 -0
- package/xanoscript_docs/README.md +1 -0
- package/xanoscript_docs/api_query_examples.md +1255 -0
- package/xanoscript_docs/api_query_guideline.md +129 -0
- package/xanoscript_docs/build_from_lovable.md +715 -0
- package/xanoscript_docs/db_query_guideline.md +427 -0
- package/xanoscript_docs/ephemeral_environment_guideline.md +529 -0
- package/xanoscript_docs/expression_guideline.md +1086 -0
- package/xanoscript_docs/frontend_guideline.md +67 -0
- package/xanoscript_docs/function_examples.md +1406 -0
- package/xanoscript_docs/function_guideline.md +130 -0
- package/xanoscript_docs/functions.md +2155 -0
- package/xanoscript_docs/input_guideline.md +227 -0
- package/xanoscript_docs/mcp_server_examples.md +36 -0
- package/xanoscript_docs/mcp_server_guideline.md +69 -0
- package/xanoscript_docs/query_filter.md +489 -0
- package/xanoscript_docs/table_examples.md +586 -0
- package/xanoscript_docs/table_guideline.md +137 -0
- package/xanoscript_docs/task_examples.md +511 -0
- package/xanoscript_docs/task_guideline.md +103 -0
- package/xanoscript_docs/tips_and_tricks.md +144 -0
- package/xanoscript_docs/tool_examples.md +69 -0
- package/xanoscript_docs/tool_guideline.md +139 -0
- package/xanoscript_docs/unit_testing_guideline.md +328 -0
- package/xanoscript_docs/version.json +3 -0
- package/xanoscript_docs/workspace.md +17 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# API Group & Endpoints
|
|
2
|
+
|
|
3
|
+
API Groups are containers for related API endpoints. Each API group has its own base URL and can contain multiple API endpoints.
|
|
4
|
+
|
|
5
|
+
## API Group Endpoints
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/apigroup` | List API groups |
|
|
10
|
+
| GET | `/workspace/{workspace_id}/apigroup/{apigroup_id}` | Get API group |
|
|
11
|
+
| POST | `/workspace/{workspace_id}/apigroup` | Create API group |
|
|
12
|
+
| PUT | `/workspace/{workspace_id}/apigroup/{apigroup_id}` | Update API group |
|
|
13
|
+
| DELETE | `/workspace/{workspace_id}/apigroup/{apigroup_id}` | Delete API group |
|
|
14
|
+
| PUT | `/workspace/{workspace_id}/apigroup/{apigroup_id}/security` | Update security |
|
|
15
|
+
| GET | `/workspace/{workspace_id}/apigroup/{apigroup_id}/openapi` | Get OpenAPI spec |
|
|
16
|
+
|
|
17
|
+
## API Endpoint Endpoints
|
|
18
|
+
|
|
19
|
+
| Method | Endpoint | Description |
|
|
20
|
+
|--------|----------|-------------|
|
|
21
|
+
| GET | `/workspace/{workspace_id}/apigroup/{apigroup_id}/api` | List endpoints |
|
|
22
|
+
| GET | `/workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}` | Get endpoint |
|
|
23
|
+
| POST | `/workspace/{workspace_id}/apigroup/{apigroup_id}/api` | Create endpoint |
|
|
24
|
+
| PUT | `/workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}` | Update endpoint |
|
|
25
|
+
| DELETE | `/workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}` | Delete endpoint |
|
|
26
|
+
| PUT | `/workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}/security` | Update security |
|
|
27
|
+
| GET | `/workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}/openapi` | Get OpenAPI spec |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## List API Groups
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
GET /workspace/{workspace_id}/apigroup
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Query Parameters:**
|
|
38
|
+
| Parameter | Type | Default | Description |
|
|
39
|
+
|-----------|------|---------|-------------|
|
|
40
|
+
| `branch` | text | "" | Branch label |
|
|
41
|
+
| `page` | int | 1 | Page number |
|
|
42
|
+
| `per_page` | int | 50 | Items per page |
|
|
43
|
+
| `search` | text | "" | Search filter |
|
|
44
|
+
| `sort` | enum | "created_at" | Sort field |
|
|
45
|
+
| `order` | enum | "desc" | Sort order |
|
|
46
|
+
| `middleware` | bool | true | Include middleware info |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Create API Group
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
POST /workspace/{workspace_id}/apigroup
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Content-Type:** `text/x-xanoscript`
|
|
57
|
+
|
|
58
|
+
```xanoscript
|
|
59
|
+
api_group foo {
|
|
60
|
+
canonical = "custom"
|
|
61
|
+
swagger = {active: true}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Query Parameters:**
|
|
66
|
+
- `branch` (text): Target branch label
|
|
67
|
+
- `middleware` (bool): Include middleware in response
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Update API Group
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
PUT /workspace/{workspace_id}/apigroup/{apigroup_id}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Content-Type:** `text/x-xanoscript`
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Delete API Group
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
DELETE /workspace/{workspace_id}/apigroup/{apigroup_id}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Deletes the API group and all its endpoints. Cannot be undone.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Update API Group Security
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
PUT /workspace/{workspace_id}/apigroup/{apigroup_id}/security
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Parameters:**
|
|
98
|
+
| Parameter | Type | Required | Description |
|
|
99
|
+
|-----------|------|----------|-------------|
|
|
100
|
+
| `guid` | text | Yes | New security GUID |
|
|
101
|
+
| `canonical` | text | Yes | Canonical URL path |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Get API Group OpenAPI Spec
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
GET /workspace/{workspace_id}/apigroup/{apigroup_id}/openapi
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Returns OpenAPI specification as JSON.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
# API Endpoints
|
|
116
|
+
|
|
117
|
+
## List API Endpoints
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
GET /workspace/{workspace_id}/apigroup/{apigroup_id}/api
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Query Parameters:**
|
|
124
|
+
| Parameter | Type | Default | Description |
|
|
125
|
+
|-----------|------|---------|-------------|
|
|
126
|
+
| `page` | int | 1 | Page number |
|
|
127
|
+
| `per_page` | int | 50 | Items per page |
|
|
128
|
+
| `search` | text | "" | Search filter |
|
|
129
|
+
| `sort` | enum | "created_at" | Sort field |
|
|
130
|
+
| `order` | enum | "desc" | Sort order |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Create API Endpoint
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
POST /workspace/{workspace_id}/apigroup/{apigroup_id}/api
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Content-Type:** `text/x-xanoscript`
|
|
141
|
+
|
|
142
|
+
### XanoScript API Endpoint Syntax
|
|
143
|
+
|
|
144
|
+
```xanoscript
|
|
145
|
+
query foo verb=GET {
|
|
146
|
+
input {
|
|
147
|
+
int score
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
stack {
|
|
151
|
+
var $x1 {
|
|
152
|
+
value = $input.score + 1
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
response = $x1
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### HTTP Verbs
|
|
161
|
+
Use `verb=` to specify: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`
|
|
162
|
+
|
|
163
|
+
### Input Section
|
|
164
|
+
Define request parameters:
|
|
165
|
+
|
|
166
|
+
```xanoscript
|
|
167
|
+
input {
|
|
168
|
+
int required_param
|
|
169
|
+
text optional_param?
|
|
170
|
+
bool param_with_default? default = true
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Stack Section
|
|
175
|
+
The API logic using XanoScript:
|
|
176
|
+
|
|
177
|
+
```xanoscript
|
|
178
|
+
stack {
|
|
179
|
+
// Variable assignment
|
|
180
|
+
var $result {
|
|
181
|
+
value = $input.score * 2
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Database queries
|
|
185
|
+
db.query user {
|
|
186
|
+
where = $db.user.id == $input.user_id
|
|
187
|
+
return = {type: "single"}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Conditional logic
|
|
191
|
+
if $input.score > 10 {
|
|
192
|
+
var $bonus { value = 100 }
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Response
|
|
198
|
+
Define what the endpoint returns:
|
|
199
|
+
|
|
200
|
+
```xanoscript
|
|
201
|
+
response = $result
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Update API Endpoint
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
PUT /workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Query Parameters:**
|
|
213
|
+
- `publish` (bool, default: true): Publish changes immediately
|
|
214
|
+
|
|
215
|
+
**Content-Type:** `text/x-xanoscript`
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Delete API Endpoint
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
DELETE /workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Update API Endpoint Security
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
PUT /workspace/{workspace_id}/apigroup/{apigroup_id}/api/{api_id}/security
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Parameters:**
|
|
234
|
+
| Parameter | Type | Required | Description |
|
|
235
|
+
|-----------|------|----------|-------------|
|
|
236
|
+
| `guid` | text | Yes | New security GUID |
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Authentication API
|
|
2
|
+
|
|
3
|
+
The Headless API requires authentication for all endpoints. This document covers the authentication endpoint.
|
|
4
|
+
|
|
5
|
+
## Endpoints
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/auth/me` | Get current user info |
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Get Current User
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
GET /auth/me
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Retrieve information about the authenticated user.
|
|
20
|
+
|
|
21
|
+
**Response Example:**
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"id": 123,
|
|
25
|
+
"name": "User Name",
|
|
26
|
+
"email": "user@example.com",
|
|
27
|
+
"extras": {
|
|
28
|
+
"instance": {
|
|
29
|
+
"membership": {
|
|
30
|
+
"role": "admin",
|
|
31
|
+
"workspace": {
|
|
32
|
+
"id": [1, 2, 3]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Response Fields:**
|
|
41
|
+
| Field | Type | Description |
|
|
42
|
+
|-------|------|-------------|
|
|
43
|
+
| `id` | int | User's unique identifier |
|
|
44
|
+
| `name` | text | User's display name |
|
|
45
|
+
| `email` | text | User's email address |
|
|
46
|
+
| `extras` | object | Additional authentication context |
|
|
47
|
+
|
|
48
|
+
### Extras Object
|
|
49
|
+
|
|
50
|
+
The `extras` object contains instance membership information:
|
|
51
|
+
|
|
52
|
+
| Path | Description |
|
|
53
|
+
|------|-------------|
|
|
54
|
+
| `extras.instance.membership.role` | User's role |
|
|
55
|
+
| `extras.instance.membership.workspace.id` | Accessible workspace IDs (for free tier) |
|
|
56
|
+
|
|
57
|
+
### User Roles
|
|
58
|
+
|
|
59
|
+
| Role | Description |
|
|
60
|
+
|------|-------------|
|
|
61
|
+
| `explore` | Free tier - limited workspace access |
|
|
62
|
+
| `admin` | Full access to all workspaces |
|
|
63
|
+
|
|
64
|
+
### Notes
|
|
65
|
+
|
|
66
|
+
- The `workspace.id` array is used for free tier users to restrict access
|
|
67
|
+
- Paid users can access all workspaces not in the disabled list
|
|
68
|
+
- The role determines what operations the user can perform
|
package/api_docs/file.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# File & Static Hosting API
|
|
2
|
+
|
|
3
|
+
File management endpoints allow you to upload, list, and delete files in a workspace. Static hosting allows you to deploy static websites.
|
|
4
|
+
|
|
5
|
+
## File Endpoints
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/file` | List files |
|
|
10
|
+
| POST | `/workspace/{workspace_id}/file` | Upload file |
|
|
11
|
+
| DELETE | `/workspace/{workspace_id}/file/{file_id}` | Delete file |
|
|
12
|
+
| DELETE | `/workspace/{workspace_id}/file/bulk_delete` | Bulk delete files |
|
|
13
|
+
|
|
14
|
+
## Static Host Endpoints
|
|
15
|
+
|
|
16
|
+
| Method | Endpoint | Description |
|
|
17
|
+
|--------|----------|-------------|
|
|
18
|
+
| GET | `/workspace/{workspace_id}/static_host` | List static hosts |
|
|
19
|
+
| GET | `/workspace/{workspace_id}/static_host/{static_host}/build` | List builds |
|
|
20
|
+
| POST | `/workspace/{workspace_id}/static_host/{static_host}/build` | Create build |
|
|
21
|
+
| GET | `/workspace/{workspace_id}/static_host/{static_host}/build/{build_id}` | Get build |
|
|
22
|
+
| POST | `/workspace/{workspace_id}/static_host/{static_host}/build/{build_id}/env` | Deploy to environment |
|
|
23
|
+
| DELETE | `/workspace/{workspace_id}/static_host/{static_host}/build/{build_id}` | Delete build |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Files
|
|
28
|
+
|
|
29
|
+
## List Files
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
GET /workspace/{workspace_id}/file
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Query Parameters:**
|
|
36
|
+
| Parameter | Type | Default | Description |
|
|
37
|
+
|-----------|------|---------|-------------|
|
|
38
|
+
| `page` | int | 1 | Page number |
|
|
39
|
+
| `per_page` | int | 50 | Items per page (1-10000) |
|
|
40
|
+
| `search` | text | "" | Search by filename or MIME type |
|
|
41
|
+
| `access` | enum | "public" | Access level: "public", "private" |
|
|
42
|
+
| `sort` | enum | "created_at" | Sort: "created_at", "name", "size", "mime" |
|
|
43
|
+
| `order` | enum | "desc" | Sort order |
|
|
44
|
+
|
|
45
|
+
**Response Fields:**
|
|
46
|
+
| Field | Type | Description |
|
|
47
|
+
|-------|------|-------------|
|
|
48
|
+
| `id` | int | File unique identifier |
|
|
49
|
+
| `name` | text | Original filename |
|
|
50
|
+
| `size` | int | File size in bytes |
|
|
51
|
+
| `mime` | text | MIME type |
|
|
52
|
+
| `path` | text | Public URL path |
|
|
53
|
+
| `access` | enum | Access level |
|
|
54
|
+
| `created_at` | timestamp | Upload timestamp |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Upload File
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
POST /workspace/{workspace_id}/file
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Content-Type:** `multipart/form-data`
|
|
65
|
+
|
|
66
|
+
**Parameters:**
|
|
67
|
+
| Parameter | Type | Required | Default | Description |
|
|
68
|
+
|-----------|------|----------|---------|-------------|
|
|
69
|
+
| `content` | file | Yes | - | File to upload |
|
|
70
|
+
| `type` | enum | No | "" | Type hint: "image", "video", "audio" |
|
|
71
|
+
| `access` | enum | No | "public" | Access: "public", "private" |
|
|
72
|
+
|
|
73
|
+
**Notes:**
|
|
74
|
+
- Free tier users are restricted to image uploads only
|
|
75
|
+
- File size limits may apply based on plan
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Delete File
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
DELETE /workspace/{workspace_id}/file/{file_id}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Warning:** Cannot be undone.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Bulk Delete Files
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
DELETE /workspace/{workspace_id}/file/bulk_delete
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Parameters:**
|
|
96
|
+
| Parameter | Type | Required | Description |
|
|
97
|
+
|-----------|------|----------|-------------|
|
|
98
|
+
| `ids[]` | int[] | Yes | Array of file IDs to delete |
|
|
99
|
+
|
|
100
|
+
**Warning:** Cannot be undone.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
# Static Hosting
|
|
105
|
+
|
|
106
|
+
## List Static Hosts
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
GET /workspace/{workspace_id}/static_host
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Query Parameters:**
|
|
113
|
+
- `page` (int, default: 1): Page number
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## List Builds
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
GET /workspace/{workspace_id}/static_host/{static_host}/build
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Path Parameters:**
|
|
124
|
+
- `static_host` (text): Static host name
|
|
125
|
+
|
|
126
|
+
**Query Parameters:**
|
|
127
|
+
- `page` (int, default: 1): Page number
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Create Build
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
POST /workspace/{workspace_id}/static_host/{static_host}/build
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Upload a zip file to create a new build.
|
|
138
|
+
|
|
139
|
+
**Content-Type:** `multipart/form-data`
|
|
140
|
+
|
|
141
|
+
**Parameters:**
|
|
142
|
+
| Parameter | Type | Required | Default | Description |
|
|
143
|
+
|-----------|------|----------|---------|-------------|
|
|
144
|
+
| `file` | file | Yes | - | Zip archive of static site |
|
|
145
|
+
| `name` | text | Yes | - | Build name/version |
|
|
146
|
+
| `description` | text | No | "" | Build description |
|
|
147
|
+
|
|
148
|
+
**Response:**
|
|
149
|
+
Returns created build object with dev environment URL.
|
|
150
|
+
|
|
151
|
+
**Notes:**
|
|
152
|
+
- New builds are automatically deployed to `dev` environment
|
|
153
|
+
- Upload a zip file containing your static site files
|
|
154
|
+
- If `static_host` is "default" and doesn't exist, it will be created
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Get Build
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
GET /workspace/{workspace_id}/static_host/{static_host}/build/{build_id}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Deploy Build to Environment
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
POST /workspace/{workspace_id}/static_host/{static_host}/build/{build_id}/env
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Deploy a build to a specific environment.
|
|
173
|
+
|
|
174
|
+
**Parameters:**
|
|
175
|
+
| Parameter | Type | Required | Description |
|
|
176
|
+
|-----------|------|----------|-------------|
|
|
177
|
+
| `env` | enum | Yes | Environment: "prod", "dev" |
|
|
178
|
+
|
|
179
|
+
**Response:**
|
|
180
|
+
Returns the environment URL for the deployed build.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Delete Build
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
DELETE /workspace/{workspace_id}/static_host/{static_host}/build/{build_id}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Warning:** Cannot be undone.
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Function API
|
|
2
|
+
|
|
3
|
+
Functions are reusable code blocks that can be called from API endpoints, tasks, triggers, and other functions. They are defined using XanoScript.
|
|
4
|
+
|
|
5
|
+
## Endpoints Overview
|
|
6
|
+
|
|
7
|
+
| Method | Endpoint | Description |
|
|
8
|
+
|--------|----------|-------------|
|
|
9
|
+
| GET | `/workspace/{workspace_id}/function` | List functions |
|
|
10
|
+
| GET | `/workspace/{workspace_id}/function/{function_id}` | Get function |
|
|
11
|
+
| POST | `/workspace/{workspace_id}/function` | Create function |
|
|
12
|
+
| PUT | `/workspace/{workspace_id}/function/{function_id}` | Update function |
|
|
13
|
+
| DELETE | `/workspace/{workspace_id}/function/{function_id}` | Delete function |
|
|
14
|
+
| PUT | `/workspace/{workspace_id}/function/{function_id}/security` | Update security |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## List Functions
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
GET /workspace/{workspace_id}/function
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Query Parameters:**
|
|
25
|
+
| Parameter | Type | Default | Description |
|
|
26
|
+
|-----------|------|---------|-------------|
|
|
27
|
+
| `branch` | text | "" | Branch label |
|
|
28
|
+
| `page` | int | 1 | Page number |
|
|
29
|
+
| `per_page` | int | 50 | Items per page (1-10000) |
|
|
30
|
+
| `search` | text | "" | Search filter |
|
|
31
|
+
| `sort` | enum | "created_at" | Sort: "created_at", "updated_at", "name" |
|
|
32
|
+
| `order` | enum | "desc" | Sort order |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Get Function
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
GET /workspace/{workspace_id}/function/{function_id}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Returns function definition including XanoScript.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Create Function
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
POST /workspace/{workspace_id}/function
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Content-Type:** `text/x-xanoscript`
|
|
53
|
+
|
|
54
|
+
**Query Parameters:**
|
|
55
|
+
- `branch` (text): Target branch label
|
|
56
|
+
|
|
57
|
+
### XanoScript Function Syntax
|
|
58
|
+
|
|
59
|
+
```xanoscript
|
|
60
|
+
function foo {
|
|
61
|
+
input {
|
|
62
|
+
int score
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
stack {
|
|
66
|
+
var $x1 {
|
|
67
|
+
value = $input.score + 1
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
response = $x1
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Input Section
|
|
76
|
+
|
|
77
|
+
Define input parameters:
|
|
78
|
+
|
|
79
|
+
```xanoscript
|
|
80
|
+
input {
|
|
81
|
+
int required_param
|
|
82
|
+
text optional_param?
|
|
83
|
+
bool param_with_default? default = true
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
| Modifier | Syntax | Description |
|
|
88
|
+
|----------|--------|-------------|
|
|
89
|
+
| Required | `type name` | Parameter is required |
|
|
90
|
+
| Optional | `type name?` | Parameter is nullable |
|
|
91
|
+
| Default | `default = value` | Provides default value |
|
|
92
|
+
|
|
93
|
+
### Stack Section
|
|
94
|
+
|
|
95
|
+
The function logic using XanoScript statements:
|
|
96
|
+
|
|
97
|
+
```xanoscript
|
|
98
|
+
stack {
|
|
99
|
+
// Variable assignment
|
|
100
|
+
var $result {
|
|
101
|
+
value = $input.score * 2
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Database queries
|
|
105
|
+
db.query user {
|
|
106
|
+
where = $db.user.id == $input.user_id
|
|
107
|
+
return = {type: "single"}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Conditional logic
|
|
111
|
+
if $input.score > 10 {
|
|
112
|
+
var $bonus {
|
|
113
|
+
value = 100
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Loops
|
|
118
|
+
foreach $items as $item {
|
|
119
|
+
// Process each item
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Response
|
|
125
|
+
|
|
126
|
+
Define what the function returns:
|
|
127
|
+
|
|
128
|
+
```xanoscript
|
|
129
|
+
response = $result
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Complete Example
|
|
133
|
+
|
|
134
|
+
```xanoscript
|
|
135
|
+
function calculate_discount {
|
|
136
|
+
input {
|
|
137
|
+
float price
|
|
138
|
+
int quantity
|
|
139
|
+
text coupon_code?
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
stack {
|
|
143
|
+
var $base_discount {
|
|
144
|
+
value = 0
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Volume discount
|
|
148
|
+
if $input.quantity > 10 {
|
|
149
|
+
var $base_discount {
|
|
150
|
+
value = 0.1
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Coupon lookup
|
|
155
|
+
if $input.coupon_code != null {
|
|
156
|
+
db.query coupon {
|
|
157
|
+
where = $db.coupon.code == $input.coupon_code
|
|
158
|
+
return = {type: "single"}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if $coupon != null {
|
|
162
|
+
var $base_discount {
|
|
163
|
+
value = $base_discount + $coupon.discount
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
var $final_price {
|
|
169
|
+
value = $input.price * $input.quantity * (1 - $base_discount)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
response = {
|
|
174
|
+
original: $input.price * $input.quantity,
|
|
175
|
+
discount: $base_discount,
|
|
176
|
+
final: $final_price
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Update Function
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
PUT /workspace/{workspace_id}/function/{function_id}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Query Parameters:**
|
|
190
|
+
- `publish` (bool, default: true): Publish changes immediately
|
|
191
|
+
|
|
192
|
+
**Content-Type:** `text/x-xanoscript`
|
|
193
|
+
|
|
194
|
+
Send complete function definition.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Delete Function
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
DELETE /workspace/{workspace_id}/function/{function_id}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Warning:** This action cannot be undone. Any code calling this function will fail.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Update Function Security
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
PUT /workspace/{workspace_id}/function/{function_id}/security
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Parameters:**
|
|
215
|
+
| Parameter | Type | Required | Description |
|
|
216
|
+
|-----------|------|----------|-------------|
|
|
217
|
+
| `guid` | text | Yes | New security GUID |
|