UNPKG

dimensions-ai

Version:

A generalized AI Competition framework that allows you to create any competition you want in any language you want with no hassle.

67 lines (66 loc) 3.17 kB
import FirebaseFirestore from '@google-cloud/firestore'; import { Plugin } from '../../Plugin'; import { Database } from '../../Plugin/Database'; import { Dimension, NanoID } from '../../Dimension'; import { Match } from '../../Match'; import { DeepPartial } from '../../utils/DeepPartial'; import { Tournament } from '../../Tournament'; import { nanoid } from '../..'; import { TournamentStatus } from '../../Tournament/TournamentStatus'; declare type TournamentConfigsCollectionData = { status: Tournament.Status; configs: Tournament.TournamentConfigsBase; modificationDate: Date; }; declare type MatchCollectionData = Pick<Match, 'creationDate' | 'id' | 'mapAgentIDtoTournamentID' | 'matchStatus' | 'name' | 'finishDate' | 'results' | 'replayFileKey' | 'replayFile'> & { governID: string; }; export declare class FireStore extends Database { name: string; type: Plugin.Type; db: FirebaseFirestore.Firestore; userCollection: FirebaseFirestore.CollectionReference<Database.User>; matchesCollection: FirebaseFirestore.CollectionReference<MatchCollectionData>; tournamentConfigsCollection: FirebaseFirestore.CollectionReference<TournamentConfigsCollectionData>; constructor(fireStoreConfigs: FireStore.Configs, configs?: DeepPartial<Database.Configs>); /** * Connects to the firestore database and returns the db object */ connect(): Promise<FirebaseFirestore.Firestore>; initialize(): Promise<void>; storeMatch(match: Match, governID: nanoid): Promise<any>; getMatch(id: NanoID): Promise<any>; getPlayerMatches(playerID: nanoid, governID: nanoid, offset?: number, limit?: number, order?: number): Promise<Array<Match>>; registerUser(username: string, password: string, userData?: any): Promise<any>; /** * Gets user information. If public is false, will retrieve all information other than password * @param usernameOrID */ getUser(usernameOrID: string, publicView?: boolean): Promise<Database.User>; private getUserDoc; loginUser(username: string, password: string): Promise<string>; updateUser(usernameOrID: string, update: Partial<Database.User>): Promise<Database.User>; deleteUser(usernameOrID: string): Promise<void>; verifyToken(jwt: string): Promise<string>; isAdmin(user: Database.PublicUser): boolean; getUsersInTournament(tournamentKey: string, offset?: number, limit?: number): Promise<Array<Database.User>>; manipulate(dimension: Dimension): Promise<void>; storeTournamentConfigs(tournamentID: nanoid, tournamentConfigs: Tournament.TournamentConfigsBase, status: TournamentStatus): Promise<void>; getTournamentConfigsModificationDate(tournamentID: nanoid): Promise<Date>; getTournamentConfigs(tournamentID: nanoid): Promise<{ configs: Tournament.TournamentConfigsBase; status: Tournament.Status; }>; } export declare namespace FireStore { interface Configs { /** Key file used for authentication */ keyFile: string; } enum Collections { MATCHES = "d_matches", USERS = "d_users", TOURNAMENT_CONFIGS = "d_tourney_configs" } } export {};