feat: Implement dual scheduling API design and interfaces

- Add comprehensive dual scheduling interfaces to definitions.ts
- Implement ContentFetchConfig, UserNotificationConfig, and DualScheduleConfiguration
- Add new plugin methods for dual scheduling, content management, and callbacks
- Update web implementations with mock functionality for all new methods
- Fix all test files to include new dual scheduling method mocks
- Ensure TypeScript compilation and all tests pass successfully

Resolves: Plugin API design for dual scheduling system implementation
This commit is contained in:
Matthew Raymer
2025-08-26 13:04:33 +00:00
parent 5ac0340bed
commit 9f8a8e60a9
7 changed files with 427 additions and 42 deletions

View File

@@ -35,19 +35,7 @@ export interface ContentHandler {
(response?: any): Promise<{ title: string; body: string; data?: any }>;
}
export interface DailyNotificationPlugin {
scheduleDailyNotification(options: NotificationOptions | ScheduleOptions): Promise<void>;
getLastNotification(): Promise<NotificationResponse | null>;
cancelAllNotifications(): Promise<void>;
getNotificationStatus(): Promise<NotificationStatus>;
updateSettings(settings: NotificationSettings): Promise<void>;
getBatteryStatus(): Promise<BatteryStatus>;
requestBatteryOptimizationExemption(): Promise<void>;
setAdaptiveScheduling(options: { enabled: boolean }): Promise<void>;
getPowerState(): Promise<PowerState>;
checkPermissions(): Promise<PermissionStatus>;
requestPermissions(): Promise<PermissionStatus>;
}
export interface ScheduleOptions {
url?: string;
@@ -163,4 +151,133 @@ export interface SchedulingConfig {
enabled: boolean;
};
timezone: string;
}
// Dual Scheduling System Interfaces
export interface ContentFetchConfig {
enabled: boolean;
schedule: string; // Cron expression
url?: string;
headers?: Record<string, string>;
timeout?: number;
retryAttempts?: number;
retryDelay?: number;
callbacks: {
apiService?: string;
database?: string;
reporting?: string;
onSuccess?: (data: any) => Promise<void>;
onError?: (error: Error) => Promise<void>;
onComplete?: (result: ContentFetchResult) => Promise<void>;
};
contentHandler?: ContentHandler;
cachePolicy?: CachePolicy;
networkConfig?: NetworkConfig;
}
export interface UserNotificationConfig {
enabled: boolean;
schedule: string; // Cron expression
title?: string;
body?: string;
sound?: boolean;
vibration?: boolean;
priority?: 'low' | 'normal' | 'high';
badge?: boolean;
actions?: NotificationAction[];
category?: string;
userInfo?: Record<string, any>;
}
export interface NotificationAction {
id: string;
title: string;
icon?: string;
destructive?: boolean;
authenticationRequired?: boolean;
}
export interface DualScheduleConfiguration {
contentFetch: ContentFetchConfig;
userNotification: UserNotificationConfig;
relationship?: {
autoLink: boolean; // Automatically link content to notification
contentTimeout: number; // How long to wait for content before notification
fallbackBehavior: 'skip' | 'show_default' | 'retry';
};
}
export interface ContentFetchResult {
success: boolean;
data?: any;
timestamp: number;
contentAge: number;
error?: string;
retryCount: number;
metadata?: Record<string, any>;
}
export interface DualScheduleStatus {
contentFetch: {
isEnabled: boolean;
isScheduled: boolean;
lastFetchTime?: number;
nextFetchTime?: number;
lastFetchResult?: ContentFetchResult;
pendingFetches: number;
};
userNotification: {
isEnabled: boolean;
isScheduled: boolean;
lastNotificationTime?: number;
nextNotificationTime?: number;
pendingNotifications: number;
};
relationship: {
isLinked: boolean;
contentAvailable: boolean;
lastLinkTime?: number;
};
overall: {
isActive: boolean;
lastActivity: number;
errorCount: number;
successRate: number;
};
}
// Enhanced DailyNotificationPlugin interface with dual scheduling
export interface DailyNotificationPlugin {
// Existing methods
scheduleDailyNotification(options: NotificationOptions | ScheduleOptions): Promise<void>;
getLastNotification(): Promise<NotificationResponse | null>;
cancelAllNotifications(): Promise<void>;
getNotificationStatus(): Promise<NotificationStatus>;
updateSettings(settings: NotificationSettings): Promise<void>;
getBatteryStatus(): Promise<BatteryStatus>;
requestBatteryOptimizationExemption(): Promise<void>;
setAdaptiveScheduling(options: { enabled: boolean }): Promise<void>;
getPowerState(): Promise<PowerState>;
checkPermissions(): Promise<PermissionStatus>;
requestPermissions(): Promise<PermissionStatus>;
// New dual scheduling methods
scheduleContentFetch(config: ContentFetchConfig): Promise<void>;
scheduleUserNotification(config: UserNotificationConfig): Promise<void>;
scheduleDualNotification(config: DualScheduleConfiguration): Promise<void>;
getDualScheduleStatus(): Promise<DualScheduleStatus>;
updateDualScheduleConfig(config: DualScheduleConfiguration): Promise<void>;
cancelDualSchedule(): Promise<void>;
pauseDualSchedule(): Promise<void>;
resumeDualSchedule(): Promise<void>;
// Content management methods
getContentCache(): Promise<Record<string, any>>;
clearContentCache(): Promise<void>;
getContentHistory(): Promise<ContentFetchResult[]>;
// Callback management methods
registerCallback(name: string, callback: Function): Promise<void>;
unregisterCallback(name: string): Promise<void>;
getRegisteredCallbacks(): Promise<string[]>;
}