mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 08:52:21 +00:00
fix(search): unblock CI types and API browse exclusion
Tighten publicBrowse test fixtures for Convex Id/license types, drop moderationSourceVersionId from digest picks, and apply pending-review filtering to listPublicApiPageV1 entries.
This commit is contained in:
committed by
Patrick Erichsen
parent
64e5bcb676
commit
b26654b3b0
@@ -8,6 +8,15 @@ import {
|
||||
shouldExcludeSkillFromPublicBrowse,
|
||||
} from "./publicBrowse";
|
||||
|
||||
const emptyStats = {
|
||||
versions: 1,
|
||||
downloads: 0,
|
||||
stars: 0,
|
||||
installsCurrent: 0,
|
||||
installsAllTime: 0,
|
||||
comments: 0,
|
||||
};
|
||||
|
||||
describe("publicBrowse", () => {
|
||||
it("treats scanner review flags as pending public review", () => {
|
||||
expect(
|
||||
@@ -38,16 +47,9 @@ describe("publicBrowse", () => {
|
||||
moderationFlags: undefined,
|
||||
moderationVerdict: "clean",
|
||||
moderationSourceVersionId: undefined,
|
||||
latestVersionId: "skillVersions:1",
|
||||
latestVersionId: "skillVersions:1" as never,
|
||||
githubScanStatus: "clean",
|
||||
stats: {
|
||||
versions: 1,
|
||||
downloads: 0,
|
||||
stars: 0,
|
||||
installsCurrent: 0,
|
||||
installsAllTime: 0,
|
||||
comments: 0,
|
||||
},
|
||||
stats: emptyStats,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
@@ -55,14 +57,7 @@ describe("publicBrowse", () => {
|
||||
it("keeps previously approved skills visible while a newer version is pending review", () => {
|
||||
expect(
|
||||
hasPriorApprovedPublicSkillVersion({
|
||||
stats: {
|
||||
versions: 2,
|
||||
downloads: 0,
|
||||
stars: 0,
|
||||
installsCurrent: 0,
|
||||
installsAllTime: 0,
|
||||
comments: 0,
|
||||
},
|
||||
stats: { ...emptyStats, versions: 2 },
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
@@ -72,17 +67,10 @@ describe("publicBrowse", () => {
|
||||
moderationReason: "pending.scan",
|
||||
moderationFlags: undefined,
|
||||
moderationVerdict: "clean",
|
||||
moderationSourceVersionId: "skillVersions:2",
|
||||
latestVersionId: "skillVersions:2",
|
||||
moderationSourceVersionId: "skillVersions:2" as never,
|
||||
latestVersionId: "skillVersions:2" as never,
|
||||
githubScanStatus: "clean",
|
||||
stats: {
|
||||
versions: 2,
|
||||
downloads: 0,
|
||||
stars: 0,
|
||||
installsCurrent: 0,
|
||||
installsAllTime: 0,
|
||||
comments: 0,
|
||||
},
|
||||
stats: { ...emptyStats, versions: 2 },
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
@@ -90,14 +78,14 @@ describe("publicBrowse", () => {
|
||||
it("rejects pending-review skill versions from public listing", () => {
|
||||
expect(
|
||||
isPubliclyListableSkillVersion({
|
||||
_id: "skillVersions:pending",
|
||||
skillId: "skills:1",
|
||||
_id: "skillVersions:pending" as never,
|
||||
skillId: "skills:1" as never,
|
||||
softDeletedAt: undefined,
|
||||
version: "2.0.0",
|
||||
createdAt: 1,
|
||||
changelog: "c",
|
||||
changelogSource: "user",
|
||||
parsed: { frontmatter: {}, license: "MIT" },
|
||||
parsed: { frontmatter: {}, license: "MIT-0" },
|
||||
vtAnalysis: { status: "pending", checkedAt: 1 },
|
||||
llmAnalysis: undefined,
|
||||
staticScan: undefined,
|
||||
@@ -107,18 +95,18 @@ describe("publicBrowse", () => {
|
||||
|
||||
it("resolves the last approved version while a newer version is pending review", async () => {
|
||||
const approvedVersion = {
|
||||
_id: "skillVersions:approved",
|
||||
skillId: "skills:1",
|
||||
_id: "skillVersions:approved" as never,
|
||||
skillId: "skills:1" as never,
|
||||
softDeletedAt: undefined,
|
||||
version: "1.0.0",
|
||||
createdAt: 1,
|
||||
changelog: "approved",
|
||||
changelogSource: "user",
|
||||
parsed: { frontmatter: {}, license: "MIT" },
|
||||
vtAnalysis: { status: "clean", checkedAt: 1 },
|
||||
llmAnalysis: { status: "clean", checkedAt: 1 },
|
||||
changelogSource: "user" as const,
|
||||
parsed: { frontmatter: {}, license: "MIT-0" as const },
|
||||
vtAnalysis: { status: "clean" as const, checkedAt: 1 },
|
||||
llmAnalysis: { status: "clean" as const, checkedAt: 1 },
|
||||
staticScan: {
|
||||
status: "clean",
|
||||
status: "clean" as const,
|
||||
reasonCodes: [],
|
||||
findings: [],
|
||||
summary: "",
|
||||
@@ -127,15 +115,15 @@ describe("publicBrowse", () => {
|
||||
},
|
||||
};
|
||||
const pendingVersion = {
|
||||
_id: "skillVersions:pending",
|
||||
skillId: "skills:1",
|
||||
_id: "skillVersions:pending" as never,
|
||||
skillId: "skills:1" as never,
|
||||
softDeletedAt: undefined,
|
||||
version: "2.0.0",
|
||||
createdAt: 2,
|
||||
changelog: "pending",
|
||||
changelogSource: "user",
|
||||
parsed: { frontmatter: {}, license: "MIT" },
|
||||
vtAnalysis: { status: "pending", checkedAt: 2 },
|
||||
changelogSource: "user" as const,
|
||||
parsed: { frontmatter: {}, license: "MIT-0" as const },
|
||||
vtAnalysis: { status: "pending" as const, checkedAt: 2 },
|
||||
};
|
||||
|
||||
const version = await resolvePublicBrowseVersionForSkill(
|
||||
@@ -144,13 +132,13 @@ describe("publicBrowse", () => {
|
||||
get: async (id: string) => {
|
||||
if (id === "skills:1") {
|
||||
return {
|
||||
_id: "skills:1",
|
||||
latestVersionId: "skillVersions:pending",
|
||||
moderationSourceVersionId: "skillVersions:pending",
|
||||
_id: "skills:1" as never,
|
||||
latestVersionId: "skillVersions:pending" as never,
|
||||
moderationSourceVersionId: "skillVersions:pending" as never,
|
||||
moderationStatus: "active",
|
||||
moderationReason: "pending.scan",
|
||||
moderationFlags: undefined,
|
||||
stats: { versions: 2 },
|
||||
stats: { ...emptyStats, versions: 2 },
|
||||
};
|
||||
}
|
||||
if (id === "skillVersions:pending") return pendingVersion;
|
||||
@@ -166,13 +154,13 @@ describe("publicBrowse", () => {
|
||||
},
|
||||
} as never,
|
||||
{
|
||||
_id: "skills:1",
|
||||
latestVersionId: "skillVersions:pending",
|
||||
moderationSourceVersionId: "skillVersions:pending",
|
||||
_id: "skills:1" as never,
|
||||
latestVersionId: "skillVersions:pending" as never,
|
||||
moderationSourceVersionId: "skillVersions:pending" as never,
|
||||
moderationStatus: "active",
|
||||
moderationReason: "pending.scan",
|
||||
moderationFlags: undefined,
|
||||
stats: { versions: 2 },
|
||||
stats: { ...emptyStats, versions: 2 },
|
||||
softDeletedAt: undefined,
|
||||
moderationVerdict: "clean",
|
||||
githubScanStatus: "clean",
|
||||
|
||||
+3
-2
@@ -6013,7 +6013,6 @@ async function loadPublicLatestVersionForDigest(
|
||||
| "moderationReason"
|
||||
| "moderationFlags"
|
||||
| "stats"
|
||||
| "moderationSourceVersionId"
|
||||
>,
|
||||
) {
|
||||
if (!digest.latestVersionId) return null;
|
||||
@@ -6077,7 +6076,9 @@ async function buildPublicSkillApiListEntryFromDigest(
|
||||
ctx: Pick<QueryCtx, "db">,
|
||||
digest: Doc<"skillSearchDigest">,
|
||||
) {
|
||||
const publicSkill = toPublicSkill(digestToHydratableSkill(digest));
|
||||
const hydratable = digestToHydratableSkill(digest);
|
||||
if (shouldExcludeSkillFromPublicBrowse(hydratable)) return null;
|
||||
const publicSkill = toPublicSkill(hydratable);
|
||||
if (!publicSkill) return null;
|
||||
const ownerInfo = digestToOwnerInfo(digest);
|
||||
if (!ownerInfo?.owner) return null;
|
||||
|
||||
Reference in New Issue
Block a user