@workers-community/workers-types 0.20230701.20240605-alpha.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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/index.d.ts +4914 -0
  3. package/package.json +18 -0
package/index.d.ts ADDED
@@ -0,0 +1,4914 @@
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
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
20
+ readonly message: string;
21
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
22
+ readonly name: string;
23
+ /**
24
+ * @deprecated
25
+ *
26
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
27
+ */
28
+ readonly code: number;
29
+ static readonly INDEX_SIZE_ERR: number;
30
+ static readonly DOMSTRING_SIZE_ERR: number;
31
+ static readonly HIERARCHY_REQUEST_ERR: number;
32
+ static readonly WRONG_DOCUMENT_ERR: number;
33
+ static readonly INVALID_CHARACTER_ERR: number;
34
+ static readonly NO_DATA_ALLOWED_ERR: number;
35
+ static readonly NO_MODIFICATION_ALLOWED_ERR: number;
36
+ static readonly NOT_FOUND_ERR: number;
37
+ static readonly NOT_SUPPORTED_ERR: number;
38
+ static readonly INUSE_ATTRIBUTE_ERR: number;
39
+ static readonly INVALID_STATE_ERR: number;
40
+ static readonly SYNTAX_ERR: number;
41
+ static readonly INVALID_MODIFICATION_ERR: number;
42
+ static readonly NAMESPACE_ERR: number;
43
+ static readonly INVALID_ACCESS_ERR: number;
44
+ static readonly VALIDATION_ERR: number;
45
+ static readonly TYPE_MISMATCH_ERR: number;
46
+ static readonly SECURITY_ERR: number;
47
+ static readonly NETWORK_ERR: number;
48
+ static readonly ABORT_ERR: number;
49
+ static readonly URL_MISMATCH_ERR: number;
50
+ static readonly QUOTA_EXCEEDED_ERR: number;
51
+ static readonly TIMEOUT_ERR: number;
52
+ static readonly INVALID_NODE_TYPE_ERR: number;
53
+ static readonly DATA_CLONE_ERR: number;
54
+ get stack(): any;
55
+ set stack(value: any);
56
+ }
57
+ declare type WorkerGlobalScopeEventMap = {
58
+ fetch: FetchEvent;
59
+ scheduled: ScheduledEvent;
60
+ queue: QueueEvent;
61
+ unhandledrejection: PromiseRejectionEvent;
62
+ rejectionhandled: PromiseRejectionEvent;
63
+ };
64
+ declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
65
+ EventTarget: typeof EventTarget;
66
+ }
67
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) */
68
+ declare interface Console {
69
+ "assert"(condition?: boolean, ...data: any[]): void;
70
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) */
71
+ clear(): void;
72
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) */
73
+ count(label?: string): void;
74
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) */
75
+ countReset(label?: string): void;
76
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) */
77
+ debug(...data: any[]): void;
78
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) */
79
+ dir(item?: any, options?: any): void;
80
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) */
81
+ dirxml(...data: any[]): void;
82
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) */
83
+ error(...data: any[]): void;
84
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) */
85
+ group(...data: any[]): void;
86
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) */
87
+ groupCollapsed(...data: any[]): void;
88
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) */
89
+ groupEnd(): void;
90
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) */
91
+ info(...data: any[]): void;
92
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) */
93
+ log(...data: any[]): void;
94
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) */
95
+ table(tabularData?: any, properties?: string[]): void;
96
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) */
97
+ time(label?: string): void;
98
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) */
99
+ timeEnd(label?: string): void;
100
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) */
101
+ timeLog(label?: string, ...data: any[]): void;
102
+ timeStamp(label?: string): void;
103
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */
104
+ trace(...data: any[]): void;
105
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) */
106
+ warn(...data: any[]): void;
107
+ }
108
+ declare const console: Console;
109
+ declare type BufferSource = ArrayBufferView | ArrayBuffer;
110
+ declare type TypedArray =
111
+ | Int8Array
112
+ | Uint8Array
113
+ | Uint8ClampedArray
114
+ | Int16Array
115
+ | Uint16Array
116
+ | Int32Array
117
+ | Uint32Array
118
+ | Float32Array
119
+ | Float64Array
120
+ | BigInt64Array
121
+ | BigUint64Array;
122
+ declare namespace WebAssembly {
123
+ class CompileError extends Error {
124
+ constructor(message?: string);
125
+ }
126
+ class RuntimeError extends Error {
127
+ constructor(message?: string);
128
+ }
129
+ type ValueType =
130
+ | "anyfunc"
131
+ | "externref"
132
+ | "f32"
133
+ | "f64"
134
+ | "i32"
135
+ | "i64"
136
+ | "v128";
137
+ interface GlobalDescriptor {
138
+ value: ValueType;
139
+ mutable?: boolean;
140
+ }
141
+ class Global {
142
+ constructor(descriptor: GlobalDescriptor, value?: any);
143
+ value: any;
144
+ valueOf(): any;
145
+ }
146
+ type ImportValue = ExportValue | number;
147
+ type ModuleImports = Record<string, ImportValue>;
148
+ type Imports = Record<string, ModuleImports>;
149
+ type ExportValue = Function | Global | Memory | Table;
150
+ type Exports = Record<string, ExportValue>;
151
+ class Instance {
152
+ constructor(module: Module, imports?: Imports);
153
+ readonly exports: Exports;
154
+ }
155
+ interface MemoryDescriptor {
156
+ initial: number;
157
+ maximum?: number;
158
+ shared?: boolean;
159
+ }
160
+ class Memory {
161
+ constructor(descriptor: MemoryDescriptor);
162
+ readonly buffer: ArrayBuffer;
163
+ grow(delta: number): number;
164
+ }
165
+ type ImportExportKind = "function" | "global" | "memory" | "table";
166
+ interface ModuleExportDescriptor {
167
+ kind: ImportExportKind;
168
+ name: string;
169
+ }
170
+ interface ModuleImportDescriptor {
171
+ kind: ImportExportKind;
172
+ module: string;
173
+ name: string;
174
+ }
175
+ abstract class Module {
176
+ static customSections(module: Module, sectionName: string): ArrayBuffer[];
177
+ static exports(module: Module): ModuleExportDescriptor[];
178
+ static imports(module: Module): ModuleImportDescriptor[];
179
+ }
180
+ type TableKind = "anyfunc" | "externref";
181
+ interface TableDescriptor {
182
+ element: TableKind;
183
+ initial: number;
184
+ maximum?: number;
185
+ }
186
+ class Table {
187
+ constructor(descriptor: TableDescriptor, value?: any);
188
+ readonly length: number;
189
+ get(index: number): any;
190
+ grow(delta: number, value?: any): number;
191
+ set(index: number, value?: any): void;
192
+ }
193
+ function instantiate(module: Module, imports?: Imports): Promise<Instance>;
194
+ function validate(bytes: BufferSource): boolean;
195
+ }
196
+ /**
197
+ * This ServiceWorker API interface represents the global execution context of a service worker.
198
+ *
199
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
200
+ */
201
+ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
202
+ DOMException: typeof DOMException;
203
+ WorkerGlobalScope: typeof WorkerGlobalScope;
204
+ btoa(data: string): string;
205
+ atob(data: string): string;
206
+ setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
207
+ setTimeout<Args extends any[]>(
208
+ callback: (...args: Args) => void,
209
+ msDelay?: number,
210
+ ...args: Args
211
+ ): number;
212
+ clearTimeout(timeoutId: number | null): void;
213
+ setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
214
+ setInterval<Args extends any[]>(
215
+ callback: (...args: Args) => void,
216
+ msDelay?: number,
217
+ ...args: Args
218
+ ): number;
219
+ clearInterval(timeoutId: number | null): void;
220
+ queueMicrotask(task: Function): void;
221
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
222
+ reportError(error: any): void;
223
+ fetch(
224
+ input: RequestInfo,
225
+ init?: RequestInit<RequestInitCfProperties>,
226
+ ): Promise<Response>;
227
+ self: ServiceWorkerGlobalScope;
228
+ crypto: Crypto;
229
+ caches: CacheStorage;
230
+ scheduler: Scheduler;
231
+ performance: Performance;
232
+ readonly origin: string;
233
+ Event: typeof Event;
234
+ ExtendableEvent: typeof ExtendableEvent;
235
+ CustomEvent: typeof CustomEvent;
236
+ PromiseRejectionEvent: typeof PromiseRejectionEvent;
237
+ FetchEvent: typeof FetchEvent;
238
+ TailEvent: typeof TailEvent;
239
+ TraceEvent: typeof TailEvent;
240
+ ScheduledEvent: typeof ScheduledEvent;
241
+ MessageEvent: typeof MessageEvent;
242
+ CloseEvent: typeof CloseEvent;
243
+ ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
244
+ ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
245
+ ReadableStream: typeof ReadableStream;
246
+ WritableStream: typeof WritableStream;
247
+ WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
248
+ TransformStream: typeof TransformStream;
249
+ ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
250
+ CountQueuingStrategy: typeof CountQueuingStrategy;
251
+ ErrorEvent: typeof ErrorEvent;
252
+ ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
253
+ ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
254
+ ReadableByteStreamController: typeof ReadableByteStreamController;
255
+ WritableStreamDefaultController: typeof WritableStreamDefaultController;
256
+ TransformStreamDefaultController: typeof TransformStreamDefaultController;
257
+ CompressionStream: typeof CompressionStream;
258
+ DecompressionStream: typeof DecompressionStream;
259
+ TextEncoderStream: typeof TextEncoderStream;
260
+ TextDecoderStream: typeof TextDecoderStream;
261
+ Headers: typeof Headers;
262
+ Body: typeof Body;
263
+ Request: typeof Request;
264
+ Response: typeof Response;
265
+ WebSocket: typeof WebSocket;
266
+ WebSocketPair: typeof WebSocketPair;
267
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
268
+ AbortController: typeof AbortController;
269
+ AbortSignal: typeof AbortSignal;
270
+ TextDecoder: typeof TextDecoder;
271
+ TextEncoder: typeof TextEncoder;
272
+ navigator: Navigator;
273
+ Navigator: typeof Navigator;
274
+ URL: typeof URL;
275
+ URLSearchParams: typeof URLSearchParams;
276
+ URLPattern: typeof URLPattern;
277
+ Blob: typeof Blob;
278
+ File: typeof File;
279
+ FormData: typeof FormData;
280
+ Crypto: typeof Crypto;
281
+ SubtleCrypto: typeof SubtleCrypto;
282
+ CryptoKey: typeof CryptoKey;
283
+ CacheStorage: typeof CacheStorage;
284
+ Cache: typeof Cache;
285
+ FixedLengthStream: typeof FixedLengthStream;
286
+ IdentityTransformStream: typeof IdentityTransformStream;
287
+ HTMLRewriter: typeof HTMLRewriter;
288
+ GPUAdapter: typeof gpuGPUAdapter;
289
+ GPUOutOfMemoryError: typeof gpuGPUOutOfMemoryError;
290
+ GPUValidationError: typeof gpuGPUValidationError;
291
+ GPUInternalError: typeof gpuGPUInternalError;
292
+ GPUDeviceLostInfo: typeof gpuGPUDeviceLostInfo;
293
+ GPUBufferUsage: typeof gpuGPUBufferUsage;
294
+ GPUShaderStage: typeof gpuGPUShaderStage;
295
+ GPUMapMode: typeof gpuGPUMapMode;
296
+ GPUTextureUsage: typeof gpuGPUTextureUsage;
297
+ GPUColorWrite: typeof gpuGPUColorWrite;
298
+ }
299
+ declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
300
+ type: Type,
301
+ handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
302
+ options?: EventTargetAddEventListenerOptions | boolean,
303
+ ): void;
304
+ declare function removeEventListener<
305
+ Type extends keyof WorkerGlobalScopeEventMap,
306
+ >(
307
+ type: Type,
308
+ handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
309
+ options?: EventTargetEventListenerOptions | boolean,
310
+ ): void;
311
+ /**
312
+ * 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.
313
+ *
314
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
315
+ */
316
+ declare function dispatchEvent(
317
+ event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap],
318
+ ): boolean;
319
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/btoa) */
320
+ declare function btoa(data: string): string;
321
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/atob) */
322
+ declare function atob(data: string): string;
323
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setTimeout) */
324
+ declare function setTimeout(
325
+ callback: (...args: any[]) => void,
326
+ msDelay?: number,
327
+ ): number;
328
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setTimeout) */
329
+ declare function setTimeout<Args extends any[]>(
330
+ callback: (...args: Args) => void,
331
+ msDelay?: number,
332
+ ...args: Args
333
+ ): number;
334
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/clearTimeout) */
335
+ declare function clearTimeout(timeoutId: number | null): void;
336
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setInterval) */
337
+ declare function setInterval(
338
+ callback: (...args: any[]) => void,
339
+ msDelay?: number,
340
+ ): number;
341
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/setInterval) */
342
+ declare function setInterval<Args extends any[]>(
343
+ callback: (...args: Args) => void,
344
+ msDelay?: number,
345
+ ...args: Args
346
+ ): number;
347
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/clearInterval) */
348
+ declare function clearInterval(timeoutId: number | null): void;
349
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/queueMicrotask) */
350
+ declare function queueMicrotask(task: Function): void;
351
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/structuredClone) */
352
+ declare function structuredClone<T>(
353
+ value: T,
354
+ options?: StructuredSerializeOptions,
355
+ ): T;
356
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/reportError) */
357
+ declare function reportError(error: any): void;
358
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/fetch) */
359
+ declare function fetch(
360
+ input: RequestInfo,
361
+ init?: RequestInit<RequestInitCfProperties>,
362
+ ): Promise<Response>;
363
+ declare const self: ServiceWorkerGlobalScope;
364
+ declare const crypto: Crypto;
365
+ declare const caches: CacheStorage;
366
+ declare const scheduler: Scheduler;
367
+ declare const performance: Performance;
368
+ declare const origin: string;
369
+ declare const navigator: Navigator;
370
+ declare interface TestController {}
371
+ declare interface ExecutionContext {
372
+ waitUntil(promise: Promise<any>): void;
373
+ passThroughOnException(): void;
374
+ }
375
+ declare type ExportedHandlerFetchHandler<
376
+ Env = unknown,
377
+ CfHostMetadata = unknown,
378
+ > = (
379
+ request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
380
+ env: Env,
381
+ ctx: ExecutionContext,
382
+ ) => Response | Promise<Response>;
383
+ declare type ExportedHandlerTailHandler<Env = unknown> = (
384
+ events: TraceItem[],
385
+ env: Env,
386
+ ctx: ExecutionContext,
387
+ ) => void | Promise<void>;
388
+ declare type ExportedHandlerTraceHandler<Env = unknown> = (
389
+ traces: TraceItem[],
390
+ env: Env,
391
+ ctx: ExecutionContext,
392
+ ) => void | Promise<void>;
393
+ declare type ExportedHandlerScheduledHandler<Env = unknown> = (
394
+ controller: ScheduledController,
395
+ env: Env,
396
+ ctx: ExecutionContext,
397
+ ) => void | Promise<void>;
398
+ declare type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
399
+ batch: MessageBatch<Message>,
400
+ env: Env,
401
+ ctx: ExecutionContext,
402
+ ) => void | Promise<void>;
403
+ declare type ExportedHandlerTestHandler<Env = unknown> = (
404
+ controller: TestController,
405
+ env: Env,
406
+ ctx: ExecutionContext,
407
+ ) => void | Promise<void>;
408
+ declare interface ExportedHandler<
409
+ Env = unknown,
410
+ QueueHandlerMessage = unknown,
411
+ CfHostMetadata = unknown,
412
+ > {
413
+ fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
414
+ tail?: ExportedHandlerTailHandler<Env>;
415
+ trace?: ExportedHandlerTraceHandler<Env>;
416
+ scheduled?: ExportedHandlerScheduledHandler<Env>;
417
+ test?: ExportedHandlerTestHandler<Env>;
418
+ email?: EmailExportedHandler<Env>;
419
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
420
+ }
421
+ declare interface StructuredSerializeOptions {
422
+ transfer?: any[];
423
+ }
424
+ declare abstract class PromiseRejectionEvent extends Event {
425
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) */
426
+ readonly promise: Promise<any>;
427
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) */
428
+ readonly reason: any;
429
+ }
430
+ declare abstract class Navigator {
431
+ sendBeacon(
432
+ url: string,
433
+ body?:
434
+ | ReadableStream
435
+ | string
436
+ | (ArrayBuffer | ArrayBufferView)
437
+ | Blob
438
+ | URLSearchParams
439
+ | FormData,
440
+ ): boolean;
441
+ readonly userAgent: string;
442
+ readonly gpu: gpuGPU;
443
+ }
444
+ /**
445
+ * 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.
446
+ *
447
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance)
448
+ */
449
+ declare interface Performance {
450
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/timeOrigin) */
451
+ readonly timeOrigin: number;
452
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/now) */
453
+ now(): number;
454
+ }
455
+ declare interface AlarmInvocationInfo {
456
+ readonly isRetry: boolean;
457
+ readonly retryCount: number;
458
+ }
459
+ declare interface DurableObject {
460
+ fetch(request: Request): Response | Promise<Response>;
461
+ alarm?(): void | Promise<void>;
462
+ webSocketMessage?(
463
+ ws: WebSocket,
464
+ message: string | ArrayBuffer,
465
+ ): void | Promise<void>;
466
+ webSocketClose?(
467
+ ws: WebSocket,
468
+ code: number,
469
+ reason: string,
470
+ wasClean: boolean,
471
+ ): void | Promise<void>;
472
+ webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
473
+ }
474
+ declare type DurableObjectStub<
475
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
476
+ > = Fetcher<
477
+ T,
478
+ "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
479
+ > & {
480
+ readonly id: DurableObjectId;
481
+ readonly name?: string;
482
+ };
483
+ declare interface DurableObjectId {
484
+ toString(): string;
485
+ equals(other: DurableObjectId): boolean;
486
+ readonly name?: string;
487
+ }
488
+ declare interface DurableObjectNamespace<
489
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
490
+ > {
491
+ newUniqueId(
492
+ options?: DurableObjectNamespaceNewUniqueIdOptions,
493
+ ): DurableObjectId;
494
+ idFromName(name: string): DurableObjectId;
495
+ idFromString(id: string): DurableObjectId;
496
+ get(
497
+ id: DurableObjectId,
498
+ options?: DurableObjectNamespaceGetDurableObjectOptions,
499
+ ): DurableObjectStub<T>;
500
+ jurisdiction(
501
+ jurisdiction: DurableObjectJurisdiction,
502
+ ): DurableObjectNamespace<T>;
503
+ }
504
+ declare type DurableObjectJurisdiction = "eu" | "fedramp";
505
+ declare interface DurableObjectNamespaceNewUniqueIdOptions {
506
+ jurisdiction?: DurableObjectJurisdiction;
507
+ }
508
+ declare type DurableObjectLocationHint =
509
+ | "wnam"
510
+ | "enam"
511
+ | "sam"
512
+ | "weur"
513
+ | "eeur"
514
+ | "apac"
515
+ | "oc"
516
+ | "afr"
517
+ | "me";
518
+ declare interface DurableObjectNamespaceGetDurableObjectOptions {
519
+ locationHint?: DurableObjectLocationHint;
520
+ }
521
+ declare interface DurableObjectState {
522
+ waitUntil(promise: Promise<any>): void;
523
+ readonly id: DurableObjectId;
524
+ readonly storage: DurableObjectStorage;
525
+ blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
526
+ acceptWebSocket(ws: WebSocket, tags?: string[]): void;
527
+ getWebSockets(tag?: string): WebSocket[];
528
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
529
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
530
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
531
+ setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
532
+ getHibernatableWebSocketEventTimeout(): number | null;
533
+ getTags(ws: WebSocket): string[];
534
+ }
535
+ declare interface DurableObjectTransaction {
536
+ get<T = unknown>(
537
+ key: string,
538
+ options?: DurableObjectGetOptions,
539
+ ): Promise<T | undefined>;
540
+ get<T = unknown>(
541
+ keys: string[],
542
+ options?: DurableObjectGetOptions,
543
+ ): Promise<Map<string, T>>;
544
+ list<T = unknown>(
545
+ options?: DurableObjectListOptions,
546
+ ): Promise<Map<string, T>>;
547
+ put<T>(
548
+ key: string,
549
+ value: T,
550
+ options?: DurableObjectPutOptions,
551
+ ): Promise<void>;
552
+ put<T>(
553
+ entries: Record<string, T>,
554
+ options?: DurableObjectPutOptions,
555
+ ): Promise<void>;
556
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
557
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
558
+ rollback(): void;
559
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
560
+ setAlarm(
561
+ scheduledTime: number | Date,
562
+ options?: DurableObjectSetAlarmOptions,
563
+ ): Promise<void>;
564
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
565
+ }
566
+ declare interface DurableObjectStorage {
567
+ get<T = unknown>(
568
+ key: string,
569
+ options?: DurableObjectGetOptions,
570
+ ): Promise<T | undefined>;
571
+ get<T = unknown>(
572
+ keys: string[],
573
+ options?: DurableObjectGetOptions,
574
+ ): Promise<Map<string, T>>;
575
+ list<T = unknown>(
576
+ options?: DurableObjectListOptions,
577
+ ): Promise<Map<string, T>>;
578
+ put<T>(
579
+ key: string,
580
+ value: T,
581
+ options?: DurableObjectPutOptions,
582
+ ): Promise<void>;
583
+ put<T>(
584
+ entries: Record<string, T>,
585
+ options?: DurableObjectPutOptions,
586
+ ): Promise<void>;
587
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
588
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
589
+ deleteAll(options?: DurableObjectPutOptions): Promise<void>;
590
+ transaction<T>(
591
+ closure: (txn: DurableObjectTransaction) => Promise<T>,
592
+ ): Promise<T>;
593
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
594
+ setAlarm(
595
+ scheduledTime: number | Date,
596
+ options?: DurableObjectSetAlarmOptions,
597
+ ): Promise<void>;
598
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
599
+ sync(): Promise<void>;
600
+ transactionSync<T>(closure: () => T): T;
601
+ }
602
+ declare interface DurableObjectListOptions {
603
+ start?: string;
604
+ startAfter?: string;
605
+ end?: string;
606
+ prefix?: string;
607
+ reverse?: boolean;
608
+ limit?: number;
609
+ allowConcurrency?: boolean;
610
+ noCache?: boolean;
611
+ }
612
+ declare interface DurableObjectGetOptions {
613
+ allowConcurrency?: boolean;
614
+ noCache?: boolean;
615
+ }
616
+ declare interface DurableObjectGetAlarmOptions {
617
+ allowConcurrency?: boolean;
618
+ }
619
+ declare interface DurableObjectPutOptions {
620
+ allowConcurrency?: boolean;
621
+ allowUnconfirmed?: boolean;
622
+ noCache?: boolean;
623
+ }
624
+ declare interface DurableObjectSetAlarmOptions {
625
+ allowConcurrency?: boolean;
626
+ allowUnconfirmed?: boolean;
627
+ }
628
+ declare class WebSocketRequestResponsePair {
629
+ constructor(request: string, response: string);
630
+ get request(): string;
631
+ get response(): string;
632
+ }
633
+ declare interface AnalyticsEngineDataset {
634
+ writeDataPoint(event?: AnalyticsEngineDataPoint): void;
635
+ }
636
+ declare interface AnalyticsEngineDataPoint {
637
+ indexes?: ((ArrayBuffer | string) | null)[];
638
+ doubles?: number[];
639
+ blobs?: ((ArrayBuffer | string) | null)[];
640
+ }
641
+ declare class Event {
642
+ constructor(type: string, init?: EventInit);
643
+ /**
644
+ * Returns the type of event, e.g. "click", "hashchange", or "submit".
645
+ *
646
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
647
+ */
648
+ get type(): string;
649
+ /**
650
+ * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
651
+ *
652
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
653
+ */
654
+ get eventPhase(): number;
655
+ /**
656
+ * Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
657
+ *
658
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
659
+ */
660
+ get composed(): boolean;
661
+ /**
662
+ * Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
663
+ *
664
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
665
+ */
666
+ get bubbles(): boolean;
667
+ /**
668
+ * Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
669
+ *
670
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
671
+ */
672
+ get cancelable(): boolean;
673
+ /**
674
+ * Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
675
+ *
676
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
677
+ */
678
+ get defaultPrevented(): boolean;
679
+ /**
680
+ * @deprecated
681
+ *
682
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
683
+ */
684
+ get returnValue(): boolean;
685
+ /**
686
+ * Returns the object whose event listener's callback is currently being invoked.
687
+ *
688
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
689
+ */
690
+ get currentTarget(): EventTarget | undefined;
691
+ /**
692
+ * @deprecated
693
+ *
694
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
695
+ */
696
+ get srcElement(): EventTarget | undefined;
697
+ /**
698
+ * Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
699
+ *
700
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
701
+ */
702
+ get timeStamp(): number;
703
+ /**
704
+ * Returns true if event was dispatched by the user agent, and false otherwise.
705
+ *
706
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
707
+ */
708
+ get isTrusted(): boolean;
709
+ /**
710
+ * @deprecated
711
+ *
712
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
713
+ */
714
+ get cancelBubble(): boolean;
715
+ /**
716
+ * @deprecated
717
+ *
718
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
719
+ */
720
+ set cancelBubble(value: boolean);
721
+ /**
722
+ * Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.
723
+ *
724
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
725
+ */
726
+ stopImmediatePropagation(): void;
727
+ /**
728
+ * If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
729
+ *
730
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
731
+ */
732
+ preventDefault(): void;
733
+ /**
734
+ * When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
735
+ *
736
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
737
+ */
738
+ stopPropagation(): void;
739
+ /**
740
+ * Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget.
741
+ *
742
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
743
+ */
744
+ composedPath(): EventTarget[];
745
+ static readonly NONE: number;
746
+ static readonly CAPTURING_PHASE: number;
747
+ static readonly AT_TARGET: number;
748
+ static readonly BUBBLING_PHASE: number;
749
+ }
750
+ declare interface EventInit {
751
+ bubbles?: boolean;
752
+ cancelable?: boolean;
753
+ composed?: boolean;
754
+ }
755
+ declare type EventListener<EventType extends Event = Event> = (
756
+ event: EventType,
757
+ ) => void;
758
+ declare interface EventListenerObject<EventType extends Event = Event> {
759
+ handleEvent(event: EventType): void;
760
+ }
761
+ declare type EventListenerOrEventListenerObject<
762
+ EventType extends Event = Event,
763
+ > = EventListener<EventType> | EventListenerObject<EventType>;
764
+ declare class EventTarget<
765
+ EventMap extends Record<string, Event> = Record<string, Event>,
766
+ > {
767
+ constructor();
768
+ /**
769
+ * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
770
+ *
771
+ * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
772
+ *
773
+ * When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
774
+ *
775
+ * When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
776
+ *
777
+ * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
778
+ *
779
+ * If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
780
+ *
781
+ * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
782
+ *
783
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
784
+ */
785
+ addEventListener<Type extends keyof EventMap>(
786
+ type: Type,
787
+ handler: EventListenerOrEventListenerObject<EventMap[Type]>,
788
+ options?: EventTargetAddEventListenerOptions | boolean,
789
+ ): void;
790
+ /**
791
+ * Removes the event listener in target's event listener list with the same type, callback, and options.
792
+ *
793
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
794
+ */
795
+ removeEventListener<Type extends keyof EventMap>(
796
+ type: Type,
797
+ handler: EventListenerOrEventListenerObject<EventMap[Type]>,
798
+ options?: EventTargetEventListenerOptions | boolean,
799
+ ): void;
800
+ /**
801
+ * 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.
802
+ *
803
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
804
+ */
805
+ dispatchEvent(event: EventMap[keyof EventMap]): boolean;
806
+ }
807
+ declare interface EventTargetEventListenerOptions {
808
+ capture?: boolean;
809
+ }
810
+ declare interface EventTargetAddEventListenerOptions {
811
+ capture?: boolean;
812
+ passive?: boolean;
813
+ once?: boolean;
814
+ signal?: AbortSignal;
815
+ }
816
+ declare interface EventTargetHandlerObject {
817
+ handleEvent: (event: Event) => any | undefined;
818
+ }
819
+ declare class AbortController {
820
+ constructor();
821
+ /**
822
+ * Returns the AbortSignal object associated with this object.
823
+ *
824
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
825
+ */
826
+ get signal(): AbortSignal;
827
+ /**
828
+ * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
829
+ *
830
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
831
+ */
832
+ abort(reason?: any): void;
833
+ }
834
+ declare abstract class AbortSignal extends EventTarget {
835
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) */
836
+ static abort(reason?: any): AbortSignal;
837
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) */
838
+ static timeout(delay: number): AbortSignal;
839
+ static any(signals: AbortSignal[]): AbortSignal;
840
+ /**
841
+ * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
842
+ *
843
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
844
+ */
845
+ get aborted(): boolean;
846
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) */
847
+ get reason(): any;
848
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
849
+ get onabort(): any | null;
850
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
851
+ set onabort(value: any | null);
852
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) */
853
+ throwIfAborted(): void;
854
+ }
855
+ declare interface Scheduler {
856
+ wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
857
+ }
858
+ declare interface SchedulerWaitOptions {
859
+ signal?: AbortSignal;
860
+ }
861
+ declare abstract class ExtendableEvent extends Event {
862
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) */
863
+ waitUntil(promise: Promise<any>): void;
864
+ }
865
+ declare class CustomEvent<T = any> extends Event {
866
+ constructor(type: string, init?: CustomEventCustomEventInit);
867
+ /**
868
+ * Returns any custom data event was created with. Typically used for synthetic events.
869
+ *
870
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
871
+ */
872
+ get detail(): T;
873
+ }
874
+ declare interface CustomEventCustomEventInit {
875
+ bubbles?: boolean;
876
+ cancelable?: boolean;
877
+ composed?: boolean;
878
+ detail?: any;
879
+ }
880
+ declare class Blob {
881
+ constructor(
882
+ type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
883
+ options?: BlobOptions,
884
+ );
885
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
886
+ get size(): number;
887
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
888
+ get type(): string;
889
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
890
+ slice(start?: number, end?: number, type?: string): Blob;
891
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
892
+ arrayBuffer(): Promise<ArrayBuffer>;
893
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
894
+ text(): Promise<string>;
895
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */
896
+ stream(): ReadableStream;
897
+ }
898
+ declare interface BlobOptions {
899
+ type?: string;
900
+ }
901
+ declare class File extends Blob {
902
+ constructor(
903
+ bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
904
+ name: string,
905
+ options?: FileOptions,
906
+ );
907
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
908
+ get name(): string;
909
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
910
+ get lastModified(): number;
911
+ }
912
+ declare interface FileOptions {
913
+ type?: string;
914
+ lastModified?: number;
915
+ }
916
+ declare abstract class CacheStorage {
917
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */
918
+ open(cacheName: string): Promise<Cache>;
919
+ readonly default: Cache;
920
+ }
921
+ declare abstract class Cache {
922
+ delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
923
+ match(
924
+ request: RequestInfo,
925
+ options?: CacheQueryOptions,
926
+ ): Promise<Response | undefined>;
927
+ put(request: RequestInfo, response: Response): Promise<void>;
928
+ }
929
+ declare interface CacheQueryOptions {
930
+ ignoreMethod?: boolean;
931
+ }
932
+ declare abstract class Crypto {
933
+ /**
934
+ * Available only in secure contexts.
935
+ *
936
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
937
+ */
938
+ get subtle(): SubtleCrypto;
939
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
940
+ getRandomValues<
941
+ T extends
942
+ | Int8Array
943
+ | Uint8Array
944
+ | Int16Array
945
+ | Uint16Array
946
+ | Int32Array
947
+ | Uint32Array
948
+ | BigInt64Array
949
+ | BigUint64Array,
950
+ >(buffer: T): T;
951
+ /**
952
+ * Available only in secure contexts.
953
+ *
954
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
955
+ */
956
+ randomUUID(): string;
957
+ DigestStream: typeof DigestStream;
958
+ }
959
+ declare abstract class SubtleCrypto {
960
+ encrypt(
961
+ algorithm: string | SubtleCryptoEncryptAlgorithm,
962
+ key: CryptoKey,
963
+ plainText: ArrayBuffer | ArrayBufferView,
964
+ ): Promise<ArrayBuffer>;
965
+ decrypt(
966
+ algorithm: string | SubtleCryptoEncryptAlgorithm,
967
+ key: CryptoKey,
968
+ cipherText: ArrayBuffer | ArrayBufferView,
969
+ ): Promise<ArrayBuffer>;
970
+ sign(
971
+ algorithm: string | SubtleCryptoSignAlgorithm,
972
+ key: CryptoKey,
973
+ data: ArrayBuffer | ArrayBufferView,
974
+ ): Promise<ArrayBuffer>;
975
+ verify(
976
+ algorithm: string | SubtleCryptoSignAlgorithm,
977
+ key: CryptoKey,
978
+ signature: ArrayBuffer | ArrayBufferView,
979
+ data: ArrayBuffer | ArrayBufferView,
980
+ ): Promise<boolean>;
981
+ digest(
982
+ algorithm: string | SubtleCryptoHashAlgorithm,
983
+ data: ArrayBuffer | ArrayBufferView,
984
+ ): Promise<ArrayBuffer>;
985
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */
986
+ generateKey(
987
+ algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
988
+ extractable: boolean,
989
+ keyUsages: string[],
990
+ ): Promise<CryptoKey | CryptoKeyPair>;
991
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */
992
+ deriveKey(
993
+ algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
994
+ baseKey: CryptoKey,
995
+ derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
996
+ extractable: boolean,
997
+ keyUsages: string[],
998
+ ): Promise<CryptoKey>;
999
+ deriveBits(
1000
+ algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1001
+ baseKey: CryptoKey,
1002
+ length: number | null,
1003
+ ): Promise<ArrayBuffer>;
1004
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */
1005
+ importKey(
1006
+ format: string,
1007
+ keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
1008
+ algorithm: string | SubtleCryptoImportKeyAlgorithm,
1009
+ extractable: boolean,
1010
+ keyUsages: string[],
1011
+ ): Promise<CryptoKey>;
1012
+ exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1013
+ wrapKey(
1014
+ format: string,
1015
+ key: CryptoKey,
1016
+ wrappingKey: CryptoKey,
1017
+ wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1018
+ ): Promise<ArrayBuffer>;
1019
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */
1020
+ unwrapKey(
1021
+ format: string,
1022
+ wrappedKey: ArrayBuffer | ArrayBufferView,
1023
+ unwrappingKey: CryptoKey,
1024
+ unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1025
+ unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1026
+ extractable: boolean,
1027
+ keyUsages: string[],
1028
+ ): Promise<CryptoKey>;
1029
+ timingSafeEqual(
1030
+ a: ArrayBuffer | ArrayBufferView,
1031
+ b: ArrayBuffer | ArrayBufferView,
1032
+ ): boolean;
1033
+ }
1034
+ declare abstract class CryptoKey {
1035
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */
1036
+ readonly type: string;
1037
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */
1038
+ readonly extractable: boolean;
1039
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */
1040
+ readonly algorithm:
1041
+ | CryptoKeyKeyAlgorithm
1042
+ | CryptoKeyAesKeyAlgorithm
1043
+ | CryptoKeyHmacKeyAlgorithm
1044
+ | CryptoKeyRsaKeyAlgorithm
1045
+ | CryptoKeyEllipticKeyAlgorithm
1046
+ | CryptoKeyArbitraryKeyAlgorithm;
1047
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */
1048
+ readonly usages: string[];
1049
+ }
1050
+ declare interface CryptoKeyPair {
1051
+ publicKey: CryptoKey;
1052
+ privateKey: CryptoKey;
1053
+ }
1054
+ declare interface JsonWebKey {
1055
+ kty: string;
1056
+ use?: string;
1057
+ key_ops?: string[];
1058
+ alg?: string;
1059
+ ext?: boolean;
1060
+ crv?: string;
1061
+ x?: string;
1062
+ y?: string;
1063
+ d?: string;
1064
+ n?: string;
1065
+ e?: string;
1066
+ p?: string;
1067
+ q?: string;
1068
+ dp?: string;
1069
+ dq?: string;
1070
+ qi?: string;
1071
+ oth?: RsaOtherPrimesInfo[];
1072
+ k?: string;
1073
+ }
1074
+ declare interface RsaOtherPrimesInfo {
1075
+ r?: string;
1076
+ d?: string;
1077
+ t?: string;
1078
+ }
1079
+ declare interface SubtleCryptoDeriveKeyAlgorithm {
1080
+ name: string;
1081
+ salt?: ArrayBuffer;
1082
+ iterations?: number;
1083
+ hash?: string | SubtleCryptoHashAlgorithm;
1084
+ $public?: CryptoKey;
1085
+ info?: ArrayBuffer;
1086
+ }
1087
+ declare interface SubtleCryptoEncryptAlgorithm {
1088
+ name: string;
1089
+ iv?: ArrayBuffer;
1090
+ additionalData?: ArrayBuffer;
1091
+ tagLength?: number;
1092
+ counter?: ArrayBuffer;
1093
+ length?: number;
1094
+ label?: ArrayBuffer;
1095
+ }
1096
+ declare interface SubtleCryptoGenerateKeyAlgorithm {
1097
+ name: string;
1098
+ hash?: string | SubtleCryptoHashAlgorithm;
1099
+ modulusLength?: number;
1100
+ publicExponent?: ArrayBuffer;
1101
+ length?: number;
1102
+ namedCurve?: string;
1103
+ }
1104
+ declare interface SubtleCryptoHashAlgorithm {
1105
+ name: string;
1106
+ }
1107
+ declare interface SubtleCryptoImportKeyAlgorithm {
1108
+ name: string;
1109
+ hash?: string | SubtleCryptoHashAlgorithm;
1110
+ length?: number;
1111
+ namedCurve?: string;
1112
+ compressed?: boolean;
1113
+ }
1114
+ declare interface SubtleCryptoSignAlgorithm {
1115
+ name: string;
1116
+ hash?: string | SubtleCryptoHashAlgorithm;
1117
+ dataLength?: number;
1118
+ saltLength?: number;
1119
+ }
1120
+ declare interface CryptoKeyKeyAlgorithm {
1121
+ name: string;
1122
+ }
1123
+ declare interface CryptoKeyAesKeyAlgorithm {
1124
+ name: string;
1125
+ length: number;
1126
+ }
1127
+ declare interface CryptoKeyHmacKeyAlgorithm {
1128
+ name: string;
1129
+ hash: CryptoKeyKeyAlgorithm;
1130
+ length: number;
1131
+ }
1132
+ declare interface CryptoKeyRsaKeyAlgorithm {
1133
+ name: string;
1134
+ modulusLength: number;
1135
+ publicExponent: ArrayBuffer | (ArrayBuffer | ArrayBufferView);
1136
+ hash?: CryptoKeyKeyAlgorithm;
1137
+ }
1138
+ declare interface CryptoKeyEllipticKeyAlgorithm {
1139
+ name: string;
1140
+ namedCurve: string;
1141
+ }
1142
+ declare interface CryptoKeyArbitraryKeyAlgorithm {
1143
+ name: string;
1144
+ hash?: CryptoKeyKeyAlgorithm;
1145
+ namedCurve?: string;
1146
+ length?: number;
1147
+ }
1148
+ declare class DigestStream extends WritableStream<
1149
+ ArrayBuffer | ArrayBufferView
1150
+ > {
1151
+ constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1152
+ get digest(): Promise<ArrayBuffer>;
1153
+ get bytesWritten(): number | bigint;
1154
+ }
1155
+ declare class TextDecoder {
1156
+ constructor(decoder?: string, options?: TextDecoderConstructorOptions);
1157
+ /**
1158
+ * Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments.
1159
+ *
1160
+ * ```
1161
+ * var string = "", decoder = new TextDecoder(encoding), buffer;
1162
+ * while(buffer = next_chunk()) {
1163
+ * string += decoder.decode(buffer, {stream:true});
1164
+ * }
1165
+ * string += decoder.decode(); // end-of-queue
1166
+ * ```
1167
+ *
1168
+ * If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError.
1169
+ *
1170
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1171
+ */
1172
+ decode(
1173
+ input?: ArrayBuffer | ArrayBufferView,
1174
+ options?: TextDecoderDecodeOptions,
1175
+ ): string;
1176
+ get encoding(): string;
1177
+ get fatal(): boolean;
1178
+ get ignoreBOM(): boolean;
1179
+ }
1180
+ declare class TextEncoder {
1181
+ constructor();
1182
+ /**
1183
+ * Returns the result of running UTF-8's encoder.
1184
+ *
1185
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1186
+ */
1187
+ encode(input?: string): Uint8Array;
1188
+ /**
1189
+ * Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as an object wherein read is the number of converted code units of source and written is the number of bytes modified in destination.
1190
+ *
1191
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1192
+ */
1193
+ encodeInto(
1194
+ input: string,
1195
+ buffer: ArrayBuffer | ArrayBufferView,
1196
+ ): TextEncoderEncodeIntoResult;
1197
+ get encoding(): string;
1198
+ }
1199
+ declare interface TextDecoderConstructorOptions {
1200
+ fatal: boolean;
1201
+ ignoreBOM: boolean;
1202
+ }
1203
+ declare interface TextDecoderDecodeOptions {
1204
+ stream: boolean;
1205
+ }
1206
+ declare interface TextEncoderEncodeIntoResult {
1207
+ read: number;
1208
+ written: number;
1209
+ }
1210
+ declare class ErrorEvent extends Event {
1211
+ constructor(type: string, init?: ErrorEventErrorEventInit);
1212
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */
1213
+ get filename(): string;
1214
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */
1215
+ get message(): string;
1216
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */
1217
+ get lineno(): number;
1218
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */
1219
+ get colno(): number;
1220
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */
1221
+ get error(): any;
1222
+ }
1223
+ declare interface ErrorEventErrorEventInit {
1224
+ message?: string;
1225
+ filename?: string;
1226
+ lineno?: number;
1227
+ colno?: number;
1228
+ error?: any;
1229
+ }
1230
+ declare class FormData {
1231
+ constructor();
1232
+ append(name: string, value: string): void;
1233
+ append(name: string, value: Blob, filename?: string): void;
1234
+ delete(name: string): void;
1235
+ get(name: string): (File | string) | null;
1236
+ getAll(name: string): (File | string)[];
1237
+ has(name: string): boolean;
1238
+ set(name: string, value: string): void;
1239
+ set(name: string, value: Blob, filename?: string): void;
1240
+ /** Returns an array of key, value pairs for every entry in the list. */
1241
+ entries(): IterableIterator<[key: string, value: File | string]>;
1242
+ /** Returns a list of keys in the list. */
1243
+ keys(): IterableIterator<string>;
1244
+ /** Returns a list of values in the list. */
1245
+ values(): IterableIterator<File | string>;
1246
+ forEach<This = unknown>(
1247
+ callback: (
1248
+ this: This,
1249
+ value: File | string,
1250
+ key: string,
1251
+ parent: FormData,
1252
+ ) => void,
1253
+ thisArg?: This,
1254
+ ): void;
1255
+ [Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
1256
+ }
1257
+ declare interface ContentOptions {
1258
+ html?: boolean;
1259
+ }
1260
+ declare class HTMLRewriter {
1261
+ constructor();
1262
+ on(
1263
+ selector: string,
1264
+ handlers: HTMLRewriterElementContentHandlers,
1265
+ ): HTMLRewriter;
1266
+ onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1267
+ transform(response: Response): Response;
1268
+ }
1269
+ declare interface HTMLRewriterElementContentHandlers {
1270
+ element?(element: Element): void | Promise<void>;
1271
+ comments?(comment: Comment): void | Promise<void>;
1272
+ text?(element: Text): void | Promise<void>;
1273
+ }
1274
+ declare interface HTMLRewriterDocumentContentHandlers {
1275
+ doctype?(doctype: Doctype): void | Promise<void>;
1276
+ comments?(comment: Comment): void | Promise<void>;
1277
+ text?(text: Text): void | Promise<void>;
1278
+ end?(end: DocumentEnd): void | Promise<void>;
1279
+ }
1280
+ declare interface Doctype {
1281
+ readonly name: string | null;
1282
+ readonly publicId: string | null;
1283
+ readonly systemId: string | null;
1284
+ }
1285
+ declare interface Element {
1286
+ tagName: string;
1287
+ readonly attributes: IterableIterator<string[]>;
1288
+ readonly removed: boolean;
1289
+ readonly namespaceURI: string;
1290
+ getAttribute(name: string): string | null;
1291
+ hasAttribute(name: string): boolean;
1292
+ setAttribute(name: string, value: string): Element;
1293
+ removeAttribute(name: string): Element;
1294
+ before(content: string, options?: ContentOptions): Element;
1295
+ after(content: string, options?: ContentOptions): Element;
1296
+ prepend(content: string, options?: ContentOptions): Element;
1297
+ append(content: string, options?: ContentOptions): Element;
1298
+ replace(content: string, options?: ContentOptions): Element;
1299
+ remove(): Element;
1300
+ removeAndKeepContent(): Element;
1301
+ setInnerContent(content: string, options?: ContentOptions): Element;
1302
+ onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1303
+ }
1304
+ declare interface EndTag {
1305
+ name: string;
1306
+ before(content: string, options?: ContentOptions): EndTag;
1307
+ after(content: string, options?: ContentOptions): EndTag;
1308
+ remove(): EndTag;
1309
+ }
1310
+ declare interface Comment {
1311
+ text: string;
1312
+ readonly removed: boolean;
1313
+ before(content: string, options?: ContentOptions): Comment;
1314
+ after(content: string, options?: ContentOptions): Comment;
1315
+ replace(content: string, options?: ContentOptions): Comment;
1316
+ remove(): Comment;
1317
+ }
1318
+ declare interface Text {
1319
+ readonly text: string;
1320
+ readonly lastInTextNode: boolean;
1321
+ readonly removed: boolean;
1322
+ before(content: string, options?: ContentOptions): Text;
1323
+ after(content: string, options?: ContentOptions): Text;
1324
+ replace(content: string, options?: ContentOptions): Text;
1325
+ remove(): Text;
1326
+ }
1327
+ declare interface DocumentEnd {
1328
+ append(content: string, options?: ContentOptions): DocumentEnd;
1329
+ }
1330
+ declare abstract class FetchEvent extends ExtendableEvent {
1331
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */
1332
+ readonly request: Request;
1333
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) */
1334
+ respondWith(promise: Response | Promise<Response>): void;
1335
+ passThroughOnException(): void;
1336
+ }
1337
+ declare type HeadersInit =
1338
+ | Headers
1339
+ | Iterable<Iterable<string>>
1340
+ | Record<string, string>;
1341
+ declare class Headers {
1342
+ constructor(init?: HeadersInit);
1343
+ get(name: string): string | null;
1344
+ getAll(name: string): string[];
1345
+ getSetCookie(): string[];
1346
+ has(name: string): boolean;
1347
+ set(name: string, value: string): void;
1348
+ append(name: string, value: string): void;
1349
+ delete(name: string): void;
1350
+ forEach<This = unknown>(
1351
+ callback: (this: This, value: string, key: string, parent: Headers) => void,
1352
+ thisArg?: This,
1353
+ ): void;
1354
+ /** Returns an iterator allowing to go through all key/value pairs contained in this object. */
1355
+ entries(): IterableIterator<[key: string, value: string]>;
1356
+ /** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
1357
+ keys(): IterableIterator<string>;
1358
+ /** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
1359
+ values(): IterableIterator<string>;
1360
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
1361
+ }
1362
+ declare type BodyInit =
1363
+ | ReadableStream<Uint8Array>
1364
+ | string
1365
+ | ArrayBuffer
1366
+ | ArrayBufferView
1367
+ | Blob
1368
+ | URLSearchParams
1369
+ | FormData;
1370
+ declare abstract class Body {
1371
+ get body(): ReadableStream | null;
1372
+ get bodyUsed(): boolean;
1373
+ arrayBuffer(): Promise<ArrayBuffer>;
1374
+ text(): Promise<string>;
1375
+ json<T>(): Promise<T>;
1376
+ formData(): Promise<FormData>;
1377
+ blob(): Promise<Blob>;
1378
+ }
1379
+ declare class Response extends Body {
1380
+ constructor(body?: BodyInit | null, init?: ResponseInit);
1381
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1382
+ static redirect(url: string, status?: number): Response;
1383
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
1384
+ static json(any: any, maybeInit?: ResponseInit | Response): Response;
1385
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
1386
+ clone(): Response;
1387
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
1388
+ get status(): number;
1389
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
1390
+ get statusText(): string;
1391
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
1392
+ get headers(): Headers;
1393
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
1394
+ get ok(): boolean;
1395
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
1396
+ get redirected(): boolean;
1397
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
1398
+ get url(): string;
1399
+ get webSocket(): WebSocket | null;
1400
+ get cf(): any | undefined;
1401
+ }
1402
+ declare interface ResponseInit {
1403
+ status?: number;
1404
+ statusText?: string;
1405
+ headers?: HeadersInit;
1406
+ cf?: any;
1407
+ webSocket?: WebSocket | null;
1408
+ encodeBody?: "automatic" | "manual";
1409
+ }
1410
+ declare type RequestInfo<
1411
+ CfHostMetadata = unknown,
1412
+ Cf = CfProperties<CfHostMetadata>,
1413
+ > = Request<CfHostMetadata, Cf> | string | URL;
1414
+ declare class Request<
1415
+ CfHostMetadata = unknown,
1416
+ Cf = CfProperties<CfHostMetadata>,
1417
+ > extends Body {
1418
+ constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1419
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
1420
+ clone(): Request<CfHostMetadata, Cf>;
1421
+ /**
1422
+ * Returns request's HTTP method, which is "GET" by default.
1423
+ *
1424
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1425
+ */
1426
+ get method(): string;
1427
+ /**
1428
+ * Returns the URL of request as a string.
1429
+ *
1430
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1431
+ */
1432
+ get url(): string;
1433
+ /**
1434
+ * Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
1435
+ *
1436
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1437
+ */
1438
+ get headers(): Headers;
1439
+ /**
1440
+ * Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.
1441
+ *
1442
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1443
+ */
1444
+ get redirect(): string;
1445
+ get fetcher(): Fetcher | null;
1446
+ /**
1447
+ * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
1448
+ *
1449
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1450
+ */
1451
+ get signal(): AbortSignal;
1452
+ get cf(): Cf | undefined;
1453
+ /**
1454
+ * Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]
1455
+ *
1456
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1457
+ */
1458
+ get integrity(): string;
1459
+ /**
1460
+ * Returns a boolean indicating whether or not request can outlive the global in which it was created.
1461
+ *
1462
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1463
+ */
1464
+ get keepalive(): boolean;
1465
+ }
1466
+ declare interface RequestInit<Cf = CfProperties> {
1467
+ /** A string to set request's method. */
1468
+ method?: string;
1469
+ /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1470
+ headers?: HeadersInit;
1471
+ /** A BodyInit object or null to set request's body. */
1472
+ body?: BodyInit | null;
1473
+ /** 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. */
1474
+ redirect?: string;
1475
+ fetcher?: Fetcher | null;
1476
+ cf?: Cf;
1477
+ /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1478
+ integrity?: string;
1479
+ /** An AbortSignal to set request's signal. */
1480
+ signal?: AbortSignal | null;
1481
+ }
1482
+ declare type Service<
1483
+ T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
1484
+ > = Fetcher<T>;
1485
+ declare type Fetcher<
1486
+ T extends Rpc.EntrypointBranded | undefined = undefined,
1487
+ Reserved extends string = never,
1488
+ > = (T extends Rpc.EntrypointBranded
1489
+ ? Rpc.Provider<T, Reserved | "fetch" | "connect">
1490
+ : unknown) & {
1491
+ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1492
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1493
+ };
1494
+ declare interface FetcherPutOptions {
1495
+ expiration?: number;
1496
+ expirationTtl?: number;
1497
+ }
1498
+ declare interface KVNamespaceListKey<Metadata, Key extends string = string> {
1499
+ name: Key;
1500
+ expiration?: number;
1501
+ metadata?: Metadata;
1502
+ }
1503
+ declare type KVNamespaceListResult<Metadata, Key extends string = string> =
1504
+ | {
1505
+ list_complete: false;
1506
+ keys: KVNamespaceListKey<Metadata, Key>[];
1507
+ cursor: string;
1508
+ cacheStatus: string | null;
1509
+ }
1510
+ | {
1511
+ list_complete: true;
1512
+ keys: KVNamespaceListKey<Metadata, Key>[];
1513
+ cacheStatus: string | null;
1514
+ };
1515
+ declare interface KVNamespace<Key extends string = string> {
1516
+ get(
1517
+ key: Key,
1518
+ options?: Partial<KVNamespaceGetOptions<undefined>>,
1519
+ ): Promise<string | null>;
1520
+ get(key: Key, type: "text"): Promise<string | null>;
1521
+ get<ExpectedValue = unknown>(
1522
+ key: Key,
1523
+ type: "json",
1524
+ ): Promise<ExpectedValue | null>;
1525
+ get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
1526
+ get(key: Key, type: "stream"): Promise<ReadableStream | null>;
1527
+ get(
1528
+ key: Key,
1529
+ options?: KVNamespaceGetOptions<"text">,
1530
+ ): Promise<string | null>;
1531
+ get<ExpectedValue = unknown>(
1532
+ key: Key,
1533
+ options?: KVNamespaceGetOptions<"json">,
1534
+ ): Promise<ExpectedValue | null>;
1535
+ get(
1536
+ key: Key,
1537
+ options?: KVNamespaceGetOptions<"arrayBuffer">,
1538
+ ): Promise<ArrayBuffer | null>;
1539
+ get(
1540
+ key: Key,
1541
+ options?: KVNamespaceGetOptions<"stream">,
1542
+ ): Promise<ReadableStream | null>;
1543
+ list<Metadata = unknown>(
1544
+ options?: KVNamespaceListOptions,
1545
+ ): Promise<KVNamespaceListResult<Metadata, Key>>;
1546
+ put(
1547
+ key: Key,
1548
+ value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
1549
+ options?: KVNamespacePutOptions,
1550
+ ): Promise<void>;
1551
+ getWithMetadata<Metadata = unknown>(
1552
+ key: Key,
1553
+ options?: Partial<KVNamespaceGetOptions<undefined>>,
1554
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1555
+ getWithMetadata<Metadata = unknown>(
1556
+ key: Key,
1557
+ type: "text",
1558
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1559
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
1560
+ key: Key,
1561
+ type: "json",
1562
+ ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1563
+ getWithMetadata<Metadata = unknown>(
1564
+ key: Key,
1565
+ type: "arrayBuffer",
1566
+ ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1567
+ getWithMetadata<Metadata = unknown>(
1568
+ key: Key,
1569
+ type: "stream",
1570
+ ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1571
+ getWithMetadata<Metadata = unknown>(
1572
+ key: Key,
1573
+ options: KVNamespaceGetOptions<"text">,
1574
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1575
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
1576
+ key: Key,
1577
+ options: KVNamespaceGetOptions<"json">,
1578
+ ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1579
+ getWithMetadata<Metadata = unknown>(
1580
+ key: Key,
1581
+ options: KVNamespaceGetOptions<"arrayBuffer">,
1582
+ ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1583
+ getWithMetadata<Metadata = unknown>(
1584
+ key: Key,
1585
+ options: KVNamespaceGetOptions<"stream">,
1586
+ ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1587
+ delete(key: Key): Promise<void>;
1588
+ }
1589
+ declare interface KVNamespaceListOptions {
1590
+ limit?: number;
1591
+ prefix?: string | null;
1592
+ cursor?: string | null;
1593
+ }
1594
+ declare interface KVNamespaceGetOptions<Type> {
1595
+ type: Type;
1596
+ cacheTtl?: number;
1597
+ }
1598
+ declare interface KVNamespacePutOptions {
1599
+ expiration?: number;
1600
+ expirationTtl?: number;
1601
+ metadata?: any | null;
1602
+ }
1603
+ declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1604
+ value: Value | null;
1605
+ metadata: Metadata | null;
1606
+ cacheStatus: string | null;
1607
+ }
1608
+ declare type QueueContentType = "text" | "bytes" | "json" | "v8";
1609
+ declare interface Queue<Body = unknown> {
1610
+ send(message: Body, options?: QueueSendOptions): Promise<void>;
1611
+ sendBatch(
1612
+ messages: Iterable<MessageSendRequest<Body>>,
1613
+ options?: QueueSendBatchOptions,
1614
+ ): Promise<void>;
1615
+ }
1616
+ declare interface QueueSendOptions {
1617
+ contentType?: QueueContentType;
1618
+ delaySeconds?: number;
1619
+ }
1620
+ declare interface QueueSendBatchOptions {
1621
+ delaySeconds?: number;
1622
+ }
1623
+ declare interface MessageSendRequest<Body = unknown> {
1624
+ body: Body;
1625
+ contentType?: QueueContentType;
1626
+ delaySeconds?: number;
1627
+ }
1628
+ declare interface QueueRetryOptions {
1629
+ delaySeconds?: number;
1630
+ }
1631
+ declare interface Message<Body = unknown> {
1632
+ readonly id: string;
1633
+ readonly timestamp: Date;
1634
+ readonly body: Body;
1635
+ readonly attempts: number;
1636
+ retry(options?: QueueRetryOptions): void;
1637
+ ack(): void;
1638
+ }
1639
+ declare interface QueueEvent<Body = unknown> extends ExtendableEvent {
1640
+ readonly messages: readonly Message<Body>[];
1641
+ readonly queue: string;
1642
+ retryAll(options?: QueueRetryOptions): void;
1643
+ ackAll(): void;
1644
+ }
1645
+ declare interface MessageBatch<Body = unknown> {
1646
+ readonly messages: readonly Message<Body>[];
1647
+ readonly queue: string;
1648
+ retryAll(options?: QueueRetryOptions): void;
1649
+ ackAll(): void;
1650
+ }
1651
+ declare interface R2Error extends Error {
1652
+ readonly name: string;
1653
+ readonly code: number;
1654
+ readonly message: string;
1655
+ readonly action: string;
1656
+ readonly stack: any;
1657
+ }
1658
+ declare interface R2ListOptions {
1659
+ limit?: number;
1660
+ prefix?: string;
1661
+ cursor?: string;
1662
+ delimiter?: string;
1663
+ startAfter?: string;
1664
+ include?: ("httpMetadata" | "customMetadata")[];
1665
+ }
1666
+ declare abstract class R2Bucket {
1667
+ head(key: string): Promise<R2Object | null>;
1668
+ get(
1669
+ key: string,
1670
+ options: R2GetOptions & {
1671
+ onlyIf: R2Conditional | Headers;
1672
+ },
1673
+ ): Promise<R2ObjectBody | R2Object | null>;
1674
+ get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1675
+ put(
1676
+ key: string,
1677
+ value:
1678
+ | ReadableStream
1679
+ | ArrayBuffer
1680
+ | ArrayBufferView
1681
+ | string
1682
+ | null
1683
+ | Blob,
1684
+ options?: R2PutOptions & {
1685
+ onlyIf: R2Conditional | Headers;
1686
+ },
1687
+ ): Promise<R2Object | null>;
1688
+ put(
1689
+ key: string,
1690
+ value:
1691
+ | ReadableStream
1692
+ | ArrayBuffer
1693
+ | ArrayBufferView
1694
+ | string
1695
+ | null
1696
+ | Blob,
1697
+ options?: R2PutOptions,
1698
+ ): Promise<R2Object>;
1699
+ createMultipartUpload(
1700
+ key: string,
1701
+ options?: R2MultipartOptions,
1702
+ ): Promise<R2MultipartUpload>;
1703
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1704
+ delete(keys: string | string[]): Promise<void>;
1705
+ list(options?: R2ListOptions): Promise<R2Objects>;
1706
+ }
1707
+ declare interface R2MultipartUpload {
1708
+ readonly key: string;
1709
+ readonly uploadId: string;
1710
+ uploadPart(
1711
+ partNumber: number,
1712
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
1713
+ ): Promise<R2UploadedPart>;
1714
+ abort(): Promise<void>;
1715
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1716
+ }
1717
+ declare interface R2UploadedPart {
1718
+ partNumber: number;
1719
+ etag: string;
1720
+ }
1721
+ declare abstract class R2Object {
1722
+ readonly key: string;
1723
+ readonly version: string;
1724
+ readonly size: number;
1725
+ readonly etag: string;
1726
+ readonly httpEtag: string;
1727
+ readonly checksums: R2Checksums;
1728
+ readonly uploaded: Date;
1729
+ readonly httpMetadata?: R2HTTPMetadata;
1730
+ readonly customMetadata?: Record<string, string>;
1731
+ readonly range?: R2Range;
1732
+ readonly storageClass: string;
1733
+ writeHttpMetadata(headers: Headers): void;
1734
+ }
1735
+ declare interface R2ObjectBody extends R2Object {
1736
+ get body(): ReadableStream;
1737
+ get bodyUsed(): boolean;
1738
+ arrayBuffer(): Promise<ArrayBuffer>;
1739
+ text(): Promise<string>;
1740
+ json<T>(): Promise<T>;
1741
+ blob(): Promise<Blob>;
1742
+ }
1743
+ declare type R2Range =
1744
+ | {
1745
+ offset: number;
1746
+ length?: number;
1747
+ }
1748
+ | {
1749
+ offset?: number;
1750
+ length: number;
1751
+ }
1752
+ | {
1753
+ suffix: number;
1754
+ };
1755
+ declare interface R2Conditional {
1756
+ etagMatches?: string;
1757
+ etagDoesNotMatch?: string;
1758
+ uploadedBefore?: Date;
1759
+ uploadedAfter?: Date;
1760
+ secondsGranularity?: boolean;
1761
+ }
1762
+ declare interface R2GetOptions {
1763
+ onlyIf?: R2Conditional | Headers;
1764
+ range?: R2Range | Headers;
1765
+ }
1766
+ declare interface R2PutOptions {
1767
+ onlyIf?: R2Conditional | Headers;
1768
+ httpMetadata?: R2HTTPMetadata | Headers;
1769
+ customMetadata?: Record<string, string>;
1770
+ md5?: ArrayBuffer | string;
1771
+ sha1?: ArrayBuffer | string;
1772
+ sha256?: ArrayBuffer | string;
1773
+ sha384?: ArrayBuffer | string;
1774
+ sha512?: ArrayBuffer | string;
1775
+ storageClass?: string;
1776
+ }
1777
+ declare interface R2MultipartOptions {
1778
+ httpMetadata?: R2HTTPMetadata | Headers;
1779
+ customMetadata?: Record<string, string>;
1780
+ storageClass?: string;
1781
+ }
1782
+ declare interface R2Checksums {
1783
+ readonly md5?: ArrayBuffer;
1784
+ readonly sha1?: ArrayBuffer;
1785
+ readonly sha256?: ArrayBuffer;
1786
+ readonly sha384?: ArrayBuffer;
1787
+ readonly sha512?: ArrayBuffer;
1788
+ toJSON(): R2StringChecksums;
1789
+ }
1790
+ declare interface R2StringChecksums {
1791
+ md5?: string;
1792
+ sha1?: string;
1793
+ sha256?: string;
1794
+ sha384?: string;
1795
+ sha512?: string;
1796
+ }
1797
+ declare interface R2HTTPMetadata {
1798
+ contentType?: string;
1799
+ contentLanguage?: string;
1800
+ contentDisposition?: string;
1801
+ contentEncoding?: string;
1802
+ cacheControl?: string;
1803
+ cacheExpiry?: Date;
1804
+ }
1805
+ declare type R2Objects = {
1806
+ objects: R2Object[];
1807
+ delimitedPrefixes: string[];
1808
+ } & (
1809
+ | {
1810
+ truncated: true;
1811
+ cursor: string;
1812
+ }
1813
+ | {
1814
+ truncated: false;
1815
+ }
1816
+ );
1817
+ declare abstract class ScheduledEvent extends ExtendableEvent {
1818
+ readonly scheduledTime: number;
1819
+ readonly cron: string;
1820
+ noRetry(): void;
1821
+ }
1822
+ declare interface ScheduledController {
1823
+ readonly scheduledTime: number;
1824
+ readonly cron: string;
1825
+ noRetry(): void;
1826
+ }
1827
+ declare interface QueuingStrategy<T = any> {
1828
+ highWaterMark?: number | bigint;
1829
+ size?: (chunk: T) => number | bigint;
1830
+ }
1831
+ declare interface UnderlyingSink<W = any> {
1832
+ type?: string;
1833
+ start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
1834
+ write?: (
1835
+ chunk: W,
1836
+ controller: WritableStreamDefaultController,
1837
+ ) => void | Promise<void>;
1838
+ abort?: (reason: any) => void | Promise<void>;
1839
+ close?: () => void | Promise<void>;
1840
+ }
1841
+ declare interface UnderlyingByteSource {
1842
+ type: "bytes";
1843
+ autoAllocateChunkSize?: number;
1844
+ start?: (controller: ReadableByteStreamController) => void | Promise<void>;
1845
+ pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
1846
+ cancel?: (reason: any) => void | Promise<void>;
1847
+ }
1848
+ declare interface UnderlyingSource<R = any> {
1849
+ type?: "" | undefined;
1850
+ start?: (
1851
+ controller: ReadableStreamDefaultController<R>,
1852
+ ) => void | Promise<void>;
1853
+ pull?: (
1854
+ controller: ReadableStreamDefaultController<R>,
1855
+ ) => void | Promise<void>;
1856
+ cancel?: (reason: any) => void | Promise<void>;
1857
+ expectedLength?: number | bigint;
1858
+ }
1859
+ declare interface Transformer<I = any, O = any> {
1860
+ readableType?: string;
1861
+ writableType?: string;
1862
+ start?: (
1863
+ controller: TransformStreamDefaultController<O>,
1864
+ ) => void | Promise<void>;
1865
+ transform?: (
1866
+ chunk: I,
1867
+ controller: TransformStreamDefaultController<O>,
1868
+ ) => void | Promise<void>;
1869
+ flush?: (
1870
+ controller: TransformStreamDefaultController<O>,
1871
+ ) => void | Promise<void>;
1872
+ cancel?: (reason: any) => void | Promise<void>;
1873
+ expectedLength?: number;
1874
+ }
1875
+ declare interface StreamPipeOptions {
1876
+ /**
1877
+ * 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.
1878
+ *
1879
+ * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1880
+ *
1881
+ * Errors and closures of the source and destination streams propagate as follows:
1882
+ *
1883
+ * 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.
1884
+ *
1885
+ * 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.
1886
+ *
1887
+ * 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.
1888
+ *
1889
+ * 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.
1890
+ *
1891
+ * 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.
1892
+ */
1893
+ preventClose?: boolean;
1894
+ preventAbort?: boolean;
1895
+ preventCancel?: boolean;
1896
+ signal?: AbortSignal;
1897
+ }
1898
+ declare type ReadableStreamReadResult<R = any> =
1899
+ | {
1900
+ done: false;
1901
+ value: R;
1902
+ }
1903
+ | {
1904
+ done: true;
1905
+ value?: undefined;
1906
+ };
1907
+ /**
1908
+ * 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.
1909
+ *
1910
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
1911
+ */
1912
+ declare interface ReadableStream<R = any> {
1913
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked) */
1914
+ get locked(): boolean;
1915
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel) */
1916
+ cancel(reason?: any): Promise<void>;
1917
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
1918
+ getReader(): ReadableStreamDefaultReader<R>;
1919
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
1920
+ getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
1921
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough) */
1922
+ pipeThrough<T>(
1923
+ transform: ReadableWritablePair<T, R>,
1924
+ options?: StreamPipeOptions,
1925
+ ): ReadableStream<T>;
1926
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo) */
1927
+ pipeTo(
1928
+ destination: WritableStream<R>,
1929
+ options?: StreamPipeOptions,
1930
+ ): Promise<void>;
1931
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee) */
1932
+ tee(): [ReadableStream<R>, ReadableStream<R>];
1933
+ values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
1934
+ [Symbol.asyncIterator](
1935
+ options?: ReadableStreamValuesOptions,
1936
+ ): AsyncIterableIterator<R>;
1937
+ }
1938
+ declare const ReadableStream: {
1939
+ prototype: ReadableStream;
1940
+ new (
1941
+ underlyingSource: UnderlyingByteSource,
1942
+ strategy?: QueuingStrategy<Uint8Array>,
1943
+ ): ReadableStream<Uint8Array>;
1944
+ new <R = any>(
1945
+ underlyingSource?: UnderlyingSource<R>,
1946
+ strategy?: QueuingStrategy<R>,
1947
+ ): ReadableStream<R>;
1948
+ };
1949
+ declare class ReadableStreamDefaultReader<R = any> {
1950
+ constructor(stream: ReadableStream);
1951
+ get closed(): Promise<void>;
1952
+ cancel(reason?: any): Promise<void>;
1953
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read) */
1954
+ read(): Promise<ReadableStreamReadResult<R>>;
1955
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock) */
1956
+ releaseLock(): void;
1957
+ }
1958
+ declare class ReadableStreamBYOBReader {
1959
+ constructor(stream: ReadableStream);
1960
+ get closed(): Promise<void>;
1961
+ cancel(reason?: any): Promise<void>;
1962
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
1963
+ read<T extends ArrayBufferView>(
1964
+ view: T,
1965
+ ): Promise<ReadableStreamReadResult<T>>;
1966
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
1967
+ releaseLock(): void;
1968
+ readAtLeast<T extends ArrayBufferView>(
1969
+ minElements: number,
1970
+ view: T,
1971
+ ): Promise<ReadableStreamReadResult<T>>;
1972
+ }
1973
+ declare interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
1974
+ min?: number;
1975
+ }
1976
+ declare interface ReadableStreamGetReaderOptions {
1977
+ /**
1978
+ * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
1979
+ *
1980
+ * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
1981
+ */
1982
+ mode: "byob";
1983
+ }
1984
+ declare abstract class ReadableStreamBYOBRequest {
1985
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
1986
+ get view(): Uint8Array | null;
1987
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
1988
+ respond(bytesWritten: number): void;
1989
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
1990
+ respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
1991
+ get atLeast(): number | null;
1992
+ }
1993
+ declare abstract class ReadableStreamDefaultController<R = any> {
1994
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize) */
1995
+ get desiredSize(): number | null;
1996
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close) */
1997
+ close(): void;
1998
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue) */
1999
+ enqueue(chunk?: R): void;
2000
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error) */
2001
+ error(reason: any): void;
2002
+ }
2003
+ declare abstract class ReadableByteStreamController {
2004
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest) */
2005
+ get byobRequest(): ReadableStreamBYOBRequest | null;
2006
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize) */
2007
+ get desiredSize(): number | null;
2008
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close) */
2009
+ close(): void;
2010
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue) */
2011
+ enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
2012
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error) */
2013
+ error(reason: any): void;
2014
+ }
2015
+ declare abstract class WritableStreamDefaultController {
2016
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal) */
2017
+ get signal(): AbortSignal;
2018
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error) */
2019
+ error(reason?: any): void;
2020
+ }
2021
+ declare abstract class TransformStreamDefaultController<O = any> {
2022
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize) */
2023
+ get desiredSize(): number | null;
2024
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue) */
2025
+ enqueue(chunk?: O): void;
2026
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error) */
2027
+ error(reason: any): void;
2028
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate) */
2029
+ terminate(): void;
2030
+ }
2031
+ declare interface ReadableWritablePair<R = any, W = any> {
2032
+ /**
2033
+ * 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.
2034
+ *
2035
+ * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2036
+ */
2037
+ writable: WritableStream<W>;
2038
+ readable: ReadableStream<R>;
2039
+ }
2040
+ declare class WritableStream<W = any> {
2041
+ constructor(
2042
+ underlyingSink?: UnderlyingSink,
2043
+ queuingStrategy?: QueuingStrategy,
2044
+ );
2045
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked) */
2046
+ get locked(): boolean;
2047
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort) */
2048
+ abort(reason?: any): Promise<void>;
2049
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close) */
2050
+ close(): Promise<void>;
2051
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter) */
2052
+ getWriter(): WritableStreamDefaultWriter<W>;
2053
+ }
2054
+ declare class WritableStreamDefaultWriter<W = any> {
2055
+ constructor(stream: WritableStream);
2056
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
2057
+ get closed(): Promise<void>;
2058
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
2059
+ get ready(): Promise<void>;
2060
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
2061
+ get desiredSize(): number | null;
2062
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
2063
+ abort(reason?: any): Promise<void>;
2064
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
2065
+ close(): Promise<void>;
2066
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write) */
2067
+ write(chunk?: W): Promise<void>;
2068
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock) */
2069
+ releaseLock(): void;
2070
+ }
2071
+ declare class TransformStream<I = any, O = any> {
2072
+ constructor(
2073
+ transformer?: Transformer<I, O>,
2074
+ writableStrategy?: QueuingStrategy<I>,
2075
+ readableStrategy?: QueuingStrategy<O>,
2076
+ );
2077
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable) */
2078
+ get readable(): ReadableStream<O>;
2079
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable) */
2080
+ get writable(): WritableStream<I>;
2081
+ }
2082
+ declare class FixedLengthStream extends IdentityTransformStream {
2083
+ constructor(
2084
+ expectedLength: number | bigint,
2085
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy,
2086
+ );
2087
+ }
2088
+ declare class IdentityTransformStream extends TransformStream<
2089
+ ArrayBuffer | ArrayBufferView,
2090
+ Uint8Array
2091
+ > {
2092
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2093
+ }
2094
+ declare interface IdentityTransformStreamQueuingStrategy {
2095
+ highWaterMark?: number | bigint;
2096
+ }
2097
+ declare interface ReadableStreamValuesOptions {
2098
+ preventCancel?: boolean;
2099
+ }
2100
+ declare class CompressionStream extends TransformStream<
2101
+ ArrayBuffer | ArrayBufferView,
2102
+ Uint8Array
2103
+ > {
2104
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
2105
+ }
2106
+ declare class DecompressionStream extends TransformStream<
2107
+ ArrayBuffer | ArrayBufferView,
2108
+ Uint8Array
2109
+ > {
2110
+ constructor(format: "gzip" | "deflate" | "deflate-raw");
2111
+ }
2112
+ declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
2113
+ constructor();
2114
+ get encoding(): string;
2115
+ }
2116
+ declare class TextDecoderStream extends TransformStream<
2117
+ ArrayBuffer | ArrayBufferView,
2118
+ string
2119
+ > {
2120
+ constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
2121
+ get encoding(): string;
2122
+ get fatal(): boolean;
2123
+ get ignoreBOM(): boolean;
2124
+ }
2125
+ declare interface TextDecoderStreamTextDecoderStreamInit {
2126
+ fatal?: boolean;
2127
+ ignoreBOM?: boolean;
2128
+ }
2129
+ declare class ByteLengthQueuingStrategy
2130
+ implements QueuingStrategy<ArrayBufferView>
2131
+ {
2132
+ constructor(init: QueuingStrategyInit);
2133
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) */
2134
+ get highWaterMark(): number;
2135
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
2136
+ get size(): (chunk?: any) => number;
2137
+ }
2138
+ declare class CountQueuingStrategy implements QueuingStrategy {
2139
+ constructor(init: QueuingStrategyInit);
2140
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) */
2141
+ get highWaterMark(): number;
2142
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
2143
+ get size(): (chunk?: any) => number;
2144
+ }
2145
+ declare interface QueuingStrategyInit {
2146
+ /**
2147
+ * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
2148
+ *
2149
+ * 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.
2150
+ */
2151
+ highWaterMark: number;
2152
+ }
2153
+ declare interface ScriptVersion {
2154
+ id?: string;
2155
+ tag?: string;
2156
+ message?: string;
2157
+ }
2158
+ declare abstract class TailEvent extends ExtendableEvent {
2159
+ readonly events: TraceItem[];
2160
+ readonly traces: TraceItem[];
2161
+ }
2162
+ declare interface TraceItem {
2163
+ readonly event:
2164
+ | (
2165
+ | TraceItemFetchEventInfo
2166
+ | TraceItemJsRpcEventInfo
2167
+ | TraceItemScheduledEventInfo
2168
+ | TraceItemAlarmEventInfo
2169
+ | TraceItemQueueEventInfo
2170
+ | TraceItemEmailEventInfo
2171
+ | TraceItemTailEventInfo
2172
+ | TraceItemCustomEventInfo
2173
+ | TraceItemHibernatableWebSocketEventInfo
2174
+ )
2175
+ | null;
2176
+ readonly eventTimestamp: number | null;
2177
+ readonly logs: TraceLog[];
2178
+ readonly exceptions: TraceException[];
2179
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
2180
+ readonly scriptName: string | null;
2181
+ readonly entrypoint?: string;
2182
+ readonly scriptVersion?: ScriptVersion;
2183
+ readonly dispatchNamespace?: string;
2184
+ readonly scriptTags?: string[];
2185
+ readonly outcome: string;
2186
+ }
2187
+ declare interface TraceItemAlarmEventInfo {
2188
+ readonly scheduledTime: Date;
2189
+ }
2190
+ declare interface TraceItemCustomEventInfo {}
2191
+ declare interface TraceItemScheduledEventInfo {
2192
+ readonly scheduledTime: number;
2193
+ readonly cron: string;
2194
+ }
2195
+ declare interface TraceItemQueueEventInfo {
2196
+ readonly queue: string;
2197
+ readonly batchSize: number;
2198
+ }
2199
+ declare interface TraceItemEmailEventInfo {
2200
+ readonly mailFrom: string;
2201
+ readonly rcptTo: string;
2202
+ readonly rawSize: number;
2203
+ }
2204
+ declare interface TraceItemTailEventInfo {
2205
+ readonly consumedEvents: TraceItemTailEventInfoTailItem[];
2206
+ }
2207
+ declare interface TraceItemTailEventInfoTailItem {
2208
+ readonly scriptName: string | null;
2209
+ }
2210
+ declare interface TraceItemFetchEventInfo {
2211
+ readonly response?: TraceItemFetchEventInfoResponse;
2212
+ readonly request: TraceItemFetchEventInfoRequest;
2213
+ }
2214
+ declare interface TraceItemFetchEventInfoRequest {
2215
+ readonly cf?: any;
2216
+ readonly headers: Record<string, string>;
2217
+ readonly method: string;
2218
+ readonly url: string;
2219
+ getUnredacted(): TraceItemFetchEventInfoRequest;
2220
+ }
2221
+ declare interface TraceItemFetchEventInfoResponse {
2222
+ readonly status: number;
2223
+ }
2224
+ declare interface TraceItemJsRpcEventInfo {
2225
+ readonly rpcMethod: string;
2226
+ }
2227
+ declare interface TraceItemHibernatableWebSocketEventInfo {
2228
+ readonly getWebSocketEvent:
2229
+ | TraceItemHibernatableWebSocketEventInfoMessage
2230
+ | TraceItemHibernatableWebSocketEventInfoClose
2231
+ | TraceItemHibernatableWebSocketEventInfoError;
2232
+ }
2233
+ declare interface TraceItemHibernatableWebSocketEventInfoMessage {
2234
+ readonly webSocketEventType: string;
2235
+ }
2236
+ declare interface TraceItemHibernatableWebSocketEventInfoClose {
2237
+ readonly webSocketEventType: string;
2238
+ readonly code: number;
2239
+ readonly wasClean: boolean;
2240
+ }
2241
+ declare interface TraceItemHibernatableWebSocketEventInfoError {
2242
+ readonly webSocketEventType: string;
2243
+ }
2244
+ declare interface TraceLog {
2245
+ readonly timestamp: number;
2246
+ readonly level: string;
2247
+ readonly message: any;
2248
+ }
2249
+ declare interface TraceException {
2250
+ readonly timestamp: number;
2251
+ readonly message: string;
2252
+ readonly name: string;
2253
+ readonly stack?: string;
2254
+ }
2255
+ declare interface TraceDiagnosticChannelEvent {
2256
+ readonly timestamp: number;
2257
+ readonly channel: string;
2258
+ readonly message: any;
2259
+ }
2260
+ declare interface TraceMetrics {
2261
+ readonly cpuTime: number;
2262
+ readonly wallTime: number;
2263
+ }
2264
+ declare interface UnsafeTraceMetrics {
2265
+ fromTrace(item: TraceItem): TraceMetrics;
2266
+ }
2267
+ declare class URL {
2268
+ constructor(url: string | URL, base?: string | URL);
2269
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */
2270
+ get origin(): string;
2271
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
2272
+ get href(): string;
2273
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
2274
+ set href(value: string);
2275
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
2276
+ get protocol(): string;
2277
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
2278
+ set protocol(value: string);
2279
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
2280
+ get username(): string;
2281
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
2282
+ set username(value: string);
2283
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
2284
+ get password(): string;
2285
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
2286
+ set password(value: string);
2287
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
2288
+ get host(): string;
2289
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
2290
+ set host(value: string);
2291
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
2292
+ get hostname(): string;
2293
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
2294
+ set hostname(value: string);
2295
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
2296
+ get port(): string;
2297
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
2298
+ set port(value: string);
2299
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
2300
+ get pathname(): string;
2301
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
2302
+ set pathname(value: string);
2303
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
2304
+ get search(): string;
2305
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
2306
+ set search(value: string);
2307
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
2308
+ get hash(): string;
2309
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
2310
+ set hash(value: string);
2311
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */
2312
+ get searchParams(): URLSearchParams;
2313
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */
2314
+ toJSON(): string;
2315
+ toString(): string;
2316
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */
2317
+ static canParse(url: string, base?: string): boolean;
2318
+ static parse(url: string, base?: string): URL | null;
2319
+ }
2320
+ declare class URLSearchParams {
2321
+ constructor(
2322
+ init?: Iterable<Iterable<string>> | Record<string, string> | string,
2323
+ );
2324
+ get size(): number;
2325
+ append(name: string, value: string): void;
2326
+ delete(name: string, value?: string): void;
2327
+ get(name: string): string | null;
2328
+ getAll(name: string): string[];
2329
+ has(name: string, value?: string): boolean;
2330
+ set(name: string, value: string): void;
2331
+ sort(): void;
2332
+ /** Returns an array of key, value pairs for every entry in the search params. */
2333
+ entries(): IterableIterator<[key: string, value: string]>;
2334
+ /** Returns a list of keys in the search params. */
2335
+ keys(): IterableIterator<string>;
2336
+ /** Returns a list of values in the search params. */
2337
+ values(): IterableIterator<string>;
2338
+ forEach<This = unknown>(
2339
+ callback: (
2340
+ this: This,
2341
+ value: string,
2342
+ key: string,
2343
+ parent: URLSearchParams,
2344
+ ) => void,
2345
+ thisArg?: This,
2346
+ ): void;
2347
+ toString(): string;
2348
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
2349
+ }
2350
+ declare class URLPattern {
2351
+ constructor(
2352
+ input?: string | URLPatternURLPatternInit,
2353
+ baseURL?: string,
2354
+ patternOptions?: URLPatternURLPatternOptions,
2355
+ );
2356
+ get protocol(): string;
2357
+ get username(): string;
2358
+ get password(): string;
2359
+ get hostname(): string;
2360
+ get port(): string;
2361
+ get pathname(): string;
2362
+ get search(): string;
2363
+ get hash(): string;
2364
+ test(input?: string | URLPatternURLPatternInit, baseURL?: string): boolean;
2365
+ exec(
2366
+ input?: string | URLPatternURLPatternInit,
2367
+ baseURL?: string,
2368
+ ): URLPatternURLPatternResult | null;
2369
+ }
2370
+ declare interface URLPatternURLPatternInit {
2371
+ protocol?: string;
2372
+ username?: string;
2373
+ password?: string;
2374
+ hostname?: string;
2375
+ port?: string;
2376
+ pathname?: string;
2377
+ search?: string;
2378
+ hash?: string;
2379
+ baseURL?: string;
2380
+ }
2381
+ declare interface URLPatternURLPatternComponentResult {
2382
+ input: string;
2383
+ groups: Record<string, string>;
2384
+ }
2385
+ declare interface URLPatternURLPatternResult {
2386
+ inputs: (string | URLPatternURLPatternInit)[];
2387
+ protocol: URLPatternURLPatternComponentResult;
2388
+ username: URLPatternURLPatternComponentResult;
2389
+ password: URLPatternURLPatternComponentResult;
2390
+ hostname: URLPatternURLPatternComponentResult;
2391
+ port: URLPatternURLPatternComponentResult;
2392
+ pathname: URLPatternURLPatternComponentResult;
2393
+ search: URLPatternURLPatternComponentResult;
2394
+ hash: URLPatternURLPatternComponentResult;
2395
+ }
2396
+ declare interface URLPatternURLPatternOptions {
2397
+ ignoreCase?: boolean;
2398
+ }
2399
+ declare class CloseEvent extends Event {
2400
+ constructor(type: string, initializer?: CloseEventInit);
2401
+ /**
2402
+ * Returns the WebSocket connection close code provided by the server.
2403
+ *
2404
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
2405
+ */
2406
+ readonly code: number;
2407
+ /**
2408
+ * Returns the WebSocket connection close reason provided by the server.
2409
+ *
2410
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
2411
+ */
2412
+ readonly reason: string;
2413
+ /**
2414
+ * Returns true if the connection closed cleanly; false otherwise.
2415
+ *
2416
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
2417
+ */
2418
+ readonly wasClean: boolean;
2419
+ }
2420
+ declare interface CloseEventInit {
2421
+ code?: number;
2422
+ reason?: string;
2423
+ wasClean?: boolean;
2424
+ }
2425
+ declare class MessageEvent extends Event {
2426
+ constructor(type: string, initializer: MessageEventInit);
2427
+ readonly data: ArrayBuffer | string;
2428
+ }
2429
+ declare interface MessageEventInit {
2430
+ data: ArrayBuffer | string;
2431
+ }
2432
+ declare type WebSocketEventMap = {
2433
+ close: CloseEvent;
2434
+ message: MessageEvent;
2435
+ open: Event;
2436
+ error: ErrorEvent;
2437
+ };
2438
+ declare class WebSocket extends EventTarget<WebSocketEventMap> {
2439
+ constructor(url: string, protocols?: string[] | string);
2440
+ accept(): void;
2441
+ /**
2442
+ * Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
2443
+ *
2444
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
2445
+ */
2446
+ send(message: (ArrayBuffer | ArrayBufferView) | string): void;
2447
+ /**
2448
+ * Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.
2449
+ *
2450
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
2451
+ */
2452
+ close(code?: number, reason?: string): void;
2453
+ serializeAttachment(attachment: any): void;
2454
+ deserializeAttachment(): any | null;
2455
+ static readonly READY_STATE_CONNECTING: number;
2456
+ static readonly CONNECTING: number;
2457
+ static readonly READY_STATE_OPEN: number;
2458
+ static readonly OPEN: number;
2459
+ static readonly READY_STATE_CLOSING: number;
2460
+ static readonly CLOSING: number;
2461
+ static readonly READY_STATE_CLOSED: number;
2462
+ static readonly CLOSED: number;
2463
+ /**
2464
+ * Returns the state of the WebSocket object's connection. It can have the values described below.
2465
+ *
2466
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
2467
+ */
2468
+ get readyState(): number;
2469
+ /**
2470
+ * Returns the URL that was used to establish the WebSocket connection.
2471
+ *
2472
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
2473
+ */
2474
+ get url(): string | null;
2475
+ /**
2476
+ * Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
2477
+ *
2478
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
2479
+ */
2480
+ get protocol(): string | null;
2481
+ /**
2482
+ * Returns the extensions selected by the server, if any.
2483
+ *
2484
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
2485
+ */
2486
+ get extensions(): string | null;
2487
+ }
2488
+ declare const WebSocketPair: {
2489
+ new (): {
2490
+ 0: WebSocket;
2491
+ 1: WebSocket;
2492
+ };
2493
+ };
2494
+ declare interface Socket {
2495
+ get readable(): ReadableStream;
2496
+ get writable(): WritableStream;
2497
+ get closed(): Promise<void>;
2498
+ get opened(): Promise<SocketInfo>;
2499
+ close(): Promise<void>;
2500
+ startTls(options?: TlsOptions): Socket;
2501
+ }
2502
+ declare interface SocketOptions {
2503
+ secureTransport?: string;
2504
+ allowHalfOpen: boolean;
2505
+ highWaterMark?: number | bigint;
2506
+ }
2507
+ declare interface SocketAddress {
2508
+ hostname: string;
2509
+ port: number;
2510
+ }
2511
+ declare interface TlsOptions {
2512
+ expectedServerHostname?: string;
2513
+ }
2514
+ declare interface SocketInfo {
2515
+ remoteAddress?: string;
2516
+ localAddress?: string;
2517
+ }
2518
+ declare interface gpuGPU {
2519
+ requestAdapter(
2520
+ param1?: gpuGPURequestAdapterOptions,
2521
+ ): Promise<gpuGPUAdapter | null>;
2522
+ }
2523
+ declare abstract class gpuGPUAdapter {
2524
+ requestDevice(param1?: gpuGPUDeviceDescriptor): Promise<gpuGPUDevice>;
2525
+ requestAdapterInfo(unmaskHints?: string[]): Promise<gpuGPUAdapterInfo>;
2526
+ get features(): gpuGPUSupportedFeatures;
2527
+ get limits(): gpuGPUSupportedLimits;
2528
+ }
2529
+ declare interface gpuGPUDevice extends EventTarget {
2530
+ createBuffer(param1: gpuGPUBufferDescriptor): gpuGPUBuffer;
2531
+ createBindGroupLayout(
2532
+ descriptor: gpuGPUBindGroupLayoutDescriptor,
2533
+ ): gpuGPUBindGroupLayout;
2534
+ createBindGroup(descriptor: gpuGPUBindGroupDescriptor): gpuGPUBindGroup;
2535
+ createSampler(descriptor: gpuGPUSamplerDescriptor): gpuGPUSampler;
2536
+ createShaderModule(
2537
+ descriptor: gpuGPUShaderModuleDescriptor,
2538
+ ): gpuGPUShaderModule;
2539
+ createPipelineLayout(
2540
+ descriptor: gpuGPUPipelineLayoutDescriptor,
2541
+ ): gpuGPUPipelineLayout;
2542
+ createComputePipeline(
2543
+ descriptor: gpuGPUComputePipelineDescriptor,
2544
+ ): gpuGPUComputePipeline;
2545
+ createRenderPipeline(
2546
+ descriptor: gpuGPURenderPipelineDescriptor,
2547
+ ): gpuGPURenderPipeline;
2548
+ createCommandEncoder(
2549
+ descriptor?: gpuGPUCommandEncoderDescriptor,
2550
+ ): gpuGPUCommandEncoder;
2551
+ createTexture(param1: gpuGPUTextureDescriptor): gpuGPUTexture;
2552
+ destroy(): void;
2553
+ createQuerySet(descriptor: gpuGPUQuerySetDescriptor): gpuGPUQuerySet;
2554
+ pushErrorScope(filter: string): void;
2555
+ popErrorScope(): Promise<gpuGPUError | null>;
2556
+ get queue(): gpuGPUQueue;
2557
+ get lost(): Promise<gpuGPUDeviceLostInfo>;
2558
+ get features(): gpuGPUSupportedFeatures;
2559
+ get limits(): gpuGPUSupportedLimits;
2560
+ }
2561
+ declare interface gpuGPUDeviceDescriptor {
2562
+ label?: string;
2563
+ requiredFeatures?: string[];
2564
+ requiredLimits?: Record<string, number | bigint>;
2565
+ defaultQueue?: gpuGPUQueueDescriptor;
2566
+ }
2567
+ declare interface gpuGPUBufferDescriptor {
2568
+ label: string;
2569
+ size: number | bigint;
2570
+ usage: number;
2571
+ mappedAtCreation: boolean;
2572
+ }
2573
+ declare interface gpuGPUQueueDescriptor {
2574
+ label?: string;
2575
+ }
2576
+ declare abstract class gpuGPUBufferUsage {
2577
+ static readonly MAP_READ: number;
2578
+ static readonly MAP_WRITE: number;
2579
+ static readonly COPY_SRC: number;
2580
+ static readonly COPY_DST: number;
2581
+ static readonly INDEX: number;
2582
+ static readonly VERTEX: number;
2583
+ static readonly UNIFORM: number;
2584
+ static readonly STORAGE: number;
2585
+ static readonly INDIRECT: number;
2586
+ static readonly QUERY_RESOLVE: number;
2587
+ }
2588
+ declare interface gpuGPUBuffer {
2589
+ getMappedRange(size?: number | bigint, param2?: number | bigint): ArrayBuffer;
2590
+ unmap(): void;
2591
+ destroy(): void;
2592
+ mapAsync(
2593
+ offset: number,
2594
+ size?: number | bigint,
2595
+ param3?: number | bigint,
2596
+ ): Promise<void>;
2597
+ get size(): number | bigint;
2598
+ get usage(): number;
2599
+ get mapState(): string;
2600
+ }
2601
+ declare abstract class gpuGPUShaderStage {
2602
+ static readonly VERTEX: number;
2603
+ static readonly FRAGMENT: number;
2604
+ static readonly COMPUTE: number;
2605
+ }
2606
+ declare interface gpuGPUBindGroupLayoutDescriptor {
2607
+ label?: string;
2608
+ entries: gpuGPUBindGroupLayoutEntry[];
2609
+ }
2610
+ declare interface gpuGPUBindGroupLayoutEntry {
2611
+ binding: number;
2612
+ visibility: number;
2613
+ buffer?: gpuGPUBufferBindingLayout;
2614
+ sampler?: gpuGPUSamplerBindingLayout;
2615
+ texture?: gpuGPUTextureBindingLayout;
2616
+ storageTexture?: gpuGPUStorageTextureBindingLayout;
2617
+ }
2618
+ declare interface gpuGPUStorageTextureBindingLayout {
2619
+ access?: string;
2620
+ format: string;
2621
+ viewDimension?: string;
2622
+ }
2623
+ declare interface gpuGPUTextureBindingLayout {
2624
+ sampleType?: string;
2625
+ viewDimension?: string;
2626
+ multisampled?: boolean;
2627
+ }
2628
+ declare interface gpuGPUSamplerBindingLayout {
2629
+ type?: string;
2630
+ }
2631
+ declare interface gpuGPUBufferBindingLayout {
2632
+ type?: string;
2633
+ hasDynamicOffset?: boolean;
2634
+ minBindingSize?: number | bigint;
2635
+ }
2636
+ declare interface gpuGPUBindGroupLayout {}
2637
+ declare interface gpuGPUBindGroup {}
2638
+ declare interface gpuGPUBindGroupDescriptor {
2639
+ label?: string;
2640
+ layout: gpuGPUBindGroupLayout;
2641
+ entries: gpuGPUBindGroupEntry[];
2642
+ }
2643
+ declare interface gpuGPUBindGroupEntry {
2644
+ binding: number;
2645
+ resource: gpuGPUBufferBinding | gpuGPUSampler;
2646
+ }
2647
+ declare interface gpuGPUBufferBinding {
2648
+ buffer: gpuGPUBuffer;
2649
+ offset?: number | bigint;
2650
+ size?: number | bigint;
2651
+ }
2652
+ declare interface gpuGPUSampler {}
2653
+ declare interface gpuGPUSamplerDescriptor {
2654
+ label?: string;
2655
+ addressModeU?: string;
2656
+ addressModeV?: string;
2657
+ addressModeW?: string;
2658
+ magFilter?: string;
2659
+ minFilter?: string;
2660
+ mipmapFilter?: string;
2661
+ lodMinClamp?: number;
2662
+ lodMaxClamp?: number;
2663
+ compare: string;
2664
+ maxAnisotropy?: number;
2665
+ }
2666
+ declare interface gpuGPUShaderModule {
2667
+ getCompilationInfo(): Promise<gpuGPUCompilationInfo>;
2668
+ }
2669
+ declare interface gpuGPUShaderModuleDescriptor {
2670
+ label?: string;
2671
+ code: string;
2672
+ }
2673
+ declare interface gpuGPUPipelineLayout {}
2674
+ declare interface gpuGPUPipelineLayoutDescriptor {
2675
+ label?: string;
2676
+ bindGroupLayouts: gpuGPUBindGroupLayout[];
2677
+ }
2678
+ declare interface gpuGPUComputePipeline {
2679
+ getBindGroupLayout(index: number): gpuGPUBindGroupLayout;
2680
+ }
2681
+ declare interface gpuGPUComputePipelineDescriptor {
2682
+ label?: string;
2683
+ compute: gpuGPUProgrammableStage;
2684
+ layout: string | gpuGPUPipelineLayout;
2685
+ }
2686
+ declare interface gpuGPUProgrammableStage {
2687
+ module: gpuGPUShaderModule;
2688
+ entryPoint: string;
2689
+ constants?: Record<string, number>;
2690
+ }
2691
+ declare interface gpuGPUCommandEncoder {
2692
+ get label(): string;
2693
+ beginComputePass(
2694
+ descriptor?: gpuGPUComputePassDescriptor,
2695
+ ): gpuGPUComputePassEncoder;
2696
+ beginRenderPass(
2697
+ descriptor: gpuGPURenderPassDescriptor,
2698
+ ): gpuGPURenderPassEncoder;
2699
+ copyBufferToBuffer(
2700
+ source: gpuGPUBuffer,
2701
+ sourceOffset: number | bigint,
2702
+ destination: gpuGPUBuffer,
2703
+ destinationOffset: number | bigint,
2704
+ size: number | bigint,
2705
+ ): void;
2706
+ finish(param0?: gpuGPUCommandBufferDescriptor): gpuGPUCommandBuffer;
2707
+ copyTextureToBuffer(
2708
+ source: gpuGPUImageCopyTexture,
2709
+ destination: gpuGPUImageCopyBuffer,
2710
+ copySize: Iterable<number> | gpuGPUExtent3DDict,
2711
+ ): void;
2712
+ copyBufferToTexture(
2713
+ source: gpuGPUImageCopyBuffer,
2714
+ destination: gpuGPUImageCopyTexture,
2715
+ copySize: Iterable<number> | gpuGPUExtent3DDict,
2716
+ ): void;
2717
+ copyTextureToTexture(
2718
+ source: gpuGPUImageCopyTexture,
2719
+ destination: gpuGPUImageCopyTexture,
2720
+ copySize: Iterable<number> | gpuGPUExtent3DDict,
2721
+ ): void;
2722
+ clearBuffer(
2723
+ buffer: gpuGPUBuffer,
2724
+ offset?: number | bigint,
2725
+ size?: number | bigint,
2726
+ ): void;
2727
+ }
2728
+ declare interface gpuGPUCommandEncoderDescriptor {
2729
+ label?: string;
2730
+ }
2731
+ declare interface gpuGPUComputePassEncoder {
2732
+ setPipeline(pipeline: gpuGPUComputePipeline): void;
2733
+ setBindGroup(
2734
+ index: number,
2735
+ bindGroup: gpuGPUBindGroup | null,
2736
+ dynamicOffsets?: Iterable<number>,
2737
+ ): void;
2738
+ dispatchWorkgroups(
2739
+ workgroupCountX: number,
2740
+ workgroupCountY?: number,
2741
+ workgroupCountZ?: number,
2742
+ ): void;
2743
+ end(): void;
2744
+ }
2745
+ declare interface gpuGPUComputePassDescriptor {
2746
+ label?: string;
2747
+ timestampWrites?: gpuGPUComputePassTimestampWrites;
2748
+ }
2749
+ declare interface gpuGPUQuerySet {}
2750
+ declare interface gpuGPUQuerySetDescriptor {
2751
+ label?: string;
2752
+ }
2753
+ declare interface gpuGPUComputePassTimestampWrites {
2754
+ querySet: gpuGPUQuerySet;
2755
+ beginningOfPassWriteIndex?: number;
2756
+ endOfPassWriteIndex?: number;
2757
+ }
2758
+ declare interface gpuGPUCommandBufferDescriptor {
2759
+ label?: string;
2760
+ }
2761
+ declare interface gpuGPUCommandBuffer {}
2762
+ declare interface gpuGPUQueue {
2763
+ submit(commandBuffers: gpuGPUCommandBuffer[]): void;
2764
+ writeBuffer(
2765
+ buffer: gpuGPUBuffer,
2766
+ bufferOffset: number | bigint,
2767
+ data: ArrayBuffer | ArrayBufferView,
2768
+ dataOffset?: number | bigint,
2769
+ size?: number | bigint,
2770
+ ): void;
2771
+ }
2772
+ declare abstract class gpuGPUMapMode {
2773
+ static readonly READ: number;
2774
+ static readonly WRITE: number;
2775
+ }
2776
+ declare interface gpuGPURequestAdapterOptions {
2777
+ powerPreference: string;
2778
+ forceFallbackAdapter?: boolean;
2779
+ }
2780
+ declare interface gpuGPUAdapterInfo {
2781
+ get vendor(): string;
2782
+ get architecture(): string;
2783
+ get device(): string;
2784
+ get description(): string;
2785
+ }
2786
+ declare interface gpuGPUSupportedFeatures {
2787
+ has(name: string): boolean;
2788
+ keys(): string[];
2789
+ }
2790
+ declare interface gpuGPUSupportedLimits {
2791
+ get maxTextureDimension1D(): number;
2792
+ get maxTextureDimension2D(): number;
2793
+ get maxTextureDimension3D(): number;
2794
+ get maxTextureArrayLayers(): number;
2795
+ get maxBindGroups(): number;
2796
+ get maxBindingsPerBindGroup(): number;
2797
+ get maxDynamicUniformBuffersPerPipelineLayout(): number;
2798
+ get maxDynamicStorageBuffersPerPipelineLayout(): number;
2799
+ get maxSampledTexturesPerShaderStage(): number;
2800
+ get maxSamplersPerShaderStage(): number;
2801
+ get maxStorageBuffersPerShaderStage(): number;
2802
+ get maxStorageTexturesPerShaderStage(): number;
2803
+ get maxUniformBuffersPerShaderStage(): number;
2804
+ get maxUniformBufferBindingSize(): number | bigint;
2805
+ get maxStorageBufferBindingSize(): number | bigint;
2806
+ get minUniformBufferOffsetAlignment(): number;
2807
+ get minStorageBufferOffsetAlignment(): number;
2808
+ get maxVertexBuffers(): number;
2809
+ get maxBufferSize(): number | bigint;
2810
+ get maxVertexAttributes(): number;
2811
+ get maxVertexBufferArrayStride(): number;
2812
+ get maxInterStageShaderComponents(): number;
2813
+ get maxInterStageShaderVariables(): number;
2814
+ get maxColorAttachments(): number;
2815
+ get maxColorAttachmentBytesPerSample(): number;
2816
+ get maxComputeWorkgroupStorageSize(): number;
2817
+ get maxComputeInvocationsPerWorkgroup(): number;
2818
+ get maxComputeWorkgroupSizeX(): number;
2819
+ get maxComputeWorkgroupSizeY(): number;
2820
+ get maxComputeWorkgroupSizeZ(): number;
2821
+ get maxComputeWorkgroupsPerDimension(): number;
2822
+ }
2823
+ declare abstract class gpuGPUError {
2824
+ get message(): string;
2825
+ }
2826
+ declare abstract class gpuGPUOutOfMemoryError extends gpuGPUError {}
2827
+ declare abstract class gpuGPUInternalError extends gpuGPUError {}
2828
+ declare abstract class gpuGPUValidationError extends gpuGPUError {}
2829
+ declare abstract class gpuGPUDeviceLostInfo {
2830
+ get message(): string;
2831
+ get reason(): string;
2832
+ }
2833
+ declare interface gpuGPUCompilationMessage {
2834
+ get message(): string;
2835
+ get type(): string;
2836
+ get lineNum(): number;
2837
+ get linePos(): number;
2838
+ get offset(): number;
2839
+ get length(): number;
2840
+ }
2841
+ declare interface gpuGPUCompilationInfo {
2842
+ get messages(): gpuGPUCompilationMessage[];
2843
+ }
2844
+ declare abstract class gpuGPUTextureUsage {
2845
+ static readonly COPY_SRC: number;
2846
+ static readonly COPY_DST: number;
2847
+ static readonly TEXTURE_BINDING: number;
2848
+ static readonly STORAGE_BINDING: number;
2849
+ static readonly RENDER_ATTACHMENT: number;
2850
+ }
2851
+ declare interface gpuGPUTextureDescriptor {
2852
+ label: string;
2853
+ size: number[] | gpuGPUExtent3DDict;
2854
+ mipLevelCount?: number;
2855
+ sampleCount?: number;
2856
+ dimension?: string;
2857
+ format: string;
2858
+ usage: number;
2859
+ viewFormats?: string[];
2860
+ }
2861
+ declare interface gpuGPUExtent3DDict {
2862
+ width: number;
2863
+ height?: number;
2864
+ depthOrArrayLayers?: number;
2865
+ }
2866
+ declare interface gpuGPUTexture {
2867
+ createView(descriptor?: gpuGPUTextureViewDescriptor): gpuGPUTextureView;
2868
+ destroy(): void;
2869
+ get width(): number;
2870
+ get height(): number;
2871
+ get depthOrArrayLayers(): number;
2872
+ get mipLevelCount(): number;
2873
+ get dimension(): string;
2874
+ get format(): string;
2875
+ get usage(): number;
2876
+ }
2877
+ declare interface gpuGPUTextureView {}
2878
+ declare interface gpuGPUTextureViewDescriptor {
2879
+ label: string;
2880
+ format: string;
2881
+ dimension: string;
2882
+ aspect?: string;
2883
+ baseMipLevel?: number;
2884
+ mipLevelCount: number;
2885
+ baseArrayLayer?: number;
2886
+ arrayLayerCount: number;
2887
+ }
2888
+ declare abstract class gpuGPUColorWrite {
2889
+ static readonly RED: number;
2890
+ static readonly GREEN: number;
2891
+ static readonly BLUE: number;
2892
+ static readonly ALPHA: number;
2893
+ static readonly ALL: number;
2894
+ }
2895
+ declare interface gpuGPURenderPipeline {}
2896
+ declare interface gpuGPURenderPipelineDescriptor {
2897
+ label?: string;
2898
+ layout: string | gpuGPUPipelineLayout;
2899
+ vertex: gpuGPUVertexState;
2900
+ primitive?: gpuGPUPrimitiveState;
2901
+ depthStencil?: gpuGPUDepthStencilState;
2902
+ multisample?: gpuGPUMultisampleState;
2903
+ fragment?: gpuGPUFragmentState;
2904
+ }
2905
+ declare interface gpuGPUVertexState {
2906
+ module: gpuGPUShaderModule;
2907
+ entryPoint: string;
2908
+ constants?: Record<string, number>;
2909
+ buffers?: gpuGPUVertexBufferLayout[];
2910
+ }
2911
+ declare interface gpuGPUVertexBufferLayout {
2912
+ arrayStride: number | bigint;
2913
+ stepMode?: string;
2914
+ attributes: gpuGPUVertexAttribute[];
2915
+ }
2916
+ declare interface gpuGPUVertexAttribute {
2917
+ format: string;
2918
+ offset: number | bigint;
2919
+ shaderLocation: number;
2920
+ }
2921
+ declare interface gpuGPUPrimitiveState {
2922
+ topology?: string;
2923
+ stripIndexFormat?: string;
2924
+ frontFace?: string;
2925
+ cullMode?: string;
2926
+ unclippedDepth?: boolean;
2927
+ }
2928
+ declare interface gpuGPUStencilFaceState {
2929
+ compare?: string;
2930
+ failOp?: string;
2931
+ depthFailOp?: string;
2932
+ passOp?: string;
2933
+ }
2934
+ declare interface gpuGPUDepthStencilState {
2935
+ format: string;
2936
+ depthWriteEnabled: boolean;
2937
+ depthCompare: string;
2938
+ stencilFront?: gpuGPUStencilFaceState;
2939
+ stencilBack?: gpuGPUStencilFaceState;
2940
+ stencilReadMask?: number;
2941
+ stencilWriteMask?: number;
2942
+ depthBias?: number;
2943
+ depthBiasSlopeScale?: number;
2944
+ depthBiasClamp?: number;
2945
+ }
2946
+ declare interface gpuGPUMultisampleState {
2947
+ count?: number;
2948
+ mask?: number;
2949
+ alphaToCoverageEnabled?: boolean;
2950
+ }
2951
+ declare interface gpuGPUFragmentState {
2952
+ module: gpuGPUShaderModule;
2953
+ entryPoint: string;
2954
+ constants?: Record<string, number>;
2955
+ targets: gpuGPUColorTargetState[];
2956
+ }
2957
+ declare interface gpuGPUColorTargetState {
2958
+ format: string;
2959
+ blend: gpuGPUBlendState;
2960
+ writeMask?: number;
2961
+ }
2962
+ declare interface gpuGPUBlendState {
2963
+ color: gpuGPUBlendComponent;
2964
+ alpha: gpuGPUBlendComponent;
2965
+ }
2966
+ declare interface gpuGPUBlendComponent {
2967
+ operation?: string;
2968
+ srcFactor?: string;
2969
+ dstFactor?: string;
2970
+ }
2971
+ declare interface gpuGPURenderPassEncoder {
2972
+ setPipeline(pipeline: gpuGPURenderPipeline): void;
2973
+ draw(
2974
+ vertexCount: number,
2975
+ instanceCount?: number,
2976
+ firstVertex?: number,
2977
+ firstInstance?: number,
2978
+ ): void;
2979
+ end(): void;
2980
+ }
2981
+ declare interface gpuGPURenderPassDescriptor {
2982
+ label?: string;
2983
+ colorAttachments: gpuGPURenderPassColorAttachment[];
2984
+ depthStencilAttachment?: gpuGPURenderPassDepthStencilAttachment;
2985
+ occlusionQuerySet?: gpuGPUQuerySet;
2986
+ timestampWrites?: gpuGPURenderPassTimestampWrites;
2987
+ maxDrawCount?: number | bigint;
2988
+ }
2989
+ declare interface gpuGPURenderPassColorAttachment {
2990
+ view: gpuGPUTextureView;
2991
+ depthSlice?: number;
2992
+ resolveTarget?: gpuGPUTextureView;
2993
+ clearValue?: number[] | gpuGPUColorDict;
2994
+ loadOp: string;
2995
+ storeOp: string;
2996
+ }
2997
+ declare interface gpuGPUColorDict {
2998
+ r: number;
2999
+ g: number;
3000
+ b: number;
3001
+ a: number;
3002
+ }
3003
+ declare interface gpuGPURenderPassDepthStencilAttachment {
3004
+ view: gpuGPUTextureView;
3005
+ depthClearValue?: number;
3006
+ depthLoadOp?: string;
3007
+ depthStoreOp?: string;
3008
+ depthReadOnly?: boolean;
3009
+ stencilClearValue?: number;
3010
+ stencilLoadOp?: string;
3011
+ stencilStoreOp?: string;
3012
+ stencilReadOnly?: boolean;
3013
+ }
3014
+ declare interface gpuGPURenderPassTimestampWrites {
3015
+ querySet: gpuGPUQuerySet;
3016
+ beginningOfPassWriteIndex?: number;
3017
+ endOfPassWriteIndex?: number;
3018
+ }
3019
+ declare interface gpuGPUImageCopyTexture {
3020
+ texture: gpuGPUTexture;
3021
+ mipLevel?: number;
3022
+ origin?: number[] | gpuGPUOrigin3DDict;
3023
+ aspect?: string;
3024
+ }
3025
+ declare interface gpuGPUImageCopyBuffer {
3026
+ buffer: gpuGPUBuffer;
3027
+ offset?: number | bigint;
3028
+ bytesPerRow?: number;
3029
+ rowsPerImage?: number;
3030
+ }
3031
+ declare interface gpuGPUOrigin3DDict {
3032
+ x?: number;
3033
+ y?: number;
3034
+ z?: number;
3035
+ }
3036
+ declare type AiImageClassificationInput = {
3037
+ image: number[];
3038
+ };
3039
+ declare type AiImageClassificationOutput = {
3040
+ score?: number;
3041
+ label?: string;
3042
+ }[];
3043
+ declare abstract class BaseAiImageClassification {
3044
+ inputs: AiImageClassificationInput;
3045
+ postProcessedOutputs: AiImageClassificationOutput;
3046
+ }
3047
+ declare type AiImageToTextInput = {
3048
+ image: number[];
3049
+ prompt?: string;
3050
+ max_tokens?: number;
3051
+ temperature?: number;
3052
+ raw?: boolean;
3053
+ messages?: RoleScopedChatInput[];
3054
+ };
3055
+ declare type AiImageToTextOutput = {
3056
+ description: string;
3057
+ };
3058
+ declare abstract class BaseAiImageToText {
3059
+ inputs: AiImageToTextInput;
3060
+ postProcessedOutputs: AiImageToTextOutput;
3061
+ }
3062
+ declare type AiObjectDetectionInput = {
3063
+ image: number[];
3064
+ };
3065
+ declare type AiObjectDetectionOutput = {
3066
+ score?: number;
3067
+ label?: string;
3068
+ }[];
3069
+ declare abstract class BaseAiObjectDetection {
3070
+ inputs: AiObjectDetectionInput;
3071
+ postProcessedOutputs: AiObjectDetectionOutput;
3072
+ }
3073
+ declare type AiSentenceSimilarityInput = {
3074
+ source: string;
3075
+ sentences: string[];
3076
+ };
3077
+ declare type AiSentenceSimilarityOutput = number[];
3078
+ declare abstract class BaseAiSentenceSimilarity {
3079
+ inputs: AiSentenceSimilarityInput;
3080
+ postProcessedOutputs: AiSentenceSimilarityOutput;
3081
+ }
3082
+ declare type AiSpeechRecognitionInput = {
3083
+ audio: number[];
3084
+ };
3085
+ declare type AiSpeechRecognitionOutput = {
3086
+ text?: string;
3087
+ words?: {
3088
+ word: string;
3089
+ start: number;
3090
+ end: number;
3091
+ }[];
3092
+ vtt?: string;
3093
+ };
3094
+ declare abstract class BaseAiSpeechRecognition {
3095
+ inputs: AiSpeechRecognitionInput;
3096
+ postProcessedOutputs: AiSpeechRecognitionOutput;
3097
+ }
3098
+ declare type AiSummarizationInput = {
3099
+ input_text: string;
3100
+ max_length?: number;
3101
+ };
3102
+ declare type AiSummarizationOutput = {
3103
+ summary: string;
3104
+ };
3105
+ declare abstract class BaseAiSummarization {
3106
+ inputs: AiSummarizationInput;
3107
+ postProcessedOutputs: AiSummarizationOutput;
3108
+ }
3109
+ declare type AiTextClassificationInput = {
3110
+ text: string;
3111
+ };
3112
+ declare type AiTextClassificationOutput = {
3113
+ score?: number;
3114
+ label?: string;
3115
+ }[];
3116
+ declare abstract class BaseAiTextClassification {
3117
+ inputs: AiTextClassificationInput;
3118
+ postProcessedOutputs: AiTextClassificationOutput;
3119
+ }
3120
+ declare type AiTextEmbeddingsInput = {
3121
+ text: string | string[];
3122
+ };
3123
+ declare type AiTextEmbeddingsOutput = {
3124
+ shape: number[];
3125
+ data: number[][];
3126
+ };
3127
+ declare abstract class BaseAiTextEmbeddings {
3128
+ inputs: AiTextEmbeddingsInput;
3129
+ postProcessedOutputs: AiTextEmbeddingsOutput;
3130
+ }
3131
+ declare type RoleScopedChatInput = {
3132
+ role: string;
3133
+ content: string;
3134
+ };
3135
+ declare type AiTextGenerationInput = {
3136
+ prompt?: string;
3137
+ raw?: boolean;
3138
+ stream?: boolean;
3139
+ max_tokens?: number;
3140
+ messages?: RoleScopedChatInput[];
3141
+ };
3142
+ declare type AiTextGenerationOutput =
3143
+ | {
3144
+ response?: string;
3145
+ }
3146
+ | ReadableStream;
3147
+ declare abstract class BaseAiTextGeneration {
3148
+ inputs: AiTextGenerationInput;
3149
+ postProcessedOutputs: AiTextGenerationOutput;
3150
+ }
3151
+ declare type AiTextToImageInput = {
3152
+ prompt: string;
3153
+ image?: number[];
3154
+ mask?: number[];
3155
+ num_steps?: number;
3156
+ strength?: number;
3157
+ guidance?: number;
3158
+ };
3159
+ declare type AiTextToImageOutput = Uint8Array;
3160
+ declare abstract class BaseAiTextToImage {
3161
+ inputs: AiTextToImageInput;
3162
+ postProcessedOutputs: AiTextToImageOutput;
3163
+ }
3164
+ declare type AiTranslationInput = {
3165
+ text: string;
3166
+ target_lang: string;
3167
+ source_lang?: string;
3168
+ };
3169
+ declare type AiTranslationOutput = {
3170
+ translated_text?: string;
3171
+ };
3172
+ declare abstract class BaseAiTranslation {
3173
+ inputs: AiTranslationInput;
3174
+ postProcessedOutputs: AiTranslationOutput;
3175
+ }
3176
+ declare type GatewayOptions = {
3177
+ id: string;
3178
+ cacheTtl?: number;
3179
+ skipCache?: boolean;
3180
+ metadata?: Record<string, number | string | boolean | null | bigint>;
3181
+ };
3182
+ declare type AiOptions = {
3183
+ gateway?: GatewayOptions;
3184
+ prefix?: string;
3185
+ extraHeaders?: object;
3186
+ };
3187
+ declare abstract class Ai {
3188
+ run(
3189
+ model:
3190
+ | "@cf/huggingface/distilbert-sst-2-int8"
3191
+ | "@cf/jpmorganchase/roberta-spam"
3192
+ | "@cf/inml/inml-roberta-dga",
3193
+ inputs: BaseAiTextClassification["inputs"],
3194
+ options?: AiOptions,
3195
+ ): Promise<BaseAiTextClassification["postProcessedOutputs"]>;
3196
+ run(
3197
+ model:
3198
+ | "@cf/stabilityai/stable-diffusion-xl-base-1.0"
3199
+ | "@cf/runwayml/stable-diffusion-v1-5-inpainting"
3200
+ | "@cf/runwayml/stable-diffusion-v1-5-img2img"
3201
+ | "@cf/lykon/dreamshaper-8-lcm"
3202
+ | "@cf/bytedance/stable-diffusion-xl-lightning",
3203
+ inputs: BaseAiTextToImage["inputs"],
3204
+ options?: AiOptions,
3205
+ ): Promise<BaseAiTextToImage["postProcessedOutputs"]>;
3206
+ run(
3207
+ model: "@hf/sentence-transformers/all-minilm-l6-v2",
3208
+ inputs: BaseAiSentenceSimilarity["inputs"],
3209
+ options?: AiOptions,
3210
+ ): Promise<BaseAiSentenceSimilarity["postProcessedOutputs"]>;
3211
+ run(
3212
+ model:
3213
+ | "@cf/baai/bge-small-en-v1.5"
3214
+ | "@cf/baai/bge-base-en-v1.5"
3215
+ | "@cf/baai/bge-large-en-v1.5",
3216
+ inputs: BaseAiTextEmbeddings["inputs"],
3217
+ options?: AiOptions,
3218
+ ): Promise<BaseAiTextEmbeddings["postProcessedOutputs"]>;
3219
+ run(
3220
+ model:
3221
+ | "@cf/openai/whisper"
3222
+ | "@cf/openai/whisper-tiny-en"
3223
+ | "@cf/openai/whisper-sherpa",
3224
+ inputs: BaseAiSpeechRecognition["inputs"],
3225
+ options?: AiOptions,
3226
+ ): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
3227
+ run(
3228
+ model: "@cf/microsoft/resnet-50",
3229
+ inputs: BaseAiImageClassification["inputs"],
3230
+ options?: AiOptions,
3231
+ ): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
3232
+ run(
3233
+ model: "@cf/facebook/detr-resnet-50",
3234
+ inputs: BaseAiObjectDetection["inputs"],
3235
+ options?: AiOptions,
3236
+ ): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
3237
+ run(
3238
+ model:
3239
+ | "@cf/meta/llama-3-8b-instruct"
3240
+ | "@cf/meta/llama-2-7b-chat-int8"
3241
+ | "@cf/mistral/mistral-7b-instruct-v0.1"
3242
+ | "@cf/mistral/mistral-7b-instruct-v0.1-vllm"
3243
+ | "@cf/mistral/mistral-7b-instruct-v0.2-lora"
3244
+ | "@cf/meta/llama-2-7b-chat-fp16"
3245
+ | "@hf/thebloke/llama-2-13b-chat-awq"
3246
+ | "@hf/thebloke/zephyr-7b-beta-awq"
3247
+ | "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
3248
+ | "@hf/thebloke/codellama-7b-instruct-awq"
3249
+ | "@hf/thebloke/openchat_3.5-awq"
3250
+ | "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
3251
+ | "@hf/thebloke/neural-chat-7b-v3-1-awq"
3252
+ | "@hf/thebloke/llamaguard-7b-awq"
3253
+ | "@hf/thebloke/deepseek-coder-6.7b-base-awq"
3254
+ | "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"
3255
+ | "@hf/nousresearch/hermes-2-pro-mistral-7b"
3256
+ | "@hf/mistral/mistral-7b-instruct-v0.2"
3257
+ | "@cf/mistral/mixtral-8x7b-instruct-v0.1-awq"
3258
+ | "@hf/google/gemma-7b-it"
3259
+ | "@hf/nexusflow/starling-lm-7b-beta"
3260
+ | "@cf/deepseek-ai/deepseek-math-7b-instruct"
3261
+ | "@cf/defog/sqlcoder-7b-2"
3262
+ | "@cf/openchat/openchat-3.5-0106"
3263
+ | "@cf/tiiuae/falcon-7b-instruct"
3264
+ | "@cf/thebloke/discolm-german-7b-v1-awq"
3265
+ | "@cf/qwen/qwen1.5-0.5b-chat"
3266
+ | "@cf/qwen/qwen1.5-1.8b-chat"
3267
+ | "@cf/qwen/qwen1.5-7b-chat-awq"
3268
+ | "@cf/qwen/qwen1.5-14b-chat-awq"
3269
+ | "@cf/tinyllama/tinyllama-1.1b-chat-v1.0"
3270
+ | "@cf/microsoft/phi-2"
3271
+ | "@cf/google/gemma-2b-it-lora"
3272
+ | "@cf/google/gemma-7b-it-lora"
3273
+ | "@cf/meta-llama/llama-2-7b-chat-hf-lora",
3274
+ inputs: BaseAiTextGeneration["inputs"],
3275
+ options?: AiOptions,
3276
+ ): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
3277
+ run(
3278
+ model: "@cf/meta/m2m100-1.2b",
3279
+ inputs: BaseAiTranslation["inputs"],
3280
+ options?: AiOptions,
3281
+ ): Promise<BaseAiTranslation["postProcessedOutputs"]>;
3282
+ run(
3283
+ model: "@cf/facebook/bart-large-cnn",
3284
+ inputs: BaseAiSummarization["inputs"],
3285
+ options?: AiOptions,
3286
+ ): Promise<BaseAiSummarization["postProcessedOutputs"]>;
3287
+ run(
3288
+ model: "@cf/unum/uform-gen2-qwen-500m" | "@cf/llava-hf/llava-1.5-7b-hf",
3289
+ inputs: BaseAiImageToText["inputs"],
3290
+ options?: AiOptions,
3291
+ ): Promise<BaseAiImageToText["postProcessedOutputs"]>;
3292
+ }
3293
+ declare interface BasicImageTransformations {
3294
+ /**
3295
+ * Maximum width in image pixels. The value must be an integer.
3296
+ */
3297
+ width?: number;
3298
+ /**
3299
+ * Maximum height in image pixels. The value must be an integer.
3300
+ */
3301
+ height?: number;
3302
+ /**
3303
+ * Resizing mode as a string. It affects interpretation of width and height
3304
+ * options:
3305
+ * - scale-down: Similar to contain, but the image is never enlarged. If
3306
+ * the image is larger than given width or height, it will be resized.
3307
+ * Otherwise its original size will be kept.
3308
+ * - contain: Resizes to maximum size that fits within the given width and
3309
+ * height. If only a single dimension is given (e.g. only width), the
3310
+ * image will be shrunk or enlarged to exactly match that dimension.
3311
+ * Aspect ratio is always preserved.
3312
+ * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
3313
+ * and height. If the image has an aspect ratio different from the ratio
3314
+ * of width and height, it will be cropped to fit.
3315
+ * - crop: The image will be shrunk and cropped to fit within the area
3316
+ * specified by width and height. The image will not be enlarged. For images
3317
+ * smaller than the given dimensions it's the same as scale-down. For
3318
+ * images larger than the given dimensions, it's the same as cover.
3319
+ * See also trim.
3320
+ * - pad: Resizes to the maximum size that fits within the given width and
3321
+ * height, and then fills the remaining area with a background color
3322
+ * (white by default). Use of this mode is not recommended, as the same
3323
+ * effect can be more efficiently achieved with the contain mode and the
3324
+ * CSS object-fit: contain property.
3325
+ */
3326
+ fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
3327
+ /**
3328
+ * When cropping with fit: "cover", this defines the side or point that should
3329
+ * be left uncropped. The value is either a string
3330
+ * "left", "right", "top", "bottom", "auto", or "center" (the default),
3331
+ * or an object {x, y} containing focal point coordinates in the original
3332
+ * image expressed as fractions ranging from 0.0 (top or left) to 1.0
3333
+ * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
3334
+ * crop bottom or left and right sides as necessary, but won’t crop anything
3335
+ * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
3336
+ * preserve as much as possible around a point at 20% of the height of the
3337
+ * source image.
3338
+ */
3339
+ gravity?:
3340
+ | "left"
3341
+ | "right"
3342
+ | "top"
3343
+ | "bottom"
3344
+ | "center"
3345
+ | "auto"
3346
+ | BasicImageTransformationsGravityCoordinates;
3347
+ /**
3348
+ * Background color to add underneath the image. Applies only to images with
3349
+ * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
3350
+ * hsl(…), etc.)
3351
+ */
3352
+ background?: string;
3353
+ /**
3354
+ * Number of degrees (90, 180, 270) to rotate the image by. width and height
3355
+ * options refer to axes after rotation.
3356
+ */
3357
+ rotate?: 0 | 90 | 180 | 270 | 360;
3358
+ }
3359
+ declare interface BasicImageTransformationsGravityCoordinates {
3360
+ x: number;
3361
+ y: number;
3362
+ }
3363
+ /**
3364
+ * In addition to the properties you can set in the RequestInit dict
3365
+ * that you pass as an argument to the Request constructor, you can
3366
+ * set certain properties of a `cf` object to control how Cloudflare
3367
+ * features are applied to that new Request.
3368
+ *
3369
+ * Note: Currently, these properties cannot be tested in the
3370
+ * playground.
3371
+ */
3372
+ declare interface RequestInitCfProperties extends Record<string, unknown> {
3373
+ cacheEverything?: boolean;
3374
+ /**
3375
+ * A request's cache key is what determines if two requests are
3376
+ * "the same" for caching purposes. If a request has the same cache key
3377
+ * as some previous request, then we can serve the same cached response for
3378
+ * both. (e.g. 'some-key')
3379
+ *
3380
+ * Only available for Enterprise customers.
3381
+ */
3382
+ cacheKey?: string;
3383
+ /**
3384
+ * This allows you to append additional Cache-Tag response headers
3385
+ * to the origin response without modifications to the origin server.
3386
+ * This will allow for greater control over the Purge by Cache Tag feature
3387
+ * utilizing changes only in the Workers process.
3388
+ *
3389
+ * Only available for Enterprise customers.
3390
+ */
3391
+ cacheTags?: string[];
3392
+ /**
3393
+ * Force response to be cached for a given number of seconds. (e.g. 300)
3394
+ */
3395
+ cacheTtl?: number;
3396
+ /**
3397
+ * Force response to be cached for a given number of seconds based on the Origin status code.
3398
+ * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
3399
+ */
3400
+ cacheTtlByStatus?: Record<string, number>;
3401
+ scrapeShield?: boolean;
3402
+ apps?: boolean;
3403
+ image?: RequestInitCfPropertiesImage;
3404
+ minify?: RequestInitCfPropertiesImageMinify;
3405
+ mirage?: boolean;
3406
+ polish?: "lossy" | "lossless" | "off";
3407
+ r2?: RequestInitCfPropertiesR2;
3408
+ /**
3409
+ * Redirects the request to an alternate origin server. You can use this,
3410
+ * for example, to implement load balancing across several origins.
3411
+ * (e.g.us-east.example.com)
3412
+ *
3413
+ * Note - For security reasons, the hostname set in resolveOverride must
3414
+ * be proxied on the same Cloudflare zone of the incoming request.
3415
+ * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
3416
+ * resolve to a host under a different domain or a DNS only domain first
3417
+ * declare a CNAME record within your own zone’s DNS mapping to the
3418
+ * external hostname, set proxy on Cloudflare, then set resolveOverride
3419
+ * to point to that CNAME record.
3420
+ */
3421
+ resolveOverride?: string;
3422
+ }
3423
+ declare interface RequestInitCfPropertiesImageDraw
3424
+ extends BasicImageTransformations {
3425
+ /**
3426
+ * Absolute URL of the image file to use for the drawing. It can be any of
3427
+ * the supported file formats. For drawing of watermarks or non-rectangular
3428
+ * overlays we recommend using PNG or WebP images.
3429
+ */
3430
+ url: string;
3431
+ /**
3432
+ * Floating-point number between 0 (transparent) and 1 (opaque).
3433
+ * For example, opacity: 0.5 makes overlay semitransparent.
3434
+ */
3435
+ opacity?: number;
3436
+ /**
3437
+ * - If set to true, the overlay image will be tiled to cover the entire
3438
+ * area. This is useful for stock-photo-like watermarks.
3439
+ * - If set to "x", the overlay image will be tiled horizontally only
3440
+ * (form a line).
3441
+ * - If set to "y", the overlay image will be tiled vertically only
3442
+ * (form a line).
3443
+ */
3444
+ repeat?: true | "x" | "y";
3445
+ /**
3446
+ * Position of the overlay image relative to a given edge. Each property is
3447
+ * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
3448
+ * positions left side of the overlay 10 pixels from the left edge of the
3449
+ * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
3450
+ * of the background image.
3451
+ *
3452
+ * Setting both left & right, or both top & bottom is an error.
3453
+ *
3454
+ * If no position is specified, the image will be centered.
3455
+ */
3456
+ top?: number;
3457
+ left?: number;
3458
+ bottom?: number;
3459
+ right?: number;
3460
+ }
3461
+ declare interface RequestInitCfPropertiesImage
3462
+ extends BasicImageTransformations {
3463
+ /**
3464
+ * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
3465
+ * easier to specify higher-DPI sizes in <img srcset>.
3466
+ */
3467
+ dpr?: number;
3468
+ /**
3469
+ * An object with four properties {left, top, right, bottom} that specify
3470
+ * a number of pixels to cut off on each side. Allows removal of borders
3471
+ * or cutting out a specific fragment of an image. Trimming is performed
3472
+ * before resizing or rotation. Takes dpr into account.
3473
+ */
3474
+ trim?: {
3475
+ left?: number;
3476
+ top?: number;
3477
+ right?: number;
3478
+ bottom?: number;
3479
+ };
3480
+ /**
3481
+ * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
3482
+ * make images look worse, but load faster. The default is 85. It applies only
3483
+ * to JPEG and WebP images. It doesn’t have any effect on PNG.
3484
+ */
3485
+ quality?: number;
3486
+ /**
3487
+ * Output format to generate. It can be:
3488
+ * - avif: generate images in AVIF format.
3489
+ * - webp: generate images in Google WebP format. Set quality to 100 to get
3490
+ * the WebP-lossless format.
3491
+ * - json: instead of generating an image, outputs information about the
3492
+ * image, in JSON format. The JSON object will contain image size
3493
+ * (before and after resizing), source image’s MIME type, file size, etc.
3494
+ * - jpeg: generate images in JPEG format.
3495
+ * - png: generate images in PNG format.
3496
+ */
3497
+ format?: "avif" | "webp" | "json" | "jpeg" | "png";
3498
+ /**
3499
+ * Whether to preserve animation frames from input files. Default is true.
3500
+ * Setting it to false reduces animations to still images. This setting is
3501
+ * recommended when enlarging images or processing arbitrary user content,
3502
+ * because large GIF animations can weigh tens or even hundreds of megabytes.
3503
+ * It is also useful to set anim:false when using format:"json" to get the
3504
+ * response quicker without the number of frames.
3505
+ */
3506
+ anim?: boolean;
3507
+ /**
3508
+ * What EXIF data should be preserved in the output image. Note that EXIF
3509
+ * rotation and embedded color profiles are always applied ("baked in" into
3510
+ * the image), and aren't affected by this option. Note that if the Polish
3511
+ * feature is enabled, all metadata may have been removed already and this
3512
+ * option may have no effect.
3513
+ * - keep: Preserve most of EXIF metadata, including GPS location if there's
3514
+ * any.
3515
+ * - copyright: Only keep the copyright tag, and discard everything else.
3516
+ * This is the default behavior for JPEG files.
3517
+ * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
3518
+ * output formats always discard metadata.
3519
+ */
3520
+ metadata?: "keep" | "copyright" | "none";
3521
+ /**
3522
+ * Strength of sharpening filter to apply to the image. Floating-point
3523
+ * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
3524
+ * recommended value for downscaled images.
3525
+ */
3526
+ sharpen?: number;
3527
+ /**
3528
+ * Radius of a blur filter (approximate gaussian). Maximum supported radius
3529
+ * is 250.
3530
+ */
3531
+ blur?: number;
3532
+ /**
3533
+ * Overlays are drawn in the order they appear in the array (last array
3534
+ * entry is the topmost layer).
3535
+ */
3536
+ draw?: RequestInitCfPropertiesImageDraw[];
3537
+ /**
3538
+ * Fetching image from authenticated origin. Setting this property will
3539
+ * pass authentication headers (Authorization, Cookie, etc.) through to
3540
+ * the origin.
3541
+ */
3542
+ "origin-auth"?: "share-publicly";
3543
+ /**
3544
+ * Adds a border around the image. The border is added after resizing. Border
3545
+ * width takes dpr into account, and can be specified either using a single
3546
+ * width property, or individually for each side.
3547
+ */
3548
+ border?:
3549
+ | {
3550
+ color: string;
3551
+ width: number;
3552
+ }
3553
+ | {
3554
+ color: string;
3555
+ top: number;
3556
+ right: number;
3557
+ bottom: number;
3558
+ left: number;
3559
+ };
3560
+ /**
3561
+ * Increase brightness by a factor. A value of 1.0 equals no change, a value
3562
+ * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
3563
+ * 0 is ignored.
3564
+ */
3565
+ brightness?: number;
3566
+ /**
3567
+ * Increase contrast by a factor. A value of 1.0 equals no change, a value of
3568
+ * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
3569
+ * ignored.
3570
+ */
3571
+ contrast?: number;
3572
+ /**
3573
+ * Increase exposure by a factor. A value of 1.0 equals no change, a value of
3574
+ * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
3575
+ */
3576
+ gamma?: number;
3577
+ /**
3578
+ * Slightly reduces latency on a cache miss by selecting a
3579
+ * quickest-to-compress file format, at a cost of increased file size and
3580
+ * lower image quality. It will usually override the format option and choose
3581
+ * JPEG over WebP or AVIF. We do not recommend using this option, except in
3582
+ * unusual circumstances like resizing uncacheable dynamically-generated
3583
+ * images.
3584
+ */
3585
+ compression?: "fast";
3586
+ }
3587
+ declare interface RequestInitCfPropertiesImageMinify {
3588
+ javascript?: boolean;
3589
+ css?: boolean;
3590
+ html?: boolean;
3591
+ }
3592
+ declare interface RequestInitCfPropertiesR2 {
3593
+ /**
3594
+ * Colo id of bucket that an object is stored in
3595
+ */
3596
+ bucketColoId?: number;
3597
+ }
3598
+ /**
3599
+ * Request metadata provided by Cloudflare's edge.
3600
+ */
3601
+ declare type IncomingRequestCfProperties<HostMetadata = unknown> =
3602
+ IncomingRequestCfPropertiesBase &
3603
+ IncomingRequestCfPropertiesBotManagementEnterprise &
3604
+ IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
3605
+ IncomingRequestCfPropertiesGeographicInformation &
3606
+ IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
3607
+ declare interface IncomingRequestCfPropertiesBase
3608
+ extends Record<string, unknown> {
3609
+ /**
3610
+ * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
3611
+ *
3612
+ * @example 395747
3613
+ */
3614
+ asn: number;
3615
+ /**
3616
+ * The organization which owns the ASN of the incoming request.
3617
+ *
3618
+ * @example "Google Cloud"
3619
+ */
3620
+ asOrganization: string;
3621
+ /**
3622
+ * The original value of the `Accept-Encoding` header if Cloudflare modified it.
3623
+ *
3624
+ * @example "gzip, deflate, br"
3625
+ */
3626
+ clientAcceptEncoding?: string;
3627
+ /**
3628
+ * The number of milliseconds it took for the request to reach your worker.
3629
+ *
3630
+ * @example 22
3631
+ */
3632
+ clientTcpRtt?: number;
3633
+ /**
3634
+ * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
3635
+ * airport code of the data center that the request hit.
3636
+ *
3637
+ * @example "DFW"
3638
+ */
3639
+ colo: string;
3640
+ /**
3641
+ * Represents the upstream's response to a
3642
+ * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
3643
+ * from cloudflare.
3644
+ *
3645
+ * For workers with no upstream, this will always be `1`.
3646
+ *
3647
+ * @example 3
3648
+ */
3649
+ edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
3650
+ /**
3651
+ * The HTTP Protocol the request used.
3652
+ *
3653
+ * @example "HTTP/2"
3654
+ */
3655
+ httpProtocol: string;
3656
+ /**
3657
+ * The browser-requested prioritization information in the request object.
3658
+ *
3659
+ * If no information was set, defaults to the empty string `""`
3660
+ *
3661
+ * @example "weight=192;exclusive=0;group=3;group-weight=127"
3662
+ * @default ""
3663
+ */
3664
+ requestPriority: string;
3665
+ /**
3666
+ * The TLS version of the connection to Cloudflare.
3667
+ * In requests served over plaintext (without TLS), this property is the empty string `""`.
3668
+ *
3669
+ * @example "TLSv1.3"
3670
+ */
3671
+ tlsVersion: string;
3672
+ /**
3673
+ * The cipher for the connection to Cloudflare.
3674
+ * In requests served over plaintext (without TLS), this property is the empty string `""`.
3675
+ *
3676
+ * @example "AEAD-AES128-GCM-SHA256"
3677
+ */
3678
+ tlsCipher: string;
3679
+ /**
3680
+ * 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.
3681
+ *
3682
+ * If the incoming request was served over plaintext (without TLS) this field is undefined.
3683
+ */
3684
+ tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
3685
+ }
3686
+ declare interface IncomingRequestCfPropertiesBotManagementBase {
3687
+ /**
3688
+ * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
3689
+ * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
3690
+ *
3691
+ * @example 54
3692
+ */
3693
+ score: number;
3694
+ /**
3695
+ * A boolean value that is true if the request comes from a good bot, like Google or Bing.
3696
+ * 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).
3697
+ */
3698
+ verifiedBot: boolean;
3699
+ /**
3700
+ * A boolean value that is true if the request originates from a
3701
+ * Cloudflare-verified proxy service.
3702
+ */
3703
+ corporateProxy: boolean;
3704
+ /**
3705
+ * 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.
3706
+ */
3707
+ staticResource: boolean;
3708
+ /**
3709
+ * 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).
3710
+ */
3711
+ detectionIds: number[];
3712
+ }
3713
+ declare interface IncomingRequestCfPropertiesBotManagement {
3714
+ /**
3715
+ * Results of Cloudflare's Bot Management analysis
3716
+ */
3717
+ botManagement: IncomingRequestCfPropertiesBotManagementBase;
3718
+ /**
3719
+ * Duplicate of `botManagement.score`.
3720
+ *
3721
+ * @deprecated
3722
+ */
3723
+ clientTrustScore: number;
3724
+ }
3725
+ declare interface IncomingRequestCfPropertiesBotManagementEnterprise
3726
+ extends IncomingRequestCfPropertiesBotManagement {
3727
+ /**
3728
+ * Results of Cloudflare's Bot Management analysis
3729
+ */
3730
+ botManagement: IncomingRequestCfPropertiesBotManagementBase & {
3731
+ /**
3732
+ * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
3733
+ * across different destination IPs, Ports, and X509 certificates.
3734
+ */
3735
+ ja3Hash: string;
3736
+ };
3737
+ }
3738
+ declare interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<
3739
+ HostMetadata,
3740
+ > {
3741
+ /**
3742
+ * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
3743
+ *
3744
+ * This field is only present if you have Cloudflare for SaaS enabled on your account
3745
+ * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
3746
+ */
3747
+ hostMetadata: HostMetadata;
3748
+ }
3749
+ declare interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
3750
+ /**
3751
+ * Information about the client certificate presented to Cloudflare.
3752
+ *
3753
+ * This is populated when the incoming request is served over TLS using
3754
+ * either Cloudflare Access or API Shield (mTLS)
3755
+ * and the presented SSL certificate has a valid
3756
+ * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
3757
+ * (i.e., not `null` or `""`).
3758
+ *
3759
+ * Otherwise, a set of placeholder values are used.
3760
+ *
3761
+ * The property `certPresented` will be set to `"1"` when
3762
+ * the object is populated (i.e. the above conditions were met).
3763
+ */
3764
+ tlsClientAuth:
3765
+ | IncomingRequestCfPropertiesTLSClientAuth
3766
+ | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
3767
+ }
3768
+ /**
3769
+ * Metadata about the request's TLS handshake
3770
+ */
3771
+ declare interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
3772
+ /**
3773
+ * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
3774
+ *
3775
+ * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
3776
+ */
3777
+ clientHandshake: string;
3778
+ /**
3779
+ * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
3780
+ *
3781
+ * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
3782
+ */
3783
+ serverHandshake: string;
3784
+ /**
3785
+ * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
3786
+ *
3787
+ * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
3788
+ */
3789
+ clientFinished: string;
3790
+ /**
3791
+ * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
3792
+ *
3793
+ * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
3794
+ */
3795
+ serverFinished: string;
3796
+ }
3797
+ /**
3798
+ * Geographic data about the request's origin.
3799
+ */
3800
+ declare interface IncomingRequestCfPropertiesGeographicInformation {
3801
+ /**
3802
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
3803
+ *
3804
+ * 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.
3805
+ *
3806
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
3807
+ *
3808
+ * The country code `"T1"` is used for requests originating on TOR.
3809
+ *
3810
+ * @example "GB"
3811
+ */
3812
+ country?: Iso3166Alpha2Code | "T1";
3813
+ /**
3814
+ * If present, this property indicates that the request originated in the EU
3815
+ *
3816
+ * @example "1"
3817
+ */
3818
+ isEUCountry?: "1";
3819
+ /**
3820
+ * A two-letter code indicating the continent the request originated from.
3821
+ *
3822
+ * @example "AN"
3823
+ */
3824
+ continent?: ContinentCode;
3825
+ /**
3826
+ * The city the request originated from
3827
+ *
3828
+ * @example "Austin"
3829
+ */
3830
+ city?: string;
3831
+ /**
3832
+ * Postal code of the incoming request
3833
+ *
3834
+ * @example "78701"
3835
+ */
3836
+ postalCode?: string;
3837
+ /**
3838
+ * Latitude of the incoming request
3839
+ *
3840
+ * @example "30.27130"
3841
+ */
3842
+ latitude?: string;
3843
+ /**
3844
+ * Longitude of the incoming request
3845
+ *
3846
+ * @example "-97.74260"
3847
+ */
3848
+ longitude?: string;
3849
+ /**
3850
+ * Timezone of the incoming request
3851
+ *
3852
+ * @example "America/Chicago"
3853
+ */
3854
+ timezone?: string;
3855
+ /**
3856
+ * If known, the ISO 3166-2 name for the first level region associated with
3857
+ * the IP address of the incoming request
3858
+ *
3859
+ * @example "Texas"
3860
+ */
3861
+ region?: string;
3862
+ /**
3863
+ * If known, the ISO 3166-2 code for the first-level region associated with
3864
+ * the IP address of the incoming request
3865
+ *
3866
+ * @example "TX"
3867
+ */
3868
+ regionCode?: string;
3869
+ /**
3870
+ * Metro code (DMA) of the incoming request
3871
+ *
3872
+ * @example "635"
3873
+ */
3874
+ metroCode?: string;
3875
+ }
3876
+ /** Data about the incoming request's TLS certificate */
3877
+ declare interface IncomingRequestCfPropertiesTLSClientAuth {
3878
+ /** Always `"1"`, indicating that the certificate was presented */
3879
+ certPresented: "1";
3880
+ /**
3881
+ * Result of certificate verification.
3882
+ *
3883
+ * @example "FAILED:self signed certificate"
3884
+ */
3885
+ certVerified: Exclude<CertVerificationStatus, "NONE">;
3886
+ /** The presented certificate's revokation status.
3887
+ *
3888
+ * - A value of `"1"` indicates the certificate has been revoked
3889
+ * - A value of `"0"` indicates the certificate has not been revoked
3890
+ */
3891
+ certRevoked: "1" | "0";
3892
+ /**
3893
+ * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
3894
+ *
3895
+ * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
3896
+ */
3897
+ certIssuerDN: string;
3898
+ /**
3899
+ * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
3900
+ *
3901
+ * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
3902
+ */
3903
+ certSubjectDN: string;
3904
+ /**
3905
+ * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
3906
+ *
3907
+ * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
3908
+ */
3909
+ certIssuerDNRFC2253: string;
3910
+ /**
3911
+ * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
3912
+ *
3913
+ * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
3914
+ */
3915
+ certSubjectDNRFC2253: string;
3916
+ /** The certificate issuer's distinguished name (legacy policies) */
3917
+ certIssuerDNLegacy: string;
3918
+ /** The certificate subject's distinguished name (legacy policies) */
3919
+ certSubjectDNLegacy: string;
3920
+ /**
3921
+ * The certificate's serial number
3922
+ *
3923
+ * @example "00936EACBE07F201DF"
3924
+ */
3925
+ certSerial: string;
3926
+ /**
3927
+ * The certificate issuer's serial number
3928
+ *
3929
+ * @example "2489002934BDFEA34"
3930
+ */
3931
+ certIssuerSerial: string;
3932
+ /**
3933
+ * The certificate's Subject Key Identifier
3934
+ *
3935
+ * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
3936
+ */
3937
+ certSKI: string;
3938
+ /**
3939
+ * The certificate issuer's Subject Key Identifier
3940
+ *
3941
+ * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
3942
+ */
3943
+ certIssuerSKI: string;
3944
+ /**
3945
+ * The certificate's SHA-1 fingerprint
3946
+ *
3947
+ * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
3948
+ */
3949
+ certFingerprintSHA1: string;
3950
+ /**
3951
+ * The certificate's SHA-256 fingerprint
3952
+ *
3953
+ * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
3954
+ */
3955
+ certFingerprintSHA256: string;
3956
+ /**
3957
+ * The effective starting date of the certificate
3958
+ *
3959
+ * @example "Dec 22 19:39:00 2018 GMT"
3960
+ */
3961
+ certNotBefore: string;
3962
+ /**
3963
+ * The effective expiration date of the certificate
3964
+ *
3965
+ * @example "Dec 22 19:39:00 2018 GMT"
3966
+ */
3967
+ certNotAfter: string;
3968
+ }
3969
+ /** Placeholder values for TLS Client Authorization */
3970
+ declare interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
3971
+ certPresented: "0";
3972
+ certVerified: "NONE";
3973
+ certRevoked: "0";
3974
+ certIssuerDN: "";
3975
+ certSubjectDN: "";
3976
+ certIssuerDNRFC2253: "";
3977
+ certSubjectDNRFC2253: "";
3978
+ certIssuerDNLegacy: "";
3979
+ certSubjectDNLegacy: "";
3980
+ certSerial: "";
3981
+ certIssuerSerial: "";
3982
+ certSKI: "";
3983
+ certIssuerSKI: "";
3984
+ certFingerprintSHA1: "";
3985
+ certFingerprintSHA256: "";
3986
+ certNotBefore: "";
3987
+ certNotAfter: "";
3988
+ }
3989
+ /** Possible outcomes of TLS verification */
3990
+ declare type CertVerificationStatus =
3991
+ /** Authentication succeeded */
3992
+ | "SUCCESS"
3993
+ /** No certificate was presented */
3994
+ | "NONE"
3995
+ /** Failed because the certificate was self-signed */
3996
+ | "FAILED:self signed certificate"
3997
+ /** Failed because the certificate failed a trust chain check */
3998
+ | "FAILED:unable to verify the first certificate"
3999
+ /** Failed because the certificate not yet valid */
4000
+ | "FAILED:certificate is not yet valid"
4001
+ /** Failed because the certificate is expired */
4002
+ | "FAILED:certificate has expired"
4003
+ /** Failed for another unspecified reason */
4004
+ | "FAILED";
4005
+ /**
4006
+ * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
4007
+ */
4008
+ declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus =
4009
+ | 0 /** Unknown */
4010
+ | 1 /** no keepalives (not found) */
4011
+ | 2 /** no connection re-use, opening keepalive connection failed */
4012
+ | 3 /** no connection re-use, keepalive accepted and saved */
4013
+ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */
4014
+ | 5; /** connection re-use, accepted by the origin server */
4015
+ /** ISO 3166-1 Alpha-2 codes */
4016
+ declare type Iso3166Alpha2Code =
4017
+ | "AD"
4018
+ | "AE"
4019
+ | "AF"
4020
+ | "AG"
4021
+ | "AI"
4022
+ | "AL"
4023
+ | "AM"
4024
+ | "AO"
4025
+ | "AQ"
4026
+ | "AR"
4027
+ | "AS"
4028
+ | "AT"
4029
+ | "AU"
4030
+ | "AW"
4031
+ | "AX"
4032
+ | "AZ"
4033
+ | "BA"
4034
+ | "BB"
4035
+ | "BD"
4036
+ | "BE"
4037
+ | "BF"
4038
+ | "BG"
4039
+ | "BH"
4040
+ | "BI"
4041
+ | "BJ"
4042
+ | "BL"
4043
+ | "BM"
4044
+ | "BN"
4045
+ | "BO"
4046
+ | "BQ"
4047
+ | "BR"
4048
+ | "BS"
4049
+ | "BT"
4050
+ | "BV"
4051
+ | "BW"
4052
+ | "BY"
4053
+ | "BZ"
4054
+ | "CA"
4055
+ | "CC"
4056
+ | "CD"
4057
+ | "CF"
4058
+ | "CG"
4059
+ | "CH"
4060
+ | "CI"
4061
+ | "CK"
4062
+ | "CL"
4063
+ | "CM"
4064
+ | "CN"
4065
+ | "CO"
4066
+ | "CR"
4067
+ | "CU"
4068
+ | "CV"
4069
+ | "CW"
4070
+ | "CX"
4071
+ | "CY"
4072
+ | "CZ"
4073
+ | "DE"
4074
+ | "DJ"
4075
+ | "DK"
4076
+ | "DM"
4077
+ | "DO"
4078
+ | "DZ"
4079
+ | "EC"
4080
+ | "EE"
4081
+ | "EG"
4082
+ | "EH"
4083
+ | "ER"
4084
+ | "ES"
4085
+ | "ET"
4086
+ | "FI"
4087
+ | "FJ"
4088
+ | "FK"
4089
+ | "FM"
4090
+ | "FO"
4091
+ | "FR"
4092
+ | "GA"
4093
+ | "GB"
4094
+ | "GD"
4095
+ | "GE"
4096
+ | "GF"
4097
+ | "GG"
4098
+ | "GH"
4099
+ | "GI"
4100
+ | "GL"
4101
+ | "GM"
4102
+ | "GN"
4103
+ | "GP"
4104
+ | "GQ"
4105
+ | "GR"
4106
+ | "GS"
4107
+ | "GT"
4108
+ | "GU"
4109
+ | "GW"
4110
+ | "GY"
4111
+ | "HK"
4112
+ | "HM"
4113
+ | "HN"
4114
+ | "HR"
4115
+ | "HT"
4116
+ | "HU"
4117
+ | "ID"
4118
+ | "IE"
4119
+ | "IL"
4120
+ | "IM"
4121
+ | "IN"
4122
+ | "IO"
4123
+ | "IQ"
4124
+ | "IR"
4125
+ | "IS"
4126
+ | "IT"
4127
+ | "JE"
4128
+ | "JM"
4129
+ | "JO"
4130
+ | "JP"
4131
+ | "KE"
4132
+ | "KG"
4133
+ | "KH"
4134
+ | "KI"
4135
+ | "KM"
4136
+ | "KN"
4137
+ | "KP"
4138
+ | "KR"
4139
+ | "KW"
4140
+ | "KY"
4141
+ | "KZ"
4142
+ | "LA"
4143
+ | "LB"
4144
+ | "LC"
4145
+ | "LI"
4146
+ | "LK"
4147
+ | "LR"
4148
+ | "LS"
4149
+ | "LT"
4150
+ | "LU"
4151
+ | "LV"
4152
+ | "LY"
4153
+ | "MA"
4154
+ | "MC"
4155
+ | "MD"
4156
+ | "ME"
4157
+ | "MF"
4158
+ | "MG"
4159
+ | "MH"
4160
+ | "MK"
4161
+ | "ML"
4162
+ | "MM"
4163
+ | "MN"
4164
+ | "MO"
4165
+ | "MP"
4166
+ | "MQ"
4167
+ | "MR"
4168
+ | "MS"
4169
+ | "MT"
4170
+ | "MU"
4171
+ | "MV"
4172
+ | "MW"
4173
+ | "MX"
4174
+ | "MY"
4175
+ | "MZ"
4176
+ | "NA"
4177
+ | "NC"
4178
+ | "NE"
4179
+ | "NF"
4180
+ | "NG"
4181
+ | "NI"
4182
+ | "NL"
4183
+ | "NO"
4184
+ | "NP"
4185
+ | "NR"
4186
+ | "NU"
4187
+ | "NZ"
4188
+ | "OM"
4189
+ | "PA"
4190
+ | "PE"
4191
+ | "PF"
4192
+ | "PG"
4193
+ | "PH"
4194
+ | "PK"
4195
+ | "PL"
4196
+ | "PM"
4197
+ | "PN"
4198
+ | "PR"
4199
+ | "PS"
4200
+ | "PT"
4201
+ | "PW"
4202
+ | "PY"
4203
+ | "QA"
4204
+ | "RE"
4205
+ | "RO"
4206
+ | "RS"
4207
+ | "RU"
4208
+ | "RW"
4209
+ | "SA"
4210
+ | "SB"
4211
+ | "SC"
4212
+ | "SD"
4213
+ | "SE"
4214
+ | "SG"
4215
+ | "SH"
4216
+ | "SI"
4217
+ | "SJ"
4218
+ | "SK"
4219
+ | "SL"
4220
+ | "SM"
4221
+ | "SN"
4222
+ | "SO"
4223
+ | "SR"
4224
+ | "SS"
4225
+ | "ST"
4226
+ | "SV"
4227
+ | "SX"
4228
+ | "SY"
4229
+ | "SZ"
4230
+ | "TC"
4231
+ | "TD"
4232
+ | "TF"
4233
+ | "TG"
4234
+ | "TH"
4235
+ | "TJ"
4236
+ | "TK"
4237
+ | "TL"
4238
+ | "TM"
4239
+ | "TN"
4240
+ | "TO"
4241
+ | "TR"
4242
+ | "TT"
4243
+ | "TV"
4244
+ | "TW"
4245
+ | "TZ"
4246
+ | "UA"
4247
+ | "UG"
4248
+ | "UM"
4249
+ | "US"
4250
+ | "UY"
4251
+ | "UZ"
4252
+ | "VA"
4253
+ | "VC"
4254
+ | "VE"
4255
+ | "VG"
4256
+ | "VI"
4257
+ | "VN"
4258
+ | "VU"
4259
+ | "WF"
4260
+ | "WS"
4261
+ | "YE"
4262
+ | "YT"
4263
+ | "ZA"
4264
+ | "ZM"
4265
+ | "ZW";
4266
+ /** The 2-letter continent codes Cloudflare uses */
4267
+ declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
4268
+ declare type CfProperties<HostMetadata = unknown> =
4269
+ | IncomingRequestCfProperties<HostMetadata>
4270
+ | RequestInitCfProperties;
4271
+ declare interface D1Meta {
4272
+ duration: number;
4273
+ size_after: number;
4274
+ rows_read: number;
4275
+ rows_written: number;
4276
+ last_row_id: number;
4277
+ changed_db: boolean;
4278
+ changes: number;
4279
+ }
4280
+ declare interface D1Response {
4281
+ success: true;
4282
+ meta: D1Meta & Record<string, unknown>;
4283
+ error?: never;
4284
+ }
4285
+ declare type D1Result<T = unknown> = D1Response & {
4286
+ results: T[];
4287
+ };
4288
+ declare interface D1ExecResult {
4289
+ count: number;
4290
+ duration: number;
4291
+ }
4292
+ declare abstract class D1Database {
4293
+ prepare(query: string): D1PreparedStatement;
4294
+ dump(): Promise<ArrayBuffer>;
4295
+ batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
4296
+ exec(query: string): Promise<D1ExecResult>;
4297
+ }
4298
+ declare abstract class D1PreparedStatement {
4299
+ bind(...values: unknown[]): D1PreparedStatement;
4300
+ first<T = unknown>(colName: string): Promise<T | null>;
4301
+ first<T = Record<string, unknown>>(): Promise<T | null>;
4302
+ run(): Promise<D1Response>;
4303
+ all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4304
+ raw<T = unknown[]>(options: {
4305
+ columnNames: true;
4306
+ }): Promise<[string[], ...T[]]>;
4307
+ raw<T = unknown[]>(options?: { columnNames?: false }): Promise<T[]>;
4308
+ }
4309
+ // `Disposable` was added to TypeScript's standard lib types in version 5.2.
4310
+ // To support older TypeScript versions, define an empty `Disposable` interface.
4311
+ // Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
4312
+ // but this will ensure type checking on older versions still passes.
4313
+ // TypeScript's interface merging will ensure our empty interface is effectively
4314
+ // ignored when `Disposable` is included in the standard lib.
4315
+ declare interface Disposable {}
4316
+ /**
4317
+ * An email message that can be sent from a Worker.
4318
+ */
4319
+ declare interface EmailMessage {
4320
+ /**
4321
+ * Envelope From attribute of the email message.
4322
+ */
4323
+ readonly from: string;
4324
+ /**
4325
+ * Envelope To attribute of the email message.
4326
+ */
4327
+ readonly to: string;
4328
+ }
4329
+ /**
4330
+ * An email message that is sent to a consumer Worker and can be rejected/forwarded.
4331
+ */
4332
+ declare interface ForwardableEmailMessage extends EmailMessage {
4333
+ /**
4334
+ * Stream of the email message content.
4335
+ */
4336
+ readonly raw: ReadableStream<Uint8Array>;
4337
+ /**
4338
+ * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
4339
+ */
4340
+ readonly headers: Headers;
4341
+ /**
4342
+ * Size of the email message content.
4343
+ */
4344
+ readonly rawSize: number;
4345
+ /**
4346
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
4347
+ * @param reason The reject reason.
4348
+ * @returns void
4349
+ */
4350
+ setReject(reason: string): void;
4351
+ /**
4352
+ * Forward this email message to a verified destination address of the account.
4353
+ * @param rcptTo Verified destination address.
4354
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
4355
+ * @returns A promise that resolves when the email message is forwarded.
4356
+ */
4357
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
4358
+ }
4359
+ /**
4360
+ * A binding that allows a Worker to send email messages.
4361
+ */
4362
+ declare interface SendEmail {
4363
+ send(message: EmailMessage): Promise<void>;
4364
+ }
4365
+ declare abstract class EmailEvent extends ExtendableEvent {
4366
+ readonly message: ForwardableEmailMessage;
4367
+ }
4368
+ declare type EmailExportedHandler<Env = unknown> = (
4369
+ message: ForwardableEmailMessage,
4370
+ env: Env,
4371
+ ctx: ExecutionContext,
4372
+ ) => void | Promise<void>;
4373
+ declare module "cloudflare:email" {
4374
+ let _EmailMessage: {
4375
+ prototype: EmailMessage;
4376
+ new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
4377
+ };
4378
+ export { _EmailMessage as EmailMessage };
4379
+ }
4380
+ declare interface Hyperdrive {
4381
+ /**
4382
+ * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
4383
+ *
4384
+ * Calling this method returns an idential socket to if you call
4385
+ * `connect("host:port")` using the `host` and `port` fields from this object.
4386
+ * Pick whichever approach works better with your preferred DB client library.
4387
+ *
4388
+ * Note that this socket is not yet authenticated -- it's expected that your
4389
+ * code (or preferably, the client library of your choice) will authenticate
4390
+ * using the information in this class's readonly fields.
4391
+ */
4392
+ connect(): Socket;
4393
+ /**
4394
+ * A valid DB connection string that can be passed straight into the typical
4395
+ * client library/driver/ORM. This will typically be the easiest way to use
4396
+ * Hyperdrive.
4397
+ */
4398
+ readonly connectionString: string;
4399
+ /*
4400
+ * A randomly generated hostname that is only valid within the context of the
4401
+ * currently running Worker which, when passed into `connect()` function from
4402
+ * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
4403
+ * for your database.
4404
+ */
4405
+ readonly host: string;
4406
+ /*
4407
+ * The port that must be paired the the host field when connecting.
4408
+ */
4409
+ readonly port: number;
4410
+ /*
4411
+ * The username to use when authenticating to your database via Hyperdrive.
4412
+ * Unlike the host and password, this will be the same every time
4413
+ */
4414
+ readonly user: string;
4415
+ /*
4416
+ * The randomly generated password to use when authenticating to your
4417
+ * database via Hyperdrive. Like the host field, this password is only valid
4418
+ * within the context of the currently running Worker instance from which
4419
+ * it's read.
4420
+ */
4421
+ readonly password: string;
4422
+ /*
4423
+ * The name of the database to connect to.
4424
+ */
4425
+ readonly database: string;
4426
+ }
4427
+ declare type Params<P extends string = any> = Record<P, string | string[]>;
4428
+ declare type EventContext<Env, P extends string, Data> = {
4429
+ request: Request<unknown, IncomingRequestCfProperties<unknown>>;
4430
+ functionPath: string;
4431
+ waitUntil: (promise: Promise<any>) => void;
4432
+ passThroughOnException: () => void;
4433
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
4434
+ env: Env & {
4435
+ ASSETS: {
4436
+ fetch: typeof fetch;
4437
+ };
4438
+ };
4439
+ params: Params<P>;
4440
+ data: Data;
4441
+ };
4442
+ declare type PagesFunction<
4443
+ Env = unknown,
4444
+ Params extends string = any,
4445
+ Data extends Record<string, unknown> = Record<string, unknown>,
4446
+ > = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
4447
+ declare type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
4448
+ request: Request<unknown, IncomingRequestCfProperties<unknown>>;
4449
+ functionPath: string;
4450
+ waitUntil: (promise: Promise<any>) => void;
4451
+ passThroughOnException: () => void;
4452
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
4453
+ env: Env & {
4454
+ ASSETS: {
4455
+ fetch: typeof fetch;
4456
+ };
4457
+ };
4458
+ params: Params<P>;
4459
+ data: Data;
4460
+ pluginArgs: PluginArgs;
4461
+ };
4462
+ declare type PagesPluginFunction<
4463
+ Env = unknown,
4464
+ Params extends string = any,
4465
+ Data extends Record<string, unknown> = Record<string, unknown>,
4466
+ PluginArgs = unknown,
4467
+ > = (
4468
+ context: EventPluginContext<Env, Params, Data, PluginArgs>,
4469
+ ) => Response | Promise<Response>;
4470
+ declare module "assets:*" {
4471
+ export const onRequest: PagesFunction;
4472
+ }
4473
+ // PubSubMessage represents an incoming PubSub message.
4474
+ // The message includes metadata about the broker, the client, and the payload
4475
+ // itself.
4476
+ // https://developers.cloudflare.com/pub-sub/
4477
+ declare interface PubSubMessage {
4478
+ // Message ID
4479
+ readonly mid: number;
4480
+ // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
4481
+ readonly broker: string;
4482
+ // The MQTT topic the message was sent on.
4483
+ readonly topic: string;
4484
+ // The client ID of the client that published this message.
4485
+ readonly clientId: string;
4486
+ // The unique identifier (JWT ID) used by the client to authenticate, if token
4487
+ // auth was used.
4488
+ readonly jti?: string;
4489
+ // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
4490
+ // received the message from the client.
4491
+ readonly receivedAt: number;
4492
+ // An (optional) string with the MIME type of the payload, if set by the
4493
+ // client.
4494
+ readonly contentType: string;
4495
+ // Set to 1 when the payload is a UTF-8 string
4496
+ // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
4497
+ readonly payloadFormatIndicator: number;
4498
+ // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
4499
+ // You can use payloadFormatIndicator to inspect this before decoding.
4500
+ payload: string | Uint8Array;
4501
+ }
4502
+ // JsonWebKey extended by kid parameter
4503
+ declare interface JsonWebKeyWithKid extends JsonWebKey {
4504
+ // Key Identifier of the JWK
4505
+ readonly kid: string;
4506
+ }
4507
+ // Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
4508
+ // to referenced by `Fetcher`. This is included in the "importable" version of the types which
4509
+ // strips all `module` blocks.
4510
+ declare namespace Rpc {
4511
+ // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
4512
+ // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
4513
+ // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
4514
+ // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
4515
+ export const __RPC_STUB_BRAND: "__RPC_STUB_BRAND";
4516
+ export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
4517
+ export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
4518
+ export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
4519
+ export interface RpcTargetBranded {
4520
+ [__RPC_TARGET_BRAND]: never;
4521
+ }
4522
+ export interface WorkerEntrypointBranded {
4523
+ [__WORKER_ENTRYPOINT_BRAND]: never;
4524
+ }
4525
+ export interface DurableObjectBranded {
4526
+ [__DURABLE_OBJECT_BRAND]: never;
4527
+ }
4528
+ export type EntrypointBranded =
4529
+ | WorkerEntrypointBranded
4530
+ | DurableObjectBranded;
4531
+ // Types that can be used through `Stub`s
4532
+ export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
4533
+ // Types that can be passed over RPC
4534
+ type Serializable =
4535
+ // Structured cloneables
4536
+ | void
4537
+ | undefined
4538
+ | null
4539
+ | boolean
4540
+ | number
4541
+ | bigint
4542
+ | string
4543
+ | TypedArray
4544
+ | ArrayBuffer
4545
+ | DataView
4546
+ | Date
4547
+ | Error
4548
+ | RegExp
4549
+ // Structured cloneable composites
4550
+ | Map<Serializable, Serializable>
4551
+ | Set<Serializable>
4552
+ | ReadonlyArray<Serializable>
4553
+ | {
4554
+ [key: string | number]: Serializable;
4555
+ }
4556
+ // Special types
4557
+ | ReadableStream<Uint8Array>
4558
+ | WritableStream<Uint8Array>
4559
+ | Request
4560
+ | Response
4561
+ | Headers
4562
+ | Stub<Stubable>
4563
+ // Serialized as stubs, see `Stubify`
4564
+ | Stubable;
4565
+ // Base type for all RPC stubs, including common memory management methods.
4566
+ // `T` is used as a marker type for unwrapping `Stub`s later.
4567
+ interface StubBase<T extends Stubable> extends Disposable {
4568
+ [__RPC_STUB_BRAND]: T;
4569
+ dup(): this;
4570
+ }
4571
+ export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
4572
+ // Recursively rewrite all `Stubable` types with `Stub`s
4573
+ type Stubify<T> = T extends Stubable
4574
+ ? Stub<T>
4575
+ : T extends Map<infer K, infer V>
4576
+ ? Map<Stubify<K>, Stubify<V>>
4577
+ : T extends Set<infer V>
4578
+ ? Set<Stubify<V>>
4579
+ : T extends Array<infer V>
4580
+ ? Array<Stubify<V>>
4581
+ : T extends ReadonlyArray<infer V>
4582
+ ? ReadonlyArray<Stubify<V>>
4583
+ : T extends {
4584
+ [key: string | number]: unknown;
4585
+ }
4586
+ ? {
4587
+ [K in keyof T]: Stubify<T[K]>;
4588
+ }
4589
+ : T;
4590
+ // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
4591
+ // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
4592
+ // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
4593
+ type Unstubify<T> =
4594
+ T extends StubBase<infer V>
4595
+ ? V
4596
+ : T extends Map<infer K, infer V>
4597
+ ? Map<Unstubify<K>, Unstubify<V>>
4598
+ : T extends Set<infer V>
4599
+ ? Set<Unstubify<V>>
4600
+ : T extends Array<infer V>
4601
+ ? Array<Unstubify<V>>
4602
+ : T extends ReadonlyArray<infer V>
4603
+ ? ReadonlyArray<Unstubify<V>>
4604
+ : T extends {
4605
+ [key: string | number]: unknown;
4606
+ }
4607
+ ? {
4608
+ [K in keyof T]: Unstubify<T[K]>;
4609
+ }
4610
+ : T;
4611
+ type UnstubifyAll<A extends any[]> = {
4612
+ [I in keyof A]: Unstubify<A[I]>;
4613
+ };
4614
+ // Utility type for adding `Provider`/`Disposable`s to `object` types only.
4615
+ // Note `unknown & T` is equivalent to `T`.
4616
+ type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
4617
+ type MaybeDisposable<T> = T extends object ? Disposable : unknown;
4618
+ // Type for method return or property on an RPC interface.
4619
+ // - Stubable types are replaced by stubs.
4620
+ // - Serializable types are passed by value, with stubable types replaced by stubs
4621
+ // and a top-level `Disposer`.
4622
+ // Everything else can't be passed over PRC.
4623
+ // Technically, we use custom thenables here, but they quack like `Promise`s.
4624
+ // Intersecting with `(Maybe)Provider` allows pipelining.
4625
+ type Result<R> = R extends Stubable
4626
+ ? Promise<Stub<R>> & Provider<R>
4627
+ : R extends Serializable
4628
+ ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
4629
+ : never;
4630
+ // Type for method or property on an RPC interface.
4631
+ // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
4632
+ // Unwrapping `Stub`s allows calling with `Stubable` arguments.
4633
+ // For properties, rewrite types to be `Result`s.
4634
+ // In each case, unwrap `Promise`s.
4635
+ type MethodOrProperty<V> = V extends (...args: infer P) => infer R
4636
+ ? (...args: UnstubifyAll<P>) => Result<Awaited<R>>
4637
+ : Result<Awaited<V>>;
4638
+ // Type for the callable part of an `Provider` if `T` is callable.
4639
+ // This is intersected with methods/properties.
4640
+ type MaybeCallableProvider<T> = T extends (...args: any[]) => any
4641
+ ? MethodOrProperty<T>
4642
+ : unknown;
4643
+ // Base type for all other types providing RPC-like interfaces.
4644
+ // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
4645
+ // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
4646
+ export type Provider<
4647
+ T extends object,
4648
+ Reserved extends string = never,
4649
+ > = MaybeCallableProvider<T> & {
4650
+ [K in Exclude<
4651
+ keyof T,
4652
+ Reserved | symbol | keyof StubBase<never>
4653
+ >]: MethodOrProperty<T[K]>;
4654
+ };
4655
+ }
4656
+ declare module "cloudflare:workers" {
4657
+ export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
4658
+ export const RpcStub: {
4659
+ new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
4660
+ };
4661
+ export abstract class RpcTarget implements Rpc.RpcTargetBranded {
4662
+ [Rpc.__RPC_TARGET_BRAND]: never;
4663
+ }
4664
+ // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
4665
+ export abstract class WorkerEntrypoint<Env = unknown>
4666
+ implements Rpc.WorkerEntrypointBranded
4667
+ {
4668
+ [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
4669
+ protected ctx: ExecutionContext;
4670
+ protected env: Env;
4671
+ constructor(ctx: ExecutionContext, env: Env);
4672
+ fetch?(request: Request): Response | Promise<Response>;
4673
+ tail?(events: TraceItem[]): void | Promise<void>;
4674
+ trace?(traces: TraceItem[]): void | Promise<void>;
4675
+ scheduled?(controller: ScheduledController): void | Promise<void>;
4676
+ queue?(batch: MessageBatch<unknown>): void | Promise<void>;
4677
+ test?(controller: TestController): void | Promise<void>;
4678
+ }
4679
+ export abstract class DurableObject<Env = unknown>
4680
+ implements Rpc.DurableObjectBranded
4681
+ {
4682
+ [Rpc.__DURABLE_OBJECT_BRAND]: never;
4683
+ protected ctx: DurableObjectState;
4684
+ protected env: Env;
4685
+ constructor(ctx: DurableObjectState, env: Env);
4686
+ fetch?(request: Request): Response | Promise<Response>;
4687
+ alarm?(): void | Promise<void>;
4688
+ webSocketMessage?(
4689
+ ws: WebSocket,
4690
+ message: string | ArrayBuffer,
4691
+ ): void | Promise<void>;
4692
+ webSocketClose?(
4693
+ ws: WebSocket,
4694
+ code: number,
4695
+ reason: string,
4696
+ wasClean: boolean,
4697
+ ): void | Promise<void>;
4698
+ webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
4699
+ }
4700
+ }
4701
+ declare module "cloudflare:sockets" {
4702
+ function _connect(
4703
+ address: string | SocketAddress,
4704
+ options?: SocketOptions,
4705
+ ): Socket;
4706
+ export { _connect as connect };
4707
+ }
4708
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
4709
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
4710
+ // https://opensource.org/licenses/Apache-2.0
4711
+ /**
4712
+ * Data types supported for holding vector metadata.
4713
+ */
4714
+ declare type VectorizeVectorMetadataValue =
4715
+ | string
4716
+ | number
4717
+ | boolean
4718
+ | string[];
4719
+ /**
4720
+ * Additional information to associate with a vector.
4721
+ */
4722
+ declare type VectorizeVectorMetadata =
4723
+ | VectorizeVectorMetadataValue
4724
+ | Record<string, VectorizeVectorMetadataValue>;
4725
+ declare type VectorFloatArray = Float32Array | Float64Array;
4726
+ declare interface VectorizeError {
4727
+ code?: number;
4728
+ error: string;
4729
+ }
4730
+ /**
4731
+ * Comparison logic/operation to use for metadata filtering.
4732
+ *
4733
+ * This list is expected to grow as support for more operations are released.
4734
+ */
4735
+ declare type VectorizeVectorMetadataFilterOp = "$eq" | "$ne";
4736
+ /**
4737
+ * Filter criteria for vector metadata used to limit the retrieved query result set.
4738
+ */
4739
+ declare type VectorizeVectorMetadataFilter = {
4740
+ [field: string]:
4741
+ | Exclude<VectorizeVectorMetadataValue, string[]>
4742
+ | null
4743
+ | {
4744
+ [Op in VectorizeVectorMetadataFilterOp]?: Exclude<
4745
+ VectorizeVectorMetadataValue,
4746
+ string[]
4747
+ > | null;
4748
+ };
4749
+ };
4750
+ /**
4751
+ * Supported distance metrics for an index.
4752
+ * Distance metrics determine how other "similar" vectors are determined.
4753
+ */
4754
+ declare type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
4755
+ declare interface VectorizeQueryOptions {
4756
+ topK?: number;
4757
+ namespace?: string;
4758
+ returnValues?: boolean;
4759
+ returnMetadata?: boolean;
4760
+ filter?: VectorizeVectorMetadataFilter;
4761
+ }
4762
+ /**
4763
+ * Information about the configuration of an index.
4764
+ */
4765
+ declare type VectorizeIndexConfig =
4766
+ | {
4767
+ dimensions: number;
4768
+ metric: VectorizeDistanceMetric;
4769
+ }
4770
+ | {
4771
+ preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
4772
+ };
4773
+ /**
4774
+ * Metadata about an existing index.
4775
+ */
4776
+ declare interface VectorizeIndexDetails {
4777
+ /** The unique ID of the index */
4778
+ readonly id: string;
4779
+ /** The name of the index. */
4780
+ name: string;
4781
+ /** (optional) A human readable description for the index. */
4782
+ description?: string;
4783
+ /** The index configuration, including the dimension size and distance metric. */
4784
+ config: VectorizeIndexConfig;
4785
+ /** The number of records containing vectors within the index. */
4786
+ vectorsCount: number;
4787
+ }
4788
+ /**
4789
+ * Represents a single vector value set along with its associated metadata.
4790
+ */
4791
+ declare interface VectorizeVector {
4792
+ /** 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. */
4793
+ id: string;
4794
+ /** The vector values */
4795
+ values: VectorFloatArray | number[];
4796
+ /** The namespace this vector belongs to. */
4797
+ namespace?: string;
4798
+ /** Metadata associated with the vector. Includes the values of the other fields and potentially additional details. */
4799
+ metadata?: Record<string, VectorizeVectorMetadata>;
4800
+ }
4801
+ /**
4802
+ * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
4803
+ */
4804
+ declare type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
4805
+ Omit<VectorizeVector, "values"> & {
4806
+ /** The score or rank for similarity, when returned as a result */
4807
+ score: number;
4808
+ };
4809
+ /**
4810
+ * A set of vector {@link VectorizeMatch} for a particular query.
4811
+ */
4812
+ declare interface VectorizeMatches {
4813
+ matches: VectorizeMatch[];
4814
+ count: number;
4815
+ }
4816
+ /**
4817
+ * Results of an operation that performed a mutation on a set of vectors.
4818
+ * Here, `ids` is a list of vectors that were successfully processed.
4819
+ */
4820
+ declare interface VectorizeVectorMutation {
4821
+ /* List of ids of vectors that were successfully processed. */
4822
+ ids: string[];
4823
+ /* Total count of the number of processed vectors. */
4824
+ count: number;
4825
+ }
4826
+ declare abstract class VectorizeIndex {
4827
+ /**
4828
+ * Get information about the currently bound index.
4829
+ * @returns A promise that resolves with information about the current index.
4830
+ */
4831
+ public describe(): Promise<VectorizeIndexDetails>;
4832
+ /**
4833
+ * Use the provided vector to perform a similarity search across the index.
4834
+ * @param vector Input vector that will be used to drive the similarity search.
4835
+ * @param options Configuration options to massage the returned data.
4836
+ * @returns A promise that resolves with matched and scored vectors.
4837
+ */
4838
+ public query(
4839
+ vector: VectorFloatArray | number[],
4840
+ options: VectorizeQueryOptions,
4841
+ ): Promise<VectorizeMatches>;
4842
+ /**
4843
+ * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
4844
+ * @param vectors List of vectors that will be inserted.
4845
+ * @returns A promise that resolves with the ids & count of records that were successfully processed.
4846
+ */
4847
+ public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
4848
+ /**
4849
+ * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
4850
+ * @param vectors List of vectors that will be upserted.
4851
+ * @returns A promise that resolves with the ids & count of records that were successfully processed.
4852
+ */
4853
+ public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
4854
+ /**
4855
+ * Delete a list of vectors with a matching id.
4856
+ * @param ids List of vector ids that should be deleted.
4857
+ * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
4858
+ */
4859
+ public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
4860
+ /**
4861
+ * Get a list of vectors with a matching id.
4862
+ * @param ids List of vector ids that should be returned.
4863
+ * @returns A promise that resolves with the raw unscored vectors matching the id set.
4864
+ */
4865
+ public getByIds(ids: string[]): Promise<VectorizeVector[]>;
4866
+ }
4867
+ /**
4868
+ * The interface for "version_metadata" binding
4869
+ * providing metadata about the Worker Version using this binding.
4870
+ */
4871
+ declare type WorkerVersionMetadata = {
4872
+ /** The ID of the Worker Version using this binding */
4873
+ id: string;
4874
+ /** The tag of the Worker Version using this binding */
4875
+ tag: string;
4876
+ };
4877
+ declare interface DynamicDispatchLimits {
4878
+ /**
4879
+ * Limit CPU time in milliseconds.
4880
+ */
4881
+ cpuMs?: number;
4882
+ /**
4883
+ * Limit number of subrequests.
4884
+ */
4885
+ subRequests?: number;
4886
+ }
4887
+ declare interface DynamicDispatchOptions {
4888
+ /**
4889
+ * Limit resources of invoked Worker script.
4890
+ */
4891
+ limits?: DynamicDispatchLimits;
4892
+ /**
4893
+ * Arguments for outbound Worker script, if configured.
4894
+ */
4895
+ outbound?: {
4896
+ [key: string]: any;
4897
+ };
4898
+ }
4899
+ declare interface DispatchNamespace {
4900
+ /**
4901
+ * @param name Name of the Worker script.
4902
+ * @param args Arguments to Worker script.
4903
+ * @param options Options for Dynamic Dispatch invocation.
4904
+ * @returns A Fetcher object that allows you to send requests to the Worker script.
4905
+ * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
4906
+ */
4907
+ get(
4908
+ name: string,
4909
+ args?: {
4910
+ [key: string]: any;
4911
+ },
4912
+ options?: DynamicDispatchOptions,
4913
+ ): Fetcher;
4914
+ }