?
defineMapper
Defines a source's mapper: how each raw object becomes zero or more corpus documents.
defineMapper(source, config: MapperConfig) → Mapper
Declares the transform for a data source. Given the source and a map function, it returns a Mapper the platform runs over each raw object during a sync or a bulk job. map takes one object and returns an outcome: documents, passthrough, skip, or deletes. Define it at module scope beside the source, then test and deploy it from the Admin CLI.
Parameters
source
{ name: string }
RequiredThe data source this mapper belongs to.
config
MapperConfig
RequiredThe transform: a single map function.
Map JSON records to documents
import { defineMapper, documents } from '@mindstudio-ai/agent'; export default defineMapper(Archive, { async map(object) { const record = await object.json(); return documents([{ externalId: record.id, title: record.title, markdown: record.body }]); }, });