@cloudbase/manager-node 4.2.2 → 4.2.4

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 (125) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +4 -3
  3. package/lib/access/index.js +0 -141
  4. package/lib/access/types.js +0 -2
  5. package/lib/billing/index.js +0 -36
  6. package/lib/cam/index.js +0 -77
  7. package/lib/cloudBaseRun/index.js +0 -36
  8. package/lib/cloudBaseRun/types.js +0 -2
  9. package/lib/common/index.js +0 -39
  10. package/lib/constant.js +0 -51
  11. package/lib/context.js +0 -14
  12. package/lib/database/index.js +0 -244
  13. package/lib/debug.js +0 -34
  14. package/lib/env/index.js +0 -488
  15. package/lib/environment.js +0 -124
  16. package/lib/environmentManager.js +0 -44
  17. package/lib/error.js +0 -16
  18. package/lib/function/index.js +0 -1022
  19. package/lib/function/packer.js +0 -129
  20. package/lib/function/types.js +0 -2
  21. package/lib/hosting/index.js +0 -461
  22. package/lib/index.js +0 -83
  23. package/lib/interfaces/base.interface.js +0 -2
  24. package/lib/interfaces/billing.interface.js +0 -2
  25. package/lib/interfaces/cam.interface.js +0 -2
  26. package/lib/interfaces/flexdb.interface.js +0 -2
  27. package/lib/interfaces/function.interface.js +0 -2
  28. package/lib/interfaces/index.js +0 -19
  29. package/lib/interfaces/storage.interface.js +0 -2
  30. package/lib/interfaces/tcb.interface.js +0 -2
  31. package/lib/storage/index.js +0 -1035
  32. package/lib/third/index.js +0 -18
  33. package/lib/user/index.js +0 -136
  34. package/lib/user/types.js +0 -2
  35. package/lib/utils/auth.js +0 -97
  36. package/lib/utils/cloud-api-request.js +0 -205
  37. package/lib/utils/cloudbase-request.js +0 -69
  38. package/lib/utils/envLazy.js +0 -18
  39. package/lib/utils/fs.js +0 -64
  40. package/lib/utils/http-request.js +0 -44
  41. package/lib/utils/index.js +0 -103
  42. package/lib/utils/parallel.js +0 -69
  43. package/lib/utils/uuid.js +0 -18
  44. package/src/access/index.ts +0 -168
  45. package/src/access/types.ts +0 -55
  46. package/src/billing/index.ts +0 -43
  47. package/src/cam/index.ts +0 -106
  48. package/src/cloudBaseRun/index.ts +0 -40
  49. package/src/cloudBaseRun/types.ts +0 -24
  50. package/src/common/index.ts +0 -54
  51. package/src/constant.ts +0 -56
  52. package/src/context.ts +0 -18
  53. package/src/database/index.ts +0 -369
  54. package/src/debug.ts +0 -34
  55. package/src/env/index.ts +0 -614
  56. package/src/environment.ts +0 -156
  57. package/src/environmentManager.ts +0 -50
  58. package/src/error.ts +0 -27
  59. package/src/function/index.ts +0 -1378
  60. package/src/function/packer.ts +0 -164
  61. package/src/function/types.ts +0 -165
  62. package/src/hosting/index.ts +0 -698
  63. package/src/index.ts +0 -127
  64. package/src/interfaces/base.interface.ts +0 -8
  65. package/src/interfaces/billing.interface.ts +0 -21
  66. package/src/interfaces/cam.interface.ts +0 -28
  67. package/src/interfaces/flexdb.interface.ts +0 -104
  68. package/src/interfaces/function.interface.ts +0 -75
  69. package/src/interfaces/index.ts +0 -7
  70. package/src/interfaces/storage.interface.ts +0 -29
  71. package/src/interfaces/tcb.interface.ts +0 -642
  72. package/src/storage/index.ts +0 -1281
  73. package/src/third/index.ts +0 -24
  74. package/src/user/index.ts +0 -174
  75. package/src/user/types.ts +0 -21
  76. package/src/utils/auth.ts +0 -112
  77. package/src/utils/cloud-api-request.ts +0 -252
  78. package/src/utils/cloudbase-request.ts +0 -109
  79. package/src/utils/envLazy.ts +0 -15
  80. package/src/utils/fs.ts +0 -57
  81. package/src/utils/http-request.ts +0 -37
  82. package/src/utils/index.ts +0 -103
  83. package/src/utils/parallel.ts +0 -82
  84. package/src/utils/uuid.ts +0 -14
  85. package/types/access/index.d.ts +0 -38
  86. package/types/access/types.d.ts +0 -42
  87. package/types/billing/index.d.ts +0 -21
  88. package/types/cam/index.d.ts +0 -63
  89. package/types/cloudBaseRun/index.d.ts +0 -12
  90. package/types/cloudBaseRun/types.d.ts +0 -21
  91. package/types/common/index.d.ts +0 -18
  92. package/types/constant.d.ts +0 -37
  93. package/types/context.d.ts +0 -17
  94. package/types/database/index.d.ts +0 -66
  95. package/types/debug.d.ts +0 -1
  96. package/types/env/index.d.ts +0 -144
  97. package/types/environment.d.ts +0 -51
  98. package/types/environmentManager.d.ts +0 -13
  99. package/types/error.d.ts +0 -18
  100. package/types/function/index.d.ts +0 -379
  101. package/types/function/packer.d.ts +0 -37
  102. package/types/function/types.d.ts +0 -156
  103. package/types/hosting/index.d.ts +0 -253
  104. package/types/index.d.ts +0 -52
  105. package/types/interfaces/base.interface.d.ts +0 -7
  106. package/types/interfaces/billing.interface.d.ts +0 -18
  107. package/types/interfaces/cam.interface.d.ts +0 -24
  108. package/types/interfaces/flexdb.interface.d.ts +0 -67
  109. package/types/interfaces/function.interface.d.ts +0 -65
  110. package/types/interfaces/index.d.ts +0 -7
  111. package/types/interfaces/storage.interface.d.ts +0 -26
  112. package/types/interfaces/tcb.interface.d.ts +0 -305
  113. package/types/storage/index.d.ts +0 -324
  114. package/types/third/index.d.ts +0 -11
  115. package/types/user/index.d.ts +0 -52
  116. package/types/user/types.d.ts +0 -20
  117. package/types/utils/auth.d.ts +0 -8
  118. package/types/utils/cloud-api-request.d.ts +0 -21
  119. package/types/utils/cloudbase-request.d.ts +0 -14
  120. package/types/utils/envLazy.d.ts +0 -1
  121. package/types/utils/fs.d.ts +0 -7
  122. package/types/utils/http-request.d.ts +0 -2
  123. package/types/utils/index.d.ts +0 -20
  124. package/types/utils/parallel.d.ts +0 -17
  125. package/types/utils/uuid.d.ts +0 -2
@@ -1,103 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.upperCaseObjKey = exports.upperCaseStringFisrt = exports.sleep = exports.rsaEncrypt = exports.getEnvVar = exports.getRuntime = exports.compressToZip = void 0;
17
- const fs_1 = __importDefault(require("fs"));
18
- const archiver_1 = __importDefault(require("archiver"));
19
- const crypto_1 = __importDefault(require("crypto"));
20
- const constant_1 = require("../constant");
21
- var uuid_1 = require("./uuid");
22
- Object.defineProperty(exports, "guid6", { enumerable: true, get: function () { return uuid_1.guid6; } });
23
- __exportStar(require("./cloud-api-request"), exports);
24
- __exportStar(require("./auth"), exports);
25
- __exportStar(require("./cloudbase-request"), exports);
26
- __exportStar(require("./http-request"), exports);
27
- __exportStar(require("./envLazy"), exports);
28
- __exportStar(require("./fs"), exports);
29
- async function compressToZip(option) {
30
- const { dirPath, outputPath, ignore, pattern = '**/*' } = option;
31
- return new Promise((resolve, reject) => {
32
- const output = fs_1.default.createWriteStream(outputPath);
33
- const archive = archiver_1.default('zip');
34
- output.on('close', function () {
35
- resolve({
36
- zipPath: outputPath,
37
- size: Math.ceil(archive.pointer() / 1024)
38
- });
39
- });
40
- archive.on('error', function (err) {
41
- reject(err);
42
- });
43
- archive.pipe(output);
44
- // append files from a glob pattern
45
- archive.glob(pattern, {
46
- // 目标路径
47
- cwd: dirPath,
48
- ignore: ignore,
49
- dot: true
50
- });
51
- archive.finalize();
52
- });
53
- }
54
- exports.compressToZip = compressToZip;
55
- function getRuntime() {
56
- return process.env[constant_1.ENV_NAME.ENV_RUNENV];
57
- }
58
- exports.getRuntime = getRuntime;
59
- function getEnvVar(envName) {
60
- return process.env[envName];
61
- }
62
- exports.getEnvVar = getEnvVar;
63
- function rsaEncrypt(data) {
64
- const buffer = Buffer.from(data);
65
- const encrypted = crypto_1.default.publicEncrypt({
66
- key: constant_1.PUBLIC_RSA_KEY,
67
- padding: crypto_1.default.constants.RSA_PKCS1_PADDING
68
- }, buffer);
69
- return encrypted.toString('base64');
70
- }
71
- exports.rsaEncrypt = rsaEncrypt;
72
- function sleep(time) {
73
- return new Promise(resolve => {
74
- setTimeout(() => {
75
- resolve();
76
- }, time);
77
- });
78
- }
79
- exports.sleep = sleep;
80
- function upperCaseStringFisrt(str) {
81
- return str.slice(0, 1).toUpperCase().concat(str.slice(1));
82
- }
83
- exports.upperCaseStringFisrt = upperCaseStringFisrt;
84
- function upperCaseObjKey(object) {
85
- const type = Object.prototype.toString.call(object).slice(8, -1);
86
- if (type === 'Object') {
87
- let newObj = {};
88
- // eslint-disable-next-line guard-for-in
89
- for (let key in object) {
90
- newObj[upperCaseStringFisrt(key)] = upperCaseObjKey(object[key]);
91
- }
92
- return newObj;
93
- }
94
- if (type === 'Array') {
95
- let newArr = [];
96
- for (let item of object) {
97
- newArr.push(upperCaseObjKey(item));
98
- }
99
- return newArr;
100
- }
101
- return object;
102
- }
103
- exports.upperCaseObjKey = upperCaseObjKey;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AsyncTaskParallelController = void 0;
4
- /**
5
- * 异步任务并发控制器,以一定的并发数执行所有任务
6
- * 不具备队列性质,异步任务随机执行
7
- * 单个任务异常,错误会返回,单不会退出执行
8
- * 所有任务执行
9
- */
10
- class AsyncTaskParallelController {
11
- constructor(maxParallel, checkInterval = 20) {
12
- this.tasks = [];
13
- this.maxParallel = Number(maxParallel) || 20;
14
- this.checkInterval = checkInterval;
15
- }
16
- loadTasks(tasks) {
17
- this.tasks.push(...tasks);
18
- this.totalTasks = this.tasks.length;
19
- }
20
- push(task) {
21
- this.tasks.push(task);
22
- this.totalTasks = this.tasks.length;
23
- }
24
- // 开始执行任务
25
- async run() {
26
- // 存储任务执行结果
27
- const results = [];
28
- // 记录已经运行的任务
29
- const taskHasRun = [];
30
- // 记录任务是否执行完成
31
- const taskDone = [];
32
- // 当前正在运行的任务数量
33
- let runningTask = 0;
34
- return new Promise(resolve => {
35
- // 使用定时器,不阻塞线程
36
- const timer = setInterval(() => {
37
- // 全部任务运行完成
38
- const taskDoneLength = taskDone.filter(item => item).length;
39
- if (runningTask === 0 && taskDoneLength === this.totalTasks) {
40
- clearInterval(timer);
41
- resolve(results);
42
- }
43
- // 当前运行任务数超过最大并发,不再执行新的任务
44
- if (runningTask >= this.maxParallel) {
45
- return;
46
- }
47
- // 遍历任务列表,开始执行还没有执行的任务
48
- this.tasks.forEach((task, index) => {
49
- if (!taskHasRun[index] && runningTask < this.maxParallel) {
50
- runningTask++;
51
- taskHasRun[index] = 1;
52
- task()
53
- .then(res => {
54
- results[index] = res;
55
- })
56
- .catch(err => {
57
- results[index] = err;
58
- })
59
- .then(() => {
60
- runningTask--;
61
- taskDone[index] = 1;
62
- });
63
- }
64
- });
65
- }, this.checkInterval);
66
- });
67
- }
68
- }
69
- exports.AsyncTaskParallelController = AsyncTaskParallelController;
package/lib/utils/uuid.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uuidv4 = exports.guid6 = void 0;
4
- // 环境 uuid
5
- function guid6() {
6
- return Math.floor((1 + Math.random()) * 0x1000000)
7
- .toString(16)
8
- .substring(1);
9
- }
10
- exports.guid6 = guid6;
11
- function uuidv4() {
12
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
13
- const r = (Math.random() * 16) | 0;
14
- const v = c === 'x' ? r : (r & 0x3) | 0x8;
15
- return v.toString(16);
16
- });
17
- }
18
- exports.uuidv4 = uuidv4;
@@ -1,168 +0,0 @@
1
- import { Environment } from '../environment'
2
- import { CloudService, preLazy } from '../utils'
3
- import {
4
- ICreateAccessOptions,
5
- IApi,
6
- IUpdateOptions,
7
- IService,
8
- IDeleteOptions,
9
- IGetOptions,
10
- IDomainOptions
11
- } from './types'
12
- import { IResponseInfo } from '../interfaces'
13
-
14
- export class AccessService {
15
- private tcbService: CloudService
16
- private environment: Environment
17
-
18
- constructor(environment: Environment) {
19
- this.environment = environment
20
- this.tcbService = new CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08')
21
- }
22
-
23
- // 创建云接入路径
24
- @preLazy()
25
- public async createAccess(options: ICreateAccessOptions) {
26
- const { path, name, type = 1, auth } = options
27
- const { envId } = this.getEnvInfo()
28
-
29
- return this.tcbService.request<{
30
- APIId: string
31
- RequestId: string
32
- }>('CreateCloudBaseGWAPI', {
33
- ServiceId: envId,
34
- Path: path,
35
- Type: type,
36
- Name: name,
37
- AuthSwitch: auth ? 1 : 2
38
- })
39
- }
40
-
41
- // 获取云接入自定义域名列表
42
- @preLazy()
43
- public async getDomainList() {
44
- const { envId } = this.getEnvInfo()
45
- return this.tcbService.request<{
46
- RequestId: string
47
- // 云接入默认域名
48
- DefaultDomain: string
49
- // 是否开启了云接入服务
50
- EnableService: boolean
51
- // 云接入服务列表
52
- ServiceSet: IService[]
53
- }>('DescribeCloudBaseGWService', {
54
- ServiceId: envId
55
- })
56
- }
57
-
58
- // 获取云接入服务列表
59
- @preLazy()
60
- public async getAccessList(options: IGetOptions = {}) {
61
- const { path, name, offset, limit } = options
62
- const { envId } = this.getEnvInfo()
63
-
64
- return this.tcbService.request<{
65
- RequestId: string
66
- APISet: IApi[]
67
- Total: number
68
- Limit: number
69
- Offset: number
70
- EnableService: boolean
71
- }>('DescribeCloudBaseGWAPI', {
72
- ServiceId: envId,
73
- Path: path,
74
- Name: name,
75
- Offset: offset,
76
- limit: limit
77
- })
78
- }
79
-
80
- // 切换云接入服务开关:开启/关闭
81
- @preLazy()
82
- public async switchAuth(auth: boolean) {
83
- const { envId } = this.getEnvInfo()
84
- return this.tcbService.request<{
85
- Count: number
86
- RequestId: string
87
- }>('ModifyCloudBaseGWPrivilege', {
88
- ServiceId: envId,
89
- EnableService: auth,
90
- Options: [
91
- {
92
- Key: 'serviceswitch',
93
- Value: auth ? 'true' : 'false'
94
- }
95
- ]
96
- })
97
- }
98
-
99
- // 更新云接入路径鉴权
100
- @preLazy()
101
- public async switchPathAuth(options: IUpdateOptions) {
102
- const { apiIds, auth } = options
103
- const { envId } = this.getEnvInfo()
104
- return this.tcbService.request<{
105
- Count: number
106
- RequestId: string
107
- }>('ModifyCloudBaseGWAPIPrivilegeBatch', {
108
- ServiceId: envId,
109
- APIIdSet: apiIds,
110
- Options: [
111
- {
112
- Key: 'authswitch',
113
- Value: auth ? 'true' : 'false'
114
- }
115
- ]
116
- })
117
- }
118
-
119
- // 删除云接入服务
120
- @preLazy()
121
- public async deleteAccess(options: IDeleteOptions) {
122
- const { name, type = 1, apiId } = options
123
- const { envId } = this.getEnvInfo()
124
-
125
- return this.tcbService.request<IResponseInfo>('DeleteCloudBaseGWAPI', {
126
- ServiceId: envId,
127
- Name: name,
128
- Type: type,
129
- APIId: apiId
130
- })
131
- }
132
-
133
- // 添加自定义域名
134
- @preLazy()
135
- public async addCustomDomain(options: IDomainOptions) {
136
- const { domain, certId } = options
137
- const { envId } = this.getEnvInfo()
138
-
139
- return this.tcbService.request<IResponseInfo>('BindCloudBaseGWDomain', {
140
- Domain: domain,
141
- ServiceId: envId,
142
- CertId: certId
143
- })
144
- }
145
-
146
- // 删除自定义域名
147
- @preLazy()
148
- public async deleteCustomDomain(domain: string) {
149
- const { envId } = this.getEnvInfo()
150
-
151
- return this.tcbService.request<IResponseInfo>('DeleteCloudBaseGWDomain', {
152
- Domain: domain,
153
- ServiceId: envId
154
- })
155
- }
156
-
157
- private getEnvInfo() {
158
- const envConfig = this.environment.lazyEnvironmentConfig
159
- const appId = envConfig.Storages[0]?.AppId
160
- const { proxy } = this.environment.cloudBaseContext
161
-
162
- return {
163
- appId,
164
- proxy,
165
- envId: envConfig.EnvId
166
- }
167
- }
168
- }
@@ -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
- }