@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
|
@@ -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,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,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,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,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rebasepro/client-firebase",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1-canary.4d4fb3e",
|
|
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
|
+
"@rebasepro/cms": "0.0.1-canary.4d4fb3e",
|
|
15
|
+
"@rebasepro/common": "0.0.1-canary.4d4fb3e",
|
|
16
|
+
"@rebasepro/core": "0.0.1-canary.4d4fb3e",
|
|
17
|
+
"@rebasepro/types": "0.0.1-canary.4d4fb3e",
|
|
18
|
+
"@rebasepro/ui": "0.0.1-canary.4d4fb3e",
|
|
19
|
+
"react-router-dom": "^7.13.1"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"firebase": "^10.12.2 || ^11.0.0 || ^12.0.0",
|
|
23
|
+
"react": ">=19.0.0",
|
|
24
|
+
"react-dom": ">=19.0.0",
|
|
25
|
+
"typesense": "^1.8.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependenciesMeta": {
|
|
28
|
+
"typesense": {
|
|
29
|
+
"optional": true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"development": "./src/index.ts",
|
|
36
|
+
"import": "./dist/index.es.js",
|
|
37
|
+
"require": "./dist/index.umd.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^20.19.17",
|
|
43
|
+
"@types/react": "^19.0.8",
|
|
44
|
+
"@types/react-dom": "^19.0.3",
|
|
45
|
+
"babel-plugin-react-compiler": "^19.0.0-beta-af1b7da-20250417",
|
|
46
|
+
"eslint-plugin-react-compiler": "^19.1.0-rc.2",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"typesense": "^2.1.0",
|
|
49
|
+
"vite": "^7.2.4"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"dev": "vite",
|
|
53
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
54
|
+
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist",
|
|
58
|
+
"src"
|
|
59
|
+
],
|
|
60
|
+
"gitHead": "71bcef3c51a458cd054f7924cc18efbbe515dcc8"
|
|
61
|
+
}
|