@purr-core/services.firebase 0.0.7 → 0.0.8
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/dist/_api.d.ts +46 -3
- package/dist/_init.d.ts +22 -2
- package/dist/_types.d.ts +24 -0
- package/dist/{index-Bb-UMLbg.cjs → index-Bg9DBNtp.cjs} +99 -99
- package/dist/{index-Cfwu2WEL.js → index-TTt48kNP.js} +1647 -1629
- package/dist/index.cjs +1 -1
- package/dist/{index.esm-CASCXGKx.cjs → index.esm-B0E-kI9K.cjs} +1 -1
- package/dist/{index.esm-BIT1xOwF.js → index.esm-CNyJBfzO.js} +2 -2
- package/dist/{index.esm-BE0Pdipi.js → index.esm-CawQvyHl.js} +1 -1
- package/dist/{index.esm-DRjOyAw_.js → index.esm-DC1750bH.js} +1 -1
- package/dist/{index.esm-DS_RlbEp.cjs → index.esm-RieK0f97.cjs} +1 -1
- package/dist/{index.esm-Bng7WOuv.cjs → index.esm-_CWU_suT.cjs} +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/_api.d.ts
CHANGED
|
@@ -1,8 +1,51 @@
|
|
|
1
1
|
import { DocumentData, Firestore } from 'firebase/firestore';
|
|
2
2
|
import { TAsyncBoundary } from '@purr-core/utils.definitions';
|
|
3
|
+
import { IAsyncFirebaseReturnType } from './_types';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Gets all documents from a collection in Firebase Firestore.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of the documents.
|
|
9
|
+
* @param {Firestore} firestore - The Firestore instance.
|
|
10
|
+
* @param {string} c - The collection name.
|
|
11
|
+
* @returns {Promise<IAsyncFirebaseReturnType<T>>} A promise that resolves to an object containing either the result or an error.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getAllDocuments: <T>(firestore: Firestore, c: string) => Promise<IAsyncFirebaseReturnType<T>>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets a document from a collection in Firebase Firestore by its ID.
|
|
16
|
+
*
|
|
17
|
+
* @template T - The type of the document.
|
|
18
|
+
* @param {Firestore} firestore - The Firestore instance.
|
|
19
|
+
* @param {string} c - The collection name.
|
|
20
|
+
* @param {string} id - The ID of the document.
|
|
21
|
+
* @returns {Promise<IAsyncFirebaseReturnType<T>>} A promise that resolves to an object containing either the result or an error.
|
|
22
|
+
*/
|
|
23
|
+
export declare const getDocumentById: <T>(firestore: Firestore, c: string, id: string) => Promise<IAsyncFirebaseReturnType<T>>;
|
|
24
|
+
/**
|
|
25
|
+
* Adds a document to a collection in Firebase Firestore.
|
|
26
|
+
*
|
|
27
|
+
* @template T - The type of the document.
|
|
28
|
+
* @param {Firestore} firestore - The Firestore instance.
|
|
29
|
+
* @param {string} c - The collection name.
|
|
30
|
+
* @param {DocumentData} data - The data to add to the document.
|
|
31
|
+
* @returns {Promise<IAsyncFirebaseReturnType<T>>} A promise that resolves to an object containing either the result or an error.
|
|
32
|
+
*/
|
|
33
|
+
export declare const addDocument: <T>(firestore: Firestore, c: string, data: DocumentData) => Promise<IAsyncFirebaseReturnType<T>>;
|
|
34
|
+
/**
|
|
35
|
+
* Sets a document in a collection in Firebase Firestore.
|
|
36
|
+
*
|
|
37
|
+
* @param {Firestore} firestore - The Firestore instance.
|
|
38
|
+
* @param {string} c - The collection name.
|
|
39
|
+
* @param {DocumentData} data - The data to set in the document.
|
|
40
|
+
* @returns {Promise<TAsyncBoundary<void>>} A promise that resolves to an object containing either the result or an error.
|
|
41
|
+
*/
|
|
7
42
|
export declare const setDocument: (firestore: Firestore, c: string, data: DocumentData) => Promise<TAsyncBoundary<void>>;
|
|
43
|
+
/**
|
|
44
|
+
* Deletes a document from a collection in Firebase Firestore.
|
|
45
|
+
*
|
|
46
|
+
* @param {Firestore} firestore - The Firestore instance.
|
|
47
|
+
* @param {string} c - The collection name.
|
|
48
|
+
* @param {string} id - The ID of the document to delete.
|
|
49
|
+
* @returns {Promise<TAsyncBoundary<void>>} A promise that resolves to an object containing either the result or an error.
|
|
50
|
+
*/
|
|
8
51
|
export declare const deleteDocument: (firestore: Firestore, c: string, id: string) => Promise<TAsyncBoundary<void>>;
|
package/dist/_init.d.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { FirebaseApp } from 'firebase/app';
|
|
2
|
+
import { Firestore } from 'firebase/firestore';
|
|
3
|
+
import { FirebaseStorage } from 'firebase/storage';
|
|
2
4
|
import { IFirebaseConfig } from './_types';
|
|
3
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Initializes a Firebase app.
|
|
8
|
+
*
|
|
9
|
+
* @param {IFirebaseConfig} config - The configuration for the Firebase app.
|
|
10
|
+
* @returns {Promise<FirebaseApp>} A promise that resolves to the initialized Firebase app.
|
|
11
|
+
*/
|
|
4
12
|
export declare const initFirebaseApp: (config: IFirebaseConfig) => Promise<FirebaseApp>;
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Gets a Firestore instance.
|
|
15
|
+
*
|
|
16
|
+
* @param {FirebaseApp} app - The Firebase app.
|
|
17
|
+
* @returns {Promise<Firestore>} A promise that resolves to the Firestore instance.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getFireStore: (app: FirebaseApp) => Promise<Firestore>;
|
|
20
|
+
/**
|
|
21
|
+
* Gets a Firebase Storage instance.
|
|
22
|
+
*
|
|
23
|
+
* @param {FirebaseApp} app - The Firebase app.
|
|
24
|
+
* @returns {Promise<FirebaseStorage>} A promise that resolves to the Firebase Storage instance.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getFireStorage: (app: FirebaseApp) => Promise<FirebaseStorage>;
|
package/dist/_types.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the configuration for a Firebase project.
|
|
3
|
+
*
|
|
4
|
+
* @interface IFirebaseConfig
|
|
5
|
+
* @property {string} [apiKey] - The API key for the Firebase project.
|
|
6
|
+
* @property {string} [authDomain] - The authentication domain for the Firebase project.
|
|
7
|
+
* @property {string} [projectId] - The project ID for the Firebase project.
|
|
8
|
+
* @property {string} [storageBucket] - The storage bucket for the Firebase project.
|
|
9
|
+
* @property {string} [messagingSenderId] - The messaging sender ID for the Firebase project.
|
|
10
|
+
* @property {string} [appId] - The app ID for the Firebase project.
|
|
11
|
+
* @property {string} [measurementId] - The measurement ID for the Firebase project.
|
|
12
|
+
*/
|
|
1
13
|
export interface IFirebaseConfig {
|
|
2
14
|
apiKey?: string;
|
|
3
15
|
authDomain?: string;
|
|
@@ -7,3 +19,15 @@ export interface IFirebaseConfig {
|
|
|
7
19
|
appId?: string;
|
|
8
20
|
measurementId?: string;
|
|
9
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents the return type of an asynchronous Firebase operation.
|
|
24
|
+
*
|
|
25
|
+
* @interface IAsyncFirebaseReturnType
|
|
26
|
+
* @template T - The type of the result.
|
|
27
|
+
* @property {unknown | null} error - The error encountered during the asynchronous operation, if any.
|
|
28
|
+
* @property {T | null} result - The result of the asynchronous operation, if successful.
|
|
29
|
+
*/
|
|
30
|
+
export interface IAsyncFirebaseReturnType<T> {
|
|
31
|
+
error: unknown | null;
|
|
32
|
+
result: T | null;
|
|
33
|
+
}
|