@crvouga/mockingbird-service-textract

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

Stateful Amazon Textract emulator with document analysis jobs, graph blocks, pagination, and deterministic notifications.

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

@crvouga/mockingbird-service-textract

Local emulators. Real API contracts. Part of Mockingbird.

Stateful Amazon Textract emulator for the official SDK v3 client. It models synchronous and asynchronous document analysis, connected block graphs, stable pagination, idempotency, and completion notifications.

Install

npm install -D @crvouga/mockingbird-service-textract

ESM only. Node 22+ or Bun 1.2+.

Usage

import { AnalyzeDocumentCommand, TextractClient } from "@aws-sdk/client-textract"
import { createServer } from "@crvouga/mockingbird-service-textract/server"

// Test setup: start the emulator with a seeded document and point the SDK's endpoint at it.
const server = await createServer({
  corpora: [
    {
      bucket: "fixtures",
      name: "invoice.pdf",
      pages: 1,
      blocks: [{ id: "line-1", blockType: "LINE", page: 1, text: "Total due 42.00", confidence: 99 }],
    },
  ],
})
const textract = new TextractClient({
  endpoint: server.url,
  region: "us-east-1",
  credentials: { accessKeyId: "fixture", secretAccessKey: "fixture" },
})

// Application code: the Textract SDK calls it already makes.
const analysis = await textract.send(
  new AnalyzeDocumentCommand({
    Document: { S3Object: { Bucket: "fixtures", Name: "invoice.pdf" } },
    FeatureTypes: ["FORMS"],
  }),
)
console.log(analysis.Blocks?.map((block) => block.Text)) // [ "Total due 42.00" ]

await server.close()

Point TextractClient.endpoint at server.url with fixture SigV4 credentials. Supported operations are AnalyzeDocument, StartDocumentAnalysis, and GetDocumentAnalysis. Block records retain PAGE, LINE, WORD, KEY_VALUE_SET, TABLE, CELL, and SELECTION_ELEMENT graph fields including Geometry, Confidence, EntityTypes, Text, and Relationships.

Controls

  • GET/POST /__admin/corpora lists or seeds a block graph by S3 bucket, key, and optional version.
  • GET /__admin/jobs and GET /__admin/jobs/:id inspect exact submitted jobs.
  • POST /__admin/jobs/:id/transition moves a job to SUCCEEDED, PARTIAL_SUCCESS, or FAILED, with an optional statusMessage.
  • Corpus fixtures choose pageSize to force deterministic page boundaries and can contain low-confidence blocks, malformed relationships, and warnings.
  • Fault presets are throttled, throughput_exceeded, and unavailable.

Terminal jobs with a NotificationChannel publish an SNS-compatible Textract status body through the shared webhook hub. The shared runtime also provides reset, clock, journal, metrics, faults, and namespace isolation.

API

  • TextractAPI, TextractAPIOptions, TextractNotification: handler and notification contract.
  • TextractBlock, TextractCorpus, TextractJob, TextractJobStatus: fixtures and durable state.
  • createRuntime, TextractRuntime, TextractRuntimeOptions: full Mockingbird runtime and webhook hub.
  • TEXTRACT_NAMESPACE, TEXTRACT_PRESETS, accessKeyCredential: constants and fault controls.
  • document, operationIds, supportedOperationIds: generated OpenAPI metadata.
  • createServer, TextractServerOptions, DEFAULT_PORT, serveTarget from ./server: Node HTTP adapter and CLI integration.

Deliberately not modelled

OCR, S3 access, IAM evaluation, adapters, output delivery, production limits, billing, dashboards, and Textract operations outside the documented subset are not modelled.

Official oracle: Amazon Textract API Reference.

版本与发布记录

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

版本发布日期距今
3.11.0latest2026/11/11今天
3.10.52026/11/038 天前
3.10.42026/11/038 天前
3.10.32026/11/038 天前
3.10.22026/11/038 天前
3.10.12026/11/038 天前

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

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

Stateful Amazon Textract emulator with document analysis jobs, graph blocks, pagination, and deterministic notifications.

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

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

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

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

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

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

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

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

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

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

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

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