Skip to content

Commit a57d719

Browse files
committed
Improved plugin readmes
1 parent 65d5aec commit a57d719

File tree

2 files changed

+128
-122
lines changed

2 files changed

+128
-122
lines changed

packages/data_export/README.md

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,86 @@
1-
## FireCMS Data enhancement plugin
1+
I'll enhance the README with more detailed documentation, configuration options, and better examples:
22

3-
This plugin allows you to enhance data in your [FireCMS](https://firecms.co)
4-
project, using ChatGPT.
3+
# FireCMS Data Export Plugin
54

6-
The ChatGPT plugin allows you to use the OpenAI API to generate content using
7-
the latest GPT models. This plugin is able to understand the structure of your
8-
data and generate content that fits your schema.
5+
This plugin enables exporting Firestore collections to CSV or JSON formats directly from your FireCMS interface. It adds an export button to collection views, providing a simple way to back up data or share it with others.
96

10-
<p align="center">
11-
<img src="https://firecms.co/img/data_import.png" width="800px" alt="Data enhancement UI" />
12-
</p>
7+
## Installation
138

14-
In order to be able to use this plugin you need to have a valid subscription.
9+
```bash
10+
npm install @firecms/data_export
11+
# or
12+
yarn add @firecms/data_export
13+
```
1514

16-
You can get a subscription in
17-
the [FireCMS dashboard](https://app.firecms.co/subscriptions).
15+
## Features
1816

19-
You need to specify the Firebase project id you would like to use the plugin
20-
with,
21-
in the website. And that's it!
17+
- Export collection data to CSV or JSON formats
18+
- Configure export permissions based on collection size or custom logic
19+
- Integration with FireCMS analytics events
20+
- Custom UI for unsupported export scenarios
2221

23-
No need to add any subscription key or anything like that.
22+
## Basic Usage
2423

2524
```tsx
2625
import React from "react";
2726
import { FirebaseCMSApp } from "@firecms/core";
28-
import "typeface-rubik";
29-
import "@fontsource/jetbrains-mono";
30-
31-
import { useDataImportPlugin } from "@firecms/data_import_export";
27+
import { useExportPlugin } from "@firecms/data_export";
3228

33-
// TODO: Replace with your Firebase config
34-
const firebaseConfig = {
35-
apiKey: "",
36-
authDomain: "",
37-
projectId: "",
38-
storageBucket: "",
39-
messagingSenderId: "",
40-
appId: ""
41-
};
29+
// Basic setup with default options
30+
const exportPlugin = useExportPlugin();
4231

4332
export default function App() {
44-
45-
const dataImportPlugin = useDataImportPlugin({
46-
// Optional callback for defining which collections should be enhanced
47-
getConfigForPath: ({ path }) => {
48-
if (path === "books")
49-
return true;
50-
return false;
51-
}
52-
});
53-
5433
return <FirebaseCMSApp
5534
name={"My Online Shop"}
56-
plugins={[dataImportPlugin]}
35+
plugins={[exportPlugin]}
5736
authentication={myAuthenticator}
58-
collections={[
59-
//...
60-
]}
37+
collections={myCollections}
6138
firebaseConfig={firebaseConfig}
6239
/>;
6340
}
6441
```
6542

66-
## How does it work?
67-
68-
This plugin uses the OpenAI API to generate content using the latest GPT models.
69-
This plugin is able to understand the structure of your data and generate
70-
content that fits your schema.
71-
72-
Some tips in order to get the best results:
73-
74-
- Make sure you select the **right data** type for your fields.
75-
- The **field names** are used to generate the content and are usually enough to
76-
generate good results. If you want to get even better results, you can
77-
**add a description** to your fields. This will help the plugin understand the
78-
context of your data and generate better results.
79-
- The **collection name** is important as well.
80-
- You can establish **relations between fields** and the plugin will pick it up.
81-
e.g. if you have a field called `author` and another field called `book`, the
82-
plugin will understand that the author is related to the book and will
83-
generate content accordingly. You can use this for making **summaries, reviews,
84-
translations, SEO content**, etc.
43+
## Advanced Configuration
44+
45+
You can customize the export behavior with these options:
46+
47+
```tsx
48+
const exportPlugin = useExportPlugin({
49+
// Control when exports are allowed
50+
exportAllowed: ({ collectionEntitiesCount, path, collection }) => {
51+
// Prevent export of large collections
52+
if (collectionEntitiesCount > 5000) return false;
53+
54+
// Only allow export for specific collections
55+
return ["products", "orders"].includes(path);
56+
},
57+
58+
// Custom view when export is not allowed
59+
notAllowedView: <div>Export is not available for this collection</div>,
60+
61+
// Track export events
62+
onAnalyticsEvent: (event, params) => {
63+
console.log("Export event:", event, params);
64+
}
65+
});
66+
```
67+
68+
## Configuration Options
69+
70+
| Option | Type | Description |
71+
|--------|------|-------------|
72+
| `exportAllowed` | `(params: ExportAllowedParams) => boolean` | Function to determine if export is allowed for a collection |
73+
| `notAllowedView` | `React.ReactNode` | Custom component to display when export is not allowed |
74+
| `onAnalyticsEvent` | `(event: string, params?: any) => void` | Callback for tracking export events |
75+
76+
Where `ExportAllowedParams` includes:
77+
- `collectionEntitiesCount`: Number of entities in the collection
78+
- `path`: Path of the collection
79+
- `collection`: Collection configuration object
80+
81+
82+
## Additional Notes
83+
84+
- Exports are performed client-side and may be limited by browser capabilities for very large collections
85+
- CSV exports maintain data types where possible but complex objects may be simplified
86+
- JSON exports preserve the complete data structure

packages/data_import/README.md

Lines changed: 64 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,89 @@
1-
## FireCMS Data enhancement plugin
1+
# FireCMS Data Import Plugin
22

3-
This plugin allows you to enhance data in your [FireCMS](https://firecms.co)
4-
project, using ChatGPT.
3+
This plugin enables importing data into Firestore collections directly from your FireCMS interface. It adds an import button to collection views, providing a simple way to bulk add or update data from CSV or JSON files.
54

6-
The ChatGPT plugin allows you to use the OpenAI API to generate content using
7-
the latest GPT models. This plugin is able to understand the structure of your
8-
data and generate content that fits your schema.
5+
## Installation
96

10-
<p align="center">
11-
<img src="https://firecms.co/img/data_import.png" width="800px" alt="Data enhancement UI" />
12-
</p>
13-
14-
In order to be able to use this plugin you need to have a valid subscription.
7+
```bash
8+
npm install @firecms/data_import
9+
# or
10+
yarn add @firecms/data_import
11+
```
1512

16-
You can get a subscription in
17-
the [FireCMS dashboard](https://app.firecms.co/subscriptions).
13+
## Features
1814

19-
You need to specify the Firebase project id you would like to use the plugin
20-
with,
21-
in the website. And that's it!
15+
- Import data from CSV or JSON formats into Firestore collections
16+
- Validate data before importing to ensure integrity
17+
- Integration with FireCMS analytics events
18+
- Support for bulk data creation and updates
2219

23-
No need to add any subscription key or anything like that.
20+
## Basic Usage
2421

2522
```tsx
2623
import React from "react";
2724
import { FirebaseCMSApp } from "@firecms/core";
28-
import "typeface-rubik";
29-
import "@fontsource/jetbrains-mono";
25+
import { useImportPlugin } from "@firecms/data_import";
3026

31-
import { useDataImportPlugin } from "@firecms/data_import_export";
32-
33-
// TODO: Replace with your Firebase config
34-
const firebaseConfig = {
35-
apiKey: "",
36-
authDomain: "",
37-
projectId: "",
38-
storageBucket: "",
39-
messagingSenderId: "",
40-
appId: ""
41-
};
27+
// Basic setup with default options
28+
const importPlugin = useImportPlugin();
4229

4330
export default function App() {
44-
45-
const dataImportPlugin = useDataImportPlugin({
46-
// Optional callback for defining which collections should be enhanced
47-
getConfigForPath: ({ path }) => {
48-
if (path === "books")
49-
return true;
50-
return false;
51-
}
52-
});
53-
5431
return <FirebaseCMSApp
5532
name={"My Online Shop"}
56-
plugins={[dataImportPlugin]}
33+
plugins={[importPlugin]}
5734
authentication={myAuthenticator}
58-
collections={[
59-
//...
60-
]}
35+
collections={myCollections}
6136
firebaseConfig={firebaseConfig}
6237
/>;
6338
}
6439
```
6540

66-
## How does it work?
41+
## Advanced Configuration
42+
43+
You can customize the import behavior with these options:
44+
45+
```tsx
46+
const importPlugin = useImportPlugin({
47+
// Track import events
48+
onAnalyticsEvent: (event, params) => {
49+
console.log("Import event:", event, params);
50+
// Example events: "import_started", "import_completed", "import_error"
51+
}
52+
});
53+
```
54+
55+
## Configuration Options
56+
57+
| Option | Type | Description |
58+
|--------|------|-------------|
59+
| `onAnalyticsEvent` | `(event: string, params?: any) => void` | Callback for tracking import events |
6760

68-
This plugin uses the OpenAI API to generate content using the latest GPT models.
69-
This plugin is able to understand the structure of your data and generate
70-
content that fits your schema.
61+
## Integration with Export
7162

72-
Some tips in order to get the best results:
63+
For a complete data management solution, use both import and export plugins together:
64+
65+
```tsx
66+
import { useImportPlugin } from "@firecms/data_import";
67+
import { useExportPlugin } from "@firecms/data_export";
68+
69+
// Set up both plugins
70+
const importPlugin = useImportPlugin();
71+
const exportPlugin = useExportPlugin();
72+
73+
// Add both to your FireCMS app
74+
return (
75+
<FireCMS
76+
// ...other props
77+
plugins={[importPlugin, exportPlugin]}
78+
>
79+
{/* ... */}
80+
</FireCMS>
81+
);
82+
```
7383

74-
- Make sure you select the **right data** type for your fields.
75-
- The **field names** are used to generate the content and are usually enough to
76-
generate good results. If you want to get even better results, you can
77-
**add a description** to your fields. This will help the plugin understand the
78-
context of your data and generate better results.
79-
- The **collection name** is important as well.
80-
- You can establish **relations between fields** and the plugin will pick it up.
81-
e.g. if you have a field called `author` and another field called `book`, the
82-
plugin will understand that the author is related to the book and will
83-
generate content accordingly. You can use this for making **summaries, reviews,
84-
translations, SEO content**, etc.
84+
## Additional Notes
8585

86+
- The import functionality validates data against your collection schema before importing
87+
- Complex data types (maps, arrays, references) are supported when importing from JSON
88+
- When importing from CSV, type conversion is performed according to your schema
89+
- Large imports are processed in batches to avoid Firestore limitations

0 commit comments

Comments
 (0)