-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtypes.d.ts
110 lines (95 loc) · 2.47 KB
/
types.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
100
101
102
103
104
105
106
107
108
109
110
declare module "@sagi.io/workers-kv" {
interface WorkersKVRESTOptions {
cfAccountId: string;
cfEmail?: string;
cfAuthKey?: string;
cfAuthToken?: string;
namespaceId?: string;
}
interface ListKeysOptions {
namespaceId?: string;
limit?: number;
cursor?: string;
prefix?: string;
}
interface ListAllKeysOptions {
namespaceId?: string;
prefix?: string;
limit?: number;
}
interface ListNamespacesOptions {
page?: number;
per_page?: number;
}
interface ReadKeyOptions {
key: string;
namespaceId?: string;
}
interface DeleteKeyOptions {
key: string;
namespaceId?: string;
}
interface WriteKeyOptions {
key: string;
value: string;
namespaceId?: string;
expiration?: number;
expiration_ttl?: number;
}
interface WriteMultipleKeysOptions {
keyValueMap: Record<string, string>;
namespaceId?: string;
expiration?: number;
expiration_ttl?: number;
base64?: boolean;
}
interface DeleteMultipleKeysOptions {
keys: string[];
namespaceId?: string;
}
interface Response {
result: null;
success: boolean;
errors: {
code: number;
message: string;
}[];
messages: {
code: number;
message: string;
}[];
}
interface ReadResponse extends Omit<Response, "result"> {
result: string;
}
interface ListResponse extends Omit<Response, "result"> {
result: { expiration?: number; metadata?: object; key: string }[];
result_info: {
count: number;
cursor: string;
};
}
interface ListNamespacesResponse extends Omit<Response, "result"> {
result: { id: string; supports_url_encoding?: boolean; title: string }[];
result_info: {
count: number;
page: number;
per_page: number;
total_count: number;
};
}
class WorkersKVREST {
constructor(options: WorkersKVRESTOptions);
listKeys(options: ListKeysOptions): Promise<ListResponse>;
listAllKeys(options: ListAllKeysOptions): Promise<ListResponse>;
listNamespaces(
options: ListNamespacesOptions,
): Promise<ListNamespacesResponse>;
readKey(options: ReadKeyOptions): Promise<ReadResponse>;
deleteKey(options: DeleteKeyOptions): Promise<Response>;
writeKey(options: WriteKeyOptions): Promise<Response>;
writeMultipleKeys(options: WriteMultipleKeysOptions): Promise<Response>;
deleteMultipleKeys(options: DeleteMultipleKeysOptions): Promise<Response>;
}
export = WorkersKVREST;
}