@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
  };
@@ -282,12 +283,16 @@ declare const crypto: Crypto;
282
283
  declare const caches: CacheStorage;
283
284
  declare const scheduler: Scheduler;
284
285
  declare const navigator: Navigator;
286
+ declare interface TestController {}
285
287
  declare interface ExecutionContext {
286
288
  waitUntil(promise: Promise<any>): void;
287
289
  passThroughOnException(): void;
288
290
  }
289
- declare type ExportedHandlerFetchHandler<Env = unknown> = (
290
- request: Request,
291
+ declare type ExportedHandlerFetchHandler<
292
+ Env = unknown,
293
+ CfHostMetadata = unknown
294
+ > = (
295
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
291
296
  env: Env,
292
297
  ctx: ExecutionContext
293
298
  ) => Response | Promise<Response>;
@@ -306,11 +311,21 @@ declare type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
306
311
  env: Env,
307
312
  ctx: ExecutionContext
308
313
  ) => void | Promise<void>;
309
- declare interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
310
- fetch?: ExportedHandlerFetchHandler<Env>;
314
+ declare type ExportedHandlerTestHandler<Env = unknown> = (
315
+ controller: TestController,
316
+ env: Env,
317
+ ctx: ExecutionContext
318
+ ) => void | Promise<void>;
319
+ declare interface ExportedHandler<
320
+ Env = unknown,
321
+ QueueMessage = unknown,
322
+ CfHostMetadata = unknown
323
+ > {
324
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
311
325
  trace?: ExportedHandlerTraceHandler<Env>;
312
326
  scheduled?: ExportedHandlerScheduledHandler<Env>;
313
- queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
327
+ test?: ExportedHandlerTestHandler<Env>;
328
+ queue?: ExportedHandlerQueueHandler<Env, Message>;
314
329
  }
315
330
  declare interface StructuredSerializeOptions {
316
331
  transfer?: any[];
@@ -345,13 +360,24 @@ declare interface DurableObjectNamespace {
345
360
  id: DurableObjectId,
346
361
  options?: DurableObjectNamespaceGetDurableObjectOptions
347
362
  ): DurableObjectStub;
348
- jurisdiction(jurisdiction: string): DurableObjectNamespace;
363
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
349
364
  }
365
+ declare type DurableObjectJurisdiction = "eu" | "fedramp";
350
366
  declare interface DurableObjectNamespaceNewUniqueIdOptions {
351
- jurisdiction?: string;
352
- }
367
+ jurisdiction?: DurableObjectJurisdiction;
368
+ }
369
+ declare type DurableObjectLocationHint =
370
+ | "wnam"
371
+ | "enam"
372
+ | "sam"
373
+ | "weur"
374
+ | "eeur"
375
+ | "apac"
376
+ | "oc"
377
+ | "afr"
378
+ | "me";
353
379
  declare interface DurableObjectNamespaceGetDurableObjectOptions {
354
- locationHint?: string;
380
+ locationHint?: DurableObjectLocationHint;
355
381
  }
356
382
  declare interface DurableObjectState {
357
383
  waitUntil(promise: Promise<any>): void;
@@ -981,23 +1007,27 @@ declare interface ResponseInit {
981
1007
  webSocket?: WebSocket | null;
982
1008
  encodeBody?: "automatic" | "manual";
983
1009
  }
984
- declare type RequestInfo = Request | string | URL;
985
- declare class Request<CfHostMetadata = unknown> extends Body {
986
- constructor(input: RequestInfo, init?: RequestInit);
987
- clone(): Request<CfHostMetadata>;
1010
+ declare type RequestInfo<
1011
+ CfHostMetadata = unknown,
1012
+ Cf = CfProperties<CfHostMetadata>
1013
+ > = Request<CfHostMetadata, Cf> | string | URL;
1014
+ declare class Request<
1015
+ CfHostMetadata = unknown,
1016
+ Cf = CfProperties<CfHostMetadata>
1017
+ > extends Body {
1018
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1019
+ clone(): Request<CfHostMetadata, Cf>;
988
1020
  get method(): string;
989
1021
  get url(): string;
990
1022
  get headers(): Headers;
991
1023
  get redirect(): string;
992
1024
  get fetcher(): Fetcher | null;
993
1025
  get signal(): AbortSignal;
994
- get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
1026
+ get cf(): Cf | undefined;
995
1027
  get integrity(): string;
996
1028
  get keepalive(): boolean;
997
1029
  }
998
- declare interface RequestInit<
999
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1000
- > {
1030
+ declare interface RequestInit<Cf = CfProperties> {
1001
1031
  /** A string to set request's method. */
1002
1032
  method?: string;
1003
1033
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1007,17 +1037,14 @@ declare interface RequestInit<
1007
1037
  /** 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. */
1008
1038
  redirect?: string;
1009
1039
  fetcher?: Fetcher | null;
1010
- cf?: CfType;
1040
+ cf?: Cf;
1011
1041
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1012
1042
  integrity?: string;
1013
1043
  /** An AbortSignal to set request's signal. */
1014
1044
  signal?: AbortSignal | null;
1015
1045
  }
1016
1046
  declare abstract class Fetcher {
1017
- fetch(
1018
- input: RequestInfo,
1019
- init?: RequestInit<RequestInitCfProperties>
1020
- ): Promise<Response>;
1047
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1021
1048
  }
1022
1049
  declare interface FetcherPutOptions {
1023
1050
  expiration?: number;
@@ -1130,6 +1157,33 @@ declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1130
1157
  value: Value | null;
1131
1158
  metadata: Metadata | null;
1132
1159
  }
1160
+ declare interface Queue<Body> {
1161
+ send(message: Body): Promise<void>;
1162
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1163
+ }
1164
+ declare interface QueueSendOptions {}
1165
+ declare interface MessageSendRequest<Body = unknown> {
1166
+ body: Body;
1167
+ }
1168
+ declare interface Message<Body = unknown> {
1169
+ readonly id: string;
1170
+ readonly timestamp: Date;
1171
+ readonly body: Body;
1172
+ retry(): void;
1173
+ ack(): void;
1174
+ }
1175
+ declare interface QueueEvent<Body = unknown> extends ExtendableEvent {
1176
+ readonly messages: readonly Message<Body>[];
1177
+ readonly queue: string;
1178
+ retryAll(): void;
1179
+ ackAll(): void;
1180
+ }
1181
+ declare interface MessageBatch<Body = unknown> {
1182
+ readonly messages: readonly Message<Body>[];
1183
+ readonly queue: string;
1184
+ retryAll(): void;
1185
+ ackAll(): void;
1186
+ }
1133
1187
  declare interface R2Error extends Error {
1134
1188
  readonly name: string;
1135
1189
  readonly code: number;
@@ -1281,12 +1335,18 @@ declare interface R2HTTPMetadata {
1281
1335
  cacheControl?: string;
1282
1336
  cacheExpiry?: Date;
1283
1337
  }
1284
- declare interface R2Objects {
1338
+ declare type R2Objects = {
1285
1339
  objects: R2Object[];
1286
- truncated: boolean;
1287
- cursor?: string;
1288
1340
  delimitedPrefixes: string[];
1289
- }
1341
+ } & (
1342
+ | {
1343
+ truncated: true;
1344
+ cursor: string;
1345
+ }
1346
+ | {
1347
+ truncated: false;
1348
+ }
1349
+ );
1290
1350
  declare abstract class ScheduledEvent extends ExtendableEvent {
1291
1351
  readonly scheduledTime: number;
1292
1352
  readonly cron: string;
@@ -1497,13 +1557,19 @@ declare class TransformStream<I = any, O = any> {
1497
1557
  get writable(): WritableStream<I>;
1498
1558
  }
1499
1559
  declare class FixedLengthStream extends IdentityTransformStream {
1500
- constructor(expectedLength: number | bigint);
1560
+ constructor(
1561
+ expectedLength: number | bigint,
1562
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1563
+ );
1501
1564
  }
1502
1565
  declare class IdentityTransformStream extends TransformStream<
1503
1566
  ArrayBuffer | ArrayBufferView,
1504
1567
  Uint8Array
1505
1568
  > {
1506
- constructor();
1569
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1570
+ }
1571
+ declare interface IdentityTransformStreamQueuingStrategy {
1572
+ highWaterMark?: number | bigint;
1507
1573
  }
1508
1574
  declare interface ReadableStreamValuesOptions {
1509
1575
  preventCancel?: boolean;
@@ -1512,13 +1578,13 @@ declare class CompressionStream extends TransformStream<
1512
1578
  ArrayBuffer | ArrayBufferView,
1513
1579
  Uint8Array
1514
1580
  > {
1515
- constructor(format: "gzip" | "deflate");
1581
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1516
1582
  }
1517
1583
  declare class DecompressionStream extends TransformStream<
1518
1584
  ArrayBuffer | ArrayBufferView,
1519
1585
  Uint8Array
1520
1586
  > {
1521
- constructor(format: "gzip" | "deflate");
1587
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1522
1588
  }
1523
1589
  declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
1524
1590
  constructor();
@@ -1657,6 +1723,7 @@ declare class URLSearchParams {
1657
1723
  | Record<string, string>
1658
1724
  | [key: string, value: string][]
1659
1725
  );
1726
+ get size(): number;
1660
1727
  append(name: string, value: string): void;
1661
1728
  delete(name: string): void;
1662
1729
  get(name: string): string | null;
@@ -1855,7 +1922,7 @@ declare interface BasicImageTransformationsGravityCoordinates {
1855
1922
  * Note: Currently, these properties cannot be tested in the
1856
1923
  * playground.
1857
1924
  */
1858
- declare interface RequestInitCfProperties {
1925
+ declare interface RequestInitCfProperties extends Record<string, unknown> {
1859
1926
  cacheEverything?: boolean;
1860
1927
  /**
1861
1928
  * A request's cache key is what determines if two requests are
@@ -2025,6 +2092,49 @@ declare interface RequestInitCfPropertiesImage
2025
2092
  * the origin.
2026
2093
  */
2027
2094
  "origin-auth"?: "share-publicly";
2095
+ /**
2096
+ * Adds a border around the image. The border is added after resizing. Border
2097
+ * width takes dpr into account, and can be specified either using a single
2098
+ * width property, or individually for each side.
2099
+ */
2100
+ border?:
2101
+ | {
2102
+ color: string;
2103
+ width: number;
2104
+ }
2105
+ | {
2106
+ color: string;
2107
+ top: number;
2108
+ right: number;
2109
+ bottom: number;
2110
+ left: number;
2111
+ };
2112
+ /**
2113
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2114
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2115
+ * 0 is ignored.
2116
+ */
2117
+ brightness?: number;
2118
+ /**
2119
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2120
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2121
+ * ignored.
2122
+ */
2123
+ contrast?: number;
2124
+ /**
2125
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2126
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2127
+ */
2128
+ gamma?: number;
2129
+ /**
2130
+ * Slightly reduces latency on a cache miss by selecting a
2131
+ * quickest-to-compress file format, at a cost of increased file size and
2132
+ * lower image quality. It will usually override the format option and choose
2133
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2134
+ * unusual circumstances like resizing uncacheable dynamically-generated
2135
+ * images.
2136
+ */
2137
+ compression?: "fast";
2028
2138
  }
2029
2139
  declare interface RequestInitCfPropertiesImageMinify {
2030
2140
  javascript?: boolean;
@@ -2040,7 +2150,8 @@ declare type IncomingRequestCfProperties<HostMetadata = unknown> =
2040
2150
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2041
2151
  IncomingRequestCfPropertiesGeographicInformation &
2042
2152
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2043
- declare interface IncomingRequestCfPropertiesBase {
2153
+ declare interface IncomingRequestCfPropertiesBase
2154
+ extends Record<string, unknown> {
2044
2155
  /**
2045
2156
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2046
2157
  *
@@ -2121,8 +2232,7 @@ declare interface IncomingRequestCfPropertiesBase {
2121
2232
  declare interface IncomingRequestCfPropertiesBotManagementBase {
2122
2233
  /**
2123
2234
  * 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).
2235
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2126
2236
  *
2127
2237
  * @example 54
2128
2238
  */
@@ -2141,6 +2251,10 @@ declare interface IncomingRequestCfPropertiesBotManagementBase {
2141
2251
  * 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
2252
  */
2143
2253
  staticResource: boolean;
2254
+ /**
2255
+ * 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).
2256
+ */
2257
+ detectionIds: number[];
2144
2258
  }
2145
2259
  declare interface IncomingRequestCfPropertiesBotManagement {
2146
2260
  /**
@@ -2229,86 +2343,82 @@ declare interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2229
2343
  /**
2230
2344
  * Geographic data about the request's origin.
2231
2345
  */
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
- };
2346
+ declare interface IncomingRequestCfPropertiesGeographicInformation {
2347
+ /**
2348
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2349
+ *
2350
+ * 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.
2351
+ *
2352
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2353
+ *
2354
+ * The country code `"T1"` is used for requests originating on TOR.
2355
+ *
2356
+ * @example "GB"
2357
+ */
2358
+ country?: Iso3166Alpha2Code | "T1";
2359
+ /**
2360
+ * If present, this property indicates that the request originated in the EU
2361
+ *
2362
+ * @example "1"
2363
+ */
2364
+ isEUCountry?: "1";
2365
+ /**
2366
+ * A two-letter code indicating the continent the request originated from.
2367
+ *
2368
+ * @example "AN"
2369
+ */
2370
+ continent?: ContinentCode;
2371
+ /**
2372
+ * The city the request originated from
2373
+ *
2374
+ * @example "Austin"
2375
+ */
2376
+ city?: string;
2377
+ /**
2378
+ * Postal code of the incoming request
2379
+ *
2380
+ * @example "78701"
2381
+ */
2382
+ postalCode?: string;
2383
+ /**
2384
+ * Latitude of the incoming request
2385
+ *
2386
+ * @example "30.27130"
2387
+ */
2388
+ latitude?: string;
2389
+ /**
2390
+ * Longitude of the incoming request
2391
+ *
2392
+ * @example "-97.74260"
2393
+ */
2394
+ longitude?: string;
2395
+ /**
2396
+ * Timezone of the incoming request
2397
+ *
2398
+ * @example "America/Chicago"
2399
+ */
2400
+ timezone?: string;
2401
+ /**
2402
+ * If known, the ISO 3166-2 name for the first level region associated with
2403
+ * the IP address of the incoming request
2404
+ *
2405
+ * @example "Texas"
2406
+ */
2407
+ region?: string;
2408
+ /**
2409
+ * If known, the ISO 3166-2 code for the first-level region associated with
2410
+ * the IP address of the incoming request
2411
+ *
2412
+ * @example "TX"
2413
+ */
2414
+ regionCode?: string;
2415
+ /**
2416
+ * Metro code (DMA) of the incoming request
2417
+ *
2418
+ * @example "635"
2419
+ */
2420
+ metroCode?: string;
2421
+ }
2312
2422
  /** Data about the incoming request's TLS certificate */
2313
2423
  declare interface IncomingRequestCfPropertiesTLSClientAuth {
2314
2424
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2701,6 +2811,9 @@ declare type Iso3166Alpha2Code =
2701
2811
  | "ZW";
2702
2812
  /** The 2-letter continent codes Cloudflare uses */
2703
2813
  declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2814
+ declare type CfProperties<HostMetadata = unknown> =
2815
+ | IncomingRequestCfProperties<HostMetadata>
2816
+ | RequestInitCfProperties;
2704
2817
  declare interface D1Result<T = unknown> {
2705
2818
  results?: T[];
2706
2819
  success: boolean;
@@ -2721,9 +2834,9 @@ declare abstract class D1PreparedStatement {
2721
2834
  raw<T = unknown>(): Promise<T[]>;
2722
2835
  }
2723
2836
  /**
2724
- * A email message that is sent to a consumer Worker.
2837
+ * An email message that can be sent from a Worker.
2725
2838
  */
2726
- declare interface EmailMessage<Body = unknown> {
2839
+ declare interface EmailMessage {
2727
2840
  /**
2728
2841
  * Envelope From attribute of the email message.
2729
2842
  */
@@ -2732,14 +2845,19 @@ declare interface EmailMessage<Body = unknown> {
2732
2845
  * Envelope To attribute of the email message.
2733
2846
  */
2734
2847
  readonly to: string;
2735
- /**
2736
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2737
- */
2738
- readonly headers: Headers;
2848
+ }
2849
+ /**
2850
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2851
+ */
2852
+ declare interface ForwardableEmailMessage extends EmailMessage {
2739
2853
  /**
2740
2854
  * Stream of the email message content.
2741
2855
  */
2742
2856
  readonly raw: ReadableStream;
2857
+ /**
2858
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2859
+ */
2860
+ readonly headers: Headers;
2743
2861
  /**
2744
2862
  * Size of the email message content.
2745
2863
  */
@@ -2758,14 +2876,27 @@ declare interface EmailMessage<Body = unknown> {
2758
2876
  */
2759
2877
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2760
2878
  }
2879
+ /**
2880
+ * A binding that allows a Worker to send email messages.
2881
+ */
2882
+ declare interface SendEmail {
2883
+ send(message: EmailMessage): Promise<void>;
2884
+ }
2761
2885
  declare abstract class EmailEvent extends ExtendableEvent {
2762
- readonly message: EmailMessage;
2886
+ readonly message: ForwardableEmailMessage;
2763
2887
  }
2764
2888
  declare type EmailExportedHandler<Env = unknown> = (
2765
- message: EmailMessage,
2889
+ message: ForwardableEmailMessage,
2766
2890
  env: Env,
2767
2891
  ctx: ExecutionContext
2768
2892
  ) => void | Promise<void>;
2893
+ declare module "cloudflare:email" {
2894
+ let _EmailMessage: {
2895
+ prototype: EmailMessage;
2896
+ new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
2897
+ };
2898
+ export { _EmailMessage as EmailMessage };
2899
+ }
2769
2900
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2770
2901
  declare type EventContext<Env, P extends string, Data> = {
2771
2902
  request: Request;
@@ -2846,75 +2977,12 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
2846
2977
  // Key Identifier of the JWK
2847
2978
  readonly kid: string;
2848
2979
  }
2849
- /**
2850
- * A message that is sent to a consumer Worker.
2851
- */
2852
- declare interface Message<Body = unknown> {
2980
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
2981
+ declare interface DispatchNamespace {
2853
2982
  /**
2854
- * A unique, system-generated ID for the message.
2983
+ * @param name Name of the Worker script.
2984
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
2985
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2855
2986
  */
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>;
2987
+ get(name: string): Fetcher;
2920
2988
  }