Skip to content

Commit d0a4f82

Browse files
committed
fix(asw): support get method
1 parent fefcd29 commit d0a4f82

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

__tests__/asw.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ describe('Account', () => {
4545
createResult = res;
4646
});
4747

48+
test('get', async () => {
49+
const res = await client.get(createResult.resourceId);
50+
51+
expect(res.FlowServiceName).toBe(options.name);
52+
expect(res.Type).toBe('STANDARD');
53+
expect(res.Definition).toBe(options.definition);
54+
});
55+
4856
test('update', async () => {
4957
options.resourceId = createResult.resourceId;
5058
options.role = createResult.roleName;

src/modules/asw/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ExecuteApiOptions,
1313
ExecuteResult,
1414
ExecuteState,
15+
FlowDetail,
1516
} from './interface';
1617
import APIS, { ActionType } from './apis';
1718
import { pascalCaseProps, randomId } from '../../utils/index';
@@ -42,6 +43,24 @@ export default class Asw {
4243
this.cam = new Cam(credentials);
4344
}
4445

46+
/**
47+
* 获取执行状态
48+
* @param executeName 执行名称
49+
* @returns 执行状态
50+
*/
51+
async get(resourceId: string): Promise<FlowDetail | null> {
52+
try {
53+
const res = await this.request({
54+
Action: 'DescribeFlowServiceDetail',
55+
FlowServiceResource: resourceId,
56+
});
57+
58+
return res as FlowDetail;
59+
} catch (e) {
60+
return null;
61+
}
62+
}
63+
4564
/**
4665
* 创建工作流
4766
* @param {CreateOptions} options 创建参数

src/modules/asw/interface.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,30 @@ export interface ExecuteState {
117117
// 请求 ID
118118
RequestId: string;
119119
}
120+
121+
export interface FlowDetail {
122+
// 状态机所属服务名
123+
FlowServiceName: string;
124+
// 状态机状态
125+
Status: string;
126+
// 定义文本(JSON格式)
127+
Definition: string;
128+
// 角色资源名
129+
RoleResource: string;
130+
// 状态机的类型,可以为 (EXPRESS/STANDARD)
131+
Type: string;
132+
// 生成时间
133+
CreateDate: string;
134+
// 备注
135+
Description: string;
136+
// 状态机所属服务中文名
137+
FlowServiceChineseName: string;
138+
// Boolean 是否开启日志CLS服务
139+
EnableCLS: boolean;
140+
// CLS日志查看地址
141+
CLSUrl: string;
142+
// 工作流提示输入
143+
FlowInput: string;
144+
// 请求 ID
145+
RequestId: string;
146+
}

0 commit comments

Comments
 (0)