@cloudflare/workers-types 0.20230307.0 → 0.20230512.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/oldest/index.ts CHANGED
@@ -49,6 +49,7 @@ export declare class DOMException extends Error {
49
49
  export type WorkerGlobalScopeEventMap = {
50
50
  fetch: FetchEvent;
51
51
  scheduled: ScheduledEvent;
52
+ queue: QueueEvent;
52
53
  unhandledrejection: PromiseRejectionEvent;
53
54
  rejectionhandled: PromiseRejectionEvent;
54
55
  };
@@ -183,11 +184,14 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
183
184
  crypto: Crypto;
184
185
  caches: CacheStorage;
185
186
  scheduler: Scheduler;
187
+ performance: Performance;
188
+ readonly origin: string;
186
189
  Event: typeof Event;
187
190
  ExtendableEvent: typeof ExtendableEvent;
188
191
  PromiseRejectionEvent: typeof PromiseRejectionEvent;
189
192
  FetchEvent: typeof FetchEvent;
190
- TraceEvent: typeof TraceEvent;
193
+ TailEvent: typeof TailEvent;
194
+ TraceEvent: typeof TailEvent;
191
195
  ScheduledEvent: typeof ScheduledEvent;
192
196
  MessageEvent: typeof MessageEvent;
193
197
  CloseEvent: typeof CloseEvent;
@@ -281,16 +285,26 @@ export declare const self: ServiceWorkerGlobalScope;
281
285
  export declare const crypto: Crypto;
282
286
  export declare const caches: CacheStorage;
283
287
  export declare const scheduler: Scheduler;
288
+ export declare const performance: Performance;
289
+ export declare const origin: string;
284
290
  export interface TestController {}
285
291
  export interface ExecutionContext {
286
292
  waitUntil(promise: Promise<any>): void;
287
293
  passThroughOnException(): void;
288
294
  }
289
- export type ExportedHandlerFetchHandler<Env = unknown> = (
290
- request: Request,
295
+ export type ExportedHandlerFetchHandler<
296
+ Env = unknown,
297
+ CfHostMetadata = unknown
298
+ > = (
299
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
291
300
  env: Env,
292
301
  ctx: ExecutionContext
293
302
  ) => Response | Promise<Response>;
303
+ export type ExportedHandlerTailHandler<Env = unknown> = (
304
+ events: TraceItem[],
305
+ env: Env,
306
+ ctx: ExecutionContext
307
+ ) => void | Promise<void>;
294
308
  export type ExportedHandlerTraceHandler<Env = unknown> = (
295
309
  traces: TraceItem[],
296
310
  env: Env,
@@ -311,12 +325,17 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
311
325
  env: Env,
312
326
  ctx: ExecutionContext
313
327
  ) => void | Promise<void>;
314
- export interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
315
- fetch?: ExportedHandlerFetchHandler<Env>;
328
+ export interface ExportedHandler<
329
+ Env = unknown,
330
+ QueueMessage = unknown,
331
+ CfHostMetadata = unknown
332
+ > {
333
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
334
+ tail?: ExportedHandlerTailHandler<Env>;
316
335
  trace?: ExportedHandlerTraceHandler<Env>;
317
336
  scheduled?: ExportedHandlerScheduledHandler<Env>;
318
337
  test?: ExportedHandlerTestHandler<Env>;
319
- queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
338
+ queue?: ExportedHandlerQueueHandler<Env, Message>;
320
339
  }
321
340
  export interface StructuredSerializeOptions {
322
341
  transfer?: any[];
@@ -325,6 +344,11 @@ export declare abstract class PromiseRejectionEvent extends Event {
325
344
  readonly promise: Promise<any>;
326
345
  readonly reason: any;
327
346
  }
347
+ /** Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
348
+ export interface Performance {
349
+ readonly timeOrigin: number;
350
+ now(): number;
351
+ }
328
352
  export interface DurableObject {
329
353
  fetch(request: Request): Response | Promise<Response>;
330
354
  alarm?(): void | Promise<void>;
@@ -348,19 +372,32 @@ export interface DurableObjectNamespace {
348
372
  id: DurableObjectId,
349
373
  options?: DurableObjectNamespaceGetDurableObjectOptions
350
374
  ): DurableObjectStub;
351
- jurisdiction(jurisdiction: string): DurableObjectNamespace;
375
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
352
376
  }
377
+ export type DurableObjectJurisdiction = "eu" | "fedramp";
353
378
  export interface DurableObjectNamespaceNewUniqueIdOptions {
354
- jurisdiction?: string;
355
- }
379
+ jurisdiction?: DurableObjectJurisdiction;
380
+ }
381
+ export type DurableObjectLocationHint =
382
+ | "wnam"
383
+ | "enam"
384
+ | "sam"
385
+ | "weur"
386
+ | "eeur"
387
+ | "apac"
388
+ | "oc"
389
+ | "afr"
390
+ | "me";
356
391
  export interface DurableObjectNamespaceGetDurableObjectOptions {
357
- locationHint?: string;
392
+ locationHint?: DurableObjectLocationHint;
358
393
  }
359
394
  export interface DurableObjectState {
360
395
  waitUntil(promise: Promise<any>): void;
361
396
  readonly id: DurableObjectId;
362
397
  readonly storage: DurableObjectStorage;
363
398
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
399
+ acceptWebSocket(ws: WebSocket, tags?: string[]): void;
400
+ getWebSockets(tag?: string): WebSocket[];
364
401
  }
365
402
  export interface DurableObjectTransaction {
366
403
  get<T = unknown>(
@@ -427,6 +464,7 @@ export interface DurableObjectStorage {
427
464
  ): Promise<void>;
428
465
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
429
466
  sync(): Promise<void>;
467
+ transactionSync<T>(closure: () => T): T;
430
468
  }
431
469
  export interface DurableObjectListOptions {
432
470
  start?: string;
@@ -547,6 +585,7 @@ export declare class AbortController {
547
585
  export declare abstract class AbortSignal extends EventTarget {
548
586
  static abort(reason?: any): AbortSignal;
549
587
  static timeout(delay: number): AbortSignal;
588
+ static any(signals: AbortSignal[]): AbortSignal;
550
589
  /** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
551
590
  readonly aborted: boolean;
552
591
  readonly reason: any;
@@ -997,10 +1036,16 @@ export interface ResponseInit {
997
1036
  webSocket?: WebSocket | null;
998
1037
  encodeBody?: "automatic" | "manual";
999
1038
  }
1000
- export type RequestInfo = Request | string | URL;
1001
- export declare class Request<CfHostMetadata = unknown> extends Body {
1002
- constructor(input: RequestInfo, init?: RequestInit);
1003
- clone(): Request<CfHostMetadata>;
1039
+ export type RequestInfo<
1040
+ CfHostMetadata = unknown,
1041
+ Cf = CfProperties<CfHostMetadata>
1042
+ > = Request<CfHostMetadata, Cf> | string | URL;
1043
+ export declare class Request<
1044
+ CfHostMetadata = unknown,
1045
+ Cf = CfProperties<CfHostMetadata>
1046
+ > extends Body {
1047
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1048
+ clone(): Request<CfHostMetadata, Cf>;
1004
1049
  /** Returns request's HTTP method, which is "GET" by default. */
1005
1050
  readonly method: string;
1006
1051
  /** Returns the URL of request as a string. */
@@ -1012,15 +1057,13 @@ export declare class Request<CfHostMetadata = unknown> extends Body {
1012
1057
  readonly fetcher: Fetcher | null;
1013
1058
  /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
1014
1059
  readonly signal: AbortSignal;
1015
- readonly cf?: IncomingRequestCfProperties<CfHostMetadata>;
1060
+ readonly cf?: Cf;
1016
1061
  /** 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] */
1017
1062
  readonly integrity: string;
1018
1063
  /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
1019
1064
  readonly keepalive: boolean;
1020
1065
  }
1021
- export interface RequestInit<
1022
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1023
- > {
1066
+ export interface RequestInit<Cf = CfProperties> {
1024
1067
  /** A string to set request's method. */
1025
1068
  method?: string;
1026
1069
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1030,17 +1073,15 @@ export interface RequestInit<
1030
1073
  /** 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. */
1031
1074
  redirect?: string;
1032
1075
  fetcher?: Fetcher | null;
1033
- cf?: CfType;
1076
+ cf?: Cf;
1034
1077
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1035
1078
  integrity?: string;
1036
1079
  /** An AbortSignal to set request's signal. */
1037
1080
  signal?: AbortSignal | null;
1038
1081
  }
1039
1082
  export declare abstract class Fetcher {
1040
- fetch(
1041
- input: RequestInfo,
1042
- init?: RequestInit<RequestInitCfProperties>
1043
- ): Promise<Response>;
1083
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1084
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1044
1085
  }
1045
1086
  export interface FetcherPutOptions {
1046
1087
  expiration?: number;
@@ -1153,6 +1194,33 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1153
1194
  value: Value | null;
1154
1195
  metadata: Metadata | null;
1155
1196
  }
1197
+ export interface Queue<Body> {
1198
+ send(message: Body): Promise<void>;
1199
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1200
+ }
1201
+ export interface QueueSendOptions {}
1202
+ export interface MessageSendRequest<Body = unknown> {
1203
+ body: Body;
1204
+ }
1205
+ export interface Message<Body = unknown> {
1206
+ readonly id: string;
1207
+ readonly timestamp: Date;
1208
+ readonly body: Body;
1209
+ retry(): void;
1210
+ ack(): void;
1211
+ }
1212
+ export interface QueueEvent<Body = unknown> extends ExtendableEvent {
1213
+ readonly messages: readonly Message<Body>[];
1214
+ readonly queue: string;
1215
+ retryAll(): void;
1216
+ ackAll(): void;
1217
+ }
1218
+ export interface MessageBatch<Body = unknown> {
1219
+ readonly messages: readonly Message<Body>[];
1220
+ readonly queue: string;
1221
+ retryAll(): void;
1222
+ ackAll(): void;
1223
+ }
1156
1224
  export interface R2Error extends Error {
1157
1225
  readonly name: string;
1158
1226
  readonly code: number;
@@ -1303,12 +1371,18 @@ export interface R2HTTPMetadata {
1303
1371
  cacheControl?: string;
1304
1372
  cacheExpiry?: Date;
1305
1373
  }
1306
- export interface R2Objects {
1374
+ export type R2Objects = {
1307
1375
  objects: R2Object[];
1308
- truncated: boolean;
1309
- cursor?: string;
1310
1376
  delimitedPrefixes: string[];
1311
- }
1377
+ } & (
1378
+ | {
1379
+ truncated: true;
1380
+ cursor: string;
1381
+ }
1382
+ | {
1383
+ truncated: false;
1384
+ }
1385
+ );
1312
1386
  export declare abstract class ScheduledEvent extends ExtendableEvent {
1313
1387
  readonly scheduledTime: number;
1314
1388
  readonly cron: string;
@@ -1519,13 +1593,19 @@ export declare class TransformStream<I = any, O = any> {
1519
1593
  readonly writable: WritableStream<I>;
1520
1594
  }
1521
1595
  export declare class FixedLengthStream extends IdentityTransformStream {
1522
- constructor(expectedLength: number | bigint);
1596
+ constructor(
1597
+ expectedLength: number | bigint,
1598
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1599
+ );
1523
1600
  }
1524
1601
  export declare class IdentityTransformStream extends TransformStream<
1525
1602
  ArrayBuffer | ArrayBufferView,
1526
1603
  Uint8Array
1527
1604
  > {
1528
- constructor();
1605
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1606
+ }
1607
+ export interface IdentityTransformStreamQueuingStrategy {
1608
+ highWaterMark?: number | bigint;
1529
1609
  }
1530
1610
  export interface ReadableStreamValuesOptions {
1531
1611
  preventCancel?: boolean;
@@ -1577,7 +1657,8 @@ export interface QueuingStrategyInit {
1577
1657
  */
1578
1658
  highWaterMark: number;
1579
1659
  }
1580
- export declare abstract class TraceEvent extends ExtendableEvent {
1660
+ export declare abstract class TailEvent extends ExtendableEvent {
1661
+ readonly events: TraceItem[];
1581
1662
  readonly traces: TraceItem[];
1582
1663
  }
1583
1664
  export interface TraceItem {
@@ -1777,6 +1858,8 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
1777
1858
  accept(): void;
1778
1859
  send(message: (ArrayBuffer | ArrayBufferView) | string): void;
1779
1860
  close(code?: number, reason?: string): void;
1861
+ serializeAttachment(attachment: any): void;
1862
+ deserializeAttachment(): any | null;
1780
1863
  static readonly READY_STATE_CONNECTING: number;
1781
1864
  static readonly READY_STATE_OPEN: number;
1782
1865
  static readonly READY_STATE_CLOSING: number;
@@ -1796,6 +1879,24 @@ export declare const WebSocketPair: {
1796
1879
  1: WebSocket;
1797
1880
  };
1798
1881
  };
1882
+ export 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
+ export interface SocketOptions {
1890
+ secureTransport?: string;
1891
+ allowHalfOpen: boolean;
1892
+ }
1893
+ export interface SocketAddress {
1894
+ hostname: string;
1895
+ port: number;
1896
+ }
1897
+ export interface TlsOptions {
1898
+ expectedServerHostname?: string;
1899
+ }
1799
1900
  export interface BasicImageTransformations {
1800
1901
  /**
1801
1902
  * Maximum width in image pixels. The value must be an integer.
@@ -1875,7 +1976,7 @@ export interface BasicImageTransformationsGravityCoordinates {
1875
1976
  * Note: Currently, these properties cannot be tested in the
1876
1977
  * playground.
1877
1978
  */
1878
- export interface RequestInitCfProperties {
1979
+ export interface RequestInitCfProperties extends Record<string, unknown> {
1879
1980
  cacheEverything?: boolean;
1880
1981
  /**
1881
1982
  * A request's cache key is what determines if two requests are
@@ -2045,6 +2146,49 @@ export interface RequestInitCfPropertiesImage
2045
2146
  * the origin.
2046
2147
  */
2047
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";
2048
2192
  }
2049
2193
  export interface RequestInitCfPropertiesImageMinify {
2050
2194
  javascript?: boolean;
@@ -2060,7 +2204,8 @@ export type IncomingRequestCfProperties<HostMetadata = unknown> =
2060
2204
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2061
2205
  IncomingRequestCfPropertiesGeographicInformation &
2062
2206
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2063
- export interface IncomingRequestCfPropertiesBase {
2207
+ export interface IncomingRequestCfPropertiesBase
2208
+ extends Record<string, unknown> {
2064
2209
  /**
2065
2210
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2066
2211
  *
@@ -2141,8 +2286,7 @@ export interface IncomingRequestCfPropertiesBase {
2141
2286
  export interface IncomingRequestCfPropertiesBotManagementBase {
2142
2287
  /**
2143
2288
  * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2144
- * represented as an integer percentage between `1` (almost certainly human)
2145
- * and `99` (almost certainly a bot).
2289
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2146
2290
  *
2147
2291
  * @example 54
2148
2292
  */
@@ -2253,86 +2397,82 @@ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2253
2397
  /**
2254
2398
  * Geographic data about the request's origin.
2255
2399
  */
2256
- export type IncomingRequestCfPropertiesGeographicInformation =
2257
- | {}
2258
- | {
2259
- /** The country code `"T1"` is used for requests originating on TOR */
2260
- country: "T1";
2261
- }
2262
- | {
2263
- /**
2264
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2265
- *
2266
- * 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.
2267
- *
2268
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2269
- *
2270
- * @example "GB"
2271
- */
2272
- country: Iso3166Alpha2Code;
2273
- /**
2274
- * If present, this property indicates that the request originated in the EU
2275
- *
2276
- * @example "1"
2277
- */
2278
- isEUCountry?: "1";
2279
- /**
2280
- * A two-letter code indicating the continent the request originated from.
2281
- *
2282
- * @example "AN"
2283
- */
2284
- continent: ContinentCode;
2285
- /**
2286
- * The city the request originated from
2287
- *
2288
- * @example "Austin"
2289
- */
2290
- city?: string;
2291
- /**
2292
- * Postal code of the incoming request
2293
- *
2294
- * @example "78701"
2295
- */
2296
- postalCode?: string;
2297
- /**
2298
- * Latitude of the incoming request
2299
- *
2300
- * @example "30.27130"
2301
- */
2302
- latitude?: string;
2303
- /**
2304
- * Longitude of the incoming request
2305
- *
2306
- * @example "-97.74260"
2307
- */
2308
- longitude?: string;
2309
- /**
2310
- * Timezone of the incoming request
2311
- *
2312
- * @example "America/Chicago"
2313
- */
2314
- timezone?: string;
2315
- /**
2316
- * If known, the ISO 3166-2 name for the first level region associated with
2317
- * the IP address of the incoming request
2318
- *
2319
- * @example "Texas"
2320
- */
2321
- region?: string;
2322
- /**
2323
- * If known, the ISO 3166-2 code for the first-level region associated with
2324
- * the IP address of the incoming request
2325
- *
2326
- * @example "TX"
2327
- */
2328
- regionCode?: string;
2329
- /**
2330
- * Metro code (DMA) of the incoming request
2331
- *
2332
- * @example "635"
2333
- */
2334
- metroCode?: string;
2335
- };
2400
+ export 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
+ }
2336
2476
  /** Data about the incoming request's TLS certificate */
2337
2477
  export interface IncomingRequestCfPropertiesTLSClientAuth {
2338
2478
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2725,6 +2865,9 @@ export type Iso3166Alpha2Code =
2725
2865
  | "ZW";
2726
2866
  /** The 2-letter continent codes Cloudflare uses */
2727
2867
  export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2868
+ export type CfProperties<HostMetadata = unknown> =
2869
+ | IncomingRequestCfProperties<HostMetadata>
2870
+ | RequestInitCfProperties;
2728
2871
  export interface D1Result<T = unknown> {
2729
2872
  results?: T[];
2730
2873
  success: boolean;
@@ -2745,7 +2888,7 @@ export declare abstract class D1PreparedStatement {
2745
2888
  raw<T = unknown>(): Promise<T[]>;
2746
2889
  }
2747
2890
  /**
2748
- * A email message that is sent to a consumer Worker.
2891
+ * An email message that can be sent from a Worker.
2749
2892
  */
2750
2893
  export interface EmailMessage {
2751
2894
  /**
@@ -2756,14 +2899,19 @@ export interface EmailMessage {
2756
2899
  * Envelope To attribute of the email message.
2757
2900
  */
2758
2901
  readonly to: string;
2759
- /**
2760
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2761
- */
2762
- readonly headers: Headers;
2902
+ }
2903
+ /**
2904
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2905
+ */
2906
+ export interface ForwardableEmailMessage extends EmailMessage {
2763
2907
  /**
2764
2908
  * Stream of the email message content.
2765
2909
  */
2766
2910
  readonly raw: ReadableStream;
2911
+ /**
2912
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2913
+ */
2914
+ readonly headers: Headers;
2767
2915
  /**
2768
2916
  * Size of the email message content.
2769
2917
  */
@@ -2782,11 +2930,17 @@ export interface EmailMessage {
2782
2930
  */
2783
2931
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2784
2932
  }
2933
+ /**
2934
+ * A binding that allows a Worker to send email messages.
2935
+ */
2936
+ export interface SendEmail {
2937
+ send(message: EmailMessage): Promise<void>;
2938
+ }
2785
2939
  export declare abstract class EmailEvent extends ExtendableEvent {
2786
- readonly message: EmailMessage;
2940
+ readonly message: ForwardableEmailMessage;
2787
2941
  }
2788
2942
  export type EmailExportedHandler<Env = unknown> = (
2789
- message: EmailMessage,
2943
+ message: ForwardableEmailMessage,
2790
2944
  env: Env,
2791
2945
  ctx: ExecutionContext
2792
2946
  ) => void | Promise<void>;
@@ -2867,75 +3021,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
2867
3021
  // Key Identifier of the JWK
2868
3022
  readonly kid: string;
2869
3023
  }
2870
- /**
2871
- * A message that is sent to a consumer Worker.
2872
- */
2873
- export interface Message<Body = unknown> {
2874
- /**
2875
- * A unique, system-generated ID for the message.
2876
- */
2877
- readonly id: string;
3024
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3025
+ export interface DispatchNamespace {
2878
3026
  /**
2879
- * A timestamp when the message was sent.
3027
+ * @param name Name of the Worker script.
3028
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
3029
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2880
3030
  */
2881
- readonly timestamp: Date;
2882
- /**
2883
- * The body of the message.
2884
- */
2885
- readonly body: Body;
2886
- /**
2887
- * Marks message to be retried.
2888
- */
2889
- retry(): void;
2890
- /**
2891
- * Marks message acknowledged.
2892
- */
2893
- ack(): void;
2894
- }
2895
- /**
2896
- * A batch of messages that are sent to a consumer Worker.
2897
- */
2898
- export interface MessageBatch<Body = unknown> {
2899
- /**
2900
- * The name of the Queue that belongs to this batch.
2901
- */
2902
- readonly queue: string;
2903
- /**
2904
- * An array of messages in the batch. Ordering of messages is not guaranteed.
2905
- */
2906
- readonly messages: readonly Message<Body>[];
2907
- /**
2908
- * Marks every message to be retried in the next batch.
2909
- */
2910
- retryAll(): void;
2911
- /**
2912
- * Marks every message acknowledged in the batch.
2913
- */
2914
- ackAll(): void;
2915
- }
2916
- /**
2917
- * A wrapper class used to structure message batches.
2918
- */
2919
- export type MessageSendRequest<Body = unknown> = {
2920
- /**
2921
- * The body of the message.
2922
- */
2923
- body: Body;
2924
- };
2925
- /**
2926
- * A binding that allows a producer to send messages to a Queue.
2927
- */
2928
- export interface Queue<Body = any> {
2929
- /**
2930
- * Sends a message to the Queue.
2931
- * @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.
2932
- * @returns A promise that resolves when the message is confirmed to be written to disk.
2933
- */
2934
- send(message: Body): Promise<void>;
2935
- /**
2936
- * Sends a batch of messages to the Queue.
2937
- * @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.
2938
- * @returns A promise that resolves when the messages are confirmed to be written to disk.
2939
- */
2940
- sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
3031
+ get(name: string): Fetcher;
2941
3032
  }