# @crvouga/mockingbird-service-step-functions 中文文档

规范地址：https://npmcn.com/package/%40crvouga/mockingbird-service-step-functions/

版本：3\.11\.0
npm 元数据更新时间：2026-11-11T02:43:48.464Z
中文译文更新时间：2026-11-11T10:02:50.006Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40crvouga/mockingbird-service-step-functions
原文对照：https://npmcn.com/package/%40crvouga/mockingbird-service-step-functions/?lang=original
项目主页：https://github.com/crvouga/mockingbird/tree/main/packages/service/step-functions#readme
源码仓库：https://github.com/crvouga/mockingbird

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：4.2 MB，18 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2026-09-23T00:02:50.906Z
- 最新版本发布：2026-11-11T02:43:47.936Z
- 近 30 天下载量：2269（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：37（近 12 个月 37 个）

## 中文简介

国家AWS步骤函数模拟器,包括一权处决、召回、决定性过渡和历史.

## 安装

```sh
npm install @crvouga/mockingbird-service-step-functions
```

也可以使用：`pnpm add @crvouga/mockingbird-service-step-functions`、`yarn add @crvouga/mockingbird-service-step-functions`、`bun add @crvouga/mockingbird-service-step-functions`

## README

# @crvouga/ mockingbird-service-step-函数

> 本地模拟器。 真正的API合同. 部分 [嘲笑鸟](https://github.com/crvouga/mockingbird)。 。 。 .

用于官方SFN SDK v3客户端的状态 AWS Step 函数模拟器. 它模拟了标准执行身份,输入/输出字符串,定点终端过渡,回调符,停止请求,命令历史,发卡,以及不与AWS联系的共享时钟脚本.

## 安装

```bash
npm install -D @crvouga/mockingbird-service-step-functions
```

仅限无害环境管理。 节点22+或Bun 1.2+.

## 使用量

指向 SFN 客户端 `endpoint` 选项。 接受Fixture SigV4证书.

```ts
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 引用](https://docs.aws.amazon.com/step-functions/latest/apireference/Welcome.html)。 。 。 .

## 常见问题

### @crvouga/mockingbird-service-step-functions 是什么？

国家AWS步骤函数模拟器,包括一权处决、召回、决定性过渡和历史\.

### 如何安装 @crvouga/mockingbird-service-step-functions？

在项目目录运行 npm install @crvouga/mockingbird-service-step-functions，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-step-functions，可以用 npx mockingbird-step-functions 直接运行。

### @crvouga/mockingbird-service-step-functions 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @crvouga/mockingbird-service-step-functions 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @crvouga/mockingbird-service-step-functions 可以商用吗？

@crvouga/mockingbird-service-step-functions 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @crvouga/mockingbird-service-step-functions 的下载量有多少？

根据 npm 官方下载统计，@crvouga/mockingbird-service-step-functions 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,269 次，日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @crvouga/mockingbird-service-step-functions 还在维护吗？

最新版本 3\.11\.0 发布于 2026/11/11（今天）；至今共发布 37 个版本，其中过去 12 个月发布了 37 个；首次发布于 2026/09/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

