1 | import './commands'
|
2 | import { login, logout } from './auth'
|
3 | import {
|
4 | listEnvs,
|
5 | createEnv,
|
6 | getEnvAuthDomains,
|
7 | createEnvDomain,
|
8 | deleteEnvDomain,
|
9 | getLoginConfigList,
|
10 | createLoginConfig,
|
11 | updateLoginConfig
|
12 | } from './env'
|
13 | import { deleteThirdPartAttach } from './third'
|
14 | import {
|
15 | createFunction,
|
16 | listFunction,
|
17 | deleteFunction,
|
18 | getFunctionDetail,
|
19 | getFunctionLog,
|
20 | updateFunctionConfig,
|
21 | createFunctionTriggers,
|
22 | deleteFunctionTrigger,
|
23 | invokeFunction,
|
24 | downloadFunctionCode,
|
25 | copyFunction,
|
26 | updateFunctionCode
|
27 | } from './function'
|
28 | import * as storage from './storage'
|
29 | import { getSyncDB } from './utils'
|
30 | import { ILoginOptions } from './types'
|
31 |
|
32 | export = class CloudBase {
|
33 | login: (
|
34 | options: ILoginOptions
|
35 | ) => Promise<{ code: string; msg: string }> = login
|
36 |
|
37 | logout = logout
|
38 |
|
39 | env = {
|
40 | list: listEnvs,
|
41 | create: createEnv,
|
42 | domain: {
|
43 | list: getEnvAuthDomains,
|
44 | create: createEnvDomain,
|
45 | delete: deleteEnvDomain
|
46 | },
|
47 | login: {
|
48 | list: getLoginConfigList,
|
49 | create: createLoginConfig,
|
50 | update: updateLoginConfig
|
51 | }
|
52 | }
|
53 |
|
54 | third = {
|
55 | deleteThirdPartAttach
|
56 | }
|
57 |
|
58 | functions = {
|
59 | invoke: invokeFunction,
|
60 | deploy: createFunction,
|
61 | list: listFunction,
|
62 | delete: deleteFunction,
|
63 | detail: getFunctionDetail,
|
64 | log: getFunctionLog,
|
65 | code: {
|
66 | update: updateFunctionCode
|
67 | },
|
68 | config: {
|
69 | update: updateFunctionConfig
|
70 | },
|
71 | trigger: {
|
72 | create: createFunctionTriggers,
|
73 | delete: deleteFunctionTrigger
|
74 | },
|
75 | download: downloadFunctionCode,
|
76 | copy: copyFunction
|
77 | }
|
78 |
|
79 | storage = storage
|
80 |
|
81 | constructor(secretId, secretKey) {
|
82 | if (secretId && secretKey) {
|
83 | const credential = {
|
84 | secretId,
|
85 | secretKey
|
86 | }
|
87 | getSyncDB('auth').set('credential', credential).write()
|
88 | }
|
89 | }
|
90 | }
|