@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.
@@ -285,7 +285,7 @@ export declare const caches: CacheStorage;
285
285
  export declare const scheduler: Scheduler;
286
286
  export declare const navigator: Navigator;
287
287
  export interface ExecutionContext {
288
- waitUntil(promise: void | Promise<void>): void;
288
+ waitUntil(promise: Promise<any>): void;
289
289
  passThroughOnException(): void;
290
290
  }
291
291
  export type ExportedHandlerFetchHandler<Env = unknown> = (
@@ -343,13 +343,20 @@ export interface DurableObjectNamespace {
343
343
  ): DurableObjectId;
344
344
  idFromName(name: string): DurableObjectId;
345
345
  idFromString(id: string): DurableObjectId;
346
- get(id: DurableObjectId): DurableObjectStub;
346
+ get(
347
+ id: DurableObjectId,
348
+ options?: DurableObjectNamespaceGetDurableObjectOptions
349
+ ): DurableObjectStub;
350
+ jurisdiction(jurisdiction: string): DurableObjectNamespace;
347
351
  }
348
352
  export interface DurableObjectNamespaceNewUniqueIdOptions {
349
353
  jurisdiction?: string;
350
354
  }
355
+ export interface DurableObjectNamespaceGetDurableObjectOptions {
356
+ locationHint?: string;
357
+ }
351
358
  export interface DurableObjectState {
352
- waitUntil(promise: void | Promise<void>): void;
359
+ waitUntil(promise: Promise<any>): void;
353
360
  readonly id: DurableObjectId;
354
361
  readonly storage: DurableObjectStorage;
355
362
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
@@ -539,7 +546,7 @@ export interface SchedulerWaitOptions {
539
546
  signal?: AbortSignal;
540
547
  }
541
548
  export declare abstract class ExtendableEvent extends Event {
542
- waitUntil(promise: void | Promise<void>): void;
549
+ waitUntil(promise: Promise<any>): void;
543
550
  }
544
551
  export declare class Blob {
545
552
  constructor(
@@ -977,16 +984,16 @@ export interface ResponseInit {
977
984
  encodeBody?: "automatic" | "manual";
978
985
  }
979
986
  export type RequestInfo = Request | string | URL;
980
- export declare class Request extends Body {
987
+ export declare class Request<CfHostMetadata = unknown> extends Body {
981
988
  constructor(input: RequestInfo, init?: RequestInit);
982
- clone(): Request;
989
+ clone(): Request<CfHostMetadata>;
983
990
  get method(): string;
984
991
  get url(): string;
985
992
  get headers(): Headers;
986
993
  get redirect(): string;
987
994
  get fetcher(): Fetcher | null;
988
995
  get signal(): AbortSignal;
989
- get cf(): IncomingRequestCfProperties | undefined;
996
+ get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
990
997
  }
991
998
  export interface RequestInit<
992
999
  CfType = IncomingRequestCfProperties | RequestInitCfProperties
@@ -1155,9 +1162,41 @@ export declare abstract class R2Bucket {
1155
1162
  | Blob,
1156
1163
  options?: R2PutOptions
1157
1164
  ): Promise<R2Object>;
1165
+ put(
1166
+ key: string,
1167
+ value:
1168
+ | ReadableStream
1169
+ | ArrayBuffer
1170
+ | ArrayBufferView
1171
+ | string
1172
+ | null
1173
+ | Blob,
1174
+ options?: R2PutOptions & {
1175
+ onlyIf: R2Conditional | Headers;
1176
+ }
1177
+ ): Promise<R2Object | null>;
1178
+ createMultipartUpload(
1179
+ key: string,
1180
+ options?: R2MultipartOptions
1181
+ ): Promise<R2MultipartUpload>;
1182
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1158
1183
  delete(keys: string | string[]): Promise<void>;
1159
1184
  list(options?: R2ListOptions): Promise<R2Objects>;
1160
1185
  }
1186
+ export interface R2MultipartUpload {
1187
+ readonly key: string;
1188
+ readonly uploadId: string;
1189
+ uploadPart(
1190
+ partNumber: number,
1191
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1192
+ ): Promise<R2UploadedPart>;
1193
+ abort(): Promise<void>;
1194
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1195
+ }
1196
+ export interface R2UploadedPart {
1197
+ partNumber: number;
1198
+ etag: string;
1199
+ }
1161
1200
  export declare abstract class R2Object {
1162
1201
  readonly key: string;
1163
1202
  readonly version: string;
@@ -1212,6 +1251,10 @@ export interface R2PutOptions {
1212
1251
  sha384?: ArrayBuffer | string;
1213
1252
  sha512?: ArrayBuffer | string;
1214
1253
  }
1254
+ export interface R2MultipartOptions {
1255
+ httpMetadata?: R2HTTPMetadata | Headers;
1256
+ customMetadata?: Record<string, string>;
1257
+ }
1215
1258
  export interface R2Checksums {
1216
1259
  readonly md5?: ArrayBuffer;
1217
1260
  readonly sha1?: ArrayBuffer;
@@ -1330,6 +1373,7 @@ export type ReadableStreamReadResult<R = any> =
1330
1373
  };
1331
1374
  /** 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
1375
  export interface ReadableStream<R = any> {
1376
+ get locked(): boolean;
1333
1377
  cancel(reason?: any): Promise<void>;
1334
1378
  getReader(): ReadableStreamDefaultReader<R>;
1335
1379
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1517,6 +1561,9 @@ export interface TraceItem {
1517
1561
  | TraceItemFetchEventInfo
1518
1562
  | TraceItemScheduledEventInfo
1519
1563
  | TraceItemAlarmEventInfo
1564
+ | TraceItemQueueEventInfo
1565
+ | TraceItemEmailEventInfo
1566
+ | TraceItemCustomEventInfo
1520
1567
  )
1521
1568
  | null;
1522
1569
  readonly eventTimestamp: number | null;
@@ -1524,15 +1571,26 @@ export interface TraceItem {
1524
1571
  readonly exceptions: TraceException[];
1525
1572
  readonly scriptName: string | null;
1526
1573
  readonly dispatchNamespace?: string;
1574
+ readonly scriptTags?: string[];
1527
1575
  readonly outcome: string;
1528
1576
  }
1529
1577
  export interface TraceItemAlarmEventInfo {
1530
1578
  readonly scheduledTime: Date;
1531
1579
  }
1580
+ export interface TraceItemCustomEventInfo {}
1532
1581
  export interface TraceItemScheduledEventInfo {
1533
1582
  readonly scheduledTime: number;
1534
1583
  readonly cron: string;
1535
1584
  }
1585
+ export interface TraceItemQueueEventInfo {
1586
+ readonly queue: string;
1587
+ readonly batchSize: number;
1588
+ }
1589
+ export interface TraceItemEmailEventInfo {
1590
+ readonly mailFrom: string;
1591
+ readonly rcptTo: string;
1592
+ readonly rawSize: number;
1593
+ }
1536
1594
  export interface TraceItemFetchEventInfo {
1537
1595
  readonly response?: TraceItemFetchEventInfoResponse;
1538
1596
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2662,6 +2720,52 @@ export declare abstract class D1PreparedStatement {
2662
2720
  all<T = unknown>(): Promise<D1Result<T>>;
2663
2721
  raw<T = unknown>(): Promise<T[]>;
2664
2722
  }
2723
+ /**
2724
+ * A email message that is sent to a consumer Worker.
2725
+ */
2726
+ export interface EmailMessage<Body = unknown> {
2727
+ /**
2728
+ * Envelope From attribute of the email message.
2729
+ */
2730
+ readonly from: string;
2731
+ /**
2732
+ * Envelope To attribute of the email message.
2733
+ */
2734
+ readonly to: string;
2735
+ /**
2736
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2737
+ */
2738
+ readonly headers: Headers;
2739
+ /**
2740
+ * Stream of the email message content.
2741
+ */
2742
+ readonly raw: ReadableStream;
2743
+ /**
2744
+ * Size of the email message content.
2745
+ */
2746
+ readonly rawSize: number;
2747
+ /**
2748
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2749
+ * @param reason The reject reason.
2750
+ * @returns void
2751
+ */
2752
+ setReject(reason: string): void;
2753
+ /**
2754
+ * Forward this email message to a verified destination address of the account.
2755
+ * @param rcptTo Verified destination address.
2756
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2757
+ * @returns A promise that resolves when the email message is forwarded.
2758
+ */
2759
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2760
+ }
2761
+ export declare abstract class EmailEvent extends ExtendableEvent {
2762
+ readonly message: EmailMessage;
2763
+ }
2764
+ export type EmailExportedHandler<Env = unknown> = (
2765
+ message: EmailMessage,
2766
+ env: Env,
2767
+ ctx: ExecutionContext
2768
+ ) => void | Promise<void>;
2665
2769
  export type Params<P extends string = any> = Record<P, string | string[]>;
2666
2770
  export type EventContext<Env, P extends string, Data> = {
2667
2771
  request: Request;
@@ -2739,6 +2843,15 @@ export interface MessageBatch<Body = unknown> {
2739
2843
  */
2740
2844
  retryAll(): void;
2741
2845
  }
2846
+ /**
2847
+ * A wrapper class used to structure message batches.
2848
+ */
2849
+ export type MessageSendRequest<Body = unknown> = {
2850
+ /**
2851
+ * The body of the message.
2852
+ */
2853
+ body: Body;
2854
+ };
2742
2855
  /**
2743
2856
  * A binding that allows a producer to send messages to a Queue.
2744
2857
  */
@@ -2749,4 +2862,10 @@ export interface Queue<Body = any> {
2749
2862
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2750
2863
  */
2751
2864
  send(message: Body): Promise<void>;
2865
+ /**
2866
+ * Sends a batch of messages to the Queue.
2867
+ * @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.
2868
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2869
+ */
2870
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2752
2871
  }
@@ -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
@@ -1154,9 +1161,41 @@ declare abstract class R2Bucket {
1154
1161
  | Blob,
1155
1162
  options?: R2PutOptions
1156
1163
  ): Promise<R2Object>;
1164
+ put(
1165
+ key: string,
1166
+ value:
1167
+ | ReadableStream
1168
+ | ArrayBuffer
1169
+ | ArrayBufferView
1170
+ | string
1171
+ | null
1172
+ | Blob,
1173
+ options?: R2PutOptions & {
1174
+ onlyIf: R2Conditional | Headers;
1175
+ }
1176
+ ): Promise<R2Object | null>;
1177
+ createMultipartUpload(
1178
+ key: string,
1179
+ options?: R2MultipartOptions
1180
+ ): Promise<R2MultipartUpload>;
1181
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1157
1182
  delete(keys: string | string[]): Promise<void>;
1158
1183
  list(options?: R2ListOptions): Promise<R2Objects>;
1159
1184
  }
1185
+ declare interface R2MultipartUpload {
1186
+ readonly key: string;
1187
+ readonly uploadId: string;
1188
+ uploadPart(
1189
+ partNumber: number,
1190
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1191
+ ): Promise<R2UploadedPart>;
1192
+ abort(): Promise<void>;
1193
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1194
+ }
1195
+ declare interface R2UploadedPart {
1196
+ partNumber: number;
1197
+ etag: string;
1198
+ }
1160
1199
  declare abstract class R2Object {
1161
1200
  readonly key: string;
1162
1201
  readonly version: string;
@@ -1211,6 +1250,10 @@ declare interface R2PutOptions {
1211
1250
  sha384?: ArrayBuffer | string;
1212
1251
  sha512?: ArrayBuffer | string;
1213
1252
  }
1253
+ declare interface R2MultipartOptions {
1254
+ httpMetadata?: R2HTTPMetadata | Headers;
1255
+ customMetadata?: Record<string, string>;
1256
+ }
1214
1257
  declare interface R2Checksums {
1215
1258
  readonly md5?: ArrayBuffer;
1216
1259
  readonly sha1?: ArrayBuffer;
@@ -1329,6 +1372,7 @@ declare type ReadableStreamReadResult<R = any> =
1329
1372
  };
1330
1373
  /** 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. */
1331
1374
  declare interface ReadableStream<R = any> {
1375
+ get locked(): boolean;
1332
1376
  cancel(reason?: any): Promise<void>;
1333
1377
  getReader(): ReadableStreamDefaultReader<R>;
1334
1378
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1513,6 +1557,9 @@ declare interface TraceItem {
1513
1557
  | TraceItemFetchEventInfo
1514
1558
  | TraceItemScheduledEventInfo
1515
1559
  | TraceItemAlarmEventInfo
1560
+ | TraceItemQueueEventInfo
1561
+ | TraceItemEmailEventInfo
1562
+ | TraceItemCustomEventInfo
1516
1563
  )
1517
1564
  | null;
1518
1565
  readonly eventTimestamp: number | null;
@@ -1520,15 +1567,26 @@ declare interface TraceItem {
1520
1567
  readonly exceptions: TraceException[];
1521
1568
  readonly scriptName: string | null;
1522
1569
  readonly dispatchNamespace?: string;
1570
+ readonly scriptTags?: string[];
1523
1571
  readonly outcome: string;
1524
1572
  }
1525
1573
  declare interface TraceItemAlarmEventInfo {
1526
1574
  readonly scheduledTime: Date;
1527
1575
  }
1576
+ declare interface TraceItemCustomEventInfo {}
1528
1577
  declare interface TraceItemScheduledEventInfo {
1529
1578
  readonly scheduledTime: number;
1530
1579
  readonly cron: string;
1531
1580
  }
1581
+ declare interface TraceItemQueueEventInfo {
1582
+ readonly queue: string;
1583
+ readonly batchSize: number;
1584
+ }
1585
+ declare interface TraceItemEmailEventInfo {
1586
+ readonly mailFrom: string;
1587
+ readonly rcptTo: string;
1588
+ readonly rawSize: number;
1589
+ }
1532
1590
  declare interface TraceItemFetchEventInfo {
1533
1591
  readonly response?: TraceItemFetchEventInfoResponse;
1534
1592
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2658,6 +2716,52 @@ declare abstract class D1PreparedStatement {
2658
2716
  all<T = unknown>(): Promise<D1Result<T>>;
2659
2717
  raw<T = unknown>(): Promise<T[]>;
2660
2718
  }
2719
+ /**
2720
+ * A email message that is sent to a consumer Worker.
2721
+ */
2722
+ declare interface EmailMessage<Body = unknown> {
2723
+ /**
2724
+ * Envelope From attribute of the email message.
2725
+ */
2726
+ readonly from: string;
2727
+ /**
2728
+ * Envelope To attribute of the email message.
2729
+ */
2730
+ readonly to: string;
2731
+ /**
2732
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2733
+ */
2734
+ readonly headers: Headers;
2735
+ /**
2736
+ * Stream of the email message content.
2737
+ */
2738
+ readonly raw: ReadableStream;
2739
+ /**
2740
+ * Size of the email message content.
2741
+ */
2742
+ readonly rawSize: number;
2743
+ /**
2744
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2745
+ * @param reason The reject reason.
2746
+ * @returns void
2747
+ */
2748
+ setReject(reason: string): void;
2749
+ /**
2750
+ * Forward this email message to a verified destination address of the account.
2751
+ * @param rcptTo Verified destination address.
2752
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2753
+ * @returns A promise that resolves when the email message is forwarded.
2754
+ */
2755
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2756
+ }
2757
+ declare abstract class EmailEvent extends ExtendableEvent {
2758
+ readonly message: EmailMessage;
2759
+ }
2760
+ declare type EmailExportedHandler<Env = unknown> = (
2761
+ message: EmailMessage,
2762
+ env: Env,
2763
+ ctx: ExecutionContext
2764
+ ) => void | Promise<void>;
2661
2765
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2662
2766
  declare type EventContext<Env, P extends string, Data> = {
2663
2767
  request: Request;
@@ -2738,6 +2842,15 @@ declare interface MessageBatch<Body = unknown> {
2738
2842
  */
2739
2843
  retryAll(): void;
2740
2844
  }
2845
+ /**
2846
+ * A wrapper class used to structure message batches.
2847
+ */
2848
+ declare type MessageSendRequest<Body = unknown> = {
2849
+ /**
2850
+ * The body of the message.
2851
+ */
2852
+ body: Body;
2853
+ };
2741
2854
  /**
2742
2855
  * A binding that allows a producer to send messages to a Queue.
2743
2856
  */
@@ -2748,4 +2861,10 @@ declare interface Queue<Body = any> {
2748
2861
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2749
2862
  */
2750
2863
  send(message: Body): Promise<void>;
2864
+ /**
2865
+ * Sends a batch of messages to the Queue.
2866
+ * @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.
2867
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2868
+ */
2869
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2751
2870
  }
@@ -285,7 +285,7 @@ export declare const caches: CacheStorage;
285
285
  export declare const scheduler: Scheduler;
286
286
  export declare const navigator: Navigator;
287
287
  export interface ExecutionContext {
288
- waitUntil(promise: void | Promise<void>): void;
288
+ waitUntil(promise: Promise<any>): void;
289
289
  passThroughOnException(): void;
290
290
  }
291
291
  export type ExportedHandlerFetchHandler<Env = unknown> = (
@@ -343,13 +343,20 @@ export interface DurableObjectNamespace {
343
343
  ): DurableObjectId;
344
344
  idFromName(name: string): DurableObjectId;
345
345
  idFromString(id: string): DurableObjectId;
346
- get(id: DurableObjectId): DurableObjectStub;
346
+ get(
347
+ id: DurableObjectId,
348
+ options?: DurableObjectNamespaceGetDurableObjectOptions
349
+ ): DurableObjectStub;
350
+ jurisdiction(jurisdiction: string): DurableObjectNamespace;
347
351
  }
348
352
  export interface DurableObjectNamespaceNewUniqueIdOptions {
349
353
  jurisdiction?: string;
350
354
  }
355
+ export interface DurableObjectNamespaceGetDurableObjectOptions {
356
+ locationHint?: string;
357
+ }
351
358
  export interface DurableObjectState {
352
- waitUntil(promise: void | Promise<void>): void;
359
+ waitUntil(promise: Promise<any>): void;
353
360
  readonly id: DurableObjectId;
354
361
  readonly storage: DurableObjectStorage;
355
362
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
@@ -539,7 +546,7 @@ export interface SchedulerWaitOptions {
539
546
  signal?: AbortSignal;
540
547
  }
541
548
  export declare abstract class ExtendableEvent extends Event {
542
- waitUntil(promise: void | Promise<void>): void;
549
+ waitUntil(promise: Promise<any>): void;
543
550
  }
544
551
  export declare class Blob {
545
552
  constructor(
@@ -977,16 +984,16 @@ export interface ResponseInit {
977
984
  encodeBody?: "automatic" | "manual";
978
985
  }
979
986
  export type RequestInfo = Request | string | URL;
980
- export declare class Request extends Body {
987
+ export declare class Request<CfHostMetadata = unknown> extends Body {
981
988
  constructor(input: RequestInfo, init?: RequestInit);
982
- clone(): Request;
989
+ clone(): Request<CfHostMetadata>;
983
990
  get method(): string;
984
991
  get url(): string;
985
992
  get headers(): Headers;
986
993
  get redirect(): string;
987
994
  get fetcher(): Fetcher | null;
988
995
  get signal(): AbortSignal;
989
- get cf(): IncomingRequestCfProperties | undefined;
996
+ get cf(): IncomingRequestCfProperties<CfHostMetadata> | undefined;
990
997
  }
991
998
  export interface RequestInit<
992
999
  CfType = IncomingRequestCfProperties | RequestInitCfProperties
@@ -1156,9 +1163,41 @@ export declare abstract class R2Bucket {
1156
1163
  | Blob,
1157
1164
  options?: R2PutOptions
1158
1165
  ): Promise<R2Object>;
1166
+ put(
1167
+ key: string,
1168
+ value:
1169
+ | ReadableStream
1170
+ | ArrayBuffer
1171
+ | ArrayBufferView
1172
+ | string
1173
+ | null
1174
+ | Blob,
1175
+ options?: R2PutOptions & {
1176
+ onlyIf: R2Conditional | Headers;
1177
+ }
1178
+ ): Promise<R2Object | null>;
1179
+ createMultipartUpload(
1180
+ key: string,
1181
+ options?: R2MultipartOptions
1182
+ ): Promise<R2MultipartUpload>;
1183
+ resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1159
1184
  delete(keys: string | string[]): Promise<void>;
1160
1185
  list(options?: R2ListOptions): Promise<R2Objects>;
1161
1186
  }
1187
+ export interface R2MultipartUpload {
1188
+ readonly key: string;
1189
+ readonly uploadId: string;
1190
+ uploadPart(
1191
+ partNumber: number,
1192
+ value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob
1193
+ ): Promise<R2UploadedPart>;
1194
+ abort(): Promise<void>;
1195
+ complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1196
+ }
1197
+ export interface R2UploadedPart {
1198
+ partNumber: number;
1199
+ etag: string;
1200
+ }
1162
1201
  export declare abstract class R2Object {
1163
1202
  readonly key: string;
1164
1203
  readonly version: string;
@@ -1213,6 +1252,10 @@ export interface R2PutOptions {
1213
1252
  sha384?: ArrayBuffer | string;
1214
1253
  sha512?: ArrayBuffer | string;
1215
1254
  }
1255
+ export interface R2MultipartOptions {
1256
+ httpMetadata?: R2HTTPMetadata | Headers;
1257
+ customMetadata?: Record<string, string>;
1258
+ }
1216
1259
  export interface R2Checksums {
1217
1260
  readonly md5?: ArrayBuffer;
1218
1261
  readonly sha1?: ArrayBuffer;
@@ -1331,6 +1374,7 @@ export type ReadableStreamReadResult<R = any> =
1331
1374
  };
1332
1375
  /** 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. */
1333
1376
  export interface ReadableStream<R = any> {
1377
+ get locked(): boolean;
1334
1378
  cancel(reason?: any): Promise<void>;
1335
1379
  getReader(): ReadableStreamDefaultReader<R>;
1336
1380
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1518,6 +1562,9 @@ export interface TraceItem {
1518
1562
  | TraceItemFetchEventInfo
1519
1563
  | TraceItemScheduledEventInfo
1520
1564
  | TraceItemAlarmEventInfo
1565
+ | TraceItemQueueEventInfo
1566
+ | TraceItemEmailEventInfo
1567
+ | TraceItemCustomEventInfo
1521
1568
  )
1522
1569
  | null;
1523
1570
  readonly eventTimestamp: number | null;
@@ -1525,15 +1572,26 @@ export interface TraceItem {
1525
1572
  readonly exceptions: TraceException[];
1526
1573
  readonly scriptName: string | null;
1527
1574
  readonly dispatchNamespace?: string;
1575
+ readonly scriptTags?: string[];
1528
1576
  readonly outcome: string;
1529
1577
  }
1530
1578
  export interface TraceItemAlarmEventInfo {
1531
1579
  readonly scheduledTime: Date;
1532
1580
  }
1581
+ export interface TraceItemCustomEventInfo {}
1533
1582
  export interface TraceItemScheduledEventInfo {
1534
1583
  readonly scheduledTime: number;
1535
1584
  readonly cron: string;
1536
1585
  }
1586
+ export interface TraceItemQueueEventInfo {
1587
+ readonly queue: string;
1588
+ readonly batchSize: number;
1589
+ }
1590
+ export interface TraceItemEmailEventInfo {
1591
+ readonly mailFrom: string;
1592
+ readonly rcptTo: string;
1593
+ readonly rawSize: number;
1594
+ }
1537
1595
  export interface TraceItemFetchEventInfo {
1538
1596
  readonly response?: TraceItemFetchEventInfoResponse;
1539
1597
  readonly request: TraceItemFetchEventInfoRequest;
@@ -2663,6 +2721,52 @@ export declare abstract class D1PreparedStatement {
2663
2721
  all<T = unknown>(): Promise<D1Result<T>>;
2664
2722
  raw<T = unknown>(): Promise<T[]>;
2665
2723
  }
2724
+ /**
2725
+ * A email message that is sent to a consumer Worker.
2726
+ */
2727
+ export interface EmailMessage<Body = unknown> {
2728
+ /**
2729
+ * Envelope From attribute of the email message.
2730
+ */
2731
+ readonly from: string;
2732
+ /**
2733
+ * Envelope To attribute of the email message.
2734
+ */
2735
+ readonly to: string;
2736
+ /**
2737
+ * A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2738
+ */
2739
+ readonly headers: Headers;
2740
+ /**
2741
+ * Stream of the email message content.
2742
+ */
2743
+ readonly raw: ReadableStream;
2744
+ /**
2745
+ * Size of the email message content.
2746
+ */
2747
+ readonly rawSize: number;
2748
+ /**
2749
+ * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
2750
+ * @param reason The reject reason.
2751
+ * @returns void
2752
+ */
2753
+ setReject(reason: string): void;
2754
+ /**
2755
+ * Forward this email message to a verified destination address of the account.
2756
+ * @param rcptTo Verified destination address.
2757
+ * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
2758
+ * @returns A promise that resolves when the email message is forwarded.
2759
+ */
2760
+ forward(rcptTo: string, headers?: Headers): Promise<void>;
2761
+ }
2762
+ export declare abstract class EmailEvent extends ExtendableEvent {
2763
+ readonly message: EmailMessage;
2764
+ }
2765
+ export type EmailExportedHandler<Env = unknown> = (
2766
+ message: EmailMessage,
2767
+ env: Env,
2768
+ ctx: ExecutionContext
2769
+ ) => void | Promise<void>;
2666
2770
  export type Params<P extends string = any> = Record<P, string | string[]>;
2667
2771
  export type EventContext<Env, P extends string, Data> = {
2668
2772
  request: Request;
@@ -2740,6 +2844,15 @@ export interface MessageBatch<Body = unknown> {
2740
2844
  */
2741
2845
  retryAll(): void;
2742
2846
  }
2847
+ /**
2848
+ * A wrapper class used to structure message batches.
2849
+ */
2850
+ export type MessageSendRequest<Body = unknown> = {
2851
+ /**
2852
+ * The body of the message.
2853
+ */
2854
+ body: Body;
2855
+ };
2743
2856
  /**
2744
2857
  * A binding that allows a producer to send messages to a Queue.
2745
2858
  */
@@ -2750,4 +2863,10 @@ export interface Queue<Body = any> {
2750
2863
  * @returns A promise that resolves when the message is confirmed to be written to disk.
2751
2864
  */
2752
2865
  send(message: Body): Promise<void>;
2866
+ /**
2867
+ * Sends a batch of messages to the Queue.
2868
+ * @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.
2869
+ * @returns A promise that resolves when the messages are confirmed to be written to disk.
2870
+ */
2871
+ sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
2753
2872
  }