@xano/developer-mcp 1.0.1 → 1.0.2
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 +96 -31
- package/dist/index.js +248 -180
- package/package.json +4 -2
- package/xanoscript_docs/README.md +107 -1
- package/xanoscript_docs/agents.md +329 -0
- package/xanoscript_docs/apis.md +343 -0
- package/xanoscript_docs/database.md +417 -0
- package/xanoscript_docs/ephemeral.md +333 -0
- package/xanoscript_docs/frontend.md +291 -0
- package/xanoscript_docs/functions.md +232 -2035
- package/xanoscript_docs/integrations.md +439 -0
- package/xanoscript_docs/mcp-servers.md +190 -0
- package/xanoscript_docs/plan.md +192 -0
- package/xanoscript_docs/syntax.md +314 -0
- package/xanoscript_docs/tables.md +270 -0
- package/xanoscript_docs/tasks.md +254 -0
- package/xanoscript_docs/testing.md +335 -0
- package/xanoscript_docs/tools.md +305 -0
- package/xanoscript_docs/types.md +297 -0
- package/xanoscript_docs/version.json +2 -1
- package/xanoscript_docs/api_query_examples.md +0 -1255
- package/xanoscript_docs/api_query_guideline.md +0 -129
- package/xanoscript_docs/build_from_lovable.md +0 -715
- package/xanoscript_docs/db_query_guideline.md +0 -427
- package/xanoscript_docs/ephemeral_environment_guideline.md +0 -529
- package/xanoscript_docs/expression_guideline.md +0 -1086
- package/xanoscript_docs/frontend_guideline.md +0 -67
- package/xanoscript_docs/function_examples.md +0 -1406
- package/xanoscript_docs/function_guideline.md +0 -130
- package/xanoscript_docs/input_guideline.md +0 -227
- package/xanoscript_docs/mcp_server_examples.md +0 -36
- package/xanoscript_docs/mcp_server_guideline.md +0 -69
- package/xanoscript_docs/query_filter.md +0 -489
- package/xanoscript_docs/table_examples.md +0 -586
- package/xanoscript_docs/table_guideline.md +0 -137
- package/xanoscript_docs/task_examples.md +0 -511
- package/xanoscript_docs/task_guideline.md +0 -103
- package/xanoscript_docs/tips_and_tricks.md +0 -144
- package/xanoscript_docs/tool_examples.md +0 -69
- package/xanoscript_docs/tool_guideline.md +0 -139
- package/xanoscript_docs/unit_testing_guideline.md +0 -328
- package/xanoscript_docs/workspace.md +0 -17
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# XanoScript AI Documentation v2 - Implementation Plan
|
|
2
|
+
|
|
3
|
+
## Design Principles
|
|
4
|
+
|
|
5
|
+
### AI-First Documentation Goals
|
|
6
|
+
1. **Scannable** - AI can quickly locate relevant syntax/patterns
|
|
7
|
+
2. **Self-contained** - Each doc has everything needed for its topic
|
|
8
|
+
3. **Pattern-consistent** - Identical structure across all docs
|
|
9
|
+
4. **Minimal but complete** - Not verbose, but covers all cases
|
|
10
|
+
5. **Examples inline** - Code immediately follows syntax it demonstrates
|
|
11
|
+
|
|
12
|
+
### Document Structure Template
|
|
13
|
+
Every doc follows this structure:
|
|
14
|
+
```
|
|
15
|
+
---
|
|
16
|
+
applyTo: "<glob pattern>"
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# <Topic>
|
|
20
|
+
|
|
21
|
+
## Quick Reference
|
|
22
|
+
<Table or code block with syntax summary>
|
|
23
|
+
|
|
24
|
+
## Overview
|
|
25
|
+
<1-2 paragraph explanation>
|
|
26
|
+
|
|
27
|
+
## <Concept 1>
|
|
28
|
+
### Syntax
|
|
29
|
+
### Example
|
|
30
|
+
### Notes
|
|
31
|
+
|
|
32
|
+
## <Concept 2>
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
## Best Practices
|
|
36
|
+
<Bullet list>
|
|
37
|
+
|
|
38
|
+
## Common Patterns
|
|
39
|
+
<Real-world usage patterns>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Proposed File Structure
|
|
45
|
+
|
|
46
|
+
### Core (Required for any XanoScript work)
|
|
47
|
+
| File | Purpose | Source Files |
|
|
48
|
+
|------|---------|--------------|
|
|
49
|
+
| `README.md` | Overview, workspace structure, getting started | README.md, workspace.md |
|
|
50
|
+
| `syntax.md` | Expressions, operators, filters | expression_guideline.md, query_filter.md |
|
|
51
|
+
| `types.md` | Data types, input blocks, validation | input_guideline.md, functions.md (input section) |
|
|
52
|
+
|
|
53
|
+
### Primary Constructs
|
|
54
|
+
| File | Purpose | Source Files |
|
|
55
|
+
|------|---------|--------------|
|
|
56
|
+
| `tables.md` | Database schemas, indexes, relationships | table_guideline.md, table_examples.md |
|
|
57
|
+
| `functions.md` | Reusable function stacks | function_guideline.md, function_examples.md |
|
|
58
|
+
| `apis.md` | HTTP API endpoints | api_query_guideline.md, api_query_examples.md |
|
|
59
|
+
| `tasks.md` | Scheduled jobs | task_guideline.md, task_examples.md |
|
|
60
|
+
| `database.md` | All db.* operations | db_query_guideline.md, functions.md (db section) |
|
|
61
|
+
|
|
62
|
+
### AI Integration
|
|
63
|
+
| File | Purpose | Source Files |
|
|
64
|
+
|------|---------|--------------|
|
|
65
|
+
| `agents.md` | AI agents, LLM providers | agent_guideline.md, agent_examples.md |
|
|
66
|
+
| `tools.md` | AI tools for agents/MCP | tool_guideline.md, tool_examples.md |
|
|
67
|
+
| `mcp-servers.md` | MCP server configuration | mcp_server_guideline.md, mcp_server_examples.md |
|
|
68
|
+
|
|
69
|
+
### Advanced Features
|
|
70
|
+
| File | Purpose | Source Files |
|
|
71
|
+
|------|---------|--------------|
|
|
72
|
+
| `testing.md` | Unit tests, mocks, assertions | unit_testing_guideline.md |
|
|
73
|
+
| `integrations.md` | Cloud, Redis, storage, security | functions.md (cloud/redis/security sections) |
|
|
74
|
+
| `frontend.md` | Static frontend, Lovable migration | frontend_guideline.md, build_from_lovable.md |
|
|
75
|
+
| `ephemeral.md` | Ephemeral services and jobs | ephemeral_environment_guideline.md |
|
|
76
|
+
|
|
77
|
+
### Reference (Optional)
|
|
78
|
+
| File | Purpose | Source Files |
|
|
79
|
+
|------|---------|--------------|
|
|
80
|
+
| `tips.md` | Tips, tricks, gotchas | tips_and_tricks.md |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Content Reduction Strategy
|
|
85
|
+
|
|
86
|
+
### V1 Verbosity Issues
|
|
87
|
+
1. **Redundant examples** - Multiple examples showing same pattern
|
|
88
|
+
2. **Explanation repetition** - Same concept explained in guideline AND examples
|
|
89
|
+
3. **Over-commented code** - Examples have excessive inline comments
|
|
90
|
+
4. **Separate files** - guideline.md + examples.md = duplication
|
|
91
|
+
|
|
92
|
+
### V2 Approach
|
|
93
|
+
1. **One canonical example** per feature (not 3-5)
|
|
94
|
+
2. **Table-based syntax reference** - Quick scan, no prose
|
|
95
|
+
3. **Inline examples** - Example immediately after syntax
|
|
96
|
+
4. **Comments only for non-obvious** - Trust the reader
|
|
97
|
+
|
|
98
|
+
### Example Transformation
|
|
99
|
+
|
|
100
|
+
**V1 Style (verbose):**
|
|
101
|
+
```xs
|
|
102
|
+
// This function calculates the total cost
|
|
103
|
+
// by multiplying quantity by price per item
|
|
104
|
+
// and returns the result
|
|
105
|
+
function "maths/calculate_total" {
|
|
106
|
+
description = "Calculate the total cost based on quantity and price per item"
|
|
107
|
+
|
|
108
|
+
input {
|
|
109
|
+
int quantity filters=min:0 {
|
|
110
|
+
description = "Number of items"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
decimal price_per_item filters=min:0.01 {
|
|
114
|
+
description = "Price for each item"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
stack {
|
|
119
|
+
var $total {
|
|
120
|
+
value = 0
|
|
121
|
+
description = "Initialize total"
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
math.add $total {
|
|
125
|
+
value = $input.quantity * $input.price_per_item
|
|
126
|
+
description = "Calculate total"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
response = $total
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**V2 Style (minimal):**
|
|
135
|
+
```xs
|
|
136
|
+
function "calculate_total" {
|
|
137
|
+
input {
|
|
138
|
+
int quantity filters=min:0
|
|
139
|
+
decimal price filters=min:0.01
|
|
140
|
+
}
|
|
141
|
+
stack {
|
|
142
|
+
var $total { value = $input.quantity * $input.price }
|
|
143
|
+
}
|
|
144
|
+
response = $total
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Estimated Reduction
|
|
151
|
+
|
|
152
|
+
| Metric | V1 | V2 Target | Reduction |
|
|
153
|
+
|--------|-----|-----------|-----------|
|
|
154
|
+
| Files | 27 | 14 | ~48% |
|
|
155
|
+
| Total Lines | ~5000 | ~2000 | ~60% |
|
|
156
|
+
| Avg File Size | 185 lines | 140 lines | ~25% |
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Implementation Order
|
|
161
|
+
|
|
162
|
+
### Phase 1: Foundation
|
|
163
|
+
1. README.md - Workspace overview
|
|
164
|
+
2. syntax.md - All expressions and filters
|
|
165
|
+
3. types.md - Data types and inputs
|
|
166
|
+
|
|
167
|
+
### Phase 2: Core Constructs
|
|
168
|
+
4. tables.md - Database tables
|
|
169
|
+
5. functions.md - Functions
|
|
170
|
+
6. apis.md - API endpoints
|
|
171
|
+
7. tasks.md - Scheduled tasks
|
|
172
|
+
8. database.md - DB operations
|
|
173
|
+
|
|
174
|
+
### Phase 3: AI Features
|
|
175
|
+
9. agents.md - AI agents
|
|
176
|
+
10. tools.md - AI tools
|
|
177
|
+
11. mcp-servers.md - MCP servers
|
|
178
|
+
|
|
179
|
+
### Phase 4: Advanced
|
|
180
|
+
12. testing.md - Unit testing
|
|
181
|
+
13. integrations.md - Cloud/Redis/Security
|
|
182
|
+
14. frontend.md - Frontend + Lovable
|
|
183
|
+
15. ephemeral.md - Ephemeral environments
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Questions Resolved
|
|
188
|
+
|
|
189
|
+
- [x] Structure: Consolidated (single file per concept)
|
|
190
|
+
- [x] Examples: Minimal (just enough to demonstrate)
|
|
191
|
+
- [x] Quick Reference: Yes (syntax cheatsheets at top)
|
|
192
|
+
- [x] Scope: Complete coverage (all features)
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: "**/*.xs"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Syntax Reference
|
|
6
|
+
|
|
7
|
+
Complete reference for XanoScript expressions, operators, and filters.
|
|
8
|
+
|
|
9
|
+
## Quick Reference
|
|
10
|
+
|
|
11
|
+
### Operators
|
|
12
|
+
| Category | Operators |
|
|
13
|
+
|----------|-----------|
|
|
14
|
+
| Comparison | `==`, `!=`, `>`, `<`, `>=`, `<=` |
|
|
15
|
+
| Logical | `&&`, `||`, `!` |
|
|
16
|
+
| Math | `+`, `-`, `*`, `/`, `%` |
|
|
17
|
+
| String | `~` (concat) |
|
|
18
|
+
| Null-safe | `==?`, `!=?`, `>=?`, `<=?` (ignore if null) |
|
|
19
|
+
|
|
20
|
+
### Common Filters
|
|
21
|
+
| Filter | Purpose | Example |
|
|
22
|
+
|--------|---------|---------|
|
|
23
|
+
| `trim` | Remove whitespace | `$s\|trim` |
|
|
24
|
+
| `lower` / `upper` | Case conversion | `$s\|to_lower` |
|
|
25
|
+
| `first` / `last` | Array endpoints | `$arr\|first` |
|
|
26
|
+
| `count` | Array/object length | `$arr\|count` |
|
|
27
|
+
| `get` | Object property | `$obj\|get:"key"` |
|
|
28
|
+
| `set` | Set property | `$obj\|set:"key":"val"` |
|
|
29
|
+
| `json_encode` / `json_decode` | JSON conversion | `$obj\|json_encode` |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Expressions
|
|
34
|
+
|
|
35
|
+
Expressions are wrapped in backticks for evaluation:
|
|
36
|
+
|
|
37
|
+
```xs
|
|
38
|
+
conditional {
|
|
39
|
+
if (`$input.age >= 18`) { ... }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var $total { value = `$input.qty * $input.price` }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Comparison
|
|
46
|
+
```xs
|
|
47
|
+
$a == $b # Equal
|
|
48
|
+
$a != $b # Not equal
|
|
49
|
+
$a > $b # Greater than
|
|
50
|
+
$a >= $b # Greater or equal
|
|
51
|
+
$a < $b # Less than
|
|
52
|
+
$a <= $b # Less or equal
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Logical
|
|
56
|
+
```xs
|
|
57
|
+
$a && $b # AND
|
|
58
|
+
$a || $b # OR
|
|
59
|
+
!$a # NOT
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Null-Safe Comparisons (DB Queries)
|
|
63
|
+
```xs
|
|
64
|
+
# In db.query where clauses - ignore condition if value is null
|
|
65
|
+
$db.post.category ==? $input.category
|
|
66
|
+
$db.post.date >=? $input.start_date
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Math Filters
|
|
72
|
+
|
|
73
|
+
| Filter | Example | Result |
|
|
74
|
+
|--------|---------|--------|
|
|
75
|
+
| `add` | `10\|add:5` | `15` |
|
|
76
|
+
| `subtract` | `10\|subtract:3` | `7` |
|
|
77
|
+
| `multiply` | `10\|multiply:2` | `20` |
|
|
78
|
+
| `divide` | `10\|divide:2` | `5` |
|
|
79
|
+
| `modulus` | `10\|modulus:3` | `1` |
|
|
80
|
+
| `floor` | `2.7\|floor` | `2` |
|
|
81
|
+
| `ceil` | `2.3\|ceil` | `3` |
|
|
82
|
+
| `round` | `2.567\|round:2` | `2.57` |
|
|
83
|
+
| `abs` | `-5\|abs` | `5` |
|
|
84
|
+
| `sqrt` | `9\|sqrt` | `3` |
|
|
85
|
+
| `pow` | `2\|pow:3` | `8` |
|
|
86
|
+
| `min` | `5\|min:3` | `3` |
|
|
87
|
+
| `max` | `5\|max:10` | `10` |
|
|
88
|
+
|
|
89
|
+
### Array Math
|
|
90
|
+
```xs
|
|
91
|
+
[1,2,3,4]|sum # 10
|
|
92
|
+
[1,2,3,4]|avg # 2.5
|
|
93
|
+
[1,2,3,4]|product # 24
|
|
94
|
+
[5,2,8,1]|array_min # 1
|
|
95
|
+
[5,2,8,1]|array_max # 8
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Trigonometry
|
|
99
|
+
`sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `deg2rad`, `rad2deg`
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## String Filters
|
|
104
|
+
|
|
105
|
+
| Filter | Example | Result |
|
|
106
|
+
|--------|---------|--------|
|
|
107
|
+
| `trim` | `" hi "\|trim` | `"hi"` |
|
|
108
|
+
| `ltrim` / `rtrim` | `" hi"\|ltrim` | `"hi"` |
|
|
109
|
+
| `to_lower` | `"Hi"\|to_lower` | `"hi"` |
|
|
110
|
+
| `to_upper` | `"Hi"\|to_upper` | `"HI"` |
|
|
111
|
+
| `capitalize` | `"hi there"\|capitalize` | `"Hi There"` |
|
|
112
|
+
| `strlen` | `"hello"\|strlen` | `5` |
|
|
113
|
+
| `substr` | `"hello"\|substr:1:3` | `"ell"` |
|
|
114
|
+
| `split` | `"a,b,c"\|split:","` | `["a","b","c"]` |
|
|
115
|
+
| `replace` | `"hello"\|replace:"l":"x"` | `"hexxo"` |
|
|
116
|
+
| `contains` | `"hello"\|contains:"ell"` | `true` |
|
|
117
|
+
| `starts_with` | `"hello"\|starts_with:"he"` | `true` |
|
|
118
|
+
| `ends_with` | `"hello"\|ends_with:"lo"` | `true` |
|
|
119
|
+
| `concat` | `"a"\|concat:"b":"-"` | `"a-b"` |
|
|
120
|
+
|
|
121
|
+
### Case-Insensitive Variants
|
|
122
|
+
`icontains`, `istarts_with`, `iends_with`, `iindex`
|
|
123
|
+
|
|
124
|
+
### Regex
|
|
125
|
+
```xs
|
|
126
|
+
"/pattern/"|regex_matches:"subject" # Boolean match
|
|
127
|
+
"/(\w+)/"|regex_get_first_match:"test" # First match
|
|
128
|
+
"/\w+/"|regex_get_all_matches:"a b c" # All matches
|
|
129
|
+
"/\s+/"|regex_replace:"-":"a b" # Replace: "a-b"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Array Filters
|
|
135
|
+
|
|
136
|
+
| Filter | Example | Result |
|
|
137
|
+
|--------|---------|--------|
|
|
138
|
+
| `first` | `[1,2,3]\|first` | `1` |
|
|
139
|
+
| `last` | `[1,2,3]\|last` | `3` |
|
|
140
|
+
| `count` | `[1,2,3]\|count` | `3` |
|
|
141
|
+
| `reverse` | `[1,2,3]\|reverse` | `[3,2,1]` |
|
|
142
|
+
| `unique` | `[1,1,2]\|unique` | `[1,2]` |
|
|
143
|
+
| `flatten` | `[[1,2],[3]]\|flatten` | `[1,2,3]` |
|
|
144
|
+
| `shuffle` | `[1,2,3]\|shuffle` | Random order |
|
|
145
|
+
| `slice` | `[1,2,3,4]\|slice:1:2` | `[2,3]` |
|
|
146
|
+
| `push` | `[1,2]\|push:3` | `[1,2,3]` |
|
|
147
|
+
| `pop` | `[1,2,3]\|pop` | `3` |
|
|
148
|
+
| `shift` | `[1,2,3]\|shift` | `1` |
|
|
149
|
+
| `unshift` | `[1,2]\|unshift:0` | `[0,1,2]` |
|
|
150
|
+
| `merge` | `[1,2]\|merge:[3,4]` | `[1,2,3,4]` |
|
|
151
|
+
| `diff` | `[1,2,3]\|diff:[2]` | `[1,3]` |
|
|
152
|
+
| `intersect` | `[1,2,3]\|intersect:[2,3,4]` | `[2,3]` |
|
|
153
|
+
| `join` | `["a","b"]\|join:","` | `"a,b"` |
|
|
154
|
+
| `range` | `\|range:1:5` | `[1,2,3,4,5]` |
|
|
155
|
+
|
|
156
|
+
### Functional Operations
|
|
157
|
+
```xs
|
|
158
|
+
# Map - transform each element
|
|
159
|
+
[{v:1},{v:2}]|map:$$.v*2 # [2,4]
|
|
160
|
+
|
|
161
|
+
# Filter - keep matching elements
|
|
162
|
+
[1,2,3,4]|filter:$$%2==0 # [2,4]
|
|
163
|
+
|
|
164
|
+
# Find - first matching element
|
|
165
|
+
[{id:1},{id:2}]|find:$$.id==2 # {id:2}
|
|
166
|
+
|
|
167
|
+
# FindIndex - index of first match
|
|
168
|
+
[{id:1},{id:2}]|findIndex:$$.id==2 # 1
|
|
169
|
+
|
|
170
|
+
# Some - any element matches?
|
|
171
|
+
[1,2,3]|some:$$>2 # true
|
|
172
|
+
|
|
173
|
+
# Every - all elements match?
|
|
174
|
+
[2,4,6]|every:$$%2==0 # true
|
|
175
|
+
|
|
176
|
+
# Reduce - accumulate to single value
|
|
177
|
+
[1,2,3,4]|reduce:$$+$result:0 # 10
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Grouping & Indexing
|
|
181
|
+
```xs
|
|
182
|
+
# Group by property
|
|
183
|
+
[{g:"a",v:1},{g:"b",v:2},{g:"a",v:3}]|index_by:g
|
|
184
|
+
# {"a":[{g:"a",v:1},{g:"a",v:3}],"b":[{g:"b",v:2}]}
|
|
185
|
+
|
|
186
|
+
# Sort
|
|
187
|
+
[{n:"z"},{n:"a"}]|sort:n:text:false # Ascending by n
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Object Filters
|
|
193
|
+
|
|
194
|
+
| Filter | Example | Result |
|
|
195
|
+
|--------|---------|--------|
|
|
196
|
+
| `get` | `{a:1}\|get:"a"` | `1` |
|
|
197
|
+
| `set` | `{a:1}\|set:"b":2` | `{a:1,b:2}` |
|
|
198
|
+
| `unset` | `{a:1,b:2}\|unset:"b"` | `{a:1}` |
|
|
199
|
+
| `has` | `{a:1}\|has:"a"` | `true` |
|
|
200
|
+
| `keys` | `{a:1,b:2}\|keys` | `["a","b"]` |
|
|
201
|
+
| `values` | `{a:1,b:2}\|values` | `[1,2]` |
|
|
202
|
+
| `entries` | `{a:1}\|entries` | `[{key:"a",value:1}]` |
|
|
203
|
+
| `pick` | `{a:1,b:2,c:3}\|pick:[a,c]` | `{a:1,c:3}` |
|
|
204
|
+
| `unpick` | `{a:1,b:2,c:3}\|unpick:[b]` | `{a:1,c:3}` |
|
|
205
|
+
|
|
206
|
+
### Conditional Set
|
|
207
|
+
```xs
|
|
208
|
+
{a:1}|set_conditional:"b":2:true # {a:1,b:2} if condition true
|
|
209
|
+
{a:1}|set_ifnotempty:"b":"val" # Set only if val not empty
|
|
210
|
+
{a:1}|set_ifnotnull:"b":$var # Set only if $var not null
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Type Filters
|
|
216
|
+
|
|
217
|
+
| Filter | Example | Result |
|
|
218
|
+
|--------|---------|--------|
|
|
219
|
+
| `to_int` | `"123"\|to_int` | `123` |
|
|
220
|
+
| `to_decimal` | `"1.5"\|to_decimal` | `1.5` |
|
|
221
|
+
| `to_text` | `123\|to_text` | `"123"` |
|
|
222
|
+
| `to_bool` | `"true"\|to_bool` | `true` |
|
|
223
|
+
| `is_null` | `null\|is_null` | `true` |
|
|
224
|
+
| `is_empty` | `[]\|is_empty` | `true` |
|
|
225
|
+
| `is_array` | `[1]\|is_array` | `true` |
|
|
226
|
+
| `is_object` | `{}\|is_object` | `true` |
|
|
227
|
+
| `is_int` | `1\|is_int` | `true` |
|
|
228
|
+
| `is_text` | `"a"\|is_text` | `true` |
|
|
229
|
+
|
|
230
|
+
### Null Handling
|
|
231
|
+
```xs
|
|
232
|
+
null|first_notnull:0 # 0
|
|
233
|
+
""|first_notempty:"default" # "default"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Date/Time Filters
|
|
239
|
+
|
|
240
|
+
| Filter | Example | Description |
|
|
241
|
+
|--------|---------|-------------|
|
|
242
|
+
| `to_timestamp` | `"now"\|to_timestamp` | Parse to timestamp |
|
|
243
|
+
| `to_ms` | `"now"\|to_ms` | Milliseconds since epoch |
|
|
244
|
+
| `to_seconds` | `"now"\|to_seconds` | Seconds since epoch |
|
|
245
|
+
| `format_timestamp` | `$ts\|format_timestamp:"Y-m-d":"UTC"` | Format timestamp |
|
|
246
|
+
| `transform_timestamp` | `$ts\|transform_timestamp:"-7 days"` | Relative time |
|
|
247
|
+
| `add_secs_to_timestamp` | `$ts\|add_secs_to_timestamp:60` | Add seconds |
|
|
248
|
+
| `add_ms_to_timestamp` | `$ts\|add_ms_to_timestamp:1000` | Add milliseconds |
|
|
249
|
+
|
|
250
|
+
### Timestamp Parts
|
|
251
|
+
```xs
|
|
252
|
+
$ts|timestamp_year # Year
|
|
253
|
+
$ts|timestamp_month # Month (1-12)
|
|
254
|
+
$ts|timestamp_day_of_month # Day (1-31)
|
|
255
|
+
$ts|timestamp_hour # Hour (0-23)
|
|
256
|
+
$ts|timestamp_minute # Minute (0-59)
|
|
257
|
+
$ts|timestamp_day_of_week # Day (0=Sunday)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Encoding Filters
|
|
263
|
+
|
|
264
|
+
| Filter | Example |
|
|
265
|
+
|--------|---------|
|
|
266
|
+
| `json_encode` | `{a:1}\|json_encode` |
|
|
267
|
+
| `json_decode` | `'{"a":1}'\|json_decode` |
|
|
268
|
+
| `base64_encode` | `"hello"\|base64_encode` |
|
|
269
|
+
| `base64_decode` | `"aGVsbG8="\|base64_decode` |
|
|
270
|
+
| `url_encode` | `"a b"\|url_encode` |
|
|
271
|
+
| `url_decode` | `"a%20b"\|url_decode` |
|
|
272
|
+
| `xml_decode` | `"<a>1</a>"\|xml_decode` |
|
|
273
|
+
| `yaml_encode` / `yaml_decode` | YAML conversion |
|
|
274
|
+
| `hex2bin` / `bin2hex` | Hex conversion |
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Security Filters
|
|
279
|
+
|
|
280
|
+
| Filter | Example |
|
|
281
|
+
|--------|---------|
|
|
282
|
+
| `md5` | `"text"\|md5` |
|
|
283
|
+
| `sha1` / `sha256` / `sha512` | Hash functions |
|
|
284
|
+
| `hmac_sha256` | `"msg"\|hmac_sha256:"key"` |
|
|
285
|
+
| `encrypt` | `"data"\|encrypt:"aes-256-cbc":"key":"iv"` |
|
|
286
|
+
| `decrypt` | `$enc\|decrypt:"aes-256-cbc":"key":"iv"` |
|
|
287
|
+
| `jws_encode` / `jws_decode` | JWT signing |
|
|
288
|
+
| `jwe_encode` / `jwe_decode` | JWT encryption |
|
|
289
|
+
| `secureid_encode` / `secureid_decode` | ID obfuscation |
|
|
290
|
+
| `uuid` | `\|uuid` |
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## DB Query Filters
|
|
295
|
+
|
|
296
|
+
Used in `db.query` where clauses:
|
|
297
|
+
|
|
298
|
+
| Filter | Example | Description |
|
|
299
|
+
|--------|---------|-------------|
|
|
300
|
+
| `contains` | `$db.tags\|contains:"featured"` | Array contains value |
|
|
301
|
+
| `includes` | `$db.title\|includes:"tutorial"` | String includes text |
|
|
302
|
+
| `overlaps` | `$db.tags\|overlaps:["a","b"]` | Arrays share elements |
|
|
303
|
+
| `between` | `$db.price\|between:10:100` | Value in range |
|
|
304
|
+
| `within` | `$db.geo\|within:$point:1000` | Geo within radius (meters) |
|
|
305
|
+
| `distance` | `$db.geo\|distance:$point` | Geo distance (meters) |
|
|
306
|
+
| `search_rank` | `$db.content\|search_rank:"query"` | Full-text search ranking |
|
|
307
|
+
| `cosine_similarity` | `$db.vector\|cosine_similarity:$vec` | Vector similarity |
|
|
308
|
+
| `l2_distance_euclidean` | `$db.vector\|l2_distance_euclidean:$vec` | Vector distance |
|
|
309
|
+
|
|
310
|
+
### Timestamp Arithmetic (DB)
|
|
311
|
+
```xs
|
|
312
|
+
$db.created_at|timestamp_add_days:7
|
|
313
|
+
$db.created_at|timestamp_subtract_hours:24
|
|
314
|
+
```
|