Skip to content

Commit 4ce6949

Browse files
补充提示
1 parent 2471cbd commit 4ce6949

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

global-types/globals.d.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ declare global {
88
TypeBinaryMessage: number;
99

1010
readText(): Promise<string>;
11+
1112
read(): Promise<{
1213
type: number;
1314
data: Uint8Array;
1415
}>;
1516

1617
writeText(data: string): Promise<void>;
18+
1719
write(mType: number, data: string | Uint8Array): Promise<void>;
1820
}
1921

@@ -22,6 +24,7 @@ declare global {
2224
// Event 相关类型
2325
interface EventSystem {
2426
load(key: string): Promise<any>;
27+
2528
put(key: string, value: string): Promise<void>;
2629
}
2730

@@ -43,13 +46,21 @@ declare global {
4346
headers: Record<string, string>;
4447

4548
get(key: string): string | null;
49+
4650
getQuery(key: string): string;
51+
4752
getHeader(name: string): string;
53+
4854
getHeaderNames(): string[];
55+
4956
getHeaders(): Record<string, string>;
57+
5058
getRawHeaderNames(): string[];
59+
5160
hasHeader(name: string): boolean;
61+
5262
readBody(): Uint8Array;
63+
5364
protocol: string;
5465
}
5566

@@ -68,15 +79,21 @@ declare global {
6879

6980
interface ResponseObject {
7081
setHeader(key: string, value: string): void;
82+
7183
getHeader(key: string): string;
84+
7285
removeHeader(key: string): void;
86+
7387
hasHeader(key: string): boolean;
7488

7589
setStatus(statusCode: number): void;
90+
7691
statusCode(statusCode: number): void;
7792

7893
write(data: string): void;
94+
7995
writeHead(statusCode: number, headers?: Record<string, string>): void;
96+
8097
end(data?: string): void;
8198

8299
redirect(location: string, statusCode?: number): void;
@@ -97,15 +114,21 @@ declare global {
97114

98115
interface KVOps {
99116
get(key: string): string | null;
100-
set(key: string, value: string): void;
117+
118+
set(key: string, value: string, ttl?: number): void;
119+
101120
delete(key: string): boolean;
102-
putIfNotExists(key: string, value: string): boolean;
121+
122+
putIfNotExists(key: string, value: string, ttl?: number): boolean;
123+
103124
compareAndSwap(key: string, oldValue: string, newValue: string): boolean;
125+
104126
list(limit?: number, cursor?: string): KVListResult;
105127
}
106128

107129
interface KVSystem {
108130
repo(...group: string[]): KVOps;
131+
109132
org(...group: string[]): KVOps;
110133
}
111134

@@ -114,9 +137,13 @@ declare global {
114137
// Console 相关 (假设通过 require 引入)
115138
interface Console {
116139
log(...args: any[]): void;
140+
117141
warn(...args: any[]): void;
142+
118143
error(...args: any[]): void;
144+
119145
info(...args: any[]): void;
146+
120147
debug(...args: any[]): void;
121148
}
122149

0 commit comments

Comments
 (0)