diff --git a/src/libs/util.ts b/src/libs/util.ts index bd70fb72..1d33f51f 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -29,6 +29,7 @@ import { KeyMeta } from "../libs/crypto/vc"; import { createPeerDid } from "../libs/crypto/vc/didPeer"; import { registerCredential } from "../libs/crypto/vc/passkeyDidPeer"; import { logger } from "../utils/logger"; +import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; export interface GiverReceiverInputInfo { did?: string; @@ -552,7 +553,8 @@ export const generateSaveAndActivateIdentity = async (): Promise => { }); // add to the new sql db - await databaseService.run( + const platformService = PlatformServiceFactory.getInstance(); + await platformService.dbExec( `INSERT INTO accounts (dateCreated, derivationPath, did, identity, mnemonic, publicKeyHex) VALUES (?, ?, ?, ?, ?, ?)`, [ diff --git a/src/services/PlatformService.ts b/src/services/PlatformService.ts index 574b1a3a..8ed8fa91 100644 --- a/src/services/PlatformService.ts +++ b/src/services/PlatformService.ts @@ -1,3 +1,5 @@ +import { QueryExecResult } from "@/interfaces/database"; + /** * Represents the result of an image capture or selection operation. * Contains both the image data as a Blob and the associated filename. @@ -98,4 +100,20 @@ export interface PlatformService { * @returns Promise that resolves when the deep link has been handled */ handleDeepLink(url: string): Promise; + + /** + * Executes a SQL query on the database. + * @param sql - The SQL query to execute + * @param params - The parameters to pass to the query + * @returns Promise resolving to the query result + */ + dbQuery(sql: string, params?: unknown[]): Promise; + + /** + * Executes a create/update/delete on the database. + * @param sql - The SQL statement to execute + * @param params - The parameters to pass to the statement + * @returns Promise resolving to the result of the statement + */ + dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }>; } diff --git a/src/services/platforms/CapacitorPlatformService.ts b/src/services/platforms/CapacitorPlatformService.ts index ee8f2f82..59e87de7 100644 --- a/src/services/platforms/CapacitorPlatformService.ts +++ b/src/services/platforms/CapacitorPlatformService.ts @@ -7,6 +7,7 @@ import { Filesystem, Directory, Encoding } from "@capacitor/filesystem"; import { Camera, CameraResultType, CameraSource } from "@capacitor/camera"; import { Share } from "@capacitor/share"; import { logger } from "../../utils/logger"; +import { QueryExecResult } from "@/interfaces/database"; /** * Platform service implementation for Capacitor (mobile) platform. @@ -476,4 +477,11 @@ export class CapacitorPlatformService implements PlatformService { // This is just a placeholder for the interface return Promise.resolve(); } + + dbQuery(sql: string, params?: unknown[]): Promise { + throw new Error("Not implemented for " + sql + " with params " + params); + } + dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> { + throw new Error("Not implemented for " + sql + " with params " + params); + } } diff --git a/src/services/platforms/ElectronPlatformService.ts b/src/services/platforms/ElectronPlatformService.ts index 74fc8290..6353f685 100644 --- a/src/services/platforms/ElectronPlatformService.ts +++ b/src/services/platforms/ElectronPlatformService.ts @@ -4,6 +4,7 @@ import { PlatformCapabilities, } from "../PlatformService"; import { logger } from "../../utils/logger"; +import { QueryExecResult } from "@/interfaces/database"; /** * Platform service implementation for Electron (desktop) platform. @@ -108,4 +109,11 @@ export class ElectronPlatformService implements PlatformService { logger.error("handleDeepLink not implemented in Electron platform"); throw new Error("Not implemented"); } + + dbQuery(sql: string, params?: unknown[]): Promise { + throw new Error("Not implemented for " + sql + " with params " + params); + } + dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> { + throw new Error("Not implemented for " + sql + " with params " + params); + } } diff --git a/src/services/platforms/PyWebViewPlatformService.ts b/src/services/platforms/PyWebViewPlatformService.ts index b27aec31..d2c07d9e 100644 --- a/src/services/platforms/PyWebViewPlatformService.ts +++ b/src/services/platforms/PyWebViewPlatformService.ts @@ -4,6 +4,7 @@ import { PlatformCapabilities, } from "../PlatformService"; import { logger } from "../../utils/logger"; +import { QueryExecResult } from "@/interfaces/database"; /** * Platform service implementation for PyWebView platform. @@ -109,4 +110,11 @@ export class PyWebViewPlatformService implements PlatformService { logger.error("handleDeepLink not implemented in PyWebView platform"); throw new Error("Not implemented"); } + + dbQuery(sql: string, params?: unknown[]): Promise { + throw new Error("Not implemented for " + sql + " with params " + params); + } + dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> { + throw new Error("Not implemented for " + sql + " with params " + params); + } } diff --git a/src/services/platforms/WebPlatformService.ts b/src/services/platforms/WebPlatformService.ts index 7f09c4d3..1d076ed0 100644 --- a/src/services/platforms/WebPlatformService.ts +++ b/src/services/platforms/WebPlatformService.ts @@ -4,6 +4,8 @@ import { PlatformCapabilities, } from "../PlatformService"; import { logger } from "../../utils/logger"; +import { QueryExecResult } from "@/interfaces/database"; +import databaseService from "../database"; /** * Platform service implementation for web browser platform. @@ -359,4 +361,18 @@ export class WebPlatformService implements PlatformService { async writeAndShareFile(_fileName: string, _content: string): Promise { throw new Error("File system access not available in web platform"); } + + /** + * @see PlatformService.dbQuery + */ + dbQuery(sql: string, params?: unknown[]): Promise { + return databaseService.query(sql, params).then((result) => result[0]); + } + + /** + * @see PlatformService.dbExec + */ + dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> { + return databaseService.run(sql, params); + } } diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index cda77e1c..59a2c449 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -955,7 +955,13 @@ :to="{ name: 'logs' }" class="block w-fit text-center text-md bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md mb-2" > - View Logs + Logs + + + Test Page diff --git a/src/views/HelpOnboardingView.vue b/src/views/HelpOnboardingView.vue index fa8e20f9..ce519a4a 100644 --- a/src/views/HelpOnboardingView.vue +++ b/src/views/HelpOnboardingView.vue @@ -114,5 +114,5 @@ import { Component, Vue } from "vue-facing-decorator"; import QuickNav from "../components/QuickNav.vue"; @Component({ components: { QuickNav } }) -export default class Help extends Vue {} +export default class HelpOnboardingView extends Vue {} diff --git a/src/views/HelpView.vue b/src/views/HelpView.vue index b4adb22c..f902d4ed 100644 --- a/src/views/HelpView.vue +++ b/src/views/HelpView.vue @@ -586,7 +586,7 @@ import { } from "../db/index"; @Component({ components: { QuickNav } }) -export default class Help extends Vue { +export default class HelpView extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; $router!: Router; diff --git a/src/views/TestView.vue b/src/views/TestView.vue index 98915fea..ec9fd71d 100644 --- a/src/views/TestView.vue +++ b/src/views/TestView.vue @@ -163,25 +163,25 @@

SQL Operations

-
-
- -
+
+
+ +
-
+