@cloudflare/workers-types 0.20230307.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.
- package/2021-11-03/index.d.ts +244 -188
- package/2021-11-03/index.ts +237 -188
- package/2022-01-31/index.d.ts +244 -188
- package/2022-01-31/index.ts +237 -188
- package/2022-03-21/index.d.ts +244 -188
- package/2022-03-21/index.ts +237 -188
- package/2022-08-04/index.d.ts +244 -188
- package/2022-08-04/index.ts +237 -188
- package/2022-10-31/index.d.ts +245 -188
- package/2022-10-31/index.ts +238 -188
- package/2022-11-30/index.d.ts +245 -188
- package/2022-11-30/index.ts +238 -188
- package/README.md +1 -1
- package/experimental/index.d.ts +298 -188
- package/experimental/index.ts +291 -188
- package/index.d.ts +244 -188
- package/index.ts +237 -188
- package/oldest/index.d.ts +244 -188
- package/oldest/index.ts +237 -188
- package/package.json +1 -1
package/experimental/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
|
};
|
|
@@ -293,8 +294,11 @@ export interface ExecutionContext {
|
|
|
293
294
|
waitUntil(promise: Promise<any>): void;
|
|
294
295
|
passThroughOnException(): void;
|
|
295
296
|
}
|
|
296
|
-
export type ExportedHandlerFetchHandler<
|
|
297
|
-
|
|
297
|
+
export type ExportedHandlerFetchHandler<
|
|
298
|
+
Env = unknown,
|
|
299
|
+
CfHostMetadata = unknown
|
|
300
|
+
> = (
|
|
301
|
+
request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
|
|
298
302
|
env: Env,
|
|
299
303
|
ctx: ExecutionContext
|
|
300
304
|
) => Response | Promise<Response>;
|
|
@@ -318,12 +322,16 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
|
|
|
318
322
|
env: Env,
|
|
319
323
|
ctx: ExecutionContext
|
|
320
324
|
) => void | Promise<void>;
|
|
321
|
-
export interface ExportedHandler<
|
|
322
|
-
|
|
325
|
+
export interface ExportedHandler<
|
|
326
|
+
Env = unknown,
|
|
327
|
+
QueueMessage = unknown,
|
|
328
|
+
CfHostMetadata = unknown
|
|
329
|
+
> {
|
|
330
|
+
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
323
331
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
324
332
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
325
333
|
test?: ExportedHandlerTestHandler<Env>;
|
|
326
|
-
queue?: ExportedHandlerQueueHandler<Env,
|
|
334
|
+
queue?: ExportedHandlerQueueHandler<Env, Message>;
|
|
327
335
|
}
|
|
328
336
|
export interface StructuredSerializeOptions {
|
|
329
337
|
transfer?: any[];
|
|
@@ -358,13 +366,28 @@ export interface DurableObjectNamespace {
|
|
|
358
366
|
id: DurableObjectId,
|
|
359
367
|
options?: DurableObjectNamespaceGetDurableObjectOptions
|
|
360
368
|
): DurableObjectStub;
|
|
361
|
-
|
|
369
|
+
getExisting(
|
|
370
|
+
id: DurableObjectId,
|
|
371
|
+
options?: DurableObjectNamespaceGetDurableObjectOptions
|
|
372
|
+
): DurableObjectStub;
|
|
373
|
+
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
|
|
362
374
|
}
|
|
375
|
+
export type DurableObjectJurisdiction = "eu" | "fedramp";
|
|
363
376
|
export interface DurableObjectNamespaceNewUniqueIdOptions {
|
|
364
|
-
jurisdiction?:
|
|
365
|
-
}
|
|
377
|
+
jurisdiction?: DurableObjectJurisdiction;
|
|
378
|
+
}
|
|
379
|
+
export type DurableObjectLocationHint =
|
|
380
|
+
| "wnam"
|
|
381
|
+
| "enam"
|
|
382
|
+
| "sam"
|
|
383
|
+
| "weur"
|
|
384
|
+
| "eeur"
|
|
385
|
+
| "apac"
|
|
386
|
+
| "oc"
|
|
387
|
+
| "afr"
|
|
388
|
+
| "me";
|
|
366
389
|
export interface DurableObjectNamespaceGetDurableObjectOptions {
|
|
367
|
-
locationHint?:
|
|
390
|
+
locationHint?: DurableObjectLocationHint;
|
|
368
391
|
}
|
|
369
392
|
export interface DurableObjectState {
|
|
370
393
|
waitUntil(promise: Promise<any>): void;
|
|
@@ -437,6 +460,7 @@ export interface DurableObjectStorage {
|
|
|
437
460
|
): Promise<void>;
|
|
438
461
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
439
462
|
sync(): Promise<void>;
|
|
463
|
+
sql: SqlStorage;
|
|
440
464
|
}
|
|
441
465
|
export interface DurableObjectListOptions {
|
|
442
466
|
start?: string;
|
|
@@ -995,23 +1019,27 @@ export interface ResponseInit {
|
|
|
995
1019
|
webSocket?: WebSocket | null;
|
|
996
1020
|
encodeBody?: "automatic" | "manual";
|
|
997
1021
|
}
|
|
998
|
-
export type RequestInfo
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1022
|
+
export type RequestInfo<
|
|
1023
|
+
CfHostMetadata = unknown,
|
|
1024
|
+
Cf = CfProperties<CfHostMetadata>
|
|
1025
|
+
> = Request<CfHostMetadata, Cf> | string | URL;
|
|
1026
|
+
export declare class Request<
|
|
1027
|
+
CfHostMetadata = unknown,
|
|
1028
|
+
Cf = CfProperties<CfHostMetadata>
|
|
1029
|
+
> extends Body {
|
|
1030
|
+
constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
|
|
1031
|
+
clone(): Request<CfHostMetadata, Cf>;
|
|
1002
1032
|
get method(): string;
|
|
1003
1033
|
get url(): string;
|
|
1004
1034
|
get headers(): Headers;
|
|
1005
1035
|
get redirect(): string;
|
|
1006
1036
|
get fetcher(): Fetcher | null;
|
|
1007
1037
|
get signal(): AbortSignal;
|
|
1008
|
-
get cf():
|
|
1038
|
+
get cf(): Cf | undefined;
|
|
1009
1039
|
get integrity(): string;
|
|
1010
1040
|
get keepalive(): boolean;
|
|
1011
1041
|
}
|
|
1012
|
-
export interface RequestInit<
|
|
1013
|
-
CfType = IncomingRequestCfProperties | RequestInitCfProperties
|
|
1014
|
-
> {
|
|
1042
|
+
export interface RequestInit<Cf = CfProperties> {
|
|
1015
1043
|
/** A string to set request's method. */
|
|
1016
1044
|
method?: string;
|
|
1017
1045
|
/** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
|
|
@@ -1021,22 +1049,29 @@ export interface RequestInit<
|
|
|
1021
1049
|
/** 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. */
|
|
1022
1050
|
redirect?: string;
|
|
1023
1051
|
fetcher?: Fetcher | null;
|
|
1024
|
-
cf?:
|
|
1052
|
+
cf?: Cf;
|
|
1025
1053
|
/** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
|
|
1026
1054
|
integrity?: string;
|
|
1027
1055
|
/** An AbortSignal to set request's signal. */
|
|
1028
1056
|
signal?: AbortSignal | null;
|
|
1029
1057
|
}
|
|
1030
1058
|
export declare abstract class Fetcher {
|
|
1031
|
-
fetch(
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1059
|
+
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1060
|
+
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1061
|
+
queue(
|
|
1062
|
+
queueName: string,
|
|
1063
|
+
messages: ServiceBindingQueueMessage[]
|
|
1064
|
+
): Promise<QueueResponse>;
|
|
1035
1065
|
}
|
|
1036
1066
|
export interface FetcherPutOptions {
|
|
1037
1067
|
expiration?: number;
|
|
1038
1068
|
expirationTtl?: number;
|
|
1039
1069
|
}
|
|
1070
|
+
export interface ServiceBindingQueueMessage<Body = unknown> {
|
|
1071
|
+
id: string;
|
|
1072
|
+
timestamp: Date;
|
|
1073
|
+
body: Body;
|
|
1074
|
+
}
|
|
1040
1075
|
export interface KVNamespaceListKey<Metadata, Key extends string = string> {
|
|
1041
1076
|
name: Key;
|
|
1042
1077
|
expiration?: number;
|
|
@@ -1144,6 +1179,40 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
|
|
|
1144
1179
|
value: Value | null;
|
|
1145
1180
|
metadata: Metadata | null;
|
|
1146
1181
|
}
|
|
1182
|
+
export interface Queue<Body> {
|
|
1183
|
+
send(message: Body): Promise<void>;
|
|
1184
|
+
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
1185
|
+
}
|
|
1186
|
+
export interface QueueSendOptions {}
|
|
1187
|
+
export interface MessageSendRequest<Body = unknown> {
|
|
1188
|
+
body: Body;
|
|
1189
|
+
}
|
|
1190
|
+
export interface QueueResponse {
|
|
1191
|
+
outcome: number;
|
|
1192
|
+
retryAll: boolean;
|
|
1193
|
+
ackAll: boolean;
|
|
1194
|
+
explicitRetries: string[];
|
|
1195
|
+
explicitAcks: string[];
|
|
1196
|
+
}
|
|
1197
|
+
export interface Message<Body = unknown> {
|
|
1198
|
+
readonly id: string;
|
|
1199
|
+
readonly timestamp: Date;
|
|
1200
|
+
readonly body: Body;
|
|
1201
|
+
retry(): void;
|
|
1202
|
+
ack(): void;
|
|
1203
|
+
}
|
|
1204
|
+
export interface QueueEvent<Body = unknown> extends ExtendableEvent {
|
|
1205
|
+
readonly messages: readonly Message<Body>[];
|
|
1206
|
+
readonly queue: string;
|
|
1207
|
+
retryAll(): void;
|
|
1208
|
+
ackAll(): void;
|
|
1209
|
+
}
|
|
1210
|
+
export interface MessageBatch<Body = unknown> {
|
|
1211
|
+
readonly messages: readonly Message<Body>[];
|
|
1212
|
+
readonly queue: string;
|
|
1213
|
+
retryAll(): void;
|
|
1214
|
+
ackAll(): void;
|
|
1215
|
+
}
|
|
1147
1216
|
export interface R2Error extends Error {
|
|
1148
1217
|
readonly name: string;
|
|
1149
1218
|
readonly code: number;
|
|
@@ -1295,12 +1364,18 @@ export interface R2HTTPMetadata {
|
|
|
1295
1364
|
cacheControl?: string;
|
|
1296
1365
|
cacheExpiry?: Date;
|
|
1297
1366
|
}
|
|
1298
|
-
export
|
|
1367
|
+
export type R2Objects = {
|
|
1299
1368
|
objects: R2Object[];
|
|
1300
|
-
truncated: boolean;
|
|
1301
|
-
cursor?: string;
|
|
1302
1369
|
delimitedPrefixes: string[];
|
|
1303
|
-
}
|
|
1370
|
+
} & (
|
|
1371
|
+
| {
|
|
1372
|
+
truncated: true;
|
|
1373
|
+
cursor: string;
|
|
1374
|
+
}
|
|
1375
|
+
| {
|
|
1376
|
+
truncated: false;
|
|
1377
|
+
}
|
|
1378
|
+
);
|
|
1304
1379
|
export declare abstract class ScheduledEvent extends ExtendableEvent {
|
|
1305
1380
|
readonly scheduledTime: number;
|
|
1306
1381
|
readonly cron: string;
|
|
@@ -1510,13 +1585,19 @@ export declare class TransformStream<I = any, O = any> {
|
|
|
1510
1585
|
get writable(): WritableStream<I>;
|
|
1511
1586
|
}
|
|
1512
1587
|
export declare class FixedLengthStream extends IdentityTransformStream {
|
|
1513
|
-
constructor(
|
|
1588
|
+
constructor(
|
|
1589
|
+
expectedLength: number | bigint,
|
|
1590
|
+
queuingStrategy?: IdentityTransformStreamQueuingStrategy
|
|
1591
|
+
);
|
|
1514
1592
|
}
|
|
1515
1593
|
export declare class IdentityTransformStream extends TransformStream<
|
|
1516
1594
|
ArrayBuffer | ArrayBufferView,
|
|
1517
1595
|
Uint8Array
|
|
1518
1596
|
> {
|
|
1519
|
-
constructor();
|
|
1597
|
+
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
|
|
1598
|
+
}
|
|
1599
|
+
export interface IdentityTransformStreamQueuingStrategy {
|
|
1600
|
+
highWaterMark?: number | bigint;
|
|
1520
1601
|
}
|
|
1521
1602
|
export interface ReadableStreamValuesOptions {
|
|
1522
1603
|
preventCancel?: boolean;
|
|
@@ -1664,6 +1745,7 @@ export declare class URL {
|
|
|
1664
1745
|
get searchParams(): URLSearchParams;
|
|
1665
1746
|
toJSON(): string;
|
|
1666
1747
|
toString(): string;
|
|
1748
|
+
static canParse(url: string, base?: string): boolean;
|
|
1667
1749
|
}
|
|
1668
1750
|
export declare class URLSearchParams {
|
|
1669
1751
|
constructor(
|
|
@@ -1789,6 +1871,37 @@ export declare const WebSocketPair: {
|
|
|
1789
1871
|
1: WebSocket;
|
|
1790
1872
|
};
|
|
1791
1873
|
};
|
|
1874
|
+
export interface SqlStorage {
|
|
1875
|
+
exec(query: string, ...bindings: any[]): SqlStorageCursor;
|
|
1876
|
+
prepare(query: string): SqlStorageStatement;
|
|
1877
|
+
Cursor: typeof SqlStorageCursor;
|
|
1878
|
+
Statement: typeof SqlStorageStatement;
|
|
1879
|
+
}
|
|
1880
|
+
export declare abstract class SqlStorageStatement {}
|
|
1881
|
+
export declare abstract class SqlStorageCursor {
|
|
1882
|
+
raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
|
|
1883
|
+
[Symbol.iterator](): IterableIterator<
|
|
1884
|
+
Record<string, (ArrayBuffer | string | number) | null>
|
|
1885
|
+
>;
|
|
1886
|
+
}
|
|
1887
|
+
export interface Socket {
|
|
1888
|
+
get readable(): ReadableStream;
|
|
1889
|
+
get writable(): WritableStream;
|
|
1890
|
+
get closed(): Promise<void>;
|
|
1891
|
+
close(): Promise<void>;
|
|
1892
|
+
startTls(options?: TlsOptions): Socket;
|
|
1893
|
+
}
|
|
1894
|
+
export interface SocketOptions {
|
|
1895
|
+
secureTransport?: string;
|
|
1896
|
+
allowHalfOpen: boolean;
|
|
1897
|
+
}
|
|
1898
|
+
export interface SocketAddress {
|
|
1899
|
+
hostname: string;
|
|
1900
|
+
port: number;
|
|
1901
|
+
}
|
|
1902
|
+
export interface TlsOptions {
|
|
1903
|
+
expectedServerHostname?: string;
|
|
1904
|
+
}
|
|
1792
1905
|
export interface BasicImageTransformations {
|
|
1793
1906
|
/**
|
|
1794
1907
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -1868,7 +1981,7 @@ export interface BasicImageTransformationsGravityCoordinates {
|
|
|
1868
1981
|
* Note: Currently, these properties cannot be tested in the
|
|
1869
1982
|
* playground.
|
|
1870
1983
|
*/
|
|
1871
|
-
export interface RequestInitCfProperties {
|
|
1984
|
+
export interface RequestInitCfProperties extends Record<string, unknown> {
|
|
1872
1985
|
cacheEverything?: boolean;
|
|
1873
1986
|
/**
|
|
1874
1987
|
* A request's cache key is what determines if two requests are
|
|
@@ -2038,6 +2151,49 @@ export interface RequestInitCfPropertiesImage
|
|
|
2038
2151
|
* the origin.
|
|
2039
2152
|
*/
|
|
2040
2153
|
"origin-auth"?: "share-publicly";
|
|
2154
|
+
/**
|
|
2155
|
+
* Adds a border around the image. The border is added after resizing. Border
|
|
2156
|
+
* width takes dpr into account, and can be specified either using a single
|
|
2157
|
+
* width property, or individually for each side.
|
|
2158
|
+
*/
|
|
2159
|
+
border?:
|
|
2160
|
+
| {
|
|
2161
|
+
color: string;
|
|
2162
|
+
width: number;
|
|
2163
|
+
}
|
|
2164
|
+
| {
|
|
2165
|
+
color: string;
|
|
2166
|
+
top: number;
|
|
2167
|
+
right: number;
|
|
2168
|
+
bottom: number;
|
|
2169
|
+
left: number;
|
|
2170
|
+
};
|
|
2171
|
+
/**
|
|
2172
|
+
* Increase brightness by a factor. A value of 1.0 equals no change, a value
|
|
2173
|
+
* of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
|
|
2174
|
+
* 0 is ignored.
|
|
2175
|
+
*/
|
|
2176
|
+
brightness?: number;
|
|
2177
|
+
/**
|
|
2178
|
+
* Increase contrast by a factor. A value of 1.0 equals no change, a value of
|
|
2179
|
+
* 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
|
|
2180
|
+
* ignored.
|
|
2181
|
+
*/
|
|
2182
|
+
contrast?: number;
|
|
2183
|
+
/**
|
|
2184
|
+
* Increase exposure by a factor. A value of 1.0 equals no change, a value of
|
|
2185
|
+
* 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
|
|
2186
|
+
*/
|
|
2187
|
+
gamma?: number;
|
|
2188
|
+
/**
|
|
2189
|
+
* Slightly reduces latency on a cache miss by selecting a
|
|
2190
|
+
* quickest-to-compress file format, at a cost of increased file size and
|
|
2191
|
+
* lower image quality. It will usually override the format option and choose
|
|
2192
|
+
* JPEG over WebP or AVIF. We do not recommend using this option, except in
|
|
2193
|
+
* unusual circumstances like resizing uncacheable dynamically-generated
|
|
2194
|
+
* images.
|
|
2195
|
+
*/
|
|
2196
|
+
compression?: "fast";
|
|
2041
2197
|
}
|
|
2042
2198
|
export interface RequestInitCfPropertiesImageMinify {
|
|
2043
2199
|
javascript?: boolean;
|
|
@@ -2053,7 +2209,8 @@ export type IncomingRequestCfProperties<HostMetadata = unknown> =
|
|
|
2053
2209
|
IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
|
|
2054
2210
|
IncomingRequestCfPropertiesGeographicInformation &
|
|
2055
2211
|
IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
|
|
2056
|
-
export interface IncomingRequestCfPropertiesBase
|
|
2212
|
+
export interface IncomingRequestCfPropertiesBase
|
|
2213
|
+
extends Record<string, unknown> {
|
|
2057
2214
|
/**
|
|
2058
2215
|
* [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
|
|
2059
2216
|
*
|
|
@@ -2134,8 +2291,7 @@ export interface IncomingRequestCfPropertiesBase {
|
|
|
2134
2291
|
export interface IncomingRequestCfPropertiesBotManagementBase {
|
|
2135
2292
|
/**
|
|
2136
2293
|
* Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
|
|
2137
|
-
* represented as an integer percentage between `1` (almost certainly human)
|
|
2138
|
-
* and `99` (almost certainly a bot).
|
|
2294
|
+
* represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
|
|
2139
2295
|
*
|
|
2140
2296
|
* @example 54
|
|
2141
2297
|
*/
|
|
@@ -2246,86 +2402,82 @@ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
|
|
|
2246
2402
|
/**
|
|
2247
2403
|
* Geographic data about the request's origin.
|
|
2248
2404
|
*/
|
|
2249
|
-
export
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
* @example "635"
|
|
2326
|
-
*/
|
|
2327
|
-
metroCode?: string;
|
|
2328
|
-
};
|
|
2405
|
+
export interface IncomingRequestCfPropertiesGeographicInformation {
|
|
2406
|
+
/**
|
|
2407
|
+
* The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
|
|
2408
|
+
*
|
|
2409
|
+
* 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.
|
|
2410
|
+
*
|
|
2411
|
+
* If Cloudflare is unable to determine where the request originated this property is omitted.
|
|
2412
|
+
*
|
|
2413
|
+
* The country code `"T1"` is used for requests originating on TOR.
|
|
2414
|
+
*
|
|
2415
|
+
* @example "GB"
|
|
2416
|
+
*/
|
|
2417
|
+
country?: Iso3166Alpha2Code | "T1";
|
|
2418
|
+
/**
|
|
2419
|
+
* If present, this property indicates that the request originated in the EU
|
|
2420
|
+
*
|
|
2421
|
+
* @example "1"
|
|
2422
|
+
*/
|
|
2423
|
+
isEUCountry?: "1";
|
|
2424
|
+
/**
|
|
2425
|
+
* A two-letter code indicating the continent the request originated from.
|
|
2426
|
+
*
|
|
2427
|
+
* @example "AN"
|
|
2428
|
+
*/
|
|
2429
|
+
continent?: ContinentCode;
|
|
2430
|
+
/**
|
|
2431
|
+
* The city the request originated from
|
|
2432
|
+
*
|
|
2433
|
+
* @example "Austin"
|
|
2434
|
+
*/
|
|
2435
|
+
city?: string;
|
|
2436
|
+
/**
|
|
2437
|
+
* Postal code of the incoming request
|
|
2438
|
+
*
|
|
2439
|
+
* @example "78701"
|
|
2440
|
+
*/
|
|
2441
|
+
postalCode?: string;
|
|
2442
|
+
/**
|
|
2443
|
+
* Latitude of the incoming request
|
|
2444
|
+
*
|
|
2445
|
+
* @example "30.27130"
|
|
2446
|
+
*/
|
|
2447
|
+
latitude?: string;
|
|
2448
|
+
/**
|
|
2449
|
+
* Longitude of the incoming request
|
|
2450
|
+
*
|
|
2451
|
+
* @example "-97.74260"
|
|
2452
|
+
*/
|
|
2453
|
+
longitude?: string;
|
|
2454
|
+
/**
|
|
2455
|
+
* Timezone of the incoming request
|
|
2456
|
+
*
|
|
2457
|
+
* @example "America/Chicago"
|
|
2458
|
+
*/
|
|
2459
|
+
timezone?: string;
|
|
2460
|
+
/**
|
|
2461
|
+
* If known, the ISO 3166-2 name for the first level region associated with
|
|
2462
|
+
* the IP address of the incoming request
|
|
2463
|
+
*
|
|
2464
|
+
* @example "Texas"
|
|
2465
|
+
*/
|
|
2466
|
+
region?: string;
|
|
2467
|
+
/**
|
|
2468
|
+
* If known, the ISO 3166-2 code for the first-level region associated with
|
|
2469
|
+
* the IP address of the incoming request
|
|
2470
|
+
*
|
|
2471
|
+
* @example "TX"
|
|
2472
|
+
*/
|
|
2473
|
+
regionCode?: string;
|
|
2474
|
+
/**
|
|
2475
|
+
* Metro code (DMA) of the incoming request
|
|
2476
|
+
*
|
|
2477
|
+
* @example "635"
|
|
2478
|
+
*/
|
|
2479
|
+
metroCode?: string;
|
|
2480
|
+
}
|
|
2329
2481
|
/** Data about the incoming request's TLS certificate */
|
|
2330
2482
|
export interface IncomingRequestCfPropertiesTLSClientAuth {
|
|
2331
2483
|
/** Always `"1"`, indicating that the certificate was presented */
|
|
@@ -2718,6 +2870,9 @@ export type Iso3166Alpha2Code =
|
|
|
2718
2870
|
| "ZW";
|
|
2719
2871
|
/** The 2-letter continent codes Cloudflare uses */
|
|
2720
2872
|
export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
2873
|
+
export type CfProperties<HostMetadata = unknown> =
|
|
2874
|
+
| IncomingRequestCfProperties<HostMetadata>
|
|
2875
|
+
| RequestInitCfProperties;
|
|
2721
2876
|
export interface D1Result<T = unknown> {
|
|
2722
2877
|
results?: T[];
|
|
2723
2878
|
success: boolean;
|
|
@@ -2738,7 +2893,7 @@ export declare abstract class D1PreparedStatement {
|
|
|
2738
2893
|
raw<T = unknown>(): Promise<T[]>;
|
|
2739
2894
|
}
|
|
2740
2895
|
/**
|
|
2741
|
-
*
|
|
2896
|
+
* An email message that can be sent from a Worker.
|
|
2742
2897
|
*/
|
|
2743
2898
|
export interface EmailMessage {
|
|
2744
2899
|
/**
|
|
@@ -2749,14 +2904,19 @@ export interface EmailMessage {
|
|
|
2749
2904
|
* Envelope To attribute of the email message.
|
|
2750
2905
|
*/
|
|
2751
2906
|
readonly to: string;
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* An email message that is sent to a consumer Worker and can be rejected/forwarded.
|
|
2910
|
+
*/
|
|
2911
|
+
export interface ForwardableEmailMessage extends EmailMessage {
|
|
2756
2912
|
/**
|
|
2757
2913
|
* Stream of the email message content.
|
|
2758
2914
|
*/
|
|
2759
2915
|
readonly raw: ReadableStream;
|
|
2916
|
+
/**
|
|
2917
|
+
* An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
|
|
2918
|
+
*/
|
|
2919
|
+
readonly headers: Headers;
|
|
2760
2920
|
/**
|
|
2761
2921
|
* Size of the email message content.
|
|
2762
2922
|
*/
|
|
@@ -2775,11 +2935,17 @@ export interface EmailMessage {
|
|
|
2775
2935
|
*/
|
|
2776
2936
|
forward(rcptTo: string, headers?: Headers): Promise<void>;
|
|
2777
2937
|
}
|
|
2938
|
+
/**
|
|
2939
|
+
* A binding that allows a Worker to send email messages.
|
|
2940
|
+
*/
|
|
2941
|
+
export interface SendEmail {
|
|
2942
|
+
send(message: EmailMessage): Promise<void>;
|
|
2943
|
+
}
|
|
2778
2944
|
export declare abstract class EmailEvent extends ExtendableEvent {
|
|
2779
|
-
readonly message:
|
|
2945
|
+
readonly message: ForwardableEmailMessage;
|
|
2780
2946
|
}
|
|
2781
2947
|
export type EmailExportedHandler<Env = unknown> = (
|
|
2782
|
-
message:
|
|
2948
|
+
message: ForwardableEmailMessage,
|
|
2783
2949
|
env: Env,
|
|
2784
2950
|
ctx: ExecutionContext
|
|
2785
2951
|
) => void | Promise<void>;
|
|
@@ -2860,75 +3026,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2860
3026
|
// Key Identifier of the JWK
|
|
2861
3027
|
readonly kid: string;
|
|
2862
3028
|
}
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
*/
|
|
2866
|
-
export interface Message<Body = unknown> {
|
|
2867
|
-
/**
|
|
2868
|
-
* A unique, system-generated ID for the message.
|
|
2869
|
-
*/
|
|
2870
|
-
readonly id: string;
|
|
3029
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3030
|
+
export interface DispatchNamespace {
|
|
2871
3031
|
/**
|
|
2872
|
-
*
|
|
3032
|
+
* @param name Name of the Worker script.
|
|
3033
|
+
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
3034
|
+
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2873
3035
|
*/
|
|
2874
|
-
|
|
2875
|
-
/**
|
|
2876
|
-
* The body of the message.
|
|
2877
|
-
*/
|
|
2878
|
-
readonly body: Body;
|
|
2879
|
-
/**
|
|
2880
|
-
* Marks message to be retried.
|
|
2881
|
-
*/
|
|
2882
|
-
retry(): void;
|
|
2883
|
-
/**
|
|
2884
|
-
* Marks message acknowledged.
|
|
2885
|
-
*/
|
|
2886
|
-
ack(): void;
|
|
2887
|
-
}
|
|
2888
|
-
/**
|
|
2889
|
-
* A batch of messages that are sent to a consumer Worker.
|
|
2890
|
-
*/
|
|
2891
|
-
export interface MessageBatch<Body = unknown> {
|
|
2892
|
-
/**
|
|
2893
|
-
* The name of the Queue that belongs to this batch.
|
|
2894
|
-
*/
|
|
2895
|
-
readonly queue: string;
|
|
2896
|
-
/**
|
|
2897
|
-
* An array of messages in the batch. Ordering of messages is not guaranteed.
|
|
2898
|
-
*/
|
|
2899
|
-
readonly messages: readonly Message<Body>[];
|
|
2900
|
-
/**
|
|
2901
|
-
* Marks every message to be retried in the next batch.
|
|
2902
|
-
*/
|
|
2903
|
-
retryAll(): void;
|
|
2904
|
-
/**
|
|
2905
|
-
* Marks every message acknowledged in the batch.
|
|
2906
|
-
*/
|
|
2907
|
-
ackAll(): void;
|
|
2908
|
-
}
|
|
2909
|
-
/**
|
|
2910
|
-
* A wrapper class used to structure message batches.
|
|
2911
|
-
*/
|
|
2912
|
-
export type MessageSendRequest<Body = unknown> = {
|
|
2913
|
-
/**
|
|
2914
|
-
* The body of the message.
|
|
2915
|
-
*/
|
|
2916
|
-
body: Body;
|
|
2917
|
-
};
|
|
2918
|
-
/**
|
|
2919
|
-
* A binding that allows a producer to send messages to a Queue.
|
|
2920
|
-
*/
|
|
2921
|
-
export interface Queue<Body = any> {
|
|
2922
|
-
/**
|
|
2923
|
-
* Sends a message to the Queue.
|
|
2924
|
-
* @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.
|
|
2925
|
-
* @returns A promise that resolves when the message is confirmed to be written to disk.
|
|
2926
|
-
*/
|
|
2927
|
-
send(message: Body): Promise<void>;
|
|
2928
|
-
/**
|
|
2929
|
-
* Sends a batch of messages to the Queue.
|
|
2930
|
-
* @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.
|
|
2931
|
-
* @returns A promise that resolves when the messages are confirmed to be written to disk.
|
|
2932
|
-
*/
|
|
2933
|
-
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
3036
|
+
get(name: string): Fetcher;
|
|
2934
3037
|
}
|