forked from trent_larson/crowd-funder-for-time-pwa
Finalize Dexie-to-SQLite migration prep: docs, circular dep removal, SQL helpers, tests
- Removed all vestigial Dexie/USE_DEXIE_DB references from code and docs - Centralized DB logic in PlatformServiceMixin; resolved logger/databaseUtil circular dependency - Modularized SQL helpers (`$generateInsertStatement`, `$generateUpdateStatement`) and added unit tests - Created/updated migration tracking docs and helper script for cross-machine progress - Confirmed all lint/type checks and tests pass; ready for systematic file migration
This commit is contained in:
@@ -48,7 +48,10 @@ 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";
|
||||
import {
|
||||
generateInsertStatement,
|
||||
generateUpdateStatement,
|
||||
} from "@/utils/sqlHelpers";
|
||||
|
||||
// =================================================
|
||||
// TYPESCRIPT INTERFACES
|
||||
@@ -93,6 +96,8 @@ const CACHE_DEFAULTS = {
|
||||
default: 15000, // 15 seconds default TTL
|
||||
} as const;
|
||||
|
||||
const _memoryLogs: string[] = [];
|
||||
|
||||
/**
|
||||
* Enhanced mixin that provides cached platform service access and utility methods
|
||||
* with smart caching layer for ultimate performance optimization
|
||||
@@ -123,7 +128,7 @@ export const PlatformServiceMixin = {
|
||||
* Provides direct access to memoryLogs without requiring databaseUtil import
|
||||
*/
|
||||
$memoryLogs(): string[] {
|
||||
return memoryLogs;
|
||||
return _memoryLogs;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1117,6 +1122,40 @@ export const PlatformServiceMixin = {
|
||||
async $logAndConsole(message: string, isError = false): Promise<void> {
|
||||
return logger.toConsoleAndDb(message, isError);
|
||||
},
|
||||
|
||||
$appendToMemoryLogs(message: string): void {
|
||||
_memoryLogs.push(`${new Date().toISOString()}: ${message}`);
|
||||
if (_memoryLogs.length > 1000) {
|
||||
_memoryLogs.splice(0, _memoryLogs.length - 1000);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Public wrapper for generateInsertStatement
|
||||
*/
|
||||
$generateInsertStatement(
|
||||
model: Record<string, unknown>,
|
||||
tableName: string,
|
||||
): { sql: string; params: unknown[] } {
|
||||
return generateInsertStatement(model, tableName);
|
||||
},
|
||||
|
||||
/**
|
||||
* Public wrapper for generateUpdateStatement
|
||||
*/
|
||||
$generateUpdateStatement(
|
||||
model: Record<string, unknown>,
|
||||
tableName: string,
|
||||
whereClause: string,
|
||||
whereParams: unknown[] = [],
|
||||
): { sql: string; params: unknown[] } {
|
||||
return generateUpdateStatement(
|
||||
model,
|
||||
tableName,
|
||||
whereClause,
|
||||
whereParams,
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1190,6 +1229,18 @@ export interface IPlatformServiceMixin {
|
||||
|
||||
// New additions
|
||||
$logs(): Promise<Array<Record<string, unknown>>>;
|
||||
|
||||
// New additions
|
||||
$generateInsertStatement(
|
||||
model: Record<string, unknown>,
|
||||
tableName: string,
|
||||
): { sql: string; params: unknown[] };
|
||||
$generateUpdateStatement(
|
||||
model: Record<string, unknown>,
|
||||
tableName: string,
|
||||
whereClause: string,
|
||||
whereParams?: unknown[],
|
||||
): { sql: string; params: unknown[] };
|
||||
}
|
||||
|
||||
// TypeScript declaration merging to eliminate (this as any) type assertions
|
||||
@@ -1296,5 +1347,17 @@ declare module "@vue/runtime-core" {
|
||||
|
||||
// New additions
|
||||
$logs(): Promise<Array<Record<string, unknown>>>;
|
||||
|
||||
// New additions
|
||||
$generateInsertStatement(
|
||||
model: Record<string, unknown>,
|
||||
tableName: string,
|
||||
): { sql: string; params: unknown[] };
|
||||
$generateUpdateStatement(
|
||||
model: Record<string, unknown>,
|
||||
tableName: string,
|
||||
whereClause: string,
|
||||
whereParams?: unknown[],
|
||||
): { sql: string; params: unknown[] };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user