@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 2.67 kB
Source Map (JSON)
{"version":3,"file":"jobs.mjs","names":["formatter"],"sources":["../../../src/libs/formatters/jobs.ts"],"sourcesContent":["import type { Job } from \"../../types/response.js\";\nimport type { QueueEvent, QueueJobStatus } from \"../queue/types.js\";\nimport formatter from \"./index.js\";\n\ninterface JobPropT {\n\tid: number;\n\tjob_id: string;\n\tevent_type: QueueEvent;\n\tevent_data: Record<string, unknown>;\n\tqueue_adapter_key: string;\n\tstatus: QueueJobStatus;\n\tpriority: number | null;\n\tattempts: number;\n\tmax_attempts: number;\n\terror_message: string | null;\n\tcreated_at: Date | string | null;\n\tscheduled_for: Date | string | null;\n\tstarted_at: Date | string | null;\n\tcompleted_at: Date | string | null;\n\tfailed_at: Date | string | null;\n\tnext_retry_at: Date | string | null;\n\tcreated_by_user_id: number | null;\n\tupdated_at: Date | string | null;\n}\n\nconst formatMultiple = (props: { jobs: JobPropT[] }) => {\n\treturn props.jobs.map((j) =>\n\t\tformatSingle({\n\t\t\tjob: j,\n\t\t}),\n\t);\n};\n\nconst formatSingle = (props: { job: JobPropT }): Job => {\n\treturn {\n\t\tid: props.job.id,\n\t\tjobId: props.job.job_id,\n\t\teventType: props.job.event_type,\n\t\teventData: props.job.event_data,\n\t\tqueueAdapterKey: props.job.queue_adapter_key,\n\t\tstatus: props.job.status,\n\t\tpriority: props.job.priority,\n\t\tattempts: props.job.attempts,\n\t\tmaxAttempts: props.job.max_attempts,\n\t\terrorMessage: props.job.error_message,\n\t\tcreatedAt: formatter.formatDate(props.job.created_at),\n\t\tscheduledFor: formatter.formatDate(props.job.scheduled_for),\n\t\tstartedAt: formatter.formatDate(props.job.started_at),\n\t\tcompletedAt: formatter.formatDate(props.job.completed_at),\n\t\tfailedAt: formatter.formatDate(props.job.failed_at),\n\t\tnextRetryAt: formatter.formatDate(props.job.next_retry_at),\n\t\tcreatedByUserId: props.job.created_by_user_id,\n\t\tupdatedAt: formatter.formatDate(props.job.updated_at),\n\t};\n};\n\nexport default {\n\tformatMultiple,\n\tformatSingle,\n};\n"],"mappings":"2BAyBA,MAAM,EAAkB,GAChB,EAAM,KAAK,IAAK,GACtB,EAAa,CACZ,IAAK,CACN,CAAC,CACF,EAGK,EAAgB,IACd,CACN,GAAI,EAAM,IAAI,GACd,MAAO,EAAM,IAAI,OACjB,UAAW,EAAM,IAAI,WACrB,UAAW,EAAM,IAAI,WACrB,gBAAiB,EAAM,IAAI,kBAC3B,OAAQ,EAAM,IAAI,OAClB,SAAU,EAAM,IAAI,SACpB,SAAU,EAAM,IAAI,SACpB,YAAa,EAAM,IAAI,aACvB,aAAc,EAAM,IAAI,cACxB,UAAWA,EAAU,WAAW,EAAM,IAAI,UAAU,EACpD,aAAcA,EAAU,WAAW,EAAM,IAAI,aAAa,EAC1D,UAAWA,EAAU,WAAW,EAAM,IAAI,UAAU,EACpD,YAAaA,EAAU,WAAW,EAAM,IAAI,YAAY,EACxD,SAAUA,EAAU,WAAW,EAAM,IAAI,SAAS,EAClD,YAAaA,EAAU,WAAW,EAAM,IAAI,aAAa,EACzD,gBAAiB,EAAM,IAAI,mBAC3B,UAAWA,EAAU,WAAW,EAAM,IAAI,UAAU,CACrD,GAGD,IAAA,EAAe,CACd,iBACA,cACD"}