@firecms/data_import_export 3.0.0-3.0.0-beta.4.pre.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/components/DataNewPropertiesMapping.d.ts +15 -0
- package/dist/components/ImportFileUpload.d.ts +3 -0
- package/dist/components/ImportNewPropertyFieldPreview.d.ts +10 -0
- package/dist/components/ImportSaveInProgress.d.ts +8 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/export_import/ExportCollectionAction.d.ts +11 -0
- package/dist/export_import/ImportCollectionAction.d.ts +15 -0
- package/dist/export_import/export.d.ts +10 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useImportConfig.d.ts +2 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +1001 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +3 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/column_mapping.d.ts +22 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/useImportExportPlugin.d.ts +16 -0
- package/dist/utils/data.d.ts +11 -0
- package/dist/utils/file_to_json.d.ts +11 -0
- package/dist/utils/get_import_inference_type.d.ts +2 -0
- package/dist/utils/get_properties_mapping.d.ts +3 -0
- package/dist/utils/index.d.ts +4 -0
- package/package.json +103 -0
- package/src/components/DataNewPropertiesMapping.tsx +128 -0
- package/src/components/ImportFileUpload.tsx +34 -0
- package/src/components/ImportNewPropertyFieldPreview.tsx +55 -0
- package/src/components/ImportSaveInProgress.tsx +122 -0
- package/src/components/index.ts +4 -0
- package/src/export_import/ExportCollectionAction.tsx +252 -0
- package/src/export_import/ImportCollectionAction.tsx +442 -0
- package/src/export_import/export.ts +200 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useImportConfig.tsx +28 -0
- package/src/index.ts +5 -0
- package/src/types/column_mapping.ts +32 -0
- package/src/types/index.ts +1 -0
- package/src/useImportExportPlugin.tsx +25 -0
- package/src/utils/data.ts +223 -0
- package/src/utils/file_to_json.ts +88 -0
- package/src/utils/get_import_inference_type.ts +27 -0
- package/src/utils/get_properties_mapping.ts +59 -0
- package/src/utils/index.ts +4 -0
- package/src/vite-env.d.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 FireCMS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
## FireCMS Data enhancement plugin
|
|
2
|
+
|
|
3
|
+
This plugin allows you to enhance data in your [FireCMS](https://firecms.co)
|
|
4
|
+
project, using ChatGPT.
|
|
5
|
+
|
|
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.
|
|
9
|
+
|
|
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.
|
|
15
|
+
|
|
16
|
+
You can get a subscription in
|
|
17
|
+
the [FireCMS dashboard](https://app.firecms.co/subscriptions).
|
|
18
|
+
|
|
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!
|
|
22
|
+
|
|
23
|
+
No need to add any subscription key or anything like that.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import React from "react";
|
|
27
|
+
import { FirebaseCMSApp } from "@firecms/core";
|
|
28
|
+
import "typeface-rubik";
|
|
29
|
+
import "@fontsource/ibm-plex-mono";
|
|
30
|
+
|
|
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
|
+
};
|
|
42
|
+
|
|
43
|
+
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
|
+
|
|
54
|
+
return <FirebaseCMSApp
|
|
55
|
+
name={"My Online Shop"}
|
|
56
|
+
plugins={[dataImportPlugin]}
|
|
57
|
+
authentication={myAuthenticator}
|
|
58
|
+
collections={[
|
|
59
|
+
//...
|
|
60
|
+
]}
|
|
61
|
+
firebaseConfig={firebaseConfig}
|
|
62
|
+
/>;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
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.
|
|
85
|
+
|
|
86
|
+
## Current limitations
|
|
87
|
+
- Markdown fields work but do not get the enhanced content highlighted.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Property } from "@firecms/core";
|
|
2
|
+
export interface DataPropertyMappingProps {
|
|
3
|
+
idColumn?: string;
|
|
4
|
+
headersMapping: Record<string, string | null>;
|
|
5
|
+
originProperties: Record<string, Property>;
|
|
6
|
+
destinationProperties: Record<string, Property>;
|
|
7
|
+
onIdPropertyChanged: (value: string | null) => void;
|
|
8
|
+
buildPropertyView?: (props: {
|
|
9
|
+
isIdColumn: boolean;
|
|
10
|
+
property: Property | null;
|
|
11
|
+
propertyKey: string | null;
|
|
12
|
+
importKey: string;
|
|
13
|
+
}) => React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function DataNewPropertiesMapping({ idColumn, headersMapping, originProperties, destinationProperties, onIdPropertyChanged, buildPropertyView, }: DataPropertyMappingProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Property } from "@firecms/core";
|
|
3
|
+
export declare function ImportNewPropertyFieldPreview({ propertyKey, property, onEditClick, includeName, onPropertyNameChanged, propertyTypeView }: {
|
|
4
|
+
propertyKey: string | null;
|
|
5
|
+
property: Property | null;
|
|
6
|
+
includeName?: boolean;
|
|
7
|
+
onEditClick?: () => void;
|
|
8
|
+
onPropertyNameChanged?: (propertyKey: string, value: string) => void;
|
|
9
|
+
propertyTypeView?: React.ReactNode;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EntityCollection } from "@firecms/core";
|
|
2
|
+
import { ImportConfig } from "../types";
|
|
3
|
+
export declare function ImportSaveInProgress<C extends EntityCollection>({ path, importConfig, collection, onImportSuccess }: {
|
|
4
|
+
path: string;
|
|
5
|
+
importConfig: ImportConfig;
|
|
6
|
+
collection: C;
|
|
7
|
+
onImportSuccess: (collection: C) => void;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CollectionActionsProps, EntityCollection, User } from "@firecms/core";
|
|
3
|
+
export declare function ExportCollectionAction<M extends Record<string, any>, UserType extends User>({ collection: inputCollection, path: inputPath, collectionEntitiesCount, exportAllowed, notAllowedView }: CollectionActionsProps<M, UserType, EntityCollection<M, any>> & {
|
|
4
|
+
exportAllowed?: (props: {
|
|
5
|
+
collectionEntitiesCount: number;
|
|
6
|
+
path: string;
|
|
7
|
+
collection: EntityCollection;
|
|
8
|
+
}) => boolean;
|
|
9
|
+
notAllowedView?: React.ReactNode;
|
|
10
|
+
onAnalyticsEvent?: (event: string, params?: any) => void;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CollectionActionsProps, Property, ResolvedProperties, User } from "@firecms/core";
|
|
2
|
+
import { ImportConfig } from "../types";
|
|
3
|
+
export declare function ImportCollectionAction<M extends Record<string, any>, UserType extends User>({ collection, path, collectionEntitiesCount, onAnalyticsEvent }: CollectionActionsProps<M, UserType> & {
|
|
4
|
+
onAnalyticsEvent?: (event: string, params?: any) => void;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare function PropertySelectEntry({ propertyKey, property, level }: {
|
|
7
|
+
propertyKey: string;
|
|
8
|
+
property: Property;
|
|
9
|
+
level?: number;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function ImportDataPreview<M extends Record<string, any>>({ importConfig, properties, propertiesOrder }: {
|
|
12
|
+
importConfig: ImportConfig;
|
|
13
|
+
properties: ResolvedProperties<M>;
|
|
14
|
+
propertiesOrder: Extract<keyof M, string>[];
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Entity, ResolvedEntityCollection, ResolvedProperties } from "@firecms/core";
|
|
2
|
+
interface Header {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function downloadExport<M extends Record<string, any>>(data: Entity<M>[], additionalData: Record<string, any>[] | undefined, collection: ResolvedEntityCollection<M>, flattenArrays: boolean, additionalHeaders: string[] | undefined, exportType: "csv" | "json", dateExportType: "timestamp" | "string"): void;
|
|
7
|
+
export declare function getCSVExportableData(data: Entity<any>[], additionalData: Record<string, any>[] | undefined, properties: ResolvedProperties, headers: Header[], dateExportType: "timestamp" | "string"): any[][];
|
|
8
|
+
export declare function getJsonExportableData(data: Entity<any>[], additionalData: Record<string, any>[] | undefined, properties: ResolvedProperties, dateExportType: "timestamp" | "string"): any[];
|
|
9
|
+
export declare function downloadBlob(content: BlobPart[], filename: string, contentType: string): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useImportConfig";
|