@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/2021-11-03/index.d.ts +288 -190
- package/2021-11-03/index.ts +281 -190
- package/2022-01-31/index.d.ts +288 -190
- package/2022-01-31/index.ts +281 -190
- package/2022-03-21/index.d.ts +288 -190
- package/2022-03-21/index.ts +281 -190
- package/2022-08-04/index.d.ts +288 -190
- package/2022-08-04/index.ts +281 -190
- package/2022-10-31/index.d.ts +291 -192
- package/2022-10-31/index.ts +284 -192
- package/2022-11-30/index.d.ts +291 -192
- package/2022-11-30/index.ts +284 -192
- package/README.md +1 -1
- package/experimental/index.d.ts +329 -192
- package/experimental/index.ts +322 -192
- package/index.d.ts +288 -190
- package/index.ts +281 -190
- package/oldest/index.d.ts +288 -190
- package/oldest/index.ts +281 -190
- package/package.json +1 -1
package/2022-08-04/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
|
-
|
|
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<
|
|
293
|
-
|
|
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<
|
|
318
|
-
|
|
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,
|
|
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:
|
|
381
|
+
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
|
|
358
382
|
}
|
|
383
|
+
export type DurableObjectJurisdiction = "eu" | "fedramp";
|
|
359
384
|
export interface DurableObjectNamespaceNewUniqueIdOptions {
|
|
360
|
-
jurisdiction?:
|
|
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?:
|
|
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
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
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():
|
|
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?:
|
|
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
|
-
|
|
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
|
|
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(
|
|
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
|
|
1647
|
+
export declare abstract class TailEvent extends ExtendableEvent {
|
|
1648
|
+
readonly events: TraceItem[];
|
|
1568
1649
|
readonly traces: TraceItem[];
|
|
1569
1650
|
}
|
|
1570
1651
|
export interface TraceItem {
|
|
@@ -1774,6 +1855,8 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
1774
1855
|
accept(): void;
|
|
1775
1856
|
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
|
|
1776
1857
|
close(code?: number, reason?: string): void;
|
|
1858
|
+
serializeAttachment(attachment: any): void;
|
|
1859
|
+
deserializeAttachment(): any | null;
|
|
1777
1860
|
static readonly READY_STATE_CONNECTING: number;
|
|
1778
1861
|
static readonly READY_STATE_OPEN: number;
|
|
1779
1862
|
static readonly READY_STATE_CLOSING: number;
|
|
@@ -1789,6 +1872,24 @@ export declare const WebSocketPair: {
|
|
|
1789
1872
|
1: WebSocket;
|
|
1790
1873
|
};
|
|
1791
1874
|
};
|
|
1875
|
+
export interface Socket {
|
|
1876
|
+
get readable(): ReadableStream;
|
|
1877
|
+
get writable(): WritableStream;
|
|
1878
|
+
get closed(): Promise<void>;
|
|
1879
|
+
close(): Promise<void>;
|
|
1880
|
+
startTls(options?: TlsOptions): Socket;
|
|
1881
|
+
}
|
|
1882
|
+
export interface SocketOptions {
|
|
1883
|
+
secureTransport?: string;
|
|
1884
|
+
allowHalfOpen: boolean;
|
|
1885
|
+
}
|
|
1886
|
+
export interface SocketAddress {
|
|
1887
|
+
hostname: string;
|
|
1888
|
+
port: number;
|
|
1889
|
+
}
|
|
1890
|
+
export interface TlsOptions {
|
|
1891
|
+
expectedServerHostname?: string;
|
|
1892
|
+
}
|
|
1792
1893
|
export interface BasicImageTransformations {
|
|
1793
1894
|
/**
|
|
1794
1895
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -1868,7 +1969,7 @@ export interface BasicImageTransformationsGravityCoordinates {
|
|
|
1868
1969
|
* Note: Currently, these properties cannot be tested in the
|
|
1869
1970
|
* playground.
|
|
1870
1971
|
*/
|
|
1871
|
-
export interface RequestInitCfProperties {
|
|
1972
|
+
export interface RequestInitCfProperties extends Record<string, unknown> {
|
|
1872
1973
|
cacheEverything?: boolean;
|
|
1873
1974
|
/**
|
|
1874
1975
|
* A request's cache key is what determines if two requests are
|
|
@@ -2038,6 +2139,49 @@ export interface RequestInitCfPropertiesImage
|
|
|
2038
2139
|
* the origin.
|
|
2039
2140
|
*/
|
|
2040
2141
|
"origin-auth"?: "share-publicly";
|
|
2142
|
+
/**
|
|
2143
|
+
* Adds a border around the image. The border is added after resizing. Border
|
|
2144
|
+
* width takes dpr into account, and can be specified either using a single
|
|
2145
|
+
* width property, or individually for each side.
|
|
2146
|
+
*/
|
|
2147
|
+
border?:
|
|
2148
|
+
| {
|
|
2149
|
+
color: string;
|
|
2150
|
+
width: number;
|
|
2151
|
+
}
|
|
2152
|
+
| {
|
|
2153
|
+
color: string;
|
|
2154
|
+
top: number;
|
|
2155
|
+
right: number;
|
|
2156
|
+
bottom: number;
|
|
2157
|
+
left: number;
|
|
2158
|
+
};
|
|
2159
|
+
/**
|
|
2160
|
+
* Increase brightness by a factor. A value of 1.0 equals no change, a value
|
|
2161
|
+
* of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
|
|
2162
|
+
* 0 is ignored.
|
|
2163
|
+
*/
|
|
2164
|
+
brightness?: number;
|
|
2165
|
+
/**
|
|
2166
|
+
* Increase contrast by a factor. A value of 1.0 equals no change, a value of
|
|
2167
|
+
* 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
|
|
2168
|
+
* ignored.
|
|
2169
|
+
*/
|
|
2170
|
+
contrast?: number;
|
|
2171
|
+
/**
|
|
2172
|
+
* Increase exposure by a factor. A value of 1.0 equals no change, a value of
|
|
2173
|
+
* 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
|
|
2174
|
+
*/
|
|
2175
|
+
gamma?: number;
|
|
2176
|
+
/**
|
|
2177
|
+
* Slightly reduces latency on a cache miss by selecting a
|
|
2178
|
+
* quickest-to-compress file format, at a cost of increased file size and
|
|
2179
|
+
* lower image quality. It will usually override the format option and choose
|
|
2180
|
+
* JPEG over WebP or AVIF. We do not recommend using this option, except in
|
|
2181
|
+
* unusual circumstances like resizing uncacheable dynamically-generated
|
|
2182
|
+
* images.
|
|
2183
|
+
*/
|
|
2184
|
+
compression?: "fast";
|
|
2041
2185
|
}
|
|
2042
2186
|
export interface RequestInitCfPropertiesImageMinify {
|
|
2043
2187
|
javascript?: boolean;
|
|
@@ -2053,7 +2197,8 @@ export type IncomingRequestCfProperties<HostMetadata = unknown> =
|
|
|
2053
2197
|
IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
|
|
2054
2198
|
IncomingRequestCfPropertiesGeographicInformation &
|
|
2055
2199
|
IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
|
|
2056
|
-
export interface IncomingRequestCfPropertiesBase
|
|
2200
|
+
export interface IncomingRequestCfPropertiesBase
|
|
2201
|
+
extends Record<string, unknown> {
|
|
2057
2202
|
/**
|
|
2058
2203
|
* [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
|
|
2059
2204
|
*
|
|
@@ -2134,8 +2279,7 @@ export interface IncomingRequestCfPropertiesBase {
|
|
|
2134
2279
|
export interface IncomingRequestCfPropertiesBotManagementBase {
|
|
2135
2280
|
/**
|
|
2136
2281
|
* 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).
|
|
2282
|
+
* represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
|
|
2139
2283
|
*
|
|
2140
2284
|
* @example 54
|
|
2141
2285
|
*/
|
|
@@ -2246,86 +2390,82 @@ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
|
|
|
2246
2390
|
/**
|
|
2247
2391
|
* Geographic data about the request's origin.
|
|
2248
2392
|
*/
|
|
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
|
-
};
|
|
2393
|
+
export interface IncomingRequestCfPropertiesGeographicInformation {
|
|
2394
|
+
/**
|
|
2395
|
+
* The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
|
|
2396
|
+
*
|
|
2397
|
+
* 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.
|
|
2398
|
+
*
|
|
2399
|
+
* If Cloudflare is unable to determine where the request originated this property is omitted.
|
|
2400
|
+
*
|
|
2401
|
+
* The country code `"T1"` is used for requests originating on TOR.
|
|
2402
|
+
*
|
|
2403
|
+
* @example "GB"
|
|
2404
|
+
*/
|
|
2405
|
+
country?: Iso3166Alpha2Code | "T1";
|
|
2406
|
+
/**
|
|
2407
|
+
* If present, this property indicates that the request originated in the EU
|
|
2408
|
+
*
|
|
2409
|
+
* @example "1"
|
|
2410
|
+
*/
|
|
2411
|
+
isEUCountry?: "1";
|
|
2412
|
+
/**
|
|
2413
|
+
* A two-letter code indicating the continent the request originated from.
|
|
2414
|
+
*
|
|
2415
|
+
* @example "AN"
|
|
2416
|
+
*/
|
|
2417
|
+
continent?: ContinentCode;
|
|
2418
|
+
/**
|
|
2419
|
+
* The city the request originated from
|
|
2420
|
+
*
|
|
2421
|
+
* @example "Austin"
|
|
2422
|
+
*/
|
|
2423
|
+
city?: string;
|
|
2424
|
+
/**
|
|
2425
|
+
* Postal code of the incoming request
|
|
2426
|
+
*
|
|
2427
|
+
* @example "78701"
|
|
2428
|
+
*/
|
|
2429
|
+
postalCode?: string;
|
|
2430
|
+
/**
|
|
2431
|
+
* Latitude of the incoming request
|
|
2432
|
+
*
|
|
2433
|
+
* @example "30.27130"
|
|
2434
|
+
*/
|
|
2435
|
+
latitude?: string;
|
|
2436
|
+
/**
|
|
2437
|
+
* Longitude of the incoming request
|
|
2438
|
+
*
|
|
2439
|
+
* @example "-97.74260"
|
|
2440
|
+
*/
|
|
2441
|
+
longitude?: string;
|
|
2442
|
+
/**
|
|
2443
|
+
* Timezone of the incoming request
|
|
2444
|
+
*
|
|
2445
|
+
* @example "America/Chicago"
|
|
2446
|
+
*/
|
|
2447
|
+
timezone?: string;
|
|
2448
|
+
/**
|
|
2449
|
+
* If known, the ISO 3166-2 name for the first level region associated with
|
|
2450
|
+
* the IP address of the incoming request
|
|
2451
|
+
*
|
|
2452
|
+
* @example "Texas"
|
|
2453
|
+
*/
|
|
2454
|
+
region?: string;
|
|
2455
|
+
/**
|
|
2456
|
+
* If known, the ISO 3166-2 code for the first-level region associated with
|
|
2457
|
+
* the IP address of the incoming request
|
|
2458
|
+
*
|
|
2459
|
+
* @example "TX"
|
|
2460
|
+
*/
|
|
2461
|
+
regionCode?: string;
|
|
2462
|
+
/**
|
|
2463
|
+
* Metro code (DMA) of the incoming request
|
|
2464
|
+
*
|
|
2465
|
+
* @example "635"
|
|
2466
|
+
*/
|
|
2467
|
+
metroCode?: string;
|
|
2468
|
+
}
|
|
2329
2469
|
/** Data about the incoming request's TLS certificate */
|
|
2330
2470
|
export interface IncomingRequestCfPropertiesTLSClientAuth {
|
|
2331
2471
|
/** Always `"1"`, indicating that the certificate was presented */
|
|
@@ -2718,6 +2858,9 @@ export type Iso3166Alpha2Code =
|
|
|
2718
2858
|
| "ZW";
|
|
2719
2859
|
/** The 2-letter continent codes Cloudflare uses */
|
|
2720
2860
|
export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
2861
|
+
export type CfProperties<HostMetadata = unknown> =
|
|
2862
|
+
| IncomingRequestCfProperties<HostMetadata>
|
|
2863
|
+
| RequestInitCfProperties;
|
|
2721
2864
|
export interface D1Result<T = unknown> {
|
|
2722
2865
|
results?: T[];
|
|
2723
2866
|
success: boolean;
|
|
@@ -2738,7 +2881,7 @@ export declare abstract class D1PreparedStatement {
|
|
|
2738
2881
|
raw<T = unknown>(): Promise<T[]>;
|
|
2739
2882
|
}
|
|
2740
2883
|
/**
|
|
2741
|
-
*
|
|
2884
|
+
* An email message that can be sent from a Worker.
|
|
2742
2885
|
*/
|
|
2743
2886
|
export interface EmailMessage {
|
|
2744
2887
|
/**
|
|
@@ -2749,14 +2892,19 @@ export interface EmailMessage {
|
|
|
2749
2892
|
* Envelope To attribute of the email message.
|
|
2750
2893
|
*/
|
|
2751
2894
|
readonly to: string;
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2895
|
+
}
|
|
2896
|
+
/**
|
|
2897
|
+
* An email message that is sent to a consumer Worker and can be rejected/forwarded.
|
|
2898
|
+
*/
|
|
2899
|
+
export interface ForwardableEmailMessage extends EmailMessage {
|
|
2756
2900
|
/**
|
|
2757
2901
|
* Stream of the email message content.
|
|
2758
2902
|
*/
|
|
2759
2903
|
readonly raw: ReadableStream;
|
|
2904
|
+
/**
|
|
2905
|
+
* An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
|
|
2906
|
+
*/
|
|
2907
|
+
readonly headers: Headers;
|
|
2760
2908
|
/**
|
|
2761
2909
|
* Size of the email message content.
|
|
2762
2910
|
*/
|
|
@@ -2775,11 +2923,17 @@ export interface EmailMessage {
|
|
|
2775
2923
|
*/
|
|
2776
2924
|
forward(rcptTo: string, headers?: Headers): Promise<void>;
|
|
2777
2925
|
}
|
|
2926
|
+
/**
|
|
2927
|
+
* A binding that allows a Worker to send email messages.
|
|
2928
|
+
*/
|
|
2929
|
+
export interface SendEmail {
|
|
2930
|
+
send(message: EmailMessage): Promise<void>;
|
|
2931
|
+
}
|
|
2778
2932
|
export declare abstract class EmailEvent extends ExtendableEvent {
|
|
2779
|
-
readonly message:
|
|
2933
|
+
readonly message: ForwardableEmailMessage;
|
|
2780
2934
|
}
|
|
2781
2935
|
export type EmailExportedHandler<Env = unknown> = (
|
|
2782
|
-
message:
|
|
2936
|
+
message: ForwardableEmailMessage,
|
|
2783
2937
|
env: Env,
|
|
2784
2938
|
ctx: ExecutionContext
|
|
2785
2939
|
) => void | Promise<void>;
|
|
@@ -2860,75 +3014,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2860
3014
|
// Key Identifier of the JWK
|
|
2861
3015
|
readonly kid: string;
|
|
2862
3016
|
}
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
*/
|
|
2866
|
-
export interface Message<Body = unknown> {
|
|
2867
|
-
/**
|
|
2868
|
-
* A unique, system-generated ID for the message.
|
|
2869
|
-
*/
|
|
2870
|
-
readonly id: string;
|
|
2871
|
-
/**
|
|
2872
|
-
* A timestamp when the message was sent.
|
|
2873
|
-
*/
|
|
2874
|
-
readonly timestamp: Date;
|
|
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> {
|
|
3017
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3018
|
+
export interface DispatchNamespace {
|
|
2892
3019
|
/**
|
|
2893
|
-
*
|
|
3020
|
+
* @param name Name of the Worker script.
|
|
3021
|
+
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
3022
|
+
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2894
3023
|
*/
|
|
2895
|
-
|
|
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>;
|
|
3024
|
+
get(name: string): Fetcher;
|
|
2934
3025
|
}
|