The root .gitignore's bare `dist` pattern matches at any depth, which was also silently excluding sdk/js/test/dist/ -- a real, hand-written test suite (cjs.dist.ts/esm.dist.ts/types.dist-d.ts/helpers.ts) that verifies the published package's actual compiled exports, not build output. `git log --all` shows zero commits ever touched this path: it has been untracked since the repo's initial commit, so a fresh clone (CI, another machine, a contributor) silently never had these tests. Un-ignore sdk/js/test/dist/ explicitly while leaving the real build output (sdk/js/dist/) ignored. Also fixed the EXPECTED_VALUE_EXPORTS list in helpers.ts, which had drifted from src/index.ts's deprecated OpenTypeSafeClient/OpenTypeSafeError aliases and was failing both dist tests the moment they actually ran. This also resolves the "biome: command not found" report from the 2026-11-09 npm publish --dry-run attempt: @biomejs/biome was already a correct devDependency, the real missing step was `npm install` (never run that session). Verified live: fresh npm install + npm run check (lint/typecheck/test:coverage/build/test:dist/check:package) + npm publish --dry-run all pass clean end to end now. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
|
|
export const pkg: { name: string; version: string; exports: Record<string, unknown> } = JSON.parse(
|
|
readFileSync(new URL("../../package.json", import.meta.url), "utf8"),
|
|
);
|
|
|
|
export interface RecordedCall {
|
|
url: string;
|
|
init: RequestInit | undefined;
|
|
}
|
|
|
|
/** Create a fetch mock that records calls and returns fixed JSON. */
|
|
export const cannedFetch = (
|
|
body: unknown,
|
|
): { fetch: (url: string, init?: RequestInit) => Promise<Response>; calls: RecordedCall[] } => {
|
|
const calls: RecordedCall[] = [];
|
|
const fetch = async (url: string, init?: RequestInit): Promise<Response> => {
|
|
calls.push({ url, init });
|
|
return new Response(JSON.stringify(body), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json", "x-typesafe-request-id": "req_dist" },
|
|
});
|
|
};
|
|
return { fetch, calls };
|
|
};
|
|
|
|
/** Fixed API root independent of `OPENJEV_BASE_URL`. */
|
|
export const BASE_URL = "https://dist.test";
|
|
|
|
export const SYSTEM_ONE_BODY: Record<string, unknown> = {
|
|
model: "jev-latest",
|
|
answers: {
|
|
ok: { type: "noul", noul: 0.9 },
|
|
tone: {
|
|
type: "choice",
|
|
choice: "warm",
|
|
confidence: 0.8,
|
|
probabilities: { warm: 0.8, cold: 0.2 },
|
|
},
|
|
},
|
|
usage: { input_tokens: 10, output_tokens: 2 },
|
|
};
|
|
|
|
/** Expected runtime exports; keep aligned with `src/index.ts`. */
|
|
export const EXPECTED_VALUE_EXPORTS: string[] = [
|
|
"APIConnectionError",
|
|
"APIError",
|
|
"APIPromise",
|
|
"APITimeoutError",
|
|
"APIUserAbortError",
|
|
"AuthenticationError",
|
|
"BadRequestError",
|
|
"ENV",
|
|
"InternalServerError",
|
|
"LOG_LEVELS",
|
|
"NotFoundError",
|
|
"OpenJevClient",
|
|
"OpenJevError",
|
|
"OpenTypeSafeClient",
|
|
"OpenTypeSafeError",
|
|
"PermissionDeniedError",
|
|
"RateLimitError",
|
|
"TypeSafeClient",
|
|
"TypeSafeError",
|
|
"UnprocessableEntityError",
|
|
"VERSION",
|
|
"choice",
|
|
"noul",
|
|
"score",
|
|
].sort();
|