diff --git a/http-client/index.ts b/http-client/index.ts index ee05168a15..74979764f5 100644 --- a/http-client/index.ts +++ b/http-client/index.ts @@ -2,18 +2,19 @@ import type { BaseUrl } from "./lib/fetcher.js"; import type { Blob, DiffResponse, - Project, - ProjectListQuery, Remote, + Repo, + RepoListQuery, Tree, TreeStats, -} from "./lib/project.js"; +} from "./lib/repo.js"; import type { + Author, Config, SeedingPolicy, DefaultSeedingPolicy, } from "./lib/shared.js"; -import type { Comment, Embed, Reaction } from "./lib/project/comment.js"; +import type { Comment, Embed, Reaction } from "./lib/repo/comment.js"; import type { Commit, CommitBlob, @@ -25,8 +26,8 @@ import type { DiffContent, DiffFile, HunkLine, -} from "./lib/project/commit.js"; -import type { Issue, IssueState } from "./lib/project/issue.js"; +} from "./lib/repo/commit.js"; +import type { Issue, IssueState } from "./lib/repo/issue.js"; import type { LifecycleState, Merge, @@ -35,13 +36,13 @@ import type { Review, Revision, Verdict, -} from "./lib/project/patch.js"; +} from "./lib/repo/patch.js"; import type { RequestOptions } from "./lib/fetcher.js"; 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/repo.js"; import { Fetcher } from "./lib/fetcher.js"; import { nodeConfigSchema, @@ -50,6 +51,7 @@ import { } from "./lib/shared.js"; export type { + Author, BaseUrl, Blob, ChangesetWithDiff, @@ -73,15 +75,15 @@ export type { Merge, Patch, PatchState, - Project, - ProjectListQuery, Reaction, Remote, + Repo, + RepoListQuery, Review, Revision, SeedingPolicy, - TreeStats, Tree, + TreeStats, Verdict, }; @@ -156,13 +158,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 { @@ -214,13 +216,13 @@ export class HttpdClient { } public async getPolicyById( - id: string, + 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 +241,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 +255,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/repo.ts similarity index 76% rename from http-client/lib/project.ts rename to http-client/lib/repo.ts index 2124b93b68..241c8f696e 100644 --- a/http-client/lib/project.ts +++ b/http-client/lib/repo.ts @@ -1,8 +1,8 @@ import type { ZodSchema } from "zod"; import type { Fetcher, RequestOptions } from "./fetcher.js"; -import type { Commit, Commits } from "./project/commit.js"; -import type { Issue } from "./project/issue.js"; -import type { Patch } from "./project/patch.js"; +import type { Commit, Commits } from "./repo/commit.js"; +import type { Issue } from "./repo/issue.js"; +import type { Patch } from "./repo/patch.js"; import { array, @@ -23,22 +23,25 @@ import { commitsSchema, diffBlobSchema, diffSchema, -} from "./project/commit.js"; -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(), - delegates: array(object({ id: string(), alias: optional(string()) })), +} from "./repo/commit.js"; +import { issueSchema, issuesSchema } from "./repo/issue.js"; +import { patchSchema, patchesSchema } from "./repo/patch.js"; +import { authorSchema } from "./shared.js"; + +const repoSchema = object({ + rid: string(), + "xyz.radicle.project": object({ + name: string(), + description: string(), + defaultBranch: string(), + }), + delegates: array(authorSchema), head: string(), threshold: number(), visibility: union([ object({ type: literal("public") }), object({ type: literal("private"), allow: optional(array(string())) }), - ]).optional(), + ]), patches: object({ open: number(), draft: number(), @@ -51,9 +54,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()), @@ -100,7 +103,7 @@ const treeSchema = object({ export type Remote = z.infer; export const remoteSchema = object({ - id: string(), + nid: string(), alias: string().optional(), heads: record(string(), string()), delegate: boolean(), @@ -116,7 +119,7 @@ const diffResponseSchema = object({ files: record(string(), diffBlobSchema), }); -export type ProjectListQuery = { +export type RepoListQuery = { page?: number; perPage?: number; show?: "pinned" | "all"; @@ -130,54 +133,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 +188,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 +203,7 @@ export class Client { } public async getBlob( - id: string, + rid: string, sha: string, path: string, options?: RequestOptions, @@ -208,7 +211,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 +220,7 @@ export class Client { } public async getTree( - id: string, + rid: string, sha: string, path?: string, options?: RequestOptions, @@ -225,7 +228,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 +237,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 +253,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 +267,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 +282,7 @@ export class Client { } public async getAllCommits( - id: string, + rid: string, query?: { parent?: string; since?: number; @@ -292,7 +295,7 @@ export class Client { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/commits`, + path: `repos/${rid}/commits`, query, options, }, @@ -301,14 +304,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 +319,7 @@ export class Client { } public async getDiff( - id: string, + rid: string, revisionBase: string, revisionOid: string, options?: RequestOptions, @@ -324,7 +327,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 +335,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 +350,7 @@ export class Client { } public async getAllIssues( - id: string, + rid: string, query?: { page?: number; perPage?: number; @@ -358,7 +361,7 @@ export class Client { return this.#fetcher.fetchOk( { method: "GET", - path: `projects/${id}/issues`, + path: `repos/${rid}/issues`, query, options, }, @@ -367,14 +370,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 +385,7 @@ export class Client { } public async getAllPatches( - id: string, + rid: string, query?: { page?: number; perPage?: number; @@ -393,7 +396,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/lib/project/comment.ts b/http-client/lib/repo/comment.ts similarity index 100% rename from http-client/lib/project/comment.ts rename to http-client/lib/repo/comment.ts diff --git a/http-client/lib/project/commit.ts b/http-client/lib/repo/commit.ts similarity index 100% rename from http-client/lib/project/commit.ts rename to http-client/lib/repo/commit.ts diff --git a/http-client/lib/project/issue.ts b/http-client/lib/repo/issue.ts similarity index 100% rename from http-client/lib/project/issue.ts rename to http-client/lib/repo/issue.ts diff --git a/http-client/lib/project/patch.ts b/http-client/lib/repo/patch.ts similarity index 100% rename from http-client/lib/project/patch.ts rename to http-client/lib/repo/patch.ts diff --git a/http-client/lib/shared.ts b/http-client/lib/shared.ts index b9e96dbd25..5ce0d53d6d 100644 --- a/http-client/lib/shared.ts +++ b/http-client/lib/shared.ts @@ -117,7 +117,9 @@ export const codeLocationSchema = object({ new: rangeSchema.nullable(), }); +export type Author = z.infer; + export const authorSchema = object({ - id: string(), + did: string(), alias: string().optional(), }); diff --git a/http-client/tests/project.test.ts b/http-client/tests/project.test.ts index 8e8b05b6e0..c56a6987d0 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 cd876b234c..1d08ce2557 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 c112919425..0aeac77748 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/radicle-httpd/src/api.rs b/radicle-httpd/src/api.rs index 8dd2878af3..9992a52a6a 100644 --- a/radicle-httpd/src/api.rs +++ b/radicle-httpd/src/api.rs @@ -211,18 +211,19 @@ mod search { use std::collections::BTreeMap; use nonempty::NonEmpty; - use radicle::identity::doc::{Payload, PayloadId}; use serde::{Deserialize, Serialize}; - use serde_json::json; + use radicle::cob::Author; use radicle::crypto::Verified; + use radicle::identity::doc::{Payload, PayloadId}; use radicle::identity::RepoId; use radicle::node::routing::Store; - use radicle::node::AliasStore; - use radicle::node::Database; + use radicle::node::{AliasStore, Database}; use radicle::profile::Aliases; use radicle::storage::RepositoryInfo; + use super::json::author; + #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SearchQueryString { @@ -256,15 +257,10 @@ mod search { return None; }; let seeds = db.count(&info.rid).unwrap_or_default(); - let delegates = info.doc.delegates.map(|did| match aliases.alias(&did) { - Some(alias) => json!({ - "id": did, - "alias": alias, - }), - None => json!({ - "id": did, - }), - }); + let delegates = info + .doc + .delegates + .map(|did| author(&Author::new(did), aliases.alias(&did))); Some(SearchResult { rid: info.rid, diff --git a/radicle-httpd/src/api/json.rs b/radicle-httpd/src/api/json.rs index 9eab0277ac..6c4b45abcd 100644 --- a/radicle-httpd/src/api/json.rs +++ b/radicle-httpd/src/api/json.rs @@ -173,10 +173,10 @@ fn reactions( pub(crate) fn author(author: &Author, alias: Option) -> Value { match alias { Some(alias) => json!({ - "id": author.id, + "did": author.id, "alias": alias, }), - None => json!(author), + None => json!({ "did": author.id }), } } diff --git a/radicle-httpd/src/api/v1/delegates.rs b/radicle-httpd/src/api/v1/delegates.rs index 48e7fae583..df92a2021c 100644 --- a/radicle-httpd/src/api/v1/delegates.rs +++ b/radicle-httpd/src/api/v1/delegates.rs @@ -133,7 +133,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS } ], @@ -163,7 +163,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, ], @@ -215,7 +215,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS } ], @@ -245,7 +245,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, ], diff --git a/radicle-httpd/src/api/v1/repos.rs b/radicle-httpd/src/api/v1/repos.rs index d748b452ec..9aa2398cc7 100644 --- a/radicle-httpd/src/api/v1/repos.rs +++ b/radicle-httpd/src/api/v1/repos.rs @@ -484,13 +484,13 @@ async fn remotes_handler(State(ctx): State, Path(rid): Path) -> match aliases.alias(&remote.id) { Some(alias) => json!({ - "id": remote.id, + "nid": remote.id, "alias": alias, "heads": refs, "delegate": delegates.contains(&remote.id.into()), }), None => json!({ - "id": remote.id, + "nid": remote.id, "heads": refs, "delegate": delegates.contains(&remote.id.into()), }), @@ -520,7 +520,7 @@ async fn remote_handler( }) .collect::>(); let remote = json!({ - "id": remote.id, + "nid": remote.id, "heads": refs, "delegate": delegates.contains(&remote.id.into()), }); @@ -736,7 +736,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, ], @@ -766,7 +766,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS } ], @@ -809,7 +809,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS } ], @@ -839,7 +839,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, ], @@ -882,7 +882,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, } ], @@ -926,7 +926,7 @@ mod routes { "rid": "rad:z4FucBZHZMCsxTyQE1dfE2YR59Qbp", "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS } ], @@ -941,7 +941,7 @@ mod routes { "rid": "rad:z4GypKmh1gkEfmkXtarcYnkvtFUfE", "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, ], @@ -970,7 +970,7 @@ mod routes { }, "delegates": [ { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, } ], @@ -1362,7 +1362,7 @@ mod routes { response.json().await, json!([ { - "id": "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi", + "nid": "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi", "alias": CONTRIBUTOR_ALIAS, "heads": { "master": HEAD @@ -1387,7 +1387,7 @@ mod routes { assert_eq!( response.json().await, json!({ - "id": "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi", + "nid": "z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi", "heads": { "master": HEAD }, @@ -1601,7 +1601,7 @@ mod routes { { "id": ISSUE_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, "title": "Issue #1", @@ -1613,14 +1613,14 @@ mod routes { { "id": ISSUE_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, "body": "Change 'hello world' to 'hello everyone'", "edits": [ { "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, "body": "Change 'hello world' to 'hello everyone'", @@ -1653,7 +1653,7 @@ mod routes { json!({ "id": ISSUE_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, "title": "Issue #1", @@ -1665,14 +1665,14 @@ mod routes { { "id": ISSUE_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, "body": "Change 'hello world' to 'hello everyone'", "edits": [ { "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS }, "body": "Change 'hello world' to 'hello everyone'", @@ -1705,7 +1705,7 @@ mod routes { { "id": PATCH_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, }, "title": "A new `hello world`", @@ -1720,14 +1720,14 @@ mod routes { { "id": PATCH_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, }, "description": "change `hello world` in README to something else", "edits": [ { "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, }, "body": "change `hello world` in README to something else", @@ -1764,7 +1764,7 @@ mod routes { json!({ "id": PATCH_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, }, "title": "A new `hello world`", @@ -1779,14 +1779,14 @@ mod routes { { "id": PATCH_ID, "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, }, "description": "change `hello world` in README to something else", "edits": [ { "author": { - "id": DID, + "did": DID, "alias": CONTRIBUTOR_ALIAS, }, "body": "change `hello world` in README to something else", diff --git a/src/App.svelte b/src/App.svelte index 744dc270c2..8161c39059 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -10,15 +10,15 @@ import Hotkeys from "./App/Hotkeys.svelte"; import LoadingBar from "./App/LoadingBar.svelte"; - import Commit from "@app/views/projects/Commit.svelte"; - import History from "@app/views/projects/History.svelte"; - import Issue from "@app/views/projects/Issue.svelte"; - import Issues from "@app/views/projects/Issues.svelte"; + import Commit from "@app/views/repos/Commit.svelte"; + import History from "@app/views/repos/History.svelte"; + import Issue from "@app/views/repos/Issue.svelte"; + import Issues from "@app/views/repos/Issues.svelte"; import Nodes from "@app/views/nodes/View.svelte"; import NotFound from "@app/views/NotFound.svelte"; - import Patch from "@app/views/projects/Patch.svelte"; - import Patches from "@app/views/projects/Patches.svelte"; - import Source from "@app/views/projects/Source.svelte"; + import Patch from "@app/views/repos/Patch.svelte"; + import Patches from "@app/views/repos/Patches.svelte"; + import Source from "@app/views/repos/Source.svelte"; import Users from "@app/views/users/View.svelte"; import Error from "@app/views/error/View.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/Avatar.svelte b/src/components/Avatar.svelte index ac31cff3df..9ab2b04488 100644 --- a/src/components/Avatar.svelte +++ b/src/components/Avatar.svelte @@ -5,7 +5,6 @@ export let variant: "small" | "large"; function createContainer(source: string) { - source = source.replace("did:key:", ""); const seed = source.toLowerCase(); const avatar = createIcon({ seed, diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte index 0c17988d08..79237d5589 100644 --- a/src/components/Comment.svelte +++ b/src/components/Comment.svelte @@ -9,7 +9,7 @@ import Reactions from "@app/components/Reactions.svelte"; export let id: string; - export let authorId: string; + export let authorDid: string; export let authorAlias: string | undefined = undefined; export let baseUrl: BaseUrl; export let body: string; @@ -108,7 +108,10 @@ {/if}
- + {caption} diff --git a/src/components/Markdown.svelte b/src/components/Markdown.svelte index e793e03de8..85ab8d3098 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 4f2891a44f..0a28e610c4 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/CommitAuthorship.svelte b/src/views/repos/Commit/CommitAuthorship.svelte similarity index 100% rename from src/views/projects/Commit/CommitAuthorship.svelte rename to src/views/repos/Commit/CommitAuthorship.svelte diff --git a/src/views/projects/Commit/CommitTeaser.svelte b/src/views/repos/Commit/CommitTeaser.svelte similarity index 92% rename from src/views/projects/Commit/CommitTeaser.svelte rename to src/views/repos/Commit/CommitTeaser.svelte index fbae9cf18f..1f1130eaa2 100644 --- a/src/views/projects/Commit/CommitTeaser.svelte +++ b/src/views/repos/Commit/CommitTeaser.svelte @@ -7,7 +7,7 @@ import ExpandButton from "@app/components/ExpandButton.svelte"; import IconButton from "@app/components/IconButton.svelte"; import Icon from "@app/components/Icon.svelte"; - import InlineTitle from "@app/views/projects/components/InlineTitle.svelte"; + import InlineTitle from "@app/views/repos/components/InlineTitle.svelte"; import Link from "@app/components/Link.svelte"; import Id from "@app/components/Id.svelte"; @@ -79,8 +79,8 @@
@@ -112,8 +112,8 @@ diff --git a/src/views/projects/DiffStatBadgeLoader.svelte b/src/views/repos/DiffStatBadgeLoader.svelte similarity index 89% rename from src/views/projects/DiffStatBadgeLoader.svelte rename to src/views/repos/DiffStatBadgeLoader.svelte index 3db848c466..cc4122e47b 100644 --- a/src/views/projects/DiffStatBadgeLoader.svelte +++ b/src/views/repos/DiffStatBadgeLoader.svelte @@ -1,7 +1,7 @@ - + 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/repos/Issue.svelte similarity index 90% rename from src/views/projects/Issue.svelte rename to src/views/repos/Issue.svelte index aa2460d159..719835e1e2 100644 --- a/src/views/projects/Issue.svelte +++ b/src/views/repos/Issue.svelte @@ -1,32 +1,32 @@ - + 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} + projectId={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/repos/Layout.svelte similarity index 85% rename from src/views/projects/Layout.svelte rename to src/views/repos/Layout.svelte index af4fd47d93..09238d46bb 100644 --- a/src/views/projects/Layout.svelte +++ b/src/views/repos/Layout.svelte @@ -1,18 +1,18 @@ @@ -126,15 +126,15 @@ - + @@ -157,11 +157,11 @@
@@ -176,8 +176,8 @@ @@ -191,10 +191,10 @@
{/if} {#if view.name === "diff"} @@ -461,7 +462,7 @@
@@ -472,7 +473,7 @@ diff --git a/src/views/projects/Patch/CheckoutButton.svelte b/src/views/repos/Patch/CheckoutButton.svelte similarity index 100% rename from src/views/projects/Patch/CheckoutButton.svelte rename to src/views/repos/Patch/CheckoutButton.svelte diff --git a/src/views/projects/Patch/CompareButton.svelte b/src/views/repos/Patch/CompareButton.svelte similarity index 100% rename from src/views/projects/Patch/CompareButton.svelte rename to src/views/repos/Patch/CompareButton.svelte diff --git a/src/views/projects/Patch/PatchTeaser.svelte b/src/views/repos/Patch/PatchTeaser.svelte similarity index 91% rename from src/views/projects/Patch/PatchTeaser.svelte rename to src/views/repos/Patch/PatchTeaser.svelte index 344d668a72..92c9820f0a 100644 --- a/src/views/projects/Patch/PatchTeaser.svelte +++ b/src/views/repos/Patch/PatchTeaser.svelte @@ -2,14 +2,18 @@ import type { BaseUrl } from "@http-client"; import type { Patch } from "@http-client"; - import { absoluteTimestamp, formatTimestamp } from "@app/lib/utils"; + import { + absoluteTimestamp, + formatNodeId, + formatTimestamp, + } from "@app/lib/utils"; import CommentCounter from "../CommentCounter.svelte"; import DiffStatBadgeLoader from "../DiffStatBadgeLoader.svelte"; import Icon from "@app/components/Icon.svelte"; import Id from "@app/components/Id.svelte"; - import InlineLabels from "@app/views/projects/Cob/InlineLabels.svelte"; - import InlineTitle from "@app/views/projects/components/InlineTitle.svelte"; + import InlineLabels from "@app/views/repos/Cob/InlineLabels.svelte"; + import InlineTitle from "@app/views/repos/components/InlineTitle.svelte"; import Link from "@app/components/Link.svelte"; import NodeId from "@app/components/NodeId.svelte"; @@ -99,8 +103,8 @@ @@ -135,7 +139,7 @@ style="display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;"> {patch.revisions.length > 1 ? "updated" : "opened"} diff --git a/src/views/projects/Patch/RevisionSelector.svelte b/src/views/repos/Patch/RevisionSelector.svelte similarity index 93% rename from src/views/projects/Patch/RevisionSelector.svelte rename to src/views/repos/Patch/RevisionSelector.svelte index b77cc55188..db0eb1ea97 100644 --- a/src/views/projects/Patch/RevisionSelector.svelte +++ b/src/views/repos/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} + projectId={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/Separator.svelte b/src/views/repos/Separator.svelte similarity index 100% rename from src/views/projects/Separator.svelte rename to src/views/repos/Separator.svelte diff --git a/src/views/projects/Share.svelte b/src/views/repos/Share.svelte similarity index 100% rename from src/views/projects/Share.svelte rename to src/views/repos/Share.svelte diff --git a/src/views/projects/Sidebar.svelte b/src/views/repos/Sidebar.svelte similarity index 91% rename from src/views/projects/Sidebar.svelte rename to src/views/repos/Sidebar.svelte index f05e753294..1afa773b16 100644 --- a/src/views/projects/Sidebar.svelte +++ b/src/views/repos/Sidebar.svelte @@ -1,9 +1,9 @@