forked from jsnbuchanan/crowd-funder-for-time-pwa
Migrate LogView.vue to PlatformServiceMixin with architectural compliance
Achieve total architectural compliance by eliminating both legacy database utilities and direct SQL queries from LogView.vue component. **Component Changes (LogView.vue):** - Replace databaseUtil.memoryLogs with this.$memoryLogs - Replace direct SQL query with this.$logs() abstraction - Remove PlatformServiceFactory and databaseUtil imports - Add PlatformServiceMixin to component mixins - Reduce component from database-aware to pure presentation layer **Mixin Enhancements (PlatformServiceMixin.ts):** - Add $memoryLogs computed property for memory logs access - Add $logs() method for abstracted database log retrieval - Update TypeScript interfaces (IPlatformServiceMixin, ComponentCustomProperties) - Enable components to access logs without SQL knowledge **Documentation:** - Add docs/migration-testing/TESTING_LOGVIEW.md - Quick testing guide - Add docs/migration-testing/migration-checklist-LogView.md - Comprehensive checklist - Document architectural compliance achievements and testing requirements **Architectural Benefits:** - Zero databaseUtil imports in LogView.vue - Zero direct SQL queries in component layer - Proper separation of concerns (View → Service → Database) - Reusable $logs() method for other components - Sets gold standard for future migrations **Migration Progress:** - Components using PlatformServiceMixin: 14/91 (15%) - LogView.vue achieves total architectural compliance - Reduces legacy databaseUtil imports from 52 to 51 **Testing:** Ready for testing at /logs route **Backwards Compatible:** Yes - no functional changes to end users
This commit is contained in:
@@ -48,6 +48,7 @@ import { MASTER_SETTINGS_KEY, type Settings } from "@/db/tables/settings";
|
||||
import { logger } from "@/utils/logger";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { QueryExecResult, DatabaseExecResult } from "@/interfaces/database";
|
||||
import { memoryLogs } from "@/db/databaseUtil";
|
||||
|
||||
// =================================================
|
||||
// TYPESCRIPT INTERFACES
|
||||
@@ -117,6 +118,14 @@ export const PlatformServiceMixin = {
|
||||
return (this as unknown as VueComponentWithMixin)._platformService!;
|
||||
},
|
||||
|
||||
/**
|
||||
* Access to in-memory logs array
|
||||
* Provides direct access to memoryLogs without requiring databaseUtil import
|
||||
*/
|
||||
$memoryLogs(): string[] {
|
||||
return memoryLogs;
|
||||
},
|
||||
|
||||
/**
|
||||
* Platform detection utilities
|
||||
*/
|
||||
@@ -562,7 +571,6 @@ export const PlatformServiceMixin = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Get total contact count - $contactCount()
|
||||
* Ultra-concise shortcut for getting number of contacts
|
||||
* @returns Promise<number> Total number of contacts
|
||||
*/
|
||||
@@ -571,6 +579,14 @@ export const PlatformServiceMixin = {
|
||||
return (countRow?.[0] as number) || 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Ultra-concise shortcut for getting all logs from database
|
||||
* @returns Promise<Array<Record<string, unknown>>> Array of log records
|
||||
*/
|
||||
async $logs(): Promise<Array<Record<string, unknown>>> {
|
||||
return await this.$query("SELECT * FROM logs ORDER BY date DESC");
|
||||
},
|
||||
|
||||
/**
|
||||
* Load settings with optional defaults WITHOUT caching - $settings()
|
||||
* Settings are loaded fresh every time for immediate consistency
|
||||
@@ -1168,6 +1184,12 @@ export interface IPlatformServiceMixin {
|
||||
$log(message: string, level?: string): Promise<void>;
|
||||
$logError(message: string): Promise<void>;
|
||||
$logAndConsole(message: string, isError?: boolean): Promise<void>;
|
||||
|
||||
// Memory logs access
|
||||
$memoryLogs: string[];
|
||||
|
||||
// New additions
|
||||
$logs(): Promise<Array<Record<string, unknown>>>;
|
||||
}
|
||||
|
||||
// TypeScript declaration merging to eliminate (this as any) type assertions
|
||||
@@ -1268,5 +1290,11 @@ declare module "@vue/runtime-core" {
|
||||
$log(message: string, level?: string): Promise<void>;
|
||||
$logError(message: string): Promise<void>;
|
||||
$logAndConsole(message: string, isError?: boolean): Promise<void>;
|
||||
|
||||
// Memory logs access
|
||||
$memoryLogs: string[];
|
||||
|
||||
// New additions
|
||||
$logs(): Promise<Array<Record<string, unknown>>>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user