@cloudbase/manager-node 4.2.3 → 4.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/constant.js +5 -1
  3. package/lib/env/index.js +10 -209
  4. package/lib/function/index.js +0 -3
  5. package/lib/storage/index.js +24 -10
  6. package/lib/utils/cloud-api-request.js +7 -0
  7. package/lib/utils/http-request.js +3 -3
  8. package/lib/utils/runenv.js +8 -0
  9. package/package.json +4 -3
  10. package/types/constant.d.ts +7 -0
  11. package/types/env/index.d.ts +0 -17
  12. package/types/function/types.d.ts +0 -2
  13. package/types/utils/runenv.d.ts +1 -0
  14. package/src/access/index.ts +0 -168
  15. package/src/access/types.ts +0 -55
  16. package/src/billing/index.ts +0 -43
  17. package/src/cam/index.ts +0 -106
  18. package/src/cloudBaseRun/index.ts +0 -40
  19. package/src/cloudBaseRun/types.ts +0 -24
  20. package/src/common/index.ts +0 -54
  21. package/src/constant.ts +0 -56
  22. package/src/context.ts +0 -18
  23. package/src/database/index.ts +0 -369
  24. package/src/debug.ts +0 -34
  25. package/src/env/index.ts +0 -614
  26. package/src/environment.ts +0 -156
  27. package/src/environmentManager.ts +0 -50
  28. package/src/error.ts +0 -27
  29. package/src/function/index.ts +0 -1378
  30. package/src/function/packer.ts +0 -164
  31. package/src/function/types.ts +0 -165
  32. package/src/hosting/index.ts +0 -698
  33. package/src/index.ts +0 -127
  34. package/src/interfaces/base.interface.ts +0 -8
  35. package/src/interfaces/billing.interface.ts +0 -21
  36. package/src/interfaces/cam.interface.ts +0 -28
  37. package/src/interfaces/flexdb.interface.ts +0 -104
  38. package/src/interfaces/function.interface.ts +0 -75
  39. package/src/interfaces/index.ts +0 -7
  40. package/src/interfaces/storage.interface.ts +0 -29
  41. package/src/interfaces/tcb.interface.ts +0 -642
  42. package/src/storage/index.ts +0 -1290
  43. package/src/third/index.ts +0 -24
  44. package/src/user/index.ts +0 -174
  45. package/src/user/types.ts +0 -21
  46. package/src/utils/auth.ts +0 -112
  47. package/src/utils/cloud-api-request.ts +0 -252
  48. package/src/utils/cloudbase-request.ts +0 -109
  49. package/src/utils/envLazy.ts +0 -15
  50. package/src/utils/fs.ts +0 -57
  51. package/src/utils/http-request.ts +0 -37
  52. package/src/utils/index.ts +0 -103
  53. package/src/utils/parallel.ts +0 -82
  54. package/src/utils/uuid.ts +0 -14
@@ -1,156 +0,0 @@
1
- import { DatabaseService } from './database'
2
- import { FunctionService } from './function'
3
- import { StorageService } from './storage'
4
-
5
- import { EnvService } from './env'
6
- import { CommonService } from './common'
7
-
8
- import { CloudBaseContext } from './context'
9
- import { CloudBaseError } from './error'
10
- import { RUN_ENV, ENV_NAME, ERROR } from './constant'
11
- import { getRuntime, getEnvVar } from './utils'
12
- import { HostingService } from './hosting'
13
- import { ThirdService } from './third'
14
- import { AccessService } from './access'
15
- import { UserService } from './user'
16
- import { CloudBaseRunService } from './cloudBaseRun'
17
- import { EnvInfo } from './interfaces'
18
-
19
- export class Environment {
20
- public inited = false
21
- public cloudBaseContext: CloudBaseContext
22
- public lazyEnvironmentConfig: EnvInfo
23
- private envId: string
24
- private envType?: string
25
-
26
- private functionService: FunctionService
27
- private databaseService: DatabaseService
28
- private storageService: StorageService
29
- private envService: EnvService
30
- private hostingService: HostingService
31
- private thirdService: ThirdService
32
- private accessService: AccessService
33
- private userService: UserService
34
- private cloudBaseRunService: CloudBaseRunService
35
-
36
- constructor(context: CloudBaseContext, envId: string) {
37
- this.envId = envId
38
- this.cloudBaseContext = context
39
- this.envType = context.envType
40
-
41
- // 拉取当前环境 的环境信息 todo
42
- this.functionService = new FunctionService(this)
43
- this.databaseService = new DatabaseService(this)
44
- this.storageService = new StorageService(this)
45
- this.envService = new EnvService(this)
46
- this.hostingService = new HostingService(this)
47
- this.thirdService = new ThirdService(this)
48
- this.accessService = new AccessService(this)
49
- this.userService = new UserService(this)
50
- this.cloudBaseRunService = new CloudBaseRunService(this)
51
- }
52
-
53
- async lazyInit(): Promise<any> {
54
- if (!this.inited) {
55
- const envConfig = this.envService
56
- return envConfig.getEnvInfo().then(envInfo => {
57
- this.lazyEnvironmentConfig = envInfo.EnvInfo
58
- if (!this.lazyEnvironmentConfig.EnvId) {
59
- throw new CloudBaseError(`Environment ${this.envId} not found`)
60
- }
61
-
62
- this.inited = true
63
- return this.lazyEnvironmentConfig
64
- })
65
- } else {
66
- return this.lazyEnvironmentConfig
67
- }
68
- }
69
-
70
- public getEnvId(): string {
71
- return this.envId
72
- }
73
-
74
- public getEnvType(): string {
75
- return this.envType
76
- }
77
-
78
- public getStorageService(): StorageService {
79
- return this.storageService
80
- }
81
-
82
- public getDatabaseService(): DatabaseService {
83
- return this.databaseService
84
- }
85
-
86
- public getFunctionService(): FunctionService {
87
- return this.functionService
88
- }
89
-
90
- public getEnvService(): EnvService {
91
- return this.envService
92
- }
93
-
94
- public getHostingService(): HostingService {
95
- return this.hostingService
96
- }
97
-
98
- public getThirdService(): ThirdService {
99
- return this.thirdService
100
- }
101
-
102
- public getAccessService(): AccessService {
103
- return this.accessService
104
- }
105
-
106
- public getUserService(): UserService {
107
- return this.userService
108
- }
109
-
110
- public getCloudBaseRunService(): CloudBaseRunService {
111
- return this.cloudBaseRunService
112
- }
113
-
114
- public getCommonService(serviceType = 'tcb', serviceVersion): CommonService {
115
- return new CommonService(this, serviceType, serviceVersion)
116
- }
117
-
118
- public getServicesEnvInfo(): Promise<any> {
119
- const envConfig = this.envService
120
- return envConfig.getEnvInfo().then(envInfo => {
121
- return envInfo.EnvInfo
122
- })
123
- }
124
-
125
- public getAuthConfig() {
126
- let { secretId, secretKey, token, proxy, region } = this.cloudBaseContext
127
- const envId = this.getEnvId()
128
-
129
- if (!secretId || !secretKey) {
130
- // 未主动传入密钥,从环境变量中读取
131
- const envSecretId = getEnvVar(ENV_NAME.ENV_SECRETID)
132
- const envSecretKey = getEnvVar(ENV_NAME.ENV_SECRETKEY)
133
- const envToken = getEnvVar(ENV_NAME.ENV_SESSIONTOKEN)
134
- if (!envSecretId || !envSecretKey) {
135
- if (getRuntime() === RUN_ENV.SCF) {
136
- throw new Error('missing authoration key, redeploy the function')
137
- } else {
138
- throw new Error('missing secretId or secretKey of tencent cloud')
139
- }
140
- } else {
141
- secretId = envSecretId
142
- secretKey = envSecretKey
143
- token = envToken
144
- }
145
- }
146
-
147
- return {
148
- envId,
149
- secretId,
150
- secretKey,
151
- token,
152
- proxy,
153
- region
154
- }
155
- }
156
- }
@@ -1,50 +0,0 @@
1
- import { Environment } from './environment'
2
- import { ERROR } from './constant'
3
- import { CloudBaseContext } from './context'
4
-
5
- export class EnvironmentManager {
6
- private cloudBaseContext: CloudBaseContext
7
-
8
- private envs: object = {}
9
-
10
- private currentEnv: Environment = null
11
-
12
- constructor(context: CloudBaseContext) {
13
- this.cloudBaseContext = context
14
- }
15
-
16
- public getCurrentEnv(): Environment {
17
- if (!this.currentEnv) {
18
- throw new Error(ERROR.CURRENT_ENVIRONMENT_IS_NULL)
19
- }
20
- return this.currentEnv
21
- }
22
-
23
- public add(envId: string): void {
24
- if (!this.envs[envId]) {
25
- this.envs[envId] = new Environment(this.cloudBaseContext, envId)
26
- }
27
- if (!this.currentEnv) {
28
- this.currentEnv = this.envs[envId]
29
- }
30
- }
31
-
32
- public remove(envId: string): void {
33
- this.envs[envId] = null
34
- delete this.envs[envId]
35
- }
36
-
37
- public get(envId: string): Environment | null {
38
- return this.envs[envId] || null
39
- }
40
-
41
- public switchEnv(envId: string): boolean {
42
- const env = this.envs[envId]
43
- if (env) {
44
- this.currentEnv = env
45
- return true
46
- } else {
47
- return false
48
- }
49
- }
50
- }
package/src/error.ts DELETED
@@ -1,27 +0,0 @@
1
- interface Options {
2
- exit?: number
3
- original?: Error | undefined
4
- code?: string | number
5
- requestId?: string
6
- action?: string
7
- }
8
-
9
- export class CloudBaseError extends Error {
10
- readonly exit: number
11
- readonly message: string
12
- readonly name = 'CloudBaseError'
13
- readonly original: Error | undefined
14
- readonly code: string | number
15
- readonly requestId: string
16
- readonly action: string
17
-
18
- constructor(message: string, options: Options = {}) {
19
- super()
20
- const { code = '', action = '', original = null, requestId = '' } = options
21
- this.message = action ? `[${action}] ${message}` : message
22
- this.original = original
23
- this.code = code
24
- this.requestId = requestId
25
- this.action = action
26
- }
27
- }