@cloudflare/workers-types 0.20230307.0 → 0.20230512.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,6 +49,7 @@ declare class DOMException extends Error {
49
49
  declare type WorkerGlobalScopeEventMap = {
50
50
  fetch: FetchEvent;
51
51
  scheduled: ScheduledEvent;
52
+ queue: QueueEvent;
52
53
  unhandledrejection: PromiseRejectionEvent;
53
54
  rejectionhandled: PromiseRejectionEvent;
54
55
  };
@@ -183,11 +184,14 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
183
184
  crypto: Crypto;
184
185
  caches: CacheStorage;
185
186
  scheduler: Scheduler;
187
+ performance: Performance;
188
+ readonly origin: string;
186
189
  Event: typeof Event;
187
190
  ExtendableEvent: typeof ExtendableEvent;
188
191
  PromiseRejectionEvent: typeof PromiseRejectionEvent;
189
192
  FetchEvent: typeof FetchEvent;
190
- TraceEvent: typeof TraceEvent;
193
+ TailEvent: typeof TailEvent;
194
+ TraceEvent: typeof TailEvent;
191
195
  ScheduledEvent: typeof ScheduledEvent;
192
196
  MessageEvent: typeof MessageEvent;
193
197
  CloseEvent: typeof CloseEvent;
@@ -279,16 +283,26 @@ declare const self: ServiceWorkerGlobalScope;
279
283
  declare const crypto: Crypto;
280
284
  declare const caches: CacheStorage;
281
285
  declare const scheduler: Scheduler;
286
+ declare const performance: Performance;
287
+ declare const origin: string;
282
288
  declare interface TestController {}
283
289
  declare interface ExecutionContext {
284
290
  waitUntil(promise: Promise<any>): void;
285
291
  passThroughOnException(): void;
286
292
  }
287
- declare type ExportedHandlerFetchHandler<Env = unknown> = (
288
- request: Request,
293
+ declare type ExportedHandlerFetchHandler<
294
+ Env = unknown,
295
+ CfHostMetadata = unknown
296
+ > = (
297
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
289
298
  env: Env,
290
299
  ctx: ExecutionContext
291
300
  ) => Response | Promise<Response>;
301
+ declare type ExportedHandlerTailHandler<Env = unknown> = (
302
+ events: TraceItem[],
303
+ env: Env,
304
+ ctx: ExecutionContext
305
+ ) => void | Promise<void>;
292
306
  declare type ExportedHandlerTraceHandler<Env = unknown> = (
293
307
  traces: TraceItem[],
294
308
  env: Env,
@@ -309,12 +323,17 @@ declare type ExportedHandlerTestHandler<Env = unknown> = (
309
323
  env: Env,
310
324
  ctx: ExecutionContext
311
325
  ) => void | Promise<void>;
312
- declare interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
313
- fetch?: ExportedHandlerFetchHandler<Env>;
326
+ declare interface ExportedHandler<
327
+ Env = unknown,
328
+ QueueMessage = unknown,
329
+ CfHostMetadata = unknown
330
+ > {
331
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
332
+ tail?: ExportedHandlerTailHandler<Env>;
314
333
  trace?: ExportedHandlerTraceHandler<Env>;
315
334
  scheduled?: ExportedHandlerScheduledHandler<Env>;
316
335
  test?: ExportedHandlerTestHandler<Env>;
317
- queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
336
+ queue?: ExportedHandlerQueueHandler<Env, Message>;
318
337
  }
319
338
  declare interface StructuredSerializeOptions {
320
339
  transfer?: any[];
@@ -323,6 +342,11 @@ declare abstract class PromiseRejectionEvent extends Event {
323
342
  readonly promise: Promise<any>;
324
343
  readonly reason: any;
325
344
  }
345
+ /** Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
346
+ declare interface Performance {
347
+ readonly timeOrigin: number;
348
+ now(): number;
349
+ }
326
350
  declare interface DurableObject {
327
351
  fetch(request: Request): Response | Promise<Response>;
328
352
  alarm?(): void | Promise<void>;
@@ -346,19 +370,32 @@ declare interface DurableObjectNamespace {
346
370
  id: DurableObjectId,
347
371
  options?: DurableObjectNamespaceGetDurableObjectOptions
348
372
  ): DurableObjectStub;
349
- jurisdiction(jurisdiction: string): DurableObjectNamespace;
373
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
350
374
  }
375
+ declare type DurableObjectJurisdiction = "eu" | "fedramp";
351
376
  declare interface DurableObjectNamespaceNewUniqueIdOptions {
352
- jurisdiction?: string;
353
- }
377
+ jurisdiction?: DurableObjectJurisdiction;
378
+ }
379
+ declare type DurableObjectLocationHint =
380
+ | "wnam"
381
+ | "enam"
382
+ | "sam"
383
+ | "weur"
384
+ | "eeur"
385
+ | "apac"
386
+ | "oc"
387
+ | "afr"
388
+ | "me";
354
389
  declare interface DurableObjectNamespaceGetDurableObjectOptions {
355
- locationHint?: string;
390
+ locationHint?: DurableObjectLocationHint;
356
391
  }
357
392
  declare interface DurableObjectState {
358
393
  waitUntil(promise: Promise<any>): void;
359
394
  readonly id: DurableObjectId;
360
395
  readonly storage: DurableObjectStorage;
361
396
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
397
+ acceptWebSocket(ws: WebSocket, tags?: string[]): void;
398
+ getWebSockets(tag?: string): WebSocket[];
362
399
  }
363
400
  declare interface DurableObjectTransaction {
364
401
  get<T = unknown>(
@@ -425,6 +462,7 @@ declare interface DurableObjectStorage {
425
462
  ): Promise<void>;
426
463
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
427
464
  sync(): Promise<void>;
465
+ transactionSync<T>(closure: () => T): T;
428
466
  }
429
467
  declare interface DurableObjectListOptions {
430
468
  start?: string;
@@ -534,6 +572,7 @@ declare class AbortController {
534
572
  declare abstract class AbortSignal extends EventTarget {
535
573
  static abort(reason?: any): AbortSignal;
536
574
  static timeout(delay: number): AbortSignal;
575
+ static any(signals: AbortSignal[]): AbortSignal;
537
576
  get aborted(): boolean;
538
577
  get reason(): any;
539
578
  throwIfAborted(): void;
@@ -982,23 +1021,27 @@ declare interface ResponseInit {
982
1021
  webSocket?: WebSocket | null;
983
1022
  encodeBody?: "automatic" | "manual";
984
1023
  }
985
- declare type RequestInfo = Request | string | URL;
986
- declare class Request<CfHostMetadata = unknown> extends Body {
987
- constructor(input: RequestInfo, init?: RequestInit);
988
- clone(): Request<CfHostMetadata>;
1024
+ declare type RequestInfo<
1025
+ CfHostMetadata = unknown,
1026
+ Cf = CfProperties<CfHostMetadata>
1027
+ > = Request<CfHostMetadata, Cf> | string | URL;
1028
+ declare class Request<
1029
+ CfHostMetadata = unknown,
1030
+ Cf = CfProperties<CfHostMetadata>
1031
+ > extends Body {
1032
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1033
+ clone(): Request<CfHostMetadata, Cf>;
989
1034
  get method(): string;
990
1035
  get url(): string;
991
1036
  get headers(): Headers;
992
1037
  get redirect(): string;
993
1038
  get fetcher(): Fetcher | null;
994
1039
  get signal(): AbortSignal;
995
- get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
1040
+ get cf(): Cf | undefined;
996
1041
  get integrity(): string;
997
1042
  get keepalive(): boolean;
998
1043
  }
999
- declare interface RequestInit<
1000
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1001
- > {
1044
+ declare interface RequestInit<Cf = CfProperties> {
1002
1045
  /** A string to set request's method. */
1003
1046
  method?: string;
1004
1047
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1008,17 +1051,15 @@ declare interface RequestInit<
1008
1051
  /** 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. */
1009
1052
  redirect?: string;
1010
1053
  fetcher?: Fetcher | null;
1011
- cf?: CfType;
1054
+ cf?: Cf;
1012
1055
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1013
1056
  integrity?: string;
1014
1057
  /** An AbortSignal to set request's signal. */
1015
1058
  signal?: AbortSignal | null;
1016
1059
  }
1017
1060
  declare abstract class Fetcher {
1018
- fetch(
1019
- input: RequestInfo,
1020
- init?: RequestInit<RequestInitCfProperties>
1021
- ): Promise<Response>;
1061
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1062
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1022
1063
  }
1023
1064
  declare interface FetcherPutOptions {
1024
1065
  expiration?: number;
@@ -1131,6 +1172,33 @@ declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1131
1172
  value: Value | null;
1132
1173
  metadata: Metadata | null;
1133
1174
  }
1175
+ declare interface Queue<Body> {
1176
+ send(message: Body): Promise<void>;
1177
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1178
+ }
1179
+ declare interface QueueSendOptions {}
1180
+ declare interface MessageSendRequest<Body = unknown> {
1181
+ body: Body;
1182
+ }
1183
+ declare interface Message<Body = unknown> {
1184
+ readonly id: string;
1185
+ readonly timestamp: Date;
1186
+ readonly body: Body;
1187
+ retry(): void;
1188
+ ack(): void;
1189
+ }
1190
+ declare interface QueueEvent<Body = unknown> extends ExtendableEvent {
1191
+ readonly messages: readonly Message<Body>[];
1192
+ readonly queue: string;
1193
+ retryAll(): void;
1194
+ ackAll(): void;
1195
+ }
1196
+ declare interface MessageBatch<Body = unknown> {
1197
+ readonly messages: readonly Message<Body>[];
1198
+ readonly queue: string;
1199
+ retryAll(): void;
1200
+ ackAll(): void;
1201
+ }
1134
1202
  declare interface R2Error extends Error {
1135
1203
  readonly name: string;
1136
1204
  readonly code: number;
@@ -1281,12 +1349,18 @@ declare interface R2HTTPMetadata {
1281
1349
  cacheControl?: string;
1282
1350
  cacheExpiry?: Date;
1283
1351
  }
1284
- declare interface R2Objects {
1352
+ declare type R2Objects = {
1285
1353
  objects: R2Object[];
1286
- truncated: boolean;
1287
- cursor?: string;
1288
1354
  delimitedPrefixes: string[];
1289
- }
1355
+ } & (
1356
+ | {
1357
+ truncated: true;
1358
+ cursor: string;
1359
+ }
1360
+ | {
1361
+ truncated: false;
1362
+ }
1363
+ );
1290
1364
  declare abstract class ScheduledEvent extends ExtendableEvent {
1291
1365
  readonly scheduledTime: number;
1292
1366
  readonly cron: string;
@@ -1497,13 +1571,19 @@ declare class TransformStream<I = any, O = any> {
1497
1571
  get writable(): WritableStream<I>;
1498
1572
  }
1499
1573
  declare class FixedLengthStream extends IdentityTransformStream {
1500
- constructor(expectedLength: number | bigint);
1574
+ constructor(
1575
+ expectedLength: number | bigint,
1576
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1577
+ );
1501
1578
  }
1502
1579
  declare class IdentityTransformStream extends TransformStream<
1503
1580
  ArrayBuffer | ArrayBufferView,
1504
1581
  Uint8Array
1505
1582
  > {
1506
- constructor();
1583
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1584
+ }
1585
+ declare interface IdentityTransformStreamQueuingStrategy {
1586
+ highWaterMark?: number | bigint;
1507
1587
  }
1508
1588
  declare interface ReadableStreamValuesOptions {
1509
1589
  preventCancel?: boolean;
@@ -1552,7 +1632,8 @@ declare interface QueuingStrategyInit {
1552
1632
  */
1553
1633
  highWaterMark: number;
1554
1634
  }
1555
- declare abstract class TraceEvent extends ExtendableEvent {
1635
+ declare abstract class TailEvent extends ExtendableEvent {
1636
+ readonly events: TraceItem[];
1556
1637
  readonly traces: TraceItem[];
1557
1638
  }
1558
1639
  declare interface TraceItem {
@@ -1762,6 +1843,8 @@ declare class WebSocket extends EventTarget<WebSocketEventMap> {
1762
1843
  accept(): void;
1763
1844
  send(message: (ArrayBuffer | ArrayBufferView) | string): void;
1764
1845
  close(code?: number, reason?: string): void;
1846
+ serializeAttachment(attachment: any): void;
1847
+ deserializeAttachment(): any | null;
1765
1848
  static readonly READY_STATE_CONNECTING: number;
1766
1849
  static readonly READY_STATE_OPEN: number;
1767
1850
  static readonly READY_STATE_CLOSING: number;
@@ -1777,6 +1860,24 @@ declare const WebSocketPair: {
1777
1860
  1: WebSocket;
1778
1861
  };
1779
1862
  };
1863
+ declare interface Socket {
1864
+ get readable(): ReadableStream;
1865
+ get writable(): WritableStream;
1866
+ get closed(): Promise<void>;
1867
+ close(): Promise<void>;
1868
+ startTls(options?: TlsOptions): Socket;
1869
+ }
1870
+ declare interface SocketOptions {
1871
+ secureTransport?: string;
1872
+ allowHalfOpen: boolean;
1873
+ }
1874
+ declare interface SocketAddress {
1875
+ hostname: string;
1876
+ port: number;
1877
+ }
1878
+ declare interface TlsOptions {
1879
+ expectedServerHostname?: string;
1880
+ }
1780
1881
  declare interface BasicImageTransformations {
1781
1882
  /**
1782
1883
  * Maximum width in image pixels. The value must be an integer.
@@ -1856,7 +1957,7 @@ declare interface BasicImageTransformationsGravityCoordinates {
1856
1957
  * Note: Currently, these properties cannot be tested in the
1857
1958
  * playground.
1858
1959
  */
1859
- declare interface RequestInitCfProperties {
1960
+ declare interface RequestInitCfProperties extends Record<string, unknown> {
1860
1961
  cacheEverything?: boolean;
1861
1962
  /**
1862
1963
  * A request's cache key is what determines if two requests are
@@ -2026,6 +2127,49 @@ declare interface RequestInitCfPropertiesImage
2026
2127
  * the origin.
2027
2128
  */
2028
2129
  "origin-auth"?: "share-publicly";
2130
+ /**
2131
+ * Adds a border around the image. The border is added after resizing. Border
2132
+ * width takes dpr into account, and can be specified either using a single
2133
+ * width property, or individually for each side.
2134
+ */
2135
+ border?:
2136
+ | {
2137
+ color: string;
2138
+ width: number;
2139
+ }
2140
+ | {
2141
+ color: string;
2142
+ top: number;
2143
+ right: number;
2144
+ bottom: number;
2145
+ left: number;
2146
+ };
2147
+ /**
2148
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2149
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2150
+ * 0 is ignored.
2151
+ */
2152
+ brightness?: number;
2153
+ /**
2154
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2155
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2156
+ * ignored.
2157
+ */
2158
+ contrast?: number;
2159
+ /**
2160
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2161
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2162
+ */
2163
+ gamma?: number;
2164
+ /**
2165
+ * Slightly reduces latency on a cache miss by selecting a
2166
+ * quickest-to-compress file format, at a cost of increased file size and
2167
+ * lower image quality. It will usually override the format option and choose
2168
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2169
+ * unusual circumstances like resizing uncacheable dynamically-generated
2170
+ * images.
2171
+ */
2172
+ compression?: "fast";
2029
2173
  }
2030
2174
  declare interface RequestInitCfPropertiesImageMinify {
2031
2175
  javascript?: boolean;
@@ -2041,7 +2185,8 @@ declare type IncomingRequestCfProperties<HostMetadata = unknown> =
2041
2185
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2042
2186
  IncomingRequestCfPropertiesGeographicInformation &
2043
2187
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2044
- declare interface IncomingRequestCfPropertiesBase {
2188
+ declare interface IncomingRequestCfPropertiesBase
2189
+ extends Record<string, unknown> {
2045
2190
  /**
2046
2191
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2047
2192
  *
@@ -2122,8 +2267,7 @@ declare interface IncomingRequestCfPropertiesBase {
2122
2267
  declare interface IncomingRequestCfPropertiesBotManagementBase {
2123
2268
  /**
2124
2269
  * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2125
- * represented as an integer percentage between `1` (almost certainly human)
2126
- * and `99` (almost certainly a bot).
2270
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2127
2271
  *
2128
2272
  * @example 54
2129
2273
  */
@@ -2234,86 +2378,82 @@ declare interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2234
2378
  /**
2235
2379
  * Geographic data about the request's origin.
2236
2380
  */
2237
- declare type IncomingRequestCfPropertiesGeographicInformation =
2238
- | {}
2239
- | {
2240
- /** The country code `"T1"` is used for requests originating on TOR */
2241
- country: "T1";
2242
- }
2243
- | {
2244
- /**
2245
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2246
- *
2247
- * 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.
2248
- *
2249
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2250
- *
2251
- * @example "GB"
2252
- */
2253
- country: Iso3166Alpha2Code;
2254
- /**
2255
- * If present, this property indicates that the request originated in the EU
2256
- *
2257
- * @example "1"
2258
- */
2259
- isEUCountry?: "1";
2260
- /**
2261
- * A two-letter code indicating the continent the request originated from.
2262
- *
2263
- * @example "AN"
2264
- */
2265
- continent: ContinentCode;
2266
- /**
2267
- * The city the request originated from
2268
- *
2269
- * @example "Austin"
2270
- */
2271
- city?: string;
2272
- /**
2273
- * Postal code of the incoming request
2274
- *
2275
- * @example "78701"
2276
- */
2277
- postalCode?: string;
2278
- /**
2279
- * Latitude of the incoming request
2280
- *
2281
- * @example "30.27130"
2282
- */
2283
- latitude?: string;
2284
- /**
2285
- * Longitude of the incoming request
2286
- *
2287
- * @example "-97.74260"
2288
- */
2289
- longitude?: string;
2290
- /**
2291
- * Timezone of the incoming request
2292
- *
2293
- * @example "America/Chicago"
2294
- */
2295
- timezone?: string;
2296
- /**
2297
- * If known, the ISO 3166-2 name for the first level region associated with
2298
- * the IP address of the incoming request
2299
- *
2300
- * @example "Texas"
2301
- */
2302
- region?: string;
2303
- /**
2304
- * If known, the ISO 3166-2 code for the first-level region associated with
2305
- * the IP address of the incoming request
2306
- *
2307
- * @example "TX"
2308
- */
2309
- regionCode?: string;
2310
- /**
2311
- * Metro code (DMA) of the incoming request
2312
- *
2313
- * @example "635"
2314
- */
2315
- metroCode?: string;
2316
- };
2381
+ declare interface IncomingRequestCfPropertiesGeographicInformation {
2382
+ /**
2383
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2384
+ *
2385
+ * 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.
2386
+ *
2387
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2388
+ *
2389
+ * The country code `"T1"` is used for requests originating on TOR.
2390
+ *
2391
+ * @example "GB"
2392
+ */
2393
+ country?: Iso3166Alpha2Code | "T1";
2394
+ /**
2395
+ * If present, this property indicates that the request originated in the EU
2396
+ *
2397
+ * @example "1"
2398
+ */
2399
+ isEUCountry?: "1";
2400
+ /**
2401
+ * A two-letter code indicating the continent the request originated from.
2402
+ *
2403
+ * @example "AN"
2404
+ */
2405
+ continent?: ContinentCode;
2406
+ /**
2407
+ * The city the request originated from
2408
+ *
2409
+ * @example "Austin"
2410
+ */
2411
+ city?: string;
2412
+ /**
2413
+ * Postal code of the incoming request
2414
+ *
2415
+ * @example "78701"
2416
+ */
2417
+ postalCode?: string;
2418
+ /**
2419
+ * Latitude of the incoming request
2420
+ *
2421
+ * @example "30.27130"
2422
+ */
2423
+ latitude?: string;
2424
+ /**
2425
+ * Longitude of the incoming request
2426
+ *
2427
+ * @example "-97.74260"
2428
+ */
2429
+ longitude?: string;
2430
+ /**
2431
+ * Timezone of the incoming request
2432
+ *
2433
+ * @example "America/Chicago"
2434
+ */
2435
+ timezone?: string;
2436
+ /**
2437
+ * If known, the ISO 3166-2 name for the first level region associated with
2438
+ * the IP address of the incoming request
2439
+ *
2440
+ * @example "Texas"
2441
+ */
2442
+ region?: string;
2443
+ /**
2444
+ * If known, the ISO 3166-2 code for the first-level region associated with
2445
+ * the IP address of the incoming request
2446
+ *
2447
+ * @example "TX"
2448
+ */
2449
+ regionCode?: string;
2450
+ /**
2451
+ * Metro code (DMA) of the incoming request
2452
+ *
2453
+ * @example "635"
2454
+ */
2455
+ metroCode?: string;
2456
+ }
2317
2457
  /** Data about the incoming request's TLS certificate */
2318
2458
  declare interface IncomingRequestCfPropertiesTLSClientAuth {
2319
2459
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2706,6 +2846,9 @@ declare type Iso3166Alpha2Code =
2706
2846
  | "ZW";
2707
2847
  /** The 2-letter continent codes Cloudflare uses */
2708
2848
  declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2849
+ declare type CfProperties<HostMetadata = unknown> =
2850
+ | IncomingRequestCfProperties<HostMetadata>
2851
+ | RequestInitCfProperties;
2709
2852
  declare interface D1Result<T = unknown> {
2710
2853
  results?: T[];
2711
2854
  success: boolean;
@@ -2726,7 +2869,7 @@ declare abstract class D1PreparedStatement {
2726
2869
  raw<T = unknown>(): Promise<T[]>;
2727
2870
  }
2728
2871
  /**
2729
- * A email message that is sent to a consumer Worker.
2872
+ * An email message that can be sent from a Worker.
2730
2873
  */
2731
2874
  declare interface EmailMessage {
2732
2875
  /**
@@ -2737,14 +2880,19 @@ declare interface EmailMessage {
2737
2880
  * Envelope To attribute of the email message.
2738
2881
  */
2739
2882
  readonly to: string;
2740
- /**
2741
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2742
- */
2743
- readonly headers: Headers;
2883
+ }
2884
+ /**
2885
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2886
+ */
2887
+ declare interface ForwardableEmailMessage extends EmailMessage {
2744
2888
  /**
2745
2889
  * Stream of the email message content.
2746
2890
  */
2747
2891
  readonly raw: ReadableStream;
2892
+ /**
2893
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2894
+ */
2895
+ readonly headers: Headers;
2748
2896
  /**
2749
2897
  * Size of the email message content.
2750
2898
  */
@@ -2763,14 +2911,27 @@ declare interface EmailMessage {
2763
2911
  */
2764
2912
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2765
2913
  }
2914
+ /**
2915
+ * A binding that allows a Worker to send email messages.
2916
+ */
2917
+ declare interface SendEmail {
2918
+ send(message: EmailMessage): Promise<void>;
2919
+ }
2766
2920
  declare abstract class EmailEvent extends ExtendableEvent {
2767
- readonly message: EmailMessage;
2921
+ readonly message: ForwardableEmailMessage;
2768
2922
  }
2769
2923
  declare type EmailExportedHandler<Env = unknown> = (
2770
- message: EmailMessage,
2924
+ message: ForwardableEmailMessage,
2771
2925
  env: Env,
2772
2926
  ctx: ExecutionContext
2773
2927
  ) => void | Promise<void>;
2928
+ declare module "cloudflare:email" {
2929
+ let _EmailMessage: {
2930
+ prototype: EmailMessage;
2931
+ new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
2932
+ };
2933
+ export { _EmailMessage as EmailMessage };
2934
+ }
2774
2935
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2775
2936
  declare type EventContext<Env, P extends string, Data> = {
2776
2937
  request: Request;
@@ -2851,75 +3012,12 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
2851
3012
  // Key Identifier of the JWK
2852
3013
  readonly kid: string;
2853
3014
  }
2854
- /**
2855
- * A message that is sent to a consumer Worker.
2856
- */
2857
- declare interface Message<Body = unknown> {
2858
- /**
2859
- * A unique, system-generated ID for the message.
2860
- */
2861
- readonly id: string;
3015
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3016
+ declare interface DispatchNamespace {
2862
3017
  /**
2863
- * A timestamp when the message was sent.
3018
+ * @param name Name of the Worker script.
3019
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
3020
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2864
3021
  */
2865
- readonly timestamp: Date;
2866
- /**
2867
- * The body of the message.
2868
- */
2869
- readonly body: Body;
2870
- /**
2871
- * Marks message to be retried.
2872
- */
2873
- retry(): void;
2874
- /**
2875
- * Marks message acknowledged.
2876
- */
2877
- ack(): void;
2878
- }
2879
- /**
2880
- * A batch of messages that are sent to a consumer Worker.
2881
- */
2882
- declare interface MessageBatch<Body = unknown> {
2883
- /**
2884
- * The name of the Queue that belongs to this batch.
2885
- */
2886
- readonly queue: string;
2887
- /**
2888
- * An array of messages in the batch. Ordering of messages is not guaranteed.
2889
- */
2890
- readonly messages: readonly Message<Body>[];
2891
- /**
2892
- * Marks every message to be retried in the next batch.
2893
- */
2894
- retryAll(): void;
2895
- /**
2896
- * Marks every message acknowledged in the batch.
2897
- */
2898
- ackAll(): void;
2899
- }
2900
- /**
2901
- * A wrapper class used to structure message batches.
2902
- */
2903
- declare type MessageSendRequest<Body = unknown> = {
2904
- /**
2905
- * The body of the message.
2906
- */
2907
- body: Body;
2908
- };
2909
- /**
2910
- * A binding that allows a producer to send messages to a Queue.
2911
- */
2912
- declare interface Queue<Body = any> {
2913
- /**
2914
- * Sends a message to the Queue.
2915
- * @param message The message can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types), as long as its size is less than 128 KB.
2916
- * @returns A promise that resolves when the message is confirmed to be written to disk.
2917
- */
2918
- send(message: Body): Promise<void>;
2919
- /**
2920
- * Sends a batch of messages to the Queue.
2921
- * @param messages Each item in the input must be supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types). A batch can contain up to 100 messages, though items are limited to 128 KB each, and the total size of the array cannot exceed 256 KB.
2922
- * @returns A promise that resolves when the messages are confirmed to be written to disk.
2923
- */
2924
- sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
3022
+ get(name: string): Fetcher;
2925
3023
  }