Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

payload-plugin-import-export

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

payload-plugin-import-export

Payload CMS plugin to export and import data from csv and json files

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
179
increased by18.54%
Maintainers
1
Weekly downloads
 
Created
Source

Payload Plugin Import / Export

A plugin for Payload CMS to import and export JSON and CSV files. You can use this to change data for many records e.g. translate content... from collections.

All parsing and transformations are done on the client keeping the load from the server.

Installation

npm i "payload-plugin-import-export"
yarn add "payload-plugin-import-export"
pnpm add "payload-plugin-import-export"
import importExportPlugin  from 'payload-plugin-import-export';
import type { User } from "payload/generated-types";

export const config = buildConfig({
  serverUrl: process.env.PAYLOAD_PUBLIC_SERVER_URL //Required!
  plugins: [
    importExportPlugin({
      enabled: true,
      excludeCollections: ["users"],
      redirectAfterImport: true,
      // import User type from your payload-types.ts
      canImport: (user:User) => user.roles.includes("admin")
    }),
  ]
});

Config

PROPTYPEDEFAULTDESCRIPTION
enabledbooleantrueEnable/disable plugin
excludeCollectionsstring[]undefinedList of collection slugs to not display the buttons
redirectAfterImportbooleantrueRedirect back to collection after import
canImport(user:unknown) => boolean() => trueRestrict access to import. You have access to the user.

How to use

Update data or create new items - and you can download csv or json with the failed items. Items fail usually due to permission issues or that required fields are not set.

Selecting fields

On import and export you can select fields.

Filter and sorting exports

The filters set on the collections will also be used for exporting items.

Access control

This plugin obeys all access control rules, so exports will only include the fields with read access. On import missing permission on field level will not result in an error. The fields will just be ignored.

Localization

If localization is configured imports and export will be done in current selected locale. Caution: If field is not localized the "global" value will be overwritten.

File formats

JSON

When importing / exporting JSON the data will be shaped like via the REST API.

CSV

For CSV exports the data will be "flattened" for any field type which contains nested data (arrays,rows,tabs). e.g.:

[{
  "id": "65e",
  "title": "Foo",
  "array": [
    {
      "title_array": "Bar",
    },
    {
      "title_array": "Baz",
    },
  ],
  "tab": {
      "title_tab": "Boz",
  },
}]

will become

idtitlearray.0.title_arrayarray.1.title_arraytab.title_tab
65eFooBarBazBoz

When importing the data will get "unflattened". Make sure to not change any header names.

License

MIT

Keywords

FAQs

Package last updated on 01 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc