@cloudflare/workers-types 4.20230821.0 → 4.20230904.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.
@@ -0,0 +1,3113 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Cloudflare. All rights reserved.
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
+ this file except in compliance with the License. You may obtain a copy of the
7
+ License at http://www.apache.org/licenses/LICENSE-2.0
8
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
+ MERCHANTABLITY OR NON-INFRINGEMENT.
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+ /* eslint-disable */
16
+ // noinspection JSUnusedGlobalSymbols
17
+ export declare class DOMException extends Error {
18
+ constructor(message?: string, name?: string);
19
+ readonly message: string;
20
+ readonly name: string;
21
+ readonly code: number;
22
+ readonly stack: any;
23
+ static readonly INDEX_SIZE_ERR: number;
24
+ static readonly DOMSTRING_SIZE_ERR: number;
25
+ static readonly HIERARCHY_REQUEST_ERR: number;
26
+ static readonly WRONG_DOCUMENT_ERR: number;
27
+ static readonly INVALID_CHARACTER_ERR: number;
28
+ static readonly NO_DATA_ALLOWED_ERR: number;
29
+ static readonly NO_MODIFICATION_ALLOWED_ERR: number;
30
+ static readonly NOT_FOUND_ERR: number;
31
+ static readonly NOT_SUPPORTED_ERR: number;
32
+ static readonly INUSE_ATTRIBUTE_ERR: number;
33
+ static readonly INVALID_STATE_ERR: number;
34
+ static readonly SYNTAX_ERR: number;
35
+ static readonly INVALID_MODIFICATION_ERR: number;
36
+ static readonly NAMESPACE_ERR: number;
37
+ static readonly INVALID_ACCESS_ERR: number;
38
+ static readonly VALIDATION_ERR: number;
39
+ static readonly TYPE_MISMATCH_ERR: number;
40
+ static readonly SECURITY_ERR: number;
41
+ static readonly NETWORK_ERR: number;
42
+ static readonly ABORT_ERR: number;
43
+ static readonly URL_MISMATCH_ERR: number;
44
+ static readonly QUOTA_EXCEEDED_ERR: number;
45
+ static readonly TIMEOUT_ERR: number;
46
+ static readonly INVALID_NODE_TYPE_ERR: number;
47
+ static readonly DATA_CLONE_ERR: number;
48
+ }
49
+ export type WorkerGlobalScopeEventMap = {
50
+ fetch: FetchEvent;
51
+ scheduled: ScheduledEvent;
52
+ queue: QueueEvent;
53
+ unhandledrejection: PromiseRejectionEvent;
54
+ rejectionhandled: PromiseRejectionEvent;
55
+ };
56
+ export declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
57
+ EventTarget: typeof EventTarget;
58
+ }
59
+ export interface Console {
60
+ "assert"(condition?: boolean, ...data: any[]): void;
61
+ clear(): void;
62
+ count(label?: string): void;
63
+ countReset(label?: string): void;
64
+ debug(...data: any[]): void;
65
+ dir(item?: any, options?: any): void;
66
+ dirxml(...data: any[]): void;
67
+ error(...data: any[]): void;
68
+ group(...data: any[]): void;
69
+ groupCollapsed(...data: any[]): void;
70
+ groupEnd(): void;
71
+ info(...data: any[]): void;
72
+ log(...data: any[]): void;
73
+ table(tabularData?: any, properties?: string[]): void;
74
+ time(label?: string): void;
75
+ timeEnd(label?: string): void;
76
+ timeLog(label?: string, ...data: any[]): void;
77
+ timeStamp(label?: string): void;
78
+ trace(...data: any[]): void;
79
+ warn(...data: any[]): void;
80
+ }
81
+ export declare const console: Console;
82
+ export type BufferSource = ArrayBufferView | ArrayBuffer;
83
+ export declare namespace WebAssembly {
84
+ class CompileError extends Error {
85
+ constructor(message?: string);
86
+ }
87
+ class RuntimeError extends Error {
88
+ constructor(message?: string);
89
+ }
90
+ type ValueType =
91
+ | "anyfunc"
92
+ | "externref"
93
+ | "f32"
94
+ | "f64"
95
+ | "i32"
96
+ | "i64"
97
+ | "v128";
98
+ interface GlobalDescriptor {
99
+ value: ValueType;
100
+ mutable?: boolean;
101
+ }
102
+ class Global {
103
+ constructor(descriptor: GlobalDescriptor, value?: any);
104
+ value: any;
105
+ valueOf(): any;
106
+ }
107
+ type ImportValue = ExportValue | number;
108
+ type ModuleImports = Record<string, ImportValue>;
109
+ type Imports = Record<string, ModuleImports>;
110
+ type ExportValue = Function | Global | Memory | Table;
111
+ type Exports = Record<string, ExportValue>;
112
+ class Instance {
113
+ constructor(module: Module, imports?: Imports);
114
+ readonly exports: Exports;
115
+ }
116
+ interface MemoryDescriptor {
117
+ initial: number;
118
+ maximum?: number;
119
+ shared?: boolean;
120
+ }
121
+ class Memory {
122
+ constructor(descriptor: MemoryDescriptor);
123
+ readonly buffer: ArrayBuffer;
124
+ grow(delta: number): number;
125
+ }
126
+ type ImportExportKind = "function" | "global" | "memory" | "table";
127
+ interface ModuleExportDescriptor {
128
+ kind: ImportExportKind;
129
+ name: string;
130
+ }
131
+ interface ModuleImportDescriptor {
132
+ kind: ImportExportKind;
133
+ module: string;
134
+ name: string;
135
+ }
136
+ abstract class Module {
137
+ static customSections(module: Module, sectionName: string): ArrayBuffer[];
138
+ static exports(module: Module): ModuleExportDescriptor[];
139
+ static imports(module: Module): ModuleImportDescriptor[];
140
+ }
141
+ type TableKind = "anyfunc" | "externref";
142
+ interface TableDescriptor {
143
+ element: TableKind;
144
+ initial: number;
145
+ maximum?: number;
146
+ }
147
+ class Table {
148
+ constructor(descriptor: TableDescriptor, value?: any);
149
+ readonly length: number;
150
+ get(index: number): any;
151
+ grow(delta: number, value?: any): number;
152
+ set(index: number, value?: any): void;
153
+ }
154
+ function instantiate(module: Module, imports?: Imports): Promise<Instance>;
155
+ function validate(bytes: BufferSource): boolean;
156
+ }
157
+ /** This ServiceWorker API interface represents the global execution context of a service worker. */
158
+ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
159
+ DOMException: typeof DOMException;
160
+ WorkerGlobalScope: typeof WorkerGlobalScope;
161
+ btoa(data: string): string;
162
+ atob(data: string): string;
163
+ setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
164
+ setTimeout<Args extends any[]>(
165
+ callback: (...args: Args) => void,
166
+ msDelay?: number,
167
+ ...args: Args
168
+ ): number;
169
+ clearTimeout(timeoutId: number | null): void;
170
+ setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
171
+ setInterval<Args extends any[]>(
172
+ callback: (...args: Args) => void,
173
+ msDelay?: number,
174
+ ...args: Args
175
+ ): number;
176
+ clearInterval(timeoutId: number | null): void;
177
+ queueMicrotask(task: Function): void;
178
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
179
+ fetch(
180
+ input: RequestInfo,
181
+ init?: RequestInit<RequestInitCfProperties>
182
+ ): Promise<Response>;
183
+ self: ServiceWorkerGlobalScope;
184
+ crypto: Crypto;
185
+ caches: CacheStorage;
186
+ scheduler: Scheduler;
187
+ performance: Performance;
188
+ readonly origin: string;
189
+ Event: typeof Event;
190
+ ExtendableEvent: typeof ExtendableEvent;
191
+ PromiseRejectionEvent: typeof PromiseRejectionEvent;
192
+ FetchEvent: typeof FetchEvent;
193
+ TailEvent: typeof TailEvent;
194
+ TraceEvent: typeof TailEvent;
195
+ ScheduledEvent: typeof ScheduledEvent;
196
+ MessageEvent: typeof MessageEvent;
197
+ CloseEvent: typeof CloseEvent;
198
+ ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
199
+ ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
200
+ ReadableStream: typeof ReadableStream;
201
+ WritableStream: typeof WritableStream;
202
+ WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
203
+ TransformStream: typeof TransformStream;
204
+ ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
205
+ CountQueuingStrategy: typeof CountQueuingStrategy;
206
+ ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
207
+ ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
208
+ ReadableByteStreamController: typeof ReadableByteStreamController;
209
+ WritableStreamDefaultController: typeof WritableStreamDefaultController;
210
+ CompressionStream: typeof CompressionStream;
211
+ DecompressionStream: typeof DecompressionStream;
212
+ TextEncoderStream: typeof TextEncoderStream;
213
+ TextDecoderStream: typeof TextDecoderStream;
214
+ Headers: typeof Headers;
215
+ Body: typeof Body;
216
+ Request: typeof Request;
217
+ Response: typeof Response;
218
+ WebSocket: typeof WebSocket;
219
+ WebSocketPair: typeof WebSocketPair;
220
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
221
+ AbortController: typeof AbortController;
222
+ AbortSignal: typeof AbortSignal;
223
+ TextDecoder: typeof TextDecoder;
224
+ TextEncoder: typeof TextEncoder;
225
+ navigator: Navigator;
226
+ Navigator: typeof Navigator;
227
+ URL: typeof URL;
228
+ URLSearchParams: typeof URLSearchParams;
229
+ URLPattern: typeof URLPattern;
230
+ Blob: typeof Blob;
231
+ File: typeof File;
232
+ FormData: typeof FormData;
233
+ Crypto: typeof Crypto;
234
+ SubtleCrypto: typeof SubtleCrypto;
235
+ CryptoKey: typeof CryptoKey;
236
+ CacheStorage: typeof CacheStorage;
237
+ Cache: typeof Cache;
238
+ FixedLengthStream: typeof FixedLengthStream;
239
+ IdentityTransformStream: typeof IdentityTransformStream;
240
+ HTMLRewriter: typeof HTMLRewriter;
241
+ }
242
+ export declare function addEventListener<
243
+ Type extends keyof WorkerGlobalScopeEventMap
244
+ >(
245
+ type: Type,
246
+ handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
247
+ options?: EventTargetAddEventListenerOptions | boolean
248
+ ): void;
249
+ export declare function removeEventListener<
250
+ Type extends keyof WorkerGlobalScopeEventMap
251
+ >(
252
+ type: Type,
253
+ handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
254
+ options?: EventTargetEventListenerOptions | boolean
255
+ ): void;
256
+ /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
257
+ export declare function dispatchEvent(
258
+ event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]
259
+ ): boolean;
260
+ export declare function btoa(data: string): string;
261
+ export declare function atob(data: string): string;
262
+ export declare function setTimeout(
263
+ callback: (...args: any[]) => void,
264
+ msDelay?: number
265
+ ): number;
266
+ export declare function setTimeout<Args extends any[]>(
267
+ callback: (...args: Args) => void,
268
+ msDelay?: number,
269
+ ...args: Args
270
+ ): number;
271
+ export declare function clearTimeout(timeoutId: number | null): void;
272
+ export declare function setInterval(
273
+ callback: (...args: any[]) => void,
274
+ msDelay?: number
275
+ ): number;
276
+ export declare function setInterval<Args extends any[]>(
277
+ callback: (...args: Args) => void,
278
+ msDelay?: number,
279
+ ...args: Args
280
+ ): number;
281
+ export declare function clearInterval(timeoutId: number | null): void;
282
+ export declare function queueMicrotask(task: Function): void;
283
+ export declare function structuredClone<T>(
284
+ value: T,
285
+ options?: StructuredSerializeOptions
286
+ ): T;
287
+ export declare function fetch(
288
+ input: RequestInfo,
289
+ init?: RequestInit<RequestInitCfProperties>
290
+ ): Promise<Response>;
291
+ export declare const self: ServiceWorkerGlobalScope;
292
+ export declare const crypto: Crypto;
293
+ export declare const caches: CacheStorage;
294
+ export declare const scheduler: Scheduler;
295
+ export declare const performance: Performance;
296
+ export declare const origin: string;
297
+ export declare const navigator: Navigator;
298
+ export interface TestController {}
299
+ export interface ExecutionContext {
300
+ waitUntil(promise: Promise<any>): void;
301
+ passThroughOnException(): void;
302
+ }
303
+ export type ExportedHandlerFetchHandler<
304
+ Env = unknown,
305
+ CfHostMetadata = unknown
306
+ > = (
307
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
308
+ env: Env,
309
+ ctx: ExecutionContext
310
+ ) => Response | Promise<Response>;
311
+ export type ExportedHandlerTailHandler<Env = unknown> = (
312
+ events: TraceItem[],
313
+ env: Env,
314
+ ctx: ExecutionContext
315
+ ) => void | Promise<void>;
316
+ export type ExportedHandlerTraceHandler<Env = unknown> = (
317
+ traces: TraceItem[],
318
+ env: Env,
319
+ ctx: ExecutionContext
320
+ ) => void | Promise<void>;
321
+ export type ExportedHandlerScheduledHandler<Env = unknown> = (
322
+ controller: ScheduledController,
323
+ env: Env,
324
+ ctx: ExecutionContext
325
+ ) => void | Promise<void>;
326
+ export type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
327
+ batch: MessageBatch<Message>,
328
+ env: Env,
329
+ ctx: ExecutionContext
330
+ ) => void | Promise<void>;
331
+ export type ExportedHandlerTestHandler<Env = unknown> = (
332
+ controller: TestController,
333
+ env: Env,
334
+ ctx: ExecutionContext
335
+ ) => void | Promise<void>;
336
+ export interface ExportedHandler<
337
+ Env = unknown,
338
+ QueueHandlerMessage = unknown,
339
+ CfHostMetadata = unknown
340
+ > {
341
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
342
+ tail?: ExportedHandlerTailHandler<Env>;
343
+ trace?: ExportedHandlerTraceHandler<Env>;
344
+ scheduled?: ExportedHandlerScheduledHandler<Env>;
345
+ test?: ExportedHandlerTestHandler<Env>;
346
+ email?: EmailExportedHandler<Env>;
347
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
348
+ }
349
+ export interface StructuredSerializeOptions {
350
+ transfer?: any[];
351
+ }
352
+ export declare abstract class PromiseRejectionEvent extends Event {
353
+ readonly promise: Promise<any>;
354
+ readonly reason: any;
355
+ }
356
+ export declare abstract class Navigator {
357
+ readonly userAgent: string;
358
+ }
359
+ /** 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. */
360
+ export interface Performance {
361
+ readonly timeOrigin: number;
362
+ now(): number;
363
+ }
364
+ export interface DurableObject {
365
+ fetch(request: Request): Response | Promise<Response>;
366
+ alarm?(): void | Promise<void>;
367
+ webSocketMessage?(
368
+ ws: WebSocket,
369
+ message: string | ArrayBuffer
370
+ ): void | Promise<void>;
371
+ webSocketClose?(
372
+ ws: WebSocket,
373
+ code: number,
374
+ reason: string,
375
+ wasClean: boolean
376
+ ): void | Promise<void>;
377
+ webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
378
+ }
379
+ export interface DurableObjectStub extends Fetcher {
380
+ readonly id: DurableObjectId;
381
+ readonly name?: string;
382
+ }
383
+ export interface DurableObjectId {
384
+ toString(): string;
385
+ equals(other: DurableObjectId): boolean;
386
+ readonly name?: string;
387
+ }
388
+ export interface DurableObjectNamespace {
389
+ newUniqueId(
390
+ options?: DurableObjectNamespaceNewUniqueIdOptions
391
+ ): DurableObjectId;
392
+ idFromName(name: string): DurableObjectId;
393
+ idFromString(id: string): DurableObjectId;
394
+ get(
395
+ id: DurableObjectId,
396
+ options?: DurableObjectNamespaceGetDurableObjectOptions
397
+ ): DurableObjectStub;
398
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
399
+ }
400
+ export type DurableObjectJurisdiction = "eu" | "fedramp";
401
+ export interface DurableObjectNamespaceNewUniqueIdOptions {
402
+ jurisdiction?: DurableObjectJurisdiction;
403
+ }
404
+ export type DurableObjectLocationHint =
405
+ | "wnam"
406
+ | "enam"
407
+ | "sam"
408
+ | "weur"
409
+ | "eeur"
410
+ | "apac"
411
+ | "oc"
412
+ | "afr"
413
+ | "me";
414
+ export interface DurableObjectNamespaceGetDurableObjectOptions {
415
+ locationHint?: DurableObjectLocationHint;
416
+ }
417
+ export interface DurableObjectState {
418
+ waitUntil(promise: Promise<any>): void;
419
+ readonly id: DurableObjectId;
420
+ readonly storage: DurableObjectStorage;
421
+ blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
422
+ acceptWebSocket(ws: WebSocket, tags?: string[]): void;
423
+ getWebSockets(tag?: string): WebSocket[];
424
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
425
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
426
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
427
+ }
428
+ export interface DurableObjectTransaction {
429
+ get<T = unknown>(
430
+ key: string,
431
+ options?: DurableObjectGetOptions
432
+ ): Promise<T | undefined>;
433
+ get<T = unknown>(
434
+ keys: string[],
435
+ options?: DurableObjectGetOptions
436
+ ): Promise<Map<string, T>>;
437
+ list<T = unknown>(
438
+ options?: DurableObjectListOptions
439
+ ): Promise<Map<string, T>>;
440
+ put<T>(
441
+ key: string,
442
+ value: T,
443
+ options?: DurableObjectPutOptions
444
+ ): Promise<void>;
445
+ put<T>(
446
+ entries: Record<string, T>,
447
+ options?: DurableObjectPutOptions
448
+ ): Promise<void>;
449
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
450
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
451
+ rollback(): void;
452
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
453
+ setAlarm(
454
+ scheduledTime: number | Date,
455
+ options?: DurableObjectSetAlarmOptions
456
+ ): Promise<void>;
457
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
458
+ }
459
+ export interface DurableObjectStorage {
460
+ get<T = unknown>(
461
+ key: string,
462
+ options?: DurableObjectGetOptions
463
+ ): Promise<T | undefined>;
464
+ get<T = unknown>(
465
+ keys: string[],
466
+ options?: DurableObjectGetOptions
467
+ ): Promise<Map<string, T>>;
468
+ list<T = unknown>(
469
+ options?: DurableObjectListOptions
470
+ ): Promise<Map<string, T>>;
471
+ put<T>(
472
+ key: string,
473
+ value: T,
474
+ options?: DurableObjectPutOptions
475
+ ): Promise<void>;
476
+ put<T>(
477
+ entries: Record<string, T>,
478
+ options?: DurableObjectPutOptions
479
+ ): Promise<void>;
480
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
481
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
482
+ deleteAll(options?: DurableObjectPutOptions): Promise<void>;
483
+ transaction<T>(
484
+ closure: (txn: DurableObjectTransaction) => Promise<T>
485
+ ): Promise<T>;
486
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
487
+ setAlarm(
488
+ scheduledTime: number | Date,
489
+ options?: DurableObjectSetAlarmOptions
490
+ ): Promise<void>;
491
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
492
+ sync(): Promise<void>;
493
+ transactionSync<T>(closure: () => T): T;
494
+ }
495
+ export interface DurableObjectListOptions {
496
+ start?: string;
497
+ startAfter?: string;
498
+ end?: string;
499
+ prefix?: string;
500
+ reverse?: boolean;
501
+ limit?: number;
502
+ allowConcurrency?: boolean;
503
+ noCache?: boolean;
504
+ }
505
+ export interface DurableObjectGetOptions {
506
+ allowConcurrency?: boolean;
507
+ noCache?: boolean;
508
+ }
509
+ export interface DurableObjectGetAlarmOptions {
510
+ allowConcurrency?: boolean;
511
+ }
512
+ export interface DurableObjectPutOptions {
513
+ allowConcurrency?: boolean;
514
+ allowUnconfirmed?: boolean;
515
+ noCache?: boolean;
516
+ }
517
+ export interface DurableObjectSetAlarmOptions {
518
+ allowConcurrency?: boolean;
519
+ allowUnconfirmed?: boolean;
520
+ }
521
+ export declare class WebSocketRequestResponsePair {
522
+ constructor(request: string, response: string);
523
+ get request(): string;
524
+ get response(): string;
525
+ }
526
+ export interface AnalyticsEngineDataset {
527
+ writeDataPoint(event?: AnalyticsEngineDataPoint): void;
528
+ }
529
+ export interface AnalyticsEngineDataPoint {
530
+ indexes?: ((ArrayBuffer | string) | null)[];
531
+ doubles?: number[];
532
+ blobs?: ((ArrayBuffer | string) | null)[];
533
+ }
534
+ export declare class Event {
535
+ constructor(type: string, init?: EventInit);
536
+ get type(): string;
537
+ get eventPhase(): number;
538
+ get composed(): boolean;
539
+ get bubbles(): boolean;
540
+ get cancelable(): boolean;
541
+ get defaultPrevented(): boolean;
542
+ get returnValue(): boolean;
543
+ get currentTarget(): EventTarget | undefined;
544
+ get srcElement(): EventTarget | undefined;
545
+ get timeStamp(): number;
546
+ get isTrusted(): boolean;
547
+ get cancelBubble(): boolean;
548
+ set cancelBubble(value: boolean);
549
+ stopImmediatePropagation(): void;
550
+ preventDefault(): void;
551
+ stopPropagation(): void;
552
+ composedPath(): EventTarget[];
553
+ static readonly NONE: number;
554
+ static readonly CAPTURING_PHASE: number;
555
+ static readonly AT_TARGET: number;
556
+ static readonly BUBBLING_PHASE: number;
557
+ }
558
+ export interface EventInit {
559
+ bubbles?: boolean;
560
+ cancelable?: boolean;
561
+ composed?: boolean;
562
+ }
563
+ export type EventListener<EventType extends Event = Event> = (
564
+ event: EventType
565
+ ) => void;
566
+ export interface EventListenerObject<EventType extends Event = Event> {
567
+ handleEvent(event: EventType): void;
568
+ }
569
+ export type EventListenerOrEventListenerObject<
570
+ EventType extends Event = Event
571
+ > = EventListener<EventType> | EventListenerObject<EventType>;
572
+ export declare class EventTarget<
573
+ EventMap extends Record<string, Event> = Record<string, Event>
574
+ > {
575
+ constructor();
576
+ addEventListener<Type extends keyof EventMap>(
577
+ type: Type,
578
+ handler: EventListenerOrEventListenerObject<EventMap[Type]>,
579
+ options?: EventTargetAddEventListenerOptions | boolean
580
+ ): void;
581
+ removeEventListener<Type extends keyof EventMap>(
582
+ type: Type,
583
+ handler: EventListenerOrEventListenerObject<EventMap[Type]>,
584
+ options?: EventTargetEventListenerOptions | boolean
585
+ ): void;
586
+ dispatchEvent(event: EventMap[keyof EventMap]): boolean;
587
+ }
588
+ export interface EventTargetEventListenerOptions {
589
+ capture?: boolean;
590
+ }
591
+ export interface EventTargetAddEventListenerOptions {
592
+ capture?: boolean;
593
+ passive?: boolean;
594
+ once?: boolean;
595
+ signal?: AbortSignal;
596
+ }
597
+ export interface EventTargetHandlerObject {
598
+ handleEvent: (event: Event) => any | undefined;
599
+ }
600
+ export declare class AbortController {
601
+ constructor();
602
+ get signal(): AbortSignal;
603
+ abort(reason?: any): void;
604
+ }
605
+ export declare abstract class AbortSignal extends EventTarget {
606
+ static abort(reason?: any): AbortSignal;
607
+ static timeout(delay: number): AbortSignal;
608
+ static any(signals: AbortSignal[]): AbortSignal;
609
+ get aborted(): boolean;
610
+ get reason(): any;
611
+ throwIfAborted(): void;
612
+ }
613
+ export interface Scheduler {
614
+ wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
615
+ }
616
+ export interface SchedulerWaitOptions {
617
+ signal?: AbortSignal;
618
+ }
619
+ export declare abstract class ExtendableEvent extends Event {
620
+ waitUntil(promise: Promise<any>): void;
621
+ }
622
+ export declare class Blob {
623
+ constructor(
624
+ bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
625
+ options?: BlobOptions
626
+ );
627
+ get size(): number;
628
+ get type(): string;
629
+ slice(start?: number, end?: number, type?: string): Blob;
630
+ arrayBuffer(): Promise<ArrayBuffer>;
631
+ text(): Promise<string>;
632
+ stream(): ReadableStream;
633
+ }
634
+ export interface BlobOptions {
635
+ type?: string;
636
+ }
637
+ export declare class File extends Blob {
638
+ constructor(
639
+ bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
640
+ name: string,
641
+ options?: FileOptions
642
+ );
643
+ get name(): string;
644
+ get lastModified(): number;
645
+ }
646
+ export interface FileOptions {
647
+ type?: string;
648
+ lastModified?: number;
649
+ }
650
+ export declare abstract class CacheStorage {
651
+ open(cacheName: string): Promise<Cache>;
652
+ readonly default: Cache;
653
+ }
654
+ export declare abstract class Cache {
655
+ delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
656
+ match(
657
+ request: RequestInfo,
658
+ options?: CacheQueryOptions
659
+ ): Promise<Response | undefined>;
660
+ put(request: RequestInfo, response: Response): Promise<void>;
661
+ }
662
+ export interface CacheQueryOptions {
663
+ ignoreMethod?: boolean;
664
+ }
665
+ export declare abstract class Crypto {
666
+ get subtle(): SubtleCrypto;
667
+ getRandomValues<
668
+ T extends
669
+ | Int8Array
670
+ | Uint8Array
671
+ | Int16Array
672
+ | Uint16Array
673
+ | Int32Array
674
+ | Uint32Array
675
+ | BigInt64Array
676
+ | BigUint64Array
677
+ >(buffer: T): T;
678
+ randomUUID(): string;
679
+ DigestStream: typeof DigestStream;
680
+ }
681
+ export declare abstract class SubtleCrypto {
682
+ encrypt(
683
+ algorithm: string | SubtleCryptoEncryptAlgorithm,
684
+ key: CryptoKey,
685
+ plainText: ArrayBuffer | ArrayBufferView
686
+ ): Promise<ArrayBuffer>;
687
+ decrypt(
688
+ algorithm: string | SubtleCryptoEncryptAlgorithm,
689
+ key: CryptoKey,
690
+ cipherText: ArrayBuffer | ArrayBufferView
691
+ ): Promise<ArrayBuffer>;
692
+ sign(
693
+ algorithm: string | SubtleCryptoSignAlgorithm,
694
+ key: CryptoKey,
695
+ data: ArrayBuffer | ArrayBufferView
696
+ ): Promise<ArrayBuffer>;
697
+ verify(
698
+ algorithm: string | SubtleCryptoSignAlgorithm,
699
+ key: CryptoKey,
700
+ signature: ArrayBuffer | ArrayBufferView,
701
+ data: ArrayBuffer | ArrayBufferView
702
+ ): Promise<boolean>;
703
+ digest(
704
+ algorithm: string | SubtleCryptoHashAlgorithm,
705
+ data: ArrayBuffer | ArrayBufferView
706
+ ): Promise<ArrayBuffer>;
707
+ generateKey(
708
+ algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
709
+ extractable: boolean,
710
+ keyUsages: string[]
711
+ ): Promise<CryptoKey | CryptoKeyPair>;
712
+ deriveKey(
713
+ algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
714
+ baseKey: CryptoKey,
715
+ derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
716
+ extractable: boolean,
717
+ keyUsages: string[]
718
+ ): Promise<CryptoKey>;
719
+ deriveBits(
720
+ algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
721
+ baseKey: CryptoKey,
722
+ length: number | null
723
+ ): Promise<ArrayBuffer>;
724
+ importKey(
725
+ format: string,
726
+ keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
727
+ algorithm: string | SubtleCryptoImportKeyAlgorithm,
728
+ extractable: boolean,
729
+ keyUsages: string[]
730
+ ): Promise<CryptoKey>;
731
+ exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
732
+ wrapKey(
733
+ format: string,
734
+ key: CryptoKey,
735
+ wrappingKey: CryptoKey,
736
+ wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm
737
+ ): Promise<ArrayBuffer>;
738
+ unwrapKey(
739
+ format: string,
740
+ wrappedKey: ArrayBuffer | ArrayBufferView,
741
+ unwrappingKey: CryptoKey,
742
+ unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
743
+ unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
744
+ extractable: boolean,
745
+ keyUsages: string[]
746
+ ): Promise<CryptoKey>;
747
+ timingSafeEqual(
748
+ a: ArrayBuffer | ArrayBufferView,
749
+ b: ArrayBuffer | ArrayBufferView
750
+ ): boolean;
751
+ }
752
+ export declare abstract class CryptoKey {
753
+ readonly type: string;
754
+ readonly extractable: boolean;
755
+ readonly algorithm:
756
+ | CryptoKeyKeyAlgorithm
757
+ | CryptoKeyAesKeyAlgorithm
758
+ | CryptoKeyHmacKeyAlgorithm
759
+ | CryptoKeyRsaKeyAlgorithm
760
+ | CryptoKeyEllipticKeyAlgorithm
761
+ | CryptoKeyArbitraryKeyAlgorithm;
762
+ readonly usages: string[];
763
+ }
764
+ export interface CryptoKeyPair {
765
+ publicKey: CryptoKey;
766
+ privateKey: CryptoKey;
767
+ }
768
+ export interface JsonWebKey {
769
+ kty: string;
770
+ use?: string;
771
+ key_ops?: string[];
772
+ alg?: string;
773
+ ext?: boolean;
774
+ crv?: string;
775
+ x?: string;
776
+ y?: string;
777
+ d?: string;
778
+ n?: string;
779
+ e?: string;
780
+ p?: string;
781
+ q?: string;
782
+ dp?: string;
783
+ dq?: string;
784
+ qi?: string;
785
+ oth?: RsaOtherPrimesInfo[];
786
+ k?: string;
787
+ }
788
+ export interface RsaOtherPrimesInfo {
789
+ r?: string;
790
+ d?: string;
791
+ t?: string;
792
+ }
793
+ export interface SubtleCryptoDeriveKeyAlgorithm {
794
+ name: string;
795
+ salt?: ArrayBuffer;
796
+ iterations?: number;
797
+ hash?: string | SubtleCryptoHashAlgorithm;
798
+ $public?: CryptoKey;
799
+ info?: ArrayBuffer;
800
+ }
801
+ export interface SubtleCryptoEncryptAlgorithm {
802
+ name: string;
803
+ iv?: ArrayBuffer;
804
+ additionalData?: ArrayBuffer;
805
+ tagLength?: number;
806
+ counter?: ArrayBuffer;
807
+ length?: number;
808
+ label?: ArrayBuffer;
809
+ }
810
+ export interface SubtleCryptoGenerateKeyAlgorithm {
811
+ name: string;
812
+ hash?: string | SubtleCryptoHashAlgorithm;
813
+ modulusLength?: number;
814
+ publicExponent?: ArrayBuffer;
815
+ length?: number;
816
+ namedCurve?: string;
817
+ }
818
+ export interface SubtleCryptoHashAlgorithm {
819
+ name: string;
820
+ }
821
+ export interface SubtleCryptoImportKeyAlgorithm {
822
+ name: string;
823
+ hash?: string | SubtleCryptoHashAlgorithm;
824
+ length?: number;
825
+ namedCurve?: string;
826
+ compressed?: boolean;
827
+ }
828
+ export interface SubtleCryptoSignAlgorithm {
829
+ name: string;
830
+ hash?: string | SubtleCryptoHashAlgorithm;
831
+ dataLength?: number;
832
+ saltLength?: number;
833
+ }
834
+ export interface CryptoKeyKeyAlgorithm {
835
+ name: string;
836
+ }
837
+ export interface CryptoKeyAesKeyAlgorithm {
838
+ name: string;
839
+ length: number;
840
+ }
841
+ export interface CryptoKeyHmacKeyAlgorithm {
842
+ name: string;
843
+ hash: CryptoKeyKeyAlgorithm;
844
+ length: number;
845
+ }
846
+ export interface CryptoKeyRsaKeyAlgorithm {
847
+ name: string;
848
+ modulusLength: number;
849
+ publicExponent: ArrayBuffer;
850
+ hash?: CryptoKeyKeyAlgorithm;
851
+ }
852
+ export interface CryptoKeyEllipticKeyAlgorithm {
853
+ name: string;
854
+ namedCurve: string;
855
+ }
856
+ export interface CryptoKeyArbitraryKeyAlgorithm {
857
+ name: string;
858
+ hash?: CryptoKeyKeyAlgorithm;
859
+ namedCurve?: string;
860
+ length?: number;
861
+ }
862
+ export declare class DigestStream extends WritableStream<
863
+ ArrayBuffer | ArrayBufferView
864
+ > {
865
+ constructor(algorithm: string | SubtleCryptoHashAlgorithm);
866
+ get digest(): Promise<ArrayBuffer>;
867
+ }
868
+ export declare class TextDecoder {
869
+ constructor(decoder?: string, options?: TextDecoderConstructorOptions);
870
+ decode(
871
+ input?: ArrayBuffer | ArrayBufferView,
872
+ options?: TextDecoderDecodeOptions
873
+ ): string;
874
+ get encoding(): string;
875
+ get fatal(): boolean;
876
+ get ignoreBOM(): boolean;
877
+ }
878
+ export declare class TextEncoder {
879
+ constructor();
880
+ encode(input?: string): ArrayBuffer | ArrayBufferView;
881
+ encodeInto(
882
+ input: string,
883
+ buffer: ArrayBuffer | ArrayBufferView
884
+ ): TextEncoderEncodeIntoResult;
885
+ get encoding(): string;
886
+ }
887
+ export interface TextDecoderConstructorOptions {
888
+ fatal: boolean;
889
+ ignoreBOM: boolean;
890
+ }
891
+ export interface TextDecoderDecodeOptions {
892
+ stream: boolean;
893
+ }
894
+ export interface TextEncoderEncodeIntoResult {
895
+ read: number;
896
+ written: number;
897
+ }
898
+ export declare class FormData {
899
+ constructor();
900
+ append(name: string, value: string): void;
901
+ append(name: string, value: Blob, filename?: string): void;
902
+ delete(name: string): void;
903
+ get(name: string): (File | string) | null;
904
+ getAll(name: string): (File | string)[];
905
+ has(name: string): boolean;
906
+ set(name: string, value: string): void;
907
+ set(name: string, value: Blob, filename?: string): void;
908
+ entries(): IterableIterator<[key: string, value: File | string]>;
909
+ keys(): IterableIterator<string>;
910
+ values(): IterableIterator<File | string>;
911
+ forEach<This = unknown>(
912
+ callback: (
913
+ this: This,
914
+ value: File | string,
915
+ key: string,
916
+ parent: FormData
917
+ ) => void,
918
+ thisArg?: This
919
+ ): void;
920
+ [Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
921
+ }
922
+ export interface ContentOptions {
923
+ html?: boolean;
924
+ }
925
+ export declare class HTMLRewriter {
926
+ constructor();
927
+ on(
928
+ selector: string,
929
+ handlers: HTMLRewriterElementContentHandlers
930
+ ): HTMLRewriter;
931
+ onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
932
+ transform(response: Response): Response;
933
+ }
934
+ export interface HTMLRewriterElementContentHandlers {
935
+ element?(element: Element): void | Promise<void>;
936
+ comments?(comment: Comment): void | Promise<void>;
937
+ text?(element: Text): void | Promise<void>;
938
+ }
939
+ export interface HTMLRewriterDocumentContentHandlers {
940
+ doctype?(doctype: Doctype): void | Promise<void>;
941
+ comments?(comment: Comment): void | Promise<void>;
942
+ text?(text: Text): void | Promise<void>;
943
+ end?(end: DocumentEnd): void | Promise<void>;
944
+ }
945
+ export interface Doctype {
946
+ readonly name: string | null;
947
+ readonly publicId: string | null;
948
+ readonly systemId: string | null;
949
+ }
950
+ export interface Element {
951
+ tagName: string;
952
+ readonly attributes: IterableIterator<string[]>;
953
+ readonly removed: boolean;
954
+ readonly namespaceURI: string;
955
+ getAttribute(name: string): string | null;
956
+ hasAttribute(name: string): boolean;
957
+ setAttribute(name: string, value: string): Element;
958
+ removeAttribute(name: string): Element;
959
+ before(content: string, options?: ContentOptions): Element;
960
+ after(content: string, options?: ContentOptions): Element;
961
+ prepend(content: string, options?: ContentOptions): Element;
962
+ append(content: string, options?: ContentOptions): Element;
963
+ replace(content: string, options?: ContentOptions): Element;
964
+ remove(): Element;
965
+ removeAndKeepContent(): Element;
966
+ setInnerContent(content: string, options?: ContentOptions): Element;
967
+ onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
968
+ }
969
+ export interface EndTag {
970
+ name: string;
971
+ before(content: string, options?: ContentOptions): EndTag;
972
+ after(content: string, options?: ContentOptions): EndTag;
973
+ remove(): EndTag;
974
+ }
975
+ export interface Comment {
976
+ text: string;
977
+ readonly removed: boolean;
978
+ before(content: string, options?: ContentOptions): Comment;
979
+ after(content: string, options?: ContentOptions): Comment;
980
+ replace(content: string, options?: ContentOptions): Comment;
981
+ remove(): Comment;
982
+ }
983
+ export interface Text {
984
+ readonly text: string;
985
+ readonly lastInTextNode: boolean;
986
+ readonly removed: boolean;
987
+ before(content: string, options?: ContentOptions): Text;
988
+ after(content: string, options?: ContentOptions): Text;
989
+ replace(content: string, options?: ContentOptions): Text;
990
+ remove(): Text;
991
+ }
992
+ export interface DocumentEnd {
993
+ append(content: string, options?: ContentOptions): DocumentEnd;
994
+ }
995
+ export declare abstract class FetchEvent extends ExtendableEvent {
996
+ readonly request: Request;
997
+ respondWith(promise: Response | Promise<Response>): void;
998
+ passThroughOnException(): void;
999
+ }
1000
+ export type HeadersInit =
1001
+ | Headers
1002
+ | Iterable<Iterable<string>>
1003
+ | Record<string, string>;
1004
+ export declare class Headers {
1005
+ constructor(init?: HeadersInit);
1006
+ get(name: string): string | null;
1007
+ getAll(name: string): string[];
1008
+ getSetCookie(): string[];
1009
+ has(name: string): boolean;
1010
+ set(name: string, value: string): void;
1011
+ append(name: string, value: string): void;
1012
+ delete(name: string): void;
1013
+ forEach<This = unknown>(
1014
+ callback: (this: This, value: string, key: string, parent: Headers) => void,
1015
+ thisArg?: This
1016
+ ): void;
1017
+ entries(): IterableIterator<[key: string, value: string]>;
1018
+ keys(): IterableIterator<string>;
1019
+ values(): IterableIterator<string>;
1020
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
1021
+ }
1022
+ export type BodyInit =
1023
+ | ReadableStream<Uint8Array>
1024
+ | string
1025
+ | ArrayBuffer
1026
+ | ArrayBufferView
1027
+ | Blob
1028
+ | URLSearchParams
1029
+ | FormData;
1030
+ export declare abstract class Body {
1031
+ get body(): ReadableStream | null;
1032
+ get bodyUsed(): boolean;
1033
+ arrayBuffer(): Promise<ArrayBuffer>;
1034
+ text(): Promise<string>;
1035
+ json<T>(): Promise<T>;
1036
+ formData(): Promise<FormData>;
1037
+ blob(): Promise<Blob>;
1038
+ }
1039
+ export declare class Response extends Body {
1040
+ constructor(body?: BodyInit | null, init?: ResponseInit);
1041
+ static redirect(url: string, status?: number): Response;
1042
+ static json(any: any, maybeInit?: ResponseInit | Response): Response;
1043
+ clone(): Response;
1044
+ get status(): number;
1045
+ get statusText(): string;
1046
+ get headers(): Headers;
1047
+ get ok(): boolean;
1048
+ get redirected(): boolean;
1049
+ get url(): string;
1050
+ get webSocket(): WebSocket | null;
1051
+ get cf(): any | undefined;
1052
+ }
1053
+ export interface ResponseInit {
1054
+ status?: number;
1055
+ statusText?: string;
1056
+ headers?: HeadersInit;
1057
+ cf?: any;
1058
+ webSocket?: WebSocket | null;
1059
+ encodeBody?: "automatic" | "manual";
1060
+ }
1061
+ export type RequestInfo<
1062
+ CfHostMetadata = unknown,
1063
+ Cf = CfProperties<CfHostMetadata>
1064
+ > = Request<CfHostMetadata, Cf> | string | URL;
1065
+ export declare class Request<
1066
+ CfHostMetadata = unknown,
1067
+ Cf = CfProperties<CfHostMetadata>
1068
+ > extends Body {
1069
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1070
+ clone(): Request<CfHostMetadata, Cf>;
1071
+ get method(): string;
1072
+ get url(): string;
1073
+ get headers(): Headers;
1074
+ get redirect(): string;
1075
+ get fetcher(): Fetcher | null;
1076
+ get signal(): AbortSignal;
1077
+ get cf(): Cf | undefined;
1078
+ get integrity(): string;
1079
+ get keepalive(): boolean;
1080
+ }
1081
+ export interface RequestInit<Cf = CfProperties> {
1082
+ /** A string to set request's method. */
1083
+ method?: string;
1084
+ /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1085
+ headers?: HeadersInit;
1086
+ /** A BodyInit object or null to set request's body. */
1087
+ body?: BodyInit | null;
1088
+ /** 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. */
1089
+ redirect?: string;
1090
+ fetcher?: Fetcher | null;
1091
+ cf?: Cf;
1092
+ /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1093
+ integrity?: string;
1094
+ /** An AbortSignal to set request's signal. */
1095
+ signal?: AbortSignal | null;
1096
+ }
1097
+ export declare abstract class Fetcher {
1098
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1099
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1100
+ }
1101
+ export interface FetcherPutOptions {
1102
+ expiration?: number;
1103
+ expirationTtl?: number;
1104
+ }
1105
+ export interface KVNamespaceListKey<Metadata, Key extends string = string> {
1106
+ name: Key;
1107
+ expiration?: number;
1108
+ metadata?: Metadata;
1109
+ }
1110
+ export type KVNamespaceListResult<Metadata, Key extends string = string> =
1111
+ | {
1112
+ list_complete: false;
1113
+ keys: KVNamespaceListKey<Metadata, Key>[];
1114
+ cursor: string;
1115
+ cacheStatus: string | null;
1116
+ }
1117
+ | {
1118
+ list_complete: true;
1119
+ keys: KVNamespaceListKey<Metadata, Key>[];
1120
+ cacheStatus: string | null;
1121
+ };
1122
+ export interface KVNamespace<Key extends string = string> {
1123
+ get(
1124
+ key: Key,
1125
+ options?: Partial<KVNamespaceGetOptions<undefined>>
1126
+ ): Promise<string | null>;
1127
+ get(key: Key, type: "text"): Promise<string | null>;
1128
+ get<ExpectedValue = unknown>(
1129
+ key: Key,
1130
+ type: "json"
1131
+ ): Promise<ExpectedValue | null>;
1132
+ get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
1133
+ get(key: Key, type: "stream"): Promise<ReadableStream | null>;
1134
+ get(
1135
+ key: Key,
1136
+ options?: KVNamespaceGetOptions<"text">
1137
+ ): Promise<string | null>;
1138
+ get<ExpectedValue = unknown>(
1139
+ key: Key,
1140
+ options?: KVNamespaceGetOptions<"json">
1141
+ ): Promise<ExpectedValue | null>;
1142
+ get(
1143
+ key: Key,
1144
+ options?: KVNamespaceGetOptions<"arrayBuffer">
1145
+ ): Promise<ArrayBuffer | null>;
1146
+ get(
1147
+ key: Key,
1148
+ options?: KVNamespaceGetOptions<"stream">
1149
+ ): Promise<ReadableStream | null>;
1150
+ list<Metadata = unknown>(
1151
+ options?: KVNamespaceListOptions
1152
+ ): Promise<KVNamespaceListResult<Metadata, Key>>;
1153
+ put(
1154
+ key: Key,
1155
+ value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
1156
+ options?: KVNamespacePutOptions
1157
+ ): Promise<void>;
1158
+ getWithMetadata<Metadata = unknown>(
1159
+ key: Key,
1160
+ options?: Partial<KVNamespaceGetOptions<undefined>>
1161
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1162
+ getWithMetadata<Metadata = unknown>(
1163
+ key: Key,
1164
+ type: "text"
1165
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1166
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
1167
+ key: Key,
1168
+ type: "json"
1169
+ ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1170
+ getWithMetadata<Metadata = unknown>(
1171
+ key: Key,
1172
+ type: "arrayBuffer"
1173
+ ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1174
+ getWithMetadata<Metadata = unknown>(
1175
+ key: Key,
1176
+ type: "stream"
1177
+ ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1178
+ getWithMetadata<Metadata = unknown>(
1179
+ key: Key,
1180
+ options: KVNamespaceGetOptions<"text">
1181
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1182
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
1183
+ key: Key,
1184
+ options: KVNamespaceGetOptions<"json">
1185
+ ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1186
+ getWithMetadata<Metadata = unknown>(
1187
+ key: Key,
1188
+ options: KVNamespaceGetOptions<"arrayBuffer">
1189
+ ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1190
+ getWithMetadata<Metadata = unknown>(
1191
+ key: Key,
1192
+ options: KVNamespaceGetOptions<"stream">
1193
+ ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1194
+ delete(key: Key): Promise<void>;
1195
+ }
1196
+ export interface KVNamespaceListOptions {
1197
+ limit?: number;
1198
+ prefix?: string | null;
1199
+ cursor?: string | null;
1200
+ }
1201
+ export interface KVNamespaceGetOptions<Type> {
1202
+ type: Type;
1203
+ cacheTtl?: number;
1204
+ }
1205
+ export interface KVNamespacePutOptions {
1206
+ expiration?: number;
1207
+ expirationTtl?: number;
1208
+ metadata?: any | null;
1209
+ }
1210
+ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1211
+ value: Value | null;
1212
+ metadata: Metadata | null;
1213
+ cacheStatus: string | null;
1214
+ }
1215
+ export type QueueContentType = "text" | "bytes" | "json" | "v8";
1216
+ export interface Queue<Body = unknown> {
1217
+ send(message: Body, options?: QueueSendOptions): Promise<void>;
1218
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1219
+ }
1220
+ export interface QueueSendOptions {
1221
+ contentType?: QueueContentType;
1222
+ }
1223
+ export interface MessageSendRequest<Body = unknown> {
1224
+ body: Body;
1225
+ contentType?: QueueContentType;
1226
+ }
1227
+ export interface Message<Body = unknown> {
1228
+ readonly id: string;
1229
+ readonly timestamp: Date;
1230
+ readonly body: Body;
1231
+ retry(): void;
1232
+ ack(): void;
1233
+ }
1234
+ export interface QueueEvent<Body = unknown> extends ExtendableEvent {
1235
+ readonly messages: readonly Message<Body>[];
1236
+ readonly queue: string;
1237
+ retryAll(): void;
1238
+ ackAll(): void;
1239
+ }
1240
+ export interface MessageBatch<Body = unknown> {
1241
+ readonly messages: readonly Message<Body>[];
1242
+ readonly queue: string;
1243
+ retryAll(): void;
1244
+ ackAll(): void;
1245
+ }
1246
+ export interface R2Error extends Error {
1247
+ readonly name: string;
1248
+ readonly code: number;
1249
+ readonly message: string;
1250
+ readonly action: string;
1251
+ readonly stack: any;
1252
+ }
1253
+ export interface R2ListOptions {
1254
+ limit?: number;
1255
+ prefix?: string;
1256
+ cursor?: string;
1257
+ delimiter?: string;
1258
+ startAfter?: string;
1259
+ include?: ("httpMetadata" | "customMetadata")[];
1260
+ }
1261
+ export declare abstract class R2Bucket {
1262
+ head(key: string): Promise<R2Object | null>;
1263
+ get(
1264
+ key: string,
1265
+ options: R2GetOptions & {
1266
+ onlyIf: R2Conditional | Headers;
1267
+ }
1268
+ ): Promise<R2ObjectBody | R2Object | null>;
1269
+ get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1270
+ put(
1271
+ key: string,
1272
+ value:
1273
+ | ReadableStream
1274
+ | ArrayBuffer
1275
+ | ArrayBufferView
1276
+ | string
1277
+ | null
1278
+ | Blob,
1279
+ options?: R2PutOptions & {
1280
+ onlyIf: R2Conditional | Headers;
1281
+ }
1282
+ ): Promise<R2Object | null>;
1283
+ put(
1284
+ key: string,
1285
+ value:
1286
+ | ReadableStream
1287
+ | ArrayBuffer
1288
+ | ArrayBufferView
1289
+ | string
1290
+ | null
1291
+ | Blob,
1292
+ options?: R2PutOptions
1293
+ ): Promise<R2Object>;
1294
+ createMultipartUpload(
1295
+ key: string,
1296
+ options?: R2MultipartOptions
1297
+ ): Promise<R2MultipartUpload>;
1298
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1299
+ delete(keys: string | string[]): Promise<void>;
1300
+ list(options?: R2ListOptions): Promise<R2Objects>;
1301
+ }
1302
+ export interface R2MultipartUpload {
1303
+ readonly key: string;
1304
+ readonly uploadId: string;
1305
+ uploadPart(
1306
+ partNumber: number,
1307
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1308
+ ): Promise<R2UploadedPart>;
1309
+ abort(): Promise<void>;
1310
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1311
+ }
1312
+ export interface R2UploadedPart {
1313
+ partNumber: number;
1314
+ etag: string;
1315
+ }
1316
+ export declare abstract class R2Object {
1317
+ readonly key: string;
1318
+ readonly version: string;
1319
+ readonly size: number;
1320
+ readonly etag: string;
1321
+ readonly httpEtag: string;
1322
+ readonly checksums: R2Checksums;
1323
+ readonly uploaded: Date;
1324
+ readonly httpMetadata?: R2HTTPMetadata;
1325
+ readonly customMetadata?: Record<string, string>;
1326
+ readonly range?: R2Range;
1327
+ writeHttpMetadata(headers: Headers): void;
1328
+ }
1329
+ export interface R2ObjectBody extends R2Object {
1330
+ get body(): ReadableStream;
1331
+ get bodyUsed(): boolean;
1332
+ arrayBuffer(): Promise<ArrayBuffer>;
1333
+ text(): Promise<string>;
1334
+ json<T>(): Promise<T>;
1335
+ blob(): Promise<Blob>;
1336
+ }
1337
+ export type R2Range =
1338
+ | {
1339
+ offset: number;
1340
+ length?: number;
1341
+ }
1342
+ | {
1343
+ offset?: number;
1344
+ length: number;
1345
+ }
1346
+ | {
1347
+ suffix: number;
1348
+ };
1349
+ export interface R2Conditional {
1350
+ etagMatches?: string;
1351
+ etagDoesNotMatch?: string;
1352
+ uploadedBefore?: Date;
1353
+ uploadedAfter?: Date;
1354
+ secondsGranularity?: boolean;
1355
+ }
1356
+ export interface R2GetOptions {
1357
+ onlyIf?: R2Conditional | Headers;
1358
+ range?: R2Range | Headers;
1359
+ }
1360
+ export interface R2PutOptions {
1361
+ onlyIf?: R2Conditional | Headers;
1362
+ httpMetadata?: R2HTTPMetadata | Headers;
1363
+ customMetadata?: Record<string, string>;
1364
+ md5?: ArrayBuffer | string;
1365
+ sha1?: ArrayBuffer | string;
1366
+ sha256?: ArrayBuffer | string;
1367
+ sha384?: ArrayBuffer | string;
1368
+ sha512?: ArrayBuffer | string;
1369
+ }
1370
+ export interface R2MultipartOptions {
1371
+ httpMetadata?: R2HTTPMetadata | Headers;
1372
+ customMetadata?: Record<string, string>;
1373
+ }
1374
+ export interface R2Checksums {
1375
+ readonly md5?: ArrayBuffer;
1376
+ readonly sha1?: ArrayBuffer;
1377
+ readonly sha256?: ArrayBuffer;
1378
+ readonly sha384?: ArrayBuffer;
1379
+ readonly sha512?: ArrayBuffer;
1380
+ toJSON(): R2StringChecksums;
1381
+ }
1382
+ export interface R2StringChecksums {
1383
+ md5?: string;
1384
+ sha1?: string;
1385
+ sha256?: string;
1386
+ sha384?: string;
1387
+ sha512?: string;
1388
+ }
1389
+ export interface R2HTTPMetadata {
1390
+ contentType?: string;
1391
+ contentLanguage?: string;
1392
+ contentDisposition?: string;
1393
+ contentEncoding?: string;
1394
+ cacheControl?: string;
1395
+ cacheExpiry?: Date;
1396
+ }
1397
+ export type R2Objects = {
1398
+ objects: R2Object[];
1399
+ delimitedPrefixes: string[];
1400
+ } & (
1401
+ | {
1402
+ truncated: true;
1403
+ cursor: string;
1404
+ }
1405
+ | {
1406
+ truncated: false;
1407
+ }
1408
+ );
1409
+ export declare abstract class ScheduledEvent extends ExtendableEvent {
1410
+ readonly scheduledTime: number;
1411
+ readonly cron: string;
1412
+ noRetry(): void;
1413
+ }
1414
+ export interface ScheduledController {
1415
+ readonly scheduledTime: number;
1416
+ readonly cron: string;
1417
+ noRetry(): void;
1418
+ }
1419
+ export interface QueuingStrategy<T = any> {
1420
+ highWaterMark?: number | bigint;
1421
+ size?: (chunk: T) => number | bigint;
1422
+ }
1423
+ export interface UnderlyingSink<W = any> {
1424
+ type?: string;
1425
+ start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
1426
+ write?: (
1427
+ chunk: W,
1428
+ controller: WritableStreamDefaultController
1429
+ ) => void | Promise<void>;
1430
+ abort?: (reason: any) => void | Promise<void>;
1431
+ close?: () => void | Promise<void>;
1432
+ }
1433
+ export interface UnderlyingByteSource {
1434
+ type: "bytes";
1435
+ autoAllocateChunkSize?: number;
1436
+ start?: (controller: ReadableByteStreamController) => void | Promise<void>;
1437
+ pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
1438
+ cancel?: (reason: any) => void | Promise<void>;
1439
+ }
1440
+ export interface UnderlyingSource<R = any> {
1441
+ type?: "" | undefined;
1442
+ start?: (
1443
+ controller: ReadableStreamDefaultController<R>
1444
+ ) => void | Promise<void>;
1445
+ pull?: (
1446
+ controller: ReadableStreamDefaultController<R>
1447
+ ) => void | Promise<void>;
1448
+ cancel?: (reason: any) => void | Promise<void>;
1449
+ }
1450
+ export interface Transformer<I = any, O = any> {
1451
+ readableType?: string;
1452
+ writableType?: string;
1453
+ start?: (
1454
+ controller: TransformStreamDefaultController<O>
1455
+ ) => void | Promise<void>;
1456
+ transform?: (
1457
+ chunk: I,
1458
+ controller: TransformStreamDefaultController<O>
1459
+ ) => void | Promise<void>;
1460
+ flush?: (
1461
+ controller: TransformStreamDefaultController<O>
1462
+ ) => void | Promise<void>;
1463
+ }
1464
+ export interface StreamPipeOptions {
1465
+ /**
1466
+ * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
1467
+ *
1468
+ * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1469
+ *
1470
+ * Errors and closures of the source and destination streams propagate as follows:
1471
+ *
1472
+ * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.
1473
+ *
1474
+ * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.
1475
+ *
1476
+ * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.
1477
+ *
1478
+ * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.
1479
+ *
1480
+ * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
1481
+ */
1482
+ preventClose?: boolean;
1483
+ preventAbort?: boolean;
1484
+ preventCancel?: boolean;
1485
+ signal?: AbortSignal;
1486
+ }
1487
+ export type ReadableStreamReadResult<R = any> =
1488
+ | {
1489
+ done: false;
1490
+ value: R;
1491
+ }
1492
+ | {
1493
+ done: true;
1494
+ value?: undefined;
1495
+ };
1496
+ /** This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. */
1497
+ export interface ReadableStream<R = any> {
1498
+ get locked(): boolean;
1499
+ cancel(reason?: any): Promise<void>;
1500
+ getReader(): ReadableStreamDefaultReader<R>;
1501
+ getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
1502
+ pipeThrough<T>(
1503
+ transform: ReadableWritablePair<T, R>,
1504
+ options?: StreamPipeOptions
1505
+ ): ReadableStream<T>;
1506
+ pipeTo(
1507
+ destination: WritableStream<R>,
1508
+ options?: StreamPipeOptions
1509
+ ): Promise<void>;
1510
+ tee(): [ReadableStream<R>, ReadableStream<R>];
1511
+ values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
1512
+ [Symbol.asyncIterator](
1513
+ options?: ReadableStreamValuesOptions
1514
+ ): AsyncIterableIterator<R>;
1515
+ }
1516
+ export declare const ReadableStream: {
1517
+ prototype: ReadableStream;
1518
+ new (
1519
+ underlyingSource: UnderlyingByteSource,
1520
+ strategy?: QueuingStrategy<Uint8Array>
1521
+ ): ReadableStream<Uint8Array>;
1522
+ new <R = any>(
1523
+ underlyingSource?: UnderlyingSource<R>,
1524
+ strategy?: QueuingStrategy<R>
1525
+ ): ReadableStream<R>;
1526
+ };
1527
+ export declare class ReadableStreamDefaultReader<R = any> {
1528
+ constructor(stream: ReadableStream);
1529
+ get closed(): Promise<void>;
1530
+ cancel(reason?: any): Promise<void>;
1531
+ read(): Promise<ReadableStreamReadResult<R>>;
1532
+ releaseLock(): void;
1533
+ }
1534
+ export declare class ReadableStreamBYOBReader {
1535
+ constructor(stream: ReadableStream);
1536
+ get closed(): Promise<void>;
1537
+ cancel(reason?: any): Promise<void>;
1538
+ read<T extends ArrayBufferView>(
1539
+ view: T
1540
+ ): Promise<ReadableStreamReadResult<T>>;
1541
+ releaseLock(): void;
1542
+ readAtLeast<T extends ArrayBufferView>(
1543
+ minElements: number,
1544
+ view: T
1545
+ ): Promise<ReadableStreamReadResult<T>>;
1546
+ }
1547
+ export interface ReadableStreamGetReaderOptions {
1548
+ mode: "byob";
1549
+ }
1550
+ export declare abstract class ReadableStreamBYOBRequest {
1551
+ readonly view: Uint8Array | null;
1552
+ respond(bytesWritten: number): void;
1553
+ respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
1554
+ readonly atLeast: number | null;
1555
+ }
1556
+ export declare abstract class ReadableStreamDefaultController<R = any> {
1557
+ readonly desiredSize: number | null;
1558
+ close(): void;
1559
+ enqueue(chunk?: R): void;
1560
+ error(reason: any): void;
1561
+ }
1562
+ export declare abstract class ReadableByteStreamController {
1563
+ readonly byobRequest: ReadableStreamBYOBRequest | null;
1564
+ readonly desiredSize: number | null;
1565
+ close(): void;
1566
+ enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
1567
+ error(reason: any): void;
1568
+ }
1569
+ export declare abstract class WritableStreamDefaultController {
1570
+ readonly signal: AbortSignal;
1571
+ error(reason?: any): void;
1572
+ }
1573
+ export interface TransformStreamDefaultController<O = any> {
1574
+ get desiredSize(): number | null;
1575
+ enqueue(chunk?: O): void;
1576
+ error(reason: any): void;
1577
+ terminate(): void;
1578
+ }
1579
+ export interface ReadableWritablePair<R = any, W = any> {
1580
+ /**
1581
+ * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
1582
+ *
1583
+ * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1584
+ */
1585
+ writable: WritableStream<W>;
1586
+ readable: ReadableStream<R>;
1587
+ }
1588
+ export declare class WritableStream<W = any> {
1589
+ constructor(
1590
+ underlyingSink?: UnderlyingSink,
1591
+ queuingStrategy?: QueuingStrategy
1592
+ );
1593
+ get locked(): boolean;
1594
+ abort(reason?: any): Promise<void>;
1595
+ close(): Promise<void>;
1596
+ getWriter(): WritableStreamDefaultWriter<W>;
1597
+ }
1598
+ export declare class WritableStreamDefaultWriter<W = any> {
1599
+ constructor(stream: WritableStream);
1600
+ get closed(): Promise<void>;
1601
+ get ready(): Promise<void>;
1602
+ get desiredSize(): number | null;
1603
+ abort(reason?: any): Promise<void>;
1604
+ close(): Promise<void>;
1605
+ write(chunk?: W): Promise<void>;
1606
+ releaseLock(): void;
1607
+ }
1608
+ export declare class TransformStream<I = any, O = any> {
1609
+ constructor(
1610
+ transformer?: Transformer<I, O>,
1611
+ writableStrategy?: QueuingStrategy<I>,
1612
+ readableStrategy?: QueuingStrategy<O>
1613
+ );
1614
+ get readable(): ReadableStream<O>;
1615
+ get writable(): WritableStream<I>;
1616
+ }
1617
+ export declare class FixedLengthStream extends IdentityTransformStream {
1618
+ constructor(
1619
+ expectedLength: number | bigint,
1620
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy
1621
+ );
1622
+ }
1623
+ export declare class IdentityTransformStream extends TransformStream<
1624
+ ArrayBuffer | ArrayBufferView,
1625
+ Uint8Array
1626
+ > {
1627
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1628
+ }
1629
+ export interface IdentityTransformStreamQueuingStrategy {
1630
+ highWaterMark?: number | bigint;
1631
+ }
1632
+ export interface ReadableStreamValuesOptions {
1633
+ preventCancel?: boolean;
1634
+ }
1635
+ export declare class CompressionStream extends TransformStream<
1636
+ ArrayBuffer | ArrayBufferView,
1637
+ Uint8Array
1638
+ > {
1639
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1640
+ }
1641
+ export declare class DecompressionStream extends TransformStream<
1642
+ ArrayBuffer | ArrayBufferView,
1643
+ Uint8Array
1644
+ > {
1645
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
1646
+ }
1647
+ export declare class TextEncoderStream extends TransformStream<
1648
+ string,
1649
+ Uint8Array
1650
+ > {
1651
+ constructor();
1652
+ }
1653
+ export declare class TextDecoderStream extends TransformStream<
1654
+ ArrayBuffer | ArrayBufferView,
1655
+ string
1656
+ > {
1657
+ constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
1658
+ }
1659
+ export interface TextDecoderStreamTextDecoderStreamInit {
1660
+ fatal?: boolean;
1661
+ }
1662
+ export declare class ByteLengthQueuingStrategy
1663
+ implements QueuingStrategy<ArrayBufferView>
1664
+ {
1665
+ constructor(init: QueuingStrategyInit);
1666
+ get highWaterMark(): number;
1667
+ get size(): (chunk?: any) => number;
1668
+ }
1669
+ export declare class CountQueuingStrategy implements QueuingStrategy {
1670
+ constructor(init: QueuingStrategyInit);
1671
+ get highWaterMark(): number;
1672
+ get size(): (chunk?: any) => number;
1673
+ }
1674
+ export interface QueuingStrategyInit {
1675
+ /**
1676
+ * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
1677
+ *
1678
+ * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw.
1679
+ */
1680
+ highWaterMark: number;
1681
+ }
1682
+ export declare abstract class TailEvent extends ExtendableEvent {
1683
+ readonly events: TraceItem[];
1684
+ readonly traces: TraceItem[];
1685
+ }
1686
+ export interface TraceItem {
1687
+ readonly event:
1688
+ | (
1689
+ | TraceItemFetchEventInfo
1690
+ | TraceItemScheduledEventInfo
1691
+ | TraceItemAlarmEventInfo
1692
+ | TraceItemQueueEventInfo
1693
+ | TraceItemEmailEventInfo
1694
+ | TraceItemCustomEventInfo
1695
+ )
1696
+ | null;
1697
+ readonly eventTimestamp: number | null;
1698
+ readonly logs: TraceLog[];
1699
+ readonly exceptions: TraceException[];
1700
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1701
+ readonly scriptName: string | null;
1702
+ readonly dispatchNamespace?: string;
1703
+ readonly scriptTags?: string[];
1704
+ readonly outcome: string;
1705
+ }
1706
+ export interface TraceItemAlarmEventInfo {
1707
+ readonly scheduledTime: Date;
1708
+ }
1709
+ export interface TraceItemCustomEventInfo {}
1710
+ export interface TraceItemScheduledEventInfo {
1711
+ readonly scheduledTime: number;
1712
+ readonly cron: string;
1713
+ }
1714
+ export interface TraceItemQueueEventInfo {
1715
+ readonly queue: string;
1716
+ readonly batchSize: number;
1717
+ }
1718
+ export interface TraceItemEmailEventInfo {
1719
+ readonly mailFrom: string;
1720
+ readonly rcptTo: string;
1721
+ readonly rawSize: number;
1722
+ }
1723
+ export interface TraceItemFetchEventInfo {
1724
+ readonly response?: TraceItemFetchEventInfoResponse;
1725
+ readonly request: TraceItemFetchEventInfoRequest;
1726
+ }
1727
+ export interface TraceItemFetchEventInfoRequest {
1728
+ readonly cf?: any;
1729
+ readonly headers: Record<string, string>;
1730
+ readonly method: string;
1731
+ readonly url: string;
1732
+ getUnredacted(): TraceItemFetchEventInfoRequest;
1733
+ }
1734
+ export interface TraceItemFetchEventInfoResponse {
1735
+ readonly status: number;
1736
+ }
1737
+ export interface TraceLog {
1738
+ readonly timestamp: number;
1739
+ readonly level: string;
1740
+ readonly message: any;
1741
+ }
1742
+ export interface TraceException {
1743
+ readonly timestamp: number;
1744
+ readonly message: string;
1745
+ readonly name: string;
1746
+ }
1747
+ export interface TraceDiagnosticChannelEvent {
1748
+ readonly timestamp: number;
1749
+ readonly channel: string;
1750
+ readonly message: any;
1751
+ }
1752
+ export interface TraceMetrics {
1753
+ readonly cpuTime: number;
1754
+ readonly wallTime: number;
1755
+ }
1756
+ export interface UnsafeTraceMetrics {
1757
+ fromTrace(item: TraceItem): TraceMetrics;
1758
+ }
1759
+ export declare class URL {
1760
+ constructor(url: string | URL, base?: string | URL);
1761
+ get origin(): string;
1762
+ get href(): string;
1763
+ set href(value: string);
1764
+ get protocol(): string;
1765
+ set protocol(value: string);
1766
+ get username(): string;
1767
+ set username(value: string);
1768
+ get password(): string;
1769
+ set password(value: string);
1770
+ get host(): string;
1771
+ set host(value: string);
1772
+ get hostname(): string;
1773
+ set hostname(value: string);
1774
+ get port(): string;
1775
+ set port(value: string);
1776
+ get pathname(): string;
1777
+ set pathname(value: string);
1778
+ get search(): string;
1779
+ set search(value: string);
1780
+ get hash(): string;
1781
+ set hash(value: string);
1782
+ get searchParams(): URLSearchParams;
1783
+ toJSON(): string;
1784
+ toString(): string;
1785
+ static canParse(url: string, base?: string): boolean;
1786
+ }
1787
+ export declare class URLSearchParams {
1788
+ constructor(
1789
+ init?: Iterable<Iterable<string>> | Record<string, string> | string
1790
+ );
1791
+ get size(): number;
1792
+ append(name: string, value: string): void;
1793
+ delete(name: string): void;
1794
+ get(name: string): string | null;
1795
+ getAll(name: string): string[];
1796
+ has(name: string): boolean;
1797
+ set(name: string, value: string): void;
1798
+ sort(): void;
1799
+ entries(): IterableIterator<[key: string, value: string]>;
1800
+ keys(): IterableIterator<string>;
1801
+ values(): IterableIterator<string>;
1802
+ forEach<This = unknown>(
1803
+ callback: (
1804
+ this: This,
1805
+ value: string,
1806
+ key: string,
1807
+ parent: URLSearchParams
1808
+ ) => void,
1809
+ thisArg?: This
1810
+ ): void;
1811
+ toString(): string;
1812
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
1813
+ }
1814
+ export declare class URLPattern {
1815
+ constructor(input?: string | URLPatternURLPatternInit, baseURL?: string);
1816
+ get protocol(): string;
1817
+ get username(): string;
1818
+ get password(): string;
1819
+ get hostname(): string;
1820
+ get port(): string;
1821
+ get pathname(): string;
1822
+ get search(): string;
1823
+ get hash(): string;
1824
+ test(input?: string | URLPatternURLPatternInit, baseURL?: string): boolean;
1825
+ exec(
1826
+ input?: string | URLPatternURLPatternInit,
1827
+ baseURL?: string
1828
+ ): URLPatternURLPatternResult | null;
1829
+ }
1830
+ export interface URLPatternURLPatternInit {
1831
+ protocol?: string;
1832
+ username?: string;
1833
+ password?: string;
1834
+ hostname?: string;
1835
+ port?: string;
1836
+ pathname?: string;
1837
+ search?: string;
1838
+ hash?: string;
1839
+ baseURL?: string;
1840
+ }
1841
+ export interface URLPatternURLPatternComponentResult {
1842
+ input: string;
1843
+ groups: Record<string, string>;
1844
+ }
1845
+ export interface URLPatternURLPatternResult {
1846
+ inputs: (string | URLPatternURLPatternInit)[];
1847
+ protocol: URLPatternURLPatternComponentResult;
1848
+ username: URLPatternURLPatternComponentResult;
1849
+ password: URLPatternURLPatternComponentResult;
1850
+ hostname: URLPatternURLPatternComponentResult;
1851
+ port: URLPatternURLPatternComponentResult;
1852
+ pathname: URLPatternURLPatternComponentResult;
1853
+ search: URLPatternURLPatternComponentResult;
1854
+ hash: URLPatternURLPatternComponentResult;
1855
+ }
1856
+ export declare class CloseEvent extends Event {
1857
+ constructor(type: string, initializer: CloseEventInit);
1858
+ /** Returns the WebSocket connection close code provided by the server. */
1859
+ readonly code: number;
1860
+ /** Returns the WebSocket connection close reason provided by the server. */
1861
+ readonly reason: string;
1862
+ /** Returns true if the connection closed cleanly; false otherwise. */
1863
+ readonly wasClean: boolean;
1864
+ }
1865
+ export interface CloseEventInit {
1866
+ code?: number;
1867
+ reason?: string;
1868
+ wasClean?: boolean;
1869
+ }
1870
+ export declare class MessageEvent extends Event {
1871
+ constructor(type: string, initializer: MessageEventInit);
1872
+ readonly data: ArrayBuffer | string;
1873
+ }
1874
+ export interface MessageEventInit {
1875
+ data: ArrayBuffer | string;
1876
+ }
1877
+ /** Events providing information related to errors in scripts or in files. */
1878
+ export interface ErrorEvent extends Event {
1879
+ readonly filename: string;
1880
+ readonly message: string;
1881
+ readonly lineno: number;
1882
+ readonly colno: number;
1883
+ readonly error: any;
1884
+ }
1885
+ export type WebSocketEventMap = {
1886
+ close: CloseEvent;
1887
+ message: MessageEvent;
1888
+ open: Event;
1889
+ error: ErrorEvent;
1890
+ };
1891
+ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
1892
+ constructor(url: string, protocols?: string[] | string);
1893
+ accept(): void;
1894
+ send(message: (ArrayBuffer | ArrayBufferView) | string): void;
1895
+ close(code?: number, reason?: string): void;
1896
+ serializeAttachment(attachment: any): void;
1897
+ deserializeAttachment(): any | null;
1898
+ static readonly READY_STATE_CONNECTING: number;
1899
+ static readonly READY_STATE_OPEN: number;
1900
+ static readonly READY_STATE_CLOSING: number;
1901
+ static readonly READY_STATE_CLOSED: number;
1902
+ get readyState(): number;
1903
+ get url(): string | null;
1904
+ get protocol(): string | null;
1905
+ get extensions(): string | null;
1906
+ }
1907
+ export declare const WebSocketPair: {
1908
+ new (): {
1909
+ 0: WebSocket;
1910
+ 1: WebSocket;
1911
+ };
1912
+ };
1913
+ export interface Socket {
1914
+ get readable(): ReadableStream;
1915
+ get writable(): WritableStream;
1916
+ get closed(): Promise<void>;
1917
+ close(): Promise<void>;
1918
+ startTls(options?: TlsOptions): Socket;
1919
+ }
1920
+ export interface SocketOptions {
1921
+ secureTransport?: string;
1922
+ allowHalfOpen: boolean;
1923
+ }
1924
+ export interface SocketAddress {
1925
+ hostname: string;
1926
+ port: number;
1927
+ }
1928
+ export interface TlsOptions {
1929
+ expectedServerHostname?: string;
1930
+ }
1931
+ export interface BasicImageTransformations {
1932
+ /**
1933
+ * Maximum width in image pixels. The value must be an integer.
1934
+ */
1935
+ width?: number;
1936
+ /**
1937
+ * Maximum height in image pixels. The value must be an integer.
1938
+ */
1939
+ height?: number;
1940
+ /**
1941
+ * Resizing mode as a string. It affects interpretation of width and height
1942
+ * options:
1943
+ * - scale-down: Similar to contain, but the image is never enlarged. If
1944
+ * the image is larger than given width or height, it will be resized.
1945
+ * Otherwise its original size will be kept.
1946
+ * - contain: Resizes to maximum size that fits within the given width and
1947
+ * height. If only a single dimension is given (e.g. only width), the
1948
+ * image will be shrunk or enlarged to exactly match that dimension.
1949
+ * Aspect ratio is always preserved.
1950
+ * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
1951
+ * and height. If the image has an aspect ratio different from the ratio
1952
+ * of width and height, it will be cropped to fit.
1953
+ * - crop: The image will be shrunk and cropped to fit within the area
1954
+ * specified by width and height. The image will not be enlarged. For images
1955
+ * smaller than the given dimensions it's the same as scale-down. For
1956
+ * images larger than the given dimensions, it's the same as cover.
1957
+ * See also trim.
1958
+ * - pad: Resizes to the maximum size that fits within the given width and
1959
+ * height, and then fills the remaining area with a background color
1960
+ * (white by default). Use of this mode is not recommended, as the same
1961
+ * effect can be more efficiently achieved with the contain mode and the
1962
+ * CSS object-fit: contain property.
1963
+ */
1964
+ fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
1965
+ /**
1966
+ * When cropping with fit: "cover", this defines the side or point that should
1967
+ * be left uncropped. The value is either a string
1968
+ * "left", "right", "top", "bottom", "auto", or "center" (the default),
1969
+ * or an object {x, y} containing focal point coordinates in the original
1970
+ * image expressed as fractions ranging from 0.0 (top or left) to 1.0
1971
+ * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
1972
+ * crop bottom or left and right sides as necessary, but won’t crop anything
1973
+ * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
1974
+ * preserve as much as possible around a point at 20% of the height of the
1975
+ * source image.
1976
+ */
1977
+ gravity?:
1978
+ | "left"
1979
+ | "right"
1980
+ | "top"
1981
+ | "bottom"
1982
+ | "center"
1983
+ | "auto"
1984
+ | BasicImageTransformationsGravityCoordinates;
1985
+ /**
1986
+ * Background color to add underneath the image. Applies only to images with
1987
+ * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
1988
+ * hsl(…), etc.)
1989
+ */
1990
+ background?: string;
1991
+ /**
1992
+ * Number of degrees (90, 180, 270) to rotate the image by. width and height
1993
+ * options refer to axes after rotation.
1994
+ */
1995
+ rotate?: 0 | 90 | 180 | 270 | 360;
1996
+ }
1997
+ export interface BasicImageTransformationsGravityCoordinates {
1998
+ x: number;
1999
+ y: number;
2000
+ }
2001
+ /**
2002
+ * In addition to the properties you can set in the RequestInit dict
2003
+ * that you pass as an argument to the Request constructor, you can
2004
+ * set certain properties of a `cf` object to control how Cloudflare
2005
+ * features are applied to that new Request.
2006
+ *
2007
+ * Note: Currently, these properties cannot be tested in the
2008
+ * playground.
2009
+ */
2010
+ export interface RequestInitCfProperties extends Record<string, unknown> {
2011
+ cacheEverything?: boolean;
2012
+ /**
2013
+ * A request's cache key is what determines if two requests are
2014
+ * "the same" for caching purposes. If a request has the same cache key
2015
+ * as some previous request, then we can serve the same cached response for
2016
+ * both. (e.g. 'some-key')
2017
+ *
2018
+ * Only available for Enterprise customers.
2019
+ */
2020
+ cacheKey?: string;
2021
+ /**
2022
+ * This allows you to append additional Cache-Tag response headers
2023
+ * to the origin response without modifications to the origin server.
2024
+ * This will allow for greater control over the Purge by Cache Tag feature
2025
+ * utilizing changes only in the Workers process.
2026
+ *
2027
+ * Only available for Enterprise customers.
2028
+ */
2029
+ cacheTags?: string[];
2030
+ /**
2031
+ * Force response to be cached for a given number of seconds. (e.g. 300)
2032
+ */
2033
+ cacheTtl?: number;
2034
+ /**
2035
+ * Force response to be cached for a given number of seconds based on the Origin status code.
2036
+ * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
2037
+ */
2038
+ cacheTtlByStatus?: Record<string, number>;
2039
+ scrapeShield?: boolean;
2040
+ apps?: boolean;
2041
+ image?: RequestInitCfPropertiesImage;
2042
+ minify?: RequestInitCfPropertiesImageMinify;
2043
+ mirage?: boolean;
2044
+ polish?: "lossy" | "lossless" | "off";
2045
+ /**
2046
+ * Redirects the request to an alternate origin server. You can use this,
2047
+ * for example, to implement load balancing across several origins.
2048
+ * (e.g.us-east.example.com)
2049
+ *
2050
+ * Note - For security reasons, the hostname set in resolveOverride must
2051
+ * be proxied on the same Cloudflare zone of the incoming request.
2052
+ * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
2053
+ * resolve to a host under a different domain or a DNS only domain first
2054
+ * declare a CNAME record within your own zone’s DNS mapping to the
2055
+ * external hostname, set proxy on Cloudflare, then set resolveOverride
2056
+ * to point to that CNAME record.
2057
+ */
2058
+ resolveOverride?: string;
2059
+ }
2060
+ export interface RequestInitCfPropertiesImageDraw
2061
+ extends BasicImageTransformations {
2062
+ /**
2063
+ * Absolute URL of the image file to use for the drawing. It can be any of
2064
+ * the supported file formats. For drawing of watermarks or non-rectangular
2065
+ * overlays we recommend using PNG or WebP images.
2066
+ */
2067
+ url: string;
2068
+ /**
2069
+ * Floating-point number between 0 (transparent) and 1 (opaque).
2070
+ * For example, opacity: 0.5 makes overlay semitransparent.
2071
+ */
2072
+ opacity?: number;
2073
+ /**
2074
+ * - If set to true, the overlay image will be tiled to cover the entire
2075
+ * area. This is useful for stock-photo-like watermarks.
2076
+ * - If set to "x", the overlay image will be tiled horizontally only
2077
+ * (form a line).
2078
+ * - If set to "y", the overlay image will be tiled vertically only
2079
+ * (form a line).
2080
+ */
2081
+ repeat?: true | "x" | "y";
2082
+ /**
2083
+ * Position of the overlay image relative to a given edge. Each property is
2084
+ * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
2085
+ * positions left side of the overlay 10 pixels from the left edge of the
2086
+ * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
2087
+ * of the background image.
2088
+ *
2089
+ * Setting both left & right, or both top & bottom is an error.
2090
+ *
2091
+ * If no position is specified, the image will be centered.
2092
+ */
2093
+ top?: number;
2094
+ left?: number;
2095
+ bottom?: number;
2096
+ right?: number;
2097
+ }
2098
+ export interface RequestInitCfPropertiesImage
2099
+ extends BasicImageTransformations {
2100
+ /**
2101
+ * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
2102
+ * easier to specify higher-DPI sizes in <img srcset>.
2103
+ */
2104
+ dpr?: number;
2105
+ /**
2106
+ * An object with four properties {left, top, right, bottom} that specify
2107
+ * a number of pixels to cut off on each side. Allows removal of borders
2108
+ * or cutting out a specific fragment of an image. Trimming is performed
2109
+ * before resizing or rotation. Takes dpr into account.
2110
+ */
2111
+ trim?: {
2112
+ left?: number;
2113
+ top?: number;
2114
+ right?: number;
2115
+ bottom?: number;
2116
+ };
2117
+ /**
2118
+ * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
2119
+ * make images look worse, but load faster. The default is 85. It applies only
2120
+ * to JPEG and WebP images. It doesn’t have any effect on PNG.
2121
+ */
2122
+ quality?: number;
2123
+ /**
2124
+ * Output format to generate. It can be:
2125
+ * - avif: generate images in AVIF format.
2126
+ * - webp: generate images in Google WebP format. Set quality to 100 to get
2127
+ * the WebP-lossless format.
2128
+ * - json: instead of generating an image, outputs information about the
2129
+ * image, in JSON format. The JSON object will contain image size
2130
+ * (before and after resizing), source image’s MIME type, file size, etc.
2131
+ * - jpeg: generate images in JPEG format.
2132
+ * - png: generate images in PNG format.
2133
+ */
2134
+ format?: "avif" | "webp" | "json" | "jpeg" | "png";
2135
+ /**
2136
+ * Whether to preserve animation frames from input files. Default is true.
2137
+ * Setting it to false reduces animations to still images. This setting is
2138
+ * recommended when enlarging images or processing arbitrary user content,
2139
+ * because large GIF animations can weigh tens or even hundreds of megabytes.
2140
+ * It is also useful to set anim:false when using format:"json" to get the
2141
+ * response quicker without the number of frames.
2142
+ */
2143
+ anim?: boolean;
2144
+ /**
2145
+ * What EXIF data should be preserved in the output image. Note that EXIF
2146
+ * rotation and embedded color profiles are always applied ("baked in" into
2147
+ * the image), and aren't affected by this option. Note that if the Polish
2148
+ * feature is enabled, all metadata may have been removed already and this
2149
+ * option may have no effect.
2150
+ * - keep: Preserve most of EXIF metadata, including GPS location if there's
2151
+ * any.
2152
+ * - copyright: Only keep the copyright tag, and discard everything else.
2153
+ * This is the default behavior for JPEG files.
2154
+ * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
2155
+ * output formats always discard metadata.
2156
+ */
2157
+ metadata?: "keep" | "copyright" | "none";
2158
+ /**
2159
+ * Strength of sharpening filter to apply to the image. Floating-point
2160
+ * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
2161
+ * recommended value for downscaled images.
2162
+ */
2163
+ sharpen?: number;
2164
+ /**
2165
+ * Radius of a blur filter (approximate gaussian). Maximum supported radius
2166
+ * is 250.
2167
+ */
2168
+ blur?: number;
2169
+ /**
2170
+ * Overlays are drawn in the order they appear in the array (last array
2171
+ * entry is the topmost layer).
2172
+ */
2173
+ draw?: RequestInitCfPropertiesImageDraw[];
2174
+ /**
2175
+ * Fetching image from authenticated origin. Setting this property will
2176
+ * pass authentication headers (Authorization, Cookie, etc.) through to
2177
+ * the origin.
2178
+ */
2179
+ "origin-auth"?: "share-publicly";
2180
+ /**
2181
+ * Adds a border around the image. The border is added after resizing. Border
2182
+ * width takes dpr into account, and can be specified either using a single
2183
+ * width property, or individually for each side.
2184
+ */
2185
+ border?:
2186
+ | {
2187
+ color: string;
2188
+ width: number;
2189
+ }
2190
+ | {
2191
+ color: string;
2192
+ top: number;
2193
+ right: number;
2194
+ bottom: number;
2195
+ left: number;
2196
+ };
2197
+ /**
2198
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
2199
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
2200
+ * 0 is ignored.
2201
+ */
2202
+ brightness?: number;
2203
+ /**
2204
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
2205
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
2206
+ * ignored.
2207
+ */
2208
+ contrast?: number;
2209
+ /**
2210
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
2211
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
2212
+ */
2213
+ gamma?: number;
2214
+ /**
2215
+ * Slightly reduces latency on a cache miss by selecting a
2216
+ * quickest-to-compress file format, at a cost of increased file size and
2217
+ * lower image quality. It will usually override the format option and choose
2218
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
2219
+ * unusual circumstances like resizing uncacheable dynamically-generated
2220
+ * images.
2221
+ */
2222
+ compression?: "fast";
2223
+ }
2224
+ export interface RequestInitCfPropertiesImageMinify {
2225
+ javascript?: boolean;
2226
+ css?: boolean;
2227
+ html?: boolean;
2228
+ }
2229
+ /**
2230
+ * Request metadata provided by Cloudflare's edge.
2231
+ */
2232
+ export type IncomingRequestCfProperties<HostMetadata = unknown> =
2233
+ IncomingRequestCfPropertiesBase &
2234
+ IncomingRequestCfPropertiesBotManagementEnterprise &
2235
+ IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
2236
+ IncomingRequestCfPropertiesGeographicInformation &
2237
+ IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
2238
+ export interface IncomingRequestCfPropertiesBase
2239
+ extends Record<string, unknown> {
2240
+ /**
2241
+ * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
2242
+ *
2243
+ * @example 395747
2244
+ */
2245
+ asn: number;
2246
+ /**
2247
+ * The organization which owns the ASN of the incoming request.
2248
+ *
2249
+ * @example "Google Cloud"
2250
+ */
2251
+ asOrganization: string;
2252
+ /**
2253
+ * The original value of the `Accept-Encoding` header if Cloudflare modified it.
2254
+ *
2255
+ * @example "gzip, deflate, br"
2256
+ */
2257
+ clientAcceptEncoding?: string;
2258
+ /**
2259
+ * The number of milliseconds it took for the request to reach your worker.
2260
+ *
2261
+ * @example 22
2262
+ */
2263
+ clientTcpRtt?: number;
2264
+ /**
2265
+ * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
2266
+ * airport code of the data center that the request hit.
2267
+ *
2268
+ * @example "DFW"
2269
+ */
2270
+ colo: string;
2271
+ /**
2272
+ * Represents the upstream's response to a
2273
+ * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
2274
+ * from cloudflare.
2275
+ *
2276
+ * For workers with no upstream, this will always be `1`.
2277
+ *
2278
+ * @example 3
2279
+ */
2280
+ edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
2281
+ /**
2282
+ * The HTTP Protocol the request used.
2283
+ *
2284
+ * @example "HTTP/2"
2285
+ */
2286
+ httpProtocol: string;
2287
+ /**
2288
+ * The browser-requested prioritization information in the request object.
2289
+ *
2290
+ * If no information was set, defaults to the empty string `""`
2291
+ *
2292
+ * @example "weight=192;exclusive=0;group=3;group-weight=127"
2293
+ * @default ""
2294
+ */
2295
+ requestPriority: string;
2296
+ /**
2297
+ * The TLS version of the connection to Cloudflare.
2298
+ * In requests served over plaintext (without TLS), this property is the empty string `""`.
2299
+ *
2300
+ * @example "TLSv1.3"
2301
+ */
2302
+ tlsVersion: string;
2303
+ /**
2304
+ * The cipher for the connection to Cloudflare.
2305
+ * In requests served over plaintext (without TLS), this property is the empty string `""`.
2306
+ *
2307
+ * @example "AEAD-AES128-GCM-SHA256"
2308
+ */
2309
+ tlsCipher: string;
2310
+ /**
2311
+ * Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake.
2312
+ *
2313
+ * If the incoming request was served over plaintext (without TLS) this field is undefined.
2314
+ */
2315
+ tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
2316
+ }
2317
+ export interface IncomingRequestCfPropertiesBotManagementBase {
2318
+ /**
2319
+ * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2320
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
2321
+ *
2322
+ * @example 54
2323
+ */
2324
+ score: number;
2325
+ /**
2326
+ * A boolean value that is true if the request comes from a good bot, like Google or Bing.
2327
+ * Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots).
2328
+ */
2329
+ verifiedBot: boolean;
2330
+ /**
2331
+ * A boolean value that is true if the request originates from a
2332
+ * Cloudflare-verified proxy service.
2333
+ */
2334
+ corporateProxy: boolean;
2335
+ /**
2336
+ * A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources.
2337
+ */
2338
+ staticResource: boolean;
2339
+ /**
2340
+ * List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request).
2341
+ */
2342
+ detectionIds: number[];
2343
+ }
2344
+ export interface IncomingRequestCfPropertiesBotManagement {
2345
+ /**
2346
+ * Results of Cloudflare's Bot Management analysis
2347
+ */
2348
+ botManagement: IncomingRequestCfPropertiesBotManagementBase;
2349
+ /**
2350
+ * Duplicate of `botManagement.score`.
2351
+ *
2352
+ * @deprecated
2353
+ */
2354
+ clientTrustScore: number;
2355
+ }
2356
+ export interface IncomingRequestCfPropertiesBotManagementEnterprise
2357
+ extends IncomingRequestCfPropertiesBotManagement {
2358
+ /**
2359
+ * Results of Cloudflare's Bot Management analysis
2360
+ */
2361
+ botManagement: IncomingRequestCfPropertiesBotManagementBase & {
2362
+ /**
2363
+ * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
2364
+ * across different destination IPs, Ports, and X509 certificates.
2365
+ */
2366
+ ja3Hash: string;
2367
+ };
2368
+ }
2369
+ export interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<
2370
+ HostMetadata
2371
+ > {
2372
+ /**
2373
+ * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
2374
+ *
2375
+ * This field is only present if you have Cloudflare for SaaS enabled on your account
2376
+ * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
2377
+ */
2378
+ hostMetadata: HostMetadata;
2379
+ }
2380
+ export interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
2381
+ /**
2382
+ * Information about the client certificate presented to Cloudflare.
2383
+ *
2384
+ * This is populated when the incoming request is served over TLS using
2385
+ * either Cloudflare Access or API Shield (mTLS)
2386
+ * and the presented SSL certificate has a valid
2387
+ * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
2388
+ * (i.e., not `null` or `""`).
2389
+ *
2390
+ * Otherwise, a set of placeholder values are used.
2391
+ *
2392
+ * The property `certPresented` will be set to `"1"` when
2393
+ * the object is populated (i.e. the above conditions were met).
2394
+ */
2395
+ tlsClientAuth:
2396
+ | IncomingRequestCfPropertiesTLSClientAuth
2397
+ | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
2398
+ }
2399
+ /**
2400
+ * Metadata about the request's TLS handshake
2401
+ */
2402
+ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2403
+ /**
2404
+ * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
2405
+ *
2406
+ * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
2407
+ */
2408
+ clientHandshake: string;
2409
+ /**
2410
+ * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
2411
+ *
2412
+ * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
2413
+ */
2414
+ serverHandshake: string;
2415
+ /**
2416
+ * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
2417
+ *
2418
+ * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
2419
+ */
2420
+ clientFinished: string;
2421
+ /**
2422
+ * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
2423
+ *
2424
+ * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
2425
+ */
2426
+ serverFinished: string;
2427
+ }
2428
+ /**
2429
+ * Geographic data about the request's origin.
2430
+ */
2431
+ export interface IncomingRequestCfPropertiesGeographicInformation {
2432
+ /**
2433
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2434
+ *
2435
+ * 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.
2436
+ *
2437
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2438
+ *
2439
+ * The country code `"T1"` is used for requests originating on TOR.
2440
+ *
2441
+ * @example "GB"
2442
+ */
2443
+ country?: Iso3166Alpha2Code | "T1";
2444
+ /**
2445
+ * If present, this property indicates that the request originated in the EU
2446
+ *
2447
+ * @example "1"
2448
+ */
2449
+ isEUCountry?: "1";
2450
+ /**
2451
+ * A two-letter code indicating the continent the request originated from.
2452
+ *
2453
+ * @example "AN"
2454
+ */
2455
+ continent?: ContinentCode;
2456
+ /**
2457
+ * The city the request originated from
2458
+ *
2459
+ * @example "Austin"
2460
+ */
2461
+ city?: string;
2462
+ /**
2463
+ * Postal code of the incoming request
2464
+ *
2465
+ * @example "78701"
2466
+ */
2467
+ postalCode?: string;
2468
+ /**
2469
+ * Latitude of the incoming request
2470
+ *
2471
+ * @example "30.27130"
2472
+ */
2473
+ latitude?: string;
2474
+ /**
2475
+ * Longitude of the incoming request
2476
+ *
2477
+ * @example "-97.74260"
2478
+ */
2479
+ longitude?: string;
2480
+ /**
2481
+ * Timezone of the incoming request
2482
+ *
2483
+ * @example "America/Chicago"
2484
+ */
2485
+ timezone?: string;
2486
+ /**
2487
+ * If known, the ISO 3166-2 name for the first level region associated with
2488
+ * the IP address of the incoming request
2489
+ *
2490
+ * @example "Texas"
2491
+ */
2492
+ region?: string;
2493
+ /**
2494
+ * If known, the ISO 3166-2 code for the first-level region associated with
2495
+ * the IP address of the incoming request
2496
+ *
2497
+ * @example "TX"
2498
+ */
2499
+ regionCode?: string;
2500
+ /**
2501
+ * Metro code (DMA) of the incoming request
2502
+ *
2503
+ * @example "635"
2504
+ */
2505
+ metroCode?: string;
2506
+ }
2507
+ /** Data about the incoming request's TLS certificate */
2508
+ export interface IncomingRequestCfPropertiesTLSClientAuth {
2509
+ /** Always `"1"`, indicating that the certificate was presented */
2510
+ certPresented: "1";
2511
+ /**
2512
+ * Result of certificate verification.
2513
+ *
2514
+ * @example "FAILED:self signed certificate"
2515
+ */
2516
+ certVerified: Exclude<CertVerificationStatus, "NONE">;
2517
+ /** The presented certificate's revokation status.
2518
+ *
2519
+ * - A value of `"1"` indicates the certificate has been revoked
2520
+ * - A value of `"0"` indicates the certificate has not been revoked
2521
+ */
2522
+ certRevoked: "1" | "0";
2523
+ /**
2524
+ * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
2525
+ *
2526
+ * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2527
+ */
2528
+ certIssuerDN: string;
2529
+ /**
2530
+ * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
2531
+ *
2532
+ * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2533
+ */
2534
+ certSubjectDN: string;
2535
+ /**
2536
+ * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
2537
+ *
2538
+ * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2539
+ */
2540
+ certIssuerDNRFC2253: string;
2541
+ /**
2542
+ * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
2543
+ *
2544
+ * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2545
+ */
2546
+ certSubjectDNRFC2253: string;
2547
+ /** The certificate issuer's distinguished name (legacy policies) */
2548
+ certIssuerDNLegacy: string;
2549
+ /** The certificate subject's distinguished name (legacy policies) */
2550
+ certSubjectDNLegacy: string;
2551
+ /**
2552
+ * The certificate's serial number
2553
+ *
2554
+ * @example "00936EACBE07F201DF"
2555
+ */
2556
+ certSerial: string;
2557
+ /**
2558
+ * The certificate issuer's serial number
2559
+ *
2560
+ * @example "2489002934BDFEA34"
2561
+ */
2562
+ certIssuerSerial: string;
2563
+ /**
2564
+ * The certificate's Subject Key Identifier
2565
+ *
2566
+ * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
2567
+ */
2568
+ certSKI: string;
2569
+ /**
2570
+ * The certificate issuer's Subject Key Identifier
2571
+ *
2572
+ * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
2573
+ */
2574
+ certIssuerSKI: string;
2575
+ /**
2576
+ * The certificate's SHA-1 fingerprint
2577
+ *
2578
+ * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
2579
+ */
2580
+ certFingerprintSHA1: string;
2581
+ /**
2582
+ * The certificate's SHA-256 fingerprint
2583
+ *
2584
+ * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
2585
+ */
2586
+ certFingerprintSHA256: string;
2587
+ /**
2588
+ * The effective starting date of the certificate
2589
+ *
2590
+ * @example "Dec 22 19:39:00 2018 GMT"
2591
+ */
2592
+ certNotBefore: string;
2593
+ /**
2594
+ * The effective expiration date of the certificate
2595
+ *
2596
+ * @example "Dec 22 19:39:00 2018 GMT"
2597
+ */
2598
+ certNotAfter: string;
2599
+ }
2600
+ /** Placeholder values for TLS Client Authorization */
2601
+ export interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
2602
+ certPresented: "0";
2603
+ certVerified: "NONE";
2604
+ certRevoked: "0";
2605
+ certIssuerDN: "";
2606
+ certSubjectDN: "";
2607
+ certIssuerDNRFC2253: "";
2608
+ certSubjectDNRFC2253: "";
2609
+ certIssuerDNLegacy: "";
2610
+ certSubjectDNLegacy: "";
2611
+ certSerial: "";
2612
+ certIssuerSerial: "";
2613
+ certSKI: "";
2614
+ certIssuerSKI: "";
2615
+ certFingerprintSHA1: "";
2616
+ certFingerprintSHA256: "";
2617
+ certNotBefore: "";
2618
+ certNotAfter: "";
2619
+ }
2620
+ /** Possible outcomes of TLS verification */
2621
+ export type CertVerificationStatus =
2622
+ /** Authentication succeeded */
2623
+ | "SUCCESS"
2624
+ /** No certificate was presented */
2625
+ | "NONE"
2626
+ /** Failed because the certificate was self-signed */
2627
+ | "FAILED:self signed certificate"
2628
+ /** Failed because the certificate failed a trust chain check */
2629
+ | "FAILED:unable to verify the first certificate"
2630
+ /** Failed because the certificate not yet valid */
2631
+ | "FAILED:certificate is not yet valid"
2632
+ /** Failed because the certificate is expired */
2633
+ | "FAILED:certificate has expired"
2634
+ /** Failed for another unspecified reason */
2635
+ | "FAILED";
2636
+ /**
2637
+ * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
2638
+ */
2639
+ export type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus =
2640
+ | 0 /** Unknown */
2641
+ | 1 /** no keepalives (not found) */
2642
+ | 2 /** no connection re-use, opening keepalive connection failed */
2643
+ | 3 /** no connection re-use, keepalive accepted and saved */
2644
+ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */
2645
+ | 5; /** connection re-use, accepted by the origin server */
2646
+ /** ISO 3166-1 Alpha-2 codes */
2647
+ export type Iso3166Alpha2Code =
2648
+ | "AD"
2649
+ | "AE"
2650
+ | "AF"
2651
+ | "AG"
2652
+ | "AI"
2653
+ | "AL"
2654
+ | "AM"
2655
+ | "AO"
2656
+ | "AQ"
2657
+ | "AR"
2658
+ | "AS"
2659
+ | "AT"
2660
+ | "AU"
2661
+ | "AW"
2662
+ | "AX"
2663
+ | "AZ"
2664
+ | "BA"
2665
+ | "BB"
2666
+ | "BD"
2667
+ | "BE"
2668
+ | "BF"
2669
+ | "BG"
2670
+ | "BH"
2671
+ | "BI"
2672
+ | "BJ"
2673
+ | "BL"
2674
+ | "BM"
2675
+ | "BN"
2676
+ | "BO"
2677
+ | "BQ"
2678
+ | "BR"
2679
+ | "BS"
2680
+ | "BT"
2681
+ | "BV"
2682
+ | "BW"
2683
+ | "BY"
2684
+ | "BZ"
2685
+ | "CA"
2686
+ | "CC"
2687
+ | "CD"
2688
+ | "CF"
2689
+ | "CG"
2690
+ | "CH"
2691
+ | "CI"
2692
+ | "CK"
2693
+ | "CL"
2694
+ | "CM"
2695
+ | "CN"
2696
+ | "CO"
2697
+ | "CR"
2698
+ | "CU"
2699
+ | "CV"
2700
+ | "CW"
2701
+ | "CX"
2702
+ | "CY"
2703
+ | "CZ"
2704
+ | "DE"
2705
+ | "DJ"
2706
+ | "DK"
2707
+ | "DM"
2708
+ | "DO"
2709
+ | "DZ"
2710
+ | "EC"
2711
+ | "EE"
2712
+ | "EG"
2713
+ | "EH"
2714
+ | "ER"
2715
+ | "ES"
2716
+ | "ET"
2717
+ | "FI"
2718
+ | "FJ"
2719
+ | "FK"
2720
+ | "FM"
2721
+ | "FO"
2722
+ | "FR"
2723
+ | "GA"
2724
+ | "GB"
2725
+ | "GD"
2726
+ | "GE"
2727
+ | "GF"
2728
+ | "GG"
2729
+ | "GH"
2730
+ | "GI"
2731
+ | "GL"
2732
+ | "GM"
2733
+ | "GN"
2734
+ | "GP"
2735
+ | "GQ"
2736
+ | "GR"
2737
+ | "GS"
2738
+ | "GT"
2739
+ | "GU"
2740
+ | "GW"
2741
+ | "GY"
2742
+ | "HK"
2743
+ | "HM"
2744
+ | "HN"
2745
+ | "HR"
2746
+ | "HT"
2747
+ | "HU"
2748
+ | "ID"
2749
+ | "IE"
2750
+ | "IL"
2751
+ | "IM"
2752
+ | "IN"
2753
+ | "IO"
2754
+ | "IQ"
2755
+ | "IR"
2756
+ | "IS"
2757
+ | "IT"
2758
+ | "JE"
2759
+ | "JM"
2760
+ | "JO"
2761
+ | "JP"
2762
+ | "KE"
2763
+ | "KG"
2764
+ | "KH"
2765
+ | "KI"
2766
+ | "KM"
2767
+ | "KN"
2768
+ | "KP"
2769
+ | "KR"
2770
+ | "KW"
2771
+ | "KY"
2772
+ | "KZ"
2773
+ | "LA"
2774
+ | "LB"
2775
+ | "LC"
2776
+ | "LI"
2777
+ | "LK"
2778
+ | "LR"
2779
+ | "LS"
2780
+ | "LT"
2781
+ | "LU"
2782
+ | "LV"
2783
+ | "LY"
2784
+ | "MA"
2785
+ | "MC"
2786
+ | "MD"
2787
+ | "ME"
2788
+ | "MF"
2789
+ | "MG"
2790
+ | "MH"
2791
+ | "MK"
2792
+ | "ML"
2793
+ | "MM"
2794
+ | "MN"
2795
+ | "MO"
2796
+ | "MP"
2797
+ | "MQ"
2798
+ | "MR"
2799
+ | "MS"
2800
+ | "MT"
2801
+ | "MU"
2802
+ | "MV"
2803
+ | "MW"
2804
+ | "MX"
2805
+ | "MY"
2806
+ | "MZ"
2807
+ | "NA"
2808
+ | "NC"
2809
+ | "NE"
2810
+ | "NF"
2811
+ | "NG"
2812
+ | "NI"
2813
+ | "NL"
2814
+ | "NO"
2815
+ | "NP"
2816
+ | "NR"
2817
+ | "NU"
2818
+ | "NZ"
2819
+ | "OM"
2820
+ | "PA"
2821
+ | "PE"
2822
+ | "PF"
2823
+ | "PG"
2824
+ | "PH"
2825
+ | "PK"
2826
+ | "PL"
2827
+ | "PM"
2828
+ | "PN"
2829
+ | "PR"
2830
+ | "PS"
2831
+ | "PT"
2832
+ | "PW"
2833
+ | "PY"
2834
+ | "QA"
2835
+ | "RE"
2836
+ | "RO"
2837
+ | "RS"
2838
+ | "RU"
2839
+ | "RW"
2840
+ | "SA"
2841
+ | "SB"
2842
+ | "SC"
2843
+ | "SD"
2844
+ | "SE"
2845
+ | "SG"
2846
+ | "SH"
2847
+ | "SI"
2848
+ | "SJ"
2849
+ | "SK"
2850
+ | "SL"
2851
+ | "SM"
2852
+ | "SN"
2853
+ | "SO"
2854
+ | "SR"
2855
+ | "SS"
2856
+ | "ST"
2857
+ | "SV"
2858
+ | "SX"
2859
+ | "SY"
2860
+ | "SZ"
2861
+ | "TC"
2862
+ | "TD"
2863
+ | "TF"
2864
+ | "TG"
2865
+ | "TH"
2866
+ | "TJ"
2867
+ | "TK"
2868
+ | "TL"
2869
+ | "TM"
2870
+ | "TN"
2871
+ | "TO"
2872
+ | "TR"
2873
+ | "TT"
2874
+ | "TV"
2875
+ | "TW"
2876
+ | "TZ"
2877
+ | "UA"
2878
+ | "UG"
2879
+ | "UM"
2880
+ | "US"
2881
+ | "UY"
2882
+ | "UZ"
2883
+ | "VA"
2884
+ | "VC"
2885
+ | "VE"
2886
+ | "VG"
2887
+ | "VI"
2888
+ | "VN"
2889
+ | "VU"
2890
+ | "WF"
2891
+ | "WS"
2892
+ | "YE"
2893
+ | "YT"
2894
+ | "ZA"
2895
+ | "ZM"
2896
+ | "ZW";
2897
+ /** The 2-letter continent codes Cloudflare uses */
2898
+ export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2899
+ export type CfProperties<HostMetadata = unknown> =
2900
+ | IncomingRequestCfProperties<HostMetadata>
2901
+ | RequestInitCfProperties;
2902
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
2903
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
2904
+ // https://opensource.org/licenses/Apache-2.0
2905
+ export interface D1Result<T = unknown> {
2906
+ results: T[];
2907
+ success: true;
2908
+ meta: any;
2909
+ error?: never;
2910
+ }
2911
+ export interface D1ExecResult {
2912
+ count: number;
2913
+ duration: number;
2914
+ }
2915
+ export declare abstract class D1Database {
2916
+ prepare(query: string): D1PreparedStatement;
2917
+ dump(): Promise<ArrayBuffer>;
2918
+ batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2919
+ exec(query: string): Promise<D1ExecResult>;
2920
+ }
2921
+ export declare abstract class D1PreparedStatement {
2922
+ bind(...values: unknown[]): D1PreparedStatement;
2923
+ first<T = unknown>(colName: string): Promise<T | null>;
2924
+ first<T = Record<string, unknown>>(): Promise<T | null>;
2925
+ run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
2926
+ all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
2927
+ raw<T = unknown[]>(): Promise<T[]>;
2928
+ }
2929
+ // Copyright (c) 2023 Cloudflare, Inc.
2930
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
2931
+ // https://opensource.org/licenses/Apache-2.0
2932
+ /**
2933
+ * An email message that can be sent from a Worker.
2934
+ */
2935
+ export interface EmailMessage {
2936
+ /**
2937
+ * Envelope From attribute of the email message.
2938
+ */
2939
+ readonly from: string;
2940
+ /**
2941
+ * Envelope To attribute of the email message.
2942
+ */
2943
+ readonly to: string;
2944
+ }
2945
+ /**
2946
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
2947
+ */
2948
+ export interface ForwardableEmailMessage extends EmailMessage {
2949
+ /**
2950
+ * Stream of the email message content.
2951
+ */
2952
+ readonly raw: ReadableStream;
2953
+ /**
2954
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2955
+ */
2956
+ readonly headers: Headers;
2957
+ /**
2958
+ * Size of the email message content.
2959
+ */
2960
+ readonly rawSize: number;
2961
+ /**
2962
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2963
+ * @param reason The reject reason.
2964
+ * @returns void
2965
+ */
2966
+ setReject(reason: string): void;
2967
+ /**
2968
+ * Forward this email message to a verified destination address of the account.
2969
+ * @param rcptTo Verified destination address.
2970
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2971
+ * @returns A promise that resolves when the email message is forwarded.
2972
+ */
2973
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2974
+ }
2975
+ /**
2976
+ * A binding that allows a Worker to send email messages.
2977
+ */
2978
+ export interface SendEmail {
2979
+ send(message: EmailMessage): Promise<void>;
2980
+ }
2981
+ export declare abstract class EmailEvent extends ExtendableEvent {
2982
+ readonly message: ForwardableEmailMessage;
2983
+ }
2984
+ export type EmailExportedHandler<Env = unknown> = (
2985
+ message: ForwardableEmailMessage,
2986
+ env: Env,
2987
+ ctx: ExecutionContext
2988
+ ) => void | Promise<void>;
2989
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
2990
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
2991
+ // https://opensource.org/licenses/Apache-2.0
2992
+ export type Params<P extends string = any> = Record<P, string | string[]>;
2993
+ export type EventContext<Env, P extends string, Data> = {
2994
+ request: Request;
2995
+ functionPath: string;
2996
+ waitUntil: (promise: Promise<any>) => void;
2997
+ passThroughOnException: () => void;
2998
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
2999
+ env: Env & {
3000
+ ASSETS: {
3001
+ fetch: typeof fetch;
3002
+ };
3003
+ };
3004
+ params: Params<P>;
3005
+ data: Data;
3006
+ };
3007
+ export type PagesFunction<
3008
+ Env = unknown,
3009
+ Params extends string = any,
3010
+ Data extends Record<string, unknown> = Record<string, unknown>
3011
+ > = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
3012
+ export type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
3013
+ request: Request;
3014
+ functionPath: string;
3015
+ waitUntil: (promise: Promise<any>) => void;
3016
+ passThroughOnException: () => void;
3017
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
3018
+ env: Env & {
3019
+ ASSETS: {
3020
+ fetch: typeof fetch;
3021
+ };
3022
+ };
3023
+ params: Params<P>;
3024
+ data: Data;
3025
+ pluginArgs: PluginArgs;
3026
+ };
3027
+ export type PagesPluginFunction<
3028
+ Env = unknown,
3029
+ Params extends string = any,
3030
+ Data extends Record<string, unknown> = Record<string, unknown>,
3031
+ PluginArgs = unknown
3032
+ > = (
3033
+ context: EventPluginContext<Env, Params, Data, PluginArgs>
3034
+ ) => Response | Promise<Response>;
3035
+ // Copyright (c) 2023 Cloudflare, Inc.
3036
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
3037
+ // https://opensource.org/licenses/Apache-2.0
3038
+ // https://developers.cloudflare.com/pub-sub/
3039
+ // PubSubMessage represents an incoming PubSub message.
3040
+ // The message includes metadata about the broker, the client, and the payload
3041
+ // itself.
3042
+ export interface PubSubMessage {
3043
+ // Message ID
3044
+ readonly mid: number;
3045
+ // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
3046
+ readonly broker: string;
3047
+ // The MQTT topic the message was sent on.
3048
+ readonly topic: string;
3049
+ // The client ID of the client that published this message.
3050
+ readonly clientId: string;
3051
+ // The unique identifier (JWT ID) used by the client to authenticate, if token
3052
+ // auth was used.
3053
+ readonly jti?: string;
3054
+ // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
3055
+ // received the message from the client.
3056
+ readonly receivedAt: number;
3057
+ // An (optional) string with the MIME type of the payload, if set by the
3058
+ // client.
3059
+ readonly contentType: string;
3060
+ // Set to 1 when the payload is a UTF-8 string
3061
+ // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
3062
+ readonly payloadFormatIndicator: number;
3063
+ // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
3064
+ // You can use payloadFormatIndicator to inspect this before decoding.
3065
+ payload: string | Uint8Array;
3066
+ }
3067
+ // JsonWebKey extended by kid parameter
3068
+ export interface JsonWebKeyWithKid extends JsonWebKey {
3069
+ // Key Identifier of the JWK
3070
+ readonly kid: string;
3071
+ }
3072
+ // Copyright (c) 2023 Cloudflare, Inc.
3073
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
3074
+ // https://opensource.org/licenses/Apache-2.0
3075
+ // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3076
+ export interface DynamicDispatchLimits {
3077
+ /**
3078
+ * Limit CPU time in milliseconds.
3079
+ */
3080
+ cpuMs?: number;
3081
+ /**
3082
+ * Limit number of subrequests.
3083
+ */
3084
+ subRequests?: number;
3085
+ }
3086
+ export interface DynamicDispatchOptions {
3087
+ /**
3088
+ * Limit resources of invoked Worker script.
3089
+ */
3090
+ limits?: DynamicDispatchLimits;
3091
+ /**
3092
+ * Arguments for outbound Worker script, if configured.
3093
+ */
3094
+ outbound?: {
3095
+ [key: string]: any;
3096
+ };
3097
+ }
3098
+ export interface DispatchNamespace {
3099
+ /**
3100
+ * @param name Name of the Worker script.
3101
+ * @param args Arguments to Worker script.
3102
+ * @param options Options for Dynamic Dispatch invocation.
3103
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
3104
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3105
+ */
3106
+ get(
3107
+ name: string,
3108
+ args?: {
3109
+ [key: string]: any;
3110
+ },
3111
+ options?: DynamicDispatchOptions
3112
+ ): Fetcher;
3113
+ }