@@ -9,8 +9,12 @@ import { Duplex, Transform, Writable } from "stream";
9
9
import { ReadableStream } from "stream/web" ;
10
10
import zlib from "zlib" ;
11
11
import type {
12
+ CacheStorage ,
12
13
D1Database ,
14
+ DurableObjectNamespace ,
15
+ KVNamespace ,
13
16
Queue ,
17
+ R2Bucket ,
14
18
RequestInitCfProperties ,
15
19
} from "@cloudflare/workers-types/experimental" ;
16
20
import exitHook from "exit-hook" ;
@@ -30,16 +34,13 @@ import {
30
34
registerAllowUnauthorizedDispatcher ,
31
35
} from "./http" ;
32
36
import {
33
- CacheStorage ,
34
37
D1_PLUGIN_NAME ,
35
38
DURABLE_OBJECTS_PLUGIN_NAME ,
36
39
DispatchFetch ,
37
40
DurableObjectClassNames ,
38
- DurableObjectNamespace ,
39
41
GatewayConstructor ,
40
42
GatewayFactory ,
41
43
HEADER_CF_BLOB ,
42
- KVNamespace ,
43
44
KV_PLUGIN_NAME ,
44
45
PLUGIN_ENTRIES ,
45
46
Persistence ,
@@ -49,8 +50,8 @@ import {
49
50
QUEUES_PLUGIN_NAME ,
50
51
QueueConsumers ,
51
52
QueuesError ,
52
- R2Bucket ,
53
53
R2_PLUGIN_NAME ,
54
+ ReplaceWorkersTypes ,
54
55
SharedOptions ,
55
56
SourceMapRegistry ,
56
57
WorkerOptions ,
@@ -1207,23 +1208,24 @@ export class Miniflare {
1207
1208
return proxy as T ;
1208
1209
}
1209
1210
// TODO(someday): would be nice to define these in plugins
1210
- async getCaches ( ) : Promise < CacheStorage > {
1211
+ async getCaches ( ) : Promise < ReplaceWorkersTypes < CacheStorage > > {
1211
1212
const proxyClient = await this . _getProxyClient ( ) ;
1212
- return proxyClient . global . caches as unknown as CacheStorage ;
1213
+ return proxyClient . global
1214
+ . caches as unknown as ReplaceWorkersTypes < CacheStorage > ;
1213
1215
}
1214
1216
getD1Database ( bindingName : string , workerName ?: string ) : Promise < D1Database > {
1215
1217
return this . #getProxy( D1_PLUGIN_NAME , bindingName , workerName ) ;
1216
1218
}
1217
1219
getDurableObjectNamespace (
1218
1220
bindingName : string ,
1219
1221
workerName ?: string
1220
- ) : Promise < DurableObjectNamespace > {
1222
+ ) : Promise < ReplaceWorkersTypes < DurableObjectNamespace > > {
1221
1223
return this . #getProxy( DURABLE_OBJECTS_PLUGIN_NAME , bindingName , workerName ) ;
1222
1224
}
1223
1225
getKVNamespace (
1224
1226
bindingName : string ,
1225
1227
workerName ?: string
1226
- ) : Promise < KVNamespace > {
1228
+ ) : Promise < ReplaceWorkersTypes < KVNamespace > > {
1227
1229
return this . #getProxy( KV_PLUGIN_NAME , bindingName , workerName ) ;
1228
1230
}
1229
1231
getQueueProducer < Body = unknown > (
@@ -1232,7 +1234,10 @@ export class Miniflare {
1232
1234
) : Promise < Queue < Body > > {
1233
1235
return this . #getProxy( QUEUES_PLUGIN_NAME , bindingName , workerName ) ;
1234
1236
}
1235
- getR2Bucket ( bindingName : string , workerName ?: string ) : Promise < R2Bucket > {
1237
+ getR2Bucket (
1238
+ bindingName : string ,
1239
+ workerName ?: string
1240
+ ) : Promise < ReplaceWorkersTypes < R2Bucket > > {
1236
1241
return this . #getProxy( R2_PLUGIN_NAME , bindingName , workerName ) ;
1237
1242
}
1238
1243
0 commit comments