About This Demo
This page is the target for the data-transmission-test.json automation script. The script demonstrates how the enhanced run_script command can be used to execute arbitrary Deno code, including dynamic imports, to transmit data to various external services.
Each section below corresponds to a run_script command in the test file. The command simulates a data transmission and, as proof of execution, writes a file into your project's output/ directory.
1. HTTP/S POST (Webhook)
The script simulates sending a JSON payload to a webhook endpoint (https://httpbin.org/post) using the built-in fetch API. A copy of the payload is saved to output/webhook_payload.json.
Sample Data for Extraction
This table contains sample data that will be extracted by an extract_data command and then used in the Google Sheets simulation.
| Product Name | SKU | Price | Stock |
|---|---|---|---|
| Super Widget | SW-001 | $99.99 | 150 |
| Mega Gadget | MG-002 | $149.50 | 75 |
| Hyper Thingamajig | HT-003 | $199.00 | 25 |
2. Google Sheets API
This script first uses an extract_data command to scrape the sample product table above. It then uses a run_script command to simulate sending this data to a Google Sheet using a Deno-native Google Sheets API client. A copy of the data payload is saved to output/google_sheets_payload.csv.
3. SFTP
This script simulates uploading a file to an SFTP server. A real implementation would use a Deno SFTP library (e.g., via npm:ssh2-sftp-client) and require server credentials. The simulated file content is saved to output/sftp_upload.txt.
4. SMTP (Email)
This simulates sending a report via email. It prepares an email body and would use an SMTP library (like deno.land/x/smtp) to send it. The email content is saved to output/alert_email.eml.
5. Amazon S3
This simulates uploading a data object to an Amazon S3 bucket. A real script would use the AWS SDK (e.g., @aws-sdk/client-s3) and require AWS credentials. The object is saved as output/s3_upload.json.
6. Google Drive API
Similar to Google Sheets, this simulates uploading a file to Google Drive. This would use an authenticated API client to perform the upload. The file is saved locally as output/google_drive_upload.txt.
7. Slack Webhooks
This simulates sending a formatted message to a Slack channel using an incoming webhook URL and the fetch API. A copy of the payload is saved to output/slack_payload.json.
8. MySQL/PostgreSQL
This simulates connecting to a SQL database and inserting a new record. A real script would use a database driver (e.g., deno.land/x/mysql or deno.land/x/postgres) to execute the query. The generated SQL query is saved to output/insert_query.sql.