diff --git a/http-client/index.ts b/http-client/index.ts index ee05168a1..1ea25a7d0 100644 --- a/http-client/index.ts +++ b/http-client/index.ts @@ -2,9 +2,9 @@ import type { BaseUrl } from "./lib/fetcher.js"; import type { Blob, DiffResponse, - Project, - ProjectListQuery, Remote, + Repo, + RepoListQuery, Tree, TreeStats, } from "./lib/project.js"; @@ -41,7 +41,7 @@ import type { ZodSchema } from "zod"; import { z, array, literal, number, object, string, union } from "zod"; -import * as project from "./lib/project.js"; +import * as repo from "./lib/project.js"; import { Fetcher } from "./lib/fetcher.js"; import { nodeConfigSchema, @@ -73,15 +73,15 @@ export type { Merge, Patch, PatchState, - Project, - ProjectListQuery, Reaction, Remote, + Repo, + RepoListQuery, Review, Revision, SeedingPolicy, - TreeStats, Tree, + TreeStats, Verdict, }; @@ -156,13 +156,13 @@ export class HttpdClient { #fetcher: Fetcher; public baseUrl: BaseUrl; - public project: project.Client; + public repo: repo.Client; public constructor(baseUrl: BaseUrl) { this.baseUrl = baseUrl; this.#fetcher = new Fetcher(this.baseUrl); - this.project = new project.Client(this.#fetcher); + this.repo = new repo.Client(this.#fetcher); } public changePort(port: number): void { @@ -213,14 +213,14 @@ export class HttpdClient { ); } - public async getPolicyById( - id: string, + public async getPolicyByRid( + rid: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `node/policies/repos/${id}`, + path: `node/policies/repos/${rid}`, options, }, seedingPolicySchema, @@ -239,13 +239,13 @@ export class HttpdClient { } public async getNodeIdentity( - id: string, + nid: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `nodes/${id}`, + path: `nodes/${nid}`, options, }, nodeIdentitySchema, @@ -253,13 +253,13 @@ export class HttpdClient { } public async getNodeInventory( - id: string, + nid: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `nodes/${id}/inventory`, + path: `nodes/${nid}/inventory`, options, }, array(string()), diff --git a/http-client/lib/project.ts b/http-client/lib/project.ts index 2124b93b6..6dab8fc80 100644 --- a/http-client/lib/project.ts +++ b/http-client/lib/project.ts @@ -27,11 +27,13 @@ import { import { issueSchema, issuesSchema } from "./project/issue.js"; import { patchSchema, patchesSchema } from "./project/patch.js"; -const projectSchema = object({ - id: string(), - name: string(), - description: string(), - defaultBranch: string(), +const repoSchema = object({ + rid: string(), + "xyz.radicle.project": object({ + name: string(), + description: string(), + defaultBranch: string(), + }), delegates: array(object({ id: string(), alias: optional(string()) })), head: string(), threshold: number(), @@ -51,9 +53,9 @@ const projectSchema = object({ }), seeding: number(), }); -const projectsSchema = array(projectSchema); +const reposSchema = array(repoSchema); -export type Project = z.infer; +export type Repo = z.infer; const activitySchema = object({ activity: array(number()), @@ -116,7 +118,7 @@ const diffResponseSchema = object({ files: record(string(), diffBlobSchema), }); -export type ProjectListQuery = { +export type RepoListQuery = { page?: number; perPage?: number; show?: "pinned" | "all"; @@ -130,54 +132,54 @@ export class Client { public async getByDelegate( delegateId: string, - query?: ProjectListQuery, + query?: RepoListQuery, options?: RequestOptions, - ): Promise { + ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `delegates/${delegateId}/projects`, + path: `delegates/${delegateId}/repos`, query, options, }, - projectsSchema, + reposSchema, ); } - public async getById(id: string, options?: RequestOptions): Promise { + public async getByRid(rid: string, options?: RequestOptions): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}`, + path: `repos/${rid}`, options, }, - projectSchema, + repoSchema, ); } public async getAll( - query?: ProjectListQuery, + query?: RepoListQuery, options?: RequestOptions, - ): Promise { + ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: "projects", + path: "repos", query, options, }, - projectsSchema, + reposSchema, ); } public async getActivity( - id: string, + rid: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/activity`, + path: `repos/${rid}/activity`, options, }, activitySchema, @@ -185,14 +187,14 @@ export class Client { } public async getReadme( - id: string, + rid: string, sha: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/readme/${sha}`, + path: `repos/${rid}/readme/${sha}`, options, }, blobSchema, @@ -200,7 +202,7 @@ export class Client { } public async getBlob( - id: string, + rid: string, sha: string, path: string, options?: RequestOptions, @@ -208,7 +210,7 @@ export class Client { const blob = await this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/blob/${sha}/${path}`, + path: `repos/${rid}/blob/${sha}/${path}`, options, }, blobSchema, @@ -217,7 +219,7 @@ export class Client { } public async getTree( - id: string, + rid: string, sha: string, path?: string, options?: RequestOptions, @@ -225,7 +227,7 @@ export class Client { const tree = await this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/tree/${sha}/${path ?? ""}`, + path: `repos/${rid}/tree/${sha}/${path ?? ""}`, options, }, treeSchema, @@ -234,14 +236,14 @@ export class Client { } public async getTreeStatsBySha( - id: string, + rid: string, sha: string, options?: RequestOptions, ): Promise { const tree = await this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/stats/tree/${sha}`, + path: `repos/${rid}/stats/tree/${sha}`, options, }, treeStatsSchema, @@ -250,13 +252,13 @@ export class Client { } public async getAllRemotes( - id: string, + rid: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/remotes`, + path: `repos/${rid}/remotes`, options, }, remotesSchema, @@ -264,14 +266,14 @@ export class Client { } public async getRemoteByPeer( - id: string, + rid: string, peer: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/remotes/${peer}`, + path: `repos/${rid}/remotes/${peer}`, options, }, remoteSchema, @@ -279,7 +281,7 @@ export class Client { } public async getAllCommits( - id: string, + rid: string, query?: { parent?: string; since?: number; @@ -292,7 +294,7 @@ export class Client { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/commits`, + path: `repos/${rid}/commits`, query, options, }, @@ -301,14 +303,14 @@ export class Client { } public async getCommitBySha( - id: string, + rid: string, sha: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/commits/${sha}`, + path: `repos/${rid}/commits/${sha}`, options, }, commitSchema, @@ -316,7 +318,7 @@ export class Client { } public async getDiff( - id: string, + rid: string, revisionBase: string, revisionOid: string, options?: RequestOptions, @@ -324,7 +326,7 @@ export class Client { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/diff/${revisionBase}/${revisionOid}`, + path: `repos/${rid}/diff/${revisionBase}/${revisionOid}`, options, }, diffResponseSchema, @@ -332,14 +334,14 @@ export class Client { } public async getIssueById( - id: string, + rid: string, issueId: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/issues/${issueId}`, + path: `repos/${rid}/issues/${issueId}`, options, }, issueSchema, @@ -347,7 +349,7 @@ export class Client { } public async getAllIssues( - id: string, + rid: string, query?: { page?: number; perPage?: number; @@ -358,7 +360,7 @@ export class Client { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/issues`, + path: `repos/${rid}/issues`, query, options, }, @@ -367,14 +369,14 @@ export class Client { } public async getPatchById( - id: string, + rid: string, patchId: string, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/patches/${patchId}`, + path: `repos/${rid}/patches/${patchId}`, options, }, patchSchema, @@ -382,7 +384,7 @@ export class Client { } public async getAllPatches( - id: string, + rid: string, query?: { page?: number; perPage?: number; @@ -393,7 +395,7 @@ export class Client { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/patches`, + path: `repos/${rid}/patches`, query, options, }, diff --git a/http-client/tests/project.test.ts b/http-client/tests/project.test.ts index 8e8b05b6e..c56a6987d 100644 --- a/http-client/tests/project.test.ts +++ b/http-client/tests/project.test.ts @@ -9,7 +9,7 @@ import { sourceBrowsingRid, } from "@tests/support/fixtures.js"; -describe("project", () => { +describe("repo", () => { const api = new HttpdClient({ hostname: "127.0.0.1", port: defaultHttpdPort, @@ -17,59 +17,56 @@ describe("project", () => { }); test("#getByDelegate(delegateId)", async () => { - await api.project.getByDelegate(aliceRemote); + await api.repo.getByDelegate(aliceRemote); }); test("#getAll()", async () => { - await api.project.getAll(); + await api.repo.getAll(); }); - test("#getById(id)", async () => { - await api.project.getById(sourceBrowsingRid); + test("#getByRid(rid)", async () => { + await api.repo.getByRid(sourceBrowsingRid); }); - test("#getActivity(id)", async () => { - await api.project.getActivity(sourceBrowsingRid); + test("#getActivity(rid)", async () => { + await api.repo.getActivity(sourceBrowsingRid); }); - test("#getReadme(id, sha)", async () => { - await api.project.getReadme(sourceBrowsingRid, aliceMainHead); + test("#getReadme(rid, sha)", async () => { + await api.repo.getReadme(sourceBrowsingRid, aliceMainHead); }); - test("#getBlob(id, sha, path)", async () => { - await api.project.getBlob(sourceBrowsingRid, aliceMainHead, "src/true.c"); + test("#getBlob(rid, sha, path)", async () => { + await api.repo.getBlob(sourceBrowsingRid, aliceMainHead, "src/true.c"); }); - test("#getTree(id, sha)", async () => { - await api.project.getTree(sourceBrowsingRid, aliceMainHead); + test("#getTree(rid, sha)", async () => { + await api.repo.getTree(sourceBrowsingRid, aliceMainHead); }); - test("#getTreeStats(id, sha)", async () => { - await api.project.getTreeStatsBySha(sourceBrowsingRid, aliceMainHead); + test("#getTreeStats(rid, sha)", async () => { + await api.repo.getTreeStatsBySha(sourceBrowsingRid, aliceMainHead); }); - test("#getTree(id, sha, path)", async () => { - await api.project.getTree(sourceBrowsingRid, aliceMainHead, "src"); + test("#getTree(rid, sha, path)", async () => { + await api.repo.getTree(sourceBrowsingRid, aliceMainHead, "src"); }); - test("#getAllRemotes(id)", async () => { - await api.project.getAllRemotes(sourceBrowsingRid); + test("#getAllRemotes(rid)", async () => { + await api.repo.getAllRemotes(sourceBrowsingRid); }); - test("#getRemoteByPeer(id, peer)", async () => { - await api.project.getRemoteByPeer( - sourceBrowsingRid, - aliceRemote.substring(8), - ); + test("#getRemoteByPeer(rid, peer)", async () => { + await api.repo.getRemoteByPeer(sourceBrowsingRid, aliceRemote.substring(8)); }); - test("#getAllCommits(id)", async () => { - await api.project.getAllCommits(sourceBrowsingRid); + test("#getAllCommits(rid)", async () => { + await api.repo.getAllCommits(sourceBrowsingRid); }); // TODO: test since/until properly. - test("#getAllCommits(id, {parent, since, until, page, perPage})", async () => { - await api.project.getAllCommits(sourceBrowsingRid, { + test("#getAllCommits(rid, {parent, since, until, page, perPage})", async () => { + await api.repo.getAllCommits(sourceBrowsingRid, { parent: aliceMainHead, since: 1679065819581, until: 1679065819590, @@ -78,41 +75,41 @@ describe("project", () => { }); }); - test("#getCommitBySha(id, sha)", async () => { - await api.project.getCommitBySha(sourceBrowsingRid, aliceMainHead); + test("#getCommitBySha(rid, sha)", async () => { + await api.repo.getCommitBySha(sourceBrowsingRid, aliceMainHead); }); - test("#getDiff(id, revisionBase, revisionOid)", async () => { - await api.project.getDiff( + test("#getDiff(rid, revisionBase, revisionOid)", async () => { + await api.repo.getDiff( sourceBrowsingRid, "90f6d058ece12f75f349bc7bbe88142187fe0379", aliceMainHead, ); }); - test("#getIssueById(id, issueId)", async () => { - await api.project.getIssueById( + test("#getIssueById(rid, issueId)", async () => { + await api.repo.getIssueById( cobRid, "d481fe6e562dd78129589d4738f171a8380fcb19", ); }); - test("#getAllIssues(id)", async () => { - await api.project.getAllIssues(cobRid, { + test("#getAllIssues(rid)", async () => { + await api.repo.getAllIssues(cobRid, { page: 0, perPage: 5, status: "open", }); }); - test("#getPatchById(id, patchId)", async () => { - await api.project.getPatchById( + test("#getPatchByOid(rid, patchId)", async () => { + await api.repo.getPatchById( cobRid, "59a0821edc73630bce540596cffc7854da557365", ); }); - test("#getAllPatches(id)", async () => { - await api.project.getAllPatches(cobRid); + test("#getAllPatches(rid)", async () => { + await api.repo.getAllPatches(cobRid); }); }); diff --git a/http-client/tests/support/support.ts b/http-client/tests/support/support.ts index cd876b234..1d08ce255 100644 --- a/http-client/tests/support/support.ts +++ b/http-client/tests/support/support.ts @@ -12,7 +12,7 @@ export async function assertIssue( ) { expect( //@prettier-ignore looks more readable than what prettier suggests. - isMatch(await api.project.getIssueById(cobRid, oid), change), + isMatch(await api.repo.getIssueById(cobRid, oid), change), ).toBe(true); } @@ -23,6 +23,6 @@ export async function assertPatch( ) { expect( //@prettier-ignore looks more readable than what prettier suggests. - isMatch(await api.project.getPatchById(cobRid, oid), change), + isMatch(await api.repo.getPatchById(cobRid, oid), change), ).toBe(true); } diff --git a/playwright.config.ts b/playwright.config.ts index c11291942..0aeac7774 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -87,7 +87,7 @@ const config: PlaywrightTestConfig = { command: "npm run start -- --strictPort --port 3001", port: 3001, }, - // Required by test tests/e2e/project/commits.spec.ts "loading more commits, adds them to the commits list" + // Required by test tests/e2e/repo/commits.spec.ts "loading more commits, adds them to the commits list" { command: "npm run start -- --strictPort --port 3002", port: 3002, diff --git a/src/App.svelte b/src/App.svelte index 744dc270c..442d6e807 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -63,19 +63,19 @@ {:else if $activeRouteStore.resource === "users"} -{:else if $activeRouteStore.resource === "project.source"} +{:else if $activeRouteStore.resource === "repo.source"} -{:else if $activeRouteStore.resource === "project.history"} +{:else if $activeRouteStore.resource === "repo.history"} -{:else if $activeRouteStore.resource === "project.commit"} +{:else if $activeRouteStore.resource === "repo.commit"} -{:else if $activeRouteStore.resource === "project.issues"} +{:else if $activeRouteStore.resource === "repo.issues"} -{:else if $activeRouteStore.resource === "project.issue"} +{:else if $activeRouteStore.resource === "repo.issue"} -{:else if $activeRouteStore.resource === "project.patches"} +{:else if $activeRouteStore.resource === "repo.patches"} -{:else if $activeRouteStore.resource === "project.patch"} +{:else if $activeRouteStore.resource === "repo.patch"} {:else if $activeRouteStore.resource === "error"} diff --git a/src/components/Markdown.svelte b/src/components/Markdown.svelte index e793e03de..85ab8d309 100644 --- a/src/components/Markdown.svelte +++ b/src/components/Markdown.svelte @@ -134,7 +134,7 @@ } // Iterate over all images, and replace the source with a canonicalized URL - // pointing at the projects /raw endpoint. + // pointing at the repos /raw endpoint. for (const i of container.querySelectorAll("img")) { const imagePath = i.getAttribute("src"); diff --git a/src/components/ProjectCard.svelte b/src/components/ProjectCard.svelte index 4f2891a44..0a28e610c 100644 --- a/src/components/ProjectCard.svelte +++ b/src/components/ProjectCard.svelte @@ -1,5 +1,5 @@ - + Commits @@ -78,8 +78,8 @@
diff --git a/src/views/projects/Commit/CommitTeaser.svelte b/src/views/projects/Commit/CommitTeaser.svelte index fbae9cf18..1430341cd 100644 --- a/src/views/projects/Commit/CommitTeaser.svelte +++ b/src/views/projects/Commit/CommitTeaser.svelte @@ -13,7 +13,7 @@ export let baseUrl: BaseUrl; export let commit: CommitHeader; - export let projectId: string; + export let repoId: string; let commitMessageVisible = false; @@ -79,8 +79,8 @@
@@ -112,8 +112,8 @@ diff --git a/src/views/projects/DiffStatBadgeLoader.svelte b/src/views/projects/DiffStatBadgeLoader.svelte index 3db848c46..fbece969f 100644 --- a/src/views/projects/DiffStatBadgeLoader.svelte +++ b/src/views/projects/DiffStatBadgeLoader.svelte @@ -8,13 +8,13 @@ import Link from "@app/components/Link.svelte"; import Loading from "@app/components/Loading.svelte"; - export let projectId: string; + export let repoId: string; export let baseUrl: BaseUrl; export let patch: Patch; export let latestRevision: Revision; -{#await cachedGetDiff(baseUrl, projectId, latestRevision.base, latestRevision.oid)} +{#await cachedGetDiff(baseUrl, repoId, latestRevision.base, latestRevision.oid)} {:then { diff }} - + Commits - +
{/each}
- {#await api.project.getTreeStatsBySha(project.id, commit)} + {#await api.repo.getTreeStatsBySha(repo.rid, commit)}
diff --git a/src/views/projects/Issue.svelte b/src/views/projects/Issue.svelte index aa2460d15..4466e80ad 100644 --- a/src/views/projects/Issue.svelte +++ b/src/views/projects/Issue.svelte @@ -1,5 +1,5 @@ - + Issues @@ -146,7 +146,7 @@
{capitalize(status)} @@ -157,8 +157,8 @@ slot="item" let:item route={{ - resource: "project.issues", - project: project.id, + resource: "repo.issues", + repo: repo.rid, node: baseUrl, status: item, }}> @@ -172,7 +172,7 @@
@@ -188,7 +188,7 @@ slot="item" let:item {baseUrl} - projectId={project.id} + repoId={repo.rid} issue={item} /> @@ -201,7 +201,7 @@ {error} /> {/if} - {#if project.issues[status] === 0} + {#if repo.issues[status] === 0}
diff --git a/src/views/projects/Layout.svelte b/src/views/projects/Layout.svelte index af4fd47d9..c70031c4e 100644 --- a/src/views/projects/Layout.svelte +++ b/src/views/projects/Layout.svelte @@ -1,6 +1,6 @@ @@ -109,7 +109,7 @@ resource: "nodes", params: { baseUrl, - projectPageIndex: 0, + repoPageIndex: 0, }, }}> - + @@ -157,11 +157,11 @@
@@ -176,8 +176,8 @@ @@ -191,10 +191,10 @@
{/if} {#if view.name === "diff"} @@ -446,7 +446,7 @@ style:padding="0 1rem" style:display="flex" class="global-hide-on-small-desktop-up"> - +
{/if} {#if view.name === "diff"} @@ -461,7 +461,7 @@ @@ -472,7 +472,7 @@ diff --git a/src/views/projects/Patch/PatchTeaser.svelte b/src/views/projects/Patch/PatchTeaser.svelte index 344d668a7..2df158d91 100644 --- a/src/views/projects/Patch/PatchTeaser.svelte +++ b/src/views/projects/Patch/PatchTeaser.svelte @@ -13,7 +13,7 @@ import Link from "@app/components/Link.svelte"; import NodeId from "@app/components/NodeId.svelte"; - export let projectId: string; + export let repoId: string; export let baseUrl: BaseUrl; export let patch: Patch; @@ -99,8 +99,8 @@ @@ -118,7 +118,7 @@ {#if commentCount > 0} {/if} - + diff --git a/src/views/projects/Patch/RevisionSelector.svelte b/src/views/projects/Patch/RevisionSelector.svelte index b77cc5518..db0eb1ea9 100644 --- a/src/views/projects/Patch/RevisionSelector.svelte +++ b/src/views/projects/Patch/RevisionSelector.svelte @@ -1,6 +1,6 @@ - + Patches @@ -154,7 +154,7 @@ {capitalize(status)} @@ -164,8 +164,8 @@ let:item on:afterNavigate={() => closeFocused()} route={{ - resource: "project.patches", - project: project.id, + resource: "repo.patches", + repo: repo.rid, node: baseUrl, search: `status=${item}`, }}> @@ -179,7 +179,7 @@ @@ -195,7 +195,7 @@ slot="item" let:item {baseUrl} - projectId={project.id} + repoId={repo.rid} patch={item} /> @@ -208,7 +208,7 @@ {error} /> {/if} - {#if project.patches[status] === 0} + {#if repo.patches[status] === 0}
diff --git a/src/views/projects/Sidebar.svelte b/src/views/projects/Sidebar.svelte index f05e75329..b9ce2fda2 100644 --- a/src/views/projects/Sidebar.svelte +++ b/src/views/projects/Sidebar.svelte @@ -1,6 +1,6 @@