Fixed empty strings making their way into schedule externalId

This commit is contained in:
Eric Allam
2024-04-17 11:59:29 +01:00
parent 4986bfda2e
commit fde939a30e
4 changed files with 13 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---
Make optional schedule object fields nullish
@@ -58,8 +58,8 @@ export class TriggerScheduledTaskService extends BaseService {
const payload = {
scheduleId: instance.taskSchedule.friendlyId,
timestamp: instance.nextScheduledTimestamp,
lastTimestamp: instance.lastScheduledTimestamp,
externalId: instance.taskSchedule.externalId,
lastTimestamp: instance.lastScheduledTimestamp ?? undefined,
externalId: instance.taskSchedule.externalId ?? undefined,
upcoming: nextScheduledTimestamps(
instance.taskSchedule.generatorExpression,
instance.nextScheduledTimestamp!,
@@ -111,7 +111,7 @@ export class UpsertTaskScheduleService extends BaseService {
options.deduplicationKey !== undefined && options.deduplicationKey !== "",
generatorExpression: options.cron,
generatorDescription: cronstrue.toString(options.cron),
externalId: options.externalId,
externalId: options.externalId ? options.externalId : undefined,
},
});
@@ -160,7 +160,7 @@ export class UpsertTaskScheduleService extends BaseService {
data: {
generatorExpression: options.cron,
generatorDescription: cronstrue.toString(options.cron),
externalId: options.externalId,
externalId: options.externalId ? options.externalId : null,
},
});
+4 -4
View File
@@ -240,19 +240,19 @@ export const ScheduleObject = z.object({
id: z.string(),
task: z.string(),
active: z.boolean(),
deduplicationKey: z.string().optional(),
externalId: z.string().optional(),
deduplicationKey: z.string().nullish(),
externalId: z.string().nullish(),
generator: z.object({
type: z.literal("CRON"),
expression: z.string(),
description: z.string(),
}),
nextRun: z.coerce.date().optional(),
nextRun: z.coerce.date().nullish(),
environments: z.array(
z.object({
id: z.string(),
type: z.string(),
userName: z.string().optional(),
userName: z.string().nullish(),
})
),
});