export declare type UserId = string; export declare type VoterId = string; export declare type VotingId = string; export declare type VoteId = string; export declare type UserInfo = { userId: UserId; alias?: string; } | { userId?: UserId; alias: string; }; export declare type EvidenceType = 'text' | 'image'; export declare type Evidence = { type: EvidenceType; data: string; }; export declare type VerdictElection = 'elect' | 'pass'; export declare type VerdictJudgment = 'innocent' | 'guilty'; export declare type Verdict = VerdictElection | VerdictJudgment; declare type VerdictFinalBase = 'undecided'; export declare type VerdictFinalElection = 'elected' | 'not elected' | VerdictFinalBase; export declare type VerdictFinalJudgment = 'innocent' | 'guilty' | VerdictFinalBase; export declare type VerdictFinalOption = 'selected' | 'rejected' | VerdictFinalBase; export declare type VerdictFinal = VerdictFinalElection | VerdictFinalJudgment | VerdictFinalOption; export declare type VerdictPartial = VerdictFinal | 'pending elected' | 'pending selected'; export declare type CandidateBasedVotingType = 'election' | 'judgment'; export declare type OptionBasedVotingType = 'option'; export declare type VotingType = CandidateBasedVotingType | OptionBasedVotingType; export declare type VoteChoiceCandidateBased = { candidateId: VoterId; verdict: Verdict; }; export declare type VoteChoiceOptionBased = { value: string; }; export declare type VoteChoice = VoteChoiceCandidateBased | VoteChoiceOptionBased; export declare type CandidateStatsElection = { [verdict in VerdictElection]: number; }; export declare type CandidateStatsJudgment = { [verdict in VerdictJudgment]: number; }; export declare type CandidateStats = CandidateStatsElection | CandidateStatsJudgment; export declare type CandidateBasedVotesStats = { [candidateId: VoterId]: Partial; }; export declare type VotesStats = CandidateBasedVotesStats | OptionsStats; export declare type CandidatesStats = { [candidateId: VoterId]: CandidateStats; }; export declare type OptionsStats = { [option: string]: number; }; export declare type VotingStats = CandidatesStats | OptionsStats; export declare type PartialVerdict = { statsKey: VoterId | string; verdict: VerdictPartial; electVotes?: number; }; export declare type FinalVerdictStatsElection = { [candidateId: VoterId]: VerdictFinalElection; }; export declare type FinalVerdictStatsJudgment = { [candidateId: VoterId]: VerdictFinalJudgment; }; export declare type FinalVerdictStatsOption = { [option: string]: VerdictFinalOption; }; export declare type FinalVerdictStats = FinalVerdictStatsElection | FinalVerdictStatsJudgment | FinalVerdictStatsOption; export declare type VotingSummaryState = 'partial' | 'final'; export declare type VotingDescription = { [language: string]: string; }; export declare type VoterStatus = 'active' | 'inactive'; export declare type Voter = { voterId: VoterId; userId: UserId; alias?: string; status: VoterStatus; }; export declare type CandidateInfo = { candidateId: VoterId; alias?: string; speech?: string; }; declare type VotingBase = { votingId: VotingId; votingDescription: VotingDescription; votingType: VotingType; startedBy: VoterId; startsAt: Date; endsAt: Date; totalVoters: number; requiredParticipationPercentage?: number; requiredVotesPercentage?: number; onlyOneSelected?: boolean; }; export declare type CandidateBasedVoting = VotingBase & { candidates: CandidateInfo[]; }; export declare type Election = CandidateBasedVoting; export declare type Judgment = CandidateBasedVoting & { evidences: Evidence[]; }; export declare type OptionBasedVoting = VotingBase & { options?: string[]; }; export declare type Voting = Election | Judgment | OptionBasedVoting; export declare type Vote = { voteId: VoteId; votingId: VotingId; voterId: VoterId; choices: VoteChoice[]; }; export declare type VoterActive = { [voterId: VoterId]: boolean; }; /** * OPTIONS */ export declare type Options = { minVotingDuration: number; maxVotingDuration: number; minCandidatesElection: number; canVoterVoteForHimself: boolean; canCandidateStartVoting: boolean; }; /** * FUNCTIONS SETS */ export declare type Callbacks = { persistVoting: (voting: VotingData) => Promise; persistVoters: (voters: VoterData[]) => Promise; persistVote: (vote: VoteData) => Promise; retrieveVoting: (votingId: VotingId) => Promise>; retrieveVoter: (userId: UserId) => Promise>; retrieveVotes: (votingId: VotingId) => Promise>; checkActiveVoters: (votersIds: VoterId[]) => Promise; countActiveVoters: () => Promise; hasVoted: (voterId: VoterId, votingId: VotingId) => Promise; }; export declare type Helpers = { getCurrentDate: () => Date; generateRandomUUID: () => string; }; /** * DATA */ declare type BasicData = { createdAt: Date; updatedAt: Date; }; export declare type VoterData = Voter & BasicData; export declare type CandidateVotingData = (Election | Judgment) & BasicData; export declare type OptionVotingData = OptionBasedVoting & BasicData; export declare type VotingData = CandidateVotingData | OptionVotingData; export declare type VoteData = Vote & Omit; /** * PARAMS */ declare type VotingParamsBase = { votingDescription: VotingDescription; votingType: VotingType; startedBy: VoterId; startsAt?: Date; endsAt: Date; requiredParticipationPercentage?: number; }; declare type CandidateBasedVotingParamsBase = VotingParamsBase & { candidates: CandidateInfo[]; }; export declare type ElectionParams = CandidateBasedVotingParamsBase & { onlyOneSelected: boolean; }; export declare type JudgmentParams = CandidateBasedVotingParamsBase & { evidences: Evidence[]; }; export declare type CandidateBasedVotingParams = ElectionParams | JudgmentParams; export declare type OptionBasedVotingParams = VotingParamsBase & { options: string[]; }; export declare type VotingParams = CandidateBasedVotingParams | OptionBasedVotingParams; export declare type VotingParamsValidate = VotingParams & { startsAt: Date; }; export declare type VoteParams = Omit; /** * REQUESTS */ export declare type RegisterVotingRequest = { votingParams: VotingParams; }; export declare type RegisterVotersRequest = { users: UserInfo[]; omitReturnedData?: boolean; }; export declare type RegisterVoteRequest = { voteParams: VoteParams; }; export declare type RegisterVoteByUserIdRequest = { voteParams: { userId: UserId; } & Omit; }; export declare type RetrieveVotingSummaryRequest = { votingId: VotingId; }; /** * RESPONSES */ export declare type PersistResponseInsert = { inserts: number; }; export declare type PersistResponseUpdate = { updates: number; }; export declare type PersistResponse = PersistResponseInsert | PersistResponseUpdate; export declare type RetrieveResponse = { data: T | null; }; export declare type RegisterVotingResponse = { voting: VotingData; }; export declare type RegisterVotersResponse = { voters?: VoterData[]; }; export declare type RegisterVoteResponse = { vote: VoteData; }; export declare type RetrieveVotingSummaryResponse = { voting: VotingData; votingStats: VotingStats; votingSummaryState: VotingSummaryState; finalVerdict?: FinalVerdictStats; }; export {};