mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
chore(style): repo-wide prettier sweep before v1.4.6 tag
Long-overdue prettier sweep; prettier had drifted vs. checked-in code across ~130 files (mostly long-argument line-break wrapping in TS and table-padding in markdown). Pure formatting — no semantic changes — and required to clear the v1.4.6 release gate's `pnpm format:check`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
67575180b8
commit
02b99553b9
135 files changed
+2159
-1583
No files matched your search
@@ -47,9 +47,7 @@ describe("AnthropicClient", () => {
|
||||
expect(body.temperature).toBe(0.4);
|
||||
// System prompt is a separate top-level field, NOT a message.
|
||||
expect(body.system).toBe("You are a doctor.");
|
||||
expect(body.messages).toEqual([
|
||||
expect.objectContaining({ role: "user" }),
|
||||
]);
|
||||
expect(body.messages).toEqual([expect.objectContaining({ role: "user" })]);
|
||||
// User message should be wrapped to coerce JSON output.
|
||||
expect(body.messages[0].content).toContain("Analyze this data.");
|
||||
expect(body.messages[0].content.toLowerCase()).toContain("json");
|
||||
@@ -87,7 +85,7 @@ describe("AnthropicClient", () => {
|
||||
status: 529,
|
||||
text: () =>
|
||||
Promise.resolve(
|
||||
'overloaded; debug=sk-ant-supersecretkey1234567890 leaked',
|
||||
"overloaded; debug=sk-ant-supersecretkey1234567890 leaked",
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -12,7 +12,10 @@ describe("CodexClient", () => {
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
output: [
|
||||
{ type: "message", content: [{ type: "output_text", text: '{"summary":"ok"}' }] },
|
||||
{
|
||||
type: "message",
|
||||
content: [{ type: "output_text", text: '{"summary":"ok"}' }],
|
||||
},
|
||||
],
|
||||
usage: { total_tokens: 50 },
|
||||
}),
|
||||
@@ -44,13 +47,20 @@ describe("CodexClient", () => {
|
||||
|
||||
const mockFetch = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({ ok: false, status: 401, text: () => Promise.resolve("unauthorized") })
|
||||
.mockResolvedValueOnce({
|
||||
ok: false,
|
||||
status: 401,
|
||||
text: () => Promise.resolve("unauthorized"),
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
output: [
|
||||
{ type: "message", content: [{ type: "output_text", text: '{"test":true}' }] },
|
||||
{
|
||||
type: "message",
|
||||
content: [{ type: "output_text", text: '{"test":true}' }],
|
||||
},
|
||||
],
|
||||
usage: { total_tokens: 10 },
|
||||
}),
|
||||
@@ -69,7 +79,9 @@ describe("CodexClient", () => {
|
||||
|
||||
expect(onRefresh).toHaveBeenCalledOnce();
|
||||
expect(result.content).toBe('{"test":true}');
|
||||
expect(mockFetch.mock.calls[1][1].headers.Authorization).toBe(`Bearer ${newToken}`);
|
||||
expect(mockFetch.mock.calls[1][1].headers.Authorization).toBe(
|
||||
`Bearer ${newToken}`,
|
||||
);
|
||||
});
|
||||
|
||||
it("throws after retry if still 401", async () => {
|
||||
|
||||
@@ -69,7 +69,9 @@ describe("codex-oauth", () => {
|
||||
expect(parsed.searchParams.get("code_challenge")).toBe("test-challenge");
|
||||
expect(parsed.searchParams.get("code_challenge_method")).toBe("S256");
|
||||
expect(parsed.searchParams.get("state")).toBe("test-state");
|
||||
expect(parsed.searchParams.get("redirect_uri")).toBe("https://example.com/callback");
|
||||
expect(parsed.searchParams.get("redirect_uri")).toBe(
|
||||
"https://example.com/callback",
|
||||
);
|
||||
});
|
||||
|
||||
it("throws CodexOAuthNotConfiguredError when CODEX_OAUTH_CLIENT_ID is unset", () => {
|
||||
|
||||
@@ -103,7 +103,7 @@ describe("LocalOpenAICompatibleClient", () => {
|
||||
status: 500,
|
||||
text: () =>
|
||||
Promise.resolve(
|
||||
'upstream rejected: Bearer sk-localabcdef12345 hit /v1',
|
||||
"upstream rejected: Bearer sk-localabcdef12345 hit /v1",
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -79,7 +79,10 @@ describe("OpenAIClient", () => {
|
||||
baseUrl: "https://openrouter.ai/api/v1",
|
||||
});
|
||||
|
||||
await client.generateCompletion({ systemPrompt: "test", userPrompt: "test" });
|
||||
await client.generateCompletion({
|
||||
systemPrompt: "test",
|
||||
userPrompt: "test",
|
||||
});
|
||||
|
||||
expect(mockFetch.mock.calls[0][0]).toBe(
|
||||
"https://openrouter.ai/api/v1/chat/completions",
|
||||
|
||||
@@ -22,10 +22,7 @@ vi.mock("@/lib/ai/codex-oauth", () => ({
|
||||
import { resolveProvider } from "../provider";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { decrypt, encrypt } from "@/lib/crypto";
|
||||
import {
|
||||
decryptTokens,
|
||||
encryptTokens,
|
||||
} from "@/lib/ai/codex-oauth";
|
||||
import { decryptTokens, encryptTokens } from "@/lib/ai/codex-oauth";
|
||||
|
||||
/**
|
||||
* resolveProvider() makes up to TWO findUnique calls per invocation:
|
||||
|
||||
@@ -26,8 +26,13 @@ export class AnthropicClient implements AIProvider {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
async generateCompletion(params: CompletionParams): Promise<CompletionResult> {
|
||||
const baseUrl = (this.config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
||||
async generateCompletion(
|
||||
params: CompletionParams,
|
||||
): Promise<CompletionResult> {
|
||||
const baseUrl = (this.config.baseUrl ?? DEFAULT_BASE_URL).replace(
|
||||
/\/$/,
|
||||
"",
|
||||
);
|
||||
const url = `${baseUrl}/messages`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
@@ -42,9 +47,7 @@ export class AnthropicClient implements AIProvider {
|
||||
max_tokens: params.maxTokens ?? 1000,
|
||||
temperature: params.temperature ?? 0.3,
|
||||
system: params.systemPrompt,
|
||||
messages: [
|
||||
{ role: "user", content: wrapForJson(params.userPrompt) },
|
||||
],
|
||||
messages: [{ role: "user", content: wrapForJson(params.userPrompt) }],
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ export class CodexClient implements AIProvider {
|
||||
this.onTokenRefresh = config.onTokenRefresh;
|
||||
}
|
||||
|
||||
async generateCompletion(params: CompletionParams): Promise<CompletionResult> {
|
||||
async generateCompletion(
|
||||
params: CompletionParams,
|
||||
): Promise<CompletionResult> {
|
||||
const firstAttempt = await this.doRequest(params);
|
||||
|
||||
if (firstAttempt.status === 401) {
|
||||
@@ -85,9 +87,12 @@ export class CodexClient implements AIProvider {
|
||||
private async parseResponse(res: Response): Promise<CompletionResult> {
|
||||
const json = await res.json();
|
||||
|
||||
const messageOutput = (json.output as Array<{ type: string; content?: Array<{ type: string; text?: string }> }>)?.find(
|
||||
(o) => o.type === "message",
|
||||
);
|
||||
const messageOutput = (
|
||||
json.output as Array<{
|
||||
type: string;
|
||||
content?: Array<{ type: string; text?: string }>;
|
||||
}>
|
||||
)?.find((o) => o.type === "message");
|
||||
const textContent = messageOutput?.content?.find(
|
||||
(c) => c.type === "output_text",
|
||||
);
|
||||
|
||||
@@ -88,7 +88,9 @@ export async function exchangeCodeForTokens(params: {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function refreshAccessToken(refreshToken: string): Promise<TokenResponse> {
|
||||
export async function refreshAccessToken(
|
||||
refreshToken: string,
|
||||
): Promise<TokenResponse> {
|
||||
const res = await fetch("https://chatgpt.com/oauth/token", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
||||
@@ -21,7 +21,9 @@ export class LocalOpenAICompatibleClient implements AIProvider {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
async generateCompletion(params: CompletionParams): Promise<CompletionResult> {
|
||||
async generateCompletion(
|
||||
params: CompletionParams,
|
||||
): Promise<CompletionResult> {
|
||||
const url = `${this.config.baseUrl.replace(/\/$/, "")}/chat/completions`;
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
|
||||
@@ -14,7 +14,9 @@ export class OpenAIClient implements AIProvider {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
async generateCompletion(params: CompletionParams): Promise<CompletionResult> {
|
||||
async generateCompletion(
|
||||
params: CompletionParams,
|
||||
): Promise<CompletionResult> {
|
||||
const url = `${this.config.baseUrl.replace(/\/$/, "")}/chat/completions`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
|
||||
+13
-2
@@ -24,7 +24,13 @@ export const insightDataQualitySchema = z.object({
|
||||
export const insightResultSchema = z.object({
|
||||
insightType: z.string().optional(),
|
||||
summary: z.string(),
|
||||
classification: z.enum(["optimal", "gut", "grenzwertig", "erhoht", "kritisch"]),
|
||||
classification: z.enum([
|
||||
"optimal",
|
||||
"gut",
|
||||
"grenzwertig",
|
||||
"erhoht",
|
||||
"kritisch",
|
||||
]),
|
||||
classificationLabel: z.string().optional(),
|
||||
findings: z.array(insightFindingSchema),
|
||||
correlations: z.array(insightCorrelationSchema),
|
||||
@@ -39,7 +45,12 @@ export type InsightFinding = z.infer<typeof insightFindingSchema>;
|
||||
|
||||
// ─── Provider Types ────────────────────────────────────────
|
||||
|
||||
export type ProviderType = "codex" | "admin-key" | "anthropic" | "local" | "none";
|
||||
export type ProviderType =
|
||||
| "codex"
|
||||
| "admin-key"
|
||||
| "anthropic"
|
||||
| "local"
|
||||
| "none";
|
||||
|
||||
export interface AIProvider {
|
||||
type: ProviderType;
|
||||
|
||||
Reference in new issue
Block a user