Files
2026-05-27 23:29:53 +01:00

68 lines
2.3 KiB
TypeScript

import { readFile } from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "@suaveplan/testing/runner";
const PKG_ROOT = path.resolve(import.meta.dirname, "..");
describe("api-plugin-sse — dependency graph and exports map", () => {
it("exports map advertises every feature subpath", {
timeout: 5000,
}, async () => {
const raw = await readFile(path.join(PKG_ROOT, "package.json"), "utf8");
const pkg = JSON.parse(raw) as {
exports: Record<string, unknown>;
};
const subpaths = Object.keys(pkg.exports)
.filter(
(k) =>
(k === "." || k.startsWith("./")) && k !== "./package.json"
)
.sort();
expect(subpaths).toEqual(
[
".",
"./plugin/plugin",
"./services/service",
"./middleware/sse-handler",
"./formatter/format",
"./formatter/parse",
"./buffer/ring-buffer",
"./fanout/in-process",
"./schemas/options",
"./schemas/event",
"./error-codes/error-codes",
"./otel/instruments",
"./types/types",
"./registry/service-registry",
].sort()
);
});
it("dependencies use only workspace and catalog refs", {
timeout: 5000,
}, async () => {
const raw = await readFile(path.join(PKG_ROOT, "package.json"), "utf8");
const pkg = JSON.parse(raw) as {
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
};
const all = {
...(pkg.dependencies ?? {}),
...(pkg.devDependencies ?? {}),
};
for (const [name, version] of Object.entries(all)) {
// Allow exact versions for explicitly pinned testing deps.
if (name === "@opentelemetry/sdk-metrics") continue;
if (
!version.startsWith("workspace:") &&
!version.startsWith("catalog:")
) {
throw new Error(
`Dependency ${name} uses bare version '${version}' — must be workspace:/catalog:`
);
}
}
expect(true).toBe(true);
});
});