{"version":3,"file":"jobs.mjs","names":[],"sources":["../../src/schemas/jobs.ts"],"sourcesContent":["import z from \"zod\";\nimport type { ControllerSchema } from \"../types.js\";\nimport { queryFormatted, queryString } from \"./helpers/querystring.js\";\n\nexport const queueJobStatusSchema = z.union([\n\tz.literal(\"pending\"),\n\tz.literal(\"processing\"),\n\tz.literal(\"completed\"),\n\tz.literal(\"failed\"),\n\tz.literal(\"cancelled\"),\n]);\n\nconst jobResponseSchema = z.object({\n\tid: z.number().meta({\n\t\tdescription: \"The job ID\",\n\t\texample: 1,\n\t}),\n\tjobId: z.string().meta({\n\t\tdescription: \"The unique job identifier\",\n\t\texample: \"job_abc123\",\n\t}),\n\teventType: z.string().meta({\n\t\tdescription: \"The type of event this job handles\",\n\t\texample: \"email:send\",\n\t}),\n\teventData: z.record(z.string(), z.any()).meta({\n\t\tdescription: \"The data associated with the job event\",\n\t\texample: {\n\t\t\temailId: 123,\n\t\t\trecipientEmail: \"user@example.com\",\n\t\t},\n\t}),\n\tqueueAdapterKey: z.string().meta({\n\t\tdescription: \"The queue adapter key used to process this job\",\n\t\texample: \"passthrough\",\n\t}),\n\tstatus: queueJobStatusSchema.meta({\n\t\tdescription: \"The current status of the job\",\n\t\texample: \"completed\",\n\t}),\n\tpriority: z.number().nullable().meta({\n\t\tdescription: \"The priority level of the job (higher = more priority)\",\n\t\texample: 10,\n\t}),\n\tattempts: z.number().meta({\n\t\tdescription: \"The number of attempts made to process this job\",\n\t\texample: 1,\n\t}),\n\tmaxAttempts: z.number().meta({\n\t\tdescription: \"The maximum number of attempts allowed for this job\",\n\t\texample: 3,\n\t}),\n\terrorMessage: z.string().nullable().meta({\n\t\tdescription: \"The error message if the job failed\",\n\t\texample: \"Connection timeout\",\n\t}),\n\tcreatedAt: z.string().nullable().meta({\n\t\tdescription: \"Timestamp when the job was created\",\n\t\texample: \"2024-04-25T14:30:00.000Z\",\n\t}),\n\tscheduledFor: z.string().nullable().meta({\n\t\tdescription: \"Timestamp when the job is scheduled to run\",\n\t\texample: \"2024-04-25T14:30:00.000Z\",\n\t}),\n\tstartedAt: z.string().nullable().meta({\n\t\tdescription: \"Timestamp when the job started processing\",\n\t\texample: \"2024-04-25T14:30:05.000Z\",\n\t}),\n\tcompletedAt: z.string().nullable().meta({\n\t\tdescription: \"Timestamp when the job completed successfully\",\n\t\texample: \"2024-04-25T14:30:10.000Z\",\n\t}),\n\tfailedAt: z.string().nullable().meta({\n\t\tdescription: \"Timestamp when the job failed\",\n\t\texample: \"2024-04-25T14:30:08.000Z\",\n\t}),\n\tnextRetryAt: z.string().nullable().meta({\n\t\tdescription: \"Timestamp when the job will be retried next\",\n\t\texample: \"2024-04-25T14:35:00.000Z\",\n\t}),\n\tcreatedByUserId: z.number().nullable().meta({\n\t\tdescription: \"The ID of the user who created the job\",\n\t\texample: 1,\n\t}),\n\tupdatedAt: z.string().nullable().meta({\n\t\tdescription: \"Timestamp when the job was last updated\",\n\t\texample: \"2024-04-25T14:30:10.000Z\",\n\t}),\n});\n\nexport const controllerSchemas = {\n\tgetMultiple: {\n\t\tbody: undefined,\n\t\tquery: {\n\t\t\tstring: z\n\t\t\t\t.object({\n\t\t\t\t\t\"filter[jobId]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"9d1fcfac-f491-43d4-a33b-4432b91a373c\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[eventType]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"email:send\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[status]\": queryString.schema.filter(true, {\n\t\t\t\t\t\texample: \"completed\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[queueAdapterKey]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"passthrough\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[priority]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"5\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[attempts]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"1\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[maxAttempts]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"3\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[errorMessage]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"Connection refused\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[createdByUserId]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"1\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[createdAt]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"2026-01-01T00:00:00Z\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[scheduledFor]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"2026-01-01T00:00:00Z\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[startedAt]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"2026-01-01T00:00:00Z\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[completedAt]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"2026-01-01T00:00:00Z\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[failedAt]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"2026-01-01T00:00:00Z\",\n\t\t\t\t\t}),\n\t\t\t\t\t\"filter[nextRetryAt]\": queryString.schema.filter(false, {\n\t\t\t\t\t\texample: \"2026-01-01T00:00:00Z\",\n\t\t\t\t\t}),\n\t\t\t\t\tsort: queryString.schema.sort(\n\t\t\t\t\t\t\"createdAt,scheduledFor,startedAt,completedAt,failedAt,priority,attempts\",\n\t\t\t\t\t),\n\t\t\t\t\tpage: queryString.schema.page,\n\t\t\t\t\tperPage: queryString.schema.perPage,\n\t\t\t\t})\n\t\t\t\t.meta(queryString.meta),\n\t\t\tformatted: z.object({\n\t\t\t\tfilter: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\tjobId: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\teventType: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tstatus: queryFormatted.schema.filters.union.optional(),\n\t\t\t\t\t\tqueueAdapterKey: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tpriority: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tattempts: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tmaxAttempts: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\terrorMessage: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tcreatedByUserId: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tcreatedAt: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tscheduledFor: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tstartedAt: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tcompletedAt: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tfailedAt: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t\tnextRetryAt: queryFormatted.schema.filters.single.optional(),\n\t\t\t\t\t})\n\t\t\t\t\t.optional(),\n\t\t\t\tfilterOr: queryFormatted.schema.filterOr,\n\t\t\t\tsort: z\n\t\t\t\t\t.array(\n\t\t\t\t\t\tz.object({\n\t\t\t\t\t\t\tkey: z.enum([\n\t\t\t\t\t\t\t\t\"createdAt\",\n\t\t\t\t\t\t\t\t\"scheduledFor\",\n\t\t\t\t\t\t\t\t\"startedAt\",\n\t\t\t\t\t\t\t\t\"completedAt\",\n\t\t\t\t\t\t\t\t\"failedAt\",\n\t\t\t\t\t\t\t\t\"priority\",\n\t\t\t\t\t\t\t\t\"attempts\",\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\tdirection: z.enum([\"asc\", \"desc\"]),\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t\t.optional(),\n\t\t\t\tpage: queryFormatted.schema.page,\n\t\t\t\tperPage: queryFormatted.schema.perPage,\n\t\t\t}),\n\t\t},\n\t\tparams: undefined,\n\t\tresponse: z.array(jobResponseSchema),\n\t} satisfies ControllerSchema,\n\tgetSingle: {\n\t\tbody: undefined,\n\t\tquery: {\n\t\t\tstring: undefined,\n\t\t\tformatted: undefined,\n\t\t},\n\t\tparams: z.object({\n\t\t\tid: z.string().trim().meta({\n\t\t\t\tdescription: \"The job ID\",\n\t\t\t\texample: 1,\n\t\t\t}),\n\t\t}),\n\t\tresponse: jobResponseSchema,\n\t} satisfies ControllerSchema,\n};\n\nexport type GetMultipleQueryParams = z.infer<\n\ttypeof controllerSchemas.getMultiple.query.formatted\n>;\n"],"mappings":"+FAIA,MAAa,EAAuB,EAAE,MAAM,CAC3C,EAAE,QAAQ,SAAS,EACnB,EAAE,QAAQ,YAAY,EACtB,EAAE,QAAQ,WAAW,EACrB,EAAE,QAAQ,QAAQ,EAClB,EAAE,QAAQ,WAAW,CACtB,CAAC,EAEK,EAAoB,EAAE,OAAO,CAClC,GAAI,EAAE,OAAO,CAAC,CAAC,KAAK,CACnB,YAAa,aACb,QAAS,CACV,CAAC,EACD,MAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CACtB,YAAa,4BACb,QAAS,YACV,CAAC,EACD,UAAW,EAAE,OAAO,CAAC,CAAC,KAAK,CAC1B,YAAa,qCACb,QAAS,YACV,CAAC,EACD,UAAW,EAAE,OAAO,EAAE,OAAO,EAAG,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAC7C,YAAa,yCACb,QAAS,CACR,QAAS,IACT,eAAgB,kBACjB,CACD,CAAC,EACD,gBAAiB,EAAE,OAAO,CAAC,CAAC,KAAK,CAChC,YAAa,iDACb,QAAS,aACV,CAAC,EACD,OAAQ,EAAqB,KAAK,CACjC,YAAa,gCACb,QAAS,WACV,CAAC,EACD,SAAU,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CACpC,YAAa,yDACb,QAAS,EACV,CAAC,EACD,SAAU,EAAE,OAAO,CAAC,CAAC,KA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