Refactor commands and DB

This commit is contained in:
Gregory Schier
2024-02-01 02:29:24 -08:00
parent 3ab1f5308c
commit c655557313
46 changed files with 534 additions and 540 deletions

View File

@@ -25,7 +25,7 @@ export function trackEvent(
| 'Duplicate',
attributes: Record<string, string | number> = {},
) {
invoke('track_event', {
invoke('cmd_track_event', {
resource: resource,
action,
attributes,

View File

@@ -14,7 +14,7 @@ export async function setKeyValue<T>({
key: string | string[];
value: T;
}): Promise<void> {
await invoke('set_key_value', {
await invoke('cmd_set_key_value', {
namespace,
key: buildKeyValueKey(key),
value: JSON.stringify(value),
@@ -30,7 +30,7 @@ export async function getKeyValue<T>({
key: string | string[];
fallback: T;
}) {
const kv = (await invoke('get_key_value', {
const kv = (await invoke('cmd_get_key_value', {
namespace,
key: buildKeyValueKey(key),
})) as KeyValue | null;

View File

@@ -7,5 +7,5 @@ export async function sendEphemeralRequest(
): Promise<HttpResponse> {
// Remove some things that we don't want to associate
const newRequest = { ...request };
return invoke('send_ephemeral_request', { request: newRequest, environmentId });
return invoke('cmd_send_ephemeral_request', { request: newRequest, environmentId });
}

View File

@@ -2,12 +2,12 @@ import { invoke } from '@tauri-apps/api';
import type { CookieJar, Environment, Folder, HttpRequest, Settings, Workspace } from './models';
export async function getSettings(): Promise<Settings> {
return invoke('get_settings', {});
return invoke('cmd_get_settings', {});
}
export async function getRequest(id: string | null): Promise<HttpRequest | null> {
if (id === null) return null;
const request: HttpRequest = (await invoke('get_request', { id })) ?? null;
const request: HttpRequest = (await invoke('cmd_get_request', { id })) ?? null;
if (request == null) {
return null;
}
@@ -16,7 +16,7 @@ export async function getRequest(id: string | null): Promise<HttpRequest | null>
export async function getEnvironment(id: string | null): Promise<Environment | null> {
if (id === null) return null;
const environment: Environment = (await invoke('get_environment', { id })) ?? null;
const environment: Environment = (await invoke('cmd_get_environment', { id })) ?? null;
if (environment == null) {
return null;
}
@@ -25,7 +25,7 @@ export async function getEnvironment(id: string | null): Promise<Environment | n
export async function getFolder(id: string | null): Promise<Folder | null> {
if (id === null) return null;
const folder: Folder = (await invoke('get_folder', { id })) ?? null;
const folder: Folder = (await invoke('cmd_get_folder', { id })) ?? null;
if (folder == null) {
return null;
}
@@ -34,7 +34,7 @@ export async function getFolder(id: string | null): Promise<Folder | null> {
export async function getWorkspace(id: string | null): Promise<Workspace | null> {
if (id === null) return null;
const workspace: Workspace = (await invoke('get_workspace', { id })) ?? null;
const workspace: Workspace = (await invoke('cmd_get_workspace', { id })) ?? null;
if (workspace == null) {
return null;
}
@@ -43,7 +43,7 @@ export async function getWorkspace(id: string | null): Promise<Workspace | null>
export async function getCookieJar(id: string | null): Promise<CookieJar | null> {
if (id === null) return null;
const cookieJar: CookieJar = (await invoke('get_cookie_jar', { id })) ?? null;
const cookieJar: CookieJar = (await invoke('cmd_get_cookie_jar', { id })) ?? null;
if (cookieJar == null) {
return null;
}