forked from cloudflare/workers-types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdurableobjects.d.ts
84 lines (69 loc) · 2 KB
/
durableobjects.d.ts
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
interface DurableObject {
fetch(request: Request): Promise<Response>;
alarm?(): Promise<void>;
}
declare abstract class DurableObjectStub extends Fetcher {
readonly id: DurableObjectId;
readonly name?: string;
}
declare abstract class DurableObjectNamespace {
get(id: DurableObjectId): DurableObjectStub;
}
declare abstract class DurableObjectState {
readonly storage: DurableObjectStorage;
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
}
declare abstract class 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>;
transaction<T>(
closure: (txn: DurableObjectTransaction) => Promise<T>
): Promise<T>;
}
declare abstract class 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>;
deleteAll: never;
rollback(): void;
}
export {};