@firecms/data_import_export 3.0.0-alpha.38

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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +87 -0
  3. package/dist/components/DataNewPropertiesMapping.d.ts +15 -0
  4. package/dist/components/ImportFileUpload.d.ts +3 -0
  5. package/dist/components/ImportNewPropertyFieldPreview.d.ts +10 -0
  6. package/dist/components/ImportSaveInProgress.d.ts +9 -0
  7. package/dist/components/index.d.ts +4 -0
  8. package/dist/export_import/ExportCollectionAction.d.ts +10 -0
  9. package/dist/export_import/ImportCollectionAction.d.ts +13 -0
  10. package/dist/export_import/export.d.ts +10 -0
  11. package/dist/hooks/index.d.ts +1 -0
  12. package/dist/hooks/useImportConfig.d.ts +2 -0
  13. package/dist/index.d.ts +5 -0
  14. package/dist/index.es.js +966 -0
  15. package/dist/index.es.js.map +1 -0
  16. package/dist/index.umd.js +3 -0
  17. package/dist/index.umd.js.map +1 -0
  18. package/dist/types/column_mapping.d.ts +22 -0
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/useImportExportPlugin.d.ts +14 -0
  21. package/dist/utils/data.d.ts +11 -0
  22. package/dist/utils/file_to_json.d.ts +11 -0
  23. package/dist/utils/get_import_inference_type.d.ts +2 -0
  24. package/dist/utils/get_properties_mapping.d.ts +3 -0
  25. package/dist/utils/index.d.ts +4 -0
  26. package/package.json +103 -0
  27. package/src/components/DataNewPropertiesMapping.tsx +128 -0
  28. package/src/components/ImportFileUpload.tsx +28 -0
  29. package/src/components/ImportNewPropertyFieldPreview.tsx +67 -0
  30. package/src/components/ImportSaveInProgress.tsx +103 -0
  31. package/src/components/index.ts +4 -0
  32. package/src/export_import/ExportCollectionAction.tsx +243 -0
  33. package/src/export_import/ImportCollectionAction.tsx +419 -0
  34. package/src/export_import/export.ts +198 -0
  35. package/src/hooks/index.ts +1 -0
  36. package/src/hooks/useImportConfig.tsx +28 -0
  37. package/src/index.ts +5 -0
  38. package/src/types/column_mapping.ts +32 -0
  39. package/src/types/index.ts +1 -0
  40. package/src/useImportExportPlugin.tsx +23 -0
  41. package/src/utils/data.ts +210 -0
  42. package/src/utils/file_to_json.ts +83 -0
  43. package/src/utils/get_import_inference_type.ts +27 -0
  44. package/src/utils/get_properties_mapping.ts +60 -0
  45. package/src/utils/index.ts +4 -0
  46. 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) => 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,3 @@
1
+ export declare function ImportFileUpload({ onDataAdded }: {
2
+ onDataAdded: (data: object[]) => void;
3
+ }): 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,9 @@
1
+ import { CMSType, EntityCollection } from "@firecms/core";
2
+ import { ImportConfig } from "../types";
3
+ export declare function ImportSaveInProgress<M extends {
4
+ [Key: string]: CMSType;
5
+ }>({ importConfig, collection, onImportSuccess }: {
6
+ importConfig: ImportConfig;
7
+ collection: EntityCollection<any>;
8
+ onImportSuccess: (collection: EntityCollection<any>) => void;
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export * from "./DataNewPropertiesMapping";
2
+ export * from "./ImportFileUpload";
3
+ export * from "./ImportNewPropertyFieldPreview";
4
+ export * from "./ImportSaveInProgress";
@@ -0,0 +1,10 @@
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
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { CollectionActionsProps, Properties, Property, 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, }: CollectionActionsProps<M, UserType>): import("react/jsx-runtime").JSX.Element | null;
4
+ export declare function PropertySelectEntry({ propertyKey, property, level }: {
5
+ propertyKey: string;
6
+ property: Property;
7
+ level?: number;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ export declare function ImportDataPreview<M extends Record<string, any>>({ importConfig, properties, propertiesOrder }: {
10
+ importConfig: ImportConfig;
11
+ properties: Properties<M>;
12
+ propertiesOrder: Extract<keyof M, string>[];
13
+ }): 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";
@@ -0,0 +1,2 @@
1
+ import { ImportConfig } from "../types";
2
+ export declare const useImportConfig: () => ImportConfig;
@@ -0,0 +1,5 @@
1
+ export * from "./useImportExportPlugin";
2
+ export * from "./components";
3
+ export * from "./types";
4
+ export * from "./utils";
5
+ export * from "./hooks";