1 | import { CloudBaseError } from './error'
|
2 |
|
3 | export type CustomEvent = 'logout'
|
4 |
|
5 | export interface ICommandContext {
|
6 | cmd: string
|
7 | envId: string
|
8 | config: ICloudBaseConfig
|
9 | options: any
|
10 | params: string[]
|
11 | }
|
12 |
|
13 |
|
14 | declare global {
|
15 | namespace NodeJS {
|
16 | interface Process extends EventEmitter {
|
17 | VERBOSE: boolean
|
18 | CLI_VERSION: string
|
19 | on(event: CustomEvent, listener: BeforeExitListener)
|
20 | emit(event: CustomEvent, message?: any)
|
21 | }
|
22 | }
|
23 | }
|
24 |
|
25 |
|
26 | export type TExportFunctionVoid = () => Promise<void | CloudBaseError>
|
27 |
|
28 | export interface PermanentCredential {
|
29 | secretId?: string
|
30 | secretKey?: string
|
31 | }
|
32 |
|
33 | export interface TmpCredential {
|
34 | tmpSecretId?: string
|
35 | tmpSecretKey?: string
|
36 | tmpToken?: string
|
37 | tmpExpired?: string
|
38 | expired?: string
|
39 | authTime?: string
|
40 | refreshToken?: string
|
41 | uin?: string
|
42 | hash?: string
|
43 | }
|
44 |
|
45 | export type Credential = TmpCredential & PermanentCredential
|
46 |
|
47 | export interface AuthSecret {
|
48 | secretId: string
|
49 | secretKey: string
|
50 | token?: string
|
51 | }
|
52 |
|
53 | export interface IConfig {
|
54 | credential?: Credential
|
55 | }
|
56 |
|
57 | export interface ICloudBaseConfig {
|
58 | envId: string
|
59 | functionRoot?: string
|
60 | functions?: ICloudFunction[]
|
61 | servers?: ServerConfig[]
|
62 | }
|
63 |
|
64 | export interface IGetCredential {
|
65 | secretId?: string
|
66 | secretKey?: string
|
67 | token: string
|
68 | }
|
69 |
|
70 | export enum ServerLanguageType {
|
71 | node = 'node'
|
72 | }
|
73 |
|
74 | export interface ServerConfig {
|
75 | type: ServerLanguageType.node
|
76 | name: string
|
77 | path: string
|
78 | }
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | export interface IFunctionPackResult {
|
84 | success: boolean
|
85 | assets: string[]
|
86 | vemo?: boolean
|
87 | }
|
88 |
|
89 | export interface IFunctionVPC {
|
90 | subnetId: string
|
91 | vpcId: string
|
92 | }
|
93 |
|
94 | export interface ICloudFunctionConfig {
|
95 | timeout?: number
|
96 | envVariables?: Record<string, string | number | boolean>
|
97 | runtime?: string
|
98 | vpc?: IFunctionVPC
|
99 | installDependency?: boolean
|
100 | l5?: boolean
|
101 | }
|
102 |
|
103 | export interface ICloudFunctionTrigger {
|
104 | name: string
|
105 | type: string
|
106 | config: string
|
107 | }
|
108 |
|
109 | export interface ICloudFunction {
|
110 | name: string
|
111 | config?: ICloudFunctionConfig
|
112 | triggers?: ICloudFunctionTrigger[]
|
113 | params?: Record<string, string>
|
114 | handler?: string
|
115 | ignore?: string | string[]
|
116 | timeout?: number
|
117 | envVariables?: Record<string, string | number | boolean>
|
118 | runtime?: string
|
119 | vpc?: IFunctionVPC
|
120 | l5?: boolean
|
121 | installDependency?: boolean
|
122 | isWaitInstall?: boolean
|
123 | }
|
124 |
|
125 | export interface ICreateFunctionOptions {
|
126 |
|
127 | func?: ICloudFunction
|
128 | functions?: ICloudFunction[]
|
129 | functionRootPath?: string
|
130 | envId: string
|
131 | force?: boolean
|
132 | base64Code?: string
|
133 | log?: boolean
|
134 | codeSecret?: string
|
135 | functionPath?: string
|
136 | accessPath?: string
|
137 | }
|
138 |
|
139 | export interface IListFunctionOptions {
|
140 | limit?: number
|
141 | offset?: number
|
142 | envId: string
|
143 | }
|
144 |
|
145 | export interface IFunctionLogOptions {
|
146 | functionName: string
|
147 | envId: string
|
148 | offset?: number
|
149 | limit?: number
|
150 | order?: string
|
151 | orderBy?: string
|
152 | startTime?: string
|
153 | endTime?: string
|
154 | functionRequestI?: string
|
155 | }
|
156 |
|
157 | export interface IUpdateFunctionConfigOptions {
|
158 | functionName: string
|
159 | config: ICloudFunctionConfig
|
160 | envId: string
|
161 | }
|
162 |
|
163 | export interface InvokeFunctionOptions {
|
164 | functionName: string
|
165 | params?: Record<string, any>
|
166 | envId: string
|
167 | }
|
168 |
|
169 | export interface IFunctionBatchOptions {
|
170 | functions: ICloudFunction[]
|
171 | envId: string
|
172 | log?: boolean
|
173 | }
|
174 |
|
175 | export interface IFunctionTriggerOptions {
|
176 | functionName: string
|
177 | triggers?: ICloudFunctionTrigger[]
|
178 | triggerName?: string
|
179 | envId: string
|
180 | }
|
181 |
|
182 | export interface ILoginOptions {
|
183 | key?: boolean
|
184 | secretId?: string
|
185 | secretKey?: string
|
186 | token?: string
|
187 | // 修改浏览器登录打开的链接
|
188 | getAuthUrl?: (url: string) => string
|
189 | }
|
190 |
|
191 | export interface GatewayContext {
|
192 | // 环境 id
|
193 | envId: string
|
194 | // 整体配置
|
195 | config: ICloudBaseConfig
|
196 | }
|
197 |
|
198 | export interface ICreateFunctionGatewayOptions {
|
199 | envId: string
|
200 | path: string
|
201 | name: string
|
202 | }
|
203 |
|
204 | export interface IQueryGatewayOptions {
|
205 | envId: string
|
206 | domain?: string
|
207 | path?: string
|
208 | gatewayId?: string
|
209 | name?: string
|
210 | }
|
211 |
|
212 | export interface IDeleteGatewayOptions {
|
213 | envId: string
|
214 | path?: string
|
215 | gatewayId?: string
|
216 | name?: string
|
217 | }
|
218 |
|
219 | export interface IBindGatewayDomainOptions {
|
220 | envId: string
|
221 | domain: string
|
222 | }
|
223 |
|
224 | export interface IQueryGatewayDomainOptions {
|
225 | envId: string
|
226 | domain?: string
|
227 | }
|
228 |
|
229 | export interface IUnbindGatewayDomainOptions {
|
230 | envId: string
|
231 | domain: string
|
232 | }
|