@xano/developer-mcp 1.0.54 → 1.0.56
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/tools/xanoscript_docs.js +3 -3
- package/dist/xanoscript.js +17 -7
- package/dist/xanoscript.test.js +9 -7
- package/dist/xanoscript_docs/README.md +7 -7
- package/dist/xanoscript_docs/cheatsheet.md +4 -1
- package/dist/xanoscript_docs/database.md +2 -2
- package/dist/xanoscript_docs/docs_index.json +60 -53
- package/dist/xanoscript_docs/essentials.md +665 -0
- package/dist/xanoscript_docs/functions.md +1 -1
- package/dist/xanoscript_docs/middleware.md +5 -18
- package/dist/xanoscript_docs/quickstart.md +15 -6
- package/dist/xanoscript_docs/security.md +18 -43
- package/dist/xanoscript_docs/syntax/array-filters.md +238 -0
- package/dist/xanoscript_docs/syntax/functions.md +136 -0
- package/dist/xanoscript_docs/syntax/string-filters.md +188 -0
- package/dist/xanoscript_docs/syntax.md +92 -900
- package/dist/xanoscript_docs/triggers.md +1 -1
- package/dist/xanoscript_docs/types.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: ""
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# String Filters & Encoding
|
|
6
|
+
|
|
7
|
+
Complete reference for XanoScript string filters, regex, encoding, and security filters.
|
|
8
|
+
|
|
9
|
+
> **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.
|
|
10
|
+
|
|
11
|
+
## Quick Reference
|
|
12
|
+
|
|
13
|
+
### String Filters
|
|
14
|
+
|
|
15
|
+
| Filter | Example | Result |
|
|
16
|
+
|--------|---------|--------|
|
|
17
|
+
| `trim` | `" hi "\|trim` | `"hi"` |
|
|
18
|
+
| `ltrim` / `rtrim` | `" hi"\|ltrim` | `"hi"` |
|
|
19
|
+
| `to_lower` | `"Hi"\|to_lower` | `"hi"` |
|
|
20
|
+
| `to_upper` | `"Hi"\|to_upper` | `"HI"` |
|
|
21
|
+
| `capitalize` | `"hi there"\|capitalize` | `"Hi There"` |
|
|
22
|
+
| `strlen` | `"hello"\|strlen` | `5` |
|
|
23
|
+
| `substr` | `"hello"\|substr:1:3` | `"ell"` |
|
|
24
|
+
| `split` | `"a,b,c"\|split:","` | `["a","b","c"]` |
|
|
25
|
+
| `replace` | `"hello"\|replace:"l":"x"` | `"hexxo"` |
|
|
26
|
+
| `contains` | `"hello"\|contains:"ell"` | `true` |
|
|
27
|
+
| `starts_with` | `"hello"\|starts_with:"he"` | `true` |
|
|
28
|
+
| `ends_with` | `"hello"\|ends_with:"lo"` | `true` |
|
|
29
|
+
| `concat` | `"a"\|concat:"b":"-"` | `"a-b"` |
|
|
30
|
+
|
|
31
|
+
### Case-Insensitive Variants
|
|
32
|
+
|
|
33
|
+
`icontains`, `istarts_with`, `iends_with`, `iindex`
|
|
34
|
+
|
|
35
|
+
### Regex
|
|
36
|
+
|
|
37
|
+
```xs
|
|
38
|
+
"/pattern/"|regex_matches:"subject" // Boolean match
|
|
39
|
+
"/(\w+)/"|regex_get_first_match:"test" // First match
|
|
40
|
+
"/\w+/"|regex_get_all_matches:"a b c" // All matches
|
|
41
|
+
"/\s+/"|regex_replace:"-":"a b" // Replace: "a-b"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Text Functions
|
|
45
|
+
|
|
46
|
+
Statement-level functions for text manipulation within stacks. Functions that check a condition (e.g., `text.contains`, `text.starts_with`) store the result in an `as` variable. Functions that modify text (e.g., `text.trim`, `text.append`) mutate the variable directly.
|
|
47
|
+
|
|
48
|
+
### text.contains / text.icontains
|
|
49
|
+
|
|
50
|
+
```xs
|
|
51
|
+
text.contains $log_entry {
|
|
52
|
+
value = "error"
|
|
53
|
+
} as $has_error
|
|
54
|
+
|
|
55
|
+
text.icontains $description {
|
|
56
|
+
value = "error"
|
|
57
|
+
} as $has_error
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### text.starts_with / text.istarts_with
|
|
61
|
+
|
|
62
|
+
```xs
|
|
63
|
+
text.starts_with $message {
|
|
64
|
+
value = "Hello"
|
|
65
|
+
} as $starts_with_hello
|
|
66
|
+
|
|
67
|
+
text.istarts_with $title {
|
|
68
|
+
value = "intro"
|
|
69
|
+
} as $starts_with_intro
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### text.ends_with / text.iends_with
|
|
73
|
+
|
|
74
|
+
```xs
|
|
75
|
+
text.ends_with $url {
|
|
76
|
+
value = ".com"
|
|
77
|
+
} as $is_com_domain
|
|
78
|
+
|
|
79
|
+
text.iends_with $filename {
|
|
80
|
+
value = "pdf"
|
|
81
|
+
} as $ends_with_pdf
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### text.trim / text.ltrim / text.rtrim
|
|
85
|
+
|
|
86
|
+
Removes characters (default is whitespace, or as specified by `value`). Mutates the variable directly.
|
|
87
|
+
|
|
88
|
+
```xs
|
|
89
|
+
text.trim $user_input { value = " " }
|
|
90
|
+
text.ltrim $user_input { value = " " }
|
|
91
|
+
text.rtrim $user_input { value = " " }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### text.append / text.prepend
|
|
95
|
+
|
|
96
|
+
Mutates the variable directly.
|
|
97
|
+
|
|
98
|
+
```xs
|
|
99
|
+
text.append $greeting { value = ", welcome!" }
|
|
100
|
+
text.prepend $message { value = "Alert: " }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Text Domain Functions
|
|
104
|
+
|
|
105
|
+
Functional equivalents for string operations:
|
|
106
|
+
|
|
107
|
+
```xs
|
|
108
|
+
text.contains("hello world", "world") // true
|
|
109
|
+
text.starts_with("hello", "he") // true
|
|
110
|
+
text.ends_with("hello", "lo") // true
|
|
111
|
+
text.icontains("Hello World", "WORLD") // true (case-insensitive)
|
|
112
|
+
text.istarts_with("Hello", "HE") // true
|
|
113
|
+
text.iends_with("Hello", "LO") // true
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Encoding Filters
|
|
117
|
+
|
|
118
|
+
| Filter | Example |
|
|
119
|
+
|--------|---------|
|
|
120
|
+
| `json_encode` | `{a:1}\|json_encode` |
|
|
121
|
+
| `json_decode` | `'{"a":1}'\|json_decode` |
|
|
122
|
+
| `base64_encode` | `"hello"\|base64_encode` |
|
|
123
|
+
| `base64_decode` | `"aGVsbG8="\|base64_decode` |
|
|
124
|
+
| `url_encode` | `"a b"\|url_encode` |
|
|
125
|
+
| `url_decode` | `"a%20b"\|url_decode` |
|
|
126
|
+
| `xml_decode` | `"<a>1</a>"\|xml_decode` |
|
|
127
|
+
| `yaml_encode` / `yaml_decode` | YAML conversion |
|
|
128
|
+
| `hex2bin` / `bin2hex` | Hex conversion |
|
|
129
|
+
|
|
130
|
+
### Character Encoding
|
|
131
|
+
|
|
132
|
+
| Filter | Description | Example |
|
|
133
|
+
|--------|-------------|---------|
|
|
134
|
+
| `list_encodings` | List available encodings | `\|list_encodings` |
|
|
135
|
+
| `detect_encoding` | Detect string encoding | `$text\|detect_encoding` |
|
|
136
|
+
| `to_utf8` | Convert to UTF-8 | `$text\|to_utf8` |
|
|
137
|
+
| `from_utf8` | Convert from UTF-8 | `$text\|from_utf8:"ISO-8859-1"` |
|
|
138
|
+
| `convert_encoding` | Convert encodings | `$text\|convert_encoding:"UTF-8":"ISO-8859-1"` |
|
|
139
|
+
|
|
140
|
+
### CSV & Query String
|
|
141
|
+
|
|
142
|
+
```xs
|
|
143
|
+
$csv_text|csv_parse // Parse CSV string
|
|
144
|
+
$data|csv_create // Create CSV string
|
|
145
|
+
"a=1&b=2"|querystring_parse // {a: "1", b: "2"}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### String Escape Filters
|
|
149
|
+
|
|
150
|
+
| Filter | Description |
|
|
151
|
+
|--------|-------------|
|
|
152
|
+
| `addslashes` | Escape quotes and backslashes |
|
|
153
|
+
| `escape` | HTML escape |
|
|
154
|
+
| `text_escape` | Escape for text output |
|
|
155
|
+
| `text_unescape` | Unescape text |
|
|
156
|
+
| `regex_quote` | Escape regex special characters |
|
|
157
|
+
|
|
158
|
+
```xs
|
|
159
|
+
"Hello \"World\""|addslashes // "Hello \\\"World\\\""
|
|
160
|
+
"<script>"|escape // "<script>"
|
|
161
|
+
"^test$"|regex_quote // "\^test\$"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Security Filters
|
|
165
|
+
|
|
166
|
+
> **Full reference:** See `xanoscript_docs({ topic: "security" })` for security best practices.
|
|
167
|
+
|
|
168
|
+
| Filter | Example |
|
|
169
|
+
|--------|---------|
|
|
170
|
+
| `md5` | `"text"\|md5` |
|
|
171
|
+
| `sha1` / `sha256` / `sha512` | Hash functions |
|
|
172
|
+
| `hmac_sha256` | `"msg"\|hmac_sha256:"key"` |
|
|
173
|
+
| `encrypt` | `"data"\|encrypt:"aes-256-cbc":"key":"iv"` |
|
|
174
|
+
| `decrypt` | `$enc\|decrypt:"aes-256-cbc":"key":"iv"` |
|
|
175
|
+
| `jws_encode` / `jws_decode` | JWT signing |
|
|
176
|
+
| `jwe_encode` / `jwe_decode` | JWT encryption |
|
|
177
|
+
| `secureid_encode` / `secureid_decode` | ID obfuscation |
|
|
178
|
+
| `uuid` | `\|uuid` |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Related Topics
|
|
183
|
+
|
|
184
|
+
| Topic | Description |
|
|
185
|
+
|-------|-------------|
|
|
186
|
+
| `syntax` | Core operators, conditionals, type filters, error handling |
|
|
187
|
+
| `syntax/array-filters` | Array filters and array functions |
|
|
188
|
+
| `syntax/functions` | Math and object functions |
|