@@ -2,159 +2,169 @@ interface FetchEvent {
2
2
passThroughOnException : ( ) => void
3
3
}
4
4
5
- interface RequestInit {
6
- cf ?: {
7
- cacheEverything ?: boolean
8
- cacheTtl ?: number
9
- cacheTtlByStatus ?: { [ key : string ] : number }
10
- scrapeShield ?: boolean
11
- apps ?: boolean
12
- image ?: {
13
- /**
14
- * Maximum width in image pixels. The value must be an integer.
15
- */
16
- width ?: number
17
- /**
18
- * Maximum height in image pixels.
19
- */
20
- height ?: number
21
- /**
22
- * Resizing mode as a string. It affects interpretation of width and height
23
- * options:
24
- * - scale-down: Similar to contain, but the image is never enlarged. If
25
- * the image is larger than given width or height, it will be resized.
26
- * Otherwise its original size will be kept.
27
- * - contain: Resizes to maximum size that fits within the given width and
28
- * height. If only a single dimension is given (e.g. only width), the
29
- * image will be shrunk or enlarged to exactly match that dimension.
30
- * Aspect ratio is always preserved.
31
- * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
32
- * and height. If the image has an aspect ratio different from the ratio
33
- * of width and height, it will be cropped to fit.
34
- */
35
- fit ?: 'scale-down' | 'contain' | 'cover'
36
- /**
37
- * When cropping with fit: "cover", this defines the side or point that should
38
- * be left uncropped. The value is either a string
39
- * "left", "right", "top", "bottom" or "center" (the default),
40
- * or an object {x, y} containing focal point coordinates in the original
41
- * image expressed as fractions ranging from 0.0 (top or left) to 1.0
42
- * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
43
- * crop bottom or left and right sides as necessary, but won’t crop anything
44
- * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
45
- * preserve as much as possible around a point at 20% of the height of the
46
- * source image.
47
- */
48
- gravity ?: 'left' | 'right' | 'top' | 'bottom' | 'center' | { x : number ; y : number }
49
- /**
50
- * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
51
- * make images look worse, but load faster. The default is 85. It applies only
52
- * to JPEG and WebP images. It doesn’t have any effect on PNG.
53
- */
54
- quality ?: number
55
- /**
56
- * Output format to generate. It can be:
57
- * - webp: generate images in Google WebP format. Set quality to 100 to get
58
- * the WebP-lossles format.
59
- * - json: instead of generating an image, outputs information about the
60
- * image, in JSON format. The JSON object will contain image size
61
- * (before and after resizing), source image’s MIME type, file size, etc.
62
- */
63
- format ?: 'webp' | 'json'
64
- }
65
- minify ?: {
66
- javascript ?: boolean
67
- css ?: boolean
68
- html ?: boolean
69
- }
70
- mirage ?: boolean
71
- /**
72
- * Redirects the request to an alternate origin server. You can use this,
73
- * for example, to implement load balancing across several origins.
74
- * (e.g.us-east.example.com)
75
- *
76
- * Note - For security reasons, the hostname set in resolveOverride must
77
- * be proxied on the same Cloudflare zone of the incoming request.
78
- * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
79
- * resolve to a host under a different domain or a DNS only domain first
80
- * declare a CNAME record within your own zone’s DNS mapping to the
81
- * external hostname, set proxy on Cloudflare, then set resolveOverride
82
- * to point to that CNAME record.
83
- */
84
- resolveOverride ?: string
85
- }
86
- }
87
-
88
- declare function addEventListener (
89
- type : 'fetch' ,
90
- handler : ( event : FetchEvent ) => void ,
91
- ) : void
92
-
93
- interface Request {
94
- /**
95
- * In addition to the properties on the standard Request object,
96
- * you can use a request.cf object to control how Cloudflare
97
- * features are applied as well as other custom information provided
98
- * by Cloudflare.
5
+ interface CfRequestInit {
6
+ /**
7
+ * In addition to the properties you can set in the RequestInit dict
8
+ * that you pass as an argument to the Request constructor, you can
9
+ * set certain properties of a `cf` object to control how Cloudflare
10
+ * features are applied to that new Request.
99
11
*
100
- * Note: Currently, settings in the cf object cannot be tested in the
12
+ * Note: Currently, these properties cannot be tested in the
101
13
* playground.
102
14
*/
103
- cf : {
15
+ cacheEverything ?: boolean
16
+ scrapeShield ?: boolean
17
+ apps ?: boolean
18
+ image ?: {
104
19
/**
105
- * (e.g. 395747)
20
+ * Maximum width in image pixels. The value must be an integer.
106
21
*/
107
- asn : string
108
- city : string
109
- clientTrustScore : number
22
+ width ?: number
110
23
/**
111
- * The three-letter airport code of the data center that the request
112
- * hit. (e.g. "DFW")
24
+ * Maximum height in image pixels.
113
25
*/
114
- colo : string
115
- continent : string
26
+ height ?: number
116
27
/**
117
- * The two-letter country code in the request. This is the same value
118
- * as that provided in the CF-IPCountry header. (e.g. "US")
28
+ * Resizing mode as a string. It affects interpretation of width and height
29
+ * options:
30
+ * - scale-down: Similar to contain, but the image is never enlarged. If
31
+ * the image is larger than given width or height, it will be resized.
32
+ * Otherwise its original size will be kept.
33
+ * - contain: Resizes to maximum size that fits within the given width and
34
+ * height. If only a single dimension is given (e.g. only width), the
35
+ * image will be shrunk or enlarged to exactly match that dimension.
36
+ * Aspect ratio is always preserved.
37
+ * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
38
+ * and height. If the image has an aspect ratio different from the ratio
39
+ * of width and height, it will be cropped to fit.
119
40
*/
120
- country : string
121
- httpProtocol : string
122
- latitude : number
123
- longitude : number
124
- postalCode : string
41
+ fit ?: 'scale-down' | 'contain' | 'cover'
125
42
/**
126
- * e.g. "Texas"
43
+ * When cropping with fit: "cover", this defines the side or point that should
44
+ * be left uncropped. The value is either a string
45
+ * "left", "right", "top", "bottom" or "center" (the default),
46
+ * or an object {x, y} containing focal point coordinates in the original
47
+ * image expressed as fractions ranging from 0.0 (top or left) to 1.0
48
+ * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
49
+ * crop bottom or left and right sides as necessary, but won’t crop anything
50
+ * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
51
+ * preserve as much as possible around a point at 20% of the height of the
52
+ * source image.
127
53
*/
128
- region : string
54
+ gravity ?: 'left' | 'right' | 'top' | 'bottom' | 'center' | { x : number ; y : number }
129
55
/**
130
- * e.g. "TX"
56
+ * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
57
+ * make images look worse, but load faster. The default is 85. It applies only
58
+ * to JPEG and WebP images. It doesn’t have any effect on PNG.
131
59
*/
132
- regionCode : string
60
+ quality ?: number
133
61
/**
134
- * e.g. "weight=256;exclusive=1"
62
+ * Output format to generate. It can be:
63
+ * - webp: generate images in Google WebP format. Set quality to 100 to get
64
+ * the WebP-lossles format.
65
+ * - json: instead of generating an image, outputs information about the
66
+ * image, in JSON format. The JSON object will contain image size
67
+ * (before and after resizing), source image’s MIME type, file size, etc.
135
68
*/
136
- requestPriority : string
137
- /**
138
- * e.g. "America/Chicago"
139
- */
140
- timezone : string
141
- tlsVersion : string
142
- tlsCipher : string
143
- tlsClientAuth : {
144
- certIssuerDNLegacy : string
145
- certIssuerDN : string
146
- certPresented : '0' | '1'
147
- certSubjectDNLegacy : string
148
- certSubjectDN : string
149
- certNotBefore : string // In format "Dec 22 19:39:00 2018 GMT"
150
- certNotAfter : string // In format "Dec 22 19:39:00 2018 GMT"
151
- certSerial : string
152
- certFingerprintSHA1 : string
153
- certVerified : string // “SUCCESS”, “FAILED:reason”, “NONE”
154
- }
69
+ format ?: 'webp' | 'json'
70
+ }
71
+ minify ?: {
72
+ javascript ?: boolean
73
+ css ?: boolean
74
+ html ?: boolean
75
+ }
76
+ mirage ?: boolean
77
+ /**
78
+ * Redirects the request to an alternate origin server. You can use this,
79
+ * for example, to implement load balancing across several origins.
80
+ * (e.g.us-east.example.com)
81
+ *
82
+ * Note - For security reasons, the hostname set in resolveOverride must
83
+ * be proxied on the same Cloudflare zone of the incoming request.
84
+ * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
85
+ * resolve to a host under a different domain or a DNS only domain first
86
+ * declare a CNAME record within your own zone’s DNS mapping to the
87
+ * external hostname, set proxy on Cloudflare, then set resolveOverride
88
+ * to point to that CNAME record.
89
+ */
90
+ resolveOverride ?: string
91
+ }
92
+
93
+ interface CfRequestProperties {
94
+ /**
95
+ * In addition to the properties on the standard Request object,
96
+ * the cf object contains extra information about the request provided
97
+ * by Cloudflare's edge.
98
+ *
99
+ * Note: Currently, settings in the cf object cannot be accessed in the
100
+ * playground.
101
+ */
102
+ /**
103
+ * (e.g. 395747)
104
+ */
105
+ asn : string
106
+ city : string
107
+ clientTrustScore : number
108
+ /**
109
+ * The three-letter airport code of the data center that the request
110
+ * hit. (e.g. "DFW")
111
+ */
112
+ colo : string
113
+ continent : string
114
+ /**
115
+ * The two-letter country code in the request. This is the same value
116
+ * as that provided in the CF-IPCountry header. (e.g. "US")
117
+ */
118
+ country : string
119
+ httpProtocol : string
120
+ latitude : number
121
+ longitude : number
122
+ postalCode : string
123
+ /**
124
+ * e.g. "Texas"
125
+ */
126
+ region : string
127
+ /**
128
+ * e.g. "TX"
129
+ */
130
+ regionCode : string
131
+ /**
132
+ * e.g. "weight=256;exclusive=1"
133
+ */
134
+ requestPriority : string
135
+ /**
136
+ * e.g. "America/Chicago"
137
+ */
138
+ timezone : string
139
+ tlsVersion : string
140
+ tlsCipher : string
141
+ tlsClientAuth : {
142
+ certIssuerDNLegacy : string
143
+ certIssuerDN : string
144
+ certPresented : '0' | '1'
145
+ certSubjectDNLegacy : string
146
+ certSubjectDN : string
147
+ certNotBefore : string // In format "Dec 22 19:39:00 2018 GMT"
148
+ certNotAfter : string // In format "Dec 22 19:39:00 2018 GMT"
149
+ certSerial : string
150
+ certFingerprintSHA1 : string
151
+ certVerified : string // “SUCCESS”, “FAILED:reason”, “NONE”
155
152
}
156
153
}
157
154
155
+ interface RequestInit {
156
+ cf ?: CfRequestInit | CfRequestProperties
157
+ }
158
+
159
+ declare function addEventListener (
160
+ type : 'fetch' ,
161
+ handler : ( event : FetchEvent ) => void ,
162
+ ) : void
163
+
164
+ interface Request {
165
+ cf : CfRequestProperties
166
+ }
167
+
158
168
interface ContentOptions {
159
169
/**
160
170
* Controls the way the HTMLRewriter treats inserted content.
@@ -353,6 +363,10 @@ declare class HTMLRewriter {
353
363
public transform ( response : Response ) : Response
354
364
}
355
365
366
+ declare interface CacheStorage {
367
+ default : Cache
368
+ }
369
+
356
370
type KVValue < Value > = Promise < Value | null >
357
371
358
372
declare module '@cloudflare/workers-types' {
0 commit comments