@xano/developer-mcp 1.0.25 → 1.0.27
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 +50 -0
- package/dist/cli_docs/format.d.ts +12 -0
- package/dist/cli_docs/format.js +98 -0
- package/dist/{api_docs → cli_docs}/index.d.ts +6 -11
- package/dist/cli_docs/index.js +86 -0
- package/dist/cli_docs/topics/function.js +114 -0
- package/dist/cli_docs/topics/integration.d.ts +2 -0
- package/dist/cli_docs/topics/integration.js +157 -0
- package/dist/{api_docs/topics/agent.d.ts → cli_docs/topics/profile.d.ts} +1 -1
- package/dist/cli_docs/topics/profile.js +153 -0
- package/dist/{api_docs/topics/api.d.ts → cli_docs/topics/run.d.ts} +1 -1
- package/dist/cli_docs/topics/run.js +248 -0
- package/dist/cli_docs/topics/start.js +111 -0
- package/dist/cli_docs/topics/static_host.d.ts +2 -0
- package/dist/cli_docs/topics/static_host.js +77 -0
- package/dist/cli_docs/topics/workspace.js +119 -0
- package/dist/cli_docs/types.d.ts +44 -0
- package/dist/cli_docs/types.js +4 -0
- package/dist/index.js +42 -0
- package/dist/xanoscript_docs/README.md +78 -64
- 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 +43 -71
- package/dist/xanoscript_docs/performance.md +14 -23
- package/dist/xanoscript_docs/tables.md +47 -1
- package/dist/xanoscript_docs/tools.md +9 -7
- package/dist/xanoscript_docs/types.md +12 -10
- package/package.json +1 -1
- package/dist/api_docs/format.d.ts +0 -5
- package/dist/api_docs/format.js +0 -171
- package/dist/api_docs/index.js +0 -111
- package/dist/api_docs/topics/agent.js +0 -142
- 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.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.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.js +0 -153
- package/dist/api_docs/types.d.ts +0 -79
- package/dist/api_docs/types.js +0 -4
- 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/xanoscript_docs/ephemeral.md +0 -330
- 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
- /package/dist/{api_docs → cli_docs}/topics/function.d.ts +0 -0
- /package/dist/{api_docs → cli_docs}/topics/start.d.ts +0 -0
- /package/dist/{api_docs → cli_docs}/topics/workspace.d.ts +0 -0
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "functions/**/*.xs"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Functions
|
|
6
|
-
|
|
7
|
-
Reusable function stacks with inputs, processing logic, and responses.
|
|
8
|
-
|
|
9
|
-
## Quick Reference
|
|
10
|
-
|
|
11
|
-
```xs
|
|
12
|
-
function "<name>" {
|
|
13
|
-
input {
|
|
14
|
-
text name
|
|
15
|
-
int? age
|
|
16
|
-
}
|
|
17
|
-
stack {
|
|
18
|
-
// Processing logic
|
|
19
|
-
var $result { value = $input.name|to_upper }
|
|
20
|
-
}
|
|
21
|
-
response = $result
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Function Invocation
|
|
26
|
-
```xs
|
|
27
|
-
function.run "<name>" {
|
|
28
|
-
input = { name: "John", age: 25 }
|
|
29
|
-
} as $result
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Function Definition
|
|
35
|
-
|
|
36
|
-
### Basic Function
|
|
37
|
-
|
|
38
|
-
```xs
|
|
39
|
-
function "greet" {
|
|
40
|
-
input {
|
|
41
|
-
text name filters=trim
|
|
42
|
-
}
|
|
43
|
-
stack {
|
|
44
|
-
var $greeting {
|
|
45
|
-
value = "Hello, " ~ $input.name ~ "!"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
response = $greeting
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Function with Optional Inputs
|
|
53
|
-
|
|
54
|
-
```xs
|
|
55
|
-
function "calculate_total" {
|
|
56
|
-
input {
|
|
57
|
-
decimal price
|
|
58
|
-
int quantity default=1
|
|
59
|
-
decimal? discount
|
|
60
|
-
}
|
|
61
|
-
stack {
|
|
62
|
-
var $subtotal {
|
|
63
|
-
value = $input.price * $input.quantity
|
|
64
|
-
}
|
|
65
|
-
var $total {
|
|
66
|
-
value = $input.discount != null
|
|
67
|
-
? $subtotal - $input.discount
|
|
68
|
-
: $subtotal
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
response = $total
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Function with Complex Response
|
|
76
|
-
|
|
77
|
-
```xs
|
|
78
|
-
function "get_user_summary" {
|
|
79
|
-
input {
|
|
80
|
-
int user_id
|
|
81
|
-
}
|
|
82
|
-
stack {
|
|
83
|
-
db.get user {
|
|
84
|
-
field_name = "id"
|
|
85
|
-
field_value = $input.user_id
|
|
86
|
-
} as $user
|
|
87
|
-
|
|
88
|
-
db.query order {
|
|
89
|
-
where = $db.order.user_id == $input.user_id
|
|
90
|
-
return = {type: "count"}
|
|
91
|
-
} as $order_count
|
|
92
|
-
}
|
|
93
|
-
response = {
|
|
94
|
-
user: $user,
|
|
95
|
-
total_orders: $order_count
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## Calling Functions
|
|
103
|
-
|
|
104
|
-
### Basic Call
|
|
105
|
-
|
|
106
|
-
```xs
|
|
107
|
-
function.run "greet" {
|
|
108
|
-
input = {name: "Alice"}
|
|
109
|
-
} as $greeting
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### With Dynamic Input
|
|
113
|
-
|
|
114
|
-
```xs
|
|
115
|
-
function.run "calculate_total" {
|
|
116
|
-
input = {
|
|
117
|
-
price: $input.price,
|
|
118
|
-
quantity: $input.qty,
|
|
119
|
-
discount: $input.coupon_value
|
|
120
|
-
}
|
|
121
|
-
} as $total
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Error Handling
|
|
125
|
-
|
|
126
|
-
```xs
|
|
127
|
-
try_catch {
|
|
128
|
-
try {
|
|
129
|
-
function.run "risky_operation" {
|
|
130
|
-
input = {data: $input.data}
|
|
131
|
-
} as $result
|
|
132
|
-
}
|
|
133
|
-
catch {
|
|
134
|
-
var $result { value = null }
|
|
135
|
-
debug.log { value = "Operation failed: " ~ $error.message }
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## Function Blocks
|
|
143
|
-
|
|
144
|
-
### Input Block
|
|
145
|
-
|
|
146
|
-
Define typed parameters with validation:
|
|
147
|
-
|
|
148
|
-
```xs
|
|
149
|
-
input {
|
|
150
|
-
// Required parameters
|
|
151
|
-
text name filters=trim|min:1|max:100
|
|
152
|
-
email user_email filters=trim|lower
|
|
153
|
-
int quantity filters=min:1
|
|
154
|
-
|
|
155
|
-
// Optional parameters
|
|
156
|
-
text? notes
|
|
157
|
-
int? priority default=1
|
|
158
|
-
|
|
159
|
-
// Complex types
|
|
160
|
-
json metadata
|
|
161
|
-
array<text> tags
|
|
162
|
-
file attachment
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Stack Block
|
|
167
|
-
|
|
168
|
-
Container for sequential operations:
|
|
169
|
-
|
|
170
|
-
```xs
|
|
171
|
-
stack {
|
|
172
|
-
// Variables
|
|
173
|
-
var $count { value = 0 }
|
|
174
|
-
|
|
175
|
-
// Database operations
|
|
176
|
-
db.query user {} as $users
|
|
177
|
-
|
|
178
|
-
// Control flow
|
|
179
|
-
conditional {
|
|
180
|
-
if ($users|count > 0) {
|
|
181
|
-
var.update $count { value = $users|count }
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Function calls
|
|
186
|
-
function.run "helper" {
|
|
187
|
-
input = {data: $users}
|
|
188
|
-
} as $processed
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Response Block
|
|
193
|
-
|
|
194
|
-
Define the return value:
|
|
195
|
-
|
|
196
|
-
```xs
|
|
197
|
-
// Simple response
|
|
198
|
-
response = $result
|
|
199
|
-
|
|
200
|
-
// Object response
|
|
201
|
-
response = {
|
|
202
|
-
data: $users,
|
|
203
|
-
count: $total,
|
|
204
|
-
page: $input.page
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Conditional response
|
|
208
|
-
response = $success ? $data : null
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## Async Operations
|
|
214
|
-
|
|
215
|
-
### Sequential Execution
|
|
216
|
-
|
|
217
|
-
```xs
|
|
218
|
-
stack {
|
|
219
|
-
// These run in sequence
|
|
220
|
-
function.run "step1" { input = {} } as $r1
|
|
221
|
-
function.run "step2" { input = {prev: $r1} } as $r2
|
|
222
|
-
function.run "step3" { input = {prev: $r2} } as $r3
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Parallel Execution
|
|
227
|
-
|
|
228
|
-
Use array operations for parallel processing:
|
|
229
|
-
|
|
230
|
-
```xs
|
|
231
|
-
stack {
|
|
232
|
-
var $ids { value = [1, 2, 3, 4, 5] }
|
|
233
|
-
|
|
234
|
-
array.map {
|
|
235
|
-
array = $ids
|
|
236
|
-
run {
|
|
237
|
-
function.run "process_item" {
|
|
238
|
-
input = {id: $this}
|
|
239
|
-
} as $result
|
|
240
|
-
}
|
|
241
|
-
} as $results
|
|
242
|
-
}
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## Loops in Functions
|
|
248
|
-
|
|
249
|
-
### For Loop (Fixed Count)
|
|
250
|
-
|
|
251
|
-
```xs
|
|
252
|
-
for (10) {
|
|
253
|
-
each as $index {
|
|
254
|
-
var.update $total { value = $total + $index }
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### Foreach Loop (Array Iteration)
|
|
260
|
-
|
|
261
|
-
```xs
|
|
262
|
-
foreach ($input.items) {
|
|
263
|
-
each as $item {
|
|
264
|
-
function.run "process" {
|
|
265
|
-
input = {item: $item}
|
|
266
|
-
} as $processed
|
|
267
|
-
|
|
268
|
-
array.push {
|
|
269
|
-
array = $results
|
|
270
|
-
value = $processed
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### While Loop (Condition)
|
|
277
|
-
|
|
278
|
-
```xs
|
|
279
|
-
var $counter { value = 0 }
|
|
280
|
-
var $max { value = 10 }
|
|
281
|
-
|
|
282
|
-
while ($counter < $max) {
|
|
283
|
-
each {
|
|
284
|
-
var.update $counter { value = $counter + 1 }
|
|
285
|
-
// Process iteration
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## Testing Functions
|
|
293
|
-
|
|
294
|
-
### Test Block
|
|
295
|
-
|
|
296
|
-
```xs
|
|
297
|
-
function "add_numbers" {
|
|
298
|
-
input {
|
|
299
|
-
int a
|
|
300
|
-
int b
|
|
301
|
-
}
|
|
302
|
-
stack {
|
|
303
|
-
var $sum { value = $input.a + $input.b }
|
|
304
|
-
}
|
|
305
|
-
response = $sum
|
|
306
|
-
|
|
307
|
-
test "adds positive numbers" {
|
|
308
|
-
function.call {
|
|
309
|
-
input = {a: 2, b: 3}
|
|
310
|
-
} as $result
|
|
311
|
-
|
|
312
|
-
expect.to_equal {
|
|
313
|
-
input = $result
|
|
314
|
-
value = 5
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
test "handles zero" {
|
|
319
|
-
function.call {
|
|
320
|
-
input = {a: 5, b: 0}
|
|
321
|
-
} as $result
|
|
322
|
-
|
|
323
|
-
expect.to_equal {
|
|
324
|
-
input = $result
|
|
325
|
-
value = 5
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### Assertions
|
|
332
|
-
|
|
333
|
-
```xs
|
|
334
|
-
expect.to_be_true { input = $value }
|
|
335
|
-
expect.to_be_false { input = $value }
|
|
336
|
-
expect.to_equal { input = $a, value = $b }
|
|
337
|
-
expect.to_not_equal { input = $a, value = $b }
|
|
338
|
-
expect.to_be_null { input = $value }
|
|
339
|
-
expect.to_not_be_null { input = $value }
|
|
340
|
-
expect.to_contain { input = $array, value = $item }
|
|
341
|
-
expect.to_be_greater_than { input = $a, value = $b }
|
|
342
|
-
expect.to_be_less_than { input = $a, value = $b }
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
---
|
|
346
|
-
|
|
347
|
-
## Function Best Practices
|
|
348
|
-
|
|
349
|
-
### Keep Functions Focused
|
|
350
|
-
|
|
351
|
-
```xs
|
|
352
|
-
// Good: Single responsibility
|
|
353
|
-
function "validate_email" {
|
|
354
|
-
input { email value }
|
|
355
|
-
stack {
|
|
356
|
-
var $valid {
|
|
357
|
-
value = $input.value|regex_matches:"^[^@]+@[^@]+\.[^@]+$"
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
response = $valid
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Good: Compose small functions
|
|
364
|
-
function "process_user" {
|
|
365
|
-
input { json user_data }
|
|
366
|
-
stack {
|
|
367
|
-
function.run "validate_email" {
|
|
368
|
-
input = {value: $input.user_data.email}
|
|
369
|
-
} as $email_valid
|
|
370
|
-
|
|
371
|
-
function.run "validate_name" {
|
|
372
|
-
input = {value: $input.user_data.name}
|
|
373
|
-
} as $name_valid
|
|
374
|
-
}
|
|
375
|
-
response = {
|
|
376
|
-
valid: $email_valid && $name_valid
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Use Descriptive Names
|
|
382
|
-
|
|
383
|
-
```xs
|
|
384
|
-
// Good naming
|
|
385
|
-
function "calculate_order_total" { ... }
|
|
386
|
-
function "send_welcome_email" { ... }
|
|
387
|
-
function "generate_invoice_pdf" { ... }
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
### Handle Errors Gracefully
|
|
391
|
-
|
|
392
|
-
```xs
|
|
393
|
-
function "fetch_user" {
|
|
394
|
-
input { int user_id }
|
|
395
|
-
stack {
|
|
396
|
-
db.get user {
|
|
397
|
-
field_name = "id"
|
|
398
|
-
field_value = $input.user_id
|
|
399
|
-
} as $user
|
|
400
|
-
|
|
401
|
-
precondition ($user != null) {
|
|
402
|
-
error_type = "notfound"
|
|
403
|
-
error = "User not found"
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
response = $user
|
|
407
|
-
}
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
---
|
|
411
|
-
|
|
412
|
-
## Function Documentation
|
|
413
|
-
|
|
414
|
-
Add descriptions to your functions:
|
|
415
|
-
|
|
416
|
-
```xs
|
|
417
|
-
function "create_invoice" {
|
|
418
|
-
description = "Creates an invoice for an order and sends email notification"
|
|
419
|
-
|
|
420
|
-
input {
|
|
421
|
-
int order_id description="The order to invoice"
|
|
422
|
-
bool? send_email description="Whether to send email" default=true
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
stack {
|
|
426
|
-
// Implementation
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
response = $invoice
|
|
430
|
-
}
|
|
431
|
-
```
|