trainingpeaks-sdk
Version:
TypeScript SDK for TrainingPeaks API integration
76 lines • 3.17 kB
TypeScript
import { LoginMethod } from '../../types/index.js';
export type DomainEvent = {
readonly eventId: string;
readonly occurredAt: Date;
readonly eventType: string;
readonly aggregateId: string;
readonly aggregateType: string;
readonly eventVersion: number;
};
export type UserLoggedInEvent = DomainEvent & {
readonly eventType: 'USER_LOGGED_IN';
readonly aggregateType: 'USER';
readonly userId: string;
readonly loginMethod: LoginMethod;
};
export type UserLoggedOutEvent = DomainEvent & {
readonly eventType: 'USER_LOGGED_OUT';
readonly aggregateType: 'USER';
readonly userId: string;
};
export type AuthenticationFailedEvent = DomainEvent & {
readonly eventType: 'AUTHENTICATION_FAILED';
readonly aggregateType: 'USER';
readonly reason: string;
readonly attemptedUsername?: string;
};
export type WorkoutUploadedEvent = DomainEvent & {
readonly eventType: 'WORKOUT_UPLOADED';
readonly aggregateType: 'WORKOUT';
readonly workoutId: string;
readonly workoutType: string;
readonly fileName: string;
readonly fileSize: number;
readonly uploadDuration: number;
};
export type WorkoutDeletedEvent = DomainEvent & {
readonly eventType: 'WORKOUT_DELETED';
readonly aggregateType: 'WORKOUT';
readonly workoutId: string;
};
export type StructuredWorkoutCreatedEvent = DomainEvent & {
readonly eventType: 'STRUCTURED_WORKOUT_CREATED';
readonly aggregateType: 'WORKOUT';
readonly workoutId: string;
readonly workoutName: string;
readonly structureType: string;
readonly totalSteps: number;
};
export type WorkoutUploadFailedEvent = DomainEvent & {
readonly eventType: 'WORKOUT_UPLOAD_FAILED';
readonly aggregateType: 'WORKOUT';
readonly fileName: string;
readonly errorType: string;
readonly errorMessage: string;
};
export type NetworkRequestStartedEvent = DomainEvent & {
readonly eventType: 'NETWORK_REQUEST_STARTED';
readonly aggregateType: 'NETWORK';
readonly requestId: string;
readonly method: string;
readonly url: string;
readonly timestamp: number;
};
export type NetworkRequestCompletedEvent = DomainEvent & {
readonly eventType: 'NETWORK_REQUEST_COMPLETED';
readonly aggregateType: 'NETWORK';
readonly requestId: string;
readonly statusCode: number;
readonly duration: number;
readonly success: boolean;
};
export type AllDomainEvents = UserLoggedInEvent | UserLoggedOutEvent | AuthenticationFailedEvent | WorkoutUploadedEvent | WorkoutDeletedEvent | StructuredWorkoutCreatedEvent | WorkoutUploadFailedEvent | NetworkRequestStartedEvent | NetworkRequestCompletedEvent;
export declare const createUserLoggedInEvent: (userId: string, loginMethod: LoginMethod) => UserLoggedInEvent;
export declare const createWorkoutUploadedEvent: (workoutId: string, workoutType: string, fileName: string, fileSize: number, uploadDuration: number) => WorkoutUploadedEvent;
export declare const createStructuredWorkoutCreatedEvent: (workoutId: string, workoutName: string, structureType: string, totalSteps: number) => StructuredWorkoutCreatedEvent;
//# sourceMappingURL=index.d.ts.map