@cloudflare/workers-types 0.20240712.0 → 0.20250124.2
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.
- package/2021-11-03/index.d.ts +1408 -183
- package/2021-11-03/index.ts +1345 -179
- package/2022-01-31/index.d.ts +1429 -204
- package/2022-01-31/index.ts +1366 -200
- package/2022-03-21/index.d.ts +1431 -205
- package/2022-03-21/index.ts +1368 -201
- package/2022-08-04/index.d.ts +1431 -205
- package/2022-08-04/index.ts +1368 -201
- package/2022-10-31/index.d.ts +1435 -205
- package/2022-10-31/index.ts +1372 -201
- package/2022-11-30/index.d.ts +1435 -205
- package/2022-11-30/index.ts +1372 -201
- package/2023-03-01/index.d.ts +1435 -205
- package/2023-03-01/index.ts +1372 -201
- package/2023-07-01/index.d.ts +1435 -205
- package/2023-07-01/index.ts +1372 -201
- package/experimental/index.d.ts +1446 -212
- package/experimental/index.ts +1383 -208
- package/index.d.ts +1408 -183
- package/index.ts +1345 -179
- package/oldest/index.d.ts +1408 -183
- package/oldest/index.ts +1345 -179
- package/package.json +1 -1
package/2021-11-03/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ and limitations under the License.
|
|
|
14
14
|
***************************************************************************** */
|
|
15
15
|
/* eslint-disable */
|
|
16
16
|
// noinspection JSUnusedGlobalSymbols
|
|
17
|
+
declare var onmessage: never;
|
|
17
18
|
/**
|
|
18
19
|
* An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
|
|
19
20
|
*
|
|
@@ -227,7 +228,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
227
228
|
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
|
|
228
229
|
reportError(error: any): void;
|
|
229
230
|
fetch(
|
|
230
|
-
input: RequestInfo,
|
|
231
|
+
input: RequestInfo | URL,
|
|
231
232
|
init?: RequestInit<RequestInitCfProperties>,
|
|
232
233
|
): Promise<Response>;
|
|
233
234
|
self: ServiceWorkerGlobalScope;
|
|
@@ -235,6 +236,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
235
236
|
caches: CacheStorage;
|
|
236
237
|
scheduler: Scheduler;
|
|
237
238
|
performance: Performance;
|
|
239
|
+
Cloudflare: Cloudflare;
|
|
238
240
|
readonly origin: string;
|
|
239
241
|
Event: typeof Event;
|
|
240
242
|
ExtendableEvent: typeof ExtendableEvent;
|
|
@@ -357,7 +359,7 @@ declare function structuredClone<T>(
|
|
|
357
359
|
declare function reportError(error: any): void;
|
|
358
360
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/fetch) */
|
|
359
361
|
declare function fetch(
|
|
360
|
-
input: RequestInfo,
|
|
362
|
+
input: RequestInfo | URL,
|
|
361
363
|
init?: RequestInit<RequestInitCfProperties>,
|
|
362
364
|
): Promise<Response>;
|
|
363
365
|
declare const self: ServiceWorkerGlobalScope;
|
|
@@ -384,11 +386,13 @@ declare const scheduler: Scheduler;
|
|
|
384
386
|
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
|
|
385
387
|
*/
|
|
386
388
|
declare const performance: Performance;
|
|
389
|
+
declare const Cloudflare: Cloudflare;
|
|
387
390
|
declare const origin: string;
|
|
388
391
|
interface TestController {}
|
|
389
392
|
interface ExecutionContext {
|
|
390
393
|
waitUntil(promise: Promise<any>): void;
|
|
391
394
|
passThroughOnException(): void;
|
|
395
|
+
props: any;
|
|
392
396
|
}
|
|
393
397
|
type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (
|
|
394
398
|
request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
|
|
@@ -405,6 +409,11 @@ type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
|
405
409
|
env: Env,
|
|
406
410
|
ctx: ExecutionContext,
|
|
407
411
|
) => void | Promise<void>;
|
|
412
|
+
type ExportedHandlerTailStreamHandler<Env = unknown> = (
|
|
413
|
+
event: TailStream.TailEvent,
|
|
414
|
+
env: Env,
|
|
415
|
+
ctx: ExecutionContext,
|
|
416
|
+
) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
|
|
408
417
|
type ExportedHandlerScheduledHandler<Env = unknown> = (
|
|
409
418
|
controller: ScheduledController,
|
|
410
419
|
env: Env,
|
|
@@ -428,6 +437,7 @@ interface ExportedHandler<
|
|
|
428
437
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
429
438
|
tail?: ExportedHandlerTailHandler<Env>;
|
|
430
439
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
440
|
+
tailStream?: ExportedHandlerTailStreamHandler<Env>;
|
|
431
441
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
432
442
|
test?: ExportedHandlerTestHandler<Env>;
|
|
433
443
|
email?: EmailExportedHandler<Env>;
|
|
@@ -459,9 +469,12 @@ interface AlarmInvocationInfo {
|
|
|
459
469
|
readonly isRetry: boolean;
|
|
460
470
|
readonly retryCount: number;
|
|
461
471
|
}
|
|
472
|
+
interface Cloudflare {
|
|
473
|
+
readonly compatibilityFlags: Record<string, boolean>;
|
|
474
|
+
}
|
|
462
475
|
interface DurableObject {
|
|
463
476
|
fetch(request: Request): Response | Promise<Response>;
|
|
464
|
-
alarm?(): void | Promise<void>;
|
|
477
|
+
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
465
478
|
webSocketMessage?(
|
|
466
479
|
ws: WebSocket,
|
|
467
480
|
message: string | ArrayBuffer,
|
|
@@ -534,6 +547,7 @@ interface DurableObjectState {
|
|
|
534
547
|
setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
|
|
535
548
|
getHibernatableWebSocketEventTimeout(): number | null;
|
|
536
549
|
getTags(ws: WebSocket): string[];
|
|
550
|
+
abort(reason?: string): void;
|
|
537
551
|
}
|
|
538
552
|
interface DurableObjectTransaction {
|
|
539
553
|
get<T = unknown>(
|
|
@@ -600,7 +614,11 @@ interface DurableObjectStorage {
|
|
|
600
614
|
): Promise<void>;
|
|
601
615
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
602
616
|
sync(): Promise<void>;
|
|
617
|
+
sql: SqlStorage;
|
|
603
618
|
transactionSync<T>(closure: () => T): T;
|
|
619
|
+
getCurrentBookmark(): Promise<string>;
|
|
620
|
+
getBookmarkForTime(timestamp: number | Date): Promise<string>;
|
|
621
|
+
onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
|
|
604
622
|
}
|
|
605
623
|
interface DurableObjectListOptions {
|
|
606
624
|
start?: string;
|
|
@@ -965,14 +983,17 @@ declare abstract class CacheStorage {
|
|
|
965
983
|
*/
|
|
966
984
|
declare abstract class Cache {
|
|
967
985
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
|
|
968
|
-
delete(
|
|
986
|
+
delete(
|
|
987
|
+
request: RequestInfo | URL,
|
|
988
|
+
options?: CacheQueryOptions,
|
|
989
|
+
): Promise<boolean>;
|
|
969
990
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
|
|
970
991
|
match(
|
|
971
|
-
request: RequestInfo,
|
|
992
|
+
request: RequestInfo | URL,
|
|
972
993
|
options?: CacheQueryOptions,
|
|
973
994
|
): Promise<Response | undefined>;
|
|
974
995
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
|
|
975
|
-
put(request: RequestInfo, response: Response): Promise<void>;
|
|
996
|
+
put(request: RequestInfo | URL, response: Response): Promise<void>;
|
|
976
997
|
}
|
|
977
998
|
interface CacheQueryOptions {
|
|
978
999
|
ignoreMethod?: boolean;
|
|
@@ -1395,20 +1416,44 @@ interface Element {
|
|
|
1395
1416
|
hasAttribute(name: string): boolean;
|
|
1396
1417
|
setAttribute(name: string, value: string): Element;
|
|
1397
1418
|
removeAttribute(name: string): Element;
|
|
1398
|
-
before(
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1419
|
+
before(
|
|
1420
|
+
content: string | ReadableStream | Response,
|
|
1421
|
+
options?: ContentOptions,
|
|
1422
|
+
): Element;
|
|
1423
|
+
after(
|
|
1424
|
+
content: string | ReadableStream | Response,
|
|
1425
|
+
options?: ContentOptions,
|
|
1426
|
+
): Element;
|
|
1427
|
+
prepend(
|
|
1428
|
+
content: string | ReadableStream | Response,
|
|
1429
|
+
options?: ContentOptions,
|
|
1430
|
+
): Element;
|
|
1431
|
+
append(
|
|
1432
|
+
content: string | ReadableStream | Response,
|
|
1433
|
+
options?: ContentOptions,
|
|
1434
|
+
): Element;
|
|
1435
|
+
replace(
|
|
1436
|
+
content: string | ReadableStream | Response,
|
|
1437
|
+
options?: ContentOptions,
|
|
1438
|
+
): Element;
|
|
1403
1439
|
remove(): Element;
|
|
1404
1440
|
removeAndKeepContent(): Element;
|
|
1405
|
-
setInnerContent(
|
|
1441
|
+
setInnerContent(
|
|
1442
|
+
content: string | ReadableStream | Response,
|
|
1443
|
+
options?: ContentOptions,
|
|
1444
|
+
): Element;
|
|
1406
1445
|
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
|
|
1407
1446
|
}
|
|
1408
1447
|
interface EndTag {
|
|
1409
1448
|
name: string;
|
|
1410
|
-
before(
|
|
1411
|
-
|
|
1449
|
+
before(
|
|
1450
|
+
content: string | ReadableStream | Response,
|
|
1451
|
+
options?: ContentOptions,
|
|
1452
|
+
): EndTag;
|
|
1453
|
+
after(
|
|
1454
|
+
content: string | ReadableStream | Response,
|
|
1455
|
+
options?: ContentOptions,
|
|
1456
|
+
): EndTag;
|
|
1412
1457
|
remove(): EndTag;
|
|
1413
1458
|
}
|
|
1414
1459
|
interface Comment {
|
|
@@ -1423,9 +1468,18 @@ interface Text {
|
|
|
1423
1468
|
readonly text: string;
|
|
1424
1469
|
readonly lastInTextNode: boolean;
|
|
1425
1470
|
readonly removed: boolean;
|
|
1426
|
-
before(
|
|
1427
|
-
|
|
1428
|
-
|
|
1471
|
+
before(
|
|
1472
|
+
content: string | ReadableStream | Response,
|
|
1473
|
+
options?: ContentOptions,
|
|
1474
|
+
): Text;
|
|
1475
|
+
after(
|
|
1476
|
+
content: string | ReadableStream | Response,
|
|
1477
|
+
options?: ContentOptions,
|
|
1478
|
+
): Text;
|
|
1479
|
+
replace(
|
|
1480
|
+
content: string | ReadableStream | Response,
|
|
1481
|
+
options?: ContentOptions,
|
|
1482
|
+
): Text;
|
|
1429
1483
|
remove(): Text;
|
|
1430
1484
|
}
|
|
1431
1485
|
interface DocumentEnd {
|
|
@@ -1507,12 +1561,18 @@ declare abstract class Body {
|
|
|
1507
1561
|
*
|
|
1508
1562
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1509
1563
|
*/
|
|
1510
|
-
declare
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1564
|
+
declare var Response: {
|
|
1565
|
+
prototype: Response;
|
|
1566
|
+
new (body?: BodyInit | null, init?: ResponseInit): Response;
|
|
1567
|
+
redirect(url: string, status?: number): Response;
|
|
1568
|
+
json(any: any, maybeInit?: ResponseInit | Response): Response;
|
|
1569
|
+
};
|
|
1570
|
+
/**
|
|
1571
|
+
* This Fetch API interface represents the response to a request.
|
|
1572
|
+
*
|
|
1573
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1574
|
+
*/
|
|
1575
|
+
interface Response extends Body {
|
|
1516
1576
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
|
|
1517
1577
|
clone(): Response;
|
|
1518
1578
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
|
|
@@ -1540,18 +1600,26 @@ interface ResponseInit {
|
|
|
1540
1600
|
}
|
|
1541
1601
|
type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
|
|
1542
1602
|
| Request<CfHostMetadata, Cf>
|
|
1543
|
-
| string
|
|
1544
|
-
| URL;
|
|
1603
|
+
| string;
|
|
1545
1604
|
/**
|
|
1546
1605
|
* This Fetch API interface represents a resource request.
|
|
1547
1606
|
*
|
|
1548
1607
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
|
|
1549
1608
|
*/
|
|
1550
|
-
declare
|
|
1551
|
-
|
|
1552
|
-
Cf = CfProperties<CfHostMetadata
|
|
1553
|
-
>
|
|
1554
|
-
|
|
1609
|
+
declare var Request: {
|
|
1610
|
+
prototype: Request;
|
|
1611
|
+
new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
|
|
1612
|
+
input: RequestInfo<CfProperties> | URL,
|
|
1613
|
+
init?: RequestInit<Cf>,
|
|
1614
|
+
): Request<CfHostMetadata, Cf>;
|
|
1615
|
+
};
|
|
1616
|
+
/**
|
|
1617
|
+
* This Fetch API interface represents a resource request.
|
|
1618
|
+
*
|
|
1619
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
|
|
1620
|
+
*/
|
|
1621
|
+
interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>
|
|
1622
|
+
extends Body {
|
|
1555
1623
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
|
|
1556
1624
|
clone(): Request<CfHostMetadata, Cf>;
|
|
1557
1625
|
/**
|
|
@@ -1623,7 +1691,7 @@ type Fetcher<
|
|
|
1623
1691
|
> = (T extends Rpc.EntrypointBranded
|
|
1624
1692
|
? Rpc.Provider<T, Reserved | "fetch" | "connect">
|
|
1625
1693
|
: unknown) & {
|
|
1626
|
-
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1694
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
1627
1695
|
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1628
1696
|
};
|
|
1629
1697
|
interface FetcherPutOptions {
|
|
@@ -1844,6 +1912,7 @@ interface R2MultipartUpload {
|
|
|
1844
1912
|
uploadPart(
|
|
1845
1913
|
partNumber: number,
|
|
1846
1914
|
value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
|
|
1915
|
+
options?: R2UploadPartOptions,
|
|
1847
1916
|
): Promise<R2UploadedPart>;
|
|
1848
1917
|
abort(): Promise<void>;
|
|
1849
1918
|
complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
|
|
@@ -1864,6 +1933,7 @@ declare abstract class R2Object {
|
|
|
1864
1933
|
readonly customMetadata?: Record<string, string>;
|
|
1865
1934
|
readonly range?: R2Range;
|
|
1866
1935
|
readonly storageClass: string;
|
|
1936
|
+
readonly ssecKeyMd5?: string;
|
|
1867
1937
|
writeHttpMetadata(headers: Headers): void;
|
|
1868
1938
|
}
|
|
1869
1939
|
interface R2ObjectBody extends R2Object {
|
|
@@ -1896,6 +1966,7 @@ interface R2Conditional {
|
|
|
1896
1966
|
interface R2GetOptions {
|
|
1897
1967
|
onlyIf?: R2Conditional | Headers;
|
|
1898
1968
|
range?: R2Range | Headers;
|
|
1969
|
+
ssecKey?: ArrayBuffer | string;
|
|
1899
1970
|
}
|
|
1900
1971
|
interface R2PutOptions {
|
|
1901
1972
|
onlyIf?: R2Conditional | Headers;
|
|
@@ -1907,11 +1978,13 @@ interface R2PutOptions {
|
|
|
1907
1978
|
sha384?: ArrayBuffer | string;
|
|
1908
1979
|
sha512?: ArrayBuffer | string;
|
|
1909
1980
|
storageClass?: string;
|
|
1981
|
+
ssecKey?: ArrayBuffer | string;
|
|
1910
1982
|
}
|
|
1911
1983
|
interface R2MultipartOptions {
|
|
1912
1984
|
httpMetadata?: R2HTTPMetadata | Headers;
|
|
1913
1985
|
customMetadata?: Record<string, string>;
|
|
1914
1986
|
storageClass?: string;
|
|
1987
|
+
ssecKey?: ArrayBuffer | string;
|
|
1915
1988
|
}
|
|
1916
1989
|
interface R2Checksums {
|
|
1917
1990
|
readonly md5?: ArrayBuffer;
|
|
@@ -1948,6 +2021,9 @@ type R2Objects = {
|
|
|
1948
2021
|
truncated: false;
|
|
1949
2022
|
}
|
|
1950
2023
|
);
|
|
2024
|
+
interface R2UploadPartOptions {
|
|
2025
|
+
ssecKey?: ArrayBuffer | string;
|
|
2026
|
+
}
|
|
1951
2027
|
declare abstract class ScheduledEvent extends ExtendableEvent {
|
|
1952
2028
|
readonly scheduledTime: number;
|
|
1953
2029
|
readonly cron: string;
|
|
@@ -2358,6 +2434,8 @@ interface TraceItem {
|
|
|
2358
2434
|
readonly dispatchNamespace?: string;
|
|
2359
2435
|
readonly scriptTags?: string[];
|
|
2360
2436
|
readonly outcome: string;
|
|
2437
|
+
readonly executionModel: string;
|
|
2438
|
+
readonly truncated: boolean;
|
|
2361
2439
|
}
|
|
2362
2440
|
interface TraceItemAlarmEventInfo {
|
|
2363
2441
|
readonly scheduledTime: Date;
|
|
@@ -2651,8 +2729,24 @@ type WebSocketEventMap = {
|
|
|
2651
2729
|
*
|
|
2652
2730
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
|
|
2653
2731
|
*/
|
|
2654
|
-
declare
|
|
2655
|
-
|
|
2732
|
+
declare var WebSocket: {
|
|
2733
|
+
prototype: WebSocket;
|
|
2734
|
+
new (url: string, protocols?: string[] | string): WebSocket;
|
|
2735
|
+
readonly READY_STATE_CONNECTING: number;
|
|
2736
|
+
readonly CONNECTING: number;
|
|
2737
|
+
readonly READY_STATE_OPEN: number;
|
|
2738
|
+
readonly OPEN: number;
|
|
2739
|
+
readonly READY_STATE_CLOSING: number;
|
|
2740
|
+
readonly CLOSING: number;
|
|
2741
|
+
readonly READY_STATE_CLOSED: number;
|
|
2742
|
+
readonly CLOSED: number;
|
|
2743
|
+
};
|
|
2744
|
+
/**
|
|
2745
|
+
* Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
|
|
2746
|
+
*
|
|
2747
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
|
|
2748
|
+
*/
|
|
2749
|
+
interface WebSocket extends EventTarget<WebSocketEventMap> {
|
|
2656
2750
|
accept(): void;
|
|
2657
2751
|
/**
|
|
2658
2752
|
* Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
|
|
@@ -2668,14 +2762,6 @@ declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
2668
2762
|
close(code?: number, reason?: string): void;
|
|
2669
2763
|
serializeAttachment(attachment: any): void;
|
|
2670
2764
|
deserializeAttachment(): any | null;
|
|
2671
|
-
static readonly READY_STATE_CONNECTING: number;
|
|
2672
|
-
static readonly CONNECTING: number;
|
|
2673
|
-
static readonly READY_STATE_OPEN: number;
|
|
2674
|
-
static readonly OPEN: number;
|
|
2675
|
-
static readonly READY_STATE_CLOSING: number;
|
|
2676
|
-
static readonly CLOSING: number;
|
|
2677
|
-
static readonly READY_STATE_CLOSED: number;
|
|
2678
|
-
static readonly CLOSED: number;
|
|
2679
2765
|
/**
|
|
2680
2766
|
* Returns the state of the WebSocket object's connection. It can have the values described below.
|
|
2681
2767
|
*
|
|
@@ -2707,6 +2793,37 @@ declare const WebSocketPair: {
|
|
|
2707
2793
|
1: WebSocket;
|
|
2708
2794
|
};
|
|
2709
2795
|
};
|
|
2796
|
+
interface SqlStorage {
|
|
2797
|
+
exec<T extends Record<string, SqlStorageValue>>(
|
|
2798
|
+
query: string,
|
|
2799
|
+
...bindings: any[]
|
|
2800
|
+
): SqlStorageCursor<T>;
|
|
2801
|
+
get databaseSize(): number;
|
|
2802
|
+
Cursor: typeof SqlStorageCursor;
|
|
2803
|
+
Statement: typeof SqlStorageStatement;
|
|
2804
|
+
}
|
|
2805
|
+
declare abstract class SqlStorageStatement {}
|
|
2806
|
+
type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
2807
|
+
declare abstract class SqlStorageCursor<
|
|
2808
|
+
T extends Record<string, SqlStorageValue>,
|
|
2809
|
+
> {
|
|
2810
|
+
next():
|
|
2811
|
+
| {
|
|
2812
|
+
done?: false;
|
|
2813
|
+
value: T;
|
|
2814
|
+
}
|
|
2815
|
+
| {
|
|
2816
|
+
done: true;
|
|
2817
|
+
value?: never;
|
|
2818
|
+
};
|
|
2819
|
+
toArray(): T[];
|
|
2820
|
+
one(): T;
|
|
2821
|
+
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
|
|
2822
|
+
columnNames: string[];
|
|
2823
|
+
get rowsRead(): number;
|
|
2824
|
+
get rowsWritten(): number;
|
|
2825
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
2826
|
+
}
|
|
2710
2827
|
interface Socket {
|
|
2711
2828
|
get readable(): ReadableStream;
|
|
2712
2829
|
get writable(): WritableStream;
|
|
@@ -3237,7 +3354,7 @@ interface GPUOrigin3DDict {
|
|
|
3237
3354
|
z?: number;
|
|
3238
3355
|
}
|
|
3239
3356
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
|
|
3240
|
-
declare class EventSource {
|
|
3357
|
+
declare class EventSource extends EventTarget {
|
|
3241
3358
|
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3242
3359
|
/**
|
|
3243
3360
|
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
@@ -3336,10 +3453,10 @@ declare abstract class BaseAiSentenceSimilarity {
|
|
|
3336
3453
|
inputs: AiSentenceSimilarityInput;
|
|
3337
3454
|
postProcessedOutputs: AiSentenceSimilarityOutput;
|
|
3338
3455
|
}
|
|
3339
|
-
type
|
|
3456
|
+
type AiAutomaticSpeechRecognitionInput = {
|
|
3340
3457
|
audio: number[];
|
|
3341
3458
|
};
|
|
3342
|
-
type
|
|
3459
|
+
type AiAutomaticSpeechRecognitionOutput = {
|
|
3343
3460
|
text?: string;
|
|
3344
3461
|
words?: {
|
|
3345
3462
|
word: string;
|
|
@@ -3348,9 +3465,9 @@ type AiSpeechRecognitionOutput = {
|
|
|
3348
3465
|
}[];
|
|
3349
3466
|
vtt?: string;
|
|
3350
3467
|
};
|
|
3351
|
-
declare abstract class
|
|
3352
|
-
inputs:
|
|
3353
|
-
postProcessedOutputs:
|
|
3468
|
+
declare abstract class BaseAiAutomaticSpeechRecognition {
|
|
3469
|
+
inputs: AiAutomaticSpeechRecognitionInput;
|
|
3470
|
+
postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
|
|
3354
3471
|
}
|
|
3355
3472
|
type AiSummarizationInput = {
|
|
3356
3473
|
input_text: string;
|
|
@@ -3386,16 +3503,36 @@ declare abstract class BaseAiTextEmbeddings {
|
|
|
3386
3503
|
postProcessedOutputs: AiTextEmbeddingsOutput;
|
|
3387
3504
|
}
|
|
3388
3505
|
type RoleScopedChatInput = {
|
|
3389
|
-
role:
|
|
3506
|
+
role:
|
|
3507
|
+
| "user"
|
|
3508
|
+
| "assistant"
|
|
3509
|
+
| "system"
|
|
3510
|
+
| "tool"
|
|
3511
|
+
| (string & NonNullable<unknown>);
|
|
3390
3512
|
content: string;
|
|
3513
|
+
name?: string;
|
|
3514
|
+
};
|
|
3515
|
+
type AiTextGenerationToolLegacyInput = {
|
|
3516
|
+
name: string;
|
|
3517
|
+
description: string;
|
|
3518
|
+
parameters?: {
|
|
3519
|
+
type: "object" | (string & NonNullable<unknown>);
|
|
3520
|
+
properties: {
|
|
3521
|
+
[key: string]: {
|
|
3522
|
+
type: string;
|
|
3523
|
+
description?: string;
|
|
3524
|
+
};
|
|
3525
|
+
};
|
|
3526
|
+
required: string[];
|
|
3527
|
+
};
|
|
3391
3528
|
};
|
|
3392
3529
|
type AiTextGenerationToolInput = {
|
|
3393
|
-
type: "function";
|
|
3530
|
+
type: "function" | (string & NonNullable<unknown>);
|
|
3394
3531
|
function: {
|
|
3395
3532
|
name: string;
|
|
3396
3533
|
description: string;
|
|
3397
3534
|
parameters?: {
|
|
3398
|
-
type: "object";
|
|
3535
|
+
type: "object" | (string & NonNullable<unknown>);
|
|
3399
3536
|
properties: {
|
|
3400
3537
|
[key: string]: {
|
|
3401
3538
|
type: string;
|
|
@@ -3406,6 +3543,10 @@ type AiTextGenerationToolInput = {
|
|
|
3406
3543
|
};
|
|
3407
3544
|
};
|
|
3408
3545
|
};
|
|
3546
|
+
type AiTextGenerationFunctionsInput = {
|
|
3547
|
+
name: string;
|
|
3548
|
+
code: string;
|
|
3549
|
+
};
|
|
3409
3550
|
type AiTextGenerationInput = {
|
|
3410
3551
|
prompt?: string;
|
|
3411
3552
|
raw?: boolean;
|
|
@@ -3419,7 +3560,11 @@ type AiTextGenerationInput = {
|
|
|
3419
3560
|
frequency_penalty?: number;
|
|
3420
3561
|
presence_penalty?: number;
|
|
3421
3562
|
messages?: RoleScopedChatInput[];
|
|
3422
|
-
tools?:
|
|
3563
|
+
tools?:
|
|
3564
|
+
| AiTextGenerationToolInput[]
|
|
3565
|
+
| AiTextGenerationToolLegacyInput[]
|
|
3566
|
+
| (object & NonNullable<unknown>);
|
|
3567
|
+
functions?: AiTextGenerationFunctionsInput[];
|
|
3423
3568
|
};
|
|
3424
3569
|
type AiTextGenerationOutput =
|
|
3425
3570
|
| {
|
|
@@ -3434,15 +3579,33 @@ declare abstract class BaseAiTextGeneration {
|
|
|
3434
3579
|
inputs: AiTextGenerationInput;
|
|
3435
3580
|
postProcessedOutputs: AiTextGenerationOutput;
|
|
3436
3581
|
}
|
|
3582
|
+
type AiTextToSpeechInput = {
|
|
3583
|
+
prompt: string;
|
|
3584
|
+
lang?: string;
|
|
3585
|
+
};
|
|
3586
|
+
type AiTextToSpeechOutput =
|
|
3587
|
+
| Uint8Array
|
|
3588
|
+
| {
|
|
3589
|
+
audio: string;
|
|
3590
|
+
};
|
|
3591
|
+
declare abstract class BaseAiTextToSpeech {
|
|
3592
|
+
inputs: AiTextToSpeechInput;
|
|
3593
|
+
postProcessedOutputs: AiTextToSpeechOutput;
|
|
3594
|
+
}
|
|
3437
3595
|
type AiTextToImageInput = {
|
|
3438
3596
|
prompt: string;
|
|
3597
|
+
negative_prompt?: string;
|
|
3598
|
+
height?: number;
|
|
3599
|
+
width?: number;
|
|
3439
3600
|
image?: number[];
|
|
3601
|
+
image_b64?: string;
|
|
3440
3602
|
mask?: number[];
|
|
3441
3603
|
num_steps?: number;
|
|
3442
3604
|
strength?: number;
|
|
3443
3605
|
guidance?: number;
|
|
3606
|
+
seed?: number;
|
|
3444
3607
|
};
|
|
3445
|
-
type AiTextToImageOutput = Uint8Array
|
|
3608
|
+
type AiTextToImageOutput = ReadableStream<Uint8Array>;
|
|
3446
3609
|
declare abstract class BaseAiTextToImage {
|
|
3447
3610
|
inputs: AiTextToImageInput;
|
|
3448
3611
|
postProcessedOutputs: AiTextToImageOutput;
|
|
@@ -3459,126 +3622,613 @@ declare abstract class BaseAiTranslation {
|
|
|
3459
3622
|
inputs: AiTranslationInput;
|
|
3460
3623
|
postProcessedOutputs: AiTranslationOutput;
|
|
3461
3624
|
}
|
|
3625
|
+
type Ai_Cf_Openai_Whisper_Input =
|
|
3626
|
+
| string
|
|
3627
|
+
| {
|
|
3628
|
+
/**
|
|
3629
|
+
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
|
|
3630
|
+
*/
|
|
3631
|
+
audio: number[];
|
|
3632
|
+
};
|
|
3633
|
+
interface Ai_Cf_Openai_Whisper_Output {
|
|
3634
|
+
/**
|
|
3635
|
+
* The transcription
|
|
3636
|
+
*/
|
|
3637
|
+
text: string;
|
|
3638
|
+
word_count?: number;
|
|
3639
|
+
words?: {
|
|
3640
|
+
word?: string;
|
|
3641
|
+
/**
|
|
3642
|
+
* The second this word begins in the recording
|
|
3643
|
+
*/
|
|
3644
|
+
start?: number;
|
|
3645
|
+
/**
|
|
3646
|
+
* The ending second when the word completes
|
|
3647
|
+
*/
|
|
3648
|
+
end?: number;
|
|
3649
|
+
}[];
|
|
3650
|
+
vtt?: string;
|
|
3651
|
+
}
|
|
3652
|
+
declare abstract class Base_Ai_Cf_Openai_Whisper {
|
|
3653
|
+
inputs: Ai_Cf_Openai_Whisper_Input;
|
|
3654
|
+
postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
|
|
3655
|
+
}
|
|
3656
|
+
type Ai_Cf_Openai_Whisper_Tiny_En_Input =
|
|
3657
|
+
| string
|
|
3658
|
+
| {
|
|
3659
|
+
/**
|
|
3660
|
+
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
|
|
3661
|
+
*/
|
|
3662
|
+
audio: number[];
|
|
3663
|
+
};
|
|
3664
|
+
interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
|
|
3665
|
+
/**
|
|
3666
|
+
* The transcription
|
|
3667
|
+
*/
|
|
3668
|
+
text: string;
|
|
3669
|
+
word_count?: number;
|
|
3670
|
+
words?: {
|
|
3671
|
+
word?: string;
|
|
3672
|
+
/**
|
|
3673
|
+
* The second this word begins in the recording
|
|
3674
|
+
*/
|
|
3675
|
+
start?: number;
|
|
3676
|
+
/**
|
|
3677
|
+
* The ending second when the word completes
|
|
3678
|
+
*/
|
|
3679
|
+
end?: number;
|
|
3680
|
+
}[];
|
|
3681
|
+
vtt?: string;
|
|
3682
|
+
}
|
|
3683
|
+
declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
3684
|
+
inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
|
|
3685
|
+
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
3686
|
+
}
|
|
3687
|
+
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
3688
|
+
/**
|
|
3689
|
+
* Base64 encoded value of the audio data.
|
|
3690
|
+
*/
|
|
3691
|
+
audio: string;
|
|
3692
|
+
/**
|
|
3693
|
+
* Supported tasks are 'translate' or 'transcribe'.
|
|
3694
|
+
*/
|
|
3695
|
+
task?: string;
|
|
3696
|
+
/**
|
|
3697
|
+
* The language of the audio being transcribed or translated.
|
|
3698
|
+
*/
|
|
3699
|
+
language?: string;
|
|
3700
|
+
/**
|
|
3701
|
+
* Preprocess the audio with a voice activity detection model.
|
|
3702
|
+
*/
|
|
3703
|
+
vad_filter?: string;
|
|
3704
|
+
/**
|
|
3705
|
+
* A text prompt to help provide context to the model on the contents of the audio.
|
|
3706
|
+
*/
|
|
3707
|
+
initial_prompt?: string;
|
|
3708
|
+
/**
|
|
3709
|
+
* The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
|
|
3710
|
+
*/
|
|
3711
|
+
prefix?: string;
|
|
3712
|
+
}
|
|
3713
|
+
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
3714
|
+
transcription_info?: {
|
|
3715
|
+
/**
|
|
3716
|
+
* The language of the audio being transcribed or translated.
|
|
3717
|
+
*/
|
|
3718
|
+
language?: string;
|
|
3719
|
+
/**
|
|
3720
|
+
* The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
|
|
3721
|
+
*/
|
|
3722
|
+
language_probability?: number;
|
|
3723
|
+
/**
|
|
3724
|
+
* The total duration of the original audio file, in seconds.
|
|
3725
|
+
*/
|
|
3726
|
+
duration?: number;
|
|
3727
|
+
/**
|
|
3728
|
+
* The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
|
|
3729
|
+
*/
|
|
3730
|
+
duration_after_vad?: number;
|
|
3731
|
+
};
|
|
3732
|
+
/**
|
|
3733
|
+
* The complete transcription of the audio.
|
|
3734
|
+
*/
|
|
3735
|
+
text: string;
|
|
3736
|
+
/**
|
|
3737
|
+
* The total number of words in the transcription.
|
|
3738
|
+
*/
|
|
3739
|
+
word_count?: number;
|
|
3740
|
+
segments?: {
|
|
3741
|
+
/**
|
|
3742
|
+
* The starting time of the segment within the audio, in seconds.
|
|
3743
|
+
*/
|
|
3744
|
+
start?: number;
|
|
3745
|
+
/**
|
|
3746
|
+
* The ending time of the segment within the audio, in seconds.
|
|
3747
|
+
*/
|
|
3748
|
+
end?: number;
|
|
3749
|
+
/**
|
|
3750
|
+
* The transcription of the segment.
|
|
3751
|
+
*/
|
|
3752
|
+
text?: string;
|
|
3753
|
+
/**
|
|
3754
|
+
* The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
|
|
3755
|
+
*/
|
|
3756
|
+
temperature?: number;
|
|
3757
|
+
/**
|
|
3758
|
+
* The average log probability of the predictions for the words in this segment, indicating overall confidence.
|
|
3759
|
+
*/
|
|
3760
|
+
avg_logprob?: number;
|
|
3761
|
+
/**
|
|
3762
|
+
* The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
|
|
3763
|
+
*/
|
|
3764
|
+
compression_ratio?: number;
|
|
3765
|
+
/**
|
|
3766
|
+
* The probability that the segment contains no speech, represented as a decimal between 0 and 1.
|
|
3767
|
+
*/
|
|
3768
|
+
no_speech_prob?: number;
|
|
3769
|
+
words?: {
|
|
3770
|
+
/**
|
|
3771
|
+
* The individual word transcribed from the audio.
|
|
3772
|
+
*/
|
|
3773
|
+
word?: string;
|
|
3774
|
+
/**
|
|
3775
|
+
* The starting time of the word within the audio, in seconds.
|
|
3776
|
+
*/
|
|
3777
|
+
start?: number;
|
|
3778
|
+
/**
|
|
3779
|
+
* The ending time of the word within the audio, in seconds.
|
|
3780
|
+
*/
|
|
3781
|
+
end?: number;
|
|
3782
|
+
}[];
|
|
3783
|
+
};
|
|
3784
|
+
/**
|
|
3785
|
+
* The transcription in WebVTT format, which includes timing and text information for use in subtitles.
|
|
3786
|
+
*/
|
|
3787
|
+
vtt?: string;
|
|
3788
|
+
}
|
|
3789
|
+
declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
|
|
3790
|
+
inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
|
|
3791
|
+
postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
|
|
3792
|
+
}
|
|
3793
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
|
|
3794
|
+
/**
|
|
3795
|
+
* A text description of the image you want to generate.
|
|
3796
|
+
*/
|
|
3797
|
+
prompt: string;
|
|
3798
|
+
/**
|
|
3799
|
+
* The number of diffusion steps; higher values can improve quality but take longer.
|
|
3800
|
+
*/
|
|
3801
|
+
steps?: number;
|
|
3802
|
+
}
|
|
3803
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
|
|
3804
|
+
/**
|
|
3805
|
+
* The generated image in Base64 format.
|
|
3806
|
+
*/
|
|
3807
|
+
image?: string;
|
|
3808
|
+
}
|
|
3809
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
|
|
3810
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
|
|
3811
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
|
|
3812
|
+
}
|
|
3813
|
+
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
|
|
3814
|
+
interface Prompt {
|
|
3815
|
+
/**
|
|
3816
|
+
* The input text prompt for the model to generate a response.
|
|
3817
|
+
*/
|
|
3818
|
+
prompt: string;
|
|
3819
|
+
image?: number[] | (string & NonNullable<unknown>);
|
|
3820
|
+
/**
|
|
3821
|
+
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
|
|
3822
|
+
*/
|
|
3823
|
+
raw?: boolean;
|
|
3824
|
+
/**
|
|
3825
|
+
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
|
|
3826
|
+
*/
|
|
3827
|
+
stream?: boolean;
|
|
3828
|
+
/**
|
|
3829
|
+
* The maximum number of tokens to generate in the response.
|
|
3830
|
+
*/
|
|
3831
|
+
max_tokens?: number;
|
|
3832
|
+
/**
|
|
3833
|
+
* Controls the randomness of the output; higher values produce more random results.
|
|
3834
|
+
*/
|
|
3835
|
+
temperature?: number;
|
|
3836
|
+
/**
|
|
3837
|
+
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
|
|
3838
|
+
*/
|
|
3839
|
+
top_p?: number;
|
|
3840
|
+
/**
|
|
3841
|
+
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
|
|
3842
|
+
*/
|
|
3843
|
+
top_k?: number;
|
|
3844
|
+
/**
|
|
3845
|
+
* Random seed for reproducibility of the generation.
|
|
3846
|
+
*/
|
|
3847
|
+
seed?: number;
|
|
3848
|
+
/**
|
|
3849
|
+
* Penalty for repeated tokens; higher values discourage repetition.
|
|
3850
|
+
*/
|
|
3851
|
+
repetition_penalty?: number;
|
|
3852
|
+
/**
|
|
3853
|
+
* Decreases the likelihood of the model repeating the same lines verbatim.
|
|
3854
|
+
*/
|
|
3855
|
+
frequency_penalty?: number;
|
|
3856
|
+
/**
|
|
3857
|
+
* Increases the likelihood of the model introducing new topics.
|
|
3858
|
+
*/
|
|
3859
|
+
presence_penalty?: number;
|
|
3860
|
+
/**
|
|
3861
|
+
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
|
|
3862
|
+
*/
|
|
3863
|
+
lora?: string;
|
|
3864
|
+
}
|
|
3865
|
+
interface Messages {
|
|
3866
|
+
/**
|
|
3867
|
+
* An array of message objects representing the conversation history.
|
|
3868
|
+
*/
|
|
3869
|
+
messages: {
|
|
3870
|
+
/**
|
|
3871
|
+
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
3872
|
+
*/
|
|
3873
|
+
role: string;
|
|
3874
|
+
/**
|
|
3875
|
+
* The content of the message as a string.
|
|
3876
|
+
*/
|
|
3877
|
+
content: string;
|
|
3878
|
+
}[];
|
|
3879
|
+
image?: number[] | string;
|
|
3880
|
+
functions?: {
|
|
3881
|
+
name: string;
|
|
3882
|
+
code: string;
|
|
3883
|
+
}[];
|
|
3884
|
+
/**
|
|
3885
|
+
* A list of tools available for the assistant to use.
|
|
3886
|
+
*/
|
|
3887
|
+
tools?: (
|
|
3888
|
+
| {
|
|
3889
|
+
/**
|
|
3890
|
+
* The name of the tool. More descriptive the better.
|
|
3891
|
+
*/
|
|
3892
|
+
name: string;
|
|
3893
|
+
/**
|
|
3894
|
+
* A brief description of what the tool does.
|
|
3895
|
+
*/
|
|
3896
|
+
description: string;
|
|
3897
|
+
/**
|
|
3898
|
+
* Schema defining the parameters accepted by the tool.
|
|
3899
|
+
*/
|
|
3900
|
+
parameters: {
|
|
3901
|
+
/**
|
|
3902
|
+
* The type of the parameters object (usually 'object').
|
|
3903
|
+
*/
|
|
3904
|
+
type: string;
|
|
3905
|
+
/**
|
|
3906
|
+
* List of required parameter names.
|
|
3907
|
+
*/
|
|
3908
|
+
required?: string[];
|
|
3909
|
+
/**
|
|
3910
|
+
* Definitions of each parameter.
|
|
3911
|
+
*/
|
|
3912
|
+
properties: {
|
|
3913
|
+
[k: string]: {
|
|
3914
|
+
/**
|
|
3915
|
+
* The data type of the parameter.
|
|
3916
|
+
*/
|
|
3917
|
+
type: string;
|
|
3918
|
+
/**
|
|
3919
|
+
* A description of the expected parameter.
|
|
3920
|
+
*/
|
|
3921
|
+
description: string;
|
|
3922
|
+
};
|
|
3923
|
+
};
|
|
3924
|
+
};
|
|
3925
|
+
}
|
|
3926
|
+
| {
|
|
3927
|
+
/**
|
|
3928
|
+
* Specifies the type of tool (e.g., 'function').
|
|
3929
|
+
*/
|
|
3930
|
+
type: string;
|
|
3931
|
+
/**
|
|
3932
|
+
* Details of the function tool.
|
|
3933
|
+
*/
|
|
3934
|
+
function: {
|
|
3935
|
+
/**
|
|
3936
|
+
* The name of the function.
|
|
3937
|
+
*/
|
|
3938
|
+
name: string;
|
|
3939
|
+
/**
|
|
3940
|
+
* A brief description of what the function does.
|
|
3941
|
+
*/
|
|
3942
|
+
description: string;
|
|
3943
|
+
/**
|
|
3944
|
+
* Schema defining the parameters accepted by the function.
|
|
3945
|
+
*/
|
|
3946
|
+
parameters: {
|
|
3947
|
+
/**
|
|
3948
|
+
* The type of the parameters object (usually 'object').
|
|
3949
|
+
*/
|
|
3950
|
+
type: string;
|
|
3951
|
+
/**
|
|
3952
|
+
* List of required parameter names.
|
|
3953
|
+
*/
|
|
3954
|
+
required?: string[];
|
|
3955
|
+
/**
|
|
3956
|
+
* Definitions of each parameter.
|
|
3957
|
+
*/
|
|
3958
|
+
properties: {
|
|
3959
|
+
[k: string]: {
|
|
3960
|
+
/**
|
|
3961
|
+
* The data type of the parameter.
|
|
3962
|
+
*/
|
|
3963
|
+
type: string;
|
|
3964
|
+
/**
|
|
3965
|
+
* A description of the expected parameter.
|
|
3966
|
+
*/
|
|
3967
|
+
description: string;
|
|
3968
|
+
};
|
|
3969
|
+
};
|
|
3970
|
+
};
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
)[];
|
|
3974
|
+
/**
|
|
3975
|
+
* If true, the response will be streamed back incrementally.
|
|
3976
|
+
*/
|
|
3977
|
+
stream?: boolean;
|
|
3978
|
+
/**
|
|
3979
|
+
* The maximum number of tokens to generate in the response.
|
|
3980
|
+
*/
|
|
3981
|
+
max_tokens?: number;
|
|
3982
|
+
/**
|
|
3983
|
+
* Controls the randomness of the output; higher values produce more random results.
|
|
3984
|
+
*/
|
|
3985
|
+
temperature?: number;
|
|
3986
|
+
/**
|
|
3987
|
+
* Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
|
|
3988
|
+
*/
|
|
3989
|
+
top_p?: number;
|
|
3990
|
+
/**
|
|
3991
|
+
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
|
|
3992
|
+
*/
|
|
3993
|
+
top_k?: number;
|
|
3994
|
+
/**
|
|
3995
|
+
* Random seed for reproducibility of the generation.
|
|
3996
|
+
*/
|
|
3997
|
+
seed?: number;
|
|
3998
|
+
/**
|
|
3999
|
+
* Penalty for repeated tokens; higher values discourage repetition.
|
|
4000
|
+
*/
|
|
4001
|
+
repetition_penalty?: number;
|
|
4002
|
+
/**
|
|
4003
|
+
* Decreases the likelihood of the model repeating the same lines verbatim.
|
|
4004
|
+
*/
|
|
4005
|
+
frequency_penalty?: number;
|
|
4006
|
+
/**
|
|
4007
|
+
* Increases the likelihood of the model introducing new topics.
|
|
4008
|
+
*/
|
|
4009
|
+
presence_penalty?: number;
|
|
4010
|
+
}
|
|
4011
|
+
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output =
|
|
4012
|
+
| {
|
|
4013
|
+
/**
|
|
4014
|
+
* The generated text response from the model
|
|
4015
|
+
*/
|
|
4016
|
+
response?: string;
|
|
4017
|
+
/**
|
|
4018
|
+
* An array of tool calls requests made during the response generation
|
|
4019
|
+
*/
|
|
4020
|
+
tool_calls?: {
|
|
4021
|
+
/**
|
|
4022
|
+
* The arguments passed to be passed to the tool call request
|
|
4023
|
+
*/
|
|
4024
|
+
arguments?: object;
|
|
4025
|
+
/**
|
|
4026
|
+
* The name of the tool to be called
|
|
4027
|
+
*/
|
|
4028
|
+
name?: string;
|
|
4029
|
+
}[];
|
|
4030
|
+
}
|
|
4031
|
+
| ReadableStream;
|
|
4032
|
+
declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
|
|
4033
|
+
inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
|
|
4034
|
+
postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
|
|
4035
|
+
}
|
|
4036
|
+
interface AiModels {
|
|
4037
|
+
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
4038
|
+
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
4039
|
+
"@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
|
|
4040
|
+
"@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
|
|
4041
|
+
"@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
|
|
4042
|
+
"@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
|
|
4043
|
+
"@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings;
|
|
4044
|
+
"@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings;
|
|
4045
|
+
"@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings;
|
|
4046
|
+
"@cf/microsoft/resnet-50": BaseAiImageClassification;
|
|
4047
|
+
"@cf/facebook/detr-resnet-50": BaseAiObjectDetection;
|
|
4048
|
+
"@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
|
|
4049
|
+
"@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
|
|
4050
|
+
"@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
|
|
4051
|
+
"@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
|
|
4052
|
+
"@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
|
|
4053
|
+
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
4054
|
+
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
4055
|
+
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
4056
|
+
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
4057
|
+
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
4058
|
+
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
4059
|
+
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
4060
|
+
"@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
|
|
4061
|
+
"@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
|
|
4062
|
+
"@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
|
|
4063
|
+
"@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
|
|
4064
|
+
"@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
|
|
4065
|
+
"@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
|
|
4066
|
+
"@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
|
|
4067
|
+
"@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
|
|
4068
|
+
"@cf/microsoft/phi-2": BaseAiTextGeneration;
|
|
4069
|
+
"@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
|
|
4070
|
+
"@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
|
|
4071
|
+
"@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
|
|
4072
|
+
"@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
|
|
4073
|
+
"@hf/google/gemma-7b-it": BaseAiTextGeneration;
|
|
4074
|
+
"@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
|
|
4075
|
+
"@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
|
|
4076
|
+
"@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
|
|
4077
|
+
"@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
|
|
4078
|
+
"@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
|
|
4079
|
+
"@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
|
|
4080
|
+
"@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
|
|
4081
|
+
"@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
|
|
4082
|
+
"@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration;
|
|
4083
|
+
"@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
|
|
4084
|
+
"@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
|
|
4085
|
+
"@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
|
|
4086
|
+
"@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
|
|
4087
|
+
"@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration;
|
|
4088
|
+
"@cf/meta/m2m100-1.2b": BaseAiTranslation;
|
|
4089
|
+
"@cf/facebook/bart-large-cnn": BaseAiSummarization;
|
|
4090
|
+
"@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
|
|
4091
|
+
"@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
|
|
4092
|
+
"@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
|
|
4093
|
+
"@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
|
|
4094
|
+
"@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
|
|
4095
|
+
"@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
|
|
4096
|
+
"@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
|
|
4097
|
+
}
|
|
4098
|
+
type AiOptions = {
|
|
4099
|
+
gateway?: GatewayOptions;
|
|
4100
|
+
prefix?: string;
|
|
4101
|
+
extraHeaders?: object;
|
|
4102
|
+
};
|
|
4103
|
+
type AiModelsSearchParams = {
|
|
4104
|
+
author?: string;
|
|
4105
|
+
hide_experimental?: boolean;
|
|
4106
|
+
page?: number;
|
|
4107
|
+
per_page?: number;
|
|
4108
|
+
search?: string;
|
|
4109
|
+
source?: number;
|
|
4110
|
+
task?: string;
|
|
4111
|
+
};
|
|
4112
|
+
type AiModelsSearchObject = {
|
|
4113
|
+
id: string;
|
|
4114
|
+
source: number;
|
|
4115
|
+
name: string;
|
|
4116
|
+
description: string;
|
|
4117
|
+
task: {
|
|
4118
|
+
id: string;
|
|
4119
|
+
name: string;
|
|
4120
|
+
description: string;
|
|
4121
|
+
};
|
|
4122
|
+
tags: string[];
|
|
4123
|
+
properties: {
|
|
4124
|
+
property_id: string;
|
|
4125
|
+
value: string;
|
|
4126
|
+
}[];
|
|
4127
|
+
};
|
|
4128
|
+
interface InferenceUpstreamError extends Error {}
|
|
4129
|
+
interface AiInternalError extends Error {}
|
|
4130
|
+
type AiModelListType = Record<string, any>;
|
|
4131
|
+
declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
4132
|
+
aiGatewayLogId: string | null;
|
|
4133
|
+
gateway(gatewayId: string): AiGateway;
|
|
4134
|
+
run<Name extends keyof AiModelList>(
|
|
4135
|
+
model: Name,
|
|
4136
|
+
inputs: AiModelList[Name]["inputs"],
|
|
4137
|
+
options?: AiOptions,
|
|
4138
|
+
): Promise<AiModelList[Name]["postProcessedOutputs"]>;
|
|
4139
|
+
public models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
|
|
4140
|
+
}
|
|
3462
4141
|
type GatewayOptions = {
|
|
3463
4142
|
id: string;
|
|
4143
|
+
cacheKey?: string;
|
|
3464
4144
|
cacheTtl?: number;
|
|
3465
4145
|
skipCache?: boolean;
|
|
3466
4146
|
metadata?: Record<string, number | string | boolean | null | bigint>;
|
|
4147
|
+
collectLog?: boolean;
|
|
3467
4148
|
};
|
|
3468
|
-
type
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
4149
|
+
type AiGatewayPatchLog = {
|
|
4150
|
+
score?: number | null;
|
|
4151
|
+
feedback?: -1 | 1 | null;
|
|
4152
|
+
metadata?: Record<string, number | string | boolean | null | bigint> | null;
|
|
3472
4153
|
};
|
|
3473
|
-
type
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
| "
|
|
3502
|
-
| "
|
|
3503
|
-
| "
|
|
3504
|
-
| "
|
|
3505
|
-
| "
|
|
3506
|
-
| "
|
|
3507
|
-
| "
|
|
3508
|
-
| "
|
|
3509
|
-
| "
|
|
3510
|
-
| "
|
|
3511
|
-
| "
|
|
3512
|
-
| "
|
|
3513
|
-
| "
|
|
3514
|
-
| "
|
|
3515
|
-
| "
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
): Promise<
|
|
3547
|
-
|
|
3548
|
-
model: BaseAiSpeechRecognitionModels,
|
|
3549
|
-
inputs: BaseAiSpeechRecognition["inputs"],
|
|
3550
|
-
options?: AiOptions,
|
|
3551
|
-
): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
|
|
3552
|
-
run(
|
|
3553
|
-
model: BaseAiImageClassificationModels,
|
|
3554
|
-
inputs: BaseAiImageClassification["inputs"],
|
|
3555
|
-
options?: AiOptions,
|
|
3556
|
-
): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
|
|
3557
|
-
run(
|
|
3558
|
-
model: BaseAiObjectDetectionModels,
|
|
3559
|
-
inputs: BaseAiObjectDetection["inputs"],
|
|
3560
|
-
options?: AiOptions,
|
|
3561
|
-
): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
|
|
3562
|
-
run(
|
|
3563
|
-
model: BaseAiTextGenerationModels,
|
|
3564
|
-
inputs: BaseAiTextGeneration["inputs"],
|
|
3565
|
-
options?: AiOptions,
|
|
3566
|
-
): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
|
|
3567
|
-
run(
|
|
3568
|
-
model: BaseAiTranslationModels,
|
|
3569
|
-
inputs: BaseAiTranslation["inputs"],
|
|
3570
|
-
options?: AiOptions,
|
|
3571
|
-
): Promise<BaseAiTranslation["postProcessedOutputs"]>;
|
|
3572
|
-
run(
|
|
3573
|
-
model: BaseAiSummarizationModels,
|
|
3574
|
-
inputs: BaseAiSummarization["inputs"],
|
|
3575
|
-
options?: AiOptions,
|
|
3576
|
-
): Promise<BaseAiSummarization["postProcessedOutputs"]>;
|
|
4154
|
+
type AiGatewayLog = {
|
|
4155
|
+
id: string;
|
|
4156
|
+
provider: string;
|
|
4157
|
+
model: string;
|
|
4158
|
+
model_type?: string;
|
|
4159
|
+
path: string;
|
|
4160
|
+
duration: number;
|
|
4161
|
+
request_type?: string;
|
|
4162
|
+
request_content_type?: string;
|
|
4163
|
+
status_code: number;
|
|
4164
|
+
response_content_type?: string;
|
|
4165
|
+
success: boolean;
|
|
4166
|
+
cached: boolean;
|
|
4167
|
+
tokens_in?: number;
|
|
4168
|
+
tokens_out?: number;
|
|
4169
|
+
metadata?: Record<string, number | string | boolean | null | bigint>;
|
|
4170
|
+
step?: number;
|
|
4171
|
+
cost?: number;
|
|
4172
|
+
custom_cost?: boolean;
|
|
4173
|
+
request_size: number;
|
|
4174
|
+
request_head?: string;
|
|
4175
|
+
request_head_complete: boolean;
|
|
4176
|
+
response_size: number;
|
|
4177
|
+
response_head?: string;
|
|
4178
|
+
response_head_complete: boolean;
|
|
4179
|
+
created_at: Date;
|
|
4180
|
+
};
|
|
4181
|
+
type AIGatewayProviders =
|
|
4182
|
+
| "workers-ai"
|
|
4183
|
+
| "anthropic"
|
|
4184
|
+
| "aws-bedrock"
|
|
4185
|
+
| "azure-openai"
|
|
4186
|
+
| "google-vertex-ai"
|
|
4187
|
+
| "huggingface"
|
|
4188
|
+
| "openai"
|
|
4189
|
+
| "perplexity-ai"
|
|
4190
|
+
| "replicate"
|
|
4191
|
+
| "groq"
|
|
4192
|
+
| "cohere"
|
|
4193
|
+
| "google-ai-studio"
|
|
4194
|
+
| "mistral"
|
|
4195
|
+
| "grok"
|
|
4196
|
+
| "openrouter";
|
|
4197
|
+
type AIGatewayHeaders = {
|
|
4198
|
+
"cf-aig-metadata":
|
|
4199
|
+
| Record<string, number | string | boolean | null | bigint>
|
|
4200
|
+
| string;
|
|
4201
|
+
"cf-aig-custom-cost":
|
|
4202
|
+
| {
|
|
4203
|
+
per_token_in?: number;
|
|
4204
|
+
per_token_out?: number;
|
|
4205
|
+
}
|
|
4206
|
+
| {
|
|
4207
|
+
total_cost?: number;
|
|
4208
|
+
}
|
|
4209
|
+
| string;
|
|
4210
|
+
"cf-aig-cache-ttl": number | string;
|
|
4211
|
+
"cf-aig-skip-cache": boolean | string;
|
|
4212
|
+
"cf-aig-cache-key": string;
|
|
4213
|
+
"cf-aig-collect-log": boolean | string;
|
|
4214
|
+
Authorization: string;
|
|
4215
|
+
"Content-Type": string;
|
|
4216
|
+
[key: string]: string | number | boolean | object;
|
|
4217
|
+
};
|
|
4218
|
+
type AIGatewayUniversalRequest = {
|
|
4219
|
+
provider: AIGatewayProviders | string; // eslint-disable-line
|
|
4220
|
+
endpoint: string;
|
|
4221
|
+
headers: Partial<AIGatewayHeaders>;
|
|
4222
|
+
query: unknown;
|
|
4223
|
+
};
|
|
4224
|
+
interface AiGatewayInternalError extends Error {}
|
|
4225
|
+
interface AiGatewayLogNotFound extends Error {}
|
|
4226
|
+
declare abstract class AiGateway {
|
|
4227
|
+
patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
|
|
4228
|
+
getLog(logId: string): Promise<AiGatewayLog>;
|
|
3577
4229
|
run(
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
options?: AiOptions,
|
|
3581
|
-
): Promise<BaseAiImageToText["postProcessedOutputs"]>;
|
|
4230
|
+
data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
|
|
4231
|
+
): Promise<Response>;
|
|
3582
4232
|
}
|
|
3583
4233
|
interface BasicImageTransformations {
|
|
3584
4234
|
/**
|
|
@@ -4584,7 +5234,7 @@ declare abstract class D1PreparedStatement {
|
|
|
4584
5234
|
bind(...values: unknown[]): D1PreparedStatement;
|
|
4585
5235
|
first<T = unknown>(colName: string): Promise<T | null>;
|
|
4586
5236
|
first<T = Record<string, unknown>>(): Promise<T | null>;
|
|
4587
|
-
run(): Promise<
|
|
5237
|
+
run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
4588
5238
|
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
4589
5239
|
raw<T = unknown[]>(options: {
|
|
4590
5240
|
columnNames: true;
|
|
@@ -4640,6 +5290,12 @@ interface ForwardableEmailMessage extends EmailMessage {
|
|
|
4640
5290
|
* @returns A promise that resolves when the email message is forwarded.
|
|
4641
5291
|
*/
|
|
4642
5292
|
forward(rcptTo: string, headers?: Headers): Promise<void>;
|
|
5293
|
+
/**
|
|
5294
|
+
* Reply to the sender of this email message with a new EmailMessage object.
|
|
5295
|
+
* @param message The reply message.
|
|
5296
|
+
* @returns A promise that resolves when the email message is replied.
|
|
5297
|
+
*/
|
|
5298
|
+
reply(message: EmailMessage): Promise<void>;
|
|
4643
5299
|
}
|
|
4644
5300
|
/**
|
|
4645
5301
|
* A binding that allows a Worker to send email messages.
|
|
@@ -4709,6 +5365,128 @@ interface Hyperdrive {
|
|
|
4709
5365
|
*/
|
|
4710
5366
|
readonly database: string;
|
|
4711
5367
|
}
|
|
5368
|
+
// Copyright (c) 2024 Cloudflare, Inc.
|
|
5369
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5370
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5371
|
+
type ImageInfoResponse =
|
|
5372
|
+
| {
|
|
5373
|
+
format: "image/svg+xml";
|
|
5374
|
+
}
|
|
5375
|
+
| {
|
|
5376
|
+
format: string;
|
|
5377
|
+
fileSize: number;
|
|
5378
|
+
width: number;
|
|
5379
|
+
height: number;
|
|
5380
|
+
};
|
|
5381
|
+
type ImageTransform = {
|
|
5382
|
+
fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
|
|
5383
|
+
gravity?:
|
|
5384
|
+
| "left"
|
|
5385
|
+
| "right"
|
|
5386
|
+
| "top"
|
|
5387
|
+
| "bottom"
|
|
5388
|
+
| "center"
|
|
5389
|
+
| "auto"
|
|
5390
|
+
| "entropy"
|
|
5391
|
+
| "face"
|
|
5392
|
+
| {
|
|
5393
|
+
x?: number;
|
|
5394
|
+
y?: number;
|
|
5395
|
+
mode: "remainder" | "box-center";
|
|
5396
|
+
};
|
|
5397
|
+
trim?: {
|
|
5398
|
+
top?: number;
|
|
5399
|
+
bottom?: number;
|
|
5400
|
+
left?: number;
|
|
5401
|
+
right?: number;
|
|
5402
|
+
width?: number;
|
|
5403
|
+
height?: number;
|
|
5404
|
+
border?:
|
|
5405
|
+
| boolean
|
|
5406
|
+
| {
|
|
5407
|
+
color?: string;
|
|
5408
|
+
tolerance?: number;
|
|
5409
|
+
keep?: number;
|
|
5410
|
+
};
|
|
5411
|
+
};
|
|
5412
|
+
width?: number;
|
|
5413
|
+
height?: number;
|
|
5414
|
+
background?: string;
|
|
5415
|
+
rotate?: number;
|
|
5416
|
+
sharpen?: number;
|
|
5417
|
+
blur?: number;
|
|
5418
|
+
contrast?: number;
|
|
5419
|
+
brightness?: number;
|
|
5420
|
+
gamma?: number;
|
|
5421
|
+
border?: {
|
|
5422
|
+
color?: string;
|
|
5423
|
+
width?: number;
|
|
5424
|
+
top?: number;
|
|
5425
|
+
bottom?: number;
|
|
5426
|
+
left?: number;
|
|
5427
|
+
right?: number;
|
|
5428
|
+
};
|
|
5429
|
+
zoom?: number;
|
|
5430
|
+
};
|
|
5431
|
+
type ImageOutputOptions = {
|
|
5432
|
+
format:
|
|
5433
|
+
| "image/jpeg"
|
|
5434
|
+
| "image/png"
|
|
5435
|
+
| "image/gif"
|
|
5436
|
+
| "image/webp"
|
|
5437
|
+
| "image/avif"
|
|
5438
|
+
| "rgb"
|
|
5439
|
+
| "rgba";
|
|
5440
|
+
quality?: number;
|
|
5441
|
+
background?: string;
|
|
5442
|
+
};
|
|
5443
|
+
interface ImagesBinding {
|
|
5444
|
+
/**
|
|
5445
|
+
* Get image metadata (type, width and height)
|
|
5446
|
+
* @throws {@link ImagesError} with code 9412 if input is not an image
|
|
5447
|
+
* @param stream The image bytes
|
|
5448
|
+
*/
|
|
5449
|
+
info(stream: ReadableStream<Uint8Array>): Promise<ImageInfoResponse>;
|
|
5450
|
+
/**
|
|
5451
|
+
* Begin applying a series of transformations to an image
|
|
5452
|
+
* @param stream The image bytes
|
|
5453
|
+
* @returns A transform handle
|
|
5454
|
+
*/
|
|
5455
|
+
input(stream: ReadableStream<Uint8Array>): ImageTransformer;
|
|
5456
|
+
}
|
|
5457
|
+
interface ImageTransformer {
|
|
5458
|
+
/**
|
|
5459
|
+
* Apply transform next, returning a transform handle.
|
|
5460
|
+
* You can then apply more transformations or retrieve the output.
|
|
5461
|
+
* @param transform
|
|
5462
|
+
*/
|
|
5463
|
+
transform(transform: ImageTransform): ImageTransformer;
|
|
5464
|
+
/**
|
|
5465
|
+
* Retrieve the image that results from applying the transforms to the
|
|
5466
|
+
* provided input
|
|
5467
|
+
* @param options Options that apply to the output e.g. output format
|
|
5468
|
+
*/
|
|
5469
|
+
output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
|
|
5470
|
+
}
|
|
5471
|
+
interface ImageTransformationResult {
|
|
5472
|
+
/**
|
|
5473
|
+
* The image as a response, ready to store in cache or return to users
|
|
5474
|
+
*/
|
|
5475
|
+
response(): Response;
|
|
5476
|
+
/**
|
|
5477
|
+
* The content type of the returned image
|
|
5478
|
+
*/
|
|
5479
|
+
contentType(): string;
|
|
5480
|
+
/**
|
|
5481
|
+
* The bytes of the response
|
|
5482
|
+
*/
|
|
5483
|
+
image(): ReadableStream<Uint8Array>;
|
|
5484
|
+
}
|
|
5485
|
+
interface ImagesError extends Error {
|
|
5486
|
+
readonly code: number;
|
|
5487
|
+
readonly message: string;
|
|
5488
|
+
readonly stack?: string;
|
|
5489
|
+
}
|
|
4712
5490
|
type Params<P extends string = any> = Record<P, string | string[]>;
|
|
4713
5491
|
type EventContext<Env, P extends string, Data> = {
|
|
4714
5492
|
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
|
|
@@ -4755,6 +5533,30 @@ type PagesPluginFunction<
|
|
|
4755
5533
|
declare module "assets:*" {
|
|
4756
5534
|
export const onRequest: PagesFunction;
|
|
4757
5535
|
}
|
|
5536
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5537
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5538
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5539
|
+
declare abstract class PipelineTransform {
|
|
5540
|
+
/**
|
|
5541
|
+
* transformJson recieves an array of javascript objects which can be
|
|
5542
|
+
* mutated and returned to the pipeline
|
|
5543
|
+
* @param data The data to be mutated
|
|
5544
|
+
* @returns A promise containing the mutated data
|
|
5545
|
+
*/
|
|
5546
|
+
public transformJson(data: object[]): Promise<object[]>;
|
|
5547
|
+
}
|
|
5548
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5549
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5550
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5551
|
+
interface Pipeline {
|
|
5552
|
+
/**
|
|
5553
|
+
* send takes an array of javascript objects which are
|
|
5554
|
+
* then received by the pipeline for processing
|
|
5555
|
+
*
|
|
5556
|
+
* @param data The data to be sent
|
|
5557
|
+
*/
|
|
5558
|
+
send(data: object[]): Promise<void>;
|
|
5559
|
+
}
|
|
4758
5560
|
// PubSubMessage represents an incoming PubSub message.
|
|
4759
5561
|
// The message includes metadata about the broker, the client, and the payload
|
|
4760
5562
|
// itself.
|
|
@@ -4815,6 +5617,7 @@ declare namespace Rpc {
|
|
|
4815
5617
|
export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
|
|
4816
5618
|
export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
|
|
4817
5619
|
export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
|
|
5620
|
+
export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
|
|
4818
5621
|
export interface RpcTargetBranded {
|
|
4819
5622
|
[__RPC_TARGET_BRAND]: never;
|
|
4820
5623
|
}
|
|
@@ -4824,13 +5627,20 @@ declare namespace Rpc {
|
|
|
4824
5627
|
export interface DurableObjectBranded {
|
|
4825
5628
|
[__DURABLE_OBJECT_BRAND]: never;
|
|
4826
5629
|
}
|
|
5630
|
+
export interface WorkflowEntrypointBranded {
|
|
5631
|
+
[__WORKFLOW_ENTRYPOINT_BRAND]: never;
|
|
5632
|
+
}
|
|
4827
5633
|
export type EntrypointBranded =
|
|
4828
5634
|
| WorkerEntrypointBranded
|
|
4829
|
-
| DurableObjectBranded
|
|
5635
|
+
| DurableObjectBranded
|
|
5636
|
+
| WorkflowEntrypointBranded;
|
|
4830
5637
|
// Types that can be used through `Stub`s
|
|
4831
5638
|
export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
|
|
4832
5639
|
// Types that can be passed over RPC
|
|
4833
|
-
type
|
|
5640
|
+
// The reason for using a generic type here is to build a serializable subset of structured
|
|
5641
|
+
// cloneable composite types. This allows types defined with the "interface" keyword to pass the
|
|
5642
|
+
// serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
|
|
5643
|
+
type Serializable<T> =
|
|
4834
5644
|
// Structured cloneables
|
|
4835
5645
|
| void
|
|
4836
5646
|
| undefined
|
|
@@ -4846,11 +5656,14 @@ declare namespace Rpc {
|
|
|
4846
5656
|
| Error
|
|
4847
5657
|
| RegExp
|
|
4848
5658
|
// Structured cloneable composites
|
|
4849
|
-
| Map<
|
|
4850
|
-
|
|
4851
|
-
|
|
5659
|
+
| Map<
|
|
5660
|
+
T extends Map<infer U, unknown> ? Serializable<U> : never,
|
|
5661
|
+
T extends Map<unknown, infer U> ? Serializable<U> : never
|
|
5662
|
+
>
|
|
5663
|
+
| Set<T extends Set<infer U> ? Serializable<U> : never>
|
|
5664
|
+
| ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
|
|
4852
5665
|
| {
|
|
4853
|
-
[
|
|
5666
|
+
[K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
|
|
4854
5667
|
}
|
|
4855
5668
|
// Special types
|
|
4856
5669
|
| ReadableStream<Uint8Array>
|
|
@@ -4880,7 +5693,7 @@ declare namespace Rpc {
|
|
|
4880
5693
|
: T extends ReadonlyArray<infer V>
|
|
4881
5694
|
? ReadonlyArray<Stubify<V>>
|
|
4882
5695
|
: T extends {
|
|
4883
|
-
[key: string | number]:
|
|
5696
|
+
[key: string | number]: any;
|
|
4884
5697
|
}
|
|
4885
5698
|
? {
|
|
4886
5699
|
[K in keyof T]: Stubify<T[K]>;
|
|
@@ -4923,7 +5736,7 @@ declare namespace Rpc {
|
|
|
4923
5736
|
// Intersecting with `(Maybe)Provider` allows pipelining.
|
|
4924
5737
|
type Result<R> = R extends Stubable
|
|
4925
5738
|
? Promise<Stub<R>> & Provider<R>
|
|
4926
|
-
: R extends Serializable
|
|
5739
|
+
: R extends Serializable<R>
|
|
4927
5740
|
? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
|
|
4928
5741
|
: never;
|
|
4929
5742
|
// Type for method or property on an RPC interface.
|
|
@@ -4983,7 +5796,7 @@ declare module "cloudflare:workers" {
|
|
|
4983
5796
|
protected env: Env;
|
|
4984
5797
|
constructor(ctx: DurableObjectState, env: Env);
|
|
4985
5798
|
fetch?(request: Request): Response | Promise<Response>;
|
|
4986
|
-
alarm?(): void | Promise<void>;
|
|
5799
|
+
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
4987
5800
|
webSocketMessage?(
|
|
4988
5801
|
ws: WebSocket,
|
|
4989
5802
|
message: string | ArrayBuffer,
|
|
@@ -4996,6 +5809,60 @@ declare module "cloudflare:workers" {
|
|
|
4996
5809
|
): void | Promise<void>;
|
|
4997
5810
|
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
|
|
4998
5811
|
}
|
|
5812
|
+
export type WorkflowDurationLabel =
|
|
5813
|
+
| "second"
|
|
5814
|
+
| "minute"
|
|
5815
|
+
| "hour"
|
|
5816
|
+
| "day"
|
|
5817
|
+
| "week"
|
|
5818
|
+
| "month"
|
|
5819
|
+
| "year";
|
|
5820
|
+
export type WorkflowSleepDuration =
|
|
5821
|
+
| `${number} ${WorkflowDurationLabel}${"s" | ""}`
|
|
5822
|
+
| number;
|
|
5823
|
+
export type WorkflowDelayDuration = WorkflowSleepDuration;
|
|
5824
|
+
export type WorkflowTimeoutDuration = WorkflowSleepDuration;
|
|
5825
|
+
export type WorkflowBackoff = "constant" | "linear" | "exponential";
|
|
5826
|
+
export type WorkflowStepConfig = {
|
|
5827
|
+
retries?: {
|
|
5828
|
+
limit: number;
|
|
5829
|
+
delay: WorkflowDelayDuration | number;
|
|
5830
|
+
backoff?: WorkflowBackoff;
|
|
5831
|
+
};
|
|
5832
|
+
timeout?: WorkflowTimeoutDuration | number;
|
|
5833
|
+
};
|
|
5834
|
+
export type WorkflowEvent<T> = {
|
|
5835
|
+
payload: Readonly<T>;
|
|
5836
|
+
timestamp: Date;
|
|
5837
|
+
instanceId: string;
|
|
5838
|
+
};
|
|
5839
|
+
export abstract class WorkflowStep {
|
|
5840
|
+
do<T extends Rpc.Serializable<T>>(
|
|
5841
|
+
name: string,
|
|
5842
|
+
callback: () => Promise<T>,
|
|
5843
|
+
): Promise<T>;
|
|
5844
|
+
do<T extends Rpc.Serializable<T>>(
|
|
5845
|
+
name: string,
|
|
5846
|
+
config: WorkflowStepConfig,
|
|
5847
|
+
callback: () => Promise<T>,
|
|
5848
|
+
): Promise<T>;
|
|
5849
|
+
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
|
|
5850
|
+
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
|
|
5851
|
+
}
|
|
5852
|
+
export abstract class WorkflowEntrypoint<
|
|
5853
|
+
Env = unknown,
|
|
5854
|
+
T extends Rpc.Serializable<T> | unknown = unknown,
|
|
5855
|
+
> implements Rpc.WorkflowEntrypointBranded
|
|
5856
|
+
{
|
|
5857
|
+
[Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
|
|
5858
|
+
protected ctx: ExecutionContext;
|
|
5859
|
+
protected env: Env;
|
|
5860
|
+
constructor(ctx: ExecutionContext, env: Env);
|
|
5861
|
+
run(
|
|
5862
|
+
event: Readonly<WorkflowEvent<T>>,
|
|
5863
|
+
step: WorkflowStep,
|
|
5864
|
+
): Promise<unknown>;
|
|
5865
|
+
}
|
|
4999
5866
|
}
|
|
5000
5867
|
declare module "cloudflare:sockets" {
|
|
5001
5868
|
function _connect(
|
|
@@ -5004,6 +5871,198 @@ declare module "cloudflare:sockets" {
|
|
|
5004
5871
|
): Socket;
|
|
5005
5872
|
export { _connect as connect };
|
|
5006
5873
|
}
|
|
5874
|
+
declare namespace TailStream {
|
|
5875
|
+
interface Header {
|
|
5876
|
+
readonly name: string;
|
|
5877
|
+
readonly value: string;
|
|
5878
|
+
}
|
|
5879
|
+
interface FetchEventInfo {
|
|
5880
|
+
readonly type: "fetch";
|
|
5881
|
+
readonly method: string;
|
|
5882
|
+
readonly url: string;
|
|
5883
|
+
readonly cfJson: string;
|
|
5884
|
+
readonly headers: Header[];
|
|
5885
|
+
}
|
|
5886
|
+
interface JsRpcEventInfo {
|
|
5887
|
+
readonly type: "jsrpc";
|
|
5888
|
+
readonly methodName: string;
|
|
5889
|
+
}
|
|
5890
|
+
interface ScheduledEventInfo {
|
|
5891
|
+
readonly type: "scheduled";
|
|
5892
|
+
readonly scheduledTime: Date;
|
|
5893
|
+
readonly cron: string;
|
|
5894
|
+
}
|
|
5895
|
+
interface AlarmEventInfo {
|
|
5896
|
+
readonly type: "alarm";
|
|
5897
|
+
readonly scheduledTime: Date;
|
|
5898
|
+
}
|
|
5899
|
+
interface QueueEventInfo {
|
|
5900
|
+
readonly type: "queue";
|
|
5901
|
+
readonly queueName: string;
|
|
5902
|
+
readonly batchSize: number;
|
|
5903
|
+
}
|
|
5904
|
+
interface EmailEventInfo {
|
|
5905
|
+
readonly type: "email";
|
|
5906
|
+
readonly mailFrom: string;
|
|
5907
|
+
readonly rcptTo: string;
|
|
5908
|
+
readonly rawSize: number;
|
|
5909
|
+
}
|
|
5910
|
+
interface TraceEventInfo {
|
|
5911
|
+
readonly type: "trace";
|
|
5912
|
+
readonly traces: (string | null)[];
|
|
5913
|
+
}
|
|
5914
|
+
interface HibernatableWebSocketEventInfoMessage {
|
|
5915
|
+
readonly type: "message";
|
|
5916
|
+
}
|
|
5917
|
+
interface HibernatableWebSocketEventInfoError {
|
|
5918
|
+
readonly type: "error";
|
|
5919
|
+
}
|
|
5920
|
+
interface HibernatableWebSocketEventInfoClose {
|
|
5921
|
+
readonly type: "close";
|
|
5922
|
+
readonly code: number;
|
|
5923
|
+
readonly wasClean: boolean;
|
|
5924
|
+
}
|
|
5925
|
+
interface HibernatableWebSocketEventInfo {
|
|
5926
|
+
readonly type: "hibernatableWebSocket";
|
|
5927
|
+
readonly info:
|
|
5928
|
+
| HibernatableWebSocketEventInfoClose
|
|
5929
|
+
| HibernatableWebSocketEventInfoError
|
|
5930
|
+
| HibernatableWebSocketEventInfoMessage;
|
|
5931
|
+
}
|
|
5932
|
+
interface Resume {
|
|
5933
|
+
readonly type: "resume";
|
|
5934
|
+
readonly attachment?: any;
|
|
5935
|
+
}
|
|
5936
|
+
interface CustomEventInfo {
|
|
5937
|
+
readonly type: "custom";
|
|
5938
|
+
}
|
|
5939
|
+
interface FetchResponseInfo {
|
|
5940
|
+
readonly type: "fetch";
|
|
5941
|
+
readonly statusCode: number;
|
|
5942
|
+
}
|
|
5943
|
+
type EventOutcome =
|
|
5944
|
+
| "ok"
|
|
5945
|
+
| "canceled"
|
|
5946
|
+
| "exception"
|
|
5947
|
+
| "unknown"
|
|
5948
|
+
| "killSwitch"
|
|
5949
|
+
| "daemonDown"
|
|
5950
|
+
| "exceededCpu"
|
|
5951
|
+
| "exceededMemory"
|
|
5952
|
+
| "loadShed"
|
|
5953
|
+
| "responseStreamDisconnected"
|
|
5954
|
+
| "scriptNotFound";
|
|
5955
|
+
interface ScriptVersion {
|
|
5956
|
+
readonly id: string;
|
|
5957
|
+
readonly tag?: string;
|
|
5958
|
+
readonly message?: string;
|
|
5959
|
+
}
|
|
5960
|
+
interface Trigger {
|
|
5961
|
+
readonly traceId: string;
|
|
5962
|
+
readonly invocationId: string;
|
|
5963
|
+
readonly spanId: string;
|
|
5964
|
+
}
|
|
5965
|
+
interface Onset {
|
|
5966
|
+
readonly type: "onset";
|
|
5967
|
+
readonly dispatchNamespace?: string;
|
|
5968
|
+
readonly entrypoint?: string;
|
|
5969
|
+
readonly scriptName?: string;
|
|
5970
|
+
readonly scriptTags?: string[];
|
|
5971
|
+
readonly scriptVersion?: ScriptVersion;
|
|
5972
|
+
readonly trigger?: Trigger;
|
|
5973
|
+
readonly info:
|
|
5974
|
+
| FetchEventInfo
|
|
5975
|
+
| JsRpcEventInfo
|
|
5976
|
+
| ScheduledEventInfo
|
|
5977
|
+
| AlarmEventInfo
|
|
5978
|
+
| QueueEventInfo
|
|
5979
|
+
| EmailEventInfo
|
|
5980
|
+
| TraceEventInfo
|
|
5981
|
+
| HibernatableWebSocketEventInfo
|
|
5982
|
+
| Resume
|
|
5983
|
+
| CustomEventInfo;
|
|
5984
|
+
}
|
|
5985
|
+
interface Outcome {
|
|
5986
|
+
readonly type: "outcome";
|
|
5987
|
+
readonly outcome: EventOutcome;
|
|
5988
|
+
readonly cpuTime: number;
|
|
5989
|
+
readonly wallTime: number;
|
|
5990
|
+
}
|
|
5991
|
+
interface Hibernate {
|
|
5992
|
+
readonly type: "hibernate";
|
|
5993
|
+
}
|
|
5994
|
+
interface SpanOpen {
|
|
5995
|
+
readonly type: "spanOpen";
|
|
5996
|
+
readonly op?: string;
|
|
5997
|
+
readonly info?: FetchEventInfo | JsRpcEventInfo | Attribute[];
|
|
5998
|
+
}
|
|
5999
|
+
interface SpanClose {
|
|
6000
|
+
readonly type: "spanClose";
|
|
6001
|
+
readonly outcome: EventOutcome;
|
|
6002
|
+
}
|
|
6003
|
+
interface DiagnosticChannelEvent {
|
|
6004
|
+
readonly type: "diagnosticChannel";
|
|
6005
|
+
readonly channel: string;
|
|
6006
|
+
readonly message: any;
|
|
6007
|
+
}
|
|
6008
|
+
interface Exception {
|
|
6009
|
+
readonly type: "exception";
|
|
6010
|
+
readonly name: string;
|
|
6011
|
+
readonly message: string;
|
|
6012
|
+
readonly stack?: string;
|
|
6013
|
+
}
|
|
6014
|
+
interface Log {
|
|
6015
|
+
readonly type: "log";
|
|
6016
|
+
readonly level: "debug" | "error" | "info" | "log" | "warn";
|
|
6017
|
+
readonly message: string;
|
|
6018
|
+
}
|
|
6019
|
+
interface Return {
|
|
6020
|
+
readonly type: "return";
|
|
6021
|
+
readonly info?: FetchResponseInfo | Attribute[];
|
|
6022
|
+
}
|
|
6023
|
+
interface Link {
|
|
6024
|
+
readonly type: "link";
|
|
6025
|
+
readonly label?: string;
|
|
6026
|
+
readonly traceId: string;
|
|
6027
|
+
readonly invocationId: string;
|
|
6028
|
+
readonly spanId: string;
|
|
6029
|
+
}
|
|
6030
|
+
interface Attribute {
|
|
6031
|
+
readonly type: "attribute";
|
|
6032
|
+
readonly name: string;
|
|
6033
|
+
readonly value: string | string[] | boolean | boolean[] | number | number[];
|
|
6034
|
+
}
|
|
6035
|
+
type Mark =
|
|
6036
|
+
| DiagnosticChannelEvent
|
|
6037
|
+
| Exception
|
|
6038
|
+
| Log
|
|
6039
|
+
| Return
|
|
6040
|
+
| Link
|
|
6041
|
+
| Attribute[];
|
|
6042
|
+
interface TailEvent {
|
|
6043
|
+
readonly traceId: string;
|
|
6044
|
+
readonly invocationId: string;
|
|
6045
|
+
readonly spanId: string;
|
|
6046
|
+
readonly timestamp: Date;
|
|
6047
|
+
readonly sequence: number;
|
|
6048
|
+
readonly event: Onset | Outcome | Hibernate | SpanOpen | SpanClose | Mark;
|
|
6049
|
+
}
|
|
6050
|
+
type TailEventHandler = (event: TailEvent) => void | Promise<void>;
|
|
6051
|
+
type TailEventHandlerName =
|
|
6052
|
+
| "onset"
|
|
6053
|
+
| "outcome"
|
|
6054
|
+
| "hibernate"
|
|
6055
|
+
| "spanOpen"
|
|
6056
|
+
| "spanClose"
|
|
6057
|
+
| "diagnosticChannel"
|
|
6058
|
+
| "exception"
|
|
6059
|
+
| "log"
|
|
6060
|
+
| "return"
|
|
6061
|
+
| "link"
|
|
6062
|
+
| "attribute";
|
|
6063
|
+
type TailEventHandlerObject = Record<TailEventHandlerName, TailEventHandler>;
|
|
6064
|
+
type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
|
|
6065
|
+
}
|
|
5007
6066
|
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5008
6067
|
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5009
6068
|
// https://opensource.org/licenses/Apache-2.0
|
|
@@ -5047,11 +6106,21 @@ type VectorizeVectorMetadataFilter = {
|
|
|
5047
6106
|
* Distance metrics determine how other "similar" vectors are determined.
|
|
5048
6107
|
*/
|
|
5049
6108
|
type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
|
|
6109
|
+
/**
|
|
6110
|
+
* Metadata return levels for a Vectorize query.
|
|
6111
|
+
*
|
|
6112
|
+
* Default to "none".
|
|
6113
|
+
*
|
|
6114
|
+
* @property all Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data.
|
|
6115
|
+
* @property indexed Return all metadata fields configured for indexing in the vector return set. This level of retrieval is "free" in that no additional overhead is incurred returning this data. However, note that indexed metadata is subject to truncation (especially for larger strings).
|
|
6116
|
+
* @property none No indexed metadata will be returned.
|
|
6117
|
+
*/
|
|
6118
|
+
type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
|
|
5050
6119
|
interface VectorizeQueryOptions {
|
|
5051
6120
|
topK?: number;
|
|
5052
6121
|
namespace?: string;
|
|
5053
6122
|
returnValues?: boolean;
|
|
5054
|
-
returnMetadata?: boolean;
|
|
6123
|
+
returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
|
|
5055
6124
|
filter?: VectorizeVectorMetadataFilter;
|
|
5056
6125
|
}
|
|
5057
6126
|
/**
|
|
@@ -5067,6 +6136,9 @@ type VectorizeIndexConfig =
|
|
|
5067
6136
|
};
|
|
5068
6137
|
/**
|
|
5069
6138
|
* Metadata about an existing index.
|
|
6139
|
+
*
|
|
6140
|
+
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
|
|
6141
|
+
* See {@link VectorizeIndexInfo} for its post-beta equivalent.
|
|
5070
6142
|
*/
|
|
5071
6143
|
interface VectorizeIndexDetails {
|
|
5072
6144
|
/** The unique ID of the index */
|
|
@@ -5080,6 +6152,19 @@ interface VectorizeIndexDetails {
|
|
|
5080
6152
|
/** The number of records containing vectors within the index. */
|
|
5081
6153
|
vectorsCount: number;
|
|
5082
6154
|
}
|
|
6155
|
+
/**
|
|
6156
|
+
* Metadata about an existing index.
|
|
6157
|
+
*/
|
|
6158
|
+
interface VectorizeIndexInfo {
|
|
6159
|
+
/** The number of records containing vectors within the index. */
|
|
6160
|
+
vectorCount: number;
|
|
6161
|
+
/** Number of dimensions the index has been configured for. */
|
|
6162
|
+
dimensions: number;
|
|
6163
|
+
/** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
|
|
6164
|
+
processedUpToDatetime: number;
|
|
6165
|
+
/** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
|
|
6166
|
+
processedUpToMutation: number;
|
|
6167
|
+
}
|
|
5083
6168
|
/**
|
|
5084
6169
|
* Represents a single vector value set along with its associated metadata.
|
|
5085
6170
|
*/
|
|
@@ -5090,7 +6175,7 @@ interface VectorizeVector {
|
|
|
5090
6175
|
values: VectorFloatArray | number[];
|
|
5091
6176
|
/** The namespace this vector belongs to. */
|
|
5092
6177
|
namespace?: string;
|
|
5093
|
-
/** Metadata associated with the vector. Includes the values of
|
|
6178
|
+
/** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
|
|
5094
6179
|
metadata?: Record<string, VectorizeVectorMetadata>;
|
|
5095
6180
|
}
|
|
5096
6181
|
/**
|
|
@@ -5102,7 +6187,7 @@ type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
|
|
|
5102
6187
|
score: number;
|
|
5103
6188
|
};
|
|
5104
6189
|
/**
|
|
5105
|
-
* A set of
|
|
6190
|
+
* A set of matching {@link VectorizeMatch} for a particular query.
|
|
5106
6191
|
*/
|
|
5107
6192
|
interface VectorizeMatches {
|
|
5108
6193
|
matches: VectorizeMatch[];
|
|
@@ -5111,6 +6196,9 @@ interface VectorizeMatches {
|
|
|
5111
6196
|
/**
|
|
5112
6197
|
* Results of an operation that performed a mutation on a set of vectors.
|
|
5113
6198
|
* Here, `ids` is a list of vectors that were successfully processed.
|
|
6199
|
+
*
|
|
6200
|
+
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
|
|
6201
|
+
* See {@link VectorizeAsyncMutation} for its post-beta equivalent.
|
|
5114
6202
|
*/
|
|
5115
6203
|
interface VectorizeVectorMutation {
|
|
5116
6204
|
/* List of ids of vectors that were successfully processed. */
|
|
@@ -5119,14 +6207,19 @@ interface VectorizeVectorMutation {
|
|
|
5119
6207
|
count: number;
|
|
5120
6208
|
}
|
|
5121
6209
|
/**
|
|
5122
|
-
*
|
|
5123
|
-
*
|
|
5124
|
-
* Here, `mutationId` is the identifier for the last mutation processed by Vectorize.
|
|
6210
|
+
* Result type indicating a mutation on the Vectorize Index.
|
|
6211
|
+
* Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
|
|
5125
6212
|
*/
|
|
5126
|
-
interface
|
|
5127
|
-
|
|
6213
|
+
interface VectorizeAsyncMutation {
|
|
6214
|
+
/** The unique identifier for the async mutation operation containing the changeset. */
|
|
5128
6215
|
mutationId: string;
|
|
5129
6216
|
}
|
|
6217
|
+
/**
|
|
6218
|
+
* A Vectorize Vector Search Index for querying vectors/embeddings.
|
|
6219
|
+
*
|
|
6220
|
+
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
|
|
6221
|
+
* See {@link Vectorize} for its new implementation.
|
|
6222
|
+
*/
|
|
5130
6223
|
declare abstract class VectorizeIndex {
|
|
5131
6224
|
/**
|
|
5132
6225
|
* Get information about the currently bound index.
|
|
@@ -5141,7 +6234,7 @@ declare abstract class VectorizeIndex {
|
|
|
5141
6234
|
*/
|
|
5142
6235
|
public query(
|
|
5143
6236
|
vector: VectorFloatArray | number[],
|
|
5144
|
-
options
|
|
6237
|
+
options?: VectorizeQueryOptions,
|
|
5145
6238
|
): Promise<VectorizeMatches>;
|
|
5146
6239
|
/**
|
|
5147
6240
|
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
@@ -5168,6 +6261,62 @@ declare abstract class VectorizeIndex {
|
|
|
5168
6261
|
*/
|
|
5169
6262
|
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
5170
6263
|
}
|
|
6264
|
+
/**
|
|
6265
|
+
* A Vectorize Vector Search Index for querying vectors/embeddings.
|
|
6266
|
+
*
|
|
6267
|
+
* Mutations in this version are async, returning a mutation id.
|
|
6268
|
+
*/
|
|
6269
|
+
declare abstract class Vectorize {
|
|
6270
|
+
/**
|
|
6271
|
+
* Get information about the currently bound index.
|
|
6272
|
+
* @returns A promise that resolves with information about the current index.
|
|
6273
|
+
*/
|
|
6274
|
+
public describe(): Promise<VectorizeIndexInfo>;
|
|
6275
|
+
/**
|
|
6276
|
+
* Use the provided vector to perform a similarity search across the index.
|
|
6277
|
+
* @param vector Input vector that will be used to drive the similarity search.
|
|
6278
|
+
* @param options Configuration options to massage the returned data.
|
|
6279
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
6280
|
+
*/
|
|
6281
|
+
public query(
|
|
6282
|
+
vector: VectorFloatArray | number[],
|
|
6283
|
+
options?: VectorizeQueryOptions,
|
|
6284
|
+
): Promise<VectorizeMatches>;
|
|
6285
|
+
/**
|
|
6286
|
+
* Use the provided vector-id to perform a similarity search across the index.
|
|
6287
|
+
* @param vectorId Id for a vector in the index against which the index should be queried.
|
|
6288
|
+
* @param options Configuration options to massage the returned data.
|
|
6289
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
6290
|
+
*/
|
|
6291
|
+
public queryById(
|
|
6292
|
+
vectorId: string,
|
|
6293
|
+
options?: VectorizeQueryOptions,
|
|
6294
|
+
): Promise<VectorizeMatches>;
|
|
6295
|
+
/**
|
|
6296
|
+
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
6297
|
+
* @param vectors List of vectors that will be inserted.
|
|
6298
|
+
* @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
|
|
6299
|
+
*/
|
|
6300
|
+
public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
|
|
6301
|
+
/**
|
|
6302
|
+
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
|
|
6303
|
+
* @param vectors List of vectors that will be upserted.
|
|
6304
|
+
* @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
|
|
6305
|
+
*/
|
|
6306
|
+
public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
|
|
6307
|
+
/**
|
|
6308
|
+
* Delete a list of vectors with a matching id.
|
|
6309
|
+
* @param ids List of vector ids that should be deleted.
|
|
6310
|
+
* @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
|
|
6311
|
+
*/
|
|
6312
|
+
public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
|
|
6313
|
+
/**
|
|
6314
|
+
* Get a list of vectors with a matching id.
|
|
6315
|
+
* @param ids List of vector ids that should be returned.
|
|
6316
|
+
* @returns A promise that resolves with the raw unscored vectors matching the id set.
|
|
6317
|
+
*/
|
|
6318
|
+
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
6319
|
+
}
|
|
5171
6320
|
/**
|
|
5172
6321
|
* The interface for "version_metadata" binding
|
|
5173
6322
|
* providing metadata about the Worker Version using this binding.
|
|
@@ -5218,3 +6367,79 @@ interface DispatchNamespace {
|
|
|
5218
6367
|
options?: DynamicDispatchOptions,
|
|
5219
6368
|
): Fetcher;
|
|
5220
6369
|
}
|
|
6370
|
+
declare module "cloudflare:workflows" {
|
|
6371
|
+
/**
|
|
6372
|
+
* NonRetryableError allows for a user to throw a fatal error
|
|
6373
|
+
* that makes a Workflow instance fail immediately without triggering a retry
|
|
6374
|
+
*/
|
|
6375
|
+
export class NonRetryableError extends Error {
|
|
6376
|
+
public constructor(message: string, name?: string);
|
|
6377
|
+
}
|
|
6378
|
+
}
|
|
6379
|
+
declare abstract class Workflow<PARAMS = unknown> {
|
|
6380
|
+
/**
|
|
6381
|
+
* Get a handle to an existing instance of the Workflow.
|
|
6382
|
+
* @param id Id for the instance of this Workflow
|
|
6383
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
6384
|
+
*/
|
|
6385
|
+
public get(id: string): Promise<WorkflowInstance>;
|
|
6386
|
+
/**
|
|
6387
|
+
* Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
|
|
6388
|
+
* @param options Options when creating an instance including id and params
|
|
6389
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
6390
|
+
*/
|
|
6391
|
+
public create(
|
|
6392
|
+
options?: WorkflowInstanceCreateOptions<PARAMS>,
|
|
6393
|
+
): Promise<WorkflowInstance>;
|
|
6394
|
+
}
|
|
6395
|
+
interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
|
|
6396
|
+
/**
|
|
6397
|
+
* An id for your Workflow instance. Must be unique within the Workflow.
|
|
6398
|
+
*/
|
|
6399
|
+
id?: string;
|
|
6400
|
+
/**
|
|
6401
|
+
* The event payload the Workflow instance is triggered with
|
|
6402
|
+
*/
|
|
6403
|
+
params?: PARAMS;
|
|
6404
|
+
}
|
|
6405
|
+
type InstanceStatus = {
|
|
6406
|
+
status:
|
|
6407
|
+
| "queued" // means that instance is waiting to be started (see concurrency limits)
|
|
6408
|
+
| "running"
|
|
6409
|
+
| "paused"
|
|
6410
|
+
| "errored"
|
|
6411
|
+
| "terminated" // user terminated the instance while it was running
|
|
6412
|
+
| "complete"
|
|
6413
|
+
| "waiting" // instance is hibernating and waiting for sleep or event to finish
|
|
6414
|
+
| "waitingForPause" // instance is finishing the current work to pause
|
|
6415
|
+
| "unknown";
|
|
6416
|
+
error?: string;
|
|
6417
|
+
output?: object;
|
|
6418
|
+
};
|
|
6419
|
+
interface WorkflowError {
|
|
6420
|
+
code?: number;
|
|
6421
|
+
message: string;
|
|
6422
|
+
}
|
|
6423
|
+
declare abstract class WorkflowInstance {
|
|
6424
|
+
public id: string;
|
|
6425
|
+
/**
|
|
6426
|
+
* Pause the instance.
|
|
6427
|
+
*/
|
|
6428
|
+
public pause(): Promise<void>;
|
|
6429
|
+
/**
|
|
6430
|
+
* Resume the instance. If it is already running, an error will be thrown.
|
|
6431
|
+
*/
|
|
6432
|
+
public resume(): Promise<void>;
|
|
6433
|
+
/**
|
|
6434
|
+
* Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
|
|
6435
|
+
*/
|
|
6436
|
+
public terminate(): Promise<void>;
|
|
6437
|
+
/**
|
|
6438
|
+
* Restart the instance.
|
|
6439
|
+
*/
|
|
6440
|
+
public restart(): Promise<void>;
|
|
6441
|
+
/**
|
|
6442
|
+
* Returns the current status of the instance.
|
|
6443
|
+
*/
|
|
6444
|
+
public status(): Promise<InstanceStatus>;
|
|
6445
|
+
}
|