serverless #atproto jetstream to webhook connector, powered by cloudflare durable objects

Initial commit

brianell.in 90fbcc2f

+7934
+18
.dev.vars.example
··· 1 + # Local development environment variables 2 + # Copy this file to .dev.vars and fill in your actual values 3 + # 4 + # Note: .dev.vars is gitignored for security 5 + 6 + # Comma-separated list of AT Protocol collections to watch 7 + # Examples: 8 + # - blue.2048.* (all 2048 game collections) 9 + # - app.bsky.feed.post (all Bluesky posts) 10 + # - app.bsky.graph.follow (all follows) 11 + JETSTREAM_COLLECTIONS=blue.2048.*,app.bsky.feed.post 12 + 13 + # Webhook URL where events will be sent 14 + WEBHOOK_URL=https://example.com/api/webhooks/jetstream-event 15 + 16 + 17 + # Webhook bearer token for authentication (optional) 18 + WEBHOOK_BEARER_TOKEN=your-bearer-token-here
+12
.editorconfig
··· 1 + # http://editorconfig.org 2 + root = true 3 + 4 + [*] 5 + indent_style = tab 6 + end_of_line = lf 7 + charset = utf-8 8 + trim_trailing_whitespace = true 9 + insert_final_newline = true 10 + 11 + [*.yml] 12 + indent_style = space
+172
.gitignore
··· 1 + # Logs 2 + 3 + logs 4 + _.log 5 + npm-debug.log_ 6 + yarn-debug.log* 7 + yarn-error.log* 8 + lerna-debug.log* 9 + .pnpm-debug.log* 10 + 11 + # Diagnostic reports (https://nodejs.org/api/report.html) 12 + 13 + report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 14 + 15 + # Runtime data 16 + 17 + pids 18 + _.pid 19 + _.seed 20 + \*.pid.lock 21 + 22 + # Directory for instrumented libs generated by jscoverage/JSCover 23 + 24 + lib-cov 25 + 26 + # Coverage directory used by tools like istanbul 27 + 28 + coverage 29 + \*.lcov 30 + 31 + # nyc test coverage 32 + 33 + .nyc_output 34 + 35 + # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 36 + 37 + .grunt 38 + 39 + # Bower dependency directory (https://bower.io/) 40 + 41 + bower_components 42 + 43 + # node-waf configuration 44 + 45 + .lock-wscript 46 + 47 + # Compiled binary addons (https://nodejs.org/api/addons.html) 48 + 49 + build/Release 50 + 51 + # Dependency directories 52 + 53 + node_modules/ 54 + jspm_packages/ 55 + 56 + # Snowpack dependency directory (https://snowpack.dev/) 57 + 58 + web_modules/ 59 + 60 + # TypeScript cache 61 + 62 + \*.tsbuildinfo 63 + 64 + # Optional npm cache directory 65 + 66 + .npm 67 + 68 + # Optional eslint cache 69 + 70 + .eslintcache 71 + 72 + # Optional stylelint cache 73 + 74 + .stylelintcache 75 + 76 + # Microbundle cache 77 + 78 + .rpt2_cache/ 79 + .rts2_cache_cjs/ 80 + .rts2_cache_es/ 81 + .rts2_cache_umd/ 82 + 83 + # Optional REPL history 84 + 85 + .node_repl_history 86 + 87 + # Output of 'npm pack' 88 + 89 + \*.tgz 90 + 91 + # Yarn Integrity file 92 + 93 + .yarn-integrity 94 + 95 + # dotenv environment variable files 96 + 97 + .env 98 + .env.development.local 99 + .env.test.local 100 + .env.production.local 101 + .env.local 102 + 103 + # parcel-bundler cache (https://parceljs.org/) 104 + 105 + .cache 106 + .parcel-cache 107 + 108 + # Next.js build output 109 + 110 + .next 111 + out 112 + 113 + # Nuxt.js build / generate output 114 + 115 + .nuxt 116 + dist 117 + 118 + # Gatsby files 119 + 120 + .cache/ 121 + 122 + # Comment in the public line in if your project uses Gatsby and not Next.js 123 + 124 + # https://nextjs.org/blog/next-9-1#public-directory-support 125 + 126 + # public 127 + 128 + # vuepress build output 129 + 130 + .vuepress/dist 131 + 132 + # vuepress v2.x temp and cache directory 133 + 134 + .temp 135 + .cache 136 + 137 + # Docusaurus cache and generated files 138 + 139 + .docusaurus 140 + 141 + # Serverless directories 142 + 143 + .serverless/ 144 + 145 + # FuseBox cache 146 + 147 + .fusebox/ 148 + 149 + # DynamoDB Local files 150 + 151 + .dynamodb/ 152 + 153 + # TernJS port file 154 + 155 + .tern-port 156 + 157 + # Stores VSCode versions used for testing VSCode extensions 158 + 159 + .vscode-test 160 + 161 + # yarn v2 162 + 163 + .yarn/cache 164 + .yarn/unplugged 165 + .yarn/build-state.yml 166 + .yarn/install-state.gz 167 + .pnp.\* 168 + 169 + # wrangler project 170 + 171 + .dev.vars 172 + .wrangler/
+6
.prettierrc
··· 1 + { 2 + "printWidth": 140, 3 + "singleQuote": true, 4 + "semi": true, 5 + "useTabs": true 6 + }
+5
.vscode/settings.json
··· 1 + { 2 + "files.associations": { 3 + "wrangler.json": "jsonc" 4 + } 5 + }
+302
README.md
··· 1 + # Jetstream Event Processor 2 + 3 + A Cloudflare Worker with Durable Objects that connects to the Bluesky Jetstream to process AT Protocol events and forward them to a webhook endpoint via Cloudflare Queues. 4 + 5 + Why might this be useful? This is an experimental setup for small atproto apps that running on serverless systems that still want to "subscribe" to realtime events from the firehose/jetstream, but may not want to run their own server and are expecting low volumes traffic. 6 + 7 + ## Features 8 + 9 + - **Real-time Event Processing**: Connects to Bluesky Jetstream WebSocket to receive live AT Protocol events 10 + - **Configurable Collections**: Subscribe to any AT Protocol collections via environment variables 11 + - **Queue-based Architecture**: Uses Cloudflare Queues for reliable event processing and delivery 12 + - **Webhook Integration**: Forwards events to your webhook endpoint with optional bearer token authentication 13 + - **Cursor Tracking**: Maintains cursor position for gapless playback during reconnections 14 + - **Statistics Collection**: Tracks event counts per collection and total processing stats 15 + - **Web Dashboard**: Beautiful HTML interface to view processing statistics 16 + - **Auto-Reconnection**: Handles WebSocket disconnections with exponential backoff 17 + - **Persistent Storage**: Uses Durable Object storage to maintain state across deployments 18 + - **Fully Configurable**: No hardcoded URLs or collections - easy to adapt for any project 19 + 20 + ## Quick Start 21 + 22 + ### Local Development 23 + 24 + ```bash 25 + # 1. Clone and install dependencies 26 + pnpm install 27 + 28 + # 2. Set up local environment 29 + pnpm run setup-local 30 + # This creates .dev.vars from template 31 + 32 + # 3. Edit .dev.vars with your configuration 33 + nano .dev.vars 34 + 35 + # 4. Create Cloudflare Queues (one-time setup) 36 + pnpm run setup-queues 37 + 38 + # 5. Start development server 39 + pnpm run dev 40 + 41 + # 6. View dashboard 42 + open http://localhost:8787/stats/html 43 + ``` 44 + 45 + ### Production Deployment 46 + 47 + ```bash 48 + # 1. Configure environment variables and secrets 49 + pnpm run setup-config 50 + 51 + # 2. Deploy to Cloudflare 52 + pnpm run deploy 53 + ``` 54 + 55 + ## Configuration 56 + 57 + This worker is fully configurable via environment variables: 58 + 59 + | Variable | Description | Example | 60 + |----------|-------------|---------| 61 + | `WEBHOOK_URL` | **Required** - Your webhook endpoint | `https://example.com/api/webhooks/jetstream` | 62 + | `JETSTREAM_COLLECTIONS` | **Required** - Collections to watch (comma-separated) | `app.bsky.feed.post,app.bsky.graph.follow` | 63 + | `WEBHOOK_BEARER_TOKEN` | **Optional** - Bearer token for webhook authentication | `your-secret-token` | 64 + 65 + ### Example Collections 66 + 67 + ```bash 68 + # Social media activity 69 + JETSTREAM_COLLECTIONS=app.bsky.feed.post,app.bsky.graph.follow,app.bsky.feed.like 70 + 71 + # Profile updates 72 + JETSTREAM_COLLECTIONS=app.bsky.actor.profile 73 + 74 + # Custom AT Protocol collections 75 + JETSTREAM_COLLECTIONS=com.example.app.*,org.myproject.data.* 76 + 77 + # Watch everything (high volume!) 78 + JETSTREAM_COLLECTIONS=* 79 + ``` 80 + 81 + ### Local Development (.dev.vars) 82 + 83 + ```bash 84 + # Copy template and edit 85 + cp .dev.vars.example .dev.vars 86 + 87 + # Example configuration 88 + WEBHOOK_URL=https://example.com/api/webhooks/jetstream-event 89 + JETSTREAM_COLLECTIONS=app.bsky.feed.post,app.bsky.graph.follow 90 + WEBHOOK_BEARER_TOKEN=your-development-token 91 + ``` 92 + 93 + ### Production (Cloudflare Secrets) 94 + 95 + ```bash 96 + # Set via interactive script 97 + pnpm run setup-config 98 + 99 + # Or manually 100 + wrangler secret put WEBHOOK_URL 101 + wrangler secret put JETSTREAM_COLLECTIONS 102 + wrangler secret put WEBHOOK_BEARER_TOKEN 103 + ``` 104 + 105 + ## Endpoints 106 + 107 + - **`GET /`** - API information and available endpoints 108 + - **`GET /stats`** - JSON statistics of processed events 109 + - **`GET /stats/html`** - HTML dashboard with real-time statistics (auto-refreshes every 30s) 110 + - **`GET /status`** - WebSocket connection status 111 + - **`GET /health`** - Health check endpoint 112 + - **`POST /reset`** - Reset all statistics 113 + - **`POST /reconnect`** - Force WebSocket reconnection 114 + 115 + ## Architecture 116 + 117 + ### Unified Worker Design 118 + 119 + This worker handles both event processing and queue consumption in a single deployment: 120 + 121 + 1. **Jetstream Processing** (Durable Object): WebSocket connection, event filtering, queueing 122 + 2. **Queue Consumption** (Queue Handler): Batch processing and webhook delivery 123 + 3. **HTTP API** (Fetch Handler): Stats, dashboard, and control endpoints 124 + 125 + ``` 126 + Jetstream Events → Durable Object → Cloudflare Queue → Queue Handler → Your Webhook 127 + ``` 128 + 129 + ### Durable Object: `JetstreamProcessor` 130 + 131 + The core processing logic runs in a single Durable Object instance that: 132 + 133 + 1. **Establishes WebSocket Connection**: Connects to `wss://jetstream1.us-west.bsky.network/subscribe` 134 + 2. **Filters Events**: Only receives events from collections specified in `JETSTREAM_COLLECTIONS` 135 + 3. **Processes Events**: For each received commit event: 136 + - Skips identity and account events (only processes commits) 137 + - Updates the cursor with the event's `time_us` 138 + - Increments collection-specific counters 139 + - Queues the event for webhook delivery 140 + - Persists statistics every 100 events 141 + 4. **Handles Reconnections**: Automatically reconnects on disconnection with cursor for gapless playback 142 + 143 + ### Queue Consumer 144 + 145 + The queue handler processes events in batches and delivers them to your webhook with: 146 + - **Batch processing**: Up to 10 events per batch 147 + - **Automatic retries**: 3 retry attempts with dead letter queue 148 + - **Bearer token authentication**: Optional secure webhook delivery 149 + 150 + ### Event Types Processed 151 + 152 + The processor handles Jetstream events with these `kind` values: 153 + 154 + - **`commit`**: Repository commits with operations (create, update, delete) - **PROCESSED** 155 + - **`identity`**: Identity/handle updates - **SKIPPED** 156 + - **`account`**: Account status changes - **SKIPPED** 157 + 158 + ### Data Persistence 159 + 160 + Statistics are stored in Durable Object storage: 161 + 162 + ```typescript 163 + interface StoredStats { 164 + cursor: number; // Latest time_us for reconnection 165 + eventCounts: Record<string, number>; // Events per collection 166 + totalEvents: number; // Total commit events processed 167 + totalReceived: number; // Total events received (including skipped) 168 + lastEventTime: string; // ISO timestamp of last processing 169 + } 170 + ``` 171 + 172 + ### Event Filtering Limitations 173 + 174 + **Important Note**: Jetstream always sends identity and account events to all subscribers, regardless of `wantedCollections` filters. This is documented behavior and cannot be changed. 175 + 176 + Our implementation handles this by: 177 + - ✅ **Efficiently skipping** non-commit events at the processing level 178 + - ✅ **Tracking volume metrics** to show received vs processed events 179 + - ✅ **Maintaining cursor position** for all events to ensure gapless replay 180 + - ✅ **Silent handling** - no console spam from skipped events 181 + 182 + **Processing Efficiency**: In practice, you may see a low efficiency percentage (e.g., 0-5%) because most events are identity/account updates rather than commits to your target collections. 183 + 184 + ## Monitoring 185 + 186 + ### Real-time Dashboard 187 + 188 + Visit `/stats/html` for a beautiful web interface showing: 189 + 190 + - **Commit events processed** - Only the events you care about 191 + - **Total events received** - All events from Jetstream (including skipped) 192 + - **Processing efficiency** - Percentage of useful vs total events 193 + - **Unique collections** - Number of different collections processed 194 + - **Last event timestamp** - When the most recent event was received 195 + - **Events breakdown by collection** - Detailed stats per collection 196 + - **Auto-refresh every 30 seconds** 197 + 198 + ### API Monitoring 199 + 200 + ```bash 201 + # Check connection status 202 + curl http://localhost:8787/status 203 + 204 + # Get current statistics 205 + curl http://localhost:8787/stats 206 + 207 + # Check health 208 + curl http://localhost:8787/health 209 + 210 + # Force reconnection if needed 211 + curl -X POST http://localhost:8787/reconnect 212 + ``` 213 + 214 + ## Webhook Integration 215 + 216 + Each commit event is posted to your webhook endpoint as JSON with optional bearer token authentication: 217 + 218 + ```http 219 + POST {WEBHOOK_URL} 220 + Content-Type: application/json 221 + Authorization: Bearer {WEBHOOK_BEARER_TOKEN} 222 + User-Agent: Jetstream-Unified/1.0 223 + 224 + { 225 + "did": "did:plc:...", 226 + "time_us": 1725911162329308, 227 + "kind": "commit", 228 + "commit": { 229 + "rev": "3l3qo2vutsw2b", 230 + "operation": "create", 231 + "collection": "app.bsky.feed.post", 232 + "rkey": "3l3qo2vuowo2b", 233 + "record": { 234 + "$type": "app.bsky.feed.post", 235 + "createdAt": "2024-09-09T19:46:02.102Z", 236 + "text": "Hello, world!", 237 + // ... record data 238 + }, 239 + "cid": "bafyreidwaivazkwu67xztlmuobx35hs2lnfh3kolmgfmucldvhd3sgzcqi" 240 + } 241 + } 242 + ``` 243 + 244 + ## Error Handling 245 + 246 + - **WebSocket Errors**: Automatic reconnection with exponential backoff 247 + - **Webhook Failures**: Automatic retries via Cloudflare Queues with dead letter queue 248 + - **Parse Errors**: Individual event failures don't crash the processor 249 + - **Storage Errors**: Graceful degradation with in-memory fallback 250 + - **Configuration Errors**: Clear error messages for missing required environment variables 251 + 252 + ## Development Commands 253 + 254 + ```bash 255 + # Local development 256 + pnpm run dev # Start development server 257 + pnpm run setup-local # Set up local environment 258 + 259 + # Configuration 260 + pnpm run setup-config # Interactive production setup 261 + pnpm run setup-queues # Create Cloudflare Queues (one-time) 262 + 263 + # Deployment 264 + pnpm run deploy # Deploy to Cloudflare 265 + pnpm run cf-typegen # Regenerate TypeScript types 266 + ``` 267 + 268 + ## Project Structure 269 + 270 + ``` 271 + src/ 272 + ├── types.ts # Shared TypeScript interfaces 273 + └── index.ts # Main worker (Durable Object + Queue Consumer) 274 + 275 + wrangler.jsonc # Cloudflare Worker configuration 276 + .dev.vars.example # Environment variables template 277 + setup-*.sh # Setup scripts for queues and configuration 278 + ``` 279 + 280 + ## Deployment 281 + 282 + The worker automatically starts processing events upon deployment. The Durable Object ensures only one instance runs globally, maintaining connection state across worker invocations. 283 + 284 + ## Adapting for Your Project 285 + 286 + This worker is designed to be easily adaptable: 287 + 288 + 1. **Fork the repository** 289 + 2. **Configure your environment variables**: 290 + - Set your webhook URL 291 + - Choose your AT Protocol collections 292 + - Add authentication if needed 293 + 3. **Deploy to Cloudflare** 294 + 4. **Monitor via the dashboard** 295 + 296 + No code changes required - everything is configurable via environment variables! 297 + 298 + ## License 299 + 300 + MIT 301 + 302 + The current implementation provides excellent reliability for most use cases! 🚀
+19
package.json
··· 1 + { 2 + "name": "doing-jetstream", 3 + "version": "0.0.0", 4 + "private": true, 5 + "scripts": { 6 + "deploy": "wrangler deploy", 7 + "dev": "wrangler dev", 8 + "test": "vitest", 9 + "cf-typegen": "wrangler types", 10 + "setup-queues": "bash setup-queues.sh", 11 + "setup-config": "bash setup-secrets.sh", 12 + "setup-local": "bash setup-local.sh" 13 + }, 14 + "devDependencies": { 15 + "typescript": "^5.5.2", 16 + "wrangler": "^4.18.0" 17 + }, 18 + "packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0" 19 + }
+905
pnpm-lock.yaml
··· 1 + lockfileVersion: '9.0' 2 + 3 + settings: 4 + autoInstallPeers: true 5 + excludeLinksFromLockfile: false 6 + 7 + importers: 8 + 9 + .: 10 + devDependencies: 11 + typescript: 12 + specifier: ^5.5.2 13 + version: 5.8.3 14 + wrangler: 15 + specifier: ^4.18.0 16 + version: 4.18.0 17 + 18 + packages: 19 + 20 + '@cloudflare/kv-asset-handler@0.4.0': 21 + resolution: {integrity: sha512-+tv3z+SPp+gqTIcImN9o0hqE9xyfQjI1XD9pL6NuKjua9B1y7mNYv0S9cP+QEbA4ppVgGZEmKOvHX5G5Ei1CVA==} 22 + engines: {node: '>=18.0.0'} 23 + 24 + '@cloudflare/unenv-preset@2.3.2': 25 + resolution: {integrity: sha512-MtUgNl+QkQyhQvv5bbWP+BpBC1N0me4CHHuP2H4ktmOMKdB/6kkz/lo+zqiA4mEazb4y+1cwyNjVrQ2DWeE4mg==} 26 + peerDependencies: 27 + unenv: 2.0.0-rc.17 28 + workerd: ^1.20250508.0 29 + peerDependenciesMeta: 30 + workerd: 31 + optional: true 32 + 33 + '@cloudflare/workerd-darwin-64@1.20250525.0': 34 + resolution: {integrity: sha512-L5l+7sSJJT2+riR5rS3Q3PKNNySPjWfRIeaNGMVRi1dPO6QPi4lwuxfRUFNoeUdilZJUVPfSZvTtj9RedsKznQ==} 35 + engines: {node: '>=16'} 36 + cpu: [x64] 37 + os: [darwin] 38 + 39 + '@cloudflare/workerd-darwin-arm64@1.20250525.0': 40 + resolution: {integrity: sha512-Y3IbIdrF/vJWh/WBvshwcSyUh175VAiLRW7963S1dXChrZ1N5wuKGQm9xY69cIGVtitpMJWWW3jLq7J/Xxwm0Q==} 41 + engines: {node: '>=16'} 42 + cpu: [arm64] 43 + os: [darwin] 44 + 45 + '@cloudflare/workerd-linux-64@1.20250525.0': 46 + resolution: {integrity: sha512-KSyQPAby+c6cpENoO0ayCQlY6QIh28l/+QID7VC1SLXfiNHy+hPNsH1vVBTST6CilHVAQSsy9tCZ9O9XECB8yg==} 47 + engines: {node: '>=16'} 48 + cpu: [x64] 49 + os: [linux] 50 + 51 + '@cloudflare/workerd-linux-arm64@1.20250525.0': 52 + resolution: {integrity: sha512-Nt0FUxS2kQhJUea4hMCNPaetkrAFDhPnNX/ntwcqVlGgnGt75iaAhupWJbU0GB+gIWlKeuClUUnDZqKbicoKyg==} 53 + engines: {node: '>=16'} 54 + cpu: [arm64] 55 + os: [linux] 56 + 57 + '@cloudflare/workerd-windows-64@1.20250525.0': 58 + resolution: {integrity: sha512-mwTj+9f3uIa4NEXR1cOa82PjLa6dbrb3J+KCVJFYIaq7e63VxEzOchCXS4tublT2pmOhmFqkgBMXrxozxNkR2Q==} 59 + engines: {node: '>=16'} 60 + cpu: [x64] 61 + os: [win32] 62 + 63 + '@cspotcode/source-map-support@0.8.1': 64 + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} 65 + engines: {node: '>=12'} 66 + 67 + '@emnapi/runtime@1.4.3': 68 + resolution: {integrity: sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ==} 69 + 70 + '@esbuild/aix-ppc64@0.25.4': 71 + resolution: {integrity: sha512-1VCICWypeQKhVbE9oW/sJaAmjLxhVqacdkvPLEjwlttjfwENRSClS8EjBz0KzRyFSCPDIkuXW34Je/vk7zdB7Q==} 72 + engines: {node: '>=18'} 73 + cpu: [ppc64] 74 + os: [aix] 75 + 76 + '@esbuild/android-arm64@0.25.4': 77 + resolution: {integrity: sha512-bBy69pgfhMGtCnwpC/x5QhfxAz/cBgQ9enbtwjf6V9lnPI/hMyT9iWpR1arm0l3kttTr4L0KSLpKmLp/ilKS9A==} 78 + engines: {node: '>=18'} 79 + cpu: [arm64] 80 + os: [android] 81 + 82 + '@esbuild/android-arm@0.25.4': 83 + resolution: {integrity: sha512-QNdQEps7DfFwE3hXiU4BZeOV68HHzYwGd0Nthhd3uCkkEKK7/R6MTgM0P7H7FAs5pU/DIWsviMmEGxEoxIZ+ZQ==} 84 + engines: {node: '>=18'} 85 + cpu: [arm] 86 + os: [android] 87 + 88 + '@esbuild/android-x64@0.25.4': 89 + resolution: {integrity: sha512-TVhdVtQIFuVpIIR282btcGC2oGQoSfZfmBdTip2anCaVYcqWlZXGcdcKIUklfX2wj0JklNYgz39OBqh2cqXvcQ==} 90 + engines: {node: '>=18'} 91 + cpu: [x64] 92 + os: [android] 93 + 94 + '@esbuild/darwin-arm64@0.25.4': 95 + resolution: {integrity: sha512-Y1giCfM4nlHDWEfSckMzeWNdQS31BQGs9/rouw6Ub91tkK79aIMTH3q9xHvzH8d0wDru5Ci0kWB8b3up/nl16g==} 96 + engines: {node: '>=18'} 97 + cpu: [arm64] 98 + os: [darwin] 99 + 100 + '@esbuild/darwin-x64@0.25.4': 101 + resolution: {integrity: sha512-CJsry8ZGM5VFVeyUYB3cdKpd/H69PYez4eJh1W/t38vzutdjEjtP7hB6eLKBoOdxcAlCtEYHzQ/PJ/oU9I4u0A==} 102 + engines: {node: '>=18'} 103 + cpu: [x64] 104 + os: [darwin] 105 + 106 + '@esbuild/freebsd-arm64@0.25.4': 107 + resolution: {integrity: sha512-yYq+39NlTRzU2XmoPW4l5Ifpl9fqSk0nAJYM/V/WUGPEFfek1epLHJIkTQM6bBs1swApjO5nWgvr843g6TjxuQ==} 108 + engines: {node: '>=18'} 109 + cpu: [arm64] 110 + os: [freebsd] 111 + 112 + '@esbuild/freebsd-x64@0.25.4': 113 + resolution: {integrity: sha512-0FgvOJ6UUMflsHSPLzdfDnnBBVoCDtBTVyn/MrWloUNvq/5SFmh13l3dvgRPkDihRxb77Y17MbqbCAa2strMQQ==} 114 + engines: {node: '>=18'} 115 + cpu: [x64] 116 + os: [freebsd] 117 + 118 + '@esbuild/linux-arm64@0.25.4': 119 + resolution: {integrity: sha512-+89UsQTfXdmjIvZS6nUnOOLoXnkUTB9hR5QAeLrQdzOSWZvNSAXAtcRDHWtqAUtAmv7ZM1WPOOeSxDzzzMogiQ==} 120 + engines: {node: '>=18'} 121 + cpu: [arm64] 122 + os: [linux] 123 + 124 + '@esbuild/linux-arm@0.25.4': 125 + resolution: {integrity: sha512-kro4c0P85GMfFYqW4TWOpvmF8rFShbWGnrLqlzp4X1TNWjRY3JMYUfDCtOxPKOIY8B0WC8HN51hGP4I4hz4AaQ==} 126 + engines: {node: '>=18'} 127 + cpu: [arm] 128 + os: [linux] 129 + 130 + '@esbuild/linux-ia32@0.25.4': 131 + resolution: {integrity: sha512-yTEjoapy8UP3rv8dB0ip3AfMpRbyhSN3+hY8mo/i4QXFeDxmiYbEKp3ZRjBKcOP862Ua4b1PDfwlvbuwY7hIGQ==} 132 + engines: {node: '>=18'} 133 + cpu: [ia32] 134 + os: [linux] 135 + 136 + '@esbuild/linux-loong64@0.25.4': 137 + resolution: {integrity: sha512-NeqqYkrcGzFwi6CGRGNMOjWGGSYOpqwCjS9fvaUlX5s3zwOtn1qwg1s2iE2svBe4Q/YOG1q6875lcAoQK/F4VA==} 138 + engines: {node: '>=18'} 139 + cpu: [loong64] 140 + os: [linux] 141 + 142 + '@esbuild/linux-mips64el@0.25.4': 143 + resolution: {integrity: sha512-IcvTlF9dtLrfL/M8WgNI/qJYBENP3ekgsHbYUIzEzq5XJzzVEV/fXY9WFPfEEXmu3ck2qJP8LG/p3Q8f7Zc2Xg==} 144 + engines: {node: '>=18'} 145 + cpu: [mips64el] 146 + os: [linux] 147 + 148 + '@esbuild/linux-ppc64@0.25.4': 149 + resolution: {integrity: sha512-HOy0aLTJTVtoTeGZh4HSXaO6M95qu4k5lJcH4gxv56iaycfz1S8GO/5Jh6X4Y1YiI0h7cRyLi+HixMR+88swag==} 150 + engines: {node: '>=18'} 151 + cpu: [ppc64] 152 + os: [linux] 153 + 154 + '@esbuild/linux-riscv64@0.25.4': 155 + resolution: {integrity: sha512-i8JUDAufpz9jOzo4yIShCTcXzS07vEgWzyX3NH2G7LEFVgrLEhjwL3ajFE4fZI3I4ZgiM7JH3GQ7ReObROvSUA==} 156 + engines: {node: '>=18'} 157 + cpu: [riscv64] 158 + os: [linux] 159 + 160 + '@esbuild/linux-s390x@0.25.4': 161 + resolution: {integrity: sha512-jFnu+6UbLlzIjPQpWCNh5QtrcNfMLjgIavnwPQAfoGx4q17ocOU9MsQ2QVvFxwQoWpZT8DvTLooTvmOQXkO51g==} 162 + engines: {node: '>=18'} 163 + cpu: [s390x] 164 + os: [linux] 165 + 166 + '@esbuild/linux-x64@0.25.4': 167 + resolution: {integrity: sha512-6e0cvXwzOnVWJHq+mskP8DNSrKBr1bULBvnFLpc1KY+d+irZSgZ02TGse5FsafKS5jg2e4pbvK6TPXaF/A6+CA==} 168 + engines: {node: '>=18'} 169 + cpu: [x64] 170 + os: [linux] 171 + 172 + '@esbuild/netbsd-arm64@0.25.4': 173 + resolution: {integrity: sha512-vUnkBYxZW4hL/ie91hSqaSNjulOnYXE1VSLusnvHg2u3jewJBz3YzB9+oCw8DABeVqZGg94t9tyZFoHma8gWZQ==} 174 + engines: {node: '>=18'} 175 + cpu: [arm64] 176 + os: [netbsd] 177 + 178 + '@esbuild/netbsd-x64@0.25.4': 179 + resolution: {integrity: sha512-XAg8pIQn5CzhOB8odIcAm42QsOfa98SBeKUdo4xa8OvX8LbMZqEtgeWE9P/Wxt7MlG2QqvjGths+nq48TrUiKw==} 180 + engines: {node: '>=18'} 181 + cpu: [x64] 182 + os: [netbsd] 183 + 184 + '@esbuild/openbsd-arm64@0.25.4': 185 + resolution: {integrity: sha512-Ct2WcFEANlFDtp1nVAXSNBPDxyU+j7+tId//iHXU2f/lN5AmO4zLyhDcpR5Cz1r08mVxzt3Jpyt4PmXQ1O6+7A==} 186 + engines: {node: '>=18'} 187 + cpu: [arm64] 188 + os: [openbsd] 189 + 190 + '@esbuild/openbsd-x64@0.25.4': 191 + resolution: {integrity: sha512-xAGGhyOQ9Otm1Xu8NT1ifGLnA6M3sJxZ6ixylb+vIUVzvvd6GOALpwQrYrtlPouMqd/vSbgehz6HaVk4+7Afhw==} 192 + engines: {node: '>=18'} 193 + cpu: [x64] 194 + os: [openbsd] 195 + 196 + '@esbuild/sunos-x64@0.25.4': 197 + resolution: {integrity: sha512-Mw+tzy4pp6wZEK0+Lwr76pWLjrtjmJyUB23tHKqEDP74R3q95luY/bXqXZeYl4NYlvwOqoRKlInQialgCKy67Q==} 198 + engines: {node: '>=18'} 199 + cpu: [x64] 200 + os: [sunos] 201 + 202 + '@esbuild/win32-arm64@0.25.4': 203 + resolution: {integrity: sha512-AVUP428VQTSddguz9dO9ngb+E5aScyg7nOeJDrF1HPYu555gmza3bDGMPhmVXL8svDSoqPCsCPjb265yG/kLKQ==} 204 + engines: {node: '>=18'} 205 + cpu: [arm64] 206 + os: [win32] 207 + 208 + '@esbuild/win32-ia32@0.25.4': 209 + resolution: {integrity: sha512-i1sW+1i+oWvQzSgfRcxxG2k4I9n3O9NRqy8U+uugaT2Dy7kLO9Y7wI72haOahxceMX8hZAzgGou1FhndRldxRg==} 210 + engines: {node: '>=18'} 211 + cpu: [ia32] 212 + os: [win32] 213 + 214 + '@esbuild/win32-x64@0.25.4': 215 + resolution: {integrity: sha512-nOT2vZNw6hJ+z43oP1SPea/G/6AbN6X+bGNhNuq8NtRHy4wsMhw765IKLNmnjek7GvjWBYQ8Q5VBoYTFg9y1UQ==} 216 + engines: {node: '>=18'} 217 + cpu: [x64] 218 + os: [win32] 219 + 220 + '@fastify/busboy@2.1.1': 221 + resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} 222 + engines: {node: '>=14'} 223 + 224 + '@img/sharp-darwin-arm64@0.33.5': 225 + resolution: {integrity: sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==} 226 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 227 + cpu: [arm64] 228 + os: [darwin] 229 + 230 + '@img/sharp-darwin-x64@0.33.5': 231 + resolution: {integrity: sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==} 232 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 233 + cpu: [x64] 234 + os: [darwin] 235 + 236 + '@img/sharp-libvips-darwin-arm64@1.0.4': 237 + resolution: {integrity: sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==} 238 + cpu: [arm64] 239 + os: [darwin] 240 + 241 + '@img/sharp-libvips-darwin-x64@1.0.4': 242 + resolution: {integrity: sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==} 243 + cpu: [x64] 244 + os: [darwin] 245 + 246 + '@img/sharp-libvips-linux-arm64@1.0.4': 247 + resolution: {integrity: sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==} 248 + cpu: [arm64] 249 + os: [linux] 250 + 251 + '@img/sharp-libvips-linux-arm@1.0.5': 252 + resolution: {integrity: sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==} 253 + cpu: [arm] 254 + os: [linux] 255 + 256 + '@img/sharp-libvips-linux-s390x@1.0.4': 257 + resolution: {integrity: sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==} 258 + cpu: [s390x] 259 + os: [linux] 260 + 261 + '@img/sharp-libvips-linux-x64@1.0.4': 262 + resolution: {integrity: sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==} 263 + cpu: [x64] 264 + os: [linux] 265 + 266 + '@img/sharp-libvips-linuxmusl-arm64@1.0.4': 267 + resolution: {integrity: sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==} 268 + cpu: [arm64] 269 + os: [linux] 270 + 271 + '@img/sharp-libvips-linuxmusl-x64@1.0.4': 272 + resolution: {integrity: sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==} 273 + cpu: [x64] 274 + os: [linux] 275 + 276 + '@img/sharp-linux-arm64@0.33.5': 277 + resolution: {integrity: sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==} 278 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 279 + cpu: [arm64] 280 + os: [linux] 281 + 282 + '@img/sharp-linux-arm@0.33.5': 283 + resolution: {integrity: sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==} 284 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 285 + cpu: [arm] 286 + os: [linux] 287 + 288 + '@img/sharp-linux-s390x@0.33.5': 289 + resolution: {integrity: sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==} 290 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 291 + cpu: [s390x] 292 + os: [linux] 293 + 294 + '@img/sharp-linux-x64@0.33.5': 295 + resolution: {integrity: sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==} 296 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 297 + cpu: [x64] 298 + os: [linux] 299 + 300 + '@img/sharp-linuxmusl-arm64@0.33.5': 301 + resolution: {integrity: sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==} 302 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 303 + cpu: [arm64] 304 + os: [linux] 305 + 306 + '@img/sharp-linuxmusl-x64@0.33.5': 307 + resolution: {integrity: sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==} 308 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 309 + cpu: [x64] 310 + os: [linux] 311 + 312 + '@img/sharp-wasm32@0.33.5': 313 + resolution: {integrity: sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==} 314 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 315 + cpu: [wasm32] 316 + 317 + '@img/sharp-win32-ia32@0.33.5': 318 + resolution: {integrity: sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==} 319 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 320 + cpu: [ia32] 321 + os: [win32] 322 + 323 + '@img/sharp-win32-x64@0.33.5': 324 + resolution: {integrity: sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==} 325 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 326 + cpu: [x64] 327 + os: [win32] 328 + 329 + '@jridgewell/resolve-uri@3.1.2': 330 + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} 331 + engines: {node: '>=6.0.0'} 332 + 333 + '@jridgewell/sourcemap-codec@1.5.0': 334 + resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} 335 + 336 + '@jridgewell/trace-mapping@0.3.9': 337 + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} 338 + 339 + acorn-walk@8.3.2: 340 + resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} 341 + engines: {node: '>=0.4.0'} 342 + 343 + acorn@8.14.0: 344 + resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} 345 + engines: {node: '>=0.4.0'} 346 + hasBin: true 347 + 348 + as-table@1.0.55: 349 + resolution: {integrity: sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==} 350 + 351 + blake3-wasm@2.1.5: 352 + resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==} 353 + 354 + color-convert@2.0.1: 355 + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} 356 + engines: {node: '>=7.0.0'} 357 + 358 + color-name@1.1.4: 359 + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} 360 + 361 + color-string@1.9.1: 362 + resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} 363 + 364 + color@4.2.3: 365 + resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} 366 + engines: {node: '>=12.5.0'} 367 + 368 + cookie@0.7.2: 369 + resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} 370 + engines: {node: '>= 0.6'} 371 + 372 + data-uri-to-buffer@2.0.2: 373 + resolution: {integrity: sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==} 374 + 375 + defu@6.1.4: 376 + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} 377 + 378 + detect-libc@2.0.4: 379 + resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==} 380 + engines: {node: '>=8'} 381 + 382 + esbuild@0.25.4: 383 + resolution: {integrity: sha512-8pgjLUcUjcgDg+2Q4NYXnPbo/vncAY4UmyaCm0jZevERqCHZIaWwdJHkf8XQtu4AxSKCdvrUbT0XUr1IdZzI8Q==} 384 + engines: {node: '>=18'} 385 + hasBin: true 386 + 387 + exit-hook@2.2.1: 388 + resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} 389 + engines: {node: '>=6'} 390 + 391 + exsolve@1.0.5: 392 + resolution: {integrity: sha512-pz5dvkYYKQ1AHVrgOzBKWeP4u4FRb3a6DNK2ucr0OoNwYIU4QWsJ+NM36LLzORT+z845MzKHHhpXiUF5nvQoJg==} 393 + 394 + fsevents@2.3.3: 395 + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} 396 + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} 397 + os: [darwin] 398 + 399 + get-source@2.0.12: 400 + resolution: {integrity: sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==} 401 + 402 + glob-to-regexp@0.4.1: 403 + resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} 404 + 405 + is-arrayish@0.3.2: 406 + resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} 407 + 408 + mime@3.0.0: 409 + resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==} 410 + engines: {node: '>=10.0.0'} 411 + hasBin: true 412 + 413 + miniflare@4.20250525.0: 414 + resolution: {integrity: sha512-F5XRDn9WqxUaHphUT8qwy5WXC/3UwbBRJTdjjP5uwHX82vypxIlHNyHziZnplPLhQa1kbSdIY7wfuP1XJyyYZw==} 415 + engines: {node: '>=18.0.0'} 416 + hasBin: true 417 + 418 + mustache@4.2.0: 419 + resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==} 420 + hasBin: true 421 + 422 + ohash@2.0.11: 423 + resolution: {integrity: sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==} 424 + 425 + path-to-regexp@6.3.0: 426 + resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} 427 + 428 + pathe@2.0.3: 429 + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} 430 + 431 + printable-characters@1.0.42: 432 + resolution: {integrity: sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==} 433 + 434 + semver@7.7.2: 435 + resolution: {integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==} 436 + engines: {node: '>=10'} 437 + hasBin: true 438 + 439 + sharp@0.33.5: 440 + resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==} 441 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} 442 + 443 + simple-swizzle@0.2.2: 444 + resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} 445 + 446 + source-map@0.6.1: 447 + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} 448 + engines: {node: '>=0.10.0'} 449 + 450 + stacktracey@2.1.8: 451 + resolution: {integrity: sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==} 452 + 453 + stoppable@1.1.0: 454 + resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} 455 + engines: {node: '>=4', npm: '>=6'} 456 + 457 + tslib@2.8.1: 458 + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} 459 + 460 + typescript@5.8.3: 461 + resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} 462 + engines: {node: '>=14.17'} 463 + hasBin: true 464 + 465 + ufo@1.6.1: 466 + resolution: {integrity: sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==} 467 + 468 + undici@5.29.0: 469 + resolution: {integrity: sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==} 470 + engines: {node: '>=14.0'} 471 + 472 + unenv@2.0.0-rc.17: 473 + resolution: {integrity: sha512-B06u0wXkEd+o5gOCMl/ZHl5cfpYbDZKAT+HWTL+Hws6jWu7dCiqBBXXXzMFcFVJb8D4ytAnYmxJA83uwOQRSsg==} 474 + 475 + workerd@1.20250525.0: 476 + resolution: {integrity: sha512-SXJgLREy/Aqw2J71Oah0Pbu+SShbqbTExjVQyRBTM1r7MG7fS5NUlknhnt6sikjA/t4cO09Bi8OJqHdTkrcnYQ==} 477 + engines: {node: '>=16'} 478 + hasBin: true 479 + 480 + wrangler@4.18.0: 481 + resolution: {integrity: sha512-/ng0KI9io97SNsBU1rheADBLLTE5Djybgsi4gXuvH1RBKJGpyj1xWvZ2fuWu8vAonit3EiZkwtERTm6kESHP3A==} 482 + engines: {node: '>=18.0.0'} 483 + hasBin: true 484 + peerDependencies: 485 + '@cloudflare/workers-types': ^4.20250525.0 486 + peerDependenciesMeta: 487 + '@cloudflare/workers-types': 488 + optional: true 489 + 490 + ws@8.18.0: 491 + resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} 492 + engines: {node: '>=10.0.0'} 493 + peerDependencies: 494 + bufferutil: ^4.0.1 495 + utf-8-validate: '>=5.0.2' 496 + peerDependenciesMeta: 497 + bufferutil: 498 + optional: true 499 + utf-8-validate: 500 + optional: true 501 + 502 + youch@3.3.4: 503 + resolution: {integrity: sha512-UeVBXie8cA35DS6+nBkls68xaBBXCye0CNznrhszZjTbRVnJKQuNsyLKBTTL4ln1o1rh2PKtv35twV7irj5SEg==} 504 + 505 + zod@3.22.3: 506 + resolution: {integrity: sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==} 507 + 508 + snapshots: 509 + 510 + '@cloudflare/kv-asset-handler@0.4.0': 511 + dependencies: 512 + mime: 3.0.0 513 + 514 + '@cloudflare/unenv-preset@2.3.2(unenv@2.0.0-rc.17)(workerd@1.20250525.0)': 515 + dependencies: 516 + unenv: 2.0.0-rc.17 517 + optionalDependencies: 518 + workerd: 1.20250525.0 519 + 520 + '@cloudflare/workerd-darwin-64@1.20250525.0': 521 + optional: true 522 + 523 + '@cloudflare/workerd-darwin-arm64@1.20250525.0': 524 + optional: true 525 + 526 + '@cloudflare/workerd-linux-64@1.20250525.0': 527 + optional: true 528 + 529 + '@cloudflare/workerd-linux-arm64@1.20250525.0': 530 + optional: true 531 + 532 + '@cloudflare/workerd-windows-64@1.20250525.0': 533 + optional: true 534 + 535 + '@cspotcode/source-map-support@0.8.1': 536 + dependencies: 537 + '@jridgewell/trace-mapping': 0.3.9 538 + 539 + '@emnapi/runtime@1.4.3': 540 + dependencies: 541 + tslib: 2.8.1 542 + optional: true 543 + 544 + '@esbuild/aix-ppc64@0.25.4': 545 + optional: true 546 + 547 + '@esbuild/android-arm64@0.25.4': 548 + optional: true 549 + 550 + '@esbuild/android-arm@0.25.4': 551 + optional: true 552 + 553 + '@esbuild/android-x64@0.25.4': 554 + optional: true 555 + 556 + '@esbuild/darwin-arm64@0.25.4': 557 + optional: true 558 + 559 + '@esbuild/darwin-x64@0.25.4': 560 + optional: true 561 + 562 + '@esbuild/freebsd-arm64@0.25.4': 563 + optional: true 564 + 565 + '@esbuild/freebsd-x64@0.25.4': 566 + optional: true 567 + 568 + '@esbuild/linux-arm64@0.25.4': 569 + optional: true 570 + 571 + '@esbuild/linux-arm@0.25.4': 572 + optional: true 573 + 574 + '@esbuild/linux-ia32@0.25.4': 575 + optional: true 576 + 577 + '@esbuild/linux-loong64@0.25.4': 578 + optional: true 579 + 580 + '@esbuild/linux-mips64el@0.25.4': 581 + optional: true 582 + 583 + '@esbuild/linux-ppc64@0.25.4': 584 + optional: true 585 + 586 + '@esbuild/linux-riscv64@0.25.4': 587 + optional: true 588 + 589 + '@esbuild/linux-s390x@0.25.4': 590 + optional: true 591 + 592 + '@esbuild/linux-x64@0.25.4': 593 + optional: true 594 + 595 + '@esbuild/netbsd-arm64@0.25.4': 596 + optional: true 597 + 598 + '@esbuild/netbsd-x64@0.25.4': 599 + optional: true 600 + 601 + '@esbuild/openbsd-arm64@0.25.4': 602 + optional: true 603 + 604 + '@esbuild/openbsd-x64@0.25.4': 605 + optional: true 606 + 607 + '@esbuild/sunos-x64@0.25.4': 608 + optional: true 609 + 610 + '@esbuild/win32-arm64@0.25.4': 611 + optional: true 612 + 613 + '@esbuild/win32-ia32@0.25.4': 614 + optional: true 615 + 616 + '@esbuild/win32-x64@0.25.4': 617 + optional: true 618 + 619 + '@fastify/busboy@2.1.1': {} 620 + 621 + '@img/sharp-darwin-arm64@0.33.5': 622 + optionalDependencies: 623 + '@img/sharp-libvips-darwin-arm64': 1.0.4 624 + optional: true 625 + 626 + '@img/sharp-darwin-x64@0.33.5': 627 + optionalDependencies: 628 + '@img/sharp-libvips-darwin-x64': 1.0.4 629 + optional: true 630 + 631 + '@img/sharp-libvips-darwin-arm64@1.0.4': 632 + optional: true 633 + 634 + '@img/sharp-libvips-darwin-x64@1.0.4': 635 + optional: true 636 + 637 + '@img/sharp-libvips-linux-arm64@1.0.4': 638 + optional: true 639 + 640 + '@img/sharp-libvips-linux-arm@1.0.5': 641 + optional: true 642 + 643 + '@img/sharp-libvips-linux-s390x@1.0.4': 644 + optional: true 645 + 646 + '@img/sharp-libvips-linux-x64@1.0.4': 647 + optional: true 648 + 649 + '@img/sharp-libvips-linuxmusl-arm64@1.0.4': 650 + optional: true 651 + 652 + '@img/sharp-libvips-linuxmusl-x64@1.0.4': 653 + optional: true 654 + 655 + '@img/sharp-linux-arm64@0.33.5': 656 + optionalDependencies: 657 + '@img/sharp-libvips-linux-arm64': 1.0.4 658 + optional: true 659 + 660 + '@img/sharp-linux-arm@0.33.5': 661 + optionalDependencies: 662 + '@img/sharp-libvips-linux-arm': 1.0.5 663 + optional: true 664 + 665 + '@img/sharp-linux-s390x@0.33.5': 666 + optionalDependencies: 667 + '@img/sharp-libvips-linux-s390x': 1.0.4 668 + optional: true 669 + 670 + '@img/sharp-linux-x64@0.33.5': 671 + optionalDependencies: 672 + '@img/sharp-libvips-linux-x64': 1.0.4 673 + optional: true 674 + 675 + '@img/sharp-linuxmusl-arm64@0.33.5': 676 + optionalDependencies: 677 + '@img/sharp-libvips-linuxmusl-arm64': 1.0.4 678 + optional: true 679 + 680 + '@img/sharp-linuxmusl-x64@0.33.5': 681 + optionalDependencies: 682 + '@img/sharp-libvips-linuxmusl-x64': 1.0.4 683 + optional: true 684 + 685 + '@img/sharp-wasm32@0.33.5': 686 + dependencies: 687 + '@emnapi/runtime': 1.4.3 688 + optional: true 689 + 690 + '@img/sharp-win32-ia32@0.33.5': 691 + optional: true 692 + 693 + '@img/sharp-win32-x64@0.33.5': 694 + optional: true 695 + 696 + '@jridgewell/resolve-uri@3.1.2': {} 697 + 698 + '@jridgewell/sourcemap-codec@1.5.0': {} 699 + 700 + '@jridgewell/trace-mapping@0.3.9': 701 + dependencies: 702 + '@jridgewell/resolve-uri': 3.1.2 703 + '@jridgewell/sourcemap-codec': 1.5.0 704 + 705 + acorn-walk@8.3.2: {} 706 + 707 + acorn@8.14.0: {} 708 + 709 + as-table@1.0.55: 710 + dependencies: 711 + printable-characters: 1.0.42 712 + 713 + blake3-wasm@2.1.5: {} 714 + 715 + color-convert@2.0.1: 716 + dependencies: 717 + color-name: 1.1.4 718 + 719 + color-name@1.1.4: {} 720 + 721 + color-string@1.9.1: 722 + dependencies: 723 + color-name: 1.1.4 724 + simple-swizzle: 0.2.2 725 + 726 + color@4.2.3: 727 + dependencies: 728 + color-convert: 2.0.1 729 + color-string: 1.9.1 730 + 731 + cookie@0.7.2: {} 732 + 733 + data-uri-to-buffer@2.0.2: {} 734 + 735 + defu@6.1.4: {} 736 + 737 + detect-libc@2.0.4: {} 738 + 739 + esbuild@0.25.4: 740 + optionalDependencies: 741 + '@esbuild/aix-ppc64': 0.25.4 742 + '@esbuild/android-arm': 0.25.4 743 + '@esbuild/android-arm64': 0.25.4 744 + '@esbuild/android-x64': 0.25.4 745 + '@esbuild/darwin-arm64': 0.25.4 746 + '@esbuild/darwin-x64': 0.25.4 747 + '@esbuild/freebsd-arm64': 0.25.4 748 + '@esbuild/freebsd-x64': 0.25.4 749 + '@esbuild/linux-arm': 0.25.4 750 + '@esbuild/linux-arm64': 0.25.4 751 + '@esbuild/linux-ia32': 0.25.4 752 + '@esbuild/linux-loong64': 0.25.4 753 + '@esbuild/linux-mips64el': 0.25.4 754 + '@esbuild/linux-ppc64': 0.25.4 755 + '@esbuild/linux-riscv64': 0.25.4 756 + '@esbuild/linux-s390x': 0.25.4 757 + '@esbuild/linux-x64': 0.25.4 758 + '@esbuild/netbsd-arm64': 0.25.4 759 + '@esbuild/netbsd-x64': 0.25.4 760 + '@esbuild/openbsd-arm64': 0.25.4 761 + '@esbuild/openbsd-x64': 0.25.4 762 + '@esbuild/sunos-x64': 0.25.4 763 + '@esbuild/win32-arm64': 0.25.4 764 + '@esbuild/win32-ia32': 0.25.4 765 + '@esbuild/win32-x64': 0.25.4 766 + 767 + exit-hook@2.2.1: {} 768 + 769 + exsolve@1.0.5: {} 770 + 771 + fsevents@2.3.3: 772 + optional: true 773 + 774 + get-source@2.0.12: 775 + dependencies: 776 + data-uri-to-buffer: 2.0.2 777 + source-map: 0.6.1 778 + 779 + glob-to-regexp@0.4.1: {} 780 + 781 + is-arrayish@0.3.2: {} 782 + 783 + mime@3.0.0: {} 784 + 785 + miniflare@4.20250525.0: 786 + dependencies: 787 + '@cspotcode/source-map-support': 0.8.1 788 + acorn: 8.14.0 789 + acorn-walk: 8.3.2 790 + exit-hook: 2.2.1 791 + glob-to-regexp: 0.4.1 792 + sharp: 0.33.5 793 + stoppable: 1.1.0 794 + undici: 5.29.0 795 + workerd: 1.20250525.0 796 + ws: 8.18.0 797 + youch: 3.3.4 798 + zod: 3.22.3 799 + transitivePeerDependencies: 800 + - bufferutil 801 + - utf-8-validate 802 + 803 + mustache@4.2.0: {} 804 + 805 + ohash@2.0.11: {} 806 + 807 + path-to-regexp@6.3.0: {} 808 + 809 + pathe@2.0.3: {} 810 + 811 + printable-characters@1.0.42: {} 812 + 813 + semver@7.7.2: {} 814 + 815 + sharp@0.33.5: 816 + dependencies: 817 + color: 4.2.3 818 + detect-libc: 2.0.4 819 + semver: 7.7.2 820 + optionalDependencies: 821 + '@img/sharp-darwin-arm64': 0.33.5 822 + '@img/sharp-darwin-x64': 0.33.5 823 + '@img/sharp-libvips-darwin-arm64': 1.0.4 824 + '@img/sharp-libvips-darwin-x64': 1.0.4 825 + '@img/sharp-libvips-linux-arm': 1.0.5 826 + '@img/sharp-libvips-linux-arm64': 1.0.4 827 + '@img/sharp-libvips-linux-s390x': 1.0.4 828 + '@img/sharp-libvips-linux-x64': 1.0.4 829 + '@img/sharp-libvips-linuxmusl-arm64': 1.0.4 830 + '@img/sharp-libvips-linuxmusl-x64': 1.0.4 831 + '@img/sharp-linux-arm': 0.33.5 832 + '@img/sharp-linux-arm64': 0.33.5 833 + '@img/sharp-linux-s390x': 0.33.5 834 + '@img/sharp-linux-x64': 0.33.5 835 + '@img/sharp-linuxmusl-arm64': 0.33.5 836 + '@img/sharp-linuxmusl-x64': 0.33.5 837 + '@img/sharp-wasm32': 0.33.5 838 + '@img/sharp-win32-ia32': 0.33.5 839 + '@img/sharp-win32-x64': 0.33.5 840 + 841 + simple-swizzle@0.2.2: 842 + dependencies: 843 + is-arrayish: 0.3.2 844 + 845 + source-map@0.6.1: {} 846 + 847 + stacktracey@2.1.8: 848 + dependencies: 849 + as-table: 1.0.55 850 + get-source: 2.0.12 851 + 852 + stoppable@1.1.0: {} 853 + 854 + tslib@2.8.1: 855 + optional: true 856 + 857 + typescript@5.8.3: {} 858 + 859 + ufo@1.6.1: {} 860 + 861 + undici@5.29.0: 862 + dependencies: 863 + '@fastify/busboy': 2.1.1 864 + 865 + unenv@2.0.0-rc.17: 866 + dependencies: 867 + defu: 6.1.4 868 + exsolve: 1.0.5 869 + ohash: 2.0.11 870 + pathe: 2.0.3 871 + ufo: 1.6.1 872 + 873 + workerd@1.20250525.0: 874 + optionalDependencies: 875 + '@cloudflare/workerd-darwin-64': 1.20250525.0 876 + '@cloudflare/workerd-darwin-arm64': 1.20250525.0 877 + '@cloudflare/workerd-linux-64': 1.20250525.0 878 + '@cloudflare/workerd-linux-arm64': 1.20250525.0 879 + '@cloudflare/workerd-windows-64': 1.20250525.0 880 + 881 + wrangler@4.18.0: 882 + dependencies: 883 + '@cloudflare/kv-asset-handler': 0.4.0 884 + '@cloudflare/unenv-preset': 2.3.2(unenv@2.0.0-rc.17)(workerd@1.20250525.0) 885 + blake3-wasm: 2.1.5 886 + esbuild: 0.25.4 887 + miniflare: 4.20250525.0 888 + path-to-regexp: 6.3.0 889 + unenv: 2.0.0-rc.17 890 + workerd: 1.20250525.0 891 + optionalDependencies: 892 + fsevents: 2.3.3 893 + transitivePeerDependencies: 894 + - bufferutil 895 + - utf-8-validate 896 + 897 + ws@8.18.0: {} 898 + 899 + youch@3.3.4: 900 + dependencies: 901 + cookie: 0.7.2 902 + mustache: 4.2.0 903 + stacktracey: 2.1.8 904 + 905 + zod@3.22.3: {}
+30
setup-local.sh
··· 1 + #!/bin/bash 2 + 3 + echo "🏠 Setting up Local Development Environment" 4 + echo "==========================================" 5 + echo "" 6 + 7 + if [ ! -f .dev.vars ]; then 8 + echo "Creating .dev.vars from template..." 9 + cp .dev.vars.example .dev.vars 10 + echo "✅ Created .dev.vars file" 11 + echo "" 12 + echo "📝 Please edit .dev.vars with your configuration:" 13 + echo " - WEBHOOK_URL: Your webhook endpoint" 14 + echo " - JETSTREAM_COLLECTIONS: Collections to watch" 15 + echo " - WEBHOOK_BEARER_TOKEN: Your auth token (optional)" 16 + echo "" 17 + echo "Example collections to watch:" 18 + echo " - app.bsky.feed.post (all Bluesky posts)" 19 + echo " - app.bsky.graph.follow (all follows)" 20 + echo " - app.bsky.actor.profile (profile updates)" 21 + else 22 + echo "⚠️ .dev.vars already exists" 23 + echo " Edit it manually if you need to update your config" 24 + fi 25 + 26 + echo "" 27 + echo "🎯 Next steps:" 28 + echo "1. Edit .dev.vars with your configuration" 29 + echo "2. Run: pnpm run dev" 30 + echo "3. Test: curl http://localhost:8787/stats"
+18
setup-queues.sh
··· 1 + #!/bin/bash 2 + 3 + echo "Setting up Cloudflare Queues for Jetstream events..." 4 + 5 + # Create the main queue 6 + echo "Creating jetstream-events queue..." 7 + pnpm wrangler queues create jetstream-events 8 + 9 + # Create the dead letter queue 10 + echo "Creating dead letter queue..." 11 + pnpm wrangler queues create jetstream-events-dlq 12 + 13 + echo "Queue setup complete!" 14 + echo "" 15 + echo "Next steps:" 16 + echo "1. Run 'pnpm run cf-typegen' to update types" 17 + echo "2. Run 'pnpm run deploy' to deploy both workers" 18 + echo "3. Test with 'curl http://localhost:8787/stats' to trigger events"
+36
setup-secrets.sh
··· 1 + #!/bin/bash 2 + 3 + echo "🔐 Setting up Cloudflare Worker Configuration" 4 + echo "=============================================" 5 + echo "" 6 + 7 + echo "This script will help you set up both environment variables and secrets." 8 + echo "" 9 + 10 + echo "📋 Setting up environment variables..." 11 + echo "Setting WEBHOOK_URL (your webhook endpoint):" 12 + read -p "Enter webhook URL: " webhook_url 13 + wrangler secret put WEBHOOK_URL --value "$webhook_url" 14 + 15 + echo "" 16 + echo "Setting JETSTREAM_COLLECTIONS (comma-separated AT Protocol collections):" 17 + echo "Examples: work.doing.*,blue.2048.* or app.bsky.feed.post,app.bsky.graph.follow" 18 + read -p "Enter collections to watch: " collections 19 + wrangler secret put JETSTREAM_COLLECTIONS --value "$collections" 20 + 21 + echo "" 22 + echo "🔐 Setting up secrets..." 23 + echo "Setting WEBHOOK_BEARER_TOKEN (this will prompt you to enter securely):" 24 + pnpm wrangler secret put WEBHOOK_BEARER_TOKEN 25 + 26 + echo "" 27 + echo "✅ Configuration setup complete!" 28 + echo "" 29 + echo "Your worker is now configured with:" 30 + echo "- WEBHOOK_URL: $webhook_url" 31 + echo "- JETSTREAM_COLLECTIONS: $collections" 32 + echo "- WEBHOOK_BEARER_TOKEN: [securely stored]" 33 + echo "" 34 + echo "For local development, create a .dev.vars file:" 35 + echo "cp .dev.vars.example .dev.vars" 36 + echo "# Then edit .dev.vars with your local values"
+475
src/index.ts
··· 1 + import { DurableObject } from "cloudflare:workers"; 2 + import type { JetstreamEvent, StoredStats, QueueMessage } from "./types"; 3 + 4 + /** 5 + * Welcome to Cloudflare Workers! This is your first Durable Objects application. 6 + * 7 + * - Run `npm run dev` in your terminal to start a development server 8 + * - Open a browser tab at http://localhost:8787/ to see your Durable Object in action 9 + * - Run `npm run deploy` to publish your application 10 + * 11 + * Bind resources to your worker in `wrangler.jsonc`. After adding bindings, a type definition for the 12 + * `Env` object can be regenerated with `npm run cf-typegen`. 13 + * 14 + * Learn more at https://developers.cloudflare.com/durable-objects 15 + */ 16 + 17 + /** Durable Object for managing Jetstream connection and event processing */ 18 + export class JetstreamProcessor extends DurableObject<Env> { 19 + private websocket: WebSocket | null = null; 20 + private reconnectTimeout: any = null; 21 + private stats: StoredStats = { 22 + cursor: 0, 23 + eventCounts: {}, 24 + totalEvents: 0, 25 + totalReceived: 0, 26 + lastEventTime: new Date().toISOString() 27 + }; 28 + 29 + /** 30 + * The constructor is invoked once upon creation of the Durable Object, i.e. the first call to 31 + * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted) 32 + * 33 + * @param ctx - The interface for interacting with Durable Object state 34 + * @param env - The interface to reference bindings declared in wrangler.jsonc 35 + */ 36 + constructor(ctx: DurableObjectState, env: Env) { 37 + super(ctx, env); 38 + 39 + // Validate required environment variables 40 + if (!env.WEBHOOK_URL) { 41 + throw new Error("WEBHOOK_URL environment variable is required"); 42 + } 43 + 44 + if (!env.JETSTREAM_COLLECTIONS) { 45 + throw new Error("JETSTREAM_COLLECTIONS environment variable is required"); 46 + } 47 + 48 + this.initializeProcessor(); 49 + } 50 + 51 + private async initializeProcessor() { 52 + // Load existing stats from storage 53 + const storedStats = await this.ctx.storage.get<StoredStats>("stats"); 54 + if (storedStats) { 55 + this.stats = storedStats; 56 + } 57 + 58 + // Start the Jetstream connection 59 + this.connectToJetstream(); 60 + } 61 + 62 + private async connectToJetstream() { 63 + try { 64 + // Parse collections from environment variable (comma-separated) 65 + const collectionsStr = this.env.JETSTREAM_COLLECTIONS; 66 + const collections = collectionsStr.split(",").map(c => c.trim()).filter(c => c.length > 0); 67 + 68 + const url = new URL("wss://jetstream1.us-west.bsky.network/subscribe"); 69 + 70 + // Add collections to the query 71 + collections.forEach(collection => { 72 + url.searchParams.append("wantedCollections", collection); 73 + }); 74 + 75 + // Add cursor if we have one (reconnection scenario) 76 + if (this.stats.cursor > 0) { 77 + // Subtract 5 seconds as buffer to ensure gapless playback 78 + const cursorWithBuffer = this.stats.cursor - (5 * 1000 * 1000); 79 + url.searchParams.set("cursor", cursorWithBuffer.toString()); 80 + } 81 + 82 + console.log("JETSTREAM_COLLECTIONS", this.env.JETSTREAM_COLLECTIONS); 83 + console.log(`Connecting to Jetstream: ${url.toString()}`); 84 + console.log(`Watching collections: ${collections.join(", ")}`); 85 + 86 + this.websocket = new WebSocket(url.toString()); 87 + 88 + this.websocket.addEventListener("open", () => { 89 + console.log("Jetstream WebSocket connected"); 90 + // Clear any existing reconnect timeout 91 + if (this.reconnectTimeout) { 92 + clearTimeout(this.reconnectTimeout); 93 + this.reconnectTimeout = null; 94 + } 95 + }); 96 + 97 + this.websocket.addEventListener("message", async (event) => { 98 + try { 99 + // WebSocket message data can be string or ArrayBuffer, we expect JSON string 100 + const data = typeof event.data === "string" ? event.data : new TextDecoder().decode(event.data); 101 + const jetstreamEvent: JetstreamEvent = JSON.parse(data); 102 + await this.processEvent(jetstreamEvent); 103 + } catch (error) { 104 + console.error("Error processing Jetstream event:", error); 105 + } 106 + }); 107 + 108 + this.websocket.addEventListener("close", (event) => { 109 + console.log(`Jetstream WebSocket closed: ${event.code} ${event.reason}`); 110 + this.websocket = null; 111 + this.scheduleReconnect(); 112 + }); 113 + 114 + this.websocket.addEventListener("error", (event) => { 115 + console.error("Jetstream WebSocket error:", event); 116 + this.websocket = null; 117 + this.scheduleReconnect(); 118 + }); 119 + 120 + } catch (error) { 121 + console.error("Error connecting to Jetstream:", error); 122 + this.scheduleReconnect(); 123 + } 124 + } 125 + 126 + private scheduleReconnect() { 127 + if (this.reconnectTimeout) return; 128 + 129 + // Exponential backoff with jitter, starting at 1 second, max 30 seconds 130 + const baseDelay = 1000; 131 + const maxDelay = 30000; 132 + const delay = Math.min(baseDelay * Math.pow(2, Math.random()), maxDelay); 133 + 134 + console.log(`Scheduling Jetstream reconnect in ${delay}ms`); 135 + this.reconnectTimeout = setTimeout(() => { 136 + this.reconnectTimeout = null; 137 + this.connectToJetstream(); 138 + }, delay); 139 + } 140 + 141 + private async processEvent(event: JetstreamEvent) { 142 + // Always update cursor and received count for all events 143 + this.stats.cursor = event.time_us; 144 + this.stats.totalReceived++; 145 + 146 + // Skip identity and account events - only process commits 147 + if (event.kind !== "commit") { 148 + return; 149 + } 150 + 151 + // Update stats for commit events only 152 + this.stats.totalEvents++; 153 + this.stats.lastEventTime = new Date().toISOString(); 154 + 155 + // Track collection-specific stats for commits only 156 + if (event.commit?.collection) { 157 + const collection = event.commit.collection; 158 + this.stats.eventCounts[collection] = (this.stats.eventCounts[collection] || 0) + 1; 159 + console.log(`Processing ${event.commit.operation} event for collection: ${collection}`); 160 + } 161 + 162 + // Send to Cloudflare Queue instead of webhook 163 + try { 164 + const queueMessage: QueueMessage = { 165 + event: event, 166 + queuedAt: new Date().toISOString(), 167 + retryCount: 0 168 + }; 169 + 170 + await this.env.JETSTREAM_QUEUE.send(queueMessage); 171 + 172 + console.log(`Event queued successfully: ${event.time_us}`); 173 + } catch (error) { 174 + console.error("Error sending to queue:", error); 175 + // Note: Queue failures are more serious than webhook failures 176 + // You might want to implement additional error handling here 177 + } 178 + 179 + // Persist stats every 100 events to avoid too frequent writes 180 + if (this.stats.totalEvents % 100 === 0) { 181 + await this.ctx.storage.put("stats", this.stats); 182 + } 183 + } 184 + 185 + /** 186 + * Get current processing statistics 187 + */ 188 + async getStats(): Promise<StoredStats> { 189 + // Ensure we have the latest stats 190 + await this.ctx.storage.put("stats", this.stats); 191 + return this.stats; 192 + } 193 + 194 + /** 195 + * Reset statistics (useful for testing) 196 + */ 197 + async resetStats(): Promise<void> { 198 + this.stats = { 199 + cursor: 0, 200 + eventCounts: {}, 201 + totalEvents: 0, 202 + totalReceived: 0, 203 + lastEventTime: new Date().toISOString() 204 + }; 205 + await this.ctx.storage.put("stats", this.stats); 206 + } 207 + 208 + /** 209 + * Get connection status 210 + */ 211 + getConnectionStatus(): { connected: boolean; readyState?: number } { 212 + return { 213 + connected: this.websocket?.readyState === WebSocket.OPEN, 214 + readyState: this.websocket?.readyState 215 + }; 216 + } 217 + 218 + /** 219 + * Force reconnection (useful for debugging) 220 + */ 221 + async forceReconnect(): Promise<void> { 222 + if (this.websocket) { 223 + this.websocket.close(); 224 + } 225 + if (this.reconnectTimeout) { 226 + clearTimeout(this.reconnectTimeout); 227 + this.reconnectTimeout = null; 228 + } 229 + this.connectToJetstream(); 230 + } 231 + } 232 + 233 + export default { 234 + /** 235 + * This is the standard fetch handler for a Cloudflare Worker 236 + * 237 + * @param request - The request submitted to the Worker from the client 238 + * @param env - The interface to reference bindings declared in wrangler.jsonc 239 + * @param ctx - The execution context of the Worker 240 + * @returns The response to be sent back to the client 241 + */ 242 + async fetch(request, env, ctx): Promise<Response> { 243 + const url = new URL(request.url); 244 + 245 + // Create a single instance of the Jetstream processor 246 + const id: DurableObjectId = env.JETSTREAM_PROCESSOR.idFromName("main"); 247 + const stub = env.JETSTREAM_PROCESSOR.get(id); 248 + 249 + // Handle different routes 250 + if (url.pathname === "/stats") { 251 + const stats = await stub.getStats(); 252 + return new Response(JSON.stringify(stats, null, 2), { 253 + headers: { "Content-Type": "application/json" } 254 + }); 255 + } 256 + 257 + if (url.pathname === "/stats/html") { 258 + const stats = await stub.getStats(); 259 + const html = ` 260 + <!DOCTYPE html> 261 + <html> 262 + <head> 263 + <title>Jetstream Statistics</title> 264 + <meta charset="utf-8"> 265 + <meta name="viewport" content="width=device-width, initial-scale=1"> 266 + <style> 267 + body { 268 + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 269 + max-width: 800px; 270 + margin: 2rem auto; 271 + padding: 0 1rem; 272 + background: #f5f5f5; 273 + } 274 + .container { 275 + background: white; 276 + border-radius: 8px; 277 + padding: 2rem; 278 + box-shadow: 0 2px 4px rgba(0,0,0,0.1); 279 + } 280 + h1 { color: #333; margin-bottom: 2rem; } 281 + .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; } 282 + .stat-card { background: #f8f9fa; padding: 1rem; border-radius: 6px; border-left: 4px solid #007bff; } 283 + .stat-value { font-size: 1.5rem; font-weight: bold; color: #007bff; } 284 + .stat-label { color: #666; font-size: 0.9rem; } 285 + .collections { margin-top: 2rem; } 286 + .collection-item { padding: 0.5rem; margin: 0.25rem 0; background: #e9ecef; border-radius: 4px; display: flex; justify-content: space-between; } 287 + .refresh-btn { 288 + background: #007bff; 289 + color: white; 290 + border: none; 291 + padding: 0.5rem 1rem; 292 + border-radius: 4px; 293 + cursor: pointer; 294 + margin-bottom: 1rem; 295 + } 296 + .refresh-btn:hover { background: #0056b3; } 297 + </style> 298 + <script> 299 + function refreshStats() { 300 + window.location.reload(); 301 + } 302 + setInterval(refreshStats, 30000); // Auto-refresh every 30 seconds 303 + </script> 304 + </head> 305 + <body> 306 + <div class="container"> 307 + <h1>🚀 Jetstream Event Processor</h1> 308 + <button class="refresh-btn" onclick="refreshStats()">Refresh Stats</button> 309 + 310 + <div class="stat-grid"> 311 + <div class="stat-card"> 312 + <div class="stat-value">${stats.totalEvents.toLocaleString()}</div> 313 + <div class="stat-label">Commit Events Processed</div> 314 + </div> 315 + <div class="stat-card"> 316 + <div class="stat-value">${stats.totalReceived.toLocaleString()}</div> 317 + <div class="stat-label">Total Events Received</div> 318 + </div> 319 + <div class="stat-card"> 320 + <div class="stat-value">${stats.totalReceived > 0 ? ((stats.totalEvents / stats.totalReceived) * 100).toFixed(1) + '%' : '0%'}</div> 321 + <div class="stat-label">Processing Efficiency</div> 322 + </div> 323 + <div class="stat-card"> 324 + <div class="stat-value">${Object.keys(stats.eventCounts).length}</div> 325 + <div class="stat-label">Unique Collections</div> 326 + </div> 327 + <div class="stat-card"> 328 + <div class="stat-value">${stats.cursor > 0 ? new Date(stats.cursor / 1000).toLocaleString() : 'N/A'}</div> 329 + <div class="stat-label">Last Event Time</div> 330 + </div> 331 + <div class="stat-card"> 332 + <div class="stat-value">${new Date(stats.lastEventTime).toLocaleString()}</div> 333 + <div class="stat-label">Last Processed</div> 334 + </div> 335 + </div> 336 + 337 + <div class="collections"> 338 + <h3>Events by Collection</h3> 339 + ${Object.entries(stats.eventCounts) 340 + .sort(([,a], [,b]) => (b as number) - (a as number)) 341 + .map(([collection, count]) => ` 342 + <div class="collection-item"> 343 + <span>${collection}</span> 344 + <span><strong>${(count as number).toLocaleString()}</strong></span> 345 + </div> 346 + `).join('')} 347 + </div> 348 + </div> 349 + </body> 350 + </html>`; 351 + return new Response(html, { 352 + headers: { "Content-Type": "text/html" } 353 + }); 354 + } 355 + 356 + if (url.pathname === "/status") { 357 + const status = await stub.getConnectionStatus(); 358 + return new Response(JSON.stringify(status, null, 2), { 359 + headers: { "Content-Type": "application/json" } 360 + }); 361 + } 362 + 363 + if (url.pathname === "/reset" && request.method === "POST") { 364 + await stub.resetStats(); 365 + return new Response(JSON.stringify({ message: "Stats reset successfully" }), { 366 + headers: { "Content-Type": "application/json" } 367 + }); 368 + } 369 + 370 + if (url.pathname === "/reconnect" && request.method === "POST") { 371 + await stub.forceReconnect(); 372 + return new Response(JSON.stringify({ message: "Reconnection initiated" }), { 373 + headers: { "Content-Type": "application/json" } 374 + }); 375 + } 376 + 377 + if (url.pathname === "/health") { 378 + return new Response(JSON.stringify({ 379 + status: "healthy", 380 + worker: "jetstream-unified", 381 + timestamp: new Date().toISOString() 382 + }), { 383 + headers: { "Content-Type": "application/json" } 384 + }); 385 + } 386 + 387 + // Default route - show basic info 388 + return new Response(JSON.stringify({ 389 + message: "Jetstream Event Processor (Unified)", 390 + endpoints: { 391 + "/stats": "Get processing statistics (JSON)", 392 + "/stats/html": "Get processing statistics (HTML dashboard)", 393 + "/status": "Get WebSocket connection status", 394 + "/health": "Health check endpoint", 395 + "POST /reset": "Reset statistics", 396 + "POST /reconnect": "Force WebSocket reconnection" 397 + } 398 + }, null, 2), { 399 + headers: { "Content-Type": "application/json" } 400 + }); 401 + }, 402 + 403 + // Scheduled event handler - keeps Durable Object alive 404 + async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise<void> { 405 + console.log("Scheduled keepalive triggered"); 406 + 407 + // Get the Durable Object instance to keep it alive 408 + const id: DurableObjectId = env.JETSTREAM_PROCESSOR.idFromName("main"); 409 + const stub = env.JETSTREAM_PROCESSOR.get(id); 410 + 411 + // Check connection status to ensure it's healthy 412 + const status = await stub.getConnectionStatus(); 413 + console.log("Keepalive check - WebSocket connected:", status.connected); 414 + 415 + // If not connected, force a reconnection attempt 416 + if (!status.connected) { 417 + console.log("WebSocket disconnected, forcing reconnection"); 418 + await stub.forceReconnect(); 419 + } 420 + }, 421 + 422 + // Queue consumer handler - processes events from the queue 423 + async queue(batch: MessageBatch, env: Env, ctx: ExecutionContext): Promise<void> { 424 + console.log(`Processing batch of ${batch.messages.length} messages`); 425 + 426 + // Process messages in batch for efficiency 427 + const webhookPromises = batch.messages.map(async (message) => { 428 + try { 429 + // Cast the unknown message body to our QueueMessage type 430 + const queueMessage = message.body as QueueMessage; 431 + await sendToWebhook(queueMessage.event, env); 432 + 433 + // Acknowledge successful processing 434 + message.ack(); 435 + 436 + console.log(`Successfully processed event ${queueMessage.event.time_us} for collection: ${queueMessage.event.commit?.collection || 'non-commit'}`); 437 + } catch (error) { 438 + console.error(`Failed to process queue message:`, error); 439 + 440 + // Let the message retry (don't ack) 441 + // Cloudflare Queues will automatically retry based on configuration 442 + message.retry(); 443 + } 444 + }); 445 + 446 + // Wait for all webhook calls to complete 447 + await Promise.allSettled(webhookPromises); 448 + } 449 + } satisfies ExportedHandler<Env>; 450 + 451 + async function sendToWebhook(event: JetstreamEvent, env: Env): Promise<void> { 452 + const webhookUrl = env.WEBHOOK_URL; 453 + const bearerToken = env.WEBHOOK_BEARER_TOKEN; 454 + 455 + const headers: Record<string, string> = { 456 + "Content-Type": "application/json", 457 + "User-Agent": "Jetstream-Unified/1.0" 458 + }; 459 + 460 + // Add Authorization header if bearer token is available 461 + if (bearerToken) { 462 + headers["Authorization"] = `Bearer ${bearerToken}`; 463 + } 464 + 465 + const response = await fetch(webhookUrl, { 466 + method: "POST", 467 + headers, 468 + body: JSON.stringify(event), 469 + }); 470 + 471 + if (!response.ok) { 472 + // This will cause the message to retry 473 + throw new Error(`Webhook request failed: ${response.status} ${response.statusText}`); 474 + } 475 + }
+39
src/types.ts
··· 1 + export interface JetstreamEvent { 2 + did: string; 3 + time_us: number; 4 + kind: "commit" | "identity" | "account"; 5 + commit?: { 6 + rev: string; 7 + operation: "create" | "update" | "delete"; 8 + collection: string; 9 + rkey: string; 10 + record?: any; 11 + cid?: string; 12 + }; 13 + identity?: { 14 + did: string; 15 + handle: string; 16 + seq: number; 17 + time: string; 18 + }; 19 + account?: { 20 + active: boolean; 21 + did: string; 22 + seq: number; 23 + time: string; 24 + }; 25 + } 26 + 27 + export interface StoredStats { 28 + cursor: number; 29 + eventCounts: Record<string, number>; 30 + totalEvents: number; 31 + totalReceived: number; 32 + lastEventTime: string; 33 + } 34 + 35 + export interface QueueMessage { 36 + event: JetstreamEvent; 37 + queuedAt: string; 38 + retryCount?: number; 39 + }
+43
tsconfig.json
··· 1 + { 2 + "compilerOptions": { 3 + /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 + 5 + /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 6 + "target": "es2021", 7 + /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 8 + "lib": ["es2021"], 9 + /* Specify what JSX code is generated. */ 10 + "jsx": "react-jsx", 11 + 12 + /* Specify what module code is generated. */ 13 + "module": "es2022", 14 + /* Specify how TypeScript looks up a file from a given module specifier. */ 15 + "moduleResolution": "node", 16 + /* Enable importing .json files */ 17 + "resolveJsonModule": true, 18 + 19 + /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ 20 + "allowJs": true, 21 + /* Enable error reporting in type-checked JavaScript files. */ 22 + "checkJs": false, 23 + 24 + /* Disable emitting files from a compilation. */ 25 + "noEmit": true, 26 + 27 + /* Ensure that each file can be safely transpiled without relying on other imports. */ 28 + "isolatedModules": true, 29 + /* Allow 'import x from y' when a module doesn't have a default export. */ 30 + "allowSyntheticDefaultImports": true, 31 + /* Ensure that casing is correct in imports. */ 32 + "forceConsistentCasingInFileNames": true, 33 + 34 + /* Enable all strict type-checking options. */ 35 + "strict": true, 36 + 37 + /* Skip type checking all .d.ts files. */ 38 + "skipLibCheck": true, 39 + "types": [ 40 + "./worker-configuration.d.ts" 41 + ] 42 + } 43 + }
+5760
worker-configuration.d.ts
··· 1 + /* eslint-disable */ 2 + // Generated by Wrangler by running `wrangler types` (hash: bcb9db85e8571edd4067dda08b6c154e) 3 + // Runtime types generated with workerd@1.20250525.0 2025-05-29 4 + declare namespace Cloudflare { 5 + interface Env { 6 + JETSTREAM_COLLECTIONS: string; 7 + WEBHOOK_URL: string; 8 + WEBHOOK_BEARER_TOKEN: string; 9 + JETSTREAM_PROCESSOR: DurableObjectNamespace<import("./src/index").JetstreamProcessor>; 10 + JETSTREAM_QUEUE: Queue; 11 + } 12 + } 13 + interface Env extends Cloudflare.Env {} 14 + 15 + // Begin runtime types 16 + /*! ***************************************************************************** 17 + Copyright (c) Cloudflare. All rights reserved. 18 + Copyright (c) Microsoft Corporation. All rights reserved. 19 + 20 + Licensed under the Apache License, Version 2.0 (the "License"); you may not use 21 + this file except in compliance with the License. You may obtain a copy of the 22 + License at http://www.apache.org/licenses/LICENSE-2.0 23 + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 24 + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 25 + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 26 + MERCHANTABLITY OR NON-INFRINGEMENT. 27 + See the Apache Version 2.0 License for specific language governing permissions 28 + and limitations under the License. 29 + ***************************************************************************** */ 30 + /* eslint-disable */ 31 + // noinspection JSUnusedGlobalSymbols 32 + declare var onmessage: never; 33 + /** 34 + * An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. 35 + * 36 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException) 37 + */ 38 + declare class DOMException extends Error { 39 + constructor(message?: string, name?: string); 40 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */ 41 + readonly message: string; 42 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */ 43 + readonly name: string; 44 + /** 45 + * @deprecated 46 + * 47 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code) 48 + */ 49 + readonly code: number; 50 + static readonly INDEX_SIZE_ERR: number; 51 + static readonly DOMSTRING_SIZE_ERR: number; 52 + static readonly HIERARCHY_REQUEST_ERR: number; 53 + static readonly WRONG_DOCUMENT_ERR: number; 54 + static readonly INVALID_CHARACTER_ERR: number; 55 + static readonly NO_DATA_ALLOWED_ERR: number; 56 + static readonly NO_MODIFICATION_ALLOWED_ERR: number; 57 + static readonly NOT_FOUND_ERR: number; 58 + static readonly NOT_SUPPORTED_ERR: number; 59 + static readonly INUSE_ATTRIBUTE_ERR: number; 60 + static readonly INVALID_STATE_ERR: number; 61 + static readonly SYNTAX_ERR: number; 62 + static readonly INVALID_MODIFICATION_ERR: number; 63 + static readonly NAMESPACE_ERR: number; 64 + static readonly INVALID_ACCESS_ERR: number; 65 + static readonly VALIDATION_ERR: number; 66 + static readonly TYPE_MISMATCH_ERR: number; 67 + static readonly SECURITY_ERR: number; 68 + static readonly NETWORK_ERR: number; 69 + static readonly ABORT_ERR: number; 70 + static readonly URL_MISMATCH_ERR: number; 71 + static readonly QUOTA_EXCEEDED_ERR: number; 72 + static readonly TIMEOUT_ERR: number; 73 + static readonly INVALID_NODE_TYPE_ERR: number; 74 + static readonly DATA_CLONE_ERR: number; 75 + get stack(): any; 76 + set stack(value: any); 77 + } 78 + type WorkerGlobalScopeEventMap = { 79 + fetch: FetchEvent; 80 + scheduled: ScheduledEvent; 81 + queue: QueueEvent; 82 + unhandledrejection: PromiseRejectionEvent; 83 + rejectionhandled: PromiseRejectionEvent; 84 + }; 85 + declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> { 86 + EventTarget: typeof EventTarget; 87 + } 88 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) */ 89 + interface Console { 90 + "assert"(condition?: boolean, ...data: any[]): void; 91 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) */ 92 + clear(): void; 93 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) */ 94 + count(label?: string): void; 95 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) */ 96 + countReset(label?: string): void; 97 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) */ 98 + debug(...data: any[]): void; 99 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) */ 100 + dir(item?: any, options?: any): void; 101 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) */ 102 + dirxml(...data: any[]): void; 103 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) */ 104 + error(...data: any[]): void; 105 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) */ 106 + group(...data: any[]): void; 107 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) */ 108 + groupCollapsed(...data: any[]): void; 109 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) */ 110 + groupEnd(): void; 111 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) */ 112 + info(...data: any[]): void; 113 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) */ 114 + log(...data: any[]): void; 115 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) */ 116 + table(tabularData?: any, properties?: string[]): void; 117 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) */ 118 + time(label?: string): void; 119 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) */ 120 + timeEnd(label?: string): void; 121 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) */ 122 + timeLog(label?: string, ...data: any[]): void; 123 + timeStamp(label?: string): void; 124 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */ 125 + trace(...data: any[]): void; 126 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) */ 127 + warn(...data: any[]): void; 128 + } 129 + declare const console: Console; 130 + type BufferSource = ArrayBufferView | ArrayBuffer; 131 + type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; 132 + declare namespace WebAssembly { 133 + class CompileError extends Error { 134 + constructor(message?: string); 135 + } 136 + class RuntimeError extends Error { 137 + constructor(message?: string); 138 + } 139 + type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128"; 140 + interface GlobalDescriptor { 141 + value: ValueType; 142 + mutable?: boolean; 143 + } 144 + class Global { 145 + constructor(descriptor: GlobalDescriptor, value?: any); 146 + value: any; 147 + valueOf(): any; 148 + } 149 + type ImportValue = ExportValue | number; 150 + type ModuleImports = Record<string, ImportValue>; 151 + type Imports = Record<string, ModuleImports>; 152 + type ExportValue = Function | Global | Memory | Table; 153 + type Exports = Record<string, ExportValue>; 154 + class Instance { 155 + constructor(module: Module, imports?: Imports); 156 + readonly exports: Exports; 157 + } 158 + interface MemoryDescriptor { 159 + initial: number; 160 + maximum?: number; 161 + shared?: boolean; 162 + } 163 + class Memory { 164 + constructor(descriptor: MemoryDescriptor); 165 + readonly buffer: ArrayBuffer; 166 + grow(delta: number): number; 167 + } 168 + type ImportExportKind = "function" | "global" | "memory" | "table"; 169 + interface ModuleExportDescriptor { 170 + kind: ImportExportKind; 171 + name: string; 172 + } 173 + interface ModuleImportDescriptor { 174 + kind: ImportExportKind; 175 + module: string; 176 + name: string; 177 + } 178 + abstract class Module { 179 + static customSections(module: Module, sectionName: string): ArrayBuffer[]; 180 + static exports(module: Module): ModuleExportDescriptor[]; 181 + static imports(module: Module): ModuleImportDescriptor[]; 182 + } 183 + type TableKind = "anyfunc" | "externref"; 184 + interface TableDescriptor { 185 + element: TableKind; 186 + initial: number; 187 + maximum?: number; 188 + } 189 + class Table { 190 + constructor(descriptor: TableDescriptor, value?: any); 191 + readonly length: number; 192 + get(index: number): any; 193 + grow(delta: number, value?: any): number; 194 + set(index: number, value?: any): void; 195 + } 196 + function instantiate(module: Module, imports?: Imports): Promise<Instance>; 197 + function validate(bytes: BufferSource): boolean; 198 + } 199 + /** 200 + * This ServiceWorker API interface represents the global execution context of a service worker. 201 + * Available only in secure contexts. 202 + * 203 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope) 204 + */ 205 + interface ServiceWorkerGlobalScope extends WorkerGlobalScope { 206 + DOMException: typeof DOMException; 207 + WorkerGlobalScope: typeof WorkerGlobalScope; 208 + btoa(data: string): string; 209 + atob(data: string): string; 210 + setTimeout(callback: (...args: any[]) => void, msDelay?: number): number; 211 + setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 212 + clearTimeout(timeoutId: number | null): void; 213 + setInterval(callback: (...args: any[]) => void, msDelay?: number): number; 214 + setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 215 + clearInterval(timeoutId: number | null): void; 216 + queueMicrotask(task: Function): void; 217 + structuredClone<T>(value: T, options?: StructuredSerializeOptions): T; 218 + reportError(error: any): void; 219 + fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>; 220 + self: ServiceWorkerGlobalScope; 221 + crypto: Crypto; 222 + caches: CacheStorage; 223 + scheduler: Scheduler; 224 + performance: Performance; 225 + Cloudflare: Cloudflare; 226 + readonly origin: string; 227 + Event: typeof Event; 228 + ExtendableEvent: typeof ExtendableEvent; 229 + CustomEvent: typeof CustomEvent; 230 + PromiseRejectionEvent: typeof PromiseRejectionEvent; 231 + FetchEvent: typeof FetchEvent; 232 + TailEvent: typeof TailEvent; 233 + TraceEvent: typeof TailEvent; 234 + ScheduledEvent: typeof ScheduledEvent; 235 + MessageEvent: typeof MessageEvent; 236 + CloseEvent: typeof CloseEvent; 237 + ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader; 238 + ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader; 239 + ReadableStream: typeof ReadableStream; 240 + WritableStream: typeof WritableStream; 241 + WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter; 242 + TransformStream: typeof TransformStream; 243 + ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy; 244 + CountQueuingStrategy: typeof CountQueuingStrategy; 245 + ErrorEvent: typeof ErrorEvent; 246 + EventSource: typeof EventSource; 247 + ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest; 248 + ReadableStreamDefaultController: typeof ReadableStreamDefaultController; 249 + ReadableByteStreamController: typeof ReadableByteStreamController; 250 + WritableStreamDefaultController: typeof WritableStreamDefaultController; 251 + TransformStreamDefaultController: typeof TransformStreamDefaultController; 252 + CompressionStream: typeof CompressionStream; 253 + DecompressionStream: typeof DecompressionStream; 254 + TextEncoderStream: typeof TextEncoderStream; 255 + TextDecoderStream: typeof TextDecoderStream; 256 + Headers: typeof Headers; 257 + Body: typeof Body; 258 + Request: typeof Request; 259 + Response: typeof Response; 260 + WebSocket: typeof WebSocket; 261 + WebSocketPair: typeof WebSocketPair; 262 + WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair; 263 + AbortController: typeof AbortController; 264 + AbortSignal: typeof AbortSignal; 265 + TextDecoder: typeof TextDecoder; 266 + TextEncoder: typeof TextEncoder; 267 + navigator: Navigator; 268 + Navigator: typeof Navigator; 269 + URL: typeof URL; 270 + URLSearchParams: typeof URLSearchParams; 271 + URLPattern: typeof URLPattern; 272 + Blob: typeof Blob; 273 + File: typeof File; 274 + FormData: typeof FormData; 275 + Crypto: typeof Crypto; 276 + SubtleCrypto: typeof SubtleCrypto; 277 + CryptoKey: typeof CryptoKey; 278 + CacheStorage: typeof CacheStorage; 279 + Cache: typeof Cache; 280 + FixedLengthStream: typeof FixedLengthStream; 281 + IdentityTransformStream: typeof IdentityTransformStream; 282 + HTMLRewriter: typeof HTMLRewriter; 283 + } 284 + declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void; 285 + declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void; 286 + /** 287 + * Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. 288 + * 289 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) 290 + */ 291 + declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean; 292 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */ 293 + declare function btoa(data: string): string; 294 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */ 295 + declare function atob(data: string): string; 296 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ 297 + declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number; 298 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ 299 + declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 300 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */ 301 + declare function clearTimeout(timeoutId: number | null): void; 302 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */ 303 + declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number; 304 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */ 305 + declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 306 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */ 307 + declare function clearInterval(timeoutId: number | null): void; 308 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */ 309 + declare function queueMicrotask(task: Function): void; 310 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */ 311 + declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T; 312 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */ 313 + declare function reportError(error: any): void; 314 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */ 315 + declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>; 316 + declare const self: ServiceWorkerGlobalScope; 317 + /** 318 + * The Web Crypto API provides a set of low-level functions for common cryptographic tasks. 319 + * The Workers runtime implements the full surface of this API, but with some differences in 320 + * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms) 321 + * compared to those implemented in most browsers. 322 + * 323 + * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/) 324 + */ 325 + declare const crypto: Crypto; 326 + /** 327 + * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. 328 + * 329 + * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) 330 + */ 331 + declare const caches: CacheStorage; 332 + declare const scheduler: Scheduler; 333 + /** 334 + * The Workers runtime supports a subset of the Performance API, used to measure timing and performance, 335 + * as well as timing of subrequests and other operations. 336 + * 337 + * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/) 338 + */ 339 + declare const performance: Performance; 340 + declare const Cloudflare: Cloudflare; 341 + declare const origin: string; 342 + declare const navigator: Navigator; 343 + interface TestController { 344 + } 345 + interface ExecutionContext { 346 + waitUntil(promise: Promise<any>): void; 347 + passThroughOnException(): void; 348 + props: any; 349 + } 350 + type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Response | Promise<Response>; 351 + type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>; 352 + type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>; 353 + type ExportedHandlerTailStreamHandler<Env = unknown> = (event: TailStream.TailEvent, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>; 354 + type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>; 355 + type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext) => void | Promise<void>; 356 + type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>; 357 + interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> { 358 + fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>; 359 + tail?: ExportedHandlerTailHandler<Env>; 360 + trace?: ExportedHandlerTraceHandler<Env>; 361 + tailStream?: ExportedHandlerTailStreamHandler<Env>; 362 + scheduled?: ExportedHandlerScheduledHandler<Env>; 363 + test?: ExportedHandlerTestHandler<Env>; 364 + email?: EmailExportedHandler<Env>; 365 + queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>; 366 + } 367 + interface StructuredSerializeOptions { 368 + transfer?: any[]; 369 + } 370 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent) */ 371 + declare abstract class PromiseRejectionEvent extends Event { 372 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) */ 373 + readonly promise: Promise<any>; 374 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) */ 375 + readonly reason: any; 376 + } 377 + declare abstract class Navigator { 378 + sendBeacon(url: string, body?: (ReadableStream | string | (ArrayBuffer | ArrayBufferView) | Blob | FormData | URLSearchParams | URLSearchParams)): boolean; 379 + readonly userAgent: string; 380 + readonly hardwareConcurrency: number; 381 + readonly language: string; 382 + readonly languages: string[]; 383 + } 384 + /** 385 + * The Workers runtime supports a subset of the Performance API, used to measure timing and performance, 386 + * as well as timing of subrequests and other operations. 387 + * 388 + * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/) 389 + */ 390 + interface Performance { 391 + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */ 392 + readonly timeOrigin: number; 393 + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */ 394 + now(): number; 395 + } 396 + interface AlarmInvocationInfo { 397 + readonly isRetry: boolean; 398 + readonly retryCount: number; 399 + } 400 + interface Cloudflare { 401 + readonly compatibilityFlags: Record<string, boolean>; 402 + } 403 + interface DurableObject { 404 + fetch(request: Request): Response | Promise<Response>; 405 + alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>; 406 + webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>; 407 + webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>; 408 + webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>; 409 + } 410 + type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & { 411 + readonly id: DurableObjectId; 412 + readonly name?: string; 413 + }; 414 + interface DurableObjectId { 415 + toString(): string; 416 + equals(other: DurableObjectId): boolean; 417 + readonly name?: string; 418 + } 419 + interface DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> { 420 + newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId; 421 + idFromName(name: string): DurableObjectId; 422 + idFromString(id: string): DurableObjectId; 423 + get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>; 424 + jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>; 425 + } 426 + type DurableObjectJurisdiction = "eu" | "fedramp"; 427 + interface DurableObjectNamespaceNewUniqueIdOptions { 428 + jurisdiction?: DurableObjectJurisdiction; 429 + } 430 + type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me"; 431 + interface DurableObjectNamespaceGetDurableObjectOptions { 432 + locationHint?: DurableObjectLocationHint; 433 + } 434 + interface DurableObjectState { 435 + waitUntil(promise: Promise<any>): void; 436 + readonly id: DurableObjectId; 437 + readonly storage: DurableObjectStorage; 438 + container?: Container; 439 + blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>; 440 + acceptWebSocket(ws: WebSocket, tags?: string[]): void; 441 + getWebSockets(tag?: string): WebSocket[]; 442 + setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void; 443 + getWebSocketAutoResponse(): WebSocketRequestResponsePair | null; 444 + getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null; 445 + setHibernatableWebSocketEventTimeout(timeoutMs?: number): void; 446 + getHibernatableWebSocketEventTimeout(): number | null; 447 + getTags(ws: WebSocket): string[]; 448 + abort(reason?: string): void; 449 + } 450 + interface DurableObjectTransaction { 451 + get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>; 452 + get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>; 453 + list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>; 454 + put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>; 455 + put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>; 456 + delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>; 457 + delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>; 458 + rollback(): void; 459 + getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>; 460 + setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>; 461 + deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>; 462 + } 463 + interface DurableObjectStorage { 464 + get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>; 465 + get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>; 466 + list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>; 467 + put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>; 468 + put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>; 469 + delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>; 470 + delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>; 471 + deleteAll(options?: DurableObjectPutOptions): Promise<void>; 472 + transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>; 473 + getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>; 474 + setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>; 475 + deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>; 476 + sync(): Promise<void>; 477 + sql: SqlStorage; 478 + transactionSync<T>(closure: () => T): T; 479 + getCurrentBookmark(): Promise<string>; 480 + getBookmarkForTime(timestamp: number | Date): Promise<string>; 481 + onNextSessionRestoreBookmark(bookmark: string): Promise<string>; 482 + } 483 + interface DurableObjectListOptions { 484 + start?: string; 485 + startAfter?: string; 486 + end?: string; 487 + prefix?: string; 488 + reverse?: boolean; 489 + limit?: number; 490 + allowConcurrency?: boolean; 491 + noCache?: boolean; 492 + } 493 + interface DurableObjectGetOptions { 494 + allowConcurrency?: boolean; 495 + noCache?: boolean; 496 + } 497 + interface DurableObjectGetAlarmOptions { 498 + allowConcurrency?: boolean; 499 + } 500 + interface DurableObjectPutOptions { 501 + allowConcurrency?: boolean; 502 + allowUnconfirmed?: boolean; 503 + noCache?: boolean; 504 + } 505 + interface DurableObjectSetAlarmOptions { 506 + allowConcurrency?: boolean; 507 + allowUnconfirmed?: boolean; 508 + } 509 + declare class WebSocketRequestResponsePair { 510 + constructor(request: string, response: string); 511 + get request(): string; 512 + get response(): string; 513 + } 514 + interface AnalyticsEngineDataset { 515 + writeDataPoint(event?: AnalyticsEngineDataPoint): void; 516 + } 517 + interface AnalyticsEngineDataPoint { 518 + indexes?: ((ArrayBuffer | string) | null)[]; 519 + doubles?: number[]; 520 + blobs?: ((ArrayBuffer | string) | null)[]; 521 + } 522 + /** 523 + * An event which takes place in the DOM. 524 + * 525 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event) 526 + */ 527 + declare class Event { 528 + constructor(type: string, init?: EventInit); 529 + /** 530 + * Returns the type of event, e.g. "click", "hashchange", or "submit". 531 + * 532 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type) 533 + */ 534 + get type(): string; 535 + /** 536 + * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. 537 + * 538 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase) 539 + */ 540 + get eventPhase(): number; 541 + /** 542 + * Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. 543 + * 544 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed) 545 + */ 546 + get composed(): boolean; 547 + /** 548 + * Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise. 549 + * 550 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles) 551 + */ 552 + get bubbles(): boolean; 553 + /** 554 + * Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. 555 + * 556 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable) 557 + */ 558 + get cancelable(): boolean; 559 + /** 560 + * Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. 561 + * 562 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented) 563 + */ 564 + get defaultPrevented(): boolean; 565 + /** 566 + * @deprecated 567 + * 568 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue) 569 + */ 570 + get returnValue(): boolean; 571 + /** 572 + * Returns the object whose event listener's callback is currently being invoked. 573 + * 574 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget) 575 + */ 576 + get currentTarget(): EventTarget | undefined; 577 + /** 578 + * Returns the object to which event is dispatched (its target). 579 + * 580 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target) 581 + */ 582 + get target(): EventTarget | undefined; 583 + /** 584 + * @deprecated 585 + * 586 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement) 587 + */ 588 + get srcElement(): EventTarget | undefined; 589 + /** 590 + * Returns the event's timestamp as the number of milliseconds measured relative to the time origin. 591 + * 592 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp) 593 + */ 594 + get timeStamp(): number; 595 + /** 596 + * Returns true if event was dispatched by the user agent, and false otherwise. 597 + * 598 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted) 599 + */ 600 + get isTrusted(): boolean; 601 + /** 602 + * @deprecated 603 + * 604 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble) 605 + */ 606 + get cancelBubble(): boolean; 607 + /** 608 + * @deprecated 609 + * 610 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble) 611 + */ 612 + set cancelBubble(value: boolean); 613 + /** 614 + * Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects. 615 + * 616 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation) 617 + */ 618 + stopImmediatePropagation(): void; 619 + /** 620 + * If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled. 621 + * 622 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault) 623 + */ 624 + preventDefault(): void; 625 + /** 626 + * When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. 627 + * 628 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation) 629 + */ 630 + stopPropagation(): void; 631 + /** 632 + * Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget. 633 + * 634 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath) 635 + */ 636 + composedPath(): EventTarget[]; 637 + static readonly NONE: number; 638 + static readonly CAPTURING_PHASE: number; 639 + static readonly AT_TARGET: number; 640 + static readonly BUBBLING_PHASE: number; 641 + } 642 + interface EventInit { 643 + bubbles?: boolean; 644 + cancelable?: boolean; 645 + composed?: boolean; 646 + } 647 + type EventListener<EventType extends Event = Event> = (event: EventType) => void; 648 + interface EventListenerObject<EventType extends Event = Event> { 649 + handleEvent(event: EventType): void; 650 + } 651 + type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>; 652 + /** 653 + * EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. 654 + * 655 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget) 656 + */ 657 + declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> { 658 + constructor(); 659 + /** 660 + * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. 661 + * 662 + * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. 663 + * 664 + * When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. 665 + * 666 + * When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. 667 + * 668 + * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. 669 + * 670 + * If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted. 671 + * 672 + * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. 673 + * 674 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) 675 + */ 676 + addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void; 677 + /** 678 + * Removes the event listener in target's event listener list with the same type, callback, and options. 679 + * 680 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) 681 + */ 682 + removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void; 683 + /** 684 + * Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. 685 + * 686 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) 687 + */ 688 + dispatchEvent(event: EventMap[keyof EventMap]): boolean; 689 + } 690 + interface EventTargetEventListenerOptions { 691 + capture?: boolean; 692 + } 693 + interface EventTargetAddEventListenerOptions { 694 + capture?: boolean; 695 + passive?: boolean; 696 + once?: boolean; 697 + signal?: AbortSignal; 698 + } 699 + interface EventTargetHandlerObject { 700 + handleEvent: (event: Event) => any | undefined; 701 + } 702 + /** 703 + * A controller object that allows you to abort one or more DOM requests as and when desired. 704 + * 705 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController) 706 + */ 707 + declare class AbortController { 708 + constructor(); 709 + /** 710 + * Returns the AbortSignal object associated with this object. 711 + * 712 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal) 713 + */ 714 + get signal(): AbortSignal; 715 + /** 716 + * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted. 717 + * 718 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort) 719 + */ 720 + abort(reason?: any): void; 721 + } 722 + /** 723 + * A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. 724 + * 725 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal) 726 + */ 727 + declare abstract class AbortSignal extends EventTarget { 728 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) */ 729 + static abort(reason?: any): AbortSignal; 730 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) */ 731 + static timeout(delay: number): AbortSignal; 732 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static) */ 733 + static any(signals: AbortSignal[]): AbortSignal; 734 + /** 735 + * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. 736 + * 737 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted) 738 + */ 739 + get aborted(): boolean; 740 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) */ 741 + get reason(): any; 742 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */ 743 + get onabort(): any | null; 744 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */ 745 + set onabort(value: any | null); 746 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) */ 747 + throwIfAborted(): void; 748 + } 749 + interface Scheduler { 750 + wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>; 751 + } 752 + interface SchedulerWaitOptions { 753 + signal?: AbortSignal; 754 + } 755 + /** 756 + * Extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries. 757 + * 758 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent) 759 + */ 760 + declare abstract class ExtendableEvent extends Event { 761 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) */ 762 + waitUntil(promise: Promise<any>): void; 763 + } 764 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent) */ 765 + declare class CustomEvent<T = any> extends Event { 766 + constructor(type: string, init?: CustomEventCustomEventInit); 767 + /** 768 + * Returns any custom data event was created with. Typically used for synthetic events. 769 + * 770 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail) 771 + */ 772 + get detail(): T; 773 + } 774 + interface CustomEventCustomEventInit { 775 + bubbles?: boolean; 776 + cancelable?: boolean; 777 + composed?: boolean; 778 + detail?: any; 779 + } 780 + /** 781 + * A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. 782 + * 783 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob) 784 + */ 785 + declare class Blob { 786 + constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions); 787 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */ 788 + get size(): number; 789 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */ 790 + get type(): string; 791 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */ 792 + slice(start?: number, end?: number, type?: string): Blob; 793 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */ 794 + arrayBuffer(): Promise<ArrayBuffer>; 795 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) */ 796 + bytes(): Promise<Uint8Array>; 797 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */ 798 + text(): Promise<string>; 799 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */ 800 + stream(): ReadableStream; 801 + } 802 + interface BlobOptions { 803 + type?: string; 804 + } 805 + /** 806 + * Provides information about files and allows JavaScript in a web page to access their content. 807 + * 808 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File) 809 + */ 810 + declare class File extends Blob { 811 + constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions); 812 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */ 813 + get name(): string; 814 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */ 815 + get lastModified(): number; 816 + } 817 + interface FileOptions { 818 + type?: string; 819 + lastModified?: number; 820 + } 821 + /** 822 + * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. 823 + * 824 + * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) 825 + */ 826 + declare abstract class CacheStorage { 827 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */ 828 + open(cacheName: string): Promise<Cache>; 829 + readonly default: Cache; 830 + } 831 + /** 832 + * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. 833 + * 834 + * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) 835 + */ 836 + declare abstract class Cache { 837 + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */ 838 + delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>; 839 + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */ 840 + match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>; 841 + /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */ 842 + put(request: RequestInfo | URL, response: Response): Promise<void>; 843 + } 844 + interface CacheQueryOptions { 845 + ignoreMethod?: boolean; 846 + } 847 + /** 848 + * The Web Crypto API provides a set of low-level functions for common cryptographic tasks. 849 + * The Workers runtime implements the full surface of this API, but with some differences in 850 + * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms) 851 + * compared to those implemented in most browsers. 852 + * 853 + * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/) 854 + */ 855 + declare abstract class Crypto { 856 + /** 857 + * Available only in secure contexts. 858 + * 859 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle) 860 + */ 861 + get subtle(): SubtleCrypto; 862 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */ 863 + getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T; 864 + /** 865 + * Available only in secure contexts. 866 + * 867 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) 868 + */ 869 + randomUUID(): string; 870 + DigestStream: typeof DigestStream; 871 + } 872 + /** 873 + * This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in a window context (via Window.crypto). 874 + * Available only in secure contexts. 875 + * 876 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto) 877 + */ 878 + declare abstract class SubtleCrypto { 879 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) */ 880 + encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 881 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) */ 882 + decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 883 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) */ 884 + sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 885 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) */ 886 + verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>; 887 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) */ 888 + digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 889 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */ 890 + generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>; 891 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */ 892 + deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>; 893 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) */ 894 + deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>; 895 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */ 896 + importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>; 897 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */ 898 + exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>; 899 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) */ 900 + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>; 901 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */ 902 + unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>; 903 + timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean; 904 + } 905 + /** 906 + * The CryptoKey dictionary of the Web Crypto API represents a cryptographic key. 907 + * Available only in secure contexts. 908 + * 909 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey) 910 + */ 911 + declare abstract class CryptoKey { 912 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */ 913 + readonly type: string; 914 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */ 915 + readonly extractable: boolean; 916 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */ 917 + readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm; 918 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */ 919 + readonly usages: string[]; 920 + } 921 + interface CryptoKeyPair { 922 + publicKey: CryptoKey; 923 + privateKey: CryptoKey; 924 + } 925 + interface JsonWebKey { 926 + kty: string; 927 + use?: string; 928 + key_ops?: string[]; 929 + alg?: string; 930 + ext?: boolean; 931 + crv?: string; 932 + x?: string; 933 + y?: string; 934 + d?: string; 935 + n?: string; 936 + e?: string; 937 + p?: string; 938 + q?: string; 939 + dp?: string; 940 + dq?: string; 941 + qi?: string; 942 + oth?: RsaOtherPrimesInfo[]; 943 + k?: string; 944 + } 945 + interface RsaOtherPrimesInfo { 946 + r?: string; 947 + d?: string; 948 + t?: string; 949 + } 950 + interface SubtleCryptoDeriveKeyAlgorithm { 951 + name: string; 952 + salt?: (ArrayBuffer | ArrayBufferView); 953 + iterations?: number; 954 + hash?: (string | SubtleCryptoHashAlgorithm); 955 + $public?: CryptoKey; 956 + info?: (ArrayBuffer | ArrayBufferView); 957 + } 958 + interface SubtleCryptoEncryptAlgorithm { 959 + name: string; 960 + iv?: (ArrayBuffer | ArrayBufferView); 961 + additionalData?: (ArrayBuffer | ArrayBufferView); 962 + tagLength?: number; 963 + counter?: (ArrayBuffer | ArrayBufferView); 964 + length?: number; 965 + label?: (ArrayBuffer | ArrayBufferView); 966 + } 967 + interface SubtleCryptoGenerateKeyAlgorithm { 968 + name: string; 969 + hash?: (string | SubtleCryptoHashAlgorithm); 970 + modulusLength?: number; 971 + publicExponent?: (ArrayBuffer | ArrayBufferView); 972 + length?: number; 973 + namedCurve?: string; 974 + } 975 + interface SubtleCryptoHashAlgorithm { 976 + name: string; 977 + } 978 + interface SubtleCryptoImportKeyAlgorithm { 979 + name: string; 980 + hash?: (string | SubtleCryptoHashAlgorithm); 981 + length?: number; 982 + namedCurve?: string; 983 + compressed?: boolean; 984 + } 985 + interface SubtleCryptoSignAlgorithm { 986 + name: string; 987 + hash?: (string | SubtleCryptoHashAlgorithm); 988 + dataLength?: number; 989 + saltLength?: number; 990 + } 991 + interface CryptoKeyKeyAlgorithm { 992 + name: string; 993 + } 994 + interface CryptoKeyAesKeyAlgorithm { 995 + name: string; 996 + length: number; 997 + } 998 + interface CryptoKeyHmacKeyAlgorithm { 999 + name: string; 1000 + hash: CryptoKeyKeyAlgorithm; 1001 + length: number; 1002 + } 1003 + interface CryptoKeyRsaKeyAlgorithm { 1004 + name: string; 1005 + modulusLength: number; 1006 + publicExponent: ArrayBuffer | ArrayBufferView; 1007 + hash?: CryptoKeyKeyAlgorithm; 1008 + } 1009 + interface CryptoKeyEllipticKeyAlgorithm { 1010 + name: string; 1011 + namedCurve: string; 1012 + } 1013 + interface CryptoKeyArbitraryKeyAlgorithm { 1014 + name: string; 1015 + hash?: CryptoKeyKeyAlgorithm; 1016 + namedCurve?: string; 1017 + length?: number; 1018 + } 1019 + declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> { 1020 + constructor(algorithm: string | SubtleCryptoHashAlgorithm); 1021 + readonly digest: Promise<ArrayBuffer>; 1022 + get bytesWritten(): number | bigint; 1023 + } 1024 + /** 1025 + * A decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. 1026 + * 1027 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder) 1028 + */ 1029 + declare class TextDecoder { 1030 + constructor(label?: string, options?: TextDecoderConstructorOptions); 1031 + /** 1032 + * Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments. 1033 + * 1034 + * ``` 1035 + * var string = "", decoder = new TextDecoder(encoding), buffer; 1036 + * while(buffer = next_chunk()) { 1037 + * string += decoder.decode(buffer, {stream:true}); 1038 + * } 1039 + * string += decoder.decode(); // end-of-queue 1040 + * ``` 1041 + * 1042 + * If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError. 1043 + * 1044 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode) 1045 + */ 1046 + decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string; 1047 + get encoding(): string; 1048 + get fatal(): boolean; 1049 + get ignoreBOM(): boolean; 1050 + } 1051 + /** 1052 + * TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays. 1053 + * 1054 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder) 1055 + */ 1056 + declare class TextEncoder { 1057 + constructor(); 1058 + /** 1059 + * Returns the result of running UTF-8's encoder. 1060 + * 1061 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode) 1062 + */ 1063 + encode(input?: string): Uint8Array; 1064 + /** 1065 + * Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as an object wherein read is the number of converted code units of source and written is the number of bytes modified in destination. 1066 + * 1067 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto) 1068 + */ 1069 + encodeInto(input: string, buffer: ArrayBuffer | ArrayBufferView): TextEncoderEncodeIntoResult; 1070 + get encoding(): string; 1071 + } 1072 + interface TextDecoderConstructorOptions { 1073 + fatal: boolean; 1074 + ignoreBOM: boolean; 1075 + } 1076 + interface TextDecoderDecodeOptions { 1077 + stream: boolean; 1078 + } 1079 + interface TextEncoderEncodeIntoResult { 1080 + read: number; 1081 + written: number; 1082 + } 1083 + /** 1084 + * Events providing information related to errors in scripts or in files. 1085 + * 1086 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent) 1087 + */ 1088 + declare class ErrorEvent extends Event { 1089 + constructor(type: string, init?: ErrorEventErrorEventInit); 1090 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */ 1091 + get filename(): string; 1092 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */ 1093 + get message(): string; 1094 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */ 1095 + get lineno(): number; 1096 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */ 1097 + get colno(): number; 1098 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */ 1099 + get error(): any; 1100 + } 1101 + interface ErrorEventErrorEventInit { 1102 + message?: string; 1103 + filename?: string; 1104 + lineno?: number; 1105 + colno?: number; 1106 + error?: any; 1107 + } 1108 + /** 1109 + * Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data". 1110 + * 1111 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData) 1112 + */ 1113 + declare class FormData { 1114 + constructor(); 1115 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */ 1116 + append(name: string, value: string): void; 1117 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */ 1118 + append(name: string, value: Blob, filename?: string): void; 1119 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) */ 1120 + delete(name: string): void; 1121 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) */ 1122 + get(name: string): (File | string) | null; 1123 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) */ 1124 + getAll(name: string): (File | string)[]; 1125 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) */ 1126 + has(name: string): boolean; 1127 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */ 1128 + set(name: string, value: string): void; 1129 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */ 1130 + set(name: string, value: Blob, filename?: string): void; 1131 + /* Returns an array of key, value pairs for every entry in the list. */ 1132 + entries(): IterableIterator<[ 1133 + key: string, 1134 + value: File | string 1135 + ]>; 1136 + /* Returns a list of keys in the list. */ 1137 + keys(): IterableIterator<string>; 1138 + /* Returns a list of values in the list. */ 1139 + values(): IterableIterator<(File | string)>; 1140 + forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void; 1141 + [Symbol.iterator](): IterableIterator<[ 1142 + key: string, 1143 + value: File | string 1144 + ]>; 1145 + } 1146 + interface ContentOptions { 1147 + html?: boolean; 1148 + } 1149 + declare class HTMLRewriter { 1150 + constructor(); 1151 + on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter; 1152 + onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter; 1153 + transform(response: Response): Response; 1154 + } 1155 + interface HTMLRewriterElementContentHandlers { 1156 + element?(element: Element): void | Promise<void>; 1157 + comments?(comment: Comment): void | Promise<void>; 1158 + text?(element: Text): void | Promise<void>; 1159 + } 1160 + interface HTMLRewriterDocumentContentHandlers { 1161 + doctype?(doctype: Doctype): void | Promise<void>; 1162 + comments?(comment: Comment): void | Promise<void>; 1163 + text?(text: Text): void | Promise<void>; 1164 + end?(end: DocumentEnd): void | Promise<void>; 1165 + } 1166 + interface Doctype { 1167 + readonly name: string | null; 1168 + readonly publicId: string | null; 1169 + readonly systemId: string | null; 1170 + } 1171 + interface Element { 1172 + tagName: string; 1173 + readonly attributes: IterableIterator<string[]>; 1174 + readonly removed: boolean; 1175 + readonly namespaceURI: string; 1176 + getAttribute(name: string): string | null; 1177 + hasAttribute(name: string): boolean; 1178 + setAttribute(name: string, value: string): Element; 1179 + removeAttribute(name: string): Element; 1180 + before(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1181 + after(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1182 + prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1183 + append(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1184 + replace(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1185 + remove(): Element; 1186 + removeAndKeepContent(): Element; 1187 + setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1188 + onEndTag(handler: (tag: EndTag) => void | Promise<void>): void; 1189 + } 1190 + interface EndTag { 1191 + name: string; 1192 + before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag; 1193 + after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag; 1194 + remove(): EndTag; 1195 + } 1196 + interface Comment { 1197 + text: string; 1198 + readonly removed: boolean; 1199 + before(content: string, options?: ContentOptions): Comment; 1200 + after(content: string, options?: ContentOptions): Comment; 1201 + replace(content: string, options?: ContentOptions): Comment; 1202 + remove(): Comment; 1203 + } 1204 + interface Text { 1205 + readonly text: string; 1206 + readonly lastInTextNode: boolean; 1207 + readonly removed: boolean; 1208 + before(content: string | ReadableStream | Response, options?: ContentOptions): Text; 1209 + after(content: string | ReadableStream | Response, options?: ContentOptions): Text; 1210 + replace(content: string | ReadableStream | Response, options?: ContentOptions): Text; 1211 + remove(): Text; 1212 + } 1213 + interface DocumentEnd { 1214 + append(content: string, options?: ContentOptions): DocumentEnd; 1215 + } 1216 + /** 1217 + * This is the event type for fetch events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the event.respondWith() method, which allows us to provide a response to this fetch. 1218 + * 1219 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent) 1220 + */ 1221 + declare abstract class FetchEvent extends ExtendableEvent { 1222 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */ 1223 + readonly request: Request; 1224 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) */ 1225 + respondWith(promise: Response | Promise<Response>): void; 1226 + passThroughOnException(): void; 1227 + } 1228 + type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>; 1229 + /** 1230 + * This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence. 1231 + * 1232 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers) 1233 + */ 1234 + declare class Headers { 1235 + constructor(init?: HeadersInit); 1236 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) */ 1237 + get(name: string): string | null; 1238 + getAll(name: string): string[]; 1239 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) */ 1240 + getSetCookie(): string[]; 1241 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) */ 1242 + has(name: string): boolean; 1243 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) */ 1244 + set(name: string, value: string): void; 1245 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) */ 1246 + append(name: string, value: string): void; 1247 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) */ 1248 + delete(name: string): void; 1249 + forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void; 1250 + /* Returns an iterator allowing to go through all key/value pairs contained in this object. */ 1251 + entries(): IterableIterator<[ 1252 + key: string, 1253 + value: string 1254 + ]>; 1255 + /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */ 1256 + keys(): IterableIterator<string>; 1257 + /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */ 1258 + values(): IterableIterator<string>; 1259 + [Symbol.iterator](): IterableIterator<[ 1260 + key: string, 1261 + value: string 1262 + ]>; 1263 + } 1264 + type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData; 1265 + declare abstract class Body { 1266 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */ 1267 + get body(): ReadableStream | null; 1268 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */ 1269 + get bodyUsed(): boolean; 1270 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */ 1271 + arrayBuffer(): Promise<ArrayBuffer>; 1272 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */ 1273 + bytes(): Promise<Uint8Array>; 1274 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */ 1275 + text(): Promise<string>; 1276 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */ 1277 + json<T>(): Promise<T>; 1278 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */ 1279 + formData(): Promise<FormData>; 1280 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */ 1281 + blob(): Promise<Blob>; 1282 + } 1283 + /** 1284 + * This Fetch API interface represents the response to a request. 1285 + * 1286 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response) 1287 + */ 1288 + declare var Response: { 1289 + prototype: Response; 1290 + new (body?: BodyInit | null, init?: ResponseInit): Response; 1291 + error(): Response; 1292 + redirect(url: string, status?: number): Response; 1293 + json(any: any, maybeInit?: (ResponseInit | Response)): Response; 1294 + }; 1295 + /** 1296 + * This Fetch API interface represents the response to a request. 1297 + * 1298 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response) 1299 + */ 1300 + interface Response extends Body { 1301 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */ 1302 + clone(): Response; 1303 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */ 1304 + status: number; 1305 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */ 1306 + statusText: string; 1307 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */ 1308 + headers: Headers; 1309 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */ 1310 + ok: boolean; 1311 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */ 1312 + redirected: boolean; 1313 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */ 1314 + url: string; 1315 + webSocket: WebSocket | null; 1316 + cf: any | undefined; 1317 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type) */ 1318 + type: "default" | "error"; 1319 + } 1320 + interface ResponseInit { 1321 + status?: number; 1322 + statusText?: string; 1323 + headers?: HeadersInit; 1324 + cf?: any; 1325 + webSocket?: (WebSocket | null); 1326 + encodeBody?: "automatic" | "manual"; 1327 + } 1328 + type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string; 1329 + /** 1330 + * This Fetch API interface represents a resource request. 1331 + * 1332 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request) 1333 + */ 1334 + declare var Request: { 1335 + prototype: Request; 1336 + new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>; 1337 + }; 1338 + /** 1339 + * This Fetch API interface represents a resource request. 1340 + * 1341 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request) 1342 + */ 1343 + interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body { 1344 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */ 1345 + clone(): Request<CfHostMetadata, Cf>; 1346 + /** 1347 + * Returns request's HTTP method, which is "GET" by default. 1348 + * 1349 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method) 1350 + */ 1351 + method: string; 1352 + /** 1353 + * Returns the URL of request as a string. 1354 + * 1355 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url) 1356 + */ 1357 + url: string; 1358 + /** 1359 + * Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. 1360 + * 1361 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers) 1362 + */ 1363 + headers: Headers; 1364 + /** 1365 + * Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. 1366 + * 1367 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect) 1368 + */ 1369 + redirect: string; 1370 + fetcher: Fetcher | null; 1371 + /** 1372 + * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. 1373 + * 1374 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal) 1375 + */ 1376 + signal: AbortSignal; 1377 + cf: Cf | undefined; 1378 + /** 1379 + * Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] 1380 + * 1381 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity) 1382 + */ 1383 + integrity: string; 1384 + /** 1385 + * Returns a boolean indicating whether or not request can outlive the global in which it was created. 1386 + * 1387 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive) 1388 + */ 1389 + keepalive: boolean; 1390 + /** 1391 + * Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. 1392 + * 1393 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache) 1394 + */ 1395 + cache?: "no-store"; 1396 + } 1397 + interface RequestInit<Cf = CfProperties> { 1398 + /* A string to set request's method. */ 1399 + method?: string; 1400 + /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */ 1401 + headers?: HeadersInit; 1402 + /* A BodyInit object or null to set request's body. */ 1403 + body?: BodyInit | null; 1404 + /* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */ 1405 + redirect?: string; 1406 + fetcher?: (Fetcher | null); 1407 + cf?: Cf; 1408 + /* A string indicating how the request will interact with the browser's cache to set request's cache. */ 1409 + cache?: "no-store"; 1410 + /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */ 1411 + integrity?: string; 1412 + /* An AbortSignal to set request's signal. */ 1413 + signal?: (AbortSignal | null); 1414 + encodeResponseBody?: "automatic" | "manual"; 1415 + } 1416 + type Service<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T>; 1417 + type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & { 1418 + fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>; 1419 + connect(address: SocketAddress | string, options?: SocketOptions): Socket; 1420 + }; 1421 + interface KVNamespaceListKey<Metadata, Key extends string = string> { 1422 + name: Key; 1423 + expiration?: number; 1424 + metadata?: Metadata; 1425 + } 1426 + type KVNamespaceListResult<Metadata, Key extends string = string> = { 1427 + list_complete: false; 1428 + keys: KVNamespaceListKey<Metadata, Key>[]; 1429 + cursor: string; 1430 + cacheStatus: string | null; 1431 + } | { 1432 + list_complete: true; 1433 + keys: KVNamespaceListKey<Metadata, Key>[]; 1434 + cacheStatus: string | null; 1435 + }; 1436 + interface KVNamespace<Key extends string = string> { 1437 + get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>; 1438 + get(key: Key, type: "text"): Promise<string | null>; 1439 + get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>; 1440 + get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>; 1441 + get(key: Key, type: "stream"): Promise<ReadableStream | null>; 1442 + get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>; 1443 + get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>; 1444 + get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>; 1445 + get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>; 1446 + get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>; 1447 + get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>; 1448 + get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>; 1449 + get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>; 1450 + get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>; 1451 + list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>; 1452 + put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>; 1453 + getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>; 1454 + getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>; 1455 + getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>; 1456 + getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>; 1457 + getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>; 1458 + getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>; 1459 + getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>; 1460 + getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>; 1461 + getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>; 1462 + getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>; 1463 + getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>; 1464 + getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>; 1465 + getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>; 1466 + getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>; 1467 + delete(key: Key): Promise<void>; 1468 + } 1469 + interface KVNamespaceListOptions { 1470 + limit?: number; 1471 + prefix?: (string | null); 1472 + cursor?: (string | null); 1473 + } 1474 + interface KVNamespaceGetOptions<Type> { 1475 + type: Type; 1476 + cacheTtl?: number; 1477 + } 1478 + interface KVNamespacePutOptions { 1479 + expiration?: number; 1480 + expirationTtl?: number; 1481 + metadata?: (any | null); 1482 + } 1483 + interface KVNamespaceGetWithMetadataResult<Value, Metadata> { 1484 + value: Value | null; 1485 + metadata: Metadata | null; 1486 + cacheStatus: string | null; 1487 + } 1488 + type QueueContentType = "text" | "bytes" | "json" | "v8"; 1489 + interface Queue<Body = unknown> { 1490 + send(message: Body, options?: QueueSendOptions): Promise<void>; 1491 + sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>; 1492 + } 1493 + interface QueueSendOptions { 1494 + contentType?: QueueContentType; 1495 + delaySeconds?: number; 1496 + } 1497 + interface QueueSendBatchOptions { 1498 + delaySeconds?: number; 1499 + } 1500 + interface MessageSendRequest<Body = unknown> { 1501 + body: Body; 1502 + contentType?: QueueContentType; 1503 + delaySeconds?: number; 1504 + } 1505 + interface QueueRetryOptions { 1506 + delaySeconds?: number; 1507 + } 1508 + interface Message<Body = unknown> { 1509 + readonly id: string; 1510 + readonly timestamp: Date; 1511 + readonly body: Body; 1512 + readonly attempts: number; 1513 + retry(options?: QueueRetryOptions): void; 1514 + ack(): void; 1515 + } 1516 + interface QueueEvent<Body = unknown> extends ExtendableEvent { 1517 + readonly messages: readonly Message<Body>[]; 1518 + readonly queue: string; 1519 + retryAll(options?: QueueRetryOptions): void; 1520 + ackAll(): void; 1521 + } 1522 + interface MessageBatch<Body = unknown> { 1523 + readonly messages: readonly Message<Body>[]; 1524 + readonly queue: string; 1525 + retryAll(options?: QueueRetryOptions): void; 1526 + ackAll(): void; 1527 + } 1528 + interface R2Error extends Error { 1529 + readonly name: string; 1530 + readonly code: number; 1531 + readonly message: string; 1532 + readonly action: string; 1533 + readonly stack: any; 1534 + } 1535 + interface R2ListOptions { 1536 + limit?: number; 1537 + prefix?: string; 1538 + cursor?: string; 1539 + delimiter?: string; 1540 + startAfter?: string; 1541 + include?: ("httpMetadata" | "customMetadata")[]; 1542 + } 1543 + declare abstract class R2Bucket { 1544 + head(key: string): Promise<R2Object | null>; 1545 + get(key: string, options: R2GetOptions & { 1546 + onlyIf: R2Conditional | Headers; 1547 + }): Promise<R2ObjectBody | R2Object | null>; 1548 + get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>; 1549 + put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & { 1550 + onlyIf: R2Conditional | Headers; 1551 + }): Promise<R2Object | null>; 1552 + put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>; 1553 + createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>; 1554 + resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload; 1555 + delete(keys: string | string[]): Promise<void>; 1556 + list(options?: R2ListOptions): Promise<R2Objects>; 1557 + } 1558 + interface R2MultipartUpload { 1559 + readonly key: string; 1560 + readonly uploadId: string; 1561 + uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>; 1562 + abort(): Promise<void>; 1563 + complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>; 1564 + } 1565 + interface R2UploadedPart { 1566 + partNumber: number; 1567 + etag: string; 1568 + } 1569 + declare abstract class R2Object { 1570 + readonly key: string; 1571 + readonly version: string; 1572 + readonly size: number; 1573 + readonly etag: string; 1574 + readonly httpEtag: string; 1575 + readonly checksums: R2Checksums; 1576 + readonly uploaded: Date; 1577 + readonly httpMetadata?: R2HTTPMetadata; 1578 + readonly customMetadata?: Record<string, string>; 1579 + readonly range?: R2Range; 1580 + readonly storageClass: string; 1581 + readonly ssecKeyMd5?: string; 1582 + writeHttpMetadata(headers: Headers): void; 1583 + } 1584 + interface R2ObjectBody extends R2Object { 1585 + get body(): ReadableStream; 1586 + get bodyUsed(): boolean; 1587 + arrayBuffer(): Promise<ArrayBuffer>; 1588 + bytes(): Promise<Uint8Array>; 1589 + text(): Promise<string>; 1590 + json<T>(): Promise<T>; 1591 + blob(): Promise<Blob>; 1592 + } 1593 + type R2Range = { 1594 + offset: number; 1595 + length?: number; 1596 + } | { 1597 + offset?: number; 1598 + length: number; 1599 + } | { 1600 + suffix: number; 1601 + }; 1602 + interface R2Conditional { 1603 + etagMatches?: string; 1604 + etagDoesNotMatch?: string; 1605 + uploadedBefore?: Date; 1606 + uploadedAfter?: Date; 1607 + secondsGranularity?: boolean; 1608 + } 1609 + interface R2GetOptions { 1610 + onlyIf?: (R2Conditional | Headers); 1611 + range?: (R2Range | Headers); 1612 + ssecKey?: (ArrayBuffer | string); 1613 + } 1614 + interface R2PutOptions { 1615 + onlyIf?: (R2Conditional | Headers); 1616 + httpMetadata?: (R2HTTPMetadata | Headers); 1617 + customMetadata?: Record<string, string>; 1618 + md5?: ((ArrayBuffer | ArrayBufferView) | string); 1619 + sha1?: ((ArrayBuffer | ArrayBufferView) | string); 1620 + sha256?: ((ArrayBuffer | ArrayBufferView) | string); 1621 + sha384?: ((ArrayBuffer | ArrayBufferView) | string); 1622 + sha512?: ((ArrayBuffer | ArrayBufferView) | string); 1623 + storageClass?: string; 1624 + ssecKey?: (ArrayBuffer | string); 1625 + } 1626 + interface R2MultipartOptions { 1627 + httpMetadata?: (R2HTTPMetadata | Headers); 1628 + customMetadata?: Record<string, string>; 1629 + storageClass?: string; 1630 + ssecKey?: (ArrayBuffer | string); 1631 + } 1632 + interface R2Checksums { 1633 + readonly md5?: ArrayBuffer; 1634 + readonly sha1?: ArrayBuffer; 1635 + readonly sha256?: ArrayBuffer; 1636 + readonly sha384?: ArrayBuffer; 1637 + readonly sha512?: ArrayBuffer; 1638 + toJSON(): R2StringChecksums; 1639 + } 1640 + interface R2StringChecksums { 1641 + md5?: string; 1642 + sha1?: string; 1643 + sha256?: string; 1644 + sha384?: string; 1645 + sha512?: string; 1646 + } 1647 + interface R2HTTPMetadata { 1648 + contentType?: string; 1649 + contentLanguage?: string; 1650 + contentDisposition?: string; 1651 + contentEncoding?: string; 1652 + cacheControl?: string; 1653 + cacheExpiry?: Date; 1654 + } 1655 + type R2Objects = { 1656 + objects: R2Object[]; 1657 + delimitedPrefixes: string[]; 1658 + } & ({ 1659 + truncated: true; 1660 + cursor: string; 1661 + } | { 1662 + truncated: false; 1663 + }); 1664 + interface R2UploadPartOptions { 1665 + ssecKey?: (ArrayBuffer | string); 1666 + } 1667 + declare abstract class ScheduledEvent extends ExtendableEvent { 1668 + readonly scheduledTime: number; 1669 + readonly cron: string; 1670 + noRetry(): void; 1671 + } 1672 + interface ScheduledController { 1673 + readonly scheduledTime: number; 1674 + readonly cron: string; 1675 + noRetry(): void; 1676 + } 1677 + interface QueuingStrategy<T = any> { 1678 + highWaterMark?: (number | bigint); 1679 + size?: (chunk: T) => number | bigint; 1680 + } 1681 + interface UnderlyingSink<W = any> { 1682 + type?: string; 1683 + start?: (controller: WritableStreamDefaultController) => void | Promise<void>; 1684 + write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>; 1685 + abort?: (reason: any) => void | Promise<void>; 1686 + close?: () => void | Promise<void>; 1687 + } 1688 + interface UnderlyingByteSource { 1689 + type: "bytes"; 1690 + autoAllocateChunkSize?: number; 1691 + start?: (controller: ReadableByteStreamController) => void | Promise<void>; 1692 + pull?: (controller: ReadableByteStreamController) => void | Promise<void>; 1693 + cancel?: (reason: any) => void | Promise<void>; 1694 + } 1695 + interface UnderlyingSource<R = any> { 1696 + type?: "" | undefined; 1697 + start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>; 1698 + pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>; 1699 + cancel?: (reason: any) => void | Promise<void>; 1700 + expectedLength?: (number | bigint); 1701 + } 1702 + interface Transformer<I = any, O = any> { 1703 + readableType?: string; 1704 + writableType?: string; 1705 + start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>; 1706 + transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>; 1707 + flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>; 1708 + cancel?: (reason: any) => void | Promise<void>; 1709 + expectedLength?: number; 1710 + } 1711 + interface StreamPipeOptions { 1712 + /** 1713 + * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. 1714 + * 1715 + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. 1716 + * 1717 + * Errors and closures of the source and destination streams propagate as follows: 1718 + * 1719 + * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. 1720 + * 1721 + * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. 1722 + * 1723 + * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. 1724 + * 1725 + * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. 1726 + * 1727 + * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. 1728 + */ 1729 + preventClose?: boolean; 1730 + preventAbort?: boolean; 1731 + preventCancel?: boolean; 1732 + signal?: AbortSignal; 1733 + } 1734 + type ReadableStreamReadResult<R = any> = { 1735 + done: false; 1736 + value: R; 1737 + } | { 1738 + done: true; 1739 + value?: undefined; 1740 + }; 1741 + /** 1742 + * This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. 1743 + * 1744 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream) 1745 + */ 1746 + interface ReadableStream<R = any> { 1747 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked) */ 1748 + get locked(): boolean; 1749 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel) */ 1750 + cancel(reason?: any): Promise<void>; 1751 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */ 1752 + getReader(): ReadableStreamDefaultReader<R>; 1753 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */ 1754 + getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader; 1755 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough) */ 1756 + pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>; 1757 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo) */ 1758 + pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>; 1759 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee) */ 1760 + tee(): [ 1761 + ReadableStream<R>, 1762 + ReadableStream<R> 1763 + ]; 1764 + values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>; 1765 + [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>; 1766 + } 1767 + /** 1768 + * This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. 1769 + * 1770 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream) 1771 + */ 1772 + declare const ReadableStream: { 1773 + prototype: ReadableStream; 1774 + new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>; 1775 + new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>; 1776 + }; 1777 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader) */ 1778 + declare class ReadableStreamDefaultReader<R = any> { 1779 + constructor(stream: ReadableStream); 1780 + get closed(): Promise<void>; 1781 + cancel(reason?: any): Promise<void>; 1782 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read) */ 1783 + read(): Promise<ReadableStreamReadResult<R>>; 1784 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock) */ 1785 + releaseLock(): void; 1786 + } 1787 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */ 1788 + declare class ReadableStreamBYOBReader { 1789 + constructor(stream: ReadableStream); 1790 + get closed(): Promise<void>; 1791 + cancel(reason?: any): Promise<void>; 1792 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */ 1793 + read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>; 1794 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */ 1795 + releaseLock(): void; 1796 + readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>; 1797 + } 1798 + interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions { 1799 + min?: number; 1800 + } 1801 + interface ReadableStreamGetReaderOptions { 1802 + /** 1803 + * Creates a ReadableStreamBYOBReader and locks the stream to the new reader. 1804 + * 1805 + * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation. 1806 + */ 1807 + mode: "byob"; 1808 + } 1809 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */ 1810 + declare abstract class ReadableStreamBYOBRequest { 1811 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */ 1812 + get view(): Uint8Array | null; 1813 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */ 1814 + respond(bytesWritten: number): void; 1815 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */ 1816 + respondWithNewView(view: ArrayBuffer | ArrayBufferView): void; 1817 + get atLeast(): number | null; 1818 + } 1819 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController) */ 1820 + declare abstract class ReadableStreamDefaultController<R = any> { 1821 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize) */ 1822 + get desiredSize(): number | null; 1823 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close) */ 1824 + close(): void; 1825 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue) */ 1826 + enqueue(chunk?: R): void; 1827 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error) */ 1828 + error(reason: any): void; 1829 + } 1830 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController) */ 1831 + declare abstract class ReadableByteStreamController { 1832 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest) */ 1833 + get byobRequest(): ReadableStreamBYOBRequest | null; 1834 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize) */ 1835 + get desiredSize(): number | null; 1836 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close) */ 1837 + close(): void; 1838 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue) */ 1839 + enqueue(chunk: ArrayBuffer | ArrayBufferView): void; 1840 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error) */ 1841 + error(reason: any): void; 1842 + } 1843 + /** 1844 + * This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. 1845 + * 1846 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController) 1847 + */ 1848 + declare abstract class WritableStreamDefaultController { 1849 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal) */ 1850 + get signal(): AbortSignal; 1851 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error) */ 1852 + error(reason?: any): void; 1853 + } 1854 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController) */ 1855 + declare abstract class TransformStreamDefaultController<O = any> { 1856 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize) */ 1857 + get desiredSize(): number | null; 1858 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue) */ 1859 + enqueue(chunk?: O): void; 1860 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error) */ 1861 + error(reason: any): void; 1862 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate) */ 1863 + terminate(): void; 1864 + } 1865 + interface ReadableWritablePair<R = any, W = any> { 1866 + /** 1867 + * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. 1868 + * 1869 + * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. 1870 + */ 1871 + writable: WritableStream<W>; 1872 + readable: ReadableStream<R>; 1873 + } 1874 + /** 1875 + * This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing. 1876 + * 1877 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream) 1878 + */ 1879 + declare class WritableStream<W = any> { 1880 + constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy); 1881 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked) */ 1882 + get locked(): boolean; 1883 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort) */ 1884 + abort(reason?: any): Promise<void>; 1885 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close) */ 1886 + close(): Promise<void>; 1887 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter) */ 1888 + getWriter(): WritableStreamDefaultWriter<W>; 1889 + } 1890 + /** 1891 + * This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink. 1892 + * 1893 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter) 1894 + */ 1895 + declare class WritableStreamDefaultWriter<W = any> { 1896 + constructor(stream: WritableStream); 1897 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */ 1898 + get closed(): Promise<void>; 1899 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */ 1900 + get ready(): Promise<void>; 1901 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */ 1902 + get desiredSize(): number | null; 1903 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */ 1904 + abort(reason?: any): Promise<void>; 1905 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */ 1906 + close(): Promise<void>; 1907 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write) */ 1908 + write(chunk?: W): Promise<void>; 1909 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock) */ 1910 + releaseLock(): void; 1911 + } 1912 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream) */ 1913 + declare class TransformStream<I = any, O = any> { 1914 + constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>); 1915 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable) */ 1916 + get readable(): ReadableStream<O>; 1917 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable) */ 1918 + get writable(): WritableStream<I>; 1919 + } 1920 + declare class FixedLengthStream extends IdentityTransformStream { 1921 + constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy); 1922 + } 1923 + declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> { 1924 + constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy); 1925 + } 1926 + interface IdentityTransformStreamQueuingStrategy { 1927 + highWaterMark?: (number | bigint); 1928 + } 1929 + interface ReadableStreamValuesOptions { 1930 + preventCancel?: boolean; 1931 + } 1932 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */ 1933 + declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> { 1934 + constructor(format: "gzip" | "deflate" | "deflate-raw"); 1935 + } 1936 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) */ 1937 + declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> { 1938 + constructor(format: "gzip" | "deflate" | "deflate-raw"); 1939 + } 1940 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream) */ 1941 + declare class TextEncoderStream extends TransformStream<string, Uint8Array> { 1942 + constructor(); 1943 + get encoding(): string; 1944 + } 1945 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream) */ 1946 + declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> { 1947 + constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit); 1948 + get encoding(): string; 1949 + get fatal(): boolean; 1950 + get ignoreBOM(): boolean; 1951 + } 1952 + interface TextDecoderStreamTextDecoderStreamInit { 1953 + fatal?: boolean; 1954 + ignoreBOM?: boolean; 1955 + } 1956 + /** 1957 + * This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. 1958 + * 1959 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy) 1960 + */ 1961 + declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> { 1962 + constructor(init: QueuingStrategyInit); 1963 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) */ 1964 + get highWaterMark(): number; 1965 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */ 1966 + get size(): (chunk?: any) => number; 1967 + } 1968 + /** 1969 + * This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. 1970 + * 1971 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy) 1972 + */ 1973 + declare class CountQueuingStrategy implements QueuingStrategy { 1974 + constructor(init: QueuingStrategyInit); 1975 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) */ 1976 + get highWaterMark(): number; 1977 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */ 1978 + get size(): (chunk?: any) => number; 1979 + } 1980 + interface QueuingStrategyInit { 1981 + /** 1982 + * Creates a new ByteLengthQueuingStrategy with the provided high water mark. 1983 + * 1984 + * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw. 1985 + */ 1986 + highWaterMark: number; 1987 + } 1988 + interface ScriptVersion { 1989 + id?: string; 1990 + tag?: string; 1991 + message?: string; 1992 + } 1993 + declare abstract class TailEvent extends ExtendableEvent { 1994 + readonly events: TraceItem[]; 1995 + readonly traces: TraceItem[]; 1996 + } 1997 + interface TraceItem { 1998 + readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null; 1999 + readonly eventTimestamp: number | null; 2000 + readonly logs: TraceLog[]; 2001 + readonly exceptions: TraceException[]; 2002 + readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[]; 2003 + readonly scriptName: string | null; 2004 + readonly entrypoint?: string; 2005 + readonly scriptVersion?: ScriptVersion; 2006 + readonly dispatchNamespace?: string; 2007 + readonly scriptTags?: string[]; 2008 + readonly outcome: string; 2009 + readonly executionModel: string; 2010 + readonly truncated: boolean; 2011 + readonly cpuTime: number; 2012 + readonly wallTime: number; 2013 + } 2014 + interface TraceItemAlarmEventInfo { 2015 + readonly scheduledTime: Date; 2016 + } 2017 + interface TraceItemCustomEventInfo { 2018 + } 2019 + interface TraceItemScheduledEventInfo { 2020 + readonly scheduledTime: number; 2021 + readonly cron: string; 2022 + } 2023 + interface TraceItemQueueEventInfo { 2024 + readonly queue: string; 2025 + readonly batchSize: number; 2026 + } 2027 + interface TraceItemEmailEventInfo { 2028 + readonly mailFrom: string; 2029 + readonly rcptTo: string; 2030 + readonly rawSize: number; 2031 + } 2032 + interface TraceItemTailEventInfo { 2033 + readonly consumedEvents: TraceItemTailEventInfoTailItem[]; 2034 + } 2035 + interface TraceItemTailEventInfoTailItem { 2036 + readonly scriptName: string | null; 2037 + } 2038 + interface TraceItemFetchEventInfo { 2039 + readonly response?: TraceItemFetchEventInfoResponse; 2040 + readonly request: TraceItemFetchEventInfoRequest; 2041 + } 2042 + interface TraceItemFetchEventInfoRequest { 2043 + readonly cf?: any; 2044 + readonly headers: Record<string, string>; 2045 + readonly method: string; 2046 + readonly url: string; 2047 + getUnredacted(): TraceItemFetchEventInfoRequest; 2048 + } 2049 + interface TraceItemFetchEventInfoResponse { 2050 + readonly status: number; 2051 + } 2052 + interface TraceItemJsRpcEventInfo { 2053 + readonly rpcMethod: string; 2054 + } 2055 + interface TraceItemHibernatableWebSocketEventInfo { 2056 + readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError; 2057 + } 2058 + interface TraceItemHibernatableWebSocketEventInfoMessage { 2059 + readonly webSocketEventType: string; 2060 + } 2061 + interface TraceItemHibernatableWebSocketEventInfoClose { 2062 + readonly webSocketEventType: string; 2063 + readonly code: number; 2064 + readonly wasClean: boolean; 2065 + } 2066 + interface TraceItemHibernatableWebSocketEventInfoError { 2067 + readonly webSocketEventType: string; 2068 + } 2069 + interface TraceLog { 2070 + readonly timestamp: number; 2071 + readonly level: string; 2072 + readonly message: any; 2073 + } 2074 + interface TraceException { 2075 + readonly timestamp: number; 2076 + readonly message: string; 2077 + readonly name: string; 2078 + readonly stack?: string; 2079 + } 2080 + interface TraceDiagnosticChannelEvent { 2081 + readonly timestamp: number; 2082 + readonly channel: string; 2083 + readonly message: any; 2084 + } 2085 + interface TraceMetrics { 2086 + readonly cpuTime: number; 2087 + readonly wallTime: number; 2088 + } 2089 + interface UnsafeTraceMetrics { 2090 + fromTrace(item: TraceItem): TraceMetrics; 2091 + } 2092 + /** 2093 + * The URL interface represents an object providing static methods used for creating object URLs. 2094 + * 2095 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL) 2096 + */ 2097 + declare class URL { 2098 + constructor(url: string | URL, base?: string | URL); 2099 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */ 2100 + get origin(): string; 2101 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */ 2102 + get href(): string; 2103 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */ 2104 + set href(value: string); 2105 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */ 2106 + get protocol(): string; 2107 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */ 2108 + set protocol(value: string); 2109 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */ 2110 + get username(): string; 2111 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */ 2112 + set username(value: string); 2113 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */ 2114 + get password(): string; 2115 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */ 2116 + set password(value: string); 2117 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */ 2118 + get host(): string; 2119 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */ 2120 + set host(value: string); 2121 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */ 2122 + get hostname(): string; 2123 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */ 2124 + set hostname(value: string); 2125 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */ 2126 + get port(): string; 2127 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */ 2128 + set port(value: string); 2129 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */ 2130 + get pathname(): string; 2131 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */ 2132 + set pathname(value: string); 2133 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */ 2134 + get search(): string; 2135 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */ 2136 + set search(value: string); 2137 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */ 2138 + get hash(): string; 2139 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */ 2140 + set hash(value: string); 2141 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */ 2142 + get searchParams(): URLSearchParams; 2143 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */ 2144 + toJSON(): string; 2145 + /*function toString() { [native code] }*/ 2146 + toString(): string; 2147 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */ 2148 + static canParse(url: string, base?: string): boolean; 2149 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */ 2150 + static parse(url: string, base?: string): URL | null; 2151 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */ 2152 + static createObjectURL(object: File | Blob): string; 2153 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */ 2154 + static revokeObjectURL(object_url: string): void; 2155 + } 2156 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) */ 2157 + declare class URLSearchParams { 2158 + constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string)); 2159 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) */ 2160 + get size(): number; 2161 + /** 2162 + * Appends a specified key/value pair as a new search parameter. 2163 + * 2164 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append) 2165 + */ 2166 + append(name: string, value: string): void; 2167 + /** 2168 + * Deletes the given search parameter, and its associated value, from the list of all search parameters. 2169 + * 2170 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete) 2171 + */ 2172 + delete(name: string, value?: string): void; 2173 + /** 2174 + * Returns the first value associated to the given search parameter. 2175 + * 2176 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get) 2177 + */ 2178 + get(name: string): string | null; 2179 + /** 2180 + * Returns all the values association with a given search parameter. 2181 + * 2182 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll) 2183 + */ 2184 + getAll(name: string): string[]; 2185 + /** 2186 + * Returns a Boolean indicating if such a search parameter exists. 2187 + * 2188 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has) 2189 + */ 2190 + has(name: string, value?: string): boolean; 2191 + /** 2192 + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 2193 + * 2194 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set) 2195 + */ 2196 + set(name: string, value: string): void; 2197 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort) */ 2198 + sort(): void; 2199 + /* Returns an array of key, value pairs for every entry in the search params. */ 2200 + entries(): IterableIterator<[ 2201 + key: string, 2202 + value: string 2203 + ]>; 2204 + /* Returns a list of keys in the search params. */ 2205 + keys(): IterableIterator<string>; 2206 + /* Returns a list of values in the search params. */ 2207 + values(): IterableIterator<string>; 2208 + forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void; 2209 + /*function toString() { [native code] } Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */ 2210 + toString(): string; 2211 + [Symbol.iterator](): IterableIterator<[ 2212 + key: string, 2213 + value: string 2214 + ]>; 2215 + } 2216 + declare class URLPattern { 2217 + constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions); 2218 + get protocol(): string; 2219 + get username(): string; 2220 + get password(): string; 2221 + get hostname(): string; 2222 + get port(): string; 2223 + get pathname(): string; 2224 + get search(): string; 2225 + get hash(): string; 2226 + get hasRegExpGroups(): boolean; 2227 + test(input?: (string | URLPatternInit), baseURL?: string): boolean; 2228 + exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null; 2229 + } 2230 + interface URLPatternInit { 2231 + protocol?: string; 2232 + username?: string; 2233 + password?: string; 2234 + hostname?: string; 2235 + port?: string; 2236 + pathname?: string; 2237 + search?: string; 2238 + hash?: string; 2239 + baseURL?: string; 2240 + } 2241 + interface URLPatternComponentResult { 2242 + input: string; 2243 + groups: Record<string, string>; 2244 + } 2245 + interface URLPatternResult { 2246 + inputs: (string | URLPatternInit)[]; 2247 + protocol: URLPatternComponentResult; 2248 + username: URLPatternComponentResult; 2249 + password: URLPatternComponentResult; 2250 + hostname: URLPatternComponentResult; 2251 + port: URLPatternComponentResult; 2252 + pathname: URLPatternComponentResult; 2253 + search: URLPatternComponentResult; 2254 + hash: URLPatternComponentResult; 2255 + } 2256 + interface URLPatternOptions { 2257 + ignoreCase?: boolean; 2258 + } 2259 + /** 2260 + * A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute. 2261 + * 2262 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent) 2263 + */ 2264 + declare class CloseEvent extends Event { 2265 + constructor(type: string, initializer?: CloseEventInit); 2266 + /** 2267 + * Returns the WebSocket connection close code provided by the server. 2268 + * 2269 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code) 2270 + */ 2271 + readonly code: number; 2272 + /** 2273 + * Returns the WebSocket connection close reason provided by the server. 2274 + * 2275 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason) 2276 + */ 2277 + readonly reason: string; 2278 + /** 2279 + * Returns true if the connection closed cleanly; false otherwise. 2280 + * 2281 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean) 2282 + */ 2283 + readonly wasClean: boolean; 2284 + } 2285 + interface CloseEventInit { 2286 + code?: number; 2287 + reason?: string; 2288 + wasClean?: boolean; 2289 + } 2290 + /** 2291 + * A message received by a target object. 2292 + * 2293 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent) 2294 + */ 2295 + declare class MessageEvent extends Event { 2296 + constructor(type: string, initializer: MessageEventInit); 2297 + /** 2298 + * Returns the data of the message. 2299 + * 2300 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data) 2301 + */ 2302 + readonly data: ArrayBuffer | string; 2303 + } 2304 + interface MessageEventInit { 2305 + data: ArrayBuffer | string; 2306 + } 2307 + type WebSocketEventMap = { 2308 + close: CloseEvent; 2309 + message: MessageEvent; 2310 + open: Event; 2311 + error: ErrorEvent; 2312 + }; 2313 + /** 2314 + * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. 2315 + * 2316 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket) 2317 + */ 2318 + declare var WebSocket: { 2319 + prototype: WebSocket; 2320 + new (url: string, protocols?: (string[] | string)): WebSocket; 2321 + readonly READY_STATE_CONNECTING: number; 2322 + readonly CONNECTING: number; 2323 + readonly READY_STATE_OPEN: number; 2324 + readonly OPEN: number; 2325 + readonly READY_STATE_CLOSING: number; 2326 + readonly CLOSING: number; 2327 + readonly READY_STATE_CLOSED: number; 2328 + readonly CLOSED: number; 2329 + }; 2330 + /** 2331 + * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. 2332 + * 2333 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket) 2334 + */ 2335 + interface WebSocket extends EventTarget<WebSocketEventMap> { 2336 + accept(): void; 2337 + /** 2338 + * Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView. 2339 + * 2340 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send) 2341 + */ 2342 + send(message: (ArrayBuffer | ArrayBufferView) | string): void; 2343 + /** 2344 + * Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason. 2345 + * 2346 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close) 2347 + */ 2348 + close(code?: number, reason?: string): void; 2349 + serializeAttachment(attachment: any): void; 2350 + deserializeAttachment(): any | null; 2351 + /** 2352 + * Returns the state of the WebSocket object's connection. It can have the values described below. 2353 + * 2354 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState) 2355 + */ 2356 + readyState: number; 2357 + /** 2358 + * Returns the URL that was used to establish the WebSocket connection. 2359 + * 2360 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url) 2361 + */ 2362 + url: string | null; 2363 + /** 2364 + * Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation. 2365 + * 2366 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol) 2367 + */ 2368 + protocol: string | null; 2369 + /** 2370 + * Returns the extensions selected by the server, if any. 2371 + * 2372 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions) 2373 + */ 2374 + extensions: string | null; 2375 + } 2376 + declare const WebSocketPair: { 2377 + new (): { 2378 + 0: WebSocket; 2379 + 1: WebSocket; 2380 + }; 2381 + }; 2382 + interface SqlStorage { 2383 + exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>; 2384 + get databaseSize(): number; 2385 + Cursor: typeof SqlStorageCursor; 2386 + Statement: typeof SqlStorageStatement; 2387 + } 2388 + declare abstract class SqlStorageStatement { 2389 + } 2390 + type SqlStorageValue = ArrayBuffer | string | number | null; 2391 + declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> { 2392 + next(): { 2393 + done?: false; 2394 + value: T; 2395 + } | { 2396 + done: true; 2397 + value?: never; 2398 + }; 2399 + toArray(): T[]; 2400 + one(): T; 2401 + raw<U extends SqlStorageValue[]>(): IterableIterator<U>; 2402 + columnNames: string[]; 2403 + get rowsRead(): number; 2404 + get rowsWritten(): number; 2405 + [Symbol.iterator](): IterableIterator<T>; 2406 + } 2407 + interface Socket { 2408 + get readable(): ReadableStream; 2409 + get writable(): WritableStream; 2410 + get closed(): Promise<void>; 2411 + get opened(): Promise<SocketInfo>; 2412 + get upgraded(): boolean; 2413 + get secureTransport(): "on" | "off" | "starttls"; 2414 + close(): Promise<void>; 2415 + startTls(options?: TlsOptions): Socket; 2416 + } 2417 + interface SocketOptions { 2418 + secureTransport?: string; 2419 + allowHalfOpen: boolean; 2420 + highWaterMark?: (number | bigint); 2421 + } 2422 + interface SocketAddress { 2423 + hostname: string; 2424 + port: number; 2425 + } 2426 + interface TlsOptions { 2427 + expectedServerHostname?: string; 2428 + } 2429 + interface SocketInfo { 2430 + remoteAddress?: string; 2431 + localAddress?: string; 2432 + } 2433 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */ 2434 + declare class EventSource extends EventTarget { 2435 + constructor(url: string, init?: EventSourceEventSourceInit); 2436 + /** 2437 + * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED. 2438 + * 2439 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close) 2440 + */ 2441 + close(): void; 2442 + /** 2443 + * Returns the URL providing the event stream. 2444 + * 2445 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url) 2446 + */ 2447 + get url(): string; 2448 + /** 2449 + * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise. 2450 + * 2451 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials) 2452 + */ 2453 + get withCredentials(): boolean; 2454 + /** 2455 + * Returns the state of this EventSource object's connection. It can have the values described below. 2456 + * 2457 + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState) 2458 + */ 2459 + get readyState(): number; 2460 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */ 2461 + get onopen(): any | null; 2462 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */ 2463 + set onopen(value: any | null); 2464 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */ 2465 + get onmessage(): any | null; 2466 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */ 2467 + set onmessage(value: any | null); 2468 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */ 2469 + get onerror(): any | null; 2470 + /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */ 2471 + set onerror(value: any | null); 2472 + static readonly CONNECTING: number; 2473 + static readonly OPEN: number; 2474 + static readonly CLOSED: number; 2475 + static from(stream: ReadableStream): EventSource; 2476 + } 2477 + interface EventSourceEventSourceInit { 2478 + withCredentials?: boolean; 2479 + fetcher?: Fetcher; 2480 + } 2481 + interface Container { 2482 + get running(): boolean; 2483 + start(options?: ContainerStartupOptions): void; 2484 + monitor(): Promise<void>; 2485 + destroy(error?: any): Promise<void>; 2486 + signal(signo: number): void; 2487 + getTcpPort(port: number): Fetcher; 2488 + } 2489 + interface ContainerStartupOptions { 2490 + entrypoint?: string[]; 2491 + enableInternet: boolean; 2492 + env?: Record<string, string>; 2493 + } 2494 + type AiImageClassificationInput = { 2495 + image: number[]; 2496 + }; 2497 + type AiImageClassificationOutput = { 2498 + score?: number; 2499 + label?: string; 2500 + }[]; 2501 + declare abstract class BaseAiImageClassification { 2502 + inputs: AiImageClassificationInput; 2503 + postProcessedOutputs: AiImageClassificationOutput; 2504 + } 2505 + type AiImageToTextInput = { 2506 + image: number[]; 2507 + prompt?: string; 2508 + max_tokens?: number; 2509 + temperature?: number; 2510 + top_p?: number; 2511 + top_k?: number; 2512 + seed?: number; 2513 + repetition_penalty?: number; 2514 + frequency_penalty?: number; 2515 + presence_penalty?: number; 2516 + raw?: boolean; 2517 + messages?: RoleScopedChatInput[]; 2518 + }; 2519 + type AiImageToTextOutput = { 2520 + description: string; 2521 + }; 2522 + declare abstract class BaseAiImageToText { 2523 + inputs: AiImageToTextInput; 2524 + postProcessedOutputs: AiImageToTextOutput; 2525 + } 2526 + type AiImageTextToTextInput = { 2527 + image: string; 2528 + prompt?: string; 2529 + max_tokens?: number; 2530 + temperature?: number; 2531 + ignore_eos?: boolean; 2532 + top_p?: number; 2533 + top_k?: number; 2534 + seed?: number; 2535 + repetition_penalty?: number; 2536 + frequency_penalty?: number; 2537 + presence_penalty?: number; 2538 + raw?: boolean; 2539 + messages?: RoleScopedChatInput[]; 2540 + }; 2541 + type AiImageTextToTextOutput = { 2542 + description: string; 2543 + }; 2544 + declare abstract class BaseAiImageTextToText { 2545 + inputs: AiImageTextToTextInput; 2546 + postProcessedOutputs: AiImageTextToTextOutput; 2547 + } 2548 + type AiObjectDetectionInput = { 2549 + image: number[]; 2550 + }; 2551 + type AiObjectDetectionOutput = { 2552 + score?: number; 2553 + label?: string; 2554 + }[]; 2555 + declare abstract class BaseAiObjectDetection { 2556 + inputs: AiObjectDetectionInput; 2557 + postProcessedOutputs: AiObjectDetectionOutput; 2558 + } 2559 + type AiSentenceSimilarityInput = { 2560 + source: string; 2561 + sentences: string[]; 2562 + }; 2563 + type AiSentenceSimilarityOutput = number[]; 2564 + declare abstract class BaseAiSentenceSimilarity { 2565 + inputs: AiSentenceSimilarityInput; 2566 + postProcessedOutputs: AiSentenceSimilarityOutput; 2567 + } 2568 + type AiAutomaticSpeechRecognitionInput = { 2569 + audio: number[]; 2570 + }; 2571 + type AiAutomaticSpeechRecognitionOutput = { 2572 + text?: string; 2573 + words?: { 2574 + word: string; 2575 + start: number; 2576 + end: number; 2577 + }[]; 2578 + vtt?: string; 2579 + }; 2580 + declare abstract class BaseAiAutomaticSpeechRecognition { 2581 + inputs: AiAutomaticSpeechRecognitionInput; 2582 + postProcessedOutputs: AiAutomaticSpeechRecognitionOutput; 2583 + } 2584 + type AiSummarizationInput = { 2585 + input_text: string; 2586 + max_length?: number; 2587 + }; 2588 + type AiSummarizationOutput = { 2589 + summary: string; 2590 + }; 2591 + declare abstract class BaseAiSummarization { 2592 + inputs: AiSummarizationInput; 2593 + postProcessedOutputs: AiSummarizationOutput; 2594 + } 2595 + type AiTextClassificationInput = { 2596 + text: string; 2597 + }; 2598 + type AiTextClassificationOutput = { 2599 + score?: number; 2600 + label?: string; 2601 + }[]; 2602 + declare abstract class BaseAiTextClassification { 2603 + inputs: AiTextClassificationInput; 2604 + postProcessedOutputs: AiTextClassificationOutput; 2605 + } 2606 + type AiTextEmbeddingsInput = { 2607 + text: string | string[]; 2608 + }; 2609 + type AiTextEmbeddingsOutput = { 2610 + shape: number[]; 2611 + data: number[][]; 2612 + }; 2613 + declare abstract class BaseAiTextEmbeddings { 2614 + inputs: AiTextEmbeddingsInput; 2615 + postProcessedOutputs: AiTextEmbeddingsOutput; 2616 + } 2617 + type RoleScopedChatInput = { 2618 + role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>); 2619 + content: string; 2620 + name?: string; 2621 + }; 2622 + type AiTextGenerationToolLegacyInput = { 2623 + name: string; 2624 + description: string; 2625 + parameters?: { 2626 + type: "object" | (string & NonNullable<unknown>); 2627 + properties: { 2628 + [key: string]: { 2629 + type: string; 2630 + description?: string; 2631 + }; 2632 + }; 2633 + required: string[]; 2634 + }; 2635 + }; 2636 + type AiTextGenerationToolInput = { 2637 + type: "function" | (string & NonNullable<unknown>); 2638 + function: { 2639 + name: string; 2640 + description: string; 2641 + parameters?: { 2642 + type: "object" | (string & NonNullable<unknown>); 2643 + properties: { 2644 + [key: string]: { 2645 + type: string; 2646 + description?: string; 2647 + }; 2648 + }; 2649 + required: string[]; 2650 + }; 2651 + }; 2652 + }; 2653 + type AiTextGenerationFunctionsInput = { 2654 + name: string; 2655 + code: string; 2656 + }; 2657 + type AiTextGenerationResponseFormat = { 2658 + type: string; 2659 + json_schema?: any; 2660 + }; 2661 + type AiTextGenerationInput = { 2662 + prompt?: string; 2663 + raw?: boolean; 2664 + stream?: boolean; 2665 + max_tokens?: number; 2666 + temperature?: number; 2667 + top_p?: number; 2668 + top_k?: number; 2669 + seed?: number; 2670 + repetition_penalty?: number; 2671 + frequency_penalty?: number; 2672 + presence_penalty?: number; 2673 + messages?: RoleScopedChatInput[]; 2674 + response_format?: AiTextGenerationResponseFormat; 2675 + tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>); 2676 + functions?: AiTextGenerationFunctionsInput[]; 2677 + }; 2678 + type AiTextGenerationOutput = { 2679 + response?: string; 2680 + tool_calls?: { 2681 + name: string; 2682 + arguments: unknown; 2683 + }[]; 2684 + } | ReadableStream; 2685 + declare abstract class BaseAiTextGeneration { 2686 + inputs: AiTextGenerationInput; 2687 + postProcessedOutputs: AiTextGenerationOutput; 2688 + } 2689 + type AiTextToSpeechInput = { 2690 + prompt: string; 2691 + lang?: string; 2692 + }; 2693 + type AiTextToSpeechOutput = Uint8Array | { 2694 + audio: string; 2695 + }; 2696 + declare abstract class BaseAiTextToSpeech { 2697 + inputs: AiTextToSpeechInput; 2698 + postProcessedOutputs: AiTextToSpeechOutput; 2699 + } 2700 + type AiTextToImageInput = { 2701 + prompt: string; 2702 + negative_prompt?: string; 2703 + height?: number; 2704 + width?: number; 2705 + image?: number[]; 2706 + image_b64?: string; 2707 + mask?: number[]; 2708 + num_steps?: number; 2709 + strength?: number; 2710 + guidance?: number; 2711 + seed?: number; 2712 + }; 2713 + type AiTextToImageOutput = ReadableStream<Uint8Array>; 2714 + declare abstract class BaseAiTextToImage { 2715 + inputs: AiTextToImageInput; 2716 + postProcessedOutputs: AiTextToImageOutput; 2717 + } 2718 + type AiTranslationInput = { 2719 + text: string; 2720 + target_lang: string; 2721 + source_lang?: string; 2722 + }; 2723 + type AiTranslationOutput = { 2724 + translated_text?: string; 2725 + }; 2726 + declare abstract class BaseAiTranslation { 2727 + inputs: AiTranslationInput; 2728 + postProcessedOutputs: AiTranslationOutput; 2729 + } 2730 + type Ai_Cf_Openai_Whisper_Input = string | { 2731 + /** 2732 + * An array of integers that represent the audio data constrained to 8-bit unsigned integer values 2733 + */ 2734 + audio: number[]; 2735 + }; 2736 + interface Ai_Cf_Openai_Whisper_Output { 2737 + /** 2738 + * The transcription 2739 + */ 2740 + text: string; 2741 + word_count?: number; 2742 + words?: { 2743 + word?: string; 2744 + /** 2745 + * The second this word begins in the recording 2746 + */ 2747 + start?: number; 2748 + /** 2749 + * The ending second when the word completes 2750 + */ 2751 + end?: number; 2752 + }[]; 2753 + vtt?: string; 2754 + } 2755 + declare abstract class Base_Ai_Cf_Openai_Whisper { 2756 + inputs: Ai_Cf_Openai_Whisper_Input; 2757 + postProcessedOutputs: Ai_Cf_Openai_Whisper_Output; 2758 + } 2759 + type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | { 2760 + /** 2761 + * The input text prompt for the model to generate a response. 2762 + */ 2763 + prompt?: string; 2764 + /** 2765 + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 2766 + */ 2767 + raw?: boolean; 2768 + /** 2769 + * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. 2770 + */ 2771 + top_p?: number; 2772 + /** 2773 + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. 2774 + */ 2775 + top_k?: number; 2776 + /** 2777 + * Random seed for reproducibility of the generation. 2778 + */ 2779 + seed?: number; 2780 + /** 2781 + * Penalty for repeated tokens; higher values discourage repetition. 2782 + */ 2783 + repetition_penalty?: number; 2784 + /** 2785 + * Decreases the likelihood of the model repeating the same lines verbatim. 2786 + */ 2787 + frequency_penalty?: number; 2788 + /** 2789 + * Increases the likelihood of the model introducing new topics. 2790 + */ 2791 + presence_penalty?: number; 2792 + image: number[] | (string & NonNullable<unknown>); 2793 + /** 2794 + * The maximum number of tokens to generate in the response. 2795 + */ 2796 + max_tokens?: number; 2797 + }; 2798 + interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output { 2799 + description?: string; 2800 + } 2801 + declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M { 2802 + inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input; 2803 + postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output; 2804 + } 2805 + type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | { 2806 + /** 2807 + * An array of integers that represent the audio data constrained to 8-bit unsigned integer values 2808 + */ 2809 + audio: number[]; 2810 + }; 2811 + interface Ai_Cf_Openai_Whisper_Tiny_En_Output { 2812 + /** 2813 + * The transcription 2814 + */ 2815 + text: string; 2816 + word_count?: number; 2817 + words?: { 2818 + word?: string; 2819 + /** 2820 + * The second this word begins in the recording 2821 + */ 2822 + start?: number; 2823 + /** 2824 + * The ending second when the word completes 2825 + */ 2826 + end?: number; 2827 + }[]; 2828 + vtt?: string; 2829 + } 2830 + declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En { 2831 + inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input; 2832 + postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output; 2833 + } 2834 + interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input { 2835 + /** 2836 + * Base64 encoded value of the audio data. 2837 + */ 2838 + audio: string; 2839 + /** 2840 + * Supported tasks are 'translate' or 'transcribe'. 2841 + */ 2842 + task?: string; 2843 + /** 2844 + * The language of the audio being transcribed or translated. 2845 + */ 2846 + language?: string; 2847 + /** 2848 + * Preprocess the audio with a voice activity detection model. 2849 + */ 2850 + vad_filter?: string; 2851 + /** 2852 + * A text prompt to help provide context to the model on the contents of the audio. 2853 + */ 2854 + initial_prompt?: string; 2855 + /** 2856 + * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result. 2857 + */ 2858 + prefix?: string; 2859 + } 2860 + interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output { 2861 + transcription_info?: { 2862 + /** 2863 + * The language of the audio being transcribed or translated. 2864 + */ 2865 + language?: string; 2866 + /** 2867 + * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1. 2868 + */ 2869 + language_probability?: number; 2870 + /** 2871 + * The total duration of the original audio file, in seconds. 2872 + */ 2873 + duration?: number; 2874 + /** 2875 + * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds. 2876 + */ 2877 + duration_after_vad?: number; 2878 + }; 2879 + /** 2880 + * The complete transcription of the audio. 2881 + */ 2882 + text: string; 2883 + /** 2884 + * The total number of words in the transcription. 2885 + */ 2886 + word_count?: number; 2887 + segments?: { 2888 + /** 2889 + * The starting time of the segment within the audio, in seconds. 2890 + */ 2891 + start?: number; 2892 + /** 2893 + * The ending time of the segment within the audio, in seconds. 2894 + */ 2895 + end?: number; 2896 + /** 2897 + * The transcription of the segment. 2898 + */ 2899 + text?: string; 2900 + /** 2901 + * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs. 2902 + */ 2903 + temperature?: number; 2904 + /** 2905 + * The average log probability of the predictions for the words in this segment, indicating overall confidence. 2906 + */ 2907 + avg_logprob?: number; 2908 + /** 2909 + * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process. 2910 + */ 2911 + compression_ratio?: number; 2912 + /** 2913 + * The probability that the segment contains no speech, represented as a decimal between 0 and 1. 2914 + */ 2915 + no_speech_prob?: number; 2916 + words?: { 2917 + /** 2918 + * The individual word transcribed from the audio. 2919 + */ 2920 + word?: string; 2921 + /** 2922 + * The starting time of the word within the audio, in seconds. 2923 + */ 2924 + start?: number; 2925 + /** 2926 + * The ending time of the word within the audio, in seconds. 2927 + */ 2928 + end?: number; 2929 + }[]; 2930 + }[]; 2931 + /** 2932 + * The transcription in WebVTT format, which includes timing and text information for use in subtitles. 2933 + */ 2934 + vtt?: string; 2935 + } 2936 + declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo { 2937 + inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input; 2938 + postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output; 2939 + } 2940 + type Ai_Cf_Baai_Bge_M3_Input = BGEM3InputQueryAndContexts | BGEM3InputEmbedding; 2941 + interface BGEM3InputQueryAndContexts { 2942 + /** 2943 + * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts 2944 + */ 2945 + query?: string; 2946 + /** 2947 + * List of provided contexts. Note that the index in this array is important, as the response will refer to it. 2948 + */ 2949 + contexts: { 2950 + /** 2951 + * One of the provided context content 2952 + */ 2953 + text?: string; 2954 + }[]; 2955 + /** 2956 + * When provided with too long context should the model error out or truncate the context to fit? 2957 + */ 2958 + truncate_inputs?: boolean; 2959 + } 2960 + interface BGEM3InputEmbedding { 2961 + text: string | string[]; 2962 + /** 2963 + * When provided with too long context should the model error out or truncate the context to fit? 2964 + */ 2965 + truncate_inputs?: boolean; 2966 + } 2967 + type Ai_Cf_Baai_Bge_M3_Output = BGEM3OuputQuery | BGEM3OutputEmbeddingForContexts | BGEM3OuputEmbedding; 2968 + interface BGEM3OuputQuery { 2969 + response?: { 2970 + /** 2971 + * Index of the context in the request 2972 + */ 2973 + id?: number; 2974 + /** 2975 + * Score of the context under the index. 2976 + */ 2977 + score?: number; 2978 + }[]; 2979 + } 2980 + interface BGEM3OutputEmbeddingForContexts { 2981 + response?: number[][]; 2982 + shape?: number[]; 2983 + /** 2984 + * The pooling method used in the embedding process. 2985 + */ 2986 + pooling?: "mean" | "cls"; 2987 + } 2988 + interface BGEM3OuputEmbedding { 2989 + shape?: number[]; 2990 + /** 2991 + * Embeddings of the requested text values 2992 + */ 2993 + data?: number[][]; 2994 + /** 2995 + * The pooling method used in the embedding process. 2996 + */ 2997 + pooling?: "mean" | "cls"; 2998 + } 2999 + declare abstract class Base_Ai_Cf_Baai_Bge_M3 { 3000 + inputs: Ai_Cf_Baai_Bge_M3_Input; 3001 + postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output; 3002 + } 3003 + interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input { 3004 + /** 3005 + * A text description of the image you want to generate. 3006 + */ 3007 + prompt: string; 3008 + /** 3009 + * The number of diffusion steps; higher values can improve quality but take longer. 3010 + */ 3011 + steps?: number; 3012 + } 3013 + interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output { 3014 + /** 3015 + * The generated image in Base64 format. 3016 + */ 3017 + image?: string; 3018 + } 3019 + declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell { 3020 + inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input; 3021 + postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output; 3022 + } 3023 + type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages; 3024 + interface Prompt { 3025 + /** 3026 + * The input text prompt for the model to generate a response. 3027 + */ 3028 + prompt: string; 3029 + image?: number[] | (string & NonNullable<unknown>); 3030 + /** 3031 + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 3032 + */ 3033 + raw?: boolean; 3034 + /** 3035 + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 3036 + */ 3037 + stream?: boolean; 3038 + /** 3039 + * The maximum number of tokens to generate in the response. 3040 + */ 3041 + max_tokens?: number; 3042 + /** 3043 + * Controls the randomness of the output; higher values produce more random results. 3044 + */ 3045 + temperature?: number; 3046 + /** 3047 + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. 3048 + */ 3049 + top_p?: number; 3050 + /** 3051 + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. 3052 + */ 3053 + top_k?: number; 3054 + /** 3055 + * Random seed for reproducibility of the generation. 3056 + */ 3057 + seed?: number; 3058 + /** 3059 + * Penalty for repeated tokens; higher values discourage repetition. 3060 + */ 3061 + repetition_penalty?: number; 3062 + /** 3063 + * Decreases the likelihood of the model repeating the same lines verbatim. 3064 + */ 3065 + frequency_penalty?: number; 3066 + /** 3067 + * Increases the likelihood of the model introducing new topics. 3068 + */ 3069 + presence_penalty?: number; 3070 + /** 3071 + * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 3072 + */ 3073 + lora?: string; 3074 + } 3075 + interface Messages { 3076 + /** 3077 + * An array of message objects representing the conversation history. 3078 + */ 3079 + messages: { 3080 + /** 3081 + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 3082 + */ 3083 + role: string; 3084 + /** 3085 + * The content of the message as a string. 3086 + */ 3087 + content: string; 3088 + }[]; 3089 + image?: number[] | string; 3090 + functions?: { 3091 + name: string; 3092 + code: string; 3093 + }[]; 3094 + /** 3095 + * A list of tools available for the assistant to use. 3096 + */ 3097 + tools?: ({ 3098 + /** 3099 + * The name of the tool. More descriptive the better. 3100 + */ 3101 + name: string; 3102 + /** 3103 + * A brief description of what the tool does. 3104 + */ 3105 + description: string; 3106 + /** 3107 + * Schema defining the parameters accepted by the tool. 3108 + */ 3109 + parameters: { 3110 + /** 3111 + * The type of the parameters object (usually 'object'). 3112 + */ 3113 + type: string; 3114 + /** 3115 + * List of required parameter names. 3116 + */ 3117 + required?: string[]; 3118 + /** 3119 + * Definitions of each parameter. 3120 + */ 3121 + properties: { 3122 + [k: string]: { 3123 + /** 3124 + * The data type of the parameter. 3125 + */ 3126 + type: string; 3127 + /** 3128 + * A description of the expected parameter. 3129 + */ 3130 + description: string; 3131 + }; 3132 + }; 3133 + }; 3134 + } | { 3135 + /** 3136 + * Specifies the type of tool (e.g., 'function'). 3137 + */ 3138 + type: string; 3139 + /** 3140 + * Details of the function tool. 3141 + */ 3142 + function: { 3143 + /** 3144 + * The name of the function. 3145 + */ 3146 + name: string; 3147 + /** 3148 + * A brief description of what the function does. 3149 + */ 3150 + description: string; 3151 + /** 3152 + * Schema defining the parameters accepted by the function. 3153 + */ 3154 + parameters: { 3155 + /** 3156 + * The type of the parameters object (usually 'object'). 3157 + */ 3158 + type: string; 3159 + /** 3160 + * List of required parameter names. 3161 + */ 3162 + required?: string[]; 3163 + /** 3164 + * Definitions of each parameter. 3165 + */ 3166 + properties: { 3167 + [k: string]: { 3168 + /** 3169 + * The data type of the parameter. 3170 + */ 3171 + type: string; 3172 + /** 3173 + * A description of the expected parameter. 3174 + */ 3175 + description: string; 3176 + }; 3177 + }; 3178 + }; 3179 + }; 3180 + })[]; 3181 + /** 3182 + * If true, the response will be streamed back incrementally. 3183 + */ 3184 + stream?: boolean; 3185 + /** 3186 + * The maximum number of tokens to generate in the response. 3187 + */ 3188 + max_tokens?: number; 3189 + /** 3190 + * Controls the randomness of the output; higher values produce more random results. 3191 + */ 3192 + temperature?: number; 3193 + /** 3194 + * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. 3195 + */ 3196 + top_p?: number; 3197 + /** 3198 + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. 3199 + */ 3200 + top_k?: number; 3201 + /** 3202 + * Random seed for reproducibility of the generation. 3203 + */ 3204 + seed?: number; 3205 + /** 3206 + * Penalty for repeated tokens; higher values discourage repetition. 3207 + */ 3208 + repetition_penalty?: number; 3209 + /** 3210 + * Decreases the likelihood of the model repeating the same lines verbatim. 3211 + */ 3212 + frequency_penalty?: number; 3213 + /** 3214 + * Increases the likelihood of the model introducing new topics. 3215 + */ 3216 + presence_penalty?: number; 3217 + } 3218 + type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = { 3219 + /** 3220 + * The generated text response from the model 3221 + */ 3222 + response?: string; 3223 + /** 3224 + * An array of tool calls requests made during the response generation 3225 + */ 3226 + tool_calls?: { 3227 + /** 3228 + * The arguments passed to be passed to the tool call request 3229 + */ 3230 + arguments?: object; 3231 + /** 3232 + * The name of the tool to be called 3233 + */ 3234 + name?: string; 3235 + }[]; 3236 + } | ReadableStream; 3237 + declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct { 3238 + inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input; 3239 + postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output; 3240 + } 3241 + interface Ai_Cf_Meta_Llama_Guard_3_8B_Input { 3242 + /** 3243 + * An array of message objects representing the conversation history. 3244 + */ 3245 + messages: { 3246 + /** 3247 + * The role of the message sender must alternate between 'user' and 'assistant'. 3248 + */ 3249 + role: "user" | "assistant"; 3250 + /** 3251 + * The content of the message as a string. 3252 + */ 3253 + content: string; 3254 + }[]; 3255 + /** 3256 + * The maximum number of tokens to generate in the response. 3257 + */ 3258 + max_tokens?: number; 3259 + /** 3260 + * Controls the randomness of the output; higher values produce more random results. 3261 + */ 3262 + temperature?: number; 3263 + /** 3264 + * Dictate the output format of the generated response. 3265 + */ 3266 + response_format?: { 3267 + /** 3268 + * Set to json_object to process and output generated text as JSON. 3269 + */ 3270 + type?: string; 3271 + }; 3272 + } 3273 + interface Ai_Cf_Meta_Llama_Guard_3_8B_Output { 3274 + response?: string | { 3275 + /** 3276 + * Whether the conversation is safe or not. 3277 + */ 3278 + safe?: boolean; 3279 + /** 3280 + * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe. 3281 + */ 3282 + categories?: string[]; 3283 + }; 3284 + /** 3285 + * Usage statistics for the inference request 3286 + */ 3287 + usage?: { 3288 + /** 3289 + * Total number of tokens in input 3290 + */ 3291 + prompt_tokens?: number; 3292 + /** 3293 + * Total number of tokens in output 3294 + */ 3295 + completion_tokens?: number; 3296 + /** 3297 + * Total number of input and output tokens 3298 + */ 3299 + total_tokens?: number; 3300 + }; 3301 + } 3302 + declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B { 3303 + inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input; 3304 + postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output; 3305 + } 3306 + interface Ai_Cf_Baai_Bge_Reranker_Base_Input { 3307 + /** 3308 + * A query you wish to perform against the provided contexts. 3309 + */ 3310 + /** 3311 + * Number of returned results starting with the best score. 3312 + */ 3313 + top_k?: number; 3314 + /** 3315 + * List of provided contexts. Note that the index in this array is important, as the response will refer to it. 3316 + */ 3317 + contexts: { 3318 + /** 3319 + * One of the provided context content 3320 + */ 3321 + text?: string; 3322 + }[]; 3323 + } 3324 + interface Ai_Cf_Baai_Bge_Reranker_Base_Output { 3325 + response?: { 3326 + /** 3327 + * Index of the context in the request 3328 + */ 3329 + id?: number; 3330 + /** 3331 + * Score of the context under the index. 3332 + */ 3333 + score?: number; 3334 + }[]; 3335 + } 3336 + declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base { 3337 + inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input; 3338 + postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output; 3339 + } 3340 + type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Prompt | Ai_Cf_Meta_Llama_4_Messages; 3341 + interface Ai_Cf_Meta_Llama_4_Prompt { 3342 + /** 3343 + * The input text prompt for the model to generate a response. 3344 + */ 3345 + prompt: string; 3346 + /** 3347 + * JSON schema that should be fulfilled for the response. 3348 + */ 3349 + guided_json?: object; 3350 + /** 3351 + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 3352 + */ 3353 + raw?: boolean; 3354 + /** 3355 + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 3356 + */ 3357 + stream?: boolean; 3358 + /** 3359 + * The maximum number of tokens to generate in the response. 3360 + */ 3361 + max_tokens?: number; 3362 + /** 3363 + * Controls the randomness of the output; higher values produce more random results. 3364 + */ 3365 + temperature?: number; 3366 + /** 3367 + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. 3368 + */ 3369 + top_p?: number; 3370 + /** 3371 + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. 3372 + */ 3373 + top_k?: number; 3374 + /** 3375 + * Random seed for reproducibility of the generation. 3376 + */ 3377 + seed?: number; 3378 + /** 3379 + * Penalty for repeated tokens; higher values discourage repetition. 3380 + */ 3381 + repetition_penalty?: number; 3382 + /** 3383 + * Decreases the likelihood of the model repeating the same lines verbatim. 3384 + */ 3385 + frequency_penalty?: number; 3386 + /** 3387 + * Increases the likelihood of the model introducing new topics. 3388 + */ 3389 + presence_penalty?: number; 3390 + } 3391 + interface Ai_Cf_Meta_Llama_4_Messages { 3392 + /** 3393 + * An array of message objects representing the conversation history. 3394 + */ 3395 + messages: { 3396 + /** 3397 + * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 3398 + */ 3399 + role?: string; 3400 + /** 3401 + * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001 3402 + */ 3403 + tool_call_id?: string; 3404 + content?: string | { 3405 + /** 3406 + * Type of the content provided 3407 + */ 3408 + type?: string; 3409 + text?: string; 3410 + image_url?: { 3411 + /** 3412 + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 3413 + */ 3414 + url?: string; 3415 + }; 3416 + }[] | { 3417 + /** 3418 + * Type of the content provided 3419 + */ 3420 + type?: string; 3421 + text?: string; 3422 + image_url?: { 3423 + /** 3424 + * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 3425 + */ 3426 + url?: string; 3427 + }; 3428 + }; 3429 + }[]; 3430 + functions?: { 3431 + name: string; 3432 + code: string; 3433 + }[]; 3434 + /** 3435 + * A list of tools available for the assistant to use. 3436 + */ 3437 + tools?: ({ 3438 + /** 3439 + * The name of the tool. More descriptive the better. 3440 + */ 3441 + name: string; 3442 + /** 3443 + * A brief description of what the tool does. 3444 + */ 3445 + description: string; 3446 + /** 3447 + * Schema defining the parameters accepted by the tool. 3448 + */ 3449 + parameters: { 3450 + /** 3451 + * The type of the parameters object (usually 'object'). 3452 + */ 3453 + type: string; 3454 + /** 3455 + * List of required parameter names. 3456 + */ 3457 + required?: string[]; 3458 + /** 3459 + * Definitions of each parameter. 3460 + */ 3461 + properties: { 3462 + [k: string]: { 3463 + /** 3464 + * The data type of the parameter. 3465 + */ 3466 + type: string; 3467 + /** 3468 + * A description of the expected parameter. 3469 + */ 3470 + description: string; 3471 + }; 3472 + }; 3473 + }; 3474 + } | { 3475 + /** 3476 + * Specifies the type of tool (e.g., 'function'). 3477 + */ 3478 + type: string; 3479 + /** 3480 + * Details of the function tool. 3481 + */ 3482 + function: { 3483 + /** 3484 + * The name of the function. 3485 + */ 3486 + name: string; 3487 + /** 3488 + * A brief description of what the function does. 3489 + */ 3490 + description: string; 3491 + /** 3492 + * Schema defining the parameters accepted by the function. 3493 + */ 3494 + parameters: { 3495 + /** 3496 + * The type of the parameters object (usually 'object'). 3497 + */ 3498 + type: string; 3499 + /** 3500 + * List of required parameter names. 3501 + */ 3502 + required?: string[]; 3503 + /** 3504 + * Definitions of each parameter. 3505 + */ 3506 + properties: { 3507 + [k: string]: { 3508 + /** 3509 + * The data type of the parameter. 3510 + */ 3511 + type: string; 3512 + /** 3513 + * A description of the expected parameter. 3514 + */ 3515 + description: string; 3516 + }; 3517 + }; 3518 + }; 3519 + }; 3520 + })[]; 3521 + /** 3522 + * JSON schema that should be fufilled for the response. 3523 + */ 3524 + guided_json?: object; 3525 + /** 3526 + * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 3527 + */ 3528 + raw?: boolean; 3529 + /** 3530 + * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 3531 + */ 3532 + stream?: boolean; 3533 + /** 3534 + * The maximum number of tokens to generate in the response. 3535 + */ 3536 + max_tokens?: number; 3537 + /** 3538 + * Controls the randomness of the output; higher values produce more random results. 3539 + */ 3540 + temperature?: number; 3541 + /** 3542 + * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses. 3543 + */ 3544 + top_p?: number; 3545 + /** 3546 + * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises. 3547 + */ 3548 + top_k?: number; 3549 + /** 3550 + * Random seed for reproducibility of the generation. 3551 + */ 3552 + seed?: number; 3553 + /** 3554 + * Penalty for repeated tokens; higher values discourage repetition. 3555 + */ 3556 + repetition_penalty?: number; 3557 + /** 3558 + * Decreases the likelihood of the model repeating the same lines verbatim. 3559 + */ 3560 + frequency_penalty?: number; 3561 + /** 3562 + * Increases the likelihood of the model introducing new topics. 3563 + */ 3564 + presence_penalty?: number; 3565 + } 3566 + type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = { 3567 + /** 3568 + * The generated text response from the model 3569 + */ 3570 + response: string; 3571 + /** 3572 + * Usage statistics for the inference request 3573 + */ 3574 + usage?: { 3575 + /** 3576 + * Total number of tokens in input 3577 + */ 3578 + prompt_tokens?: number; 3579 + /** 3580 + * Total number of tokens in output 3581 + */ 3582 + completion_tokens?: number; 3583 + /** 3584 + * Total number of input and output tokens 3585 + */ 3586 + total_tokens?: number; 3587 + }; 3588 + /** 3589 + * An array of tool calls requests made during the response generation 3590 + */ 3591 + tool_calls?: { 3592 + /** 3593 + * The arguments passed to be passed to the tool call request 3594 + */ 3595 + arguments?: object; 3596 + /** 3597 + * The name of the tool to be called 3598 + */ 3599 + name?: string; 3600 + }[]; 3601 + } | string; 3602 + declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct { 3603 + inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input; 3604 + postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output; 3605 + } 3606 + interface AiModels { 3607 + "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification; 3608 + "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage; 3609 + "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage; 3610 + "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage; 3611 + "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage; 3612 + "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage; 3613 + "@cf/myshell-ai/melotts": BaseAiTextToSpeech; 3614 + "@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings; 3615 + "@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings; 3616 + "@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings; 3617 + "@cf/microsoft/resnet-50": BaseAiImageClassification; 3618 + "@cf/facebook/detr-resnet-50": BaseAiObjectDetection; 3619 + "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration; 3620 + "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration; 3621 + "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration; 3622 + "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration; 3623 + "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration; 3624 + "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration; 3625 + "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration; 3626 + "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration; 3627 + "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration; 3628 + "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration; 3629 + "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration; 3630 + "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration; 3631 + "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration; 3632 + "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration; 3633 + "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration; 3634 + "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration; 3635 + "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration; 3636 + "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration; 3637 + "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration; 3638 + "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration; 3639 + "@cf/microsoft/phi-2": BaseAiTextGeneration; 3640 + "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration; 3641 + "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration; 3642 + "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration; 3643 + "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration; 3644 + "@hf/google/gemma-7b-it": BaseAiTextGeneration; 3645 + "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration; 3646 + "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration; 3647 + "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration; 3648 + "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration; 3649 + "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration; 3650 + "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration; 3651 + "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration; 3652 + "@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration; 3653 + "@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration; 3654 + "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration; 3655 + "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration; 3656 + "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration; 3657 + "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration; 3658 + "@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration; 3659 + "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration; 3660 + "@cf/meta/m2m100-1.2b": BaseAiTranslation; 3661 + "@cf/facebook/bart-large-cnn": BaseAiSummarization; 3662 + "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; 3663 + "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper; 3664 + "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M; 3665 + "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En; 3666 + "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo; 3667 + "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3; 3668 + "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell; 3669 + "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct; 3670 + "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B; 3671 + "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base; 3672 + "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct; 3673 + } 3674 + type AiOptions = { 3675 + gateway?: GatewayOptions; 3676 + returnRawResponse?: boolean; 3677 + prefix?: string; 3678 + extraHeaders?: object; 3679 + }; 3680 + type ConversionResponse = { 3681 + name: string; 3682 + mimeType: string; 3683 + format: "markdown"; 3684 + tokens: number; 3685 + data: string; 3686 + }; 3687 + type AiModelsSearchParams = { 3688 + author?: string; 3689 + hide_experimental?: boolean; 3690 + page?: number; 3691 + per_page?: number; 3692 + search?: string; 3693 + source?: number; 3694 + task?: string; 3695 + }; 3696 + type AiModelsSearchObject = { 3697 + id: string; 3698 + source: number; 3699 + name: string; 3700 + description: string; 3701 + task: { 3702 + id: string; 3703 + name: string; 3704 + description: string; 3705 + }; 3706 + tags: string[]; 3707 + properties: { 3708 + property_id: string; 3709 + value: string; 3710 + }[]; 3711 + }; 3712 + interface InferenceUpstreamError extends Error { 3713 + } 3714 + interface AiInternalError extends Error { 3715 + } 3716 + type AiModelListType = Record<string, any>; 3717 + declare abstract class Ai<AiModelList extends AiModelListType = AiModels> { 3718 + aiGatewayLogId: string | null; 3719 + gateway(gatewayId: string): AiGateway; 3720 + autorag(autoragId: string): AutoRAG; 3721 + run<Name extends keyof AiModelList, Options extends AiOptions>(model: Name, inputs: AiModelList[Name]["inputs"], options?: Options): Promise<Options extends { 3722 + returnRawResponse: true; 3723 + } ? Response : AiModelList[Name]["postProcessedOutputs"]>; 3724 + models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>; 3725 + toMarkdown(files: { 3726 + name: string; 3727 + blob: Blob; 3728 + }[], options?: { 3729 + gateway?: GatewayOptions; 3730 + extraHeaders?: object; 3731 + }): Promise<ConversionResponse[]>; 3732 + toMarkdown(files: { 3733 + name: string; 3734 + blob: Blob; 3735 + }, options?: { 3736 + gateway?: GatewayOptions; 3737 + extraHeaders?: object; 3738 + }): Promise<ConversionResponse>; 3739 + } 3740 + type GatewayRetries = { 3741 + maxAttempts?: 1 | 2 | 3 | 4 | 5; 3742 + retryDelayMs?: number; 3743 + backoff?: 'constant' | 'linear' | 'exponential'; 3744 + }; 3745 + type GatewayOptions = { 3746 + id: string; 3747 + cacheKey?: string; 3748 + cacheTtl?: number; 3749 + skipCache?: boolean; 3750 + metadata?: Record<string, number | string | boolean | null | bigint>; 3751 + collectLog?: boolean; 3752 + eventId?: string; 3753 + requestTimeoutMs?: number; 3754 + retries?: GatewayRetries; 3755 + }; 3756 + type AiGatewayPatchLog = { 3757 + score?: number | null; 3758 + feedback?: -1 | 1 | null; 3759 + metadata?: Record<string, number | string | boolean | null | bigint> | null; 3760 + }; 3761 + type AiGatewayLog = { 3762 + id: string; 3763 + provider: string; 3764 + model: string; 3765 + model_type?: string; 3766 + path: string; 3767 + duration: number; 3768 + request_type?: string; 3769 + request_content_type?: string; 3770 + status_code: number; 3771 + response_content_type?: string; 3772 + success: boolean; 3773 + cached: boolean; 3774 + tokens_in?: number; 3775 + tokens_out?: number; 3776 + metadata?: Record<string, number | string | boolean | null | bigint>; 3777 + step?: number; 3778 + cost?: number; 3779 + custom_cost?: boolean; 3780 + request_size: number; 3781 + request_head?: string; 3782 + request_head_complete: boolean; 3783 + response_size: number; 3784 + response_head?: string; 3785 + response_head_complete: boolean; 3786 + created_at: Date; 3787 + }; 3788 + type AIGatewayProviders = 'workers-ai' | 'anthropic' | 'aws-bedrock' | 'azure-openai' | 'google-vertex-ai' | 'huggingface' | 'openai' | 'perplexity-ai' | 'replicate' | 'groq' | 'cohere' | 'google-ai-studio' | 'mistral' | 'grok' | 'openrouter' | 'deepseek' | 'cerebras' | 'cartesia' | 'elevenlabs' | 'adobe-firefly'; 3789 + type AIGatewayHeaders = { 3790 + 'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string; 3791 + 'cf-aig-custom-cost': { 3792 + per_token_in?: number; 3793 + per_token_out?: number; 3794 + } | { 3795 + total_cost?: number; 3796 + } | string; 3797 + 'cf-aig-cache-ttl': number | string; 3798 + 'cf-aig-skip-cache': boolean | string; 3799 + 'cf-aig-cache-key': string; 3800 + 'cf-aig-event-id': string; 3801 + 'cf-aig-request-timeout': number | string; 3802 + 'cf-aig-max-attempts': number | string; 3803 + 'cf-aig-retry-delay': number | string; 3804 + 'cf-aig-backoff': string; 3805 + 'cf-aig-collect-log': boolean | string; 3806 + Authorization: string; 3807 + 'Content-Type': string; 3808 + [key: string]: string | number | boolean | object; 3809 + }; 3810 + type AIGatewayUniversalRequest = { 3811 + provider: AIGatewayProviders | string; // eslint-disable-line 3812 + endpoint: string; 3813 + headers: Partial<AIGatewayHeaders>; 3814 + query: unknown; 3815 + }; 3816 + interface AiGatewayInternalError extends Error { 3817 + } 3818 + interface AiGatewayLogNotFound extends Error { 3819 + } 3820 + declare abstract class AiGateway { 3821 + patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>; 3822 + getLog(logId: string): Promise<AiGatewayLog>; 3823 + run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: { 3824 + gateway?: GatewayOptions; 3825 + extraHeaders?: object; 3826 + }): Promise<Response>; 3827 + getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line 3828 + } 3829 + interface AutoRAGInternalError extends Error { 3830 + } 3831 + interface AutoRAGNotFoundError extends Error { 3832 + } 3833 + interface AutoRAGUnauthorizedError extends Error { 3834 + } 3835 + type ComparisonFilter = { 3836 + key: string; 3837 + type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte'; 3838 + value: string | number | boolean; 3839 + }; 3840 + type CompoundFilter = { 3841 + type: 'and' | 'or'; 3842 + filters: ComparisonFilter[]; 3843 + }; 3844 + type AutoRagSearchRequest = { 3845 + query: string; 3846 + filters?: CompoundFilter | ComparisonFilter; 3847 + max_num_results?: number; 3848 + ranking_options?: { 3849 + ranker?: string; 3850 + score_threshold?: number; 3851 + }; 3852 + rewrite_query?: boolean; 3853 + }; 3854 + type AutoRagAiSearchRequest = AutoRagSearchRequest & { 3855 + stream?: boolean; 3856 + }; 3857 + type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & { 3858 + stream: true; 3859 + }; 3860 + type AutoRagSearchResponse = { 3861 + object: 'vector_store.search_results.page'; 3862 + search_query: string; 3863 + data: { 3864 + file_id: string; 3865 + filename: string; 3866 + score: number; 3867 + attributes: Record<string, string | number | boolean | null>; 3868 + content: { 3869 + type: 'text'; 3870 + text: string; 3871 + }[]; 3872 + }[]; 3873 + has_more: boolean; 3874 + next_page: string | null; 3875 + }; 3876 + type AutoRagAiSearchResponse = AutoRagSearchResponse & { 3877 + response: string; 3878 + }; 3879 + declare abstract class AutoRAG { 3880 + search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>; 3881 + aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>; 3882 + aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>; 3883 + aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>; 3884 + } 3885 + interface BasicImageTransformations { 3886 + /** 3887 + * Maximum width in image pixels. The value must be an integer. 3888 + */ 3889 + width?: number; 3890 + /** 3891 + * Maximum height in image pixels. The value must be an integer. 3892 + */ 3893 + height?: number; 3894 + /** 3895 + * Resizing mode as a string. It affects interpretation of width and height 3896 + * options: 3897 + * - scale-down: Similar to contain, but the image is never enlarged. If 3898 + * the image is larger than given width or height, it will be resized. 3899 + * Otherwise its original size will be kept. 3900 + * - contain: Resizes to maximum size that fits within the given width and 3901 + * height. If only a single dimension is given (e.g. only width), the 3902 + * image will be shrunk or enlarged to exactly match that dimension. 3903 + * Aspect ratio is always preserved. 3904 + * - cover: Resizes (shrinks or enlarges) to fill the entire area of width 3905 + * and height. If the image has an aspect ratio different from the ratio 3906 + * of width and height, it will be cropped to fit. 3907 + * - crop: The image will be shrunk and cropped to fit within the area 3908 + * specified by width and height. The image will not be enlarged. For images 3909 + * smaller than the given dimensions it's the same as scale-down. For 3910 + * images larger than the given dimensions, it's the same as cover. 3911 + * See also trim. 3912 + * - pad: Resizes to the maximum size that fits within the given width and 3913 + * height, and then fills the remaining area with a background color 3914 + * (white by default). Use of this mode is not recommended, as the same 3915 + * effect can be more efficiently achieved with the contain mode and the 3916 + * CSS object-fit: contain property. 3917 + * - squeeze: Stretches and deforms to the width and height given, even if it 3918 + * breaks aspect ratio 3919 + */ 3920 + fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze"; 3921 + /** 3922 + * When cropping with fit: "cover", this defines the side or point that should 3923 + * be left uncropped. The value is either a string 3924 + * "left", "right", "top", "bottom", "auto", or "center" (the default), 3925 + * or an object {x, y} containing focal point coordinates in the original 3926 + * image expressed as fractions ranging from 0.0 (top or left) to 1.0 3927 + * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will 3928 + * crop bottom or left and right sides as necessary, but won't crop anything 3929 + * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to 3930 + * preserve as much as possible around a point at 20% of the height of the 3931 + * source image. 3932 + */ 3933 + gravity?: 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates; 3934 + /** 3935 + * Background color to add underneath the image. Applies only to images with 3936 + * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…), 3937 + * hsl(…), etc.) 3938 + */ 3939 + background?: string; 3940 + /** 3941 + * Number of degrees (90, 180, 270) to rotate the image by. width and height 3942 + * options refer to axes after rotation. 3943 + */ 3944 + rotate?: 0 | 90 | 180 | 270 | 360; 3945 + } 3946 + interface BasicImageTransformationsGravityCoordinates { 3947 + x?: number; 3948 + y?: number; 3949 + mode?: 'remainder' | 'box-center'; 3950 + } 3951 + /** 3952 + * In addition to the properties you can set in the RequestInit dict 3953 + * that you pass as an argument to the Request constructor, you can 3954 + * set certain properties of a `cf` object to control how Cloudflare 3955 + * features are applied to that new Request. 3956 + * 3957 + * Note: Currently, these properties cannot be tested in the 3958 + * playground. 3959 + */ 3960 + interface RequestInitCfProperties extends Record<string, unknown> { 3961 + cacheEverything?: boolean; 3962 + /** 3963 + * A request's cache key is what determines if two requests are 3964 + * "the same" for caching purposes. If a request has the same cache key 3965 + * as some previous request, then we can serve the same cached response for 3966 + * both. (e.g. 'some-key') 3967 + * 3968 + * Only available for Enterprise customers. 3969 + */ 3970 + cacheKey?: string; 3971 + /** 3972 + * This allows you to append additional Cache-Tag response headers 3973 + * to the origin response without modifications to the origin server. 3974 + * This will allow for greater control over the Purge by Cache Tag feature 3975 + * utilizing changes only in the Workers process. 3976 + * 3977 + * Only available for Enterprise customers. 3978 + */ 3979 + cacheTags?: string[]; 3980 + /** 3981 + * Force response to be cached for a given number of seconds. (e.g. 300) 3982 + */ 3983 + cacheTtl?: number; 3984 + /** 3985 + * Force response to be cached for a given number of seconds based on the Origin status code. 3986 + * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 }) 3987 + */ 3988 + cacheTtlByStatus?: Record<string, number>; 3989 + scrapeShield?: boolean; 3990 + apps?: boolean; 3991 + image?: RequestInitCfPropertiesImage; 3992 + minify?: RequestInitCfPropertiesImageMinify; 3993 + mirage?: boolean; 3994 + polish?: "lossy" | "lossless" | "off"; 3995 + r2?: RequestInitCfPropertiesR2; 3996 + /** 3997 + * Redirects the request to an alternate origin server. You can use this, 3998 + * for example, to implement load balancing across several origins. 3999 + * (e.g.us-east.example.com) 4000 + * 4001 + * Note - For security reasons, the hostname set in resolveOverride must 4002 + * be proxied on the same Cloudflare zone of the incoming request. 4003 + * Otherwise, the setting is ignored. CNAME hosts are allowed, so to 4004 + * resolve to a host under a different domain or a DNS only domain first 4005 + * declare a CNAME record within your own zone's DNS mapping to the 4006 + * external hostname, set proxy on Cloudflare, then set resolveOverride 4007 + * to point to that CNAME record. 4008 + */ 4009 + resolveOverride?: string; 4010 + } 4011 + interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations { 4012 + /** 4013 + * Absolute URL of the image file to use for the drawing. It can be any of 4014 + * the supported file formats. For drawing of watermarks or non-rectangular 4015 + * overlays we recommend using PNG or WebP images. 4016 + */ 4017 + url: string; 4018 + /** 4019 + * Floating-point number between 0 (transparent) and 1 (opaque). 4020 + * For example, opacity: 0.5 makes overlay semitransparent. 4021 + */ 4022 + opacity?: number; 4023 + /** 4024 + * - If set to true, the overlay image will be tiled to cover the entire 4025 + * area. This is useful for stock-photo-like watermarks. 4026 + * - If set to "x", the overlay image will be tiled horizontally only 4027 + * (form a line). 4028 + * - If set to "y", the overlay image will be tiled vertically only 4029 + * (form a line). 4030 + */ 4031 + repeat?: true | "x" | "y"; 4032 + /** 4033 + * Position of the overlay image relative to a given edge. Each property is 4034 + * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10 4035 + * positions left side of the overlay 10 pixels from the left edge of the 4036 + * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom 4037 + * of the background image. 4038 + * 4039 + * Setting both left & right, or both top & bottom is an error. 4040 + * 4041 + * If no position is specified, the image will be centered. 4042 + */ 4043 + top?: number; 4044 + left?: number; 4045 + bottom?: number; 4046 + right?: number; 4047 + } 4048 + interface RequestInitCfPropertiesImage extends BasicImageTransformations { 4049 + /** 4050 + * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it 4051 + * easier to specify higher-DPI sizes in <img srcset>. 4052 + */ 4053 + dpr?: number; 4054 + /** 4055 + * Allows you to trim your image. Takes dpr into account and is performed before 4056 + * resizing or rotation. 4057 + * 4058 + * It can be used as: 4059 + * - left, top, right, bottom - it will specify the number of pixels to cut 4060 + * off each side 4061 + * - width, height - the width/height you'd like to end up with - can be used 4062 + * in combination with the properties above 4063 + * - border - this will automatically trim the surroundings of an image based on 4064 + * it's color. It consists of three properties: 4065 + * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit) 4066 + * - tolerance: difference from color to treat as color 4067 + * - keep: the number of pixels of border to keep 4068 + */ 4069 + trim?: "border" | { 4070 + top?: number; 4071 + bottom?: number; 4072 + left?: number; 4073 + right?: number; 4074 + width?: number; 4075 + height?: number; 4076 + border?: boolean | { 4077 + color?: string; 4078 + tolerance?: number; 4079 + keep?: number; 4080 + }; 4081 + }; 4082 + /** 4083 + * Quality setting from 1-100 (useful values are in 60-90 range). Lower values 4084 + * make images look worse, but load faster. The default is 85. It applies only 4085 + * to JPEG and WebP images. It doesn't have any effect on PNG. 4086 + */ 4087 + quality?: number | "low" | "medium-low" | "medium-high" | "high"; 4088 + /** 4089 + * Output format to generate. It can be: 4090 + * - avif: generate images in AVIF format. 4091 + * - webp: generate images in Google WebP format. Set quality to 100 to get 4092 + * the WebP-lossless format. 4093 + * - json: instead of generating an image, outputs information about the 4094 + * image, in JSON format. The JSON object will contain image size 4095 + * (before and after resizing), source image's MIME type, file size, etc. 4096 + * - jpeg: generate images in JPEG format. 4097 + * - png: generate images in PNG format. 4098 + */ 4099 + format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg"; 4100 + /** 4101 + * Whether to preserve animation frames from input files. Default is true. 4102 + * Setting it to false reduces animations to still images. This setting is 4103 + * recommended when enlarging images or processing arbitrary user content, 4104 + * because large GIF animations can weigh tens or even hundreds of megabytes. 4105 + * It is also useful to set anim:false when using format:"json" to get the 4106 + * response quicker without the number of frames. 4107 + */ 4108 + anim?: boolean; 4109 + /** 4110 + * What EXIF data should be preserved in the output image. Note that EXIF 4111 + * rotation and embedded color profiles are always applied ("baked in" into 4112 + * the image), and aren't affected by this option. Note that if the Polish 4113 + * feature is enabled, all metadata may have been removed already and this 4114 + * option may have no effect. 4115 + * - keep: Preserve most of EXIF metadata, including GPS location if there's 4116 + * any. 4117 + * - copyright: Only keep the copyright tag, and discard everything else. 4118 + * This is the default behavior for JPEG files. 4119 + * - none: Discard all invisible EXIF metadata. Currently WebP and PNG 4120 + * output formats always discard metadata. 4121 + */ 4122 + metadata?: "keep" | "copyright" | "none"; 4123 + /** 4124 + * Strength of sharpening filter to apply to the image. Floating-point 4125 + * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a 4126 + * recommended value for downscaled images. 4127 + */ 4128 + sharpen?: number; 4129 + /** 4130 + * Radius of a blur filter (approximate gaussian). Maximum supported radius 4131 + * is 250. 4132 + */ 4133 + blur?: number; 4134 + /** 4135 + * Overlays are drawn in the order they appear in the array (last array 4136 + * entry is the topmost layer). 4137 + */ 4138 + draw?: RequestInitCfPropertiesImageDraw[]; 4139 + /** 4140 + * Fetching image from authenticated origin. Setting this property will 4141 + * pass authentication headers (Authorization, Cookie, etc.) through to 4142 + * the origin. 4143 + */ 4144 + "origin-auth"?: "share-publicly"; 4145 + /** 4146 + * Adds a border around the image. The border is added after resizing. Border 4147 + * width takes dpr into account, and can be specified either using a single 4148 + * width property, or individually for each side. 4149 + */ 4150 + border?: { 4151 + color: string; 4152 + width: number; 4153 + } | { 4154 + color: string; 4155 + top: number; 4156 + right: number; 4157 + bottom: number; 4158 + left: number; 4159 + }; 4160 + /** 4161 + * Increase brightness by a factor. A value of 1.0 equals no change, a value 4162 + * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright. 4163 + * 0 is ignored. 4164 + */ 4165 + brightness?: number; 4166 + /** 4167 + * Increase contrast by a factor. A value of 1.0 equals no change, a value of 4168 + * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is 4169 + * ignored. 4170 + */ 4171 + contrast?: number; 4172 + /** 4173 + * Increase exposure by a factor. A value of 1.0 equals no change, a value of 4174 + * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored. 4175 + */ 4176 + gamma?: number; 4177 + /** 4178 + * Increase contrast by a factor. A value of 1.0 equals no change, a value of 4179 + * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is 4180 + * ignored. 4181 + */ 4182 + saturation?: number; 4183 + /** 4184 + * Flips the images horizontally, vertically, or both. Flipping is applied before 4185 + * rotation, so if you apply flip=h,rotate=90 then the image will be flipped 4186 + * horizontally, then rotated by 90 degrees. 4187 + */ 4188 + flip?: 'h' | 'v' | 'hv'; 4189 + /** 4190 + * Slightly reduces latency on a cache miss by selecting a 4191 + * quickest-to-compress file format, at a cost of increased file size and 4192 + * lower image quality. It will usually override the format option and choose 4193 + * JPEG over WebP or AVIF. We do not recommend using this option, except in 4194 + * unusual circumstances like resizing uncacheable dynamically-generated 4195 + * images. 4196 + */ 4197 + compression?: "fast"; 4198 + } 4199 + interface RequestInitCfPropertiesImageMinify { 4200 + javascript?: boolean; 4201 + css?: boolean; 4202 + html?: boolean; 4203 + } 4204 + interface RequestInitCfPropertiesR2 { 4205 + /** 4206 + * Colo id of bucket that an object is stored in 4207 + */ 4208 + bucketColoId?: number; 4209 + } 4210 + /** 4211 + * Request metadata provided by Cloudflare's edge. 4212 + */ 4213 + type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield; 4214 + interface IncomingRequestCfPropertiesBase extends Record<string, unknown> { 4215 + /** 4216 + * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request. 4217 + * 4218 + * @example 395747 4219 + */ 4220 + asn: number; 4221 + /** 4222 + * The organization which owns the ASN of the incoming request. 4223 + * 4224 + * @example "Google Cloud" 4225 + */ 4226 + asOrganization: string; 4227 + /** 4228 + * The original value of the `Accept-Encoding` header if Cloudflare modified it. 4229 + * 4230 + * @example "gzip, deflate, br" 4231 + */ 4232 + clientAcceptEncoding?: string; 4233 + /** 4234 + * The number of milliseconds it took for the request to reach your worker. 4235 + * 4236 + * @example 22 4237 + */ 4238 + clientTcpRtt?: number; 4239 + /** 4240 + * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code) 4241 + * airport code of the data center that the request hit. 4242 + * 4243 + * @example "DFW" 4244 + */ 4245 + colo: string; 4246 + /** 4247 + * Represents the upstream's response to a 4248 + * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html) 4249 + * from cloudflare. 4250 + * 4251 + * For workers with no upstream, this will always be `1`. 4252 + * 4253 + * @example 3 4254 + */ 4255 + edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus; 4256 + /** 4257 + * The HTTP Protocol the request used. 4258 + * 4259 + * @example "HTTP/2" 4260 + */ 4261 + httpProtocol: string; 4262 + /** 4263 + * The browser-requested prioritization information in the request object. 4264 + * 4265 + * If no information was set, defaults to the empty string `""` 4266 + * 4267 + * @example "weight=192;exclusive=0;group=3;group-weight=127" 4268 + * @default "" 4269 + */ 4270 + requestPriority: string; 4271 + /** 4272 + * The TLS version of the connection to Cloudflare. 4273 + * In requests served over plaintext (without TLS), this property is the empty string `""`. 4274 + * 4275 + * @example "TLSv1.3" 4276 + */ 4277 + tlsVersion: string; 4278 + /** 4279 + * The cipher for the connection to Cloudflare. 4280 + * In requests served over plaintext (without TLS), this property is the empty string `""`. 4281 + * 4282 + * @example "AEAD-AES128-GCM-SHA256" 4283 + */ 4284 + tlsCipher: string; 4285 + /** 4286 + * Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake. 4287 + * 4288 + * If the incoming request was served over plaintext (without TLS) this field is undefined. 4289 + */ 4290 + tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata; 4291 + } 4292 + interface IncomingRequestCfPropertiesBotManagementBase { 4293 + /** 4294 + * Cloudflare's [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot, 4295 + * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human). 4296 + * 4297 + * @example 54 4298 + */ 4299 + score: number; 4300 + /** 4301 + * A boolean value that is true if the request comes from a good bot, like Google or Bing. 4302 + * Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots). 4303 + */ 4304 + verifiedBot: boolean; 4305 + /** 4306 + * A boolean value that is true if the request originates from a 4307 + * Cloudflare-verified proxy service. 4308 + */ 4309 + corporateProxy: boolean; 4310 + /** 4311 + * A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources. 4312 + */ 4313 + staticResource: boolean; 4314 + /** 4315 + * List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request). 4316 + */ 4317 + detectionIds: number[]; 4318 + } 4319 + interface IncomingRequestCfPropertiesBotManagement { 4320 + /** 4321 + * Results of Cloudflare's Bot Management analysis 4322 + */ 4323 + botManagement: IncomingRequestCfPropertiesBotManagementBase; 4324 + /** 4325 + * Duplicate of `botManagement.score`. 4326 + * 4327 + * @deprecated 4328 + */ 4329 + clientTrustScore: number; 4330 + } 4331 + interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement { 4332 + /** 4333 + * Results of Cloudflare's Bot Management analysis 4334 + */ 4335 + botManagement: IncomingRequestCfPropertiesBotManagementBase & { 4336 + /** 4337 + * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients 4338 + * across different destination IPs, Ports, and X509 certificates. 4339 + */ 4340 + ja3Hash: string; 4341 + }; 4342 + } 4343 + interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> { 4344 + /** 4345 + * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/). 4346 + * 4347 + * This field is only present if you have Cloudflare for SaaS enabled on your account 4348 + * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)). 4349 + */ 4350 + hostMetadata: HostMetadata; 4351 + } 4352 + interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield { 4353 + /** 4354 + * Information about the client certificate presented to Cloudflare. 4355 + * 4356 + * This is populated when the incoming request is served over TLS using 4357 + * either Cloudflare Access or API Shield (mTLS) 4358 + * and the presented SSL certificate has a valid 4359 + * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number) 4360 + * (i.e., not `null` or `""`). 4361 + * 4362 + * Otherwise, a set of placeholder values are used. 4363 + * 4364 + * The property `certPresented` will be set to `"1"` when 4365 + * the object is populated (i.e. the above conditions were met). 4366 + */ 4367 + tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder; 4368 + } 4369 + /** 4370 + * Metadata about the request's TLS handshake 4371 + */ 4372 + interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata { 4373 + /** 4374 + * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal 4375 + * 4376 + * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d" 4377 + */ 4378 + clientHandshake: string; 4379 + /** 4380 + * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal 4381 + * 4382 + * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d" 4383 + */ 4384 + serverHandshake: string; 4385 + /** 4386 + * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal 4387 + * 4388 + * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b" 4389 + */ 4390 + clientFinished: string; 4391 + /** 4392 + * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal 4393 + * 4394 + * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b" 4395 + */ 4396 + serverFinished: string; 4397 + } 4398 + /** 4399 + * Geographic data about the request's origin. 4400 + */ 4401 + interface IncomingRequestCfPropertiesGeographicInformation { 4402 + /** 4403 + * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from. 4404 + * 4405 + * If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR. 4406 + * 4407 + * If Cloudflare is unable to determine where the request originated this property is omitted. 4408 + * 4409 + * The country code `"T1"` is used for requests originating on TOR. 4410 + * 4411 + * @example "GB" 4412 + */ 4413 + country?: Iso3166Alpha2Code | "T1"; 4414 + /** 4415 + * If present, this property indicates that the request originated in the EU 4416 + * 4417 + * @example "1" 4418 + */ 4419 + isEUCountry?: "1"; 4420 + /** 4421 + * A two-letter code indicating the continent the request originated from. 4422 + * 4423 + * @example "AN" 4424 + */ 4425 + continent?: ContinentCode; 4426 + /** 4427 + * The city the request originated from 4428 + * 4429 + * @example "Austin" 4430 + */ 4431 + city?: string; 4432 + /** 4433 + * Postal code of the incoming request 4434 + * 4435 + * @example "78701" 4436 + */ 4437 + postalCode?: string; 4438 + /** 4439 + * Latitude of the incoming request 4440 + * 4441 + * @example "30.27130" 4442 + */ 4443 + latitude?: string; 4444 + /** 4445 + * Longitude of the incoming request 4446 + * 4447 + * @example "-97.74260" 4448 + */ 4449 + longitude?: string; 4450 + /** 4451 + * Timezone of the incoming request 4452 + * 4453 + * @example "America/Chicago" 4454 + */ 4455 + timezone?: string; 4456 + /** 4457 + * If known, the ISO 3166-2 name for the first level region associated with 4458 + * the IP address of the incoming request 4459 + * 4460 + * @example "Texas" 4461 + */ 4462 + region?: string; 4463 + /** 4464 + * If known, the ISO 3166-2 code for the first-level region associated with 4465 + * the IP address of the incoming request 4466 + * 4467 + * @example "TX" 4468 + */ 4469 + regionCode?: string; 4470 + /** 4471 + * Metro code (DMA) of the incoming request 4472 + * 4473 + * @example "635" 4474 + */ 4475 + metroCode?: string; 4476 + } 4477 + /** Data about the incoming request's TLS certificate */ 4478 + interface IncomingRequestCfPropertiesTLSClientAuth { 4479 + /** Always `"1"`, indicating that the certificate was presented */ 4480 + certPresented: "1"; 4481 + /** 4482 + * Result of certificate verification. 4483 + * 4484 + * @example "FAILED:self signed certificate" 4485 + */ 4486 + certVerified: Exclude<CertVerificationStatus, "NONE">; 4487 + /** The presented certificate's revokation status. 4488 + * 4489 + * - A value of `"1"` indicates the certificate has been revoked 4490 + * - A value of `"0"` indicates the certificate has not been revoked 4491 + */ 4492 + certRevoked: "1" | "0"; 4493 + /** 4494 + * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) 4495 + * 4496 + * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 4497 + */ 4498 + certIssuerDN: string; 4499 + /** 4500 + * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) 4501 + * 4502 + * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 4503 + */ 4504 + certSubjectDN: string; 4505 + /** 4506 + * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted) 4507 + * 4508 + * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 4509 + */ 4510 + certIssuerDNRFC2253: string; 4511 + /** 4512 + * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted) 4513 + * 4514 + * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 4515 + */ 4516 + certSubjectDNRFC2253: string; 4517 + /** The certificate issuer's distinguished name (legacy policies) */ 4518 + certIssuerDNLegacy: string; 4519 + /** The certificate subject's distinguished name (legacy policies) */ 4520 + certSubjectDNLegacy: string; 4521 + /** 4522 + * The certificate's serial number 4523 + * 4524 + * @example "00936EACBE07F201DF" 4525 + */ 4526 + certSerial: string; 4527 + /** 4528 + * The certificate issuer's serial number 4529 + * 4530 + * @example "2489002934BDFEA34" 4531 + */ 4532 + certIssuerSerial: string; 4533 + /** 4534 + * The certificate's Subject Key Identifier 4535 + * 4536 + * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4" 4537 + */ 4538 + certSKI: string; 4539 + /** 4540 + * The certificate issuer's Subject Key Identifier 4541 + * 4542 + * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4" 4543 + */ 4544 + certIssuerSKI: string; 4545 + /** 4546 + * The certificate's SHA-1 fingerprint 4547 + * 4548 + * @example "6b9109f323999e52259cda7373ff0b4d26bd232e" 4549 + */ 4550 + certFingerprintSHA1: string; 4551 + /** 4552 + * The certificate's SHA-256 fingerprint 4553 + * 4554 + * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea" 4555 + */ 4556 + certFingerprintSHA256: string; 4557 + /** 4558 + * The effective starting date of the certificate 4559 + * 4560 + * @example "Dec 22 19:39:00 2018 GMT" 4561 + */ 4562 + certNotBefore: string; 4563 + /** 4564 + * The effective expiration date of the certificate 4565 + * 4566 + * @example "Dec 22 19:39:00 2018 GMT" 4567 + */ 4568 + certNotAfter: string; 4569 + } 4570 + /** Placeholder values for TLS Client Authorization */ 4571 + interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder { 4572 + certPresented: "0"; 4573 + certVerified: "NONE"; 4574 + certRevoked: "0"; 4575 + certIssuerDN: ""; 4576 + certSubjectDN: ""; 4577 + certIssuerDNRFC2253: ""; 4578 + certSubjectDNRFC2253: ""; 4579 + certIssuerDNLegacy: ""; 4580 + certSubjectDNLegacy: ""; 4581 + certSerial: ""; 4582 + certIssuerSerial: ""; 4583 + certSKI: ""; 4584 + certIssuerSKI: ""; 4585 + certFingerprintSHA1: ""; 4586 + certFingerprintSHA256: ""; 4587 + certNotBefore: ""; 4588 + certNotAfter: ""; 4589 + } 4590 + /** Possible outcomes of TLS verification */ 4591 + declare type CertVerificationStatus = 4592 + /** Authentication succeeded */ 4593 + "SUCCESS" 4594 + /** No certificate was presented */ 4595 + | "NONE" 4596 + /** Failed because the certificate was self-signed */ 4597 + | "FAILED:self signed certificate" 4598 + /** Failed because the certificate failed a trust chain check */ 4599 + | "FAILED:unable to verify the first certificate" 4600 + /** Failed because the certificate not yet valid */ 4601 + | "FAILED:certificate is not yet valid" 4602 + /** Failed because the certificate is expired */ 4603 + | "FAILED:certificate has expired" 4604 + /** Failed for another unspecified reason */ 4605 + | "FAILED"; 4606 + /** 4607 + * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare. 4608 + */ 4609 + declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus = 0 /** Unknown */ | 1 /** no keepalives (not found) */ | 2 /** no connection re-use, opening keepalive connection failed */ | 3 /** no connection re-use, keepalive accepted and saved */ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */ | 5; /** connection re-use, accepted by the origin server */ 4610 + /** ISO 3166-1 Alpha-2 codes */ 4611 + declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW"; 4612 + /** The 2-letter continent codes Cloudflare uses */ 4613 + declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA"; 4614 + type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties; 4615 + interface D1Meta { 4616 + duration: number; 4617 + size_after: number; 4618 + rows_read: number; 4619 + rows_written: number; 4620 + last_row_id: number; 4621 + changed_db: boolean; 4622 + changes: number; 4623 + /** 4624 + * The region of the database instance that executed the query. 4625 + */ 4626 + served_by_region?: string; 4627 + /** 4628 + * True if-and-only-if the database instance that executed the query was the primary. 4629 + */ 4630 + served_by_primary?: boolean; 4631 + timings?: { 4632 + /** 4633 + * The duration of the SQL query execution by the database instance. It doesn't include any network time. 4634 + */ 4635 + sql_duration_ms: number; 4636 + }; 4637 + } 4638 + interface D1Response { 4639 + success: true; 4640 + meta: D1Meta & Record<string, unknown>; 4641 + error?: never; 4642 + } 4643 + type D1Result<T = unknown> = D1Response & { 4644 + results: T[]; 4645 + }; 4646 + interface D1ExecResult { 4647 + count: number; 4648 + duration: number; 4649 + } 4650 + type D1SessionConstraint = 4651 + // Indicates that the first query should go to the primary, and the rest queries 4652 + // using the same D1DatabaseSession will go to any replica that is consistent with 4653 + // the bookmark maintained by the session (returned by the first query). 4654 + "first-primary" 4655 + // Indicates that the first query can go anywhere (primary or replica), and the rest queries 4656 + // using the same D1DatabaseSession will go to any replica that is consistent with 4657 + // the bookmark maintained by the session (returned by the first query). 4658 + | "first-unconstrained"; 4659 + type D1SessionBookmark = string; 4660 + declare abstract class D1Database { 4661 + prepare(query: string): D1PreparedStatement; 4662 + batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>; 4663 + exec(query: string): Promise<D1ExecResult>; 4664 + /** 4665 + * Creates a new D1 Session anchored at the given constraint or the bookmark. 4666 + * All queries executed using the created session will have sequential consistency, 4667 + * meaning that all writes done through the session will be visible in subsequent reads. 4668 + * 4669 + * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session. 4670 + */ 4671 + withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession; 4672 + /** 4673 + * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases. 4674 + */ 4675 + dump(): Promise<ArrayBuffer>; 4676 + } 4677 + declare abstract class D1DatabaseSession { 4678 + prepare(query: string): D1PreparedStatement; 4679 + batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>; 4680 + /** 4681 + * @returns The latest session bookmark across all executed queries on the session. 4682 + * If no query has been executed yet, `null` is returned. 4683 + */ 4684 + getBookmark(): D1SessionBookmark | null; 4685 + } 4686 + declare abstract class D1PreparedStatement { 4687 + bind(...values: unknown[]): D1PreparedStatement; 4688 + first<T = unknown>(colName: string): Promise<T | null>; 4689 + first<T = Record<string, unknown>>(): Promise<T | null>; 4690 + run<T = Record<string, unknown>>(): Promise<D1Result<T>>; 4691 + all<T = Record<string, unknown>>(): Promise<D1Result<T>>; 4692 + raw<T = unknown[]>(options: { 4693 + columnNames: true; 4694 + }): Promise<[ 4695 + string[], 4696 + ...T[] 4697 + ]>; 4698 + raw<T = unknown[]>(options?: { 4699 + columnNames?: false; 4700 + }): Promise<T[]>; 4701 + } 4702 + // `Disposable` was added to TypeScript's standard lib types in version 5.2. 4703 + // To support older TypeScript versions, define an empty `Disposable` interface. 4704 + // Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2, 4705 + // but this will ensure type checking on older versions still passes. 4706 + // TypeScript's interface merging will ensure our empty interface is effectively 4707 + // ignored when `Disposable` is included in the standard lib. 4708 + interface Disposable { 4709 + } 4710 + /** 4711 + * An email message that can be sent from a Worker. 4712 + */ 4713 + interface EmailMessage { 4714 + /** 4715 + * Envelope From attribute of the email message. 4716 + */ 4717 + readonly from: string; 4718 + /** 4719 + * Envelope To attribute of the email message. 4720 + */ 4721 + readonly to: string; 4722 + } 4723 + /** 4724 + * An email message that is sent to a consumer Worker and can be rejected/forwarded. 4725 + */ 4726 + interface ForwardableEmailMessage extends EmailMessage { 4727 + /** 4728 + * Stream of the email message content. 4729 + */ 4730 + readonly raw: ReadableStream<Uint8Array>; 4731 + /** 4732 + * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers). 4733 + */ 4734 + readonly headers: Headers; 4735 + /** 4736 + * Size of the email message content. 4737 + */ 4738 + readonly rawSize: number; 4739 + /** 4740 + * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason. 4741 + * @param reason The reject reason. 4742 + * @returns void 4743 + */ 4744 + setReject(reason: string): void; 4745 + /** 4746 + * Forward this email message to a verified destination address of the account. 4747 + * @param rcptTo Verified destination address. 4748 + * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers). 4749 + * @returns A promise that resolves when the email message is forwarded. 4750 + */ 4751 + forward(rcptTo: string, headers?: Headers): Promise<void>; 4752 + /** 4753 + * Reply to the sender of this email message with a new EmailMessage object. 4754 + * @param message The reply message. 4755 + * @returns A promise that resolves when the email message is replied. 4756 + */ 4757 + reply(message: EmailMessage): Promise<void>; 4758 + } 4759 + /** 4760 + * A binding that allows a Worker to send email messages. 4761 + */ 4762 + interface SendEmail { 4763 + send(message: EmailMessage): Promise<void>; 4764 + } 4765 + declare abstract class EmailEvent extends ExtendableEvent { 4766 + readonly message: ForwardableEmailMessage; 4767 + } 4768 + declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise<void>; 4769 + declare module "cloudflare:email" { 4770 + let _EmailMessage: { 4771 + prototype: EmailMessage; 4772 + new (from: string, to: string, raw: ReadableStream | string): EmailMessage; 4773 + }; 4774 + export { _EmailMessage as EmailMessage }; 4775 + } 4776 + interface Hyperdrive { 4777 + /** 4778 + * Connect directly to Hyperdrive as if it's your database, returning a TCP socket. 4779 + * 4780 + * Calling this method returns an idential socket to if you call 4781 + * `connect("host:port")` using the `host` and `port` fields from this object. 4782 + * Pick whichever approach works better with your preferred DB client library. 4783 + * 4784 + * Note that this socket is not yet authenticated -- it's expected that your 4785 + * code (or preferably, the client library of your choice) will authenticate 4786 + * using the information in this class's readonly fields. 4787 + */ 4788 + connect(): Socket; 4789 + /** 4790 + * A valid DB connection string that can be passed straight into the typical 4791 + * client library/driver/ORM. This will typically be the easiest way to use 4792 + * Hyperdrive. 4793 + */ 4794 + readonly connectionString: string; 4795 + /* 4796 + * A randomly generated hostname that is only valid within the context of the 4797 + * currently running Worker which, when passed into `connect()` function from 4798 + * the "cloudflare:sockets" module, will connect to the Hyperdrive instance 4799 + * for your database. 4800 + */ 4801 + readonly host: string; 4802 + /* 4803 + * The port that must be paired the the host field when connecting. 4804 + */ 4805 + readonly port: number; 4806 + /* 4807 + * The username to use when authenticating to your database via Hyperdrive. 4808 + * Unlike the host and password, this will be the same every time 4809 + */ 4810 + readonly user: string; 4811 + /* 4812 + * The randomly generated password to use when authenticating to your 4813 + * database via Hyperdrive. Like the host field, this password is only valid 4814 + * within the context of the currently running Worker instance from which 4815 + * it's read. 4816 + */ 4817 + readonly password: string; 4818 + /* 4819 + * The name of the database to connect to. 4820 + */ 4821 + readonly database: string; 4822 + } 4823 + // Copyright (c) 2024 Cloudflare, Inc. 4824 + // Licensed under the Apache 2.0 license found in the LICENSE file or at: 4825 + // https://opensource.org/licenses/Apache-2.0 4826 + type ImageInfoResponse = { 4827 + format: 'image/svg+xml'; 4828 + } | { 4829 + format: string; 4830 + fileSize: number; 4831 + width: number; 4832 + height: number; 4833 + }; 4834 + type ImageTransform = { 4835 + width?: number; 4836 + height?: number; 4837 + background?: string; 4838 + blur?: number; 4839 + border?: { 4840 + color?: string; 4841 + width?: number; 4842 + } | { 4843 + top?: number; 4844 + bottom?: number; 4845 + left?: number; 4846 + right?: number; 4847 + }; 4848 + brightness?: number; 4849 + contrast?: number; 4850 + fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop'; 4851 + flip?: 'h' | 'v' | 'hv'; 4852 + gamma?: number; 4853 + gravity?: 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | { 4854 + x?: number; 4855 + y?: number; 4856 + mode: 'remainder' | 'box-center'; 4857 + }; 4858 + rotate?: 0 | 90 | 180 | 270; 4859 + saturation?: number; 4860 + sharpen?: number; 4861 + trim?: "border" | { 4862 + top?: number; 4863 + bottom?: number; 4864 + left?: number; 4865 + right?: number; 4866 + width?: number; 4867 + height?: number; 4868 + border?: boolean | { 4869 + color?: string; 4870 + tolerance?: number; 4871 + keep?: number; 4872 + }; 4873 + }; 4874 + }; 4875 + type ImageDrawOptions = { 4876 + opacity?: number; 4877 + repeat?: boolean | string; 4878 + top?: number; 4879 + left?: number; 4880 + bottom?: number; 4881 + right?: number; 4882 + }; 4883 + type ImageOutputOptions = { 4884 + format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba'; 4885 + quality?: number; 4886 + background?: string; 4887 + }; 4888 + interface ImagesBinding { 4889 + /** 4890 + * Get image metadata (type, width and height) 4891 + * @throws {@link ImagesError} with code 9412 if input is not an image 4892 + * @param stream The image bytes 4893 + */ 4894 + info(stream: ReadableStream<Uint8Array>): Promise<ImageInfoResponse>; 4895 + /** 4896 + * Begin applying a series of transformations to an image 4897 + * @param stream The image bytes 4898 + * @returns A transform handle 4899 + */ 4900 + input(stream: ReadableStream<Uint8Array>): ImageTransformer; 4901 + } 4902 + interface ImageTransformer { 4903 + /** 4904 + * Apply transform next, returning a transform handle. 4905 + * You can then apply more transformations, draw, or retrieve the output. 4906 + * @param transform 4907 + */ 4908 + transform(transform: ImageTransform): ImageTransformer; 4909 + /** 4910 + * Draw an image on this transformer, returning a transform handle. 4911 + * You can then apply more transformations, draw, or retrieve the output. 4912 + * @param image The image (or transformer that will give the image) to draw 4913 + * @param options The options configuring how to draw the image 4914 + */ 4915 + draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer; 4916 + /** 4917 + * Retrieve the image that results from applying the transforms to the 4918 + * provided input 4919 + * @param options Options that apply to the output e.g. output format 4920 + */ 4921 + output(options: ImageOutputOptions): Promise<ImageTransformationResult>; 4922 + } 4923 + interface ImageTransformationResult { 4924 + /** 4925 + * The image as a response, ready to store in cache or return to users 4926 + */ 4927 + response(): Response; 4928 + /** 4929 + * The content type of the returned image 4930 + */ 4931 + contentType(): string; 4932 + /** 4933 + * The bytes of the response 4934 + */ 4935 + image(): ReadableStream<Uint8Array>; 4936 + } 4937 + interface ImagesError extends Error { 4938 + readonly code: number; 4939 + readonly message: string; 4940 + readonly stack?: string; 4941 + } 4942 + type Params<P extends string = any> = Record<P, string | string[]>; 4943 + type EventContext<Env, P extends string, Data> = { 4944 + request: Request<unknown, IncomingRequestCfProperties<unknown>>; 4945 + functionPath: string; 4946 + waitUntil: (promise: Promise<any>) => void; 4947 + passThroughOnException: () => void; 4948 + next: (input?: Request | string, init?: RequestInit) => Promise<Response>; 4949 + env: Env & { 4950 + ASSETS: { 4951 + fetch: typeof fetch; 4952 + }; 4953 + }; 4954 + params: Params<P>; 4955 + data: Data; 4956 + }; 4957 + type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>; 4958 + type EventPluginContext<Env, P extends string, Data, PluginArgs> = { 4959 + request: Request<unknown, IncomingRequestCfProperties<unknown>>; 4960 + functionPath: string; 4961 + waitUntil: (promise: Promise<any>) => void; 4962 + passThroughOnException: () => void; 4963 + next: (input?: Request | string, init?: RequestInit) => Promise<Response>; 4964 + env: Env & { 4965 + ASSETS: { 4966 + fetch: typeof fetch; 4967 + }; 4968 + }; 4969 + params: Params<P>; 4970 + data: Data; 4971 + pluginArgs: PluginArgs; 4972 + }; 4973 + type PagesPluginFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginArgs = unknown> = (context: EventPluginContext<Env, Params, Data, PluginArgs>) => Response | Promise<Response>; 4974 + declare module "assets:*" { 4975 + export const onRequest: PagesFunction; 4976 + } 4977 + // Copyright (c) 2022-2023 Cloudflare, Inc. 4978 + // Licensed under the Apache 2.0 license found in the LICENSE file or at: 4979 + // https://opensource.org/licenses/Apache-2.0 4980 + declare module "cloudflare:pipelines" { 4981 + export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> { 4982 + protected env: Env; 4983 + protected ctx: ExecutionContext; 4984 + constructor(ctx: ExecutionContext, env: Env); 4985 + /** 4986 + * run recieves an array of PipelineRecord which can be 4987 + * transformed and returned to the pipeline 4988 + * @param records Incoming records from the pipeline to be transformed 4989 + * @param metadata Information about the specific pipeline calling the transformation entrypoint 4990 + * @returns A promise containing the transformed PipelineRecord array 4991 + */ 4992 + public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>; 4993 + } 4994 + export type PipelineRecord = Record<string, unknown>; 4995 + export type PipelineBatchMetadata = { 4996 + pipelineId: string; 4997 + pipelineName: string; 4998 + }; 4999 + export interface Pipeline<T extends PipelineRecord = PipelineRecord> { 5000 + /** 5001 + * The Pipeline interface represents the type of a binding to a Pipeline 5002 + * 5003 + * @param records The records to send to the pipeline 5004 + */ 5005 + send(records: T[]): Promise<void>; 5006 + } 5007 + } 5008 + // PubSubMessage represents an incoming PubSub message. 5009 + // The message includes metadata about the broker, the client, and the payload 5010 + // itself. 5011 + // https://developers.cloudflare.com/pub-sub/ 5012 + interface PubSubMessage { 5013 + // Message ID 5014 + readonly mid: number; 5015 + // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT 5016 + readonly broker: string; 5017 + // The MQTT topic the message was sent on. 5018 + readonly topic: string; 5019 + // The client ID of the client that published this message. 5020 + readonly clientId: string; 5021 + // The unique identifier (JWT ID) used by the client to authenticate, if token 5022 + // auth was used. 5023 + readonly jti?: string; 5024 + // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker 5025 + // received the message from the client. 5026 + readonly receivedAt: number; 5027 + // An (optional) string with the MIME type of the payload, if set by the 5028 + // client. 5029 + readonly contentType: string; 5030 + // Set to 1 when the payload is a UTF-8 string 5031 + // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063 5032 + readonly payloadFormatIndicator: number; 5033 + // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays. 5034 + // You can use payloadFormatIndicator to inspect this before decoding. 5035 + payload: string | Uint8Array; 5036 + } 5037 + // JsonWebKey extended by kid parameter 5038 + interface JsonWebKeyWithKid extends JsonWebKey { 5039 + // Key Identifier of the JWK 5040 + readonly kid: string; 5041 + } 5042 + interface RateLimitOptions { 5043 + key: string; 5044 + } 5045 + interface RateLimitOutcome { 5046 + success: boolean; 5047 + } 5048 + interface RateLimit { 5049 + /** 5050 + * Rate limit a request based on the provided options. 5051 + * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/ 5052 + * @returns A promise that resolves with the outcome of the rate limit. 5053 + */ 5054 + limit(options: RateLimitOptions): Promise<RateLimitOutcome>; 5055 + } 5056 + // Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need 5057 + // to referenced by `Fetcher`. This is included in the "importable" version of the types which 5058 + // strips all `module` blocks. 5059 + declare namespace Rpc { 5060 + // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. 5061 + // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`. 5062 + // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to 5063 + // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape) 5064 + export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND'; 5065 + export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND'; 5066 + export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND'; 5067 + export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND'; 5068 + export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND'; 5069 + export interface RpcTargetBranded { 5070 + [__RPC_TARGET_BRAND]: never; 5071 + } 5072 + export interface WorkerEntrypointBranded { 5073 + [__WORKER_ENTRYPOINT_BRAND]: never; 5074 + } 5075 + export interface DurableObjectBranded { 5076 + [__DURABLE_OBJECT_BRAND]: never; 5077 + } 5078 + export interface WorkflowEntrypointBranded { 5079 + [__WORKFLOW_ENTRYPOINT_BRAND]: never; 5080 + } 5081 + export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded; 5082 + // Types that can be used through `Stub`s 5083 + export type Stubable = RpcTargetBranded | ((...args: any[]) => any); 5084 + // Types that can be passed over RPC 5085 + // The reason for using a generic type here is to build a serializable subset of structured 5086 + // cloneable composite types. This allows types defined with the "interface" keyword to pass the 5087 + // serializable check as well. Otherwise, only types defined with the "type" keyword would pass. 5088 + type Serializable<T> = 5089 + // Structured cloneables 5090 + BaseType 5091 + // Structured cloneable composites 5092 + | Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | { 5093 + [K in keyof T]: K extends number | string ? Serializable<T[K]> : never; 5094 + } 5095 + // Special types 5096 + | Stub<Stubable> 5097 + // Serialized as stubs, see `Stubify` 5098 + | Stubable; 5099 + // Base type for all RPC stubs, including common memory management methods. 5100 + // `T` is used as a marker type for unwrapping `Stub`s later. 5101 + interface StubBase<T extends Stubable> extends Disposable { 5102 + [__RPC_STUB_BRAND]: T; 5103 + dup(): this; 5104 + } 5105 + export type Stub<T extends Stubable> = Provider<T> & StubBase<T>; 5106 + // This represents all the types that can be sent as-is over an RPC boundary 5107 + type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers; 5108 + // Recursively rewrite all `Stubable` types with `Stub`s 5109 + // prettier-ignore 5110 + type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends { 5111 + [key: string | number]: any; 5112 + } ? { 5113 + [K in keyof T]: Stubify<T[K]>; 5114 + } : T; 5115 + // Recursively rewrite all `Stub<T>`s with the corresponding `T`s. 5116 + // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: 5117 + // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. 5118 + // prettier-ignore 5119 + type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends { 5120 + [key: string | number]: unknown; 5121 + } ? { 5122 + [K in keyof T]: Unstubify<T[K]>; 5123 + } : T; 5124 + type UnstubifyAll<A extends any[]> = { 5125 + [I in keyof A]: Unstubify<A[I]>; 5126 + }; 5127 + // Utility type for adding `Provider`/`Disposable`s to `object` types only. 5128 + // Note `unknown & T` is equivalent to `T`. 5129 + type MaybeProvider<T> = T extends object ? Provider<T> : unknown; 5130 + type MaybeDisposable<T> = T extends object ? Disposable : unknown; 5131 + // Type for method return or property on an RPC interface. 5132 + // - Stubable types are replaced by stubs. 5133 + // - Serializable types are passed by value, with stubable types replaced by stubs 5134 + // and a top-level `Disposer`. 5135 + // Everything else can't be passed over PRC. 5136 + // Technically, we use custom thenables here, but they quack like `Promise`s. 5137 + // Intersecting with `(Maybe)Provider` allows pipelining. 5138 + // prettier-ignore 5139 + type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never; 5140 + // Type for method or property on an RPC interface. 5141 + // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s. 5142 + // Unwrapping `Stub`s allows calling with `Stubable` arguments. 5143 + // For properties, rewrite types to be `Result`s. 5144 + // In each case, unwrap `Promise`s. 5145 + type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>; 5146 + // Type for the callable part of an `Provider` if `T` is callable. 5147 + // This is intersected with methods/properties. 5148 + type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown; 5149 + // Base type for all other types providing RPC-like interfaces. 5150 + // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types. 5151 + // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC. 5152 + export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & { 5153 + [K in Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>]: MethodOrProperty<T[K]>; 5154 + }; 5155 + } 5156 + declare namespace Cloudflare { 5157 + interface Env { 5158 + } 5159 + } 5160 + declare module 'cloudflare:workers' { 5161 + export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>; 5162 + export const RpcStub: { 5163 + new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>; 5164 + }; 5165 + export abstract class RpcTarget implements Rpc.RpcTargetBranded { 5166 + [Rpc.__RPC_TARGET_BRAND]: never; 5167 + } 5168 + // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC 5169 + export abstract class WorkerEntrypoint<Env = unknown> implements Rpc.WorkerEntrypointBranded { 5170 + [Rpc.__WORKER_ENTRYPOINT_BRAND]: never; 5171 + protected ctx: ExecutionContext; 5172 + protected env: Env; 5173 + constructor(ctx: ExecutionContext, env: Env); 5174 + fetch?(request: Request): Response | Promise<Response>; 5175 + tail?(events: TraceItem[]): void | Promise<void>; 5176 + trace?(traces: TraceItem[]): void | Promise<void>; 5177 + scheduled?(controller: ScheduledController): void | Promise<void>; 5178 + queue?(batch: MessageBatch<unknown>): void | Promise<void>; 5179 + test?(controller: TestController): void | Promise<void>; 5180 + } 5181 + export abstract class DurableObject<Env = unknown> implements Rpc.DurableObjectBranded { 5182 + [Rpc.__DURABLE_OBJECT_BRAND]: never; 5183 + protected ctx: DurableObjectState; 5184 + protected env: Env; 5185 + constructor(ctx: DurableObjectState, env: Env); 5186 + fetch?(request: Request): Response | Promise<Response>; 5187 + alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>; 5188 + webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>; 5189 + webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>; 5190 + webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>; 5191 + } 5192 + export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; 5193 + export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; 5194 + export type WorkflowDelayDuration = WorkflowSleepDuration; 5195 + export type WorkflowTimeoutDuration = WorkflowSleepDuration; 5196 + export type WorkflowBackoff = 'constant' | 'linear' | 'exponential'; 5197 + export type WorkflowStepConfig = { 5198 + retries?: { 5199 + limit: number; 5200 + delay: WorkflowDelayDuration | number; 5201 + backoff?: WorkflowBackoff; 5202 + }; 5203 + timeout?: WorkflowTimeoutDuration | number; 5204 + }; 5205 + export type WorkflowEvent<T> = { 5206 + payload: Readonly<T>; 5207 + timestamp: Date; 5208 + instanceId: string; 5209 + }; 5210 + export type WorkflowStepEvent<T> = { 5211 + payload: Readonly<T>; 5212 + timestamp: Date; 5213 + type: string; 5214 + }; 5215 + export abstract class WorkflowStep { 5216 + do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>; 5217 + do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>; 5218 + sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>; 5219 + sleepUntil: (name: string, timestamp: Date | number) => Promise<void>; 5220 + waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: { 5221 + type: string; 5222 + timeout?: WorkflowTimeoutDuration | number; 5223 + }): Promise<WorkflowStepEvent<T>>; 5224 + } 5225 + export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded { 5226 + [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never; 5227 + protected ctx: ExecutionContext; 5228 + protected env: Env; 5229 + constructor(ctx: ExecutionContext, env: Env); 5230 + run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>; 5231 + } 5232 + export const env: Cloudflare.Env; 5233 + } 5234 + interface SecretsStoreSecret { 5235 + /** 5236 + * Get a secret from the Secrets Store, returning a string of the secret value 5237 + * if it exists, or throws an error if it does not exist 5238 + */ 5239 + get(): Promise<string>; 5240 + } 5241 + declare module "cloudflare:sockets" { 5242 + function _connect(address: string | SocketAddress, options?: SocketOptions): Socket; 5243 + export { _connect as connect }; 5244 + } 5245 + declare namespace TailStream { 5246 + interface Header { 5247 + readonly name: string; 5248 + readonly value: string; 5249 + } 5250 + interface FetchEventInfo { 5251 + readonly type: "fetch"; 5252 + readonly method: string; 5253 + readonly url: string; 5254 + readonly cfJson: string; 5255 + readonly headers: Header[]; 5256 + } 5257 + interface JsRpcEventInfo { 5258 + readonly type: "jsrpc"; 5259 + readonly methodName: string; 5260 + } 5261 + interface ScheduledEventInfo { 5262 + readonly type: "scheduled"; 5263 + readonly scheduledTime: Date; 5264 + readonly cron: string; 5265 + } 5266 + interface AlarmEventInfo { 5267 + readonly type: "alarm"; 5268 + readonly scheduledTime: Date; 5269 + } 5270 + interface QueueEventInfo { 5271 + readonly type: "queue"; 5272 + readonly queueName: string; 5273 + readonly batchSize: number; 5274 + } 5275 + interface EmailEventInfo { 5276 + readonly type: "email"; 5277 + readonly mailFrom: string; 5278 + readonly rcptTo: string; 5279 + readonly rawSize: number; 5280 + } 5281 + interface TraceEventInfo { 5282 + readonly type: "trace"; 5283 + readonly traces: (string | null)[]; 5284 + } 5285 + interface HibernatableWebSocketEventInfoMessage { 5286 + readonly type: "message"; 5287 + } 5288 + interface HibernatableWebSocketEventInfoError { 5289 + readonly type: "error"; 5290 + } 5291 + interface HibernatableWebSocketEventInfoClose { 5292 + readonly type: "close"; 5293 + readonly code: number; 5294 + readonly wasClean: boolean; 5295 + } 5296 + interface HibernatableWebSocketEventInfo { 5297 + readonly type: "hibernatableWebSocket"; 5298 + readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage; 5299 + } 5300 + interface Resume { 5301 + readonly type: "resume"; 5302 + readonly attachment?: any; 5303 + } 5304 + interface CustomEventInfo { 5305 + readonly type: "custom"; 5306 + } 5307 + interface FetchResponseInfo { 5308 + readonly type: "fetch"; 5309 + readonly statusCode: number; 5310 + } 5311 + type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound"; 5312 + interface ScriptVersion { 5313 + readonly id: string; 5314 + readonly tag?: string; 5315 + readonly message?: string; 5316 + } 5317 + interface Trigger { 5318 + readonly traceId: string; 5319 + readonly invocationId: string; 5320 + readonly spanId: string; 5321 + } 5322 + interface Onset { 5323 + readonly type: "onset"; 5324 + readonly dispatchNamespace?: string; 5325 + readonly entrypoint?: string; 5326 + readonly scriptName?: string; 5327 + readonly scriptTags?: string[]; 5328 + readonly scriptVersion?: ScriptVersion; 5329 + readonly trigger?: Trigger; 5330 + readonly info: FetchEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | Resume | CustomEventInfo; 5331 + } 5332 + interface Outcome { 5333 + readonly type: "outcome"; 5334 + readonly outcome: EventOutcome; 5335 + readonly cpuTime: number; 5336 + readonly wallTime: number; 5337 + } 5338 + interface Hibernate { 5339 + readonly type: "hibernate"; 5340 + } 5341 + interface SpanOpen { 5342 + readonly type: "spanOpen"; 5343 + readonly name: string; 5344 + readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes; 5345 + } 5346 + interface SpanClose { 5347 + readonly type: "spanClose"; 5348 + readonly outcome: EventOutcome; 5349 + } 5350 + interface DiagnosticChannelEvent { 5351 + readonly type: "diagnosticChannel"; 5352 + readonly channel: string; 5353 + readonly message: any; 5354 + } 5355 + interface Exception { 5356 + readonly type: "exception"; 5357 + readonly name: string; 5358 + readonly message: string; 5359 + readonly stack?: string; 5360 + } 5361 + interface Log { 5362 + readonly type: "log"; 5363 + readonly level: "debug" | "error" | "info" | "log" | "warn"; 5364 + readonly message: string; 5365 + } 5366 + interface Return { 5367 + readonly type: "return"; 5368 + readonly info?: FetchResponseInfo | Attributes; 5369 + } 5370 + interface Link { 5371 + readonly type: "link"; 5372 + readonly label?: string; 5373 + readonly traceId: string; 5374 + readonly invocationId: string; 5375 + readonly spanId: string; 5376 + } 5377 + interface Attribute { 5378 + readonly name: string; 5379 + readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[]; 5380 + } 5381 + interface Attributes { 5382 + readonly type: "attributes"; 5383 + readonly info: Attribute[]; 5384 + } 5385 + interface TailEvent { 5386 + readonly traceId: string; 5387 + readonly invocationId: string; 5388 + readonly spanId: string; 5389 + readonly timestamp: Date; 5390 + readonly sequence: number; 5391 + readonly event: Onset | Outcome | Hibernate | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | Return | Link | Attributes; 5392 + } 5393 + type TailEventHandler = (event: TailEvent) => void | Promise<void>; 5394 + type TailEventHandlerName = "outcome" | "hibernate" | "spanOpen" | "spanClose" | "diagnosticChannel" | "exception" | "log" | "return" | "link" | "attributes"; 5395 + type TailEventHandlerObject = Record<TailEventHandlerName, TailEventHandler>; 5396 + type TailEventHandlerType = TailEventHandler | TailEventHandlerObject; 5397 + } 5398 + // Copyright (c) 2022-2023 Cloudflare, Inc. 5399 + // Licensed under the Apache 2.0 license found in the LICENSE file or at: 5400 + // https://opensource.org/licenses/Apache-2.0 5401 + /** 5402 + * Data types supported for holding vector metadata. 5403 + */ 5404 + type VectorizeVectorMetadataValue = string | number | boolean | string[]; 5405 + /** 5406 + * Additional information to associate with a vector. 5407 + */ 5408 + type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>; 5409 + type VectorFloatArray = Float32Array | Float64Array; 5410 + interface VectorizeError { 5411 + code?: number; 5412 + error: string; 5413 + } 5414 + /** 5415 + * Comparison logic/operation to use for metadata filtering. 5416 + * 5417 + * This list is expected to grow as support for more operations are released. 5418 + */ 5419 + type VectorizeVectorMetadataFilterOp = "$eq" | "$ne"; 5420 + /** 5421 + * Filter criteria for vector metadata used to limit the retrieved query result set. 5422 + */ 5423 + type VectorizeVectorMetadataFilter = { 5424 + [field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | { 5425 + [Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null; 5426 + }; 5427 + }; 5428 + /** 5429 + * Supported distance metrics for an index. 5430 + * Distance metrics determine how other "similar" vectors are determined. 5431 + */ 5432 + type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product"; 5433 + /** 5434 + * Metadata return levels for a Vectorize query. 5435 + * 5436 + * Default to "none". 5437 + * 5438 + * @property all Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data. 5439 + * @property indexed Return all metadata fields configured for indexing in the vector return set. This level of retrieval is "free" in that no additional overhead is incurred returning this data. However, note that indexed metadata is subject to truncation (especially for larger strings). 5440 + * @property none No indexed metadata will be returned. 5441 + */ 5442 + type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none"; 5443 + interface VectorizeQueryOptions { 5444 + topK?: number; 5445 + namespace?: string; 5446 + returnValues?: boolean; 5447 + returnMetadata?: boolean | VectorizeMetadataRetrievalLevel; 5448 + filter?: VectorizeVectorMetadataFilter; 5449 + } 5450 + /** 5451 + * Information about the configuration of an index. 5452 + */ 5453 + type VectorizeIndexConfig = { 5454 + dimensions: number; 5455 + metric: VectorizeDistanceMetric; 5456 + } | { 5457 + preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity 5458 + }; 5459 + /** 5460 + * Metadata about an existing index. 5461 + * 5462 + * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. 5463 + * See {@link VectorizeIndexInfo} for its post-beta equivalent. 5464 + */ 5465 + interface VectorizeIndexDetails { 5466 + /** The unique ID of the index */ 5467 + readonly id: string; 5468 + /** The name of the index. */ 5469 + name: string; 5470 + /** (optional) A human readable description for the index. */ 5471 + description?: string; 5472 + /** The index configuration, including the dimension size and distance metric. */ 5473 + config: VectorizeIndexConfig; 5474 + /** The number of records containing vectors within the index. */ 5475 + vectorsCount: number; 5476 + } 5477 + /** 5478 + * Metadata about an existing index. 5479 + */ 5480 + interface VectorizeIndexInfo { 5481 + /** The number of records containing vectors within the index. */ 5482 + vectorCount: number; 5483 + /** Number of dimensions the index has been configured for. */ 5484 + dimensions: number; 5485 + /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */ 5486 + processedUpToDatetime: number; 5487 + /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */ 5488 + processedUpToMutation: number; 5489 + } 5490 + /** 5491 + * Represents a single vector value set along with its associated metadata. 5492 + */ 5493 + interface VectorizeVector { 5494 + /** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */ 5495 + id: string; 5496 + /** The vector values */ 5497 + values: VectorFloatArray | number[]; 5498 + /** The namespace this vector belongs to. */ 5499 + namespace?: string; 5500 + /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */ 5501 + metadata?: Record<string, VectorizeVectorMetadata>; 5502 + } 5503 + /** 5504 + * Represents a matched vector for a query along with its score and (if specified) the matching vector information. 5505 + */ 5506 + type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & { 5507 + /** The score or rank for similarity, when returned as a result */ 5508 + score: number; 5509 + }; 5510 + /** 5511 + * A set of matching {@link VectorizeMatch} for a particular query. 5512 + */ 5513 + interface VectorizeMatches { 5514 + matches: VectorizeMatch[]; 5515 + count: number; 5516 + } 5517 + /** 5518 + * Results of an operation that performed a mutation on a set of vectors. 5519 + * Here, `ids` is a list of vectors that were successfully processed. 5520 + * 5521 + * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. 5522 + * See {@link VectorizeAsyncMutation} for its post-beta equivalent. 5523 + */ 5524 + interface VectorizeVectorMutation { 5525 + /* List of ids of vectors that were successfully processed. */ 5526 + ids: string[]; 5527 + /* Total count of the number of processed vectors. */ 5528 + count: number; 5529 + } 5530 + /** 5531 + * Result type indicating a mutation on the Vectorize Index. 5532 + * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation. 5533 + */ 5534 + interface VectorizeAsyncMutation { 5535 + /** The unique identifier for the async mutation operation containing the changeset. */ 5536 + mutationId: string; 5537 + } 5538 + /** 5539 + * A Vectorize Vector Search Index for querying vectors/embeddings. 5540 + * 5541 + * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. 5542 + * See {@link Vectorize} for its new implementation. 5543 + */ 5544 + declare abstract class VectorizeIndex { 5545 + /** 5546 + * Get information about the currently bound index. 5547 + * @returns A promise that resolves with information about the current index. 5548 + */ 5549 + public describe(): Promise<VectorizeIndexDetails>; 5550 + /** 5551 + * Use the provided vector to perform a similarity search across the index. 5552 + * @param vector Input vector that will be used to drive the similarity search. 5553 + * @param options Configuration options to massage the returned data. 5554 + * @returns A promise that resolves with matched and scored vectors. 5555 + */ 5556 + public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>; 5557 + /** 5558 + * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown. 5559 + * @param vectors List of vectors that will be inserted. 5560 + * @returns A promise that resolves with the ids & count of records that were successfully processed. 5561 + */ 5562 + public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>; 5563 + /** 5564 + * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values. 5565 + * @param vectors List of vectors that will be upserted. 5566 + * @returns A promise that resolves with the ids & count of records that were successfully processed. 5567 + */ 5568 + public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>; 5569 + /** 5570 + * Delete a list of vectors with a matching id. 5571 + * @param ids List of vector ids that should be deleted. 5572 + * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted). 5573 + */ 5574 + public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>; 5575 + /** 5576 + * Get a list of vectors with a matching id. 5577 + * @param ids List of vector ids that should be returned. 5578 + * @returns A promise that resolves with the raw unscored vectors matching the id set. 5579 + */ 5580 + public getByIds(ids: string[]): Promise<VectorizeVector[]>; 5581 + } 5582 + /** 5583 + * A Vectorize Vector Search Index for querying vectors/embeddings. 5584 + * 5585 + * Mutations in this version are async, returning a mutation id. 5586 + */ 5587 + declare abstract class Vectorize { 5588 + /** 5589 + * Get information about the currently bound index. 5590 + * @returns A promise that resolves with information about the current index. 5591 + */ 5592 + public describe(): Promise<VectorizeIndexInfo>; 5593 + /** 5594 + * Use the provided vector to perform a similarity search across the index. 5595 + * @param vector Input vector that will be used to drive the similarity search. 5596 + * @param options Configuration options to massage the returned data. 5597 + * @returns A promise that resolves with matched and scored vectors. 5598 + */ 5599 + public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>; 5600 + /** 5601 + * Use the provided vector-id to perform a similarity search across the index. 5602 + * @param vectorId Id for a vector in the index against which the index should be queried. 5603 + * @param options Configuration options to massage the returned data. 5604 + * @returns A promise that resolves with matched and scored vectors. 5605 + */ 5606 + public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>; 5607 + /** 5608 + * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown. 5609 + * @param vectors List of vectors that will be inserted. 5610 + * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset. 5611 + */ 5612 + public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>; 5613 + /** 5614 + * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values. 5615 + * @param vectors List of vectors that will be upserted. 5616 + * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset. 5617 + */ 5618 + public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>; 5619 + /** 5620 + * Delete a list of vectors with a matching id. 5621 + * @param ids List of vector ids that should be deleted. 5622 + * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset. 5623 + */ 5624 + public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>; 5625 + /** 5626 + * Get a list of vectors with a matching id. 5627 + * @param ids List of vector ids that should be returned. 5628 + * @returns A promise that resolves with the raw unscored vectors matching the id set. 5629 + */ 5630 + public getByIds(ids: string[]): Promise<VectorizeVector[]>; 5631 + } 5632 + /** 5633 + * The interface for "version_metadata" binding 5634 + * providing metadata about the Worker Version using this binding. 5635 + */ 5636 + type WorkerVersionMetadata = { 5637 + /** The ID of the Worker Version using this binding */ 5638 + id: string; 5639 + /** The tag of the Worker Version using this binding */ 5640 + tag: string; 5641 + /** The timestamp of when the Worker Version was uploaded */ 5642 + timestamp: string; 5643 + }; 5644 + interface DynamicDispatchLimits { 5645 + /** 5646 + * Limit CPU time in milliseconds. 5647 + */ 5648 + cpuMs?: number; 5649 + /** 5650 + * Limit number of subrequests. 5651 + */ 5652 + subRequests?: number; 5653 + } 5654 + interface DynamicDispatchOptions { 5655 + /** 5656 + * Limit resources of invoked Worker script. 5657 + */ 5658 + limits?: DynamicDispatchLimits; 5659 + /** 5660 + * Arguments for outbound Worker script, if configured. 5661 + */ 5662 + outbound?: { 5663 + [key: string]: any; 5664 + }; 5665 + } 5666 + interface DispatchNamespace { 5667 + /** 5668 + * @param name Name of the Worker script. 5669 + * @param args Arguments to Worker script. 5670 + * @param options Options for Dynamic Dispatch invocation. 5671 + * @returns A Fetcher object that allows you to send requests to the Worker script. 5672 + * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown. 5673 + */ 5674 + get(name: string, args?: { 5675 + [key: string]: any; 5676 + }, options?: DynamicDispatchOptions): Fetcher; 5677 + } 5678 + declare module 'cloudflare:workflows' { 5679 + /** 5680 + * NonRetryableError allows for a user to throw a fatal error 5681 + * that makes a Workflow instance fail immediately without triggering a retry 5682 + */ 5683 + export class NonRetryableError extends Error { 5684 + public constructor(message: string, name?: string); 5685 + } 5686 + } 5687 + declare abstract class Workflow<PARAMS = unknown> { 5688 + /** 5689 + * Get a handle to an existing instance of the Workflow. 5690 + * @param id Id for the instance of this Workflow 5691 + * @returns A promise that resolves with a handle for the Instance 5692 + */ 5693 + public get(id: string): Promise<WorkflowInstance>; 5694 + /** 5695 + * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown. 5696 + * @param options Options when creating an instance including id and params 5697 + * @returns A promise that resolves with a handle for the Instance 5698 + */ 5699 + public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>; 5700 + /** 5701 + * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown. 5702 + * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached. 5703 + * @param batch List of Options when creating an instance including name and params 5704 + * @returns A promise that resolves with a list of handles for the created instances. 5705 + */ 5706 + public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>; 5707 + } 5708 + interface WorkflowInstanceCreateOptions<PARAMS = unknown> { 5709 + /** 5710 + * An id for your Workflow instance. Must be unique within the Workflow. 5711 + */ 5712 + id?: string; 5713 + /** 5714 + * The event payload the Workflow instance is triggered with 5715 + */ 5716 + params?: PARAMS; 5717 + } 5718 + type InstanceStatus = { 5719 + status: 'queued' // means that instance is waiting to be started (see concurrency limits) 5720 + | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running 5721 + | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish 5722 + | 'waitingForPause' // instance is finishing the current work to pause 5723 + | 'unknown'; 5724 + error?: string; 5725 + output?: object; 5726 + }; 5727 + interface WorkflowError { 5728 + code?: number; 5729 + message: string; 5730 + } 5731 + declare abstract class WorkflowInstance { 5732 + public id: string; 5733 + /** 5734 + * Pause the instance. 5735 + */ 5736 + public pause(): Promise<void>; 5737 + /** 5738 + * Resume the instance. If it is already running, an error will be thrown. 5739 + */ 5740 + public resume(): Promise<void>; 5741 + /** 5742 + * Terminate the instance. If it is errored, terminated or complete, an error will be thrown. 5743 + */ 5744 + public terminate(): Promise<void>; 5745 + /** 5746 + * Restart the instance. 5747 + */ 5748 + public restart(): Promise<void>; 5749 + /** 5750 + * Returns the current status of the instance. 5751 + */ 5752 + public status(): Promise<InstanceStatus>; 5753 + /** 5754 + * Send an event to this instance. 5755 + */ 5756 + public sendEvent({ type, payload, }: { 5757 + type: string; 5758 + payload: unknown; 5759 + }): Promise<void>; 5760 + }
+94
wrangler.jsonc
··· 1 + /** 2 + * For more details on how to configure Wrangler, refer to: 3 + * https://developers.cloudflare.com/workers/wrangler/configuration/ 4 + */ 5 + { 6 + "$schema": "node_modules/wrangler/config-schema.json", 7 + "name": "doing-jetstream", 8 + "main": "src/index.ts", 9 + "compatibility_date": "2025-05-29", 10 + "migrations": [ 11 + { 12 + "new_sqlite_classes": [ 13 + "JetstreamProcessor" 14 + ], 15 + "tag": "v1" 16 + } 17 + ], 18 + "durable_objects": { 19 + "bindings": [ 20 + { 21 + "class_name": "JetstreamProcessor", 22 + "name": "JETSTREAM_PROCESSOR" 23 + } 24 + ] 25 + }, 26 + "queues": { 27 + "producers": [ 28 + { 29 + "queue": "jetstream-events", 30 + "binding": "JETSTREAM_QUEUE" 31 + } 32 + ], 33 + "consumers": [ 34 + { 35 + "queue": "jetstream-events", 36 + "max_batch_size": 10, 37 + "max_batch_timeout": 5, 38 + "max_retries": 3, 39 + "dead_letter_queue": "jetstream-events-dlq" 40 + } 41 + ] 42 + }, 43 + "observability": { 44 + "enabled": true 45 + }, 46 + /** 47 + * Smart Placement 48 + * Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement 49 + */ 50 + // "placement": { "mode": "smart" }, 51 + 52 + /** 53 + * Bindings 54 + * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including 55 + * databases, object storage, AI inference, real-time communication and more. 56 + * https://developers.cloudflare.com/workers/runtime-apis/bindings/ 57 + */ 58 + 59 + /** 60 + * Scheduled Events - Keep worker alive 61 + * https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/ 62 + */ 63 + "triggers": [ 64 + { 65 + "crons": ["*/5 * * * *"] 66 + } 67 + ], 68 + 69 + /** 70 + * Environment Variables and Secrets 71 + * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables 72 + * 73 + * Note: WEBHOOK_URL and JETSTREAM_COLLECTIONS are now configured via: 74 + * - Production: wrangler secret put or environment variables 75 + * - Development: .dev.vars file 76 + */ 77 + 78 + /** 79 + * Note: Secrets are set via CLI and not stored in this file 80 + * Set secrets with: wrangler secret put WEBHOOK_BEARER_TOKEN 81 + */ 82 + 83 + /** 84 + * Static Assets 85 + * https://developers.cloudflare.com/workers/static-assets/binding/ 86 + */ 87 + // "assets": { "directory": "./public/", "binding": "ASSETS" }, 88 + 89 + /** 90 + * Service Bindings (communicate between multiple Workers) 91 + * https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings 92 + */ 93 + // "services": [{ "binding": "MY_SERVICE", "service": "my-service" }] 94 + }