@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 @@ export declare class DOMException extends Error {
49
49
  export 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 @@ export 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;
@@ -283,17 +287,27 @@ export declare const self: ServiceWorkerGlobalScope;
283
287
  export declare const crypto: Crypto;
284
288
  export declare const caches: CacheStorage;
285
289
  export declare const scheduler: Scheduler;
290
+ export declare const performance: Performance;
291
+ export declare const origin: string;
286
292
  export declare const navigator: Navigator;
287
293
  export interface TestController {}
288
294
  export interface ExecutionContext {
289
295
  waitUntil(promise: Promise<any>): void;
290
296
  passThroughOnException(): void;
291
297
  }
292
- export type ExportedHandlerFetchHandler<Env = unknown> = (
293
- request: Request,
298
+ export type ExportedHandlerFetchHandler<
299
+ Env = unknown,
300
+ CfHostMetadata = unknown
301
+ > = (
302
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
294
303
  env: Env,
295
304
  ctx: ExecutionContext
296
305
  ) => Response | Promise<Response>;
306
+ export type ExportedHandlerTailHandler<Env = unknown> = (
307
+ events: TraceItem[],
308
+ env: Env,
309
+ ctx: ExecutionContext
310
+ ) => void | Promise<void>;
297
311
  export type ExportedHandlerTraceHandler<Env = unknown> = (
298
312
  traces: TraceItem[],
299
313
  env: Env,
@@ -314,12 +328,17 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
314
328
  env: Env,
315
329
  ctx: ExecutionContext
316
330
  ) => void | Promise<void>;
317
- export interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
318
- fetch?: ExportedHandlerFetchHandler<Env>;
331
+ export interface ExportedHandler<
332
+ Env = unknown,
333
+ QueueMessage = unknown,
334
+ CfHostMetadata = unknown
335
+ > {
336
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
337
+ tail?: ExportedHandlerTailHandler<Env>;
319
338
  trace?: ExportedHandlerTraceHandler<Env>;
320
339
  scheduled?: ExportedHandlerScheduledHandler<Env>;
321
340
  test?: ExportedHandlerTestHandler<Env>;
322
- queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
341
+ queue?: ExportedHandlerQueueHandler<Env, Message>;
323
342
  }
324
343
  export interface StructuredSerializeOptions {
325
344
  transfer?: any[];
@@ -331,6 +350,11 @@ export declare abstract class PromiseRejectionEvent extends Event {
331
350
  export declare abstract class Navigator {
332
351
  readonly userAgent: string;
333
352
  }
353
+ /** 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. */
354
+ export interface Performance {
355
+ readonly timeOrigin: number;
356
+ now(): number;
357
+ }
334
358
  export interface DurableObject {
335
359
  fetch(request: Request): Response | Promise<Response>;
336
360
  alarm?(): void | Promise<void>;
@@ -354,19 +378,32 @@ export interface DurableObjectNamespace {
354
378
  id: DurableObjectId,
355
379
  options?: DurableObjectNamespaceGetDurableObjectOptions
356
380
  ): DurableObjectStub;
357
- jurisdiction(jurisdiction: string): DurableObjectNamespace;
381
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
358
382
  }
383
+ export type DurableObjectJurisdiction = "eu" | "fedramp";
359
384
  export interface DurableObjectNamespaceNewUniqueIdOptions {
360
- jurisdiction?: string;
361
- }
385
+ jurisdiction?: DurableObjectJurisdiction;
386
+ }
387
+ export type DurableObjectLocationHint =
388
+ | "wnam"
389
+ | "enam"
390
+ | "sam"
391
+ | "weur"
392
+ | "eeur"
393
+ | "apac"
394
+ | "oc"
395
+ | "afr"
396
+ | "me";
362
397
  export interface DurableObjectNamespaceGetDurableObjectOptions {
363
- locationHint?: string;
398
+ locationHint?: DurableObjectLocationHint;
364
399
  }
365
400
  export interface DurableObjectState {
366
401
  waitUntil(promise: Promise<any>): void;
367
402
  readonly id: DurableObjectId;
368
403
  readonly storage: DurableObjectStorage;
369
404
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
405
+ acceptWebSocket(ws: WebSocket, tags?: string[]): void;
406
+ getWebSockets(tag?: string): WebSocket[];
370
407
  }
371
408
  export interface DurableObjectTransaction {
372
409
  get<T = unknown>(
@@ -433,6 +470,7 @@ export interface DurableObjectStorage {
433
470
  ): Promise<void>;
434
471
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
435
472
  sync(): Promise<void>;
473
+ transactionSync<T>(closure: () => T): T;
436
474
  }
437
475
  export interface DurableObjectListOptions {
438
476
  start?: string;
@@ -542,6 +580,7 @@ export declare class AbortController {
542
580
  export declare abstract class AbortSignal extends EventTarget {
543
581
  static abort(reason?: any): AbortSignal;
544
582
  static timeout(delay: number): AbortSignal;
583
+ static any(signals: AbortSignal[]): AbortSignal;
545
584
  get aborted(): boolean;
546
585
  get reason(): any;
547
586
  throwIfAborted(): void;
@@ -990,23 +1029,27 @@ export interface ResponseInit {
990
1029
  webSocket?: WebSocket | null;
991
1030
  encodeBody?: "automatic" | "manual";
992
1031
  }
993
- export type RequestInfo = Request | string | URL;
994
- export declare class Request<CfHostMetadata = unknown> extends Body {
995
- constructor(input: RequestInfo, init?: RequestInit);
996
- clone(): Request<CfHostMetadata>;
1032
+ export type RequestInfo<
1033
+ CfHostMetadata = unknown,
1034
+ Cf = CfProperties<CfHostMetadata>
1035
+ > = Request<CfHostMetadata, Cf> | string | URL;
1036
+ export declare class Request<
1037
+ CfHostMetadata = unknown,
1038
+ Cf = CfProperties<CfHostMetadata>
1039
+ > extends Body {
1040
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1041
+ clone(): Request<CfHostMetadata, Cf>;
997
1042
  get method(): string;
998
1043
  get url(): string;
999
1044
  get headers(): Headers;
1000
1045
  get redirect(): string;
1001
1046
  get fetcher(): Fetcher | null;
1002
1047
  get signal(): AbortSignal;
1003
- get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
1048
+ get cf(): Cf | undefined;
1004
1049
  get integrity(): string;
1005
1050
  get keepalive(): boolean;
1006
1051
  }
1007
- export interface RequestInit<
1008
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1009
- > {
1052
+ export interface RequestInit<Cf = CfProperties> {
1010
1053
  /** A string to set request's method. */
1011
1054
  method?: string;
1012
1055
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1016,17 +1059,15 @@ export interface RequestInit<
1016
1059
  /** 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. */
1017
1060
  redirect?: string;
1018
1061
  fetcher?: Fetcher | null;
1019
- cf?: CfType;
1062
+ cf?: Cf;
1020
1063
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1021
1064
  integrity?: string;
1022
1065
  /** An AbortSignal to set request's signal. */
1023
1066
  signal?: AbortSignal | null;
1024
1067
  }
1025
1068
  export declare abstract class Fetcher {
1026
- fetch(
1027
- input: RequestInfo,
1028
- init?: RequestInit<RequestInitCfProperties>
1029
- ): Promise<Response>;
1069
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1070
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1030
1071
  }
1031
1072
  export interface FetcherPutOptions {
1032
1073
  expiration?: number;
@@ -1139,6 +1180,33 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1139
1180
  value: Value | null;
1140
1181
  metadata: Metadata | null;
1141
1182
  }
1183
+ export interface Queue<Body> {
1184
+ send(message: Body): Promise<void>;
1185
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1186
+ }
1187
+ export interface QueueSendOptions {}
1188
+ export interface MessageSendRequest<Body = unknown> {
1189
+ body: Body;
1190
+ }
1191
+ export interface Message<Body = unknown> {
1192
+ readonly id: string;
1193
+ readonly timestamp: Date;
1194
+ readonly body: Body;
1195
+ retry(): void;
1196
+ ack(): void;
1197
+ }
1198
+ export interface QueueEvent<Body = unknown> extends ExtendableEvent {
1199
+ readonly messages: readonly Message<Body>[];
1200
+ readonly queue: string;
1201
+ retryAll(): void;
1202
+ ackAll(): void;
1203
+ }
1204
+ export interface MessageBatch<Body = unknown> {
1205
+ readonly messages: readonly Message<Body>[];
1206
+ readonly queue: string;
1207
+ retryAll(): void;
1208
+ ackAll(): void;
1209
+ }
1142
1210
  export interface R2Error extends Error {
1143
1211
  readonly name: string;
1144
1212
  readonly code: number;
@@ -1289,12 +1357,18 @@ export interface R2HTTPMetadata {
1289
1357
  cacheControl?: string;
1290
1358
  cacheExpiry?: Date;
1291
1359
  }
1292
- export interface R2Objects {
1360
+ export type R2Objects = {
1293
1361
  objects: R2Object[];
1294
- truncated: boolean;
1295
- cursor?: string;
1296
1362
  delimitedPrefixes: string[];
1297
- }
1363
+ } & (
1364
+ | {
1365
+ truncated: true;
1366
+ cursor: string;
1367
+ }
1368
+ | {
1369
+ truncated: false;
1370
+ }
1371
+ );
1298
1372
  export declare abstract class ScheduledEvent extends ExtendableEvent {
1299
1373
  readonly scheduledTime: number;
1300
1374
  readonly cron: string;
@@ -1505,13 +1579,19 @@ export declare class TransformStream<I = any, O = any> {
1505
1579
  get writable(): WritableStream<I>;
1506
1580
  }
1507
1581
  export declare class FixedLengthStream extends IdentityTransformStream {
1508
- constructor(expectedLength: number | bigint);
1582
+ constructor(
1583
+ expectedLength: number | bigint,
1584
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1585
+ );
1509
1586
  }
1510
1587
  export declare class IdentityTransformStream extends TransformStream<
1511
1588
  ArrayBuffer | ArrayBufferView,
1512
1589
  Uint8Array
1513
1590
  > {
1514
- constructor();
1591
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1592
+ }
1593
+ export interface IdentityTransformStreamQueuingStrategy {
1594
+ highWaterMark?: number | bigint;
1515
1595
  }
1516
1596
  export interface ReadableStreamValuesOptions {
1517
1597
  preventCancel?: boolean;
@@ -1563,7 +1643,8 @@ export interface QueuingStrategyInit {
1563
1643
  */
1564
1644
  highWaterMark: number;
1565
1645
  }
1566
- export declare abstract class TraceEvent extends ExtendableEvent {
1646
+ export declare abstract class TailEvent extends ExtendableEvent {
1647
+ readonly events: TraceItem[];
1567
1648
  readonly traces: TraceItem[];
1568
1649
  }
1569
1650
  export interface TraceItem {
@@ -1773,6 +1854,8 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
1773
1854
  accept(): void;
1774
1855
  send(message: (ArrayBuffer | ArrayBufferView) | string): void;
1775
1856
  close(code?: number, reason?: string): void;
1857
+ serializeAttachment(attachment: any): void;
1858
+ deserializeAttachment(): any | null;
1776
1859
  static readonly READY_STATE_CONNECTING: number;
1777
1860
  static readonly READY_STATE_OPEN: number;
1778
1861
  static readonly READY_STATE_CLOSING: number;
@@ -1788,6 +1871,24 @@ export declare const WebSocketPair: {
1788
1871
  1: WebSocket;
1789
1872
  };
1790
1873
  };
1874
+ export interface Socket {
1875
+ get readable(): ReadableStream;
1876
+ get writable(): WritableStream;
1877
+ get closed(): Promise<void>;
1878
+ close(): Promise<void>;
1879
+ startTls(options?: TlsOptions): Socket;
1880
+ }
1881
+ export interface SocketOptions {
1882
+ secureTransport?: string;
1883
+ allowHalfOpen: boolean;
1884
+ }
1885
+ export interface SocketAddress {
1886
+ hostname: string;
1887
+ port: number;
1888
+ }
1889
+ export interface TlsOptions {
1890
+ expectedServerHostname?: string;
1891
+ }
1791
1892
  export interface BasicImageTransformations {
1792
1893
  /**
1793
1894
  * Maximum width in image pixels. The value must be an integer.
@@ -1867,7 +1968,7 @@ export interface BasicImageTransformationsGravityCoordinates {
1867
1968
  * Note: Currently, these properties cannot be tested in the
1868
1969
  * playground.
1869
1970
  */
1870
- export interface RequestInitCfProperties {
1971
+ export interface RequestInitCfProperties extends Record<string, unknown> {
1871
1972
  cacheEverything?: boolean;
1872
1973
  /**
1873
1974
  * A request's cache key is what determines if two requests are
@@ -2037,6 +2138,49 @@ export interface RequestInitCfPropertiesImage
2037
2138
  * the origin.
2038
2139
  */
2039
2140
  "origin-auth"?: "share-publicly";
2141
+ /**
2142
+ * Adds a border around the image. The border is added after resizing. Border
2143
+ * width takes dpr into account, and can be specified either using a single
2144
+ * width property, or individually for each side.
2145
+ */
2146
+ border?:
2147
+ | {
2148
+ color: string;
2149
+ width: number;
2150
+ }
2151
+ | {
2152
+ color: string;
2153
+ top: number;
2154
+ right: number;
2155
+ bottom: number;
2156
+ left: number;
2157
+ };
2158
+ /**
2159
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2160
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2161
+ * 0 is ignored.
2162
+ */
2163
+ brightness?: number;
2164
+ /**
2165
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2166
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2167
+ * ignored.
2168
+ */
2169
+ contrast?: number;
2170
+ /**
2171
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2172
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2173
+ */
2174
+ gamma?: number;
2175
+ /**
2176
+ * Slightly reduces latency on a cache miss by selecting a
2177
+ * quickest-to-compress file format, at a cost of increased file size and
2178
+ * lower image quality. It will usually override the format option and choose
2179
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2180
+ * unusual circumstances like resizing uncacheable dynamically-generated
2181
+ * images.
2182
+ */
2183
+ compression?: "fast";
2040
2184
  }
2041
2185
  export interface RequestInitCfPropertiesImageMinify {
2042
2186
  javascript?: boolean;
@@ -2052,7 +2196,8 @@ export type IncomingRequestCfProperties<HostMetadata = unknown> =
2052
2196
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2053
2197
  IncomingRequestCfPropertiesGeographicInformation &
2054
2198
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2055
- export interface IncomingRequestCfPropertiesBase {
2199
+ export interface IncomingRequestCfPropertiesBase
2200
+ extends Record<string, unknown> {
2056
2201
  /**
2057
2202
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2058
2203
  *
@@ -2133,8 +2278,7 @@ export interface IncomingRequestCfPropertiesBase {
2133
2278
  export interface IncomingRequestCfPropertiesBotManagementBase {
2134
2279
  /**
2135
2280
  * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2136
- * represented as an integer percentage between `1` (almost certainly human)
2137
- * and `99` (almost certainly a bot).
2281
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2138
2282
  *
2139
2283
  * @example 54
2140
2284
  */
@@ -2245,86 +2389,82 @@ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2245
2389
  /**
2246
2390
  * Geographic data about the request's origin.
2247
2391
  */
2248
- export type IncomingRequestCfPropertiesGeographicInformation =
2249
- | {}
2250
- | {
2251
- /** The country code `"T1"` is used for requests originating on TOR */
2252
- country: "T1";
2253
- }
2254
- | {
2255
- /**
2256
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2257
- *
2258
- * 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.
2259
- *
2260
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2261
- *
2262
- * @example "GB"
2263
- */
2264
- country: Iso3166Alpha2Code;
2265
- /**
2266
- * If present, this property indicates that the request originated in the EU
2267
- *
2268
- * @example "1"
2269
- */
2270
- isEUCountry?: "1";
2271
- /**
2272
- * A two-letter code indicating the continent the request originated from.
2273
- *
2274
- * @example "AN"
2275
- */
2276
- continent: ContinentCode;
2277
- /**
2278
- * The city the request originated from
2279
- *
2280
- * @example "Austin"
2281
- */
2282
- city?: string;
2283
- /**
2284
- * Postal code of the incoming request
2285
- *
2286
- * @example "78701"
2287
- */
2288
- postalCode?: string;
2289
- /**
2290
- * Latitude of the incoming request
2291
- *
2292
- * @example "30.27130"
2293
- */
2294
- latitude?: string;
2295
- /**
2296
- * Longitude of the incoming request
2297
- *
2298
- * @example "-97.74260"
2299
- */
2300
- longitude?: string;
2301
- /**
2302
- * Timezone of the incoming request
2303
- *
2304
- * @example "America/Chicago"
2305
- */
2306
- timezone?: string;
2307
- /**
2308
- * If known, the ISO 3166-2 name for the first level region associated with
2309
- * the IP address of the incoming request
2310
- *
2311
- * @example "Texas"
2312
- */
2313
- region?: string;
2314
- /**
2315
- * If known, the ISO 3166-2 code for the first-level region associated with
2316
- * the IP address of the incoming request
2317
- *
2318
- * @example "TX"
2319
- */
2320
- regionCode?: string;
2321
- /**
2322
- * Metro code (DMA) of the incoming request
2323
- *
2324
- * @example "635"
2325
- */
2326
- metroCode?: string;
2327
- };
2392
+ export interface IncomingRequestCfPropertiesGeographicInformation {
2393
+ /**
2394
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2395
+ *
2396
+ * 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.
2397
+ *
2398
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2399
+ *
2400
+ * The country code `"T1"` is used for requests originating on TOR.
2401
+ *
2402
+ * @example "GB"
2403
+ */
2404
+ country?: Iso3166Alpha2Code | "T1";
2405
+ /**
2406
+ * If present, this property indicates that the request originated in the EU
2407
+ *
2408
+ * @example "1"
2409
+ */
2410
+ isEUCountry?: "1";
2411
+ /**
2412
+ * A two-letter code indicating the continent the request originated from.
2413
+ *
2414
+ * @example "AN"
2415
+ */
2416
+ continent?: ContinentCode;
2417
+ /**
2418
+ * The city the request originated from
2419
+ *
2420
+ * @example "Austin"
2421
+ */
2422
+ city?: string;
2423
+ /**
2424
+ * Postal code of the incoming request
2425
+ *
2426
+ * @example "78701"
2427
+ */
2428
+ postalCode?: string;
2429
+ /**
2430
+ * Latitude of the incoming request
2431
+ *
2432
+ * @example "30.27130"
2433
+ */
2434
+ latitude?: string;
2435
+ /**
2436
+ * Longitude of the incoming request
2437
+ *
2438
+ * @example "-97.74260"
2439
+ */
2440
+ longitude?: string;
2441
+ /**
2442
+ * Timezone of the incoming request
2443
+ *
2444
+ * @example "America/Chicago"
2445
+ */
2446
+ timezone?: string;
2447
+ /**
2448
+ * If known, the ISO 3166-2 name for the first level region associated with
2449
+ * the IP address of the incoming request
2450
+ *
2451
+ * @example "Texas"
2452
+ */
2453
+ region?: string;
2454
+ /**
2455
+ * If known, the ISO 3166-2 code for the first-level region associated with
2456
+ * the IP address of the incoming request
2457
+ *
2458
+ * @example "TX"
2459
+ */
2460
+ regionCode?: string;
2461
+ /**
2462
+ * Metro code (DMA) of the incoming request
2463
+ *
2464
+ * @example "635"
2465
+ */
2466
+ metroCode?: string;
2467
+ }
2328
2468
  /** Data about the incoming request's TLS certificate */
2329
2469
  export interface IncomingRequestCfPropertiesTLSClientAuth {
2330
2470
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2717,6 +2857,9 @@ export type Iso3166Alpha2Code =
2717
2857
  | "ZW";
2718
2858
  /** The 2-letter continent codes Cloudflare uses */
2719
2859
  export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2860
+ export type CfProperties<HostMetadata = unknown> =
2861
+ | IncomingRequestCfProperties<HostMetadata>
2862
+ | RequestInitCfProperties;
2720
2863
  export interface D1Result<T = unknown> {
2721
2864
  results?: T[];
2722
2865
  success: boolean;
@@ -2737,7 +2880,7 @@ export declare abstract class D1PreparedStatement {
2737
2880
  raw<T = unknown>(): Promise<T[]>;
2738
2881
  }
2739
2882
  /**
2740
- * A email message that is sent to a consumer Worker.
2883
+ * An email message that can be sent from a Worker.
2741
2884
  */
2742
2885
  export interface EmailMessage {
2743
2886
  /**
@@ -2748,14 +2891,19 @@ export interface EmailMessage {
2748
2891
  * Envelope To attribute of the email message.
2749
2892
  */
2750
2893
  readonly to: string;
2751
- /**
2752
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2753
- */
2754
- readonly headers: Headers;
2894
+ }
2895
+ /**
2896
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2897
+ */
2898
+ export interface ForwardableEmailMessage extends EmailMessage {
2755
2899
  /**
2756
2900
  * Stream of the email message content.
2757
2901
  */
2758
2902
  readonly raw: ReadableStream;
2903
+ /**
2904
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2905
+ */
2906
+ readonly headers: Headers;
2759
2907
  /**
2760
2908
  * Size of the email message content.
2761
2909
  */
@@ -2774,11 +2922,17 @@ export interface EmailMessage {
2774
2922
  */
2775
2923
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2776
2924
  }
2925
+ /**
2926
+ * A binding that allows a Worker to send email messages.
2927
+ */
2928
+ export interface SendEmail {
2929
+ send(message: EmailMessage): Promise<void>;
2930
+ }
2777
2931
  export declare abstract class EmailEvent extends ExtendableEvent {
2778
- readonly message: EmailMessage;
2932
+ readonly message: ForwardableEmailMessage;
2779
2933
  }
2780
2934
  export type EmailExportedHandler<Env = unknown> = (
2781
- message: EmailMessage,
2935
+ message: ForwardableEmailMessage,
2782
2936
  env: Env,
2783
2937
  ctx: ExecutionContext
2784
2938
  ) => void | Promise<void>;
@@ -2859,75 +3013,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
2859
3013
  // Key Identifier of the JWK
2860
3014
  readonly kid: string;
2861
3015
  }
2862
- /**
2863
- * A message that is sent to a consumer Worker.
2864
- */
2865
- export interface Message<Body = unknown> {
2866
- /**
2867
- * A unique, system-generated ID for the message.
2868
- */
2869
- readonly id: string;
2870
- /**
2871
- * A timestamp when the message was sent.
2872
- */
2873
- readonly timestamp: Date;
2874
- /**
2875
- * The body of the message.
2876
- */
2877
- readonly body: Body;
2878
- /**
2879
- * Marks message to be retried.
2880
- */
2881
- retry(): void;
2882
- /**
2883
- * Marks message acknowledged.
2884
- */
2885
- ack(): void;
2886
- }
2887
- /**
2888
- * A batch of messages that are sent to a consumer Worker.
2889
- */
2890
- export interface MessageBatch<Body = unknown> {
3016
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3017
+ export interface DispatchNamespace {
2891
3018
  /**
2892
- * The name of the Queue that belongs to this batch.
3019
+ * @param name Name of the Worker script.
3020
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
3021
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2893
3022
  */
2894
- readonly queue: string;
2895
- /**
2896
- * An array of messages in the batch. Ordering of messages is not guaranteed.
2897
- */
2898
- readonly messages: readonly Message<Body>[];
2899
- /**
2900
- * Marks every message to be retried in the next batch.
2901
- */
2902
- retryAll(): void;
2903
- /**
2904
- * Marks every message acknowledged in the batch.
2905
- */
2906
- ackAll(): void;
2907
- }
2908
- /**
2909
- * A wrapper class used to structure message batches.
2910
- */
2911
- export type MessageSendRequest<Body = unknown> = {
2912
- /**
2913
- * The body of the message.
2914
- */
2915
- body: Body;
2916
- };
2917
- /**
2918
- * A binding that allows a producer to send messages to a Queue.
2919
- */
2920
- export interface Queue<Body = any> {
2921
- /**
2922
- * Sends a message to the Queue.
2923
- * @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.
2924
- * @returns A promise that resolves when the message is confirmed to be written to disk.
2925
- */
2926
- send(message: Body): Promise<void>;
2927
- /**
2928
- * Sends a batch of messages to the Queue.
2929
- * @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.
2930
- * @returns A promise that resolves when the messages are confirmed to be written to disk.
2931
- */
2932
- sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
3023
+ get(name: string): Fetcher;
2933
3024
  }