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:
167
src/web/index.ts
167
src/web/index.ts
@@ -100,14 +100,14 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
||||
*/
|
||||
async updateSettings(settings: NotificationSettings): Promise<void> {
|
||||
this.settings = { ...this.settings, ...settings };
|
||||
console.log('Web notification settings updated:', this.settings);
|
||||
console.log('Settings updated:', this.settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get battery status (mock implementation)
|
||||
* Get battery status (mock implementation for web)
|
||||
*/
|
||||
async getBatteryStatus(): Promise<BatteryStatus> {
|
||||
// Mock battery status for web
|
||||
// Mock implementation for web
|
||||
return {
|
||||
level: 100,
|
||||
isCharging: false,
|
||||
@@ -117,21 +117,21 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Request battery optimization exemption (web not applicable)
|
||||
* Request battery optimization exemption (mock for web)
|
||||
*/
|
||||
async requestBatteryOptimizationExemption(): Promise<void> {
|
||||
console.log('Battery optimization exemption not applicable on web');
|
||||
console.log('Battery optimization exemption requested (web mock)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set adaptive scheduling (web not applicable)
|
||||
* Set adaptive scheduling (mock for web)
|
||||
*/
|
||||
async setAdaptiveScheduling(options: { enabled: boolean }): Promise<void> {
|
||||
console.log('Adaptive scheduling not applicable on web:', options);
|
||||
console.log('Adaptive scheduling set:', options.enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get power state (mock implementation)
|
||||
* Get power state (mock for web)
|
||||
*/
|
||||
async getPowerState(): Promise<PowerState> {
|
||||
return {
|
||||
@@ -141,13 +141,11 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permissions
|
||||
* Check permissions (web implementation)
|
||||
*/
|
||||
async checkPermissions(): Promise<PermissionStatus> {
|
||||
if (!('Notification' in window)) {
|
||||
return {
|
||||
status: 'denied',
|
||||
granted: false,
|
||||
notifications: 'denied',
|
||||
alert: false,
|
||||
badge: false,
|
||||
@@ -161,7 +159,8 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
||||
return {
|
||||
status: permission,
|
||||
granted: permission === 'granted',
|
||||
notifications: permission as any,
|
||||
notifications: permission === 'granted' ? 'granted' :
|
||||
permission === 'denied' ? 'denied' : 'prompt',
|
||||
alert: permission === 'granted',
|
||||
badge: permission === 'granted',
|
||||
sound: permission === 'granted',
|
||||
@@ -171,29 +170,139 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Request permissions
|
||||
* Request permissions (web implementation)
|
||||
*/
|
||||
async requestPermissions(): Promise<PermissionStatus> {
|
||||
if (!('Notification' in window)) {
|
||||
throw new Error('Notifications not supported in this browser');
|
||||
}
|
||||
|
||||
try {
|
||||
const permission = await Notification.requestPermission();
|
||||
return {
|
||||
status: permission,
|
||||
granted: permission === 'granted',
|
||||
notifications: permission as any,
|
||||
alert: permission === 'granted',
|
||||
badge: permission === 'granted',
|
||||
sound: permission === 'granted',
|
||||
lockScreen: permission === 'granted',
|
||||
carPlay: false
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error requesting notification permissions:', error);
|
||||
throw error;
|
||||
}
|
||||
await Notification.requestPermission();
|
||||
return this.checkPermissions();
|
||||
}
|
||||
|
||||
// Dual Scheduling Methods Implementation
|
||||
|
||||
/**
|
||||
* Schedule content fetch (web implementation)
|
||||
*/
|
||||
async scheduleContentFetch(config: any): Promise<void> {
|
||||
console.log('Content fetch scheduled (web mock):', config);
|
||||
// Mock implementation - in real app would use Service Worker
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule user notification (web implementation)
|
||||
*/
|
||||
async scheduleUserNotification(config: any): Promise<void> {
|
||||
console.log('User notification scheduled (web mock):', config);
|
||||
// Mock implementation - in real app would use browser notifications
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule dual notification (web implementation)
|
||||
*/
|
||||
async scheduleDualNotification(config: any): Promise<void> {
|
||||
console.log('Dual notification scheduled (web mock):', config);
|
||||
// Mock implementation combining content fetch and user notification
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dual schedule status (web implementation)
|
||||
*/
|
||||
async getDualScheduleStatus(): Promise<any> {
|
||||
return {
|
||||
contentFetch: {
|
||||
isEnabled: false,
|
||||
isScheduled: false,
|
||||
pendingFetches: 0
|
||||
},
|
||||
userNotification: {
|
||||
isEnabled: false,
|
||||
isScheduled: false,
|
||||
pendingNotifications: 0
|
||||
},
|
||||
relationship: {
|
||||
isLinked: false,
|
||||
contentAvailable: false
|
||||
},
|
||||
overall: {
|
||||
isActive: false,
|
||||
lastActivity: Date.now(),
|
||||
errorCount: 0,
|
||||
successRate: 1.0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Update dual schedule configuration (web implementation)
|
||||
*/
|
||||
async updateDualScheduleConfig(config: any): Promise<void> {
|
||||
console.log('Dual schedule config updated (web mock):', config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel dual schedule (web implementation)
|
||||
*/
|
||||
async cancelDualSchedule(): Promise<void> {
|
||||
console.log('Dual schedule cancelled (web mock)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause dual schedule (web implementation)
|
||||
*/
|
||||
async pauseDualSchedule(): Promise<void> {
|
||||
console.log('Dual schedule paused (web mock)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume dual schedule (web implementation)
|
||||
*/
|
||||
async resumeDualSchedule(): Promise<void> {
|
||||
console.log('Dual schedule resumed (web mock)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content cache (web implementation)
|
||||
*/
|
||||
async getContentCache(): Promise<Record<string, any>> {
|
||||
return {}; // Mock empty cache
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear content cache (web implementation)
|
||||
*/
|
||||
async clearContentCache(): Promise<void> {
|
||||
console.log('Content cache cleared (web mock)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content history (web implementation)
|
||||
*/
|
||||
async getContentHistory(): Promise<any[]> {
|
||||
return []; // Mock empty history
|
||||
}
|
||||
|
||||
/**
|
||||
* Register callback (web implementation)
|
||||
*/
|
||||
async registerCallback(name: string, _callback: Function): Promise<void> {
|
||||
console.log('Callback registered (web mock):', name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister callback (web implementation)
|
||||
*/
|
||||
async unregisterCallback(name: string): Promise<void> {
|
||||
console.log('Callback unregistered (web mock):', name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get registered callbacks (web implementation)
|
||||
*/
|
||||
async getRegisteredCallbacks(): Promise<string[]> {
|
||||
return []; // Mock empty callback list
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user