npm package: @some-dev/strapi-plugin-csv-manager
Description: Strapi v5 plugin for CSV import/export with components, relations, media support
Author: Some Dev
Latest version: 1.1.6

# Strapi Plugin CSV Manager

A powerful Strapi v5 plugin for importing and exporting CSV data with full support for components, relations, media, nested fields, and mapping presets.

## ✨ Features

### Import
- 📁 Upload CSV files with configurable delimiter and encoding
- 🔄 Auto-mapping of CSV columns to Strapi fields
- 📍 Support for nested paths (`seo.metaTitle`, `intro.title`, `items.0.name`)
- 🧩 Components support (single and repeatable)
- 🔗 Relations support (oneToOne, oneToMany, manyToMany)
- 🖼️ Media upload from URLs
- 🔀 Upsert by any unique field (id, slug, email, etc.)
- 👁️ Preview before import
- 💾 Save mapping as preset

### Export
- 📊 Select specific fields to export
- 🔗 Configurable relation format (ID, slug, or full JSON)
- 🖼️ Configurable media format (URL, ID, or full JSON)
- 📦 Components exported as JSON
- 🌐 Locale support for i18n content

### Presets
- 💾 Save and reuse mapping configurations
- ⚡ Quick import with predefined settings

## 📦 Installation

```bash
npm install @some-dev/strapi-plugin-csv-manager
# or
yarn add @some-dev/strapi-plugin-csv-manager
```

## ⚙️ Configuration

Add the plugin to your `config/plugins.ts` (or `config/plugins.js`):

```typescript
export default () => ({
  'csv-manager': {
    enabled: true,
  },
});
```

Then rebuild your Strapi admin panel:

```bash
npm run build
npm run develop
```

## 🚀 Usage

After installation, you'll find **CSV Manager** in the left sidebar of your Strapi admin panel.

### Importing CSV

1. Go to **CSV Manager** → **Import** tab
2. Select the target **Content Type**
3. (Optional) Select a saved **Preset**
4. Upload your **CSV file**
5. Configure CSV options (delimiter, encoding)
6. Map CSV columns to Strapi fields
7. Select **Unique Field** for upsert logic
8. Click **Preview** to verify data
9. Click **Import**

### Exporting CSV

1. Go to **CSV Manager** → **Export** tab
2. Select the **Content Type**
3. Choose fields to export
4. Configure relation/media format
5. Set limit (optional)
6. Click **Export**

### Managing Presets

1. Go to **CSV Manager** → **Presets** tab
2. Create, edit, or delete mapping presets
3. Use presets during import for quick configuration

## 📋 Supported Data Types

| Type | Import Format | Export Format |
|------|---------------|---------------|
| String | Plain text | Plain text |
| Number | `123` or `123.45` | Number |
| Boolean | `true`/`false`, `1`/`0`, `yes`/`no` | `true`/`false` |
| Date | `YYYY-MM-DD`, `DD.MM.YYYY`, `DD/MM/YYYY` | `YYYY-MM-DD` |
| DateTime | ISO 8601 format | ISO 8601 |
| JSON | Valid JSON string | JSON string |
| Array | `value1\|value2\|value3` or JSON array | Pipe-separated or JSON |
| Relation | ID, slug, or JSON | ID, slug, or JSON |
| Media | URL to download | URL or ID |
| Component | JSON object | JSON object |
| Repeatable Component | JSON array or pipe-separated JSON objects | JSON array |

## 📝 CSV Format Examples

### Basic Import

```csv
title;slug;price;is_featured
Product 1;product-1;99.99;true
Product 2;product-2;149.99;false
```

### With Relations

```csv
title;slug;category;tags
Product 1;product-1;electronics;tag1|tag2|tag3
Product 2;product-2;clothing;tag4|tag5
```

### With Nested Fields (Components)

```csv
title;slug;seo.title;seo.description
Product 1;product-1;SEO Title 1;Meta description 1
Product 2;product-2;SEO Title 2;Meta description 2
```

### With Media URLs

```csv
title;slug;image;gallery
Product 1;product-1;https://example.com/img1.jpg;https://example.com/g1.jpg|https://example.com/g2.jpg
```

### With Repeatable Components

```csv
title;advantages
Product 1;[{"title":"Fast","description":"Very fast"},{"title":"Reliable","description":"Always works"}]
```

## 🔧 Advanced Configuration

### Relation Lookup

By default, relations are looked up by `id`. You can configure lookup by other fields:

- `id` - Match by Strapi ID
- `documentId` - Match by document ID
- `slug` - Match by slug field
- `name` - Match by name field
- `title` - Match by title field
- `email` - Match by email field

### Auto-Create Relations

Enable "Auto-create" option to automatically create related entries if they don't exist.

### Upsert Logic

Choose a unique field for upsert:
- If a record with matching value exists → **Update**
- If no match found → **Create**

## 🌐 Internationalization

The plugin supports Strapi's i18n plugin:
- Select locale during import/export
- Content is imported/exported for the specified locale

## 📄 License

MIT License

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## 🐛 Issues

If you find a bug or have a feature request, please open an issue on GitHub.

## 📧 Support

For questions and support, please open an issue on the GitHub repository.