@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,55 +0,0 @@
1
- export interface ICreateAccessOptions {
2
- path: string
3
- // 云函数名或云应用名称
4
- name: string
5
- // 1 表示云函数,2 表示云应用
6
- type?: 1 | 2
7
- // 鉴权开关
8
- auth?: boolean
9
- }
10
-
11
- export interface IApi {
12
- ServiceId: string
13
- APIId: string
14
- Path: string
15
- Type: number
16
- Name: string
17
- CreateTime: number
18
- EnvId: string
19
- EnableAuth: boolean
20
- }
21
-
22
- export interface IUpdateOptions {
23
- // APIId
24
- apiIds: string[]
25
- // true 为开启,false 为关闭
26
- auth: boolean
27
- }
28
-
29
- export interface IService {
30
- ServiceId: string
31
- Domain: string
32
- OpenTime: number
33
- Status?: number
34
- }
35
-
36
- export interface IDeleteOptions {
37
- name?: string
38
- type?: number
39
- apiId?: string
40
- path?: string
41
- }
42
-
43
- export interface IGetOptions {
44
- path?: string
45
- name?: string
46
- limit?: number
47
- offset?: number
48
- }
49
-
50
- export interface IDomainOptions {
51
- // 域名
52
- domain: string
53
- // 腾讯云 SSL 证书 Id
54
- certId?: string
55
- }
@@ -1,43 +0,0 @@
1
- import { CloudService } from '../utils'
2
- import { CloudBaseContext } from '../context'
3
- import { IServiceVersion, IGoodItem, IGenerateDealsRes, IPayDealsRes } from '../interfaces'
4
-
5
- export class BillingService {
6
- static billServiceVersion: IServiceVersion = {
7
- service: 'billing',
8
- version: '2018-07-09'
9
- }
10
- private billService: CloudService
11
-
12
- constructor(context: CloudBaseContext) {
13
- this.billService = new CloudService(
14
- context,
15
- BillingService.billServiceVersion.service,
16
- BillingService.billServiceVersion.version
17
- )
18
- }
19
-
20
- /**
21
- * 创建订单
22
- * @param {Array<IGoodItem>} goods
23
- * @returns {Promise<IGenerateDealsRes>}
24
- * @memberof BillingService
25
- */
26
- public async GenerateDeals(goods: Array<IGoodItem>): Promise<IGenerateDealsRes> {
27
- return this.billService.request<IGenerateDealsRes>('GenerateDeals', {
28
- Goods: goods
29
- })
30
- }
31
-
32
- /**
33
- * 支付订单
34
- * @param {Array<string>} orderIds
35
- * @returns {Promise<IPayDealsRes>}
36
- * @memberof BillingService
37
- */
38
- public async PayDeals(orderIds: Array<string>): Promise<IPayDealsRes> {
39
- return this.billService.request<IPayDealsRes>('PayDeals', {
40
- OrderIds: orderIds
41
- })
42
- }
43
- }
package/src/cam/index.ts DELETED
@@ -1,106 +0,0 @@
1
- import { CloudService } from '../utils'
2
- import { CloudBaseContext } from '../context'
3
- import {
4
- IServiceVersion,
5
- IRoleListRes,
6
- ICreateRoleRes,
7
- IResponseInfo,
8
- IGetRoleRes
9
- } from '../interfaces'
10
-
11
- export class CamService {
12
- static camServiceVersion: IServiceVersion = {
13
- service: 'cam',
14
- version: '2019-01-16'
15
- }
16
- private camService: CloudService
17
-
18
- constructor(context: CloudBaseContext) {
19
- this.camService = new CloudService(
20
- context,
21
- CamService.camServiceVersion.service,
22
- CamService.camServiceVersion.version
23
- )
24
- }
25
-
26
- /**
27
- * 查询账户角色列表
28
- * @param {number} page
29
- * @param {number} rp
30
- * @returns {Promise<IRoleListRes>}
31
- * @memberof CamService
32
- */
33
- public async describeRoleList(page: number, rp: number): Promise<IRoleListRes> {
34
- return this.camService.request<IRoleListRes>('DescribeRoleList', {
35
- Page: page,
36
- Rp: rp
37
- })
38
- }
39
-
40
- /**
41
- * 获取角色详情
42
- * @param {string} roleName
43
- * @returns {Promise<IGetRoleRes>}
44
- * @memberof CamService
45
- */
46
- public async getRole(roleName: string): Promise<IGetRoleRes> {
47
- return this.camService.request<IGetRoleRes>('GetRole', {
48
- RoleName: roleName
49
- })
50
- }
51
-
52
- /**
53
- * 创建角色
54
- * @param {{
55
- * RoleName: string
56
- * PolicyDocument: string
57
- * Description: string
58
- * }} param
59
- * @returns {Promise<ICreateRoleRes>}
60
- * @memberof CamService
61
- */
62
- public async createRole(param: {
63
- RoleName: string
64
- PolicyDocument: string
65
- Description: string
66
- }): Promise<ICreateRoleRes> {
67
- return this.camService.request<ICreateRoleRes>('CreateRole', param)
68
- }
69
-
70
- /**
71
- * 绑定角色策略
72
- * @param {{
73
- * PolicyId: number
74
- * AttachRoleName: string
75
- * }} param
76
- * @returns {Promise<IResponseInfo>}
77
- * @memberof CamService
78
- */
79
- public async attachRolePolicy(param: {
80
- PolicyId: number
81
- AttachRoleName: string
82
- }): Promise<IResponseInfo> {
83
- return this.camService.request<IResponseInfo>('AttachRolePolicy', param)
84
- }
85
-
86
- public async attachRolePolicies(param: {
87
- RoleId?: number
88
- RoleName?: string
89
- PolicyId?: number[]
90
- PolicyName?: string[]
91
- }): Promise<IResponseInfo> {
92
- return this.camService.request<IResponseInfo>('AttachRolePolicies', param)
93
- }
94
-
95
- /**
96
- * 删除角色
97
- * @param {string} roleName
98
- * @returns {Promise<IResponseInfo>}
99
- * @memberof CamService
100
- */
101
- public async deleteRole(roleName: string): Promise<IResponseInfo> {
102
- return this.camService.request<IResponseInfo>('DeleteRole', {
103
- RoleName: roleName
104
- })
105
- }
106
- }
@@ -1,40 +0,0 @@
1
- import { Environment } from '../environment'
2
- import { CloudService, preLazy, upperCaseObjKey } from '../utils'
3
- import { IModifyServerFlowOption } from './types'
4
- import { IResponseInfo } from '../interfaces'
5
-
6
- export class CloudBaseRunService {
7
- private tcbService: CloudService
8
- private environment: Environment
9
-
10
- constructor(environment: Environment) {
11
- this.environment = environment
12
- this.tcbService = new CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08')
13
- }
14
-
15
- // 修改容器内版本流量配置
16
- @preLazy()
17
- public async modifyServerFlow(
18
- options: IModifyServerFlowOption
19
- ): Promise<{
20
- Result: string // succ代表成功
21
- RequestId: string // 请求ID
22
- }> {
23
- const { envId } = this.getEnvInfo()
24
-
25
- return this.tcbService.request('ModifyCloudBaseRunServerFlowConf', {
26
- EnvId: envId,
27
- ServerName: options.serverName,
28
- VersionFlowItems: upperCaseObjKey(options.versionFlowItems)
29
- // TrafficType: options.trafficType
30
- })
31
- }
32
-
33
- private getEnvInfo() {
34
- const envConfig = this.environment.lazyEnvironmentConfig
35
-
36
- return {
37
- envId: envConfig.EnvId
38
- }
39
- }
40
- }
@@ -1,24 +0,0 @@
1
- export interface IModifyServerFlowOption {
2
- serverName: string
3
- versionFlowItems?: ICloudBaseRunVersionFlowItem[]
4
- trafficType?: string
5
- }
6
-
7
- export interface ICloudBaseRunVersionFlowItem {
8
- versionName: string // 版本名称
9
- flowRatio: number // 流量占比
10
- urlParam?: IObjectKV // 流量参数
11
- priority?: number // 优先级(数值越小,优先级越高)
12
- isDefaultPriority?: boolean // 是否是默认兜底版本
13
- }
14
-
15
- export interface IObjectKV {
16
- key: string
17
- value: string
18
- }
19
-
20
- export interface IClouBaseRunKVPriority {
21
- key: string
22
- value: string
23
- priority: number
24
- }
@@ -1,54 +0,0 @@
1
- import { CloudService, preLazy } from '../utils'
2
- import { CloudBaseContext } from '../context'
3
- import { CloudBaseError } from '../error'
4
- import { Environment } from '../environment'
5
-
6
- interface ICommonApiServiceOption {
7
- Action: string // 接口名称
8
- Param: Record<string, any> // 接口传参
9
- }
10
- /**
11
- * 公共的云api调用方法 透传用户参数 无业务逻辑处理
12
- * @export
13
- * @class CommonService
14
- */
15
-
16
- const ActionVersionMap = {
17
- tcb: '2018-06-08',
18
- flexdb: '2018-11-27',
19
- scf: '2018-04-16',
20
- sts: '2018-04-16',
21
- cam: '2018-04-16',
22
- lowcode: '2021-01-08'
23
- }
24
-
25
- export class CommonService {
26
- private commonService: CloudService
27
- private environment: Environment
28
-
29
- constructor(environment: Environment, serviceType: string, serviceVersion: string) {
30
- this.environment = environment
31
- this.commonService = new CloudService(
32
- environment.cloudBaseContext,
33
- serviceType,
34
- serviceVersion || ActionVersionMap[serviceType]
35
- )
36
- }
37
-
38
- /**
39
- * 公共方法调用
40
- * @param {ICommonApiServiceParam} param
41
- * @returns {Promise<any>}
42
- * @memberof CommonService
43
- */
44
- public async call(options: ICommonApiServiceOption): Promise<any> {
45
- const { Action, Param = {} } = options
46
- if (!Action) {
47
- throw new CloudBaseError('缺少必填参数 Action')
48
- }
49
-
50
- const res = await this.commonService.request(Action, { ...Param })
51
-
52
- return res
53
- }
54
- }
package/src/constant.ts DELETED
@@ -1,56 +0,0 @@
1
- // // cloudbase cli 配置的字段名
2
- // export class ConfigItems {
3
- // static credentail = 'credential'
4
- // }
5
-
6
- export const ENV_NAME = {
7
- ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
8
- ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
9
- ENV_SESSIONTOKEN: 'TENCENTCLOUD_SESSIONTOKEN',
10
- ENV_TCB_ENV_ID: 'TENCENTCLOUD_TCB_ENVID',
11
- ENV_RUNENV: 'TENCENTCLOUD_RUNENV',
12
- ENV_RUNENV_SCF: 'TENCENTCLOUD_RUNENV=SCF'
13
- }
14
-
15
- export const SDK_VERSION = 'TCB-NODE-MANAGER/1.0.O'
16
-
17
- export const RUN_ENV = {
18
- SCF: 'SCF'
19
- }
20
-
21
- export const ENDPOINT = {
22
- TCB: 'tcb.tencentcloudapi.com',
23
- SCF: 'scf.tencentcloudapi.com',
24
- COS: 'cos.tencentcloudapi.com',
25
- FLEXDB: 'flexdb.tencentcloudapi.com'
26
- }
27
-
28
- export const SERVICE_TYPE = {
29
- TCB: 'tcb'
30
- }
31
-
32
- export const ERROR = {
33
- MISS_SECRET_INFO_IN_ENV: 'MISS_SECRET_INFO_IN_ENV',
34
- MISS_SECRET_INFO_IN_ARGS: 'MISS_SECRET_INFO_IN_ARGS',
35
- CURRENT_ENVIRONMENT_IS_NULL: 'CURRENT_ENVIRONMENT_IS_NULL',
36
- ENV_ID_NOT_EXISTS: 'ENV_ID_NOT_EXISTS'
37
- }
38
-
39
- export const PUBLIC_RSA_KEY = `
40
- -----BEGIN PUBLIC KEY-----
41
- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0ZLB0ZpWWFsHPnDDw++Nc2wI3
42
- nl2uyOrIJ5FUfxt4GAmt1Faf5pgMxAnL9exEUrrUDUX8Ri1R0KyfnHQQwCvKt8T8
43
- bgILIJe9UB8e9dvFqgqH2oA8Vqwi0YqDcvFLFJk2BJbm/0QYtZ563FumW8LEXAgu
44
- UeHi/0OZN9vQ33jWMQIDAQAB
45
- -----END PUBLIC KEY-----
46
- `
47
- export const ROLE_NAME = {
48
- TCB: 'TCB_QcsRole'
49
- }
50
-
51
- export const SCF_STATUS = {
52
- ACTIVE: 'Active',
53
- CREATING: 'Creating',
54
- UPDATING: 'Updating',
55
- CREATE_FAILED: 'CreateFailed'
56
- }
package/src/context.ts DELETED
@@ -1,18 +0,0 @@
1
- export class CloudBaseContext {
2
- public readonly secretId: string
3
- public readonly secretKey: string
4
- public readonly token: string
5
- public readonly proxy: string
6
- public readonly envId: string
7
- public readonly region: string
8
- public readonly envType: string // baas/run/weda/hosting
9
-
10
- constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '' }) {
11
- this.secretId = secretId
12
- this.secretKey = secretKey
13
- this.token = token
14
- this.proxy = proxy
15
- this.region = region
16
- this.envType = envType
17
- }
18
- }