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