-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathtyping.ts
81 lines (63 loc) · 1.94 KB
/
typing.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
import { Readable } from 'node:stream';
import { IncomingHttpHeaders } from 'node:http';
import { EggContext } from '@eggjs/tegg';
import { estypes } from '@elastic/elasticsearch';
import { CnpmcoreConfig } from '../port/config.js';
export interface UploadResult {
key: string;
}
export interface AppendResult {
key: string;
nextAppendPosition?: number;
}
export interface UploadOptions {
key: string;
}
export interface AppendOptions {
key: string;
position?: string,
headers?: IncomingHttpHeaders,
}
export interface DownloadOptions {
timeout: number;
}
export interface NFSClient {
uploadBytes(bytes: Uint8Array, options: UploadOptions): Promise<UploadResult>;
appendBytes(bytes: Uint8Array, options: AppendOptions): Promise<AppendResult>;
upload(filePath: string, options: UploadOptions): Promise<UploadResult>;
remove(key: string): Promise<void>;
readBytes(key: string): Promise<Uint8Array | undefined>;
createDownloadStream(key: string): Promise<Readable | undefined>;
download(key: string, filepath: string, options: DownloadOptions): Promise<void>;
url?(key: string): string;
}
export interface QueueAdapter {
push<T>(key: string, item: T): Promise<boolean>;
pop<T>(key: string): Promise<T | null>;
length(key: string): Promise<number>;
}
export interface SearchAdapter {
search<T>(query: any): Promise<estypes.SearchHitsMetadata<T>>;
upsert<T>(id: string, document: T): Promise<string>;
delete(id: string): Promise<string>;
}
export interface AuthUrlResult {
loginUrl: string;
doneUrl: string;
}
export interface userResult {
name: string;
email: string;
}
export interface AuthClient {
getAuthUrl(ctx: EggContext): Promise<AuthUrlResult>;
ensureCurrentUser(): Promise<userResult | null>;
}
declare module 'egg' {
// eslint-disable-next-line
// @ts-ignore
// avoid TS2310 Type 'EggAppConfig' recursively references itself as a base type.
interface EggAppConfig {
cnpmcore: CnpmcoreConfig;
}
}