@cloudflare/workers-types 0.20221111.0 → 0.20230215.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.
@@ -280,7 +280,7 @@ declare const crypto: Crypto;
280
280
  declare const caches: CacheStorage;
281
281
  declare const scheduler: Scheduler;
282
282
  declare interface ExecutionContext {
283
- waitUntil(promise: void | Promise<void>): void;
283
+ waitUntil(promise: Promise<any>): void;
284
284
  passThroughOnException(): void;
285
285
  }
286
286
  declare type ExportedHandlerFetchHandler<Env = unknown> = (
@@ -335,13 +335,20 @@ declare interface DurableObjectNamespace {
335
335
  ): DurableObjectId;
336
336
  idFromName(name: string): DurableObjectId;
337
337
  idFromString(id: string): DurableObjectId;
338
- get(id: DurableObjectId): DurableObjectStub;
338
+ get(
339
+ id: DurableObjectId,
340
+ options?: DurableObjectNamespaceGetDurableObjectOptions
341
+ ): DurableObjectStub;
342
+ jurisdiction(jurisdiction: string): DurableObjectNamespace;
339
343
  }
340
344
  declare interface DurableObjectNamespaceNewUniqueIdOptions {
341
345
  jurisdiction?: string;
342
346
  }
347
+ declare interface DurableObjectNamespaceGetDurableObjectOptions {
348
+ locationHint?: string;
349
+ }
343
350
  declare interface DurableObjectState {
344
- waitUntil(promise: void | Promise<void>): void;
351
+ waitUntil(promise: Promise<any>): void;
345
352
  readonly id: DurableObjectId;
346
353
  readonly storage: DurableObjectStorage;
347
354
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
@@ -543,7 +550,7 @@ declare interface SchedulerWaitOptions {
543
550
  signal?: AbortSignal;
544
551
  }
545
552
  declare abstract class ExtendableEvent extends Event {
546
- waitUntil(promise: void | Promise<void>): void;
553
+ waitUntil(promise: Promise<any>): void;
547
554
  }
548
555
  declare class Blob {
549
556
  constructor(
@@ -982,9 +989,9 @@ declare interface ResponseInit {
982
989
  encodeBody?: "automatic" | "manual";
983
990
  }
984
991
  declare type RequestInfo = Request | string | URL;
985
- declare class Request extends Body {
992
+ declare class Request<CfHostMetadata = unknown> extends Body {
986
993
  constructor(input: RequestInfo, init?: RequestInit);
987
- clone(): Request;
994
+ clone(): Request<CfHostMetadata>;
988
995
  /** Returns request's HTTP method, which is "GET" by default. */
989
996
  readonly method: string;
990
997
  /** Returns the URL of request as a string. */
@@ -996,7 +1003,11 @@ declare class Request extends Body {
996
1003
  readonly fetcher: Fetcher | null;
997
1004
  /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
998
1005
  readonly signal: AbortSignal;
999
- readonly cf?: IncomingRequestCfProperties;
1006
+ readonly cf?: IncomingRequestCfProperties<CfHostMetadata>;
1007
+ /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
1008
+ readonly integrity: string;
1009
+ /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
1010
+ readonly keepalive: boolean;
1000
1011
  }
1001
1012
  declare interface RequestInit<
1002
1013
  CfType = IncomingRequestCfProperties | RequestInitCfProperties
@@ -1011,6 +1022,8 @@ declare interface RequestInit<
1011
1022
  redirect?: string;
1012
1023
  fetcher?: Fetcher | null;
1013
1024
  cf?: CfType;
1025
+ /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1026
+ integrity?: string;
1014
1027
  /** An AbortSignal to set request's signal. */
1015
1028
  signal?: AbortSignal | null;
1016
1029
  }
@@ -1062,11 +1075,11 @@ declare interface KVNamespace<Key extends string = string> {
1062
1075
  get(
1063
1076
  key: Key,
1064
1077
  options?: KVNamespaceGetOptions<"arrayBuffer">
1065
- ): Promise<string | null>;
1078
+ ): Promise<ArrayBuffer | null>;
1066
1079
  get(
1067
1080
  key: Key,
1068
1081
  options?: KVNamespaceGetOptions<"stream">
1069
- ): Promise<string | null>;
1082
+ ): Promise<ReadableStream | null>;
1070
1083
  list<Metadata = unknown>(
1071
1084
  options?: KVNamespaceListOptions
1072
1085
  ): Promise<KVNamespaceListResult<Metadata, Key>>;
@@ -1165,9 +1178,41 @@ declare abstract class R2Bucket {
1165
1178
  | Blob,
1166
1179
  options?: R2PutOptions
1167
1180
  ): Promise<R2Object>;
1181
+ put(
1182
+ key: string,
1183
+ value:
1184
+ | ReadableStream
1185
+ | ArrayBuffer
1186
+ | ArrayBufferView
1187
+ | string
1188
+ | null
1189
+ | Blob,
1190
+ options?: R2PutOptions & {
1191
+ onlyIf: R2Conditional | Headers;
1192
+ }
1193
+ ): Promise<R2Object | null>;
1194
+ createMultipartUpload(
1195
+ key: string,
1196
+ options?: R2MultipartOptions
1197
+ ): Promise<R2MultipartUpload>;
1198
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1168
1199
  delete(keys: string | string[]): Promise<void>;
1169
1200
  list(options?: R2ListOptions): Promise<R2Objects>;
1170
1201
  }
1202
+ declare interface R2MultipartUpload {
1203
+ readonly key: string;
1204
+ readonly uploadId: string;
1205
+ uploadPart(
1206
+ partNumber: number,
1207
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1208
+ ): Promise<R2UploadedPart>;
1209
+ abort(): Promise<void>;
1210
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1211
+ }
1212
+ declare interface R2UploadedPart {
1213
+ partNumber: number;
1214
+ etag: string;
1215
+ }
1171
1216
  declare abstract class R2Object {
1172
1217
  readonly key: string;
1173
1218
  readonly version: string;
@@ -1222,6 +1267,10 @@ declare interface R2PutOptions {
1222
1267
  sha384?: ArrayBuffer | string;
1223
1268
  sha512?: ArrayBuffer | string;
1224
1269
  }
1270
+ declare interface R2MultipartOptions {
1271
+ httpMetadata?: R2HTTPMetadata | Headers;
1272
+ customMetadata?: Record<string, string>;
1273
+ }
1225
1274
  declare interface R2Checksums {
1226
1275
  readonly md5?: ArrayBuffer;
1227
1276
  readonly sha1?: ArrayBuffer;
@@ -1340,6 +1389,7 @@ declare type ReadableStreamReadResult<R = any> =
1340
1389
  };
1341
1390
  /** 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. */
1342
1391
  declare interface ReadableStream<R = any> {
1392
+ readonly locked: boolean;
1343
1393
  cancel(reason?: any): Promise<void>;
1344
1394
  getReader(): ReadableStreamDefaultReader<R>;
1345
1395
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1524,6 +1574,9 @@ declare interface TraceItem {
1524
1574
  | TraceItemFetchEventInfo
1525
1575
  | TraceItemScheduledEventInfo
1526
1576
  | TraceItemAlarmEventInfo
1577
+ | TraceItemQueueEventInfo
1578
+ | TraceItemEmailEventInfo
1579
+ | TraceItemCustomEventInfo
1527
1580
  )
1528
1581
  | null;
1529
1582
  readonly eventTimestamp: number | null;
@@ -1531,15 +1584,26 @@ declare interface TraceItem {
1531
1584
  readonly exceptions: TraceException[];
1532
1585
  readonly scriptName: string | null;
1533
1586
  readonly dispatchNamespace?: string;
1587
+ readonly scriptTags?: string[];
1534
1588
  readonly outcome: string;
1535
1589
  }
1536
1590
  declare interface TraceItemAlarmEventInfo {
1537
1591
  readonly scheduledTime: Date;
1538
1592
  }
1593
+ declare interface TraceItemCustomEventInfo {}
1539
1594
  declare interface TraceItemScheduledEventInfo {
1540
1595
  readonly scheduledTime: number;
1541
1596
  readonly cron: string;
1542
1597
  }
1598
+ declare interface TraceItemQueueEventInfo {
1599
+ readonly queue: string;
1600
+ readonly batchSize: number;
1601
+ }
1602
+ declare interface TraceItemEmailEventInfo {
1603
+ readonly mailFrom: string;
1604
+ readonly rcptTo: string;
1605
+ readonly rawSize: number;
1606
+ }
1543
1607
  declare interface TraceItemFetchEventInfo {
1544
1608
  readonly response?: TraceItemFetchEventInfoResponse;
1545
1609
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2663,6 +2727,52 @@ declare abstract class D1PreparedStatement {
2663
2727
  all<T = unknown>(): Promise<D1Result<T>>;
2664
2728
  raw<T = unknown>(): Promise<T[]>;
2665
2729
  }
2730
+ /**
2731
+ * A email message that is sent to a consumer Worker.
2732
+ */
2733
+ declare interface EmailMessage<Body = unknown> {
2734
+ /**
2735
+ * Envelope From attribute of the email message.
2736
+ */
2737
+ readonly from: string;
2738
+ /**
2739
+ * Envelope To attribute of the email message.
2740
+ */
2741
+ readonly to: string;
2742
+ /**
2743
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2744
+ */
2745
+ readonly headers: Headers;
2746
+ /**
2747
+ * Stream of the email message content.
2748
+ */
2749
+ readonly raw: ReadableStream;
2750
+ /**
2751
+ * Size of the email message content.
2752
+ */
2753
+ readonly rawSize: number;
2754
+ /**
2755
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2756
+ * @param reason The reject reason.
2757
+ * @returns void
2758
+ */
2759
+ setReject(reason: string): void;
2760
+ /**
2761
+ * Forward this email message to a verified destination address of the account.
2762
+ * @param rcptTo Verified destination address.
2763
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2764
+ * @returns A promise that resolves when the email message is forwarded.
2765
+ */
2766
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2767
+ }
2768
+ declare abstract class EmailEvent extends ExtendableEvent {
2769
+ readonly message: EmailMessage;
2770
+ }
2771
+ declare type EmailExportedHandler<Env = unknown> = (
2772
+ message: EmailMessage,
2773
+ env: Env,
2774
+ ctx: ExecutionContext
2775
+ ) => void | Promise<void>;
2666
2776
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2667
2777
  declare type EventContext<Env, P extends string, Data> = {
2668
2778
  request: Request;
@@ -2709,6 +2819,40 @@ declare type PagesPluginFunction<
2709
2819
  declare module "assets:*" {
2710
2820
  export const onRequest: PagesFunction;
2711
2821
  }
2822
+ // https://developers.cloudflare.com/pub-sub/
2823
+ // PubSubMessage represents an incoming PubSub message.
2824
+ // The message includes metadata about the broker, the client, and the payload
2825
+ // itself.
2826
+ declare interface PubSubMessage {
2827
+ // Message ID
2828
+ readonly mid: number;
2829
+ // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
2830
+ readonly broker: string;
2831
+ // The MQTT topic the message was sent on.
2832
+ readonly topic: string;
2833
+ // The client ID of the client that published this message.
2834
+ readonly clientId: string;
2835
+ // The unique identifier (JWT ID) used by the client to authenticate, if token
2836
+ // auth was used.
2837
+ readonly jti?: string;
2838
+ // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
2839
+ // received the message from the client.
2840
+ readonly receivedAt: number;
2841
+ // An (optional) string with the MIME type of the payload, if set by the
2842
+ // client.
2843
+ readonly contentType: string;
2844
+ // Set to 1 when the payload is a UTF-8 string
2845
+ // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
2846
+ readonly payloadFormatIndicator: number;
2847
+ // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
2848
+ // You can use payloadFormatIndicator to inspect this before decoding.
2849
+ payload: string | Uint8Array;
2850
+ }
2851
+ // JsonWebKey extended by kid parameter
2852
+ declare interface JsonWebKeyWithKid extends JsonWebKey {
2853
+ // Key Identifier of the JWK
2854
+ readonly kid: string;
2855
+ }
2712
2856
  /**
2713
2857
  * A message that is sent to a consumer Worker.
2714
2858
  */
@@ -2725,6 +2869,14 @@ declare interface Message<Body = unknown> {
2725
2869
  * The body of the message.
2726
2870
  */
2727
2871
  readonly body: Body;
2872
+ /**
2873
+ * Marks message to be retried.
2874
+ */
2875
+ retry(): void;
2876
+ /**
2877
+ * Marks message acknowledged.
2878
+ */
2879
+ ack(): void;
2728
2880
  }
2729
2881
  /**
2730
2882
  * A batch of messages that are sent to a consumer Worker.
@@ -2742,7 +2894,20 @@ declare interface MessageBatch<Body = unknown> {
2742
2894
  * Marks every message to be retried in the next batch.
2743
2895
  */
2744
2896
  retryAll(): void;
2897
+ /**
2898
+ * Marks every message acknowledged in the batch.
2899
+ */
2900
+ ackAll(): void;
2745
2901
  }
2902
+ /**
2903
+ * A wrapper class used to structure message batches.
2904
+ */
2905
+ declare type MessageSendRequest<Body = unknown> = {
2906
+ /**
2907
+ * The body of the message.
2908
+ */
2909
+ body: Body;
2910
+ };
2746
2911
  /**
2747
2912
  * A binding that allows a producer to send messages to a Queue.
2748
2913
  */
@@ -2753,4 +2918,10 @@ declare interface Queue<Body = any> {
2753
2918
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2754
2919
  */
2755
2920
  send(message: Body): Promise<void>;
2921
+ /**
2922
+ * Sends a batch of messages to the Queue.
2923
+ * @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.
2924
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2925
+ */
2926
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2756
2927
  }
@@ -282,7 +282,7 @@ export declare const crypto: Crypto;
282
282
  export declare const caches: CacheStorage;
283
283
  export declare const scheduler: Scheduler;
284
284
  export interface ExecutionContext {
285
- waitUntil(promise: void | Promise<void>): void;
285
+ waitUntil(promise: Promise<any>): void;
286
286
  passThroughOnException(): void;
287
287
  }
288
288
  export type ExportedHandlerFetchHandler<Env = unknown> = (
@@ -337,13 +337,20 @@ export interface DurableObjectNamespace {
337
337
  ): DurableObjectId;
338
338
  idFromName(name: string): DurableObjectId;
339
339
  idFromString(id: string): DurableObjectId;
340
- get(id: DurableObjectId): DurableObjectStub;
340
+ get(
341
+ id: DurableObjectId,
342
+ options?: DurableObjectNamespaceGetDurableObjectOptions
343
+ ): DurableObjectStub;
344
+ jurisdiction(jurisdiction: string): DurableObjectNamespace;
341
345
  }
342
346
  export interface DurableObjectNamespaceNewUniqueIdOptions {
343
347
  jurisdiction?: string;
344
348
  }
349
+ export interface DurableObjectNamespaceGetDurableObjectOptions {
350
+ locationHint?: string;
351
+ }
345
352
  export interface DurableObjectState {
346
- waitUntil(promise: void | Promise<void>): void;
353
+ waitUntil(promise: Promise<any>): void;
347
354
  readonly id: DurableObjectId;
348
355
  readonly storage: DurableObjectStorage;
349
356
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
@@ -545,7 +552,7 @@ export interface SchedulerWaitOptions {
545
552
  signal?: AbortSignal;
546
553
  }
547
554
  export declare abstract class ExtendableEvent extends Event {
548
- waitUntil(promise: void | Promise<void>): void;
555
+ waitUntil(promise: Promise<any>): void;
549
556
  }
550
557
  export declare class Blob {
551
558
  constructor(
@@ -984,9 +991,9 @@ export interface ResponseInit {
984
991
  encodeBody?: "automatic" | "manual";
985
992
  }
986
993
  export type RequestInfo = Request | string | URL;
987
- export declare class Request extends Body {
994
+ export declare class Request<CfHostMetadata = unknown> extends Body {
988
995
  constructor(input: RequestInfo, init?: RequestInit);
989
- clone(): Request;
996
+ clone(): Request<CfHostMetadata>;
990
997
  /** Returns request's HTTP method, which is "GET" by default. */
991
998
  readonly method: string;
992
999
  /** Returns the URL of request as a string. */
@@ -998,7 +1005,11 @@ export declare class Request extends Body {
998
1005
  readonly fetcher: Fetcher | null;
999
1006
  /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
1000
1007
  readonly signal: AbortSignal;
1001
- readonly cf?: IncomingRequestCfProperties;
1008
+ readonly cf?: IncomingRequestCfProperties<CfHostMetadata>;
1009
+ /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
1010
+ readonly integrity: string;
1011
+ /** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
1012
+ readonly keepalive: boolean;
1002
1013
  }
1003
1014
  export interface RequestInit<
1004
1015
  CfType = IncomingRequestCfProperties | RequestInitCfProperties
@@ -1013,6 +1024,8 @@ export interface RequestInit<
1013
1024
  redirect?: string;
1014
1025
  fetcher?: Fetcher | null;
1015
1026
  cf?: CfType;
1027
+ /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1028
+ integrity?: string;
1016
1029
  /** An AbortSignal to set request's signal. */
1017
1030
  signal?: AbortSignal | null;
1018
1031
  }
@@ -1064,11 +1077,11 @@ export interface KVNamespace<Key extends string = string> {
1064
1077
  get(
1065
1078
  key: Key,
1066
1079
  options?: KVNamespaceGetOptions<"arrayBuffer">
1067
- ): Promise<string | null>;
1080
+ ): Promise<ArrayBuffer | null>;
1068
1081
  get(
1069
1082
  key: Key,
1070
1083
  options?: KVNamespaceGetOptions<"stream">
1071
- ): Promise<string | null>;
1084
+ ): Promise<ReadableStream | null>;
1072
1085
  list<Metadata = unknown>(
1073
1086
  options?: KVNamespaceListOptions
1074
1087
  ): Promise<KVNamespaceListResult<Metadata, Key>>;
@@ -1167,9 +1180,41 @@ export declare abstract class R2Bucket {
1167
1180
  | Blob,
1168
1181
  options?: R2PutOptions
1169
1182
  ): Promise<R2Object>;
1183
+ put(
1184
+ key: string,
1185
+ value:
1186
+ | ReadableStream
1187
+ | ArrayBuffer
1188
+ | ArrayBufferView
1189
+ | string
1190
+ | null
1191
+ | Blob,
1192
+ options?: R2PutOptions & {
1193
+ onlyIf: R2Conditional | Headers;
1194
+ }
1195
+ ): Promise<R2Object | null>;
1196
+ createMultipartUpload(
1197
+ key: string,
1198
+ options?: R2MultipartOptions
1199
+ ): Promise<R2MultipartUpload>;
1200
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1170
1201
  delete(keys: string | string[]): Promise<void>;
1171
1202
  list(options?: R2ListOptions): Promise<R2Objects>;
1172
1203
  }
1204
+ export interface R2MultipartUpload {
1205
+ readonly key: string;
1206
+ readonly uploadId: string;
1207
+ uploadPart(
1208
+ partNumber: number,
1209
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1210
+ ): Promise<R2UploadedPart>;
1211
+ abort(): Promise<void>;
1212
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1213
+ }
1214
+ export interface R2UploadedPart {
1215
+ partNumber: number;
1216
+ etag: string;
1217
+ }
1173
1218
  export declare abstract class R2Object {
1174
1219
  readonly key: string;
1175
1220
  readonly version: string;
@@ -1224,6 +1269,10 @@ export interface R2PutOptions {
1224
1269
  sha384?: ArrayBuffer | string;
1225
1270
  sha512?: ArrayBuffer | string;
1226
1271
  }
1272
+ export interface R2MultipartOptions {
1273
+ httpMetadata?: R2HTTPMetadata | Headers;
1274
+ customMetadata?: Record<string, string>;
1275
+ }
1227
1276
  export interface R2Checksums {
1228
1277
  readonly md5?: ArrayBuffer;
1229
1278
  readonly sha1?: ArrayBuffer;
@@ -1342,6 +1391,7 @@ export type ReadableStreamReadResult<R = any> =
1342
1391
  };
1343
1392
  /** 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. */
1344
1393
  export interface ReadableStream<R = any> {
1394
+ readonly locked: boolean;
1345
1395
  cancel(reason?: any): Promise<void>;
1346
1396
  getReader(): ReadableStreamDefaultReader<R>;
1347
1397
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1529,6 +1579,9 @@ export interface TraceItem {
1529
1579
  | TraceItemFetchEventInfo
1530
1580
  | TraceItemScheduledEventInfo
1531
1581
  | TraceItemAlarmEventInfo
1582
+ | TraceItemQueueEventInfo
1583
+ | TraceItemEmailEventInfo
1584
+ | TraceItemCustomEventInfo
1532
1585
  )
1533
1586
  | null;
1534
1587
  readonly eventTimestamp: number | null;
@@ -1536,15 +1589,26 @@ export interface TraceItem {
1536
1589
  readonly exceptions: TraceException[];
1537
1590
  readonly scriptName: string | null;
1538
1591
  readonly dispatchNamespace?: string;
1592
+ readonly scriptTags?: string[];
1539
1593
  readonly outcome: string;
1540
1594
  }
1541
1595
  export interface TraceItemAlarmEventInfo {
1542
1596
  readonly scheduledTime: Date;
1543
1597
  }
1598
+ export interface TraceItemCustomEventInfo {}
1544
1599
  export interface TraceItemScheduledEventInfo {
1545
1600
  readonly scheduledTime: number;
1546
1601
  readonly cron: string;
1547
1602
  }
1603
+ export interface TraceItemQueueEventInfo {
1604
+ readonly queue: string;
1605
+ readonly batchSize: number;
1606
+ }
1607
+ export interface TraceItemEmailEventInfo {
1608
+ readonly mailFrom: string;
1609
+ readonly rcptTo: string;
1610
+ readonly rawSize: number;
1611
+ }
1548
1612
  export interface TraceItemFetchEventInfo {
1549
1613
  readonly response?: TraceItemFetchEventInfoResponse;
1550
1614
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2668,6 +2732,52 @@ export declare abstract class D1PreparedStatement {
2668
2732
  all<T = unknown>(): Promise<D1Result<T>>;
2669
2733
  raw<T = unknown>(): Promise<T[]>;
2670
2734
  }
2735
+ /**
2736
+ * A email message that is sent to a consumer Worker.
2737
+ */
2738
+ export interface EmailMessage<Body = unknown> {
2739
+ /**
2740
+ * Envelope From attribute of the email message.
2741
+ */
2742
+ readonly from: string;
2743
+ /**
2744
+ * Envelope To attribute of the email message.
2745
+ */
2746
+ readonly to: string;
2747
+ /**
2748
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2749
+ */
2750
+ readonly headers: Headers;
2751
+ /**
2752
+ * Stream of the email message content.
2753
+ */
2754
+ readonly raw: ReadableStream;
2755
+ /**
2756
+ * Size of the email message content.
2757
+ */
2758
+ readonly rawSize: number;
2759
+ /**
2760
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2761
+ * @param reason The reject reason.
2762
+ * @returns void
2763
+ */
2764
+ setReject(reason: string): void;
2765
+ /**
2766
+ * Forward this email message to a verified destination address of the account.
2767
+ * @param rcptTo Verified destination address.
2768
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2769
+ * @returns A promise that resolves when the email message is forwarded.
2770
+ */
2771
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2772
+ }
2773
+ export declare abstract class EmailEvent extends ExtendableEvent {
2774
+ readonly message: EmailMessage;
2775
+ }
2776
+ export type EmailExportedHandler<Env = unknown> = (
2777
+ message: EmailMessage,
2778
+ env: Env,
2779
+ ctx: ExecutionContext
2780
+ ) => void | Promise<void>;
2671
2781
  export type Params<P extends string = any> = Record<P, string | string[]>;
2672
2782
  export type EventContext<Env, P extends string, Data> = {
2673
2783
  request: Request;
@@ -2711,6 +2821,40 @@ export type PagesPluginFunction<
2711
2821
  > = (
2712
2822
  context: EventPluginContext<Env, Params, Data, PluginArgs>
2713
2823
  ) => Response | Promise<Response>;
2824
+ // https://developers.cloudflare.com/pub-sub/
2825
+ // PubSubMessage represents an incoming PubSub message.
2826
+ // The message includes metadata about the broker, the client, and the payload
2827
+ // itself.
2828
+ export interface PubSubMessage {
2829
+ // Message ID
2830
+ readonly mid: number;
2831
+ // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
2832
+ readonly broker: string;
2833
+ // The MQTT topic the message was sent on.
2834
+ readonly topic: string;
2835
+ // The client ID of the client that published this message.
2836
+ readonly clientId: string;
2837
+ // The unique identifier (JWT ID) used by the client to authenticate, if token
2838
+ // auth was used.
2839
+ readonly jti?: string;
2840
+ // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
2841
+ // received the message from the client.
2842
+ readonly receivedAt: number;
2843
+ // An (optional) string with the MIME type of the payload, if set by the
2844
+ // client.
2845
+ readonly contentType: string;
2846
+ // Set to 1 when the payload is a UTF-8 string
2847
+ // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
2848
+ readonly payloadFormatIndicator: number;
2849
+ // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
2850
+ // You can use payloadFormatIndicator to inspect this before decoding.
2851
+ payload: string | Uint8Array;
2852
+ }
2853
+ // JsonWebKey extended by kid parameter
2854
+ export interface JsonWebKeyWithKid extends JsonWebKey {
2855
+ // Key Identifier of the JWK
2856
+ readonly kid: string;
2857
+ }
2714
2858
  /**
2715
2859
  * A message that is sent to a consumer Worker.
2716
2860
  */
@@ -2727,6 +2871,14 @@ export interface Message<Body = unknown> {
2727
2871
  * The body of the message.
2728
2872
  */
2729
2873
  readonly body: Body;
2874
+ /**
2875
+ * Marks message to be retried.
2876
+ */
2877
+ retry(): void;
2878
+ /**
2879
+ * Marks message acknowledged.
2880
+ */
2881
+ ack(): void;
2730
2882
  }
2731
2883
  /**
2732
2884
  * A batch of messages that are sent to a consumer Worker.
@@ -2744,7 +2896,20 @@ export interface MessageBatch<Body = unknown> {
2744
2896
  * Marks every message to be retried in the next batch.
2745
2897
  */
2746
2898
  retryAll(): void;
2899
+ /**
2900
+ * Marks every message acknowledged in the batch.
2901
+ */
2902
+ ackAll(): void;
2747
2903
  }
2904
+ /**
2905
+ * A wrapper class used to structure message batches.
2906
+ */
2907
+ export type MessageSendRequest<Body = unknown> = {
2908
+ /**
2909
+ * The body of the message.
2910
+ */
2911
+ body: Body;
2912
+ };
2748
2913
  /**
2749
2914
  * A binding that allows a producer to send messages to a Queue.
2750
2915
  */
@@ -2755,4 +2920,10 @@ export interface Queue<Body = any> {
2755
2920
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2756
2921
  */
2757
2922
  send(message: Body): Promise<void>;
2923
+ /**
2924
+ * Sends a batch of messages to the Queue.
2925
+ * @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.
2926
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2927
+ */
2928
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2758
2929
  }