@crvouga/ mockingbird-service-textraft (英语)
本地模拟器。 真正的API合同. 部分 嘲笑鸟。 。 。 .
用于官方SDK v3客户端的 stateful Amazon Textract模拟器. 它模拟同步和同步的文档分析,相接的块图,稳定的平面图,一能和完成通知.
安装
npm install -D @crvouga/mockingbird-service-textract
仅限无害环境管理。 节点22+或Bun 1.2+.
使用量
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()
点 TextractClient.endpoint 时间 server.url 有固定的SigV4证书。 支持的操作有分析文件,开始文件分析,以及GetDocument分析. 块记录保留了 PAGE, LINE, WORD, nube VALUE SET, Table, CELL, 和SelectCition Election 图表字段,包括几何,信心,实体类型,文本,和关系.
控件
GET/POST /__admin/corpora按 S3 桶、密钥和可选版本列出块图或种子.GET /__admin/jobs财务报告和审定财务报表GET /__admin/jobs/:id检查提交的准确工作.POST /__admin/jobs/:id/transition移动任务到SUCCEEDED, (中文(简体) ),PARTIAL_SUCCESS,或FAILED,带有可选statusMessage。 。 。 .- 选择公司固定装置
pageSize以强制决定的页面边界,并可能包含低自信块、错误的关系和警告. - 错误预设为
throttled, (中文(简体) ),throughput_exceeded,以及unavailable。 。 。 .
有通知频道的终端任务通过共享的webhook中枢发布一个SNS相容的Textract状态机构. 共享运行时间还提供重置,时钟,日记,度量衡,断层,和名空间隔离.
API 密码
TextractAPI, (中文(简体) ),TextractAPIOptions, (中文(简体) ),TextractNotification: 处理者和通知合同.TextractBlock, (中文(简体) ),TextractCorpus, (中文(简体) ),TextractJob, (中文(简体) ),TextractJobStatus:固定和持久状态.createRuntime, (中文(简体) ),TextractRuntime, (中文(简体) ),TextractRuntimeOptions:完整的"鸟"跑步时间和"网球"中枢.TEXTRACT_NAMESPACE, (中文(简体) ),TEXTRACT_PRESETS, (中文(简体) ),accessKeyCredential:常数和故障控制.document, (中文(简体) ),operationIds, (中文(简体) ),supportedOperationIds: 生成了 OpenAPI 元数据.createServer, (中文(简体) ),TextractServerOptions, (中文(简体) ),DEFAULT_PORT, (中文(简体) ),serveTarget从./server:节点HTTP适配器和CLI集成.
故意不模拟
OCR、S3访问、IAM评价、适配器、产出交付、生产限制、计费、仪表板、以及文件子集以外的文本格式操作没有模型化.
官方预言: Amazon Textract API 参考文献。 。 。 .