# @flatfile/plugin-automap 中文文档

规范地址：https://npmcn.com/package/%40flatfile/plugin-automap/

版本：0\.8\.2
npm 元数据更新时间：2026-04-23T23:54:36.264Z
中文译文更新时间：2026-11-14T22:24:22.264Z
软件包许可：ISC

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

原始 npm 页面：https://www.npmjs.com/package/%40flatfile/plugin-automap
原文对照：https://npmcn.com/package/%40flatfile/plugin-automap/?lang=original
项目主页：https://github.com/FlatFilers/flatfile-plugins#readme
源码仓库：https://github.com/FlatFilers/flatfile-plugins

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

- 包体积（解压后）：114 kB，12 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>= 18
- 运行依赖：2 个
- peer 依赖：@flatfile/api ^1\.9\.19，@flatfile/listener ^1\.1\.0
- 首次发布：2023-06-30T22:28:38.021Z
- 最新版本发布：2025-06-25T22:44:55.903Z
- 近 30 天下载量：4060（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：27（近 12 个月 0 个）

## 中文简介

为无头工作流程提供自定义导入文件的插件 .

## 安装

```sh
npm install @flatfile/plugin-automap
```

也可以使用：`pnpm add @flatfile/plugin-automap`、`yarn add @flatfile/plugin-automap`、`bun add @flatfile/plugin-automap`

## README

这个 `@flatfile/plugin-automap` 插件会听取文件提取任务并作出反应,然后创建一个用于自动化的映射任务. 目前,就业执行计划中的每个领域都必须达到《就业计划》中规定的最低信任水平 `accuracy` 配置道具 .

> 嵌入Flatfile时,该插件应被部署在服务器侧听器中. [学多点](https://flatfile.com/docs/orchestration/listeners#listener-types)

## 参数

#### `accuracy` - 说吧 `'confident' | 'exact'` - (必须)

这个 `accuracy` 参数匹配列或“ 自信”( > 90%匹配) 或“ 准确”( 100%匹配) .

#### `debug` - 说吧 `boolean`

这个 `debug` 参数允许您为开发目的切换或关闭帮助调试消息.

#### `defaultTargetSheet` - 说吧 `'string' | '(fileName: string) => string | Promise'`

这个 `defaultTargetSheet` 参数将精确的表 sattle 或调用函数解决到精确表 sattle 以导入数据.

#### `matchFilename` - 说吧 `RegExp`

这个 `matchFilename` 参数需要一个正则表达式来匹配特定文件来进行自动映射.

#### `onFailure` - 说吧 `(event: FlatfileEvent) => void | Promise<void>`

这个 `onFailure` 参数需要调用功能, 当插件保释时执行 。 回调可以是同步的,也可以是同步的.

#### `targetWorkbook` - 说吧 `string`

这个 `targetWorkbook` 参数指定了目的 Workbook id或名称.

## API 调用

-   `api.files.get`
-   `api.files.update`
-   `api.jobs.create`
-   `api.jobs.execute`
-   `api.jobs.getExecutionPlan`
-   `api.workbooks.list`
-   `api.workbooks.get`

## 使用量

对于自动化工作流程,请使用 `files` 终点 测试时,您通过UI中的文件区域导入并使用 `debug` 配置属性.

**安装**

```bash
npm i @flatfile/plugin-automap
```

**导入**

```ts
import { automap } from "@flatfile/plugin-automap";
```

**监听器**

```ts
listener.use(
  automap({
    accuracy: "confident",
    defaultTargetSheet: "Contact",
    matchFilename: /test.csv$/g,
    onFailure: async (event: FlatfileEvent) => {
      // send an SMS, an email, post to an endpoint, etc.
      console.error(
        `Please visit https://spaces.flatfile.com/space/${event.context.spaceId}/files?mode=import to manually import file.`
      );
    },
  })
);
```

## 常见问题

### @flatfile/plugin-automap 是什么？

为无头工作流程提供自定义导入文件的插件 \.

### 如何安装 @flatfile/plugin-automap？

在项目目录运行 npm install @flatfile/plugin-automap，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@flatfile/api（^1\.9\.19）、@flatfile/listener（^1\.1\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @flatfile/plugin-automap 支持 TypeScript 吗？

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

### @flatfile/plugin-automap 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @flatfile/plugin-automap 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>= 18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @flatfile/plugin-automap 可以商用吗？

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

### @flatfile/plugin-automap 的下载量有多少？

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

### @flatfile/plugin-automap 还在维护吗？

最新版本 0\.8\.2 发布于 2025/06/26（1\.4 年前）；至今共发布 27 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/07/01。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

