Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

Rename method name to fetch backlink DIDs

Renaming from `getDistinct` to `getBacklinkDids` to better reflect the
output type and the close relationship to the `getBacklinks` method.

+21 -39
+9 -9
constellation/src/server/mod.rs
··· 137 137 }), 138 138 ) 139 139 .route( 140 - "/xrpc/blue.microcosm.links.getDistinct", 140 + "/xrpc/blue.microcosm.links.getBacklinkDids", 141 141 get({ 142 142 let store = store.clone(); 143 143 move |accept, query| async { 144 - spawn_blocking(|| get_distinct(accept, query, store)) 144 + spawn_blocking(|| get_backlink_dids(accept, query, store)) 145 145 .await 146 146 .map_err(to500)? 147 147 } ··· 683 683 } 684 684 685 685 #[derive(Clone, Deserialize)] 686 - struct GetDistinctItemsQuery { 686 + struct GetBacklinkDidsQuery { 687 687 subject: String, 688 688 source: String, 689 689 cursor: Option<OpaqueApiCursor>, ··· 691 691 // TODO: allow reverse (er, forward) order as well 692 692 } 693 693 #[derive(Template, Serialize)] 694 - #[template(path = "get-distinct.html.j2")] 695 - struct GetDistinctItemsResponse { 694 + #[template(path = "get-backlink-dids.html.j2")] 695 + struct GetBacklinkDidsResponse { 696 696 // what does staleness mean? 697 697 // - new links have appeared. would be nice to offer a `since` cursor to fetch these. and/or, 698 698 // - links have been deleted. hmm. ··· 700 700 linking_dids: Vec<Did>, 701 701 cursor: Option<OpaqueApiCursor>, 702 702 #[serde(skip_serializing)] 703 - query: GetDistinctItemsQuery, 703 + query: GetBacklinkDidsQuery, 704 704 } 705 - fn get_distinct( 705 + fn get_backlink_dids( 706 706 accept: ExtractAccept, 707 - query: Query<GetDistinctItemsQuery>, 707 + query: Query<GetBacklinkDidsQuery>, 708 708 store: impl LinkReader, 709 709 ) -> Result<impl IntoResponse, http::StatusCode> { 710 710 let until = query ··· 738 738 739 739 Ok(acceptable( 740 740 accept, 741 - GetDistinctItemsResponse { 741 + GetBacklinkDidsResponse { 742 742 total: paged.total, 743 743 linking_dids: paged.items, 744 744 cursor,
+3 -19
constellation/templates/hello.html.j2
··· 82 82 25, 83 83 ) %} 84 84 85 - 86 - <h3 class="route"><code>GET /xrpc/blue.microcosm.links.getCounts</code></h3> 87 - 88 - <p>The total number of links pointing at a given target.</p> 89 - 90 - <h4>Query parameters:</h4> 91 - 92 - <ul> 93 - <li><code>subject</code>: required, must url-encode. The target being linked to. Example: <code>did:plc:vc7f4oafdgxsihk4cry2xpze</code> or <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></li> 94 - <li><code>source</code>: required. Collection and path specification for the primary link. Example: <code>app.bsky.feed.like:subject.uri</code></li> 95 - </ul> 96 - 97 - <p style="margin-bottom: 0"><strong>Try it:</strong></p> 98 - {% call try_it::get_counts("did:plc:vc7f4oafdgxsihk4cry2xpze", "app.bsky.graph.block:subject.uri") %} 99 - 100 - 101 - <h3 class="route"><code>GET /xrpc/blue.microcosm.links.getDistinct</code></h3> 85 + <h3 class="route"><code>GET /xrpc/blue.microcosm.links.getBacklinkDids</code></h3> 102 86 103 87 <p>A list of distinct DIDs (identities) with links to a target.</p> 104 88 ··· 112 96 </ul> 113 97 114 98 <p style="margin-bottom: 0"><strong>Try it:</strong></p> 115 - {% call try_it::get_distinct("at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r", "app.bsky.feed.like:subject.uri") %} 99 + {% call try_it::get_backlink_dids("at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r", "app.bsky.feed.like:subject.uri") %} 116 100 117 101 118 102 <h3 class="route"><code>GET /links</code></h3> ··· 148 132 </ul> 149 133 150 134 <p style="margin-bottom: 0"><strong>Try it:</strong></p> 151 - {% call try_it::get_distinct("at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r", "app.bsky.feed.like:.subject.uri") %} 135 + {% call try_it::get_backlink_dids("at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r", "app.bsky.feed.like:.subject.uri") %} 152 136 153 137 <h3 class="route"><code>GET /links/distinct-dids</code></h3> 154 138
+6 -8
constellation/templates/try-it-macros.html.j2
··· 112 112 </form> 113 113 {% endmacro %} 114 114 115 - {% macro get_distinct(subject, source) %} 116 - <form method="get" action="/xrpc/blue.microcosm.links.getDistinct"> 117 - <pre class="code"><strong>GET</strong> /xrpc/blue.microcosm.links.getDistinct 118 - ?subject= <input type="text" name="subject" value="{{ subject }}" placeholder="subject" /> 119 - &source= <input type="text" name="source" value="{{ source }}" placeholder="source" /> 120 - <button type="submit">get links</button> 121 - </pre> 122 - </form> 115 + {% macro get_backlink_dids(subject, source) %} 116 + <form method="get" action="/xrpc/blue.microcosm.links.getBacklinkDids"> 117 + <pre class="code"><strong>GET</strong> /xrpc/blue.microcosm.links.getBacklinkDids 118 + ?subject= <input type="text" name="subject" value="{{ subject }}" placeholder="subject" /> 119 + &source= <input type="text" name="source" value="{{ source }}" placeholder="source" /> <button type="submit">get links</button></pre> 120 + </form> 123 121 {% endmacro %} 124 122 125 123 {% macro links_count(target, collection, path) %}
+1 -1
lexicons/blue.microcosm/links/getDistinct.json lexicons/blue.microcosm/links/getBacklinkDids.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "blue.microcosm.links.getDistinct", 3 + "id": "blue.microcosm.links.getBacklinkDids", 4 4 "defs": { 5 5 "main": { 6 6 "type": "query",