@cloudflare/workers-types 4.20230404.0 → 4.20230419.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 +46 -74
- package/2021-11-03/index.ts +46 -74
- package/2022-01-31/index.d.ts +46 -74
- package/2022-01-31/index.ts +46 -74
- package/2022-03-21/index.d.ts +46 -74
- package/2022-03-21/index.ts +46 -74
- package/2022-08-04/index.d.ts +46 -74
- package/2022-08-04/index.ts +46 -74
- package/2022-10-31/index.d.ts +46 -74
- package/2022-10-31/index.ts +46 -74
- package/2022-11-30/index.d.ts +46 -74
- package/2022-11-30/index.ts +46 -74
- package/experimental/index.d.ts +99 -74
- package/experimental/index.ts +99 -74
- package/index.d.ts +46 -74
- package/index.ts +46 -74
- package/oldest/index.d.ts +46 -74
- package/oldest/index.ts +46 -74
- package/package.json +1 -1
package/experimental/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ declare class DOMException extends Error {
|
|
|
49
49
|
declare type WorkerGlobalScopeEventMap = {
|
|
50
50
|
fetch: FetchEvent;
|
|
51
51
|
scheduled: ScheduledEvent;
|
|
52
|
+
queue: QueueEvent;
|
|
52
53
|
unhandledrejection: PromiseRejectionEvent;
|
|
53
54
|
rejectionhandled: PromiseRejectionEvent;
|
|
54
55
|
};
|
|
@@ -187,7 +188,8 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
187
188
|
ExtendableEvent: typeof ExtendableEvent;
|
|
188
189
|
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
|
189
190
|
FetchEvent: typeof FetchEvent;
|
|
190
|
-
|
|
191
|
+
TailEvent: typeof TailEvent;
|
|
192
|
+
TraceEvent: typeof TailEvent;
|
|
191
193
|
ScheduledEvent: typeof ScheduledEvent;
|
|
192
194
|
MessageEvent: typeof MessageEvent;
|
|
193
195
|
CloseEvent: typeof CloseEvent;
|
|
@@ -299,6 +301,11 @@ declare type ExportedHandlerFetchHandler<
|
|
|
299
301
|
env: Env,
|
|
300
302
|
ctx: ExecutionContext
|
|
301
303
|
) => Response | Promise<Response>;
|
|
304
|
+
declare type ExportedHandlerTailHandler<Env = unknown> = (
|
|
305
|
+
events: TraceItem[],
|
|
306
|
+
env: Env,
|
|
307
|
+
ctx: ExecutionContext
|
|
308
|
+
) => void | Promise<void>;
|
|
302
309
|
declare type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
303
310
|
traces: TraceItem[],
|
|
304
311
|
env: Env,
|
|
@@ -325,10 +332,11 @@ declare interface ExportedHandler<
|
|
|
325
332
|
CfHostMetadata = unknown
|
|
326
333
|
> {
|
|
327
334
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
335
|
+
tail?: ExportedHandlerTailHandler<Env>;
|
|
328
336
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
329
337
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
330
338
|
test?: ExportedHandlerTestHandler<Env>;
|
|
331
|
-
queue?: ExportedHandlerQueueHandler<Env,
|
|
339
|
+
queue?: ExportedHandlerQueueHandler<Env, Message>;
|
|
332
340
|
}
|
|
333
341
|
declare interface StructuredSerializeOptions {
|
|
334
342
|
transfer?: any[];
|
|
@@ -363,6 +371,10 @@ declare interface DurableObjectNamespace {
|
|
|
363
371
|
id: DurableObjectId,
|
|
364
372
|
options?: DurableObjectNamespaceGetDurableObjectOptions
|
|
365
373
|
): DurableObjectStub;
|
|
374
|
+
getExisting(
|
|
375
|
+
id: DurableObjectId,
|
|
376
|
+
options?: DurableObjectNamespaceGetDurableObjectOptions
|
|
377
|
+
): DurableObjectStub;
|
|
366
378
|
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
|
|
367
379
|
}
|
|
368
380
|
declare type DurableObjectJurisdiction = "eu" | "fedramp";
|
|
@@ -453,6 +465,7 @@ declare interface DurableObjectStorage {
|
|
|
453
465
|
): Promise<void>;
|
|
454
466
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
455
467
|
sync(): Promise<void>;
|
|
468
|
+
sql: SqlStorage;
|
|
456
469
|
}
|
|
457
470
|
declare interface DurableObjectListOptions {
|
|
458
471
|
start?: string;
|
|
@@ -1049,11 +1062,21 @@ declare interface RequestInit<Cf = CfProperties> {
|
|
|
1049
1062
|
}
|
|
1050
1063
|
declare abstract class Fetcher {
|
|
1051
1064
|
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1065
|
+
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1066
|
+
queue(
|
|
1067
|
+
queueName: string,
|
|
1068
|
+
messages: ServiceBindingQueueMessage[]
|
|
1069
|
+
): Promise<QueueResponse>;
|
|
1052
1070
|
}
|
|
1053
1071
|
declare interface FetcherPutOptions {
|
|
1054
1072
|
expiration?: number;
|
|
1055
1073
|
expirationTtl?: number;
|
|
1056
1074
|
}
|
|
1075
|
+
declare interface ServiceBindingQueueMessage<Body = unknown> {
|
|
1076
|
+
id: string;
|
|
1077
|
+
timestamp: Date;
|
|
1078
|
+
body: Body;
|
|
1079
|
+
}
|
|
1057
1080
|
declare interface KVNamespaceListKey<Metadata, Key extends string = string> {
|
|
1058
1081
|
name: Key;
|
|
1059
1082
|
expiration?: number;
|
|
@@ -1161,6 +1184,40 @@ declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
|
|
|
1161
1184
|
value: Value | null;
|
|
1162
1185
|
metadata: Metadata | null;
|
|
1163
1186
|
}
|
|
1187
|
+
declare interface Queue<Body> {
|
|
1188
|
+
send(message: Body): Promise<void>;
|
|
1189
|
+
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
1190
|
+
}
|
|
1191
|
+
declare interface QueueSendOptions {}
|
|
1192
|
+
declare interface MessageSendRequest<Body = unknown> {
|
|
1193
|
+
body: Body;
|
|
1194
|
+
}
|
|
1195
|
+
declare interface QueueResponse {
|
|
1196
|
+
outcome: number;
|
|
1197
|
+
retryAll: boolean;
|
|
1198
|
+
ackAll: boolean;
|
|
1199
|
+
explicitRetries: string[];
|
|
1200
|
+
explicitAcks: string[];
|
|
1201
|
+
}
|
|
1202
|
+
declare interface Message<Body = unknown> {
|
|
1203
|
+
readonly id: string;
|
|
1204
|
+
readonly timestamp: Date;
|
|
1205
|
+
readonly body: Body;
|
|
1206
|
+
retry(): void;
|
|
1207
|
+
ack(): void;
|
|
1208
|
+
}
|
|
1209
|
+
declare interface QueueEvent<Body = unknown> extends ExtendableEvent {
|
|
1210
|
+
readonly messages: readonly Message<Body>[];
|
|
1211
|
+
readonly queue: string;
|
|
1212
|
+
retryAll(): void;
|
|
1213
|
+
ackAll(): void;
|
|
1214
|
+
}
|
|
1215
|
+
declare interface MessageBatch<Body = unknown> {
|
|
1216
|
+
readonly messages: readonly Message<Body>[];
|
|
1217
|
+
readonly queue: string;
|
|
1218
|
+
retryAll(): void;
|
|
1219
|
+
ackAll(): void;
|
|
1220
|
+
}
|
|
1164
1221
|
declare interface R2Error extends Error {
|
|
1165
1222
|
readonly name: string;
|
|
1166
1223
|
readonly code: number;
|
|
@@ -1594,7 +1651,8 @@ declare interface QueuingStrategyInit {
|
|
|
1594
1651
|
*/
|
|
1595
1652
|
highWaterMark: number;
|
|
1596
1653
|
}
|
|
1597
|
-
declare abstract class
|
|
1654
|
+
declare abstract class TailEvent extends ExtendableEvent {
|
|
1655
|
+
readonly events: TraceItem[];
|
|
1598
1656
|
readonly traces: TraceItem[];
|
|
1599
1657
|
}
|
|
1600
1658
|
declare interface TraceItem {
|
|
@@ -1816,6 +1874,37 @@ declare const WebSocketPair: {
|
|
|
1816
1874
|
1: WebSocket;
|
|
1817
1875
|
};
|
|
1818
1876
|
};
|
|
1877
|
+
declare interface SqlStorage {
|
|
1878
|
+
exec(query: string, ...bindings: any[]): SqlStorageCursor;
|
|
1879
|
+
prepare(query: string): SqlStorageStatement;
|
|
1880
|
+
Cursor: typeof SqlStorageCursor;
|
|
1881
|
+
Statement: typeof SqlStorageStatement;
|
|
1882
|
+
}
|
|
1883
|
+
declare abstract class SqlStorageStatement {}
|
|
1884
|
+
declare abstract class SqlStorageCursor {
|
|
1885
|
+
raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
|
|
1886
|
+
[Symbol.iterator](): IterableIterator<
|
|
1887
|
+
Record<string, (ArrayBuffer | string | number) | null>
|
|
1888
|
+
>;
|
|
1889
|
+
}
|
|
1890
|
+
declare interface Socket {
|
|
1891
|
+
get readable(): ReadableStream;
|
|
1892
|
+
get writable(): WritableStream;
|
|
1893
|
+
get closed(): Promise<void>;
|
|
1894
|
+
close(): Promise<void>;
|
|
1895
|
+
startTls(options?: TlsOptions): Socket;
|
|
1896
|
+
}
|
|
1897
|
+
declare interface SocketOptions {
|
|
1898
|
+
secureTransport?: string;
|
|
1899
|
+
allowHalfOpen: boolean;
|
|
1900
|
+
}
|
|
1901
|
+
declare interface SocketAddress {
|
|
1902
|
+
hostname: string;
|
|
1903
|
+
port: number;
|
|
1904
|
+
}
|
|
1905
|
+
declare interface TlsOptions {
|
|
1906
|
+
expectedServerHostname?: string;
|
|
1907
|
+
}
|
|
1819
1908
|
declare interface BasicImageTransformations {
|
|
1820
1909
|
/**
|
|
1821
1910
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -2205,8 +2294,7 @@ declare interface IncomingRequestCfPropertiesBase
|
|
|
2205
2294
|
declare interface IncomingRequestCfPropertiesBotManagementBase {
|
|
2206
2295
|
/**
|
|
2207
2296
|
* Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
|
|
2208
|
-
* represented as an integer percentage between `1` (almost certainly human)
|
|
2209
|
-
* and `99` (almost certainly a bot).
|
|
2297
|
+
* represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
|
|
2210
2298
|
*
|
|
2211
2299
|
* @example 54
|
|
2212
2300
|
*/
|
|
@@ -2951,75 +3039,12 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2951
3039
|
// Key Identifier of the JWK
|
|
2952
3040
|
readonly kid: string;
|
|
2953
3041
|
}
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
*/
|
|
2957
|
-
declare interface Message<Body = unknown> {
|
|
3042
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3043
|
+
declare interface DispatchNamespace {
|
|
2958
3044
|
/**
|
|
2959
|
-
*
|
|
3045
|
+
* @param name Name of the Worker script.
|
|
3046
|
+
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
3047
|
+
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2960
3048
|
*/
|
|
2961
|
-
|
|
2962
|
-
/**
|
|
2963
|
-
* A timestamp when the message was sent.
|
|
2964
|
-
*/
|
|
2965
|
-
readonly timestamp: Date;
|
|
2966
|
-
/**
|
|
2967
|
-
* The body of the message.
|
|
2968
|
-
*/
|
|
2969
|
-
readonly body: Body;
|
|
2970
|
-
/**
|
|
2971
|
-
* Marks message to be retried.
|
|
2972
|
-
*/
|
|
2973
|
-
retry(): void;
|
|
2974
|
-
/**
|
|
2975
|
-
* Marks message acknowledged.
|
|
2976
|
-
*/
|
|
2977
|
-
ack(): void;
|
|
2978
|
-
}
|
|
2979
|
-
/**
|
|
2980
|
-
* A batch of messages that are sent to a consumer Worker.
|
|
2981
|
-
*/
|
|
2982
|
-
declare interface MessageBatch<Body = unknown> {
|
|
2983
|
-
/**
|
|
2984
|
-
* The name of the Queue that belongs to this batch.
|
|
2985
|
-
*/
|
|
2986
|
-
readonly queue: string;
|
|
2987
|
-
/**
|
|
2988
|
-
* An array of messages in the batch. Ordering of messages is not guaranteed.
|
|
2989
|
-
*/
|
|
2990
|
-
readonly messages: readonly Message<Body>[];
|
|
2991
|
-
/**
|
|
2992
|
-
* Marks every message to be retried in the next batch.
|
|
2993
|
-
*/
|
|
2994
|
-
retryAll(): void;
|
|
2995
|
-
/**
|
|
2996
|
-
* Marks every message acknowledged in the batch.
|
|
2997
|
-
*/
|
|
2998
|
-
ackAll(): void;
|
|
2999
|
-
}
|
|
3000
|
-
/**
|
|
3001
|
-
* A wrapper class used to structure message batches.
|
|
3002
|
-
*/
|
|
3003
|
-
declare type MessageSendRequest<Body = unknown> = {
|
|
3004
|
-
/**
|
|
3005
|
-
* The body of the message.
|
|
3006
|
-
*/
|
|
3007
|
-
body: Body;
|
|
3008
|
-
};
|
|
3009
|
-
/**
|
|
3010
|
-
* A binding that allows a producer to send messages to a Queue.
|
|
3011
|
-
*/
|
|
3012
|
-
declare interface Queue<Body = any> {
|
|
3013
|
-
/**
|
|
3014
|
-
* Sends a message to the Queue.
|
|
3015
|
-
* @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.
|
|
3016
|
-
* @returns A promise that resolves when the message is confirmed to be written to disk.
|
|
3017
|
-
*/
|
|
3018
|
-
send(message: Body): Promise<void>;
|
|
3019
|
-
/**
|
|
3020
|
-
* Sends a batch of messages to the Queue.
|
|
3021
|
-
* @param messages Each item in the input must be supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types). A batch can contain up to 100 messages, though items are limited to 128 KB each, and the total size of the array cannot exceed 256 KB.
|
|
3022
|
-
* @returns A promise that resolves when the messages are confirmed to be written to disk.
|
|
3023
|
-
*/
|
|
3024
|
-
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
3049
|
+
get(name: string): Fetcher;
|
|
3025
3050
|
}
|
package/experimental/index.ts
CHANGED
|
@@ -49,6 +49,7 @@ export declare class DOMException extends Error {
|
|
|
49
49
|
export type WorkerGlobalScopeEventMap = {
|
|
50
50
|
fetch: FetchEvent;
|
|
51
51
|
scheduled: ScheduledEvent;
|
|
52
|
+
queue: QueueEvent;
|
|
52
53
|
unhandledrejection: PromiseRejectionEvent;
|
|
53
54
|
rejectionhandled: PromiseRejectionEvent;
|
|
54
55
|
};
|
|
@@ -187,7 +188,8 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
187
188
|
ExtendableEvent: typeof ExtendableEvent;
|
|
188
189
|
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
|
189
190
|
FetchEvent: typeof FetchEvent;
|
|
190
|
-
|
|
191
|
+
TailEvent: typeof TailEvent;
|
|
192
|
+
TraceEvent: typeof TailEvent;
|
|
191
193
|
ScheduledEvent: typeof ScheduledEvent;
|
|
192
194
|
MessageEvent: typeof MessageEvent;
|
|
193
195
|
CloseEvent: typeof CloseEvent;
|
|
@@ -301,6 +303,11 @@ export type ExportedHandlerFetchHandler<
|
|
|
301
303
|
env: Env,
|
|
302
304
|
ctx: ExecutionContext
|
|
303
305
|
) => Response | Promise<Response>;
|
|
306
|
+
export type ExportedHandlerTailHandler<Env = unknown> = (
|
|
307
|
+
events: TraceItem[],
|
|
308
|
+
env: Env,
|
|
309
|
+
ctx: ExecutionContext
|
|
310
|
+
) => void | Promise<void>;
|
|
304
311
|
export type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
305
312
|
traces: TraceItem[],
|
|
306
313
|
env: Env,
|
|
@@ -327,10 +334,11 @@ export interface ExportedHandler<
|
|
|
327
334
|
CfHostMetadata = unknown
|
|
328
335
|
> {
|
|
329
336
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
337
|
+
tail?: ExportedHandlerTailHandler<Env>;
|
|
330
338
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
331
339
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
332
340
|
test?: ExportedHandlerTestHandler<Env>;
|
|
333
|
-
queue?: ExportedHandlerQueueHandler<Env,
|
|
341
|
+
queue?: ExportedHandlerQueueHandler<Env, Message>;
|
|
334
342
|
}
|
|
335
343
|
export interface StructuredSerializeOptions {
|
|
336
344
|
transfer?: any[];
|
|
@@ -365,6 +373,10 @@ export interface DurableObjectNamespace {
|
|
|
365
373
|
id: DurableObjectId,
|
|
366
374
|
options?: DurableObjectNamespaceGetDurableObjectOptions
|
|
367
375
|
): DurableObjectStub;
|
|
376
|
+
getExisting(
|
|
377
|
+
id: DurableObjectId,
|
|
378
|
+
options?: DurableObjectNamespaceGetDurableObjectOptions
|
|
379
|
+
): DurableObjectStub;
|
|
368
380
|
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
|
|
369
381
|
}
|
|
370
382
|
export type DurableObjectJurisdiction = "eu" | "fedramp";
|
|
@@ -455,6 +467,7 @@ export interface DurableObjectStorage {
|
|
|
455
467
|
): Promise<void>;
|
|
456
468
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
457
469
|
sync(): Promise<void>;
|
|
470
|
+
sql: SqlStorage;
|
|
458
471
|
}
|
|
459
472
|
export interface DurableObjectListOptions {
|
|
460
473
|
start?: string;
|
|
@@ -1051,11 +1064,21 @@ export interface RequestInit<Cf = CfProperties> {
|
|
|
1051
1064
|
}
|
|
1052
1065
|
export declare abstract class Fetcher {
|
|
1053
1066
|
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1067
|
+
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1068
|
+
queue(
|
|
1069
|
+
queueName: string,
|
|
1070
|
+
messages: ServiceBindingQueueMessage[]
|
|
1071
|
+
): Promise<QueueResponse>;
|
|
1054
1072
|
}
|
|
1055
1073
|
export interface FetcherPutOptions {
|
|
1056
1074
|
expiration?: number;
|
|
1057
1075
|
expirationTtl?: number;
|
|
1058
1076
|
}
|
|
1077
|
+
export interface ServiceBindingQueueMessage<Body = unknown> {
|
|
1078
|
+
id: string;
|
|
1079
|
+
timestamp: Date;
|
|
1080
|
+
body: Body;
|
|
1081
|
+
}
|
|
1059
1082
|
export interface KVNamespaceListKey<Metadata, Key extends string = string> {
|
|
1060
1083
|
name: Key;
|
|
1061
1084
|
expiration?: number;
|
|
@@ -1163,6 +1186,40 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
|
|
|
1163
1186
|
value: Value | null;
|
|
1164
1187
|
metadata: Metadata | null;
|
|
1165
1188
|
}
|
|
1189
|
+
export interface Queue<Body> {
|
|
1190
|
+
send(message: Body): Promise<void>;
|
|
1191
|
+
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
1192
|
+
}
|
|
1193
|
+
export interface QueueSendOptions {}
|
|
1194
|
+
export interface MessageSendRequest<Body = unknown> {
|
|
1195
|
+
body: Body;
|
|
1196
|
+
}
|
|
1197
|
+
export interface QueueResponse {
|
|
1198
|
+
outcome: number;
|
|
1199
|
+
retryAll: boolean;
|
|
1200
|
+
ackAll: boolean;
|
|
1201
|
+
explicitRetries: string[];
|
|
1202
|
+
explicitAcks: string[];
|
|
1203
|
+
}
|
|
1204
|
+
export interface Message<Body = unknown> {
|
|
1205
|
+
readonly id: string;
|
|
1206
|
+
readonly timestamp: Date;
|
|
1207
|
+
readonly body: Body;
|
|
1208
|
+
retry(): void;
|
|
1209
|
+
ack(): void;
|
|
1210
|
+
}
|
|
1211
|
+
export interface QueueEvent<Body = unknown> extends ExtendableEvent {
|
|
1212
|
+
readonly messages: readonly Message<Body>[];
|
|
1213
|
+
readonly queue: string;
|
|
1214
|
+
retryAll(): void;
|
|
1215
|
+
ackAll(): void;
|
|
1216
|
+
}
|
|
1217
|
+
export interface MessageBatch<Body = unknown> {
|
|
1218
|
+
readonly messages: readonly Message<Body>[];
|
|
1219
|
+
readonly queue: string;
|
|
1220
|
+
retryAll(): void;
|
|
1221
|
+
ackAll(): void;
|
|
1222
|
+
}
|
|
1166
1223
|
export interface R2Error extends Error {
|
|
1167
1224
|
readonly name: string;
|
|
1168
1225
|
readonly code: number;
|
|
@@ -1599,7 +1656,8 @@ export interface QueuingStrategyInit {
|
|
|
1599
1656
|
*/
|
|
1600
1657
|
highWaterMark: number;
|
|
1601
1658
|
}
|
|
1602
|
-
export declare abstract class
|
|
1659
|
+
export declare abstract class TailEvent extends ExtendableEvent {
|
|
1660
|
+
readonly events: TraceItem[];
|
|
1603
1661
|
readonly traces: TraceItem[];
|
|
1604
1662
|
}
|
|
1605
1663
|
export interface TraceItem {
|
|
@@ -1821,6 +1879,37 @@ export declare const WebSocketPair: {
|
|
|
1821
1879
|
1: WebSocket;
|
|
1822
1880
|
};
|
|
1823
1881
|
};
|
|
1882
|
+
export interface SqlStorage {
|
|
1883
|
+
exec(query: string, ...bindings: any[]): SqlStorageCursor;
|
|
1884
|
+
prepare(query: string): SqlStorageStatement;
|
|
1885
|
+
Cursor: typeof SqlStorageCursor;
|
|
1886
|
+
Statement: typeof SqlStorageStatement;
|
|
1887
|
+
}
|
|
1888
|
+
export declare abstract class SqlStorageStatement {}
|
|
1889
|
+
export declare abstract class SqlStorageCursor {
|
|
1890
|
+
raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
|
|
1891
|
+
[Symbol.iterator](): IterableIterator<
|
|
1892
|
+
Record<string, (ArrayBuffer | string | number) | null>
|
|
1893
|
+
>;
|
|
1894
|
+
}
|
|
1895
|
+
export interface Socket {
|
|
1896
|
+
get readable(): ReadableStream;
|
|
1897
|
+
get writable(): WritableStream;
|
|
1898
|
+
get closed(): Promise<void>;
|
|
1899
|
+
close(): Promise<void>;
|
|
1900
|
+
startTls(options?: TlsOptions): Socket;
|
|
1901
|
+
}
|
|
1902
|
+
export interface SocketOptions {
|
|
1903
|
+
secureTransport?: string;
|
|
1904
|
+
allowHalfOpen: boolean;
|
|
1905
|
+
}
|
|
1906
|
+
export interface SocketAddress {
|
|
1907
|
+
hostname: string;
|
|
1908
|
+
port: number;
|
|
1909
|
+
}
|
|
1910
|
+
export interface TlsOptions {
|
|
1911
|
+
expectedServerHostname?: string;
|
|
1912
|
+
}
|
|
1824
1913
|
export interface BasicImageTransformations {
|
|
1825
1914
|
/**
|
|
1826
1915
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -2210,8 +2299,7 @@ export interface IncomingRequestCfPropertiesBase
|
|
|
2210
2299
|
export interface IncomingRequestCfPropertiesBotManagementBase {
|
|
2211
2300
|
/**
|
|
2212
2301
|
* Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
|
|
2213
|
-
* represented as an integer percentage between `1` (almost certainly human)
|
|
2214
|
-
* and `99` (almost certainly a bot).
|
|
2302
|
+
* represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
|
|
2215
2303
|
*
|
|
2216
2304
|
* @example 54
|
|
2217
2305
|
*/
|
|
@@ -2946,75 +3034,12 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2946
3034
|
// Key Identifier of the JWK
|
|
2947
3035
|
readonly kid: string;
|
|
2948
3036
|
}
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
*/
|
|
2952
|
-
export interface Message<Body = unknown> {
|
|
3037
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3038
|
+
export interface DispatchNamespace {
|
|
2953
3039
|
/**
|
|
2954
|
-
*
|
|
3040
|
+
* @param name Name of the Worker script.
|
|
3041
|
+
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
3042
|
+
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2955
3043
|
*/
|
|
2956
|
-
|
|
2957
|
-
/**
|
|
2958
|
-
* A timestamp when the message was sent.
|
|
2959
|
-
*/
|
|
2960
|
-
readonly timestamp: Date;
|
|
2961
|
-
/**
|
|
2962
|
-
* The body of the message.
|
|
2963
|
-
*/
|
|
2964
|
-
readonly body: Body;
|
|
2965
|
-
/**
|
|
2966
|
-
* Marks message to be retried.
|
|
2967
|
-
*/
|
|
2968
|
-
retry(): void;
|
|
2969
|
-
/**
|
|
2970
|
-
* Marks message acknowledged.
|
|
2971
|
-
*/
|
|
2972
|
-
ack(): void;
|
|
2973
|
-
}
|
|
2974
|
-
/**
|
|
2975
|
-
* A batch of messages that are sent to a consumer Worker.
|
|
2976
|
-
*/
|
|
2977
|
-
export interface MessageBatch<Body = unknown> {
|
|
2978
|
-
/**
|
|
2979
|
-
* The name of the Queue that belongs to this batch.
|
|
2980
|
-
*/
|
|
2981
|
-
readonly queue: string;
|
|
2982
|
-
/**
|
|
2983
|
-
* An array of messages in the batch. Ordering of messages is not guaranteed.
|
|
2984
|
-
*/
|
|
2985
|
-
readonly messages: readonly Message<Body>[];
|
|
2986
|
-
/**
|
|
2987
|
-
* Marks every message to be retried in the next batch.
|
|
2988
|
-
*/
|
|
2989
|
-
retryAll(): void;
|
|
2990
|
-
/**
|
|
2991
|
-
* Marks every message acknowledged in the batch.
|
|
2992
|
-
*/
|
|
2993
|
-
ackAll(): void;
|
|
2994
|
-
}
|
|
2995
|
-
/**
|
|
2996
|
-
* A wrapper class used to structure message batches.
|
|
2997
|
-
*/
|
|
2998
|
-
export type MessageSendRequest<Body = unknown> = {
|
|
2999
|
-
/**
|
|
3000
|
-
* The body of the message.
|
|
3001
|
-
*/
|
|
3002
|
-
body: Body;
|
|
3003
|
-
};
|
|
3004
|
-
/**
|
|
3005
|
-
* A binding that allows a producer to send messages to a Queue.
|
|
3006
|
-
*/
|
|
3007
|
-
export interface Queue<Body = any> {
|
|
3008
|
-
/**
|
|
3009
|
-
* Sends a message to the Queue.
|
|
3010
|
-
* @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.
|
|
3011
|
-
* @returns A promise that resolves when the message is confirmed to be written to disk.
|
|
3012
|
-
*/
|
|
3013
|
-
send(message: Body): Promise<void>;
|
|
3014
|
-
/**
|
|
3015
|
-
* Sends a batch of messages to the Queue.
|
|
3016
|
-
* @param messages Each item in the input must be supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types). A batch can contain up to 100 messages, though items are limited to 128 KB each, and the total size of the array cannot exceed 256 KB.
|
|
3017
|
-
* @returns A promise that resolves when the messages are confirmed to be written to disk.
|
|
3018
|
-
*/
|
|
3019
|
-
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
3044
|
+
get(name: string): Fetcher;
|
|
3020
3045
|
}
|
package/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ declare class DOMException extends Error {
|
|
|
49
49
|
declare type WorkerGlobalScopeEventMap = {
|
|
50
50
|
fetch: FetchEvent;
|
|
51
51
|
scheduled: ScheduledEvent;
|
|
52
|
+
queue: QueueEvent;
|
|
52
53
|
unhandledrejection: PromiseRejectionEvent;
|
|
53
54
|
rejectionhandled: PromiseRejectionEvent;
|
|
54
55
|
};
|
|
@@ -187,7 +188,8 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
187
188
|
ExtendableEvent: typeof ExtendableEvent;
|
|
188
189
|
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
|
189
190
|
FetchEvent: typeof FetchEvent;
|
|
190
|
-
|
|
191
|
+
TailEvent: typeof TailEvent;
|
|
192
|
+
TraceEvent: typeof TailEvent;
|
|
191
193
|
ScheduledEvent: typeof ScheduledEvent;
|
|
192
194
|
MessageEvent: typeof MessageEvent;
|
|
193
195
|
CloseEvent: typeof CloseEvent;
|
|
@@ -292,6 +294,11 @@ declare type ExportedHandlerFetchHandler<
|
|
|
292
294
|
env: Env,
|
|
293
295
|
ctx: ExecutionContext
|
|
294
296
|
) => Response | Promise<Response>;
|
|
297
|
+
declare type ExportedHandlerTailHandler<Env = unknown> = (
|
|
298
|
+
events: TraceItem[],
|
|
299
|
+
env: Env,
|
|
300
|
+
ctx: ExecutionContext
|
|
301
|
+
) => void | Promise<void>;
|
|
295
302
|
declare type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
296
303
|
traces: TraceItem[],
|
|
297
304
|
env: Env,
|
|
@@ -318,10 +325,11 @@ declare interface ExportedHandler<
|
|
|
318
325
|
CfHostMetadata = unknown
|
|
319
326
|
> {
|
|
320
327
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
328
|
+
tail?: ExportedHandlerTailHandler<Env>;
|
|
321
329
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
322
330
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
323
331
|
test?: ExportedHandlerTestHandler<Env>;
|
|
324
|
-
queue?: ExportedHandlerQueueHandler<Env,
|
|
332
|
+
queue?: ExportedHandlerQueueHandler<Env, Message>;
|
|
325
333
|
}
|
|
326
334
|
declare interface StructuredSerializeOptions {
|
|
327
335
|
transfer?: any[];
|
|
@@ -1170,6 +1178,33 @@ declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
|
|
|
1170
1178
|
value: Value | null;
|
|
1171
1179
|
metadata: Metadata | null;
|
|
1172
1180
|
}
|
|
1181
|
+
declare interface Queue<Body> {
|
|
1182
|
+
send(message: Body): Promise<void>;
|
|
1183
|
+
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
1184
|
+
}
|
|
1185
|
+
declare interface QueueSendOptions {}
|
|
1186
|
+
declare interface MessageSendRequest<Body = unknown> {
|
|
1187
|
+
body: Body;
|
|
1188
|
+
}
|
|
1189
|
+
declare interface Message<Body = unknown> {
|
|
1190
|
+
readonly id: string;
|
|
1191
|
+
readonly timestamp: Date;
|
|
1192
|
+
readonly body: Body;
|
|
1193
|
+
retry(): void;
|
|
1194
|
+
ack(): void;
|
|
1195
|
+
}
|
|
1196
|
+
declare interface QueueEvent<Body = unknown> extends ExtendableEvent {
|
|
1197
|
+
readonly messages: readonly Message<Body>[];
|
|
1198
|
+
readonly queue: string;
|
|
1199
|
+
retryAll(): void;
|
|
1200
|
+
ackAll(): void;
|
|
1201
|
+
}
|
|
1202
|
+
declare interface MessageBatch<Body = unknown> {
|
|
1203
|
+
readonly messages: readonly Message<Body>[];
|
|
1204
|
+
readonly queue: string;
|
|
1205
|
+
retryAll(): void;
|
|
1206
|
+
ackAll(): void;
|
|
1207
|
+
}
|
|
1173
1208
|
declare interface R2Error extends Error {
|
|
1174
1209
|
readonly name: string;
|
|
1175
1210
|
readonly code: number;
|
|
@@ -1603,7 +1638,8 @@ declare interface QueuingStrategyInit {
|
|
|
1603
1638
|
*/
|
|
1604
1639
|
highWaterMark: number;
|
|
1605
1640
|
}
|
|
1606
|
-
declare abstract class
|
|
1641
|
+
declare abstract class TailEvent extends ExtendableEvent {
|
|
1642
|
+
readonly events: TraceItem[];
|
|
1607
1643
|
readonly traces: TraceItem[];
|
|
1608
1644
|
}
|
|
1609
1645
|
declare interface TraceItem {
|
|
@@ -2211,8 +2247,7 @@ declare interface IncomingRequestCfPropertiesBase
|
|
|
2211
2247
|
declare interface IncomingRequestCfPropertiesBotManagementBase {
|
|
2212
2248
|
/**
|
|
2213
2249
|
* Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
|
|
2214
|
-
* represented as an integer percentage between `1` (almost certainly human)
|
|
2215
|
-
* and `99` (almost certainly a bot).
|
|
2250
|
+
* represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
|
|
2216
2251
|
*
|
|
2217
2252
|
* @example 54
|
|
2218
2253
|
*/
|
|
@@ -2957,75 +2992,12 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2957
2992
|
// Key Identifier of the JWK
|
|
2958
2993
|
readonly kid: string;
|
|
2959
2994
|
}
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
*/
|
|
2963
|
-
declare interface Message<Body = unknown> {
|
|
2995
|
+
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
2996
|
+
declare interface DispatchNamespace {
|
|
2964
2997
|
/**
|
|
2965
|
-
*
|
|
2998
|
+
* @param name Name of the Worker script.
|
|
2999
|
+
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
3000
|
+
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2966
3001
|
*/
|
|
2967
|
-
|
|
2968
|
-
/**
|
|
2969
|
-
* A timestamp when the message was sent.
|
|
2970
|
-
*/
|
|
2971
|
-
readonly timestamp: Date;
|
|
2972
|
-
/**
|
|
2973
|
-
* The body of the message.
|
|
2974
|
-
*/
|
|
2975
|
-
readonly body: Body;
|
|
2976
|
-
/**
|
|
2977
|
-
* Marks message to be retried.
|
|
2978
|
-
*/
|
|
2979
|
-
retry(): void;
|
|
2980
|
-
/**
|
|
2981
|
-
* Marks message acknowledged.
|
|
2982
|
-
*/
|
|
2983
|
-
ack(): void;
|
|
2984
|
-
}
|
|
2985
|
-
/**
|
|
2986
|
-
* A batch of messages that are sent to a consumer Worker.
|
|
2987
|
-
*/
|
|
2988
|
-
declare interface MessageBatch<Body = unknown> {
|
|
2989
|
-
/**
|
|
2990
|
-
* The name of the Queue that belongs to this batch.
|
|
2991
|
-
*/
|
|
2992
|
-
readonly queue: string;
|
|
2993
|
-
/**
|
|
2994
|
-
* An array of messages in the batch. Ordering of messages is not guaranteed.
|
|
2995
|
-
*/
|
|
2996
|
-
readonly messages: readonly Message<Body>[];
|
|
2997
|
-
/**
|
|
2998
|
-
* Marks every message to be retried in the next batch.
|
|
2999
|
-
*/
|
|
3000
|
-
retryAll(): void;
|
|
3001
|
-
/**
|
|
3002
|
-
* Marks every message acknowledged in the batch.
|
|
3003
|
-
*/
|
|
3004
|
-
ackAll(): void;
|
|
3005
|
-
}
|
|
3006
|
-
/**
|
|
3007
|
-
* A wrapper class used to structure message batches.
|
|
3008
|
-
*/
|
|
3009
|
-
declare type MessageSendRequest<Body = unknown> = {
|
|
3010
|
-
/**
|
|
3011
|
-
* The body of the message.
|
|
3012
|
-
*/
|
|
3013
|
-
body: Body;
|
|
3014
|
-
};
|
|
3015
|
-
/**
|
|
3016
|
-
* A binding that allows a producer to send messages to a Queue.
|
|
3017
|
-
*/
|
|
3018
|
-
declare interface Queue<Body = any> {
|
|
3019
|
-
/**
|
|
3020
|
-
* Sends a message to the Queue.
|
|
3021
|
-
* @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.
|
|
3022
|
-
* @returns A promise that resolves when the message is confirmed to be written to disk.
|
|
3023
|
-
*/
|
|
3024
|
-
send(message: Body): Promise<void>;
|
|
3025
|
-
/**
|
|
3026
|
-
* Sends a batch of messages to the Queue.
|
|
3027
|
-
* @param messages Each item in the input must be supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types). A batch can contain up to 100 messages, though items are limited to 128 KB each, and the total size of the array cannot exceed 256 KB.
|
|
3028
|
-
* @returns A promise that resolves when the messages are confirmed to be written to disk.
|
|
3029
|
-
*/
|
|
3030
|
-
sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
|
|
3002
|
+
get(name: string): Fetcher;
|
|
3031
3003
|
}
|