From c5a93e2e280bb6dbdad2f7c638283caf7976000e Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 2 Jun 2025 19:45:00 -0600 Subject: [PATCH] rename raw query method in preparation for typed query --- src/components/GiftedDialog.vue | 2 +- src/components/GiftedPrompts.vue | 4 +-- src/components/MembersList.vue | 2 +- src/components/OnboardingDialog.vue | 2 +- src/db-sql/migration.ts | 4 +-- src/db/databaseUtil.ts | 8 ++--- src/interfaces/absurd-sql.d.ts | 4 +-- src/interfaces/database.ts | 12 ++++--- src/libs/util.ts | 14 ++++---- src/services/AbsurdSqlDatabaseService.ts | 23 +++--------- src/services/PlatformService.ts | 19 ++++++---- src/services/migrationService.ts | 6 ++-- .../platforms/CapacitorPlatformService.ts | 6 ++-- .../platforms/ElectronPlatformService.ts | 26 +++++++++----- .../platforms/PyWebViewPlatformService.ts | 4 +-- src/services/platforms/WebPlatformService.ts | 35 +++++++++++-------- src/views/AccountViewView.vue | 2 +- src/views/ClaimCertificateView.vue | 2 +- src/views/ClaimReportCertificateView.vue | 2 +- src/views/ClaimView.vue | 2 +- src/views/ConfirmGiftView.vue | 2 +- src/views/ContactAmountsView.vue | 2 +- src/views/ContactEditView.vue | 2 +- src/views/ContactGiftingView.vue | 2 +- src/views/ContactImportView.vue | 2 +- src/views/ContactQRScanFullView.vue | 2 +- src/views/ContactQRScanShowView.vue | 2 +- src/views/ContactsView.vue | 4 +-- src/views/DIDView.vue | 2 +- src/views/DiscoverView.vue | 2 +- src/views/GiftedDetailsView.vue | 2 +- src/views/HomeView.vue | 4 +-- src/views/ImportDerivedAccountView.vue | 2 +- src/views/InviteOneView.vue | 2 +- src/views/LogView.vue | 2 +- src/views/NewActivityView.vue | 2 +- src/views/OfferDetailsView.vue | 2 +- src/views/ProjectViewView.vue | 2 +- src/views/ProjectsView.vue | 2 +- src/views/QuickActionBvcEndView.vue | 4 +-- src/views/RecentOffersToUserProjectsView.vue | 2 +- src/views/RecentOffersToUserView.vue | 2 +- src/views/ShareMyContactInfoView.vue | 2 +- src/views/SharedPhotoView.vue | 2 +- src/views/TestView.vue | 4 +-- src/views/UserProfileView.vue | 4 +-- 46 files changed, 127 insertions(+), 114 deletions(-) diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 754c9bf6..d42c81de 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -154,7 +154,7 @@ export default class GiftedDialog extends Vue { this.activeDid = settings.activeDid || ""; const platformService = PlatformServiceFactory.getInstance(); - const result = await platformService.dbQuery(`SELECT * FROM contacts`); + const result = await platformService.dbQueryRaw(`SELECT * FROM contacts`); if (result) { this.allContacts = databaseUtil.mapQueryResultToValues( result, diff --git a/src/components/GiftedPrompts.vue b/src/components/GiftedPrompts.vue index 186600d0..8f90455a 100644 --- a/src/components/GiftedPrompts.vue +++ b/src/components/GiftedPrompts.vue @@ -130,7 +130,7 @@ export default class GivenPrompts extends Vue { this.callbackOnFullGiftInfo = callbackOnFullGiftInfo; const platformService = PlatformServiceFactory.getInstance(); - const result = await platformService.dbQuery( + const result = await platformService.dbQueryRaw( "SELECT COUNT(*) FROM contacts", ); if (result) { @@ -240,7 +240,7 @@ export default class GivenPrompts extends Vue { } else { // get the contact at that offset const platformService = PlatformServiceFactory.getInstance(); - const result = await platformService.dbQuery( + const result = await platformService.dbQueryRaw( "SELECT * FROM contacts LIMIT 1 OFFSET ?", [someContactDbIndex], ); diff --git a/src/components/MembersList.vue b/src/components/MembersList.vue index 4451fec0..492f64bf 100644 --- a/src/components/MembersList.vue +++ b/src/components/MembersList.vue @@ -361,7 +361,7 @@ export default class MembersList extends Vue { async loadContacts() { const platformService = PlatformServiceFactory.getInstance(); - const result = await platformService.dbQuery("SELECT * FROM contacts"); + const result = await platformService.dbQueryRaw("SELECT * FROM contacts"); if (result) { this.contacts = databaseUtil.mapQueryResultToValues( result, diff --git a/src/components/OnboardingDialog.vue b/src/components/OnboardingDialog.vue index f3ecf615..3f0600f9 100644 --- a/src/components/OnboardingDialog.vue +++ b/src/components/OnboardingDialog.vue @@ -241,7 +241,7 @@ export default class OnboardingDialog extends Vue { this.activeDid = settings.activeDid || ""; this.isRegistered = !!settings.isRegistered; const platformService = PlatformServiceFactory.getInstance(); - const dbContacts = await platformService.dbQuery("SELECT * FROM contacts"); + const dbContacts = await platformService.dbQueryRaw("SELECT * FROM contacts"); if (dbContacts) { this.numContacts = dbContacts.values.length; const firstContact = dbContacts.values[0]; diff --git a/src/db-sql/migration.ts b/src/db-sql/migration.ts index 7a99724f..27c24406 100644 --- a/src/db-sql/migration.ts +++ b/src/db-sql/migration.ts @@ -1,5 +1,5 @@ import migrationService from "../services/migrationService"; -import type { QueryExecResult } from "../interfaces/database"; +import type { QueryExecResultRaw } from "../interfaces/database"; import { DEFAULT_ENDORSER_API_SERVER } from "@/constants/app"; import { arrayBufferToBase64 } from "@/libs/crypto"; @@ -127,7 +127,7 @@ export async function registerMigrations(): Promise { } export async function runMigrations( - sqlExec: (sql: string, params?: unknown[]) => Promise>, + sqlExec: (sql: string, params?: unknown[]) => Promise>, ): Promise { await registerMigrations(); await migrationService.runMigrations(sqlExec); diff --git a/src/db/databaseUtil.ts b/src/db/databaseUtil.ts index f8079c97..45779b1d 100644 --- a/src/db/databaseUtil.ts +++ b/src/db/databaseUtil.ts @@ -7,7 +7,7 @@ import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; import { MASTER_SETTINGS_KEY, Settings } from "./tables/settings"; import { logger } from "@/utils/logger"; import { DEFAULT_ENDORSER_API_SERVER } from "@/constants/app"; -import { QueryExecResult } from "@/interfaces/database"; +import { QueryExecResultRaw } from "@/interfaces/database"; export async function updateDefaultSettings( settingsChanges: Settings, @@ -80,7 +80,7 @@ const DEFAULT_SETTINGS: Settings = { // retrieves default settings export async function retrieveSettingsForDefaultAccount(): Promise { const platform = PlatformServiceFactory.getInstance(); - const result = await platform.dbQuery("SELECT * FROM settings WHERE id = ?", [ + const result = await platform.dbQueryRaw("SELECT * FROM settings WHERE id = ?", [ MASTER_SETTINGS_KEY, ]); if (!result) { @@ -104,7 +104,7 @@ export async function retrieveSettingsForActiveAccount(): Promise { return defaultSettings; } else { const platform = PlatformServiceFactory.getInstance(); - const result = await platform.dbQuery( + const result = await platform.dbQueryRaw( "SELECT * FROM settings WHERE accountDid = ?", [defaultSettings.activeDid], ); @@ -236,7 +236,7 @@ export function generateUpdateStatement( } export function mapQueryResultToValues( - record: QueryExecResult | undefined, + record: QueryExecResultRaw | undefined, ): Array> { if (!record) { return []; diff --git a/src/interfaces/absurd-sql.d.ts b/src/interfaces/absurd-sql.d.ts index b1534f8d..a7a441a6 100644 --- a/src/interfaces/absurd-sql.d.ts +++ b/src/interfaces/absurd-sql.d.ts @@ -1,4 +1,4 @@ -import type { QueryExecResult, SqlValue } from "./database"; +import type { QueryExecResultRaw, SqlValue } from "./database"; declare module "@jlongster/sql.js" { interface SQL { @@ -49,7 +49,7 @@ declare module "absurd-sql/dist/indexeddb-main-thread" { } export interface SQLiteDatabase { - exec: (sql: string, params?: unknown[]) => Promise; + exec: (sql: string, params?: unknown[]) => Promise; close: () => Promise; } diff --git a/src/interfaces/database.ts b/src/interfaces/database.ts index 4dda80ef..4d2ddc7e 100644 --- a/src/interfaces/database.ts +++ b/src/interfaces/database.ts @@ -1,17 +1,21 @@ export type SqlValue = string | number | null | Uint8Array; -export interface QueryExecResult { +export interface QueryExecResultRaw { columns: Array; values: Array>; } export interface DatabaseService { initialize(): Promise; - query(sql: string, params?: unknown[]): Promise; + query(sql: string, params?: unknown[]): Promise; run( sql: string, params?: unknown[], ): Promise<{ changes: number; lastId?: number }>; - getOneRow(sql: string, params?: unknown[]): Promise; - getAll(sql: string, params?: unknown[]): Promise; + + // Change this to return QueryExecResultRaw[] so that we can create objects with the right keys + // getOneRow(sql: string, params?: unknown[]): Promise; + + // Change this to return QueryExecResultRaw[] so that we can create objects with the right keys + // getAll(sql: string, params?: unknown[]): Promise; } diff --git a/src/libs/util.ts b/src/libs/util.ts index b969c6e0..0c46eb30 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -479,7 +479,7 @@ export type AccountKeyInfo = Account & KeyMetaWithPrivate; export const retrieveAccountCount = async (): Promise => { let result = 0; const platformService = PlatformServiceFactory.getInstance(); - const dbResult = await platformService.dbQuery( + const dbResult = await platformService.dbQueryRaw( `SELECT COUNT(*) FROM accounts`, ); if (dbResult?.values?.[0]?.[0]) { @@ -496,7 +496,7 @@ export const retrieveAccountCount = async (): Promise => { export const retrieveAccountDids = async (): Promise => { const platformService = PlatformServiceFactory.getInstance(); - const dbAccounts = await platformService.dbQuery(`SELECT did FROM accounts`); + const dbAccounts = await platformService.dbQueryRaw(`SELECT did FROM accounts`); let allDids = databaseUtil .mapQueryResultToValues(dbAccounts) @@ -522,7 +522,7 @@ export const retrieveAccountMetadata = async ( ): Promise => { let result: Account | undefined = undefined; const platformService = PlatformServiceFactory.getInstance(); - const dbAccount = await platformService.dbQuery( + const dbAccount = await platformService.dbQueryRaw( `SELECT * FROM accounts WHERE did = ?`, [activeDid], ); @@ -563,7 +563,7 @@ export const retrieveFullyDecryptedAccount = async ( ): Promise => { let result: Account | undefined = undefined; const platformService = PlatformServiceFactory.getInstance(); - const dbSecrets = await platformService.dbQuery( + const dbSecrets = await platformService.dbQueryRaw( `SELECT secretBase64 from secret`, ); if ( @@ -577,7 +577,7 @@ export const retrieveFullyDecryptedAccount = async ( } const secretBase64 = dbSecrets.values[0][0] as string; const secret = base64ToArrayBuffer(secretBase64); - const dbAccount = await platformService.dbQuery( + const dbAccount = await platformService.dbQueryRaw( `SELECT * FROM accounts WHERE did = ?`, [activeDid], ); @@ -611,7 +611,7 @@ export const retrieveFullyDecryptedAccount = async ( export const retrieveAllAccountsMetadata = async (): Promise => { const platformService = PlatformServiceFactory.getInstance(); - const dbAccounts = await platformService.dbQuery(`SELECT * FROM accounts`); + const dbAccounts = await platformService.dbQueryRaw(`SELECT * FROM accounts`); const accounts = databaseUtil.mapQueryResultToValues(dbAccounts) as Account[]; let result = accounts.map((account) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -643,7 +643,7 @@ export async function saveNewIdentity( try { // add to the new sql db const platformService = PlatformServiceFactory.getInstance(); - const secrets = await platformService.dbQuery( + const secrets = await platformService.dbQueryRaw( `SELECT secretBase64 FROM secret`, ); if (!secrets?.values?.length || !secrets.values[0]?.length) { diff --git a/src/services/AbsurdSqlDatabaseService.ts b/src/services/AbsurdSqlDatabaseService.ts index 004e6c0b..74a74831 100644 --- a/src/services/AbsurdSqlDatabaseService.ts +++ b/src/services/AbsurdSqlDatabaseService.ts @@ -3,7 +3,7 @@ import { SQLiteFS } from "absurd-sql"; import IndexedDBBackend from "absurd-sql/dist/indexeddb-backend"; import { runMigrations } from "../db-sql/migration"; -import type { DatabaseService, QueryExecResult } from "../interfaces/database"; +import type { DatabaseService, QueryExecResultRaw } from "../interfaces/database"; import { logger } from "@/utils/logger"; interface QueuedOperation { @@ -15,7 +15,7 @@ interface QueuedOperation { } interface AbsurdSqlDatabase { - exec: (sql: string, params?: unknown[]) => Promise; + exec: (sql: string, params?: unknown[]) => Promise; run: ( sql: string, params?: unknown[], @@ -123,7 +123,7 @@ class AbsurdSqlDatabaseService implements DatabaseService { if (!operation) continue; try { - let queryResult: QueryExecResult[] = []; + let queryResult: QueryExecResultRaw[] = []; let result: unknown; switch (operation.type) { case "run": @@ -218,22 +218,9 @@ class AbsurdSqlDatabaseService implements DatabaseService { } // Note that the resulting array may be empty if there are no results from the query - async query(sql: string, params: unknown[] = []): Promise { + async query(sql: string, params: unknown[] = []): Promise { await this.waitForInitialization(); - return this.queueOperation("query", sql, params); - } - - async getOneRow( - sql: string, - params: unknown[] = [], - ): Promise { - await this.waitForInitialization(); - return this.queueOperation("getOneRow", sql, params); - } - - async getAll(sql: string, params: unknown[] = []): Promise { - await this.waitForInitialization(); - return this.queueOperation("getAll", sql, params); + return this.queueOperation("query", sql, params); } } diff --git a/src/services/PlatformService.ts b/src/services/PlatformService.ts index 65a61574..05f0cad2 100644 --- a/src/services/PlatformService.ts +++ b/src/services/PlatformService.ts @@ -1,12 +1,9 @@ -import { QueryExecResult } from "@/interfaces/database"; +import { QueryExecResultRaw } from "@/interfaces/database"; /** * Query execution result interface */ -export interface QueryExecResult { - columns: string[]; - values: T[]; -} +export type QueryExecResult = T[]; /** * Represents the result of an image capture or selection operation. @@ -110,12 +107,20 @@ export interface PlatformService { handleDeepLink(url: string): Promise; /** - * Execute a database query and return the results + * Execute a database query and return the well-typed results + * @param sql SQL query to execute + * @param params Query parameters + * @returns Query results with array of values + */ + // dbQuery(sql: string, params?: unknown[]): Promise>; + + /** + * Execute a database query and return the raw results * @param sql SQL query to execute * @param params Query parameters * @returns Query results with columns and values */ - dbQuery(sql: string, params?: unknown[]): Promise>; + dbQueryRaw(sql: string, params?: unknown[]): Promise; /** * Executes a create/update/delete on the database. diff --git a/src/services/migrationService.ts b/src/services/migrationService.ts index d571f1ba..904eeaf1 100644 --- a/src/services/migrationService.ts +++ b/src/services/migrationService.ts @@ -1,5 +1,5 @@ import { logger } from "@/utils/logger"; -import { QueryExecResult } from "../interfaces/database"; +import { QueryExecResultRaw } from "../interfaces/database"; interface Migration { name: string; @@ -27,7 +27,7 @@ export class MigrationService { sqlExec: ( sql: string, params?: unknown[], - ) => Promise>, + ) => Promise>, ): Promise { // Create migrations table if it doesn't exist await sqlExec(` @@ -39,7 +39,7 @@ export class MigrationService { `); // Get list of executed migrations - const result: QueryExecResult[] = await sqlExec( + const result: QueryExecResultRaw[] = await sqlExec( "SELECT name FROM migrations;", ); let executedMigrations: Set = new Set(); diff --git a/src/services/platforms/CapacitorPlatformService.ts b/src/services/platforms/CapacitorPlatformService.ts index 8df1985f..4b401e13 100644 --- a/src/services/platforms/CapacitorPlatformService.ts +++ b/src/services/platforms/CapacitorPlatformService.ts @@ -13,7 +13,7 @@ import { Changes, } from "@capacitor-community/sqlite"; import { logger } from "../../utils/logger"; -import { QueryExecResult, SqlValue } from "@/interfaces/database"; +import { QueryExecResultRaw, SqlValue } from "@/interfaces/database"; import { DEFAULT_ENDORSER_API_SERVER } from "@/constants/app"; interface Migration { @@ -657,9 +657,9 @@ export class CapacitorPlatformService implements PlatformService { } /** - * @see PlatformService.dbQuery + * @see PlatformService.dbQueryRaw */ - async dbQuery(sql: string, params?: unknown[]): Promise { + async dbQueryRaw(sql: string, params?: unknown[]): Promise { await this.initializeDatabase(); if (!this.db) { throw new Error("Database not initialized"); diff --git a/src/services/platforms/ElectronPlatformService.ts b/src/services/platforms/ElectronPlatformService.ts index 5caafa8a..759580c3 100644 --- a/src/services/platforms/ElectronPlatformService.ts +++ b/src/services/platforms/ElectronPlatformService.ts @@ -2,11 +2,10 @@ import { ImageResult, PlatformService, PlatformCapabilities, - QueryExecResult, } from "../PlatformService"; import { logger } from "../../utils/logger"; import { DEFAULT_ENDORSER_API_SERVER } from "@/constants/app"; -import { DatabaseConnectionPool } from "../database/ConnectionPool"; +import { QueryExecResultRaw, SqlValue } from "@/interfaces/database"; // Type for the electron window object declare global { @@ -325,10 +324,21 @@ export class ElectronPlatformService implements PlatformService { throw new Error("Not implemented"); } - /** - * @see PlatformService.dbQuery - */ - async dbQuery(sql: string, params: unknown[] = []): Promise> { + // /** + // * @see PlatformService.dbQueryRaw + // */ + // async dbQuery(sql: string, params: unknown[] = []): Promise> { + // await this.initializeDatabase(); + // if (this.dbFatalError) throw new Error("Database is in a fatal error state. Please restart the app."); + // const result = await this.sqlite.query({ + // database: this.dbName, + // statement: sql, + // values: params + // }); + // return (result.values || []) as T[]; + // } + + async dbQueryRaw(sql: string, params?: unknown[]): Promise { await this.initializeDatabase(); if (this.dbFatalError) throw new Error("Database is in a fatal error state. Please restart the app."); const result = await this.sqlite.query({ @@ -336,10 +346,10 @@ export class ElectronPlatformService implements PlatformService { statement: sql, values: params }); - const columns = result.values?.[0] ? Object.keys(result.values[0]) : []; + const columns = Object.keys(result.values?.[0] || {}); return { columns, - values: (result.values || []).map((row: Record) => row as T) + values: result.values.map((row: Record) => columns.map((column) => row[column] as SqlValue)) }; } diff --git a/src/services/platforms/PyWebViewPlatformService.ts b/src/services/platforms/PyWebViewPlatformService.ts index 5caf7b3a..7de5f0dc 100644 --- a/src/services/platforms/PyWebViewPlatformService.ts +++ b/src/services/platforms/PyWebViewPlatformService.ts @@ -4,7 +4,7 @@ import { PlatformCapabilities, } from "../PlatformService"; import { logger } from "../../utils/logger"; -import { QueryExecResult } from "@/interfaces/database"; +import { QueryExecResultRaw } from "@/interfaces/database"; /** * Platform service implementation for PyWebView platform. @@ -111,7 +111,7 @@ export class PyWebViewPlatformService implements PlatformService { throw new Error("Not implemented"); } - dbQuery(sql: string, params?: unknown[]): Promise { + dbQueryRaw(sql: string, params?: unknown[]): Promise { throw new Error("Not implemented for " + sql + " with params " + params); } dbExec( diff --git a/src/services/platforms/WebPlatformService.ts b/src/services/platforms/WebPlatformService.ts index 6f66367d..42fd7b59 100644 --- a/src/services/platforms/WebPlatformService.ts +++ b/src/services/platforms/WebPlatformService.ts @@ -4,7 +4,7 @@ import { PlatformCapabilities, } from "../PlatformService"; import { logger } from "../../utils/logger"; -import { QueryExecResult } from "@/interfaces/database"; +import { QueryExecResultRaw } from "@/interfaces/database"; import databaseService from "../AbsurdSqlDatabaseService"; /** @@ -362,32 +362,39 @@ export class WebPlatformService implements PlatformService { throw new Error("File system access not available in web platform"); } + // /** + // * @see PlatformService.dbQuery + // */ + // async dbQuery(sql: string, params: unknown[] = []): Promise> { + // const result = await databaseService.query(sql, params); + // const columns = result[0]?.columns || []; + // const values = result[0]?.values || []; + // return values.map((row: SqlValue[]) => { + // const obj: Record = {}; + // columns.forEach((column, index) => { + // obj[column] = row[index]; + // }); + // return obj as T; + // }); + // } + /** - * @see PlatformService.dbQuery + * @see PlatformService.dbQueryRaw */ - dbQuery( + async dbQueryRaw( sql: string, params?: unknown[], - ): Promise { + ): Promise { return databaseService.query(sql, params).then((result) => result[0]); } /** * @see PlatformService.dbExec */ - dbExec( + async dbExec( sql: string, params?: unknown[], ): Promise<{ changes: number; lastId?: number }> { return databaseService.run(sql, params); } - - async dbGetOneRow( - sql: string, - params?: unknown[], - ): Promise { - return databaseService - .query(sql, params) - .then((result: QueryExecResult[]) => result[0]?.values[0]); - } } diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 22f342f1..9e71ec34 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -1352,7 +1352,7 @@ export default class AccountViewView extends Vue { async processIdentity() { let account: Account | undefined = undefined; const platformService = PlatformServiceFactory.getInstance(); - const dbAccount = await platformService.dbQuery( + const dbAccount = await platformService.dbQueryRaw( "SELECT * FROM accounts WHERE did = ?", [this.activeDid], ); diff --git a/src/views/ClaimCertificateView.vue b/src/views/ClaimCertificateView.vue index a38f6f83..bb5ca467 100644 --- a/src/views/ClaimCertificateView.vue +++ b/src/views/ClaimCertificateView.vue @@ -91,7 +91,7 @@ export default class ClaimCertificateView extends Vue { confirmerIds: Array, ) { const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); let allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ClaimReportCertificateView.vue b/src/views/ClaimReportCertificateView.vue index fa42ec93..e8b1477f 100644 --- a/src/views/ClaimReportCertificateView.vue +++ b/src/views/ClaimReportCertificateView.vue @@ -73,7 +73,7 @@ export default class ClaimReportCertificateView extends Vue { claimData: endorserServer.GenericCredWrapper, ) { const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); let allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue index 2aeab8f6..4ce64fef 100644 --- a/src/views/ClaimView.vue +++ b/src/views/ClaimView.vue @@ -623,7 +623,7 @@ export default class ClaimView extends Vue { this.activeDid = settings.activeDid || ""; this.apiServer = settings.apiServer || ""; const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ConfirmGiftView.vue b/src/views/ConfirmGiftView.vue index 9ec3dfae..8e91f5ee 100644 --- a/src/views/ConfirmGiftView.vue +++ b/src/views/ConfirmGiftView.vue @@ -537,7 +537,7 @@ export default class ConfirmGiftView extends Vue { this.activeDid = settings.activeDid || ""; this.apiServer = settings.apiServer || ""; const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index 1d2f3916..742dbc13 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -157,7 +157,7 @@ export default class ContactAmountssView extends Vue { try { const contactDid = this.$route.query["contactDid"] as string; const platformService = PlatformServiceFactory.getInstance(); - const dbContact = await platformService.dbQuery( + const dbContact = await platformService.dbQueryRaw( "SELECT * FROM contacts WHERE did = ?", [contactDid], ); diff --git a/src/views/ContactEditView.vue b/src/views/ContactEditView.vue index b36b676c..917ca88f 100644 --- a/src/views/ContactEditView.vue +++ b/src/views/ContactEditView.vue @@ -223,7 +223,7 @@ export default class ContactEditView extends Vue { async created() { const contactDid = this.$route.params.did; const platformService = PlatformServiceFactory.getInstance(); - const dbContact = await platformService.dbQuery( + const dbContact = await platformService.dbQueryRaw( "SELECT * FROM contacts WHERE did = ?", [contactDid], ); diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index c359a817..084a1a0c 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -108,7 +108,7 @@ export default class ContactGiftingView extends Vue { this.activeDid = settings.activeDid || ""; const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts ORDER BY name", ); this.allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ContactImportView.vue b/src/views/ContactImportView.vue index ebbc21da..7f428599 100644 --- a/src/views/ContactImportView.vue +++ b/src/views/ContactImportView.vue @@ -412,7 +412,7 @@ export default class ContactImportView extends Vue { this.contactsSelected = new Array(this.contactsImporting.length).fill(true); const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); let baseContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ContactQRScanFullView.vue b/src/views/ContactQRScanFullView.vue index 8525d8d1..2bef7d87 100644 --- a/src/views/ContactQRScanFullView.vue +++ b/src/views/ContactQRScanFullView.vue @@ -443,7 +443,7 @@ export default class ContactQRScan extends Vue { // Check if contact already exists const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts WHERE did = ?", [contact.did], ); diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index 22728997..f78b19d2 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -770,7 +770,7 @@ export default class ContactQRScanShow extends Vue { // Check if contact already exists const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts WHERE did = ?", [contact.did], ); diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index beebf6e0..33604fe7 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -468,7 +468,7 @@ export default class ContactsView extends Vue { } const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts ORDER BY name", ); this.contacts = databaseUtil.mapQueryResultToValues( @@ -846,7 +846,7 @@ export default class ContactsView extends Vue { } const platformService = PlatformServiceFactory.getInstance(); - const dbAllContacts = await platformService.dbQuery( + const dbAllContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts ORDER BY name", ); this.contacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/DIDView.vue b/src/views/DIDView.vue index 5f7a1864..aa54a582 100644 --- a/src/views/DIDView.vue +++ b/src/views/DIDView.vue @@ -376,7 +376,7 @@ export default class DIDView extends Vue { if (!this.viewingDid) return; const platformService = PlatformServiceFactory.getInstance(); - const dbContacts = await platformService.dbQuery( + const dbContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts WHERE did = ?", [this.viewingDid], ); diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 09ca7a3b..bac20315 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -407,7 +407,7 @@ export default class DiscoverView extends Vue { this.searchBox = settings.searchBoxes?.[0] || null; const platformService = PlatformServiceFactory.getInstance(); - const dbContacts = await platformService.dbQuery("SELECT * FROM contacts"); + const dbContacts = await platformService.dbQueryRaw("SELECT * FROM contacts"); this.allContacts = databaseUtil.mapQueryResultToValues(dbContacts) as unknown as Contact[]; if (USE_DEXIE_DB) { this.allContacts = await db.contacts.toArray(); diff --git a/src/views/GiftedDetailsView.vue b/src/views/GiftedDetailsView.vue index dc9475a6..f5e749f6 100644 --- a/src/views/GiftedDetailsView.vue +++ b/src/views/GiftedDetailsView.vue @@ -440,7 +440,7 @@ export default class GiftedDetails extends Vue { (this.recipientDid && !this.recipientName) ) { const platformService = PlatformServiceFactory.getInstance(); - const dbContacts = await platformService.dbQuery( + const dbContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); let allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 4bd03745..931bbf47 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -530,7 +530,7 @@ export default class HomeView extends Vue { this.apiServer = settings.apiServer || ""; this.activeDid = settings.activeDid || ""; const platformService = PlatformServiceFactory.getInstance(); - const dbContacts = await platformService.dbQuery( + const dbContacts = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( @@ -666,7 +666,7 @@ export default class HomeView extends Vue { */ private async loadContacts() { const platformService = PlatformServiceFactory.getInstance(); - const dbContacts = await platformService.dbQuery("SELECT * FROM contacts"); + const dbContacts = await platformService.dbQueryRaw("SELECT * FROM contacts"); this.allContacts = databaseUtil.mapQueryResultToValues( dbContacts, ) as unknown as Contact[]; diff --git a/src/views/ImportDerivedAccountView.vue b/src/views/ImportDerivedAccountView.vue index 2561d659..56b6af09 100644 --- a/src/views/ImportDerivedAccountView.vue +++ b/src/views/ImportDerivedAccountView.vue @@ -129,7 +129,7 @@ export default class ImportAccountView extends Vue { []; const platformService = PlatformServiceFactory.getInstance(); const qmarks = selectedArray.map(() => "?").join(","); - const queryResult = await platformService.dbQuery( + const queryResult = await platformService.dbQueryRaw( `SELECT * FROM accounts WHERE did IN (${qmarks})`, selectedArray, ); diff --git a/src/views/InviteOneView.vue b/src/views/InviteOneView.vue index 0ae150c1..c34770a5 100644 --- a/src/views/InviteOneView.vue +++ b/src/views/InviteOneView.vue @@ -193,7 +193,7 @@ export default class InviteOneView extends Vue { this.invites = response.data.data; const platformService = PlatformServiceFactory.getInstance(); - const queryResult = await platformService.dbQuery( + const queryResult = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); let baseContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/LogView.vue b/src/views/LogView.vue index deecbb56..60f069d0 100644 --- a/src/views/LogView.vue +++ b/src/views/LogView.vue @@ -81,7 +81,7 @@ export default class LogView extends Vue { let allLogs: Log[] = []; const platformService = PlatformServiceFactory.getInstance(); - const queryResult = await platformService.dbQuery( + const queryResult = await platformService.dbQueryRaw( "SELECT * FROM logs ORDER BY date DESC", ); this.logs = databaseUtil.mapQueryResultToValues( diff --git a/src/views/NewActivityView.vue b/src/views/NewActivityView.vue index 0becc1b5..ce80b5d4 100644 --- a/src/views/NewActivityView.vue +++ b/src/views/NewActivityView.vue @@ -208,7 +208,7 @@ export default class NewActivityView extends Vue { settings.lastAckedOfferToUserProjectsJwtId || ""; const platformService = PlatformServiceFactory.getInstance(); - const queryResult = await platformService.dbQuery( + const queryResult = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/OfferDetailsView.vue b/src/views/OfferDetailsView.vue index 1c88fbba..5a64353c 100644 --- a/src/views/OfferDetailsView.vue +++ b/src/views/OfferDetailsView.vue @@ -418,7 +418,7 @@ export default class OfferDetailsView extends Vue { if (this.recipientDid && !this.recipientName) { let allContacts: Contact[] = []; const platformService = PlatformServiceFactory.getInstance(); - const queryResult = await platformService.dbQuery( + const queryResult = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 23718f3a..43b25216 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -787,7 +787,7 @@ export default class ProjectViewView extends Vue { this.activeDid = settings.activeDid || ""; this.apiServer = settings.apiServer || ""; const platformService = PlatformServiceFactory.getInstance(); - const queryResult = await platformService.dbQuery("SELECT * FROM contacts"); + const queryResult = await platformService.dbQueryRaw("SELECT * FROM contacts"); this.allContacts = databaseUtil.mapQueryResultToValues( queryResult, ) as unknown as Contact[]; diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 6b59749c..3009a1d9 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -336,7 +336,7 @@ export default class ProjectsView extends Vue { this.givenName = settings.firstName || ""; const platformService = PlatformServiceFactory.getInstance(); - const queryResult = await platformService.dbQuery( + const queryResult = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/QuickActionBvcEndView.vue b/src/views/QuickActionBvcEndView.vue index f9b62055..981aacbc 100644 --- a/src/views/QuickActionBvcEndView.vue +++ b/src/views/QuickActionBvcEndView.vue @@ -201,7 +201,7 @@ export default class QuickActionBvcBeginView extends Vue { this.activeDid = settings.activeDid || ""; const platformService = PlatformServiceFactory.getInstance(); - const contactQueryResult = await platformService.dbQuery( + const contactQueryResult = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( @@ -229,7 +229,7 @@ export default class QuickActionBvcBeginView extends Vue { suppressMilliseconds: true, }) || ""; - const queryResult = await platformService.dbQuery( + const queryResult = await platformService.dbQueryRaw( "SELECT did FROM accounts", ); this.allMyDids = diff --git a/src/views/RecentOffersToUserProjectsView.vue b/src/views/RecentOffersToUserProjectsView.vue index e613b82c..f6f3a30e 100644 --- a/src/views/RecentOffersToUserProjectsView.vue +++ b/src/views/RecentOffersToUserProjectsView.vue @@ -128,7 +128,7 @@ export default class RecentOffersToUserView extends Vue { settings.lastAckedOfferToUserProjectsJwtId || ""; const contactQueryResult = - await PlatformServiceFactory.getInstance().dbQuery( + await PlatformServiceFactory.getInstance().dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/RecentOffersToUserView.vue b/src/views/RecentOffersToUserView.vue index 8f2ab687..f1c9bdc6 100644 --- a/src/views/RecentOffersToUserView.vue +++ b/src/views/RecentOffersToUserView.vue @@ -119,7 +119,7 @@ export default class RecentOffersToUserView extends Vue { this.lastAckedOfferToUserJwtId = settings.lastAckedOfferToUserJwtId || ""; const contactQueryResult = - await PlatformServiceFactory.getInstance().dbQuery( + await PlatformServiceFactory.getInstance().dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues( diff --git a/src/views/ShareMyContactInfoView.vue b/src/views/ShareMyContactInfoView.vue index 445c2775..b7ea84f7 100644 --- a/src/views/ShareMyContactInfoView.vue +++ b/src/views/ShareMyContactInfoView.vue @@ -78,7 +78,7 @@ export default class ShareMyContactInfoView extends Vue { const account = await retrieveFullyDecryptedAccount(activeDid); const platformService = PlatformServiceFactory.getInstance(); - const contactQueryResult = await platformService.dbQuery( + const contactQueryResult = await platformService.dbQueryRaw( "SELECT COUNT(*) FROM contacts", ); let numContacts = diff --git a/src/views/SharedPhotoView.vue b/src/views/SharedPhotoView.vue index 7fb7606a..c878f275 100644 --- a/src/views/SharedPhotoView.vue +++ b/src/views/SharedPhotoView.vue @@ -111,7 +111,7 @@ export default class SharedPhotoView extends Vue { this.activeDid = settings.activeDid; const platformService = PlatformServiceFactory.getInstance(); - const tempQuery = await platformService.dbQuery( + const tempQuery = await platformService.dbQueryRaw( "SELECT * FROM temp WHERE id = ?", [SHARED_PHOTO_BASE64_KEY], ); diff --git a/src/views/TestView.vue b/src/views/TestView.vue index 91dd673b..1759db74 100644 --- a/src/views/TestView.vue +++ b/src/views/TestView.vue @@ -425,7 +425,7 @@ export default class Help extends Vue { this.fileName = (file as File).name; const platformService = PlatformServiceFactory.getInstance(); - const tempQuery = await platformService.dbQuery( + const tempQuery = await platformService.dbQueryRaw( "SELECT * FROM temp WHERE id = ?", [SHARED_PHOTO_BASE64_KEY], ); @@ -602,7 +602,7 @@ export default class Help extends Vue { try { const isSelect = this.sqlQuery.trim().toLowerCase().startsWith("select"); if (isSelect) { - this.sqlResult = await platformService.dbQuery(this.sqlQuery); + this.sqlResult = await platformService.dbQueryRaw(this.sqlQuery); } else { this.sqlResult = await platformService.dbExec(this.sqlQuery); } diff --git a/src/views/UserProfileView.vue b/src/views/UserProfileView.vue index 0e1471b8..0bbf7b70 100644 --- a/src/views/UserProfileView.vue +++ b/src/views/UserProfileView.vue @@ -140,7 +140,7 @@ export default class UserProfileView extends Vue { async mounted() { const platformService = PlatformServiceFactory.getInstance(); - const settingsQuery = await platformService.dbQuery( + const settingsQuery = await platformService.dbQueryRaw( "SELECT * FROM settings", ); let settings = databaseUtil.mapQueryResultToValues( @@ -153,7 +153,7 @@ export default class UserProfileView extends Vue { this.partnerApiServer = settings[0]?.partnerApiServer || this.partnerApiServer; - const contactQuery = await platformService.dbQuery( + const contactQuery = await platformService.dbQueryRaw( "SELECT * FROM contacts", ); this.allContacts = databaseUtil.mapQueryResultToValues(