The Data Hub DSL (Domain Specific Language) provides a fluent TypeScript API for defining pipelines.
import { createPipeline } from '@oronts/vendure-data-hub-plugin';
const pipeline = createPipeline()
.name('My Pipeline')
.trigger('start', { type: 'MANUAL' })
.extract('fetch', { adapterCode: 'httpApi', url: 'https://api.example.com/products' })
.transform('process', { operators: [...] })
.load('save', { adapterCode: 'productUpsert', strategy: 'UPSERT', matchField: 'slug' })
.edge('start', 'fetch')
.edge('fetch', 'process')
.edge('process', 'save')
.build();
The DSL uses a fluent builder pattern. Each method returns the builder, allowing chaining:
createPipeline()
.name('Name') // Returns builder
.description('Desc') // Returns builder
.trigger(...) // Returns builder
.build(); // Returns PipelineDefinition
Each step has a unique key within the pipeline:
.extract('my-unique-key', { ... })
Keys are used in edges to connect steps.
Edges define the execution order:
.edge('step-a', 'step-b') // step-a runs before step-b
Each step type has specific configuration:
// Extract step
.extract('fetch', {
adapterCode: 'httpApi',
url: 'https://api.example.com/products',
method: 'GET',
})
// Transform step
.transform('process', {
operators: [
{ op: 'rename', args: { from: 'old', to: 'new' } },
],
})
// Load step
.load('save', {
adapterCode: 'productUpsert',
strategy: 'UPSERT',
matchField: 'slug',
})
The DSL is fully typed. Import types for IDE support:
import {
createPipeline,
PipelineBuilder,
PipelineDefinition,
ExtractStepConfig,
TransformStepConfig,
LoadStepConfig,
} from '@oronts/vendure-data-hub-plugin';
Pass built pipelines to the plugin:
import { DataHubPlugin, createPipeline } from '@oronts/vendure-data-hub-plugin';
const myPipeline = createPipeline()
.name('My Pipeline')
// ... steps ...
.build();
export const config: VendureConfig = {
plugins: [
DataHubPlugin.init({
pipelines: [{
code: 'my-pipeline',
name: 'My Pipeline',
enabled: true,
definition: myPipeline,
}],
}),
],
};