UNPKG

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