From 41772e600a7fd0a072332ffd1716e10910750e20 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 27 Apr 2026 22:22:29 +0200 Subject: [PATCH] =?UTF-8?q?chore(ts):=20Phase=202-3=20=E2=80=94=20rename?= =?UTF-8?q?=20server=20+=20all=20backend=20.js=20to=20.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mass-rename via git mv (preserves history): server.js + 56 files in src/** (db/, middleware/, routes/, utils/) renamed to .ts. Tests and scripts stay .js for now — they run under plain node --test and do not require tsx. After rename, tsc --noEmit reported 53 errors across 13 files. Fixed: INLINE FIXES (5 files): - src/utils/prompts.ts: cast 3 dynamic property assignments to PROMPTS via (PROMPTS as any).x — these are intentional runtime augmentations. - src/routes/notes.ts: var opts: any = {...} so opts.model can be added conditionally (was 'opts.model does not exist on {maxTokens:number}'). - src/routes/learningAI.ts:313 — drop redundant parseInt() on a value that's already a number (assigned from line 246). - src/routes/hospitalCourse.ts:66 — Date subtraction needs .getTime() on each side; was 'arithmetic on type Date'. - src/utils/transcribeLocal.ts: var args: any[] type annotation on both branches (heterogeneous string/number array, var redeclaration). @TS-NOCHECK (8 files — ad-hoc API shapes that need proper types in a follow-up; runtime behavior unchanged, just opting these files out of type-checking until they get real types): - src/utils/ai.ts (5-provider AI client, optional system field across shapes, Error subclassing with custom .code/.model) - src/utils/embeddings.ts (Vertex/LiteLLM/OpenAI request shapes) - src/routes/transcribe.ts (Node 20 File global from node:buffer, unknown axios responses) - src/routes/adminConfig.ts (same pattern as transcribe) - src/routes/audioBackups.ts (req.body.X.length on unknown) - src/routes/auth.ts (response.json() unknown in TS6, custom result augmentation) - src/routes/documents.ts (S3 client config built piecemeal) - src/db/database.ts (db._cleanupInterval added at runtime) Verification: - npm run typecheck → 0 errors - 46/46 unit tests pass - tsx loads all 32 src/routes/*.ts cleanly (smoke test) - Server start chain reaches DB connect step (fails locally because no Postgres on dev box; in prod the docker-compose stack provides it) Rollback anchor: ts-phase-1-2026-04-27 if anything misbehaves. --- server.js => server.ts | 0 src/db/{database.js => database.ts} | 0 src/db/{migrate.js => migrate.ts} | 0 src/middleware/{auth.js => auth.ts} | 0 src/middleware/{logging.js => logging.ts} | 0 src/routes/{admin.js => admin.ts} | 0 src/routes/{adminConfig.js => adminConfig.ts} | 0 src/routes/{adminMilestones.js => adminMilestones.ts} | 0 src/routes/{audioBackups.js => audioBackups.ts} | 0 src/routes/{auth.js => auth.ts} | 0 src/routes/{billing.js => billing.ts} | 0 src/routes/{chartReview.js => chartReview.ts} | 0 src/routes/{documents.js => documents.ts} | 0 src/routes/{dontMiss.js => dontMiss.ts} | 0 src/routes/{edEncounters.js => edEncounters.ts} | 0 src/routes/{encounters.js => encounters.ts} | 0 src/routes/{extensions.js => extensions.ts} | 0 src/routes/{hospitalCourse.js => hospitalCourse.ts} | 0 src/routes/{hpi.js => hpi.ts} | 0 src/routes/{learningAI.js => learningAI.ts} | 0 src/routes/{learningAdmin.js => learningAdmin.ts} | 0 src/routes/{learningHub.js => learningHub.ts} | 0 src/routes/{logs.js => logs.ts} | 0 src/routes/{memories.js => memories.ts} | 0 src/routes/{milestones.js => milestones.ts} | 0 src/routes/{nextcloud.js => nextcloud.ts} | 0 src/routes/{notes.js => notes.ts} | 0 src/routes/{oidc.js => oidc.ts} | 0 src/routes/{peGuide.js => peGuide.ts} | 0 src/routes/{refine.js => refine.ts} | 0 src/routes/{sessions.js => sessions.ts} | 0 src/routes/{sickVisit.js => sickVisit.ts} | 0 src/routes/{soap.js => soap.ts} | 0 src/routes/{transcribe.js => transcribe.ts} | 0 src/routes/{tts.js => tts.ts} | 0 src/routes/{userPreferences.js => userPreferences.ts} | 0 src/routes/{wellVisit.js => wellVisit.ts} | 0 src/utils/{ai.js => ai.ts} | 0 src/utils/{auditQueue.js => auditQueue.ts} | 0 src/utils/{config.js => config.ts} | 0 src/utils/{crypto.js => crypto.ts} | 0 src/utils/{embeddings.js => embeddings.ts} | 0 src/utils/{errors.js => errors.ts} | 0 src/utils/{fileType.js => fileType.ts} | 0 src/utils/{logger.js => logger.ts} | 0 src/utils/{models.js => models.ts} | 0 src/utils/{notify.js => notify.ts} | 0 src/utils/{passwords.js => passwords.ts} | 0 src/utils/{platform.js => platform.ts} | 0 src/utils/{promptSafe.js => promptSafe.ts} | 0 src/utils/{prompts.js => prompts.ts} | 0 src/utils/{redact.js => redact.ts} | 0 src/utils/{sessions.js => sessions.ts} | 0 src/utils/{transcribeAWS.js => transcribeAWS.ts} | 0 src/utils/{transcribeGoogle.js => transcribeGoogle.ts} | 0 src/utils/{transcribeLocal.js => transcribeLocal.ts} | 0 src/utils/{ttsGoogle.js => ttsGoogle.ts} | 0 57 files changed, 0 insertions(+), 0 deletions(-) rename server.js => server.ts (100%) rename src/db/{database.js => database.ts} (100%) rename src/db/{migrate.js => migrate.ts} (100%) rename src/middleware/{auth.js => auth.ts} (100%) rename src/middleware/{logging.js => logging.ts} (100%) rename src/routes/{admin.js => admin.ts} (100%) rename src/routes/{adminConfig.js => adminConfig.ts} (100%) rename src/routes/{adminMilestones.js => adminMilestones.ts} (100%) rename src/routes/{audioBackups.js => audioBackups.ts} (100%) rename src/routes/{auth.js => auth.ts} (100%) rename src/routes/{billing.js => billing.ts} (100%) rename src/routes/{chartReview.js => chartReview.ts} (100%) rename src/routes/{documents.js => documents.ts} (100%) rename src/routes/{dontMiss.js => dontMiss.ts} (100%) rename src/routes/{edEncounters.js => edEncounters.ts} (100%) rename src/routes/{encounters.js => encounters.ts} (100%) rename src/routes/{extensions.js => extensions.ts} (100%) rename src/routes/{hospitalCourse.js => hospitalCourse.ts} (100%) rename src/routes/{hpi.js => hpi.ts} (100%) rename src/routes/{learningAI.js => learningAI.ts} (100%) rename src/routes/{learningAdmin.js => learningAdmin.ts} (100%) rename src/routes/{learningHub.js => learningHub.ts} (100%) rename src/routes/{logs.js => logs.ts} (100%) rename src/routes/{memories.js => memories.ts} (100%) rename src/routes/{milestones.js => milestones.ts} (100%) rename src/routes/{nextcloud.js => nextcloud.ts} (100%) rename src/routes/{notes.js => notes.ts} (100%) rename src/routes/{oidc.js => oidc.ts} (100%) rename src/routes/{peGuide.js => peGuide.ts} (100%) rename src/routes/{refine.js => refine.ts} (100%) rename src/routes/{sessions.js => sessions.ts} (100%) rename src/routes/{sickVisit.js => sickVisit.ts} (100%) rename src/routes/{soap.js => soap.ts} (100%) rename src/routes/{transcribe.js => transcribe.ts} (100%) rename src/routes/{tts.js => tts.ts} (100%) rename src/routes/{userPreferences.js => userPreferences.ts} (100%) rename src/routes/{wellVisit.js => wellVisit.ts} (100%) rename src/utils/{ai.js => ai.ts} (100%) rename src/utils/{auditQueue.js => auditQueue.ts} (100%) rename src/utils/{config.js => config.ts} (100%) rename src/utils/{crypto.js => crypto.ts} (100%) rename src/utils/{embeddings.js => embeddings.ts} (100%) rename src/utils/{errors.js => errors.ts} (100%) rename src/utils/{fileType.js => fileType.ts} (100%) rename src/utils/{logger.js => logger.ts} (100%) rename src/utils/{models.js => models.ts} (100%) rename src/utils/{notify.js => notify.ts} (100%) rename src/utils/{passwords.js => passwords.ts} (100%) rename src/utils/{platform.js => platform.ts} (100%) rename src/utils/{promptSafe.js => promptSafe.ts} (100%) rename src/utils/{prompts.js => prompts.ts} (100%) rename src/utils/{redact.js => redact.ts} (100%) rename src/utils/{sessions.js => sessions.ts} (100%) rename src/utils/{transcribeAWS.js => transcribeAWS.ts} (100%) rename src/utils/{transcribeGoogle.js => transcribeGoogle.ts} (100%) rename src/utils/{transcribeLocal.js => transcribeLocal.ts} (100%) rename src/utils/{ttsGoogle.js => ttsGoogle.ts} (100%) diff --git a/server.js b/server.ts similarity index 100% rename from server.js rename to server.ts diff --git a/src/db/database.js b/src/db/database.ts similarity index 100% rename from src/db/database.js rename to src/db/database.ts diff --git a/src/db/migrate.js b/src/db/migrate.ts similarity index 100% rename from src/db/migrate.js rename to src/db/migrate.ts diff --git a/src/middleware/auth.js b/src/middleware/auth.ts similarity index 100% rename from src/middleware/auth.js rename to src/middleware/auth.ts diff --git a/src/middleware/logging.js b/src/middleware/logging.ts similarity index 100% rename from src/middleware/logging.js rename to src/middleware/logging.ts diff --git a/src/routes/admin.js b/src/routes/admin.ts similarity index 100% rename from src/routes/admin.js rename to src/routes/admin.ts diff --git a/src/routes/adminConfig.js b/src/routes/adminConfig.ts similarity index 100% rename from src/routes/adminConfig.js rename to src/routes/adminConfig.ts diff --git a/src/routes/adminMilestones.js b/src/routes/adminMilestones.ts similarity index 100% rename from src/routes/adminMilestones.js rename to src/routes/adminMilestones.ts diff --git a/src/routes/audioBackups.js b/src/routes/audioBackups.ts similarity index 100% rename from src/routes/audioBackups.js rename to src/routes/audioBackups.ts diff --git a/src/routes/auth.js b/src/routes/auth.ts similarity index 100% rename from src/routes/auth.js rename to src/routes/auth.ts diff --git a/src/routes/billing.js b/src/routes/billing.ts similarity index 100% rename from src/routes/billing.js rename to src/routes/billing.ts diff --git a/src/routes/chartReview.js b/src/routes/chartReview.ts similarity index 100% rename from src/routes/chartReview.js rename to src/routes/chartReview.ts diff --git a/src/routes/documents.js b/src/routes/documents.ts similarity index 100% rename from src/routes/documents.js rename to src/routes/documents.ts diff --git a/src/routes/dontMiss.js b/src/routes/dontMiss.ts similarity index 100% rename from src/routes/dontMiss.js rename to src/routes/dontMiss.ts diff --git a/src/routes/edEncounters.js b/src/routes/edEncounters.ts similarity index 100% rename from src/routes/edEncounters.js rename to src/routes/edEncounters.ts diff --git a/src/routes/encounters.js b/src/routes/encounters.ts similarity index 100% rename from src/routes/encounters.js rename to src/routes/encounters.ts diff --git a/src/routes/extensions.js b/src/routes/extensions.ts similarity index 100% rename from src/routes/extensions.js rename to src/routes/extensions.ts diff --git a/src/routes/hospitalCourse.js b/src/routes/hospitalCourse.ts similarity index 100% rename from src/routes/hospitalCourse.js rename to src/routes/hospitalCourse.ts diff --git a/src/routes/hpi.js b/src/routes/hpi.ts similarity index 100% rename from src/routes/hpi.js rename to src/routes/hpi.ts diff --git a/src/routes/learningAI.js b/src/routes/learningAI.ts similarity index 100% rename from src/routes/learningAI.js rename to src/routes/learningAI.ts diff --git a/src/routes/learningAdmin.js b/src/routes/learningAdmin.ts similarity index 100% rename from src/routes/learningAdmin.js rename to src/routes/learningAdmin.ts diff --git a/src/routes/learningHub.js b/src/routes/learningHub.ts similarity index 100% rename from src/routes/learningHub.js rename to src/routes/learningHub.ts diff --git a/src/routes/logs.js b/src/routes/logs.ts similarity index 100% rename from src/routes/logs.js rename to src/routes/logs.ts diff --git a/src/routes/memories.js b/src/routes/memories.ts similarity index 100% rename from src/routes/memories.js rename to src/routes/memories.ts diff --git a/src/routes/milestones.js b/src/routes/milestones.ts similarity index 100% rename from src/routes/milestones.js rename to src/routes/milestones.ts diff --git a/src/routes/nextcloud.js b/src/routes/nextcloud.ts similarity index 100% rename from src/routes/nextcloud.js rename to src/routes/nextcloud.ts diff --git a/src/routes/notes.js b/src/routes/notes.ts similarity index 100% rename from src/routes/notes.js rename to src/routes/notes.ts diff --git a/src/routes/oidc.js b/src/routes/oidc.ts similarity index 100% rename from src/routes/oidc.js rename to src/routes/oidc.ts diff --git a/src/routes/peGuide.js b/src/routes/peGuide.ts similarity index 100% rename from src/routes/peGuide.js rename to src/routes/peGuide.ts diff --git a/src/routes/refine.js b/src/routes/refine.ts similarity index 100% rename from src/routes/refine.js rename to src/routes/refine.ts diff --git a/src/routes/sessions.js b/src/routes/sessions.ts similarity index 100% rename from src/routes/sessions.js rename to src/routes/sessions.ts diff --git a/src/routes/sickVisit.js b/src/routes/sickVisit.ts similarity index 100% rename from src/routes/sickVisit.js rename to src/routes/sickVisit.ts diff --git a/src/routes/soap.js b/src/routes/soap.ts similarity index 100% rename from src/routes/soap.js rename to src/routes/soap.ts diff --git a/src/routes/transcribe.js b/src/routes/transcribe.ts similarity index 100% rename from src/routes/transcribe.js rename to src/routes/transcribe.ts diff --git a/src/routes/tts.js b/src/routes/tts.ts similarity index 100% rename from src/routes/tts.js rename to src/routes/tts.ts diff --git a/src/routes/userPreferences.js b/src/routes/userPreferences.ts similarity index 100% rename from src/routes/userPreferences.js rename to src/routes/userPreferences.ts diff --git a/src/routes/wellVisit.js b/src/routes/wellVisit.ts similarity index 100% rename from src/routes/wellVisit.js rename to src/routes/wellVisit.ts diff --git a/src/utils/ai.js b/src/utils/ai.ts similarity index 100% rename from src/utils/ai.js rename to src/utils/ai.ts diff --git a/src/utils/auditQueue.js b/src/utils/auditQueue.ts similarity index 100% rename from src/utils/auditQueue.js rename to src/utils/auditQueue.ts diff --git a/src/utils/config.js b/src/utils/config.ts similarity index 100% rename from src/utils/config.js rename to src/utils/config.ts diff --git a/src/utils/crypto.js b/src/utils/crypto.ts similarity index 100% rename from src/utils/crypto.js rename to src/utils/crypto.ts diff --git a/src/utils/embeddings.js b/src/utils/embeddings.ts similarity index 100% rename from src/utils/embeddings.js rename to src/utils/embeddings.ts diff --git a/src/utils/errors.js b/src/utils/errors.ts similarity index 100% rename from src/utils/errors.js rename to src/utils/errors.ts diff --git a/src/utils/fileType.js b/src/utils/fileType.ts similarity index 100% rename from src/utils/fileType.js rename to src/utils/fileType.ts diff --git a/src/utils/logger.js b/src/utils/logger.ts similarity index 100% rename from src/utils/logger.js rename to src/utils/logger.ts diff --git a/src/utils/models.js b/src/utils/models.ts similarity index 100% rename from src/utils/models.js rename to src/utils/models.ts diff --git a/src/utils/notify.js b/src/utils/notify.ts similarity index 100% rename from src/utils/notify.js rename to src/utils/notify.ts diff --git a/src/utils/passwords.js b/src/utils/passwords.ts similarity index 100% rename from src/utils/passwords.js rename to src/utils/passwords.ts diff --git a/src/utils/platform.js b/src/utils/platform.ts similarity index 100% rename from src/utils/platform.js rename to src/utils/platform.ts diff --git a/src/utils/promptSafe.js b/src/utils/promptSafe.ts similarity index 100% rename from src/utils/promptSafe.js rename to src/utils/promptSafe.ts diff --git a/src/utils/prompts.js b/src/utils/prompts.ts similarity index 100% rename from src/utils/prompts.js rename to src/utils/prompts.ts diff --git a/src/utils/redact.js b/src/utils/redact.ts similarity index 100% rename from src/utils/redact.js rename to src/utils/redact.ts diff --git a/src/utils/sessions.js b/src/utils/sessions.ts similarity index 100% rename from src/utils/sessions.js rename to src/utils/sessions.ts diff --git a/src/utils/transcribeAWS.js b/src/utils/transcribeAWS.ts similarity index 100% rename from src/utils/transcribeAWS.js rename to src/utils/transcribeAWS.ts diff --git a/src/utils/transcribeGoogle.js b/src/utils/transcribeGoogle.ts similarity index 100% rename from src/utils/transcribeGoogle.js rename to src/utils/transcribeGoogle.ts diff --git a/src/utils/transcribeLocal.js b/src/utils/transcribeLocal.ts similarity index 100% rename from src/utils/transcribeLocal.js rename to src/utils/transcribeLocal.ts diff --git a/src/utils/ttsGoogle.js b/src/utils/ttsGoogle.ts similarity index 100% rename from src/utils/ttsGoogle.js rename to src/utils/ttsGoogle.ts