@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;
@@ -325,7 +326,7 @@ declare type ExportedHandlerTestHandler<Env = unknown> = (
325
326
  ) => void | Promise<void>;
326
327
  declare interface ExportedHandler<
327
328
  Env = unknown,
328
- QueueMessage = unknown,
329
+ QueueHandlerMessage = unknown,
329
330
  CfHostMetadata = unknown
330
331
  > {
331
332
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -333,7 +334,8 @@ declare interface ExportedHandler<
333
334
  trace?: ExportedHandlerTraceHandler<Env>;
334
335
  scheduled?: ExportedHandlerScheduledHandler<Env>;
335
336
  test?: ExportedHandlerTestHandler<Env>;
336
- queue?: ExportedHandlerQueueHandler<Env, Message>;
337
+ email?: EmailExportedHandler<Env>;
338
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
337
339
  }
338
340
  declare interface StructuredSerializeOptions {
339
341
  transfer?: any[];
@@ -396,6 +398,9 @@ declare interface DurableObjectState {
396
398
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
397
399
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
398
400
  getWebSockets(tag?: string): WebSocket[];
401
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
402
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
403
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
399
404
  }
400
405
  declare interface DurableObjectTransaction {
401
406
  get<T = unknown>(
@@ -462,6 +467,7 @@ declare interface DurableObjectStorage {
462
467
  ): Promise<void>;
463
468
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
464
469
  sync(): Promise<void>;
470
+ transactionSync<T>(closure: () => T): T;
465
471
  }
466
472
  declare interface DurableObjectListOptions {
467
473
  start?: string;
@@ -489,6 +495,11 @@ declare interface DurableObjectSetAlarmOptions {
489
495
  allowConcurrency?: boolean;
490
496
  allowUnconfirmed?: boolean;
491
497
  }
498
+ declare class WebSocketRequestResponsePair {
499
+ constructor(request: string, response: string);
500
+ get request(): string;
501
+ get response(): string;
502
+ }
492
503
  declare interface AnalyticsEngineDataset {
493
504
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
494
505
  }
@@ -1669,6 +1680,7 @@ declare interface TraceItem {
1669
1680
  readonly eventTimestamp: number | null;
1670
1681
  readonly logs: TraceLog[];
1671
1682
  readonly exceptions: TraceException[];
1683
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1672
1684
  readonly scriptName: string | null;
1673
1685
  readonly dispatchNamespace?: string;
1674
1686
  readonly scriptTags?: string[];
@@ -1715,6 +1727,11 @@ declare interface TraceException {
1715
1727
  readonly message: string;
1716
1728
  readonly name: string;
1717
1729
  }
1730
+ declare interface TraceDiagnosticChannelEvent {
1731
+ readonly timestamp: number;
1732
+ readonly channel: string;
1733
+ readonly message: any;
1734
+ }
1718
1735
  declare interface TraceMetrics {
1719
1736
  readonly cpuTime: number;
1720
1737
  readonly wallTime: number;
@@ -2863,22 +2880,27 @@ declare type CfProperties<HostMetadata = unknown> =
2863
2880
  | IncomingRequestCfProperties<HostMetadata>
2864
2881
  | RequestInitCfProperties;
2865
2882
  declare interface D1Result<T = unknown> {
2866
- results?: T[];
2867
- success: boolean;
2868
- error?: string;
2883
+ results: T[];
2884
+ success: true;
2869
2885
  meta: any;
2886
+ error?: never;
2887
+ }
2888
+ declare interface D1ExecResult {
2889
+ count: number;
2890
+ duration: number;
2870
2891
  }
2871
2892
  declare abstract class D1Database {
2872
2893
  prepare(query: string): D1PreparedStatement;
2873
2894
  dump(): Promise<ArrayBuffer>;
2874
2895
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2875
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2896
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2876
2897
  }
2877
2898
  declare abstract class D1PreparedStatement {
2878
2899
  bind(...values: any[]): D1PreparedStatement;
2879
- first<T = unknown>(colName?: string): Promise<T>;
2900
+ first<T = unknown>(colName: string): Promise<T | null>;
2901
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2880
2902
  run<T = unknown>(): Promise<D1Result<T>>;
2881
- all<T = unknown>(): Promise<D1Result<T>>;
2903
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2882
2904
  raw<T = unknown>(): Promise<T[]>;
2883
2905
  }
2884
2906
  /**
@@ -3025,12 +3047,49 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
3025
3047
  // Key Identifier of the JWK
3026
3048
  readonly kid: string;
3027
3049
  }
3050
+ declare module "cloudflare:sockets" {
3051
+ function _connect(
3052
+ address: string | SocketAddress,
3053
+ options?: SocketOptions
3054
+ ): Socket;
3055
+ export { _connect as connect };
3056
+ }
3028
3057
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3058
+ declare interface DynamicDispatchLimits {
3059
+ /**
3060
+ * Limit CPU time in milliseconds.
3061
+ */
3062
+ cpuMs?: number;
3063
+ /**
3064
+ * Limit number of subrequests.
3065
+ */
3066
+ subRequests?: number;
3067
+ }
3068
+ declare interface DynamicDispatchOptions {
3069
+ /**
3070
+ * Limit resources of invoked Worker script.
3071
+ */
3072
+ limits?: DynamicDispatchLimits;
3073
+ /**
3074
+ * Arguments for outbound Worker script, if configured.
3075
+ */
3076
+ outbound?: {
3077
+ [key: string]: any;
3078
+ };
3079
+ }
3029
3080
  declare interface DispatchNamespace {
3030
3081
  /**
3031
3082
  * @param name Name of the Worker script.
3083
+ * @param args Arguments to Worker script.
3084
+ * @param options Options for Dynamic Dispatch invocation.
3032
3085
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3033
3086
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3034
3087
  */
3035
- get(name: string): Fetcher;
3088
+ get(
3089
+ name: string,
3090
+ args?: {
3091
+ [key: string]: any;
3092
+ },
3093
+ options?: DynamicDispatchOptions
3094
+ ): Fetcher;
3036
3095
  }
@@ -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;
@@ -327,7 +328,7 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
327
328
  ) => void | Promise<void>;
328
329
  export interface ExportedHandler<
329
330
  Env = unknown,
330
- QueueMessage = unknown,
331
+ QueueHandlerMessage = unknown,
331
332
  CfHostMetadata = unknown
332
333
  > {
333
334
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -335,7 +336,8 @@ export interface ExportedHandler<
335
336
  trace?: ExportedHandlerTraceHandler<Env>;
336
337
  scheduled?: ExportedHandlerScheduledHandler<Env>;
337
338
  test?: ExportedHandlerTestHandler<Env>;
338
- queue?: ExportedHandlerQueueHandler<Env, Message>;
339
+ email?: EmailExportedHandler<Env>;
340
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
339
341
  }
340
342
  export interface StructuredSerializeOptions {
341
343
  transfer?: any[];
@@ -398,6 +400,9 @@ export interface DurableObjectState {
398
400
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
399
401
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
400
402
  getWebSockets(tag?: string): WebSocket[];
403
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
404
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
405
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
401
406
  }
402
407
  export interface DurableObjectTransaction {
403
408
  get<T = unknown>(
@@ -464,6 +469,7 @@ export interface DurableObjectStorage {
464
469
  ): Promise<void>;
465
470
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
466
471
  sync(): Promise<void>;
472
+ transactionSync<T>(closure: () => T): T;
467
473
  }
468
474
  export interface DurableObjectListOptions {
469
475
  start?: string;
@@ -491,6 +497,11 @@ export interface DurableObjectSetAlarmOptions {
491
497
  allowConcurrency?: boolean;
492
498
  allowUnconfirmed?: boolean;
493
499
  }
500
+ export declare class WebSocketRequestResponsePair {
501
+ constructor(request: string, response: string);
502
+ get request(): string;
503
+ get response(): string;
504
+ }
494
505
  export interface AnalyticsEngineDataset {
495
506
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
496
507
  }
@@ -1674,6 +1685,7 @@ export interface TraceItem {
1674
1685
  readonly eventTimestamp: number | null;
1675
1686
  readonly logs: TraceLog[];
1676
1687
  readonly exceptions: TraceException[];
1688
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1677
1689
  readonly scriptName: string | null;
1678
1690
  readonly dispatchNamespace?: string;
1679
1691
  readonly scriptTags?: string[];
@@ -1720,6 +1732,11 @@ export interface TraceException {
1720
1732
  readonly message: string;
1721
1733
  readonly name: string;
1722
1734
  }
1735
+ export interface TraceDiagnosticChannelEvent {
1736
+ readonly timestamp: number;
1737
+ readonly channel: string;
1738
+ readonly message: any;
1739
+ }
1723
1740
  export interface TraceMetrics {
1724
1741
  readonly cpuTime: number;
1725
1742
  readonly wallTime: number;
@@ -2868,22 +2885,27 @@ export type CfProperties<HostMetadata = unknown> =
2868
2885
  | IncomingRequestCfProperties<HostMetadata>
2869
2886
  | RequestInitCfProperties;
2870
2887
  export interface D1Result<T = unknown> {
2871
- results?: T[];
2872
- success: boolean;
2873
- error?: string;
2888
+ results: T[];
2889
+ success: true;
2874
2890
  meta: any;
2891
+ error?: never;
2892
+ }
2893
+ export interface D1ExecResult {
2894
+ count: number;
2895
+ duration: number;
2875
2896
  }
2876
2897
  export declare abstract class D1Database {
2877
2898
  prepare(query: string): D1PreparedStatement;
2878
2899
  dump(): Promise<ArrayBuffer>;
2879
2900
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2880
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2901
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2881
2902
  }
2882
2903
  export declare abstract class D1PreparedStatement {
2883
2904
  bind(...values: any[]): D1PreparedStatement;
2884
- first<T = unknown>(colName?: string): Promise<T>;
2905
+ first<T = unknown>(colName: string): Promise<T | null>;
2906
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2885
2907
  run<T = unknown>(): Promise<D1Result<T>>;
2886
- all<T = unknown>(): Promise<D1Result<T>>;
2908
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2887
2909
  raw<T = unknown>(): Promise<T[]>;
2888
2910
  }
2889
2911
  /**
@@ -3021,11 +3043,41 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
3021
3043
  readonly kid: string;
3022
3044
  }
3023
3045
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3046
+ export interface DynamicDispatchLimits {
3047
+ /**
3048
+ * Limit CPU time in milliseconds.
3049
+ */
3050
+ cpuMs?: number;
3051
+ /**
3052
+ * Limit number of subrequests.
3053
+ */
3054
+ subRequests?: number;
3055
+ }
3056
+ export interface DynamicDispatchOptions {
3057
+ /**
3058
+ * Limit resources of invoked Worker script.
3059
+ */
3060
+ limits?: DynamicDispatchLimits;
3061
+ /**
3062
+ * Arguments for outbound Worker script, if configured.
3063
+ */
3064
+ outbound?: {
3065
+ [key: string]: any;
3066
+ };
3067
+ }
3024
3068
  export interface DispatchNamespace {
3025
3069
  /**
3026
3070
  * @param name Name of the Worker script.
3071
+ * @param args Arguments to Worker script.
3072
+ * @param options Options for Dynamic Dispatch invocation.
3027
3073
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3028
3074
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3029
3075
  */
3030
- get(name: string): Fetcher;
3076
+ get(
3077
+ name: string,
3078
+ args?: {
3079
+ [key: string]: any;
3080
+ },
3081
+ options?: DynamicDispatchOptions
3082
+ ): Fetcher;
3031
3083
  }
@@ -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;
@@ -325,7 +326,7 @@ declare type ExportedHandlerTestHandler<Env = unknown> = (
325
326
  ) => void | Promise<void>;
326
327
  declare interface ExportedHandler<
327
328
  Env = unknown,
328
- QueueMessage = unknown,
329
+ QueueHandlerMessage = unknown,
329
330
  CfHostMetadata = unknown
330
331
  > {
331
332
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -333,7 +334,8 @@ declare interface ExportedHandler<
333
334
  trace?: ExportedHandlerTraceHandler<Env>;
334
335
  scheduled?: ExportedHandlerScheduledHandler<Env>;
335
336
  test?: ExportedHandlerTestHandler<Env>;
336
- queue?: ExportedHandlerQueueHandler<Env, Message>;
337
+ email?: EmailExportedHandler<Env>;
338
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
337
339
  }
338
340
  declare interface StructuredSerializeOptions {
339
341
  transfer?: any[];
@@ -396,6 +398,9 @@ declare interface DurableObjectState {
396
398
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
397
399
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
398
400
  getWebSockets(tag?: string): WebSocket[];
401
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
402
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
403
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
399
404
  }
400
405
  declare interface DurableObjectTransaction {
401
406
  get<T = unknown>(
@@ -462,6 +467,7 @@ declare interface DurableObjectStorage {
462
467
  ): Promise<void>;
463
468
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
464
469
  sync(): Promise<void>;
470
+ transactionSync<T>(closure: () => T): T;
465
471
  }
466
472
  declare interface DurableObjectListOptions {
467
473
  start?: string;
@@ -489,6 +495,11 @@ declare interface DurableObjectSetAlarmOptions {
489
495
  allowConcurrency?: boolean;
490
496
  allowUnconfirmed?: boolean;
491
497
  }
498
+ declare class WebSocketRequestResponsePair {
499
+ constructor(request: string, response: string);
500
+ get request(): string;
501
+ get response(): string;
502
+ }
492
503
  declare interface AnalyticsEngineDataset {
493
504
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
494
505
  }
@@ -1649,6 +1660,7 @@ declare interface TraceItem {
1649
1660
  readonly eventTimestamp: number | null;
1650
1661
  readonly logs: TraceLog[];
1651
1662
  readonly exceptions: TraceException[];
1663
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1652
1664
  readonly scriptName: string | null;
1653
1665
  readonly dispatchNamespace?: string;
1654
1666
  readonly scriptTags?: string[];
@@ -1695,6 +1707,11 @@ declare interface TraceException {
1695
1707
  readonly message: string;
1696
1708
  readonly name: string;
1697
1709
  }
1710
+ declare interface TraceDiagnosticChannelEvent {
1711
+ readonly timestamp: number;
1712
+ readonly channel: string;
1713
+ readonly message: any;
1714
+ }
1698
1715
  declare interface TraceMetrics {
1699
1716
  readonly cpuTime: number;
1700
1717
  readonly wallTime: number;
@@ -2849,22 +2866,27 @@ declare type CfProperties<HostMetadata = unknown> =
2849
2866
  | IncomingRequestCfProperties<HostMetadata>
2850
2867
  | RequestInitCfProperties;
2851
2868
  declare interface D1Result<T = unknown> {
2852
- results?: T[];
2853
- success: boolean;
2854
- error?: string;
2869
+ results: T[];
2870
+ success: true;
2855
2871
  meta: any;
2872
+ error?: never;
2873
+ }
2874
+ declare interface D1ExecResult {
2875
+ count: number;
2876
+ duration: number;
2856
2877
  }
2857
2878
  declare abstract class D1Database {
2858
2879
  prepare(query: string): D1PreparedStatement;
2859
2880
  dump(): Promise<ArrayBuffer>;
2860
2881
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2861
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2882
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2862
2883
  }
2863
2884
  declare abstract class D1PreparedStatement {
2864
2885
  bind(...values: any[]): D1PreparedStatement;
2865
- first<T = unknown>(colName?: string): Promise<T>;
2886
+ first<T = unknown>(colName: string): Promise<T | null>;
2887
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2866
2888
  run<T = unknown>(): Promise<D1Result<T>>;
2867
- all<T = unknown>(): Promise<D1Result<T>>;
2889
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2868
2890
  raw<T = unknown>(): Promise<T[]>;
2869
2891
  }
2870
2892
  /**
@@ -3011,12 +3033,49 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
3011
3033
  // Key Identifier of the JWK
3012
3034
  readonly kid: string;
3013
3035
  }
3036
+ declare module "cloudflare:sockets" {
3037
+ function _connect(
3038
+ address: string | SocketAddress,
3039
+ options?: SocketOptions
3040
+ ): Socket;
3041
+ export { _connect as connect };
3042
+ }
3014
3043
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3044
+ declare interface DynamicDispatchLimits {
3045
+ /**
3046
+ * Limit CPU time in milliseconds.
3047
+ */
3048
+ cpuMs?: number;
3049
+ /**
3050
+ * Limit number of subrequests.
3051
+ */
3052
+ subRequests?: number;
3053
+ }
3054
+ declare interface DynamicDispatchOptions {
3055
+ /**
3056
+ * Limit resources of invoked Worker script.
3057
+ */
3058
+ limits?: DynamicDispatchLimits;
3059
+ /**
3060
+ * Arguments for outbound Worker script, if configured.
3061
+ */
3062
+ outbound?: {
3063
+ [key: string]: any;
3064
+ };
3065
+ }
3015
3066
  declare interface DispatchNamespace {
3016
3067
  /**
3017
3068
  * @param name Name of the Worker script.
3069
+ * @param args Arguments to Worker script.
3070
+ * @param options Options for Dynamic Dispatch invocation.
3018
3071
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3019
3072
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3020
3073
  */
3021
- get(name: string): Fetcher;
3074
+ get(
3075
+ name: string,
3076
+ args?: {
3077
+ [key: string]: any;
3078
+ },
3079
+ options?: DynamicDispatchOptions
3080
+ ): Fetcher;
3022
3081
  }
@@ -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;
@@ -327,7 +328,7 @@ export type ExportedHandlerTestHandler<Env = unknown> = (
327
328
  ) => void | Promise<void>;
328
329
  export interface ExportedHandler<
329
330
  Env = unknown,
330
- QueueMessage = unknown,
331
+ QueueHandlerMessage = unknown,
331
332
  CfHostMetadata = unknown
332
333
  > {
333
334
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -335,7 +336,8 @@ export interface ExportedHandler<
335
336
  trace?: ExportedHandlerTraceHandler<Env>;
336
337
  scheduled?: ExportedHandlerScheduledHandler<Env>;
337
338
  test?: ExportedHandlerTestHandler<Env>;
338
- queue?: ExportedHandlerQueueHandler<Env, Message>;
339
+ email?: EmailExportedHandler<Env>;
340
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
339
341
  }
340
342
  export interface StructuredSerializeOptions {
341
343
  transfer?: any[];
@@ -398,6 +400,9 @@ export interface DurableObjectState {
398
400
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
399
401
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
400
402
  getWebSockets(tag?: string): WebSocket[];
403
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
404
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
405
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
401
406
  }
402
407
  export interface DurableObjectTransaction {
403
408
  get<T = unknown>(
@@ -464,6 +469,7 @@ export interface DurableObjectStorage {
464
469
  ): Promise<void>;
465
470
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
466
471
  sync(): Promise<void>;
472
+ transactionSync<T>(closure: () => T): T;
467
473
  }
468
474
  export interface DurableObjectListOptions {
469
475
  start?: string;
@@ -491,6 +497,11 @@ export interface DurableObjectSetAlarmOptions {
491
497
  allowConcurrency?: boolean;
492
498
  allowUnconfirmed?: boolean;
493
499
  }
500
+ export declare class WebSocketRequestResponsePair {
501
+ constructor(request: string, response: string);
502
+ get request(): string;
503
+ get response(): string;
504
+ }
494
505
  export interface AnalyticsEngineDataset {
495
506
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
496
507
  }
@@ -1654,6 +1665,7 @@ export interface TraceItem {
1654
1665
  readonly eventTimestamp: number | null;
1655
1666
  readonly logs: TraceLog[];
1656
1667
  readonly exceptions: TraceException[];
1668
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1657
1669
  readonly scriptName: string | null;
1658
1670
  readonly dispatchNamespace?: string;
1659
1671
  readonly scriptTags?: string[];
@@ -1700,6 +1712,11 @@ export interface TraceException {
1700
1712
  readonly message: string;
1701
1713
  readonly name: string;
1702
1714
  }
1715
+ export interface TraceDiagnosticChannelEvent {
1716
+ readonly timestamp: number;
1717
+ readonly channel: string;
1718
+ readonly message: any;
1719
+ }
1703
1720
  export interface TraceMetrics {
1704
1721
  readonly cpuTime: number;
1705
1722
  readonly wallTime: number;
@@ -2854,22 +2871,27 @@ export type CfProperties<HostMetadata = unknown> =
2854
2871
  | IncomingRequestCfProperties<HostMetadata>
2855
2872
  | RequestInitCfProperties;
2856
2873
  export interface D1Result<T = unknown> {
2857
- results?: T[];
2858
- success: boolean;
2859
- error?: string;
2874
+ results: T[];
2875
+ success: true;
2860
2876
  meta: any;
2877
+ error?: never;
2878
+ }
2879
+ export interface D1ExecResult {
2880
+ count: number;
2881
+ duration: number;
2861
2882
  }
2862
2883
  export declare abstract class D1Database {
2863
2884
  prepare(query: string): D1PreparedStatement;
2864
2885
  dump(): Promise<ArrayBuffer>;
2865
2886
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2866
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
2887
+ exec<T = unknown>(query: string): Promise<D1ExecResult>;
2867
2888
  }
2868
2889
  export declare abstract class D1PreparedStatement {
2869
2890
  bind(...values: any[]): D1PreparedStatement;
2870
- first<T = unknown>(colName?: string): Promise<T>;
2891
+ first<T = unknown>(colName: string): Promise<T | null>;
2892
+ first<T = unknown>(): Promise<Record<string, T> | null>;
2871
2893
  run<T = unknown>(): Promise<D1Result<T>>;
2872
- all<T = unknown>(): Promise<D1Result<T>>;
2894
+ all<T = unknown>(): Promise<D1Result<T[]>>;
2873
2895
  raw<T = unknown>(): Promise<T[]>;
2874
2896
  }
2875
2897
  /**
@@ -3007,11 +3029,41 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
3007
3029
  readonly kid: string;
3008
3030
  }
3009
3031
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3032
+ export interface DynamicDispatchLimits {
3033
+ /**
3034
+ * Limit CPU time in milliseconds.
3035
+ */
3036
+ cpuMs?: number;
3037
+ /**
3038
+ * Limit number of subrequests.
3039
+ */
3040
+ subRequests?: number;
3041
+ }
3042
+ export interface DynamicDispatchOptions {
3043
+ /**
3044
+ * Limit resources of invoked Worker script.
3045
+ */
3046
+ limits?: DynamicDispatchLimits;
3047
+ /**
3048
+ * Arguments for outbound Worker script, if configured.
3049
+ */
3050
+ outbound?: {
3051
+ [key: string]: any;
3052
+ };
3053
+ }
3010
3054
  export interface DispatchNamespace {
3011
3055
  /**
3012
3056
  * @param name Name of the Worker script.
3057
+ * @param args Arguments to Worker script.
3058
+ * @param options Options for Dynamic Dispatch invocation.
3013
3059
  * @returns A Fetcher object that allows you to send requests to the Worker script.
3014
3060
  * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
3015
3061
  */
3016
- get(name: string): Fetcher;
3062
+ get(
3063
+ name: string,
3064
+ args?: {
3065
+ [key: string]: any;
3066
+ },
3067
+ options?: DynamicDispatchOptions
3068
+ ): Fetcher;
3017
3069
  }