@cloudflare/workers-types 0.20221111.0 → 0.20230115.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>;
@@ -531,7 +538,7 @@ declare interface SchedulerWaitOptions {
531
538
  signal?: AbortSignal;
532
539
  }
533
540
  declare abstract class ExtendableEvent extends Event {
534
- waitUntil(promise: void | Promise<void>): void;
541
+ waitUntil(promise: Promise<any>): void;
535
542
  }
536
543
  declare class Blob {
537
544
  constructor(
@@ -969,16 +976,16 @@ declare interface ResponseInit {
969
976
  encodeBody?: "automatic" | "manual";
970
977
  }
971
978
  declare type RequestInfo = Request | string | URL;
972
- declare class Request extends Body {
979
+ declare class Request<CfHostMetadata = unknown> extends Body {
973
980
  constructor(input: RequestInfo, init?: RequestInit);
974
- clone(): Request;
981
+ clone(): Request<CfHostMetadata>;
975
982
  get method(): string;
976
983
  get url(): string;
977
984
  get headers(): Headers;
978
985
  get redirect(): string;
979
986
  get fetcher(): Fetcher | null;
980
987
  get signal(): AbortSignal;
981
- get cf(): IncomingRequestCfProperties | undefined;
988
+ get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
982
989
  }
983
990
  declare interface RequestInit<
984
991
  CfType = IncomingRequestCfProperties | RequestInitCfProperties
@@ -1147,9 +1154,41 @@ declare abstract class R2Bucket {
1147
1154
  | Blob,
1148
1155
  options?: R2PutOptions
1149
1156
  ): Promise<R2Object>;
1157
+ put(
1158
+ key: string,
1159
+ value:
1160
+ | ReadableStream
1161
+ | ArrayBuffer
1162
+ | ArrayBufferView
1163
+ | string
1164
+ | null
1165
+ | Blob,
1166
+ options?: R2PutOptions & {
1167
+ onlyIf: R2Conditional | Headers;
1168
+ }
1169
+ ): Promise<R2Object | null>;
1170
+ createMultipartUpload(
1171
+ key: string,
1172
+ options?: R2MultipartOptions
1173
+ ): Promise<R2MultipartUpload>;
1174
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1150
1175
  delete(keys: string | string[]): Promise<void>;
1151
1176
  list(options?: R2ListOptions): Promise<R2Objects>;
1152
1177
  }
1178
+ declare interface R2MultipartUpload {
1179
+ readonly key: string;
1180
+ readonly uploadId: string;
1181
+ uploadPart(
1182
+ partNumber: number,
1183
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1184
+ ): Promise<R2UploadedPart>;
1185
+ abort(): Promise<void>;
1186
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1187
+ }
1188
+ declare interface R2UploadedPart {
1189
+ partNumber: number;
1190
+ etag: string;
1191
+ }
1153
1192
  declare abstract class R2Object {
1154
1193
  readonly key: string;
1155
1194
  readonly version: string;
@@ -1204,6 +1243,10 @@ declare interface R2PutOptions {
1204
1243
  sha384?: ArrayBuffer | string;
1205
1244
  sha512?: ArrayBuffer | string;
1206
1245
  }
1246
+ declare interface R2MultipartOptions {
1247
+ httpMetadata?: R2HTTPMetadata | Headers;
1248
+ customMetadata?: Record<string, string>;
1249
+ }
1207
1250
  declare interface R2Checksums {
1208
1251
  readonly md5?: ArrayBuffer;
1209
1252
  readonly sha1?: ArrayBuffer;
@@ -1322,6 +1365,7 @@ declare type ReadableStreamReadResult<R = any> =
1322
1365
  };
1323
1366
  /** 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. */
1324
1367
  declare interface ReadableStream<R = any> {
1368
+ get locked(): boolean;
1325
1369
  cancel(reason?: any): Promise<void>;
1326
1370
  getReader(): ReadableStreamDefaultReader<R>;
1327
1371
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1506,6 +1550,9 @@ declare interface TraceItem {
1506
1550
  | TraceItemFetchEventInfo
1507
1551
  | TraceItemScheduledEventInfo
1508
1552
  | TraceItemAlarmEventInfo
1553
+ | TraceItemQueueEventInfo
1554
+ | TraceItemEmailEventInfo
1555
+ | TraceItemCustomEventInfo
1509
1556
  )
1510
1557
  | null;
1511
1558
  readonly eventTimestamp: number | null;
@@ -1513,15 +1560,26 @@ declare interface TraceItem {
1513
1560
  readonly exceptions: TraceException[];
1514
1561
  readonly scriptName: string | null;
1515
1562
  readonly dispatchNamespace?: string;
1563
+ readonly scriptTags?: string[];
1516
1564
  readonly outcome: string;
1517
1565
  }
1518
1566
  declare interface TraceItemAlarmEventInfo {
1519
1567
  readonly scheduledTime: Date;
1520
1568
  }
1569
+ declare interface TraceItemCustomEventInfo {}
1521
1570
  declare interface TraceItemScheduledEventInfo {
1522
1571
  readonly scheduledTime: number;
1523
1572
  readonly cron: string;
1524
1573
  }
1574
+ declare interface TraceItemQueueEventInfo {
1575
+ readonly queue: string;
1576
+ readonly batchSize: number;
1577
+ }
1578
+ declare interface TraceItemEmailEventInfo {
1579
+ readonly mailFrom: string;
1580
+ readonly rcptTo: string;
1581
+ readonly rawSize: number;
1582
+ }
1525
1583
  declare interface TraceItemFetchEventInfo {
1526
1584
  readonly response?: TraceItemFetchEventInfoResponse;
1527
1585
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2651,6 +2709,52 @@ declare abstract class D1PreparedStatement {
2651
2709
  all<T = unknown>(): Promise<D1Result<T>>;
2652
2710
  raw<T = unknown>(): Promise<T[]>;
2653
2711
  }
2712
+ /**
2713
+ * A email message that is sent to a consumer Worker.
2714
+ */
2715
+ declare interface EmailMessage<Body = unknown> {
2716
+ /**
2717
+ * Envelope From attribute of the email message.
2718
+ */
2719
+ readonly from: string;
2720
+ /**
2721
+ * Envelope To attribute of the email message.
2722
+ */
2723
+ readonly to: string;
2724
+ /**
2725
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2726
+ */
2727
+ readonly headers: Headers;
2728
+ /**
2729
+ * Stream of the email message content.
2730
+ */
2731
+ readonly raw: ReadableStream;
2732
+ /**
2733
+ * Size of the email message content.
2734
+ */
2735
+ readonly rawSize: number;
2736
+ /**
2737
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2738
+ * @param reason The reject reason.
2739
+ * @returns void
2740
+ */
2741
+ setReject(reason: string): void;
2742
+ /**
2743
+ * Forward this email message to a verified destination address of the account.
2744
+ * @param rcptTo Verified destination address.
2745
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2746
+ * @returns A promise that resolves when the email message is forwarded.
2747
+ */
2748
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2749
+ }
2750
+ declare abstract class EmailEvent extends ExtendableEvent {
2751
+ readonly message: EmailMessage;
2752
+ }
2753
+ declare type EmailExportedHandler<Env = unknown> = (
2754
+ message: EmailMessage,
2755
+ env: Env,
2756
+ ctx: ExecutionContext
2757
+ ) => void | Promise<void>;
2654
2758
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2655
2759
  declare type EventContext<Env, P extends string, Data> = {
2656
2760
  request: Request;
@@ -2731,6 +2835,15 @@ declare interface MessageBatch<Body = unknown> {
2731
2835
  */
2732
2836
  retryAll(): void;
2733
2837
  }
2838
+ /**
2839
+ * A wrapper class used to structure message batches.
2840
+ */
2841
+ declare type MessageSendRequest<Body = unknown> = {
2842
+ /**
2843
+ * The body of the message.
2844
+ */
2845
+ body: Body;
2846
+ };
2734
2847
  /**
2735
2848
  * A binding that allows a producer to send messages to a Queue.
2736
2849
  */
@@ -2741,4 +2854,10 @@ declare interface Queue<Body = any> {
2741
2854
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2742
2855
  */
2743
2856
  send(message: Body): Promise<void>;
2857
+ /**
2858
+ * Sends a batch of messages to the Queue.
2859
+ * @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.
2860
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2861
+ */
2862
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2744
2863
  }
@@ -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>;
@@ -533,7 +540,7 @@ export interface SchedulerWaitOptions {
533
540
  signal?: AbortSignal;
534
541
  }
535
542
  export declare abstract class ExtendableEvent extends Event {
536
- waitUntil(promise: void | Promise<void>): void;
543
+ waitUntil(promise: Promise<any>): void;
537
544
  }
538
545
  export declare class Blob {
539
546
  constructor(
@@ -971,16 +978,16 @@ export interface ResponseInit {
971
978
  encodeBody?: "automatic" | "manual";
972
979
  }
973
980
  export type RequestInfo = Request | string | URL;
974
- export declare class Request extends Body {
981
+ export declare class Request<CfHostMetadata = unknown> extends Body {
975
982
  constructor(input: RequestInfo, init?: RequestInit);
976
- clone(): Request;
983
+ clone(): Request<CfHostMetadata>;
977
984
  get method(): string;
978
985
  get url(): string;
979
986
  get headers(): Headers;
980
987
  get redirect(): string;
981
988
  get fetcher(): Fetcher | null;
982
989
  get signal(): AbortSignal;
983
- get cf(): IncomingRequestCfProperties | undefined;
990
+ get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
984
991
  }
985
992
  export interface RequestInit<
986
993
  CfType = IncomingRequestCfProperties | RequestInitCfProperties
@@ -1149,9 +1156,41 @@ export declare abstract class R2Bucket {
1149
1156
  | Blob,
1150
1157
  options?: R2PutOptions
1151
1158
  ): Promise<R2Object>;
1159
+ put(
1160
+ key: string,
1161
+ value:
1162
+ | ReadableStream
1163
+ | ArrayBuffer
1164
+ | ArrayBufferView
1165
+ | string
1166
+ | null
1167
+ | Blob,
1168
+ options?: R2PutOptions & {
1169
+ onlyIf: R2Conditional | Headers;
1170
+ }
1171
+ ): Promise<R2Object | null>;
1172
+ createMultipartUpload(
1173
+ key: string,
1174
+ options?: R2MultipartOptions
1175
+ ): Promise<R2MultipartUpload>;
1176
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1152
1177
  delete(keys: string | string[]): Promise<void>;
1153
1178
  list(options?: R2ListOptions): Promise<R2Objects>;
1154
1179
  }
1180
+ export interface R2MultipartUpload {
1181
+ readonly key: string;
1182
+ readonly uploadId: string;
1183
+ uploadPart(
1184
+ partNumber: number,
1185
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1186
+ ): Promise<R2UploadedPart>;
1187
+ abort(): Promise<void>;
1188
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1189
+ }
1190
+ export interface R2UploadedPart {
1191
+ partNumber: number;
1192
+ etag: string;
1193
+ }
1155
1194
  export declare abstract class R2Object {
1156
1195
  readonly key: string;
1157
1196
  readonly version: string;
@@ -1206,6 +1245,10 @@ export interface R2PutOptions {
1206
1245
  sha384?: ArrayBuffer | string;
1207
1246
  sha512?: ArrayBuffer | string;
1208
1247
  }
1248
+ export interface R2MultipartOptions {
1249
+ httpMetadata?: R2HTTPMetadata | Headers;
1250
+ customMetadata?: Record<string, string>;
1251
+ }
1209
1252
  export interface R2Checksums {
1210
1253
  readonly md5?: ArrayBuffer;
1211
1254
  readonly sha1?: ArrayBuffer;
@@ -1324,6 +1367,7 @@ export type ReadableStreamReadResult<R = any> =
1324
1367
  };
1325
1368
  /** 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. */
1326
1369
  export interface ReadableStream<R = any> {
1370
+ get locked(): boolean;
1327
1371
  cancel(reason?: any): Promise<void>;
1328
1372
  getReader(): ReadableStreamDefaultReader<R>;
1329
1373
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1511,6 +1555,9 @@ export interface TraceItem {
1511
1555
  | TraceItemFetchEventInfo
1512
1556
  | TraceItemScheduledEventInfo
1513
1557
  | TraceItemAlarmEventInfo
1558
+ | TraceItemQueueEventInfo
1559
+ | TraceItemEmailEventInfo
1560
+ | TraceItemCustomEventInfo
1514
1561
  )
1515
1562
  | null;
1516
1563
  readonly eventTimestamp: number | null;
@@ -1518,15 +1565,26 @@ export interface TraceItem {
1518
1565
  readonly exceptions: TraceException[];
1519
1566
  readonly scriptName: string | null;
1520
1567
  readonly dispatchNamespace?: string;
1568
+ readonly scriptTags?: string[];
1521
1569
  readonly outcome: string;
1522
1570
  }
1523
1571
  export interface TraceItemAlarmEventInfo {
1524
1572
  readonly scheduledTime: Date;
1525
1573
  }
1574
+ export interface TraceItemCustomEventInfo {}
1526
1575
  export interface TraceItemScheduledEventInfo {
1527
1576
  readonly scheduledTime: number;
1528
1577
  readonly cron: string;
1529
1578
  }
1579
+ export interface TraceItemQueueEventInfo {
1580
+ readonly queue: string;
1581
+ readonly batchSize: number;
1582
+ }
1583
+ export interface TraceItemEmailEventInfo {
1584
+ readonly mailFrom: string;
1585
+ readonly rcptTo: string;
1586
+ readonly rawSize: number;
1587
+ }
1530
1588
  export interface TraceItemFetchEventInfo {
1531
1589
  readonly response?: TraceItemFetchEventInfoResponse;
1532
1590
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2656,6 +2714,52 @@ export declare abstract class D1PreparedStatement {
2656
2714
  all<T = unknown>(): Promise<D1Result<T>>;
2657
2715
  raw<T = unknown>(): Promise<T[]>;
2658
2716
  }
2717
+ /**
2718
+ * A email message that is sent to a consumer Worker.
2719
+ */
2720
+ export interface EmailMessage<Body = unknown> {
2721
+ /**
2722
+ * Envelope From attribute of the email message.
2723
+ */
2724
+ readonly from: string;
2725
+ /**
2726
+ * Envelope To attribute of the email message.
2727
+ */
2728
+ readonly to: string;
2729
+ /**
2730
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2731
+ */
2732
+ readonly headers: Headers;
2733
+ /**
2734
+ * Stream of the email message content.
2735
+ */
2736
+ readonly raw: ReadableStream;
2737
+ /**
2738
+ * Size of the email message content.
2739
+ */
2740
+ readonly rawSize: number;
2741
+ /**
2742
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2743
+ * @param reason The reject reason.
2744
+ * @returns void
2745
+ */
2746
+ setReject(reason: string): void;
2747
+ /**
2748
+ * Forward this email message to a verified destination address of the account.
2749
+ * @param rcptTo Verified destination address.
2750
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2751
+ * @returns A promise that resolves when the email message is forwarded.
2752
+ */
2753
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2754
+ }
2755
+ export declare abstract class EmailEvent extends ExtendableEvent {
2756
+ readonly message: EmailMessage;
2757
+ }
2758
+ export type EmailExportedHandler<Env = unknown> = (
2759
+ message: EmailMessage,
2760
+ env: Env,
2761
+ ctx: ExecutionContext
2762
+ ) => void | Promise<void>;
2659
2763
  export type Params<P extends string = any> = Record<P, string | string[]>;
2660
2764
  export type EventContext<Env, P extends string, Data> = {
2661
2765
  request: Request;
@@ -2733,6 +2837,15 @@ export interface MessageBatch<Body = unknown> {
2733
2837
  */
2734
2838
  retryAll(): void;
2735
2839
  }
2840
+ /**
2841
+ * A wrapper class used to structure message batches.
2842
+ */
2843
+ export type MessageSendRequest<Body = unknown> = {
2844
+ /**
2845
+ * The body of the message.
2846
+ */
2847
+ body: Body;
2848
+ };
2736
2849
  /**
2737
2850
  * A binding that allows a producer to send messages to a Queue.
2738
2851
  */
@@ -2743,4 +2856,10 @@ export interface Queue<Body = any> {
2743
2856
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2744
2857
  */
2745
2858
  send(message: Body): Promise<void>;
2859
+ /**
2860
+ * Sends a batch of messages to the Queue.
2861
+ * @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.
2862
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2863
+ */
2864
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2746
2865
  }
@@ -283,7 +283,7 @@ declare const caches: CacheStorage;
283
283
  declare const scheduler: Scheduler;
284
284
  declare const navigator: Navigator;
285
285
  declare interface ExecutionContext {
286
- waitUntil(promise: void | Promise<void>): void;
286
+ waitUntil(promise: Promise<any>): void;
287
287
  passThroughOnException(): void;
288
288
  }
289
289
  declare type ExportedHandlerFetchHandler<Env = unknown> = (
@@ -341,13 +341,20 @@ declare interface DurableObjectNamespace {
341
341
  ): DurableObjectId;
342
342
  idFromName(name: string): DurableObjectId;
343
343
  idFromString(id: string): DurableObjectId;
344
- get(id: DurableObjectId): DurableObjectStub;
344
+ get(
345
+ id: DurableObjectId,
346
+ options?: DurableObjectNamespaceGetDurableObjectOptions
347
+ ): DurableObjectStub;
348
+ jurisdiction(jurisdiction: string): DurableObjectNamespace;
345
349
  }
346
350
  declare interface DurableObjectNamespaceNewUniqueIdOptions {
347
351
  jurisdiction?: string;
348
352
  }
353
+ declare interface DurableObjectNamespaceGetDurableObjectOptions {
354
+ locationHint?: string;
355
+ }
349
356
  declare interface DurableObjectState {
350
- waitUntil(promise: void | Promise<void>): void;
357
+ waitUntil(promise: Promise<any>): void;
351
358
  readonly id: DurableObjectId;
352
359
  readonly storage: DurableObjectStorage;
353
360
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
@@ -537,7 +544,7 @@ declare interface SchedulerWaitOptions {
537
544
  signal?: AbortSignal;
538
545
  }
539
546
  declare abstract class ExtendableEvent extends Event {
540
- waitUntil(promise: void | Promise<void>): void;
547
+ waitUntil(promise: Promise<any>): void;
541
548
  }
542
549
  declare class Blob {
543
550
  constructor(
@@ -975,16 +982,16 @@ declare interface ResponseInit {
975
982
  encodeBody?: "automatic" | "manual";
976
983
  }
977
984
  declare type RequestInfo = Request | string | URL;
978
- declare class Request extends Body {
985
+ declare class Request<CfHostMetadata = unknown> extends Body {
979
986
  constructor(input: RequestInfo, init?: RequestInit);
980
- clone(): Request;
987
+ clone(): Request<CfHostMetadata>;
981
988
  get method(): string;
982
989
  get url(): string;
983
990
  get headers(): Headers;
984
991
  get redirect(): string;
985
992
  get fetcher(): Fetcher | null;
986
993
  get signal(): AbortSignal;
987
- get cf(): IncomingRequestCfProperties | undefined;
994
+ get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
988
995
  }
989
996
  declare interface RequestInit<
990
997
  CfType = IncomingRequestCfProperties | RequestInitCfProperties
@@ -1153,9 +1160,41 @@ declare abstract class R2Bucket {
1153
1160
  | Blob,
1154
1161
  options?: R2PutOptions
1155
1162
  ): Promise<R2Object>;
1163
+ put(
1164
+ key: string,
1165
+ value:
1166
+ | ReadableStream
1167
+ | ArrayBuffer
1168
+ | ArrayBufferView
1169
+ | string
1170
+ | null
1171
+ | Blob,
1172
+ options?: R2PutOptions & {
1173
+ onlyIf: R2Conditional | Headers;
1174
+ }
1175
+ ): Promise<R2Object | null>;
1176
+ createMultipartUpload(
1177
+ key: string,
1178
+ options?: R2MultipartOptions
1179
+ ): Promise<R2MultipartUpload>;
1180
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1156
1181
  delete(keys: string | string[]): Promise<void>;
1157
1182
  list(options?: R2ListOptions): Promise<R2Objects>;
1158
1183
  }
1184
+ declare interface R2MultipartUpload {
1185
+ readonly key: string;
1186
+ readonly uploadId: string;
1187
+ uploadPart(
1188
+ partNumber: number,
1189
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1190
+ ): Promise<R2UploadedPart>;
1191
+ abort(): Promise<void>;
1192
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1193
+ }
1194
+ declare interface R2UploadedPart {
1195
+ partNumber: number;
1196
+ etag: string;
1197
+ }
1159
1198
  declare abstract class R2Object {
1160
1199
  readonly key: string;
1161
1200
  readonly version: string;
@@ -1210,6 +1249,10 @@ declare interface R2PutOptions {
1210
1249
  sha384?: ArrayBuffer | string;
1211
1250
  sha512?: ArrayBuffer | string;
1212
1251
  }
1252
+ declare interface R2MultipartOptions {
1253
+ httpMetadata?: R2HTTPMetadata | Headers;
1254
+ customMetadata?: Record<string, string>;
1255
+ }
1213
1256
  declare interface R2Checksums {
1214
1257
  readonly md5?: ArrayBuffer;
1215
1258
  readonly sha1?: ArrayBuffer;
@@ -1328,6 +1371,7 @@ declare type ReadableStreamReadResult<R = any> =
1328
1371
  };
1329
1372
  /** 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. */
1330
1373
  declare interface ReadableStream<R = any> {
1374
+ get locked(): boolean;
1331
1375
  cancel(reason?: any): Promise<void>;
1332
1376
  getReader(): ReadableStreamDefaultReader<R>;
1333
1377
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1512,6 +1556,9 @@ declare interface TraceItem {
1512
1556
  | TraceItemFetchEventInfo
1513
1557
  | TraceItemScheduledEventInfo
1514
1558
  | TraceItemAlarmEventInfo
1559
+ | TraceItemQueueEventInfo
1560
+ | TraceItemEmailEventInfo
1561
+ | TraceItemCustomEventInfo
1515
1562
  )
1516
1563
  | null;
1517
1564
  readonly eventTimestamp: number | null;
@@ -1519,15 +1566,26 @@ declare interface TraceItem {
1519
1566
  readonly exceptions: TraceException[];
1520
1567
  readonly scriptName: string | null;
1521
1568
  readonly dispatchNamespace?: string;
1569
+ readonly scriptTags?: string[];
1522
1570
  readonly outcome: string;
1523
1571
  }
1524
1572
  declare interface TraceItemAlarmEventInfo {
1525
1573
  readonly scheduledTime: Date;
1526
1574
  }
1575
+ declare interface TraceItemCustomEventInfo {}
1527
1576
  declare interface TraceItemScheduledEventInfo {
1528
1577
  readonly scheduledTime: number;
1529
1578
  readonly cron: string;
1530
1579
  }
1580
+ declare interface TraceItemQueueEventInfo {
1581
+ readonly queue: string;
1582
+ readonly batchSize: number;
1583
+ }
1584
+ declare interface TraceItemEmailEventInfo {
1585
+ readonly mailFrom: string;
1586
+ readonly rcptTo: string;
1587
+ readonly rawSize: number;
1588
+ }
1531
1589
  declare interface TraceItemFetchEventInfo {
1532
1590
  readonly response?: TraceItemFetchEventInfoResponse;
1533
1591
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2657,6 +2715,52 @@ declare abstract class D1PreparedStatement {
2657
2715
  all<T = unknown>(): Promise<D1Result<T>>;
2658
2716
  raw<T = unknown>(): Promise<T[]>;
2659
2717
  }
2718
+ /**
2719
+ * A email message that is sent to a consumer Worker.
2720
+ */
2721
+ declare interface EmailMessage<Body = unknown> {
2722
+ /**
2723
+ * Envelope From attribute of the email message.
2724
+ */
2725
+ readonly from: string;
2726
+ /**
2727
+ * Envelope To attribute of the email message.
2728
+ */
2729
+ readonly to: string;
2730
+ /**
2731
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2732
+ */
2733
+ readonly headers: Headers;
2734
+ /**
2735
+ * Stream of the email message content.
2736
+ */
2737
+ readonly raw: ReadableStream;
2738
+ /**
2739
+ * Size of the email message content.
2740
+ */
2741
+ readonly rawSize: number;
2742
+ /**
2743
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2744
+ * @param reason The reject reason.
2745
+ * @returns void
2746
+ */
2747
+ setReject(reason: string): void;
2748
+ /**
2749
+ * Forward this email message to a verified destination address of the account.
2750
+ * @param rcptTo Verified destination address.
2751
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2752
+ * @returns A promise that resolves when the email message is forwarded.
2753
+ */
2754
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2755
+ }
2756
+ declare abstract class EmailEvent extends ExtendableEvent {
2757
+ readonly message: EmailMessage;
2758
+ }
2759
+ declare type EmailExportedHandler<Env = unknown> = (
2760
+ message: EmailMessage,
2761
+ env: Env,
2762
+ ctx: ExecutionContext
2763
+ ) => void | Promise<void>;
2660
2764
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2661
2765
  declare type EventContext<Env, P extends string, Data> = {
2662
2766
  request: Request;
@@ -2737,6 +2841,15 @@ declare interface MessageBatch<Body = unknown> {
2737
2841
  */
2738
2842
  retryAll(): void;
2739
2843
  }
2844
+ /**
2845
+ * A wrapper class used to structure message batches.
2846
+ */
2847
+ declare type MessageSendRequest<Body = unknown> = {
2848
+ /**
2849
+ * The body of the message.
2850
+ */
2851
+ body: Body;
2852
+ };
2740
2853
  /**
2741
2854
  * A binding that allows a producer to send messages to a Queue.
2742
2855
  */
@@ -2747,4 +2860,10 @@ declare interface Queue<Body = any> {
2747
2860
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2748
2861
  */
2749
2862
  send(message: Body): Promise<void>;
2863
+ /**
2864
+ * Sends a batch of messages to the Queue.
2865
+ * @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.
2866
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2867
+ */
2868
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2750
2869
  }