@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;
@@ -1280,12 +1334,18 @@ declare interface R2HTTPMetadata {
1280
1334
  cacheControl?: string;
1281
1335
  cacheExpiry?: Date;
1282
1336
  }
1283
- declare interface R2Objects {
1337
+ declare type R2Objects = {
1284
1338
  objects: R2Object[];
1285
- truncated: boolean;
1286
- cursor?: string;
1287
1339
  delimitedPrefixes: string[];
1288
- }
1340
+ } & (
1341
+ | {
1342
+ truncated: true;
1343
+ cursor: string;
1344
+ }
1345
+ | {
1346
+ truncated: false;
1347
+ }
1348
+ );
1289
1349
  declare abstract class ScheduledEvent extends ExtendableEvent {
1290
1350
  readonly scheduledTime: number;
1291
1351
  readonly cron: string;
@@ -1496,13 +1556,19 @@ declare class TransformStream<I = any, O = any> {
1496
1556
  get writable(): WritableStream<I>;
1497
1557
  }
1498
1558
  declare class FixedLengthStream extends IdentityTransformStream {
1499
- constructor(expectedLength: number | bigint);
1559
+ constructor(
1560
+ expectedLength: number | bigint,
1561
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1562
+ );
1500
1563
  }
1501
1564
  declare class IdentityTransformStream extends TransformStream<
1502
1565
  ArrayBuffer | ArrayBufferView,
1503
1566
  Uint8Array
1504
1567
  > {
1505
- constructor();
1568
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1569
+ }
1570
+ declare interface IdentityTransformStreamQueuingStrategy {
1571
+ highWaterMark?: number | bigint;
1506
1572
  }
1507
1573
  declare interface ReadableStreamValuesOptions {
1508
1574
  preventCancel?: boolean;
@@ -1511,13 +1577,13 @@ declare class CompressionStream extends TransformStream<
1511
1577
  ArrayBuffer | ArrayBufferView,
1512
1578
  Uint8Array
1513
1579
  > {
1514
- constructor(format: "gzip" | "deflate");
1580
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1515
1581
  }
1516
1582
  declare class DecompressionStream extends TransformStream<
1517
1583
  ArrayBuffer | ArrayBufferView,
1518
1584
  Uint8Array
1519
1585
  > {
1520
- constructor(format: "gzip" | "deflate");
1586
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1521
1587
  }
1522
1588
  declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
1523
1589
  constructor();
@@ -1656,6 +1722,7 @@ declare class URLSearchParams {
1656
1722
  | Record<string, string>
1657
1723
  | [key: string, value: string][]
1658
1724
  );
1725
+ get size(): number;
1659
1726
  append(name: string, value: string): void;
1660
1727
  delete(name: string): void;
1661
1728
  get(name: string): string | null;
@@ -1854,7 +1921,7 @@ declare interface BasicImageTransformationsGravityCoordinates {
1854
1921
  * Note: Currently, these properties cannot be tested in the
1855
1922
  * playground.
1856
1923
  */
1857
- declare interface RequestInitCfProperties {
1924
+ declare interface RequestInitCfProperties extends Record<string, unknown> {
1858
1925
  cacheEverything?: boolean;
1859
1926
  /**
1860
1927
  * A request's cache key is what determines if two requests are
@@ -2024,6 +2091,49 @@ declare interface RequestInitCfPropertiesImage
2024
2091
  * the origin.
2025
2092
  */
2026
2093
  "origin-auth"?: "share-publicly";
2094
+ /**
2095
+ * Adds a border around the image. The border is added after resizing. Border
2096
+ * width takes dpr into account, and can be specified either using a single
2097
+ * width property, or individually for each side.
2098
+ */
2099
+ border?:
2100
+ | {
2101
+ color: string;
2102
+ width: number;
2103
+ }
2104
+ | {
2105
+ color: string;
2106
+ top: number;
2107
+ right: number;
2108
+ bottom: number;
2109
+ left: number;
2110
+ };
2111
+ /**
2112
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2113
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2114
+ * 0 is ignored.
2115
+ */
2116
+ brightness?: number;
2117
+ /**
2118
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2119
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2120
+ * ignored.
2121
+ */
2122
+ contrast?: number;
2123
+ /**
2124
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2125
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2126
+ */
2127
+ gamma?: number;
2128
+ /**
2129
+ * Slightly reduces latency on a cache miss by selecting a
2130
+ * quickest-to-compress file format, at a cost of increased file size and
2131
+ * lower image quality. It will usually override the format option and choose
2132
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2133
+ * unusual circumstances like resizing uncacheable dynamically-generated
2134
+ * images.
2135
+ */
2136
+ compression?: "fast";
2027
2137
  }
2028
2138
  declare interface RequestInitCfPropertiesImageMinify {
2029
2139
  javascript?: boolean;
@@ -2039,7 +2149,8 @@ declare type IncomingRequestCfProperties<HostMetadata = unknown> =
2039
2149
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2040
2150
  IncomingRequestCfPropertiesGeographicInformation &
2041
2151
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2042
- declare interface IncomingRequestCfPropertiesBase {
2152
+ declare interface IncomingRequestCfPropertiesBase
2153
+ extends Record<string, unknown> {
2043
2154
  /**
2044
2155
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2045
2156
  *
@@ -2120,8 +2231,7 @@ declare interface IncomingRequestCfPropertiesBase {
2120
2231
  declare interface IncomingRequestCfPropertiesBotManagementBase {
2121
2232
  /**
2122
2233
  * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2123
- * represented as an integer percentage between `1` (almost certainly human)
2124
- * and `99` (almost certainly a bot).
2234
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2125
2235
  *
2126
2236
  * @example 54
2127
2237
  */
@@ -2140,6 +2250,10 @@ declare interface IncomingRequestCfPropertiesBotManagementBase {
2140
2250
  * 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.
2141
2251
  */
2142
2252
  staticResource: boolean;
2253
+ /**
2254
+ * 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).
2255
+ */
2256
+ detectionIds: number[];
2143
2257
  }
2144
2258
  declare interface IncomingRequestCfPropertiesBotManagement {
2145
2259
  /**
@@ -2228,86 +2342,82 @@ declare interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2228
2342
  /**
2229
2343
  * Geographic data about the request's origin.
2230
2344
  */
2231
- declare type IncomingRequestCfPropertiesGeographicInformation =
2232
- | {}
2233
- | {
2234
- /** The country code `"T1"` is used for requests originating on TOR */
2235
- country: "T1";
2236
- }
2237
- | {
2238
- /**
2239
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2240
- *
2241
- * 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.
2242
- *
2243
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2244
- *
2245
- * @example "GB"
2246
- */
2247
- country: Iso3166Alpha2Code;
2248
- /**
2249
- * If present, this property indicates that the request originated in the EU
2250
- *
2251
- * @example "1"
2252
- */
2253
- isEUCountry?: "1";
2254
- /**
2255
- * A two-letter code indicating the continent the request originated from.
2256
- *
2257
- * @example "AN"
2258
- */
2259
- continent: ContinentCode;
2260
- /**
2261
- * The city the request originated from
2262
- *
2263
- * @example "Austin"
2264
- */
2265
- city?: string;
2266
- /**
2267
- * Postal code of the incoming request
2268
- *
2269
- * @example "78701"
2270
- */
2271
- postalCode?: string;
2272
- /**
2273
- * Latitude of the incoming request
2274
- *
2275
- * @example "30.27130"
2276
- */
2277
- latitude?: string;
2278
- /**
2279
- * Longitude of the incoming request
2280
- *
2281
- * @example "-97.74260"
2282
- */
2283
- longitude?: string;
2284
- /**
2285
- * Timezone of the incoming request
2286
- *
2287
- * @example "America/Chicago"
2288
- */
2289
- timezone?: string;
2290
- /**
2291
- * If known, the ISO 3166-2 name for the first level region associated with
2292
- * the IP address of the incoming request
2293
- *
2294
- * @example "Texas"
2295
- */
2296
- region?: string;
2297
- /**
2298
- * If known, the ISO 3166-2 code for the first-level region associated with
2299
- * the IP address of the incoming request
2300
- *
2301
- * @example "TX"
2302
- */
2303
- regionCode?: string;
2304
- /**
2305
- * Metro code (DMA) of the incoming request
2306
- *
2307
- * @example "635"
2308
- */
2309
- metroCode?: string;
2310
- };
2345
+ declare interface IncomingRequestCfPropertiesGeographicInformation {
2346
+ /**
2347
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2348
+ *
2349
+ * 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.
2350
+ *
2351
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2352
+ *
2353
+ * The country code `"T1"` is used for requests originating on TOR.
2354
+ *
2355
+ * @example "GB"
2356
+ */
2357
+ country?: Iso3166Alpha2Code | "T1";
2358
+ /**
2359
+ * If present, this property indicates that the request originated in the EU
2360
+ *
2361
+ * @example "1"
2362
+ */
2363
+ isEUCountry?: "1";
2364
+ /**
2365
+ * A two-letter code indicating the continent the request originated from.
2366
+ *
2367
+ * @example "AN"
2368
+ */
2369
+ continent?: ContinentCode;
2370
+ /**
2371
+ * The city the request originated from
2372
+ *
2373
+ * @example "Austin"
2374
+ */
2375
+ city?: string;
2376
+ /**
2377
+ * Postal code of the incoming request
2378
+ *
2379
+ * @example "78701"
2380
+ */
2381
+ postalCode?: string;
2382
+ /**
2383
+ * Latitude of the incoming request
2384
+ *
2385
+ * @example "30.27130"
2386
+ */
2387
+ latitude?: string;
2388
+ /**
2389
+ * Longitude of the incoming request
2390
+ *
2391
+ * @example "-97.74260"
2392
+ */
2393
+ longitude?: string;
2394
+ /**
2395
+ * Timezone of the incoming request
2396
+ *
2397
+ * @example "America/Chicago"
2398
+ */
2399
+ timezone?: string;
2400
+ /**
2401
+ * If known, the ISO 3166-2 name for the first level region associated with
2402
+ * the IP address of the incoming request
2403
+ *
2404
+ * @example "Texas"
2405
+ */
2406
+ region?: string;
2407
+ /**
2408
+ * If known, the ISO 3166-2 code for the first-level region associated with
2409
+ * the IP address of the incoming request
2410
+ *
2411
+ * @example "TX"
2412
+ */
2413
+ regionCode?: string;
2414
+ /**
2415
+ * Metro code (DMA) of the incoming request
2416
+ *
2417
+ * @example "635"
2418
+ */
2419
+ metroCode?: string;
2420
+ }
2311
2421
  /** Data about the incoming request's TLS certificate */
2312
2422
  declare interface IncomingRequestCfPropertiesTLSClientAuth {
2313
2423
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2700,6 +2810,9 @@ declare type Iso3166Alpha2Code =
2700
2810
  | "ZW";
2701
2811
  /** The 2-letter continent codes Cloudflare uses */
2702
2812
  declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2813
+ declare type CfProperties<HostMetadata = unknown> =
2814
+ | IncomingRequestCfProperties<HostMetadata>
2815
+ | RequestInitCfProperties;
2703
2816
  declare interface D1Result<T = unknown> {
2704
2817
  results?: T[];
2705
2818
  success: boolean;
@@ -2720,9 +2833,9 @@ declare abstract class D1PreparedStatement {
2720
2833
  raw<T = unknown>(): Promise<T[]>;
2721
2834
  }
2722
2835
  /**
2723
- * A email message that is sent to a consumer Worker.
2836
+ * An email message that can be sent from a Worker.
2724
2837
  */
2725
- declare interface EmailMessage<Body = unknown> {
2838
+ declare interface EmailMessage {
2726
2839
  /**
2727
2840
  * Envelope From attribute of the email message.
2728
2841
  */
@@ -2731,14 +2844,19 @@ declare interface EmailMessage<Body = unknown> {
2731
2844
  * Envelope To attribute of the email message.
2732
2845
  */
2733
2846
  readonly to: string;
2734
- /**
2735
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2736
- */
2737
- readonly headers: Headers;
2847
+ }
2848
+ /**
2849
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2850
+ */
2851
+ declare interface ForwardableEmailMessage extends EmailMessage {
2738
2852
  /**
2739
2853
  * Stream of the email message content.
2740
2854
  */
2741
2855
  readonly raw: ReadableStream;
2856
+ /**
2857
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2858
+ */
2859
+ readonly headers: Headers;
2742
2860
  /**
2743
2861
  * Size of the email message content.
2744
2862
  */
@@ -2757,14 +2875,27 @@ declare interface EmailMessage<Body = unknown> {
2757
2875
  */
2758
2876
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2759
2877
  }
2878
+ /**
2879
+ * A binding that allows a Worker to send email messages.
2880
+ */
2881
+ declare interface SendEmail {
2882
+ send(message: EmailMessage): Promise<void>;
2883
+ }
2760
2884
  declare abstract class EmailEvent extends ExtendableEvent {
2761
- readonly message: EmailMessage;
2885
+ readonly message: ForwardableEmailMessage;
2762
2886
  }
2763
2887
  declare type EmailExportedHandler<Env = unknown> = (
2764
- message: EmailMessage,
2888
+ message: ForwardableEmailMessage,
2765
2889
  env: Env,
2766
2890
  ctx: ExecutionContext
2767
2891
  ) => void | Promise<void>;
2892
+ declare module "cloudflare:email" {
2893
+ let _EmailMessage: {
2894
+ prototype: EmailMessage;
2895
+ new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
2896
+ };
2897
+ export { _EmailMessage as EmailMessage };
2898
+ }
2768
2899
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2769
2900
  declare type EventContext<Env, P extends string, Data> = {
2770
2901
  request: Request;
@@ -2845,75 +2976,12 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
2845
2976
  // Key Identifier of the JWK
2846
2977
  readonly kid: string;
2847
2978
  }
2848
- /**
2849
- * A message that is sent to a consumer Worker.
2850
- */
2851
- declare interface Message<Body = unknown> {
2979
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
2980
+ declare interface DispatchNamespace {
2852
2981
  /**
2853
- * A unique, system-generated ID for the message.
2982
+ * @param name Name of the Worker script.
2983
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
2984
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2854
2985
  */
2855
- readonly id: string;
2856
- /**
2857
- * A timestamp when the message was sent.
2858
- */
2859
- readonly timestamp: Date;
2860
- /**
2861
- * The body of the message.
2862
- */
2863
- readonly body: Body;
2864
- /**
2865
- * Marks message to be retried.
2866
- */
2867
- retry(): void;
2868
- /**
2869
- * Marks message acknowledged.
2870
- */
2871
- ack(): void;
2872
- }
2873
- /**
2874
- * A batch of messages that are sent to a consumer Worker.
2875
- */
2876
- declare interface MessageBatch<Body = unknown> {
2877
- /**
2878
- * The name of the Queue that belongs to this batch.
2879
- */
2880
- readonly queue: string;
2881
- /**
2882
- * An array of messages in the batch. Ordering of messages is not guaranteed.
2883
- */
2884
- readonly messages: readonly Message<Body>[];
2885
- /**
2886
- * Marks every message to be retried in the next batch.
2887
- */
2888
- retryAll(): void;
2889
- /**
2890
- * Marks every message acknowledged in the batch.
2891
- */
2892
- ackAll(): void;
2893
- }
2894
- /**
2895
- * A wrapper class used to structure message batches.
2896
- */
2897
- declare type MessageSendRequest<Body = unknown> = {
2898
- /**
2899
- * The body of the message.
2900
- */
2901
- body: Body;
2902
- };
2903
- /**
2904
- * A binding that allows a producer to send messages to a Queue.
2905
- */
2906
- declare interface Queue<Body = any> {
2907
- /**
2908
- * Sends a message to the Queue.
2909
- * @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.
2910
- * @returns A promise that resolves when the message is confirmed to be written to disk.
2911
- */
2912
- send(message: Body): Promise<void>;
2913
- /**
2914
- * Sends a batch of messages to the Queue.
2915
- * @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.
2916
- * @returns A promise that resolves when the messages are confirmed to be written to disk.
2917
- */
2918
- sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2986
+ get(name: string): Fetcher;
2919
2987
  }