@@ -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
WorkerOptions ,
56
57
getGlobalServices ,
@@ -1197,23 +1198,24 @@ export class Miniflare {
1197
1198
return proxy as T ;
1198
1199
}
1199
1200
// TODO(someday): would be nice to define these in plugins
1200
- async getCaches ( ) : Promise < CacheStorage > {
1201
+ async getCaches ( ) : Promise < ReplaceWorkersTypes < CacheStorage > > {
1201
1202
const proxyClient = await this . _getProxyClient ( ) ;
1202
- return proxyClient . global . caches as unknown as CacheStorage ;
1203
+ return proxyClient . global
1204
+ . caches as unknown as ReplaceWorkersTypes < CacheStorage > ;
1203
1205
}
1204
1206
getD1Database ( bindingName : string , workerName ?: string ) : Promise < D1Database > {
1205
1207
return this . #getProxy( D1_PLUGIN_NAME , bindingName , workerName ) ;
1206
1208
}
1207
1209
getDurableObjectNamespace (
1208
1210
bindingName : string ,
1209
1211
workerName ?: string
1210
- ) : Promise < DurableObjectNamespace > {
1212
+ ) : Promise < ReplaceWorkersTypes < DurableObjectNamespace > > {
1211
1213
return this . #getProxy( DURABLE_OBJECTS_PLUGIN_NAME , bindingName , workerName ) ;
1212
1214
}
1213
1215
getKVNamespace (
1214
1216
bindingName : string ,
1215
1217
workerName ?: string
1216
- ) : Promise < KVNamespace > {
1218
+ ) : Promise < ReplaceWorkersTypes < KVNamespace > > {
1217
1219
return this . #getProxy( KV_PLUGIN_NAME , bindingName , workerName ) ;
1218
1220
}
1219
1221
getQueueProducer < Body = unknown > (
@@ -1222,7 +1224,10 @@ export class Miniflare {
1222
1224
) : Promise < Queue < Body > > {
1223
1225
return this . #getProxy( QUEUES_PLUGIN_NAME , bindingName , workerName ) ;
1224
1226
}
1225
- getR2Bucket ( bindingName : string , workerName ?: string ) : Promise < R2Bucket > {
1227
+ getR2Bucket (
1228
+ bindingName : string ,
1229
+ workerName ?: string
1230
+ ) : Promise < ReplaceWorkersTypes < R2Bucket > > {
1226
1231
return this . #getProxy( R2_PLUGIN_NAME , bindingName , workerName ) ;
1227
1232
}
1228
1233
0 commit comments