@app-vitals/agent-lib 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin-types.ts +947 -803
- package/admin-types.unit.test.ts +35 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
const spec = JSON.parse(
|
|
5
|
+
readFileSync(
|
|
6
|
+
new URL("../admin/openapi.platform.json", import.meta.url),
|
|
7
|
+
"utf8",
|
|
8
|
+
),
|
|
9
|
+
) as { paths: Record<string, unknown> };
|
|
10
|
+
|
|
11
|
+
/** Top-level keys of the generated `paths` interface (4-space-indented quoted keys). */
|
|
12
|
+
function generatedPathKeys(): Set<string> {
|
|
13
|
+
const src = readFileSync(new URL("./admin-types.ts", import.meta.url), "utf8");
|
|
14
|
+
const start = src.indexOf("export interface paths {");
|
|
15
|
+
const end = src.indexOf("\n}\n", start);
|
|
16
|
+
const body = src.slice(start, end);
|
|
17
|
+
return new Set(
|
|
18
|
+
[...body.matchAll(/^ {4}"([^"]+)": \{$/gm)].map((m) => m[1] as string),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe("lib/admin-types.ts", () => {
|
|
23
|
+
it("has every path in admin/openapi.platform.json as a key of the paths interface", () => {
|
|
24
|
+
const generated = generatedPathKeys();
|
|
25
|
+
const missing = Object.keys(spec.paths).filter((p) => !generated.has(p));
|
|
26
|
+
expect(
|
|
27
|
+
missing,
|
|
28
|
+
`paths missing from lib/admin-types.ts: run \`bun run generate:admin-types\``,
|
|
29
|
+
).toEqual([]);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("parses a non-empty set of generated paths", () => {
|
|
33
|
+
expect(generatedPathKeys().size).toBeGreaterThan(0);
|
|
34
|
+
});
|
|
35
|
+
});
|