npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@flatfile/v2-shims

v1.2.0

Published

A collection of helpers for migrating from v2 to platform

Downloads

5,076

Readme

@flatfile/v2-shims

This package is designed to help Flatfile Portal 2 customers upgrade quicker to the new Platform version. You can leverage this package to quickly convert your current setup to a Platform setup. To learn more about the new concepts and what's happening behind the scenes, you can go to the Platform documentation.

Convert Your Config

In Portal 2, the configuration was where everything got started. This contained your Flatfile settings and fields. The configToBlueprint method takes in your old configuration and will create a Platform Blueprint for it.

When we talk about your Flatfile config for Portal 2, we are talking about the Object that gets passed in as the 2nd parameter of the FlatfileImporter Class.

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

Below you can see some simple usage snippets of how this will look when converting:

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

Convert Your Data Hooks

The validators function implements v2 validator shims on any migrated schema. It is designed to be used as a middleware for Flatfile Platform integration. The function takes a sheetSlug as input and returns a function that can be used as a Listener with Flatfile.

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));

Handle Data Egress

This function is a plugin designed to handle data from Flatfile. It's used with a Flatfile Listener and is intended for processing data after a submission action in your Flatfile integration. It takes a handler function as input, which is responsible for processing the data and returns a Listener that can be used with Flatfile.

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