@crvouga/mockingbird-service-vibe

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

Vibe OAuth and asynchronous campaign-spend report emulator.

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Contract
  4. Test controls
  5. Deliberately not modelled
  6. API

@crvouga/mockingbird-service-vibe

Local emulators. Real API contracts. Part of Mockingbird.

WIP Vibe revision 2026-06-01 OAuth and asynchronous campaign-spend reports.

Install

bun add @crvouga/mockingbird-service-vibe

Usage

import { DEFAULT_ADVERTISER } from "@crvouga/mockingbird-service-vibe"
import { createServer } from "@crvouga/mockingbird-service-vibe/server"

// Test setup: a local Vibe with one spend row for the default client's advertiser.
const advertiserId = DEFAULT_ADVERTISER
const server = await createServer({ rows: [{
  advertiser_id: advertiserId, impression_date: "2026-01-01", spend: "12.50",
}] })
const baseUrl = server.url

// Application code: the report request it sends to Vibe.
const response = await fetch(`${baseUrl}/reports`, {
  method: "POST",
  headers: { authorization: "Bearer mock_vibe_token", "x-vibe-revision": "2026-06-01", "content-type": "application/json" },
  body: JSON.stringify({ start_date: "2026-01-01", end_date: "2026-01-02", advertiser_ids: [advertiserId], dimensions: ["impression_date"], metrics: ["spend"] }),
})
const report = await response.json()
console.log(report.id, report.status)

await server.close()

Run mockingbird-vibe serve --port 12128, then inject http://localhost:12128 as the consumer's API origin. Downloads point at this same origin. There is no universal vendor environment variable for that override; keep the consumer's production HTTPS policy intact.

Contract

  • POST /oauth2/token: form-encoded client_credentials with HTTP Basic credentials. Default synthetic client is mock_client / mock_client_secret. Optional scope must be a subset of the client's scopes. Response includes bearer token, scope and expires_in. This endpoint does not require X-Vibe-Revision; failures use the standard OAuth envelope.
  • POST /reports: JSON report request, Bearer token and pinned revision. Returns 201 with UUID/status/created_at. Advertisers must belong to the client. Windows are start-inclusive, end-exclusive, positive and at most 45 days. JSON/DAY fixtures only.
  • GET /reports/{report_id}: only the owning client can poll. Default clock progression: CREATED initially, PROCESSING at one second, READY at two seconds. READY includes the local download_url and generation/expiration timestamps; FAILED includes failure_reason.
  • Internal /__admin/blobs/{id}?token=…: local stand-in for the vendor's pre-signed download. Returns a JSON array of synthetic rows, preserves numeric-as-string metrics and nulls, and expires 24 hours after generation. Capability values are deterministic test stand-ins, not production signing. No browser tracking or real campaign data is fetched.

Seed clients, pre-aggregated rows and settings through constructor options or shared /__admin/state. Reports retain fixture rows at creation time and select requested columns. Fixture dates are already in the requested reporting timezone; no attribution or aggregation engine is implied. Default bearer mock_vibe_token is valid for one hour from initial seeding.

Test controls

Collections: clients, tokens, rows, reports, settings. Settings expose processingMs, readyMs and tokenTtlSeconds. Reports expose readyAt (null means stuck), failure and missingArtifact. Use the shared clock to advance lifecycle/expiry, and shared Timeline/reset/state/journal APIs. Reset restores constructor fixtures. Journals contain metadata, never report rows or credentials. Namespaces work by header, mapped bearer token or /__admin/ns/{name} path. Download links retain namespace and custom adminPrefix routing.

Presets: rate_limited (scripted 429/Retry-After), server_error (500), connection_drop, report_failed and report_stuck. Shared fault rules also provide deterministic latency. These are test controls; they do not model a real sliding-window quota or actual processing SLA. No webhooks are needed for this subset.

Acceptance tests exercise all four issue #271 behaviors, OAuth expiry/scope, local artifact expiry/missing files, namespaces/reset/redacted journals and served HTTP. Property tests run every parity-enabled operation and detect divergence. bun scripts/parity.ts uses VIBE_ACCESS_TOKEN and VIBE_REPORT_ID for a read-only existing-report envelope check; live authenticated parity has not run. bun scripts/parity.ts --unauthenticated compares missing/ invalid synthetic-token errors against the real endpoint. This probe passed and confirms token_invalid plus WWW-Authenticate: Bearer, differing from the documentation's invalid_token example. The rest of the contract follows the published OpenAPI reference.

Deliberately not modelled

Ad purchases, campaign mutation, attribution inference, production JWT signing, OAuth browser consent/refresh, CSV or non-DAY reports, metric aggregation, timezone conversion, and report filter expressions. Seed already-aggregated rows for the requested dimensions. The emulator rejects CSV/non-DAY requests even though the vendor supports them; those are outside this initial consumer subset. It does not claim full vendor API or live rate-limit parity.

API

  • VibeAPI: FetchAPI, reset and state collections.
  • createRuntime: shared admin/namespace/clock/fault surface.
  • VIBE_NAMESPACE, VIBE_PRESETS, DEFAULT_ADVERTISER: service constants.
  • document, operationIds, supportedOperationIds: generated contract metadata.
  • createServer, serveTarget, DEFAULT_PORT from ./server: Node HTTP/CLI entry points.

Public types: Client, Token, Row, Report, Settings, VibeAPIOptions, OperationId, SupportedOperationId; server types are VibeServerOptions and VibeServer.

版本与发布记录

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

版本发布日期距今
1.12.0latest2026/11/131 天前
1.11.12026/11/122 天前
1.11.02026/11/122 天前
1.10.02026/11/113 天前
1.9.42026/11/0311 天前
1.9.32026/11/0311 天前

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

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

Vibe OAuth and asynchronous campaign-spend report emulator.

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

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

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

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

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

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

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

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

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

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

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

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