@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
|
@@ -107,10 +107,10 @@ var $data { value = { key: "value" } }
|
|
|
107
107
|
### Conditional Logic
|
|
108
108
|
```xs
|
|
109
109
|
conditional {
|
|
110
|
-
if (
|
|
110
|
+
if ($status == "active") {
|
|
111
111
|
var $result { value = "Active user" }
|
|
112
112
|
}
|
|
113
|
-
elseif (
|
|
113
|
+
elseif ($status == "pending") {
|
|
114
114
|
var $result { value = "Pending approval" }
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
@@ -464,7 +464,7 @@ conditional {
|
|
|
464
464
|
}
|
|
465
465
|
else {
|
|
466
466
|
throw {
|
|
467
|
-
name = "APIError"
|
|
467
|
+
name = "APIError"
|
|
468
468
|
value = "OpenAI API error: " ~ ($api_result.response.status|to_text)
|
|
469
469
|
}
|
|
470
470
|
}
|
|
@@ -574,19 +574,28 @@ var $data { value = { customer = $id } }
|
|
|
574
574
|
var $data { value = { customer: $id } }
|
|
575
575
|
```
|
|
576
576
|
|
|
577
|
-
### 9.
|
|
577
|
+
### 9. Commas in block properties (`=`) vs object literals (`:`)
|
|
578
|
+
|
|
579
|
+
Block properties use `=` and go on **separate lines with no commas**. Object literals use `:` and **require commas** between entries.
|
|
580
|
+
|
|
578
581
|
```xs
|
|
579
|
-
// ❌ Wrong -
|
|
582
|
+
// ❌ Wrong - block properties don't use commas
|
|
580
583
|
throw {
|
|
581
584
|
name = "Error",
|
|
582
585
|
value = "message"
|
|
583
586
|
}
|
|
584
587
|
|
|
585
|
-
// ✅ Correct - no commas between properties
|
|
588
|
+
// ✅ Correct - no commas between block properties (=)
|
|
586
589
|
throw {
|
|
587
590
|
name = "Error"
|
|
588
591
|
value = "message"
|
|
589
592
|
}
|
|
593
|
+
|
|
594
|
+
// ✅ Correct - object literals (:) DO use commas
|
|
595
|
+
db.query "dad_jokes" {
|
|
596
|
+
sort = {dad_jokes.id: "rand", dad_jokes.joke: "asc"}
|
|
597
|
+
return = {type: "single"}
|
|
598
|
+
} as $joke
|
|
590
599
|
```
|
|
591
600
|
|
|
592
601
|
### 10. Using $env in run.job input blocks
|
|
@@ -10,14 +10,14 @@ Best practices for building secure XanoScript applications.
|
|
|
10
10
|
|
|
11
11
|
## Section Index
|
|
12
12
|
|
|
13
|
-
- [Authentication](#authentication)
|
|
14
|
-
- [Authorization](#authorization)
|
|
15
|
-
- [Input Validation](#input-validation)
|
|
16
|
-
- [Data Protection](#data-protection)
|
|
17
|
-
- [Rate Limiting](#rate-limiting--abuse-prevention)
|
|
18
|
-
- [Security Headers](#security-headers)
|
|
19
|
-
- [Audit Logging](#audit-logging)
|
|
20
|
-
- [Best Practices Summary](#best-practices-summary)
|
|
13
|
+
- [Authentication](#authentication) - Tokens, sessions, refresh tokens
|
|
14
|
+
- [Authorization](#authorization) - Role checks, ownership
|
|
15
|
+
- [Input Validation](#input-validation) - Type enforcement, sanitization
|
|
16
|
+
- [Data Protection](#data-protection) - Encryption, hashing, secrets
|
|
17
|
+
- [Rate Limiting](#rate-limiting--abuse-prevention) - API limits, abuse prevention
|
|
18
|
+
- [Security Headers](#security-headers) - CORS configuration
|
|
19
|
+
- [Audit Logging](#audit-logging) - Security event tracking
|
|
20
|
+
- [Best Practices Summary](#best-practices-summary) - Quick checklist
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
@@ -162,36 +162,6 @@ function "validate_session" {
|
|
|
162
162
|
}
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
### Multi-Factor Authentication
|
|
166
|
-
|
|
167
|
-
```xs
|
|
168
|
-
function "verify_mfa" {
|
|
169
|
-
input {
|
|
170
|
-
int user_id
|
|
171
|
-
text code filters=digitOk|min:6|max:6
|
|
172
|
-
}
|
|
173
|
-
stack {
|
|
174
|
-
db.get "user" {
|
|
175
|
-
field_name = "id"
|
|
176
|
-
field_value = $input.user_id
|
|
177
|
-
} as $user
|
|
178
|
-
|
|
179
|
-
// Verify TOTP code
|
|
180
|
-
security.verify_totp {
|
|
181
|
-
secret = $user.mfa_secret
|
|
182
|
-
code = $input.code
|
|
183
|
-
window = 1
|
|
184
|
-
} as $is_valid
|
|
185
|
-
|
|
186
|
-
precondition ($is_valid) {
|
|
187
|
-
error_type = "accessdenied"
|
|
188
|
-
error = "Invalid MFA code"
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
response = { verified: true }
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
165
|
---
|
|
196
166
|
|
|
197
167
|
## Authorization
|
|
@@ -294,7 +264,7 @@ input {
|
|
|
294
264
|
email email filters=trim|lower
|
|
295
265
|
text password filters=min:8|max:128
|
|
296
266
|
int age filters=min:0|max:150
|
|
297
|
-
text username filters=trim|lower|min:3|max:20|
|
|
267
|
+
text username filters=trim|lower|min:3|max:20|alphaOk|digitOk
|
|
298
268
|
}
|
|
299
269
|
```
|
|
300
270
|
|
|
@@ -324,9 +294,9 @@ var $safe_content {
|
|
|
324
294
|
value = $input.content|escape
|
|
325
295
|
}
|
|
326
296
|
|
|
327
|
-
// For rich text,
|
|
297
|
+
// For rich text, escape HTML entities
|
|
328
298
|
var $sanitized {
|
|
329
|
-
value = $input.html|
|
|
299
|
+
value = $input.html|escape
|
|
330
300
|
}
|
|
331
301
|
```
|
|
332
302
|
|
|
@@ -508,8 +478,13 @@ function "record_failed_login" {
|
|
|
508
478
|
input { text email }
|
|
509
479
|
stack {
|
|
510
480
|
var $key { value = "login_attempts:" ~ $input.email|md5 }
|
|
511
|
-
|
|
512
|
-
redis.
|
|
481
|
+
|
|
482
|
+
redis.get { key = $key } as $current
|
|
483
|
+
redis.set {
|
|
484
|
+
key = $key
|
|
485
|
+
data = ($current|to_int ?? 0) + 1
|
|
486
|
+
ttl = 900
|
|
487
|
+
}
|
|
513
488
|
}
|
|
514
489
|
}
|
|
515
490
|
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: ""
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Array Filters & Functions
|
|
6
|
+
|
|
7
|
+
Complete reference for XanoScript array filters, functional operations, and statement-level array functions.
|
|
8
|
+
|
|
9
|
+
> **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.
|
|
10
|
+
|
|
11
|
+
## Quick Reference
|
|
12
|
+
|
|
13
|
+
### Array Filters
|
|
14
|
+
|
|
15
|
+
| Filter | Example | Result |
|
|
16
|
+
|--------|---------|--------|
|
|
17
|
+
| `first` | `[1,2,3]\|first` | `1` |
|
|
18
|
+
| `last` | `[1,2,3]\|last` | `3` |
|
|
19
|
+
| `count` | `[1,2,3]\|count` | `3` |
|
|
20
|
+
| `reverse` | `[1,2,3]\|reverse` | `[3,2,1]` |
|
|
21
|
+
| `unique` | `[1,1,2]\|unique` | `[1,2]` |
|
|
22
|
+
| `flatten` | `[[1,2],[3]]\|flatten` | `[1,2,3]` |
|
|
23
|
+
| `shuffle` | `[1,2,3]\|shuffle` | Random order |
|
|
24
|
+
| `slice` | `[1,2,3,4]\|slice:1:2` | `[2,3]` -- offset 1, length 2 |
|
|
25
|
+
| `push` | `[1,2]\|push:3` | `[1,2,3]` |
|
|
26
|
+
| `pop` | `[1,2,3]\|pop` | `3` |
|
|
27
|
+
| `shift` | `[1,2,3]\|shift` | `1` |
|
|
28
|
+
| `unshift` | `[1,2]\|unshift:0` | `[0,1,2]` |
|
|
29
|
+
| `merge` | `[1,2]\|merge:[3,4]` | `[1,2,3,4]` |
|
|
30
|
+
| `diff` | `[1,2,3]\|diff:[2]` | `[1,3]` |
|
|
31
|
+
| `intersect` | `[1,2,3]\|intersect:[2,3,4]` | `[2,3]` |
|
|
32
|
+
| `join` | `["a","b"]\|join:","` | `"a,b"` |
|
|
33
|
+
| `range` | `\|range:1:5` | `[1,2,3,4,5]` |
|
|
34
|
+
| `..` | `(1..5)` | `[1,2,3,4,5]` |
|
|
35
|
+
|
|
36
|
+
### Range Operator
|
|
37
|
+
|
|
38
|
+
```xs
|
|
39
|
+
(1..5) // [1,2,3,4,5]
|
|
40
|
+
(0..10) // [0,1,2,3,4,5,6,7,8,9,10]
|
|
41
|
+
($start..$end) // Dynamic range with variables
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Functional Operations
|
|
45
|
+
|
|
46
|
+
```xs
|
|
47
|
+
// Map - transform each element
|
|
48
|
+
[{v:1},{v:2}]|map:$$.v*2 // [2,4]
|
|
49
|
+
|
|
50
|
+
// Filter - keep matching elements
|
|
51
|
+
[1,2,3,4]|filter:$$%2==0 // [2,4]
|
|
52
|
+
|
|
53
|
+
// Find - first matching element
|
|
54
|
+
[{id:1},{id:2}]|find:$$.id==2 // {id:2}
|
|
55
|
+
|
|
56
|
+
// FindIndex - index of first match
|
|
57
|
+
[{id:1},{id:2}]|findIndex:$$.id==2 // 1
|
|
58
|
+
|
|
59
|
+
// Some - any element matches?
|
|
60
|
+
[1,2,3]|some:$$>2 // true
|
|
61
|
+
|
|
62
|
+
// Every - all elements match?
|
|
63
|
+
[2,4,6]|every:$$%2==0 // true
|
|
64
|
+
|
|
65
|
+
// Reduce - accumulate to single value
|
|
66
|
+
[1,2,3,4]|reduce:$$+$result:0 // 10
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Array Element Access: `|get` vs `|slice`
|
|
70
|
+
|
|
71
|
+
> **`|get:N`** returns a **single element** by zero-based index.
|
|
72
|
+
> **`|slice:offset:length`** returns a **sub-array**, skipping `offset` elements and returning the next `length` elements.
|
|
73
|
+
|
|
74
|
+
| Method | Use For | Example | Result |
|
|
75
|
+
|--------|---------|---------|--------|
|
|
76
|
+
| `\|get:N` | Single element by index (0-based) | `[10,20,30]\|get:0` | `10` |
|
|
77
|
+
| `\|slice:offset:length` | Sub-array -- skip N, take M | `[10,20,30,40]\|slice:1:2` | `[20,30]` |
|
|
78
|
+
| `\|first` | First element | `[10,20,30]\|first` | `10` |
|
|
79
|
+
| `\|last` | Last element | `[10,20,30]\|last` | `30` |
|
|
80
|
+
|
|
81
|
+
```xs
|
|
82
|
+
var $third { value = $items|get:2 } // 0-based: 3rd element
|
|
83
|
+
var $page { value = $items|slice:10:5 } // skip 10, return 5 elements
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Grouping & Indexing
|
|
87
|
+
|
|
88
|
+
```xs
|
|
89
|
+
// Group by property
|
|
90
|
+
[{g:"a",v:1},{g:"b",v:2},{g:"a",v:3}]|index_by:g
|
|
91
|
+
// {"a":[{g:"a",v:1},{g:"a",v:3}],"b":[{g:"b",v:2}]}
|
|
92
|
+
|
|
93
|
+
// Sort
|
|
94
|
+
[{n:"z"},{n:"a"}]|sort:n:text:false // Ascending by n
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Math on Arrays
|
|
98
|
+
|
|
99
|
+
```xs
|
|
100
|
+
[1,2,3,4]|sum // 10
|
|
101
|
+
[1,2,3,4]|avg // 2.5
|
|
102
|
+
[1,2,3,4]|product // 24
|
|
103
|
+
[5,2,8,1]|array_min // 1
|
|
104
|
+
[5,2,8,1]|array_max // 8
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Array Filtering
|
|
108
|
+
|
|
109
|
+
| Filter | Description | Example |
|
|
110
|
+
|--------|-------------|---------|
|
|
111
|
+
| `filter_empty` | Remove empty values | `$arr\|filter_empty` |
|
|
112
|
+
| `filter_empty_text` | Remove empty strings | `$arr\|filter_empty_text` |
|
|
113
|
+
| `filter_empty_array` | Remove empty arrays | `$arr\|filter_empty_array` |
|
|
114
|
+
| `filter_empty_object` | Remove empty objects | `$arr\|filter_empty_object` |
|
|
115
|
+
| `filter_null` | Remove null values | `$arr\|filter_null` |
|
|
116
|
+
| `filter_zero` | Remove zero values | `$arr\|filter_zero` |
|
|
117
|
+
| `filter_false` | Remove false values | `$arr\|filter_false` |
|
|
118
|
+
|
|
119
|
+
```xs
|
|
120
|
+
[1, null, "", 0, "text", false]|filter_empty // [1, "text"]
|
|
121
|
+
["a", "", "b", ""]|filter_empty_text // ["a", "b"]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Array Fill Operations
|
|
125
|
+
|
|
126
|
+
```xs
|
|
127
|
+
|fill:5:"x" // ["x", "x", "x", "x", "x"]
|
|
128
|
+
["a", "b"]|fill_keys:{"a": 1, "b": 2} // {a: 1, b: 2}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Deep Merge & Comparison
|
|
132
|
+
|
|
133
|
+
```xs
|
|
134
|
+
{a: {b: 1}}|merge_recursive:{a: {c: 2}} // {a: {b: 1, c: 2}}
|
|
135
|
+
[1, 2, 3]|diff_assoc:[2] // Associative diff
|
|
136
|
+
[1, 2, 3]|intersect_assoc:[2, 3, 4] // Associative intersect
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Array Functions (Statement-Level)
|
|
140
|
+
|
|
141
|
+
Statement-level functions for manipulating arrays within stacks. Unlike filters (e.g., `$arr|push:3`), these are standalone operations.
|
|
142
|
+
|
|
143
|
+
> **Syntax note:** Functions that use a `{ by = ... }` or `{ value = ... }` block wrap the array in parentheses -- e.g., `array.map ($arr) { ... }`. Functions that use an `if (...)` condition take a bare variable -- e.g., `array.filter $arr if (...) as $result`.
|
|
144
|
+
|
|
145
|
+
### array.push / array.unshift
|
|
146
|
+
|
|
147
|
+
```xs
|
|
148
|
+
array.push $shopping_cart { value = "oranges" }
|
|
149
|
+
array.unshift $priority_tasks { value = "urgent meeting" }
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### array.pop / array.shift
|
|
153
|
+
|
|
154
|
+
```xs
|
|
155
|
+
array.pop $completed_tasks as $last_finished_task
|
|
156
|
+
array.shift $waiting_list as $next_customer
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### array.merge
|
|
160
|
+
|
|
161
|
+
```xs
|
|
162
|
+
array.merge $active_users { value = $new_users }
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### array.find / array.find_index
|
|
166
|
+
|
|
167
|
+
```xs
|
|
168
|
+
array.find $customer_ages if ($this > 18) as $first_adult_age
|
|
169
|
+
array.find_index $sale_prices if ($this < 20) as $first_discount_index
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### array.has / array.every
|
|
173
|
+
|
|
174
|
+
```xs
|
|
175
|
+
array.has $team_roles if ($this == "manager") as $has_manager
|
|
176
|
+
array.every $exam_scores if ($this >= 70) as $all_passed
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### array.filter / array.filter_count
|
|
180
|
+
|
|
181
|
+
```xs
|
|
182
|
+
array.filter $temperatures if ($this > 32) as $above_freezing
|
|
183
|
+
array.filter_count $survey_responses if ($this == "yes") as $yes_count
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### array.map
|
|
187
|
+
|
|
188
|
+
```xs
|
|
189
|
+
array.map ($json) {
|
|
190
|
+
by = $this.email
|
|
191
|
+
} as $emails
|
|
192
|
+
|
|
193
|
+
array.map ($json) {
|
|
194
|
+
by = {name: $this.name, gender: $this.gender}
|
|
195
|
+
} as $people
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### array.partition / array.group_by
|
|
199
|
+
|
|
200
|
+
```xs
|
|
201
|
+
array.partition ($json) if ($this.gender == "male") as $is_male
|
|
202
|
+
|
|
203
|
+
array.group_by ($users) {
|
|
204
|
+
by = $this.gender
|
|
205
|
+
} as $user_by_gender
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### array.union / array.difference / array.intersection
|
|
209
|
+
|
|
210
|
+
```xs
|
|
211
|
+
array.union ([1,3,5,7,9]) {
|
|
212
|
+
value = [2,4,6,8]
|
|
213
|
+
by = $this
|
|
214
|
+
} as $union
|
|
215
|
+
// Result: [1,2,3,4,5,6,7,8,9]
|
|
216
|
+
|
|
217
|
+
array.difference ([1,2,3,4,5,6,7,8,9]) {
|
|
218
|
+
value = [2,4,6,8]
|
|
219
|
+
by = $this
|
|
220
|
+
} as $difference
|
|
221
|
+
// Result: [1,3,5,7,9]
|
|
222
|
+
|
|
223
|
+
array.intersection ([1,2,3,4,5,6,7,8,9]) {
|
|
224
|
+
value = [2,4,6,8]
|
|
225
|
+
by = $this
|
|
226
|
+
} as $intersection
|
|
227
|
+
// Result: [2,4,6,8]
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Related Topics
|
|
233
|
+
|
|
234
|
+
| Topic | Description |
|
|
235
|
+
|-------|-------------|
|
|
236
|
+
| `syntax` | Core operators, conditionals, type filters, error handling |
|
|
237
|
+
| `syntax/string-filters` | String filters, encoding, and security filters |
|
|
238
|
+
| `syntax/functions` | Math and object functions |
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: ""
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Math & Object Functions
|
|
6
|
+
|
|
7
|
+
Statement-level math and object functions for XanoScript.
|
|
8
|
+
|
|
9
|
+
## Quick Reference
|
|
10
|
+
|
|
11
|
+
### Math Filters
|
|
12
|
+
|
|
13
|
+
| Filter | Example | Result |
|
|
14
|
+
|--------|---------|--------|
|
|
15
|
+
| `add` | `10\|add:5` | `15` |
|
|
16
|
+
| `subtract` | `10\|subtract:3` | `7` |
|
|
17
|
+
| `multiply` | `10\|multiply:2` | `20` |
|
|
18
|
+
| `divide` | `10\|divide:2` | `5` |
|
|
19
|
+
| `modulus` | `10\|modulus:3` | `1` |
|
|
20
|
+
| `floor` | `2.7\|floor` | `2` |
|
|
21
|
+
| `ceil` | `2.3\|ceil` | `3` |
|
|
22
|
+
| `round` | `2.567\|round:2` | `2.57` |
|
|
23
|
+
| `abs` | `-5\|abs` | `5` |
|
|
24
|
+
| `sqrt` | `9\|sqrt` | `3` |
|
|
25
|
+
| `pow` | `2\|pow:3` | `8` |
|
|
26
|
+
| `min` | `5\|min:3` | `3` |
|
|
27
|
+
| `max` | `5\|max:10` | `10` |
|
|
28
|
+
|
|
29
|
+
### Trigonometry
|
|
30
|
+
|
|
31
|
+
```xs
|
|
32
|
+
90|deg2rad // 1.5707963...
|
|
33
|
+
1.5707963|rad2deg // 90
|
|
34
|
+
0|sin // 0
|
|
35
|
+
0|cos // 1
|
|
36
|
+
0.785398|tan // ~1 (45 degrees)
|
|
37
|
+
0|asin // 0
|
|
38
|
+
1|acos // 0
|
|
39
|
+
1|atan // 0.785398...
|
|
40
|
+
0|sinh // 0
|
|
41
|
+
0|cosh // 1
|
|
42
|
+
0|tanh // 0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Math Functions (Statement-Level)
|
|
46
|
+
|
|
47
|
+
Statement-level functions for arithmetic and bitwise operations. These mutate the target variable directly.
|
|
48
|
+
|
|
49
|
+
> **Note:** These are different from math filters (e.g., `$x|add:5`) and math domain functions (e.g., `math.add(5, 3)`). Statement-level math functions modify the variable in place.
|
|
50
|
+
|
|
51
|
+
### math.add / math.sub
|
|
52
|
+
|
|
53
|
+
```xs
|
|
54
|
+
math.add $cart_total { value = $item_price }
|
|
55
|
+
math.sub $total_cost { value = $discount_amount }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### math.mul / math.div
|
|
59
|
+
|
|
60
|
+
```xs
|
|
61
|
+
math.mul $base_price { value = $tax_rate }
|
|
62
|
+
math.div $total_time { value = $num_tasks }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### math.bitwise.and / math.bitwise.or / math.bitwise.xor
|
|
66
|
+
|
|
67
|
+
```xs
|
|
68
|
+
math.bitwise.and $status_flags { value = $check_bit }
|
|
69
|
+
math.bitwise.or $permissions { value = $new_permission }
|
|
70
|
+
math.bitwise.xor $flags { value = $toggle_bit }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Math Domain Functions
|
|
74
|
+
|
|
75
|
+
```xs
|
|
76
|
+
math.add(5, 3) // 8
|
|
77
|
+
math.sub(10, 4) // 6
|
|
78
|
+
math.mul(3, 4) // 12
|
|
79
|
+
math.div(20, 5) // 4
|
|
80
|
+
math.mod(10, 3) // 1
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Bitwise Filters
|
|
84
|
+
|
|
85
|
+
```xs
|
|
86
|
+
5|bitwise_and:3 // 1
|
|
87
|
+
5|bitwise_or:3 // 7
|
|
88
|
+
5|bitwise_xor:3 // 6
|
|
89
|
+
5|bitwise_not // -6
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Logical NOT Filter
|
|
93
|
+
|
|
94
|
+
```xs
|
|
95
|
+
true|not // false
|
|
96
|
+
false|not // true
|
|
97
|
+
$condition|not // Inverts boolean
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Object Functions (Statement-Level)
|
|
101
|
+
|
|
102
|
+
Statement-level functions for extracting object properties. These return results via the `as` variable.
|
|
103
|
+
|
|
104
|
+
### object.keys / object.values / object.entries
|
|
105
|
+
|
|
106
|
+
```xs
|
|
107
|
+
object.keys {
|
|
108
|
+
value = $user_data
|
|
109
|
+
} as $user_data_keys
|
|
110
|
+
|
|
111
|
+
object.values {
|
|
112
|
+
value = $product_info
|
|
113
|
+
} as $product_values
|
|
114
|
+
|
|
115
|
+
object.entries {
|
|
116
|
+
value = $settings
|
|
117
|
+
} as $settings_pairs
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Object Domain Functions
|
|
121
|
+
|
|
122
|
+
```xs
|
|
123
|
+
object.keys({a: 1, b: 2}) // ["a", "b"]
|
|
124
|
+
object.values({a: 1, b: 2}) // [1, 2]
|
|
125
|
+
object.entries({a: 1, b: 2}) // [{key: "a", value: 1}, {key: "b", value: 2}]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Related Topics
|
|
131
|
+
|
|
132
|
+
| Topic | Description |
|
|
133
|
+
|-------|-------------|
|
|
134
|
+
| `syntax` | Core operators, conditionals, type filters, error handling |
|
|
135
|
+
| `syntax/string-filters` | String filters, encoding, and security filters |
|
|
136
|
+
| `syntax/array-filters` | Array filters and array functions |
|