@xano/developer-mcp 1.0.40 → 1.0.41
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/docs_index.json +70 -1
- package/dist/xanoscript_docs/integrations/cloud-storage.md +59 -3
- package/dist/xanoscript_docs/integrations/redis.md +28 -8
- package/dist/xanoscript_docs/integrations/search.md +39 -3
- package/dist/xanoscript_docs/integrations/utilities.md +25 -0
- package/dist/xanoscript_docs/security.md +39 -0
- package/dist/xanoscript_docs/syntax.md +411 -4
- package/dist/xanoscript_docs/version.json +2 -2
- package/package.json +1 -1
|
@@ -221,7 +221,76 @@
|
|
|
221
221
|
"redis.get": { "file": "integrations/redis.md" },
|
|
222
222
|
"redis.set": { "file": "integrations/redis.md" },
|
|
223
223
|
"storage.s3_put": { "file": "integrations/cloud-storage.md" },
|
|
224
|
-
"storage.s3_get": { "file": "integrations/cloud-storage.md" }
|
|
224
|
+
"storage.s3_get": { "file": "integrations/cloud-storage.md" },
|
|
225
|
+
"array.push": { "file": "syntax.md" },
|
|
226
|
+
"array.pop": { "file": "syntax.md" },
|
|
227
|
+
"array.shift": { "file": "syntax.md" },
|
|
228
|
+
"array.unshift": { "file": "syntax.md" },
|
|
229
|
+
"array.merge": { "file": "syntax.md" },
|
|
230
|
+
"array.find": { "file": "syntax.md" },
|
|
231
|
+
"array.find_index": { "file": "syntax.md" },
|
|
232
|
+
"array.has": { "file": "syntax.md" },
|
|
233
|
+
"array.every": { "file": "syntax.md" },
|
|
234
|
+
"array.filter": { "file": "syntax.md" },
|
|
235
|
+
"array.filter_count": { "file": "syntax.md" },
|
|
236
|
+
"array.map": { "file": "syntax.md" },
|
|
237
|
+
"array.partition": { "file": "syntax.md" },
|
|
238
|
+
"array.group_by": { "file": "syntax.md" },
|
|
239
|
+
"array.union": { "file": "syntax.md" },
|
|
240
|
+
"array.difference": { "file": "syntax.md" },
|
|
241
|
+
"array.intersection": { "file": "syntax.md" },
|
|
242
|
+
"text.contains": { "file": "syntax.md" },
|
|
243
|
+
"text.icontains": { "file": "syntax.md" },
|
|
244
|
+
"text.starts_with": { "file": "syntax.md" },
|
|
245
|
+
"text.istarts_with": { "file": "syntax.md" },
|
|
246
|
+
"text.ends_with": { "file": "syntax.md" },
|
|
247
|
+
"text.iends_with": { "file": "syntax.md" },
|
|
248
|
+
"text.trim": { "file": "syntax.md" },
|
|
249
|
+
"text.ltrim": { "file": "syntax.md" },
|
|
250
|
+
"text.rtrim": { "file": "syntax.md" },
|
|
251
|
+
"text.append": { "file": "syntax.md" },
|
|
252
|
+
"text.prepend": { "file": "syntax.md" },
|
|
253
|
+
"math.add": { "file": "syntax.md" },
|
|
254
|
+
"math.sub": { "file": "syntax.md" },
|
|
255
|
+
"math.mul": { "file": "syntax.md" },
|
|
256
|
+
"math.div": { "file": "syntax.md" },
|
|
257
|
+
"math.bitwise.and": { "file": "syntax.md" },
|
|
258
|
+
"math.bitwise.or": { "file": "syntax.md" },
|
|
259
|
+
"math.bitwise.xor": { "file": "syntax.md" },
|
|
260
|
+
"object.keys": { "file": "syntax.md" },
|
|
261
|
+
"object.values": { "file": "syntax.md" },
|
|
262
|
+
"object.entries": { "file": "syntax.md" },
|
|
263
|
+
"redis.remove": { "file": "integrations/redis.md" },
|
|
264
|
+
"redis.keys": { "file": "integrations/redis.md" },
|
|
265
|
+
"security.jwe_encode": { "file": "security.md" },
|
|
266
|
+
"security.jwe_decode": { "file": "security.md" },
|
|
267
|
+
"security.create_curve_key": { "file": "security.md" },
|
|
268
|
+
"security.create_secret_key": { "file": "security.md" },
|
|
269
|
+
"util.set_header": { "file": "integrations/utilities.md" },
|
|
270
|
+
"util.get_env": { "file": "integrations/utilities.md" },
|
|
271
|
+
"util.get_all_input": { "file": "integrations/utilities.md" },
|
|
272
|
+
"util.get_input": { "file": "integrations/utilities.md" },
|
|
273
|
+
"cloud.aws.s3.upload_file": { "file": "integrations/cloud-storage.md" },
|
|
274
|
+
"cloud.aws.s3.read_file": { "file": "integrations/cloud-storage.md" },
|
|
275
|
+
"cloud.aws.s3.sign_url": { "file": "integrations/cloud-storage.md" },
|
|
276
|
+
"cloud.aws.s3.list_directory": { "file": "integrations/cloud-storage.md" },
|
|
277
|
+
"cloud.aws.s3.delete_file": { "file": "integrations/cloud-storage.md" },
|
|
278
|
+
"cloud.aws.s3.get_file_info": { "file": "integrations/cloud-storage.md" },
|
|
279
|
+
"cloud.azure.storage.upload_file": { "file": "integrations/cloud-storage.md" },
|
|
280
|
+
"cloud.azure.storage.read_file": { "file": "integrations/cloud-storage.md" },
|
|
281
|
+
"cloud.azure.storage.sign_url": { "file": "integrations/cloud-storage.md" },
|
|
282
|
+
"cloud.azure.storage.list_directory": { "file": "integrations/cloud-storage.md" },
|
|
283
|
+
"cloud.azure.storage.delete_file": { "file": "integrations/cloud-storage.md" },
|
|
284
|
+
"cloud.azure.storage.get_file_info": { "file": "integrations/cloud-storage.md" },
|
|
285
|
+
"cloud.google.storage.upload_file": { "file": "integrations/cloud-storage.md" },
|
|
286
|
+
"cloud.google.storage.read_file": { "file": "integrations/cloud-storage.md" },
|
|
287
|
+
"cloud.google.storage.sign_url": { "file": "integrations/cloud-storage.md" },
|
|
288
|
+
"cloud.google.storage.list_directory": { "file": "integrations/cloud-storage.md" },
|
|
289
|
+
"cloud.google.storage.delete_file": { "file": "integrations/cloud-storage.md" },
|
|
290
|
+
"cloud.google.storage.get_file_info": { "file": "integrations/cloud-storage.md" },
|
|
291
|
+
"cloud.elasticsearch.request": { "file": "integrations/search.md" },
|
|
292
|
+
"cloud.aws.opensearch.request": { "file": "integrations/search.md" },
|
|
293
|
+
"cloud.algolia.request": { "file": "integrations/search.md" }
|
|
225
294
|
},
|
|
226
295
|
|
|
227
296
|
"tasks": {
|
|
@@ -10,9 +10,9 @@ applyTo: "function/**/*.xs, api/**/*.xs, task/**/*.xs"
|
|
|
10
10
|
|
|
11
11
|
| Provider | Prefix | Operations |
|
|
12
12
|
|----------|--------|------------|
|
|
13
|
-
| AWS S3 | `cloud.aws.s3.*` | upload_file, read_file, sign_url, list_directory, delete_file |
|
|
14
|
-
| Azure Blob | `cloud.azure.storage.*` | upload_file, read_file, sign_url |
|
|
15
|
-
| Google Cloud | `cloud.google.storage.*` | upload_file, read_file, sign_url |
|
|
13
|
+
| AWS S3 | `cloud.aws.s3.*` | upload_file, read_file, sign_url, list_directory, delete_file, get_file_info |
|
|
14
|
+
| Azure Blob | `cloud.azure.storage.*` | upload_file, read_file, sign_url, list_directory, delete_file, get_file_info |
|
|
15
|
+
| Google Cloud | `cloud.google.storage.*` | upload_file, read_file, sign_url, list_directory, delete_file, get_file_info |
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
@@ -75,6 +75,17 @@ cloud.aws.s3.delete_file {
|
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
### Get File Info
|
|
79
|
+
```xs
|
|
80
|
+
cloud.aws.s3.get_file_info {
|
|
81
|
+
bucket = "my-bucket"
|
|
82
|
+
region = "us-east-1"
|
|
83
|
+
key = $env.AWS_ACCESS_KEY
|
|
84
|
+
secret = $env.AWS_SECRET_KEY
|
|
85
|
+
file_key = "items/photo.jpg"
|
|
86
|
+
} as $file_metadata
|
|
87
|
+
```
|
|
88
|
+
|
|
78
89
|
---
|
|
79
90
|
|
|
80
91
|
## Azure Blob Storage
|
|
@@ -102,6 +113,30 @@ cloud.azure.storage.sign_url {
|
|
|
102
113
|
path = "document.pdf"
|
|
103
114
|
ttl = 300
|
|
104
115
|
} as $url
|
|
116
|
+
|
|
117
|
+
// List directory
|
|
118
|
+
cloud.azure.storage.list_directory {
|
|
119
|
+
account_name = $env.AZURE_ACCOUNT
|
|
120
|
+
account_key = $env.AZURE_KEY
|
|
121
|
+
container_name = "archives"
|
|
122
|
+
path = "2023/"
|
|
123
|
+
} as $yearly_archives
|
|
124
|
+
|
|
125
|
+
// Delete file
|
|
126
|
+
cloud.azure.storage.delete_file {
|
|
127
|
+
account_name = $env.AZURE_ACCOUNT
|
|
128
|
+
account_key = $env.AZURE_KEY
|
|
129
|
+
container_name = "temp_files"
|
|
130
|
+
filePath = "drafts/old_draft.docx"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Get file info
|
|
134
|
+
cloud.azure.storage.get_file_info {
|
|
135
|
+
account_name = $env.AZURE_ACCOUNT
|
|
136
|
+
account_key = $env.AZURE_KEY
|
|
137
|
+
container_name = "media"
|
|
138
|
+
filePath = "videos/intro.mp4"
|
|
139
|
+
} as $video_metadata
|
|
105
140
|
```
|
|
106
141
|
|
|
107
142
|
---
|
|
@@ -129,6 +164,27 @@ cloud.google.storage.sign_url {
|
|
|
129
164
|
method = "GET"
|
|
130
165
|
ttl = 300
|
|
131
166
|
} as $url
|
|
167
|
+
|
|
168
|
+
// List directory
|
|
169
|
+
cloud.google.storage.list_directory {
|
|
170
|
+
service_account = $env.GCP_SERVICE_ACCOUNT
|
|
171
|
+
bucket = "my-bucket"
|
|
172
|
+
path = "designs/"
|
|
173
|
+
} as $design_files
|
|
174
|
+
|
|
175
|
+
// Delete file
|
|
176
|
+
cloud.google.storage.delete_file {
|
|
177
|
+
service_account = $env.GCP_SERVICE_ACCOUNT
|
|
178
|
+
bucket = "my-bucket"
|
|
179
|
+
filePath = "old/temp_data.csv"
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Get file info
|
|
183
|
+
cloud.google.storage.get_file_info {
|
|
184
|
+
service_account = $env.GCP_SERVICE_ACCOUNT
|
|
185
|
+
bucket = "my-bucket"
|
|
186
|
+
filePath = "icons/app_icon.png"
|
|
187
|
+
} as $icon_details
|
|
132
188
|
```
|
|
133
189
|
|
|
134
190
|
---
|
|
@@ -20,6 +20,8 @@ applyTo: "function/**/*.xs, api/**/*.xs, task/**/*.xs"
|
|
|
20
20
|
| `redis.range` | Get list range |
|
|
21
21
|
| `redis.count` | Get list length |
|
|
22
22
|
| `redis.ratelimit` | Rate limiting |
|
|
23
|
+
| `redis.remove` | Remove elements from list |
|
|
24
|
+
| `redis.keys` | Search keys by pattern |
|
|
23
25
|
|
|
24
26
|
---
|
|
25
27
|
|
|
@@ -48,13 +50,13 @@ redis.del { key = "user:123:session" }
|
|
|
48
50
|
## Counters
|
|
49
51
|
|
|
50
52
|
```xs
|
|
51
|
-
|
|
53
|
+
// Increment
|
|
52
54
|
redis.incr {
|
|
53
55
|
key = "page_views"
|
|
54
56
|
by = 1
|
|
55
57
|
} as $new_count
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
// Decrement
|
|
58
60
|
redis.decr {
|
|
59
61
|
key = "inventory:item-123"
|
|
60
62
|
by = 1
|
|
@@ -66,33 +68,51 @@ redis.decr {
|
|
|
66
68
|
## Lists
|
|
67
69
|
|
|
68
70
|
```xs
|
|
69
|
-
|
|
71
|
+
// Push to end
|
|
70
72
|
redis.push {
|
|
71
73
|
key = "queue:tasks"
|
|
72
74
|
value = $task
|
|
73
75
|
} as $length
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
// Push to front
|
|
76
78
|
redis.unshift {
|
|
77
79
|
key = "queue:priority"
|
|
78
80
|
value = $urgent_task
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
// Pop from end
|
|
82
84
|
redis.pop { key = "queue:tasks" } as $task
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
// Pop from front
|
|
85
87
|
redis.shift { key = "queue:tasks" } as $task
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
// Get range
|
|
88
90
|
redis.range {
|
|
89
91
|
key = "recent:logs"
|
|
90
92
|
start = 0
|
|
91
93
|
stop = 9
|
|
92
94
|
} as $logs
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
// Count
|
|
95
97
|
redis.count { key = "queue:tasks" } as $count
|
|
98
|
+
|
|
99
|
+
// Remove specific elements from list
|
|
100
|
+
redis.remove {
|
|
101
|
+
key = "user_list"
|
|
102
|
+
value = "inactive_user"
|
|
103
|
+
count = 1
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Key Management
|
|
110
|
+
|
|
111
|
+
```xs
|
|
112
|
+
// Search keys by pattern
|
|
113
|
+
redis.keys {
|
|
114
|
+
search = "user_*"
|
|
115
|
+
} as $user_keys
|
|
96
116
|
```
|
|
97
117
|
|
|
98
118
|
---
|
|
@@ -10,9 +10,9 @@ applyTo: "function/**/*.xs, api/**/*.xs, task/**/*.xs"
|
|
|
10
10
|
|
|
11
11
|
| Provider | Prefix | Operations |
|
|
12
12
|
|----------|--------|------------|
|
|
13
|
-
| Elasticsearch | `cloud.elasticsearch.*` | query, document, bulk |
|
|
14
|
-
| AWS OpenSearch | `cloud.aws.opensearch.*` | query, document |
|
|
15
|
-
| Algolia | `cloud.algolia.*` | search, save_object, save_objects, delete_object, set_settings |
|
|
13
|
+
| Elasticsearch | `cloud.elasticsearch.*` | query, document, request, bulk |
|
|
14
|
+
| AWS OpenSearch | `cloud.aws.opensearch.*` | query, document, request |
|
|
15
|
+
| Algolia | `cloud.algolia.*` | search, request, save_object, save_objects, delete_object, set_settings |
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
@@ -93,6 +93,19 @@ cloud.elasticsearch.bulk {
|
|
|
93
93
|
} as $result
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
### Raw Request
|
|
97
|
+
|
|
98
|
+
```xs
|
|
99
|
+
cloud.elasticsearch.request {
|
|
100
|
+
auth_type = "API Key"
|
|
101
|
+
key_id = $env.ES_KEY_ID
|
|
102
|
+
access_key = $env.ES_ACCESS_KEY
|
|
103
|
+
method = "GET"
|
|
104
|
+
url = "https://my-cluster.es.io/posts/_search"
|
|
105
|
+
query = { query: { match: { category: "tech" } } }
|
|
106
|
+
} as $search_results
|
|
107
|
+
```
|
|
108
|
+
|
|
96
109
|
### Advanced Search
|
|
97
110
|
|
|
98
111
|
```xs
|
|
@@ -147,6 +160,17 @@ cloud.aws.opensearch.query {
|
|
|
147
160
|
size = 100
|
|
148
161
|
} as $logs
|
|
149
162
|
|
|
163
|
+
// Raw request
|
|
164
|
+
cloud.aws.opensearch.request {
|
|
165
|
+
auth_type = "IAM"
|
|
166
|
+
key_id = $env.AWS_ACCESS_KEY
|
|
167
|
+
access_key = $env.AWS_SECRET_KEY
|
|
168
|
+
region = "us-east-1"
|
|
169
|
+
method = "POST"
|
|
170
|
+
url = "https://search-domain.us-east-1.es.amazonaws.com/_search"
|
|
171
|
+
query = { query: { term: { status: "active" } } }
|
|
172
|
+
} as $active_items
|
|
173
|
+
|
|
150
174
|
// Index document
|
|
151
175
|
cloud.aws.opensearch.document {
|
|
152
176
|
region = "us-east-1"
|
|
@@ -164,6 +188,18 @@ cloud.aws.opensearch.document {
|
|
|
164
188
|
|
|
165
189
|
## Algolia
|
|
166
190
|
|
|
191
|
+
### Raw Request
|
|
192
|
+
|
|
193
|
+
```xs
|
|
194
|
+
cloud.algolia.request {
|
|
195
|
+
application_id = $env.ALGOLIA_APP_ID
|
|
196
|
+
api_key = $env.ALGOLIA_API_KEY
|
|
197
|
+
url = "https://my-algolia-app.algolia.net/1/indexes/posts/query"
|
|
198
|
+
method = "POST"
|
|
199
|
+
payload = { query: "tech" }
|
|
200
|
+
} as $tech_posts
|
|
201
|
+
```
|
|
202
|
+
|
|
167
203
|
### Search
|
|
168
204
|
|
|
169
205
|
```xs
|
|
@@ -294,6 +294,31 @@ api.lambda {
|
|
|
294
294
|
|
|
295
295
|
## Utilities
|
|
296
296
|
|
|
297
|
+
### Headers
|
|
298
|
+
|
|
299
|
+
```xs
|
|
300
|
+
// Set a response header
|
|
301
|
+
util.set_header {
|
|
302
|
+
value = "Set-Cookie: sessionId=e8bb43229de9; HttpOnly; Secure; Domain=foo.example.com"
|
|
303
|
+
duplicates = "replace"
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Request Introspection
|
|
308
|
+
|
|
309
|
+
```xs
|
|
310
|
+
// Get all environment variables
|
|
311
|
+
util.get_env as $environment_vars
|
|
312
|
+
|
|
313
|
+
// Get all parsed input data
|
|
314
|
+
util.get_all_input as $input_data
|
|
315
|
+
|
|
316
|
+
// Get raw, unparsed input data
|
|
317
|
+
util.get_input as $raw_input
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Template Engine, IP Lookup, Geo & Sleep
|
|
321
|
+
|
|
297
322
|
```xs
|
|
298
323
|
// Template engine (Twig)
|
|
299
324
|
util.template_engine {
|
|
@@ -410,6 +410,45 @@ input {
|
|
|
410
410
|
}
|
|
411
411
|
```
|
|
412
412
|
|
|
413
|
+
### Key Generation
|
|
414
|
+
|
|
415
|
+
```xs
|
|
416
|
+
// Generate elliptic curve key
|
|
417
|
+
security.create_curve_key {
|
|
418
|
+
curve = "P-256"
|
|
419
|
+
format = "object"
|
|
420
|
+
} as $crypto_key
|
|
421
|
+
|
|
422
|
+
// Generate secret key for symmetric encryption
|
|
423
|
+
security.create_secret_key {
|
|
424
|
+
bits = 2048
|
|
425
|
+
format = "object"
|
|
426
|
+
} as $secret_key
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### JWE (Encrypted JWT)
|
|
430
|
+
|
|
431
|
+
```xs
|
|
432
|
+
// Encrypt JWT payload
|
|
433
|
+
security.jwe_encode {
|
|
434
|
+
headers = { "alg": "A256KW" }
|
|
435
|
+
claims = { data: "secret" }
|
|
436
|
+
key = $env.JWE_KEY
|
|
437
|
+
key_algorithm = "A256KW"
|
|
438
|
+
content_algorithm = "A256GCM"
|
|
439
|
+
ttl = 3600
|
|
440
|
+
} as $encrypted_token
|
|
441
|
+
|
|
442
|
+
// Decrypt JWE token
|
|
443
|
+
security.jwe_decode {
|
|
444
|
+
token = $encrypted_token
|
|
445
|
+
key = $env.JWE_KEY
|
|
446
|
+
key_algorithm = "A256KW"
|
|
447
|
+
content_algorithm = "A256GCM"
|
|
448
|
+
check_claims = { "iss": "my_app" }
|
|
449
|
+
} as $decoded_payload
|
|
450
|
+
```
|
|
451
|
+
|
|
413
452
|
### JWT Security
|
|
414
453
|
|
|
415
454
|
```xs
|
|
@@ -18,6 +18,10 @@ Complete reference for XanoScript expressions, operators, and filters.
|
|
|
18
18
|
| [Math Filters](#math-filters) | `add`, `subtract`, `round`, `abs`, `ceil`, `floor` |
|
|
19
19
|
| [String Filters](#string-filters) | `trim`, `to_lower`, `to_upper`, `substr`, `split`, `replace` |
|
|
20
20
|
| [Array Filters](#array-filters) | `first`, `last`, `count`, `map`, `filter`, `reduce` |
|
|
21
|
+
| [Array Functions](#array-functions) | `array.push`, `array.pop`, `array.map`, `array.filter`, `array.group_by` |
|
|
22
|
+
| [Text Functions](#text-functions) | `text.contains`, `text.starts_with`, `text.trim`, `text.append`, `text.prepend` |
|
|
23
|
+
| [Math Functions](#math-functions) | `math.add`, `math.sub`, `math.mul`, `math.div`, `math.bitwise.*` |
|
|
24
|
+
| [Object Functions](#object-functions) | `object.keys`, `object.values`, `object.entries` |
|
|
21
25
|
| [Object Filters](#object-filters) | `get`, `set`, `has`, `keys`, `values` |
|
|
22
26
|
| [Type Filters](#type-filters) | `to_int`, `to_text`, `to_bool`, `json_encode` |
|
|
23
27
|
| [Date/Time Filters](#datetime-filters) | `to_timestamp`, `format_timestamp` |
|
|
@@ -56,12 +60,13 @@ Working with...
|
|
|
56
60
|
├── Arrays? → USE ARRAY FILTERS ONLY (see Array Filters section)
|
|
57
61
|
│ ├── Get element? → first, last, get
|
|
58
62
|
│ ├── Count items? → count (NOT strlen)
|
|
59
|
-
│ ├── Transform all? → map
|
|
60
|
-
│ ├── Keep some? → filter
|
|
61
|
-
│ ├── Find one? → find
|
|
63
|
+
│ ├── Transform all? → map (filter) or array.map (statement)
|
|
64
|
+
│ ├── Keep some? → filter (filter) or array.filter (statement)
|
|
65
|
+
│ ├── Find one? → find (filter) or array.find (statement)
|
|
62
66
|
│ ├── Combine? → reduce
|
|
63
67
|
│ ├── Reverse? → reverse (NOT available on strings)
|
|
64
|
-
│
|
|
68
|
+
│ ├── Sort? → sort
|
|
69
|
+
│ └── Statement-level ops? → See Array Functions (array.push, array.pop, etc.)
|
|
65
70
|
├── Objects?
|
|
66
71
|
│ ├── Get value? → get
|
|
67
72
|
│ ├── Set value? → set
|
|
@@ -335,6 +340,408 @@ Generate numeric ranges with the `..` operator:
|
|
|
335
340
|
|
|
336
341
|
---
|
|
337
342
|
|
|
343
|
+
## Array Functions
|
|
344
|
+
|
|
345
|
+
Statement-level functions for manipulating arrays within stacks. Unlike filters (e.g., `$arr|push:3`), these are standalone operations.
|
|
346
|
+
|
|
347
|
+
> **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`.
|
|
348
|
+
|
|
349
|
+
### array.push
|
|
350
|
+
|
|
351
|
+
Appends a new element to the end of an array.
|
|
352
|
+
|
|
353
|
+
```xs
|
|
354
|
+
array.push $shopping_cart {
|
|
355
|
+
value = "oranges"
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### array.unshift
|
|
360
|
+
|
|
361
|
+
Inserts a new element at the beginning of an array, shifting existing elements to higher indexes.
|
|
362
|
+
|
|
363
|
+
```xs
|
|
364
|
+
array.unshift $priority_tasks {
|
|
365
|
+
value = "urgent meeting"
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### array.pop
|
|
370
|
+
|
|
371
|
+
Removes and returns the last element of an array. The removed element is stored in the `as` variable.
|
|
372
|
+
|
|
373
|
+
```xs
|
|
374
|
+
array.pop $completed_tasks as $last_finished_task
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### array.shift
|
|
378
|
+
|
|
379
|
+
Removes and returns the first element of an array. The removed element is stored in the `as` variable.
|
|
380
|
+
|
|
381
|
+
```xs
|
|
382
|
+
array.shift $waiting_list as $next_customer
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### array.merge
|
|
386
|
+
|
|
387
|
+
Combines another array or a single value into the target array, appending all elements from the provided `value`.
|
|
388
|
+
|
|
389
|
+
```xs
|
|
390
|
+
array.merge $active_users {
|
|
391
|
+
value = $new_users
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### array.find
|
|
396
|
+
|
|
397
|
+
Searches an array and returns the first element that meets the specified condition. Returns `null` if no match.
|
|
398
|
+
|
|
399
|
+
```xs
|
|
400
|
+
array.find $customer_ages if ($this > 18) as $first_adult_age
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### array.find_index
|
|
404
|
+
|
|
405
|
+
Returns the index of the first element that satisfies the condition. Returns `-1` if no match.
|
|
406
|
+
|
|
407
|
+
```xs
|
|
408
|
+
array.find_index $sale_prices if ($this < 20) as $first_discount_index
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### array.has
|
|
412
|
+
|
|
413
|
+
Checks if at least one element meets the condition. Returns `true` or `false`.
|
|
414
|
+
|
|
415
|
+
```xs
|
|
416
|
+
array.has $team_roles if ($this == "manager") as $has_manager
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### array.every
|
|
420
|
+
|
|
421
|
+
Tests whether every element satisfies the condition. Returns `true` if all pass, `false` otherwise.
|
|
422
|
+
|
|
423
|
+
```xs
|
|
424
|
+
array.every $exam_scores if ($this >= 70) as $all_passed
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### array.filter
|
|
428
|
+
|
|
429
|
+
Creates a new array containing only the elements that meet the condition.
|
|
430
|
+
|
|
431
|
+
```xs
|
|
432
|
+
array.filter $temperatures if ($this > 32) as $above_freezing
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### array.filter_count
|
|
436
|
+
|
|
437
|
+
Counts how many elements satisfy the condition.
|
|
438
|
+
|
|
439
|
+
```xs
|
|
440
|
+
array.filter_count $survey_responses if ($this == "yes") as $yes_count
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### array.map
|
|
444
|
+
|
|
445
|
+
Transforms each element in an array based on a specified mapping. The `by` parameter defines the transformation.
|
|
446
|
+
|
|
447
|
+
```xs
|
|
448
|
+
array.map ($json) {
|
|
449
|
+
by = $this.email
|
|
450
|
+
} as $emails
|
|
451
|
+
|
|
452
|
+
array.map ($json) {
|
|
453
|
+
by = {name: $this.name, gender: $this.gender}
|
|
454
|
+
} as $people
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### array.partition
|
|
458
|
+
|
|
459
|
+
Divides an array into two groups based on a condition. Returns an object with `true` and `false` keys.
|
|
460
|
+
|
|
461
|
+
```xs
|
|
462
|
+
array.partition ($json) if ($this.gender == "male") as $is_male
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### array.group_by
|
|
466
|
+
|
|
467
|
+
Groups elements based on a specified key or expression. Returns an object where each key is a group.
|
|
468
|
+
|
|
469
|
+
```xs
|
|
470
|
+
array.group_by ($users) {
|
|
471
|
+
by = $this.gender
|
|
472
|
+
} as $user_by_gender
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### array.union
|
|
476
|
+
|
|
477
|
+
Combines two arrays ensuring all elements are unique based on the `by` key.
|
|
478
|
+
|
|
479
|
+
```xs
|
|
480
|
+
array.union ([1,3,5,7,9]) {
|
|
481
|
+
value = [2,4,6,8]
|
|
482
|
+
by = $this
|
|
483
|
+
} as $union
|
|
484
|
+
// Result: [1,2,3,4,5,6,7,8,9]
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### array.difference
|
|
488
|
+
|
|
489
|
+
Returns elements present in the first array but not in the second, based on the `by` key.
|
|
490
|
+
|
|
491
|
+
```xs
|
|
492
|
+
array.difference ([1,2,3,4,5,6,7,8,9]) {
|
|
493
|
+
value = [2,4,6,8]
|
|
494
|
+
by = $this
|
|
495
|
+
} as $difference
|
|
496
|
+
// Result: [1,3,5,7,9]
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### array.intersection
|
|
500
|
+
|
|
501
|
+
Returns elements present in both arrays, based on the `by` key.
|
|
502
|
+
|
|
503
|
+
```xs
|
|
504
|
+
array.intersection ([1,2,3,4,5,6,7,8,9]) {
|
|
505
|
+
value = [2,4,6,8]
|
|
506
|
+
by = $this
|
|
507
|
+
} as $intersection
|
|
508
|
+
// Result: [2,4,6,8]
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## Text Functions
|
|
514
|
+
|
|
515
|
+
Statement-level functions for text manipulation within stacks. These operate directly on variables — checking conditions (returning `true`/`false` via `as`) or mutating the variable in place.
|
|
516
|
+
|
|
517
|
+
> **Syntax note:** 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 and do not return a value.
|
|
518
|
+
|
|
519
|
+
### text.contains
|
|
520
|
+
|
|
521
|
+
Checks if a text string contains the specified value. Returns `true` if found, `false` otherwise.
|
|
522
|
+
|
|
523
|
+
```xs
|
|
524
|
+
text.contains $log_entry {
|
|
525
|
+
value = "error"
|
|
526
|
+
} as $has_error
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### text.icontains
|
|
530
|
+
|
|
531
|
+
Performs a case-insensitive check to see if a text string contains the specified value.
|
|
532
|
+
|
|
533
|
+
```xs
|
|
534
|
+
text.icontains $description {
|
|
535
|
+
value = "error"
|
|
536
|
+
} as $has_error
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### text.starts_with
|
|
540
|
+
|
|
541
|
+
Checks if a text string begins with the specified value.
|
|
542
|
+
|
|
543
|
+
```xs
|
|
544
|
+
text.starts_with $message {
|
|
545
|
+
value = "Hello"
|
|
546
|
+
} as $starts_with_hello
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### text.istarts_with
|
|
550
|
+
|
|
551
|
+
Performs a case-insensitive check to see if a text string starts with the specified value.
|
|
552
|
+
|
|
553
|
+
```xs
|
|
554
|
+
text.istarts_with $title {
|
|
555
|
+
value = "intro"
|
|
556
|
+
} as $starts_with_intro
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### text.ends_with
|
|
560
|
+
|
|
561
|
+
Checks if a text string ends with the specified value.
|
|
562
|
+
|
|
563
|
+
```xs
|
|
564
|
+
text.ends_with $url {
|
|
565
|
+
value = ".com"
|
|
566
|
+
} as $is_com_domain
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### text.iends_with
|
|
570
|
+
|
|
571
|
+
Performs a case-insensitive check to see if a text string ends with the specified value.
|
|
572
|
+
|
|
573
|
+
```xs
|
|
574
|
+
text.iends_with $filename {
|
|
575
|
+
value = "pdf"
|
|
576
|
+
} as $ends_with_pdf
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### text.trim
|
|
580
|
+
|
|
581
|
+
Removes characters (default is whitespace, or as specified by `value`) from both the beginning and end of a text string. Mutates the variable directly.
|
|
582
|
+
|
|
583
|
+
```xs
|
|
584
|
+
text.trim $user_input {
|
|
585
|
+
value = " "
|
|
586
|
+
}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### text.ltrim
|
|
590
|
+
|
|
591
|
+
Removes leading characters (default is whitespace, or as specified by `value`) from a text string. Mutates the variable directly.
|
|
592
|
+
|
|
593
|
+
```xs
|
|
594
|
+
text.ltrim $user_input {
|
|
595
|
+
value = " "
|
|
596
|
+
}
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
### text.rtrim
|
|
600
|
+
|
|
601
|
+
Removes trailing characters (default is whitespace, or as specified by `value`) from a text string. Mutates the variable directly.
|
|
602
|
+
|
|
603
|
+
```xs
|
|
604
|
+
text.rtrim $user_input {
|
|
605
|
+
value = " "
|
|
606
|
+
}
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
### text.append
|
|
610
|
+
|
|
611
|
+
Adds the specified value to the end of a text string. Mutates the variable directly.
|
|
612
|
+
|
|
613
|
+
```xs
|
|
614
|
+
text.append $greeting {
|
|
615
|
+
value = ", welcome!"
|
|
616
|
+
}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
### text.prepend
|
|
620
|
+
|
|
621
|
+
Adds the specified value to the beginning of a text string. Mutates the variable directly.
|
|
622
|
+
|
|
623
|
+
```xs
|
|
624
|
+
text.prepend $message {
|
|
625
|
+
value = "Alert: "
|
|
626
|
+
}
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
---
|
|
630
|
+
|
|
631
|
+
## Math Functions
|
|
632
|
+
|
|
633
|
+
Statement-level functions for arithmetic and bitwise operations within stacks. These mutate the target variable directly and do not return a value.
|
|
634
|
+
|
|
635
|
+
> **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.
|
|
636
|
+
|
|
637
|
+
### math.add
|
|
638
|
+
|
|
639
|
+
Adds the specified value to the variable.
|
|
640
|
+
|
|
641
|
+
```xs
|
|
642
|
+
math.add $cart_total {
|
|
643
|
+
value = $item_price
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
### math.sub
|
|
648
|
+
|
|
649
|
+
Subtracts the specified value from the variable.
|
|
650
|
+
|
|
651
|
+
```xs
|
|
652
|
+
math.sub $total_cost {
|
|
653
|
+
value = $discount_amount
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
### math.mul
|
|
658
|
+
|
|
659
|
+
Multiplies the variable by the specified value.
|
|
660
|
+
|
|
661
|
+
```xs
|
|
662
|
+
math.mul $base_price {
|
|
663
|
+
value = $tax_rate
|
|
664
|
+
}
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### math.div
|
|
668
|
+
|
|
669
|
+
Divides the variable by the specified value.
|
|
670
|
+
|
|
671
|
+
```xs
|
|
672
|
+
math.div $total_time {
|
|
673
|
+
value = $num_tasks
|
|
674
|
+
}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
### math.bitwise.and
|
|
678
|
+
|
|
679
|
+
Performs a bitwise AND operation on the variable.
|
|
680
|
+
|
|
681
|
+
```xs
|
|
682
|
+
math.bitwise.and $status_flags {
|
|
683
|
+
value = $check_bit
|
|
684
|
+
}
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
### math.bitwise.or
|
|
688
|
+
|
|
689
|
+
Performs a bitwise OR operation on the variable.
|
|
690
|
+
|
|
691
|
+
```xs
|
|
692
|
+
math.bitwise.or $permissions {
|
|
693
|
+
value = $new_permission
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### math.bitwise.xor
|
|
698
|
+
|
|
699
|
+
Performs a bitwise XOR operation on the variable.
|
|
700
|
+
|
|
701
|
+
```xs
|
|
702
|
+
math.bitwise.xor $flags {
|
|
703
|
+
value = $toggle_bit
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
---
|
|
708
|
+
|
|
709
|
+
## Object Functions
|
|
710
|
+
|
|
711
|
+
Statement-level functions for extracting object properties within stacks. These return results via the `as` variable.
|
|
712
|
+
|
|
713
|
+
### object.keys
|
|
714
|
+
|
|
715
|
+
Retrieves the property keys of an object as an array.
|
|
716
|
+
|
|
717
|
+
```xs
|
|
718
|
+
object.keys {
|
|
719
|
+
value = $user_data
|
|
720
|
+
} as $user_data_keys
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
### object.values
|
|
724
|
+
|
|
725
|
+
Extracts the values of an object's properties into an array.
|
|
726
|
+
|
|
727
|
+
```xs
|
|
728
|
+
object.values {
|
|
729
|
+
value = $product_info
|
|
730
|
+
} as $product_values
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
### object.entries
|
|
734
|
+
|
|
735
|
+
Returns an array of key-value pairs from an object.
|
|
736
|
+
|
|
737
|
+
```xs
|
|
738
|
+
object.entries {
|
|
739
|
+
value = $settings
|
|
740
|
+
} as $settings_pairs
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
---
|
|
744
|
+
|
|
338
745
|
## Object Filters
|
|
339
746
|
|
|
340
747
|
| Filter | Example | Result |
|
package/package.json
CHANGED