Skip to content

runSource

function runSource<C>(source: TroveSource<C>, options?: RunOptions<C>): Promise<RunResult>;

Run a source’s sync against a built ctx and collect/validate the result.

This is the harness the CLI drives for trove source dev / trove source test: it builds the SourceContext from { config, cursor }, runs sync(ctx), normalizes a bare-array return, validates every document’s required fields (clear, indexed errors), and dedups by id. Errors thrown by sync itself propagate unchanged so the CLI can report a failed run exactly as the Mac app would.

Type ParameterDefault typeDescription
CRecord<string, unknown>The shape of the source’s typed ctx.config preferences.
ParameterTypeDescription
sourceTroveSource<C>The source whose sync to run.
optionsRunOptions<C>The { config, cursor } spec plus test injection points.

Promise<RunResult>

The validated, deduped RunResult.

If sync throws, returns a malformed value, or a document fails validation.