···4# paths because the flake.nix is written in a way such that top-level members
5# (`weaver-cli` and `weaver-server`) are built as different derivations which avoid being
6# rebuilt if the other package's sources change.
7-members = ["crates/*", "crates/weaver-server", "crates/weaver-server"]
89#default-members = ["crates/weaver-cli"]
10···4243jacquard = { git = "https://tangled.org/@nonbinary.computer/jacquard", default-features = false, features = ["derive", "api_bluesky"] }
44jacquard-api = { git = "https://tangled.org/@nonbinary.computer/jacquard" }
045jacquard-axum = { git = "https://tangled.org/@nonbinary.computer/jacquard" }
4647[profile]
···4# paths because the flake.nix is written in a way such that top-level members
5# (`weaver-cli` and `weaver-server`) are built as different derivations which avoid being
6# rebuilt if the other package's sources change.
7+members = ["crates/*"]
89#default-members = ["crates/weaver-cli"]
10···4243jacquard = { git = "https://tangled.org/@nonbinary.computer/jacquard", default-features = false, features = ["derive", "api_bluesky"] }
44jacquard-api = { git = "https://tangled.org/@nonbinary.computer/jacquard" }
45+jacquard-common = { git = "https://tangled.org/@nonbinary.computer/jacquard" }
46jacquard-axum = { git = "https://tangled.org/@nonbinary.computer/jacquard" }
4748[profile]
···15 "type": "string",
16 "description": "Reference (AT-URI) to post record. This is the anchor post.",
17 "format": "at-uri"
18- },
19- "prioritizeFollowedUsers": {
20- "type": "boolean",
21- "description": "Whether to prioritize posts from followed users. It only has effect when the user is authenticated.",
22- "default": false
23 }
24 }
25 },
···15 "type": "string",
16 "description": "Reference (AT-URI) to post record. This is the anchor post.",
17 "format": "at-uri"
0000018 }
19 }
20 },
···35 "minimum": 0,
36 "maximum": 100
37 },
38- "prioritizeFollowedUsers": {
39- "type": "boolean",
40- "description": "Whether to prioritize posts from followed users. It only has effect when the user is authenticated.",
41- "default": false
42- },
43 "sort": {
44 "type": "string",
45 "description": "Sorting for the thread replies.",
···1+use jacquard::{
2+ CowStr, IntoStatic, XrpcRequest,
3+ types::{
4+ did::Did,
5+ nsid::Nsid,
6+ string::{RecordKey, Rkey},
7+ },
8+};
9+use serde::{Deserialize, Serialize};
10+11+const DEFAULT_CURSOR_LIMIT: u64 = 16;
12+const DEFAULT_CURSOR_LIMIT_MAX: u64 = 100;
13+14+fn get_default_cursor_limit() -> u64 {
15+ DEFAULT_CURSOR_LIMIT
16+}
17+18+#[derive(Clone, Deserialize, Serialize, XrpcRequest, IntoStatic)]
19+#[xrpc(
20+ nsid = "blue.microcosm.links.getBacklinks",
21+ method = Query,
22+ output = GetBacklinksResponse,
23+)]
24+pub struct GetBacklinksQuery<'a> {
25+ /// The link target
26+ ///
27+ /// can be an AT-URI, plain DID, or regular URI
28+ subject: jacquard::types::uri::Uri<'a>,
29+ /// Filter links only from this link source
30+ ///
31+ /// eg.: `app.bsky.feed.like:subject.uri`
32+ source: CowStr<'a>,
33+ #[serde(borrow)]
34+ cursor: Option<CowStr<'a>>,
35+ /// Filter links only from these DIDs
36+ ///
37+ /// include multiple times to filter by multiple source DIDs
38+ #[serde(default)]
39+ did: Vec<Did<'a>>,
40+ /// Set the max number of links to return per page of results
41+ #[serde(default = "get_default_cursor_limit")]
42+ limit: u64,
43+ // TODO: allow reverse (er, forward) order as well
44+}
45+#[derive(Deserialize, Serialize, IntoStatic)]
46+pub struct GetBacklinksResponse<'a> {
47+ total: u64,
48+ #[serde(borrow)]
49+ records: Vec<RecordId<'a>>,
50+ cursor: Option<CowStr<'a>>,
51+}
52+53+#[derive(Debug, PartialEq, Serialize, Deserialize, IntoStatic)]
54+pub struct RecordId<'a> {
55+ #[serde(borrow)]
56+ pub did: Did<'a>,
57+ pub collection: Nsid<'a>,
58+ pub rkey: RecordKey<Rkey<'a>>,
59+}
60+61+impl RecordId<'_> {
62+ pub fn did(&self) -> Did<'_> {
63+ self.did.clone()
64+ }
65+ pub fn collection(&self) -> Nsid<'_> {
66+ self.collection.clone()
67+ }
68+ pub fn rkey(&self) -> RecordKey<Rkey<'_>> {
69+ self.rkey.clone()
70+ }
71+}
+1
crates/weaver-common/src/lib.rs
···1//! Weaver common library - thin wrapper around jacquard with notebook-specific conveniences
203pub mod error;
4pub mod view;
5
···1//! Weaver common library - thin wrapper around jacquard with notebook-specific conveniences
23+pub mod constellation;
4pub mod error;
5pub mod view;
6