Skip to content

createJobTypes

createJobTypes<TJobTypeDefinitions, TExternalJobTypeDefinitions>(options): JobTypes<TJobTypeDefinitions, TExternalJobTypeDefinitions>

Defined in: packages/core/src/entities/job-types.ts:102

Create a job type registry with runtime validation. Wraps adapter errors in JobTypeValidationError.

TJobTypeDefinitions extends BaseJobTypeDefinitions

TExternalJobTypeDefinitions extends BaseJobTypeDefinitions = Record<never, never>

Adapter-supplied validation callbacks. Functions should throw on validation failure (any error type).

() => readonly string[]

Returns the known job type names. Used for runtime duplicate detection when createClient merges slices.

(typeName, input) => unknown

Parse and validate input. Return transformed value or throw on failure.

(typeName, output) => unknown

Parse and validate output. Return transformed value or throw on failure.

(typeName, blockers) => void

Validate blocker references. Receives array of { typeName, input } objects. Throw on failure.

(typeName, target) => void

Validate continuation target. Receives { typeName, input } for nominal/structural validation. Throw on failure.

(typeName) => void

Validate that a job type can start a chain. Throw on failure.

JobTypes<TJobTypeDefinitions, TExternalJobTypeDefinitions>

const registry = createJobTypes<MyJobTypes>({
getTypeNames: () => Object.keys(schemas),
validateEntry: (typeName) => {
if (!entryTypes.has(typeName)) throw new Error('Not an entry point');
},
parseInput: (typeName, input) => schemas[typeName].input.parse(input),
parseOutput: (typeName, output) => schemas[typeName].output.parse(output),
validateContinueWith: (typeName, target) => schemas[typeName].continueWith.parse(target),
validateBlockers: (typeName, blockers) => schemas[typeName].blockers.parse(blockers),
});