Browse Source

refactor: add strict types to PlatformServiceMixin interfaces

- Replace all `any` types in IPlatformServiceMixin and ComponentCustomProperties with proper types:
  - Use PlatformCapabilities for capabilities
  - Use QueryExecResult, DatabaseExecResult, and generics for database methods
  - Use Contact[] and Settings for contact and settings methods
- Improves IDE type inference and type safety for all consumers of the mixin
- No functional changes, interface/type declarations only
pull/142/head
Matthew Raymer 3 days ago
parent
commit
1d8b63b52a
  1. 30
      src/utils/PlatformServiceMixin.ts

30
src/utils/PlatformServiceMixin.ts

@ -35,7 +35,10 @@
*/
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
import type { PlatformService } from "@/services/PlatformService";
import type {
PlatformService,
PlatformCapabilities,
} from "@/services/PlatformService";
import { mapColumnsToValues, parseJsonField } from "@/db/databaseUtil";
import { MASTER_SETTINGS_KEY, type Settings } from "@/db/tables/settings";
import * as databaseUtil from "@/db/databaseUtil";
@ -671,9 +674,12 @@ export const PlatformServiceMixin = {
*/
export interface IPlatformServiceMixin {
platformService: PlatformService;
$dbQuery(sql: string, params?: unknown[]): Promise<any>;
$dbExec(sql: string, params?: unknown[]): Promise<any>;
$dbGetOneRow(sql: string, params?: unknown[]): Promise<any>;
$dbQuery(
sql: string,
params?: unknown[],
): Promise<QueryExecResult | undefined>;
$dbExec(sql: string, params?: unknown[]): Promise<DatabaseExecResult>;
$dbGetOneRow(sql: string, params?: unknown[]): Promise<unknown[] | undefined>;
$getSettings(
key: string,
fallback?: Settings | null,
@ -687,7 +693,7 @@ export interface IPlatformServiceMixin {
isCapacitor: boolean;
isWeb: boolean;
isElectron: boolean;
capabilities: any;
capabilities: PlatformCapabilities;
}
// TypeScript declaration merging to eliminate (this as any) type assertions
@ -698,7 +704,7 @@ declare module "@vue/runtime-core" {
isCapacitor: boolean;
isWeb: boolean;
isElectron: boolean;
capabilities: any;
capabilities: PlatformCapabilities;
// Ultra-concise database methods (shortest possible names)
$db(sql: string, params?: unknown[]): Promise<QueryExecResult | undefined>;
@ -716,9 +722,15 @@ declare module "@vue/runtime-core" {
): Promise<T | null>;
// Enhanced utility methods
$dbQuery(sql: string, params?: unknown[]): Promise<any>;
$dbExec(sql: string, params?: unknown[]): Promise<any>;
$dbGetOneRow(sql: string, params?: unknown[]): Promise<any>;
$dbQuery(
sql: string,
params?: unknown[],
): Promise<QueryExecResult | undefined>;
$dbExec(sql: string, params?: unknown[]): Promise<DatabaseExecResult>;
$dbGetOneRow(
sql: string,
params?: unknown[],
): Promise<unknown[] | undefined>;
$getSettings(
key: string,
defaults?: Settings | null,

Loading…
Cancel
Save