@cloudflare/workers-types 4.20230307.0 → 4.20230321.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.
@@ -286,8 +286,11 @@ export interface ExecutionContext {
286
286
  waitUntil(promise: Promise<any>): void;
287
287
  passThroughOnException(): void;
288
288
  }
289
- export type ExportedHandlerFetchHandler<Env = unknown> = (
290
- request: Request,
289
+ export type ExportedHandlerFetchHandler<
290
+ Env = unknown,
291
+ CfHostMetadata = unknown
292
+ > = (
293
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
291
294
  env: Env,
292
295
  ctx: ExecutionContext
293
296
  ) => Response | Promise<Response>;
@@ -311,8 +314,12 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
311
314
  env: Env,
312
315
  ctx: ExecutionContext
313
316
  ) => void | Promise<void>;
314
- export interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
315
- fetch?: ExportedHandlerFetchHandler<Env>;
317
+ export interface ExportedHandler<
318
+ Env = unknown,
319
+ QueueMessage = unknown,
320
+ CfHostMetadata = unknown
321
+ > {
322
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
316
323
  trace?: ExportedHandlerTraceHandler<Env>;
317
324
  scheduled?: ExportedHandlerScheduledHandler<Env>;
318
325
  test?: ExportedHandlerTestHandler<Env>;
@@ -997,10 +1004,16 @@ export interface ResponseInit {
997
1004
  webSocket?: WebSocket | null;
998
1005
  encodeBody?: "automatic" | "manual";
999
1006
  }
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>;
1007
+ export type RequestInfo<
1008
+ CfHostMetadata = unknown,
1009
+ Cf = CfProperties<CfHostMetadata>
1010
+ > = Request<CfHostMetadata, Cf> | string | URL;
1011
+ export declare class Request<
1012
+ CfHostMetadata = unknown,
1013
+ Cf = CfProperties<CfHostMetadata>
1014
+ > extends Body {
1015
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1016
+ clone(): Request<CfHostMetadata, Cf>;
1004
1017
  /** Returns request's HTTP method, which is "GET" by default. */
1005
1018
  readonly method: string;
1006
1019
  /** Returns the URL of request as a string. */
@@ -1012,15 +1025,13 @@ export declare class Request<CfHostMetadata = unknown> extends Body {
1012
1025
  readonly fetcher: Fetcher | null;
1013
1026
  /** 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
1027
  readonly signal: AbortSignal;
1015
- readonly cf?: IncomingRequestCfProperties<CfHostMetadata>;
1028
+ readonly cf?: Cf;
1016
1029
  /** 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
1030
  readonly integrity: string;
1018
1031
  /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
1019
1032
  readonly keepalive: boolean;
1020
1033
  }
1021
- export interface RequestInit<
1022
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1023
- > {
1034
+ export interface RequestInit<Cf = CfProperties> {
1024
1035
  /** A string to set request's method. */
1025
1036
  method?: string;
1026
1037
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1030,17 +1041,14 @@ export interface RequestInit<
1030
1041
  /** 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
1042
  redirect?: string;
1032
1043
  fetcher?: Fetcher | null;
1033
- cf?: CfType;
1044
+ cf?: Cf;
1034
1045
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1035
1046
  integrity?: string;
1036
1047
  /** An AbortSignal to set request's signal. */
1037
1048
  signal?: AbortSignal | null;
1038
1049
  }
1039
1050
  export declare abstract class Fetcher {
1040
- fetch(
1041
- input: RequestInfo,
1042
- init?: RequestInit<RequestInitCfProperties>
1043
- ): Promise<Response>;
1051
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1044
1052
  }
1045
1053
  export interface FetcherPutOptions {
1046
1054
  expiration?: number;
@@ -1875,7 +1883,7 @@ export interface BasicImageTransformationsGravityCoordinates {
1875
1883
  * Note: Currently, these properties cannot be tested in the
1876
1884
  * playground.
1877
1885
  */
1878
- export interface RequestInitCfProperties {
1886
+ export interface RequestInitCfProperties extends Record<string, unknown> {
1879
1887
  cacheEverything?: boolean;
1880
1888
  /**
1881
1889
  * A request's cache key is what determines if two requests are
@@ -2045,6 +2053,49 @@ export interface RequestInitCfPropertiesImage
2045
2053
  * the origin.
2046
2054
  */
2047
2055
  "origin-auth"?: "share-publicly";
2056
+ /**
2057
+ * Adds a border around the image. The border is added after resizing. Border
2058
+ * width takes dpr into account, and can be specified either using a single
2059
+ * width property, or individually for each side.
2060
+ */
2061
+ border?:
2062
+ | {
2063
+ color: string;
2064
+ width: number;
2065
+ }
2066
+ | {
2067
+ color: string;
2068
+ top: number;
2069
+ right: number;
2070
+ bottom: number;
2071
+ left: number;
2072
+ };
2073
+ /**
2074
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2075
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2076
+ * 0 is ignored.
2077
+ */
2078
+ brightness?: number;
2079
+ /**
2080
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2081
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2082
+ * ignored.
2083
+ */
2084
+ contrast?: number;
2085
+ /**
2086
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2087
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2088
+ */
2089
+ gamma?: number;
2090
+ /**
2091
+ * Slightly reduces latency on a cache miss by selecting a
2092
+ * quickest-to-compress file format, at a cost of increased file size and
2093
+ * lower image quality. It will usually override the format option and choose
2094
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2095
+ * unusual circumstances like resizing uncacheable dynamically-generated
2096
+ * images.
2097
+ */
2098
+ compression?: "fast";
2048
2099
  }
2049
2100
  export interface RequestInitCfPropertiesImageMinify {
2050
2101
  javascript?: boolean;
@@ -2060,7 +2111,8 @@ export type IncomingRequestCfProperties<HostMetadata = unknown> =
2060
2111
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2061
2112
  IncomingRequestCfPropertiesGeographicInformation &
2062
2113
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2063
- export interface IncomingRequestCfPropertiesBase {
2114
+ export interface IncomingRequestCfPropertiesBase
2115
+ extends Record<string, unknown> {
2064
2116
  /**
2065
2117
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2066
2118
  *
@@ -2253,86 +2305,82 @@ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2253
2305
  /**
2254
2306
  * Geographic data about the request's origin.
2255
2307
  */
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
- };
2308
+ export interface IncomingRequestCfPropertiesGeographicInformation {
2309
+ /**
2310
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2311
+ *
2312
+ * 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.
2313
+ *
2314
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2315
+ *
2316
+ * The country code `"T1"` is used for requests originating on TOR.
2317
+ *
2318
+ * @example "GB"
2319
+ */
2320
+ country?: Iso3166Alpha2Code | "T1";
2321
+ /**
2322
+ * If present, this property indicates that the request originated in the EU
2323
+ *
2324
+ * @example "1"
2325
+ */
2326
+ isEUCountry?: "1";
2327
+ /**
2328
+ * A two-letter code indicating the continent the request originated from.
2329
+ *
2330
+ * @example "AN"
2331
+ */
2332
+ continent?: ContinentCode;
2333
+ /**
2334
+ * The city the request originated from
2335
+ *
2336
+ * @example "Austin"
2337
+ */
2338
+ city?: string;
2339
+ /**
2340
+ * Postal code of the incoming request
2341
+ *
2342
+ * @example "78701"
2343
+ */
2344
+ postalCode?: string;
2345
+ /**
2346
+ * Latitude of the incoming request
2347
+ *
2348
+ * @example "30.27130"
2349
+ */
2350
+ latitude?: string;
2351
+ /**
2352
+ * Longitude of the incoming request
2353
+ *
2354
+ * @example "-97.74260"
2355
+ */
2356
+ longitude?: string;
2357
+ /**
2358
+ * Timezone of the incoming request
2359
+ *
2360
+ * @example "America/Chicago"
2361
+ */
2362
+ timezone?: string;
2363
+ /**
2364
+ * If known, the ISO 3166-2 name for the first level region associated with
2365
+ * the IP address of the incoming request
2366
+ *
2367
+ * @example "Texas"
2368
+ */
2369
+ region?: string;
2370
+ /**
2371
+ * If known, the ISO 3166-2 code for the first-level region associated with
2372
+ * the IP address of the incoming request
2373
+ *
2374
+ * @example "TX"
2375
+ */
2376
+ regionCode?: string;
2377
+ /**
2378
+ * Metro code (DMA) of the incoming request
2379
+ *
2380
+ * @example "635"
2381
+ */
2382
+ metroCode?: string;
2383
+ }
2336
2384
  /** Data about the incoming request's TLS certificate */
2337
2385
  export interface IncomingRequestCfPropertiesTLSClientAuth {
2338
2386
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2725,6 +2773,9 @@ export type Iso3166Alpha2Code =
2725
2773
  | "ZW";
2726
2774
  /** The 2-letter continent codes Cloudflare uses */
2727
2775
  export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2776
+ export type CfProperties<HostMetadata = unknown> =
2777
+ | IncomingRequestCfProperties<HostMetadata>
2778
+ | RequestInitCfProperties;
2728
2779
  export interface D1Result<T = unknown> {
2729
2780
  results?: T[];
2730
2781
  success: boolean;
@@ -2747,7 +2798,7 @@ export declare abstract class D1PreparedStatement {
2747
2798
  /**
2748
2799
  * A email message that is sent to a consumer Worker.
2749
2800
  */
2750
- export interface EmailMessage<Body = unknown> {
2801
+ export interface EmailMessage {
2751
2802
  /**
2752
2803
  * Envelope From attribute of the email message.
2753
2804
  */
@@ -284,8 +284,11 @@ declare interface ExecutionContext {
284
284
  waitUntil(promise: Promise<any>): void;
285
285
  passThroughOnException(): void;
286
286
  }
287
- declare type ExportedHandlerFetchHandler<Env = unknown> = (
288
- request: Request,
287
+ declare type ExportedHandlerFetchHandler<
288
+ Env = unknown,
289
+ CfHostMetadata = unknown
290
+ > = (
291
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
289
292
  env: Env,
290
293
  ctx: ExecutionContext
291
294
  ) => Response | Promise<Response>;
@@ -309,8 +312,12 @@ declare type ExportedHandlerTestHandler<Env = unknown> = (
309
312
  env: Env,
310
313
  ctx: ExecutionContext
311
314
  ) => void | Promise<void>;
312
- declare interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
313
- fetch?: ExportedHandlerFetchHandler<Env>;
315
+ declare interface ExportedHandler<
316
+ Env = unknown,
317
+ QueueMessage = unknown,
318
+ CfHostMetadata = unknown
319
+ > {
320
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
314
321
  trace?: ExportedHandlerTraceHandler<Env>;
315
322
  scheduled?: ExportedHandlerScheduledHandler<Env>;
316
323
  test?: ExportedHandlerTestHandler<Env>;
@@ -982,23 +989,27 @@ declare interface ResponseInit {
982
989
  webSocket?: WebSocket | null;
983
990
  encodeBody?: "automatic" | "manual";
984
991
  }
985
- declare type RequestInfo = Request | string | URL;
986
- declare class Request<CfHostMetadata = unknown> extends Body {
987
- constructor(input: RequestInfo, init?: RequestInit);
988
- clone(): Request<CfHostMetadata>;
992
+ declare type RequestInfo<
993
+ CfHostMetadata = unknown,
994
+ Cf = CfProperties<CfHostMetadata>
995
+ > = Request<CfHostMetadata, Cf> | string | URL;
996
+ declare class Request<
997
+ CfHostMetadata = unknown,
998
+ Cf = CfProperties<CfHostMetadata>
999
+ > extends Body {
1000
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1001
+ clone(): Request<CfHostMetadata, Cf>;
989
1002
  get method(): string;
990
1003
  get url(): string;
991
1004
  get headers(): Headers;
992
1005
  get redirect(): string;
993
1006
  get fetcher(): Fetcher | null;
994
1007
  get signal(): AbortSignal;
995
- get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
1008
+ get cf(): Cf | undefined;
996
1009
  get integrity(): string;
997
1010
  get keepalive(): boolean;
998
1011
  }
999
- declare interface RequestInit<
1000
- CfType = IncomingRequestCfProperties | RequestInitCfProperties
1001
- > {
1012
+ declare interface RequestInit<Cf = CfProperties> {
1002
1013
  /** A string to set request's method. */
1003
1014
  method?: string;
1004
1015
  /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
@@ -1008,17 +1019,14 @@ declare interface RequestInit<
1008
1019
  /** 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. */
1009
1020
  redirect?: string;
1010
1021
  fetcher?: Fetcher | null;
1011
- cf?: CfType;
1022
+ cf?: Cf;
1012
1023
  /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1013
1024
  integrity?: string;
1014
1025
  /** An AbortSignal to set request's signal. */
1015
1026
  signal?: AbortSignal | null;
1016
1027
  }
1017
1028
  declare abstract class Fetcher {
1018
- fetch(
1019
- input: RequestInfo,
1020
- init?: RequestInit<RequestInitCfProperties>
1021
- ): Promise<Response>;
1029
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1022
1030
  }
1023
1031
  declare interface FetcherPutOptions {
1024
1032
  expiration?: number;
@@ -1856,7 +1864,7 @@ declare interface BasicImageTransformationsGravityCoordinates {
1856
1864
  * Note: Currently, these properties cannot be tested in the
1857
1865
  * playground.
1858
1866
  */
1859
- declare interface RequestInitCfProperties {
1867
+ declare interface RequestInitCfProperties extends Record<string, unknown> {
1860
1868
  cacheEverything?: boolean;
1861
1869
  /**
1862
1870
  * A request's cache key is what determines if two requests are
@@ -2026,6 +2034,49 @@ declare interface RequestInitCfPropertiesImage
2026
2034
  * the origin.
2027
2035
  */
2028
2036
  "origin-auth"?: "share-publicly";
2037
+ /**
2038
+ * Adds a border around the image. The border is added after resizing. Border
2039
+ * width takes dpr into account, and can be specified either using a single
2040
+ * width property, or individually for each side.
2041
+ */
2042
+ border?:
2043
+ | {
2044
+ color: string;
2045
+ width: number;
2046
+ }
2047
+ | {
2048
+ color: string;
2049
+ top: number;
2050
+ right: number;
2051
+ bottom: number;
2052
+ left: number;
2053
+ };
2054
+ /**
2055
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2056
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2057
+ * 0 is ignored.
2058
+ */
2059
+ brightness?: number;
2060
+ /**
2061
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2062
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2063
+ * ignored.
2064
+ */
2065
+ contrast?: number;
2066
+ /**
2067
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2068
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2069
+ */
2070
+ gamma?: number;
2071
+ /**
2072
+ * Slightly reduces latency on a cache miss by selecting a
2073
+ * quickest-to-compress file format, at a cost of increased file size and
2074
+ * lower image quality. It will usually override the format option and choose
2075
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2076
+ * unusual circumstances like resizing uncacheable dynamically-generated
2077
+ * images.
2078
+ */
2079
+ compression?: "fast";
2029
2080
  }
2030
2081
  declare interface RequestInitCfPropertiesImageMinify {
2031
2082
  javascript?: boolean;
@@ -2041,7 +2092,8 @@ declare type IncomingRequestCfProperties<HostMetadata = unknown> =
2041
2092
  IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2042
2093
  IncomingRequestCfPropertiesGeographicInformation &
2043
2094
  IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2044
- declare interface IncomingRequestCfPropertiesBase {
2095
+ declare interface IncomingRequestCfPropertiesBase
2096
+ extends Record<string, unknown> {
2045
2097
  /**
2046
2098
  * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2047
2099
  *
@@ -2234,86 +2286,82 @@ declare interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2234
2286
  /**
2235
2287
  * Geographic data about the request's origin.
2236
2288
  */
2237
- declare type IncomingRequestCfPropertiesGeographicInformation =
2238
- | {}
2239
- | {
2240
- /** The country code `"T1"` is used for requests originating on TOR */
2241
- country: "T1";
2242
- }
2243
- | {
2244
- /**
2245
- * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2246
- *
2247
- * 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.
2248
- *
2249
- * If Cloudflare is unable to determine where the request originated this property is omitted.
2250
- *
2251
- * @example "GB"
2252
- */
2253
- country: Iso3166Alpha2Code;
2254
- /**
2255
- * If present, this property indicates that the request originated in the EU
2256
- *
2257
- * @example "1"
2258
- */
2259
- isEUCountry?: "1";
2260
- /**
2261
- * A two-letter code indicating the continent the request originated from.
2262
- *
2263
- * @example "AN"
2264
- */
2265
- continent: ContinentCode;
2266
- /**
2267
- * The city the request originated from
2268
- *
2269
- * @example "Austin"
2270
- */
2271
- city?: string;
2272
- /**
2273
- * Postal code of the incoming request
2274
- *
2275
- * @example "78701"
2276
- */
2277
- postalCode?: string;
2278
- /**
2279
- * Latitude of the incoming request
2280
- *
2281
- * @example "30.27130"
2282
- */
2283
- latitude?: string;
2284
- /**
2285
- * Longitude of the incoming request
2286
- *
2287
- * @example "-97.74260"
2288
- */
2289
- longitude?: string;
2290
- /**
2291
- * Timezone of the incoming request
2292
- *
2293
- * @example "America/Chicago"
2294
- */
2295
- timezone?: string;
2296
- /**
2297
- * If known, the ISO 3166-2 name for the first level region associated with
2298
- * the IP address of the incoming request
2299
- *
2300
- * @example "Texas"
2301
- */
2302
- region?: string;
2303
- /**
2304
- * If known, the ISO 3166-2 code for the first-level region associated with
2305
- * the IP address of the incoming request
2306
- *
2307
- * @example "TX"
2308
- */
2309
- regionCode?: string;
2310
- /**
2311
- * Metro code (DMA) of the incoming request
2312
- *
2313
- * @example "635"
2314
- */
2315
- metroCode?: string;
2316
- };
2289
+ declare interface IncomingRequestCfPropertiesGeographicInformation {
2290
+ /**
2291
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2292
+ *
2293
+ * 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.
2294
+ *
2295
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2296
+ *
2297
+ * The country code `"T1"` is used for requests originating on TOR.
2298
+ *
2299
+ * @example "GB"
2300
+ */
2301
+ country?: Iso3166Alpha2Code | "T1";
2302
+ /**
2303
+ * If present, this property indicates that the request originated in the EU
2304
+ *
2305
+ * @example "1"
2306
+ */
2307
+ isEUCountry?: "1";
2308
+ /**
2309
+ * A two-letter code indicating the continent the request originated from.
2310
+ *
2311
+ * @example "AN"
2312
+ */
2313
+ continent?: ContinentCode;
2314
+ /**
2315
+ * The city the request originated from
2316
+ *
2317
+ * @example "Austin"
2318
+ */
2319
+ city?: string;
2320
+ /**
2321
+ * Postal code of the incoming request
2322
+ *
2323
+ * @example "78701"
2324
+ */
2325
+ postalCode?: string;
2326
+ /**
2327
+ * Latitude of the incoming request
2328
+ *
2329
+ * @example "30.27130"
2330
+ */
2331
+ latitude?: string;
2332
+ /**
2333
+ * Longitude of the incoming request
2334
+ *
2335
+ * @example "-97.74260"
2336
+ */
2337
+ longitude?: string;
2338
+ /**
2339
+ * Timezone of the incoming request
2340
+ *
2341
+ * @example "America/Chicago"
2342
+ */
2343
+ timezone?: string;
2344
+ /**
2345
+ * If known, the ISO 3166-2 name for the first level region associated with
2346
+ * the IP address of the incoming request
2347
+ *
2348
+ * @example "Texas"
2349
+ */
2350
+ region?: string;
2351
+ /**
2352
+ * If known, the ISO 3166-2 code for the first-level region associated with
2353
+ * the IP address of the incoming request
2354
+ *
2355
+ * @example "TX"
2356
+ */
2357
+ regionCode?: string;
2358
+ /**
2359
+ * Metro code (DMA) of the incoming request
2360
+ *
2361
+ * @example "635"
2362
+ */
2363
+ metroCode?: string;
2364
+ }
2317
2365
  /** Data about the incoming request's TLS certificate */
2318
2366
  declare interface IncomingRequestCfPropertiesTLSClientAuth {
2319
2367
  /** Always `"1"`, indicating that the certificate was presented */
@@ -2706,6 +2754,9 @@ declare type Iso3166Alpha2Code =
2706
2754
  | "ZW";
2707
2755
  /** The 2-letter continent codes Cloudflare uses */
2708
2756
  declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2757
+ declare type CfProperties<HostMetadata = unknown> =
2758
+ | IncomingRequestCfProperties<HostMetadata>
2759
+ | RequestInitCfProperties;
2709
2760
  declare interface D1Result<T = unknown> {
2710
2761
  results?: T[];
2711
2762
  success: boolean;
@@ -2728,7 +2779,7 @@ declare abstract class D1PreparedStatement {
2728
2779
  /**
2729
2780
  * A email message that is sent to a consumer Worker.
2730
2781
  */
2731
- declare interface EmailMessage<Body = unknown> {
2782
+ declare interface EmailMessage {
2732
2783
  /**
2733
2784
  * Envelope From attribute of the email message.
2734
2785
  */