Sources
Define pipeline sources and choose the right backend helper
Sources define where versioned files come from. A pipeline definition lists sources in inputs, and the executor resolves those sources before any route runs.
Source definitions are backend-driven
A source definition wraps a backend:
import { definePipelineSource } from "@ucdjs/pipeline-core";
const mySource = definePipelineSource({
id: "custom-source",
backend: {
async listFiles(version) {
return [];
},
async readFile(file) {
return "";
},
},
});A backend can implement:
listFiles(version)to enumerate available filesreadFile(file)to read contentreadFileStream(file, options)when streaming is neededgetMetadata(file)when metadata is available
Source definitions can also add:
includesto keep only matching filesexcludesto drop matching fileskind: "pipeline-output"for synthetic sources built from another pipeline's outputs
Use helpers when possible
createMemorySource(...)
This is the best authoring helper for examples, tests, and playground pipelines:
import { createMemorySource } from "@ucdjs/pipeline-core/sources";
const colorsSource = createMemorySource({
id: "colors",
files: {
"1.0.0": [{
path: "data/colors.txt",
content: "FF0000; Red",
}],
},
});createHttpSource(...) and createUnicodeOrgSource(...)
These helpers create HTTP-backed sources:
import { createUnicodeOrgSource } from "@ucdjs/pipeline-core/sources";
const unicodeOrgSource = createUnicodeOrgSource();Use them when HTTP transport is the right abstraction for your environment. They are lower-level than the in-memory helper, and they are best suited to setups where file enumeration is controlled intentionally.
Filter files at the source boundary
Source-level includes and excludes run before route matching. That makes them useful for broad source shaping, such as limiting a large source to one directory or excluding generated files.
import { byGlob, definePipelineSource } from "@ucdjs/pipeline-core";
const source = definePipelineSource({
id: "custom-source",
backend,
includes: byGlob("**/*.txt"),
});Consume outputs from another pipeline
pipelineOutputSource(...) creates a synthetic source backed by outputs from an upstream pipeline:
import { pipelineOutputSource } from "@ucdjs/pipeline-core";
const publishedColorsInput = pipelineOutputSource({
pipelineId: "traced-outputs",
outputId: "filesystem-archive",
});Use this when one pipeline should read a published output from another pipeline in the same executor batch.