@devtion/actions
Version:
A set of actions and helpers for CLI commands
113 lines • 7.67 kB
TypeScript
import { DocumentData, DocumentSnapshot, Firestore, QueryConstraint, QueryDocumentSnapshot, QuerySnapshot } from "firebase/firestore";
import { FirebaseDocumentInfo } from "../types/index";
/**
* Get participants collection path for database reference.
* @notice all participants related documents are store under `ceremonies/<ceremonyId>/participants` collection path.
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
* @param ceremonyId <string> - the unique identifier of the ceremony.
* @returns <string> - the participants collection path.
*/
export declare const getParticipantsCollectionPath: (ceremonyId: string) => string;
/**
* Get circuits collection path for database reference.
* @notice all circuits related documents are store under `ceremonies/<ceremonyId>/circuits` collection path.
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
* @param ceremonyId <string> - the unique identifier of the ceremony.
* @returns <string> - the participants collection path.
*/
export declare const getCircuitsCollectionPath: (ceremonyId: string) => string;
/**
* Get contributions collection path for database reference.
* @notice all contributions related documents are store under `ceremonies/<ceremonyId>/circuits/<circuitId>/contributions` collection path.
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
* @param ceremonyId <string> - the unique identifier of the ceremony.
* @param circuitId <string> - the unique identifier of the circuit.
* @returns <string> - the contributions collection path.
*/
export declare const getContributionsCollectionPath: (ceremonyId: string, circuitId: string) => string;
/**
* Get timeouts collection path for database reference.
* @notice all timeouts related documents are store under `ceremonies/<ceremonyId>/participants/<participantId>/timeouts` collection path.
* nb. This is a rule that must be satisfied. This is NOT an optional convention.
* @param ceremonyId <string> - the unique identifier of the ceremony.
* @param participantId <string> - the unique identifier of the participant.
* @returns <string> - the timeouts collection path.
*/
export declare const getTimeoutsCollectionPath: (ceremonyId: string, participantId: string) => string;
/**
* Helper for query a collection based on certain constraints.
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @param collection <string> - the name of the collection.
* @param queryConstraints <Array<QueryConstraint>> - a sequence of where conditions.
* @returns <Promise<QuerySnapshot<DocumentData>>> - return the matching documents (if any).
*/
export declare const queryCollection: (firestoreDatabase: Firestore, collection: string, queryConstraints: Array<QueryConstraint>) => Promise<QuerySnapshot<DocumentData>>;
/**
* Helper for obtaining uid and data for query document snapshots.
* @param queryDocSnap <Array<QueryDocumentSnapshot>> - the array of query document snapshot to be converted.
* @returns Array<FirebaseDocumentInfo>
*/
export declare const fromQueryToFirebaseDocumentInfo: (queryDocSnap: Array<QueryDocumentSnapshot>) => Array<FirebaseDocumentInfo>;
/**
* Fetch for all documents in a collection.
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @param collection <string> - the name of the collection.
* @returns <Promise<Array<QueryDocumentSnapshot<DocumentData>>>> - return all documents (if any).
*/
export declare const getAllCollectionDocs: (firestoreDatabase: Firestore, collection: string) => Promise<Array<QueryDocumentSnapshot<DocumentData>>>;
/**
* Get a specific document from database.
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @param collection <string> - the name of the collection.
* @param documentId <string> - the unique identifier of the document in the collection.
* @returns <Promise<DocumentSnapshot<DocumentData>>> - return the document from Firestore.
*/
export declare const getDocumentById: (firestoreDatabase: Firestore, collection: string, documentId: string) => Promise<DocumentSnapshot<DocumentData>>;
/**
* Query for opened ceremonies.
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @returns <Promise<Array<FirebaseDocumentInfo>>>
*/
export declare const getOpenedCeremonies: (firestoreDatabase: Firestore) => Promise<Array<FirebaseDocumentInfo>>;
/**
* Query for ceremony circuits.
* @notice the order by sequence position is fundamental to maintain parallelism among contributions for different circuits.
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @param ceremonyId <string> - the ceremony unique identifier.
* @returns Promise<Array<FirebaseDocumentInfo>> - the ceremony' circuits documents ordered by sequence position.
*/
export declare const getCeremonyCircuits: (firestoreDatabase: Firestore, ceremonyId: string) => Promise<Array<FirebaseDocumentInfo>>;
/**
* Query for a specific ceremony' circuit contribution from a given contributor (if any).
* @notice if the caller is a coordinator, there could be more than one contribution (= the one from finalization applies to this criteria).
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @param ceremonyId <string> - the unique identifier of the ceremony.
* @param circuitId <string> - the unique identifier of the circuit.
* @param participantId <string> - the unique identifier of the participant.
* @returns <Promise<Array<FirebaseDocumentInfo>>> - the document info about the circuit contributions from contributor.
*/
export declare const getCircuitContributionsFromContributor: (firestoreDatabase: Firestore, ceremonyId: string, circuitId: string, participantId: string) => Promise<Array<FirebaseDocumentInfo>>;
/**
* Query for the active timeout from given participant for a given ceremony (if any).
* @param ceremonyId <string> - the identifier of the ceremony.
* @param participantId <string> - the identifier of the participant.
* @returns <Promise<Array<FirebaseDocumentInfo>>> - the document info about the current active participant timeout.
*/
export declare const getCurrentActiveParticipantTimeout: (firestoreDatabase: Firestore, ceremonyId: string, participantId: string) => Promise<Array<FirebaseDocumentInfo>>;
/**
* Query for the closed ceremonies.
* @notice a ceremony is closed when the period for receiving new contributions has ended.
* @dev when the ceremony is closed it becomes ready for finalization.
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @returns <Promise<Array<FirebaseDocumentInfo>>> - the list of closed ceremonies.
*/
export declare const getClosedCeremonies: (firestoreDatabase: Firestore) => Promise<Array<FirebaseDocumentInfo>>;
/**
* Query all ceremonies
* @notice get all ceremonies from the database.
* @dev this is a helper for the CLI ceremony methods.
* @param firestoreDatabase <Firestore> - the Firestore service instance associated to the current Firebase application.
* @returns <Promise<Array<FirebaseDocumentInfo>>> - the list of all ceremonies.
*/
export declare const getAllCeremonies: (firestoreDatabase: Firestore) => Promise<Array<FirebaseDocumentInfo>>;
//# sourceMappingURL=database.d.ts.map