This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
/
kv.d.ts
99 lines (89 loc) · 2.94 KB
/
kv.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
interface KVNamespaceGetOptions<Type> {
type: Type;
cacheTtl?: number;
}
interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
value: Value | null;
metadata: Metadata | null;
}
interface KVNamespaceListKey<Metadata> {
name: string;
expiration?: number;
metadata?: Metadata;
}
interface KVNamespaceListResult<Metadata> {
keys: KVNamespaceListKey<Metadata>[];
list_complete: boolean;
cursor?: string;
}
declare class KVNamespace<K extends string = string> {
get(
key: K,
options?: Partial<KVNamespaceGetOptions<undefined>>
): Promise<string | null>;
get(key: K, type: "text"): Promise<string | null>;
get<ExpectedValue = unknown>(
key: K,
type: "json"
): Promise<ExpectedValue | null>;
get(key: K, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
get(key: K, type: "stream"): Promise<ReadableStream | null>;
get(key: K, options: KVNamespaceGetOptions<"text">): Promise<string | null>;
get<ExpectedValue = unknown>(
key: string,
options: KVNamespaceGetOptions<"json">
): Promise<ExpectedValue | null>;
get(
key: K,
options: KVNamespaceGetOptions<"arrayBuffer">
): Promise<ArrayBuffer | null>;
get(
key: K,
options: KVNamespaceGetOptions<"stream">
): Promise<ReadableStream | null>;
getWithMetadata<Metadata = unknown>(
key: K,
options?: Partial<KVNamespaceGetOptions<undefined>>
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: K,
type: "text"
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: K,
type: "json"
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: K,
type: "arrayBuffer"
): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: K,
type: "stream"
): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: K,
options: KVNamespaceGetOptions<"text">
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: K,
options: KVNamespaceGetOptions<"json">
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: K,
options: KVNamespaceGetOptions<"arrayBuffer">
): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: K,
options: KVNamespaceGetOptions<"stream">
): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
put(
key: K,
value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
options?: KVNamespacePutOptions
): Promise<void>;
list<Metadata = unknown>(
options?: KVNamespaceListOptions
): Promise<KVNamespaceListResult<Metadata>>;
}
export {};