@cloudflare/workers-types 4.20230511.0 → 4.20230628.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.
@@ -213,6 +213,7 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
213
213
  Response: typeof Response;
214
214
  WebSocket: typeof WebSocket;
215
215
  WebSocketPair: typeof WebSocketPair;
216
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
216
217
  AbortController: typeof AbortController;
217
218
  AbortSignal: typeof AbortSignal;
218
219
  TextDecoder: typeof TextDecoder;
@@ -328,7 +329,7 @@ declare type ExportedHandlerTestHandler<Env = unknown> = (
328
329
  ) => void | Promise<void>;
329
330
  declare interface ExportedHandler<
330
331
  Env = unknown,
331
- QueueMessage = unknown,
332
+ QueueHandlerMessage = unknown,
332
333
  CfHostMetadata = unknown
333
334
  > {
334
335
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -336,7 +337,8 @@ declare interface ExportedHandler<
336
337
  trace?: ExportedHandlerTraceHandler<Env>;
337
338
  scheduled?: ExportedHandlerScheduledHandler<Env>;
338
339
  test?: ExportedHandlerTestHandler<Env>;
339
- queue?: ExportedHandlerQueueHandler<Env, Message>;
340
+ email?: EmailExportedHandler<Env>;
341
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
340
342
  }
341
343
  declare interface StructuredSerializeOptions {
342
344
  transfer?: any[];
@@ -402,6 +404,9 @@ declare interface DurableObjectState {
402
404
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
403
405
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
404
406
  getWebSockets(tag?: string): WebSocket[];
407
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
408
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
409
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
405
410
  }
406
411
  declare interface DurableObjectTransaction {
407
412
  get<T = unknown>(
@@ -468,6 +473,7 @@ declare interface DurableObjectStorage {
468
473
  ): Promise<void>;
469
474
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
470
475
  sync(): Promise<void>;
476
+ transactionSync<T>(closure: () => T): T;
471
477
  }
472
478
  declare interface DurableObjectListOptions {
473
479
  start?: string;
@@ -495,6 +501,11 @@ declare interface DurableObjectSetAlarmOptions {
495
501
  allowConcurrency?: boolean;
496
502
  allowUnconfirmed?: boolean;
497
503
  }
504
+ declare class WebSocketRequestResponsePair {
505
+ constructor(request: string, response: string);
506
+ get request(): string;
507
+ get response(): string;
508
+ }
498
509
  declare interface AnalyticsEngineDataset {
499
510
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
500
511
  }
@@ -1655,6 +1666,7 @@ declare interface TraceItem {
1655
1666
  readonly eventTimestamp: number | null;
1656
1667
  readonly logs: TraceLog[];
1657
1668
  readonly exceptions: TraceException[];
1669
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1658
1670
  readonly scriptName: string | null;
1659
1671
  readonly dispatchNamespace?: string;
1660
1672
  readonly scriptTags?: string[];
@@ -1701,6 +1713,11 @@ declare interface TraceException {
1701
1713
  readonly message: string;
1702
1714
  readonly name: string;
1703
1715
  }
1716
+ declare interface TraceDiagnosticChannelEvent {
1717
+ readonly timestamp: number;
1718
+ readonly channel: string;
1719
+ readonly message: any;
1720
+ }
1704
1721
  declare interface TraceMetrics {
1705
1722
  readonly cpuTime: number;
1706
1723
  readonly wallTime: number;
@@ -2855,22 +2872,27 @@ declare type CfProperties<HostMetadata = unknown> =
2855
2872
  | IncomingRequestCfProperties<HostMetadata>
2856
2873
  | RequestInitCfProperties;
2857
2874
  declare interface D1Result<T = unknown> {
2858
- results?: T[];
2859
- success: boolean;
2860
- error?: string;
2875
+ results: T[];
2876
+ success: true;
2861
2877
  meta: any;
2878
+ error?: never;
2879
+ }
2880
+ declare interface D1ExecResult {
2881
+ count: number;
2882
+ duration: number;
2862
2883
  }
2863
2884
  declare abstract class D1Database {
2864
2885
  prepare(query: string): D1PreparedStatement;
2865
2886
  dump(): Promise<ArrayBuffer>;
2866
2887
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2867
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2888
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2868
2889
  }
2869
2890
  declare abstract class D1PreparedStatement {
2870
2891
  bind(...values: any[]): D1PreparedStatement;
2871
- first<T = unknown>(colName?: string): Promise<T>;
2892
+ first<T = unknown>(colName: string): Promise<T | null>;
2893
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2872
2894
  run<T = unknown>(): Promise<D1Result<T>>;
2873
- all<T = unknown>(): Promise<D1Result<T>>;
2895
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2874
2896
  raw<T = unknown>(): Promise<T[]>;
2875
2897
  }
2876
2898
  /**
@@ -3017,12 +3039,49 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
3017
3039
  // Key Identifier of the JWK
3018
3040
  readonly kid: string;
3019
3041
  }
3042
+ declare module "cloudflare:sockets" {
3043
+ function _connect(
3044
+ address: string | SocketAddress,
3045
+ options?: SocketOptions
3046
+ ): Socket;
3047
+ export { _connect as connect };
3048
+ }
3020
3049
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3050
+ declare interface DynamicDispatchLimits {
3051
+ /**
3052
+ * Limit CPU time in milliseconds.
3053
+ */
3054
+ cpuMs?: number;
3055
+ /**
3056
+ * Limit number of subrequests.
3057
+ */
3058
+ subRequests?: number;
3059
+ }
3060
+ declare interface DynamicDispatchOptions {
3061
+ /**
3062
+ * Limit resources of invoked Worker script.
3063
+ */
3064
+ limits?: DynamicDispatchLimits;
3065
+ /**
3066
+ * Arguments for outbound Worker script, if configured.
3067
+ */
3068
+ outbound?: {
3069
+ [key: string]: any;
3070
+ };
3071
+ }
3021
3072
  declare interface DispatchNamespace {
3022
3073
  /**
3023
3074
  * @param name Name of the Worker script.
3075
+ * @param args Arguments to Worker script.
3076
+ * @param options Options for Dynamic Dispatch invocation.
3024
3077
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3025
3078
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3026
3079
  */
3027
- get(name: string): Fetcher;
3080
+ get(
3081
+ name: string,
3082
+ args?: {
3083
+ [key: string]: any;
3084
+ },
3085
+ options?: DynamicDispatchOptions
3086
+ ): Fetcher;
3028
3087
  }
@@ -213,6 +213,7 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
213
213
  Response: typeof Response;
214
214
  WebSocket: typeof WebSocket;
215
215
  WebSocketPair: typeof WebSocketPair;
216
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
216
217
  AbortController: typeof AbortController;
217
218
  AbortSignal: typeof AbortSignal;
218
219
  TextDecoder: typeof TextDecoder;
@@ -330,7 +331,7 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
330
331
  ) => void | Promise<void>;
331
332
  export interface ExportedHandler<
332
333
  Env = unknown,
333
- QueueMessage = unknown,
334
+ QueueHandlerMessage = unknown,
334
335
  CfHostMetadata = unknown
335
336
  > {
336
337
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -338,7 +339,8 @@ export interface ExportedHandler<
338
339
  trace?: ExportedHandlerTraceHandler<Env>;
339
340
  scheduled?: ExportedHandlerScheduledHandler<Env>;
340
341
  test?: ExportedHandlerTestHandler<Env>;
341
- queue?: ExportedHandlerQueueHandler<Env, Message>;
342
+ email?: EmailExportedHandler<Env>;
343
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
342
344
  }
343
345
  export interface StructuredSerializeOptions {
344
346
  transfer?: any[];
@@ -404,6 +406,9 @@ export interface DurableObjectState {
404
406
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
405
407
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
406
408
  getWebSockets(tag?: string): WebSocket[];
409
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
410
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
411
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
407
412
  }
408
413
  export interface DurableObjectTransaction {
409
414
  get<T = unknown>(
@@ -470,6 +475,7 @@ export interface DurableObjectStorage {
470
475
  ): Promise<void>;
471
476
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
472
477
  sync(): Promise<void>;
478
+ transactionSync<T>(closure: () => T): T;
473
479
  }
474
480
  export interface DurableObjectListOptions {
475
481
  start?: string;
@@ -497,6 +503,11 @@ export interface DurableObjectSetAlarmOptions {
497
503
  allowConcurrency?: boolean;
498
504
  allowUnconfirmed?: boolean;
499
505
  }
506
+ export declare class WebSocketRequestResponsePair {
507
+ constructor(request: string, response: string);
508
+ get request(): string;
509
+ get response(): string;
510
+ }
500
511
  export interface AnalyticsEngineDataset {
501
512
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
502
513
  }
@@ -1660,6 +1671,7 @@ export interface TraceItem {
1660
1671
  readonly eventTimestamp: number | null;
1661
1672
  readonly logs: TraceLog[];
1662
1673
  readonly exceptions: TraceException[];
1674
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1663
1675
  readonly scriptName: string | null;
1664
1676
  readonly dispatchNamespace?: string;
1665
1677
  readonly scriptTags?: string[];
@@ -1706,6 +1718,11 @@ export interface TraceException {
1706
1718
  readonly message: string;
1707
1719
  readonly name: string;
1708
1720
  }
1721
+ export interface TraceDiagnosticChannelEvent {
1722
+ readonly timestamp: number;
1723
+ readonly channel: string;
1724
+ readonly message: any;
1725
+ }
1709
1726
  export interface TraceMetrics {
1710
1727
  readonly cpuTime: number;
1711
1728
  readonly wallTime: number;
@@ -2860,22 +2877,27 @@ export type CfProperties<HostMetadata = unknown> =
2860
2877
  | IncomingRequestCfProperties<HostMetadata>
2861
2878
  | RequestInitCfProperties;
2862
2879
  export interface D1Result<T = unknown> {
2863
- results?: T[];
2864
- success: boolean;
2865
- error?: string;
2880
+ results: T[];
2881
+ success: true;
2866
2882
  meta: any;
2883
+ error?: never;
2884
+ }
2885
+ export interface D1ExecResult {
2886
+ count: number;
2887
+ duration: number;
2867
2888
  }
2868
2889
  export declare abstract class D1Database {
2869
2890
  prepare(query: string): D1PreparedStatement;
2870
2891
  dump(): Promise<ArrayBuffer>;
2871
2892
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2872
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2893
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2873
2894
  }
2874
2895
  export declare abstract class D1PreparedStatement {
2875
2896
  bind(...values: any[]): D1PreparedStatement;
2876
- first<T = unknown>(colName?: string): Promise<T>;
2897
+ first<T = unknown>(colName: string): Promise<T | null>;
2898
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2877
2899
  run<T = unknown>(): Promise<D1Result<T>>;
2878
- all<T = unknown>(): Promise<D1Result<T>>;
2900
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2879
2901
  raw<T = unknown>(): Promise<T[]>;
2880
2902
  }
2881
2903
  /**
@@ -3013,11 +3035,41 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
3013
3035
  readonly kid: string;
3014
3036
  }
3015
3037
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3038
+ export interface DynamicDispatchLimits {
3039
+ /**
3040
+ * Limit CPU time in milliseconds.
3041
+ */
3042
+ cpuMs?: number;
3043
+ /**
3044
+ * Limit number of subrequests.
3045
+ */
3046
+ subRequests?: number;
3047
+ }
3048
+ export interface DynamicDispatchOptions {
3049
+ /**
3050
+ * Limit resources of invoked Worker script.
3051
+ */
3052
+ limits?: DynamicDispatchLimits;
3053
+ /**
3054
+ * Arguments for outbound Worker script, if configured.
3055
+ */
3056
+ outbound?: {
3057
+ [key: string]: any;
3058
+ };
3059
+ }
3016
3060
  export interface DispatchNamespace {
3017
3061
  /**
3018
3062
  * @param name Name of the Worker script.
3063
+ * @param args Arguments to Worker script.
3064
+ * @param options Options for Dynamic Dispatch invocation.
3019
3065
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3020
3066
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3021
3067
  */
3022
- get(name: string): Fetcher;
3068
+ get(
3069
+ name: string,
3070
+ args?: {
3071
+ [key: string]: any;
3072
+ },
3073
+ options?: DynamicDispatchOptions
3074
+ ): Fetcher;
3023
3075
  }
@@ -213,6 +213,7 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
213
213
  Response: typeof Response;
214
214
  WebSocket: typeof WebSocket;
215
215
  WebSocketPair: typeof WebSocketPair;
216
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
216
217
  AbortController: typeof AbortController;
217
218
  AbortSignal: typeof AbortSignal;
218
219
  TextDecoder: typeof TextDecoder;
@@ -328,7 +329,7 @@ declare type ExportedHandlerTestHandler<Env = unknown> = (
328
329
  ) => void | Promise<void>;
329
330
  declare interface ExportedHandler<
330
331
  Env = unknown,
331
- QueueMessage = unknown,
332
+ QueueHandlerMessage = unknown,
332
333
  CfHostMetadata = unknown
333
334
  > {
334
335
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -336,7 +337,8 @@ declare interface ExportedHandler<
336
337
  trace?: ExportedHandlerTraceHandler<Env>;
337
338
  scheduled?: ExportedHandlerScheduledHandler<Env>;
338
339
  test?: ExportedHandlerTestHandler<Env>;
339
- queue?: ExportedHandlerQueueHandler<Env, Message>;
340
+ email?: EmailExportedHandler<Env>;
341
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
340
342
  }
341
343
  declare interface StructuredSerializeOptions {
342
344
  transfer?: any[];
@@ -402,6 +404,9 @@ declare interface DurableObjectState {
402
404
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
403
405
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
404
406
  getWebSockets(tag?: string): WebSocket[];
407
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
408
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
409
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
405
410
  }
406
411
  declare interface DurableObjectTransaction {
407
412
  get<T = unknown>(
@@ -468,6 +473,7 @@ declare interface DurableObjectStorage {
468
473
  ): Promise<void>;
469
474
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
470
475
  sync(): Promise<void>;
476
+ transactionSync<T>(closure: () => T): T;
471
477
  }
472
478
  declare interface DurableObjectListOptions {
473
479
  start?: string;
@@ -495,6 +501,11 @@ declare interface DurableObjectSetAlarmOptions {
495
501
  allowConcurrency?: boolean;
496
502
  allowUnconfirmed?: boolean;
497
503
  }
504
+ declare class WebSocketRequestResponsePair {
505
+ constructor(request: string, response: string);
506
+ get request(): string;
507
+ get response(): string;
508
+ }
498
509
  declare interface AnalyticsEngineDataset {
499
510
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
500
511
  }
@@ -1656,6 +1667,7 @@ declare interface TraceItem {
1656
1667
  readonly eventTimestamp: number | null;
1657
1668
  readonly logs: TraceLog[];
1658
1669
  readonly exceptions: TraceException[];
1670
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1659
1671
  readonly scriptName: string | null;
1660
1672
  readonly dispatchNamespace?: string;
1661
1673
  readonly scriptTags?: string[];
@@ -1702,6 +1714,11 @@ declare interface TraceException {
1702
1714
  readonly message: string;
1703
1715
  readonly name: string;
1704
1716
  }
1717
+ declare interface TraceDiagnosticChannelEvent {
1718
+ readonly timestamp: number;
1719
+ readonly channel: string;
1720
+ readonly message: any;
1721
+ }
1705
1722
  declare interface TraceMetrics {
1706
1723
  readonly cpuTime: number;
1707
1724
  readonly wallTime: number;
@@ -2856,22 +2873,27 @@ declare type CfProperties<HostMetadata = unknown> =
2856
2873
  | IncomingRequestCfProperties<HostMetadata>
2857
2874
  | RequestInitCfProperties;
2858
2875
  declare interface D1Result<T = unknown> {
2859
- results?: T[];
2860
- success: boolean;
2861
- error?: string;
2876
+ results: T[];
2877
+ success: true;
2862
2878
  meta: any;
2879
+ error?: never;
2880
+ }
2881
+ declare interface D1ExecResult {
2882
+ count: number;
2883
+ duration: number;
2863
2884
  }
2864
2885
  declare abstract class D1Database {
2865
2886
  prepare(query: string): D1PreparedStatement;
2866
2887
  dump(): Promise<ArrayBuffer>;
2867
2888
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2868
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2889
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2869
2890
  }
2870
2891
  declare abstract class D1PreparedStatement {
2871
2892
  bind(...values: any[]): D1PreparedStatement;
2872
- first<T = unknown>(colName?: string): Promise<T>;
2893
+ first<T = unknown>(colName: string): Promise<T | null>;
2894
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2873
2895
  run<T = unknown>(): Promise<D1Result<T>>;
2874
- all<T = unknown>(): Promise<D1Result<T>>;
2896
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2875
2897
  raw<T = unknown>(): Promise<T[]>;
2876
2898
  }
2877
2899
  /**
@@ -3018,12 +3040,49 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
3018
3040
  // Key Identifier of the JWK
3019
3041
  readonly kid: string;
3020
3042
  }
3043
+ declare module "cloudflare:sockets" {
3044
+ function _connect(
3045
+ address: string | SocketAddress,
3046
+ options?: SocketOptions
3047
+ ): Socket;
3048
+ export { _connect as connect };
3049
+ }
3021
3050
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3051
+ declare interface DynamicDispatchLimits {
3052
+ /**
3053
+ * Limit CPU time in milliseconds.
3054
+ */
3055
+ cpuMs?: number;
3056
+ /**
3057
+ * Limit number of subrequests.
3058
+ */
3059
+ subRequests?: number;
3060
+ }
3061
+ declare interface DynamicDispatchOptions {
3062
+ /**
3063
+ * Limit resources of invoked Worker script.
3064
+ */
3065
+ limits?: DynamicDispatchLimits;
3066
+ /**
3067
+ * Arguments for outbound Worker script, if configured.
3068
+ */
3069
+ outbound?: {
3070
+ [key: string]: any;
3071
+ };
3072
+ }
3022
3073
  declare interface DispatchNamespace {
3023
3074
  /**
3024
3075
  * @param name Name of the Worker script.
3076
+ * @param args Arguments to Worker script.
3077
+ * @param options Options for Dynamic Dispatch invocation.
3025
3078
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3026
3079
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3027
3080
  */
3028
- get(name: string): Fetcher;
3081
+ get(
3082
+ name: string,
3083
+ args?: {
3084
+ [key: string]: any;
3085
+ },
3086
+ options?: DynamicDispatchOptions
3087
+ ): Fetcher;
3029
3088
  }
@@ -213,6 +213,7 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
213
213
  Response: typeof Response;
214
214
  WebSocket: typeof WebSocket;
215
215
  WebSocketPair: typeof WebSocketPair;
216
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
216
217
  AbortController: typeof AbortController;
217
218
  AbortSignal: typeof AbortSignal;
218
219
  TextDecoder: typeof TextDecoder;
@@ -330,7 +331,7 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
330
331
  ) => void | Promise<void>;
331
332
  export interface ExportedHandler<
332
333
  Env = unknown,
333
- QueueMessage = unknown,
334
+ QueueHandlerMessage = unknown,
334
335
  CfHostMetadata = unknown
335
336
  > {
336
337
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -338,7 +339,8 @@ export interface ExportedHandler<
338
339
  trace?: ExportedHandlerTraceHandler<Env>;
339
340
  scheduled?: ExportedHandlerScheduledHandler<Env>;
340
341
  test?: ExportedHandlerTestHandler<Env>;
341
- queue?: ExportedHandlerQueueHandler<Env, Message>;
342
+ email?: EmailExportedHandler<Env>;
343
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
342
344
  }
343
345
  export interface StructuredSerializeOptions {
344
346
  transfer?: any[];
@@ -404,6 +406,9 @@ export interface DurableObjectState {
404
406
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
405
407
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
406
408
  getWebSockets(tag?: string): WebSocket[];
409
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
410
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
411
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
407
412
  }
408
413
  export interface DurableObjectTransaction {
409
414
  get<T = unknown>(
@@ -470,6 +475,7 @@ export interface DurableObjectStorage {
470
475
  ): Promise<void>;
471
476
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
472
477
  sync(): Promise<void>;
478
+ transactionSync<T>(closure: () => T): T;
473
479
  }
474
480
  export interface DurableObjectListOptions {
475
481
  start?: string;
@@ -497,6 +503,11 @@ export interface DurableObjectSetAlarmOptions {
497
503
  allowConcurrency?: boolean;
498
504
  allowUnconfirmed?: boolean;
499
505
  }
506
+ export declare class WebSocketRequestResponsePair {
507
+ constructor(request: string, response: string);
508
+ get request(): string;
509
+ get response(): string;
510
+ }
500
511
  export interface AnalyticsEngineDataset {
501
512
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
502
513
  }
@@ -1661,6 +1672,7 @@ export interface TraceItem {
1661
1672
  readonly eventTimestamp: number | null;
1662
1673
  readonly logs: TraceLog[];
1663
1674
  readonly exceptions: TraceException[];
1675
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1664
1676
  readonly scriptName: string | null;
1665
1677
  readonly dispatchNamespace?: string;
1666
1678
  readonly scriptTags?: string[];
@@ -1707,6 +1719,11 @@ export interface TraceException {
1707
1719
  readonly message: string;
1708
1720
  readonly name: string;
1709
1721
  }
1722
+ export interface TraceDiagnosticChannelEvent {
1723
+ readonly timestamp: number;
1724
+ readonly channel: string;
1725
+ readonly message: any;
1726
+ }
1710
1727
  export interface TraceMetrics {
1711
1728
  readonly cpuTime: number;
1712
1729
  readonly wallTime: number;
@@ -2861,22 +2878,27 @@ export type CfProperties<HostMetadata = unknown> =
2861
2878
  | IncomingRequestCfProperties<HostMetadata>
2862
2879
  | RequestInitCfProperties;
2863
2880
  export interface D1Result<T = unknown> {
2864
- results?: T[];
2865
- success: boolean;
2866
- error?: string;
2881
+ results: T[];
2882
+ success: true;
2867
2883
  meta: any;
2884
+ error?: never;
2885
+ }
2886
+ export interface D1ExecResult {
2887
+ count: number;
2888
+ duration: number;
2868
2889
  }
2869
2890
  export declare abstract class D1Database {
2870
2891
  prepare(query: string): D1PreparedStatement;
2871
2892
  dump(): Promise<ArrayBuffer>;
2872
2893
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2873
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2894
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2874
2895
  }
2875
2896
  export declare abstract class D1PreparedStatement {
2876
2897
  bind(...values: any[]): D1PreparedStatement;
2877
- first<T = unknown>(colName?: string): Promise<T>;
2898
+ first<T = unknown>(colName: string): Promise<T | null>;
2899
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2878
2900
  run<T = unknown>(): Promise<D1Result<T>>;
2879
- all<T = unknown>(): Promise<D1Result<T>>;
2901
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2880
2902
  raw<T = unknown>(): Promise<T[]>;
2881
2903
  }
2882
2904
  /**
@@ -3014,11 +3036,41 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
3014
3036
  readonly kid: string;
3015
3037
  }
3016
3038
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3039
+ export interface DynamicDispatchLimits {
3040
+ /**
3041
+ * Limit CPU time in milliseconds.
3042
+ */
3043
+ cpuMs?: number;
3044
+ /**
3045
+ * Limit number of subrequests.
3046
+ */
3047
+ subRequests?: number;
3048
+ }
3049
+ export interface DynamicDispatchOptions {
3050
+ /**
3051
+ * Limit resources of invoked Worker script.
3052
+ */
3053
+ limits?: DynamicDispatchLimits;
3054
+ /**
3055
+ * Arguments for outbound Worker script, if configured.
3056
+ */
3057
+ outbound?: {
3058
+ [key: string]: any;
3059
+ };
3060
+ }
3017
3061
  export interface DispatchNamespace {
3018
3062
  /**
3019
3063
  * @param name Name of the Worker script.
3064
+ * @param args Arguments to Worker script.
3065
+ * @param options Options for Dynamic Dispatch invocation.
3020
3066
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3021
3067
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3022
3068
  */
3023
- get(name: string): Fetcher;
3069
+ get(
3070
+ name: string,
3071
+ args?: {
3072
+ [key: string]: any;
3073
+ },
3074
+ options?: DynamicDispatchOptions
3075
+ ): Fetcher;
3024
3076
  }