@flatfile/hooks

中文文档
1.6.0发布于 2024/12/07ISCTypeScriptESM + CJS零依赖近 30 天下载 90.7万

FlatfileRecord

原始使用文档
文档目录4 节
  1. FlatfileRecord
  2. FlatfileRecords
  3. FlatfileSession
  4. Get started

@flatfile/hooks

FlatfileRecord

The FlatfileRecord class represents a record with methods for manipulating and retrieving field values, metadata, and handling record information such as errors, warnings, and comments. Overall, it provides a convenient way to work with individual records of data and perform operations on them.

  • FlatfileRecord has various getter and setter methods for accessing and modifying the record's data.
  • It also provides methods for adding information, comments, errors, and warnings to the record.
  • The compute, computeIfPresent, and validate methods perform computations and validations on specific fields of the record.
  • The toJSON method returns a JSON representation of the record with associated information.

FlatfileRecords

The FlatfileRecords class represents a collection of FlatfileRecord instances. It takes an array of raw records (IRawRecord) as input and creates an array of FlatfileRecord objects by mapping each raw record to a FlatfileRecord instance. The FlatfileRecords class provides a records property to access the array of records and a toJSON method that converts the collection of records to JSON format by calling the toJSON method on each individual FlatfileRecord.

FlatfileSession

The FlatfileSession class encapsulates an instance of the IPayload interface. It has various getter methods that allow accessing different properties of the payload.

  • workspaceId: Retrieves the workspace ID from the payload.
  • workbookId: Retrieves the workbook ID from the payload.
  • schemaId: Retrieves the schema ID from the payload.
  • schemaSlug: Retrieves the schema slug from the payload.
  • uploads: Retrieves the uploads array from the payload.
  • endUser: Retrieves the endUser object from the payload.
  • rows: Retrieves the rows array from the payload.
  • env: Retrieves the env object from the payload.
  • envSignature: Retrieves the envSignature value from the payload.

By creating an instance of the FlatfileSession class with a payload, you can conveniently access the payload properties using the provided getter methods.

Get started

FlatfileRecord is now folded into the @flatfile/plugin-record-hook and most commonly used there.

版本与发布记录

@flatfile/hooks 共发布 15 个版本,首次发布于 2021/12/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.6.0latest2024/12/071.9 年前
1.5.12024/11/182 年前
1.5.02024/05/232 年前
1.4.02024/04/142 年前
1.3.22023/08/023 年前
1.3.12023/06/153 年前

关于 @flatfile/hooks 的常见问题

@flatfile/hooks 是什么?

FlatfileRecord

如何安装 @flatfile/hooks?

在项目目录运行 npm install @flatfile/hooks,或使用 pnpm add / yarn add / bun add。

@flatfile/hooks 支持 TypeScript 吗?

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

@flatfile/hooks 支持 ESM 还是 CommonJS?

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

@flatfile/hooks 可以商用吗?

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

@flatfile/hooks 的下载量有多少?

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

@flatfile/hooks 还在维护吗?

最新版本 1.6.0 发布于 2024/12/07(1.9 年前);至今共发布 15 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/12/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。