1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
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
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
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: cde5d6bbbb8f5d59a6f6313ce6d7b38b)
// Runtime types generated with workerd@1.20251109.0 2025-11-15
declare namespace Cloudflare {
interface GlobalProps {
mainModule: typeof import("./worker/index");
}
interface Env {
}
}
interface Env extends Cloudflare.Env {}
// Begin runtime types
/*! *****************************************************************************
Copyright (c) Cloudflare. All rights reserved.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* eslint-disable */
// noinspection JSUnusedGlobalSymbols
declare var onmessage: never;
/**
* The **`DOMException`** interface represents an abnormal event (called an **exception**) that occurs as a result of calling a method or accessing a property of a web API.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
*/
declare class DOMException extends Error {
constructor(message?: string, name?: string);
/**
* The **`message`** read-only property of the a message or description associated with the given error name.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)
*/
readonly message: string;
/**
* The **`name`** read-only property of the one of the strings associated with an error name.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)
*/
readonly name: string;
/**
* The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match.
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
*/
readonly code: number;
static readonly INDEX_SIZE_ERR: number;
static readonly DOMSTRING_SIZE_ERR: number;
static readonly HIERARCHY_REQUEST_ERR: number;
static readonly WRONG_DOCUMENT_ERR: number;
static readonly INVALID_CHARACTER_ERR: number;
static readonly NO_DATA_ALLOWED_ERR: number;
static readonly NO_MODIFICATION_ALLOWED_ERR: number;
static readonly NOT_FOUND_ERR: number;
static readonly NOT_SUPPORTED_ERR: number;
static readonly INUSE_ATTRIBUTE_ERR: number;
static readonly INVALID_STATE_ERR: number;
static readonly SYNTAX_ERR: number;
static readonly INVALID_MODIFICATION_ERR: number;
static readonly NAMESPACE_ERR: number;
static readonly INVALID_ACCESS_ERR: number;
static readonly VALIDATION_ERR: number;
static readonly TYPE_MISMATCH_ERR: number;
static readonly SECURITY_ERR: number;
static readonly NETWORK_ERR: number;
static readonly ABORT_ERR: number;
static readonly URL_MISMATCH_ERR: number;
static readonly QUOTA_EXCEEDED_ERR: number;
static readonly TIMEOUT_ERR: number;
static readonly INVALID_NODE_TYPE_ERR: number;
static readonly DATA_CLONE_ERR: number;
get stack(): any;
set stack(value: any);
}
type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
scheduled: ScheduledEvent;
queue: QueueEvent;
unhandledrejection: PromiseRejectionEvent;
rejectionhandled: PromiseRejectionEvent;
};
declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
EventTarget: typeof EventTarget;
}
/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *
* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
*/
interface Console {
"assert"(condition?: boolean, ...data: any[]): void;
/**
* The **`console.clear()`** static method clears the console if possible.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)
*/
clear(): void;
/**
* The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)
*/
count(label?: string): void;
/**
* The **`console.countReset()`** static method resets counter used with console/count_static.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)
*/
countReset(label?: string): void;
/**
* The **`console.debug()`** static method outputs a message to the console at the 'debug' log level.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
*/
debug(...data: any[]): void;
/**
* The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)
*/
dir(item?: any, options?: any): void;
/**
* The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)
*/
dirxml(...data: any[]): void;
/**
* The **`console.error()`** static method outputs a message to the console at the 'error' log level.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
*/
error(...data: any[]): void;
/**
* The **`console.group()`** static method creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console/groupEnd_static is called.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)
*/
group(...data: any[]): void;
/**
* The **`console.groupCollapsed()`** static method creates a new inline group in the console.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)
*/
groupCollapsed(...data: any[]): void;
/**
* The **`console.groupEnd()`** static method exits the current inline group in the console.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)
*/
groupEnd(): void;
/**
* The **`console.info()`** static method outputs a message to the console at the 'info' log level.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
*/
info(...data: any[]): void;
/**
* The **`console.log()`** static method outputs a message to the console.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
*/
log(...data: any[]): void;
/**
* The **`console.table()`** static method displays tabular data as a table.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)
*/
table(tabularData?: any, properties?: string[]): void;
/**
* The **`console.time()`** static method starts a timer you can use to track how long an operation takes.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)
*/
time(label?: string): void;
/**
* The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)
*/
timeEnd(label?: string): void;
/**
* The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)
*/
timeLog(label?: string, ...data: any[]): void;
timeStamp(label?: string): void;
/**
* The **`console.trace()`** static method outputs a stack trace to the console.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
*/
trace(...data: any[]): void;
/**
* The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
*/
warn(...data: any[]): void;
}
declare const console: Console;
type BufferSource = ArrayBufferView | ArrayBuffer;
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
declare namespace WebAssembly {
class CompileError extends Error {
constructor(message?: string);
}
class RuntimeError extends Error {
constructor(message?: string);
}
type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
interface GlobalDescriptor {
value: ValueType;
mutable?: boolean;
}
class Global {
constructor(descriptor: GlobalDescriptor, value?: any);
value: any;
valueOf(): any;
}
type ImportValue = ExportValue | number;
type ModuleImports = Record<string, ImportValue>;
type Imports = Record<string, ModuleImports>;
type ExportValue = Function | Global | Memory | Table;
type Exports = Record<string, ExportValue>;
class Instance {
constructor(module: Module, imports?: Imports);
readonly exports: Exports;
}
interface MemoryDescriptor {
initial: number;
maximum?: number;
shared?: boolean;
}
class Memory {
constructor(descriptor: MemoryDescriptor);
readonly buffer: ArrayBuffer;
grow(delta: number): number;
}
type ImportExportKind = "function" | "global" | "memory" | "table";
interface ModuleExportDescriptor {
kind: ImportExportKind;
name: string;
}
interface ModuleImportDescriptor {
kind: ImportExportKind;
module: string;
name: string;
}
abstract class Module {
static customSections(module: Module, sectionName: string): ArrayBuffer[];
static exports(module: Module): ModuleExportDescriptor[];
static imports(module: Module): ModuleImportDescriptor[];
}
type TableKind = "anyfunc" | "externref";
interface TableDescriptor {
element: TableKind;
initial: number;
maximum?: number;
}
class Table {
constructor(descriptor: TableDescriptor, value?: any);
readonly length: number;
get(index: number): any;
grow(delta: number, value?: any): number;
set(index: number, value?: any): void;
}
function instantiate(module: Module, imports?: Imports): Promise<Instance>;
function validate(bytes: BufferSource): boolean;
}
/**
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
*/
interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
DOMException: typeof DOMException;
WorkerGlobalScope: typeof WorkerGlobalScope;
btoa(data: string): string;
atob(data: string): string;
setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
clearTimeout(timeoutId: number | null): void;
setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
clearInterval(timeoutId: number | null): void;
queueMicrotask(task: Function): void;
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
reportError(error: any): void;
fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
self: ServiceWorkerGlobalScope;
crypto: Crypto;
caches: CacheStorage;
scheduler: Scheduler;
performance: Performance;
Cloudflare: Cloudflare;
readonly origin: string;
Event: typeof Event;
ExtendableEvent: typeof ExtendableEvent;
CustomEvent: typeof CustomEvent;
PromiseRejectionEvent: typeof PromiseRejectionEvent;
FetchEvent: typeof FetchEvent;
TailEvent: typeof TailEvent;
TraceEvent: typeof TailEvent;
ScheduledEvent: typeof ScheduledEvent;
MessageEvent: typeof MessageEvent;
CloseEvent: typeof CloseEvent;
ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
ReadableStream: typeof ReadableStream;
WritableStream: typeof WritableStream;
WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
TransformStream: typeof TransformStream;
ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
CountQueuingStrategy: typeof CountQueuingStrategy;
ErrorEvent: typeof ErrorEvent;
MessageChannel: typeof MessageChannel;
MessagePort: typeof MessagePort;
EventSource: typeof EventSource;
ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
ReadableByteStreamController: typeof ReadableByteStreamController;
WritableStreamDefaultController: typeof WritableStreamDefaultController;
TransformStreamDefaultController: typeof TransformStreamDefaultController;
CompressionStream: typeof CompressionStream;
DecompressionStream: typeof DecompressionStream;
TextEncoderStream: typeof TextEncoderStream;
TextDecoderStream: typeof TextDecoderStream;
Headers: typeof Headers;
Body: typeof Body;
Request: typeof Request;
Response: typeof Response;
WebSocket: typeof WebSocket;
WebSocketPair: typeof WebSocketPair;
WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
AbortController: typeof AbortController;
AbortSignal: typeof AbortSignal;
TextDecoder: typeof TextDecoder;
TextEncoder: typeof TextEncoder;
navigator: Navigator;
Navigator: typeof Navigator;
URL: typeof URL;
URLSearchParams: typeof URLSearchParams;
URLPattern: typeof URLPattern;
Blob: typeof Blob;
File: typeof File;
FormData: typeof FormData;
Crypto: typeof Crypto;
SubtleCrypto: typeof SubtleCrypto;
CryptoKey: typeof CryptoKey;
CacheStorage: typeof CacheStorage;
Cache: typeof Cache;
FixedLengthStream: typeof FixedLengthStream;
IdentityTransformStream: typeof IdentityTransformStream;
HTMLRewriter: typeof HTMLRewriter;
}
declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
/**
* The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
declare function btoa(data: string): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
declare function atob(data: string): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
declare function clearTimeout(timeoutId: number | null): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
declare function clearInterval(timeoutId: number | null): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
declare function queueMicrotask(task: Function): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
declare function reportError(error: any): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
declare const self: ServiceWorkerGlobalScope;
/**
* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
* The Workers runtime implements the full surface of this API, but with some differences in
* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
* compared to those implemented in most browsers.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
*/
declare const crypto: Crypto;
/**
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
*/
declare const caches: CacheStorage;
declare const scheduler: Scheduler;
/**
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
* as well as timing of subrequests and other operations.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
*/
declare const performance: Performance;
declare const Cloudflare: Cloudflare;
declare const origin: string;
declare const navigator: Navigator;
interface TestController {
}
interface ExecutionContext<Props = unknown> {
waitUntil(promise: Promise<any>): void;
passThroughOnException(): void;
readonly props: Props;
}
type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Response | Promise<Response>;
type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
type ExportedHandlerTailStreamHandler<Env = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext) => void | Promise<void>;
type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> {
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
tail?: ExportedHandlerTailHandler<Env>;
trace?: ExportedHandlerTraceHandler<Env>;
tailStream?: ExportedHandlerTailStreamHandler<Env>;
scheduled?: ExportedHandlerScheduledHandler<Env>;
test?: ExportedHandlerTestHandler<Env>;
email?: EmailExportedHandler<Env>;
queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
}
interface StructuredSerializeOptions {
transfer?: any[];
}
declare abstract class Navigator {
sendBeacon(url: string, body?: (ReadableStream | string | (ArrayBuffer | ArrayBufferView) | Blob | FormData | URLSearchParams | URLSearchParams)): boolean;
readonly userAgent: string;
readonly hardwareConcurrency: number;
readonly language: string;
readonly languages: string[];
}
interface AlarmInvocationInfo {
readonly isRetry: boolean;
readonly retryCount: number;
}
interface Cloudflare {
readonly compatibilityFlags: Record<string, boolean>;
}
interface DurableObject {
fetch(request: Request): Response | Promise<Response>;
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
}
type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & {
readonly id: DurableObjectId;
readonly name?: string;
};
interface DurableObjectId {
toString(): string;
equals(other: DurableObjectId): boolean;
readonly name?: string;
}
declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
idFromName(name: string): DurableObjectId;
idFromString(id: string): DurableObjectId;
get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
}
type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
interface DurableObjectNamespaceNewUniqueIdOptions {
jurisdiction?: DurableObjectJurisdiction;
}
type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
interface DurableObjectNamespaceGetDurableObjectOptions {
locationHint?: DurableObjectLocationHint;
}
interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {
}
interface DurableObjectState<Props = unknown> {
waitUntil(promise: Promise<any>): void;
readonly props: Props;
readonly id: DurableObjectId;
readonly storage: DurableObjectStorage;
container?: Container;
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
getWebSockets(tag?: string): WebSocket[];
setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
getHibernatableWebSocketEventTimeout(): number | null;
getTags(ws: WebSocket): string[];
abort(reason?: string): void;
}
interface DurableObjectTransaction {
get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
rollback(): void;
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
}
interface DurableObjectStorage {
get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
deleteAll(options?: DurableObjectPutOptions): Promise<void>;
transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
sync(): Promise<void>;
sql: SqlStorage;
kv: SyncKvStorage;
transactionSync<T>(closure: () => T): T;
getCurrentBookmark(): Promise<string>;
getBookmarkForTime(timestamp: number | Date): Promise<string>;
onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
}
interface DurableObjectListOptions {
start?: string;
startAfter?: string;
end?: string;
prefix?: string;
reverse?: boolean;
limit?: number;
allowConcurrency?: boolean;
noCache?: boolean;
}
interface DurableObjectGetOptions {
allowConcurrency?: boolean;
noCache?: boolean;
}
interface DurableObjectGetAlarmOptions {
allowConcurrency?: boolean;
}
interface DurableObjectPutOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
noCache?: boolean;
}
interface DurableObjectSetAlarmOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
}
declare class WebSocketRequestResponsePair {
constructor(request: string, response: string);
get request(): string;
get response(): string;
}
interface AnalyticsEngineDataset {
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
}
interface AnalyticsEngineDataPoint {
indexes?: ((ArrayBuffer | string) | null)[];
doubles?: number[];
blobs?: ((ArrayBuffer | string) | null)[];
}
/**
* The **`Event`** interface represents an event which takes place on an `EventTarget`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
*/
declare class Event {
constructor(type: string, init?: EventInit);
/**
* The **`type`** read-only property of the Event interface returns a string containing the event's type.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
*/
get type(): string;
/**
* The **`eventPhase`** read-only property of the being evaluated.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
*/
get eventPhase(): number;
/**
* The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
*/
get composed(): boolean;
/**
* The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
*/
get bubbles(): boolean;
/**
* The **`cancelable`** read-only property of the Event interface indicates whether the event can be canceled, and therefore prevented as if the event never happened.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
*/
get cancelable(): boolean;
/**
* The **`defaultPrevented`** read-only property of the Event interface returns a boolean value indicating whether or not the call to Event.preventDefault() canceled the event.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
*/
get defaultPrevented(): boolean;
/**
* The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
*/
get returnValue(): boolean;
/**
* The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
*/
get currentTarget(): EventTarget | undefined;
/**
* The read-only **`target`** property of the dispatched.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
*/
get target(): EventTarget | undefined;
/**
* The deprecated **`Event.srcElement`** is an alias for the Event.target property.
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
*/
get srcElement(): EventTarget | undefined;
/**
* The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
*/
get timeStamp(): number;
/**
* The **`isTrusted`** read-only property of the when the event was generated by the user agent (including via user actions and programmatic methods such as HTMLElement.focus()), and `false` when the event was dispatched via The only exception is the `click` event, which initializes the `isTrusted` property to `false` in user agents.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
*/
get isTrusted(): boolean;
/**
* The **`cancelBubble`** property of the Event interface is deprecated.
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
*/
get cancelBubble(): boolean;
/**
* The **`cancelBubble`** property of the Event interface is deprecated.
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
*/
set cancelBubble(value: boolean);
/**
* The **`stopImmediatePropagation()`** method of the If several listeners are attached to the same element for the same event type, they are called in the order in which they were added.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
*/
stopImmediatePropagation(): void;
/**
* The **`preventDefault()`** method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
*/
preventDefault(): void;
/**
* The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
*/
stopPropagation(): void;
/**
* The **`composedPath()`** method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
*/
composedPath(): EventTarget[];
static readonly NONE: number;
static readonly CAPTURING_PHASE: number;
static readonly AT_TARGET: number;
static readonly BUBBLING_PHASE: number;
}
interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
}
type EventListener<EventType extends Event = Event> = (event: EventType) => void;
interface EventListenerObject<EventType extends Event = Event> {
handleEvent(event: EventType): void;
}
type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
/**
* The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
*/
declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
constructor();
/**
* The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
*/
addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
/**
* The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
*/
removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
/**
* The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
dispatchEvent(event: EventMap[keyof EventMap]): boolean;
}
interface EventTargetEventListenerOptions {
capture?: boolean;
}
interface EventTargetAddEventListenerOptions {
capture?: boolean;
passive?: boolean;
once?: boolean;
signal?: AbortSignal;
}
interface EventTargetHandlerObject {
handleEvent: (event: Event) => any | undefined;
}
/**
* The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
*/
declare class AbortController {
constructor();
/**
* The **`signal`** read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
*/
get signal(): AbortSignal;
/**
* The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
*/
abort(reason?: any): void;
}
/**
* The **`AbortSignal`** interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
*/
declare abstract class AbortSignal extends EventTarget {
/**
* The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
*/
static abort(reason?: any): AbortSignal;
/**
* The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
*/
static timeout(delay: number): AbortSignal;
/**
* The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
*/
static any(signals: AbortSignal[]): AbortSignal;
/**
* The **`aborted`** read-only property returns a value that indicates whether the asynchronous operations the signal is communicating with are aborted (`true`) or not (`false`).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
*/
get aborted(): boolean;
/**
* The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
*/
get reason(): any;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
get onabort(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
set onabort(value: any | null);
/**
* The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
*/
throwIfAborted(): void;
}
interface Scheduler {
wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
}
interface SchedulerWaitOptions {
signal?: AbortSignal;
}
/**
* The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
*/
declare abstract class ExtendableEvent extends Event {
/**
* The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
*/
waitUntil(promise: Promise<any>): void;
}
/**
* The **`CustomEvent`** interface represents events initialized by an application for any purpose.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
*/
declare class CustomEvent<T = any> extends Event {
constructor(type: string, init?: CustomEventCustomEventInit);
/**
* The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
*/
get detail(): T;
}
interface CustomEventCustomEventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
detail?: any;
}
/**
* The **`Blob`** interface represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
*/
declare class Blob {
constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
/**
* The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
*/
get size(): number;
/**
* The **`type`** read-only property of the Blob interface returns the MIME type of the file.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
*/
get type(): string;
/**
* The **`slice()`** method of the Blob interface creates and returns a new `Blob` object which contains data from a subset of the blob on which it's called.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
*/
slice(start?: number, end?: number, type?: string): Blob;
/**
* The **`arrayBuffer()`** method of the Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
*/
arrayBuffer(): Promise<ArrayBuffer>;
/**
* The **`bytes()`** method of the Blob interface returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
*/
bytes(): Promise<Uint8Array>;
/**
* The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
*/
text(): Promise<string>;
/**
* The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
*/
stream(): ReadableStream;
}
interface BlobOptions {
type?: string;
}
/**
* The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
*/
declare class File extends Blob {
constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
/**
* The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
*/
get name(): string;
/**
* The **`lastModified`** read-only property of the File interface provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
*/
get lastModified(): number;
}
interface FileOptions {
type?: string;
lastModified?: number;
}
/**
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
*/
declare abstract class CacheStorage {
/**
* The **`open()`** method of the the Cache object matching the `cacheName`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
*/
open(cacheName: string): Promise<Cache>;
readonly default: Cache;
}
/**
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
*/
declare abstract class Cache {
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
put(request: RequestInfo | URL, response: Response): Promise<void>;
}
interface CacheQueryOptions {
ignoreMethod?: boolean;
}
/**
* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
* The Workers runtime implements the full surface of this API, but with some differences in
* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
* compared to those implemented in most browsers.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
*/
declare abstract class Crypto {
/**
* The **`Crypto.subtle`** read-only property returns a cryptographic operations.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
*/
get subtle(): SubtleCrypto;
/**
* The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
*/
getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T;
/**
* The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
*/
randomUUID(): string;
DigestStream: typeof DigestStream;
}
/**
* The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
*/
declare abstract class SubtleCrypto {
/**
* The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
*/
encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
/**
* The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
*/
decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
/**
* The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
*/
sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
/**
* The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
*/
verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>;
/**
* The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
*/
digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
/**
* The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
*/
generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;
/**
* The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
*/
deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
/**
* The **`deriveBits()`** method of the key.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
*/
deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;
/**
* The **`importKey()`** method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
*/
importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
/**
* The **`exportKey()`** method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
*/
exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
/**
* The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
*/
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;
/**
* The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
*/
unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
}
/**
* The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods SubtleCrypto.generateKey, SubtleCrypto.deriveKey, SubtleCrypto.importKey, or SubtleCrypto.unwrapKey.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
*/
declare abstract class CryptoKey {
/**
* The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
*/
readonly type: string;
/**
* The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
*/
readonly extractable: boolean;
/**
* The read-only **`algorithm`** property of the CryptoKey interface returns an object describing the algorithm for which this key can be used, and any associated extra parameters.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
*/
readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;
/**
* The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
*/
readonly usages: string[];
}
interface CryptoKeyPair {
publicKey: CryptoKey;
privateKey: CryptoKey;
}
interface JsonWebKey {
kty: string;
use?: string;
key_ops?: string[];
alg?: string;
ext?: boolean;
crv?: string;
x?: string;
y?: string;
d?: string;
n?: string;
e?: string;
p?: string;
q?: string;
dp?: string;
dq?: string;
qi?: string;
oth?: RsaOtherPrimesInfo[];
k?: string;
}
interface RsaOtherPrimesInfo {
r?: string;
d?: string;
t?: string;
}
interface SubtleCryptoDeriveKeyAlgorithm {
name: string;
salt?: (ArrayBuffer | ArrayBufferView);
iterations?: number;
hash?: (string | SubtleCryptoHashAlgorithm);
$public?: CryptoKey;
info?: (ArrayBuffer | ArrayBufferView);
}
interface SubtleCryptoEncryptAlgorithm {
name: string;
iv?: (ArrayBuffer | ArrayBufferView);
additionalData?: (ArrayBuffer | ArrayBufferView);
tagLength?: number;
counter?: (ArrayBuffer | ArrayBufferView);
length?: number;
label?: (ArrayBuffer | ArrayBufferView);
}
interface SubtleCryptoGenerateKeyAlgorithm {
name: string;
hash?: (string | SubtleCryptoHashAlgorithm);
modulusLength?: number;
publicExponent?: (ArrayBuffer | ArrayBufferView);
length?: number;
namedCurve?: string;
}
interface SubtleCryptoHashAlgorithm {
name: string;
}
interface SubtleCryptoImportKeyAlgorithm {
name: string;
hash?: (string | SubtleCryptoHashAlgorithm);
length?: number;
namedCurve?: string;
compressed?: boolean;
}
interface SubtleCryptoSignAlgorithm {
name: string;
hash?: (string | SubtleCryptoHashAlgorithm);
dataLength?: number;
saltLength?: number;
}
interface CryptoKeyKeyAlgorithm {
name: string;
}
interface CryptoKeyAesKeyAlgorithm {
name: string;
length: number;
}
interface CryptoKeyHmacKeyAlgorithm {
name: string;
hash: CryptoKeyKeyAlgorithm;
length: number;
}
interface CryptoKeyRsaKeyAlgorithm {
name: string;
modulusLength: number;
publicExponent: ArrayBuffer | ArrayBufferView;
hash?: CryptoKeyKeyAlgorithm;
}
interface CryptoKeyEllipticKeyAlgorithm {
name: string;
namedCurve: string;
}
interface CryptoKeyArbitraryKeyAlgorithm {
name: string;
hash?: CryptoKeyKeyAlgorithm;
namedCurve?: string;
length?: number;
}
declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
constructor(algorithm: string | SubtleCryptoHashAlgorithm);
readonly digest: Promise<ArrayBuffer>;
get bytesWritten(): number | bigint;
}
/**
* The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
*/
declare class TextDecoder {
constructor(label?: string, options?: TextDecoderConstructorOptions);
/**
* The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
*/
decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;
get encoding(): string;
get fatal(): boolean;
get ignoreBOM(): boolean;
}
/**
* The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
*/
declare class TextEncoder {
constructor();
/**
* The **`TextEncoder.encode()`** method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
*/
encode(input?: string): Uint8Array;
/**
* The **`TextEncoder.encodeInto()`** method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
*/
encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
get encoding(): string;
}
interface TextDecoderConstructorOptions {
fatal: boolean;
ignoreBOM: boolean;
}
interface TextDecoderDecodeOptions {
stream: boolean;
}
interface TextEncoderEncodeIntoResult {
read: number;
written: number;
}
/**
* The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
*/
declare class ErrorEvent extends Event {
constructor(type: string, init?: ErrorEventErrorEventInit);
/**
* The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
*/
get filename(): string;
/**
* The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
*/
get message(): string;
/**
* The **`lineno`** read-only property of the ErrorEvent interface returns an integer containing the line number of the script file on which the error occurred.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
*/
get lineno(): number;
/**
* The **`colno`** read-only property of the ErrorEvent interface returns an integer containing the column number of the script file on which the error occurred.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
*/
get colno(): number;
/**
* The **`error`** read-only property of the ErrorEvent interface returns a JavaScript value, such as an Error or DOMException, representing the error associated with this event.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
*/
get error(): any;
}
interface ErrorEventErrorEventInit {
message?: string;
filename?: string;
lineno?: number;
colno?: number;
error?: any;
}
/**
* The **`MessageEvent`** interface represents a message received by a target object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
*/
declare class MessageEvent extends Event {
constructor(type: string, initializer: MessageEventInit);
/**
* The **`data`** read-only property of the The data sent by the message emitter; this can be any data type, depending on what originated this event.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
*/
readonly data: any;
/**
* The **`origin`** read-only property of the origin of the message emitter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
*/
readonly origin: string | null;
/**
* The **`lastEventId`** read-only property of the unique ID for the event.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
*/
readonly lastEventId: string;
/**
* The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
*/
readonly source: MessagePort | null;
/**
* The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
*/
readonly ports: MessagePort[];
}
interface MessageEventInit {
data: ArrayBuffer | string;
}
/**
* The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
*/
declare abstract class PromiseRejectionEvent extends Event {
/**
* The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
*/
readonly promise: Promise<any>;
/**
* The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
*/
readonly reason: any;
}
/**
* The **`FormData`** interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the Window/fetch, XMLHttpRequest.send() or navigator.sendBeacon() methods.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
*/
declare class FormData {
constructor();
/**
* The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
*/
append(name: string, value: string): void;
/**
* The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
*/
append(name: string, value: Blob, filename?: string): void;
/**
* The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
*/
delete(name: string): void;
/**
* The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
*/
get(name: string): (File | string) | null;
/**
* The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
*/
getAll(name: string): (File | string)[];
/**
* The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
*/
has(name: string): boolean;
/**
* The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
*/
set(name: string, value: string): void;
/**
* The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
*/
set(name: string, value: Blob, filename?: string): void;
/* Returns an array of key, value pairs for every entry in the list. */
entries(): IterableIterator<[
key: string,
value: File | string
]>;
/* Returns a list of keys in the list. */
keys(): IterableIterator<string>;
/* Returns a list of values in the list. */
values(): IterableIterator<(File | string)>;
forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
[Symbol.iterator](): IterableIterator<[
key: string,
value: File | string
]>;
}
interface ContentOptions {
html?: boolean;
}
declare class HTMLRewriter {
constructor();
on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
transform(response: Response): Response;
}
interface HTMLRewriterElementContentHandlers {
element?(element: Element): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(element: Text): void | Promise<void>;
}
interface HTMLRewriterDocumentContentHandlers {
doctype?(doctype: Doctype): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(text: Text): void | Promise<void>;
end?(end: DocumentEnd): void | Promise<void>;
}
interface Doctype {
readonly name: string | null;
readonly publicId: string | null;
readonly systemId: string | null;
}
interface Element {
tagName: string;
readonly attributes: IterableIterator<string[]>;
readonly removed: boolean;
readonly namespaceURI: string;
getAttribute(name: string): string | null;
hasAttribute(name: string): boolean;
setAttribute(name: string, value: string): Element;
removeAttribute(name: string): Element;
before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
remove(): Element;
removeAndKeepContent(): Element;
setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
}
interface EndTag {
name: string;
before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
remove(): EndTag;
}
interface Comment {
text: string;
readonly removed: boolean;
before(content: string, options?: ContentOptions): Comment;
after(content: string, options?: ContentOptions): Comment;
replace(content: string, options?: ContentOptions): Comment;
remove(): Comment;
}
interface Text {
readonly text: string;
readonly lastInTextNode: boolean;
readonly removed: boolean;
before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
remove(): Text;
}
interface DocumentEnd {
append(content: string, options?: ContentOptions): DocumentEnd;
}
/**
* This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
*/
declare abstract class FetchEvent extends ExtendableEvent {
/**
* The **`request`** read-only property of the the event handler.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
*/
readonly request: Request;
/**
* The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
*/
respondWith(promise: Response | Promise<Response>): void;
passThroughOnException(): void;
}
type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;
/**
* The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
*/
declare class Headers {
constructor(init?: HeadersInit);
/**
* The **`get()`** method of the Headers interface returns a byte string of all the values of a header within a `Headers` object with a given name.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
*/
get(name: string): string | null;
getAll(name: string): string[];
/**
* The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
*/
getSetCookie(): string[];
/**
* The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
*/
has(name: string): boolean;
/**
* The **`set()`** method of the Headers interface sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
*/
set(name: string, value: string): void;
/**
* The **`append()`** method of the Headers interface appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
*/
append(name: string, value: string): void;
/**
* The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
*/
delete(name: string): void;
forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
/* Returns an iterator allowing to go through all key/value pairs contained in this object. */
entries(): IterableIterator<[
key: string,
value: string
]>;
/* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
keys(): IterableIterator<string>;
/* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
values(): IterableIterator<string>;
[Symbol.iterator](): IterableIterator<[
key: string,
value: string
]>;
}
type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData;
declare abstract class Body {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
get body(): ReadableStream | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
get bodyUsed(): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
arrayBuffer(): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
bytes(): Promise<Uint8Array>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
text(): Promise<string>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
json<T>(): Promise<T>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
formData(): Promise<FormData>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
blob(): Promise<Blob>;
}
/**
* The **`Response`** interface of the Fetch API represents the response to a request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
*/
declare var Response: {
prototype: Response;
new (body?: BodyInit | null, init?: ResponseInit): Response;
error(): Response;
redirect(url: string, status?: number): Response;
json(any: any, maybeInit?: (ResponseInit | Response)): Response;
};
/**
* The **`Response`** interface of the Fetch API represents the response to a request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
*/
interface Response extends Body {
/**
* The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
*/
clone(): Response;
/**
* The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
*/
status: number;
/**
* The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
*/
statusText: string;
/**
* The **`headers`** read-only property of the with the response.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
*/
headers: Headers;
/**
* The **`ok`** read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
*/
ok: boolean;
/**
* The **`redirected`** read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
*/
redirected: boolean;
/**
* The **`url`** read-only property of the Response interface contains the URL of the response.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
*/
url: string;
webSocket: WebSocket | null;
cf: any | undefined;
/**
* The **`type`** read-only property of the Response interface contains the type of the response.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
*/
type: "default" | "error";
}
interface ResponseInit {
status?: number;
statusText?: string;
headers?: HeadersInit;
cf?: any;
webSocket?: (WebSocket | null);
encodeBody?: "automatic" | "manual";
}
type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;
/**
* The **`Request`** interface of the Fetch API represents a resource request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
*/
declare var Request: {
prototype: Request;
new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>;
};
/**
* The **`Request`** interface of the Fetch API represents a resource request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
*/
interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {
/**
* The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
*/
clone(): Request<CfHostMetadata, Cf>;
/**
* The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
*/
method: string;
/**
* The **`url`** read-only property of the Request interface contains the URL of the request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
*/
url: string;
/**
* The **`headers`** read-only property of the with the request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
*/
headers: Headers;
/**
* The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
*/
redirect: string;
fetcher: Fetcher | null;
/**
* The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
*/
signal: AbortSignal;
cf: Cf | undefined;
/**
* The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
*/
integrity: string;
/**
* The **`keepalive`** read-only property of the Request interface contains the request's `keepalive` setting (`true` or `false`), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
*/
keepalive: boolean;
/**
* The **`cache`** read-only property of the Request interface contains the cache mode of the request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
*/
cache?: "no-store" | "no-cache";
}
interface RequestInit<Cf = CfProperties> {
/* A string to set request's method. */
method?: string;
/* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
headers?: HeadersInit;
/* A BodyInit object or null to set request's body. */
body?: BodyInit | null;
/* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
redirect?: string;
fetcher?: (Fetcher | null);
cf?: Cf;
/* A string indicating how the request will interact with the browser's cache to set request's cache. */
cache?: "no-store" | "no-cache";
/* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
integrity?: string;
/* An AbortSignal to set request's signal. */
signal?: (AbortSignal | null);
encodeResponseBody?: "automatic" | "manual";
}
type Service<T extends (new (...args: any[]) => Rpc.WorkerEntrypointBranded) | Rpc.WorkerEntrypointBranded | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? Fetcher<InstanceType<T>> : T extends Rpc.WorkerEntrypointBranded ? Fetcher<T> : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded> ? never : Fetcher<undefined>;
type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & {
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
};
interface KVNamespaceListKey<Metadata, Key extends string = string> {
name: Key;
expiration?: number;
metadata?: Metadata;
}
type KVNamespaceListResult<Metadata, Key extends string = string> = {
list_complete: false;
keys: KVNamespaceListKey<Metadata, Key>[];
cursor: string;
cacheStatus: string | null;
} | {
list_complete: true;
keys: KVNamespaceListKey<Metadata, Key>[];
cacheStatus: string | null;
};
interface KVNamespace<Key extends string = string> {
get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
get(key: Key, type: "text"): Promise<string | null>;
get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;
get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
get(key: Key, type: "stream"): Promise<ReadableStream | null>;
get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;
get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;
get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;
get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;
get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;
list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;
put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
delete(key: Key): Promise<void>;
}
interface KVNamespaceListOptions {
limit?: number;
prefix?: (string | null);
cursor?: (string | null);
}
interface KVNamespaceGetOptions<Type> {
type: Type;
cacheTtl?: number;
}
interface KVNamespacePutOptions {
expiration?: number;
expirationTtl?: number;
metadata?: (any | null);
}
interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
value: Value | null;
metadata: Metadata | null;
cacheStatus: string | null;
}
type QueueContentType = "text" | "bytes" | "json" | "v8";
interface Queue<Body = unknown> {
send(message: Body, options?: QueueSendOptions): Promise<void>;
sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>;
}
interface QueueSendOptions {
contentType?: QueueContentType;
delaySeconds?: number;
}
interface QueueSendBatchOptions {
delaySeconds?: number;
}
interface MessageSendRequest<Body = unknown> {
body: Body;
contentType?: QueueContentType;
delaySeconds?: number;
}
interface QueueRetryOptions {
delaySeconds?: number;
}
interface Message<Body = unknown> {
readonly id: string;
readonly timestamp: Date;
readonly body: Body;
readonly attempts: number;
retry(options?: QueueRetryOptions): void;
ack(): void;
}
interface QueueEvent<Body = unknown> extends ExtendableEvent {
readonly messages: readonly Message<Body>[];
readonly queue: string;
retryAll(options?: QueueRetryOptions): void;
ackAll(): void;
}
interface MessageBatch<Body = unknown> {
readonly messages: readonly Message<Body>[];
readonly queue: string;
retryAll(options?: QueueRetryOptions): void;
ackAll(): void;
}
interface R2Error extends Error {
readonly name: string;
readonly code: number;
readonly message: string;
readonly action: string;
readonly stack: any;
}
interface R2ListOptions {
limit?: number;
prefix?: string;
cursor?: string;
delimiter?: string;
startAfter?: string;
include?: ("httpMetadata" | "customMetadata")[];
}
declare abstract class R2Bucket {
head(key: string): Promise<R2Object | null>;
get(key: string, options: R2GetOptions & {
onlyIf: R2Conditional | Headers;
}): Promise<R2ObjectBody | R2Object | null>;
get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & {
onlyIf: R2Conditional | Headers;
}): Promise<R2Object | null>;
put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;
createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;
resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
delete(keys: string | string[]): Promise<void>;
list(options?: R2ListOptions): Promise<R2Objects>;
}
interface R2MultipartUpload {
readonly key: string;
readonly uploadId: string;
uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>;
abort(): Promise<void>;
complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
}
interface R2UploadedPart {
partNumber: number;
etag: string;
}
declare abstract class R2Object {
readonly key: string;
readonly version: string;
readonly size: number;
readonly etag: string;
readonly httpEtag: string;
readonly checksums: R2Checksums;
readonly uploaded: Date;
readonly httpMetadata?: R2HTTPMetadata;
readonly customMetadata?: Record<string, string>;
readonly range?: R2Range;
readonly storageClass: string;
readonly ssecKeyMd5?: string;
writeHttpMetadata(headers: Headers): void;
}
interface R2ObjectBody extends R2Object {
get body(): ReadableStream;
get bodyUsed(): boolean;
arrayBuffer(): Promise<ArrayBuffer>;
bytes(): Promise<Uint8Array>;
text(): Promise<string>;
json<T>(): Promise<T>;
blob(): Promise<Blob>;
}
type R2Range = {
offset: number;
length?: number;
} | {
offset?: number;
length: number;
} | {
suffix: number;
};
interface R2Conditional {
etagMatches?: string;
etagDoesNotMatch?: string;
uploadedBefore?: Date;
uploadedAfter?: Date;
secondsGranularity?: boolean;
}
interface R2GetOptions {
onlyIf?: (R2Conditional | Headers);
range?: (R2Range | Headers);
ssecKey?: (ArrayBuffer | string);
}
interface R2PutOptions {
onlyIf?: (R2Conditional | Headers);
httpMetadata?: (R2HTTPMetadata | Headers);
customMetadata?: Record<string, string>;
md5?: ((ArrayBuffer | ArrayBufferView) | string);
sha1?: ((ArrayBuffer | ArrayBufferView) | string);
sha256?: ((ArrayBuffer | ArrayBufferView) | string);
sha384?: ((ArrayBuffer | ArrayBufferView) | string);
sha512?: ((ArrayBuffer | ArrayBufferView) | string);
storageClass?: string;
ssecKey?: (ArrayBuffer | string);
}
interface R2MultipartOptions {
httpMetadata?: (R2HTTPMetadata | Headers);
customMetadata?: Record<string, string>;
storageClass?: string;
ssecKey?: (ArrayBuffer | string);
}
interface R2Checksums {
readonly md5?: ArrayBuffer;
readonly sha1?: ArrayBuffer;
readonly sha256?: ArrayBuffer;
readonly sha384?: ArrayBuffer;
readonly sha512?: ArrayBuffer;
toJSON(): R2StringChecksums;
}
interface R2StringChecksums {
md5?: string;
sha1?: string;
sha256?: string;
sha384?: string;
sha512?: string;
}
interface R2HTTPMetadata {
contentType?: string;
contentLanguage?: string;
contentDisposition?: string;
contentEncoding?: string;
cacheControl?: string;
cacheExpiry?: Date;
}
type R2Objects = {
objects: R2Object[];
delimitedPrefixes: string[];
} & ({
truncated: true;
cursor: string;
} | {
truncated: false;
});
interface R2UploadPartOptions {
ssecKey?: (ArrayBuffer | string);
}
declare abstract class ScheduledEvent extends ExtendableEvent {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
}
interface ScheduledController {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
}
interface QueuingStrategy<T = any> {
highWaterMark?: (number | bigint);
size?: (chunk: T) => number | bigint;
}
interface UnderlyingSink<W = any> {
type?: string;
start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;
abort?: (reason: any) => void | Promise<void>;
close?: () => void | Promise<void>;
}
interface UnderlyingByteSource {
type: "bytes";
autoAllocateChunkSize?: number;
start?: (controller: ReadableByteStreamController) => void | Promise<void>;
pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
cancel?: (reason: any) => void | Promise<void>;
}
interface UnderlyingSource<R = any> {
type?: "" | undefined;
start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
cancel?: (reason: any) => void | Promise<void>;
expectedLength?: (number | bigint);
}
interface Transformer<I = any, O = any> {
readableType?: string;
writableType?: string;
start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;
flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
cancel?: (reason: any) => void | Promise<void>;
expectedLength?: number;
}
interface StreamPipeOptions {
/**
* Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
*
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
*
* Errors and closures of the source and destination streams propagate as follows:
*
* An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.
*
* An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.
*
* When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.
*
* If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.
*
* The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
*/
preventClose?: boolean;
preventAbort?: boolean;
preventCancel?: boolean;
signal?: AbortSignal;
}
type ReadableStreamReadResult<R = any> = {
done: false;
value: R;
} | {
done: true;
value?: undefined;
};
/**
* The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
*/
interface ReadableStream<R = any> {
/**
* The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
*/
get locked(): boolean;
/**
* The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
*/
cancel(reason?: any): Promise<void>;
/**
* The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
*/
getReader(): ReadableStreamDefaultReader<R>;
/**
* The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
*/
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
/**
* The **`pipeThrough()`** method of the ReadableStream interface provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
*/
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
/**
* The **`pipeTo()`** method of the ReadableStream interface pipes the current `ReadableStream` to a given WritableStream and returns a Promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
*/
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
/**
* The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
*/
tee(): [
ReadableStream<R>,
ReadableStream<R>
];
values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
[Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
}
/**
* The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
*/
declare const ReadableStream: {
prototype: ReadableStream;
new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
};
/**
* The **`ReadableStreamDefaultReader`** interface of the Streams API represents a default reader that can be used to read stream data supplied from a network (such as a fetch request).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
*/
declare class ReadableStreamDefaultReader<R = any> {
constructor(stream: ReadableStream);
get closed(): Promise<void>;
cancel(reason?: any): Promise<void>;
/**
* The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
*/
read(): Promise<ReadableStreamReadResult<R>>;
/**
* The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
*/
releaseLock(): void;
}
/**
* The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
*/
declare class ReadableStreamBYOBReader {
constructor(stream: ReadableStream);
get closed(): Promise<void>;
cancel(reason?: any): Promise<void>;
/**
* The **`read()`** method of the ReadableStreamBYOBReader interface is used to read data into a view on a user-supplied buffer from an associated readable byte stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
*/
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
/**
* The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
*/
releaseLock(): void;
readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;
}
interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
min?: number;
}
interface ReadableStreamGetReaderOptions {
/**
* Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
*
* This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
*/
mode: "byob";
}
/**
* The **`ReadableStreamBYOBRequest`** interface of the Streams API represents a 'pull request' for data from an underlying source that will made as a zero-copy transfer to a consumer (bypassing the stream's internal queues).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
*/
declare abstract class ReadableStreamBYOBRequest {
/**
* The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
*/
get view(): Uint8Array | null;
/**
* The **`respond()`** method of the ReadableStreamBYOBRequest interface is used to signal to the associated readable byte stream that the specified number of bytes were written into the ReadableStreamBYOBRequest.view.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
*/
respond(bytesWritten: number): void;
/**
* The **`respondWithNewView()`** method of the ReadableStreamBYOBRequest interface specifies a new view that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
*/
respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
get atLeast(): number | null;
}
/**
* The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
*/
declare abstract class ReadableStreamDefaultController<R = any> {
/**
* The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
*/
get desiredSize(): number | null;
/**
* The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
*/
close(): void;
/**
* The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
*/
enqueue(chunk?: R): void;
/**
* The **`error()`** method of the with the associated stream to error.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
*/
error(reason: any): void;
}
/**
* The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
*/
declare abstract class ReadableByteStreamController {
/**
* The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
*/
get byobRequest(): ReadableStreamBYOBRequest | null;
/**
* The **`desiredSize`** read-only property of the ReadableByteStreamController interface returns the number of bytes required to fill the stream's internal queue to its 'desired size'.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
*/
get desiredSize(): number | null;
/**
* The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
*/
close(): void;
/**
* The **`enqueue()`** method of the ReadableByteStreamController interface enqueues a given chunk on the associated readable byte stream (the chunk is copied into the stream's internal queues).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
*/
enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
/**
* The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
*/
error(reason: any): void;
}
/**
* The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
*/
declare abstract class WritableStreamDefaultController {
/**
* The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
*/
get signal(): AbortSignal;
/**
* The **`error()`** method of the with the associated stream to error.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
*/
error(reason?: any): void;
}
/**
* The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
*/
declare abstract class TransformStreamDefaultController<O = any> {
/**
* The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
*/
get desiredSize(): number | null;
/**
* The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
*/
enqueue(chunk?: O): void;
/**
* The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
*/
error(reason: any): void;
/**
* The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
*/
terminate(): void;
}
interface ReadableWritablePair<R = any, W = any> {
/**
* Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
*
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
*/
writable: WritableStream<W>;
readable: ReadableStream<R>;
}
/**
* The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
*/
declare class WritableStream<W = any> {
constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);
/**
* The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
*/
get locked(): boolean;
/**
* The **`abort()`** method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
*/
abort(reason?: any): Promise<void>;
/**
* The **`close()`** method of the WritableStream interface closes the associated stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
*/
close(): Promise<void>;
/**
* The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
*/
getWriter(): WritableStreamDefaultWriter<W>;
}
/**
* The **`WritableStreamDefaultWriter`** interface of the Streams API is the object returned by WritableStream.getWriter() and once created locks the writer to the `WritableStream` ensuring that no other streams can write to the underlying sink.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
*/
declare class WritableStreamDefaultWriter<W = any> {
constructor(stream: WritableStream);
/**
* The **`closed`** read-only property of the the stream errors or the writer's lock is released.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
*/
get closed(): Promise<void>;
/**
* The **`ready`** read-only property of the that resolves when the desired size of the stream's internal queue transitions from non-positive to positive, signaling that it is no longer applying backpressure.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
*/
get ready(): Promise<void>;
/**
* The **`desiredSize`** read-only property of the to fill the stream's internal queue.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
*/
get desiredSize(): number | null;
/**
* The **`abort()`** method of the the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
*/
abort(reason?: any): Promise<void>;
/**
* The **`close()`** method of the stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
*/
close(): Promise<void>;
/**
* The **`write()`** method of the operation.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
*/
write(chunk?: W): Promise<void>;
/**
* The **`releaseLock()`** method of the corresponding stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
*/
releaseLock(): void;
}
/**
* The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
*/
declare class TransformStream<I = any, O = any> {
constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
/**
* The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
*/
get readable(): ReadableStream<O>;
/**
* The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
*/
get writable(): WritableStream<I>;
}
declare class FixedLengthStream extends IdentityTransformStream {
constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);
}
declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
}
interface IdentityTransformStreamQueuingStrategy {
highWaterMark?: (number | bigint);
}
interface ReadableStreamValuesOptions {
preventCancel?: boolean;
}
/**
* The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
*/
declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
constructor(format: "gzip" | "deflate" | "deflate-raw");
}
/**
* The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
*/
declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
constructor(format: "gzip" | "deflate" | "deflate-raw");
}
/**
* The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
*/
declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
constructor();
get encoding(): string;
}
/**
* The **`TextDecoderStream`** interface of the Encoding API converts a stream of text in a binary encoding, such as UTF-8 etc., to a stream of strings.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
*/
declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {
constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
get encoding(): string;
get fatal(): boolean;
get ignoreBOM(): boolean;
}
interface TextDecoderStreamTextDecoderStreamInit {
fatal?: boolean;
ignoreBOM?: boolean;
}
/**
* The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
*/
declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
constructor(init: QueuingStrategyInit);
/**
* The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
*/
get highWaterMark(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
get size(): (chunk?: any) => number;
}
/**
* The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
*/
declare class CountQueuingStrategy implements QueuingStrategy {
constructor(init: QueuingStrategyInit);
/**
* The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
*/
get highWaterMark(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
get size(): (chunk?: any) => number;
}
interface QueuingStrategyInit {
/**
* Creates a new ByteLengthQueuingStrategy with the provided high water mark.
*
* Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw.
*/
highWaterMark: number;
}
interface ScriptVersion {
id?: string;
tag?: string;
message?: string;
}
declare abstract class TailEvent extends ExtendableEvent {
readonly events: TraceItem[];
readonly traces: TraceItem[];
}
interface TraceItem {
readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null;
readonly eventTimestamp: number | null;
readonly logs: TraceLog[];
readonly exceptions: TraceException[];
readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
readonly scriptName: string | null;
readonly entrypoint?: string;
readonly scriptVersion?: ScriptVersion;
readonly dispatchNamespace?: string;
readonly scriptTags?: string[];
readonly durableObjectId?: string;
readonly outcome: string;
readonly executionModel: string;
readonly truncated: boolean;
readonly cpuTime: number;
readonly wallTime: number;
}
interface TraceItemAlarmEventInfo {
readonly scheduledTime: Date;
}
interface TraceItemCustomEventInfo {
}
interface TraceItemScheduledEventInfo {
readonly scheduledTime: number;
readonly cron: string;
}
interface TraceItemQueueEventInfo {
readonly queue: string;
readonly batchSize: number;
}
interface TraceItemEmailEventInfo {
readonly mailFrom: string;
readonly rcptTo: string;
readonly rawSize: number;
}
interface TraceItemTailEventInfo {
readonly consumedEvents: TraceItemTailEventInfoTailItem[];
}
interface TraceItemTailEventInfoTailItem {
readonly scriptName: string | null;
}
interface TraceItemFetchEventInfo {
readonly response?: TraceItemFetchEventInfoResponse;
readonly request: TraceItemFetchEventInfoRequest;
}
interface TraceItemFetchEventInfoRequest {
readonly cf?: any;
readonly headers: Record<string, string>;
readonly method: string;
readonly url: string;
getUnredacted(): TraceItemFetchEventInfoRequest;
}
interface TraceItemFetchEventInfoResponse {
readonly status: number;
}
interface TraceItemJsRpcEventInfo {
readonly rpcMethod: string;
}
interface TraceItemHibernatableWebSocketEventInfo {
readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError;
}
interface TraceItemHibernatableWebSocketEventInfoMessage {
readonly webSocketEventType: string;
}
interface TraceItemHibernatableWebSocketEventInfoClose {
readonly webSocketEventType: string;
readonly code: number;
readonly wasClean: boolean;
}
interface TraceItemHibernatableWebSocketEventInfoError {
readonly webSocketEventType: string;
}
interface TraceLog {
readonly timestamp: number;
readonly level: string;
readonly message: any;
}
interface TraceException {
readonly timestamp: number;
readonly message: string;
readonly name: string;
readonly stack?: string;
}
interface TraceDiagnosticChannelEvent {
readonly timestamp: number;
readonly channel: string;
readonly message: any;
}
interface TraceMetrics {
readonly cpuTime: number;
readonly wallTime: number;
}
interface UnsafeTraceMetrics {
fromTrace(item: TraceItem): TraceMetrics;
}
/**
* The **`URL`** interface is used to parse, construct, normalize, and encode URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
*/
declare class URL {
constructor(url: string | URL, base?: string | URL);
/**
* The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
*/
get origin(): string;
/**
* The **`href`** property of the URL interface is a string containing the whole URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
*/
get href(): string;
/**
* The **`href`** property of the URL interface is a string containing the whole URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
*/
set href(value: string);
/**
* The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
*/
get protocol(): string;
/**
* The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
*/
set protocol(value: string);
/**
* The **`username`** property of the URL interface is a string containing the username component of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
*/
get username(): string;
/**
* The **`username`** property of the URL interface is a string containing the username component of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
*/
set username(value: string);
/**
* The **`password`** property of the URL interface is a string containing the password component of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
*/
get password(): string;
/**
* The **`password`** property of the URL interface is a string containing the password component of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
*/
set password(value: string);
/**
* The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
*/
get host(): string;
/**
* The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
*/
set host(value: string);
/**
* The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
*/
get hostname(): string;
/**
* The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
*/
set hostname(value: string);
/**
* The **`port`** property of the URL interface is a string containing the port number of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
*/
get port(): string;
/**
* The **`port`** property of the URL interface is a string containing the port number of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
*/
set port(value: string);
/**
* The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
*/
get pathname(): string;
/**
* The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
*/
set pathname(value: string);
/**
* The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
*/
get search(): string;
/**
* The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
*/
set search(value: string);
/**
* The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
*/
get hash(): string;
/**
* The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
*/
set hash(value: string);
/**
* The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
*/
get searchParams(): URLSearchParams;
/**
* The **`toJSON()`** method of the URL interface returns a string containing a serialized version of the URL, although in practice it seems to have the same effect as ```js-nolint toJSON() ``` None.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
*/
toJSON(): string;
/*function toString() { [native code] }*/
toString(): string;
/**
* The **`URL.canParse()`** static method of the URL interface returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
*/
static canParse(url: string, base?: string): boolean;
/**
* The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
*/
static parse(url: string, base?: string): URL | null;
/**
* The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
*/
static createObjectURL(object: File | Blob): string;
/**
* The **`revokeObjectURL()`** static method of the URL interface releases an existing object URL which was previously created by calling Call this method when you've finished using an object URL to let the browser know not to keep the reference to the file any longer.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
*/
static revokeObjectURL(object_url: string): void;
}
/**
* The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
*/
declare class URLSearchParams {
constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string));
/**
* The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
*/
get size(): number;
/**
* The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
*/
append(name: string, value: string): void;
/**
* The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
*/
delete(name: string, value?: string): void;
/**
* The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
*/
get(name: string): string | null;
/**
* The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
*/
getAll(name: string): string[];
/**
* The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
*/
has(name: string, value?: string): boolean;
/**
* The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
*/
set(name: string, value: string): void;
/**
* The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
*/
sort(): void;
/* Returns an array of key, value pairs for every entry in the search params. */
entries(): IterableIterator<[
key: string,
value: string
]>;
/* Returns a list of keys in the search params. */
keys(): IterableIterator<string>;
/* Returns a list of values in the search params. */
values(): IterableIterator<string>;
forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;
/*function toString() { [native code] }*/
toString(): string;
[Symbol.iterator](): IterableIterator<[
key: string,
value: string
]>;
}
declare class URLPattern {
constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions);
get protocol(): string;
get username(): string;
get password(): string;
get hostname(): string;
get port(): string;
get pathname(): string;
get search(): string;
get hash(): string;
get hasRegExpGroups(): boolean;
test(input?: (string | URLPatternInit), baseURL?: string): boolean;
exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null;
}
interface URLPatternInit {
protocol?: string;
username?: string;
password?: string;
hostname?: string;
port?: string;
pathname?: string;
search?: string;
hash?: string;
baseURL?: string;
}
interface URLPatternComponentResult {
input: string;
groups: Record<string, string>;
}
interface URLPatternResult {
inputs: (string | URLPatternInit)[];
protocol: URLPatternComponentResult;
username: URLPatternComponentResult;
password: URLPatternComponentResult;
hostname: URLPatternComponentResult;
port: URLPatternComponentResult;
pathname: URLPatternComponentResult;
search: URLPatternComponentResult;
hash: URLPatternComponentResult;
}
interface URLPatternOptions {
ignoreCase?: boolean;
}
/**
* A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
*/
declare class CloseEvent extends Event {
constructor(type: string, initializer?: CloseEventInit);
/**
* The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
*/
readonly code: number;
/**
* The **`reason`** read-only property of the CloseEvent interface returns the WebSocket connection close reason the server gave for closing the connection; that is, a concise human-readable prose explanation for the closure.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
*/
readonly reason: string;
/**
* The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
*/
readonly wasClean: boolean;
}
interface CloseEventInit {
code?: number;
reason?: string;
wasClean?: boolean;
}
type WebSocketEventMap = {
close: CloseEvent;
message: MessageEvent;
open: Event;
error: ErrorEvent;
};
/**
* The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
*/
declare var WebSocket: {
prototype: WebSocket;
new (url: string, protocols?: (string[] | string)): WebSocket;
readonly READY_STATE_CONNECTING: number;
readonly CONNECTING: number;
readonly READY_STATE_OPEN: number;
readonly OPEN: number;
readonly READY_STATE_CLOSING: number;
readonly CLOSING: number;
readonly READY_STATE_CLOSED: number;
readonly CLOSED: number;
};
/**
* The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
*/
interface WebSocket extends EventTarget<WebSocketEventMap> {
accept(): void;
/**
* The **`WebSocket.send()`** method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of `bufferedAmount` by the number of bytes needed to contain the data.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
*/
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
/**
* The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
*/
close(code?: number, reason?: string): void;
serializeAttachment(attachment: any): void;
deserializeAttachment(): any | null;
/**
* The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
*/
readyState: number;
/**
* The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
*/
url: string | null;
/**
* The **`WebSocket.protocol`** read-only property returns the name of the sub-protocol the server selected; this will be one of the strings specified in the `protocols` parameter when creating the WebSocket object, or the empty string if no connection is established.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
*/
protocol: string | null;
/**
* The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
*/
extensions: string | null;
}
declare const WebSocketPair: {
new (): {
0: WebSocket;
1: WebSocket;
};
};
interface SqlStorage {
exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;
get databaseSize(): number;
Cursor: typeof SqlStorageCursor;
Statement: typeof SqlStorageStatement;
}
declare abstract class SqlStorageStatement {
}
type SqlStorageValue = ArrayBuffer | string | number | null;
declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {
next(): {
done?: false;
value: T;
} | {
done: true;
value?: never;
};
toArray(): T[];
one(): T;
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
columnNames: string[];
get rowsRead(): number;
get rowsWritten(): number;
[Symbol.iterator](): IterableIterator<T>;
}
interface Socket {
get readable(): ReadableStream;
get writable(): WritableStream;
get closed(): Promise<void>;
get opened(): Promise<SocketInfo>;
get upgraded(): boolean;
get secureTransport(): "on" | "off" | "starttls";
close(): Promise<void>;
startTls(options?: TlsOptions): Socket;
}
interface SocketOptions {
secureTransport?: string;
allowHalfOpen: boolean;
highWaterMark?: (number | bigint);
}
interface SocketAddress {
hostname: string;
port: number;
}
interface TlsOptions {
expectedServerHostname?: string;
}
interface SocketInfo {
remoteAddress?: string;
localAddress?: string;
}
/**
* The **`EventSource`** interface is web content's interface to server-sent events.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
*/
declare class EventSource extends EventTarget {
constructor(url: string, init?: EventSourceEventSourceInit);
/**
* The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
*/
close(): void;
/**
* The **`url`** read-only property of the URL of the source.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
*/
get url(): string;
/**
* The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
*/
get withCredentials(): boolean;
/**
* The **`readyState`** read-only property of the connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
*/
get readyState(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
get onopen(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
set onopen(value: any | null);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
get onmessage(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
set onmessage(value: any | null);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
get onerror(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
set onerror(value: any | null);
static readonly CONNECTING: number;
static readonly OPEN: number;
static readonly CLOSED: number;
static from(stream: ReadableStream): EventSource;
}
interface EventSourceEventSourceInit {
withCredentials?: boolean;
fetcher?: Fetcher;
}
interface Container {
get running(): boolean;
start(options?: ContainerStartupOptions): void;
monitor(): Promise<void>;
destroy(error?: any): Promise<void>;
signal(signo: number): void;
getTcpPort(port: number): Fetcher;
setInactivityTimeout(durationMs: number | bigint): Promise<void>;
}
interface ContainerStartupOptions {
entrypoint?: string[];
enableInternet: boolean;
env?: Record<string, string>;
hardTimeout?: (number | bigint);
}
/**
* The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
*/
declare abstract class MessagePort extends EventTarget {
/**
* The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
*/
postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void;
/**
* The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
*/
close(): void;
/**
* The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
*/
start(): void;
get onmessage(): any | null;
set onmessage(value: any | null);
}
/**
* The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
*/
declare class MessageChannel {
constructor();
/**
* The **`port1`** read-only property of the the port attached to the context that originated the channel.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
*/
readonly port1: MessagePort;
/**
* The **`port2`** read-only property of the the port attached to the context at the other end of the channel, which the message is initially sent to.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
*/
readonly port2: MessagePort;
}
interface MessagePortPostMessageOptions {
transfer?: any[];
}
type LoopbackForExport<T extends (new (...args: any[]) => Rpc.EntrypointBranded) | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? LoopbackServiceStub<InstanceType<T>> : T extends new (...args: any[]) => Rpc.DurableObjectBranded ? LoopbackDurableObjectClass<InstanceType<T>> : T extends ExportedHandler<any, any, any> ? LoopbackServiceStub<undefined> : undefined;
type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> & (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props> ? (opts: {
props?: Props;
}) => Fetcher<T> : (opts: {
props?: any;
}) => Fetcher<T>);
type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> & (T extends CloudflareWorkersModule.DurableObject<any, infer Props> ? (opts: {
props?: Props;
}) => DurableObjectClass<T> : (opts: {
props?: any;
}) => DurableObjectClass<T>);
interface SyncKvStorage {
get<T = unknown>(key: string): T | undefined;
list<T = unknown>(options?: SyncKvListOptions): Iterable<[
string,
T
]>;
put<T>(key: string, value: T): void;
delete(key: string): boolean;
}
interface SyncKvListOptions {
start?: string;
startAfter?: string;
end?: string;
prefix?: string;
reverse?: boolean;
limit?: number;
}
interface WorkerStub {
getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>;
}
interface WorkerStubEntrypointOptions {
props?: any;
}
interface WorkerLoader {
get(name: string, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub;
}
interface WorkerLoaderModule {
js?: string;
cjs?: string;
text?: string;
data?: ArrayBuffer;
json?: any;
py?: string;
wasm?: ArrayBuffer;
}
interface WorkerLoaderWorkerCode {
compatibilityDate: string;
compatibilityFlags?: string[];
allowExperimental?: boolean;
mainModule: string;
modules: Record<string, WorkerLoaderModule | string>;
env?: any;
globalOutbound?: (Fetcher | null);
tails?: Fetcher[];
streamingTails?: Fetcher[];
}
/**
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
* as well as timing of subrequests and other operations.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
*/
declare abstract class Performance {
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
get timeOrigin(): number;
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
now(): number;
}
type AiImageClassificationInput = {
image: number[];
};
type AiImageClassificationOutput = {
score?: number;
label?: string;
}[];
declare abstract class BaseAiImageClassification {
inputs: AiImageClassificationInput;
postProcessedOutputs: AiImageClassificationOutput;
}
type AiImageToTextInput = {
image: number[];
prompt?: string;
max_tokens?: number;
temperature?: number;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
raw?: boolean;
messages?: RoleScopedChatInput[];
};
type AiImageToTextOutput = {
description: string;
};
declare abstract class BaseAiImageToText {
inputs: AiImageToTextInput;
postProcessedOutputs: AiImageToTextOutput;
}
type AiImageTextToTextInput = {
image: string;
prompt?: string;
max_tokens?: number;
temperature?: number;
ignore_eos?: boolean;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
raw?: boolean;
messages?: RoleScopedChatInput[];
};
type AiImageTextToTextOutput = {
description: string;
};
declare abstract class BaseAiImageTextToText {
inputs: AiImageTextToTextInput;
postProcessedOutputs: AiImageTextToTextOutput;
}
type AiMultimodalEmbeddingsInput = {
image: string;
text: string[];
};
type AiIMultimodalEmbeddingsOutput = {
data: number[][];
shape: number[];
};
declare abstract class BaseAiMultimodalEmbeddings {
inputs: AiImageTextToTextInput;
postProcessedOutputs: AiImageTextToTextOutput;
}
type AiObjectDetectionInput = {
image: number[];
};
type AiObjectDetectionOutput = {
score?: number;
label?: string;
}[];
declare abstract class BaseAiObjectDetection {
inputs: AiObjectDetectionInput;
postProcessedOutputs: AiObjectDetectionOutput;
}
type AiSentenceSimilarityInput = {
source: string;
sentences: string[];
};
type AiSentenceSimilarityOutput = number[];
declare abstract class BaseAiSentenceSimilarity {
inputs: AiSentenceSimilarityInput;
postProcessedOutputs: AiSentenceSimilarityOutput;
}
type AiAutomaticSpeechRecognitionInput = {
audio: number[];
};
type AiAutomaticSpeechRecognitionOutput = {
text?: string;
words?: {
word: string;
start: number;
end: number;
}[];
vtt?: string;
};
declare abstract class BaseAiAutomaticSpeechRecognition {
inputs: AiAutomaticSpeechRecognitionInput;
postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
}
type AiSummarizationInput = {
input_text: string;
max_length?: number;
};
type AiSummarizationOutput = {
summary: string;
};
declare abstract class BaseAiSummarization {
inputs: AiSummarizationInput;
postProcessedOutputs: AiSummarizationOutput;
}
type AiTextClassificationInput = {
text: string;
};
type AiTextClassificationOutput = {
score?: number;
label?: string;
}[];
declare abstract class BaseAiTextClassification {
inputs: AiTextClassificationInput;
postProcessedOutputs: AiTextClassificationOutput;
}
type AiTextEmbeddingsInput = {
text: string | string[];
};
type AiTextEmbeddingsOutput = {
shape: number[];
data: number[][];
};
declare abstract class BaseAiTextEmbeddings {
inputs: AiTextEmbeddingsInput;
postProcessedOutputs: AiTextEmbeddingsOutput;
}
type RoleScopedChatInput = {
role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);
content: string;
name?: string;
};
type AiTextGenerationToolLegacyInput = {
name: string;
description: string;
parameters?: {
type: "object" | (string & NonNullable<unknown>);
properties: {
[key: string]: {
type: string;
description?: string;
};
};
required: string[];
};
};
type AiTextGenerationToolInput = {
type: "function" | (string & NonNullable<unknown>);
function: {
name: string;
description: string;
parameters?: {
type: "object" | (string & NonNullable<unknown>);
properties: {
[key: string]: {
type: string;
description?: string;
};
};
required: string[];
};
};
};
type AiTextGenerationFunctionsInput = {
name: string;
code: string;
};
type AiTextGenerationResponseFormat = {
type: string;
json_schema?: any;
};
type AiTextGenerationInput = {
prompt?: string;
raw?: boolean;
stream?: boolean;
max_tokens?: number;
temperature?: number;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
messages?: RoleScopedChatInput[];
response_format?: AiTextGenerationResponseFormat;
tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);
functions?: AiTextGenerationFunctionsInput[];
};
type AiTextGenerationToolLegacyOutput = {
name: string;
arguments: unknown;
};
type AiTextGenerationToolOutput = {
id: string;
type: "function";
function: {
name: string;
arguments: string;
};
};
type UsageTags = {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
type AiTextGenerationOutput = {
response?: string;
tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[];
usage?: UsageTags;
};
declare abstract class BaseAiTextGeneration {
inputs: AiTextGenerationInput;
postProcessedOutputs: AiTextGenerationOutput;
}
type AiTextToSpeechInput = {
prompt: string;
lang?: string;
};
type AiTextToSpeechOutput = Uint8Array | {
audio: string;
};
declare abstract class BaseAiTextToSpeech {
inputs: AiTextToSpeechInput;
postProcessedOutputs: AiTextToSpeechOutput;
}
type AiTextToImageInput = {
prompt: string;
negative_prompt?: string;
height?: number;
width?: number;
image?: number[];
image_b64?: string;
mask?: number[];
num_steps?: number;
strength?: number;
guidance?: number;
seed?: number;
};
type AiTextToImageOutput = ReadableStream<Uint8Array>;
declare abstract class BaseAiTextToImage {
inputs: AiTextToImageInput;
postProcessedOutputs: AiTextToImageOutput;
}
type AiTranslationInput = {
text: string;
target_lang: string;
source_lang?: string;
};
type AiTranslationOutput = {
translated_text?: string;
};
declare abstract class BaseAiTranslation {
inputs: AiTranslationInput;
postProcessedOutputs: AiTranslationOutput;
}
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = {
text: string | string[];
/**
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
*/
pooling?: "mean" | "cls";
} | {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
text: string | string[];
/**
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
*/
pooling?: "mean" | "cls";
}[];
};
type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
} | AsyncResponse;
interface AsyncResponse {
/**
* The async request id that can be used to obtain the results.
*/
request_id?: string;
}
declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
}
type Ai_Cf_Openai_Whisper_Input = string | {
/**
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
*/
audio: number[];
};
interface Ai_Cf_Openai_Whisper_Output {
/**
* The transcription
*/
text: string;
word_count?: number;
words?: {
word?: string;
/**
* The second this word begins in the recording
*/
start?: number;
/**
* The ending second when the word completes
*/
end?: number;
}[];
vtt?: string;
}
declare abstract class Base_Ai_Cf_Openai_Whisper {
inputs: Ai_Cf_Openai_Whisper_Input;
postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
}
type Ai_Cf_Meta_M2M100_1_2B_Input = {
/**
* The text to be translated
*/
text: string;
/**
* The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
*/
source_lang?: string;
/**
* The language code to translate the text into (e.g., 'es' for Spanish)
*/
target_lang: string;
} | {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
/**
* The text to be translated
*/
text: string;
/**
* The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
*/
source_lang?: string;
/**
* The language code to translate the text into (e.g., 'es' for Spanish)
*/
target_lang: string;
}[];
};
type Ai_Cf_Meta_M2M100_1_2B_Output = {
/**
* The translated text in the target language
*/
translated_text?: string;
} | AsyncResponse;
declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
}
type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = {
text: string | string[];
/**
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
*/
pooling?: "mean" | "cls";
} | {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
text: string | string[];
/**
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
*/
pooling?: "mean" | "cls";
}[];
};
type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
} | AsyncResponse;
declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
}
type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = {
text: string | string[];
/**
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
*/
pooling?: "mean" | "cls";
} | {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
text: string | string[];
/**
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
*/
pooling?: "mean" | "cls";
}[];
};
type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
} | AsyncResponse;
declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
}
type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | {
/**
* The input text prompt for the model to generate a response.
*/
prompt?: string;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
image: number[] | (string & NonNullable<unknown>);
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
};
interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
description?: string;
}
declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
}
type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | {
/**
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
*/
audio: number[];
};
interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
/**
* The transcription
*/
text: string;
word_count?: number;
words?: {
word?: string;
/**
* The second this word begins in the recording
*/
start?: number;
/**
* The ending second when the word completes
*/
end?: number;
}[];
vtt?: string;
}
declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
}
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
/**
* Base64 encoded value of the audio data.
*/
audio: string;
/**
* Supported tasks are 'translate' or 'transcribe'.
*/
task?: string;
/**
* The language of the audio being transcribed or translated.
*/
language?: string;
/**
* Preprocess the audio with a voice activity detection model.
*/
vad_filter?: boolean;
/**
* A text prompt to help provide context to the model on the contents of the audio.
*/
initial_prompt?: string;
/**
* The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
*/
prefix?: string;
}
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
transcription_info?: {
/**
* The language of the audio being transcribed or translated.
*/
language?: string;
/**
* The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
*/
language_probability?: number;
/**
* The total duration of the original audio file, in seconds.
*/
duration?: number;
/**
* The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
*/
duration_after_vad?: number;
};
/**
* The complete transcription of the audio.
*/
text: string;
/**
* The total number of words in the transcription.
*/
word_count?: number;
segments?: {
/**
* The starting time of the segment within the audio, in seconds.
*/
start?: number;
/**
* The ending time of the segment within the audio, in seconds.
*/
end?: number;
/**
* The transcription of the segment.
*/
text?: string;
/**
* The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
*/
temperature?: number;
/**
* The average log probability of the predictions for the words in this segment, indicating overall confidence.
*/
avg_logprob?: number;
/**
* The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
*/
compression_ratio?: number;
/**
* The probability that the segment contains no speech, represented as a decimal between 0 and 1.
*/
no_speech_prob?: number;
words?: {
/**
* The individual word transcribed from the audio.
*/
word?: string;
/**
* The starting time of the word within the audio, in seconds.
*/
start?: number;
/**
* The ending time of the word within the audio, in seconds.
*/
end?: number;
}[];
}[];
/**
* The transcription in WebVTT format, which includes timing and text information for use in subtitles.
*/
vtt?: string;
}
declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
}
type Ai_Cf_Baai_Bge_M3_Input = BGEM3InputQueryAndContexts | BGEM3InputEmbedding | {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: (BGEM3InputQueryAndContexts1 | BGEM3InputEmbedding1)[];
};
interface BGEM3InputQueryAndContexts {
/**
* A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
*/
query?: string;
/**
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
*/
contexts: {
/**
* One of the provided context content
*/
text?: string;
}[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
}
interface BGEM3InputEmbedding {
text: string | string[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
}
interface BGEM3InputQueryAndContexts1 {
/**
* A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
*/
query?: string;
/**
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
*/
contexts: {
/**
* One of the provided context content
*/
text?: string;
}[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
}
interface BGEM3InputEmbedding1 {
text: string | string[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
}
type Ai_Cf_Baai_Bge_M3_Output = BGEM3OuputQuery | BGEM3OutputEmbeddingForContexts | BGEM3OuputEmbedding | AsyncResponse;
interface BGEM3OuputQuery {
response?: {
/**
* Index of the context in the request
*/
id?: number;
/**
* Score of the context under the index.
*/
score?: number;
}[];
}
interface BGEM3OutputEmbeddingForContexts {
response?: number[][];
shape?: number[];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
}
interface BGEM3OuputEmbedding {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
}
declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
inputs: Ai_Cf_Baai_Bge_M3_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
}
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
/**
* A text description of the image you want to generate.
*/
prompt: string;
/**
* The number of diffusion steps; higher values can improve quality but take longer.
*/
steps?: number;
}
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
/**
* The generated image in Base64 format.
*/
image?: string;
}
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
}
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
interface Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
image?: number[] | (string & NonNullable<unknown>);
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
/**
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
*/
lora?: string;
}
interface Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
*/
tool_call_id?: string;
content?: string | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[] | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
image?: number[] | (string & NonNullable<unknown>);
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
/**
* If true, the response will be streamed back incrementally.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
/**
* The generated text response from the model
*/
response?: string;
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
};
declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
}
type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input = Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt | Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages | AsyncBatch;
interface Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
*/
lora?: string;
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface JSONMode {
type?: "json_object" | "json_schema";
json_schema?: unknown;
}
interface Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role: string;
/**
* The content of the message as a string.
*/
content: string;
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface AsyncBatch {
requests?: {
/**
* User-supplied reference. This field will be present in the response as well it can be used to reference the request and response. It's NOT validated to be unique.
*/
external_reference?: string;
/**
* Prompt for the text generation model
*/
prompt?: string;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
response_format?: JSONMode;
}[];
}
type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
} | string | AsyncResponse;
declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
}
interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender must alternate between 'user' and 'assistant'.
*/
role: "user" | "assistant";
/**
* The content of the message as a string.
*/
content: string;
}[];
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* Dictate the output format of the generated response.
*/
response_format?: {
/**
* Set to json_object to process and output generated text as JSON.
*/
type?: string;
};
}
interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
response?: string | {
/**
* Whether the conversation is safe or not.
*/
safe?: boolean;
/**
* A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
*/
categories?: string[];
};
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
}
declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
}
interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
/**
* A query you wish to perform against the provided contexts.
*/
/**
* Number of returned results starting with the best score.
*/
top_k?: number;
/**
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
*/
contexts: {
/**
* One of the provided context content
*/
text?: string;
}[];
}
interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
response?: {
/**
* Index of the context in the request
*/
id?: number;
/**
* Score of the context under the index.
*/
score?: number;
}[];
}
declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
}
type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input = Qwen2_5_Coder_32B_Instruct_Prompt | Qwen2_5_Coder_32B_Instruct_Messages;
interface Qwen2_5_Coder_32B_Instruct_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
*/
lora?: string;
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface Qwen2_5_Coder_32B_Instruct_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role: string;
/**
* The content of the message as a string.
*/
content: string;
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
};
declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
}
type Ai_Cf_Qwen_Qwq_32B_Input = Qwen_Qwq_32B_Prompt | Qwen_Qwq_32B_Messages;
interface Qwen_Qwq_32B_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fulfilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface Qwen_Qwq_32B_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
*/
tool_call_id?: string;
content?: string | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[] | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
type Ai_Cf_Qwen_Qwq_32B_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
};
declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
inputs: Ai_Cf_Qwen_Qwq_32B_Input;
postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
}
type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input = Mistral_Small_3_1_24B_Instruct_Prompt | Mistral_Small_3_1_24B_Instruct_Messages;
interface Mistral_Small_3_1_24B_Instruct_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fulfilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface Mistral_Small_3_1_24B_Instruct_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
*/
tool_call_id?: string;
content?: string | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[] | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
};
declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
}
type Ai_Cf_Google_Gemma_3_12B_It_Input = Google_Gemma_3_12B_It_Prompt | Google_Gemma_3_12B_It_Messages;
interface Google_Gemma_3_12B_It_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface Google_Gemma_3_12B_It_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
content?: string | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[] | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
type Ai_Cf_Google_Gemma_3_12B_It_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
};
declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
}
type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Prompt | Ai_Cf_Meta_Llama_4_Messages | Ai_Cf_Meta_Llama_4_Async_Batch;
interface Ai_Cf_Meta_Llama_4_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fulfilled for the response.
*/
guided_json?: object;
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface Ai_Cf_Meta_Llama_4_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* The tool call id. If you don't know what to put here you can fall back to 000000001
*/
tool_call_id?: string;
content?: string | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[] | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
response_format?: JSONMode;
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface Ai_Cf_Meta_Llama_4_Async_Batch {
requests: (Ai_Cf_Meta_Llama_4_Prompt_Inner | Ai_Cf_Meta_Llama_4_Messages_Inner)[];
}
interface Ai_Cf_Meta_Llama_4_Prompt_Inner {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fulfilled for the response.
*/
guided_json?: object;
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
interface Ai_Cf_Meta_Llama_4_Messages_Inner {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* The tool call id. If you don't know what to put here you can fall back to 000000001
*/
tool_call_id?: string;
content?: string | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[] | {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: ({
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
} | {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
})[];
response_format?: JSONMode;
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
}
type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The tool call id.
*/
id?: string;
/**
* Specifies the type of tool (e.g., 'function').
*/
type?: string;
/**
* Details of the function tool.
*/
function?: {
/**
* The name of the tool to be called
*/
name?: string;
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
};
}[];
};
declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
}
interface Ai_Cf_Deepgram_Nova_3_Input {
audio: {
body: object;
contentType: string;
};
/**
* Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param.
*/
custom_topic_mode?: "extended" | "strict";
/**
* Custom topics you want the model to detect within your input audio or text if present Submit up to 100
*/
custom_topic?: string;
/**
* Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in addition those submitted using the custom_intents param
*/
custom_intent_mode?: "extended" | "strict";
/**
* Custom intents you want the model to detect within your input audio if present
*/
custom_intent?: string;
/**
* Identifies and extracts key entities from content in submitted audio
*/
detect_entities?: boolean;
/**
* Identifies the dominant language spoken in submitted audio
*/
detect_language?: boolean;
/**
* Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
*/
diarize?: boolean;
/**
* Identify and extract key entities from content in submitted audio
*/
dictation?: boolean;
/**
* Specify the expected encoding of your submitted audio
*/
encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729";
/**
* Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
*/
extra?: string;
/**
* Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
*/
filler_words?: boolean;
/**
* Key term prompting can boost or suppress specialized terminology and brands.
*/
keyterm?: string;
/**
* Keywords can boost or suppress specialized terminology and brands.
*/
keywords?: string;
/**
* The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available.
*/
language?: string;
/**
* Spoken measurements will be converted to their corresponding abbreviations.
*/
measurements?: boolean;
/**
* Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip.
*/
mip_opt_out?: boolean;
/**
* Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
*/
mode?: "general" | "medical" | "finance";
/**
* Transcribe each audio channel independently.
*/
multichannel?: boolean;
/**
* Numerals converts numbers from written format to numerical format.
*/
numerals?: boolean;
/**
* Splits audio into paragraphs to improve transcript readability.
*/
paragraphs?: boolean;
/**
* Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
*/
profanity_filter?: boolean;
/**
* Add punctuation and capitalization to the transcript.
*/
punctuate?: boolean;
/**
* Redaction removes sensitive information from your transcripts.
*/
redact?: string;
/**
* Search for terms or phrases in submitted audio and replaces them.
*/
replace?: string;
/**
* Search for terms or phrases in submitted audio.
*/
search?: string;
/**
* Recognizes the sentiment throughout a transcript or text.
*/
sentiment?: boolean;
/**
* Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
*/
smart_format?: boolean;
/**
* Detect topics throughout a transcript or text.
*/
topics?: boolean;
/**
* Segments speech into meaningful semantic units.
*/
utterances?: boolean;
/**
* Seconds to wait before detecting a pause between words in submitted audio.
*/
utt_split?: number;
/**
* The number of channels in the submitted audio
*/
channels?: number;
/**
* Specifies whether the streaming endpoint should provide ongoing transcription updates as more audio is received. When set to true, the endpoint sends continuous updates, meaning transcription results may evolve over time. Note: Supported only for webosockets.
*/
interim_results?: boolean;
/**
* Indicates how long model will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech_final parameter set to true. Can also be set to false to disable endpointing
*/
endpointing?: string;
/**
* Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
*/
vad_events?: boolean;
/**
* Indicates how long model will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim_results. Note: Supported only for webosockets.
*/
utterance_end_ms?: boolean;
}
interface Ai_Cf_Deepgram_Nova_3_Output {
results?: {
channels?: {
alternatives?: {
confidence?: number;
transcript?: string;
words?: {
confidence?: number;
end?: number;
start?: number;
word?: string;
}[];
}[];
}[];
summary?: {
result?: string;
short?: string;
};
sentiments?: {
segments?: {
text?: string;
start_word?: number;
end_word?: number;
sentiment?: string;
sentiment_score?: number;
}[];
average?: {
sentiment?: string;
sentiment_score?: number;
};
};
};
}
declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
inputs: Ai_Cf_Deepgram_Nova_3_Input;
postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
}
type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = {
/**
* readable stream with audio data and content-type specified for that data
*/
audio: {
body: object;
contentType: string;
};
/**
* type of data PCM data that's sent to the inference server as raw array
*/
dtype?: "uint8" | "float32" | "float64";
} | {
/**
* base64 encoded audio data
*/
audio: string;
/**
* type of data PCM data that's sent to the inference server as raw array
*/
dtype?: "uint8" | "float32" | "float64";
};
interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
/**
* if true, end-of-turn was detected
*/
is_complete?: boolean;
/**
* probability of the end-of-turn detection
*/
probability?: number;
}
declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
}
type Ai_Cf_Openai_Gpt_Oss_120B_Input = GPT_OSS_120B_Responses | GPT_OSS_120B_Responses_Async;
interface GPT_OSS_120B_Responses {
/**
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
*/
input: string | unknown[];
reasoning?: {
/**
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
*/
effort?: "low" | "medium" | "high";
/**
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
*/
summary?: "auto" | "concise" | "detailed";
};
}
interface GPT_OSS_120B_Responses_Async {
requests: {
/**
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
*/
input: string | unknown[];
reasoning?: {
/**
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
*/
effort?: "low" | "medium" | "high";
/**
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
*/
summary?: "auto" | "concise" | "detailed";
};
}[];
}
type Ai_Cf_Openai_Gpt_Oss_120B_Output = {} | (string & NonNullable<unknown>);
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
inputs: Ai_Cf_Openai_Gpt_Oss_120B_Input;
postProcessedOutputs: Ai_Cf_Openai_Gpt_Oss_120B_Output;
}
type Ai_Cf_Openai_Gpt_Oss_20B_Input = GPT_OSS_20B_Responses | GPT_OSS_20B_Responses_Async;
interface GPT_OSS_20B_Responses {
/**
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
*/
input: string | unknown[];
reasoning?: {
/**
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
*/
effort?: "low" | "medium" | "high";
/**
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
*/
summary?: "auto" | "concise" | "detailed";
};
}
interface GPT_OSS_20B_Responses_Async {
requests: {
/**
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
*/
input: string | unknown[];
reasoning?: {
/**
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
*/
effort?: "low" | "medium" | "high";
/**
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
*/
summary?: "auto" | "concise" | "detailed";
};
}[];
}
type Ai_Cf_Openai_Gpt_Oss_20B_Output = {} | (string & NonNullable<unknown>);
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
inputs: Ai_Cf_Openai_Gpt_Oss_20B_Input;
postProcessedOutputs: Ai_Cf_Openai_Gpt_Oss_20B_Output;
}
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
/**
* A text description of the image you want to generate.
*/
prompt: string;
/**
* Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
*/
guidance?: number;
/**
* Random seed for reproducibility of the image generation
*/
seed?: number;
/**
* The height of the generated image in pixels
*/
height?: number;
/**
* The width of the generated image in pixels
*/
width?: number;
/**
* The number of diffusion steps; higher values can improve quality but take longer
*/
num_steps?: number;
/**
* Specify what to exclude from the generated images
*/
negative_prompt?: string;
}
/**
* The generated image in JPEG format
*/
type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
}
interface Ai_Cf_Leonardo_Lucid_Origin_Input {
/**
* A text description of the image you want to generate.
*/
prompt: string;
/**
* Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
*/
guidance?: number;
/**
* Random seed for reproducibility of the image generation
*/
seed?: number;
/**
* The height of the generated image in pixels
*/
height?: number;
/**
* The width of the generated image in pixels
*/
width?: number;
/**
* The number of diffusion steps; higher values can improve quality but take longer
*/
num_steps?: number;
/**
* The number of diffusion steps; higher values can improve quality but take longer
*/
steps?: number;
}
interface Ai_Cf_Leonardo_Lucid_Origin_Output {
/**
* The generated image in Base64 format.
*/
image?: string;
}
declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
}
interface Ai_Cf_Deepgram_Aura_1_Input {
/**
* Speaker used to produce the audio.
*/
speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella";
/**
* Encoding of the output audio.
*/
encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
/**
* Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
*/
container?: "none" | "wav" | "ogg";
/**
* The text content to be converted to speech
*/
text: string;
/**
* Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
*/
sample_rate?: number;
/**
* The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
*/
bit_rate?: number;
}
/**
* The generated audio in MP3 format
*/
type Ai_Cf_Deepgram_Aura_1_Output = string;
declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
inputs: Ai_Cf_Deepgram_Aura_1_Input;
postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
}
interface AiModels {
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
"@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
"@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
"@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
"@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
"@cf/myshell-ai/melotts": BaseAiTextToSpeech;
"@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
"@cf/microsoft/resnet-50": BaseAiImageClassification;
"@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
"@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
"@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
"@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
"@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
"@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
"@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
"@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
"@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
"@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
"@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
"@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
"@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
"@cf/microsoft/phi-2": BaseAiTextGeneration;
"@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
"@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
"@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
"@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
"@hf/google/gemma-7b-it": BaseAiTextGeneration;
"@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
"@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
"@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
"@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
"@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
"@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
"@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
"@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
"@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
"@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
"@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
"@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
"@cf/facebook/bart-large-cnn": BaseAiSummarization;
"@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
"@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
"@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
"@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
"@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
"@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
"@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
"@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
"@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
"@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
"@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
"@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
"@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
"@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
"@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
"@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
"@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
"@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
"@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
"@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
"@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
"@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
"@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
"@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
"@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
"@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
"@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
}
type AiOptions = {
/**
* Send requests as an asynchronous batch job, only works for supported models
* https://developers.cloudflare.com/workers-ai/features/batch-api
*/
queueRequest?: boolean;
/**
* Establish websocket connections, only works for supported models
*/
websocket?: boolean;
gateway?: GatewayOptions;
returnRawResponse?: boolean;
prefix?: string;
extraHeaders?: object;
};
type AiModelsSearchParams = {
author?: string;
hide_experimental?: boolean;
page?: number;
per_page?: number;
search?: string;
source?: number;
task?: string;
};
type AiModelsSearchObject = {
id: string;
source: number;
name: string;
description: string;
task: {
id: string;
name: string;
description: string;
};
tags: string[];
properties: {
property_id: string;
value: string;
}[];
};
interface InferenceUpstreamError extends Error {
}
interface AiInternalError extends Error {
}
type AiModelListType = Record<string, any>;
declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
aiGatewayLogId: string | null;
gateway(gatewayId: string): AiGateway;
autorag(autoragId: string): AutoRAG;
run<Name extends keyof AiModelList, Options extends AiOptions, InputOptions extends AiModelList[Name]["inputs"]>(model: Name, inputs: InputOptions, options?: Options): Promise<Options extends {
returnRawResponse: true;
} | {
websocket: true;
} ? Response : InputOptions extends {
stream: true;
} ? ReadableStream : AiModelList[Name]["postProcessedOutputs"]>;
models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
toMarkdown(): ToMarkdownService;
toMarkdown(files: {
name: string;
blob: Blob;
}[], options?: {
gateway?: GatewayOptions;
extraHeaders?: object;
}): Promise<ConversionResponse[]>;
toMarkdown(files: {
name: string;
blob: Blob;
}, options?: {
gateway?: GatewayOptions;
extraHeaders?: object;
}): Promise<ConversionResponse>;
}
type GatewayRetries = {
maxAttempts?: 1 | 2 | 3 | 4 | 5;
retryDelayMs?: number;
backoff?: 'constant' | 'linear' | 'exponential';
};
type GatewayOptions = {
id: string;
cacheKey?: string;
cacheTtl?: number;
skipCache?: boolean;
metadata?: Record<string, number | string | boolean | null | bigint>;
collectLog?: boolean;
eventId?: string;
requestTimeoutMs?: number;
retries?: GatewayRetries;
};
type UniversalGatewayOptions = Exclude<GatewayOptions, 'id'> & {
/**
** @deprecated
*/
id?: string;
};
type AiGatewayPatchLog = {
score?: number | null;
feedback?: -1 | 1 | null;
metadata?: Record<string, number | string | boolean | null | bigint> | null;
};
type AiGatewayLog = {
id: string;
provider: string;
model: string;
model_type?: string;
path: string;
duration: number;
request_type?: string;
request_content_type?: string;
status_code: number;
response_content_type?: string;
success: boolean;
cached: boolean;
tokens_in?: number;
tokens_out?: number;
metadata?: Record<string, number | string | boolean | null | bigint>;
step?: number;
cost?: number;
custom_cost?: boolean;
request_size: number;
request_head?: string;
request_head_complete: boolean;
response_size: number;
response_head?: string;
response_head_complete: boolean;
created_at: Date;
};
type AIGatewayProviders = 'workers-ai' | 'anthropic' | 'aws-bedrock' | 'azure-openai' | 'google-vertex-ai' | 'huggingface' | 'openai' | 'perplexity-ai' | 'replicate' | 'groq' | 'cohere' | 'google-ai-studio' | 'mistral' | 'grok' | 'openrouter' | 'deepseek' | 'cerebras' | 'cartesia' | 'elevenlabs' | 'adobe-firefly';
type AIGatewayHeaders = {
'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string;
'cf-aig-custom-cost': {
per_token_in?: number;
per_token_out?: number;
} | {
total_cost?: number;
} | string;
'cf-aig-cache-ttl': number | string;
'cf-aig-skip-cache': boolean | string;
'cf-aig-cache-key': string;
'cf-aig-event-id': string;
'cf-aig-request-timeout': number | string;
'cf-aig-max-attempts': number | string;
'cf-aig-retry-delay': number | string;
'cf-aig-backoff': string;
'cf-aig-collect-log': boolean | string;
Authorization: string;
'Content-Type': string;
[key: string]: string | number | boolean | object;
};
type AIGatewayUniversalRequest = {
provider: AIGatewayProviders | string; // eslint-disable-line
endpoint: string;
headers: Partial<AIGatewayHeaders>;
query: unknown;
};
interface AiGatewayInternalError extends Error {
}
interface AiGatewayLogNotFound extends Error {
}
declare abstract class AiGateway {
patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
getLog(logId: string): Promise<AiGatewayLog>;
run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: {
gateway?: UniversalGatewayOptions;
extraHeaders?: object;
}): Promise<Response>;
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
}
interface AutoRAGInternalError extends Error {
}
interface AutoRAGNotFoundError extends Error {
}
interface AutoRAGUnauthorizedError extends Error {
}
interface AutoRAGNameNotSetError extends Error {
}
type ComparisonFilter = {
key: string;
type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
value: string | number | boolean;
};
type CompoundFilter = {
type: 'and' | 'or';
filters: ComparisonFilter[];
};
type AutoRagSearchRequest = {
query: string;
filters?: CompoundFilter | ComparisonFilter;
max_num_results?: number;
ranking_options?: {
ranker?: string;
score_threshold?: number;
};
reranking?: {
enabled?: boolean;
model?: string;
};
rewrite_query?: boolean;
};
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
stream?: boolean;
system_prompt?: string;
};
type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & {
stream: true;
};
type AutoRagSearchResponse = {
object: 'vector_store.search_results.page';
search_query: string;
data: {
file_id: string;
filename: string;
score: number;
attributes: Record<string, string | number | boolean | null>;
content: {
type: 'text';
text: string;
}[];
}[];
has_more: boolean;
next_page: string | null;
};
type AutoRagListResponse = {
id: string;
enable: boolean;
type: string;
source: string;
vectorize_name: string;
paused: boolean;
status: string;
}[];
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
response: string;
};
declare abstract class AutoRAG {
list(): Promise<AutoRagListResponse>;
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>;
}
interface BasicImageTransformations {
/**
* Maximum width in image pixels. The value must be an integer.
*/
width?: number;
/**
* Maximum height in image pixels. The value must be an integer.
*/
height?: number;
/**
* Resizing mode as a string. It affects interpretation of width and height
* options:
* - scale-down: Similar to contain, but the image is never enlarged. If
* the image is larger than given width or height, it will be resized.
* Otherwise its original size will be kept.
* - contain: Resizes to maximum size that fits within the given width and
* height. If only a single dimension is given (e.g. only width), the
* image will be shrunk or enlarged to exactly match that dimension.
* Aspect ratio is always preserved.
* - cover: Resizes (shrinks or enlarges) to fill the entire area of width
* and height. If the image has an aspect ratio different from the ratio
* of width and height, it will be cropped to fit.
* - crop: The image will be shrunk and cropped to fit within the area
* specified by width and height. The image will not be enlarged. For images
* smaller than the given dimensions it's the same as scale-down. For
* images larger than the given dimensions, it's the same as cover.
* See also trim.
* - pad: Resizes to the maximum size that fits within the given width and
* height, and then fills the remaining area with a background color
* (white by default). Use of this mode is not recommended, as the same
* effect can be more efficiently achieved with the contain mode and the
* CSS object-fit: contain property.
* - squeeze: Stretches and deforms to the width and height given, even if it
* breaks aspect ratio
*/
fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
/**
* Image segmentation using artificial intelligence models. Sets pixels not
* within selected segment area to transparent e.g "foreground" sets every
* background pixel as transparent.
*/
segment?: "foreground";
/**
* When cropping with fit: "cover", this defines the side or point that should
* be left uncropped. The value is either a string
* "left", "right", "top", "bottom", "auto", or "center" (the default),
* or an object {x, y} containing focal point coordinates in the original
* image expressed as fractions ranging from 0.0 (top or left) to 1.0
* (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
* crop bottom or left and right sides as necessary, but wonโt crop anything
* from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
* preserve as much as possible around a point at 20% of the height of the
* source image.
*/
gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates;
/**
* Background color to add underneath the image. Applies only to images with
* transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(โฆ),
* hsl(โฆ), etc.)
*/
background?: string;
/**
* Number of degrees (90, 180, 270) to rotate the image by. width and height
* options refer to axes after rotation.
*/
rotate?: 0 | 90 | 180 | 270 | 360;
}
interface BasicImageTransformationsGravityCoordinates {
x?: number;
y?: number;
mode?: 'remainder' | 'box-center';
}
/**
* In addition to the properties you can set in the RequestInit dict
* that you pass as an argument to the Request constructor, you can
* set certain properties of a `cf` object to control how Cloudflare
* features are applied to that new Request.
*
* Note: Currently, these properties cannot be tested in the
* playground.
*/
interface RequestInitCfProperties extends Record<string, unknown> {
cacheEverything?: boolean;
/**
* A request's cache key is what determines if two requests are
* "the same" for caching purposes. If a request has the same cache key
* as some previous request, then we can serve the same cached response for
* both. (e.g. 'some-key')
*
* Only available for Enterprise customers.
*/
cacheKey?: string;
/**
* This allows you to append additional Cache-Tag response headers
* to the origin response without modifications to the origin server.
* This will allow for greater control over the Purge by Cache Tag feature
* utilizing changes only in the Workers process.
*
* Only available for Enterprise customers.
*/
cacheTags?: string[];
/**
* Force response to be cached for a given number of seconds. (e.g. 300)
*/
cacheTtl?: number;
/**
* Force response to be cached for a given number of seconds based on the Origin status code.
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
*/
cacheTtlByStatus?: Record<string, number>;
scrapeShield?: boolean;
apps?: boolean;
image?: RequestInitCfPropertiesImage;
minify?: RequestInitCfPropertiesImageMinify;
mirage?: boolean;
polish?: "lossy" | "lossless" | "off";
r2?: RequestInitCfPropertiesR2;
/**
* Redirects the request to an alternate origin server. You can use this,
* for example, to implement load balancing across several origins.
* (e.g.us-east.example.com)
*
* Note - For security reasons, the hostname set in resolveOverride must
* be proxied on the same Cloudflare zone of the incoming request.
* Otherwise, the setting is ignored. CNAME hosts are allowed, so to
* resolve to a host under a different domain or a DNS only domain first
* declare a CNAME record within your own zoneโs DNS mapping to the
* external hostname, set proxy on Cloudflare, then set resolveOverride
* to point to that CNAME record.
*/
resolveOverride?: string;
}
interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
/**
* Absolute URL of the image file to use for the drawing. It can be any of
* the supported file formats. For drawing of watermarks or non-rectangular
* overlays we recommend using PNG or WebP images.
*/
url: string;
/**
* Floating-point number between 0 (transparent) and 1 (opaque).
* For example, opacity: 0.5 makes overlay semitransparent.
*/
opacity?: number;
/**
* - If set to true, the overlay image will be tiled to cover the entire
* area. This is useful for stock-photo-like watermarks.
* - If set to "x", the overlay image will be tiled horizontally only
* (form a line).
* - If set to "y", the overlay image will be tiled vertically only
* (form a line).
*/
repeat?: true | "x" | "y";
/**
* Position of the overlay image relative to a given edge. Each property is
* an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
* positions left side of the overlay 10 pixels from the left edge of the
* image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
* of the background image.
*
* Setting both left & right, or both top & bottom is an error.
*
* If no position is specified, the image will be centered.
*/
top?: number;
left?: number;
bottom?: number;
right?: number;
}
interface RequestInitCfPropertiesImage extends BasicImageTransformations {
/**
* Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
* easier to specify higher-DPI sizes in <img srcset>.
*/
dpr?: number;
/**
* Allows you to trim your image. Takes dpr into account and is performed before
* resizing or rotation.
*
* It can be used as:
* - left, top, right, bottom - it will specify the number of pixels to cut
* off each side
* - width, height - the width/height you'd like to end up with - can be used
* in combination with the properties above
* - border - this will automatically trim the surroundings of an image based on
* it's color. It consists of three properties:
* - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
* - tolerance: difference from color to treat as color
* - keep: the number of pixels of border to keep
*/
trim?: "border" | {
top?: number;
bottom?: number;
left?: number;
right?: number;
width?: number;
height?: number;
border?: boolean | {
color?: string;
tolerance?: number;
keep?: number;
};
};
/**
* Quality setting from 1-100 (useful values are in 60-90 range). Lower values
* make images look worse, but load faster. The default is 85. It applies only
* to JPEG and WebP images. It doesnโt have any effect on PNG.
*/
quality?: number | "low" | "medium-low" | "medium-high" | "high";
/**
* Output format to generate. It can be:
* - avif: generate images in AVIF format.
* - webp: generate images in Google WebP format. Set quality to 100 to get
* the WebP-lossless format.
* - json: instead of generating an image, outputs information about the
* image, in JSON format. The JSON object will contain image size
* (before and after resizing), source imageโs MIME type, file size, etc.
* - jpeg: generate images in JPEG format.
* - png: generate images in PNG format.
*/
format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg";
/**
* Whether to preserve animation frames from input files. Default is true.
* Setting it to false reduces animations to still images. This setting is
* recommended when enlarging images or processing arbitrary user content,
* because large GIF animations can weigh tens or even hundreds of megabytes.
* It is also useful to set anim:false when using format:"json" to get the
* response quicker without the number of frames.
*/
anim?: boolean;
/**
* What EXIF data should be preserved in the output image. Note that EXIF
* rotation and embedded color profiles are always applied ("baked in" into
* the image), and aren't affected by this option. Note that if the Polish
* feature is enabled, all metadata may have been removed already and this
* option may have no effect.
* - keep: Preserve most of EXIF metadata, including GPS location if there's
* any.
* - copyright: Only keep the copyright tag, and discard everything else.
* This is the default behavior for JPEG files.
* - none: Discard all invisible EXIF metadata. Currently WebP and PNG
* output formats always discard metadata.
*/
metadata?: "keep" | "copyright" | "none";
/**
* Strength of sharpening filter to apply to the image. Floating-point
* number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
* recommended value for downscaled images.
*/
sharpen?: number;
/**
* Radius of a blur filter (approximate gaussian). Maximum supported radius
* is 250.
*/
blur?: number;
/**
* Overlays are drawn in the order they appear in the array (last array
* entry is the topmost layer).
*/
draw?: RequestInitCfPropertiesImageDraw[];
/**
* Fetching image from authenticated origin. Setting this property will
* pass authentication headers (Authorization, Cookie, etc.) through to
* the origin.
*/
"origin-auth"?: "share-publicly";
/**
* Adds a border around the image. The border is added after resizing. Border
* width takes dpr into account, and can be specified either using a single
* width property, or individually for each side.
*/
border?: {
color: string;
width: number;
} | {
color: string;
top: number;
right: number;
bottom: number;
left: number;
};
/**
* Increase brightness by a factor. A value of 1.0 equals no change, a value
* of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
* 0 is ignored.
*/
brightness?: number;
/**
* Increase contrast by a factor. A value of 1.0 equals no change, a value of
* 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
* ignored.
*/
contrast?: number;
/**
* Increase exposure by a factor. A value of 1.0 equals no change, a value of
* 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
*/
gamma?: number;
/**
* Increase contrast by a factor. A value of 1.0 equals no change, a value of
* 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
* ignored.
*/
saturation?: number;
/**
* Flips the images horizontally, vertically, or both. Flipping is applied before
* rotation, so if you apply flip=h,rotate=90 then the image will be flipped
* horizontally, then rotated by 90 degrees.
*/
flip?: 'h' | 'v' | 'hv';
/**
* Slightly reduces latency on a cache miss by selecting a
* quickest-to-compress file format, at a cost of increased file size and
* lower image quality. It will usually override the format option and choose
* JPEG over WebP or AVIF. We do not recommend using this option, except in
* unusual circumstances like resizing uncacheable dynamically-generated
* images.
*/
compression?: "fast";
}
interface RequestInitCfPropertiesImageMinify {
javascript?: boolean;
css?: boolean;
html?: boolean;
}
interface RequestInitCfPropertiesR2 {
/**
* Colo id of bucket that an object is stored in
*/
bucketColoId?: number;
}
/**
* Request metadata provided by Cloudflare's edge.
*/
type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
/**
* [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
*
* @example 395747
*/
asn?: number;
/**
* The organization which owns the ASN of the incoming request.
*
* @example "Google Cloud"
*/
asOrganization?: string;
/**
* The original value of the `Accept-Encoding` header if Cloudflare modified it.
*
* @example "gzip, deflate, br"
*/
clientAcceptEncoding?: string;
/**
* The number of milliseconds it took for the request to reach your worker.
*
* @example 22
*/
clientTcpRtt?: number;
/**
* The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
* airport code of the data center that the request hit.
*
* @example "DFW"
*/
colo: string;
/**
* Represents the upstream's response to a
* [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
* from cloudflare.
*
* For workers with no upstream, this will always be `1`.
*
* @example 3
*/
edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
/**
* The HTTP Protocol the request used.
*
* @example "HTTP/2"
*/
httpProtocol: string;
/**
* The browser-requested prioritization information in the request object.
*
* If no information was set, defaults to the empty string `""`
*
* @example "weight=192;exclusive=0;group=3;group-weight=127"
* @default ""
*/
requestPriority: string;
/**
* The TLS version of the connection to Cloudflare.
* In requests served over plaintext (without TLS), this property is the empty string `""`.
*
* @example "TLSv1.3"
*/
tlsVersion: string;
/**
* The cipher for the connection to Cloudflare.
* In requests served over plaintext (without TLS), this property is the empty string `""`.
*
* @example "AEAD-AES128-GCM-SHA256"
*/
tlsCipher: string;
/**
* Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake.
*
* If the incoming request was served over plaintext (without TLS) this field is undefined.
*/
tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
}
interface IncomingRequestCfPropertiesBotManagementBase {
/**
* Cloudflareโs [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
* represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
*
* @example 54
*/
score: number;
/**
* A boolean value that is true if the request comes from a good bot, like Google or Bing.
* Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots).
*/
verifiedBot: boolean;
/**
* A boolean value that is true if the request originates from a
* Cloudflare-verified proxy service.
*/
corporateProxy: boolean;
/**
* A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources.
*/
staticResource: boolean;
/**
* List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request).
*/
detectionIds: number[];
}
interface IncomingRequestCfPropertiesBotManagement {
/**
* Results of Cloudflare's Bot Management analysis
*/
botManagement: IncomingRequestCfPropertiesBotManagementBase;
/**
* Duplicate of `botManagement.score`.
*
* @deprecated
*/
clientTrustScore: number;
}
interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
/**
* Results of Cloudflare's Bot Management analysis
*/
botManagement: IncomingRequestCfPropertiesBotManagementBase & {
/**
* A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
* across different destination IPs, Ports, and X509 certificates.
*/
ja3Hash: string;
};
}
interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
/**
* Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
*
* This field is only present if you have Cloudflare for SaaS enabled on your account
* and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
*/
hostMetadata?: HostMetadata;
}
interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
/**
* Information about the client certificate presented to Cloudflare.
*
* This is populated when the incoming request is served over TLS using
* either Cloudflare Access or API Shield (mTLS)
* and the presented SSL certificate has a valid
* [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
* (i.e., not `null` or `""`).
*
* Otherwise, a set of placeholder values are used.
*
* The property `certPresented` will be set to `"1"` when
* the object is populated (i.e. the above conditions were met).
*/
tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
}
/**
* Metadata about the request's TLS handshake
*/
interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
/**
* The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
*
* @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
*/
clientHandshake: string;
/**
* The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
*
* @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
*/
serverHandshake: string;
/**
* The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
*
* @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
*/
clientFinished: string;
/**
* The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
*
* @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
*/
serverFinished: string;
}
/**
* Geographic data about the request's origin.
*/
interface IncomingRequestCfPropertiesGeographicInformation {
/**
* The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
*
* If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR.
*
* If Cloudflare is unable to determine where the request originated this property is omitted.
*
* The country code `"T1"` is used for requests originating on TOR.
*
* @example "GB"
*/
country?: Iso3166Alpha2Code | "T1";
/**
* If present, this property indicates that the request originated in the EU
*
* @example "1"
*/
isEUCountry?: "1";
/**
* A two-letter code indicating the continent the request originated from.
*
* @example "AN"
*/
continent?: ContinentCode;
/**
* The city the request originated from
*
* @example "Austin"
*/
city?: string;
/**
* Postal code of the incoming request
*
* @example "78701"
*/
postalCode?: string;
/**
* Latitude of the incoming request
*
* @example "30.27130"
*/
latitude?: string;
/**
* Longitude of the incoming request
*
* @example "-97.74260"
*/
longitude?: string;
/**
* Timezone of the incoming request
*
* @example "America/Chicago"
*/
timezone?: string;
/**
* If known, the ISO 3166-2 name for the first level region associated with
* the IP address of the incoming request
*
* @example "Texas"
*/
region?: string;
/**
* If known, the ISO 3166-2 code for the first-level region associated with
* the IP address of the incoming request
*
* @example "TX"
*/
regionCode?: string;
/**
* Metro code (DMA) of the incoming request
*
* @example "635"
*/
metroCode?: string;
}
/** Data about the incoming request's TLS certificate */
interface IncomingRequestCfPropertiesTLSClientAuth {
/** Always `"1"`, indicating that the certificate was presented */
certPresented: "1";
/**
* Result of certificate verification.
*
* @example "FAILED:self signed certificate"
*/
certVerified: Exclude<CertVerificationStatus, "NONE">;
/** The presented certificate's revokation status.
*
* - A value of `"1"` indicates the certificate has been revoked
* - A value of `"0"` indicates the certificate has not been revoked
*/
certRevoked: "1" | "0";
/**
* The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
*
* @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
*/
certIssuerDN: string;
/**
* The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
*
* @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
*/
certSubjectDN: string;
/**
* The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
*
* @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
*/
certIssuerDNRFC2253: string;
/**
* The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
*
* @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
*/
certSubjectDNRFC2253: string;
/** The certificate issuer's distinguished name (legacy policies) */
certIssuerDNLegacy: string;
/** The certificate subject's distinguished name (legacy policies) */
certSubjectDNLegacy: string;
/**
* The certificate's serial number
*
* @example "00936EACBE07F201DF"
*/
certSerial: string;
/**
* The certificate issuer's serial number
*
* @example "2489002934BDFEA34"
*/
certIssuerSerial: string;
/**
* The certificate's Subject Key Identifier
*
* @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
*/
certSKI: string;
/**
* The certificate issuer's Subject Key Identifier
*
* @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
*/
certIssuerSKI: string;
/**
* The certificate's SHA-1 fingerprint
*
* @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
*/
certFingerprintSHA1: string;
/**
* The certificate's SHA-256 fingerprint
*
* @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
*/
certFingerprintSHA256: string;
/**
* The effective starting date of the certificate
*
* @example "Dec 22 19:39:00 2018 GMT"
*/
certNotBefore: string;
/**
* The effective expiration date of the certificate
*
* @example "Dec 22 19:39:00 2018 GMT"
*/
certNotAfter: string;
}
/** Placeholder values for TLS Client Authorization */
interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
certPresented: "0";
certVerified: "NONE";
certRevoked: "0";
certIssuerDN: "";
certSubjectDN: "";
certIssuerDNRFC2253: "";
certSubjectDNRFC2253: "";
certIssuerDNLegacy: "";
certSubjectDNLegacy: "";
certSerial: "";
certIssuerSerial: "";
certSKI: "";
certIssuerSKI: "";
certFingerprintSHA1: "";
certFingerprintSHA256: "";
certNotBefore: "";
certNotAfter: "";
}
/** Possible outcomes of TLS verification */
declare type CertVerificationStatus =
/** Authentication succeeded */
"SUCCESS"
/** No certificate was presented */
| "NONE"
/** Failed because the certificate was self-signed */
| "FAILED:self signed certificate"
/** Failed because the certificate failed a trust chain check */
| "FAILED:unable to verify the first certificate"
/** Failed because the certificate not yet valid */
| "FAILED:certificate is not yet valid"
/** Failed because the certificate is expired */
| "FAILED:certificate has expired"
/** Failed for another unspecified reason */
| "FAILED";
/**
* An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
*/
declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus = 0 /** Unknown */ | 1 /** no keepalives (not found) */ | 2 /** no connection re-use, opening keepalive connection failed */ | 3 /** no connection re-use, keepalive accepted and saved */ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */ | 5; /** connection re-use, accepted by the origin server */
/** ISO 3166-1 Alpha-2 codes */
declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW";
/** The 2-letter continent codes Cloudflare uses */
declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties;
interface D1Meta {
duration: number;
size_after: number;
rows_read: number;
rows_written: number;
last_row_id: number;
changed_db: boolean;
changes: number;
/**
* The region of the database instance that executed the query.
*/
served_by_region?: string;
/**
* True if-and-only-if the database instance that executed the query was the primary.
*/
served_by_primary?: boolean;
timings?: {
/**
* The duration of the SQL query execution by the database instance. It doesn't include any network time.
*/
sql_duration_ms: number;
};
/**
* Number of total attempts to execute the query, due to automatic retries.
* Note: All other fields in the response like `timings` only apply to the last attempt.
*/
total_attempts?: number;
}
interface D1Response {
success: true;
meta: D1Meta & Record<string, unknown>;
error?: never;
}
type D1Result<T = unknown> = D1Response & {
results: T[];
};
interface D1ExecResult {
count: number;
duration: number;
}
type D1SessionConstraint =
// Indicates that the first query should go to the primary, and the rest queries
// using the same D1DatabaseSession will go to any replica that is consistent with
// the bookmark maintained by the session (returned by the first query).
'first-primary'
// Indicates that the first query can go anywhere (primary or replica), and the rest queries
// using the same D1DatabaseSession will go to any replica that is consistent with
// the bookmark maintained by the session (returned by the first query).
| 'first-unconstrained';
type D1SessionBookmark = string;
declare abstract class D1Database {
prepare(query: string): D1PreparedStatement;
batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
exec(query: string): Promise<D1ExecResult>;
/**
* Creates a new D1 Session anchored at the given constraint or the bookmark.
* All queries executed using the created session will have sequential consistency,
* meaning that all writes done through the session will be visible in subsequent reads.
*
* @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
*/
withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession;
/**
* @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
*/
dump(): Promise<ArrayBuffer>;
}
declare abstract class D1DatabaseSession {
prepare(query: string): D1PreparedStatement;
batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
/**
* @returns The latest session bookmark across all executed queries on the session.
* If no query has been executed yet, `null` is returned.
*/
getBookmark(): D1SessionBookmark | null;
}
declare abstract class D1PreparedStatement {
bind(...values: unknown[]): D1PreparedStatement;
first<T = unknown>(colName: string): Promise<T | null>;
first<T = Record<string, unknown>>(): Promise<T | null>;
run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
raw<T = unknown[]>(options: {
columnNames: true;
}): Promise<[
string[],
...T[]
]>;
raw<T = unknown[]>(options?: {
columnNames?: false;
}): Promise<T[]>;
}
// `Disposable` was added to TypeScript's standard lib types in version 5.2.
// To support older TypeScript versions, define an empty `Disposable` interface.
// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
// but this will ensure type checking on older versions still passes.
// TypeScript's interface merging will ensure our empty interface is effectively
// ignored when `Disposable` is included in the standard lib.
interface Disposable {
}
/**
* An email message that can be sent from a Worker.
*/
interface EmailMessage {
/**
* Envelope From attribute of the email message.
*/
readonly from: string;
/**
* Envelope To attribute of the email message.
*/
readonly to: string;
}
/**
* An email message that is sent to a consumer Worker and can be rejected/forwarded.
*/
interface ForwardableEmailMessage extends EmailMessage {
/**
* Stream of the email message content.
*/
readonly raw: ReadableStream<Uint8Array>;
/**
* An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
*/
readonly headers: Headers;
/**
* Size of the email message content.
*/
readonly rawSize: number;
/**
* Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
* @param reason The reject reason.
* @returns void
*/
setReject(reason: string): void;
/**
* Forward this email message to a verified destination address of the account.
* @param rcptTo Verified destination address.
* @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
* @returns A promise that resolves when the email message is forwarded.
*/
forward(rcptTo: string, headers?: Headers): Promise<void>;
/**
* Reply to the sender of this email message with a new EmailMessage object.
* @param message The reply message.
* @returns A promise that resolves when the email message is replied.
*/
reply(message: EmailMessage): Promise<void>;
}
/**
* A binding that allows a Worker to send email messages.
*/
interface SendEmail {
send(message: EmailMessage): Promise<void>;
}
declare abstract class EmailEvent extends ExtendableEvent {
readonly message: ForwardableEmailMessage;
}
declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise<void>;
declare module "cloudflare:email" {
let _EmailMessage: {
prototype: EmailMessage;
new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
};
export { _EmailMessage as EmailMessage };
}
/**
* Hello World binding to serve as an explanatory example. DO NOT USE
*/
interface HelloWorldBinding {
/**
* Retrieve the current stored value
*/
get(): Promise<{
value: string;
ms?: number;
}>;
/**
* Set a new stored value
*/
set(value: string): Promise<void>;
}
interface Hyperdrive {
/**
* Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
*
* Calling this method returns an idential socket to if you call
* `connect("host:port")` using the `host` and `port` fields from this object.
* Pick whichever approach works better with your preferred DB client library.
*
* Note that this socket is not yet authenticated -- it's expected that your
* code (or preferably, the client library of your choice) will authenticate
* using the information in this class's readonly fields.
*/
connect(): Socket;
/**
* A valid DB connection string that can be passed straight into the typical
* client library/driver/ORM. This will typically be the easiest way to use
* Hyperdrive.
*/
readonly connectionString: string;
/*
* A randomly generated hostname that is only valid within the context of the
* currently running Worker which, when passed into `connect()` function from
* the "cloudflare:sockets" module, will connect to the Hyperdrive instance
* for your database.
*/
readonly host: string;
/*
* The port that must be paired the the host field when connecting.
*/
readonly port: number;
/*
* The username to use when authenticating to your database via Hyperdrive.
* Unlike the host and password, this will be the same every time
*/
readonly user: string;
/*
* The randomly generated password to use when authenticating to your
* database via Hyperdrive. Like the host field, this password is only valid
* within the context of the currently running Worker instance from which
* it's read.
*/
readonly password: string;
/*
* The name of the database to connect to.
*/
readonly database: string;
}
// Copyright (c) 2024 Cloudflare, Inc.
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0
type ImageInfoResponse = {
format: 'image/svg+xml';
} | {
format: string;
fileSize: number;
width: number;
height: number;
};
type ImageTransform = {
width?: number;
height?: number;
background?: string;
blur?: number;
border?: {
color?: string;
width?: number;
} | {
top?: number;
bottom?: number;
left?: number;
right?: number;
};
brightness?: number;
contrast?: number;
fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop';
flip?: 'h' | 'v' | 'hv';
gamma?: number;
segment?: 'foreground';
gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | {
x?: number;
y?: number;
mode: 'remainder' | 'box-center';
};
rotate?: 0 | 90 | 180 | 270;
saturation?: number;
sharpen?: number;
trim?: 'border' | {
top?: number;
bottom?: number;
left?: number;
right?: number;
width?: number;
height?: number;
border?: boolean | {
color?: string;
tolerance?: number;
keep?: number;
};
};
};
type ImageDrawOptions = {
opacity?: number;
repeat?: boolean | string;
top?: number;
left?: number;
bottom?: number;
right?: number;
};
type ImageInputOptions = {
encoding?: 'base64';
};
type ImageOutputOptions = {
format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba';
quality?: number;
background?: string;
anim?: boolean;
};
interface ImagesBinding {
/**
* Get image metadata (type, width and height)
* @throws {@link ImagesError} with code 9412 if input is not an image
* @param stream The image bytes
*/
info(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): Promise<ImageInfoResponse>;
/**
* Begin applying a series of transformations to an image
* @param stream The image bytes
* @returns A transform handle
*/
input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer;
}
interface ImageTransformer {
/**
* Apply transform next, returning a transform handle.
* You can then apply more transformations, draw, or retrieve the output.
* @param transform
*/
transform(transform: ImageTransform): ImageTransformer;
/**
* Draw an image on this transformer, returning a transform handle.
* You can then apply more transformations, draw, or retrieve the output.
* @param image The image (or transformer that will give the image) to draw
* @param options The options configuring how to draw the image
*/
draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer;
/**
* Retrieve the image that results from applying the transforms to the
* provided input
* @param options Options that apply to the output e.g. output format
*/
output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
}
type ImageTransformationOutputOptions = {
encoding?: 'base64';
};
interface ImageTransformationResult {
/**
* The image as a response, ready to store in cache or return to users
*/
response(): Response;
/**
* The content type of the returned image
*/
contentType(): string;
/**
* The bytes of the response
*/
image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
}
interface ImagesError extends Error {
readonly code: number;
readonly message: string;
readonly stack?: string;
}
/**
* Media binding for transforming media streams.
* Provides the entry point for media transformation operations.
*/
interface MediaBinding {
/**
* Creates a media transformer from an input stream.
* @param media - The input media bytes
* @returns A MediaTransformer instance for applying transformations
*/
input(media: ReadableStream<Uint8Array>): MediaTransformer;
}
/**
* Media transformer for applying transformation operations to media content.
* Handles sizing, fitting, and other input transformation parameters.
*/
interface MediaTransformer {
/**
* Applies transformation options to the media content.
* @param transform - Configuration for how the media should be transformed
* @returns A generator for producing the transformed media output
*/
transform(transform: MediaTransformationInputOptions): MediaTransformationGenerator;
}
/**
* Generator for producing media transformation results.
* Configures the output format and parameters for the transformed media.
*/
interface MediaTransformationGenerator {
/**
* Generates the final media output with specified options.
* @param output - Configuration for the output format and parameters
* @returns The final transformation result containing the transformed media
*/
output(output: MediaTransformationOutputOptions): MediaTransformationResult;
}
/**
* Result of a media transformation operation.
* Provides multiple ways to access the transformed media content.
*/
interface MediaTransformationResult {
/**
* Returns the transformed media as a readable stream of bytes.
* @returns A stream containing the transformed media data
*/
media(): ReadableStream<Uint8Array>;
/**
* Returns the transformed media as an HTTP response object.
* @returns The transformed media as a Response, ready to store in cache or return to users
*/
response(): Response;
/**
* Returns the MIME type of the transformed media.
* @returns The content type string (e.g., 'image/jpeg', 'video/mp4')
*/
contentType(): string;
}
/**
* Configuration options for transforming media input.
* Controls how the media should be resized and fitted.
*/
type MediaTransformationInputOptions = {
/** How the media should be resized to fit the specified dimensions */
fit?: 'contain' | 'cover' | 'scale-down';
/** Target width in pixels */
width?: number;
/** Target height in pixels */
height?: number;
};
/**
* Configuration options for Media Transformations output.
* Controls the format, timing, and type of the generated output.
*/
type MediaTransformationOutputOptions = {
/**
* Output mode determining the type of media to generate
*/
mode?: 'video' | 'spritesheet' | 'frame' | 'audio';
/** Whether to include audio in the output */
audio?: boolean;
/**
* Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
*/
time?: string;
/**
* Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
*/
duration?: string;
/**
* Number of frames in the spritesheet.
*/
imageCount?: number;
/**
* Output format for the generated media.
*/
format?: 'jpg' | 'png' | 'm4a';
};
/**
* Error object for media transformation operations.
* Extends the standard Error interface with additional media-specific information.
*/
interface MediaError extends Error {
readonly code: number;
readonly message: string;
readonly stack?: string;
}
declare module 'cloudflare:node' {
interface NodeStyleServer {
listen(...args: unknown[]): this;
address(): {
port?: number | null | undefined;
};
}
export function httpServerHandler(port: number): ExportedHandler;
export function httpServerHandler(options: {
port: number;
}): ExportedHandler;
export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
}
type Params<P extends string = any> = Record<P, string | string[]>;
type EventContext<Env, P extends string, Data> = {
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
functionPath: string;
waitUntil: (promise: Promise<any>) => void;
passThroughOnException: () => void;
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
env: Env & {
ASSETS: {
fetch: typeof fetch;
};
};
params: Params<P>;
data: Data;
};
type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
functionPath: string;
waitUntil: (promise: Promise<any>) => void;
passThroughOnException: () => void;
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
env: Env & {
ASSETS: {
fetch: typeof fetch;
};
};
params: Params<P>;
data: Data;
pluginArgs: PluginArgs;
};
type PagesPluginFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginArgs = unknown> = (context: EventPluginContext<Env, Params, Data, PluginArgs>) => Response | Promise<Response>;
declare module "assets:*" {
export const onRequest: PagesFunction;
}
// Copyright (c) 2022-2023 Cloudflare, Inc.
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0
declare module "cloudflare:pipelines" {
export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> {
protected env: Env;
protected ctx: ExecutionContext;
constructor(ctx: ExecutionContext, env: Env);
/**
* run recieves an array of PipelineRecord which can be
* transformed and returned to the pipeline
* @param records Incoming records from the pipeline to be transformed
* @param metadata Information about the specific pipeline calling the transformation entrypoint
* @returns A promise containing the transformed PipelineRecord array
*/
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
}
export type PipelineRecord = Record<string, unknown>;
export type PipelineBatchMetadata = {
pipelineId: string;
pipelineName: string;
};
export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
/**
* The Pipeline interface represents the type of a binding to a Pipeline
*
* @param records The records to send to the pipeline
*/
send(records: T[]): Promise<void>;
}
}
// PubSubMessage represents an incoming PubSub message.
// The message includes metadata about the broker, the client, and the payload
// itself.
// https://developers.cloudflare.com/pub-sub/
interface PubSubMessage {
// Message ID
readonly mid: number;
// MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
readonly broker: string;
// The MQTT topic the message was sent on.
readonly topic: string;
// The client ID of the client that published this message.
readonly clientId: string;
// The unique identifier (JWT ID) used by the client to authenticate, if token
// auth was used.
readonly jti?: string;
// A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
// received the message from the client.
readonly receivedAt: number;
// An (optional) string with the MIME type of the payload, if set by the
// client.
readonly contentType: string;
// Set to 1 when the payload is a UTF-8 string
// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
readonly payloadFormatIndicator: number;
// Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
// You can use payloadFormatIndicator to inspect this before decoding.
payload: string | Uint8Array;
}
// JsonWebKey extended by kid parameter
interface JsonWebKeyWithKid extends JsonWebKey {
// Key Identifier of the JWK
readonly kid: string;
}
interface RateLimitOptions {
key: string;
}
interface RateLimitOutcome {
success: boolean;
}
interface RateLimit {
/**
* Rate limit a request based on the provided options.
* @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
* @returns A promise that resolves with the outcome of the rate limit.
*/
limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
}
// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
// to referenced by `Fetcher`. This is included in the "importable" version of the types which
// strips all `module` blocks.
declare namespace Rpc {
// Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
// TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
// For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
// accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND';
export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND';
export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND';
export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND';
export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND';
export interface RpcTargetBranded {
[__RPC_TARGET_BRAND]: never;
}
export interface WorkerEntrypointBranded {
[__WORKER_ENTRYPOINT_BRAND]: never;
}
export interface DurableObjectBranded {
[__DURABLE_OBJECT_BRAND]: never;
}
export interface WorkflowEntrypointBranded {
[__WORKFLOW_ENTRYPOINT_BRAND]: never;
}
export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded;
// Types that can be used through `Stub`s
export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
// Types that can be passed over RPC
// The reason for using a generic type here is to build a serializable subset of structured
// cloneable composite types. This allows types defined with the "interface" keyword to pass the
// serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
type Serializable<T> =
// Structured cloneables
BaseType
// Structured cloneable composites
| Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | {
[K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
}
// Special types
| Stub<Stubable>
// Serialized as stubs, see `Stubify`
| Stubable;
// Base type for all RPC stubs, including common memory management methods.
// `T` is used as a marker type for unwrapping `Stub`s later.
interface StubBase<T extends Stubable> extends Disposable {
[__RPC_STUB_BRAND]: T;
dup(): this;
}
export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
// This represents all the types that can be sent as-is over an RPC boundary
type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
// Recursively rewrite all `Stubable` types with `Stub`s
// prettier-ignore
type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends {
[key: string | number]: any;
} ? {
[K in keyof T]: Stubify<T[K]>;
} : T;
// Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
// Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
// `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
// prettier-ignore
type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends {
[key: string | number]: unknown;
} ? {
[K in keyof T]: Unstubify<T[K]>;
} : T;
type UnstubifyAll<A extends any[]> = {
[I in keyof A]: Unstubify<A[I]>;
};
// Utility type for adding `Provider`/`Disposable`s to `object` types only.
// Note `unknown & T` is equivalent to `T`.
type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
type MaybeDisposable<T> = T extends object ? Disposable : unknown;
// Type for method return or property on an RPC interface.
// - Stubable types are replaced by stubs.
// - Serializable types are passed by value, with stubable types replaced by stubs
// and a top-level `Disposer`.
// Everything else can't be passed over PRC.
// Technically, we use custom thenables here, but they quack like `Promise`s.
// Intersecting with `(Maybe)Provider` allows pipelining.
// prettier-ignore
type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never;
// Type for method or property on an RPC interface.
// For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
// Unwrapping `Stub`s allows calling with `Stubable` arguments.
// For properties, rewrite types to be `Result`s.
// In each case, unwrap `Promise`s.
type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>;
// Type for the callable part of an `Provider` if `T` is callable.
// This is intersected with methods/properties.
type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown;
// Base type for all other types providing RPC-like interfaces.
// Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
// `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & {
[K in Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>]: MethodOrProperty<T[K]>;
};
}
declare namespace Cloudflare {
// Type of `env`.
//
// The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
// will merge all declarations.
//
// You can use `wrangler types` to generate the `Env` type automatically.
interface Env {
}
// Project-specific parameters used to inform types.
//
// This interface is, again, intended to be declared in project-specific files, and then that
// declaration will be merged with this one.
//
// A project should have a declaration like this:
//
// interface GlobalProps {
// // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
// // of `ctx.exports`.
// mainModule: typeof import("my-main-module");
//
// // Declares which of the main module's exports are configured with durable storage, and
// // thus should behave as Durable Object namsepace bindings.
// durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
// }
//
// You can use `wrangler types` to generate `GlobalProps` automatically.
interface GlobalProps {
}
// Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
// present.
type GlobalProp<K extends string, Default> = K extends keyof GlobalProps ? GlobalProps[K] : Default;
// The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
// `mainModule` property.
type MainModule = GlobalProp<"mainModule", {}>;
// The type of ctx.exports, which contains loopback bindings for all top-level exports.
type Exports = {
[K in keyof MainModule]: LoopbackForExport<MainModule[K]>
// If the export is listed in `durableNamespaces`, then it is also a
// DurableObjectNamespace.
& (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {});
};
}
declare namespace CloudflareWorkersModule {
export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
export const RpcStub: {
new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
};
export abstract class RpcTarget implements Rpc.RpcTargetBranded {
[Rpc.__RPC_TARGET_BRAND]: never;
}
// `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}> implements Rpc.WorkerEntrypointBranded {
[Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
protected ctx: ExecutionContext<Props>;
protected env: Env;
constructor(ctx: ExecutionContext, env: Env);
fetch?(request: Request): Response | Promise<Response>;
tail?(events: TraceItem[]): void | Promise<void>;
tailStream?(event: TailStream.TailEvent<TailStream.Onset>): TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
trace?(traces: TraceItem[]): void | Promise<void>;
scheduled?(controller: ScheduledController): void | Promise<void>;
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
test?(controller: TestController): void | Promise<void>;
}
export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded {
[Rpc.__DURABLE_OBJECT_BRAND]: never;
protected ctx: DurableObjectState<Props>;
protected env: Env;
constructor(ctx: DurableObjectState, env: Env);
fetch?(request: Request): Response | Promise<Response>;
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
}
export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
export type WorkflowDelayDuration = WorkflowSleepDuration;
export type WorkflowTimeoutDuration = WorkflowSleepDuration;
export type WorkflowRetentionDuration = WorkflowSleepDuration;
export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';
export type WorkflowStepConfig = {
retries?: {
limit: number;
delay: WorkflowDelayDuration | number;
backoff?: WorkflowBackoff;
};
timeout?: WorkflowTimeoutDuration | number;
};
export type WorkflowEvent<T> = {
payload: Readonly<T>;
timestamp: Date;
instanceId: string;
};
export type WorkflowStepEvent<T> = {
payload: Readonly<T>;
timestamp: Date;
type: string;
};
export abstract class WorkflowStep {
do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>;
do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>;
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {
type: string;
timeout?: WorkflowTimeoutDuration | number;
}): Promise<WorkflowStepEvent<T>>;
}
export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded {
[Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
protected ctx: ExecutionContext;
protected env: Env;
constructor(ctx: ExecutionContext, env: Env);
run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
}
export function waitUntil(promise: Promise<unknown>): void;
export const env: Cloudflare.Env;
}
declare module 'cloudflare:workers' {
export = CloudflareWorkersModule;
}
interface SecretsStoreSecret {
/**
* Get a secret from the Secrets Store, returning a string of the secret value
* if it exists, or throws an error if it does not exist
*/
get(): Promise<string>;
}
declare module "cloudflare:sockets" {
function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;
export { _connect as connect };
}
type ConversionResponse = {
name: string;
mimeType: string;
} & ({
format: "markdown";
tokens: number;
data: string;
} | {
format: "error";
error: string;
});
type SupportedFileFormat = {
mimeType: string;
extension: string;
};
declare abstract class ToMarkdownService {
transform(files: {
name: string;
blob: Blob;
}[], options?: {
gateway?: GatewayOptions;
extraHeaders?: object;
}): Promise<ConversionResponse[]>;
transform(files: {
name: string;
blob: Blob;
}, options?: {
gateway?: GatewayOptions;
extraHeaders?: object;
}): Promise<ConversionResponse>;
supported(): Promise<SupportedFileFormat[]>;
}
declare namespace TailStream {
interface Header {
readonly name: string;
readonly value: string;
}
interface FetchEventInfo {
readonly type: "fetch";
readonly method: string;
readonly url: string;
readonly cfJson?: object;
readonly headers: Header[];
}
interface JsRpcEventInfo {
readonly type: "jsrpc";
}
interface ScheduledEventInfo {
readonly type: "scheduled";
readonly scheduledTime: Date;
readonly cron: string;
}
interface AlarmEventInfo {
readonly type: "alarm";
readonly scheduledTime: Date;
}
interface QueueEventInfo {
readonly type: "queue";
readonly queueName: string;
readonly batchSize: number;
}
interface EmailEventInfo {
readonly type: "email";
readonly mailFrom: string;
readonly rcptTo: string;
readonly rawSize: number;
}
interface TraceEventInfo {
readonly type: "trace";
readonly traces: (string | null)[];
}
interface HibernatableWebSocketEventInfoMessage {
readonly type: "message";
}
interface HibernatableWebSocketEventInfoError {
readonly type: "error";
}
interface HibernatableWebSocketEventInfoClose {
readonly type: "close";
readonly code: number;
readonly wasClean: boolean;
}
interface HibernatableWebSocketEventInfo {
readonly type: "hibernatableWebSocket";
readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage;
}
interface CustomEventInfo {
readonly type: "custom";
}
interface FetchResponseInfo {
readonly type: "fetch";
readonly statusCode: number;
}
type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound";
interface ScriptVersion {
readonly id: string;
readonly tag?: string;
readonly message?: string;
}
interface Onset {
readonly type: "onset";
readonly attributes: Attribute[];
// id for the span being opened by this Onset event.
readonly spanId: string;
readonly dispatchNamespace?: string;
readonly entrypoint?: string;
readonly executionModel: string;
readonly scriptName?: string;
readonly scriptTags?: string[];
readonly scriptVersion?: ScriptVersion;
readonly info: FetchEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo;
}
interface Outcome {
readonly type: "outcome";
readonly outcome: EventOutcome;
readonly cpuTime: number;
readonly wallTime: number;
}
interface SpanOpen {
readonly type: "spanOpen";
readonly name: string;
// id for the span being opened by this SpanOpen event.
readonly spanId: string;
readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
}
interface SpanClose {
readonly type: "spanClose";
readonly outcome: EventOutcome;
}
interface DiagnosticChannelEvent {
readonly type: "diagnosticChannel";
readonly channel: string;
readonly message: any;
}
interface Exception {
readonly type: "exception";
readonly name: string;
readonly message: string;
readonly stack?: string;
}
interface Log {
readonly type: "log";
readonly level: "debug" | "error" | "info" | "log" | "warn";
readonly message: object;
}
// This marks the worker handler return information.
// This is separate from Outcome because the worker invocation can live for a long time after
// returning. For example - Websockets that return an http upgrade response but then continue
// streaming information or SSE http connections.
interface Return {
readonly type: "return";
readonly info?: FetchResponseInfo;
}
interface Attribute {
readonly name: string;
readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[];
}
interface Attributes {
readonly type: "attributes";
readonly info: Attribute[];
}
type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | Return | Attributes;
// Context in which this trace event lives.
interface SpanContext {
// Single id for the entire top-level invocation
// This should be a new traceId for the first worker stage invoked in the eyeball request and then
// same-account service-bindings should reuse the same traceId but cross-account service-bindings
// should use a new traceId.
readonly traceId: string;
// spanId in which this event is handled
// for Onset and SpanOpen events this would be the parent span id
// for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
// For Hibernate and Mark this would be the span under which they were emitted.
// spanId is not set ONLY if:
// 1. This is an Onset event
// 2. We are not inherting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
readonly spanId?: string;
}
interface TailEvent<Event extends EventType> {
// invocation id of the currently invoked worker stage.
// invocation id will always be unique to every Onset event and will be the same until the Outcome event.
readonly invocationId: string;
// Inherited spanContext for this event.
readonly spanContext: SpanContext;
readonly timestamp: Date;
readonly sequence: number;
readonly event: Event;
}
type TailEventHandler<Event extends EventType = EventType> = (event: TailEvent<Event>) => void | Promise<void>;
type TailEventHandlerObject = {
outcome?: TailEventHandler<Outcome>;
spanOpen?: TailEventHandler<SpanOpen>;
spanClose?: TailEventHandler<SpanClose>;
diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
exception?: TailEventHandler<Exception>;
log?: TailEventHandler<Log>;
return?: TailEventHandler<Return>;
attributes?: TailEventHandler<Attributes>;
};
type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
}
// Copyright (c) 2022-2023 Cloudflare, Inc.
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
// https://opensource.org/licenses/Apache-2.0
/**
* Data types supported for holding vector metadata.
*/
type VectorizeVectorMetadataValue = string | number | boolean | string[];
/**
* Additional information to associate with a vector.
*/
type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>;
type VectorFloatArray = Float32Array | Float64Array;
interface VectorizeError {
code?: number;
error: string;
}
/**
* Comparison logic/operation to use for metadata filtering.
*
* This list is expected to grow as support for more operations are released.
*/
type VectorizeVectorMetadataFilterOp = '$eq' | '$ne' | '$lt' | '$lte' | '$gt' | '$gte';
type VectorizeVectorMetadataFilterCollectionOp = '$in' | '$nin';
/**
* Filter criteria for vector metadata used to limit the retrieved query result set.
*/
type VectorizeVectorMetadataFilter = {
[field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | {
[Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null;
} | {
[Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<VectorizeVectorMetadataValue, string[]>[];
};
};
/**
* Supported distance metrics for an index.
* Distance metrics determine how other "similar" vectors are determined.
*/
type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
/**
* Metadata return levels for a Vectorize query.
*
* Default to "none".
*
* @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.
* @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).
* @property none No indexed metadata will be returned.
*/
type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
interface VectorizeQueryOptions {
topK?: number;
namespace?: string;
returnValues?: boolean;
returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
filter?: VectorizeVectorMetadataFilter;
}
/**
* Information about the configuration of an index.
*/
type VectorizeIndexConfig = {
dimensions: number;
metric: VectorizeDistanceMetric;
} | {
preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
};
/**
* Metadata about an existing index.
*
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
* See {@link VectorizeIndexInfo} for its post-beta equivalent.
*/
interface VectorizeIndexDetails {
/** The unique ID of the index */
readonly id: string;
/** The name of the index. */
name: string;
/** (optional) A human readable description for the index. */
description?: string;
/** The index configuration, including the dimension size and distance metric. */
config: VectorizeIndexConfig;
/** The number of records containing vectors within the index. */
vectorsCount: number;
}
/**
* Metadata about an existing index.
*/
interface VectorizeIndexInfo {
/** The number of records containing vectors within the index. */
vectorCount: number;
/** Number of dimensions the index has been configured for. */
dimensions: number;
/** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
processedUpToDatetime: number;
/** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
processedUpToMutation: number;
}
/**
* Represents a single vector value set along with its associated metadata.
*/
interface VectorizeVector {
/** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
id: string;
/** The vector values */
values: VectorFloatArray | number[];
/** The namespace this vector belongs to. */
namespace?: string;
/** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
metadata?: Record<string, VectorizeVectorMetadata>;
}
/**
* Represents a matched vector for a query along with its score and (if specified) the matching vector information.
*/
type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & {
/** The score or rank for similarity, when returned as a result */
score: number;
};
/**
* A set of matching {@link VectorizeMatch} for a particular query.
*/
interface VectorizeMatches {
matches: VectorizeMatch[];
count: number;
}
/**
* Results of an operation that performed a mutation on a set of vectors.
* Here, `ids` is a list of vectors that were successfully processed.
*
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
* See {@link VectorizeAsyncMutation} for its post-beta equivalent.
*/
interface VectorizeVectorMutation {
/* List of ids of vectors that were successfully processed. */
ids: string[];
/* Total count of the number of processed vectors. */
count: number;
}
/**
* Result type indicating a mutation on the Vectorize Index.
* Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
*/
interface VectorizeAsyncMutation {
/** The unique identifier for the async mutation operation containing the changeset. */
mutationId: string;
}
/**
* A Vectorize Vector Search Index for querying vectors/embeddings.
*
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
* See {@link Vectorize} for its new implementation.
*/
declare abstract class VectorizeIndex {
/**
* Get information about the currently bound index.
* @returns A promise that resolves with information about the current index.
*/
public describe(): Promise<VectorizeIndexDetails>;
/**
* Use the provided vector to perform a similarity search across the index.
* @param vector Input vector that will be used to drive the similarity search.
* @param options Configuration options to massage the returned data.
* @returns A promise that resolves with matched and scored vectors.
*/
public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
/**
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
* @param vectors List of vectors that will be inserted.
* @returns A promise that resolves with the ids & count of records that were successfully processed.
*/
public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
/**
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
* @param vectors List of vectors that will be upserted.
* @returns A promise that resolves with the ids & count of records that were successfully processed.
*/
public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
/**
* Delete a list of vectors with a matching id.
* @param ids List of vector ids that should be deleted.
* @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
*/
public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
/**
* Get a list of vectors with a matching id.
* @param ids List of vector ids that should be returned.
* @returns A promise that resolves with the raw unscored vectors matching the id set.
*/
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
}
/**
* A Vectorize Vector Search Index for querying vectors/embeddings.
*
* Mutations in this version are async, returning a mutation id.
*/
declare abstract class Vectorize {
/**
* Get information about the currently bound index.
* @returns A promise that resolves with information about the current index.
*/
public describe(): Promise<VectorizeIndexInfo>;
/**
* Use the provided vector to perform a similarity search across the index.
* @param vector Input vector that will be used to drive the similarity search.
* @param options Configuration options to massage the returned data.
* @returns A promise that resolves with matched and scored vectors.
*/
public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
/**
* Use the provided vector-id to perform a similarity search across the index.
* @param vectorId Id for a vector in the index against which the index should be queried.
* @param options Configuration options to massage the returned data.
* @returns A promise that resolves with matched and scored vectors.
*/
public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
/**
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
* @param vectors List of vectors that will be inserted.
* @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
*/
public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
/**
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
* @param vectors List of vectors that will be upserted.
* @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
*/
public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
/**
* Delete a list of vectors with a matching id.
* @param ids List of vector ids that should be deleted.
* @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
*/
public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
/**
* Get a list of vectors with a matching id.
* @param ids List of vector ids that should be returned.
* @returns A promise that resolves with the raw unscored vectors matching the id set.
*/
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
}
/**
* The interface for "version_metadata" binding
* providing metadata about the Worker Version using this binding.
*/
type WorkerVersionMetadata = {
/** The ID of the Worker Version using this binding */
id: string;
/** The tag of the Worker Version using this binding */
tag: string;
/** The timestamp of when the Worker Version was uploaded */
timestamp: string;
};
interface DynamicDispatchLimits {
/**
* Limit CPU time in milliseconds.
*/
cpuMs?: number;
/**
* Limit number of subrequests.
*/
subRequests?: number;
}
interface DynamicDispatchOptions {
/**
* Limit resources of invoked Worker script.
*/
limits?: DynamicDispatchLimits;
/**
* Arguments for outbound Worker script, if configured.
*/
outbound?: {
[key: string]: any;
};
}
interface DispatchNamespace {
/**
* @param name Name of the Worker script.
* @param args Arguments to Worker script.
* @param options Options for Dynamic Dispatch invocation.
* @returns A Fetcher object that allows you to send requests to the Worker script.
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
*/
get(name: string, args?: {
[key: string]: any;
}, options?: DynamicDispatchOptions): Fetcher;
}
declare module 'cloudflare:workflows' {
/**
* NonRetryableError allows for a user to throw a fatal error
* that makes a Workflow instance fail immediately without triggering a retry
*/
export class NonRetryableError extends Error {
public constructor(message: string, name?: string);
}
}
declare abstract class Workflow<PARAMS = unknown> {
/**
* Get a handle to an existing instance of the Workflow.
* @param id Id for the instance of this Workflow
* @returns A promise that resolves with a handle for the Instance
*/
public get(id: string): Promise<WorkflowInstance>;
/**
* Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
* @param options Options when creating an instance including id and params
* @returns A promise that resolves with a handle for the Instance
*/
public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>;
/**
* Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
* `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
* @param batch List of Options when creating an instance including name and params
* @returns A promise that resolves with a list of handles for the created instances.
*/
public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
}
type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
type WorkflowRetentionDuration = WorkflowSleepDuration;
interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
/**
* An id for your Workflow instance. Must be unique within the Workflow.
*/
id?: string;
/**
* The event payload the Workflow instance is triggered with
*/
params?: PARAMS;
/**
* The retention policy for Workflow instance.
* Defaults to the maximum retention period available for the owner's account.
*/
retention?: {
successRetention?: WorkflowRetentionDuration;
errorRetention?: WorkflowRetentionDuration;
};
}
type InstanceStatus = {
status: 'queued' // means that instance is waiting to be started (see concurrency limits)
| 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running
| 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish
| 'waitingForPause' // instance is finishing the current work to pause
| 'unknown';
error?: string;
output?: object;
};
interface WorkflowError {
code?: number;
message: string;
}
declare abstract class WorkflowInstance {
public id: string;
/**
* Pause the instance.
*/
public pause(): Promise<void>;
/**
* Resume the instance. If it is already running, an error will be thrown.
*/
public resume(): Promise<void>;
/**
* Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
*/
public terminate(): Promise<void>;
/**
* Restart the instance.
*/
public restart(): Promise<void>;
/**
* Returns the current status of the instance.
*/
public status(): Promise<InstanceStatus>;
/**
* Send an event to this instance.
*/
public sendEvent({ type, payload, }: {
type: string;
payload: unknown;
}): Promise<void>;
}