@cloudflare/workers-types 0.20230215.0 → 0.20230404.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
  };
@@ -286,12 +287,16 @@ declare const crypto: Crypto;
286
287
  declare const caches: CacheStorage;
287
288
  declare const scheduler: Scheduler;
288
289
  declare const navigator: Navigator;
290
+ declare interface TestController {}
289
291
  declare interface ExecutionContext {
290
292
  waitUntil(promise: Promise<any>): void;
291
293
  passThroughOnException(): void;
292
294
  }
293
- declare type ExportedHandlerFetchHandler<Env = unknown> = (
294
- request: Request,
295
+ declare type ExportedHandlerFetchHandler<
296
+ Env = unknown,
297
+ CfHostMetadata = unknown
298
+ > = (
299
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
295
300
  env: Env,
296
301
  ctx: ExecutionContext
297
302
  ) => Response | Promise<Response>;
@@ -310,11 +315,21 @@ declare type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
310
315
  env: Env,
311
316
  ctx: ExecutionContext
312
317
  ) => void | Promise<void>;
313
- declare interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
314
- fetch?: ExportedHandlerFetchHandler<Env>;
318
+ declare type ExportedHandlerTestHandler<Env = unknown> = (
319
+ controller: TestController,
320
+ env: Env,
321
+ ctx: ExecutionContext
322
+ ) => void | Promise<void>;
323
+ declare interface ExportedHandler<
324
+ Env = unknown,
325
+ QueueMessage = unknown,
326
+ CfHostMetadata = unknown
327
+ > {
328
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
315
329
  trace?: ExportedHandlerTraceHandler<Env>;
316
330
  scheduled?: ExportedHandlerScheduledHandler<Env>;
317
- queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
331
+ test?: ExportedHandlerTestHandler<Env>;
332
+ queue?: ExportedHandlerQueueHandler<Env, Message>;
318
333
  }
319
334
  declare interface StructuredSerializeOptions {
320
335
  transfer?: any[];
@@ -349,13 +364,28 @@ declare interface DurableObjectNamespace {
349
364
  id: DurableObjectId,
350
365
  options?: DurableObjectNamespaceGetDurableObjectOptions
351
366
  ): DurableObjectStub;
352
- jurisdiction(jurisdiction: string): DurableObjectNamespace;
367
+ getExisting(
368
+ id: DurableObjectId,
369
+ options?: DurableObjectNamespaceGetDurableObjectOptions
370
+ ): DurableObjectStub;
371
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
353
372
  }
373
+ declare type DurableObjectJurisdiction = "eu" | "fedramp";
354
374
  declare interface DurableObjectNamespaceNewUniqueIdOptions {
355
- jurisdiction?: string;
356
- }
375
+ jurisdiction?: DurableObjectJurisdiction;
376
+ }
377
+ declare type DurableObjectLocationHint =
378
+ | "wnam"
379
+ | "enam"
380
+ | "sam"
381
+ | "weur"
382
+ | "eeur"
383
+ | "apac"
384
+ | "oc"
385
+ | "afr"
386
+ | "me";
357
387
  declare interface DurableObjectNamespaceGetDurableObjectOptions {
358
- locationHint?: string;
388
+ locationHint?: DurableObjectLocationHint;
359
389
  }
360
390
  declare interface DurableObjectState {
361
391
  waitUntil(promise: Promise<any>): void;
@@ -428,6 +458,7 @@ declare interface DurableObjectStorage {
428
458
  ): Promise<void>;
429
459
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
430
460
  sync(): Promise<void>;
461
+ sql: SqlStorage;
431
462
  }
432
463
  declare interface DurableObjectListOptions {
433
464
  start?: string;
@@ -986,23 +1017,27 @@ declare interface ResponseInit {
986
1017
  webSocket?: WebSocket | null;
987
1018
  encodeBody?: "automatic" | "manual";
988
1019
  }
989
- declare type RequestInfo = Request | string | URL;
990
- declare class Request<CfHostMetadata = unknown> extends Body {
991
- constructor(input: RequestInfo, init?: RequestInit);
992
- clone(): Request<CfHostMetadata>;
1020
+ declare type RequestInfo<
1021
+ CfHostMetadata = unknown,
1022
+ Cf = CfProperties<CfHostMetadata>
1023
+ > = Request<CfHostMetadata, Cf> | string | URL;
1024
+ declare class Request<
1025
+ CfHostMetadata = unknown,
1026
+ Cf = CfProperties<CfHostMetadata>
1027
+ > extends Body {
1028
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1029
+ clone(): Request<CfHostMetadata, Cf>;
993
1030
  get method(): string;
994
1031
  get url(): string;
995
1032
  get headers(): Headers;
996
1033
  get redirect(): string;
997
1034
  get fetcher(): Fetcher | null;
998
1035
  get signal(): AbortSignal;
999
- get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
1036
+ get cf(): Cf | undefined;
1000
1037
  get integrity(): string;
1001
1038
  get keepalive(): boolean;
1002
1039
  }
1003
- declare interface RequestInit<
1004
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1005
- > {
1040
+ declare interface RequestInit<Cf = CfProperties> {
1006
1041
  /** A string to set request's method. */
1007
1042
  method?: string;
1008
1043
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1012,22 +1047,29 @@ declare interface RequestInit<
1012
1047
  /** 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. */
1013
1048
  redirect?: string;
1014
1049
  fetcher?: Fetcher | null;
1015
- cf?: CfType;
1050
+ cf?: Cf;
1016
1051
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1017
1052
  integrity?: string;
1018
1053
  /** An AbortSignal to set request's signal. */
1019
1054
  signal?: AbortSignal | null;
1020
1055
  }
1021
1056
  declare abstract class Fetcher {
1022
- fetch(
1023
- input: RequestInfo,
1024
- init?: RequestInit<RequestInitCfProperties>
1025
- ): Promise<Response>;
1057
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1058
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1059
+ queue(
1060
+ queueName: string,
1061
+ messages: ServiceBindingQueueMessage[]
1062
+ ): Promise<QueueResponse>;
1026
1063
  }
1027
1064
  declare interface FetcherPutOptions {
1028
1065
  expiration?: number;
1029
1066
  expirationTtl?: number;
1030
1067
  }
1068
+ declare interface ServiceBindingQueueMessage<Body = unknown> {
1069
+ id: string;
1070
+ timestamp: Date;
1071
+ body: Body;
1072
+ }
1031
1073
  declare interface KVNamespaceListKey<Metadata, Key extends string = string> {
1032
1074
  name: Key;
1033
1075
  expiration?: number;
@@ -1135,6 +1177,40 @@ declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1135
1177
  value: Value | null;
1136
1178
  metadata: Metadata | null;
1137
1179
  }
1180
+ declare interface Queue<Body> {
1181
+ send(message: Body): Promise<void>;
1182
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1183
+ }
1184
+ declare interface QueueSendOptions {}
1185
+ declare interface MessageSendRequest<Body = unknown> {
1186
+ body: Body;
1187
+ }
1188
+ declare interface QueueResponse {
1189
+ outcome: number;
1190
+ retryAll: boolean;
1191
+ ackAll: boolean;
1192
+ explicitRetries: string[];
1193
+ explicitAcks: string[];
1194
+ }
1195
+ declare interface Message<Body = unknown> {
1196
+ readonly id: string;
1197
+ readonly timestamp: Date;
1198
+ readonly body: Body;
1199
+ retry(): void;
1200
+ ack(): void;
1201
+ }
1202
+ declare interface QueueEvent<Body = unknown> extends ExtendableEvent {
1203
+ readonly messages: readonly Message<Body>[];
1204
+ readonly queue: string;
1205
+ retryAll(): void;
1206
+ ackAll(): void;
1207
+ }
1208
+ declare interface MessageBatch<Body = unknown> {
1209
+ readonly messages: readonly Message<Body>[];
1210
+ readonly queue: string;
1211
+ retryAll(): void;
1212
+ ackAll(): void;
1213
+ }
1138
1214
  declare interface R2Error extends Error {
1139
1215
  readonly name: string;
1140
1216
  readonly code: number;
@@ -1286,12 +1362,18 @@ declare interface R2HTTPMetadata {
1286
1362
  cacheControl?: string;
1287
1363
  cacheExpiry?: Date;
1288
1364
  }
1289
- declare interface R2Objects {
1365
+ declare type R2Objects = {
1290
1366
  objects: R2Object[];
1291
- truncated: boolean;
1292
- cursor?: string;
1293
1367
  delimitedPrefixes: string[];
1294
- }
1368
+ } & (
1369
+ | {
1370
+ truncated: true;
1371
+ cursor: string;
1372
+ }
1373
+ | {
1374
+ truncated: false;
1375
+ }
1376
+ );
1295
1377
  declare abstract class ScheduledEvent extends ExtendableEvent {
1296
1378
  readonly scheduledTime: number;
1297
1379
  readonly cron: string;
@@ -1501,13 +1583,19 @@ declare class TransformStream<I = any, O = any> {
1501
1583
  get writable(): WritableStream<I>;
1502
1584
  }
1503
1585
  declare class FixedLengthStream extends IdentityTransformStream {
1504
- constructor(expectedLength: number | bigint);
1586
+ constructor(
1587
+ expectedLength: number | bigint,
1588
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1589
+ );
1505
1590
  }
1506
1591
  declare class IdentityTransformStream extends TransformStream<
1507
1592
  ArrayBuffer | ArrayBufferView,
1508
1593
  Uint8Array
1509
1594
  > {
1510
- constructor();
1595
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1596
+ }
1597
+ declare interface IdentityTransformStreamQueuingStrategy {
1598
+ highWaterMark?: number | bigint;
1511
1599
  }
1512
1600
  declare interface ReadableStreamValuesOptions {
1513
1601
  preventCancel?: boolean;
@@ -1516,13 +1604,13 @@ declare class CompressionStream extends TransformStream<
1516
1604
  ArrayBuffer | ArrayBufferView,
1517
1605
  Uint8Array
1518
1606
  > {
1519
- constructor(format: "gzip" | "deflate");
1607
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1520
1608
  }
1521
1609
  declare class DecompressionStream extends TransformStream<
1522
1610
  ArrayBuffer | ArrayBufferView,
1523
1611
  Uint8Array
1524
1612
  > {
1525
- constructor(format: "gzip" | "deflate");
1613
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1526
1614
  }
1527
1615
  declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
1528
1616
  constructor();
@@ -1652,11 +1740,13 @@ declare class URL {
1652
1740
  get searchParams(): URLSearchParams;
1653
1741
  toJSON(): string;
1654
1742
  toString(): string;
1743
+ static canParse(url: string, base?: string): boolean;
1655
1744
  }
1656
1745
  declare class URLSearchParams {
1657
1746
  constructor(
1658
1747
  init?: Iterable<Iterable<string>> | Record<string, string> | string
1659
1748
  );
1749
+ get size(): number;
1660
1750
  append(name: string, value: string): void;
1661
1751
  delete(name: string): void;
1662
1752
  get(name: string): string | null;
@@ -1776,6 +1866,37 @@ declare const WebSocketPair: {
1776
1866
  1: WebSocket;
1777
1867
  };
1778
1868
  };
1869
+ declare interface SqlStorage {
1870
+ exec(query: string, ...bindings: any[]): SqlStorageCursor;
1871
+ prepare(query: string): SqlStorageStatement;
1872
+ Cursor: typeof SqlStorageCursor;
1873
+ Statement: typeof SqlStorageStatement;
1874
+ }
1875
+ declare abstract class SqlStorageStatement {}
1876
+ declare abstract class SqlStorageCursor {
1877
+ raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
1878
+ [Symbol.iterator](): IterableIterator<
1879
+ Record<string, (ArrayBuffer | string | number) | null>
1880
+ >;
1881
+ }
1882
+ declare interface Socket {
1883
+ get readable(): ReadableStream;
1884
+ get writable(): WritableStream;
1885
+ get closed(): Promise<void>;
1886
+ close(): Promise<void>;
1887
+ startTls(options?: TlsOptions): Socket;
1888
+ }
1889
+ declare interface SocketOptions {
1890
+ secureTransport?: string;
1891
+ allowHalfOpen: boolean;
1892
+ }
1893
+ declare interface SocketAddress {
1894
+ hostname: string;
1895
+ port: number;
1896
+ }
1897
+ declare interface TlsOptions {
1898
+ expectedServerHostname?: string;
1899
+ }
1779
1900
  declare interface BasicImageTransformations {
1780
1901
  /**
1781
1902
  * Maximum width in image pixels. The value must be an integer.
@@ -1855,7 +1976,7 @@ declare interface BasicImageTransformationsGravityCoordinates {
1855
1976
  * Note: Currently, these properties cannot be tested in the
1856
1977
  * playground.
1857
1978
  */
1858
- declare interface RequestInitCfProperties {
1979
+ declare interface RequestInitCfProperties extends Record<string, unknown> {
1859
1980
  cacheEverything?: boolean;
1860
1981
  /**
1861
1982
  * A request's cache key is what determines if two requests are
@@ -2025,6 +2146,49 @@ declare interface RequestInitCfPropertiesImage
2025
2146
  * the origin.
2026
2147
  */
2027
2148
  "origin-auth"?: "share-publicly";
2149
+ /**
2150
+ * Adds a border around the image. The border is added after resizing. Border
2151
+ * width takes dpr into account, and can be specified either using a single
2152
+ * width property, or individually for each side.
2153
+ */
2154
+ border?:
2155
+ | {
2156
+ color: string;
2157
+ width: number;
2158
+ }
2159
+ | {
2160
+ color: string;
2161
+ top: number;
2162
+ right: number;
2163
+ bottom: number;
2164
+ left: number;
2165
+ };
2166
+ /**
2167
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2168
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2169
+ * 0 is ignored.
2170
+ */
2171
+ brightness?: number;
2172
+ /**
2173
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2174
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2175
+ * ignored.
2176
+ */
2177
+ contrast?: number;
2178
+ /**
2179
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2180
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2181
+ */
2182
+ gamma?: number;
2183
+ /**
2184
+ * Slightly reduces latency on a cache miss by selecting a
2185
+ * quickest-to-compress file format, at a cost of increased file size and
2186
+ * lower image quality. It will usually override the format option and choose
2187
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2188
+ * unusual circumstances like resizing uncacheable dynamically-generated
2189
+ * images.
2190
+ */
2191
+ compression?: "fast";
2028
2192
  }
2029
2193
  declare interface RequestInitCfPropertiesImageMinify {
2030
2194
  javascript?: boolean;
@@ -2040,7 +2204,8 @@ declare type IncomingRequestCfProperties<HostMetadata = unknown> =
2040
2204
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2041
2205
  IncomingRequestCfPropertiesGeographicInformation &
2042
2206
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2043
- declare interface IncomingRequestCfPropertiesBase {
2207
+ declare interface IncomingRequestCfPropertiesBase
2208
+ extends Record<string, unknown> {
2044
2209
  /**
2045
2210
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2046
2211
  *
@@ -2121,8 +2286,7 @@ declare interface IncomingRequestCfPropertiesBase {
2121
2286
  declare interface IncomingRequestCfPropertiesBotManagementBase {
2122
2287
  /**
2123
2288
  * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2124
- * represented as an integer percentage between `1` (almost certainly human)
2125
- * and `99` (almost certainly a bot).
2289
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2126
2290
  *
2127
2291
  * @example 54
2128
2292
  */
@@ -2141,6 +2305,10 @@ declare interface IncomingRequestCfPropertiesBotManagementBase {
2141
2305
  * 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.
2142
2306
  */
2143
2307
  staticResource: boolean;
2308
+ /**
2309
+ * 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).
2310
+ */
2311
+ detectionIds: number[];
2144
2312
  }
2145
2313
  declare interface IncomingRequestCfPropertiesBotManagement {
2146
2314
  /**
@@ -2229,86 +2397,82 @@ declare interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2229
2397
  /**
2230
2398
  * Geographic data about the request's origin.
2231
2399
  */
2232
- declare type IncomingRequestCfPropertiesGeographicInformation =
2233
- | {}
2234
- | {
2235
- /** The country code `"T1"` is used for requests originating on TOR */
2236
- country: "T1";
2237
- }
2238
- | {
2239
- /**
2240
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2241
- *
2242
- * 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.
2243
- *
2244
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2245
- *
2246
- * @example "GB"
2247
- */
2248
- country: Iso3166Alpha2Code;
2249
- /**
2250
- * If present, this property indicates that the request originated in the EU
2251
- *
2252
- * @example "1"
2253
- */
2254
- isEUCountry?: "1";
2255
- /**
2256
- * A two-letter code indicating the continent the request originated from.
2257
- *
2258
- * @example "AN"
2259
- */
2260
- continent: ContinentCode;
2261
- /**
2262
- * The city the request originated from
2263
- *
2264
- * @example "Austin"
2265
- */
2266
- city?: string;
2267
- /**
2268
- * Postal code of the incoming request
2269
- *
2270
- * @example "78701"
2271
- */
2272
- postalCode?: string;
2273
- /**
2274
- * Latitude of the incoming request
2275
- *
2276
- * @example "30.27130"
2277
- */
2278
- latitude?: string;
2279
- /**
2280
- * Longitude of the incoming request
2281
- *
2282
- * @example "-97.74260"
2283
- */
2284
- longitude?: string;
2285
- /**
2286
- * Timezone of the incoming request
2287
- *
2288
- * @example "America/Chicago"
2289
- */
2290
- timezone?: string;
2291
- /**
2292
- * If known, the ISO 3166-2 name for the first level region associated with
2293
- * the IP address of the incoming request
2294
- *
2295
- * @example "Texas"
2296
- */
2297
- region?: string;
2298
- /**
2299
- * If known, the ISO 3166-2 code for the first-level region associated with
2300
- * the IP address of the incoming request
2301
- *
2302
- * @example "TX"
2303
- */
2304
- regionCode?: string;
2305
- /**
2306
- * Metro code (DMA) of the incoming request
2307
- *
2308
- * @example "635"
2309
- */
2310
- metroCode?: string;
2311
- };
2400
+ declare interface IncomingRequestCfPropertiesGeographicInformation {
2401
+ /**
2402
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2403
+ *
2404
+ * 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.
2405
+ *
2406
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2407
+ *
2408
+ * The country code `"T1"` is used for requests originating on TOR.
2409
+ *
2410
+ * @example "GB"
2411
+ */
2412
+ country?: Iso3166Alpha2Code | "T1";
2413
+ /**
2414
+ * If present, this property indicates that the request originated in the EU
2415
+ *
2416
+ * @example "1"
2417
+ */
2418
+ isEUCountry?: "1";
2419
+ /**
2420
+ * A two-letter code indicating the continent the request originated from.
2421
+ *
2422
+ * @example "AN"
2423
+ */
2424
+ continent?: ContinentCode;
2425
+ /**
2426
+ * The city the request originated from
2427
+ *
2428
+ * @example "Austin"
2429
+ */
2430
+ city?: string;
2431
+ /**
2432
+ * Postal code of the incoming request
2433
+ *
2434
+ * @example "78701"
2435
+ */
2436
+ postalCode?: string;
2437
+ /**
2438
+ * Latitude of the incoming request
2439
+ *
2440
+ * @example "30.27130"
2441
+ */
2442
+ latitude?: string;
2443
+ /**
2444
+ * Longitude of the incoming request
2445
+ *
2446
+ * @example "-97.74260"
2447
+ */
2448
+ longitude?: string;
2449
+ /**
2450
+ * Timezone of the incoming request
2451
+ *
2452
+ * @example "America/Chicago"
2453
+ */
2454
+ timezone?: string;
2455
+ /**
2456
+ * If known, the ISO 3166-2 name for the first level region associated with
2457
+ * the IP address of the incoming request
2458
+ *
2459
+ * @example "Texas"
2460
+ */
2461
+ region?: string;
2462
+ /**
2463
+ * If known, the ISO 3166-2 code for the first-level region associated with
2464
+ * the IP address of the incoming request
2465
+ *
2466
+ * @example "TX"
2467
+ */
2468
+ regionCode?: string;
2469
+ /**
2470
+ * Metro code (DMA) of the incoming request
2471
+ *
2472
+ * @example "635"
2473
+ */
2474
+ metroCode?: string;
2475
+ }
2312
2476
  /** Data about the incoming request's TLS certificate */
2313
2477
  declare interface IncomingRequestCfPropertiesTLSClientAuth {
2314
2478
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2701,6 +2865,9 @@ declare type Iso3166Alpha2Code =
2701
2865
  | "ZW";
2702
2866
  /** The 2-letter continent codes Cloudflare uses */
2703
2867
  declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2868
+ declare type CfProperties<HostMetadata = unknown> =
2869
+ | IncomingRequestCfProperties<HostMetadata>
2870
+ | RequestInitCfProperties;
2704
2871
  declare interface D1Result<T = unknown> {
2705
2872
  results?: T[];
2706
2873
  success: boolean;
@@ -2721,9 +2888,9 @@ declare abstract class D1PreparedStatement {
2721
2888
  raw<T = unknown>(): Promise<T[]>;
2722
2889
  }
2723
2890
  /**
2724
- * A email message that is sent to a consumer Worker.
2891
+ * An email message that can be sent from a Worker.
2725
2892
  */
2726
- declare interface EmailMessage<Body = unknown> {
2893
+ declare interface EmailMessage {
2727
2894
  /**
2728
2895
  * Envelope From attribute of the email message.
2729
2896
  */
@@ -2732,14 +2899,19 @@ declare interface EmailMessage<Body = unknown> {
2732
2899
  * Envelope To attribute of the email message.
2733
2900
  */
2734
2901
  readonly to: string;
2735
- /**
2736
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2737
- */
2738
- readonly headers: Headers;
2902
+ }
2903
+ /**
2904
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2905
+ */
2906
+ declare interface ForwardableEmailMessage extends EmailMessage {
2739
2907
  /**
2740
2908
  * Stream of the email message content.
2741
2909
  */
2742
2910
  readonly raw: ReadableStream;
2911
+ /**
2912
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2913
+ */
2914
+ readonly headers: Headers;
2743
2915
  /**
2744
2916
  * Size of the email message content.
2745
2917
  */
@@ -2758,14 +2930,27 @@ declare interface EmailMessage<Body = unknown> {
2758
2930
  */
2759
2931
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2760
2932
  }
2933
+ /**
2934
+ * A binding that allows a Worker to send email messages.
2935
+ */
2936
+ declare interface SendEmail {
2937
+ send(message: EmailMessage): Promise<void>;
2938
+ }
2761
2939
  declare abstract class EmailEvent extends ExtendableEvent {
2762
- readonly message: EmailMessage;
2940
+ readonly message: ForwardableEmailMessage;
2763
2941
  }
2764
2942
  declare type EmailExportedHandler<Env = unknown> = (
2765
- message: EmailMessage,
2943
+ message: ForwardableEmailMessage,
2766
2944
  env: Env,
2767
2945
  ctx: ExecutionContext
2768
2946
  ) => void | Promise<void>;
2947
+ declare module "cloudflare:email" {
2948
+ let _EmailMessage: {
2949
+ prototype: EmailMessage;
2950
+ new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
2951
+ };
2952
+ export { _EmailMessage as EmailMessage };
2953
+ }
2769
2954
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2770
2955
  declare type EventContext<Env, P extends string, Data> = {
2771
2956
  request: Request;
@@ -2846,75 +3031,12 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
2846
3031
  // Key Identifier of the JWK
2847
3032
  readonly kid: string;
2848
3033
  }
2849
- /**
2850
- * A message that is sent to a consumer Worker.
2851
- */
2852
- declare interface Message<Body = unknown> {
3034
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3035
+ declare interface DispatchNamespace {
2853
3036
  /**
2854
- * A unique, system-generated ID for the message.
3037
+ * @param name Name of the Worker script.
3038
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
3039
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2855
3040
  */
2856
- readonly id: string;
2857
- /**
2858
- * A timestamp when the message was sent.
2859
- */
2860
- readonly timestamp: Date;
2861
- /**
2862
- * The body of the message.
2863
- */
2864
- readonly body: Body;
2865
- /**
2866
- * Marks message to be retried.
2867
- */
2868
- retry(): void;
2869
- /**
2870
- * Marks message acknowledged.
2871
- */
2872
- ack(): void;
2873
- }
2874
- /**
2875
- * A batch of messages that are sent to a consumer Worker.
2876
- */
2877
- declare interface MessageBatch<Body = unknown> {
2878
- /**
2879
- * The name of the Queue that belongs to this batch.
2880
- */
2881
- readonly queue: string;
2882
- /**
2883
- * An array of messages in the batch. Ordering of messages is not guaranteed.
2884
- */
2885
- readonly messages: readonly Message<Body>[];
2886
- /**
2887
- * Marks every message to be retried in the next batch.
2888
- */
2889
- retryAll(): void;
2890
- /**
2891
- * Marks every message acknowledged in the batch.
2892
- */
2893
- ackAll(): void;
2894
- }
2895
- /**
2896
- * A wrapper class used to structure message batches.
2897
- */
2898
- declare type MessageSendRequest<Body = unknown> = {
2899
- /**
2900
- * The body of the message.
2901
- */
2902
- body: Body;
2903
- };
2904
- /**
2905
- * A binding that allows a producer to send messages to a Queue.
2906
- */
2907
- declare interface Queue<Body = any> {
2908
- /**
2909
- * Sends a message to the Queue.
2910
- * @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.
2911
- * @returns A promise that resolves when the message is confirmed to be written to disk.
2912
- */
2913
- send(message: Body): Promise<void>;
2914
- /**
2915
- * Sends a batch of messages to the Queue.
2916
- * @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.
2917
- * @returns A promise that resolves when the messages are confirmed to be written to disk.
2918
- */
2919
- sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
3041
+ get(name: string): Fetcher;
2920
3042
  }