From 1348fca84d940c862ba41ab20aa1884cf0baf3e7 Mon Sep 17 00:00:00 2001 From: Till-JS <101404291+Till-JS@users.noreply.github.com> Date: Thu, 29 Jan 2026 16:19:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20remove=20dupli?= =?UTF-8?q?cated=20code=20(Quick=20Wins)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Delete unused Input.svelte from Picture app (70 LOC) - Remove sleep() from shared-api-client, import from shared-utils - Fix NodeJS.Timeout type for browser compatibility Part of consolidation effort - see docs/CONSOLIDATION_OPPORTUNITIES.md Co-Authored-By: Claude Opus 4.5 --- .../web/src/lib/components/ui/Input.svelte | 69 ------------------- packages/shared-api-client/package.json | 3 + packages/shared-api-client/src/client.ts | 2 +- packages/shared-api-client/src/utils.ts | 7 -- packages/shared-utils/src/async.ts | 2 +- pnpm-lock.yaml | 4 ++ 6 files changed, 9 insertions(+), 78 deletions(-) delete mode 100644 apps/picture/apps/web/src/lib/components/ui/Input.svelte diff --git a/apps/picture/apps/web/src/lib/components/ui/Input.svelte b/apps/picture/apps/web/src/lib/components/ui/Input.svelte deleted file mode 100644 index 34bf4ed1f..000000000 --- a/apps/picture/apps/web/src/lib/components/ui/Input.svelte +++ /dev/null @@ -1,69 +0,0 @@ - - -{#if label} - -{/if} - - - -{#if error} -

{error}

-{/if} diff --git a/packages/shared-api-client/package.json b/packages/shared-api-client/package.json index d55304d8f..db2486ab6 100644 --- a/packages/shared-api-client/package.json +++ b/packages/shared-api-client/package.json @@ -15,6 +15,9 @@ "build": "tsc", "type-check": "tsc --noEmit" }, + "dependencies": { + "@manacore/shared-utils": "workspace:*" + }, "devDependencies": { "typescript": "^5.9.3" } diff --git a/packages/shared-api-client/src/client.ts b/packages/shared-api-client/src/client.ts index 0af2f3506..1dfe1b395 100644 --- a/packages/shared-api-client/src/client.ts +++ b/packages/shared-api-client/src/client.ts @@ -11,8 +11,8 @@ import { getErrorCodeFromStatus, isRetryableError, parseErrorResponse, - sleep, } from './utils'; +import { sleep } from '@manacore/shared-utils'; const DEFAULT_TIMEOUT = 30000; const DEFAULT_RETRIES = 0; diff --git a/packages/shared-api-client/src/utils.ts b/packages/shared-api-client/src/utils.ts index 413a88903..e1118e790 100644 --- a/packages/shared-api-client/src/utils.ts +++ b/packages/shared-api-client/src/utils.ts @@ -59,13 +59,6 @@ export async function parseErrorResponse(response: Response): Promise { } } -/** - * Sleep utility for retry delays - */ -export function sleep(ms: number): Promise { - return new Promise((resolve) => setTimeout(resolve, ms)); -} - /** * Check if error is retryable (network issues, 5xx errors) */ diff --git a/packages/shared-utils/src/async.ts b/packages/shared-utils/src/async.ts index 52a2d562f..7d1421d9b 100644 --- a/packages/shared-utils/src/async.ts +++ b/packages/shared-utils/src/async.ts @@ -51,7 +51,7 @@ export function debounce any>( fn: T, delay: number ): (...args: Parameters) => void { - let timeoutId: NodeJS.Timeout | null = null; + let timeoutId: ReturnType | null = null; return (...args: Parameters) => { if (timeoutId) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0dbccf43c..9be323785 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4472,6 +4472,10 @@ importers: version: 5.9.3 packages/shared-api-client: + dependencies: + '@manacore/shared-utils': + specifier: workspace:* + version: link:../shared-utils devDependencies: typescript: specifier: ^5.9.3