@rebasepro/client-firebase 0.0.1-canary.09e5ec5

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/components/FirebaseLoginView.d.ts +72 -0
  4. package/dist/components/RebaseFirebaseApp.d.ts +19 -0
  5. package/dist/components/RebaseFirebaseAppProps.d.ts +144 -0
  6. package/dist/components/index.d.ts +3 -0
  7. package/dist/components/social_icons.d.ts +6 -0
  8. package/dist/hooks/index.d.ts +8 -0
  9. package/dist/hooks/useAppCheck.d.ts +20 -0
  10. package/dist/hooks/useBuildUserManagement.d.ts +46 -0
  11. package/dist/hooks/useFirebaseAuthController.d.ts +15 -0
  12. package/dist/hooks/useFirebaseRealTimeDBDelegate.d.ts +5 -0
  13. package/dist/hooks/useFirebaseStorageSource.d.ts +14 -0
  14. package/dist/hooks/useFirestoreDriver.d.ts +56 -0
  15. package/dist/hooks/useInitialiseFirebase.d.ts +34 -0
  16. package/dist/hooks/useRecaptcha.d.ts +8 -0
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.es.js +3060 -0
  19. package/dist/index.es.js.map +1 -0
  20. package/dist/index.umd.js +3043 -0
  21. package/dist/index.umd.js.map +1 -0
  22. package/dist/social_icons.d.ts +6 -0
  23. package/dist/types/appcheck.d.ts +10 -0
  24. package/dist/types/auth.d.ts +41 -0
  25. package/dist/types/index.d.ts +3 -0
  26. package/dist/types/text_search.d.ts +39 -0
  27. package/dist/utils/algolia.d.ts +9 -0
  28. package/dist/utils/collections_firestore.d.ts +5 -0
  29. package/dist/utils/database.d.ts +2 -0
  30. package/dist/utils/index.d.ts +7 -0
  31. package/dist/utils/local_text_search_controller.d.ts +2 -0
  32. package/dist/utils/pinecone.d.ts +24 -0
  33. package/dist/utils/rebase_search_controller.d.ts +73 -0
  34. package/dist/utils/text_search_controller.d.ts +13 -0
  35. package/package.json +63 -0
  36. package/src/components/FirebaseLoginView.tsx +693 -0
  37. package/src/components/RebaseFirebaseApp.tsx +291 -0
  38. package/src/components/RebaseFirebaseAppProps.tsx +180 -0
  39. package/src/components/index.ts +3 -0
  40. package/src/components/social_icons.tsx +135 -0
  41. package/src/hooks/index.ts +8 -0
  42. package/src/hooks/useAppCheck.ts +101 -0
  43. package/src/hooks/useBuildUserManagement.tsx +374 -0
  44. package/src/hooks/useFirebaseAuthController.ts +334 -0
  45. package/src/hooks/useFirebaseRealTimeDBDelegate.ts +269 -0
  46. package/src/hooks/useFirebaseStorageSource.ts +207 -0
  47. package/src/hooks/useFirestoreDriver.ts +784 -0
  48. package/src/hooks/useInitialiseFirebase.ts +132 -0
  49. package/src/hooks/useRecaptcha.tsx +28 -0
  50. package/src/index.ts +4 -0
  51. package/src/social_icons.tsx +135 -0
  52. package/src/types/appcheck.ts +11 -0
  53. package/src/types/auth.tsx +74 -0
  54. package/src/types/index.ts +3 -0
  55. package/src/types/text_search.ts +42 -0
  56. package/src/utils/algolia.ts +27 -0
  57. package/src/utils/collections_firestore.ts +148 -0
  58. package/src/utils/database.ts +39 -0
  59. package/src/utils/index.ts +7 -0
  60. package/src/utils/local_text_search_controller.ts +143 -0
  61. package/src/utils/pinecone.ts +75 -0
  62. package/src/utils/rebase_search_controller.ts +357 -0
  63. package/src/utils/text_search_controller.ts +34 -0
@@ -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,10 @@
1
+ import { CustomProvider, ReCaptchaEnterpriseProvider, ReCaptchaV3Provider } from "@firebase/app-check";
2
+ /**
3
+ * @group Firebase
4
+ */
5
+ export interface AppCheckOptions {
6
+ provider: CustomProvider | ReCaptchaV3Provider | ReCaptchaEnterpriseProvider;
7
+ isTokenAutoRefreshEnabled?: boolean;
8
+ debugToken?: string;
9
+ forceRefresh?: boolean;
10
+ }
@@ -0,0 +1,41 @@
1
+ import { ApplicationVerifier, ConfirmationResult, User as FirebaseUser } from "@firebase/auth";
2
+ import { AuthController, Role, User } from "@rebasepro/types";
3
+ /**
4
+ * @group Firebase
5
+ */
6
+ export type FirebaseSignInProvider = "password" | "phone" | "anonymous" | "google.com" | "facebook.com" | "github.com" | "twitter.com" | "microsoft.com" | "apple.com";
7
+ /**
8
+ * @group Firebase
9
+ */
10
+ export type FirebaseSignInOption = {
11
+ provider: FirebaseSignInProvider;
12
+ scopes?: string[];
13
+ customParameters?: Record<string, string>;
14
+ };
15
+ export type FirebaseUserWrapper = User & FirebaseUser & {
16
+ firebaseUser: FirebaseUser | null;
17
+ };
18
+ /**
19
+ * @group Firebase
20
+ */
21
+ export type FirebaseAuthController<USER extends User = FirebaseUserWrapper, ExtraData = any> = AuthController<USER, ExtraData> & {
22
+ confirmationResult?: ConfirmationResult;
23
+ googleLogin: () => void;
24
+ anonymousLogin: () => void;
25
+ appleLogin: () => void;
26
+ facebookLogin: () => void;
27
+ githubLogin: () => void;
28
+ microsoftLogin: () => void;
29
+ twitterLogin: () => void;
30
+ emailPasswordLogin: (email: string, password: string) => void;
31
+ fetchSignInMethodsForEmail: (email: string) => Promise<string[]>;
32
+ createUserWithEmailAndPassword: (email: string, password: string) => void;
33
+ sendPasswordResetEmail: (email: string) => Promise<void>;
34
+ phoneLogin: (phone: string, applicationVerifier: ApplicationVerifier) => void;
35
+ /**
36
+ * Skip login
37
+ */
38
+ skipLogin: () => void;
39
+ setUser: (user: USER | null) => void;
40
+ setUserRoles: (roles: Role[]) => void;
41
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./auth";
2
+ export * from "./text_search";
3
+ export * from "./appcheck";
@@ -0,0 +1,39 @@
1
+ import { User as FirebaseUser } from "@firebase/auth";
2
+ import { FirebaseApp } from "@firebase/app";
3
+ import { EntityCollection } from "@rebasepro/types";
4
+ export type FirestoreTextSearchControllerBuilder = (props: {
5
+ firebaseApp: FirebaseApp;
6
+ }) => FirestoreTextSearchController;
7
+ /**
8
+ * Use this controller to return a list of ids from a search index, given a
9
+ * `path` and a `searchString`.
10
+ * Firestore does not support text search directly, so we need to rely on an external
11
+ * index, such as Algolia.
12
+ * Note that you will get text search requests for collections that have the
13
+ * `textSearchEnabled` flag set to `true`.
14
+ * @see performAlgoliaTextSearch
15
+ * @group Firebase
16
+ */
17
+ export type FirestoreTextSearchController = {
18
+ /**
19
+ * This method is called when a search delegate is ready to be used.
20
+ * Return true if this path can be handled by this controller.
21
+ * @param props
22
+ */
23
+ init: (props: {
24
+ path: string;
25
+ databaseId?: string;
26
+ collection?: EntityCollection;
27
+ }) => Promise<boolean>;
28
+ /**
29
+ * Do the search and return a list of ids.
30
+ * @param props
31
+ */
32
+ search: (props: {
33
+ searchString: string;
34
+ path: string;
35
+ currentUser?: FirebaseUser;
36
+ databaseId?: string;
37
+ collection?: EntityCollection;
38
+ }) => (Promise<readonly string[] | undefined>);
39
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Utility function to perform a text search in an algolia index,
3
+ * returning the ids of the entities.
4
+ * @param client The algolia client
5
+ * @param indexName
6
+ * @param query
7
+ * @group Firebase
8
+ */
9
+ export declare function performAlgoliaTextSearch(client: any, indexName: string, query: string): Promise<readonly string[]>;
@@ -0,0 +1,5 @@
1
+ import { DocumentSnapshot } from "@firebase/firestore";
2
+ import { EntityCollection } from "@rebasepro/types";
3
+ export declare function buildCollectionId(idOrPath: string, parentCollectionIds?: string[]): string;
4
+ export declare const docsToCollectionTree: (docs: DocumentSnapshot[]) => EntityCollection[];
5
+ export declare const docToCollection: (doc: DocumentSnapshot) => EntityCollection;
@@ -0,0 +1,2 @@
1
+ import { FirebaseApp } from "@firebase/app";
2
+ export declare function getFirestoreDataInPath(firebaseApp: FirebaseApp, path: string, parentPaths: string[], limit: number): Promise<object[]>;
@@ -0,0 +1,7 @@
1
+ export * from "./collections_firestore";
2
+ export * from "./database";
3
+ export * from "./algolia";
4
+ export * from "./pinecone";
5
+ export * from "./text_search_controller";
6
+ export * from "./local_text_search_controller";
7
+ export * from "./rebase_search_controller";
@@ -0,0 +1,2 @@
1
+ import { FirestoreTextSearchControllerBuilder } from "../types";
2
+ export declare const localSearchControllerBuilder: FirestoreTextSearchControllerBuilder;
@@ -0,0 +1,24 @@
1
+ import { User as FirebaseUser } from "@firebase/auth";
2
+ import { FirestoreTextSearchControllerBuilder } from "../types";
3
+ /**
4
+ * Utility function to perform a text search in an algolia index,
5
+ * returning the ids of the entities.
6
+ * @param index
7
+ * @param query
8
+ * @group Firebase
9
+ */
10
+ export declare function performPineconeTextSearch({ host, firebaseToken, projectId, collectionPath, query }: {
11
+ host?: string;
12
+ firebaseToken: string;
13
+ collectionPath: string;
14
+ projectId: string;
15
+ query: string;
16
+ }): Promise<readonly string[]>;
17
+ export declare function buildPineconeSearchController({ isPathSupported, search }: {
18
+ isPathSupported: (path: string) => boolean;
19
+ search: (props: {
20
+ searchString: string;
21
+ path: string;
22
+ currentUser?: FirebaseUser;
23
+ }) => Promise<readonly string[] | undefined>;
24
+ }): FirestoreTextSearchControllerBuilder;
@@ -0,0 +1,73 @@
1
+ import { FirestoreTextSearchControllerBuilder } from "../types";
2
+ /**
3
+ * Options for building the Rebase Search Controller
4
+ */
5
+ export interface RebaseSearchControllerOptions {
6
+ /**
7
+ * The Firebase region where the extension is deployed.
8
+ */
9
+ region: string;
10
+ /**
11
+ * The extension instance ID. Defaults to "rebase-search".
12
+ * Use this if you installed the extension with a custom instance ID.
13
+ */
14
+ extensionInstanceId?: string;
15
+ /**
16
+ * Custom Typesense configuration. If provided, skips fetching from extension.
17
+ * Use this if you want to connect to your own Typesense instance.
18
+ */
19
+ customConfig?: {
20
+ host: string;
21
+ port?: number;
22
+ protocol?: "http" | "https";
23
+ apiKey: string;
24
+ path?: string;
25
+ };
26
+ /**
27
+ * Override the collections to index returned by the extension.
28
+ * Use this if you want to restrict search to specific collections on the client side,
29
+ * regardless of what is configured in the extension.
30
+ */
31
+ collections?: string[];
32
+ }
33
+ /**
34
+ * Creates a text search controller that uses the Rebase Search Extension.
35
+ *
36
+ * This requires the `rebase-search` extension to be installed in the user's
37
+ * Firebase project. The extension automatically deploys Typesense to Cloud Run
38
+ * and syncs Firestore data.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * import { buildRebaseSearchController } from "@rebasepro/client-firebase";
43
+ *
44
+ * // Using the extension (recommended)
45
+ * const textSearchControllerBuilder = buildRebaseSearchController();
46
+ *
47
+ * // Or with custom Typesense instance
48
+ * const textSearchControllerBuilder = buildRebaseSearchController({
49
+ * customConfig: {
50
+ * host: "your-typesense-instance.com",
51
+ * apiKey: "your-api-key"
52
+ * }
53
+ * });
54
+ *
55
+ * <RebaseApp
56
+ * textSearchControllerBuilder={textSearchControllerBuilder}
57
+ * collections={[
58
+ * {
59
+ * path: "products",
60
+ * name: "Products",
61
+ * textSearchEnabled: true, // Enable search for this collection
62
+ * properties: { ... }
63
+ * }
64
+ * ]}
65
+ * />
66
+ * ```
67
+ *
68
+ * @param options - Configuration options
69
+ * @returns A FirestoreTextSearchControllerBuilder
70
+ *
71
+ * @group Firebase
72
+ */
73
+ export declare function buildRebaseSearchController(options?: RebaseSearchControllerOptions): FirestoreTextSearchControllerBuilder;
@@ -0,0 +1,13 @@
1
+ import { FirestoreTextSearchControllerBuilder } from "../types";
2
+ /**
3
+ * Utility function to perform a text search in an external index,
4
+ * returning the ids of the entities.
5
+ * @group Firebase
6
+ */
7
+ export declare function buildExternalSearchController({ isPathSupported, search }: {
8
+ isPathSupported: (path: string) => boolean;
9
+ search: (props: {
10
+ searchString: string;
11
+ path: string;
12
+ }) => Promise<readonly string[] | undefined>;
13
+ }): FirestoreTextSearchControllerBuilder;
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@rebasepro/client-firebase",
3
+ "type": "module",
4
+ "version": "0.0.1-canary.09e5ec5",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "./dist/index.umd.js",
9
+ "module": "./dist/index.es.js",
10
+ "types": "./dist/index.d.ts",
11
+ "source": "src/index.ts",
12
+ "dependencies": {
13
+ "@firebase/auth": "*",
14
+ "react-fast-compare": "3.2.2",
15
+ "react-router-dom": "^7.13.1",
16
+ "@rebasepro/admin": "0.0.1-canary.09e5ec5",
17
+ "@rebasepro/types": "0.0.1-canary.09e5ec5",
18
+ "@rebasepro/core": "0.0.1-canary.09e5ec5",
19
+ "@rebasepro/utils": "0.0.1-canary.09e5ec5",
20
+ "@rebasepro/common": "0.0.1-canary.09e5ec5",
21
+ "@rebasepro/ui": "0.0.1-canary.09e5ec5"
22
+ },
23
+ "peerDependencies": {
24
+ "firebase": "^10.12.2 || ^11.0.0 || ^12.0.0",
25
+ "react": ">=19.0.0",
26
+ "react-dom": ">=19.0.0",
27
+ "typesense": "^1.8.0"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "typesense": {
31
+ "optional": true
32
+ }
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "development": "./src/index.ts",
38
+ "import": "./dist/index.es.js",
39
+ "require": "./dist/index.umd.js"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^20.19.17",
45
+ "@types/react": "^19.0.8",
46
+ "@types/react-dom": "^19.0.3",
47
+ "babel-plugin-react-compiler": "^19.0.0-beta-af1b7da-20250417",
48
+ "eslint-plugin-react-compiler": "^19.1.0-rc.2",
49
+ "typescript": "^5.9.3",
50
+ "typesense": "^2.1.0",
51
+ "vite": "^7.2.4"
52
+ },
53
+ "files": [
54
+ "dist",
55
+ "src"
56
+ ],
57
+ "gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
58
+ "scripts": {
59
+ "dev": "vite",
60
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
61
+ "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
62
+ }
63
+ }