@crvouga/mockingbird-service-eventbridge

中文文档
1.11.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 2985

Seeded AWS EventBridge rule and ECS target discovery with pagination.

原始使用文档
文档目录7 节
  1. Install
  2. Usage
  3. Controls and state
  4. Verification
  5. Deliberately not modelled
  6. API
  7. Extended AWS operations runtime

@crvouga/mockingbird-service-eventbridge

Local emulators. Real API contracts. Part of Mockingbird.

WIP AWS EventBridge control-plane discovery. Seeded rule and target reads use AWS JSON 1.1; no containers or infrastructure are executed. Follows the official ListRules, ListTargetsByRule and common errors.

Install

bun add @crvouga/mockingbird-service-eventbridge

Usage

import { EventBridgeClient, ListRulesCommand } from "@aws-sdk/client-eventbridge"
import { createServer } from "@crvouga/mockingbird-service-eventbridge/server"

// Test setup: seed a rule, then point the EventBridge client your application already uses
// at the emulator.
const server = await createServer({
  rules: [{ rule: { Name: "nightly", Arn: "arn:aws:events:us-east-1:000000000000:rule/nightly" }, targets: [] }],
})
const eventBridge = new EventBridgeClient({
  endpoint: server.url,
  region: "us-east-1",
  credentials: { accessKeyId: "fixture", secretAccessKey: "fixture" },
})

// Application code, unchanged.
const { Rules } = await eventBridge.send(new ListRulesCommand({ NamePrefix: "night" }))
// Rules[0].Name === "nightly"

await server.close()

CLI: mockingbird-eventbridge serve --port 12128. Set your client factory's endpoint_url or AWS_ENDPOINT_URL_EVENTBRIDGE to that URL. The default instance has no rules. POST / dispatches X-Amz-Target AWSEvents.ListRules and AWSEvents.ListTargetsByRule. NamePrefix filters names; Limit (1–100) and NextToken paginate rules and targets. The terminal page omits NextToken. Missing buses/rules return ResourceNotFoundException (400).

Controls and state

Seed through options.rules ({rule, targets}) or POST /__admin/state/rules with {id: "default:nightly", value: {rule: {Name, Arn}, targets: [{Id, Arn, EcsParameters}]}}. Custom buses must also be seeded in options.buses or /__admin/state/buses ({name}). The default bus always exists. Rule.EventBusName defaults to default. Target objects, including TaskDefinitionArn and awsvpcConfiguration, round-trip without execution. State collections: rules, buses, cursors and initialization marker. Shared /__admin provides health, state, reset, Timeline checkpoints, clock, journal, metrics and UI. Namespaces work via x-mockingbird-namespace, /__admin/ns/name and SigV4 access-key mappings set with PUT /__admin/credentials. No cryptographic signature or IAM evaluation is performed. The journal records metadata, not request bodies or credentials.

Presets: access_denied (403), throttled (AWS 400), rate_limited (explicit HTTP 429 fault), internal_error (500), connection_drop. Standard faults support deterministic latency. No outbound webhooks are emitted.

Verification

Run bun test here for acceptance, JS SDK, self-parity and deliberate divergence tests. Run bun scripts/sdk.ts with uv installed for the separate pinned boto3 1.43.56 drop-in/paginator/error proof (uv obtains that exact package; no AWS credentials are needed). Live safe empty-prefix discovery: bun run parity with EVENTBRIDGE_ACCESS_KEY_ID, EVENTBRIDGE_SECRET_ACCESS_KEY, optional EVENTBRIDGE_REGION. Missing credentials exit 2. The SDK tests prove client compatibility, not live AWS equivalence.

Deliberately not modelled

Rule/target mutation, event delivery, schedules, IAM policy evaluation, cryptographic SigV4 validation, real execution, provisioning and deployment. Seeded resources are fixtures, not AWS accounts. Cursor strings and their one-hour emulator-clock lifetime are deterministic local stand-ins; AWS does not document a fixed lifetime or wire token format. Pagination binds arguments but does not freeze a snapshot of concurrent fixture edits. Result order is fixture insertion order, not a guarantee about AWS ordering. HTTP 429 is a test fault, not the normal EventBridge throttling status.

API

  • EventbridgeAPI, createAwsRuntime, and createAwsServer (server entry): separate extended AWS operations runtime.

Main exports: EventBridgeAPI, EVENTBRIDGE_NAMESPACE, createRuntime, EVENTBRIDGE_PRESETS, document, operationIds, supportedOperationIds. Types: Rule, Target, SeedRule, EventBridgeAPIOptions, EventBridgeRuntimeOptions, EventBridgeRuntime. Server entry: createServer, DEFAULT_PORT, serveTarget; type EventBridgeServerOptions. CLI entry runs the serve command and exports no runtime values.

Extended AWS operations runtime

createAwsRuntime (and createAwsServer from the server entry) exposes the additional LocalStack-oriented event bus, rule, target, event ingestion and tagging operations. It has separate state and does not claim the seeded discovery runtime's pagination behavior. The default createRuntime retains the documented discovery contract and fixtures. Both modes remain WIP. Run bun run parity:localstack for the extended runtime.

版本与发布记录

@crvouga/mockingbird-service-eventbridge 共发布 23 个版本,首次发布于 2026/10/05;过去 12 个月发布了 23 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.11.0latest2026/11/11今天
1.10.92026/11/038 天前
1.10.82026/11/038 天前
1.10.72026/11/038 天前
1.10.62026/11/038 天前
1.10.52026/11/038 天前

关于 @crvouga/mockingbird-service-eventbridge 的常见问题

@crvouga/mockingbird-service-eventbridge 是什么?

Seeded AWS EventBridge rule and ECS target discovery with pagination.

如何安装 @crvouga/mockingbird-service-eventbridge?

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

@crvouga/mockingbird-service-eventbridge 支持 TypeScript 吗?

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

@crvouga/mockingbird-service-eventbridge 支持 ESM 还是 CommonJS?

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

@crvouga/mockingbird-service-eventbridge 可以商用吗?

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

@crvouga/mockingbird-service-eventbridge 的下载量有多少?

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

@crvouga/mockingbird-service-eventbridge 还在维护吗?

最新版本 1.11.0 发布于 2026/11/11(今天);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/10/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。