/** * The discovery port over the local index. It answers the same question * Constellation answers, from records the appview indexed itself: which * records, in which accounts, name this repository at this path. * * Whoever answers can add noise or omit; they cannot forge a word, because * the caller reads each record from its author. */ import { linksOf } from './store.js'; /** One record about the subject, by its address. */ export { linksOf }; /** * @typedef {Object} DiscoveryPort * @property {(subjectUri: string, collection: string, path?: string) => Promise<{did: string, collection: string, rkey: string}[]>} about - * every record of the collection naming the subject at the path, which is * `subject.uri` unless given. */ /** * @param {import('./store.js').AppViewStore} store * @returns {DiscoveryPort} */ export function createIndexedDiscovery(store) { return { async about(subjectUri, collection, path = 'subject.uri') { const rows = store.about(subjectUri, collection, path); return rows.map((row) => ({ did: row.did, collection: row.collection, rkey: row.rkey, })); }, }; }