From aacece4e044d31104443f1545166502bc5ce8d44 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:53:48 +0100 Subject: [PATCH] fix: imports and typing Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> --- packages/backend/src/{ => managers}/playground.ts | 2 +- packages/backend/src/studio-api-impl.spec.ts | 2 +- packages/backend/src/studio-api-impl.ts | 2 +- packages/backend/src/studio.ts | 4 ++-- packages/frontend/src/pages/ModelPlayground.svelte | 6 +++--- packages/frontend/src/utils/client.ts | 2 +- packages/shared/src/{ => messages}/MessageProxy.spec.ts | 1 - packages/shared/src/{ => messages}/MessageProxy.ts | 8 ++++---- 8 files changed, 13 insertions(+), 14 deletions(-) rename packages/backend/src/{ => managers}/playground.ts (99%) rename packages/shared/src/{ => messages}/MessageProxy.spec.ts (96%) rename packages/shared/src/{ => messages}/MessageProxy.ts (95%) diff --git a/packages/backend/src/playground.ts b/packages/backend/src/managers/playground.ts similarity index 99% rename from packages/backend/src/playground.ts rename to packages/backend/src/managers/playground.ts index 214c9349d..c1ccfbe47 100644 --- a/packages/backend/src/playground.ts +++ b/packages/backend/src/managers/playground.ts @@ -10,7 +10,7 @@ import type { ModelResponse } from '@shared/src/models/IModelResponse'; import path from 'node:path'; import * as http from 'node:http'; -import { getFreePort } from './utils/ports'; +import { getFreePort } from '../utils/ports'; import type { QueryState } from '@shared/src/models/IPlaygroundQueryState'; import { MSG_NEW_PLAYGROUND_QUERIES_STATE } from '@shared/Messages'; diff --git a/packages/backend/src/studio-api-impl.spec.ts b/packages/backend/src/studio-api-impl.spec.ts index ab3423765..029a89c45 100644 --- a/packages/backend/src/studio-api-impl.spec.ts +++ b/packages/backend/src/studio-api-impl.spec.ts @@ -24,7 +24,7 @@ import userContent from './ai-user-test.json'; import type { ApplicationManager } from './managers/applicationManager'; import type { RecipeStatusRegistry } from './registries/RecipeStatusRegistry'; import { StudioApiImpl } from './studio-api-impl'; -import type { PlayGroundManager } from './playground'; +import type { PlayGroundManager } from './managers/playground'; import type { TaskRegistry } from './registries/TaskRegistry'; import * as fs from 'node:fs'; diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index 30f0c5ab6..754a22748 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -8,7 +8,7 @@ import type { RecipeStatus } from '@shared/src/models/IRecipeStatus'; import type { ModelInfo } from '@shared/src/models/IModelInfo'; import type { TaskRegistry } from './registries/TaskRegistry'; import type { Task } from '@shared/src/models/ITask'; -import type { PlayGroundManager } from './playground'; +import type { PlayGroundManager } from './managers/playground'; import * as podmanDesktopApi from '@podman-desktop/api'; import type { QueryState } from '@shared/src/models/IPlaygroundQueryState'; import type { Catalog } from '@shared/src/models/ICatalog'; diff --git a/packages/backend/src/studio.ts b/packages/backend/src/studio.ts index 7ec079d86..ce438cff1 100644 --- a/packages/backend/src/studio.ts +++ b/packages/backend/src/studio.ts @@ -18,7 +18,7 @@ import type { ExtensionContext, WebviewOptions, WebviewPanel } from '@podman-desktop/api'; import { Uri, window } from '@podman-desktop/api'; -import { RpcExtension } from '@shared/src/MessageProxy'; +import { RpcExtension } from '@shared/src/messages/MessageProxy'; import { StudioApiImpl } from './studio-api-impl'; import { ApplicationManager } from './managers/applicationManager'; import { GitManager } from './managers/gitManager'; @@ -26,7 +26,7 @@ import { RecipeStatusRegistry } from './registries/RecipeStatusRegistry'; import * as fs from 'node:fs'; import { TaskRegistry } from './registries/TaskRegistry'; -import { PlayGroundManager } from './playground'; +import { PlayGroundManager } from './managers/playground'; export class Studio { readonly #extensionContext: ExtensionContext; diff --git a/packages/frontend/src/pages/ModelPlayground.svelte b/packages/frontend/src/pages/ModelPlayground.svelte index ab4811b62..62907d27d 100644 --- a/packages/frontend/src/pages/ModelPlayground.svelte +++ b/packages/frontend/src/pages/ModelPlayground.svelte @@ -60,7 +60,7 @@ result = undefined; // do not display anything before we get a response from askPlayground // (we can receive a new queryState before the new QueryId) - queryId = -1; + queryId = -1; queryId = await studioClient.askPlayground(model.id, prompt); } @@ -73,8 +73,8 @@ rows="4" class="w-full p-2 outline-none text-sm bg-charcoal-800 rounded-sm text-gray-700 placeholder-gray-700" placeholder="Type your prompt here"> - -
+ +
diff --git a/packages/frontend/src/utils/client.ts b/packages/frontend/src/utils/client.ts index 71c97a9c9..93efd1cea 100644 --- a/packages/frontend/src/utils/client.ts +++ b/packages/frontend/src/utils/client.ts @@ -1,5 +1,5 @@ import type { StudioAPI } from '@shared/src/StudioAPI'; -import { RpcBrowser } from '@shared/src/MessageProxy'; +import { RpcBrowser } from '@shared/src/messages/MessageProxy'; export const RECENT_CATEGORY_ID = 'recent-category'; const podmanDesktopApi = acquirePodmanDesktopApi(); diff --git a/packages/shared/src/MessageProxy.spec.ts b/packages/shared/src/messages/MessageProxy.spec.ts similarity index 96% rename from packages/shared/src/MessageProxy.spec.ts rename to packages/shared/src/messages/MessageProxy.spec.ts index 595ce0fa6..656b9b9e6 100644 --- a/packages/shared/src/MessageProxy.spec.ts +++ b/packages/shared/src/messages/MessageProxy.spec.ts @@ -1,6 +1,5 @@ import { test, expect, beforeAll } from 'vitest'; import { RpcBrowser, RpcExtension } from './MessageProxy'; -import type { PodmanDesktopApi } from '../../../types/podman-desktop-api'; import type { Webview } from '@podman-desktop/api'; let webview: Webview; diff --git a/packages/shared/src/MessageProxy.ts b/packages/shared/src/messages/MessageProxy.ts similarity index 95% rename from packages/shared/src/MessageProxy.ts rename to packages/shared/src/messages/MessageProxy.ts index 6e5e777b6..e98e83c56 100644 --- a/packages/shared/src/MessageProxy.ts +++ b/packages/shared/src/messages/MessageProxy.ts @@ -17,7 +17,6 @@ ***********************************************************************/ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { PodmanDesktopApi } from '../../../types/podman-desktop-api'; import type { Webview } from '@podman-desktop/api'; export interface IMessage { @@ -40,6 +39,8 @@ export interface ISubscribedMessage { body: any; } +type UnaryRPC = (...args: unknown[]) => Promise; + export function isMessageRequest(content: unknown): content is IMessageRequest { return ( content !== undefined && content !== null && typeof content === 'object' && 'id' in content && 'channel' in content @@ -90,7 +91,7 @@ export class RpcExtension { }); } - registerInstance(classType: { new (...args: any[]): T }, instance: T) { + registerInstance>(classType: { new (...args: any[]): T }, instance: T) { const methodNames = Object.getOwnPropertyNames(classType.prototype).filter( name => name !== 'constructor' && typeof instance[name as keyof T] === 'function', ); @@ -156,8 +157,7 @@ export class RpcBrowser { getProxy(): T { // eslint-disable-next-line @typescript-eslint/no-this-alias const thisRef = this; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const proxyHandler: ProxyHandler = { + const proxyHandler: ProxyHandler = { get(target, prop, receiver) { if (typeof prop === 'string') { return (...args: unknown[]) => {