refactor(plugin): modernize plugin architecture and improve type definitions
- Update package.json with modern build tooling and dependencies - Streamline and enhance TypeScript definitions for better type safety - Reorganize plugin structure for better maintainability - Add comprehensive interface definitions for notification features - Implement proper build configuration with rollup - Update tsconfig.json for stricter type checking and ES2020 modules Breaking Changes: - Changed module structure to use ES modules - Updated interface definitions with stricter typing - Removed redundant notification options - Simplified API surface while maintaining core functionality Dependencies: - Upgrade @capacitor dependencies to v5.7.8 - Add rollup and typescript build tools - Update test framework configuration
This commit is contained in:
@@ -1,98 +1,61 @@
|
||||
/**
|
||||
* Interface definitions for the Daily Notification plugin
|
||||
* Daily Notification Plugin Definitions
|
||||
*
|
||||
* TypeScript definitions for the Daily Notification Plugin
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
|
||||
export interface NotificationOptions {
|
||||
url: string;
|
||||
time: string;
|
||||
title?: string;
|
||||
body?: string;
|
||||
sound?: boolean;
|
||||
vibrate?: boolean;
|
||||
priority?: 'low' | 'normal' | 'high';
|
||||
retryCount?: number;
|
||||
retryInterval?: number;
|
||||
cacheDuration?: number;
|
||||
headers?: Record<string, string>;
|
||||
offlineFallback?: boolean;
|
||||
timezone?: string;
|
||||
contentHandler?: (response: Response) => Promise<{
|
||||
title: string;
|
||||
body: string;
|
||||
data?: any;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface NotificationStatus {
|
||||
isScheduled: boolean;
|
||||
nextNotificationTime?: string;
|
||||
lastNotificationTime?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface NotificationResponse {
|
||||
title: string;
|
||||
body: string;
|
||||
data?: any;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export interface NotificationSettings {
|
||||
time?: string;
|
||||
export interface NotificationOptions {
|
||||
title?: string;
|
||||
body?: string;
|
||||
sound?: boolean;
|
||||
vibrate?: boolean;
|
||||
priority?: 'low' | 'normal' | 'high';
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
export interface NotificationEvent extends Event {
|
||||
detail: {
|
||||
id: string;
|
||||
action: string;
|
||||
data?: any;
|
||||
};
|
||||
priority?: 'high' | 'low' | 'normal';
|
||||
}
|
||||
|
||||
export interface DailyNotificationPlugin {
|
||||
/**
|
||||
* Schedule a daily notification with the specified options
|
||||
*/
|
||||
scheduleDailyNotification(options: NotificationOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* Get the last notification that was delivered
|
||||
*/
|
||||
scheduleDailyNotification(options: NotificationOptions | ScheduleOptions): Promise<void>;
|
||||
getLastNotification(): Promise<NotificationResponse | null>;
|
||||
|
||||
/**
|
||||
* Cancel all scheduled notifications
|
||||
*/
|
||||
cancelAllNotifications(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Get the current status of notifications
|
||||
*/
|
||||
getNotificationStatus(): Promise<NotificationStatus>;
|
||||
|
||||
/**
|
||||
* Update notification settings
|
||||
*/
|
||||
updateSettings(settings: NotificationSettings): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check notification permissions
|
||||
*/
|
||||
checkPermissions(): Promise<PermissionStatus>;
|
||||
|
||||
/**
|
||||
* Request notification permissions
|
||||
*/
|
||||
requestPermissions(): Promise<PermissionStatus>;
|
||||
getBatteryStatus(): Promise<BatteryStatus>;
|
||||
requestBatteryOptimizationExemption(): Promise<void>;
|
||||
setAdaptiveScheduling(options: { enabled: boolean }): Promise<void>;
|
||||
getPowerState(): Promise<PowerState>;
|
||||
}
|
||||
|
||||
export interface PermissionStatus {
|
||||
notifications: PermissionState;
|
||||
backgroundRefresh?: PermissionState; // iOS only
|
||||
export interface ScheduleOptions {
|
||||
sound?: boolean;
|
||||
priority?: 'high' | 'default' | 'low' | 'min' | 'max';
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';
|
||||
export interface NotificationSettings {
|
||||
sound?: boolean;
|
||||
priority?: string;
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
export interface NotificationStatus {
|
||||
lastNotificationTime: number;
|
||||
nextNotificationTime: number;
|
||||
settings: NotificationSettings;
|
||||
}
|
||||
|
||||
export interface BatteryStatus {
|
||||
level: number;
|
||||
isCharging: boolean;
|
||||
powerState: number;
|
||||
isOptimizationExempt: boolean;
|
||||
}
|
||||
|
||||
export interface PowerState {
|
||||
powerState: number;
|
||||
isOptimizationExempt: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user