@xano/developer-mcp 1.0.35 → 1.0.36

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.
Files changed (31) hide show
  1. package/README.md +17 -2
  2. package/dist/xanoscript.js +31 -1
  3. package/dist/xanoscript.test.js +6 -0
  4. package/dist/xanoscript_docs/README.md +42 -42
  5. package/dist/xanoscript_docs/addons.md +10 -0
  6. package/dist/xanoscript_docs/agents.md +15 -0
  7. package/dist/xanoscript_docs/apis.md +45 -24
  8. package/dist/xanoscript_docs/cheatsheet.md +252 -0
  9. package/dist/xanoscript_docs/database.md +23 -0
  10. package/dist/xanoscript_docs/docs_index.json +236 -0
  11. package/dist/xanoscript_docs/frontend.md +10 -0
  12. package/dist/xanoscript_docs/functions.md +4 -0
  13. package/dist/xanoscript_docs/integrations/cloud-storage.md +142 -0
  14. package/dist/xanoscript_docs/integrations/external-apis.md +201 -0
  15. package/dist/xanoscript_docs/integrations/redis.md +194 -0
  16. package/dist/xanoscript_docs/integrations/search.md +242 -0
  17. package/dist/xanoscript_docs/integrations/utilities.md +331 -0
  18. package/dist/xanoscript_docs/integrations.md +55 -901
  19. package/dist/xanoscript_docs/mcp-servers.md +10 -0
  20. package/dist/xanoscript_docs/performance.md +15 -0
  21. package/dist/xanoscript_docs/quickstart.md +22 -88
  22. package/dist/xanoscript_docs/run.md +10 -0
  23. package/dist/xanoscript_docs/security.md +26 -0
  24. package/dist/xanoscript_docs/streaming.md +10 -0
  25. package/dist/xanoscript_docs/syntax.md +56 -0
  26. package/dist/xanoscript_docs/tables.md +15 -0
  27. package/dist/xanoscript_docs/tasks.md +11 -0
  28. package/dist/xanoscript_docs/tools.md +15 -0
  29. package/dist/xanoscript_docs/triggers.md +57 -192
  30. package/dist/xanoscript_docs/types.md +4 -0
  31. package/package.json +1 -1
@@ -4,910 +4,64 @@ applyTo: "function/**/*.xs, api/**/*.xs, task/**/*.xs"
4
4
 
5
5
  # Integrations
6
6
 
7
- Cloud services, Redis, storage, archives, and security operations.
7
+ > **TL;DR:** External service integrations. Use specific sub-topics for detailed documentation.
8
8
 
9
- ## Quick Reference
10
-
11
- ### Cloud Storage
12
- | Provider | Prefix |
13
- |----------|--------|
14
- | AWS S3 | `cloud.aws.s3.*` |
15
- | Azure Blob | `cloud.azure.storage.*` |
16
- | Google Cloud | `cloud.google.storage.*` |
17
-
18
- ### Search
19
- | Provider | Prefix |
20
- |----------|--------|
21
- | Elasticsearch | `cloud.elasticsearch.*` |
22
- | AWS OpenSearch | `cloud.aws.opensearch.*` |
23
- | Algolia | `cloud.algolia.*` |
24
-
25
- ### Other
26
- | Service | Prefix |
27
- |---------|--------|
28
- | Redis | `redis.*` |
29
- | Storage | `storage.*` |
30
- | Security | `security.*` |
31
- | Zip/Archive | `zip.*` |
32
- | Lambda | `api.lambda` |
33
-
34
- ---
35
-
36
- ## AWS S3
37
-
38
- ### Upload File
39
- ```xs
40
- cloud.aws.s3.upload_file {
41
- bucket = "my-bucket"
42
- region = "us-east-1"
43
- key = $env.AWS_ACCESS_KEY
44
- secret = $env.AWS_SECRET_KEY
45
- file_key = "uploads/" ~ $input.filename
46
- file = $input.file
47
- } as $result
48
- ```
49
-
50
- ### Read File
51
- ```xs
52
- cloud.aws.s3.read_file {
53
- bucket = "my-bucket"
54
- region = "us-east-1"
55
- key = $env.AWS_ACCESS_KEY
56
- secret = $env.AWS_SECRET_KEY
57
- file_key = "data/config.json"
58
- } as $file
59
- ```
60
-
61
- ### Sign URL
62
- ```xs
63
- cloud.aws.s3.sign_url {
64
- bucket = "my-bucket"
65
- region = "us-east-1"
66
- key = $env.AWS_ACCESS_KEY
67
- secret = $env.AWS_SECRET_KEY
68
- file_key = "private/document.pdf"
69
- ttl = 300
70
- } as $signed_url
71
- ```
72
-
73
- ### List Directory
74
- ```xs
75
- cloud.aws.s3.list_directory {
76
- bucket = "my-bucket"
77
- region = "us-east-1"
78
- key = $env.AWS_ACCESS_KEY
79
- secret = $env.AWS_SECRET_KEY
80
- prefix = "uploads/"
81
- } as $files
82
- ```
83
-
84
- ### Delete File
85
- ```xs
86
- cloud.aws.s3.delete_file {
87
- bucket = "my-bucket"
88
- region = "us-east-1"
89
- key = $env.AWS_ACCESS_KEY
90
- secret = $env.AWS_SECRET_KEY
91
- file_key = "temp/old-file.txt"
92
- }
93
- ```
94
-
95
- ---
96
-
97
- ## Azure Blob Storage
98
-
99
- ```xs
100
- cloud.azure.storage.upload_file {
101
- account_name = $env.AZURE_ACCOUNT
102
- account_key = $env.AZURE_KEY
103
- container_name = "files"
104
- filePath = "uploads/doc.pdf"
105
- file = $input.file
106
- }
107
-
108
- cloud.azure.storage.read_file {
109
- account_name = $env.AZURE_ACCOUNT
110
- account_key = $env.AZURE_KEY
111
- container_name = "files"
112
- filePath = "data/config.json"
113
- } as $file
114
-
115
- cloud.azure.storage.sign_url {
116
- account_name = $env.AZURE_ACCOUNT
117
- account_key = $env.AZURE_KEY
118
- container_name = "private"
119
- path = "document.pdf"
120
- ttl = 300
121
- } as $url
122
- ```
123
-
124
- ---
125
-
126
- ## Google Cloud Storage
127
-
128
- ```xs
129
- cloud.google.storage.upload_file {
130
- service_account = $env.GCP_SERVICE_ACCOUNT
131
- bucket = "my-bucket"
132
- filePath = "uploads/file.pdf"
133
- file = $input.file
134
- }
135
-
136
- cloud.google.storage.read_file {
137
- service_account = $env.GCP_SERVICE_ACCOUNT
138
- bucket = "my-bucket"
139
- filePath = "data/config.json"
140
- } as $file
141
-
142
- cloud.google.storage.sign_url {
143
- service_account = $env.GCP_SERVICE_ACCOUNT
144
- bucket = "my-bucket"
145
- filePath = "private/doc.pdf"
146
- method = "GET"
147
- ttl = 300
148
- } as $url
149
- ```
150
-
151
- ---
152
-
153
- ## Elasticsearch
154
-
155
- ### Search Query
156
-
157
- ```xs
158
- cloud.elasticsearch.query {
159
- auth_type = "API Key"
160
- key_id = $env.ES_KEY_ID
161
- access_key = $env.ES_ACCESS_KEY
162
- base_url = "https://my-cluster.es.io"
163
- index = "products"
164
- return_type = "search"
165
- expression = [{ field: "category", value: "electronics", op: "eq" }]
166
- size = 10
167
- sort = [{ field: "price", order: "asc" }]
168
- } as $results
169
- ```
170
-
171
- ### Document Operations
172
-
173
- ```xs
174
- // Get document
175
- cloud.elasticsearch.document {
176
- auth_type = "API Key"
177
- key_id = $env.ES_KEY_ID
178
- access_key = $env.ES_ACCESS_KEY
179
- base_url = "https://my-cluster.es.io"
180
- index = "products"
181
- method = "GET"
182
- doc_id = "product-123"
183
- } as $doc
184
-
185
- // Index document
186
- cloud.elasticsearch.document {
187
- auth_type = "API Key"
188
- key_id = $env.ES_KEY_ID
189
- access_key = $env.ES_ACCESS_KEY
190
- base_url = "https://my-cluster.es.io"
191
- index = "products"
192
- method = "PUT"
193
- doc_id = "product-123"
194
- body = {
195
- name: "Product Name",
196
- category: "electronics",
197
- price: 99.99
198
- }
199
- }
200
-
201
- // Delete document
202
- cloud.elasticsearch.document {
203
- auth_type = "API Key"
204
- key_id = $env.ES_KEY_ID
205
- access_key = $env.ES_ACCESS_KEY
206
- base_url = "https://my-cluster.es.io"
207
- index = "products"
208
- method = "DELETE"
209
- doc_id = "product-123"
210
- }
211
- ```
212
-
213
- ### Bulk Operations
214
-
215
- ```xs
216
- cloud.elasticsearch.bulk {
217
- auth_type = "API Key"
218
- key_id = $env.ES_KEY_ID
219
- access_key = $env.ES_ACCESS_KEY
220
- base_url = "https://my-cluster.es.io"
221
- index = "products"
222
- operations = [
223
- { action: "index", id: "1", doc: { name: "Product 1" } },
224
- { action: "update", id: "2", doc: { price: 29.99 } },
225
- { action: "delete", id: "3" }
226
- ]
227
- } as $result
228
- ```
229
-
230
- ### Advanced Search
231
-
232
- ```xs
233
- cloud.elasticsearch.query {
234
- auth_type = "API Key"
235
- key_id = $env.ES_KEY_ID
236
- access_key = $env.ES_ACCESS_KEY
237
- base_url = "https://my-cluster.es.io"
238
- index = "products"
239
- return_type = "search"
240
- query = {
241
- bool: {
242
- must: [
243
- { match: { name: $input.search } }
244
- ],
245
- filter: [
246
- { range: { price: { gte: $input.min_price, lte: $input.max_price } } },
247
- { term: { is_active: true } }
248
- ]
249
- }
250
- }
251
- aggregations = {
252
- categories: { terms: { field: "category.keyword" } },
253
- avg_price: { avg: { field: "price" } }
254
- }
255
- size = 20
256
- from = $input.offset
257
- } as $results
258
- ```
259
-
260
- ---
261
-
262
- ## AWS OpenSearch
263
-
264
- ```xs
265
- cloud.aws.opensearch.query {
266
- region = "us-east-1"
267
- access_key = $env.AWS_ACCESS_KEY
268
- secret_key = $env.AWS_SECRET_KEY
269
- endpoint = "https://search-domain.us-east-1.es.amazonaws.com"
270
- index = "logs"
271
- query = {
272
- bool: {
273
- must: [
274
- { match: { level: "error" } }
275
- ],
276
- filter: [
277
- { range: { timestamp: { gte: "now-24h" } } }
278
- ]
279
- }
280
- }
281
- size = 100
282
- } as $logs
283
-
284
- // Index document
285
- cloud.aws.opensearch.document {
286
- region = "us-east-1"
287
- access_key = $env.AWS_ACCESS_KEY
288
- secret_key = $env.AWS_SECRET_KEY
289
- endpoint = "https://search-domain.us-east-1.es.amazonaws.com"
290
- index = "logs"
291
- method = "PUT"
292
- doc_id = $log_id
293
- body = $log_data
294
- }
295
- ```
296
-
297
- ---
298
-
299
- ## Algolia
300
-
301
- ### Search
302
-
303
- ```xs
304
- cloud.algolia.search {
305
- app_id = $env.ALGOLIA_APP_ID
306
- api_key = $env.ALGOLIA_API_KEY
307
- index = "products"
308
- query = $input.search
309
- filters = "category:electronics AND price<100"
310
- facets = ["category", "brand"]
311
- hitsPerPage = 20
312
- page = $input.page
313
- } as $results
314
- ```
315
-
316
- ### Manage Records
317
-
318
- ```xs
319
- // Add/update record
320
- cloud.algolia.save_object {
321
- app_id = $env.ALGOLIA_APP_ID
322
- api_key = $env.ALGOLIA_ADMIN_KEY
323
- index = "products"
324
- object = {
325
- objectID: $product.id|to_text,
326
- name: $product.name,
327
- category: $product.category,
328
- price: $product.price
329
- }
330
- }
331
-
332
- // Batch save
333
- cloud.algolia.save_objects {
334
- app_id = $env.ALGOLIA_APP_ID
335
- api_key = $env.ALGOLIA_ADMIN_KEY
336
- index = "products"
337
- objects = $products|map:{
338
- objectID: $$.id|to_text,
339
- name: $$.name,
340
- category: $$.category
341
- }
342
- }
343
-
344
- // Delete record
345
- cloud.algolia.delete_object {
346
- app_id = $env.ALGOLIA_APP_ID
347
- api_key = $env.ALGOLIA_ADMIN_KEY
348
- index = "products"
349
- objectID = $input.product_id|to_text
350
- }
351
- ```
352
-
353
- ### Configure Index
354
-
355
- ```xs
356
- cloud.algolia.set_settings {
357
- app_id = $env.ALGOLIA_APP_ID
358
- api_key = $env.ALGOLIA_ADMIN_KEY
359
- index = "products"
360
- settings = {
361
- searchableAttributes: ["name", "description", "category"],
362
- attributesForFaceting: ["category", "brand", "filterOnly(is_active)"],
363
- ranking: ["typo", "geo", "words", "filters", "proximity", "attribute", "exact", "custom"]
364
- }
365
- }
366
- ```
367
-
368
- ---
369
-
370
- ## Redis
371
-
372
- ### Key-Value Operations
373
- ```xs
374
- // Set value
375
- redis.set {
376
- key = "user:123:session"
377
- data = $session_data
378
- ttl = 3600 // Expires in 1 hour
379
- }
380
-
381
- // Get value
382
- redis.get { key = "user:123:session" } as $session
383
-
384
- // Check exists
385
- redis.has { key = "user:123:session" } as $exists
386
-
387
- // Delete
388
- redis.del { key = "user:123:session" }
389
- ```
390
-
391
- ### Counters
392
- ```xs
393
- # Increment
394
- redis.incr {
395
- key = "page_views"
396
- by = 1
397
- } as $new_count
398
-
399
- # Decrement
400
- redis.decr {
401
- key = "inventory:item-123"
402
- by = 1
403
- } as $new_count
404
- ```
405
-
406
- ### Lists
407
- ```xs
408
- # Push to end
409
- redis.push {
410
- key = "queue:tasks"
411
- value = $task
412
- } as $length
413
-
414
- # Push to front
415
- redis.unshift {
416
- key = "queue:priority"
417
- value = $urgent_task
418
- }
419
-
420
- # Pop from end
421
- redis.pop { key = "queue:tasks" } as $task
422
-
423
- # Pop from front
424
- redis.shift { key = "queue:tasks" } as $task
425
-
426
- # Get range
427
- redis.range {
428
- key = "recent:logs"
429
- start = 0
430
- stop = 9
431
- } as $logs
432
-
433
- # Count
434
- redis.count { key = "queue:tasks" } as $count
435
- ```
436
-
437
- ### Rate Limiting
438
- ```xs
439
- redis.ratelimit {
440
- key = "api:" ~ $env.$remote_ip
441
- max = 100
442
- ttl = 60
443
- error = "Rate limit exceeded"
444
- } as $status
445
- ```
446
-
447
- ---
448
-
449
- ## Local Storage
450
-
451
- ### File Operations
452
- ```xs
453
- # Create file resource
454
- storage.create_file_resource {
455
- filename = "report.csv"
456
- filedata = $csv_content
457
- } as $file
458
-
459
- # Read file resource
460
- storage.read_file_resource {
461
- value = $input.file
462
- } as $content
463
-
464
- # Delete file
465
- storage.delete_file { pathname = "temp/old-file.txt" }
466
- ```
467
-
468
- ### Image/Attachment Handling
469
- ```xs
470
- # Create image metadata
471
- storage.create_image {
472
- value = $input.image
473
- access = "public"
474
- filename = "profile.jpg"
475
- } as $image_meta
476
-
477
- # Create attachment metadata
478
- storage.create_attachment {
479
- value = $input.file
480
- access = "private"
481
- filename = "document.pdf"
482
- } as $attachment_meta
483
-
484
- # Sign private URL
485
- storage.sign_private_url {
486
- pathname = "private/document.pdf"
487
- ttl = 300
488
- } as $signed_url
489
- ```
490
-
491
- ---
492
-
493
- ## Security
494
-
495
- ### Password Hashing
496
- ```xs
497
- # Password is auto-hashed on insert
498
- db.add "user" {
499
- data = { email: $input.email, password: $input.password }
500
- }
501
-
502
- # Verify password
503
- security.check_password {
504
- text_password = $input.password
505
- hash_password = $user.password
506
- } as $is_valid
507
- ```
508
-
509
- ### Encryption
510
- ```xs
511
- # Encrypt
512
- security.encrypt {
513
- data = $sensitive_data
514
- algorithm = "aes-256-cbc"
515
- key = $env.ENCRYPTION_KEY
516
- iv = $env.ENCRYPTION_IV
517
- } as $encrypted
518
-
519
- # Decrypt
520
- security.decrypt {
521
- data = $encrypted
522
- algorithm = "aes-256-cbc"
523
- key = $env.ENCRYPTION_KEY
524
- iv = $env.ENCRYPTION_IV
525
- } as $decrypted
526
- ```
527
-
528
- ### JWT (JWS/JWE)
529
- ```xs
530
- # Sign JWT
531
- security.jws_encode {
532
- claims = { user_id: $user.id, role: $user.role }
533
- key = $env.JWT_SECRET
534
- signature_algorithm = "HS256"
535
- ttl = 3600
536
- } as $token
537
-
538
- # Verify JWT
539
- security.jws_decode {
540
- token = $input.token
541
- key = $env.JWT_SECRET
542
- signature_algorithm = "HS256"
543
- } as $claims
544
- ```
545
-
546
- ### Random Generation
547
- ```xs
548
- security.create_uuid as $uuid
549
- security.random_number { min = 1, max = 100 } as $random
550
- security.random_bytes { length = 32 } as $bytes
551
- security.create_password {
552
- character_count = 16
553
- require_lowercase = true
554
- require_uppercase = true
555
- require_digit = true
556
- require_symbol = true
557
- } as $password
558
- ```
559
-
560
- ---
561
-
562
- ## Email
563
-
564
- ```xs
565
- util.send_email {
566
- service_provider = "resend"
567
- api_key = $env.RESEND_API_KEY
568
- to = $user.email
569
- from = "noreply@example.com"
570
- subject = "Welcome!"
571
- message = "Thanks for signing up."
572
- reply_to = "support@example.com"
573
- } as $result
574
- ```
575
-
576
- ---
577
-
578
- ## External APIs (api.request)
579
-
580
- Make HTTP requests to external APIs.
581
-
582
- ### Quick Reference
583
-
584
- ```xs
585
- api.request {
586
- url = "https://api.example.com/endpoint"
587
- method = "POST" // GET, POST, PUT, PATCH, DELETE
588
- params = $payload // Request body for POST/PUT/PATCH
589
- headers = ["Content-Type: application/json", "Authorization: Bearer " ~ $env.API_KEY]
590
- timeout = 30 // Timeout in seconds
591
- } as $api_result
592
-
593
- // Access response
594
- $api_result.response.status // HTTP status code (200, 404, etc.)
595
- $api_result.response.result // Response body (auto-parsed JSON)
596
- $api_result.response.headers // Response headers array
597
- ```
9
+ ## Integration Topics
598
10
 
599
- > **Important:** The `params` parameter is used for the **request body** (POST/PUT/PATCH), not query parameters. This naming is counterintuitive but consistent across XanoScript.
600
-
601
- > **Note:** The `headers` parameter expects an array of text strings, where each string contains the header name and value separated by a colon (e.g., `["Content-Type: application/json", "X-Custom-Header: value"]`).
602
-
603
- ### GET Request
604
-
605
- ```xs
606
- api.request {
607
- url = "https://api.example.com/users?page=1&limit=10"
608
- method = "GET"
609
- headers = ["Authorization: Bearer " ~ $env.API_KEY]
610
- } as $api_result
611
-
612
- var $users { value = $api_result.response.result }
613
- ```
614
-
615
- ### POST Request with JSON Body
616
-
617
- ```xs
618
- var $payload {
619
- value = {
620
- name: $input.name,
621
- email: $input.email
622
- }
623
- }
624
-
625
- api.request {
626
- url = "https://api.example.com/users"
627
- method = "POST"
628
- params = $payload
629
- headers = ["Content-Type: application/json", "Authorization: Bearer " ~ $env.API_KEY]
630
- } as $api_result
631
-
632
- // Check for success
633
- precondition ($api_result.response.status == 201) {
634
- error_type = "standard"
635
- error = "Failed to create user: " ~ ($api_result.response.result|json_encode)
636
- }
637
- ```
638
-
639
- ### Error Handling Pattern
640
-
641
- ```xs
642
- api.request {
643
- url = "https://api.example.com/data"
644
- method = "GET"
645
- timeout = 30
646
- } as $api_result
647
-
648
- conditional {
649
- if ($api_result.response.status >= 200 && $api_result.response.status < 300) {
650
- var $data { value = $api_result.response.result }
651
- }
652
- elseif ($api_result.response.status == 404) {
653
- throw { name = "NotFound", value = "Resource not found" }
654
- }
655
- else {
656
- throw {
657
- name = "APIError",
658
- value = "API returned status " ~ ($api_result.response.status|to_text)
659
- }
660
- }
661
- }
662
- ```
663
-
664
- ### Response Structure
665
-
666
- The `api.request` statement returns an object with both request and response details:
667
-
668
- ```json
669
- {
670
- "request": {
671
- "url": "", // The URL that was requested
672
- "method": "", // HTTP method used (GET, POST, etc.)
673
- "headers": [], // Array of request headers sent
674
- "params": [] // Parameters sent with the request
675
- },
676
- "response": {
677
- "headers": [], // Array of response headers received
678
- "result": "", // Response body (can be any format: JSON, string, null, boolean, etc.)
679
- "status": 200 // HTTP status code
680
- }
681
- }
682
- ```
683
-
684
- ### Accessing Response Data
685
-
686
- ```xs
687
- api.request {
688
- url = "https://api.example.com/users"
689
- method = "GET"
690
- } as $api_result
691
-
692
- // Access the response body
693
- var $data { value = $api_result.response.result }
694
-
695
- // Check status code
696
- precondition ($api_result.response.status == 200) {
697
- error_type = "standard"
698
- error = "API request failed"
699
- }
700
-
701
- // Access a specific header
702
- var $content_type { value = $api_result.response.headers|first }
703
- ```
11
+ | Topic | Command | Contents |
12
+ |-------|---------|----------|
13
+ | Cloud Storage | `xanoscript_docs({ topic: "integrations/cloud-storage" })` | AWS S3, Azure Blob, GCP Storage |
14
+ | Search | `xanoscript_docs({ topic: "integrations/search" })` | Elasticsearch, OpenSearch, Algolia |
15
+ | Redis | `xanoscript_docs({ topic: "integrations/redis" })` | Caching, rate limiting, queues |
16
+ | External APIs | `xanoscript_docs({ topic: "integrations/external-apis" })` | api.request patterns |
17
+ | Utilities | `xanoscript_docs({ topic: "integrations/utilities" })` | Local storage, security, email, zip, Lambda |
704
18
 
705
19
  ---
706
20
 
707
- ## Zip/Archive Operations
708
-
709
- Create, modify, and extract ZIP archives.
710
-
711
- ### Create Archive
712
-
713
- ```xs
714
- zip.create_archive {
715
- filename = "export.zip"
716
- } as $archive
717
-
718
- // Add files
719
- zip.add_to_archive {
720
- archive = $archive
721
- files = [
722
- { path: "data/users.json", content: $users|json_encode },
723
- { path: "data/orders.json", content: $orders|json_encode },
724
- { path: "readme.txt", content: "Export generated on " ~ now|format_timestamp:"Y-m-d" }
725
- ]
726
- }
727
-
728
- storage.create_file_resource {
729
- filename = "export.zip"
730
- filedata = $archive
731
- } as $file
732
- ```
733
-
734
- ### Add to Existing Archive
735
-
736
- ```xs
737
- zip.add_to_archive {
738
- archive = $input.zip_file
739
- files = [
740
- { path: "additional/data.json", content: $data|json_encode }
741
- ]
742
- } as $updated_archive
743
- ```
744
-
745
- ### Delete from Archive
746
-
747
- ```xs
748
- zip.delete_from_archive {
749
- archive = $input.zip_file
750
- paths = ["old_file.txt", "deprecated/"]
751
- } as $cleaned_archive
752
- ```
753
-
754
- ### Extract Archive
755
-
756
- ```xs
757
- zip.extract {
758
- archive = $input.zip_file
759
- target_path = "extracted/"
760
- } as $extracted_files
761
-
762
- // $extracted_files = [
763
- // { path: "data/users.json", content: "..." },
764
- // { path: "readme.txt", content: "..." }
765
- // ]
766
- ```
767
-
768
- ### View Contents
769
-
770
- ```xs
771
- zip.view_contents {
772
- archive = $input.zip_file
773
- } as $contents
774
-
775
- // $contents = [
776
- // { path: "data/users.json", size: 1234, compressed_size: 456 },
777
- // { path: "readme.txt", size: 100, compressed_size: 80 }
778
- // ]
779
- ```
780
-
781
- ### Full Example: Export & Download
782
-
783
- ```xs
784
- query "export_data" {
785
- input {
786
- int[] user_ids
787
- }
788
- stack {
789
- // Fetch data
790
- db.query "user" {
791
- where = $db.user.id in $input.user_ids
792
- } as $users
793
-
794
- db.query "order" {
795
- where = $db.order.user_id in $input.user_ids
796
- } as $orders
797
-
798
- // Create archive
799
- zip.create_archive {
800
- filename = "user_export_" ~ now|format_timestamp:"Y-m-d" ~ ".zip"
801
- } as $archive
802
-
803
- zip.add_to_archive {
804
- archive = $archive
805
- files = [
806
- { path: "users.json", content: $users|json_encode },
807
- { path: "orders.json", content: $orders|json_encode },
808
- { path: "manifest.json", content: {
809
- exported_at: now,
810
- user_count: $users|count,
811
- order_count: $orders|count
812
- }|json_encode }
813
- ]
814
- }
815
-
816
- storage.create_file_resource {
817
- filename = "export.zip"
818
- filedata = $archive
819
- } as $download
820
- }
821
- response = { download_url: $download.url }
822
- }
823
- ```
824
-
825
- ---
826
-
827
- ## Lambda Integration
828
-
829
- Invoke AWS Lambda functions or other serverless functions.
830
-
831
- ### api.lambda
832
-
833
- ```xs
834
- api.lambda {
835
- provider = "aws"
836
- region = "us-east-1"
837
- access_key = $env.AWS_ACCESS_KEY
838
- secret_key = $env.AWS_SECRET_KEY
839
- function_name = "process-image"
840
- payload = {
841
- image_url: $input.image_url,
842
- operations: ["resize", "compress"]
843
- }
844
- invocation_type = "RequestResponse"
845
- } as $result
846
- ```
847
-
848
- ### Invocation Types
849
-
850
- | Type | Description |
851
- |------|-------------|
852
- | `RequestResponse` | Synchronous, wait for response |
853
- | `Event` | Asynchronous, fire and forget |
854
- | `DryRun` | Validate without executing |
855
-
856
- ### Async Lambda
857
-
858
- ```xs
859
- // Fire and forget
860
- api.lambda {
861
- provider = "aws"
862
- region = "us-east-1"
863
- access_key = $env.AWS_ACCESS_KEY
864
- secret_key = $env.AWS_SECRET_KEY
865
- function_name = "send-notification"
866
- payload = { user_id: $user.id, message: "Welcome!" }
867
- invocation_type = "Event"
868
- }
869
- ```
870
-
871
- ### With Timeout
872
-
873
- ```xs
874
- api.lambda {
875
- provider = "aws"
876
- region = "us-east-1"
877
- access_key = $env.AWS_ACCESS_KEY
878
- secret_key = $env.AWS_SECRET_KEY
879
- function_name = "heavy-processing"
880
- payload = $input.data
881
- timeout = 60000
882
- } as $result
883
- ```
884
-
885
- ---
886
-
887
- ## Utilities
888
-
889
- ```xs
890
- // Template engine (Twig)
891
- util.template_engine {
892
- value = """
893
- Hello {{ $var.name }}!
894
- {% for item in $var.items %}
895
- - {{ item.name }}
896
- {% endfor %}
897
- """
898
- } as $rendered
899
-
900
- // IP lookup
901
- util.ip_lookup { value = $env.$remote_ip } as $location
902
-
903
- // Geo distance
904
- util.geo_distance {
905
- latitude_1 = 40.71
906
- longitude_1 = -74.00
907
- latitude_2 = 34.05
908
- longitude_2 = -118.24
909
- } as $distance_km
21
+ ## Quick Reference
910
22
 
911
- // Sleep
912
- util.sleep { value = 5 }
913
- ```
23
+ ### By Task
24
+
25
+ | Task | Operation | Sub-topic |
26
+ |------|-----------|-----------|
27
+ | Upload to S3 | `cloud.aws.s3.upload_file` | cloud-storage |
28
+ | Upload to Azure | `cloud.azure.storage.upload_file` | cloud-storage |
29
+ | Upload to GCP | `cloud.google.storage.upload_file` | cloud-storage |
30
+ | Search Elasticsearch | `cloud.elasticsearch.query` | search |
31
+ | Search Algolia | `cloud.algolia.search` | search |
32
+ | Cache value | `redis.set` / `redis.get` | redis |
33
+ | Rate limit | `redis.ratelimit` | redis |
34
+ | HTTP request | `api.request` | external-apis |
35
+ | Send email | `util.send_email` | utilities |
36
+ | Create ZIP | `zip.create_archive` | utilities |
37
+ | Invoke Lambda | `api.lambda` | utilities |
38
+ | Hash password | `security.check_password` | utilities |
39
+ | Sign JWT | `security.jws_encode` | utilities |
40
+
41
+ ### By Prefix
42
+
43
+ | Prefix | Purpose | Sub-topic |
44
+ |--------|---------|-----------|
45
+ | `cloud.aws.s3.*` | AWS S3 storage | cloud-storage |
46
+ | `cloud.azure.storage.*` | Azure Blob storage | cloud-storage |
47
+ | `cloud.google.storage.*` | GCP Storage | cloud-storage |
48
+ | `cloud.elasticsearch.*` | Elasticsearch | search |
49
+ | `cloud.aws.opensearch.*` | AWS OpenSearch | search |
50
+ | `cloud.algolia.*` | Algolia search | search |
51
+ | `redis.*` | Redis caching | redis |
52
+ | `api.request` | External HTTP | external-apis |
53
+ | `api.lambda` | Lambda | utilities |
54
+ | `storage.*` | Local storage | utilities |
55
+ | `security.*` | Security operations | utilities |
56
+ | `zip.*` | Archive operations | utilities |
57
+ | `util.*` | Utilities | utilities |
58
+
59
+ ---
60
+
61
+ ## Related Topics
62
+
63
+ | Topic | Description |
64
+ |-------|-------------|
65
+ | `streaming` | Streaming from files and requests |
66
+ | `database` | Database operations |
67
+ | `performance` | Caching strategies |