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