-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathversion.ts
39 lines (34 loc) · 1.22 KB
/
version.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { CloudBaseError } from '../error'
import { IPublishVersionParams, IListFunctionVersionParams, IFunctionVersionsRes } from '../types'
import { getFunctionService } from './base'
// 发布云函数新版本
export async function publishVersion(options: IPublishVersionParams) {
const { envId, functionName, description = '' } = options
const scfService = await getFunctionService(envId)
try {
await scfService.publishVersion({
functionName,
description
})
} catch (e) {
throw new CloudBaseError(`[${functionName}] 函数发布新版本失败: ${e.message}`, {
code: e.code
})
}
}
// 查看函数所有版本
export async function listFunctionVersions(options: IListFunctionVersionParams): Promise<IFunctionVersionsRes> {
const { envId, functionName, offset = 0, limit = 20 } = options
const scfService = await getFunctionService(envId)
try {
return scfService.listVersionByFunction({
functionName,
offset,
limit
})
} catch (e) {
throw new CloudBaseError(`[${functionName}] 查看寒函数版本列表失败: ${e.message}`, {
code: e.code
})
}
}