withJobContext
withJobContext<
T>(data):WithJobContext<T>
Defined in: packages/pipeline-job-context/src/helpers/with-job-context.ts:26
Stamps the current execution context onto a job payload: the tenant and
correlation id of the registered sources (a new one from the correlation
source’s create() when none is active), and the principal the registered IJobPrincipal
captures, reduced to its identity. The processor restores it with
@InJobContext.
Type Parameters
Section titled “Type Parameters”T extends Record<string, unknown>
Parameters
Section titled “Parameters”T
The payload. Must be a plain object; a shallow copy is returned.
Returns
Section titled “Returns”A copy of data with jobContext added.
Throws
Section titled “Throws”When data is not a plain object.
Throws
Section titled “Throws”Without a registerJobContext registration, a
current tenant, or a current principal.
Example
Section titled “Example”await queue.add('send', withJobContext({ userId, email }));