UNPKG

4.6 kBPlain TextView Raw
1import { CloudBaseError } from './error'
2
3export type CustomEvent = 'logout'
4
5export interface ICommandContext {
6 cmd: string
7 envId: string
8 config: ICloudBaseConfig
9 options: any
10 params: string[]
11}
12
13/* eslint-disable */
14declare 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/* eslint-enable */
25
26export type TExportFunctionVoid = () => Promise<void | CloudBaseError>
27
28export interface PermanentCredential {
29 secretId?: string
30 secretKey?: string
31}
32
33export 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
45export type Credential = TmpCredential & PermanentCredential
46
47export interface AuthSecret {
48 secretId: string
49 secretKey: string
50 token?: string
51}
52
53export interface IConfig {
54 credential?: Credential
55}
56
57export interface ICloudBaseConfig {
58 envId: string
59 functionRoot?: string
60 functions?: ICloudFunction[]
61 servers?: ServerConfig[]
62}
63
64export interface IGetCredential {
65 secretId?: string
66 secretKey?: string
67 token: string
68}
69
70export enum ServerLanguageType {
71 node = 'node'
72}
73
74export interface ServerConfig {
75 type: ServerLanguageType.node
76 name: string
77 path: string
78}
79
80/**
81 * 函数
82 */
83export interface IFunctionPackResult {
84 success: boolean
85 assets: string[]
86 vemo?: boolean
87}
88
89export interface IFunctionVPC {
90 subnetId: string
91 vpcId: string
92}
93
94export 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
103export interface ICloudFunctionTrigger {
104 name: string
105 type: string
106 config: string
107}
108
109export 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
125export 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
139export interface IListFunctionOptions {
140 limit?: number
141 offset?: number
142 envId: string
143}
144
145export 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
157export interface IUpdateFunctionConfigOptions {
158 functionName: string
159 config: ICloudFunctionConfig
160 envId: string
161}
162
163export interface InvokeFunctionOptions {
164 functionName: string
165 params?: Record<string, any>
166 envId: string
167}
168
169export interface IFunctionBatchOptions {
170 functions: ICloudFunction[]
171 envId: string
172 log?: boolean
173}
174
175export interface IFunctionTriggerOptions {
176 functionName: string
177 triggers?: ICloudFunctionTrigger[]
178 triggerName?: string
179 envId: string
180}
181
182export interface ILoginOptions {
183 key?: boolean
184 secretId?: string
185 secretKey?: string
186 token?: string
187 // 修改浏览器登录打开的链接
188 getAuthUrl?: (url: string) => string
189}
190
191export interface GatewayContext {
192 // 环境 id
193 envId: string
194 // 整体配置
195 config: ICloudBaseConfig
196}
197
198export interface ICreateFunctionGatewayOptions {
199 envId: string
200 path: string
201 name: string
202}
203
204export interface IQueryGatewayOptions {
205 envId: string
206 domain?: string
207 path?: string
208 gatewayId?: string
209 name?: string
210}
211
212export interface IDeleteGatewayOptions {
213 envId: string
214 path?: string
215 gatewayId?: string
216 name?: string
217}
218
219export interface IBindGatewayDomainOptions {
220 envId: string
221 domain: string
222}
223
224export interface IQueryGatewayDomainOptions {
225 envId: string
226 domain?: string
227}
228
229export interface IUnbindGatewayDomainOptions {
230 envId: string
231 domain: string
232}