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