@ 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
})