127 lines
4.5 KiB
TypeScript
127 lines
4.5 KiB
TypeScript
import { Prisma } from '@prisma/client';
|
|
import type { StartTrackingInput, SubmitPointsInput, LinkCanvassInput, LiveVolunteersQueryInput, HistoricalListQueryInput } from './tracking.schemas';
|
|
declare class TrackingService {
|
|
/** Start or resume a tracking session for a volunteer. */
|
|
startSession(userId: string, data: StartTrackingInput): Promise<{
|
|
id: string;
|
|
userId: string;
|
|
isActive: boolean;
|
|
startedAt: Date;
|
|
endedAt: Date | null;
|
|
totalPoints: number;
|
|
totalDistanceM: number;
|
|
lastLatitude: Prisma.Decimal | null;
|
|
lastLongitude: Prisma.Decimal | null;
|
|
lastRecordedAt: Date | null;
|
|
canvassSessionId: string | null;
|
|
}>;
|
|
/** End a tracking session. */
|
|
endSession(sessionId: string, userId: string): Promise<{
|
|
id: string;
|
|
userId: string;
|
|
isActive: boolean;
|
|
startedAt: Date;
|
|
endedAt: Date | null;
|
|
totalPoints: number;
|
|
totalDistanceM: number;
|
|
lastLatitude: Prisma.Decimal | null;
|
|
lastLongitude: Prisma.Decimal | null;
|
|
lastRecordedAt: Date | null;
|
|
canvassSessionId: string | null;
|
|
} | null>;
|
|
/** Submit a batch of GPS points for a tracking session. */
|
|
submitPoints(sessionId: string, userId: string, data: SubmitPointsInput): Promise<{
|
|
inserted: number;
|
|
addedDistanceM: number;
|
|
}>;
|
|
/** Get the active tracking session for a user. */
|
|
getActiveSession(userId: string): Promise<{
|
|
id: string;
|
|
userId: string;
|
|
isActive: boolean;
|
|
startedAt: Date;
|
|
endedAt: Date | null;
|
|
totalPoints: number;
|
|
totalDistanceM: number;
|
|
lastLatitude: Prisma.Decimal | null;
|
|
lastLongitude: Prisma.Decimal | null;
|
|
lastRecordedAt: Date | null;
|
|
canvassSessionId: string | null;
|
|
} | null>;
|
|
/** Link a canvass session to an existing tracking session. */
|
|
linkCanvassSession(trackingSessionId: string, data: LinkCanvassInput): Promise<{
|
|
id: string;
|
|
userId: string;
|
|
isActive: boolean;
|
|
startedAt: Date;
|
|
endedAt: Date | null;
|
|
totalPoints: number;
|
|
totalDistanceM: number;
|
|
lastLatitude: Prisma.Decimal | null;
|
|
lastLongitude: Prisma.Decimal | null;
|
|
lastRecordedAt: Date | null;
|
|
canvassSessionId: string | null;
|
|
}>;
|
|
/** Get all active volunteers with their recent trail for the admin live map. */
|
|
getLiveVolunteers(query: LiveVolunteersQueryInput): Promise<{
|
|
userId: string;
|
|
name: string | null;
|
|
email: string;
|
|
latitude: number;
|
|
longitude: number;
|
|
lastRecordedAt: string;
|
|
recentTrail: [number, number][];
|
|
canvassSessionId: string | null;
|
|
trackingSessionId: string;
|
|
}[]>;
|
|
/** Get the full route for a tracking session, verifying ownership. */
|
|
getMySessionRoute(trackingSessionId: string, userId: string): Promise<{
|
|
coordinates: [number, number][];
|
|
events: {
|
|
latitude: number;
|
|
longitude: number;
|
|
eventType: import(".prisma/client").$Enums.TrackPointEvent;
|
|
recordedAt: string;
|
|
}[];
|
|
totalPoints: number;
|
|
} | null>;
|
|
/** Get the full route for a tracking session. */
|
|
getSessionRoute(trackingSessionId: string): Promise<{
|
|
coordinates: [number, number][];
|
|
events: {
|
|
latitude: number;
|
|
longitude: number;
|
|
eventType: import(".prisma/client").$Enums.TrackPointEvent;
|
|
recordedAt: string;
|
|
}[];
|
|
totalPoints: number;
|
|
}>;
|
|
/** Paginated list of historical tracking sessions. */
|
|
getHistoricalSessions(query: HistoricalListQueryInput): Promise<{
|
|
sessions: {
|
|
id: string;
|
|
userId: string;
|
|
userName: string | null;
|
|
userEmail: string;
|
|
startedAt: string;
|
|
endedAt: string | null;
|
|
totalPoints: number;
|
|
totalDistanceM: number;
|
|
canvassSessionId: string | null;
|
|
isActive: boolean;
|
|
}[];
|
|
pagination: {
|
|
page: number;
|
|
limit: number;
|
|
total: number;
|
|
totalPages: number;
|
|
};
|
|
}>;
|
|
/** Delete old track points and empty sessions. */
|
|
cleanupOldData(retentionDays: number): Promise<void>;
|
|
/** Mark stale tracking sessions as inactive. */
|
|
closeStaleTrackingSessions(minutes: number): Promise<void>;
|
|
}
|
|
export declare const trackingService: TrackingService;
|
|
export {};
|
|
//# sourceMappingURL=tracking.service.d.ts.map
|