Skip to content

TroveSource

The type a source’s default export satisfies. A source is an object with a sync method that fetches new content and returns documents to index.

import { defineSource } from '@ontrove/extend/source';
export default defineSource({
async sync(ctx) {
const res = await ctx.fetch(ctx.config.feedUrl as string);
return parse(await res.text());
},
});
Type ParameterDefault typeDescription
CRecord<string, unknown>The shape of the source’s typed ctx.config preferences.
sync(ctx: SourceContext<C>): Promise<SourceSyncResult | Document[]>;

The batch entry point. Fetches new content and returns documents to index, optionally with a new cursor. May return a bare Document[] for convenience. Throw a plain Error to fail the run (the Mac app records the error and retries next tick).

ParameterType
ctxSourceContext<C>

Promise<SourceSyncResult | Document[]>