@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
  };
@@ -279,12 +280,16 @@ declare const self: ServiceWorkerGlobalScope;
279
280
  declare const crypto: Crypto;
280
281
  declare const caches: CacheStorage;
281
282
  declare const scheduler: Scheduler;
283
+ declare interface TestController {}
282
284
  declare interface ExecutionContext {
283
285
  waitUntil(promise: Promise<any>): void;
284
286
  passThroughOnException(): void;
285
287
  }
286
- declare type ExportedHandlerFetchHandler<Env = unknown> = (
287
- request: Request,
288
+ declare type ExportedHandlerFetchHandler<
289
+ Env = unknown,
290
+ CfHostMetadata = unknown
291
+ > = (
292
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
288
293
  env: Env,
289
294
  ctx: ExecutionContext
290
295
  ) => Response | Promise<Response>;
@@ -303,11 +308,21 @@ declare type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
303
308
  env: Env,
304
309
  ctx: ExecutionContext
305
310
  ) => void | Promise<void>;
306
- declare interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
307
- fetch?: ExportedHandlerFetchHandler<Env>;
311
+ declare type ExportedHandlerTestHandler<Env = unknown> = (
312
+ controller: TestController,
313
+ env: Env,
314
+ ctx: ExecutionContext
315
+ ) => void | Promise<void>;
316
+ declare interface ExportedHandler<
317
+ Env = unknown,
318
+ QueueMessage = unknown,
319
+ CfHostMetadata = unknown
320
+ > {
321
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
308
322
  trace?: ExportedHandlerTraceHandler<Env>;
309
323
  scheduled?: ExportedHandlerScheduledHandler<Env>;
310
- queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
324
+ test?: ExportedHandlerTestHandler<Env>;
325
+ queue?: ExportedHandlerQueueHandler<Env, Message>;
311
326
  }
312
327
  declare interface StructuredSerializeOptions {
313
328
  transfer?: any[];
@@ -339,13 +354,24 @@ declare interface DurableObjectNamespace {
339
354
  id: DurableObjectId,
340
355
  options?: DurableObjectNamespaceGetDurableObjectOptions
341
356
  ): DurableObjectStub;
342
- jurisdiction(jurisdiction: string): DurableObjectNamespace;
357
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
343
358
  }
359
+ declare type DurableObjectJurisdiction = "eu" | "fedramp";
344
360
  declare interface DurableObjectNamespaceNewUniqueIdOptions {
345
- jurisdiction?: string;
346
- }
361
+ jurisdiction?: DurableObjectJurisdiction;
362
+ }
363
+ declare type DurableObjectLocationHint =
364
+ | "wnam"
365
+ | "enam"
366
+ | "sam"
367
+ | "weur"
368
+ | "eeur"
369
+ | "apac"
370
+ | "oc"
371
+ | "afr"
372
+ | "me";
347
373
  declare interface DurableObjectNamespaceGetDurableObjectOptions {
348
- locationHint?: string;
374
+ locationHint?: DurableObjectLocationHint;
349
375
  }
350
376
  declare interface DurableObjectState {
351
377
  waitUntil(promise: Promise<any>): void;
@@ -988,10 +1014,16 @@ declare interface ResponseInit {
988
1014
  webSocket?: WebSocket | null;
989
1015
  encodeBody?: "automatic" | "manual";
990
1016
  }
991
- declare type RequestInfo = Request | string | URL;
992
- declare class Request<CfHostMetadata = unknown> extends Body {
993
- constructor(input: RequestInfo, init?: RequestInit);
994
- clone(): Request<CfHostMetadata>;
1017
+ declare type RequestInfo<
1018
+ CfHostMetadata = unknown,
1019
+ Cf = CfProperties<CfHostMetadata>
1020
+ > = Request<CfHostMetadata, Cf> | string | URL;
1021
+ declare class Request<
1022
+ CfHostMetadata = unknown,
1023
+ Cf = CfProperties<CfHostMetadata>
1024
+ > extends Body {
1025
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1026
+ clone(): Request<CfHostMetadata, Cf>;
995
1027
  /** Returns request's HTTP method, which is "GET" by default. */
996
1028
  readonly method: string;
997
1029
  /** Returns the URL of request as a string. */
@@ -1003,15 +1035,13 @@ declare class Request<CfHostMetadata = unknown> extends Body {
1003
1035
  readonly fetcher: Fetcher | null;
1004
1036
  /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
1005
1037
  readonly signal: AbortSignal;
1006
- readonly cf?: IncomingRequestCfProperties<CfHostMetadata>;
1038
+ readonly cf?: Cf;
1007
1039
  /** 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] */
1008
1040
  readonly integrity: string;
1009
1041
  /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
1010
1042
  readonly keepalive: boolean;
1011
1043
  }
1012
- declare interface RequestInit<
1013
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1014
- > {
1044
+ declare interface RequestInit<Cf = CfProperties> {
1015
1045
  /** A string to set request's method. */
1016
1046
  method?: string;
1017
1047
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1021,17 +1051,14 @@ declare interface RequestInit<
1021
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. */
1022
1052
  redirect?: string;
1023
1053
  fetcher?: Fetcher | null;
1024
- cf?: CfType;
1054
+ cf?: Cf;
1025
1055
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1026
1056
  integrity?: string;
1027
1057
  /** An AbortSignal to set request's signal. */
1028
1058
  signal?: AbortSignal | null;
1029
1059
  }
1030
1060
  declare abstract class Fetcher {
1031
- fetch(
1032
- input: RequestInfo,
1033
- init?: RequestInit<RequestInitCfProperties>
1034
- ): Promise<Response>;
1061
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1035
1062
  }
1036
1063
  declare interface FetcherPutOptions {
1037
1064
  expiration?: number;
@@ -1144,6 +1171,33 @@ declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1144
1171
  value: Value | null;
1145
1172
  metadata: Metadata | null;
1146
1173
  }
1174
+ declare interface Queue<Body> {
1175
+ send(message: Body): Promise<void>;
1176
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1177
+ }
1178
+ declare interface QueueSendOptions {}
1179
+ declare interface MessageSendRequest<Body = unknown> {
1180
+ body: Body;
1181
+ }
1182
+ declare interface Message<Body = unknown> {
1183
+ readonly id: string;
1184
+ readonly timestamp: Date;
1185
+ readonly body: Body;
1186
+ retry(): void;
1187
+ ack(): void;
1188
+ }
1189
+ declare interface QueueEvent<Body = unknown> extends ExtendableEvent {
1190
+ readonly messages: readonly Message<Body>[];
1191
+ readonly queue: string;
1192
+ retryAll(): void;
1193
+ ackAll(): void;
1194
+ }
1195
+ declare interface MessageBatch<Body = unknown> {
1196
+ readonly messages: readonly Message<Body>[];
1197
+ readonly queue: string;
1198
+ retryAll(): void;
1199
+ ackAll(): void;
1200
+ }
1147
1201
  declare interface R2Error extends Error {
1148
1202
  readonly name: string;
1149
1203
  readonly code: number;
@@ -1294,12 +1348,18 @@ declare interface R2HTTPMetadata {
1294
1348
  cacheControl?: string;
1295
1349
  cacheExpiry?: Date;
1296
1350
  }
1297
- declare interface R2Objects {
1351
+ declare type R2Objects = {
1298
1352
  objects: R2Object[];
1299
- truncated: boolean;
1300
- cursor?: string;
1301
1353
  delimitedPrefixes: string[];
1302
- }
1354
+ } & (
1355
+ | {
1356
+ truncated: true;
1357
+ cursor: string;
1358
+ }
1359
+ | {
1360
+ truncated: false;
1361
+ }
1362
+ );
1303
1363
  declare abstract class ScheduledEvent extends ExtendableEvent {
1304
1364
  readonly scheduledTime: number;
1305
1365
  readonly cron: string;
@@ -1510,13 +1570,19 @@ declare class TransformStream<I = any, O = any> {
1510
1570
  readonly writable: WritableStream<I>;
1511
1571
  }
1512
1572
  declare class FixedLengthStream extends IdentityTransformStream {
1513
- constructor(expectedLength: number | bigint);
1573
+ constructor(
1574
+ expectedLength: number | bigint,
1575
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1576
+ );
1514
1577
  }
1515
1578
  declare class IdentityTransformStream extends TransformStream<
1516
1579
  ArrayBuffer | ArrayBufferView,
1517
1580
  Uint8Array
1518
1581
  > {
1519
- constructor();
1582
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1583
+ }
1584
+ declare interface IdentityTransformStreamQueuingStrategy {
1585
+ highWaterMark?: number | bigint;
1520
1586
  }
1521
1587
  declare interface ReadableStreamValuesOptions {
1522
1588
  preventCancel?: boolean;
@@ -1525,13 +1591,13 @@ declare class CompressionStream extends TransformStream<
1525
1591
  ArrayBuffer | ArrayBufferView,
1526
1592
  Uint8Array
1527
1593
  > {
1528
- constructor(format: "gzip" | "deflate");
1594
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1529
1595
  }
1530
1596
  declare class DecompressionStream extends TransformStream<
1531
1597
  ArrayBuffer | ArrayBufferView,
1532
1598
  Uint8Array
1533
1599
  > {
1534
- constructor(format: "gzip" | "deflate");
1600
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1535
1601
  }
1536
1602
  declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
1537
1603
  constructor();
@@ -1660,6 +1726,7 @@ declare class URLSearchParams {
1660
1726
  | Record<string, string>
1661
1727
  | [key: string, value: string][]
1662
1728
  );
1729
+ get size(): number;
1663
1730
  append(name: string, value: string): void;
1664
1731
  delete(name: string): void;
1665
1732
  get(name: string): string | null;
@@ -1862,7 +1929,7 @@ declare interface BasicImageTransformationsGravityCoordinates {
1862
1929
  * Note: Currently, these properties cannot be tested in the
1863
1930
  * playground.
1864
1931
  */
1865
- declare interface RequestInitCfProperties {
1932
+ declare interface RequestInitCfProperties extends Record<string, unknown> {
1866
1933
  cacheEverything?: boolean;
1867
1934
  /**
1868
1935
  * A request's cache key is what determines if two requests are
@@ -2032,6 +2099,49 @@ declare interface RequestInitCfPropertiesImage
2032
2099
  * the origin.
2033
2100
  */
2034
2101
  "origin-auth"?: "share-publicly";
2102
+ /**
2103
+ * Adds a border around the image. The border is added after resizing. Border
2104
+ * width takes dpr into account, and can be specified either using a single
2105
+ * width property, or individually for each side.
2106
+ */
2107
+ border?:
2108
+ | {
2109
+ color: string;
2110
+ width: number;
2111
+ }
2112
+ | {
2113
+ color: string;
2114
+ top: number;
2115
+ right: number;
2116
+ bottom: number;
2117
+ left: number;
2118
+ };
2119
+ /**
2120
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2121
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2122
+ * 0 is ignored.
2123
+ */
2124
+ brightness?: number;
2125
+ /**
2126
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2127
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2128
+ * ignored.
2129
+ */
2130
+ contrast?: number;
2131
+ /**
2132
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2133
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2134
+ */
2135
+ gamma?: number;
2136
+ /**
2137
+ * Slightly reduces latency on a cache miss by selecting a
2138
+ * quickest-to-compress file format, at a cost of increased file size and
2139
+ * lower image quality. It will usually override the format option and choose
2140
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2141
+ * unusual circumstances like resizing uncacheable dynamically-generated
2142
+ * images.
2143
+ */
2144
+ compression?: "fast";
2035
2145
  }
2036
2146
  declare interface RequestInitCfPropertiesImageMinify {
2037
2147
  javascript?: boolean;
@@ -2047,7 +2157,8 @@ declare type IncomingRequestCfProperties<HostMetadata = unknown> =
2047
2157
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2048
2158
  IncomingRequestCfPropertiesGeographicInformation &
2049
2159
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2050
- declare interface IncomingRequestCfPropertiesBase {
2160
+ declare interface IncomingRequestCfPropertiesBase
2161
+ extends Record<string, unknown> {
2051
2162
  /**
2052
2163
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2053
2164
  *
@@ -2128,8 +2239,7 @@ declare interface IncomingRequestCfPropertiesBase {
2128
2239
  declare interface IncomingRequestCfPropertiesBotManagementBase {
2129
2240
  /**
2130
2241
  * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2131
- * represented as an integer percentage between `1` (almost certainly human)
2132
- * and `99` (almost certainly a bot).
2242
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2133
2243
  *
2134
2244
  * @example 54
2135
2245
  */
@@ -2148,6 +2258,10 @@ declare interface IncomingRequestCfPropertiesBotManagementBase {
2148
2258
  * 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.
2149
2259
  */
2150
2260
  staticResource: boolean;
2261
+ /**
2262
+ * 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).
2263
+ */
2264
+ detectionIds: number[];
2151
2265
  }
2152
2266
  declare interface IncomingRequestCfPropertiesBotManagement {
2153
2267
  /**
@@ -2236,86 +2350,82 @@ declare interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2236
2350
  /**
2237
2351
  * Geographic data about the request's origin.
2238
2352
  */
2239
- declare type IncomingRequestCfPropertiesGeographicInformation =
2240
- | {}
2241
- | {
2242
- /** The country code `"T1"` is used for requests originating on TOR */
2243
- country: "T1";
2244
- }
2245
- | {
2246
- /**
2247
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2248
- *
2249
- * 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.
2250
- *
2251
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2252
- *
2253
- * @example "GB"
2254
- */
2255
- country: Iso3166Alpha2Code;
2256
- /**
2257
- * If present, this property indicates that the request originated in the EU
2258
- *
2259
- * @example "1"
2260
- */
2261
- isEUCountry?: "1";
2262
- /**
2263
- * A two-letter code indicating the continent the request originated from.
2264
- *
2265
- * @example "AN"
2266
- */
2267
- continent: ContinentCode;
2268
- /**
2269
- * The city the request originated from
2270
- *
2271
- * @example "Austin"
2272
- */
2273
- city?: string;
2274
- /**
2275
- * Postal code of the incoming request
2276
- *
2277
- * @example "78701"
2278
- */
2279
- postalCode?: string;
2280
- /**
2281
- * Latitude of the incoming request
2282
- *
2283
- * @example "30.27130"
2284
- */
2285
- latitude?: string;
2286
- /**
2287
- * Longitude of the incoming request
2288
- *
2289
- * @example "-97.74260"
2290
- */
2291
- longitude?: string;
2292
- /**
2293
- * Timezone of the incoming request
2294
- *
2295
- * @example "America/Chicago"
2296
- */
2297
- timezone?: string;
2298
- /**
2299
- * If known, the ISO 3166-2 name for the first level region associated with
2300
- * the IP address of the incoming request
2301
- *
2302
- * @example "Texas"
2303
- */
2304
- region?: string;
2305
- /**
2306
- * If known, the ISO 3166-2 code for the first-level region associated with
2307
- * the IP address of the incoming request
2308
- *
2309
- * @example "TX"
2310
- */
2311
- regionCode?: string;
2312
- /**
2313
- * Metro code (DMA) of the incoming request
2314
- *
2315
- * @example "635"
2316
- */
2317
- metroCode?: string;
2318
- };
2353
+ declare interface IncomingRequestCfPropertiesGeographicInformation {
2354
+ /**
2355
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2356
+ *
2357
+ * 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.
2358
+ *
2359
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2360
+ *
2361
+ * The country code `"T1"` is used for requests originating on TOR.
2362
+ *
2363
+ * @example "GB"
2364
+ */
2365
+ country?: Iso3166Alpha2Code | "T1";
2366
+ /**
2367
+ * If present, this property indicates that the request originated in the EU
2368
+ *
2369
+ * @example "1"
2370
+ */
2371
+ isEUCountry?: "1";
2372
+ /**
2373
+ * A two-letter code indicating the continent the request originated from.
2374
+ *
2375
+ * @example "AN"
2376
+ */
2377
+ continent?: ContinentCode;
2378
+ /**
2379
+ * The city the request originated from
2380
+ *
2381
+ * @example "Austin"
2382
+ */
2383
+ city?: string;
2384
+ /**
2385
+ * Postal code of the incoming request
2386
+ *
2387
+ * @example "78701"
2388
+ */
2389
+ postalCode?: string;
2390
+ /**
2391
+ * Latitude of the incoming request
2392
+ *
2393
+ * @example "30.27130"
2394
+ */
2395
+ latitude?: string;
2396
+ /**
2397
+ * Longitude of the incoming request
2398
+ *
2399
+ * @example "-97.74260"
2400
+ */
2401
+ longitude?: string;
2402
+ /**
2403
+ * Timezone of the incoming request
2404
+ *
2405
+ * @example "America/Chicago"
2406
+ */
2407
+ timezone?: string;
2408
+ /**
2409
+ * If known, the ISO 3166-2 name for the first level region associated with
2410
+ * the IP address of the incoming request
2411
+ *
2412
+ * @example "Texas"
2413
+ */
2414
+ region?: string;
2415
+ /**
2416
+ * If known, the ISO 3166-2 code for the first-level region associated with
2417
+ * the IP address of the incoming request
2418
+ *
2419
+ * @example "TX"
2420
+ */
2421
+ regionCode?: string;
2422
+ /**
2423
+ * Metro code (DMA) of the incoming request
2424
+ *
2425
+ * @example "635"
2426
+ */
2427
+ metroCode?: string;
2428
+ }
2319
2429
  /** Data about the incoming request's TLS certificate */
2320
2430
  declare interface IncomingRequestCfPropertiesTLSClientAuth {
2321
2431
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2708,6 +2818,9 @@ declare type Iso3166Alpha2Code =
2708
2818
  | "ZW";
2709
2819
  /** The 2-letter continent codes Cloudflare uses */
2710
2820
  declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2821
+ declare type CfProperties<HostMetadata = unknown> =
2822
+ | IncomingRequestCfProperties<HostMetadata>
2823
+ | RequestInitCfProperties;
2711
2824
  declare interface D1Result<T = unknown> {
2712
2825
  results?: T[];
2713
2826
  success: boolean;
@@ -2728,9 +2841,9 @@ declare abstract class D1PreparedStatement {
2728
2841
  raw<T = unknown>(): Promise<T[]>;
2729
2842
  }
2730
2843
  /**
2731
- * A email message that is sent to a consumer Worker.
2844
+ * An email message that can be sent from a Worker.
2732
2845
  */
2733
- declare interface EmailMessage<Body = unknown> {
2846
+ declare interface EmailMessage {
2734
2847
  /**
2735
2848
  * Envelope From attribute of the email message.
2736
2849
  */
@@ -2739,14 +2852,19 @@ declare interface EmailMessage<Body = unknown> {
2739
2852
  * Envelope To attribute of the email message.
2740
2853
  */
2741
2854
  readonly to: string;
2742
- /**
2743
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2744
- */
2745
- readonly headers: Headers;
2855
+ }
2856
+ /**
2857
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2858
+ */
2859
+ declare interface ForwardableEmailMessage extends EmailMessage {
2746
2860
  /**
2747
2861
  * Stream of the email message content.
2748
2862
  */
2749
2863
  readonly raw: ReadableStream;
2864
+ /**
2865
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2866
+ */
2867
+ readonly headers: Headers;
2750
2868
  /**
2751
2869
  * Size of the email message content.
2752
2870
  */
@@ -2765,14 +2883,27 @@ declare interface EmailMessage<Body = unknown> {
2765
2883
  */
2766
2884
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2767
2885
  }
2886
+ /**
2887
+ * A binding that allows a Worker to send email messages.
2888
+ */
2889
+ declare interface SendEmail {
2890
+ send(message: EmailMessage): Promise<void>;
2891
+ }
2768
2892
  declare abstract class EmailEvent extends ExtendableEvent {
2769
- readonly message: EmailMessage;
2893
+ readonly message: ForwardableEmailMessage;
2770
2894
  }
2771
2895
  declare type EmailExportedHandler<Env = unknown> = (
2772
- message: EmailMessage,
2896
+ message: ForwardableEmailMessage,
2773
2897
  env: Env,
2774
2898
  ctx: ExecutionContext
2775
2899
  ) => void | Promise<void>;
2900
+ declare module "cloudflare:email" {
2901
+ let _EmailMessage: {
2902
+ prototype: EmailMessage;
2903
+ new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
2904
+ };
2905
+ export { _EmailMessage as EmailMessage };
2906
+ }
2776
2907
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2777
2908
  declare type EventContext<Env, P extends string, Data> = {
2778
2909
  request: Request;
@@ -2853,75 +2984,12 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
2853
2984
  // Key Identifier of the JWK
2854
2985
  readonly kid: string;
2855
2986
  }
2856
- /**
2857
- * A message that is sent to a consumer Worker.
2858
- */
2859
- declare interface Message<Body = unknown> {
2987
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
2988
+ declare interface DispatchNamespace {
2860
2989
  /**
2861
- * A unique, system-generated ID for the message.
2990
+ * @param name Name of the Worker script.
2991
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
2992
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2862
2993
  */
2863
- readonly id: string;
2864
- /**
2865
- * A timestamp when the message was sent.
2866
- */
2867
- readonly timestamp: Date;
2868
- /**
2869
- * The body of the message.
2870
- */
2871
- readonly body: Body;
2872
- /**
2873
- * Marks message to be retried.
2874
- */
2875
- retry(): void;
2876
- /**
2877
- * Marks message acknowledged.
2878
- */
2879
- ack(): void;
2880
- }
2881
- /**
2882
- * A batch of messages that are sent to a consumer Worker.
2883
- */
2884
- declare interface MessageBatch<Body = unknown> {
2885
- /**
2886
- * The name of the Queue that belongs to this batch.
2887
- */
2888
- readonly queue: string;
2889
- /**
2890
- * An array of messages in the batch. Ordering of messages is not guaranteed.
2891
- */
2892
- readonly messages: readonly Message<Body>[];
2893
- /**
2894
- * Marks every message to be retried in the next batch.
2895
- */
2896
- retryAll(): void;
2897
- /**
2898
- * Marks every message acknowledged in the batch.
2899
- */
2900
- ackAll(): void;
2901
- }
2902
- /**
2903
- * A wrapper class used to structure message batches.
2904
- */
2905
- declare type MessageSendRequest<Body = unknown> = {
2906
- /**
2907
- * The body of the message.
2908
- */
2909
- body: Body;
2910
- };
2911
- /**
2912
- * A binding that allows a producer to send messages to a Queue.
2913
- */
2914
- declare interface Queue<Body = any> {
2915
- /**
2916
- * Sends a message to the Queue.
2917
- * @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.
2918
- * @returns A promise that resolves when the message is confirmed to be written to disk.
2919
- */
2920
- send(message: Body): Promise<void>;
2921
- /**
2922
- * Sends a batch of messages to the Queue.
2923
- * @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.
2924
- * @returns A promise that resolves when the messages are confirmed to be written to disk.
2925
- */
2926
- sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2994
+ get(name: string): Fetcher;
2927
2995
  }