@cloudbase/manager-node 4.2.3 → 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 -1037
  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 -1290
  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,164 +0,0 @@
1
- import fs from 'fs'
2
- import del from 'del'
3
- import path from 'path'
4
- import makeDir from 'make-dir'
5
- import util from 'util'
6
- import { compressToZip, checkFullAccess } from '../utils'
7
- import { CloudBaseError } from '../error'
8
-
9
- // 10 MB
10
- export const BIG_FILE_SIZE = 10485760
11
- export const API_MAX_SIZE = 52428800
12
-
13
- export enum CodeType {
14
- File,
15
- JavaFile
16
- }
17
-
18
- export interface IPackerOptions {
19
- // 通过根目录和函数名指定函数路径
20
- root?: string
21
- name?: string
22
- ignore: string | string[]
23
- incrementalPath?: string
24
- // 直接指定函数的路径
25
- functionPath?: string
26
- codeType: CodeType
27
- }
28
-
29
- const TEMPDIR_NAME = '.cloudbase_temp'
30
-
31
- /**
32
- * 将函数代码转换成 Base64 编码
33
- * 普通文件:Node,PHP
34
- * Java 文件:Jar,ZIP
35
- */
36
- export class FunctionPacker {
37
- // 函数名
38
- name: string
39
- // 代码文件类型
40
- type: CodeType
41
- funcPath: string
42
- zipFilePath: string
43
- // 存放打包文件的临时目录
44
- tmpPath: string
45
- // 忽略文件模式
46
- ignore: string | string[]
47
- // 指定增量文件路径
48
- incrementalPath: string
49
- // 代码类型: Java 和 其他
50
- codeType: CodeType
51
-
52
- constructor(options: IPackerOptions) {
53
- const { root, name, codeType, ignore, incrementalPath, functionPath } = options
54
- this.name = name
55
- this.ignore = ignore
56
- this.codeType = codeType
57
- this.incrementalPath = incrementalPath
58
- this.funcPath = functionPath ? functionPath : path.resolve(root, name)
59
- // 每个函数采用不同的文件夹
60
- this.tmpPath = root
61
- ? path.join(root, `${TEMPDIR_NAME}_${name}`)
62
- : path.join(process.cwd(), `${TEMPDIR_NAME}_${name}`)
63
- }
64
-
65
- async compressFiles() {
66
- checkFullAccess(this.funcPath, true)
67
- // 清除原打包文件
68
- this.clean()
69
- // 确保目标路径存在
70
- await makeDir(this.tmpPath)
71
- // 生成 name.zip 文件
72
- this.zipFilePath = path.resolve(this.tmpPath, `${this.name}.zip`)
73
-
74
- const zipOption: any = {
75
- dirPath: this.funcPath,
76
- outputPath: this.zipFilePath,
77
- ignore: this.ignore
78
- }
79
-
80
- if (this.incrementalPath) {
81
- zipOption.pattern = this.incrementalPath
82
- }
83
-
84
- await compressToZip(zipOption)
85
- }
86
-
87
- // 获取 Java 代码
88
- getJavaFile() {
89
- const { funcPath } = this
90
- // funcPath 可能以 .jar 或 .zip 结尾
91
- const filePath = funcPath.replace(/\.jar$|\.zip$/g, '')
92
- // Java 代码为 jar 或 zip 包
93
- const jarExist = checkFullAccess(`${filePath}.jar`)
94
- const zipExist = checkFullAccess(`${filePath}.zip`)
95
- if (!jarExist && !zipExist) {
96
- throw new CloudBaseError('未找到部署函数的 Jar 或者 ZIP 格式文件!')
97
- }
98
- this.zipFilePath = jarExist ? `${filePath}.jar` : `${filePath}.zip`
99
- }
100
-
101
- async build() {
102
- if (this.codeType === CodeType.JavaFile) {
103
- try {
104
- await this.getJavaFile()
105
- } catch (e) {
106
- this.clean()
107
- throw new CloudBaseError(`函数代码打包失败:${e.message}`, {
108
- code: e.code
109
- })
110
- }
111
- }
112
-
113
- if (this.codeType === CodeType.File) {
114
- try {
115
- await this.compressFiles()
116
- } catch (e) {
117
- this.clean()
118
- throw new CloudBaseError(`函数代码打包失败:${e.message}`, {
119
- code: e.code
120
- })
121
- }
122
- }
123
- }
124
-
125
- // 函数压缩后的代码大于 10M,建议使用 COS 上传(当前暂不支持)
126
- async isBigFile() {
127
- if (!this.zipFilePath) {
128
- await this.build()
129
- }
130
-
131
- const promiseStat = util.promisify(fs.stat)
132
- const fileStats = await promiseStat(this.zipFilePath)
133
-
134
- return fileStats.size > BIG_FILE_SIZE
135
- }
136
-
137
- // API 最大 50MB
138
- async isReachMaxSize() {
139
- if (!this.zipFilePath) {
140
- await this.build()
141
- }
142
-
143
- const promiseStat = util.promisify(fs.stat)
144
- const fileStats = await promiseStat(this.zipFilePath)
145
-
146
- return fileStats.size > API_MAX_SIZE
147
- }
148
-
149
- async getBase64Code() {
150
- // 将 zip 文件转换成 base64
151
- const base64 = fs.readFileSync(this.zipFilePath).toString('base64')
152
- // 非 Java 函数清除打包文件
153
- if (this.codeType !== CodeType.JavaFile) {
154
- await this.clean()
155
- }
156
- return base64
157
- }
158
-
159
- async clean(): Promise<void> {
160
- // allow deleting the current working directory and outside
161
- this.tmpPath && del.sync([this.tmpPath], { force: true })
162
- return
163
- }
164
- }
@@ -1,165 +0,0 @@
1
- export interface ITag {
2
- TagKey: string
3
- TagValue: string[]
4
- }
5
-
6
- /**
7
- * VPC
8
- */
9
- export interface IVpc {
10
- VpcId: string
11
- VpcName: string
12
- CidrBlock: string
13
- Ipv6CidrBlock: string
14
- IsDefault: false
15
- EnableMulticast: false
16
- CreatedTime: string
17
- EnableDhcp: boolean
18
- DhcpOptionsId: string
19
- DnsServerSet: string[]
20
- DomainName: string
21
- TagSet: any[]
22
- AssistantCidrSet: any[]
23
- }
24
-
25
- /**
26
- * 子网
27
- */
28
-
29
- export interface ISubnet {
30
- VpcId: string
31
- SubnetId: string
32
- SubnetName: string
33
- CidrBlock: string
34
- Ipv6CidrBlock: string
35
- IsDefault: boolean
36
- IsRemoteVpcSnat: boolean
37
- EnableBroadcast: boolean
38
- Zone: string
39
- RouteTableId: string
40
- NetworkAclId: string
41
- TotalIpAddressCount: number
42
- AvailableIpAddressCount: number
43
- CreatedTime: string
44
- TagSet: any[]
45
- }
46
- /**
47
- * 函数
48
- */
49
- export interface IFunctionLog {
50
- FunctionName: string
51
- RetMsg: string
52
- RequestId: string
53
- StartTime?: string
54
- RetCode?: number
55
- InvokeFinished?: number
56
- Duration?: number
57
- BillDuration?: number
58
- MemUsage: number
59
- Log?: string
60
- Level?: string
61
- Source?: string
62
- }
63
-
64
- export interface ILogFilter {
65
- RetCode?: 'not0' | 'is0' | 'TimeLimitExceeded' | 'ResourceLimitExceeded' | 'UserCodeException'
66
- }
67
-
68
- export type IRegion = number
69
-
70
- export interface IEnvVariable {
71
- Key: string
72
- Value: string
73
- }
74
-
75
- export interface ITrigger {
76
- Name: string
77
- Type: string
78
- Config: string
79
- TriggerName: string
80
- TriggerDesc: string
81
- }
82
-
83
- export interface IFunctionInfo {
84
- FunctionName: string
85
- FunctionId: string
86
- Runtime: string
87
- Handler: string
88
- CodeSize: number
89
- Timeout: number
90
- FunctionVersion: string
91
- MemorySize: number
92
- UseGpu: 'TRUE' | 'FALSE'
93
- CodeInfo: string
94
- CodeResult: string
95
- CodeError: string
96
- ErrNo: number
97
- Role: string
98
- InstallDependency: 'FALSE' | 'TRUE'
99
- AddTime: string
100
- ModTime: string
101
- Namespace: string
102
- Status: string
103
- StatusDesc: string
104
- Description: string
105
- Tags: ITag[]
106
- VpcConfig: {
107
- VpcId?: string
108
- SubnetId?: string
109
- vpc?: string
110
- subnet?: string
111
- }
112
- Environment: {
113
- Variables: IEnvVariable[]
114
- }
115
- Type: string
116
-
117
- EipConfig: {
118
- EipFixed: 'FALSE' | 'TRUE'
119
- Eips: string[]
120
- }
121
-
122
- PublicNetConfig: {
123
- PublicNetStatus: 'ENABLE' | 'DISABLE'
124
- EipConfig: {
125
- EipStatus: 'ENABLE' | 'DISABLE'
126
- EipAddress: string[]
127
- }
128
- }
129
-
130
- Triggers: ITrigger[]
131
- }
132
-
133
- export interface IFunctionCode {
134
- // 对象存储桶名称
135
- CosBucketName?: string
136
- // 对象存储对象路径
137
- CosObjectName?: string
138
- // 包含函数代码文件及其依赖项的 zip 格式文件,使用该接口时要求将 zip 文件的内容转成 base64 编码,最大支持20M
139
- ZipFile: string
140
- }
141
-
142
- export interface ILayerVersionItem {
143
- LayerName: string
144
- LayerVersion: number
145
- }
146
-
147
- export interface IFunctionUpdateAttribute {
148
- Code: IFunctionCode
149
- Description: string
150
- FunctionName: string
151
- MemorySize: number
152
- Timeout: number
153
- UseGpu: 'FALSE' | 'TRUE'
154
- Namespace: string
155
- Environment: { Variables: IEnvVariable[] }
156
- VpcConfig: { VpcId: string; SubnetId: string }
157
- InstallDependency?: 'FALSE' | 'TRUE'
158
- PublicNetConfig: {
159
- PublicNetStatus: string
160
- EipConfig: { EipStatus: string; EipAddress: string[] }
161
- }
162
- Layers?: ILayerVersionItem[]
163
- ClsLogsetId?: string
164
- ClsTopicId?: string
165
- }