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.
Example
Section titled “Example”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()); },});Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
C | Record<string, unknown> | The shape of the source’s typed ctx.config preferences. |
Methods
Section titled “Methods”sync()
Section titled “sync()”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).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ctx | SourceContext<C> |
Returns
Section titled “Returns”Promise<SourceSyncResult | Document[]>