@flatfile/v2-shims

中文文档
1.2.0发布于 2024/05/23ISCTypeScriptESM + CJS近 30 天下载 1.7万

用于从 v2 迁移到平台的帮助工具集

中文使用文档
文档目录3 节
  1. 转换您的配置
  2. 转换您的数据钩
  3. 处理数据 Egress

@ fallowfile/v2-shims (英语)

这个软件包旨在帮助Flatfile Portal 2客户更快地升级到新的平台版本. 您可以利用这个软件包来快速地将当前的设置转换为平台设置. 为了更多地了解新概念和幕后发生的事情,你可以去 平台文件。 。 。 .

转换您的配置

在"门户2"中,配置是一切开始的地方. 包含您的平面文件设置和字段 。 这个 configToBlueprint 方法将使用旧配置并创建 平台蓝图 对于它.

当我们谈论你的平面文件配置 用于Portal 2时,我们谈论的是 被传递的物体,作为第二参数 FlatfileImporter 班级.

const importer = new FlatfileImporter(
  'License_Key',
  {} // This is your config Object
)

您可以在下面看到一些简单的用法片断, 说明转换时这个用法会是什么样子 :

import FlatfileImporter from '@flatfile/adapter'

const importer = new FlatfileImporter('License_Key', {
  type: 'Contacts',
  fields: [
    {
      key: 'name',
      label: 'Name',
      description: 'Contact name',
      validators: [{ validate: 'required' }],
    },
  ],
})
import { configToBlueprint } from '@flatfile/v2-shims'
import { configureSpace } from '@flatfile/plugin-space-configure'

const v2config = {
  type: 'Contacts',
  fields: [
    {
      key: 'name',
      label: 'Name',
      description: 'Contact name',
      validators: [{ validate: 'required' }],
    },
  ],
}

const blueprint = configToBlueprint(v2config)

export default function (listener) {
  listener.use(configureSpace({ workbooks: [blueprint] }))
}

转换您的数据钩

这个 validators 函数执行任何迁移的图案上的 v2 验证符 shims。 它被设计成用于Flatfile平台集成的中相软件. 该函数需要 sheetSlug 作为输入并返回可以用作一个函数 听众 与平发相接.

import { validators } from '@flatfile/v2-shims';

// Define the sheetSlug for the schema you want to apply validators to
const sheetSlug = 'your-sheet-slug';

// Create a FlatfileListener instance
const flatfileListener = ...; // Initialize your FlatfileListener

// Use the validators function to attach validator shims to the listener
flatfileListener.use(validators(sheetSlug));

处理数据 Egress

此函数是一个用于处理Flatfile数据而设计的插件. 它与 Flatfile 收听器一起使用,用于在您的 Flatfile 集成中进行提交动作后处理数据. 它使用一个处理器功能作为输入,它负责处理数据并返回一个可以与Flatfile一起使用的Listers.

import { handleData } from '@flatfile/v2-shims'

// Define your data handling logic in the handler function
const handler = (results) => {
  // Example data handling logic
  console.log('Received Flatfile Results:')
  console.log(results)
}

// Initialize a FlatfileListener (assuming you have the necessary setup)
const flatfileListener = Flatfile.listener({
  // Configure your Flatfile settings here
  apiKey: 'your-api-key',
  // ...
})

// Use the handleData function to attach data handling functionality to the listener
flatfileListener.use(handleData(handler))

// Define event handling logic (e.g., on job:ready event) as needed
flatfileListener.on('job:ready', (event) => {
  // Handle the job:ready event
})

版本与发布记录

@flatfile/v2-shims 共发布 14 个版本,首次发布于 2023/10/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.0latest2024/05/232 年前
1.1.42024/05/022 年前
1.1.22024/02/082 年前
1.1.12024/02/072 年前
1.1.02024/02/072 年前
1.0.12024/01/272 年前

关于 @flatfile/v2-shims 的常见问题

@flatfile/v2-shims 是什么?

用于从 v2 迁移到平台的帮助工具集

如何安装 @flatfile/v2-shims?

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

@flatfile/v2-shims 支持 TypeScript 吗?

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

@flatfile/v2-shims 支持 ESM 还是 CommonJS?

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

@flatfile/v2-shims 可以商用吗?

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

@flatfile/v2-shims 的下载量有多少?

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

@flatfile/v2-shims 还在维护吗?

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