@rebasepro/client-firebase 0.0.1-canary.4d4fb3e
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 +4 -0
- package/dist/components/FirebaseLoginView.d.ts +72 -0
- package/dist/components/RebaseFirebaseApp.d.ts +19 -0
- package/dist/components/RebaseFirebaseAppProps.d.ts +144 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/social_icons.d.ts +6 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useAppCheck.d.ts +20 -0
- package/dist/hooks/useFirebaseAuthController.d.ts +15 -0
- package/dist/hooks/useFirebaseRealTimeDBDelegate.d.ts +5 -0
- package/dist/hooks/useFirebaseStorageSource.d.ts +14 -0
- package/dist/hooks/useFirestoreDriver.d.ts +56 -0
- package/dist/hooks/useInitialiseFirebase.d.ts +34 -0
- package/dist/hooks/useRecaptcha.d.ts +8 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +2757 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +2743 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/social_icons.d.ts +6 -0
- package/dist/types/appcheck.d.ts +10 -0
- package/dist/types/auth.d.ts +41 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/text_search.d.ts +39 -0
- package/dist/utils/algolia.d.ts +9 -0
- package/dist/utils/collections_firestore.d.ts +5 -0
- package/dist/utils/database.d.ts +2 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/local_text_search_controller.d.ts +2 -0
- package/dist/utils/pinecone.d.ts +24 -0
- package/dist/utils/rebase_search_controller.d.ts +73 -0
- package/dist/utils/text_search_controller.d.ts +13 -0
- package/package.json +61 -0
- package/src/components/FirebaseLoginView.tsx +703 -0
- package/src/components/RebaseFirebaseApp.tsx +275 -0
- package/src/components/RebaseFirebaseAppProps.tsx +180 -0
- package/src/components/index.ts +3 -0
- package/src/components/social_icons.tsx +135 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useAppCheck.ts +101 -0
- package/src/hooks/useFirebaseAuthController.ts +334 -0
- package/src/hooks/useFirebaseRealTimeDBDelegate.ts +269 -0
- package/src/hooks/useFirebaseStorageSource.ts +208 -0
- package/src/hooks/useFirestoreDriver.ts +778 -0
- package/src/hooks/useInitialiseFirebase.ts +132 -0
- package/src/hooks/useRecaptcha.tsx +28 -0
- package/src/index.ts +4 -0
- package/src/social_icons.tsx +135 -0
- package/src/types/appcheck.ts +11 -0
- package/src/types/auth.tsx +74 -0
- package/src/types/index.ts +3 -0
- package/src/types/text_search.ts +42 -0
- package/src/utils/algolia.ts +27 -0
- package/src/utils/collections_firestore.ts +149 -0
- package/src/utils/database.ts +39 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/local_text_search_controller.ts +143 -0
- package/src/utils/pinecone.ts +75 -0
- package/src/utils/rebase_search_controller.ts +356 -0
- package/src/utils/text_search_controller.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Rebase
|
|
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,72 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { FirebaseApp } from "@firebase/app";
|
|
3
|
+
import { FirebaseAuthController, FirebaseSignInOption, FirebaseSignInProvider } from "../index";
|
|
4
|
+
/**
|
|
5
|
+
* @category Firebase
|
|
6
|
+
*/
|
|
7
|
+
export interface FirebaseLoginViewProps {
|
|
8
|
+
/**
|
|
9
|
+
* Firebase app this login view is accessing
|
|
10
|
+
*/
|
|
11
|
+
firebaseApp: FirebaseApp;
|
|
12
|
+
/**
|
|
13
|
+
* Delegate holding the auth state
|
|
14
|
+
*/
|
|
15
|
+
authController: FirebaseAuthController;
|
|
16
|
+
/**
|
|
17
|
+
* Path to the logo displayed in the login screen
|
|
18
|
+
*/
|
|
19
|
+
logo?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Enable the skip login button
|
|
22
|
+
*/
|
|
23
|
+
allowSkipLogin?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Each of the sign in options that get a custom button
|
|
26
|
+
*/
|
|
27
|
+
signInOptions: Array<FirebaseSignInProvider | FirebaseSignInOption>;
|
|
28
|
+
/**
|
|
29
|
+
* Disable the login buttons
|
|
30
|
+
*/
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Prevent users from creating new users in when the `signInOptions` value
|
|
34
|
+
* is `password`. This does not apply to the rest of login providers.
|
|
35
|
+
*/
|
|
36
|
+
disableSignupScreen?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Prevent users from resetting their password when the `signInOptions` value
|
|
39
|
+
* is `password`. This does not apply to the rest of login providers.
|
|
40
|
+
*/
|
|
41
|
+
disableResetPassword?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Display this component when no user is found a user tries to log in
|
|
44
|
+
* when the `signInOptions` value is `password`.
|
|
45
|
+
*/
|
|
46
|
+
noUserComponent?: ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* Include additional components in the login view, on top of the login buttons.
|
|
49
|
+
*/
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Display this component bellow the sign-in buttons.
|
|
53
|
+
* Useful for adding checkboxes for privacy and terms and conditions.
|
|
54
|
+
* You may want to use it in conjunction with the `disabled` prop.
|
|
55
|
+
*/
|
|
56
|
+
additionalComponent?: ReactNode;
|
|
57
|
+
notAllowedError?: any;
|
|
58
|
+
className?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Use this component to render a login view, that updates
|
|
62
|
+
* the state of the {@link FirebaseAuthController} based on the result
|
|
63
|
+
|
|
64
|
+
* @category Firebase
|
|
65
|
+
*/
|
|
66
|
+
export declare function FirebaseLoginView({ children, allowSkipLogin, logo, signInOptions, firebaseApp, authController, noUserComponent, disableSignupScreen, disableResetPassword, disabled, additionalComponent, notAllowedError, className }: FirebaseLoginViewProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
export declare function LoginButton({ icon, onClick, text, disabled }: {
|
|
68
|
+
icon: React.ReactNode;
|
|
69
|
+
onClick: () => void;
|
|
70
|
+
text: string;
|
|
71
|
+
disabled?: boolean;
|
|
72
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RebaseFirebaseAppProps } from "./RebaseFirebaseAppProps";
|
|
2
|
+
/**
|
|
3
|
+
* This is the default implementation of a Rebase app using the Firebase services
|
|
4
|
+
* as a backend.
|
|
5
|
+
* You can use this component as a full app, by specifying collections and
|
|
6
|
+
* entity collections.
|
|
7
|
+
*
|
|
8
|
+
* This component is in charge of initialising Firebase, with the given
|
|
9
|
+
* configuration object.
|
|
10
|
+
*
|
|
11
|
+
* If you are building a larger app and need finer control, you can use
|
|
12
|
+
* {@link Rebase}, {@link Scaffold}, {@link SideDialogs}
|
|
13
|
+
* and {@link NavigationRoutes} instead.
|
|
14
|
+
*
|
|
15
|
+
* @param props
|
|
16
|
+
|
|
17
|
+
* @category Firebase
|
|
18
|
+
*/
|
|
19
|
+
export declare function RebaseFirebaseApp({ name, logo, logoDark, authenticator, collections, views, adminViews, textSearchControllerBuilder, allowSkipLogin, signInOptions, firebaseConfig, onFirebaseInit, appCheckOptions, dateTimeFormat, locale, basePath, baseCollectionPath, onAnalyticsEvent, propertyConfigs: propertyConfigsProp, plugins, autoOpenDrawer, firestoreIndexesBuilder, components, localTextSearchEnabled, userManagement }: RebaseFirebaseAppProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Authenticator, AnalyticsEvent, AppView, AppViewsBuilder, EntityCollection, EntityCollectionsBuilder, RebasePlugin, Locale, PropertyConfig } from "@rebasepro/types";
|
|
3
|
+
import { UserManagementDelegate } from "@rebasepro/types";
|
|
4
|
+
import { FirebaseApp } from "@firebase/app";
|
|
5
|
+
import { FirebaseLoginViewProps } from "./FirebaseLoginView";
|
|
6
|
+
import { AppCheckOptions, FirebaseSignInOption, FirebaseSignInProvider, FirebaseUserWrapper, FirestoreTextSearchControllerBuilder } from "../types";
|
|
7
|
+
import { FirestoreIndexesBuilder } from "../hooks";
|
|
8
|
+
/**
|
|
9
|
+
* Main entry point that defines the CMS configuration
|
|
10
|
+
* @category Firebase
|
|
11
|
+
*/
|
|
12
|
+
export type RebaseFirebaseAppProps = {
|
|
13
|
+
/**
|
|
14
|
+
* Name of the app, displayed as the main title and in the tab title
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Logo to be displayed in the drawer of the CMS.
|
|
19
|
+
* If not specified, the Rebase logo will be used
|
|
20
|
+
*/
|
|
21
|
+
logo?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Logo used in dark mode. If not specified, `logo` will always be used.
|
|
24
|
+
*/
|
|
25
|
+
logoDark?: string;
|
|
26
|
+
/**
|
|
27
|
+
* List of the mapped collections in the CMS.
|
|
28
|
+
* Each entry relates to a collection in the root database.
|
|
29
|
+
* Each of the navigation entries in this field
|
|
30
|
+
* generates an entry in the main menu.
|
|
31
|
+
*/
|
|
32
|
+
collections?: EntityCollection[] | EntityCollectionsBuilder;
|
|
33
|
+
/**
|
|
34
|
+
* Custom additional views created by the developer, added to the main
|
|
35
|
+
* navigation
|
|
36
|
+
*/
|
|
37
|
+
views?: AppView[] | AppViewsBuilder;
|
|
38
|
+
/**
|
|
39
|
+
* Custom additional views created by the developer, added to the admin
|
|
40
|
+
* navigation
|
|
41
|
+
*/
|
|
42
|
+
adminViews?: AppView[] | AppViewsBuilder;
|
|
43
|
+
/**
|
|
44
|
+
* Record of custom form fields to be used in the CMS.
|
|
45
|
+
* You can use the key to reference the custom field in
|
|
46
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
47
|
+
*/
|
|
48
|
+
propertyConfigs?: PropertyConfig[];
|
|
49
|
+
/**
|
|
50
|
+
* Do the users need to log in to access the CMS.
|
|
51
|
+
* You can specify an Authenticator function to discriminate which users can
|
|
52
|
+
* access the CMS or not.
|
|
53
|
+
* If not specified, authentication is enabled but no user restrictions
|
|
54
|
+
* apply
|
|
55
|
+
*/
|
|
56
|
+
authenticator?: boolean | Authenticator<FirebaseUserWrapper>;
|
|
57
|
+
/**
|
|
58
|
+
* List of sign in options that will be displayed in the login
|
|
59
|
+
* view if `authentication` is enabled. You can pass Firebase providers strings,
|
|
60
|
+
* such as `firebase.auth.GoogleAuthProvider.PROVIDER_ID` or include additional
|
|
61
|
+
* config such as scopes or custom parameters
|
|
62
|
+
* {@link FirebaseSignInOption}
|
|
63
|
+
* Defaults to Google sign in only.
|
|
64
|
+
*/
|
|
65
|
+
signInOptions?: Array<FirebaseSignInProvider | FirebaseSignInOption>;
|
|
66
|
+
/**
|
|
67
|
+
* If authentication is enabled, allow the user to access the content
|
|
68
|
+
* without login.
|
|
69
|
+
*/
|
|
70
|
+
allowSkipLogin?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Firebase configuration of the project. If you afe deploying the app to
|
|
73
|
+
* Firebase hosting, you don't need to specify this value
|
|
74
|
+
*/
|
|
75
|
+
firebaseConfig?: Record<string, unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* Optional callback after Firebase has been initialised. Useful for
|
|
78
|
+
* using the local emulator or retrieving the used configuration.
|
|
79
|
+
* @param config
|
|
80
|
+
*/
|
|
81
|
+
onFirebaseInit?: (config: object, app: FirebaseApp) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Use this to enable Firebase App Check
|
|
84
|
+
*/
|
|
85
|
+
appCheckOptions?: AppCheckOptions;
|
|
86
|
+
/**
|
|
87
|
+
* Format of the dates in the CMS.
|
|
88
|
+
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
89
|
+
*/
|
|
90
|
+
dateTimeFormat?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Locale of the CMS, currently only affecting dates
|
|
93
|
+
*/
|
|
94
|
+
locale?: Locale;
|
|
95
|
+
/**
|
|
96
|
+
* Use this controller to return text search results as document ids, that
|
|
97
|
+
* get then fetched from Firestore.
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
textSearchControllerBuilder?: FirestoreTextSearchControllerBuilder;
|
|
101
|
+
/**
|
|
102
|
+
* Default path under the navigation routes of the CMS will be created
|
|
103
|
+
*/
|
|
104
|
+
basePath?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Default path under the collection routes of the CMS will be created
|
|
107
|
+
*/
|
|
108
|
+
baseCollectionPath?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Callback used to get analytics events from the CMS
|
|
111
|
+
*/
|
|
112
|
+
onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Use plugins to modify the behaviour of the CMS.
|
|
115
|
+
* Currently, in ALPHA, and likely subject to change.
|
|
116
|
+
*/
|
|
117
|
+
plugins?: RebasePlugin[];
|
|
118
|
+
/**
|
|
119
|
+
* Open the drawer on hover. Defaults to `false`
|
|
120
|
+
*/
|
|
121
|
+
autoOpenDrawer?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Use this builder to indicate which indexes are available in your
|
|
124
|
+
* Firestore database. This is used to allow filtering and sorting
|
|
125
|
+
* for multiple fields in the CMS.
|
|
126
|
+
*/
|
|
127
|
+
firestoreIndexesBuilder?: FirestoreIndexesBuilder;
|
|
128
|
+
localTextSearchEnabled?: boolean;
|
|
129
|
+
components?: ComponentsRegistry;
|
|
130
|
+
/**
|
|
131
|
+
* Delegate for user and role management. Provides the admin views if specified.
|
|
132
|
+
*/
|
|
133
|
+
userManagement?: UserManagementDelegate;
|
|
134
|
+
};
|
|
135
|
+
export type ComponentsRegistry = {
|
|
136
|
+
/**
|
|
137
|
+
* Component to be used to render the login view
|
|
138
|
+
*/
|
|
139
|
+
LoginView?: React.ComponentType<FirebaseLoginViewProps>;
|
|
140
|
+
/**
|
|
141
|
+
* Component to be used to render the home page
|
|
142
|
+
*/
|
|
143
|
+
HomePage?: React.ComponentType;
|
|
144
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const googleIcon: (mode: "light" | "dark") => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const appleIcon: (mode: "light" | "dark") => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const githubIcon: (mode: "light" | "dark") => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const facebookIcon: (mode: "light" | "dark") => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const microsoftIcon: (mode: "light" | "dark") => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const twitterIcon: (mode: "light" | "dark") => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./useFirebaseAuthController";
|
|
2
|
+
export * from "./useFirebaseStorageSource";
|
|
3
|
+
export * from "./useInitialiseFirebase";
|
|
4
|
+
export * from "./useAppCheck";
|
|
5
|
+
export * from "./useFirestoreDriver";
|
|
6
|
+
export * from "./useFirebaseRealTimeDBDelegate";
|
|
7
|
+
export * from "./useRecaptcha";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FirebaseApp } from "@firebase/app";
|
|
2
|
+
import { AppCheckOptions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* @group Firebase
|
|
5
|
+
*/
|
|
6
|
+
export interface InitializeAppCheckProps {
|
|
7
|
+
firebaseApp?: FirebaseApp;
|
|
8
|
+
options?: AppCheckOptions;
|
|
9
|
+
}
|
|
10
|
+
export interface InitializeAppCheckResult {
|
|
11
|
+
loading: boolean;
|
|
12
|
+
appCheckVerified?: boolean;
|
|
13
|
+
error?: any;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Function used to initialise Firebase App Check.
|
|
17
|
+
*
|
|
18
|
+
* @group Firebase
|
|
19
|
+
*/
|
|
20
|
+
export declare function useAppCheck({ firebaseApp, options, }: InitializeAppCheckProps): InitializeAppCheckResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FirebaseApp } from "@firebase/app";
|
|
2
|
+
import { FirebaseAuthController, FirebaseSignInOption, FirebaseSignInProvider, FirebaseUserWrapper } from "../types";
|
|
3
|
+
import { Role, User } from "@rebasepro/types";
|
|
4
|
+
export interface FirebaseAuthControllerProps {
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
firebaseApp?: FirebaseApp;
|
|
7
|
+
signInOptions?: Array<FirebaseSignInProvider | FirebaseSignInOption>;
|
|
8
|
+
onSignOut?: () => void;
|
|
9
|
+
defineRolesFor?: (user: User) => Promise<Role[] | undefined> | Role[] | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Use this hook to build an {@link AuthController} based on Firebase Auth
|
|
13
|
+
* @group Firebase
|
|
14
|
+
*/
|
|
15
|
+
export declare const useFirebaseAuthController: <USER extends FirebaseUserWrapper = any, ExtraData = any>({ loading, firebaseApp, signInOptions, onSignOut: onSignOutProp, defineRolesFor }: FirebaseAuthControllerProps) => FirebaseAuthController<USER, ExtraData>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FirebaseApp } from "@firebase/app";
|
|
2
|
+
import { StorageSource } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* @group Firebase
|
|
5
|
+
*/
|
|
6
|
+
export interface FirebaseStorageSourceProps {
|
|
7
|
+
firebaseApp?: FirebaseApp;
|
|
8
|
+
bucketUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Use this hook to build an {@link StorageSource} based on Firebase storage
|
|
12
|
+
* @group Firebase
|
|
13
|
+
*/
|
|
14
|
+
export declare function useFirebaseStorageSource({ firebaseApp, bucketUrl }: FirebaseStorageSourceProps): StorageSource;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DataDriver, EntityCollection, FilterCombination } from "@rebasepro/types";
|
|
2
|
+
import { Firestore } from "@firebase/firestore";
|
|
3
|
+
import { FirebaseApp } from "@firebase/app";
|
|
4
|
+
import { FirestoreTextSearchControllerBuilder } from "../types/text_search";
|
|
5
|
+
/**
|
|
6
|
+
* @group Firebase
|
|
7
|
+
*/
|
|
8
|
+
export interface FirestoreDataDriverProps {
|
|
9
|
+
firebaseApp?: FirebaseApp;
|
|
10
|
+
/**
|
|
11
|
+
* You can use this controller to return a list of ids from a search index, given a
|
|
12
|
+
* `path` and a `searchString`.
|
|
13
|
+
*/
|
|
14
|
+
textSearchControllerBuilder?: FirestoreTextSearchControllerBuilder;
|
|
15
|
+
/**
|
|
16
|
+
* Fallback to local text search if no text search controller is specified,
|
|
17
|
+
* or if the controller does not support the given path.
|
|
18
|
+
*/
|
|
19
|
+
localTextSearchEnabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Use this builder to indicate which indexes are available in your
|
|
22
|
+
* Firestore database. This is used to allow filtering and sorting
|
|
23
|
+
* for multiple fields in the CMS.
|
|
24
|
+
*/
|
|
25
|
+
firestoreIndexesBuilder?: FirestoreIndexesBuilder;
|
|
26
|
+
}
|
|
27
|
+
export type FirestoreIndexesBuilder = (params: {
|
|
28
|
+
path: string;
|
|
29
|
+
collection: EntityCollection<any>;
|
|
30
|
+
}) => FilterCombination<string>[] | undefined;
|
|
31
|
+
export type FirestoreDataDriver = DataDriver & {
|
|
32
|
+
initTextSearch: (props: {
|
|
33
|
+
path: string;
|
|
34
|
+
databaseId?: string;
|
|
35
|
+
collection?: EntityCollection;
|
|
36
|
+
}) => Promise<boolean>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Use this hook to build a {@link DataDriver} based on Firestore
|
|
40
|
+
* @param firebaseApp
|
|
41
|
+
* @param textSearchControllerBuilder
|
|
42
|
+
* @group Firebase
|
|
43
|
+
*/
|
|
44
|
+
export declare function useFirestoreDriver({ firebaseApp, textSearchControllerBuilder, firestoreIndexesBuilder, localTextSearchEnabled }: FirestoreDataDriverProps): FirestoreDataDriver;
|
|
45
|
+
/**
|
|
46
|
+
* Recursive function that converts Firestore data types into CMS or plain
|
|
47
|
+
* JS types.
|
|
48
|
+
* Rebase uses Javascript dates internally instead of Firestore timestamps.
|
|
49
|
+
* This makes it easier to interact with the rest of the libraries and
|
|
50
|
+
* bindings.
|
|
51
|
+
* Also, Firestore references are replaced with {@link EntityReference}
|
|
52
|
+
* @param data
|
|
53
|
+
* @group Firestore
|
|
54
|
+
*/
|
|
55
|
+
export declare function firestoreToCMSModel(data: any): any;
|
|
56
|
+
export declare function cmsToFirestoreModel(data: any, firestore: Firestore, inArray?: boolean): any;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FirebaseApp } from "@firebase/app";
|
|
2
|
+
/**
|
|
3
|
+
* @group Firebase
|
|
4
|
+
*/
|
|
5
|
+
export interface InitialiseFirebaseResult {
|
|
6
|
+
firebaseConfigLoading: boolean;
|
|
7
|
+
firebaseApp?: FirebaseApp;
|
|
8
|
+
configError?: string;
|
|
9
|
+
firebaseConfigError?: Error;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Function used to initialise Firebase, either by using the provided config,
|
|
13
|
+
* or by fetching it by Firebase Hosting, if not specified.
|
|
14
|
+
*
|
|
15
|
+
* It works as a hook that gives you the loading state and the used
|
|
16
|
+
* configuration.
|
|
17
|
+
*
|
|
18
|
+
* You most likely only need to use this if you are developing a custom app. You can also not use this component
|
|
19
|
+
* and initialise Firebase yourself.
|
|
20
|
+
*
|
|
21
|
+
* @param onFirebaseInit
|
|
22
|
+
* @param firebaseConfig
|
|
23
|
+
* @param fromUrl
|
|
24
|
+
* @param name
|
|
25
|
+
* @param authDomain
|
|
26
|
+
* @group Firebase
|
|
27
|
+
*/
|
|
28
|
+
export declare function useInitialiseFirebase({ firebaseConfig, fromUrl, onFirebaseInit, name, authDomain }: {
|
|
29
|
+
firebaseConfig?: Record<string, unknown>;
|
|
30
|
+
fromUrl?: string | undefined;
|
|
31
|
+
onFirebaseInit?: ((config: object, firebaseApp: FirebaseApp) => void) | undefined;
|
|
32
|
+
name?: string;
|
|
33
|
+
authDomain?: string;
|
|
34
|
+
}): InitialiseFirebaseResult;
|
package/dist/index.d.ts
ADDED