Skip to content

Programmatic API

The pipeline engine is a CDS service you connect to and drive from code. This page is the reference for the public DataPipelineService API: registering pipelines, running them, managing schedules and overrides, and registering event hooks.

The engine itself has no OData surface (@protocol: 'none') — for the HTTP management API, see Management service. When you use @federation.replicate or @materialize.snapshot, the annotation plugins call addPipeline for you; you only touch this API directly for programmatic pipelines or event hooks.

Connecting

javascript
const pipelines = await cds.connect.to('data-pipeline')

Connect inside cds.on('served', …) in server.js, after the model is loaded.

addPipeline(config)

Registers a pipeline: validates and normalizes the config, initializes its tracker row, starts its schedule (if any), and optionally runs an initial load. Returns once registration is complete (or, with preload.wait, once the initial load finishes).

javascript
await pipelines.addPipeline({
  name: 'NorthwindProducts',
  source: { service: 'northwind', entity: 'Products' },
  target: { entity: 'my.app.LocalProducts' },
  mode: 'full',
  schedule: 600_000,
})

You do not pass a kind — the engine derives the shape (replicate / materialize / move) from the config. See Inference rules.

Top-level options

OptionType / defaultNotes
namestring (required)Unique pipeline id and tracker key.
descriptionstring? (max 1024 chars)Stored on the tracker; shown in the console.
sourceobject (required)Read side — see source.
targetobject (required)Write side — see target.
mode'delta' | 'full' | 'partial-refresh'Default: 'full'. Set 'delta' for incremental sync (requires delta config; defaults apply when omitted).
deltaobjectDelta detection — only used when mode: 'delta'. See delta.
schedulenumber | string | object | nullInternal schedule — see schedule. Omit for manual/external runs.
viewMappingobjectColumn/rename mapping. Inferred from the target consumption view if omitted.
refresh'full' | { mode: 'partial', slice }Query-shape rebuild strategy; slice is required for partial refresh.
retention{ retentionDays?, maxRuns? }Per-pipeline run-history retention (overrides the global housekeeping policy).
preloadboolean | { mode?, wait? }Initial load at startup — see preload.
flagsobject?Advanced integration flags (e.g. entity-cache behavior for federation). Rarely set directly.

source

FieldDefaultPurpose
serviceConnected service name (cds.requires key).
entityEntity-shape read. Mutually exclusive with query.
queryQuery-shape read: a closure (tracker) => SELECT ….
kindauto'cqn' | 'odata' | 'odata-v2' | 'hcql' | 'rest'. Usually inferred from the service.
adapterCustom BaseSourceAdapter subclass — see Custom source adapter.
originMulti-source fan-in label; requires the sourced aspect on the target. See Multi-source fan-in.
batchSize1000Rows requested per read batch.
maxRetries3Remote I/O retries.
retryDelay1000Retry backoff (ms).
delay0Inter-batch delay (ms) for throttling.
restREST adapter config (path, pagination, dataPath, …). See REST sources.

target

FieldPurpose
entityTarget entity fully-qualified name (required).
service'db' or unset → local DB (DbTargetAdapter); a remote OData service → ODataTargetAdapter; anything else needs adapter.
kindExplicit selector: 'odata' | 'odata-v2'.
adapterCustom BaseTargetAdapter subclass — see Custom target adapter.
batchSize, keyColumns, maxRetries, retryDelayWrite tuning (documented in OData targets).

delta

FieldDefaultNotes
mode'timestamp' when mode: 'delta''timestamp', 'key', or 'datetime-fields'. Ignored unless pipeline mode is 'delta'.
field'modifiedAt'Timestamp or key field carrying the high-watermark.
dateField, timeFieldFor 'datetime-fields' mode (OData V2 pattern).

schedule

Normalized to { every, engine } or no internal schedule.

InputResult
undefined / null / 0 / ''No internal schedule — run via execute or the management API.
number (ms){ every, engine: 'spawn' } — in-process interval.
time string (e.g. '10m'){ every, engine: 'spawn' }.
5-field cron string{ every, engine: 'queued' } — cross-instance single-winner.
{ every, engine? }engine defaults to 'queued' for cron, else 'spawn'.

See Internal scheduling (queued) and External scheduling (JSS).

preload

Runs an initial load right after registration, so the target is not empty between boot and the first scheduled tick.

InputBehavior
omitted / falseNo startup run.
trueBackground initial load in the pipeline's effective mode (does not block boot).
{ mode?, wait? }wait: true blocks addPipeline until the load completes (a failure then fails boot). mode overrides the run mode for the initial load only.

A disabled (paused) pipeline skips its preload run.

Running pipelines

execute(name, options?)

Runs a pipeline immediately.

javascript
await pipelines.execute('NorthwindProducts', { mode: 'full' })
// fire-and-forget:
await pipelines.execute('NorthwindProducts', { async: true, engine: 'queued' })
OptionDefaultValues
modepipeline default'full', 'delta', 'partial-refresh'.
trigger'manual''manual', 'scheduled', 'external', 'event' — recorded on the run.
asyncfalsetrue returns immediately; the run continues in the background.
engine'spawn''spawn' or 'queued' (only meaningful with async: true).
eventEvent-driven micro-run block: { read: 'key' | 'payload', action?, keys?, payload? }. See Event-driven runs.
tenantExplicit tenant context.

executeForTenant(tenant, name, options?)

Runs a pipeline in a specific tenant's context. See Multi-tenancy.

executeEvent(name, options)

Convenience wrapper for event-driven micro-runs; requires options.event.read. See Event-driven runs.

Managing pipelines at runtime

All of these persist to the tracker as overrides on top of the coded baseline — they survive restarts. See Configuration overrides.

MethodPurpose
getStatus(name)Current tracker status (idle / running / failed, last run, counts).
setSchedule(name, { every, cron, engine })Hot-replace the schedule.
clearSchedule(name)Stop the schedule (persists schedule: null).
isScheduleLiveChangeSupported(name)Whether a queued schedule can be changed live on this runtime (CDS 10+).
setEnabled(name, enabled)Pause/resume scheduled ticks. Manual execute still works while paused.
setOverrides(name, patch)Merge and persist a runtime override patch.
clearOverrides(name, keys?)Remove override keys (all, or the listed ones).
getConfigView(name)Returns { base, overrides, effective } for the pipeline.
clear(name)Clear the target and reset the tracker watermark.

Data inspector / flow metadata

These back the Pipeline Console; you can also call them directly.

MethodReturns
inspectData(name, opts?)Paged source/target preview rows (JSON).
inspectCapabilities(name)Which inspector sides are available.
getFlowMetadata(name, opts?)Per-pipeline data-flow graph.
getLandscapeMetadata(opts?)All-pipelines landscape graph.

Event hooks

Five namespaced events bracket every run. Register handlers with the standard CAP before / on / after API, keyed by pipeline name.

javascript
pipelines.before('PIPELINE.MAP', 'NorthwindProducts', (req) => { … })
pipelines.on('PIPELINE.READ', 'NorthwindProducts', (req) => { … })
pipelines.after('PIPELINE.DONE', 'NorthwindProducts', (req) => { … })
EventWhenCardinality
PIPELINE.STARTBefore READOnce per run
PIPELINE.READStream setupOnce per run
PIPELINE.MAPAfter each batch is readPer batch
PIPELINE.WRITEAfter each batch is mappedPer batch
PIPELINE.DONERun finished (success or failure)Once per run

on replaces the default

on('PIPELINE.MAP', …) and on('PIPELINE.WRITE', …) replace the built-in mapper/writer for that pipeline. To layer behavior on top of the defaults, use before / after. The name must match addPipeline({ name }) (or the federated entity name for @federation.replicate).

For worked examples, see Event hooks.

Plugin configuration (cds.requires['data-pipeline'])

Separate from addPipeline — this configures the plugin itself in package.json.

FieldPurpose
impl: 'cds-data-pipeline'Activates the plugin.
management.reuse.apiMount the management OData service at /pipeline/.
management.reuse.consoleMount the Pipeline Console (implies api).
management.inspect: falseDisable the data inspector.
housekeeping.{ retentionDays, maxRuns, schedule }Global PipelineRuns retention. See Housekeeping.

See also

Released under the MIT License.