fix: Resolve TypeScript compilation errors and test environment issues
- Update interface definitions to match test requirements - Add missing methods to DailyNotificationPlugin interface - Fix ContentHandler signature compatibility - Switch Jest test environment from node to jsdom - Install required jsdom dependencies - Update mock plugin objects with all required methods - Fix timestamp type mismatches in tests
This commit is contained in:
@@ -2,14 +2,18 @@
|
||||
* Daily Notification Plugin Definitions
|
||||
*
|
||||
* TypeScript definitions for the Daily Notification Plugin
|
||||
* Aligned with Android implementation and test requirements
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
* @version 2.0.0
|
||||
*/
|
||||
|
||||
export interface NotificationResponse {
|
||||
id: string;
|
||||
title: string;
|
||||
body: string;
|
||||
timestamp?: string;
|
||||
timestamp: number;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface NotificationOptions {
|
||||
@@ -18,8 +22,17 @@ export interface NotificationOptions {
|
||||
title?: string;
|
||||
body?: string;
|
||||
sound?: boolean;
|
||||
priority?: 'high' | 'low' | 'normal';
|
||||
priority?: 'high' | 'default' | 'low' | 'min' | 'max' | 'normal';
|
||||
timezone?: string;
|
||||
retryCount?: number;
|
||||
retryInterval?: number;
|
||||
offlineFallback?: boolean;
|
||||
contentHandler?: ContentHandler;
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface ContentHandler {
|
||||
(response?: any): Promise<{ title: string; body: string; data?: any }>;
|
||||
}
|
||||
|
||||
export interface DailyNotificationPlugin {
|
||||
@@ -32,14 +45,21 @@ export interface DailyNotificationPlugin {
|
||||
requestBatteryOptimizationExemption(): Promise<void>;
|
||||
setAdaptiveScheduling(options: { enabled: boolean }): Promise<void>;
|
||||
getPowerState(): Promise<PowerState>;
|
||||
checkPermissions(): Promise<PermissionStatus>;
|
||||
requestPermissions(): Promise<PermissionStatus>;
|
||||
}
|
||||
|
||||
export interface ScheduleOptions {
|
||||
url?: string;
|
||||
time?: string;
|
||||
sound?: boolean;
|
||||
priority?: 'high' | 'default' | 'low' | 'min' | 'max';
|
||||
priority?: 'high' | 'default' | 'low' | 'min' | 'max' | 'normal';
|
||||
timezone?: string;
|
||||
retryCount?: number;
|
||||
retryInterval?: number;
|
||||
offlineFallback?: boolean;
|
||||
contentHandler?: ContentHandler;
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface NotificationSettings {
|
||||
@@ -48,13 +68,18 @@ export interface NotificationSettings {
|
||||
sound?: boolean;
|
||||
priority?: string;
|
||||
timezone?: string;
|
||||
retryCount?: number;
|
||||
retryInterval?: number;
|
||||
offlineFallback?: boolean;
|
||||
}
|
||||
|
||||
export interface NotificationStatus {
|
||||
lastNotificationTime: number;
|
||||
nextNotificationTime: number;
|
||||
settings: NotificationSettings;
|
||||
isEnabled?: boolean;
|
||||
isScheduled?: boolean;
|
||||
lastNotificationTime: number | Promise<number>;
|
||||
nextNotificationTime: number | Promise<number>;
|
||||
pending?: number;
|
||||
settings: NotificationSettings;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
@@ -79,8 +104,63 @@ export interface NotificationEvent extends Event {
|
||||
}
|
||||
|
||||
export interface PermissionStatus {
|
||||
status?: string;
|
||||
granted?: boolean;
|
||||
notifications: PermissionState;
|
||||
backgroundRefresh?: PermissionState; // iOS only
|
||||
alert?: boolean;
|
||||
badge?: boolean;
|
||||
sound?: boolean;
|
||||
lockScreen?: boolean;
|
||||
carPlay?: boolean;
|
||||
}
|
||||
|
||||
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';
|
||||
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied' | 'provisional' | 'ephemeral' | 'unknown';
|
||||
|
||||
// Additional interfaces for enhanced functionality
|
||||
export interface NotificationMetrics {
|
||||
scheduledTime: number;
|
||||
actualDeliveryTime?: number;
|
||||
contentAge: number;
|
||||
engagement?: 'TAPPED' | 'DISMISSED' | 'IGNORED';
|
||||
failureReason?: string;
|
||||
platformInfo: PlatformInfo;
|
||||
}
|
||||
|
||||
export interface PlatformInfo {
|
||||
oem?: string;
|
||||
osVersion: string;
|
||||
appState: string;
|
||||
}
|
||||
|
||||
export interface FallbackContent {
|
||||
title: string;
|
||||
body: string;
|
||||
isEmergency: boolean;
|
||||
age?: string;
|
||||
}
|
||||
|
||||
export interface CachePolicy {
|
||||
maxSize: number;
|
||||
evictionPolicy: 'LRU' | 'FIFO' | 'TTL';
|
||||
ttl?: number;
|
||||
cleanupInterval: number;
|
||||
}
|
||||
|
||||
export interface NetworkConfig {
|
||||
timeout: number;
|
||||
retryAttempts: number;
|
||||
retryDelay: number;
|
||||
offlineFallback: boolean;
|
||||
}
|
||||
|
||||
export interface SchedulingConfig {
|
||||
exactAlarms: boolean;
|
||||
adaptiveScheduling: boolean;
|
||||
quietHours?: {
|
||||
start: string;
|
||||
end: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
timezone: string;
|
||||
}
|
||||
Reference in New Issue
Block a user