@app-vitals/agent-admin 1.75.0 → 1.76.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/package.json +2 -2
- package/prisma/client/browser.ts +15 -0
- package/prisma/client/client.ts +15 -0
- package/prisma/client/internal/class.ts +34 -4
- package/prisma/client/internal/prismaNamespace.ts +284 -2
- package/prisma/client/internal/prismaNamespaceBrowser.ts +58 -1
- package/prisma/client/models/GitHubCachedRepo.ts +1430 -0
- package/prisma/client/models/GitHubRepoAccess.ts +1397 -0
- package/prisma/client/models/GitHubRepoSnapshot.ts +1807 -0
- package/prisma/client/models.ts +3 -0
- package/prisma/migrations/20261120000000_add_github_repo_cache/migration.sql +75 -0
- package/prisma/schema/schema.prisma +62 -0
- package/src/github-repo-cache.integration.test.ts +227 -0
- package/src/github-repo-cache.ts +296 -0
- package/src/github-repo-cache.unit.test.ts +66 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import type { PrismaClient } from "../prisma/client/client.ts";
|
|
3
|
+
import { GitHubRepoCacheService } from "./github-repo-cache.ts";
|
|
4
|
+
|
|
5
|
+
// Validation runs before any DB call, so a throwing proxy proves none happens.
|
|
6
|
+
const noDb = new Proxy(
|
|
7
|
+
{},
|
|
8
|
+
{
|
|
9
|
+
get() {
|
|
10
|
+
throw new Error("db touched");
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
) as unknown as PrismaClient;
|
|
14
|
+
const svc = new GitHubRepoCacheService(noDb);
|
|
15
|
+
const key = {
|
|
16
|
+
accountId: "a",
|
|
17
|
+
appKind: "lookup" as const,
|
|
18
|
+
appRef: "1",
|
|
19
|
+
org: "o",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe("GitHubRepoCacheService argument validation", () => {
|
|
23
|
+
it("rejects a bad appKind", async () => {
|
|
24
|
+
await expect(
|
|
25
|
+
svc.upsertSnapshot({ ...key, appKind: "bogus" as never }),
|
|
26
|
+
).rejects.toThrow("appKind");
|
|
27
|
+
});
|
|
28
|
+
it("rejects empty key parts", async () => {
|
|
29
|
+
await expect(svc.getSnapshot({ ...key, org: " " })).rejects.toThrow("org");
|
|
30
|
+
await expect(svc.getSnapshot({ ...key, accountId: "" })).rejects.toThrow(
|
|
31
|
+
"accountId",
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
it("rejects a non-positive lease ttl and empty holder", async () => {
|
|
35
|
+
await expect(svc.acquireLease("s", "h", 0)).rejects.toThrow("ttlMs");
|
|
36
|
+
await expect(svc.acquireLease("s", "", 10)).rejects.toThrow("holder");
|
|
37
|
+
});
|
|
38
|
+
it("rejects an empty repo fullName", async () => {
|
|
39
|
+
await expect(
|
|
40
|
+
svc.upsertRepos("s", [{ githubId: 1, fullName: "" }]),
|
|
41
|
+
).rejects.toThrow("fullName");
|
|
42
|
+
});
|
|
43
|
+
it("rejects a bad access status", async () => {
|
|
44
|
+
await expect(
|
|
45
|
+
svc.upsertAccess({
|
|
46
|
+
accountId: "a",
|
|
47
|
+
org: "o",
|
|
48
|
+
repo: "r",
|
|
49
|
+
username: "u",
|
|
50
|
+
canPush: true,
|
|
51
|
+
status: "nope" as never,
|
|
52
|
+
}),
|
|
53
|
+
).rejects.toThrow("status");
|
|
54
|
+
});
|
|
55
|
+
it("rejects a non-positive maxAgeMs", async () => {
|
|
56
|
+
await expect(
|
|
57
|
+
svc.findMissingOrExpiredAccess({
|
|
58
|
+
accountId: "a",
|
|
59
|
+
org: "o",
|
|
60
|
+
username: "u",
|
|
61
|
+
repos: ["r"],
|
|
62
|
+
maxAgeMs: -1,
|
|
63
|
+
}),
|
|
64
|
+
).rejects.toThrow("maxAgeMs");
|
|
65
|
+
});
|
|
66
|
+
});
|