Public: anyone can read this; the crew can change it.

/explore keeps its filters in the address, so a filtered view can be sent and reloaded #16031

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/15970-explore-keeps-its-filters-in-the-address → main 0 commits fork

  • Merged. mason/15970-explore-keeps-its-filters-in-the-address was merged into main as 54ea598.

Review

Sign in to review this change.
4 files changed +41 −4
src/contract/openapi/routes/getApiV1Explore.ts +2 −2
@@ -1,3 +1,3 @@
1 import { limitTo, type Route } from "../shared.ts";
1 import { EXPLORE_QUERY, type Route } from "../shared.ts";
22
3 export const route: Route = { method: "get", path: "/api/v1/explore", summary: "Explore apps and repositories", detail: "Explore apps and repositories; `q` takes words and `kind:`/`owner:` filters; answers { query, items, next_cursor } (an app item carries forks, ships, likes and updatedAt, the time of its last ship, not of its last push, null when never shipped) (`limit` 1 to 100 rows a page, default 30; next_cursor null on the last; a bad `limit`, `sort` or `kind` is a 422 naming the field); cursor from next_cursor; a bad cursor is a 422 `invalid_cursor`; the answer carries an ETag (cache-control private, no-cache; vary authorization, cookie) that changes when anything listed changes, and a repeat sending it in If-None-Match gets 304 with no body", auth: false, role: "anonymous", alsoStatus: [304, 422], query: { q: "string", cursor: "string", limit: limitTo(100), sort: "string", kind: "string" } };
3 export const route: Route = { method: "get", path: "/api/v1/explore", summary: "Explore apps and repositories", detail: "Explore apps and repositories; `q` takes words and `kind:`/`owner:` filters; answers { query, items, next_cursor } (an app item carries forks, ships, likes and updatedAt, the time of its last ship, not of its last push, null when never shipped) (`limit` 1 to 100 rows a page, default 30; next_cursor null on the last; a bad `limit`, `sort` or `kind` is a 422 naming the field); cursor from next_cursor; a bad cursor is a 422 `invalid_cursor`; the answer carries an ETag (cache-control private, no-cache; vary authorization, cookie) that changes when anything listed changes, and a repeat sending it in If-None-Match gets 304 with no body", auth: false, role: "anonymous", alsoStatus: [304, 422], query: EXPLORE_QUERY };
src/contract/openapi/routes/getExploreJson.ts +2 −2
@@ -1,3 +1,3 @@
1 import { limitTo, type Route } from "../shared.ts";
1 import { EXPLORE_QUERY, type Route } from "../shared.ts";
22
3 export const route: Route = { method: "get", path: "/explore.json", summary: "The explore page as JSON", detail: "The rows /explore shows, for the same filter line (`q` words, or `kind`, `sort`, `updated`, `owner` and the other parameters); answers { query, filters, items, next_cursor } where `filters` names what the line set and each app item carries `score_parts` (forks, ships, likes, fresh, use, quiet, total); a word the explorer does not take is a 422 naming it; a private app appears only to a viewer who may read it", auth: false, role: "anonymous", alsoStatus: [304, 422], query: { q: "string", cursor: "string", limit: limitTo(100), sort: "string", kind: "string" } };
3 export const route: Route = { method: "get", path: "/explore.json", summary: "The explore page as JSON", detail: "The rows /explore shows, for the same filter line (`q` words, or `kind`, `sort`, `updated`, `owner` and the other parameters); answers { query, filters, items, next_cursor } where `filters` names what the line set and each app item carries `score_parts` (forks, ships, likes, fresh, use, quiet, total); a word the explorer does not take is a 422 naming it; a private app appears only to a viewer who may read it", auth: false, role: "anonymous", alsoStatus: [304, 422], query: EXPLORE_QUERY };
src/contract/openapi/shared.ts +25
@@ -139,3 +139,28 @@ export const ISSUE_ITEM_KEYS: readonly string[] = [
139139 "closeReason", "originAuthor", "originUrl", "assigneeId", "assigneeName", "assigneeIsAgent", "authorIsAgent", "sealed",
140140 "estimated", "labels", "comments",
141141 ];
142
143 /**
144 * What the explorer reads from the address (#15970): the words, the page, and each filter as its
145 * own parameter, the same names `EXPLORE_PARAMS` holds, plus the aliases (`since`, `min_forks`,
146 * `week`, `fresh`). Both explore routes list the same set.
147 */
148 export const EXPLORE_QUERY: Readonly<Record<string, QueryType>> = {
149 q: "string",
150 cursor: "string",
151 limit: limitTo(100),
152 kind: "string",
153 sort: "string",
154 updated: "string",
155 since: "string",
156 owner: "string",
157 archived: "string",
158 forks: "string",
159 min_forks: "string",
160 ships: "string",
161 live: "string",
162 week: "string",
163 fresh: "string",
164 mine: "string",
165 template: "string",
166 };
test/explore-openapi-filters.test.ts added +12
@@ -0,0 +1,12 @@
1 /** Both explore routes list every filter the page reads from the address (#15970). */
2 import { expect, test } from "bun:test";
3 import { EXPLORE_PARAMS } from "../src/actions/explore.ts";
4 import { route as json } from "../src/contract/openapi/routes/getExploreJson.ts";
5 import { route as api } from "../src/contract/openapi/routes/getApiV1Explore.ts";
6
7 test("the OpenAPI description of /explore.json and /api/v1/explore lists each filter parameter", () => {
8 for (const r of [json, api]) {
9 const named = Object.keys(r.query ?? {});
10 for (const p of [...EXPLORE_PARAMS, "q", "cursor", "limit", "since", "min_forks"]) expect(named).toContain(p);
11 }
12 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs