feat: complete Priority 2 console cleanup and start return types
🚀 Priority 2 Progress: - Completed console statement cleanup in test apps (TimeSafariNotificationManager) - Completed console statement cleanup in core plugin (web implementation) - Started return type annotations in polling contracts - Started return type annotations in test apps Console statements: 60 remaining (down from 128, 53% reduction) Return types: 54 remaining (down from 62, 13% reduction) Linting status: ✅ 0 errors, 156 warnings (down from 436 warnings) Total improvement: 280 warnings fixed (64% reduction) Priority 2: Excellent progress on both console cleanup and return types
This commit is contained in:
@@ -64,7 +64,7 @@ export class TelemetryManager {
|
|||||||
help,
|
help,
|
||||||
type: 'counter',
|
type: 'counter',
|
||||||
value: 0,
|
value: 0,
|
||||||
inc: () => { this.metrics.get(name)!.value++; }
|
inc: (): void => { this.metrics.get(name)!.value++; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ export class TelemetryManager {
|
|||||||
type: 'histogram',
|
type: 'histogram',
|
||||||
buckets,
|
buckets,
|
||||||
values: new Array(buckets.length + 1).fill(0),
|
values: new Array(buckets.length + 1).fill(0),
|
||||||
observe: (value: number) => {
|
observe: (value: number): void => {
|
||||||
const metric = this.metrics.get(name)!;
|
const metric = this.metrics.get(name)!;
|
||||||
// Find bucket and increment
|
// Find bucket and increment
|
||||||
for (let i = 0; i < buckets.length; i++) {
|
for (let i = 0; i < buckets.length; i++) {
|
||||||
@@ -97,7 +97,7 @@ export class TelemetryManager {
|
|||||||
help,
|
help,
|
||||||
type: 'gauge',
|
type: 'gauge',
|
||||||
value: 0,
|
value: 0,
|
||||||
set: (value: number) => { this.metrics.get(name)!.value = value; }
|
set: (value: number): void => { this.metrics.get(name)!.value = value; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,10 +70,13 @@ export function validateRateLimitResponse(data: unknown): boolean {
|
|||||||
/**
|
/**
|
||||||
* Create response schema validator
|
* Create response schema validator
|
||||||
*/
|
*/
|
||||||
export function createResponseValidator<T>(schema: z.ZodSchema<T>) {
|
export function createResponseValidator<T>(schema: z.ZodSchema<T>): {
|
||||||
|
validate: (data: unknown) => data is T;
|
||||||
|
transformError: (error: unknown) => PollingError;
|
||||||
|
} {
|
||||||
return {
|
return {
|
||||||
validate: (data: unknown): data is T => schema.safeParse(data).success,
|
validate: (data: unknown): data is T => schema.safeParse(data).success,
|
||||||
transformError: (error: unknown) => ({
|
transformError: (error: unknown): PollingError => ({
|
||||||
code: ERROR_CODES.VALIDATION_ERROR,
|
code: ERROR_CODES.VALIDATION_ERROR,
|
||||||
message: error.message || 'Validation failed',
|
message: error.message || 'Validation failed',
|
||||||
retryable: false
|
retryable: false
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async requestExactAlarmPermission(): Promise<void> {
|
async requestExactAlarmPermission(): Promise<void> {
|
||||||
console.log('Request exact alarm permission called on web platform');
|
// Request exact alarm permission called on web platform
|
||||||
}
|
}
|
||||||
|
|
||||||
async openExactAlarmSettings(): Promise<void> {
|
async openExactAlarmSettings(): Promise<void> {
|
||||||
console.log('Open exact alarm settings called on web platform');
|
// Open exact alarm settings called on web platform
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRebootRecoveryStatus(): Promise<{
|
async getRebootRecoveryStatus(): Promise<{
|
||||||
@@ -81,7 +81,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
|||||||
timeSinceLastRecovery: number;
|
timeSinceLastRecovery: number;
|
||||||
recoveryNeeded: boolean;
|
recoveryNeeded: boolean;
|
||||||
}> {
|
}> {
|
||||||
console.log('Get reboot recovery status called on web platform');
|
// Get reboot recovery status called on web platform
|
||||||
return {
|
return {
|
||||||
inProgress: false,
|
inProgress: false,
|
||||||
lastRecoveryTime: 0,
|
lastRecoveryTime: 0,
|
||||||
@@ -117,7 +117,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
|||||||
await this.scheduleBrowserNotification(notification, options);
|
await this.scheduleBrowserNotification(notification, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Web notification scheduled:', notification);
|
// Web notification scheduled
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +145,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
|||||||
Notification.requestPermission().then(permission => {
|
Notification.requestPermission().then(permission => {
|
||||||
if (permission === 'granted') {
|
if (permission === 'granted') {
|
||||||
// Clear any existing browser notifications
|
// Clear any existing browser notifications
|
||||||
console.log('Browser notifications cleared');
|
// Browser notifications cleared
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
|||||||
*/
|
*/
|
||||||
async updateSettings(settings: NotificationSettings): Promise<void> {
|
async updateSettings(settings: NotificationSettings): Promise<void> {
|
||||||
this.settings = { ...this.settings, ...settings };
|
this.settings = { ...this.settings, ...settings };
|
||||||
console.log('Settings updated:', this.settings);
|
// Settings updated
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,14 +191,14 @@ export class DailyNotificationWeb implements DailyNotificationPlugin {
|
|||||||
* Request battery optimization exemption (mock for web)
|
* Request battery optimization exemption (mock for web)
|
||||||
*/
|
*/
|
||||||
async requestBatteryOptimizationExemption(): Promise<void> {
|
async requestBatteryOptimizationExemption(): Promise<void> {
|
||||||
console.log('Battery optimization exemption requested (web mock)');
|
// Battery optimization exemption requested (web mock)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set adaptive scheduling (mock for web)
|
* Set adaptive scheduling (mock for web)
|
||||||
*/
|
*/
|
||||||
async setAdaptiveScheduling(options: { enabled: boolean }): Promise<void> {
|
async setAdaptiveScheduling(options: { enabled: boolean }): Promise<void> {
|
||||||
console.log('Adaptive scheduling set:', options.enabled);
|
// Adaptive scheduling set
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -161,15 +161,15 @@ class TestLogger {
|
|||||||
console.log('Mock logger initialized with level:', level);
|
console.log('Mock logger initialized with level:', level);
|
||||||
}
|
}
|
||||||
|
|
||||||
info(message: string, data?: Record<string, unknown>) {
|
info(message: string, data?: Record<string, unknown>): void {
|
||||||
console.log(`[INFO] ${message}`, data);
|
console.log(`[INFO] ${message}`, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
error(message: string, data?: Record<string, unknown>) {
|
error(message: string, data?: Record<string, unknown>): void {
|
||||||
console.error(`[ERROR] ${message}`, data);
|
console.error(`[ERROR] ${message}`, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(message: string, data?: Record<string, unknown>) {
|
debug(message: string, data?: Record<string, unknown>): void {
|
||||||
console.log(`[DEBUG] ${message}`, data);
|
console.log(`[DEBUG] ${message}`, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export class TimeSafariNotificationManager {
|
|||||||
*/
|
*/
|
||||||
async initialize(user: TimeSafariUser): Promise<boolean> {
|
async initialize(user: TimeSafariUser): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
console.log('Initializing TimeSafariNotificationManager for:', user.activeDid);
|
// Initializing TimeSafariNotificationManager for user
|
||||||
|
|
||||||
// Initialize security manager with active DID
|
// Initialize security manager with active DID
|
||||||
const securityInitialized = await this.securityManager.initialize(user.activeDid);
|
const securityInitialized = await this.securityManager.initialize(user.activeDid);
|
||||||
@@ -173,7 +173,7 @@ export class TimeSafariNotificationManager {
|
|||||||
// Set user configuration
|
// Set user configuration
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
console.log('TimeSafariNotificationManager initialized successfully');
|
// TimeSafariNotificationManager initialized successfully
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -203,11 +203,11 @@ export class TimeSafariNotificationManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`Starting notification generation: ${generationId}`);
|
// Starting notification generation
|
||||||
|
|
||||||
// Prevent concurrent generations for same user
|
// Prevent concurrent generations for same user
|
||||||
if (this.activeGeneration.has(this.user.activeDid)) {
|
if (this.activeGeneration.has(this.user.activeDid)) {
|
||||||
console.log('Generation already in progress, skipping');
|
// Generation already in progress, skipping
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ export class TimeSafariNotificationManager {
|
|||||||
// Check cache first
|
// Check cache first
|
||||||
const cached = options.forceFetch ? null : this.getCachedNotifications();
|
const cached = options.forceFetch ? null : this.getCachedNotifications();
|
||||||
if (cached) {
|
if (cached) {
|
||||||
console.log('Returning cached notifications');
|
// Returning cached notifications
|
||||||
return this.filterNotificationsByPreferences(cached, generationOptions);
|
return this.filterNotificationsByPreferences(cached, generationOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@ export class TimeSafariNotificationManager {
|
|||||||
generationOptions
|
generationOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(`Generated ${filteredNotifications.length} notifications out of ${allNotifications.length} total`);
|
// Generated notifications successfully
|
||||||
|
|
||||||
return filteredNotifications;
|
return filteredNotifications;
|
||||||
|
|
||||||
@@ -429,7 +429,7 @@ export class TimeSafariNotificationManager {
|
|||||||
* Generate fallback notifications when API fails
|
* Generate fallback notifications when API fails
|
||||||
*/
|
*/
|
||||||
private generateFallbackNotifications(): TimeSafariNotification[] {
|
private generateFallbackNotifications(): TimeSafariNotification[] {
|
||||||
console.log('Generating fallback notifications');
|
// Generating fallback notifications
|
||||||
|
|
||||||
const fallbackNotifications: TimeSafariNotification[] = [
|
const fallbackNotifications: TimeSafariNotification[] = [
|
||||||
{
|
{
|
||||||
@@ -516,7 +516,7 @@ export class TimeSafariNotificationManager {
|
|||||||
// Clear cache to force refresh with new preferences
|
// Clear cache to force refresh with new preferences
|
||||||
this.clearCache();
|
this.clearCache();
|
||||||
|
|
||||||
console.log('User preferences updated');
|
// User preferences updated
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -530,7 +530,7 @@ export class TimeSafariNotificationManager {
|
|||||||
*/
|
*/
|
||||||
async updateActiveDid(newActiveDid: string): Promise<boolean> {
|
async updateActiveDid(newActiveDid: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
console.log('Updating active DID to:', newActiveDid);
|
// Updating active DID
|
||||||
|
|
||||||
// Update security manager
|
// Update security manager
|
||||||
const securityUpdated = await this.securityManager.updateActiveDid(newActiveDid);
|
const securityUpdated = await this.securityManager.updateActiveDid(newActiveDid);
|
||||||
@@ -556,7 +556,7 @@ export class TimeSafariNotificationManager {
|
|||||||
this.user.activeDid = newActiveDid;
|
this.user.activeDid = newActiveDid;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Active DID updated successfully');
|
// Active DID updated successfully
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -571,7 +571,7 @@ export class TimeSafariNotificationManager {
|
|||||||
clearCache(): void {
|
clearCache(): void {
|
||||||
this.cache.clear();
|
this.cache.clear();
|
||||||
this.apiClient.clearCache();
|
this.apiClient.clearCache();
|
||||||
console.log('TimeSafari notification cache cleared');
|
// TimeSafari notification cache cleared
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -610,7 +610,7 @@ export class TimeSafariNotificationManager {
|
|||||||
await this.securityManager.reset();
|
await this.securityManager.reset();
|
||||||
this.clearCache();
|
this.clearCache();
|
||||||
this.user = undefined;
|
this.user = undefined;
|
||||||
console.log('TimeSafariNotificationManager reset completed');
|
// TimeSafariNotificationManager reset completed
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error resetting TimeSafariNotificationManager:', error);
|
console.error('Error resetting TimeSafariNotificationManager:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user