@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/2022-01-31/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;
|
|
@@ -971,14 +989,17 @@ declare abstract class CacheStorage {
|
|
|
971
989
|
*/
|
|
972
990
|
declare abstract class Cache {
|
|
973
991
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
|
|
974
|
-
delete(
|
|
992
|
+
delete(
|
|
993
|
+
request: RequestInfo | URL,
|
|
994
|
+
options?: CacheQueryOptions,
|
|
995
|
+
): Promise<boolean>;
|
|
975
996
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
|
|
976
997
|
match(
|
|
977
|
-
request: RequestInfo,
|
|
998
|
+
request: RequestInfo | URL,
|
|
978
999
|
options?: CacheQueryOptions,
|
|
979
1000
|
): Promise<Response | undefined>;
|
|
980
1001
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
|
|
981
|
-
put(request: RequestInfo, response: Response): Promise<void>;
|
|
1002
|
+
put(request: RequestInfo | URL, response: Response): Promise<void>;
|
|
982
1003
|
}
|
|
983
1004
|
interface CacheQueryOptions {
|
|
984
1005
|
ignoreMethod?: boolean;
|
|
@@ -1401,20 +1422,44 @@ interface Element {
|
|
|
1401
1422
|
hasAttribute(name: string): boolean;
|
|
1402
1423
|
setAttribute(name: string, value: string): Element;
|
|
1403
1424
|
removeAttribute(name: string): Element;
|
|
1404
|
-
before(
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1425
|
+
before(
|
|
1426
|
+
content: string | ReadableStream | Response,
|
|
1427
|
+
options?: ContentOptions,
|
|
1428
|
+
): Element;
|
|
1429
|
+
after(
|
|
1430
|
+
content: string | ReadableStream | Response,
|
|
1431
|
+
options?: ContentOptions,
|
|
1432
|
+
): Element;
|
|
1433
|
+
prepend(
|
|
1434
|
+
content: string | ReadableStream | Response,
|
|
1435
|
+
options?: ContentOptions,
|
|
1436
|
+
): Element;
|
|
1437
|
+
append(
|
|
1438
|
+
content: string | ReadableStream | Response,
|
|
1439
|
+
options?: ContentOptions,
|
|
1440
|
+
): Element;
|
|
1441
|
+
replace(
|
|
1442
|
+
content: string | ReadableStream | Response,
|
|
1443
|
+
options?: ContentOptions,
|
|
1444
|
+
): Element;
|
|
1409
1445
|
remove(): Element;
|
|
1410
1446
|
removeAndKeepContent(): Element;
|
|
1411
|
-
setInnerContent(
|
|
1447
|
+
setInnerContent(
|
|
1448
|
+
content: string | ReadableStream | Response,
|
|
1449
|
+
options?: ContentOptions,
|
|
1450
|
+
): Element;
|
|
1412
1451
|
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
|
|
1413
1452
|
}
|
|
1414
1453
|
interface EndTag {
|
|
1415
1454
|
name: string;
|
|
1416
|
-
before(
|
|
1417
|
-
|
|
1455
|
+
before(
|
|
1456
|
+
content: string | ReadableStream | Response,
|
|
1457
|
+
options?: ContentOptions,
|
|
1458
|
+
): EndTag;
|
|
1459
|
+
after(
|
|
1460
|
+
content: string | ReadableStream | Response,
|
|
1461
|
+
options?: ContentOptions,
|
|
1462
|
+
): EndTag;
|
|
1418
1463
|
remove(): EndTag;
|
|
1419
1464
|
}
|
|
1420
1465
|
interface Comment {
|
|
@@ -1429,9 +1474,18 @@ interface Text {
|
|
|
1429
1474
|
readonly text: string;
|
|
1430
1475
|
readonly lastInTextNode: boolean;
|
|
1431
1476
|
readonly removed: boolean;
|
|
1432
|
-
before(
|
|
1433
|
-
|
|
1434
|
-
|
|
1477
|
+
before(
|
|
1478
|
+
content: string | ReadableStream | Response,
|
|
1479
|
+
options?: ContentOptions,
|
|
1480
|
+
): Text;
|
|
1481
|
+
after(
|
|
1482
|
+
content: string | ReadableStream | Response,
|
|
1483
|
+
options?: ContentOptions,
|
|
1484
|
+
): Text;
|
|
1485
|
+
replace(
|
|
1486
|
+
content: string | ReadableStream | Response,
|
|
1487
|
+
options?: ContentOptions,
|
|
1488
|
+
): Text;
|
|
1435
1489
|
remove(): Text;
|
|
1436
1490
|
}
|
|
1437
1491
|
interface DocumentEnd {
|
|
@@ -1513,28 +1567,34 @@ declare abstract class Body {
|
|
|
1513
1567
|
*
|
|
1514
1568
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1515
1569
|
*/
|
|
1516
|
-
declare
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1570
|
+
declare var Response: {
|
|
1571
|
+
prototype: Response;
|
|
1572
|
+
new (body?: BodyInit | null, init?: ResponseInit): Response;
|
|
1573
|
+
redirect(url: string, status?: number): Response;
|
|
1574
|
+
json(any: any, maybeInit?: ResponseInit | Response): Response;
|
|
1575
|
+
};
|
|
1576
|
+
/**
|
|
1577
|
+
* This Fetch API interface represents the response to a request.
|
|
1578
|
+
*
|
|
1579
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1580
|
+
*/
|
|
1581
|
+
interface Response extends Body {
|
|
1522
1582
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
|
|
1523
1583
|
clone(): Response;
|
|
1524
1584
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
|
|
1525
|
-
|
|
1585
|
+
status: number;
|
|
1526
1586
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
|
|
1527
|
-
|
|
1587
|
+
statusText: string;
|
|
1528
1588
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
|
|
1529
|
-
|
|
1589
|
+
headers: Headers;
|
|
1530
1590
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
|
|
1531
|
-
|
|
1591
|
+
ok: boolean;
|
|
1532
1592
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
|
|
1533
|
-
|
|
1593
|
+
redirected: boolean;
|
|
1534
1594
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1595
|
+
url: string;
|
|
1596
|
+
webSocket: WebSocket | null;
|
|
1597
|
+
cf: any | undefined;
|
|
1538
1598
|
}
|
|
1539
1599
|
interface ResponseInit {
|
|
1540
1600
|
status?: number;
|
|
@@ -1546,18 +1606,26 @@ interface ResponseInit {
|
|
|
1546
1606
|
}
|
|
1547
1607
|
type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
|
|
1548
1608
|
| Request<CfHostMetadata, Cf>
|
|
1549
|
-
| string
|
|
1550
|
-
| URL;
|
|
1609
|
+
| string;
|
|
1551
1610
|
/**
|
|
1552
1611
|
* This Fetch API interface represents a resource request.
|
|
1553
1612
|
*
|
|
1554
1613
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
|
|
1555
1614
|
*/
|
|
1556
|
-
declare
|
|
1557
|
-
|
|
1558
|
-
Cf = CfProperties<CfHostMetadata
|
|
1559
|
-
>
|
|
1560
|
-
|
|
1615
|
+
declare var Request: {
|
|
1616
|
+
prototype: Request;
|
|
1617
|
+
new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
|
|
1618
|
+
input: RequestInfo<CfProperties> | URL,
|
|
1619
|
+
init?: RequestInit<Cf>,
|
|
1620
|
+
): Request<CfHostMetadata, Cf>;
|
|
1621
|
+
};
|
|
1622
|
+
/**
|
|
1623
|
+
* This Fetch API interface represents a resource request.
|
|
1624
|
+
*
|
|
1625
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
|
|
1626
|
+
*/
|
|
1627
|
+
interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>
|
|
1628
|
+
extends Body {
|
|
1561
1629
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
|
|
1562
1630
|
clone(): Request<CfHostMetadata, Cf>;
|
|
1563
1631
|
/**
|
|
@@ -1565,45 +1633,45 @@ declare class Request<
|
|
|
1565
1633
|
*
|
|
1566
1634
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
|
|
1567
1635
|
*/
|
|
1568
|
-
|
|
1636
|
+
method: string;
|
|
1569
1637
|
/**
|
|
1570
1638
|
* Returns the URL of request as a string.
|
|
1571
1639
|
*
|
|
1572
1640
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
|
|
1573
1641
|
*/
|
|
1574
|
-
|
|
1642
|
+
url: string;
|
|
1575
1643
|
/**
|
|
1576
1644
|
* Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
|
|
1577
1645
|
*
|
|
1578
1646
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
|
|
1579
1647
|
*/
|
|
1580
|
-
|
|
1648
|
+
headers: Headers;
|
|
1581
1649
|
/**
|
|
1582
1650
|
* Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.
|
|
1583
1651
|
*
|
|
1584
1652
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
|
|
1585
1653
|
*/
|
|
1586
|
-
|
|
1587
|
-
|
|
1654
|
+
redirect: string;
|
|
1655
|
+
fetcher: Fetcher | null;
|
|
1588
1656
|
/**
|
|
1589
1657
|
* Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
|
|
1590
1658
|
*
|
|
1591
1659
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
|
|
1592
1660
|
*/
|
|
1593
|
-
|
|
1594
|
-
|
|
1661
|
+
signal: AbortSignal;
|
|
1662
|
+
cf: Cf | undefined;
|
|
1595
1663
|
/**
|
|
1596
1664
|
* Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]
|
|
1597
1665
|
*
|
|
1598
1666
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
|
|
1599
1667
|
*/
|
|
1600
|
-
|
|
1668
|
+
integrity: string;
|
|
1601
1669
|
/**
|
|
1602
1670
|
* Returns a boolean indicating whether or not request can outlive the global in which it was created.
|
|
1603
1671
|
*
|
|
1604
1672
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
|
|
1605
1673
|
*/
|
|
1606
|
-
|
|
1674
|
+
keepalive: boolean;
|
|
1607
1675
|
}
|
|
1608
1676
|
interface RequestInit<Cf = CfProperties> {
|
|
1609
1677
|
/* A string to set request's method. */
|
|
@@ -1629,7 +1697,7 @@ type Fetcher<
|
|
|
1629
1697
|
> = (T extends Rpc.EntrypointBranded
|
|
1630
1698
|
? Rpc.Provider<T, Reserved | "fetch" | "connect">
|
|
1631
1699
|
: unknown) & {
|
|
1632
|
-
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1700
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
1633
1701
|
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1634
1702
|
};
|
|
1635
1703
|
interface FetcherPutOptions {
|
|
@@ -1850,6 +1918,7 @@ interface R2MultipartUpload {
|
|
|
1850
1918
|
uploadPart(
|
|
1851
1919
|
partNumber: number,
|
|
1852
1920
|
value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
|
|
1921
|
+
options?: R2UploadPartOptions,
|
|
1853
1922
|
): Promise<R2UploadedPart>;
|
|
1854
1923
|
abort(): Promise<void>;
|
|
1855
1924
|
complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
|
|
@@ -1870,6 +1939,7 @@ declare abstract class R2Object {
|
|
|
1870
1939
|
readonly customMetadata?: Record<string, string>;
|
|
1871
1940
|
readonly range?: R2Range;
|
|
1872
1941
|
readonly storageClass: string;
|
|
1942
|
+
readonly ssecKeyMd5?: string;
|
|
1873
1943
|
writeHttpMetadata(headers: Headers): void;
|
|
1874
1944
|
}
|
|
1875
1945
|
interface R2ObjectBody extends R2Object {
|
|
@@ -1902,6 +1972,7 @@ interface R2Conditional {
|
|
|
1902
1972
|
interface R2GetOptions {
|
|
1903
1973
|
onlyIf?: R2Conditional | Headers;
|
|
1904
1974
|
range?: R2Range | Headers;
|
|
1975
|
+
ssecKey?: ArrayBuffer | string;
|
|
1905
1976
|
}
|
|
1906
1977
|
interface R2PutOptions {
|
|
1907
1978
|
onlyIf?: R2Conditional | Headers;
|
|
@@ -1913,11 +1984,13 @@ interface R2PutOptions {
|
|
|
1913
1984
|
sha384?: ArrayBuffer | string;
|
|
1914
1985
|
sha512?: ArrayBuffer | string;
|
|
1915
1986
|
storageClass?: string;
|
|
1987
|
+
ssecKey?: ArrayBuffer | string;
|
|
1916
1988
|
}
|
|
1917
1989
|
interface R2MultipartOptions {
|
|
1918
1990
|
httpMetadata?: R2HTTPMetadata | Headers;
|
|
1919
1991
|
customMetadata?: Record<string, string>;
|
|
1920
1992
|
storageClass?: string;
|
|
1993
|
+
ssecKey?: ArrayBuffer | string;
|
|
1921
1994
|
}
|
|
1922
1995
|
interface R2Checksums {
|
|
1923
1996
|
readonly md5?: ArrayBuffer;
|
|
@@ -1954,6 +2027,9 @@ type R2Objects = {
|
|
|
1954
2027
|
truncated: false;
|
|
1955
2028
|
}
|
|
1956
2029
|
);
|
|
2030
|
+
interface R2UploadPartOptions {
|
|
2031
|
+
ssecKey?: ArrayBuffer | string;
|
|
2032
|
+
}
|
|
1957
2033
|
declare abstract class ScheduledEvent extends ExtendableEvent {
|
|
1958
2034
|
readonly scheduledTime: number;
|
|
1959
2035
|
readonly cron: string;
|
|
@@ -2364,6 +2440,8 @@ interface TraceItem {
|
|
|
2364
2440
|
readonly dispatchNamespace?: string;
|
|
2365
2441
|
readonly scriptTags?: string[];
|
|
2366
2442
|
readonly outcome: string;
|
|
2443
|
+
readonly executionModel: string;
|
|
2444
|
+
readonly truncated: boolean;
|
|
2367
2445
|
}
|
|
2368
2446
|
interface TraceItemAlarmEventInfo {
|
|
2369
2447
|
readonly scheduledTime: Date;
|
|
@@ -2677,8 +2755,24 @@ type WebSocketEventMap = {
|
|
|
2677
2755
|
*
|
|
2678
2756
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
|
|
2679
2757
|
*/
|
|
2680
|
-
declare
|
|
2681
|
-
|
|
2758
|
+
declare var WebSocket: {
|
|
2759
|
+
prototype: WebSocket;
|
|
2760
|
+
new (url: string, protocols?: string[] | string): WebSocket;
|
|
2761
|
+
readonly READY_STATE_CONNECTING: number;
|
|
2762
|
+
readonly CONNECTING: number;
|
|
2763
|
+
readonly READY_STATE_OPEN: number;
|
|
2764
|
+
readonly OPEN: number;
|
|
2765
|
+
readonly READY_STATE_CLOSING: number;
|
|
2766
|
+
readonly CLOSING: number;
|
|
2767
|
+
readonly READY_STATE_CLOSED: number;
|
|
2768
|
+
readonly CLOSED: number;
|
|
2769
|
+
};
|
|
2770
|
+
/**
|
|
2771
|
+
* Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
|
|
2772
|
+
*
|
|
2773
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
|
|
2774
|
+
*/
|
|
2775
|
+
interface WebSocket extends EventTarget<WebSocketEventMap> {
|
|
2682
2776
|
accept(): void;
|
|
2683
2777
|
/**
|
|
2684
2778
|
* Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
|
|
@@ -2694,38 +2788,30 @@ declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
2694
2788
|
close(code?: number, reason?: string): void;
|
|
2695
2789
|
serializeAttachment(attachment: any): void;
|
|
2696
2790
|
deserializeAttachment(): any | null;
|
|
2697
|
-
static readonly READY_STATE_CONNECTING: number;
|
|
2698
|
-
static readonly CONNECTING: number;
|
|
2699
|
-
static readonly READY_STATE_OPEN: number;
|
|
2700
|
-
static readonly OPEN: number;
|
|
2701
|
-
static readonly READY_STATE_CLOSING: number;
|
|
2702
|
-
static readonly CLOSING: number;
|
|
2703
|
-
static readonly READY_STATE_CLOSED: number;
|
|
2704
|
-
static readonly CLOSED: number;
|
|
2705
2791
|
/**
|
|
2706
2792
|
* Returns the state of the WebSocket object's connection. It can have the values described below.
|
|
2707
2793
|
*
|
|
2708
2794
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
|
|
2709
2795
|
*/
|
|
2710
|
-
|
|
2796
|
+
readyState: number;
|
|
2711
2797
|
/**
|
|
2712
2798
|
* Returns the URL that was used to establish the WebSocket connection.
|
|
2713
2799
|
*
|
|
2714
2800
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
|
|
2715
2801
|
*/
|
|
2716
|
-
|
|
2802
|
+
url: string | null;
|
|
2717
2803
|
/**
|
|
2718
2804
|
* Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
|
|
2719
2805
|
*
|
|
2720
2806
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
|
|
2721
2807
|
*/
|
|
2722
|
-
|
|
2808
|
+
protocol: string | null;
|
|
2723
2809
|
/**
|
|
2724
2810
|
* Returns the extensions selected by the server, if any.
|
|
2725
2811
|
*
|
|
2726
2812
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
|
|
2727
2813
|
*/
|
|
2728
|
-
|
|
2814
|
+
extensions: string | null;
|
|
2729
2815
|
}
|
|
2730
2816
|
declare const WebSocketPair: {
|
|
2731
2817
|
new (): {
|
|
@@ -2733,6 +2819,37 @@ declare const WebSocketPair: {
|
|
|
2733
2819
|
1: WebSocket;
|
|
2734
2820
|
};
|
|
2735
2821
|
};
|
|
2822
|
+
interface SqlStorage {
|
|
2823
|
+
exec<T extends Record<string, SqlStorageValue>>(
|
|
2824
|
+
query: string,
|
|
2825
|
+
...bindings: any[]
|
|
2826
|
+
): SqlStorageCursor<T>;
|
|
2827
|
+
get databaseSize(): number;
|
|
2828
|
+
Cursor: typeof SqlStorageCursor;
|
|
2829
|
+
Statement: typeof SqlStorageStatement;
|
|
2830
|
+
}
|
|
2831
|
+
declare abstract class SqlStorageStatement {}
|
|
2832
|
+
type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
2833
|
+
declare abstract class SqlStorageCursor<
|
|
2834
|
+
T extends Record<string, SqlStorageValue>,
|
|
2835
|
+
> {
|
|
2836
|
+
next():
|
|
2837
|
+
| {
|
|
2838
|
+
done?: false;
|
|
2839
|
+
value: T;
|
|
2840
|
+
}
|
|
2841
|
+
| {
|
|
2842
|
+
done: true;
|
|
2843
|
+
value?: never;
|
|
2844
|
+
};
|
|
2845
|
+
toArray(): T[];
|
|
2846
|
+
one(): T;
|
|
2847
|
+
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
|
|
2848
|
+
columnNames: string[];
|
|
2849
|
+
get rowsRead(): number;
|
|
2850
|
+
get rowsWritten(): number;
|
|
2851
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
2852
|
+
}
|
|
2736
2853
|
interface Socket {
|
|
2737
2854
|
get readable(): ReadableStream;
|
|
2738
2855
|
get writable(): WritableStream;
|
|
@@ -3263,7 +3380,7 @@ interface GPUOrigin3DDict {
|
|
|
3263
3380
|
z?: number;
|
|
3264
3381
|
}
|
|
3265
3382
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
|
|
3266
|
-
declare class EventSource {
|
|
3383
|
+
declare class EventSource extends EventTarget {
|
|
3267
3384
|
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3268
3385
|
/**
|
|
3269
3386
|
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
@@ -3362,10 +3479,10 @@ declare abstract class BaseAiSentenceSimilarity {
|
|
|
3362
3479
|
inputs: AiSentenceSimilarityInput;
|
|
3363
3480
|
postProcessedOutputs: AiSentenceSimilarityOutput;
|
|
3364
3481
|
}
|
|
3365
|
-
type
|
|
3482
|
+
type AiAutomaticSpeechRecognitionInput = {
|
|
3366
3483
|
audio: number[];
|
|
3367
3484
|
};
|
|
3368
|
-
type
|
|
3485
|
+
type AiAutomaticSpeechRecognitionOutput = {
|
|
3369
3486
|
text?: string;
|
|
3370
3487
|
words?: {
|
|
3371
3488
|
word: string;
|
|
@@ -3374,9 +3491,9 @@ type AiSpeechRecognitionOutput = {
|
|
|
3374
3491
|
}[];
|
|
3375
3492
|
vtt?: string;
|
|
3376
3493
|
};
|
|
3377
|
-
declare abstract class
|
|
3378
|
-
inputs:
|
|
3379
|
-
postProcessedOutputs:
|
|
3494
|
+
declare abstract class BaseAiAutomaticSpeechRecognition {
|
|
3495
|
+
inputs: AiAutomaticSpeechRecognitionInput;
|
|
3496
|
+
postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
|
|
3380
3497
|
}
|
|
3381
3498
|
type AiSummarizationInput = {
|
|
3382
3499
|
input_text: string;
|
|
@@ -3412,16 +3529,36 @@ declare abstract class BaseAiTextEmbeddings {
|
|
|
3412
3529
|
postProcessedOutputs: AiTextEmbeddingsOutput;
|
|
3413
3530
|
}
|
|
3414
3531
|
type RoleScopedChatInput = {
|
|
3415
|
-
role:
|
|
3532
|
+
role:
|
|
3533
|
+
| "user"
|
|
3534
|
+
| "assistant"
|
|
3535
|
+
| "system"
|
|
3536
|
+
| "tool"
|
|
3537
|
+
| (string & NonNullable<unknown>);
|
|
3416
3538
|
content: string;
|
|
3539
|
+
name?: string;
|
|
3540
|
+
};
|
|
3541
|
+
type AiTextGenerationToolLegacyInput = {
|
|
3542
|
+
name: string;
|
|
3543
|
+
description: string;
|
|
3544
|
+
parameters?: {
|
|
3545
|
+
type: "object" | (string & NonNullable<unknown>);
|
|
3546
|
+
properties: {
|
|
3547
|
+
[key: string]: {
|
|
3548
|
+
type: string;
|
|
3549
|
+
description?: string;
|
|
3550
|
+
};
|
|
3551
|
+
};
|
|
3552
|
+
required: string[];
|
|
3553
|
+
};
|
|
3417
3554
|
};
|
|
3418
3555
|
type AiTextGenerationToolInput = {
|
|
3419
|
-
type: "function";
|
|
3556
|
+
type: "function" | (string & NonNullable<unknown>);
|
|
3420
3557
|
function: {
|
|
3421
3558
|
name: string;
|
|
3422
3559
|
description: string;
|
|
3423
3560
|
parameters?: {
|
|
3424
|
-
type: "object";
|
|
3561
|
+
type: "object" | (string & NonNullable<unknown>);
|
|
3425
3562
|
properties: {
|
|
3426
3563
|
[key: string]: {
|
|
3427
3564
|
type: string;
|
|
@@ -3432,6 +3569,10 @@ type AiTextGenerationToolInput = {
|
|
|
3432
3569
|
};
|
|
3433
3570
|
};
|
|
3434
3571
|
};
|
|
3572
|
+
type AiTextGenerationFunctionsInput = {
|
|
3573
|
+
name: string;
|
|
3574
|
+
code: string;
|
|
3575
|
+
};
|
|
3435
3576
|
type AiTextGenerationInput = {
|
|
3436
3577
|
prompt?: string;
|
|
3437
3578
|
raw?: boolean;
|
|
@@ -3445,7 +3586,11 @@ type AiTextGenerationInput = {
|
|
|
3445
3586
|
frequency_penalty?: number;
|
|
3446
3587
|
presence_penalty?: number;
|
|
3447
3588
|
messages?: RoleScopedChatInput[];
|
|
3448
|
-
tools?:
|
|
3589
|
+
tools?:
|
|
3590
|
+
| AiTextGenerationToolInput[]
|
|
3591
|
+
| AiTextGenerationToolLegacyInput[]
|
|
3592
|
+
| (object & NonNullable<unknown>);
|
|
3593
|
+
functions?: AiTextGenerationFunctionsInput[];
|
|
3449
3594
|
};
|
|
3450
3595
|
type AiTextGenerationOutput =
|
|
3451
3596
|
| {
|
|
@@ -3460,15 +3605,33 @@ declare abstract class BaseAiTextGeneration {
|
|
|
3460
3605
|
inputs: AiTextGenerationInput;
|
|
3461
3606
|
postProcessedOutputs: AiTextGenerationOutput;
|
|
3462
3607
|
}
|
|
3608
|
+
type AiTextToSpeechInput = {
|
|
3609
|
+
prompt: string;
|
|
3610
|
+
lang?: string;
|
|
3611
|
+
};
|
|
3612
|
+
type AiTextToSpeechOutput =
|
|
3613
|
+
| Uint8Array
|
|
3614
|
+
| {
|
|
3615
|
+
audio: string;
|
|
3616
|
+
};
|
|
3617
|
+
declare abstract class BaseAiTextToSpeech {
|
|
3618
|
+
inputs: AiTextToSpeechInput;
|
|
3619
|
+
postProcessedOutputs: AiTextToSpeechOutput;
|
|
3620
|
+
}
|
|
3463
3621
|
type AiTextToImageInput = {
|
|
3464
3622
|
prompt: string;
|
|
3623
|
+
negative_prompt?: string;
|
|
3624
|
+
height?: number;
|
|
3625
|
+
width?: number;
|
|
3465
3626
|
image?: number[];
|
|
3627
|
+
image_b64?: string;
|
|
3466
3628
|
mask?: number[];
|
|
3467
3629
|
num_steps?: number;
|
|
3468
3630
|
strength?: number;
|
|
3469
3631
|
guidance?: number;
|
|
3632
|
+
seed?: number;
|
|
3470
3633
|
};
|
|
3471
|
-
type AiTextToImageOutput = Uint8Array
|
|
3634
|
+
type AiTextToImageOutput = ReadableStream<Uint8Array>;
|
|
3472
3635
|
declare abstract class BaseAiTextToImage {
|
|
3473
3636
|
inputs: AiTextToImageInput;
|
|
3474
3637
|
postProcessedOutputs: AiTextToImageOutput;
|
|
@@ -3485,126 +3648,613 @@ declare abstract class BaseAiTranslation {
|
|
|
3485
3648
|
inputs: AiTranslationInput;
|
|
3486
3649
|
postProcessedOutputs: AiTranslationOutput;
|
|
3487
3650
|
}
|
|
3651
|
+
type Ai_Cf_Openai_Whisper_Input =
|
|
3652
|
+
| string
|
|
3653
|
+
| {
|
|
3654
|
+
/**
|
|
3655
|
+
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
|
|
3656
|
+
*/
|
|
3657
|
+
audio: number[];
|
|
3658
|
+
};
|
|
3659
|
+
interface Ai_Cf_Openai_Whisper_Output {
|
|
3660
|
+
/**
|
|
3661
|
+
* The transcription
|
|
3662
|
+
*/
|
|
3663
|
+
text: string;
|
|
3664
|
+
word_count?: number;
|
|
3665
|
+
words?: {
|
|
3666
|
+
word?: string;
|
|
3667
|
+
/**
|
|
3668
|
+
* The second this word begins in the recording
|
|
3669
|
+
*/
|
|
3670
|
+
start?: number;
|
|
3671
|
+
/**
|
|
3672
|
+
* The ending second when the word completes
|
|
3673
|
+
*/
|
|
3674
|
+
end?: number;
|
|
3675
|
+
}[];
|
|
3676
|
+
vtt?: string;
|
|
3677
|
+
}
|
|
3678
|
+
declare abstract class Base_Ai_Cf_Openai_Whisper {
|
|
3679
|
+
inputs: Ai_Cf_Openai_Whisper_Input;
|
|
3680
|
+
postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
|
|
3681
|
+
}
|
|
3682
|
+
type Ai_Cf_Openai_Whisper_Tiny_En_Input =
|
|
3683
|
+
| string
|
|
3684
|
+
| {
|
|
3685
|
+
/**
|
|
3686
|
+
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
|
|
3687
|
+
*/
|
|
3688
|
+
audio: number[];
|
|
3689
|
+
};
|
|
3690
|
+
interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
|
|
3691
|
+
/**
|
|
3692
|
+
* The transcription
|
|
3693
|
+
*/
|
|
3694
|
+
text: string;
|
|
3695
|
+
word_count?: number;
|
|
3696
|
+
words?: {
|
|
3697
|
+
word?: string;
|
|
3698
|
+
/**
|
|
3699
|
+
* The second this word begins in the recording
|
|
3700
|
+
*/
|
|
3701
|
+
start?: number;
|
|
3702
|
+
/**
|
|
3703
|
+
* The ending second when the word completes
|
|
3704
|
+
*/
|
|
3705
|
+
end?: number;
|
|
3706
|
+
}[];
|
|
3707
|
+
vtt?: string;
|
|
3708
|
+
}
|
|
3709
|
+
declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
|
|
3710
|
+
inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
|
|
3711
|
+
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
|
|
3712
|
+
}
|
|
3713
|
+
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
|
|
3714
|
+
/**
|
|
3715
|
+
* Base64 encoded value of the audio data.
|
|
3716
|
+
*/
|
|
3717
|
+
audio: string;
|
|
3718
|
+
/**
|
|
3719
|
+
* Supported tasks are 'translate' or 'transcribe'.
|
|
3720
|
+
*/
|
|
3721
|
+
task?: string;
|
|
3722
|
+
/**
|
|
3723
|
+
* The language of the audio being transcribed or translated.
|
|
3724
|
+
*/
|
|
3725
|
+
language?: string;
|
|
3726
|
+
/**
|
|
3727
|
+
* Preprocess the audio with a voice activity detection model.
|
|
3728
|
+
*/
|
|
3729
|
+
vad_filter?: string;
|
|
3730
|
+
/**
|
|
3731
|
+
* A text prompt to help provide context to the model on the contents of the audio.
|
|
3732
|
+
*/
|
|
3733
|
+
initial_prompt?: string;
|
|
3734
|
+
/**
|
|
3735
|
+
* The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
|
|
3736
|
+
*/
|
|
3737
|
+
prefix?: string;
|
|
3738
|
+
}
|
|
3739
|
+
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
|
|
3740
|
+
transcription_info?: {
|
|
3741
|
+
/**
|
|
3742
|
+
* The language of the audio being transcribed or translated.
|
|
3743
|
+
*/
|
|
3744
|
+
language?: string;
|
|
3745
|
+
/**
|
|
3746
|
+
* The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
|
|
3747
|
+
*/
|
|
3748
|
+
language_probability?: number;
|
|
3749
|
+
/**
|
|
3750
|
+
* The total duration of the original audio file, in seconds.
|
|
3751
|
+
*/
|
|
3752
|
+
duration?: number;
|
|
3753
|
+
/**
|
|
3754
|
+
* The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
|
|
3755
|
+
*/
|
|
3756
|
+
duration_after_vad?: number;
|
|
3757
|
+
};
|
|
3758
|
+
/**
|
|
3759
|
+
* The complete transcription of the audio.
|
|
3760
|
+
*/
|
|
3761
|
+
text: string;
|
|
3762
|
+
/**
|
|
3763
|
+
* The total number of words in the transcription.
|
|
3764
|
+
*/
|
|
3765
|
+
word_count?: number;
|
|
3766
|
+
segments?: {
|
|
3767
|
+
/**
|
|
3768
|
+
* The starting time of the segment within the audio, in seconds.
|
|
3769
|
+
*/
|
|
3770
|
+
start?: number;
|
|
3771
|
+
/**
|
|
3772
|
+
* The ending time of the segment within the audio, in seconds.
|
|
3773
|
+
*/
|
|
3774
|
+
end?: number;
|
|
3775
|
+
/**
|
|
3776
|
+
* The transcription of the segment.
|
|
3777
|
+
*/
|
|
3778
|
+
text?: string;
|
|
3779
|
+
/**
|
|
3780
|
+
* The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
|
|
3781
|
+
*/
|
|
3782
|
+
temperature?: number;
|
|
3783
|
+
/**
|
|
3784
|
+
* The average log probability of the predictions for the words in this segment, indicating overall confidence.
|
|
3785
|
+
*/
|
|
3786
|
+
avg_logprob?: number;
|
|
3787
|
+
/**
|
|
3788
|
+
* The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
|
|
3789
|
+
*/
|
|
3790
|
+
compression_ratio?: number;
|
|
3791
|
+
/**
|
|
3792
|
+
* The probability that the segment contains no speech, represented as a decimal between 0 and 1.
|
|
3793
|
+
*/
|
|
3794
|
+
no_speech_prob?: number;
|
|
3795
|
+
words?: {
|
|
3796
|
+
/**
|
|
3797
|
+
* The individual word transcribed from the audio.
|
|
3798
|
+
*/
|
|
3799
|
+
word?: string;
|
|
3800
|
+
/**
|
|
3801
|
+
* The starting time of the word within the audio, in seconds.
|
|
3802
|
+
*/
|
|
3803
|
+
start?: number;
|
|
3804
|
+
/**
|
|
3805
|
+
* The ending time of the word within the audio, in seconds.
|
|
3806
|
+
*/
|
|
3807
|
+
end?: number;
|
|
3808
|
+
}[];
|
|
3809
|
+
};
|
|
3810
|
+
/**
|
|
3811
|
+
* The transcription in WebVTT format, which includes timing and text information for use in subtitles.
|
|
3812
|
+
*/
|
|
3813
|
+
vtt?: string;
|
|
3814
|
+
}
|
|
3815
|
+
declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
|
|
3816
|
+
inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
|
|
3817
|
+
postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
|
|
3818
|
+
}
|
|
3819
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
|
|
3820
|
+
/**
|
|
3821
|
+
* A text description of the image you want to generate.
|
|
3822
|
+
*/
|
|
3823
|
+
prompt: string;
|
|
3824
|
+
/**
|
|
3825
|
+
* The number of diffusion steps; higher values can improve quality but take longer.
|
|
3826
|
+
*/
|
|
3827
|
+
steps?: number;
|
|
3828
|
+
}
|
|
3829
|
+
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
|
|
3830
|
+
/**
|
|
3831
|
+
* The generated image in Base64 format.
|
|
3832
|
+
*/
|
|
3833
|
+
image?: string;
|
|
3834
|
+
}
|
|
3835
|
+
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
|
|
3836
|
+
inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
|
|
3837
|
+
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
|
|
3838
|
+
}
|
|
3839
|
+
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
|
|
3840
|
+
interface Prompt {
|
|
3841
|
+
/**
|
|
3842
|
+
* The input text prompt for the model to generate a response.
|
|
3843
|
+
*/
|
|
3844
|
+
prompt: string;
|
|
3845
|
+
image?: number[] | (string & NonNullable<unknown>);
|
|
3846
|
+
/**
|
|
3847
|
+
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
|
|
3848
|
+
*/
|
|
3849
|
+
raw?: boolean;
|
|
3850
|
+
/**
|
|
3851
|
+
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
|
|
3852
|
+
*/
|
|
3853
|
+
stream?: boolean;
|
|
3854
|
+
/**
|
|
3855
|
+
* The maximum number of tokens to generate in the response.
|
|
3856
|
+
*/
|
|
3857
|
+
max_tokens?: number;
|
|
3858
|
+
/**
|
|
3859
|
+
* Controls the randomness of the output; higher values produce more random results.
|
|
3860
|
+
*/
|
|
3861
|
+
temperature?: number;
|
|
3862
|
+
/**
|
|
3863
|
+
* 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.
|
|
3864
|
+
*/
|
|
3865
|
+
top_p?: number;
|
|
3866
|
+
/**
|
|
3867
|
+
* 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.
|
|
3868
|
+
*/
|
|
3869
|
+
top_k?: number;
|
|
3870
|
+
/**
|
|
3871
|
+
* Random seed for reproducibility of the generation.
|
|
3872
|
+
*/
|
|
3873
|
+
seed?: number;
|
|
3874
|
+
/**
|
|
3875
|
+
* Penalty for repeated tokens; higher values discourage repetition.
|
|
3876
|
+
*/
|
|
3877
|
+
repetition_penalty?: number;
|
|
3878
|
+
/**
|
|
3879
|
+
* Decreases the likelihood of the model repeating the same lines verbatim.
|
|
3880
|
+
*/
|
|
3881
|
+
frequency_penalty?: number;
|
|
3882
|
+
/**
|
|
3883
|
+
* Increases the likelihood of the model introducing new topics.
|
|
3884
|
+
*/
|
|
3885
|
+
presence_penalty?: number;
|
|
3886
|
+
/**
|
|
3887
|
+
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
|
|
3888
|
+
*/
|
|
3889
|
+
lora?: string;
|
|
3890
|
+
}
|
|
3891
|
+
interface Messages {
|
|
3892
|
+
/**
|
|
3893
|
+
* An array of message objects representing the conversation history.
|
|
3894
|
+
*/
|
|
3895
|
+
messages: {
|
|
3896
|
+
/**
|
|
3897
|
+
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
|
|
3898
|
+
*/
|
|
3899
|
+
role: string;
|
|
3900
|
+
/**
|
|
3901
|
+
* The content of the message as a string.
|
|
3902
|
+
*/
|
|
3903
|
+
content: string;
|
|
3904
|
+
}[];
|
|
3905
|
+
image?: number[] | string;
|
|
3906
|
+
functions?: {
|
|
3907
|
+
name: string;
|
|
3908
|
+
code: string;
|
|
3909
|
+
}[];
|
|
3910
|
+
/**
|
|
3911
|
+
* A list of tools available for the assistant to use.
|
|
3912
|
+
*/
|
|
3913
|
+
tools?: (
|
|
3914
|
+
| {
|
|
3915
|
+
/**
|
|
3916
|
+
* The name of the tool. More descriptive the better.
|
|
3917
|
+
*/
|
|
3918
|
+
name: string;
|
|
3919
|
+
/**
|
|
3920
|
+
* A brief description of what the tool does.
|
|
3921
|
+
*/
|
|
3922
|
+
description: string;
|
|
3923
|
+
/**
|
|
3924
|
+
* Schema defining the parameters accepted by the tool.
|
|
3925
|
+
*/
|
|
3926
|
+
parameters: {
|
|
3927
|
+
/**
|
|
3928
|
+
* The type of the parameters object (usually 'object').
|
|
3929
|
+
*/
|
|
3930
|
+
type: string;
|
|
3931
|
+
/**
|
|
3932
|
+
* List of required parameter names.
|
|
3933
|
+
*/
|
|
3934
|
+
required?: string[];
|
|
3935
|
+
/**
|
|
3936
|
+
* Definitions of each parameter.
|
|
3937
|
+
*/
|
|
3938
|
+
properties: {
|
|
3939
|
+
[k: string]: {
|
|
3940
|
+
/**
|
|
3941
|
+
* The data type of the parameter.
|
|
3942
|
+
*/
|
|
3943
|
+
type: string;
|
|
3944
|
+
/**
|
|
3945
|
+
* A description of the expected parameter.
|
|
3946
|
+
*/
|
|
3947
|
+
description: string;
|
|
3948
|
+
};
|
|
3949
|
+
};
|
|
3950
|
+
};
|
|
3951
|
+
}
|
|
3952
|
+
| {
|
|
3953
|
+
/**
|
|
3954
|
+
* Specifies the type of tool (e.g., 'function').
|
|
3955
|
+
*/
|
|
3956
|
+
type: string;
|
|
3957
|
+
/**
|
|
3958
|
+
* Details of the function tool.
|
|
3959
|
+
*/
|
|
3960
|
+
function: {
|
|
3961
|
+
/**
|
|
3962
|
+
* The name of the function.
|
|
3963
|
+
*/
|
|
3964
|
+
name: string;
|
|
3965
|
+
/**
|
|
3966
|
+
* A brief description of what the function does.
|
|
3967
|
+
*/
|
|
3968
|
+
description: string;
|
|
3969
|
+
/**
|
|
3970
|
+
* Schema defining the parameters accepted by the function.
|
|
3971
|
+
*/
|
|
3972
|
+
parameters: {
|
|
3973
|
+
/**
|
|
3974
|
+
* The type of the parameters object (usually 'object').
|
|
3975
|
+
*/
|
|
3976
|
+
type: string;
|
|
3977
|
+
/**
|
|
3978
|
+
* List of required parameter names.
|
|
3979
|
+
*/
|
|
3980
|
+
required?: string[];
|
|
3981
|
+
/**
|
|
3982
|
+
* Definitions of each parameter.
|
|
3983
|
+
*/
|
|
3984
|
+
properties: {
|
|
3985
|
+
[k: string]: {
|
|
3986
|
+
/**
|
|
3987
|
+
* The data type of the parameter.
|
|
3988
|
+
*/
|
|
3989
|
+
type: string;
|
|
3990
|
+
/**
|
|
3991
|
+
* A description of the expected parameter.
|
|
3992
|
+
*/
|
|
3993
|
+
description: string;
|
|
3994
|
+
};
|
|
3995
|
+
};
|
|
3996
|
+
};
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
)[];
|
|
4000
|
+
/**
|
|
4001
|
+
* If true, the response will be streamed back incrementally.
|
|
4002
|
+
*/
|
|
4003
|
+
stream?: boolean;
|
|
4004
|
+
/**
|
|
4005
|
+
* The maximum number of tokens to generate in the response.
|
|
4006
|
+
*/
|
|
4007
|
+
max_tokens?: number;
|
|
4008
|
+
/**
|
|
4009
|
+
* Controls the randomness of the output; higher values produce more random results.
|
|
4010
|
+
*/
|
|
4011
|
+
temperature?: number;
|
|
4012
|
+
/**
|
|
4013
|
+
* 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.
|
|
4014
|
+
*/
|
|
4015
|
+
top_p?: number;
|
|
4016
|
+
/**
|
|
4017
|
+
* 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.
|
|
4018
|
+
*/
|
|
4019
|
+
top_k?: number;
|
|
4020
|
+
/**
|
|
4021
|
+
* Random seed for reproducibility of the generation.
|
|
4022
|
+
*/
|
|
4023
|
+
seed?: number;
|
|
4024
|
+
/**
|
|
4025
|
+
* Penalty for repeated tokens; higher values discourage repetition.
|
|
4026
|
+
*/
|
|
4027
|
+
repetition_penalty?: number;
|
|
4028
|
+
/**
|
|
4029
|
+
* Decreases the likelihood of the model repeating the same lines verbatim.
|
|
4030
|
+
*/
|
|
4031
|
+
frequency_penalty?: number;
|
|
4032
|
+
/**
|
|
4033
|
+
* Increases the likelihood of the model introducing new topics.
|
|
4034
|
+
*/
|
|
4035
|
+
presence_penalty?: number;
|
|
4036
|
+
}
|
|
4037
|
+
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output =
|
|
4038
|
+
| {
|
|
4039
|
+
/**
|
|
4040
|
+
* The generated text response from the model
|
|
4041
|
+
*/
|
|
4042
|
+
response?: string;
|
|
4043
|
+
/**
|
|
4044
|
+
* An array of tool calls requests made during the response generation
|
|
4045
|
+
*/
|
|
4046
|
+
tool_calls?: {
|
|
4047
|
+
/**
|
|
4048
|
+
* The arguments passed to be passed to the tool call request
|
|
4049
|
+
*/
|
|
4050
|
+
arguments?: object;
|
|
4051
|
+
/**
|
|
4052
|
+
* The name of the tool to be called
|
|
4053
|
+
*/
|
|
4054
|
+
name?: string;
|
|
4055
|
+
}[];
|
|
4056
|
+
}
|
|
4057
|
+
| ReadableStream;
|
|
4058
|
+
declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
|
|
4059
|
+
inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
|
|
4060
|
+
postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
|
|
4061
|
+
}
|
|
4062
|
+
interface AiModels {
|
|
4063
|
+
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
|
|
4064
|
+
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
|
|
4065
|
+
"@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
|
|
4066
|
+
"@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
|
|
4067
|
+
"@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
|
|
4068
|
+
"@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
|
|
4069
|
+
"@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings;
|
|
4070
|
+
"@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings;
|
|
4071
|
+
"@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings;
|
|
4072
|
+
"@cf/microsoft/resnet-50": BaseAiImageClassification;
|
|
4073
|
+
"@cf/facebook/detr-resnet-50": BaseAiObjectDetection;
|
|
4074
|
+
"@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
|
|
4075
|
+
"@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
|
|
4076
|
+
"@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
|
|
4077
|
+
"@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
|
|
4078
|
+
"@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
|
|
4079
|
+
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
|
|
4080
|
+
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
|
|
4081
|
+
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
|
|
4082
|
+
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
|
|
4083
|
+
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
|
|
4084
|
+
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
|
|
4085
|
+
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
|
|
4086
|
+
"@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
|
|
4087
|
+
"@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
|
|
4088
|
+
"@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
|
|
4089
|
+
"@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
|
|
4090
|
+
"@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
|
|
4091
|
+
"@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
|
|
4092
|
+
"@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
|
|
4093
|
+
"@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
|
|
4094
|
+
"@cf/microsoft/phi-2": BaseAiTextGeneration;
|
|
4095
|
+
"@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
|
|
4096
|
+
"@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
|
|
4097
|
+
"@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
|
|
4098
|
+
"@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
|
|
4099
|
+
"@hf/google/gemma-7b-it": BaseAiTextGeneration;
|
|
4100
|
+
"@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
|
|
4101
|
+
"@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
|
|
4102
|
+
"@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
|
|
4103
|
+
"@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
|
|
4104
|
+
"@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
|
|
4105
|
+
"@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
|
|
4106
|
+
"@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
|
|
4107
|
+
"@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
|
|
4108
|
+
"@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration;
|
|
4109
|
+
"@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
|
|
4110
|
+
"@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
|
|
4111
|
+
"@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
|
|
4112
|
+
"@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
|
|
4113
|
+
"@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration;
|
|
4114
|
+
"@cf/meta/m2m100-1.2b": BaseAiTranslation;
|
|
4115
|
+
"@cf/facebook/bart-large-cnn": BaseAiSummarization;
|
|
4116
|
+
"@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
|
|
4117
|
+
"@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
|
|
4118
|
+
"@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
|
|
4119
|
+
"@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
|
|
4120
|
+
"@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
|
|
4121
|
+
"@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
|
|
4122
|
+
"@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
|
|
4123
|
+
}
|
|
4124
|
+
type AiOptions = {
|
|
4125
|
+
gateway?: GatewayOptions;
|
|
4126
|
+
prefix?: string;
|
|
4127
|
+
extraHeaders?: object;
|
|
4128
|
+
};
|
|
4129
|
+
type AiModelsSearchParams = {
|
|
4130
|
+
author?: string;
|
|
4131
|
+
hide_experimental?: boolean;
|
|
4132
|
+
page?: number;
|
|
4133
|
+
per_page?: number;
|
|
4134
|
+
search?: string;
|
|
4135
|
+
source?: number;
|
|
4136
|
+
task?: string;
|
|
4137
|
+
};
|
|
4138
|
+
type AiModelsSearchObject = {
|
|
4139
|
+
id: string;
|
|
4140
|
+
source: number;
|
|
4141
|
+
name: string;
|
|
4142
|
+
description: string;
|
|
4143
|
+
task: {
|
|
4144
|
+
id: string;
|
|
4145
|
+
name: string;
|
|
4146
|
+
description: string;
|
|
4147
|
+
};
|
|
4148
|
+
tags: string[];
|
|
4149
|
+
properties: {
|
|
4150
|
+
property_id: string;
|
|
4151
|
+
value: string;
|
|
4152
|
+
}[];
|
|
4153
|
+
};
|
|
4154
|
+
interface InferenceUpstreamError extends Error {}
|
|
4155
|
+
interface AiInternalError extends Error {}
|
|
4156
|
+
type AiModelListType = Record<string, any>;
|
|
4157
|
+
declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
4158
|
+
aiGatewayLogId: string | null;
|
|
4159
|
+
gateway(gatewayId: string): AiGateway;
|
|
4160
|
+
run<Name extends keyof AiModelList>(
|
|
4161
|
+
model: Name,
|
|
4162
|
+
inputs: AiModelList[Name]["inputs"],
|
|
4163
|
+
options?: AiOptions,
|
|
4164
|
+
): Promise<AiModelList[Name]["postProcessedOutputs"]>;
|
|
4165
|
+
public models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
|
|
4166
|
+
}
|
|
3488
4167
|
type GatewayOptions = {
|
|
3489
4168
|
id: string;
|
|
4169
|
+
cacheKey?: string;
|
|
3490
4170
|
cacheTtl?: number;
|
|
3491
4171
|
skipCache?: boolean;
|
|
3492
4172
|
metadata?: Record<string, number | string | boolean | null | bigint>;
|
|
4173
|
+
collectLog?: boolean;
|
|
3493
4174
|
};
|
|
3494
|
-
type
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
4175
|
+
type AiGatewayPatchLog = {
|
|
4176
|
+
score?: number | null;
|
|
4177
|
+
feedback?: -1 | 1 | null;
|
|
4178
|
+
metadata?: Record<string, number | string | boolean | null | bigint> | null;
|
|
3498
4179
|
};
|
|
3499
|
-
type
|
|
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
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
): Promise<
|
|
3573
|
-
|
|
3574
|
-
model: BaseAiSpeechRecognitionModels,
|
|
3575
|
-
inputs: BaseAiSpeechRecognition["inputs"],
|
|
3576
|
-
options?: AiOptions,
|
|
3577
|
-
): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
|
|
3578
|
-
run(
|
|
3579
|
-
model: BaseAiImageClassificationModels,
|
|
3580
|
-
inputs: BaseAiImageClassification["inputs"],
|
|
3581
|
-
options?: AiOptions,
|
|
3582
|
-
): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
|
|
3583
|
-
run(
|
|
3584
|
-
model: BaseAiObjectDetectionModels,
|
|
3585
|
-
inputs: BaseAiObjectDetection["inputs"],
|
|
3586
|
-
options?: AiOptions,
|
|
3587
|
-
): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
|
|
3588
|
-
run(
|
|
3589
|
-
model: BaseAiTextGenerationModels,
|
|
3590
|
-
inputs: BaseAiTextGeneration["inputs"],
|
|
3591
|
-
options?: AiOptions,
|
|
3592
|
-
): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
|
|
3593
|
-
run(
|
|
3594
|
-
model: BaseAiTranslationModels,
|
|
3595
|
-
inputs: BaseAiTranslation["inputs"],
|
|
3596
|
-
options?: AiOptions,
|
|
3597
|
-
): Promise<BaseAiTranslation["postProcessedOutputs"]>;
|
|
3598
|
-
run(
|
|
3599
|
-
model: BaseAiSummarizationModels,
|
|
3600
|
-
inputs: BaseAiSummarization["inputs"],
|
|
3601
|
-
options?: AiOptions,
|
|
3602
|
-
): Promise<BaseAiSummarization["postProcessedOutputs"]>;
|
|
4180
|
+
type AiGatewayLog = {
|
|
4181
|
+
id: string;
|
|
4182
|
+
provider: string;
|
|
4183
|
+
model: string;
|
|
4184
|
+
model_type?: string;
|
|
4185
|
+
path: string;
|
|
4186
|
+
duration: number;
|
|
4187
|
+
request_type?: string;
|
|
4188
|
+
request_content_type?: string;
|
|
4189
|
+
status_code: number;
|
|
4190
|
+
response_content_type?: string;
|
|
4191
|
+
success: boolean;
|
|
4192
|
+
cached: boolean;
|
|
4193
|
+
tokens_in?: number;
|
|
4194
|
+
tokens_out?: number;
|
|
4195
|
+
metadata?: Record<string, number | string | boolean | null | bigint>;
|
|
4196
|
+
step?: number;
|
|
4197
|
+
cost?: number;
|
|
4198
|
+
custom_cost?: boolean;
|
|
4199
|
+
request_size: number;
|
|
4200
|
+
request_head?: string;
|
|
4201
|
+
request_head_complete: boolean;
|
|
4202
|
+
response_size: number;
|
|
4203
|
+
response_head?: string;
|
|
4204
|
+
response_head_complete: boolean;
|
|
4205
|
+
created_at: Date;
|
|
4206
|
+
};
|
|
4207
|
+
type AIGatewayProviders =
|
|
4208
|
+
| "workers-ai"
|
|
4209
|
+
| "anthropic"
|
|
4210
|
+
| "aws-bedrock"
|
|
4211
|
+
| "azure-openai"
|
|
4212
|
+
| "google-vertex-ai"
|
|
4213
|
+
| "huggingface"
|
|
4214
|
+
| "openai"
|
|
4215
|
+
| "perplexity-ai"
|
|
4216
|
+
| "replicate"
|
|
4217
|
+
| "groq"
|
|
4218
|
+
| "cohere"
|
|
4219
|
+
| "google-ai-studio"
|
|
4220
|
+
| "mistral"
|
|
4221
|
+
| "grok"
|
|
4222
|
+
| "openrouter";
|
|
4223
|
+
type AIGatewayHeaders = {
|
|
4224
|
+
"cf-aig-metadata":
|
|
4225
|
+
| Record<string, number | string | boolean | null | bigint>
|
|
4226
|
+
| string;
|
|
4227
|
+
"cf-aig-custom-cost":
|
|
4228
|
+
| {
|
|
4229
|
+
per_token_in?: number;
|
|
4230
|
+
per_token_out?: number;
|
|
4231
|
+
}
|
|
4232
|
+
| {
|
|
4233
|
+
total_cost?: number;
|
|
4234
|
+
}
|
|
4235
|
+
| string;
|
|
4236
|
+
"cf-aig-cache-ttl": number | string;
|
|
4237
|
+
"cf-aig-skip-cache": boolean | string;
|
|
4238
|
+
"cf-aig-cache-key": string;
|
|
4239
|
+
"cf-aig-collect-log": boolean | string;
|
|
4240
|
+
Authorization: string;
|
|
4241
|
+
"Content-Type": string;
|
|
4242
|
+
[key: string]: string | number | boolean | object;
|
|
4243
|
+
};
|
|
4244
|
+
type AIGatewayUniversalRequest = {
|
|
4245
|
+
provider: AIGatewayProviders | string; // eslint-disable-line
|
|
4246
|
+
endpoint: string;
|
|
4247
|
+
headers: Partial<AIGatewayHeaders>;
|
|
4248
|
+
query: unknown;
|
|
4249
|
+
};
|
|
4250
|
+
interface AiGatewayInternalError extends Error {}
|
|
4251
|
+
interface AiGatewayLogNotFound extends Error {}
|
|
4252
|
+
declare abstract class AiGateway {
|
|
4253
|
+
patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
|
|
4254
|
+
getLog(logId: string): Promise<AiGatewayLog>;
|
|
3603
4255
|
run(
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
options?: AiOptions,
|
|
3607
|
-
): Promise<BaseAiImageToText["postProcessedOutputs"]>;
|
|
4256
|
+
data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
|
|
4257
|
+
): Promise<Response>;
|
|
3608
4258
|
}
|
|
3609
4259
|
interface BasicImageTransformations {
|
|
3610
4260
|
/**
|
|
@@ -4610,7 +5260,7 @@ declare abstract class D1PreparedStatement {
|
|
|
4610
5260
|
bind(...values: unknown[]): D1PreparedStatement;
|
|
4611
5261
|
first<T = unknown>(colName: string): Promise<T | null>;
|
|
4612
5262
|
first<T = Record<string, unknown>>(): Promise<T | null>;
|
|
4613
|
-
run(): Promise<
|
|
5263
|
+
run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
4614
5264
|
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
4615
5265
|
raw<T = unknown[]>(options: {
|
|
4616
5266
|
columnNames: true;
|
|
@@ -4666,6 +5316,12 @@ interface ForwardableEmailMessage extends EmailMessage {
|
|
|
4666
5316
|
* @returns A promise that resolves when the email message is forwarded.
|
|
4667
5317
|
*/
|
|
4668
5318
|
forward(rcptTo: string, headers?: Headers): Promise<void>;
|
|
5319
|
+
/**
|
|
5320
|
+
* Reply to the sender of this email message with a new EmailMessage object.
|
|
5321
|
+
* @param message The reply message.
|
|
5322
|
+
* @returns A promise that resolves when the email message is replied.
|
|
5323
|
+
*/
|
|
5324
|
+
reply(message: EmailMessage): Promise<void>;
|
|
4669
5325
|
}
|
|
4670
5326
|
/**
|
|
4671
5327
|
* A binding that allows a Worker to send email messages.
|
|
@@ -4735,6 +5391,128 @@ interface Hyperdrive {
|
|
|
4735
5391
|
*/
|
|
4736
5392
|
readonly database: string;
|
|
4737
5393
|
}
|
|
5394
|
+
// Copyright (c) 2024 Cloudflare, Inc.
|
|
5395
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5396
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5397
|
+
type ImageInfoResponse =
|
|
5398
|
+
| {
|
|
5399
|
+
format: "image/svg+xml";
|
|
5400
|
+
}
|
|
5401
|
+
| {
|
|
5402
|
+
format: string;
|
|
5403
|
+
fileSize: number;
|
|
5404
|
+
width: number;
|
|
5405
|
+
height: number;
|
|
5406
|
+
};
|
|
5407
|
+
type ImageTransform = {
|
|
5408
|
+
fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
|
|
5409
|
+
gravity?:
|
|
5410
|
+
| "left"
|
|
5411
|
+
| "right"
|
|
5412
|
+
| "top"
|
|
5413
|
+
| "bottom"
|
|
5414
|
+
| "center"
|
|
5415
|
+
| "auto"
|
|
5416
|
+
| "entropy"
|
|
5417
|
+
| "face"
|
|
5418
|
+
| {
|
|
5419
|
+
x?: number;
|
|
5420
|
+
y?: number;
|
|
5421
|
+
mode: "remainder" | "box-center";
|
|
5422
|
+
};
|
|
5423
|
+
trim?: {
|
|
5424
|
+
top?: number;
|
|
5425
|
+
bottom?: number;
|
|
5426
|
+
left?: number;
|
|
5427
|
+
right?: number;
|
|
5428
|
+
width?: number;
|
|
5429
|
+
height?: number;
|
|
5430
|
+
border?:
|
|
5431
|
+
| boolean
|
|
5432
|
+
| {
|
|
5433
|
+
color?: string;
|
|
5434
|
+
tolerance?: number;
|
|
5435
|
+
keep?: number;
|
|
5436
|
+
};
|
|
5437
|
+
};
|
|
5438
|
+
width?: number;
|
|
5439
|
+
height?: number;
|
|
5440
|
+
background?: string;
|
|
5441
|
+
rotate?: number;
|
|
5442
|
+
sharpen?: number;
|
|
5443
|
+
blur?: number;
|
|
5444
|
+
contrast?: number;
|
|
5445
|
+
brightness?: number;
|
|
5446
|
+
gamma?: number;
|
|
5447
|
+
border?: {
|
|
5448
|
+
color?: string;
|
|
5449
|
+
width?: number;
|
|
5450
|
+
top?: number;
|
|
5451
|
+
bottom?: number;
|
|
5452
|
+
left?: number;
|
|
5453
|
+
right?: number;
|
|
5454
|
+
};
|
|
5455
|
+
zoom?: number;
|
|
5456
|
+
};
|
|
5457
|
+
type ImageOutputOptions = {
|
|
5458
|
+
format:
|
|
5459
|
+
| "image/jpeg"
|
|
5460
|
+
| "image/png"
|
|
5461
|
+
| "image/gif"
|
|
5462
|
+
| "image/webp"
|
|
5463
|
+
| "image/avif"
|
|
5464
|
+
| "rgb"
|
|
5465
|
+
| "rgba";
|
|
5466
|
+
quality?: number;
|
|
5467
|
+
background?: string;
|
|
5468
|
+
};
|
|
5469
|
+
interface ImagesBinding {
|
|
5470
|
+
/**
|
|
5471
|
+
* Get image metadata (type, width and height)
|
|
5472
|
+
* @throws {@link ImagesError} with code 9412 if input is not an image
|
|
5473
|
+
* @param stream The image bytes
|
|
5474
|
+
*/
|
|
5475
|
+
info(stream: ReadableStream<Uint8Array>): Promise<ImageInfoResponse>;
|
|
5476
|
+
/**
|
|
5477
|
+
* Begin applying a series of transformations to an image
|
|
5478
|
+
* @param stream The image bytes
|
|
5479
|
+
* @returns A transform handle
|
|
5480
|
+
*/
|
|
5481
|
+
input(stream: ReadableStream<Uint8Array>): ImageTransformer;
|
|
5482
|
+
}
|
|
5483
|
+
interface ImageTransformer {
|
|
5484
|
+
/**
|
|
5485
|
+
* Apply transform next, returning a transform handle.
|
|
5486
|
+
* You can then apply more transformations or retrieve the output.
|
|
5487
|
+
* @param transform
|
|
5488
|
+
*/
|
|
5489
|
+
transform(transform: ImageTransform): ImageTransformer;
|
|
5490
|
+
/**
|
|
5491
|
+
* Retrieve the image that results from applying the transforms to the
|
|
5492
|
+
* provided input
|
|
5493
|
+
* @param options Options that apply to the output e.g. output format
|
|
5494
|
+
*/
|
|
5495
|
+
output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
|
|
5496
|
+
}
|
|
5497
|
+
interface ImageTransformationResult {
|
|
5498
|
+
/**
|
|
5499
|
+
* The image as a response, ready to store in cache or return to users
|
|
5500
|
+
*/
|
|
5501
|
+
response(): Response;
|
|
5502
|
+
/**
|
|
5503
|
+
* The content type of the returned image
|
|
5504
|
+
*/
|
|
5505
|
+
contentType(): string;
|
|
5506
|
+
/**
|
|
5507
|
+
* The bytes of the response
|
|
5508
|
+
*/
|
|
5509
|
+
image(): ReadableStream<Uint8Array>;
|
|
5510
|
+
}
|
|
5511
|
+
interface ImagesError extends Error {
|
|
5512
|
+
readonly code: number;
|
|
5513
|
+
readonly message: string;
|
|
5514
|
+
readonly stack?: string;
|
|
5515
|
+
}
|
|
4738
5516
|
type Params<P extends string = any> = Record<P, string | string[]>;
|
|
4739
5517
|
type EventContext<Env, P extends string, Data> = {
|
|
4740
5518
|
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
|
|
@@ -4781,6 +5559,30 @@ type PagesPluginFunction<
|
|
|
4781
5559
|
declare module "assets:*" {
|
|
4782
5560
|
export const onRequest: PagesFunction;
|
|
4783
5561
|
}
|
|
5562
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5563
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5564
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5565
|
+
declare abstract class PipelineTransform {
|
|
5566
|
+
/**
|
|
5567
|
+
* transformJson recieves an array of javascript objects which can be
|
|
5568
|
+
* mutated and returned to the pipeline
|
|
5569
|
+
* @param data The data to be mutated
|
|
5570
|
+
* @returns A promise containing the mutated data
|
|
5571
|
+
*/
|
|
5572
|
+
public transformJson(data: object[]): Promise<object[]>;
|
|
5573
|
+
}
|
|
5574
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5575
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5576
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5577
|
+
interface Pipeline {
|
|
5578
|
+
/**
|
|
5579
|
+
* send takes an array of javascript objects which are
|
|
5580
|
+
* then received by the pipeline for processing
|
|
5581
|
+
*
|
|
5582
|
+
* @param data The data to be sent
|
|
5583
|
+
*/
|
|
5584
|
+
send(data: object[]): Promise<void>;
|
|
5585
|
+
}
|
|
4784
5586
|
// PubSubMessage represents an incoming PubSub message.
|
|
4785
5587
|
// The message includes metadata about the broker, the client, and the payload
|
|
4786
5588
|
// itself.
|
|
@@ -4841,6 +5643,7 @@ declare namespace Rpc {
|
|
|
4841
5643
|
export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
|
|
4842
5644
|
export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
|
|
4843
5645
|
export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
|
|
5646
|
+
export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
|
|
4844
5647
|
export interface RpcTargetBranded {
|
|
4845
5648
|
[__RPC_TARGET_BRAND]: never;
|
|
4846
5649
|
}
|
|
@@ -4850,13 +5653,20 @@ declare namespace Rpc {
|
|
|
4850
5653
|
export interface DurableObjectBranded {
|
|
4851
5654
|
[__DURABLE_OBJECT_BRAND]: never;
|
|
4852
5655
|
}
|
|
5656
|
+
export interface WorkflowEntrypointBranded {
|
|
5657
|
+
[__WORKFLOW_ENTRYPOINT_BRAND]: never;
|
|
5658
|
+
}
|
|
4853
5659
|
export type EntrypointBranded =
|
|
4854
5660
|
| WorkerEntrypointBranded
|
|
4855
|
-
| DurableObjectBranded
|
|
5661
|
+
| DurableObjectBranded
|
|
5662
|
+
| WorkflowEntrypointBranded;
|
|
4856
5663
|
// Types that can be used through `Stub`s
|
|
4857
5664
|
export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
|
|
4858
5665
|
// Types that can be passed over RPC
|
|
4859
|
-
type
|
|
5666
|
+
// The reason for using a generic type here is to build a serializable subset of structured
|
|
5667
|
+
// cloneable composite types. This allows types defined with the "interface" keyword to pass the
|
|
5668
|
+
// serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
|
|
5669
|
+
type Serializable<T> =
|
|
4860
5670
|
// Structured cloneables
|
|
4861
5671
|
| void
|
|
4862
5672
|
| undefined
|
|
@@ -4872,11 +5682,14 @@ declare namespace Rpc {
|
|
|
4872
5682
|
| Error
|
|
4873
5683
|
| RegExp
|
|
4874
5684
|
// Structured cloneable composites
|
|
4875
|
-
| Map<
|
|
4876
|
-
|
|
4877
|
-
|
|
5685
|
+
| Map<
|
|
5686
|
+
T extends Map<infer U, unknown> ? Serializable<U> : never,
|
|
5687
|
+
T extends Map<unknown, infer U> ? Serializable<U> : never
|
|
5688
|
+
>
|
|
5689
|
+
| Set<T extends Set<infer U> ? Serializable<U> : never>
|
|
5690
|
+
| ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
|
|
4878
5691
|
| {
|
|
4879
|
-
[
|
|
5692
|
+
[K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
|
|
4880
5693
|
}
|
|
4881
5694
|
// Special types
|
|
4882
5695
|
| ReadableStream<Uint8Array>
|
|
@@ -4906,7 +5719,7 @@ declare namespace Rpc {
|
|
|
4906
5719
|
: T extends ReadonlyArray<infer V>
|
|
4907
5720
|
? ReadonlyArray<Stubify<V>>
|
|
4908
5721
|
: T extends {
|
|
4909
|
-
[key: string | number]:
|
|
5722
|
+
[key: string | number]: any;
|
|
4910
5723
|
}
|
|
4911
5724
|
? {
|
|
4912
5725
|
[K in keyof T]: Stubify<T[K]>;
|
|
@@ -4949,7 +5762,7 @@ declare namespace Rpc {
|
|
|
4949
5762
|
// Intersecting with `(Maybe)Provider` allows pipelining.
|
|
4950
5763
|
type Result<R> = R extends Stubable
|
|
4951
5764
|
? Promise<Stub<R>> & Provider<R>
|
|
4952
|
-
: R extends Serializable
|
|
5765
|
+
: R extends Serializable<R>
|
|
4953
5766
|
? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
|
|
4954
5767
|
: never;
|
|
4955
5768
|
// Type for method or property on an RPC interface.
|
|
@@ -5009,7 +5822,7 @@ declare module "cloudflare:workers" {
|
|
|
5009
5822
|
protected env: Env;
|
|
5010
5823
|
constructor(ctx: DurableObjectState, env: Env);
|
|
5011
5824
|
fetch?(request: Request): Response | Promise<Response>;
|
|
5012
|
-
alarm?(): void | Promise<void>;
|
|
5825
|
+
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
5013
5826
|
webSocketMessage?(
|
|
5014
5827
|
ws: WebSocket,
|
|
5015
5828
|
message: string | ArrayBuffer,
|
|
@@ -5022,6 +5835,60 @@ declare module "cloudflare:workers" {
|
|
|
5022
5835
|
): void | Promise<void>;
|
|
5023
5836
|
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
|
|
5024
5837
|
}
|
|
5838
|
+
export type WorkflowDurationLabel =
|
|
5839
|
+
| "second"
|
|
5840
|
+
| "minute"
|
|
5841
|
+
| "hour"
|
|
5842
|
+
| "day"
|
|
5843
|
+
| "week"
|
|
5844
|
+
| "month"
|
|
5845
|
+
| "year";
|
|
5846
|
+
export type WorkflowSleepDuration =
|
|
5847
|
+
| `${number} ${WorkflowDurationLabel}${"s" | ""}`
|
|
5848
|
+
| number;
|
|
5849
|
+
export type WorkflowDelayDuration = WorkflowSleepDuration;
|
|
5850
|
+
export type WorkflowTimeoutDuration = WorkflowSleepDuration;
|
|
5851
|
+
export type WorkflowBackoff = "constant" | "linear" | "exponential";
|
|
5852
|
+
export type WorkflowStepConfig = {
|
|
5853
|
+
retries?: {
|
|
5854
|
+
limit: number;
|
|
5855
|
+
delay: WorkflowDelayDuration | number;
|
|
5856
|
+
backoff?: WorkflowBackoff;
|
|
5857
|
+
};
|
|
5858
|
+
timeout?: WorkflowTimeoutDuration | number;
|
|
5859
|
+
};
|
|
5860
|
+
export type WorkflowEvent<T> = {
|
|
5861
|
+
payload: Readonly<T>;
|
|
5862
|
+
timestamp: Date;
|
|
5863
|
+
instanceId: string;
|
|
5864
|
+
};
|
|
5865
|
+
export abstract class WorkflowStep {
|
|
5866
|
+
do<T extends Rpc.Serializable<T>>(
|
|
5867
|
+
name: string,
|
|
5868
|
+
callback: () => Promise<T>,
|
|
5869
|
+
): Promise<T>;
|
|
5870
|
+
do<T extends Rpc.Serializable<T>>(
|
|
5871
|
+
name: string,
|
|
5872
|
+
config: WorkflowStepConfig,
|
|
5873
|
+
callback: () => Promise<T>,
|
|
5874
|
+
): Promise<T>;
|
|
5875
|
+
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
|
|
5876
|
+
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
|
|
5877
|
+
}
|
|
5878
|
+
export abstract class WorkflowEntrypoint<
|
|
5879
|
+
Env = unknown,
|
|
5880
|
+
T extends Rpc.Serializable<T> | unknown = unknown,
|
|
5881
|
+
> implements Rpc.WorkflowEntrypointBranded
|
|
5882
|
+
{
|
|
5883
|
+
[Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
|
|
5884
|
+
protected ctx: ExecutionContext;
|
|
5885
|
+
protected env: Env;
|
|
5886
|
+
constructor(ctx: ExecutionContext, env: Env);
|
|
5887
|
+
run(
|
|
5888
|
+
event: Readonly<WorkflowEvent<T>>,
|
|
5889
|
+
step: WorkflowStep,
|
|
5890
|
+
): Promise<unknown>;
|
|
5891
|
+
}
|
|
5025
5892
|
}
|
|
5026
5893
|
declare module "cloudflare:sockets" {
|
|
5027
5894
|
function _connect(
|
|
@@ -5030,6 +5897,198 @@ declare module "cloudflare:sockets" {
|
|
|
5030
5897
|
): Socket;
|
|
5031
5898
|
export { _connect as connect };
|
|
5032
5899
|
}
|
|
5900
|
+
declare namespace TailStream {
|
|
5901
|
+
interface Header {
|
|
5902
|
+
readonly name: string;
|
|
5903
|
+
readonly value: string;
|
|
5904
|
+
}
|
|
5905
|
+
interface FetchEventInfo {
|
|
5906
|
+
readonly type: "fetch";
|
|
5907
|
+
readonly method: string;
|
|
5908
|
+
readonly url: string;
|
|
5909
|
+
readonly cfJson: string;
|
|
5910
|
+
readonly headers: Header[];
|
|
5911
|
+
}
|
|
5912
|
+
interface JsRpcEventInfo {
|
|
5913
|
+
readonly type: "jsrpc";
|
|
5914
|
+
readonly methodName: string;
|
|
5915
|
+
}
|
|
5916
|
+
interface ScheduledEventInfo {
|
|
5917
|
+
readonly type: "scheduled";
|
|
5918
|
+
readonly scheduledTime: Date;
|
|
5919
|
+
readonly cron: string;
|
|
5920
|
+
}
|
|
5921
|
+
interface AlarmEventInfo {
|
|
5922
|
+
readonly type: "alarm";
|
|
5923
|
+
readonly scheduledTime: Date;
|
|
5924
|
+
}
|
|
5925
|
+
interface QueueEventInfo {
|
|
5926
|
+
readonly type: "queue";
|
|
5927
|
+
readonly queueName: string;
|
|
5928
|
+
readonly batchSize: number;
|
|
5929
|
+
}
|
|
5930
|
+
interface EmailEventInfo {
|
|
5931
|
+
readonly type: "email";
|
|
5932
|
+
readonly mailFrom: string;
|
|
5933
|
+
readonly rcptTo: string;
|
|
5934
|
+
readonly rawSize: number;
|
|
5935
|
+
}
|
|
5936
|
+
interface TraceEventInfo {
|
|
5937
|
+
readonly type: "trace";
|
|
5938
|
+
readonly traces: (string | null)[];
|
|
5939
|
+
}
|
|
5940
|
+
interface HibernatableWebSocketEventInfoMessage {
|
|
5941
|
+
readonly type: "message";
|
|
5942
|
+
}
|
|
5943
|
+
interface HibernatableWebSocketEventInfoError {
|
|
5944
|
+
readonly type: "error";
|
|
5945
|
+
}
|
|
5946
|
+
interface HibernatableWebSocketEventInfoClose {
|
|
5947
|
+
readonly type: "close";
|
|
5948
|
+
readonly code: number;
|
|
5949
|
+
readonly wasClean: boolean;
|
|
5950
|
+
}
|
|
5951
|
+
interface HibernatableWebSocketEventInfo {
|
|
5952
|
+
readonly type: "hibernatableWebSocket";
|
|
5953
|
+
readonly info:
|
|
5954
|
+
| HibernatableWebSocketEventInfoClose
|
|
5955
|
+
| HibernatableWebSocketEventInfoError
|
|
5956
|
+
| HibernatableWebSocketEventInfoMessage;
|
|
5957
|
+
}
|
|
5958
|
+
interface Resume {
|
|
5959
|
+
readonly type: "resume";
|
|
5960
|
+
readonly attachment?: any;
|
|
5961
|
+
}
|
|
5962
|
+
interface CustomEventInfo {
|
|
5963
|
+
readonly type: "custom";
|
|
5964
|
+
}
|
|
5965
|
+
interface FetchResponseInfo {
|
|
5966
|
+
readonly type: "fetch";
|
|
5967
|
+
readonly statusCode: number;
|
|
5968
|
+
}
|
|
5969
|
+
type EventOutcome =
|
|
5970
|
+
| "ok"
|
|
5971
|
+
| "canceled"
|
|
5972
|
+
| "exception"
|
|
5973
|
+
| "unknown"
|
|
5974
|
+
| "killSwitch"
|
|
5975
|
+
| "daemonDown"
|
|
5976
|
+
| "exceededCpu"
|
|
5977
|
+
| "exceededMemory"
|
|
5978
|
+
| "loadShed"
|
|
5979
|
+
| "responseStreamDisconnected"
|
|
5980
|
+
| "scriptNotFound";
|
|
5981
|
+
interface ScriptVersion {
|
|
5982
|
+
readonly id: string;
|
|
5983
|
+
readonly tag?: string;
|
|
5984
|
+
readonly message?: string;
|
|
5985
|
+
}
|
|
5986
|
+
interface Trigger {
|
|
5987
|
+
readonly traceId: string;
|
|
5988
|
+
readonly invocationId: string;
|
|
5989
|
+
readonly spanId: string;
|
|
5990
|
+
}
|
|
5991
|
+
interface Onset {
|
|
5992
|
+
readonly type: "onset";
|
|
5993
|
+
readonly dispatchNamespace?: string;
|
|
5994
|
+
readonly entrypoint?: string;
|
|
5995
|
+
readonly scriptName?: string;
|
|
5996
|
+
readonly scriptTags?: string[];
|
|
5997
|
+
readonly scriptVersion?: ScriptVersion;
|
|
5998
|
+
readonly trigger?: Trigger;
|
|
5999
|
+
readonly info:
|
|
6000
|
+
| FetchEventInfo
|
|
6001
|
+
| JsRpcEventInfo
|
|
6002
|
+
| ScheduledEventInfo
|
|
6003
|
+
| AlarmEventInfo
|
|
6004
|
+
| QueueEventInfo
|
|
6005
|
+
| EmailEventInfo
|
|
6006
|
+
| TraceEventInfo
|
|
6007
|
+
| HibernatableWebSocketEventInfo
|
|
6008
|
+
| Resume
|
|
6009
|
+
| CustomEventInfo;
|
|
6010
|
+
}
|
|
6011
|
+
interface Outcome {
|
|
6012
|
+
readonly type: "outcome";
|
|
6013
|
+
readonly outcome: EventOutcome;
|
|
6014
|
+
readonly cpuTime: number;
|
|
6015
|
+
readonly wallTime: number;
|
|
6016
|
+
}
|
|
6017
|
+
interface Hibernate {
|
|
6018
|
+
readonly type: "hibernate";
|
|
6019
|
+
}
|
|
6020
|
+
interface SpanOpen {
|
|
6021
|
+
readonly type: "spanOpen";
|
|
6022
|
+
readonly op?: string;
|
|
6023
|
+
readonly info?: FetchEventInfo | JsRpcEventInfo | Attribute[];
|
|
6024
|
+
}
|
|
6025
|
+
interface SpanClose {
|
|
6026
|
+
readonly type: "spanClose";
|
|
6027
|
+
readonly outcome: EventOutcome;
|
|
6028
|
+
}
|
|
6029
|
+
interface DiagnosticChannelEvent {
|
|
6030
|
+
readonly type: "diagnosticChannel";
|
|
6031
|
+
readonly channel: string;
|
|
6032
|
+
readonly message: any;
|
|
6033
|
+
}
|
|
6034
|
+
interface Exception {
|
|
6035
|
+
readonly type: "exception";
|
|
6036
|
+
readonly name: string;
|
|
6037
|
+
readonly message: string;
|
|
6038
|
+
readonly stack?: string;
|
|
6039
|
+
}
|
|
6040
|
+
interface Log {
|
|
6041
|
+
readonly type: "log";
|
|
6042
|
+
readonly level: "debug" | "error" | "info" | "log" | "warn";
|
|
6043
|
+
readonly message: string;
|
|
6044
|
+
}
|
|
6045
|
+
interface Return {
|
|
6046
|
+
readonly type: "return";
|
|
6047
|
+
readonly info?: FetchResponseInfo | Attribute[];
|
|
6048
|
+
}
|
|
6049
|
+
interface Link {
|
|
6050
|
+
readonly type: "link";
|
|
6051
|
+
readonly label?: string;
|
|
6052
|
+
readonly traceId: string;
|
|
6053
|
+
readonly invocationId: string;
|
|
6054
|
+
readonly spanId: string;
|
|
6055
|
+
}
|
|
6056
|
+
interface Attribute {
|
|
6057
|
+
readonly type: "attribute";
|
|
6058
|
+
readonly name: string;
|
|
6059
|
+
readonly value: string | string[] | boolean | boolean[] | number | number[];
|
|
6060
|
+
}
|
|
6061
|
+
type Mark =
|
|
6062
|
+
| DiagnosticChannelEvent
|
|
6063
|
+
| Exception
|
|
6064
|
+
| Log
|
|
6065
|
+
| Return
|
|
6066
|
+
| Link
|
|
6067
|
+
| Attribute[];
|
|
6068
|
+
interface TailEvent {
|
|
6069
|
+
readonly traceId: string;
|
|
6070
|
+
readonly invocationId: string;
|
|
6071
|
+
readonly spanId: string;
|
|
6072
|
+
readonly timestamp: Date;
|
|
6073
|
+
readonly sequence: number;
|
|
6074
|
+
readonly event: Onset | Outcome | Hibernate | SpanOpen | SpanClose | Mark;
|
|
6075
|
+
}
|
|
6076
|
+
type TailEventHandler = (event: TailEvent) => void | Promise<void>;
|
|
6077
|
+
type TailEventHandlerName =
|
|
6078
|
+
| "onset"
|
|
6079
|
+
| "outcome"
|
|
6080
|
+
| "hibernate"
|
|
6081
|
+
| "spanOpen"
|
|
6082
|
+
| "spanClose"
|
|
6083
|
+
| "diagnosticChannel"
|
|
6084
|
+
| "exception"
|
|
6085
|
+
| "log"
|
|
6086
|
+
| "return"
|
|
6087
|
+
| "link"
|
|
6088
|
+
| "attribute";
|
|
6089
|
+
type TailEventHandlerObject = Record<TailEventHandlerName, TailEventHandler>;
|
|
6090
|
+
type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
|
|
6091
|
+
}
|
|
5033
6092
|
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5034
6093
|
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5035
6094
|
// https://opensource.org/licenses/Apache-2.0
|
|
@@ -5073,11 +6132,21 @@ type VectorizeVectorMetadataFilter = {
|
|
|
5073
6132
|
* Distance metrics determine how other "similar" vectors are determined.
|
|
5074
6133
|
*/
|
|
5075
6134
|
type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
|
|
6135
|
+
/**
|
|
6136
|
+
* Metadata return levels for a Vectorize query.
|
|
6137
|
+
*
|
|
6138
|
+
* Default to "none".
|
|
6139
|
+
*
|
|
6140
|
+
* @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.
|
|
6141
|
+
* @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).
|
|
6142
|
+
* @property none No indexed metadata will be returned.
|
|
6143
|
+
*/
|
|
6144
|
+
type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
|
|
5076
6145
|
interface VectorizeQueryOptions {
|
|
5077
6146
|
topK?: number;
|
|
5078
6147
|
namespace?: string;
|
|
5079
6148
|
returnValues?: boolean;
|
|
5080
|
-
returnMetadata?: boolean;
|
|
6149
|
+
returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
|
|
5081
6150
|
filter?: VectorizeVectorMetadataFilter;
|
|
5082
6151
|
}
|
|
5083
6152
|
/**
|
|
@@ -5093,6 +6162,9 @@ type VectorizeIndexConfig =
|
|
|
5093
6162
|
};
|
|
5094
6163
|
/**
|
|
5095
6164
|
* Metadata about an existing index.
|
|
6165
|
+
*
|
|
6166
|
+
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
|
|
6167
|
+
* See {@link VectorizeIndexInfo} for its post-beta equivalent.
|
|
5096
6168
|
*/
|
|
5097
6169
|
interface VectorizeIndexDetails {
|
|
5098
6170
|
/** The unique ID of the index */
|
|
@@ -5106,6 +6178,19 @@ interface VectorizeIndexDetails {
|
|
|
5106
6178
|
/** The number of records containing vectors within the index. */
|
|
5107
6179
|
vectorsCount: number;
|
|
5108
6180
|
}
|
|
6181
|
+
/**
|
|
6182
|
+
* Metadata about an existing index.
|
|
6183
|
+
*/
|
|
6184
|
+
interface VectorizeIndexInfo {
|
|
6185
|
+
/** The number of records containing vectors within the index. */
|
|
6186
|
+
vectorCount: number;
|
|
6187
|
+
/** Number of dimensions the index has been configured for. */
|
|
6188
|
+
dimensions: number;
|
|
6189
|
+
/** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
|
|
6190
|
+
processedUpToDatetime: number;
|
|
6191
|
+
/** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
|
|
6192
|
+
processedUpToMutation: number;
|
|
6193
|
+
}
|
|
5109
6194
|
/**
|
|
5110
6195
|
* Represents a single vector value set along with its associated metadata.
|
|
5111
6196
|
*/
|
|
@@ -5116,7 +6201,7 @@ interface VectorizeVector {
|
|
|
5116
6201
|
values: VectorFloatArray | number[];
|
|
5117
6202
|
/** The namespace this vector belongs to. */
|
|
5118
6203
|
namespace?: string;
|
|
5119
|
-
/** Metadata associated with the vector. Includes the values of
|
|
6204
|
+
/** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
|
|
5120
6205
|
metadata?: Record<string, VectorizeVectorMetadata>;
|
|
5121
6206
|
}
|
|
5122
6207
|
/**
|
|
@@ -5128,7 +6213,7 @@ type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
|
|
|
5128
6213
|
score: number;
|
|
5129
6214
|
};
|
|
5130
6215
|
/**
|
|
5131
|
-
* A set of
|
|
6216
|
+
* A set of matching {@link VectorizeMatch} for a particular query.
|
|
5132
6217
|
*/
|
|
5133
6218
|
interface VectorizeMatches {
|
|
5134
6219
|
matches: VectorizeMatch[];
|
|
@@ -5137,6 +6222,9 @@ interface VectorizeMatches {
|
|
|
5137
6222
|
/**
|
|
5138
6223
|
* Results of an operation that performed a mutation on a set of vectors.
|
|
5139
6224
|
* Here, `ids` is a list of vectors that were successfully processed.
|
|
6225
|
+
*
|
|
6226
|
+
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
|
|
6227
|
+
* See {@link VectorizeAsyncMutation} for its post-beta equivalent.
|
|
5140
6228
|
*/
|
|
5141
6229
|
interface VectorizeVectorMutation {
|
|
5142
6230
|
/* List of ids of vectors that were successfully processed. */
|
|
@@ -5145,14 +6233,19 @@ interface VectorizeVectorMutation {
|
|
|
5145
6233
|
count: number;
|
|
5146
6234
|
}
|
|
5147
6235
|
/**
|
|
5148
|
-
*
|
|
5149
|
-
*
|
|
5150
|
-
* Here, `mutationId` is the identifier for the last mutation processed by Vectorize.
|
|
6236
|
+
* Result type indicating a mutation on the Vectorize Index.
|
|
6237
|
+
* Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
|
|
5151
6238
|
*/
|
|
5152
|
-
interface
|
|
5153
|
-
|
|
6239
|
+
interface VectorizeAsyncMutation {
|
|
6240
|
+
/** The unique identifier for the async mutation operation containing the changeset. */
|
|
5154
6241
|
mutationId: string;
|
|
5155
6242
|
}
|
|
6243
|
+
/**
|
|
6244
|
+
* A Vectorize Vector Search Index for querying vectors/embeddings.
|
|
6245
|
+
*
|
|
6246
|
+
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
|
|
6247
|
+
* See {@link Vectorize} for its new implementation.
|
|
6248
|
+
*/
|
|
5156
6249
|
declare abstract class VectorizeIndex {
|
|
5157
6250
|
/**
|
|
5158
6251
|
* Get information about the currently bound index.
|
|
@@ -5167,7 +6260,7 @@ declare abstract class VectorizeIndex {
|
|
|
5167
6260
|
*/
|
|
5168
6261
|
public query(
|
|
5169
6262
|
vector: VectorFloatArray | number[],
|
|
5170
|
-
options
|
|
6263
|
+
options?: VectorizeQueryOptions,
|
|
5171
6264
|
): Promise<VectorizeMatches>;
|
|
5172
6265
|
/**
|
|
5173
6266
|
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
@@ -5194,6 +6287,62 @@ declare abstract class VectorizeIndex {
|
|
|
5194
6287
|
*/
|
|
5195
6288
|
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
5196
6289
|
}
|
|
6290
|
+
/**
|
|
6291
|
+
* A Vectorize Vector Search Index for querying vectors/embeddings.
|
|
6292
|
+
*
|
|
6293
|
+
* Mutations in this version are async, returning a mutation id.
|
|
6294
|
+
*/
|
|
6295
|
+
declare abstract class Vectorize {
|
|
6296
|
+
/**
|
|
6297
|
+
* Get information about the currently bound index.
|
|
6298
|
+
* @returns A promise that resolves with information about the current index.
|
|
6299
|
+
*/
|
|
6300
|
+
public describe(): Promise<VectorizeIndexInfo>;
|
|
6301
|
+
/**
|
|
6302
|
+
* Use the provided vector to perform a similarity search across the index.
|
|
6303
|
+
* @param vector Input vector that will be used to drive the similarity search.
|
|
6304
|
+
* @param options Configuration options to massage the returned data.
|
|
6305
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
6306
|
+
*/
|
|
6307
|
+
public query(
|
|
6308
|
+
vector: VectorFloatArray | number[],
|
|
6309
|
+
options?: VectorizeQueryOptions,
|
|
6310
|
+
): Promise<VectorizeMatches>;
|
|
6311
|
+
/**
|
|
6312
|
+
* Use the provided vector-id to perform a similarity search across the index.
|
|
6313
|
+
* @param vectorId Id for a vector in the index against which the index should be queried.
|
|
6314
|
+
* @param options Configuration options to massage the returned data.
|
|
6315
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
6316
|
+
*/
|
|
6317
|
+
public queryById(
|
|
6318
|
+
vectorId: string,
|
|
6319
|
+
options?: VectorizeQueryOptions,
|
|
6320
|
+
): Promise<VectorizeMatches>;
|
|
6321
|
+
/**
|
|
6322
|
+
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
6323
|
+
* @param vectors List of vectors that will be inserted.
|
|
6324
|
+
* @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
|
|
6325
|
+
*/
|
|
6326
|
+
public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
|
|
6327
|
+
/**
|
|
6328
|
+
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
|
|
6329
|
+
* @param vectors List of vectors that will be upserted.
|
|
6330
|
+
* @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
|
|
6331
|
+
*/
|
|
6332
|
+
public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
|
|
6333
|
+
/**
|
|
6334
|
+
* Delete a list of vectors with a matching id.
|
|
6335
|
+
* @param ids List of vector ids that should be deleted.
|
|
6336
|
+
* @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
|
|
6337
|
+
*/
|
|
6338
|
+
public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
|
|
6339
|
+
/**
|
|
6340
|
+
* Get a list of vectors with a matching id.
|
|
6341
|
+
* @param ids List of vector ids that should be returned.
|
|
6342
|
+
* @returns A promise that resolves with the raw unscored vectors matching the id set.
|
|
6343
|
+
*/
|
|
6344
|
+
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
6345
|
+
}
|
|
5197
6346
|
/**
|
|
5198
6347
|
* The interface for "version_metadata" binding
|
|
5199
6348
|
* providing metadata about the Worker Version using this binding.
|
|
@@ -5244,3 +6393,79 @@ interface DispatchNamespace {
|
|
|
5244
6393
|
options?: DynamicDispatchOptions,
|
|
5245
6394
|
): Fetcher;
|
|
5246
6395
|
}
|
|
6396
|
+
declare module "cloudflare:workflows" {
|
|
6397
|
+
/**
|
|
6398
|
+
* NonRetryableError allows for a user to throw a fatal error
|
|
6399
|
+
* that makes a Workflow instance fail immediately without triggering a retry
|
|
6400
|
+
*/
|
|
6401
|
+
export class NonRetryableError extends Error {
|
|
6402
|
+
public constructor(message: string, name?: string);
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
declare abstract class Workflow<PARAMS = unknown> {
|
|
6406
|
+
/**
|
|
6407
|
+
* Get a handle to an existing instance of the Workflow.
|
|
6408
|
+
* @param id Id for the instance of this Workflow
|
|
6409
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
6410
|
+
*/
|
|
6411
|
+
public get(id: string): Promise<WorkflowInstance>;
|
|
6412
|
+
/**
|
|
6413
|
+
* Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
|
|
6414
|
+
* @param options Options when creating an instance including id and params
|
|
6415
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
6416
|
+
*/
|
|
6417
|
+
public create(
|
|
6418
|
+
options?: WorkflowInstanceCreateOptions<PARAMS>,
|
|
6419
|
+
): Promise<WorkflowInstance>;
|
|
6420
|
+
}
|
|
6421
|
+
interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
|
|
6422
|
+
/**
|
|
6423
|
+
* An id for your Workflow instance. Must be unique within the Workflow.
|
|
6424
|
+
*/
|
|
6425
|
+
id?: string;
|
|
6426
|
+
/**
|
|
6427
|
+
* The event payload the Workflow instance is triggered with
|
|
6428
|
+
*/
|
|
6429
|
+
params?: PARAMS;
|
|
6430
|
+
}
|
|
6431
|
+
type InstanceStatus = {
|
|
6432
|
+
status:
|
|
6433
|
+
| "queued" // means that instance is waiting to be started (see concurrency limits)
|
|
6434
|
+
| "running"
|
|
6435
|
+
| "paused"
|
|
6436
|
+
| "errored"
|
|
6437
|
+
| "terminated" // user terminated the instance while it was running
|
|
6438
|
+
| "complete"
|
|
6439
|
+
| "waiting" // instance is hibernating and waiting for sleep or event to finish
|
|
6440
|
+
| "waitingForPause" // instance is finishing the current work to pause
|
|
6441
|
+
| "unknown";
|
|
6442
|
+
error?: string;
|
|
6443
|
+
output?: object;
|
|
6444
|
+
};
|
|
6445
|
+
interface WorkflowError {
|
|
6446
|
+
code?: number;
|
|
6447
|
+
message: string;
|
|
6448
|
+
}
|
|
6449
|
+
declare abstract class WorkflowInstance {
|
|
6450
|
+
public id: string;
|
|
6451
|
+
/**
|
|
6452
|
+
* Pause the instance.
|
|
6453
|
+
*/
|
|
6454
|
+
public pause(): Promise<void>;
|
|
6455
|
+
/**
|
|
6456
|
+
* Resume the instance. If it is already running, an error will be thrown.
|
|
6457
|
+
*/
|
|
6458
|
+
public resume(): Promise<void>;
|
|
6459
|
+
/**
|
|
6460
|
+
* Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
|
|
6461
|
+
*/
|
|
6462
|
+
public terminate(): Promise<void>;
|
|
6463
|
+
/**
|
|
6464
|
+
* Restart the instance.
|
|
6465
|
+
*/
|
|
6466
|
+
public restart(): Promise<void>;
|
|
6467
|
+
/**
|
|
6468
|
+
* Returns the current status of the instance.
|
|
6469
|
+
*/
|
|
6470
|
+
public status(): Promise<InstanceStatus>;
|
|
6471
|
+
}
|