a tool for shared writing and social publishing
at refactor/standard.site 34 lines 1.6 kB view raw
1import { AtUri } from "@atproto/syntax"; 2import { ids } from "lexicons/api/lexicons"; 3 4/** 5 * Returns an OR filter string for Supabase queries to match either namespace URI. 6 * Used for querying documents that may be stored under either pub.leaflet.document 7 * or site.standard.document namespaces. 8 */ 9export function documentUriFilter(did: string, rkey: string): string { 10 const standard = AtUri.make(did, ids.SiteStandardDocument, rkey).toString(); 11 const legacy = AtUri.make(did, ids.PubLeafletDocument, rkey).toString(); 12 return `uri.eq.${standard},uri.eq.${legacy}`; 13} 14 15/** 16 * Returns an OR filter string for Supabase queries to match either namespace URI. 17 * Used for querying publications that may be stored under either pub.leaflet.publication 18 * or site.standard.publication namespaces. 19 */ 20export function publicationUriFilter(did: string, rkey: string): string { 21 const standard = AtUri.make(did, ids.SiteStandardPublication, rkey).toString(); 22 const legacy = AtUri.make(did, ids.PubLeafletPublication, rkey).toString(); 23 return `uri.eq.${standard},uri.eq.${legacy}`; 24} 25 26/** 27 * Returns an OR filter string for Supabase queries to match a publication by name 28 * or by either namespace URI. Used when the rkey might be the publication name. 29 */ 30export function publicationNameOrUriFilter(did: string, nameOrRkey: string): string { 31 const standard = AtUri.make(did, ids.SiteStandardPublication, nameOrRkey).toString(); 32 const legacy = AtUri.make(did, ids.PubLeafletPublication, nameOrRkey).toString(); 33 return `name.eq.${nameOrRkey},uri.eq.${standard},uri.eq.${legacy}`; 34}