@cloudflare/workers-types 0.20230518.0 → 0.20231030.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.
@@ -188,6 +188,7 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
188
188
  readonly origin: string;
189
189
  Event: typeof Event;
190
190
  ExtendableEvent: typeof ExtendableEvent;
191
+ CustomEvent: typeof CustomEvent;
191
192
  PromiseRejectionEvent: typeof PromiseRejectionEvent;
192
193
  FetchEvent: typeof FetchEvent;
193
194
  TailEvent: typeof TailEvent;
@@ -213,6 +214,7 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
213
214
  Response: typeof Response;
214
215
  WebSocket: typeof WebSocket;
215
216
  WebSocketPair: typeof WebSocketPair;
217
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
216
218
  AbortController: typeof AbortController;
217
219
  AbortSignal: typeof AbortSignal;
218
220
  TextDecoder: typeof TextDecoder;
@@ -231,6 +233,16 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
231
233
  FixedLengthStream: typeof FixedLengthStream;
232
234
  IdentityTransformStream: typeof IdentityTransformStream;
233
235
  HTMLRewriter: typeof HTMLRewriter;
236
+ GPUAdapter: typeof gpuGPUAdapter;
237
+ GPUOutOfMemoryError: typeof gpuGPUOutOfMemoryError;
238
+ GPUValidationError: typeof gpuGPUValidationError;
239
+ GPUInternalError: typeof gpuGPUInternalError;
240
+ GPUDeviceLostInfo: typeof gpuGPUDeviceLostInfo;
241
+ GPUBufferUsage: typeof gpuGPUBufferUsage;
242
+ GPUShaderStage: typeof gpuGPUShaderStage;
243
+ GPUMapMode: typeof gpuGPUMapMode;
244
+ GPUTextureUsage: typeof gpuGPUTextureUsage;
245
+ GPUColorWrite: typeof gpuGPUColorWrite;
234
246
  }
235
247
  declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
236
248
  type: Type,
@@ -325,7 +337,7 @@ declare type ExportedHandlerTestHandler<Env = unknown> = (
325
337
  ) => void | Promise<void>;
326
338
  declare interface ExportedHandler<
327
339
  Env = unknown,
328
- QueueMessage = unknown,
340
+ QueueHandlerMessage = unknown,
329
341
  CfHostMetadata = unknown
330
342
  > {
331
343
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
@@ -333,7 +345,8 @@ declare interface ExportedHandler<
333
345
  trace?: ExportedHandlerTraceHandler<Env>;
334
346
  scheduled?: ExportedHandlerScheduledHandler<Env>;
335
347
  test?: ExportedHandlerTestHandler<Env>;
336
- queue?: ExportedHandlerQueueHandler<Env, Message>;
348
+ email?: EmailExportedHandler<Env>;
349
+ queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
337
350
  }
338
351
  declare interface StructuredSerializeOptions {
339
352
  transfer?: any[];
@@ -350,6 +363,17 @@ declare interface Performance {
350
363
  declare interface DurableObject {
351
364
  fetch(request: Request): Response | Promise<Response>;
352
365
  alarm?(): void | Promise<void>;
366
+ webSocketMessage?(
367
+ ws: WebSocket,
368
+ message: string | ArrayBuffer
369
+ ): void | Promise<void>;
370
+ webSocketClose?(
371
+ ws: WebSocket,
372
+ code: number,
373
+ reason: string,
374
+ wasClean: boolean
375
+ ): void | Promise<void>;
376
+ webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
353
377
  }
354
378
  declare interface DurableObjectStub extends Fetcher {
355
379
  readonly id: DurableObjectId;
@@ -396,6 +420,9 @@ declare interface DurableObjectState {
396
420
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
397
421
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
398
422
  getWebSockets(tag?: string): WebSocket[];
423
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
424
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
425
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
399
426
  }
400
427
  declare interface DurableObjectTransaction {
401
428
  get<T = unknown>(
@@ -490,6 +517,11 @@ declare interface DurableObjectSetAlarmOptions {
490
517
  allowConcurrency?: boolean;
491
518
  allowUnconfirmed?: boolean;
492
519
  }
520
+ declare class WebSocketRequestResponsePair {
521
+ constructor(request: string, response: string);
522
+ get request(): string;
523
+ get response(): string;
524
+ }
493
525
  declare interface AnalyticsEngineDataset {
494
526
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
495
527
  }
@@ -598,6 +630,16 @@ declare interface SchedulerWaitOptions {
598
630
  declare abstract class ExtendableEvent extends Event {
599
631
  waitUntil(promise: Promise<any>): void;
600
632
  }
633
+ declare class CustomEvent extends Event {
634
+ constructor(type: string, init?: CustomEventCustomEventInit);
635
+ get detail(): any | undefined;
636
+ }
637
+ declare interface CustomEventCustomEventInit {
638
+ bubbles?: boolean;
639
+ cancelable?: boolean;
640
+ composed?: boolean;
641
+ detail?: any;
642
+ }
601
643
  declare class Blob {
602
644
  constructor(
603
645
  bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
@@ -826,7 +868,7 @@ declare interface CryptoKeyHmacKeyAlgorithm {
826
868
  declare interface CryptoKeyRsaKeyAlgorithm {
827
869
  name: string;
828
870
  modulusLength: number;
829
- publicExponent: ArrayBuffer;
871
+ publicExponent: ArrayBuffer | (ArrayBuffer | ArrayBufferView);
830
872
  hash?: CryptoKeyKeyAlgorithm;
831
873
  }
832
874
  declare interface CryptoKeyEllipticKeyAlgorithm {
@@ -858,7 +900,10 @@ declare class TextDecoder {
858
900
  declare class TextEncoder {
859
901
  constructor();
860
902
  encode(input?: string): Uint8Array;
861
- encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
903
+ encodeInto(
904
+ input: string,
905
+ buffer: ArrayBuffer | ArrayBufferView
906
+ ): TextEncoderEncodeIntoResult;
862
907
  readonly encoding: string;
863
908
  }
864
909
  declare interface TextDecoderConstructorOptions {
@@ -1095,10 +1140,12 @@ declare type KVNamespaceListResult<Metadata, Key extends string = string> =
1095
1140
  list_complete: false;
1096
1141
  keys: KVNamespaceListKey<Metadata, Key>[];
1097
1142
  cursor: string;
1143
+ cacheStatus: string | null;
1098
1144
  }
1099
1145
  | {
1100
1146
  list_complete: true;
1101
1147
  keys: KVNamespaceListKey<Metadata, Key>[];
1148
+ cacheStatus: string | null;
1102
1149
  };
1103
1150
  declare interface KVNamespace<Key extends string = string> {
1104
1151
  get(
@@ -1191,14 +1238,19 @@ declare interface KVNamespacePutOptions {
1191
1238
  declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1192
1239
  value: Value | null;
1193
1240
  metadata: Metadata | null;
1241
+ cacheStatus: string | null;
1194
1242
  }
1195
- declare interface Queue<Body> {
1196
- send(message: Body): Promise<void>;
1243
+ declare type QueueContentType = "text" | "bytes" | "json" | "v8";
1244
+ declare interface Queue<Body = unknown> {
1245
+ send(message: Body, options?: QueueSendOptions): Promise<void>;
1197
1246
  sendBatch(messages: Iterable<MessageSendRequest<Body>>): Promise<void>;
1198
1247
  }
1199
- declare interface QueueSendOptions {}
1248
+ declare interface QueueSendOptions {
1249
+ contentType?: QueueContentType;
1250
+ }
1200
1251
  declare interface MessageSendRequest<Body = unknown> {
1201
1252
  body: Body;
1253
+ contentType?: QueueContentType;
1202
1254
  }
1203
1255
  declare interface Message<Body = unknown> {
1204
1256
  readonly id: string;
@@ -1251,8 +1303,10 @@ declare abstract class R2Bucket {
1251
1303
  | string
1252
1304
  | null
1253
1305
  | Blob,
1254
- options?: R2PutOptions
1255
- ): Promise<R2Object>;
1306
+ options?: R2PutOptions & {
1307
+ onlyIf: R2Conditional | Headers;
1308
+ }
1309
+ ): Promise<R2Object | null>;
1256
1310
  put(
1257
1311
  key: string,
1258
1312
  value:
@@ -1262,10 +1316,8 @@ declare abstract class R2Bucket {
1262
1316
  | string
1263
1317
  | null
1264
1318
  | Blob,
1265
- options?: R2PutOptions & {
1266
- onlyIf: R2Conditional | Headers;
1267
- }
1268
- ): Promise<R2Object | null>;
1319
+ options?: R2PutOptions
1320
+ ): Promise<R2Object>;
1269
1321
  createMultipartUpload(
1270
1322
  key: string,
1271
1323
  options?: R2MultipartOptions
@@ -1664,12 +1716,14 @@ declare interface TraceItem {
1664
1716
  | TraceItemAlarmEventInfo
1665
1717
  | TraceItemQueueEventInfo
1666
1718
  | TraceItemEmailEventInfo
1719
+ | TraceItemTailEventInfo
1667
1720
  | TraceItemCustomEventInfo
1668
1721
  )
1669
1722
  | null;
1670
1723
  readonly eventTimestamp: number | null;
1671
1724
  readonly logs: TraceLog[];
1672
1725
  readonly exceptions: TraceException[];
1726
+ readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1673
1727
  readonly scriptName: string | null;
1674
1728
  readonly dispatchNamespace?: string;
1675
1729
  readonly scriptTags?: string[];
@@ -1692,6 +1746,12 @@ declare interface TraceItemEmailEventInfo {
1692
1746
  readonly rcptTo: string;
1693
1747
  readonly rawSize: number;
1694
1748
  }
1749
+ declare interface TraceItemTailEventInfo {
1750
+ readonly consumedEvents: TraceItemTailEventInfoTailItem[];
1751
+ }
1752
+ declare interface TraceItemTailEventInfoTailItem {
1753
+ readonly scriptName: string | null;
1754
+ }
1695
1755
  declare interface TraceItemFetchEventInfo {
1696
1756
  readonly response?: TraceItemFetchEventInfoResponse;
1697
1757
  readonly request: TraceItemFetchEventInfoRequest;
@@ -1716,6 +1776,11 @@ declare interface TraceException {
1716
1776
  readonly message: string;
1717
1777
  readonly name: string;
1718
1778
  }
1779
+ declare interface TraceDiagnosticChannelEvent {
1780
+ readonly timestamp: number;
1781
+ readonly channel: string;
1782
+ readonly message: any;
1783
+ }
1719
1784
  declare interface TraceMetrics {
1720
1785
  readonly cpuTime: number;
1721
1786
  readonly wallTime: number;
@@ -1892,6 +1957,427 @@ declare interface SocketAddress {
1892
1957
  declare interface TlsOptions {
1893
1958
  expectedServerHostname?: string;
1894
1959
  }
1960
+ declare abstract class gpuGPUAdapter {
1961
+ requestDevice(param1?: gpuGPUDeviceDescriptor): Promise<gpuGPUDevice>;
1962
+ requestAdapterInfo(unmaskHints?: string[]): Promise<gpuGPUAdapterInfo>;
1963
+ get features(): gpuGPUSupportedFeatures;
1964
+ get limits(): gpuGPUSupportedLimits;
1965
+ }
1966
+ declare interface gpuGPUDevice extends EventTarget {
1967
+ createBuffer(param1: gpuGPUBufferDescriptor): gpuGPUBuffer;
1968
+ createBindGroupLayout(
1969
+ descriptor: gpuGPUBindGroupLayoutDescriptor
1970
+ ): gpuGPUBindGroupLayout;
1971
+ createBindGroup(descriptor: gpuGPUBindGroupDescriptor): gpuGPUBindGroup;
1972
+ createSampler(descriptor: gpuGPUSamplerDescriptor): gpuGPUSampler;
1973
+ createShaderModule(
1974
+ descriptor: gpuGPUShaderModuleDescriptor
1975
+ ): gpuGPUShaderModule;
1976
+ createPipelineLayout(
1977
+ descriptor: gpuGPUPipelineLayoutDescriptor
1978
+ ): gpuGPUPipelineLayout;
1979
+ createComputePipeline(
1980
+ descriptor: gpuGPUComputePipelineDescriptor
1981
+ ): gpuGPUComputePipeline;
1982
+ createRenderPipeline(
1983
+ descriptor: gpuGPURenderPipelineDescriptor
1984
+ ): gpuGPURenderPipeline;
1985
+ createCommandEncoder(
1986
+ descriptor?: gpuGPUCommandEncoderDescriptor
1987
+ ): gpuGPUCommandEncoder;
1988
+ createTexture(param1: gpuGPUTextureDescriptor): gpuGPUTexture;
1989
+ destroy(): void;
1990
+ createQuerySet(descriptor: gpuGPUQuerySetDescriptor): gpuGPUQuerySet;
1991
+ pushErrorScope(filter: string): void;
1992
+ popErrorScope(): Promise<gpuGPUError | null>;
1993
+ get queue(): gpuGPUQueue;
1994
+ get lost(): Promise<gpuGPUDeviceLostInfo>;
1995
+ get features(): gpuGPUSupportedFeatures;
1996
+ get limits(): gpuGPUSupportedLimits;
1997
+ }
1998
+ declare interface gpuGPUDeviceDescriptor {
1999
+ label?: string;
2000
+ requiredFeatures?: string[];
2001
+ requiredLimits?: Record<string, number | bigint>;
2002
+ defaultQueue?: gpuGPUQueueDescriptor;
2003
+ }
2004
+ declare interface gpuGPUBufferDescriptor {
2005
+ label: string;
2006
+ size: number | bigint;
2007
+ usage: number;
2008
+ mappedAtCreation: boolean;
2009
+ }
2010
+ declare interface gpuGPUQueueDescriptor {
2011
+ label?: string;
2012
+ }
2013
+ declare abstract class gpuGPUBufferUsage {
2014
+ static readonly MAP_READ: number;
2015
+ static readonly MAP_WRITE: number;
2016
+ static readonly COPY_SRC: number;
2017
+ static readonly COPY_DST: number;
2018
+ static readonly INDEX: number;
2019
+ static readonly VERTEX: number;
2020
+ static readonly UNIFORM: number;
2021
+ static readonly STORAGE: number;
2022
+ static readonly INDIRECT: number;
2023
+ static readonly QUERY_RESOLVE: number;
2024
+ }
2025
+ declare interface gpuGPUBuffer {
2026
+ getMappedRange(size?: number | bigint, param2?: number | bigint): ArrayBuffer;
2027
+ unmap(): void;
2028
+ destroy(): void;
2029
+ mapAsync(
2030
+ mode: number,
2031
+ offset?: number | bigint,
2032
+ size?: number | bigint
2033
+ ): Promise<void>;
2034
+ get size(): number | bigint;
2035
+ get usage(): number;
2036
+ get mapState(): string;
2037
+ }
2038
+ declare abstract class gpuGPUShaderStage {
2039
+ static readonly VERTEX: number;
2040
+ static readonly FRAGMENT: number;
2041
+ static readonly COMPUTE: number;
2042
+ }
2043
+ declare interface gpuGPUBindGroupLayoutDescriptor {
2044
+ label?: string;
2045
+ entries: gpuGPUBindGroupLayoutEntry[];
2046
+ }
2047
+ declare interface gpuGPUBindGroupLayoutEntry {
2048
+ binding: number;
2049
+ visibility: number;
2050
+ buffer?: gpuGPUBufferBindingLayout;
2051
+ sampler?: gpuGPUSamplerBindingLayout;
2052
+ texture?: gpuGPUTextureBindingLayout;
2053
+ storageTexture?: gpuGPUStorageTextureBindingLayout;
2054
+ }
2055
+ declare interface gpuGPUStorageTextureBindingLayout {
2056
+ access?: string;
2057
+ format: string;
2058
+ viewDimension?: string;
2059
+ }
2060
+ declare interface gpuGPUTextureBindingLayout {
2061
+ sampleType?: string;
2062
+ viewDimension?: string;
2063
+ multisampled?: boolean;
2064
+ }
2065
+ declare interface gpuGPUSamplerBindingLayout {
2066
+ type?: string;
2067
+ }
2068
+ declare interface gpuGPUBufferBindingLayout {
2069
+ type?: string;
2070
+ hasDynamicOffset?: boolean;
2071
+ minBindingSize?: number | bigint;
2072
+ }
2073
+ declare interface gpuGPUBindGroupLayout {}
2074
+ declare interface gpuGPUBindGroup {}
2075
+ declare interface gpuGPUBindGroupDescriptor {
2076
+ label?: string;
2077
+ layout: gpuGPUBindGroupLayout;
2078
+ entries: gpuGPUBindGroupEntry[];
2079
+ }
2080
+ declare interface gpuGPUBindGroupEntry {
2081
+ binding: number;
2082
+ resource: gpuGPUBufferBinding | gpuGPUSampler;
2083
+ }
2084
+ declare interface gpuGPUBufferBinding {
2085
+ buffer: gpuGPUBuffer;
2086
+ offset?: number | bigint;
2087
+ size?: number | bigint;
2088
+ }
2089
+ declare interface gpuGPUSampler {}
2090
+ declare interface gpuGPUSamplerDescriptor {
2091
+ label?: string;
2092
+ addressModeU?: string;
2093
+ addressModeV?: string;
2094
+ addressModeW?: string;
2095
+ magFilter?: string;
2096
+ minFilter?: string;
2097
+ mipmapFilter?: string;
2098
+ lodMinClamp?: number;
2099
+ lodMaxClamp?: number;
2100
+ compare: string;
2101
+ maxAnisotropy?: number;
2102
+ }
2103
+ declare interface gpuGPUShaderModule {
2104
+ getCompilationInfo(): Promise<gpuGPUCompilationInfo>;
2105
+ }
2106
+ declare interface gpuGPUShaderModuleDescriptor {
2107
+ label?: string;
2108
+ code: string;
2109
+ }
2110
+ declare interface gpuGPUPipelineLayout {}
2111
+ declare interface gpuGPUPipelineLayoutDescriptor {
2112
+ label?: string;
2113
+ bindGroupLayouts: gpuGPUBindGroupLayout[];
2114
+ }
2115
+ declare interface gpuGPUComputePipeline {
2116
+ getBindGroupLayout(index: number): gpuGPUBindGroupLayout;
2117
+ }
2118
+ declare interface gpuGPUComputePipelineDescriptor {
2119
+ label?: string;
2120
+ compute: gpuGPUProgrammableStage;
2121
+ layout: string | gpuGPUPipelineLayout;
2122
+ }
2123
+ declare interface gpuGPUProgrammableStage {
2124
+ module: gpuGPUShaderModule;
2125
+ entryPoint: string;
2126
+ constants?: Record<string, number>;
2127
+ }
2128
+ declare interface gpuGPUCommandEncoder {
2129
+ get label(): string;
2130
+ beginComputePass(
2131
+ descriptor?: gpuGPUComputePassDescriptor
2132
+ ): gpuGPUComputePassEncoder;
2133
+ copyBufferToBuffer(
2134
+ source: gpuGPUBuffer,
2135
+ sourceOffset: number | bigint,
2136
+ destination: gpuGPUBuffer,
2137
+ destinationOffset: number | bigint,
2138
+ size: number | bigint
2139
+ ): void;
2140
+ finish(param0?: gpuGPUCommandBufferDescriptor): gpuGPUCommandBuffer;
2141
+ }
2142
+ declare interface gpuGPUCommandEncoderDescriptor {
2143
+ label?: string;
2144
+ }
2145
+ declare interface gpuGPUComputePassEncoder {
2146
+ setPipeline(pipeline: gpuGPUComputePipeline): void;
2147
+ setBindGroup(
2148
+ index: number,
2149
+ bindGroup: gpuGPUBindGroup | null,
2150
+ dynamicOffsets?: Iterable<number>
2151
+ ): void;
2152
+ dispatchWorkgroups(
2153
+ workgroupCountX: number,
2154
+ workgroupCountY?: number,
2155
+ workgroupCountZ?: number
2156
+ ): void;
2157
+ end(): void;
2158
+ }
2159
+ declare interface gpuGPUComputePassDescriptor {
2160
+ label?: string;
2161
+ timestampWrites?: gpuGPUComputePassTimestampWrite[];
2162
+ }
2163
+ declare interface gpuGPUQuerySet {}
2164
+ declare interface gpuGPUQuerySetDescriptor {
2165
+ label?: string;
2166
+ }
2167
+ declare interface gpuGPUComputePassTimestampWrite {
2168
+ querySet: gpuGPUQuerySet;
2169
+ queryIndex: number;
2170
+ location: string;
2171
+ }
2172
+ declare interface gpuGPUCommandBufferDescriptor {
2173
+ label?: string;
2174
+ }
2175
+ declare interface gpuGPUCommandBuffer {}
2176
+ declare interface gpuGPUQueue {
2177
+ submit(commandBuffers: gpuGPUCommandBuffer[]): void;
2178
+ writeBuffer(
2179
+ buffer: gpuGPUBuffer,
2180
+ bufferOffset: number | bigint,
2181
+ data: ArrayBuffer | ArrayBufferView,
2182
+ dataOffset?: number | bigint,
2183
+ size?: number | bigint
2184
+ ): void;
2185
+ }
2186
+ declare abstract class gpuGPUMapMode {
2187
+ static readonly READ: number;
2188
+ static readonly WRITE: number;
2189
+ }
2190
+ declare interface gpuGPUAdapterInfo {
2191
+ get vendor(): string;
2192
+ get architecture(): string;
2193
+ get device(): string;
2194
+ get description(): string;
2195
+ }
2196
+ declare interface gpuGPUSupportedFeatures {
2197
+ has(name: string): boolean;
2198
+ keys(): string[];
2199
+ }
2200
+ declare interface gpuGPUSupportedLimits {
2201
+ get maxTextureDimension1D(): number;
2202
+ get maxTextureDimension2D(): number;
2203
+ get maxTextureDimension3D(): number;
2204
+ get maxTextureArrayLayers(): number;
2205
+ get maxBindGroups(): number;
2206
+ get maxBindingsPerBindGroup(): number;
2207
+ get maxDynamicUniformBuffersPerPipelineLayout(): number;
2208
+ get maxDynamicStorageBuffersPerPipelineLayout(): number;
2209
+ get maxSampledTexturesPerShaderStage(): number;
2210
+ get maxSamplersPerShaderStage(): number;
2211
+ get maxStorageBuffersPerShaderStage(): number;
2212
+ get maxStorageTexturesPerShaderStage(): number;
2213
+ get maxUniformBuffersPerShaderStage(): number;
2214
+ get maxUniformBufferBindingSize(): number | bigint;
2215
+ get maxStorageBufferBindingSize(): number | bigint;
2216
+ get minUniformBufferOffsetAlignment(): number;
2217
+ get minStorageBufferOffsetAlignment(): number;
2218
+ get maxVertexBuffers(): number;
2219
+ get maxBufferSize(): number | bigint;
2220
+ get maxVertexAttributes(): number;
2221
+ get maxVertexBufferArrayStride(): number;
2222
+ get maxInterStageShaderComponents(): number;
2223
+ get maxInterStageShaderVariables(): number;
2224
+ get maxColorAttachments(): number;
2225
+ get maxColorAttachmentBytesPerSample(): number;
2226
+ get maxComputeWorkgroupStorageSize(): number;
2227
+ get maxComputeInvocationsPerWorkgroup(): number;
2228
+ get maxComputeWorkgroupSizeX(): number;
2229
+ get maxComputeWorkgroupSizeY(): number;
2230
+ get maxComputeWorkgroupSizeZ(): number;
2231
+ get maxComputeWorkgroupsPerDimension(): number;
2232
+ }
2233
+ declare abstract class gpuGPUError {
2234
+ get message(): string;
2235
+ }
2236
+ declare abstract class gpuGPUOutOfMemoryError extends gpuGPUError {}
2237
+ declare abstract class gpuGPUInternalError extends gpuGPUError {}
2238
+ declare abstract class gpuGPUValidationError extends gpuGPUError {}
2239
+ declare abstract class gpuGPUDeviceLostInfo {
2240
+ get message(): string;
2241
+ get reason(): string;
2242
+ }
2243
+ declare interface gpuGPUCompilationMessage {
2244
+ get message(): string;
2245
+ get type(): string;
2246
+ get lineNum(): number;
2247
+ get linePos(): number;
2248
+ get offset(): number;
2249
+ get length(): number;
2250
+ }
2251
+ declare interface gpuGPUCompilationInfo {
2252
+ get messages(): gpuGPUCompilationMessage[];
2253
+ }
2254
+ declare abstract class gpuGPUTextureUsage {
2255
+ static readonly COPY_SRC: number;
2256
+ static readonly COPY_DST: number;
2257
+ static readonly TEXTURE_BINDING: number;
2258
+ static readonly STORAGE_BINDING: number;
2259
+ static readonly RENDER_ATTACHMENT: number;
2260
+ }
2261
+ declare interface gpuGPUTextureDescriptor {
2262
+ label: string;
2263
+ size: number[] | gpuGPUExtent3DDict;
2264
+ mipLevelCount?: number;
2265
+ sampleCount?: number;
2266
+ dimension?: string;
2267
+ format: string;
2268
+ usage: number;
2269
+ viewFormats?: string[];
2270
+ }
2271
+ declare interface gpuGPUExtent3DDict {
2272
+ width: number;
2273
+ height?: number;
2274
+ depthOrArrayLayers?: number;
2275
+ }
2276
+ declare interface gpuGPUTexture {
2277
+ createView(descriptor?: gpuGPUTextureViewDescriptor): gpuGPUTextureView;
2278
+ destroy(): void;
2279
+ get width(): number;
2280
+ get height(): number;
2281
+ get depthOrArrayLayers(): number;
2282
+ get mipLevelCount(): number;
2283
+ get dimension(): string;
2284
+ get format(): string;
2285
+ get usage(): number;
2286
+ }
2287
+ declare interface gpuGPUTextureView {}
2288
+ declare interface gpuGPUTextureViewDescriptor {
2289
+ label: string;
2290
+ format: string;
2291
+ dimension: string;
2292
+ aspect?: string;
2293
+ baseMipLevel?: number;
2294
+ mipLevelCount: number;
2295
+ baseArrayLayer?: number;
2296
+ arrayLayerCount: number;
2297
+ }
2298
+ declare abstract class gpuGPUColorWrite {
2299
+ static readonly RED: number;
2300
+ static readonly GREEN: number;
2301
+ static readonly BLUE: number;
2302
+ static readonly ALPHA: number;
2303
+ static readonly ALL: number;
2304
+ }
2305
+ declare interface gpuGPURenderPipeline {}
2306
+ declare interface gpuGPURenderPipelineDescriptor {
2307
+ label?: string;
2308
+ layout: string | gpuGPUPipelineLayout;
2309
+ vertex: gpuGPUVertexState;
2310
+ primitive?: gpuGPUPrimitiveState;
2311
+ depthStencil?: gpuGPUDepthStencilState;
2312
+ multisample?: gpuGPUMultisampleState;
2313
+ fragment?: gpuGPUFragmentState;
2314
+ }
2315
+ declare interface gpuGPUVertexState {
2316
+ module: gpuGPUShaderModule;
2317
+ entryPoint: string;
2318
+ constants?: Record<string, number>;
2319
+ buffers?: gpuGPUVertexBufferLayout[];
2320
+ }
2321
+ declare interface gpuGPUVertexBufferLayout {
2322
+ arrayStride: number | bigint;
2323
+ stepMode?: string;
2324
+ attributes: gpuGPUVertexAttribute[];
2325
+ }
2326
+ declare interface gpuGPUVertexAttribute {
2327
+ format: string;
2328
+ offset: number | bigint;
2329
+ shaderLocation: number;
2330
+ }
2331
+ declare interface gpuGPUPrimitiveState {
2332
+ topology?: string;
2333
+ stripIndexFormat?: string;
2334
+ frontFace?: string;
2335
+ cullMode?: string;
2336
+ unclippedDepth?: boolean;
2337
+ }
2338
+ declare interface gpuGPUStencilFaceState {
2339
+ compare?: string;
2340
+ failOp?: string;
2341
+ depthFailOp?: string;
2342
+ passOp?: string;
2343
+ }
2344
+ declare interface gpuGPUDepthStencilState {
2345
+ format: string;
2346
+ depthWriteEnabled: boolean;
2347
+ depthCompare: string;
2348
+ stencilFront?: gpuGPUStencilFaceState;
2349
+ stencilBack?: gpuGPUStencilFaceState;
2350
+ stencilReadMask?: number;
2351
+ stencilWriteMask?: number;
2352
+ depthBias?: number;
2353
+ depthBiasSlopeScale?: number;
2354
+ depthBiasClamp?: number;
2355
+ }
2356
+ declare interface gpuGPUMultisampleState {
2357
+ count?: number;
2358
+ mask?: number;
2359
+ alphaToCoverageEnabled?: boolean;
2360
+ }
2361
+ declare interface gpuGPUFragmentState {
2362
+ module: gpuGPUShaderModule;
2363
+ entryPoint: string;
2364
+ constants?: Record<string, number>;
2365
+ targets: gpuGPUColorTargetState[];
2366
+ }
2367
+ declare interface gpuGPUColorTargetState {
2368
+ format: string;
2369
+ blend: gpuGPUBlendState;
2370
+ writeMask?: number;
2371
+ }
2372
+ declare interface gpuGPUBlendState {
2373
+ color: gpuGPUBlendComponent;
2374
+ alpha: gpuGPUBlendComponent;
2375
+ }
2376
+ declare interface gpuGPUBlendComponent {
2377
+ operation?: string;
2378
+ srcFactor?: string;
2379
+ dstFactor?: string;
2380
+ }
1895
2381
  declare interface BasicImageTransformations {
1896
2382
  /**
1897
2383
  * Maximum width in image pixels. The value must be an integer.
@@ -2864,23 +3350,28 @@ declare type CfProperties<HostMetadata = unknown> =
2864
3350
  | IncomingRequestCfProperties<HostMetadata>
2865
3351
  | RequestInitCfProperties;
2866
3352
  declare interface D1Result<T = unknown> {
2867
- results?: T[];
2868
- success: boolean;
2869
- error?: string;
3353
+ results: T[];
3354
+ success: true;
2870
3355
  meta: any;
3356
+ error?: never;
3357
+ }
3358
+ declare interface D1ExecResult {
3359
+ count: number;
3360
+ duration: number;
2871
3361
  }
2872
3362
  declare abstract class D1Database {
2873
3363
  prepare(query: string): D1PreparedStatement;
2874
3364
  dump(): Promise<ArrayBuffer>;
2875
3365
  batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2876
- exec<T = unknown>(query: string): Promise<D1Result<T>>;
3366
+ exec(query: string): Promise<D1ExecResult>;
2877
3367
  }
2878
3368
  declare abstract class D1PreparedStatement {
2879
- bind(...values: any[]): D1PreparedStatement;
2880
- first<T = unknown>(colName?: string): Promise<T>;
2881
- run<T = unknown>(): Promise<D1Result<T>>;
2882
- all<T = unknown>(): Promise<D1Result<T>>;
2883
- raw<T = unknown>(): Promise<T[]>;
3369
+ bind(...values: unknown[]): D1PreparedStatement;
3370
+ first<T = unknown>(colName: string): Promise<T | null>;
3371
+ first<T = Record<string, unknown>>(): Promise<T | null>;
3372
+ run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
3373
+ all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
3374
+ raw<T = unknown[]>(): Promise<T[]>;
2884
3375
  }
2885
3376
  /**
2886
3377
  * An email message that can be sent from a Worker.
@@ -2946,6 +3437,53 @@ declare module "cloudflare:email" {
2946
3437
  };
2947
3438
  export { _EmailMessage as EmailMessage };
2948
3439
  }
3440
+ declare interface Hyperdrive {
3441
+ /**
3442
+ * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
3443
+ *
3444
+ * Calling this method returns an idential socket to if you call
3445
+ * `connect("host:port")` using the `host` and `port` fields from this object.
3446
+ * Pick whichever approach works better with your preferred DB client library.
3447
+ *
3448
+ * Note that this socket is not yet authenticated -- it's expected that your
3449
+ * code (or preferably, the client library of your choice) will authenticate
3450
+ * using the information in this class's readonly fields.
3451
+ */
3452
+ connect(): Socket;
3453
+ /**
3454
+ * A valid DB connection string that can be passed straight into the typical
3455
+ * client library/driver/ORM. This will typically be the easiest way to use
3456
+ * Hyperdrive.
3457
+ */
3458
+ readonly connectionString: string;
3459
+ /*
3460
+ * A randomly generated hostname that is only valid within the context of the
3461
+ * currently running Worker which, when passed into `connect()` function from
3462
+ * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
3463
+ * for your database.
3464
+ */
3465
+ readonly host: string;
3466
+ /*
3467
+ * The port that must be paired the the host field when connecting.
3468
+ */
3469
+ readonly port: string;
3470
+ /*
3471
+ * The username to use when authenticating to your database via Hyperdrive.
3472
+ * Unlike the host and password, this will be the same every time
3473
+ */
3474
+ readonly user: string;
3475
+ /*
3476
+ * The randomly generated password to use when authenticating to your
3477
+ * database via Hyperdrive. Like the host field, this password is only valid
3478
+ * within the context of the currently running Worker instance from which
3479
+ * it's read.
3480
+ */
3481
+ readonly password: string;
3482
+ /*
3483
+ * The name of the database to connect to.
3484
+ */
3485
+ readonly database: string;
3486
+ }
2949
3487
  declare type Params<P extends string = any> = Record<P, string | string[]>;
2950
3488
  declare type EventContext<Env, P extends string, Data> = {
2951
3489
  request: Request;
@@ -2992,10 +3530,10 @@ declare type PagesPluginFunction<
2992
3530
  declare module "assets:*" {
2993
3531
  export const onRequest: PagesFunction;
2994
3532
  }
2995
- // https://developers.cloudflare.com/pub-sub/
2996
3533
  // PubSubMessage represents an incoming PubSub message.
2997
3534
  // The message includes metadata about the broker, the client, and the payload
2998
3535
  // itself.
3536
+ // https://developers.cloudflare.com/pub-sub/
2999
3537
  declare interface PubSubMessage {
3000
3538
  // Message ID
3001
3539
  readonly mid: number;
@@ -3033,7 +3571,141 @@ declare module "cloudflare:sockets" {
3033
3571
  ): Socket;
3034
3572
  export { _connect as connect };
3035
3573
  }
3036
- // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
3574
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
3575
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
3576
+ // https://opensource.org/licenses/Apache-2.0
3577
+ /**
3578
+ * Additional information to associate with a vector.
3579
+ */
3580
+ declare type VectorizeVectorMetadata =
3581
+ | string
3582
+ | number
3583
+ | boolean
3584
+ | string[]
3585
+ | Record<string, string | number | boolean | string[]>;
3586
+ declare type VectorFloatArray = Float32Array | Float64Array;
3587
+ declare interface VectorizeError {
3588
+ code?: number;
3589
+ error: string;
3590
+ }
3591
+ /**
3592
+ * Supported distance metrics for an index.
3593
+ * Distance metrics determine how other "similar" vectors are determined.
3594
+ */
3595
+ declare type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
3596
+ declare interface VectorizeQueryOptions {
3597
+ topK?: number;
3598
+ namespace?: string;
3599
+ returnVectors?: boolean;
3600
+ }
3601
+ /**
3602
+ * Information about the configuration of an index.
3603
+ */
3604
+ declare type VectorizeIndexConfig =
3605
+ | {
3606
+ dimensions: number;
3607
+ metric: VectorizeDistanceMetric;
3608
+ }
3609
+ | {
3610
+ preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
3611
+ };
3612
+ /**
3613
+ * Metadata about an existing index.
3614
+ */
3615
+ declare interface VectorizeIndexDetails {
3616
+ /** The unique ID of the index */
3617
+ readonly id: string;
3618
+ /** The name of the index. */
3619
+ name: string;
3620
+ /** (optional) A human readable description for the index. */
3621
+ description?: string;
3622
+ /** The index configuration, including the dimension size and distance metric. */
3623
+ config: VectorizeIndexConfig;
3624
+ /** The number of records containing vectors within the index. */
3625
+ vectorsCount: number;
3626
+ }
3627
+ /**
3628
+ * Represents a single vector value set along with its associated metadata.
3629
+ */
3630
+ declare interface VectorizeVector {
3631
+ /** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
3632
+ id: string;
3633
+ /** The vector values */
3634
+ values: VectorFloatArray | number[];
3635
+ /** The namespace this vector belongs to. */
3636
+ namespace?: string;
3637
+ /** Metadata associated with the binding. Includes the values of the other fields and potentially additional details. */
3638
+ metadata?: Record<string, VectorizeVectorMetadata>;
3639
+ }
3640
+ /**
3641
+ * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
3642
+ */
3643
+ declare interface VectorizeMatch {
3644
+ /** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
3645
+ vectorId: string;
3646
+ /** The score or rank for similarity, when returned as a result */
3647
+ score: number;
3648
+ /** Vector data for the match. Included only if the user specified they want it returned (via {@link VectorizeQueryOptions}). */
3649
+ vector?: VectorizeVector;
3650
+ }
3651
+ /**
3652
+ * A set of vector {@link VectorizeMatch} for a particular query.
3653
+ */
3654
+ declare interface VectorizeMatches {
3655
+ matches: VectorizeMatch[];
3656
+ count: number;
3657
+ }
3658
+ /**
3659
+ * Results of an operation that performed a mutation on a set of vectors.
3660
+ * Here, `ids` is a list of vectors that were successfully processed.
3661
+ */
3662
+ declare interface VectorizeVectorMutation {
3663
+ /* List of ids of vectors that were successfully processed. */
3664
+ ids: string[];
3665
+ /* Total count of the number of processed vectors. */
3666
+ count: number;
3667
+ }
3668
+ declare abstract class VectorizeIndex {
3669
+ /**
3670
+ * Get information about the currently bound index.
3671
+ * @returns A promise that resolves with information about the current index.
3672
+ */
3673
+ public describe(): Promise<VectorizeIndexDetails>;
3674
+ /**
3675
+ * Use the provided vector to perform a similarity search across the index.
3676
+ * @param vector Input vector that will be used to drive the similarity search.
3677
+ * @param options Configuration options to massage the returned data.
3678
+ * @returns A promise that resolves with matched and scored vectors.
3679
+ */
3680
+ public query(
3681
+ vector: VectorFloatArray | number[],
3682
+ options: VectorizeQueryOptions
3683
+ ): Promise<VectorizeMatches>;
3684
+ /**
3685
+ * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
3686
+ * @param vectors List of vectors that will be inserted.
3687
+ * @returns A promise that resolves with the ids & count of records that were successfully processed.
3688
+ */
3689
+ public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
3690
+ /**
3691
+ * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
3692
+ * @param vectors List of vectors that will be upserted.
3693
+ * @returns A promise that resolves with the ids & count of records that were successfully processed.
3694
+ */
3695
+ public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
3696
+ /**
3697
+ * Delete a list of vectors with a matching id.
3698
+ * @param ids List of vector ids that should be deleted.
3699
+ * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
3700
+ */
3701
+ public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
3702
+ /**
3703
+ * Get a list of vectors with a matching id.
3704
+ * @param ids List of vector ids that should be returned.
3705
+ * @returns A promise that resolves with the raw unscored vectors matching the id set.
3706
+ */
3707
+ public getByIds(ids: string[]): Promise<VectorizeVector[]>;
3708
+ }
3037
3709
  declare interface DynamicDispatchLimits {
3038
3710
  /**
3039
3711
  * Limit CPU time in milliseconds.