@xano/developer-mcp 1.0.38 → 1.0.39
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/dist/xanoscript_docs/syntax.md +39 -15
- package/package.json +1 -1
|
@@ -27,24 +27,40 @@ Complete reference for XanoScript expressions, operators, and filters.
|
|
|
27
27
|
| [Error Handling](#error-handling) | `precondition`, `try_catch`, `throw` |
|
|
28
28
|
| [System Variables](#system-variables) | `$env.*`, `$auth.*`, request context |
|
|
29
29
|
|
|
30
|
+
## CRITICAL: Filters Are Type-Specific
|
|
31
|
+
|
|
32
|
+
> **Filters only work on the correct input type.** String filters and array filters are NOT interchangeable. Using the wrong filter type will produce errors or incorrect results.
|
|
33
|
+
|
|
34
|
+
| Task | WRONG (type mismatch) | CORRECT |
|
|
35
|
+
|------|----------------------|---------|
|
|
36
|
+
| Get string length | `$text\|count` | `$text\|strlen` |
|
|
37
|
+
| Get array length | `$arr\|strlen` | `$arr\|count` |
|
|
38
|
+
| Reverse a string | `$text\|reverse` | `$text\|split:""\|reverse\|join:""` |
|
|
39
|
+
| Reverse an array | Use `reverse` directly | `$arr\|reverse` |
|
|
40
|
+
| Check string has substring | `$text\|some:...` | `$text\|contains:"sub"` |
|
|
41
|
+
| Check array has element | `$arr\|contains:$val` (db only) | `$arr\|some:$$==$val` |
|
|
42
|
+
| Get part of string | `$text\|slice:0:3` | `$text\|substr:0:3` |
|
|
43
|
+
| Get part of array | `$arr\|substr:0:3` | `$arr\|slice:0:3` |
|
|
44
|
+
|
|
30
45
|
## Choosing a Filter
|
|
31
46
|
|
|
32
47
|
```
|
|
33
48
|
Working with...
|
|
34
|
-
├── Strings?
|
|
49
|
+
├── Strings? → USE STRING FILTERS ONLY (see String Filters section)
|
|
35
50
|
│ ├── Clean whitespace? → trim, ltrim, rtrim
|
|
36
51
|
│ ├── Change case? → to_lower, to_upper, capitalize
|
|
37
|
-
│ ├── Extract part? → substr
|
|
52
|
+
│ ├── Extract part? → substr (NOT slice)
|
|
38
53
|
│ ├── Split to array? → split
|
|
39
54
|
│ ├── Find/replace? → replace, contains
|
|
40
|
-
│ └── Get length? → strlen
|
|
41
|
-
├── Arrays?
|
|
55
|
+
│ └── Get length? → strlen (NOT count)
|
|
56
|
+
├── Arrays? → USE ARRAY FILTERS ONLY (see Array Filters section)
|
|
42
57
|
│ ├── Get element? → first, last, get
|
|
43
|
-
│ ├── Count items? → count
|
|
58
|
+
│ ├── Count items? → count (NOT strlen)
|
|
44
59
|
│ ├── Transform all? → map
|
|
45
60
|
│ ├── Keep some? → filter
|
|
46
61
|
│ ├── Find one? → find
|
|
47
62
|
│ ├── Combine? → reduce
|
|
63
|
+
│ ├── Reverse? → reverse (NOT available on strings)
|
|
48
64
|
│ └── Sort? → sort
|
|
49
65
|
├── Objects?
|
|
50
66
|
│ ├── Get value? → get
|
|
@@ -74,16 +90,20 @@ Working with...
|
|
|
74
90
|
| Null-safe | `==?`, `!=?`, `>=?`, `<=?` (ignore if null) |
|
|
75
91
|
|
|
76
92
|
### Common Filters
|
|
77
|
-
| Filter | Purpose | Example |
|
|
78
|
-
|
|
79
|
-
| `trim` | Remove whitespace | `$s\|trim` |
|
|
80
|
-
| `to_lower` / `to_upper` | Case conversion | `$s\|to_lower` |
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
93
|
+
| Filter | Type | Purpose | Example |
|
|
94
|
+
|--------|------|---------|---------|
|
|
95
|
+
| `trim` | STRING | Remove whitespace | `$s\|trim` |
|
|
96
|
+
| `to_lower` / `to_upper` | STRING | Case conversion | `$s\|to_lower` |
|
|
97
|
+
| `strlen` | STRING | String length | `$s\|strlen` |
|
|
98
|
+
| `substr` | STRING | Extract substring | `$s\|substr:0:5` |
|
|
99
|
+
| `first` / `last` | ARRAY | Array endpoints | `$arr\|first` |
|
|
100
|
+
| `count` | ARRAY | Array length | `$arr\|count` |
|
|
101
|
+
| `slice` | ARRAY | Extract sub-array | `$arr\|slice:0:3` |
|
|
102
|
+
| `reverse` | ARRAY | Reverse array | `$arr\|reverse` |
|
|
103
|
+
| `get` | OBJECT | Object property | `$obj\|get:"key"` |
|
|
104
|
+
| `set` | OBJECT | Set property | `$obj\|set:"key":"val"` |
|
|
105
|
+
| `json_encode` / `json_decode` | ANY | JSON conversion | `$obj\|json_encode` |
|
|
106
|
+
| `to_text` / `to_int` | ANY | Type conversion | `$num\|to_text` |
|
|
87
107
|
|
|
88
108
|
> **Note:** There is no `default` filter. Use conditional blocks or `first_notnull`/`first_notempty` instead.
|
|
89
109
|
|
|
@@ -213,6 +233,8 @@ $db.post.date >=? $input.start_date
|
|
|
213
233
|
|
|
214
234
|
## String Filters
|
|
215
235
|
|
|
236
|
+
> **These filters operate on STRING values only.** Do not use array filters (`count`, `reverse`, `first`, `last`, `slice`) on strings. Use `strlen` for string length, `substr` for substrings.
|
|
237
|
+
|
|
216
238
|
| Filter | Example | Result |
|
|
217
239
|
|--------|---------|--------|
|
|
218
240
|
| `trim` | `" hi "\|trim` | `"hi"` |
|
|
@@ -244,6 +266,8 @@ $db.post.date >=? $input.start_date
|
|
|
244
266
|
|
|
245
267
|
## Array Filters
|
|
246
268
|
|
|
269
|
+
> **These filters operate on ARRAY values only.** Do not use string filters (`strlen`, `substr`, `split`, `replace`) on arrays. Use `count` for array length, `slice` for sub-arrays, `join` to convert to string.
|
|
270
|
+
|
|
247
271
|
| Filter | Example | Result |
|
|
248
272
|
|--------|---------|--------|
|
|
249
273
|
| `first` | `[1,2,3]\|first` | `1` |
|
package/package.json
CHANGED