web / lib/jobs/utils/job-context
lib/jobs/utils/job-context
Defines types and helper functions for managing the context object passed to job handlers.
This module provides a standardized structure (JobHandlerContext) for the context
object that job handlers receive. It includes TypeScript interfaces for various job
payloads and helper functions to safely extract necessary information like the
Payload instance and job-specific inputs from the context. This ensures
consistency and robustness in how jobs are executed.
Interfaces
FileParsingJobPayload
Properties
input
input:
object
importJobId
importJobId:
number
filePath
filePath:
string
fileType
fileType:
"csv"|"xlsx"
BatchProcessingJobPayload
Properties
input
input:
object
importJobId
importJobId:
number
batchNumber
batchNumber:
number
batchData
batchData:
Record<string,unknown>[]
GeocodingBatchJobPayload
Properties
input
input:
object
importJobId
importJobId:
number
eventIds?
optionaleventIds:number[]
batchNumber?
optionalbatchNumber:number
EventCreationJobPayload
Properties
input
input:
object
importJobId
importJobId:
number
processedData
processedData:
Record<string,unknown>[]
batchNumber
batchNumber:
number
Type Aliases
JobHandlerContext<T>
JobHandlerContext<
T> =object
Type Parameters
T
T = unknown
Indexable
[key: string]: unknown
Properties
input?
optionalinput:T
job?
optionaljob:object
Index Signature
[key: string]: unknown
id
id:
string|number
taskStatus?
optionaltaskStatus:Record<string,unknown>
req?
optionalreq:object
Index Signature
[key: string]: unknown
payload
payload:
Payload
payload?
optionalpayload:Payload
Functions
extractFileParsingContext()
extractFileParsingContext(
context):object
Parameters
context
Returns
object
payload
payload:
BasePayload
input
input:
object
input.importJobId
importJobId:
number
input.filePath
filePath:
string
input.fileType
fileType:
"csv"|"xlsx"
extractEventCreationContext()
extractEventCreationContext(
context):object
Parameters
context
Returns
object
payload
payload:
BasePayload
input
input:
object
input.importJobId
importJobId:
number
input.processedData
processedData:
Record<string,unknown>[]
input.batchNumber
batchNumber:
number