@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.
@@ -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;
@@ -283,17 +287,27 @@ export declare const self: ServiceWorkerGlobalScope;
283
287
  export declare const crypto: Crypto;
284
288
  export declare const caches: CacheStorage;
285
289
  export declare const scheduler: Scheduler;
290
+ export declare const performance: Performance;
291
+ export declare const origin: string;
286
292
  export declare const navigator: Navigator;
287
293
  export interface TestController {}
288
294
  export interface ExecutionContext {
289
295
  waitUntil(promise: Promise<any>): void;
290
296
  passThroughOnException(): void;
291
297
  }
292
- export type ExportedHandlerFetchHandler<Env = unknown> = (
293
- request: Request,
298
+ export type ExportedHandlerFetchHandler<
299
+ Env = unknown,
300
+ CfHostMetadata = unknown
301
+ > = (
302
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
294
303
  env: Env,
295
304
  ctx: ExecutionContext
296
305
  ) => Response | Promise<Response>;
306
+ export type ExportedHandlerTailHandler<Env = unknown> = (
307
+ events: TraceItem[],
308
+ env: Env,
309
+ ctx: ExecutionContext
310
+ ) => void | Promise<void>;
297
311
  export type ExportedHandlerTraceHandler<Env = unknown> = (
298
312
  traces: TraceItem[],
299
313
  env: Env,
@@ -314,12 +328,17 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
314
328
  env: Env,
315
329
  ctx: ExecutionContext
316
330
  ) => void | Promise<void>;
317
- export interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
318
- fetch?: ExportedHandlerFetchHandler<Env>;
331
+ export interface ExportedHandler<
332
+ Env = unknown,
333
+ QueueMessage = unknown,
334
+ CfHostMetadata = unknown
335
+ > {
336
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
337
+ tail?: ExportedHandlerTailHandler<Env>;
319
338
  trace?: ExportedHandlerTraceHandler<Env>;
320
339
  scheduled?: ExportedHandlerScheduledHandler<Env>;
321
340
  test?: ExportedHandlerTestHandler<Env>;
322
- queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
341
+ queue?: ExportedHandlerQueueHandler<Env, Message>;
323
342
  }
324
343
  export interface StructuredSerializeOptions {
325
344
  transfer?: any[];
@@ -331,6 +350,11 @@ export declare abstract class PromiseRejectionEvent extends Event {
331
350
  export declare abstract class Navigator {
332
351
  readonly userAgent: string;
333
352
  }
353
+ /** 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. */
354
+ export interface Performance {
355
+ readonly timeOrigin: number;
356
+ now(): number;
357
+ }
334
358
  export interface DurableObject {
335
359
  fetch(request: Request): Response | Promise<Response>;
336
360
  alarm?(): void | Promise<void>;
@@ -354,19 +378,32 @@ export interface DurableObjectNamespace {
354
378
  id: DurableObjectId,
355
379
  options?: DurableObjectNamespaceGetDurableObjectOptions
356
380
  ): DurableObjectStub;
357
- jurisdiction(jurisdiction: string): DurableObjectNamespace;
381
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
358
382
  }
383
+ export type DurableObjectJurisdiction = "eu" | "fedramp";
359
384
  export interface DurableObjectNamespaceNewUniqueIdOptions {
360
- jurisdiction?: string;
361
- }
385
+ jurisdiction?: DurableObjectJurisdiction;
386
+ }
387
+ export type DurableObjectLocationHint =
388
+ | "wnam"
389
+ | "enam"
390
+ | "sam"
391
+ | "weur"
392
+ | "eeur"
393
+ | "apac"
394
+ | "oc"
395
+ | "afr"
396
+ | "me";
362
397
  export interface DurableObjectNamespaceGetDurableObjectOptions {
363
- locationHint?: string;
398
+ locationHint?: DurableObjectLocationHint;
364
399
  }
365
400
  export interface DurableObjectState {
366
401
  waitUntil(promise: Promise<any>): void;
367
402
  readonly id: DurableObjectId;
368
403
  readonly storage: DurableObjectStorage;
369
404
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
405
+ acceptWebSocket(ws: WebSocket, tags?: string[]): void;
406
+ getWebSockets(tag?: string): WebSocket[];
370
407
  }
371
408
  export interface DurableObjectTransaction {
372
409
  get<T = unknown>(
@@ -433,6 +470,7 @@ export interface DurableObjectStorage {
433
470
  ): Promise<void>;
434
471
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
435
472
  sync(): Promise<void>;
473
+ transactionSync<T>(closure: () => T): T;
436
474
  }
437
475
  export interface DurableObjectListOptions {
438
476
  start?: string;
@@ -542,6 +580,7 @@ export declare class AbortController {
542
580
  export declare abstract class AbortSignal extends EventTarget {
543
581
  static abort(reason?: any): AbortSignal;
544
582
  static timeout(delay: number): AbortSignal;
583
+ static any(signals: AbortSignal[]): AbortSignal;
545
584
  get aborted(): boolean;
546
585
  get reason(): any;
547
586
  throwIfAborted(): void;
@@ -990,23 +1029,27 @@ export interface ResponseInit {
990
1029
  webSocket?: WebSocket | null;
991
1030
  encodeBody?: "automatic" | "manual";
992
1031
  }
993
- export type RequestInfo = Request | string | URL;
994
- export declare class Request<CfHostMetadata = unknown> extends Body {
995
- constructor(input: RequestInfo, init?: RequestInit);
996
- clone(): Request<CfHostMetadata>;
1032
+ export type RequestInfo<
1033
+ CfHostMetadata = unknown,
1034
+ Cf = CfProperties<CfHostMetadata>
1035
+ > = Request<CfHostMetadata, Cf> | string | URL;
1036
+ export declare class Request<
1037
+ CfHostMetadata = unknown,
1038
+ Cf = CfProperties<CfHostMetadata>
1039
+ > extends Body {
1040
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1041
+ clone(): Request<CfHostMetadata, Cf>;
997
1042
  get method(): string;
998
1043
  get url(): string;
999
1044
  get headers(): Headers;
1000
1045
  get redirect(): string;
1001
1046
  get fetcher(): Fetcher | null;
1002
1047
  get signal(): AbortSignal;
1003
- get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
1048
+ get cf(): Cf | undefined;
1004
1049
  get integrity(): string;
1005
1050
  get keepalive(): boolean;
1006
1051
  }
1007
- export interface RequestInit<
1008
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1009
- > {
1052
+ export interface RequestInit<Cf = CfProperties> {
1010
1053
  /** A string to set request's method. */
1011
1054
  method?: string;
1012
1055
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1016,17 +1059,15 @@ export interface RequestInit<
1016
1059
  /** 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. */
1017
1060
  redirect?: string;
1018
1061
  fetcher?: Fetcher | null;
1019
- cf?: CfType;
1062
+ cf?: Cf;
1020
1063
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1021
1064
  integrity?: string;
1022
1065
  /** An AbortSignal to set request's signal. */
1023
1066
  signal?: AbortSignal | null;
1024
1067
  }
1025
1068
  export declare abstract class Fetcher {
1026
- fetch(
1027
- input: RequestInfo,
1028
- init?: RequestInit<RequestInitCfProperties>
1029
- ): Promise<Response>;
1069
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1070
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1030
1071
  }
1031
1072
  export interface FetcherPutOptions {
1032
1073
  expiration?: number;
@@ -1139,6 +1180,33 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1139
1180
  value: Value | null;
1140
1181
  metadata: Metadata | null;
1141
1182
  }
1183
+ export interface Queue<Body> {
1184
+ send(message: Body): Promise<void>;
1185
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1186
+ }
1187
+ export interface QueueSendOptions {}
1188
+ export interface MessageSendRequest<Body = unknown> {
1189
+ body: Body;
1190
+ }
1191
+ export interface Message<Body = unknown> {
1192
+ readonly id: string;
1193
+ readonly timestamp: Date;
1194
+ readonly body: Body;
1195
+ retry(): void;
1196
+ ack(): void;
1197
+ }
1198
+ export interface QueueEvent<Body = unknown> extends ExtendableEvent {
1199
+ readonly messages: readonly Message<Body>[];
1200
+ readonly queue: string;
1201
+ retryAll(): void;
1202
+ ackAll(): void;
1203
+ }
1204
+ export interface MessageBatch<Body = unknown> {
1205
+ readonly messages: readonly Message<Body>[];
1206
+ readonly queue: string;
1207
+ retryAll(): void;
1208
+ ackAll(): void;
1209
+ }
1142
1210
  export interface R2Error extends Error {
1143
1211
  readonly name: string;
1144
1212
  readonly code: number;
@@ -1290,12 +1358,18 @@ export interface R2HTTPMetadata {
1290
1358
  cacheControl?: string;
1291
1359
  cacheExpiry?: Date;
1292
1360
  }
1293
- export interface R2Objects {
1361
+ export type R2Objects = {
1294
1362
  objects: R2Object[];
1295
- truncated: boolean;
1296
- cursor?: string;
1297
1363
  delimitedPrefixes: string[];
1298
- }
1364
+ } & (
1365
+ | {
1366
+ truncated: true;
1367
+ cursor: string;
1368
+ }
1369
+ | {
1370
+ truncated: false;
1371
+ }
1372
+ );
1299
1373
  export declare abstract class ScheduledEvent extends ExtendableEvent {
1300
1374
  readonly scheduledTime: number;
1301
1375
  readonly cron: string;
@@ -1506,13 +1580,19 @@ export declare class TransformStream<I = any, O = any> {
1506
1580
  get writable(): WritableStream<I>;
1507
1581
  }
1508
1582
  export declare class FixedLengthStream extends IdentityTransformStream {
1509
- constructor(expectedLength: number | bigint);
1583
+ constructor(
1584
+ expectedLength: number | bigint,
1585
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1586
+ );
1510
1587
  }
1511
1588
  export declare class IdentityTransformStream extends TransformStream<
1512
1589
  ArrayBuffer | ArrayBufferView,
1513
1590
  Uint8Array
1514
1591
  > {
1515
- constructor();
1592
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1593
+ }
1594
+ export interface IdentityTransformStreamQueuingStrategy {
1595
+ highWaterMark?: number | bigint;
1516
1596
  }
1517
1597
  export interface ReadableStreamValuesOptions {
1518
1598
  preventCancel?: boolean;
@@ -1564,7 +1644,8 @@ export interface QueuingStrategyInit {
1564
1644
  */
1565
1645
  highWaterMark: number;
1566
1646
  }
1567
- export declare abstract class TraceEvent extends ExtendableEvent {
1647
+ export declare abstract class TailEvent extends ExtendableEvent {
1648
+ readonly events: TraceItem[];
1568
1649
  readonly traces: TraceItem[];
1569
1650
  }
1570
1651
  export interface TraceItem {
@@ -1660,6 +1741,7 @@ export declare class URL {
1660
1741
  get searchParams(): URLSearchParams;
1661
1742
  toJSON(): string;
1662
1743
  toString(): string;
1744
+ static canParse(url: string, base?: string): boolean;
1663
1745
  }
1664
1746
  export declare class URLSearchParams {
1665
1747
  constructor(
@@ -1667,10 +1749,10 @@ export declare class URLSearchParams {
1667
1749
  );
1668
1750
  get size(): number;
1669
1751
  append(name: string, value: string): void;
1670
- delete(name: string): void;
1752
+ delete(name: string, value?: any): void;
1671
1753
  get(name: string): string | null;
1672
1754
  getAll(name: string): string[];
1673
- has(name: string): boolean;
1755
+ has(name: string, value?: any): boolean;
1674
1756
  set(name: string, value: string): void;
1675
1757
  sort(): void;
1676
1758
  entries(): IterableIterator<[key: string, value: string]>;
@@ -1770,6 +1852,8 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
1770
1852
  accept(): void;
1771
1853
  send(message: (ArrayBuffer | ArrayBufferView) | string): void;
1772
1854
  close(code?: number, reason?: string): void;
1855
+ serializeAttachment(attachment: any): void;
1856
+ deserializeAttachment(): any | null;
1773
1857
  static readonly READY_STATE_CONNECTING: number;
1774
1858
  static readonly READY_STATE_OPEN: number;
1775
1859
  static readonly READY_STATE_CLOSING: number;
@@ -1785,6 +1869,24 @@ export declare const WebSocketPair: {
1785
1869
  1: WebSocket;
1786
1870
  };
1787
1871
  };
1872
+ export interface Socket {
1873
+ get readable(): ReadableStream;
1874
+ get writable(): WritableStream;
1875
+ get closed(): Promise<void>;
1876
+ close(): Promise<void>;
1877
+ startTls(options?: TlsOptions): Socket;
1878
+ }
1879
+ export interface SocketOptions {
1880
+ secureTransport?: string;
1881
+ allowHalfOpen: boolean;
1882
+ }
1883
+ export interface SocketAddress {
1884
+ hostname: string;
1885
+ port: number;
1886
+ }
1887
+ export interface TlsOptions {
1888
+ expectedServerHostname?: string;
1889
+ }
1788
1890
  export interface BasicImageTransformations {
1789
1891
  /**
1790
1892
  * Maximum width in image pixels. The value must be an integer.
@@ -1864,7 +1966,7 @@ export interface BasicImageTransformationsGravityCoordinates {
1864
1966
  * Note: Currently, these properties cannot be tested in the
1865
1967
  * playground.
1866
1968
  */
1867
- export interface RequestInitCfProperties {
1969
+ export interface RequestInitCfProperties extends Record<string, unknown> {
1868
1970
  cacheEverything?: boolean;
1869
1971
  /**
1870
1972
  * A request's cache key is what determines if two requests are
@@ -2034,6 +2136,49 @@ export interface RequestInitCfPropertiesImage
2034
2136
  * the origin.
2035
2137
  */
2036
2138
  "origin-auth"?: "share-publicly";
2139
+ /**
2140
+ * Adds a border around the image. The border is added after resizing. Border
2141
+ * width takes dpr into account, and can be specified either using a single
2142
+ * width property, or individually for each side.
2143
+ */
2144
+ border?:
2145
+ | {
2146
+ color: string;
2147
+ width: number;
2148
+ }
2149
+ | {
2150
+ color: string;
2151
+ top: number;
2152
+ right: number;
2153
+ bottom: number;
2154
+ left: number;
2155
+ };
2156
+ /**
2157
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2158
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2159
+ * 0 is ignored.
2160
+ */
2161
+ brightness?: number;
2162
+ /**
2163
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2164
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2165
+ * ignored.
2166
+ */
2167
+ contrast?: number;
2168
+ /**
2169
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2170
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2171
+ */
2172
+ gamma?: number;
2173
+ /**
2174
+ * Slightly reduces latency on a cache miss by selecting a
2175
+ * quickest-to-compress file format, at a cost of increased file size and
2176
+ * lower image quality. It will usually override the format option and choose
2177
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2178
+ * unusual circumstances like resizing uncacheable dynamically-generated
2179
+ * images.
2180
+ */
2181
+ compression?: "fast";
2037
2182
  }
2038
2183
  export interface RequestInitCfPropertiesImageMinify {
2039
2184
  javascript?: boolean;
@@ -2049,7 +2194,8 @@ export type IncomingRequestCfProperties<HostMetadata = unknown> =
2049
2194
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2050
2195
  IncomingRequestCfPropertiesGeographicInformation &
2051
2196
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2052
- export interface IncomingRequestCfPropertiesBase {
2197
+ export interface IncomingRequestCfPropertiesBase
2198
+ extends Record<string, unknown> {
2053
2199
  /**
2054
2200
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2055
2201
  *
@@ -2130,8 +2276,7 @@ export interface IncomingRequestCfPropertiesBase {
2130
2276
  export interface IncomingRequestCfPropertiesBotManagementBase {
2131
2277
  /**
2132
2278
  * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2133
- * represented as an integer percentage between `1` (almost certainly human)
2134
- * and `99` (almost certainly a bot).
2279
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2135
2280
  *
2136
2281
  * @example 54
2137
2282
  */
@@ -2242,86 +2387,82 @@ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2242
2387
  /**
2243
2388
  * Geographic data about the request's origin.
2244
2389
  */
2245
- export type IncomingRequestCfPropertiesGeographicInformation =
2246
- | {}
2247
- | {
2248
- /** The country code `"T1"` is used for requests originating on TOR */
2249
- country: "T1";
2250
- }
2251
- | {
2252
- /**
2253
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2254
- *
2255
- * 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.
2256
- *
2257
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2258
- *
2259
- * @example "GB"
2260
- */
2261
- country: Iso3166Alpha2Code;
2262
- /**
2263
- * If present, this property indicates that the request originated in the EU
2264
- *
2265
- * @example "1"
2266
- */
2267
- isEUCountry?: "1";
2268
- /**
2269
- * A two-letter code indicating the continent the request originated from.
2270
- *
2271
- * @example "AN"
2272
- */
2273
- continent: ContinentCode;
2274
- /**
2275
- * The city the request originated from
2276
- *
2277
- * @example "Austin"
2278
- */
2279
- city?: string;
2280
- /**
2281
- * Postal code of the incoming request
2282
- *
2283
- * @example "78701"
2284
- */
2285
- postalCode?: string;
2286
- /**
2287
- * Latitude of the incoming request
2288
- *
2289
- * @example "30.27130"
2290
- */
2291
- latitude?: string;
2292
- /**
2293
- * Longitude of the incoming request
2294
- *
2295
- * @example "-97.74260"
2296
- */
2297
- longitude?: string;
2298
- /**
2299
- * Timezone of the incoming request
2300
- *
2301
- * @example "America/Chicago"
2302
- */
2303
- timezone?: string;
2304
- /**
2305
- * If known, the ISO 3166-2 name for the first level region associated with
2306
- * the IP address of the incoming request
2307
- *
2308
- * @example "Texas"
2309
- */
2310
- region?: string;
2311
- /**
2312
- * If known, the ISO 3166-2 code for the first-level region associated with
2313
- * the IP address of the incoming request
2314
- *
2315
- * @example "TX"
2316
- */
2317
- regionCode?: string;
2318
- /**
2319
- * Metro code (DMA) of the incoming request
2320
- *
2321
- * @example "635"
2322
- */
2323
- metroCode?: string;
2324
- };
2390
+ export interface IncomingRequestCfPropertiesGeographicInformation {
2391
+ /**
2392
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2393
+ *
2394
+ * 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.
2395
+ *
2396
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2397
+ *
2398
+ * The country code `"T1"` is used for requests originating on TOR.
2399
+ *
2400
+ * @example "GB"
2401
+ */
2402
+ country?: Iso3166Alpha2Code | "T1";
2403
+ /**
2404
+ * If present, this property indicates that the request originated in the EU
2405
+ *
2406
+ * @example "1"
2407
+ */
2408
+ isEUCountry?: "1";
2409
+ /**
2410
+ * A two-letter code indicating the continent the request originated from.
2411
+ *
2412
+ * @example "AN"
2413
+ */
2414
+ continent?: ContinentCode;
2415
+ /**
2416
+ * The city the request originated from
2417
+ *
2418
+ * @example "Austin"
2419
+ */
2420
+ city?: string;
2421
+ /**
2422
+ * Postal code of the incoming request
2423
+ *
2424
+ * @example "78701"
2425
+ */
2426
+ postalCode?: string;
2427
+ /**
2428
+ * Latitude of the incoming request
2429
+ *
2430
+ * @example "30.27130"
2431
+ */
2432
+ latitude?: string;
2433
+ /**
2434
+ * Longitude of the incoming request
2435
+ *
2436
+ * @example "-97.74260"
2437
+ */
2438
+ longitude?: string;
2439
+ /**
2440
+ * Timezone of the incoming request
2441
+ *
2442
+ * @example "America/Chicago"
2443
+ */
2444
+ timezone?: string;
2445
+ /**
2446
+ * If known, the ISO 3166-2 name for the first level region associated with
2447
+ * the IP address of the incoming request
2448
+ *
2449
+ * @example "Texas"
2450
+ */
2451
+ region?: string;
2452
+ /**
2453
+ * If known, the ISO 3166-2 code for the first-level region associated with
2454
+ * the IP address of the incoming request
2455
+ *
2456
+ * @example "TX"
2457
+ */
2458
+ regionCode?: string;
2459
+ /**
2460
+ * Metro code (DMA) of the incoming request
2461
+ *
2462
+ * @example "635"
2463
+ */
2464
+ metroCode?: string;
2465
+ }
2325
2466
  /** Data about the incoming request's TLS certificate */
2326
2467
  export interface IncomingRequestCfPropertiesTLSClientAuth {
2327
2468
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2714,6 +2855,9 @@ export type Iso3166Alpha2Code =
2714
2855
  | "ZW";
2715
2856
  /** The 2-letter continent codes Cloudflare uses */
2716
2857
  export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2858
+ export type CfProperties<HostMetadata = unknown> =
2859
+ | IncomingRequestCfProperties<HostMetadata>
2860
+ | RequestInitCfProperties;
2717
2861
  export interface D1Result<T = unknown> {
2718
2862
  results?: T[];
2719
2863
  success: boolean;
@@ -2734,7 +2878,7 @@ export declare abstract class D1PreparedStatement {
2734
2878
  raw<T = unknown>(): Promise<T[]>;
2735
2879
  }
2736
2880
  /**
2737
- * A email message that is sent to a consumer Worker.
2881
+ * An email message that can be sent from a Worker.
2738
2882
  */
2739
2883
  export interface EmailMessage {
2740
2884
  /**
@@ -2745,14 +2889,19 @@ export interface EmailMessage {
2745
2889
  * Envelope To attribute of the email message.
2746
2890
  */
2747
2891
  readonly to: string;
2748
- /**
2749
- * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2750
- */
2751
- readonly headers: Headers;
2892
+ }
2893
+ /**
2894
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2895
+ */
2896
+ export interface ForwardableEmailMessage extends EmailMessage {
2752
2897
  /**
2753
2898
  * Stream of the email message content.
2754
2899
  */
2755
2900
  readonly raw: ReadableStream;
2901
+ /**
2902
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2903
+ */
2904
+ readonly headers: Headers;
2756
2905
  /**
2757
2906
  * Size of the email message content.
2758
2907
  */
@@ -2771,11 +2920,17 @@ export interface EmailMessage {
2771
2920
  */
2772
2921
  forward(rcptTo: string, headers?: Headers): Promise<void>;
2773
2922
  }
2923
+ /**
2924
+ * A binding that allows a Worker to send email messages.
2925
+ */
2926
+ export interface SendEmail {
2927
+ send(message: EmailMessage): Promise<void>;
2928
+ }
2774
2929
  export declare abstract class EmailEvent extends ExtendableEvent {
2775
- readonly message: EmailMessage;
2930
+ readonly message: ForwardableEmailMessage;
2776
2931
  }
2777
2932
  export type EmailExportedHandler<Env = unknown> = (
2778
- message: EmailMessage,
2933
+ message: ForwardableEmailMessage,
2779
2934
  env: Env,
2780
2935
  ctx: ExecutionContext
2781
2936
  ) => void | Promise<void>;
@@ -2856,75 +3011,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
2856
3011
  // Key Identifier of the JWK
2857
3012
  readonly kid: string;
2858
3013
  }
2859
- /**
2860
- * A message that is sent to a consumer Worker.
2861
- */
2862
- export interface Message<Body = unknown> {
2863
- /**
2864
- * A unique, system-generated ID for the message.
2865
- */
2866
- readonly id: string;
3014
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3015
+ export interface DispatchNamespace {
2867
3016
  /**
2868
- * A timestamp when the message was sent.
3017
+ * @param name Name of the Worker script.
3018
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
3019
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
2869
3020
  */
2870
- readonly timestamp: Date;
2871
- /**
2872
- * The body of the message.
2873
- */
2874
- readonly body: Body;
2875
- /**
2876
- * Marks message to be retried.
2877
- */
2878
- retry(): void;
2879
- /**
2880
- * Marks message acknowledged.
2881
- */
2882
- ack(): void;
2883
- }
2884
- /**
2885
- * A batch of messages that are sent to a consumer Worker.
2886
- */
2887
- export interface MessageBatch<Body = unknown> {
2888
- /**
2889
- * The name of the Queue that belongs to this batch.
2890
- */
2891
- readonly queue: string;
2892
- /**
2893
- * An array of messages in the batch. Ordering of messages is not guaranteed.
2894
- */
2895
- readonly messages: readonly Message<Body>[];
2896
- /**
2897
- * Marks every message to be retried in the next batch.
2898
- */
2899
- retryAll(): void;
2900
- /**
2901
- * Marks every message acknowledged in the batch.
2902
- */
2903
- ackAll(): void;
2904
- }
2905
- /**
2906
- * A wrapper class used to structure message batches.
2907
- */
2908
- export type MessageSendRequest<Body = unknown> = {
2909
- /**
2910
- * The body of the message.
2911
- */
2912
- body: Body;
2913
- };
2914
- /**
2915
- * A binding that allows a producer to send messages to a Queue.
2916
- */
2917
- export interface Queue<Body = any> {
2918
- /**
2919
- * Sends a message to the Queue.
2920
- * @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.
2921
- * @returns A promise that resolves when the message is confirmed to be written to disk.
2922
- */
2923
- send(message: Body): Promise<void>;
2924
- /**
2925
- * Sends a batch of messages to the Queue.
2926
- * @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.
2927
- * @returns A promise that resolves when the messages are confirmed to be written to disk.
2928
- */
2929
- sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
3021
+ get(name: string): Fetcher;
2930
3022
  }