UNPKG

1.74 kBTypeScriptView Raw
1export declare namespace nam {
2 const socketRpcEventNamePrefix = "socket-rpc.device";
3 interface AppletImage {
4 naType: string;
5 naVersion: string;
6 packageName: string;
7 version: string;
8 }
9 interface AppletRunOptions extends AppletImage {
10 appletId: string;
11 appletToken: string;
12 }
13 interface AppletStatus extends AppletImage {
14 appletId: string;
15 ip: string;
16 port: number;
17 status: string;
18 }
19 interface RouteOptions extends AppletImage {
20 appletId: string;
21 }
22 interface Route {
23 route: string;
24 target: string;
25 }
26 interface RequestOptions extends RouteOptions {
27 uri: string;
28 method: string;
29 body?: object;
30 headers?: {
31 [key: string]: string;
32 };
33 resolveWithFullResponse?: boolean;
34 }
35 interface WorkOptions {
36 route: RouteOptions;
37 worker: Worker;
38 payload: object;
39 }
40 interface RequestResponse {
41 statusCode: number;
42 headers?: {
43 [key: string]: string;
44 };
45 body: object;
46 }
47 interface Worker {
48 handler: string;
49 name: string;
50 }
51 interface AccountOperateOptions {
52 accountId: string;
53 appletId: string;
54 body: string;
55 }
56 interface INAM {
57 install(options: AppletImage): Promise<void>;
58 images(): Promise<AppletImage[]>;
59 run(options: AppletRunOptions): Promise<void>;
60 ps(): Promise<AppletStatus[]>;
61 kill(options: AppletImage): Promise<void>;
62 work(options: WorkOptions): Promise<any>;
63 request<T>(options: RequestOptions): Promise<RequestResponse | T>;
64 }
65}