@cloudflare/workers-types 3.6.0 → 3.8.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.
Files changed (2) hide show
  1. package/index.d.ts +80 -29
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -131,7 +131,7 @@ declare type BodyInitializer = BodyInit;
131
131
  declare class ByteLengthQueuingStrategy {
132
132
  constructor(init: QueuingStrategyInit);
133
133
  readonly highWaterMark: number;
134
- size(arg1?: any): number | undefined;
134
+ size(chunk?: any): number;
135
135
  }
136
136
 
137
137
  declare abstract class Cache {
@@ -194,7 +194,7 @@ interface Comment {
194
194
  }
195
195
 
196
196
  declare class CompressionStream extends TransformStream {
197
- constructor(format: string);
197
+ constructor(format: "gzip" | "deflate");
198
198
  }
199
199
 
200
200
  interface Console {
@@ -214,7 +214,7 @@ interface ContentOptions {
214
214
  declare class CountQueuingStrategy {
215
215
  constructor(init: QueuingStrategyInit);
216
216
  readonly highWaterMark: number;
217
- size(arg1?: any): number | undefined;
217
+ size(chunk?: any): number;
218
218
  }
219
219
 
220
220
  declare abstract class Crypto {
@@ -323,7 +323,7 @@ declare class DOMException extends Error {
323
323
  }
324
324
 
325
325
  declare class DecompressionStream extends TransformStream {
326
- constructor(format: string);
326
+ constructor(format: "gzip" | "deflate");
327
327
  }
328
328
 
329
329
  declare class DigestStream extends WritableStream {
@@ -345,6 +345,10 @@ interface DurableObject {
345
345
  fetch(request: Request): Promise<Response>;
346
346
  }
347
347
 
348
+ interface DurableObjectGetAlarmOptions {
349
+ allowConcurrency?: boolean;
350
+ }
351
+
348
352
  interface DurableObjectGetOptions {
349
353
  allowConcurrency?: boolean;
350
354
  noCache?: boolean;
@@ -385,6 +389,11 @@ interface DurableObjectPutOptions {
385
389
  noCache?: boolean;
386
390
  }
387
391
 
392
+ interface DurableObjectSetAlarmOptions {
393
+ allowConcurrency?: boolean;
394
+ allowUnconfirmed?: boolean;
395
+ }
396
+
388
397
  interface DurableObjectState {
389
398
  waitUntil(promise: Promise<any>): void;
390
399
  readonly id: DurableObjectId | string;
@@ -419,17 +428,12 @@ interface DurableObjectStorage {
419
428
  transaction<T>(
420
429
  closure: (txn: DurableObjectTransaction) => Promise<T>
421
430
  ): Promise<T>;
422
- getAlarm(
423
- options?: DurableObjectStorageOperationsGetAlarmOptions
424
- ): Promise<Date | null>;
431
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
425
432
  setAlarm(
426
- arg2: Date,
427
- options?: DurableObjectStorageOperationsSetAlarmOptions
433
+ scheduledTime: Date,
434
+ options?: DurableObjectSetAlarmOptions
428
435
  ): Promise<void>;
429
- }
430
-
431
- interface DurableObjectStorageOperationsGetAlarmOptions {
432
- allowConcurrency?: boolean;
436
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
433
437
  }
434
438
 
435
439
  /**
@@ -451,11 +455,6 @@ declare type DurableObjectStorageOperationsListOptions =
451
455
  */
452
456
  declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions;
453
457
 
454
- interface DurableObjectStorageOperationsSetAlarmOptions {
455
- allowConcurrency?: boolean;
456
- allowUnconfirmed?: boolean;
457
- }
458
-
459
458
  interface DurableObjectStub extends Fetcher {
460
459
  readonly id: DurableObjectId;
461
460
  readonly name?: string;
@@ -482,13 +481,12 @@ interface DurableObjectTransaction {
482
481
  delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
483
482
  delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
484
483
  rollback(): void;
485
- getAlarm(
486
- options?: DurableObjectStorageOperationsGetAlarmOptions
487
- ): Promise<Date | null>;
484
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
488
485
  setAlarm(
489
- arg2: Date,
490
- options?: DurableObjectStorageOperationsSetAlarmOptions
486
+ scheduledTime: Date,
487
+ options?: DurableObjectSetAlarmOptions
491
488
  ): Promise<void>;
489
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
492
490
  }
493
491
 
494
492
  interface Element {
@@ -1003,7 +1001,13 @@ interface R2Bucket {
1003
1001
  get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1004
1002
  put(
1005
1003
  key: string,
1006
- value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null,
1004
+ value:
1005
+ | ReadableStream
1006
+ | ArrayBuffer
1007
+ | ArrayBufferView
1008
+ | string
1009
+ | null
1010
+ | Blob,
1007
1011
  options?: R2PutOptions
1008
1012
  ): Promise<R2Object>;
1009
1013
  delete(key: string): Promise<void>;
@@ -1077,7 +1081,7 @@ interface R2ListOptions {
1077
1081
  * }
1078
1082
  * ```
1079
1083
  */
1080
- include: ("httpMetadata" | "customMetadata")[];
1084
+ include?: ("httpMetadata" | "customMetadata")[];
1081
1085
  }
1082
1086
 
1083
1087
  /**
@@ -1135,12 +1139,15 @@ declare abstract class ReadableByteStreamController {
1135
1139
  readonly byobRequest: ReadableStreamBYOBRequest | null;
1136
1140
  readonly desiredSize: number | null;
1137
1141
  close(): void;
1138
- enqueue(chunk: ArrayBufferView): void;
1142
+ enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
1139
1143
  error(reason: any): void;
1140
1144
  }
1141
1145
 
1142
1146
  declare class ReadableStream {
1143
- constructor(underlyingSource?: Object, queuingStrategy?: Object);
1147
+ constructor(
1148
+ underlyingSource?: UnderlyingSource,
1149
+ queuingStrategy?: StreamQueuingStrategy
1150
+ );
1144
1151
  readonly locked: boolean;
1145
1152
  cancel(reason?: any): Promise<void>;
1146
1153
  getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
@@ -1174,7 +1181,7 @@ declare class ReadableStreamBYOBReader {
1174
1181
  declare abstract class ReadableStreamBYOBRequest {
1175
1182
  readonly view: Uint8Array | null;
1176
1183
  respond(bytesWritten: number): void;
1177
- respondWithNewView(view: ArrayBufferView): void;
1184
+ respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
1178
1185
  readonly atLeast: number | null;
1179
1186
  }
1180
1187
 
@@ -1814,6 +1821,26 @@ declare type URLSearchParamsInit =
1814
1821
  */
1815
1822
  declare type URLSearchParamsInitializer = URLSearchParamsInit;
1816
1823
 
1824
+ interface UnderlyingSink {
1825
+ type?: string;
1826
+ start?(controller: WritableStreamDefaultController): any;
1827
+ write?(chunk: any, controller: WritableStreamDefaultController): any;
1828
+ abort?(reason: any): any;
1829
+ close?(): any;
1830
+ }
1831
+
1832
+ interface UnderlyingSource {
1833
+ type?: string;
1834
+ autoAllocateChunkSize?: number;
1835
+ start?(
1836
+ controller: ReadableStreamDefaultController | ReadableByteStreamController
1837
+ ): any;
1838
+ pull?(
1839
+ controller: ReadableStreamDefaultController | ReadableByteStreamController
1840
+ ): any;
1841
+ cancel?(reason?: any): any;
1842
+ }
1843
+
1817
1844
  declare class WebSocket extends EventTarget<WebSocketEventMap> {
1818
1845
  constructor(url: string, protocols?: string[] | string);
1819
1846
  accept(): void;
@@ -1848,7 +1875,10 @@ declare type WorkerGlobalScopeEventMap = {
1848
1875
  };
1849
1876
 
1850
1877
  declare class WritableStream {
1851
- constructor(underlyingSink?: Object, queuingStrategy?: Object);
1878
+ constructor(
1879
+ underlyingSink?: UnderlyingSink,
1880
+ queuingStrategy?: StreamQueuingStrategy
1881
+ );
1852
1882
  readonly locked: boolean;
1853
1883
  abort(reason: any): Promise<void>;
1854
1884
  close(): Promise<void>;
@@ -1947,6 +1977,7 @@ type Params<P extends string = any> = Record<P, string | string[]>;
1947
1977
 
1948
1978
  type EventContext<Env, P extends string, Data> = {
1949
1979
  request: Request;
1980
+ functionPath: string;
1950
1981
  waitUntil: (promise: Promise<any>) => void;
1951
1982
  next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
1952
1983
  env: Env & { ASSETS: { fetch: typeof fetch } };
@@ -1959,3 +1990,23 @@ declare type PagesFunction<
1959
1990
  Params extends string = any,
1960
1991
  Data extends Record<string, unknown> = Record<string, unknown>
1961
1992
  > = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
1993
+
1994
+ type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
1995
+ request: Request;
1996
+ functionPath: string;
1997
+ waitUntil: (promise: Promise<any>) => void;
1998
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
1999
+ env: Env & { ASSETS: { fetch: typeof fetch } };
2000
+ params: Params<P>;
2001
+ data: Data;
2002
+ pluginArgs: PluginArgs;
2003
+ };
2004
+
2005
+ declare type PagesPluginFunction<
2006
+ Env = unknown,
2007
+ Params extends string = any,
2008
+ Data extends Record<string, unknown> = Record<string, unknown>,
2009
+ PluginArgs = unknown
2010
+ > = (
2011
+ context: EventPluginContext<Env, Params, Data, PluginArgs>
2012
+ ) => Response | Promise<Response>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/workers-types",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "TypeScript typings for Cloudflare Workers",
5
5
  "repository": {
6
6
  "type": "git",