Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-dashboard-catalog-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@caplets/core": patch
---

Source the built-in dashboard catalog from the authenticated catalog API, load and search the complete compact index without the former result ceiling, and expose dedicated catalog detail routes with window-virtualized results. Revalidate catalog entries before typed-confirmation installs, keep missing or unreadable entries non-installable, remove the redundant source card and legacy in-page inspector, and isolate test lockfiles from the user's global Caplets state.
8 changes: 8 additions & 0 deletions apps/catalog/src/lib/catalog-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ export async function listCatalogEntries(env: CatalogStoreEnv = {}): Promise<Cat
});
}

export async function listCompactCatalogEntries(
env: CatalogStoreEnv = {},
): Promise<Array<Omit<CatalogEntryRecord, "contentMarkdown">>> {
return (await listCatalogEntries(env)).map(
({ contentMarkdown: _contentMarkdown, ...entry }) => entry,
);
}

export async function getCatalogEntry(
entryKey: string,
env: CatalogStoreEnv = {},
Expand Down
9 changes: 6 additions & 3 deletions apps/catalog/src/pages/api/v1/catalog/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { APIContext } from "astro";
import { getCatalogEnv } from "../../../../lib/catalog-env";
import { listCatalogEntries } from "../../../../lib/catalog-store";
import { listCatalogEntries, listCompactCatalogEntries } from "../../../../lib/catalog-store";
import { jsonResponse } from "../../../../lib/catalog-response";

export async function GET(_context: APIContext): Promise<Response> {
export async function GET(context: APIContext): Promise<Response> {
const compact = context.url.searchParams.get("view") === "compact";
const env = getCatalogEnv();
return jsonResponse({
version: 1,
entries: await listCatalogEntries(getCatalogEnv()),
...(compact ? { view: "compact" as const } : {}),
entries: compact ? await listCompactCatalogEntries(env) : await listCatalogEntries(env),
});
}
24 changes: 23 additions & 1 deletion apps/catalog/test/catalog-api.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { D1Database } from "@cloudflare/workers-types";
import { describe, expect, it } from "vitest";
import { getCatalogEntry, listCatalogEntries } from "../src/lib/catalog-store";
import {
getCatalogEntry,
listCatalogEntries,
listCompactCatalogEntries,
} from "../src/lib/catalog-store";

describe("catalog read model", () => {
it("serves official entries with low-count display and generated install commands", async () => {
Expand All @@ -19,6 +23,24 @@ describe("catalog read model", () => {
expect(await getCatalogEntry(github?.entryKey ?? "")).toMatchObject({ id: "github" });
});

it("projects a complete compact index without readable content", async () => {
const full = await listCatalogEntries();
const compact = await listCompactCatalogEntries();

expect(compact).toHaveLength(full.length);
expect(compact[0]).toMatchObject({
entryKey: expect.any(String),
installCount: expect.any(Number),
installCountDisplay: expect.any(String),
rankScore: expect.any(Number),
tags: expect.any(Array),
warnings: expect.any(Array),
source: expect.objectContaining({ repository: expect.any(String) }),
installCommand: expect.objectContaining({ text: expect.any(String) }),
});
expect(compact.some((entry) => "contentMarkdown" in entry)).toBe(false);
});

it("hides suppressed entries from list and detail reads", async () => {
const githubEntryKey = "github:spiritledsoftware:caplets:github%2Fcaplet.md:github";
const entries = await listCatalogEntries({
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@astrojs/react": "^6.0.1",
"@base-ui/react": "^1.6.0",
"@tailwindcss/vite": "^4.3.1",
"@tanstack/react-virtual": "^3.14.5",
"astro": "^7.0.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down
Loading
Loading