@crvouga/ mockingbird-service-step-函数
本地模拟器。 真正的API合同. 部分 嘲笑鸟。 。 。 .
用于官方SFN SDK v3客户端的状态 AWS Step 函数模拟器. 它模拟了标准执行身份,输入/输出字符串,定点终端过渡,回调符,停止请求,命令历史,发卡,以及不与AWS联系的共享时钟脚本.
安装
npm install -D @crvouga/mockingbird-service-step-functions
仅限无害环境管理。 节点22+或Bun 1.2+.
使用量
指向 SFN 客户端 endpoint 选项。 接受Fixture SigV4证书.
import { DescribeExecutionCommand, SFNClient, StartExecutionCommand } from "@aws-sdk/client-sfn"
import { createServer } from "@crvouga/mockingbird-service-step-functions/server"
// Test setup: start the emulator with a scripted state machine and point the SDK's endpoint at it.
const server = await createServer({
stateMachines: [
{
name: "jobs",
scripted: { status: "SUCCEEDED", output: '{"ok":true}', afterMs: 1000 },
},
],
})
const sfn = new SFNClient({
endpoint: server.url,
region: "us-east-1",
credentials: { accessKeyId: "fixture", secretAccessKey: "fixture" },
})
// Application code: the SFN SDK calls it already makes.
const { executionArn } = await sfn.send(
new StartExecutionCommand({
stateMachineArn: "arn:aws:states:us-east-1:000000000000:stateMachine:jobs",
input: JSON.stringify({ id: 1 }),
}),
)
// Test control: move the emulator clock past the script's `afterMs` instead of sleeping.
await fetch(`${server.url}/__admin/clock`, { method: "POST", body: JSON.stringify({ advance: 1000 }) })
const execution = await sfn.send(new DescribeExecutionCommand({ executionArn }))
console.log(execution.status, execution.output) // SUCCEEDED {"ok":true}
await server.close()
所支持的操作有:StartExecution,DescriptionExecution,StopExecution,GetExecutionHistory,SendTaskSuccess,SendTaskFailure,和SendTaskHeartbeat. 国家机器ARN、姓名和确切的输入, 关闭名重用和相冲突的运行中的输入返回“已执行 ” 。 JSON 输入/输出仍然是线上的字符串.
管理和确定性控制
GET/POST /__admin/state-machines列出或登记紧凑的本地定义.GET /__admin/executions以修改的任务符号检查处决.GET /__admin/executions/:arn/task-token获取本地调用符 .POST /__admin/executions/:arn/transition决定性地将运行中的执行移动到SOCCEED, 故障, TimeD OUT, 或 ABORTED .- 共享时钟到达时被脚本机器转换
afterMs无需在投票时睡觉. - 错误预设为
throttled财务报告和审定财务报表unavailable。 。 。 .
共享运行时间还提供重设、时间表、日记、度量、断层和名称空间隔离 x-mockingbird-namespace, (中文(简体) ), /__admin/ns/<name>,或SigV4存取键映射.
故意不模拟
完整的亚马逊州语言翻译、实际服务集成、快通工作流程、IAM评价、云表交付、生产保留限额、仪表板和计费等都不是模拟。 定义可以保留作为定着物,而确定性脚本和回调任务则涵盖目前的消费者合同.
API 密码
StepFunctionsAPI, (中文(简体) ),StepFunctionsAPIOptions, (中文(简体) ),StateMachineSeed:处理器和固定装置.Execution, (中文(简体) ),ExecutionStatus, (中文(简体) ),HistoryEvent, (中文(简体) ),StateMachine: 持久工作流程状态.createRuntime, (中文(简体) ),StepFunctionsRuntime, (中文(简体) ),StepFunctionsRuntimeOptions:满口口鸟跑.STEP_FUNCTIONS_NAMESPACE, (中文(简体) ),STEP_FUNCTIONS_PRESETS, (中文(简体) ),accessKeyCredential:常数与控制.document, (中文(简体) ),operationIds, (中文(简体) ),supportedOperationIds: 生成了 OpenAPI 元数据.createServer, (中文(简体) ),StepFunctionsServerOptions, (中文(简体) ),DEFAULT_PORT, (中文(简体) ),serveTarget从./server:节点HTTP适配器和CLI集成.
官方预言: AWS 步骤函数 API 引用。 。 。 .