|
|
@@ -50,8 +50,10 @@ export const serviceValidator = z.object({
|
|
|
}),
|
|
|
z.object({
|
|
|
type: z.literal("job"),
|
|
|
- allowConcurrent: serviceBooleanValidator,
|
|
|
+ allowConcurrent: serviceBooleanValidator.optional(),
|
|
|
cron: serviceStringValidator,
|
|
|
+ suspendCron: serviceBooleanValidator.optional(),
|
|
|
+ timeoutSeconds: serviceNumberValidator
|
|
|
}),
|
|
|
z.object({
|
|
|
type: z.literal("predeploy"),
|
|
|
@@ -86,8 +88,10 @@ export type SerializedService = {
|
|
|
}
|
|
|
| {
|
|
|
type: "job";
|
|
|
- allowConcurrent: boolean;
|
|
|
+ allowConcurrent?: boolean;
|
|
|
cron: string;
|
|
|
+ suspendCron?: boolean;
|
|
|
+ timeoutSeconds: number;
|
|
|
}
|
|
|
| {
|
|
|
type: "predeploy";
|
|
|
@@ -158,6 +162,8 @@ export function defaultSerialized({
|
|
|
type: "job" as const,
|
|
|
allowConcurrent: false,
|
|
|
cron: "",
|
|
|
+ suspendCron: false,
|
|
|
+ timeoutSeconds: 3600,
|
|
|
},
|
|
|
}))
|
|
|
.with("predeploy", () => ({
|
|
|
@@ -221,8 +227,10 @@ export function serializeService(service: ClientService): SerializedService {
|
|
|
ramMegabytes: service.ramMegabytes.value,
|
|
|
config: {
|
|
|
type: "job" as const,
|
|
|
- allowConcurrent: config.allowConcurrent.value,
|
|
|
+ allowConcurrent: config.allowConcurrent?.value,
|
|
|
cron: config.cron.value,
|
|
|
+ suspendCron: config.suspendCron?.value,
|
|
|
+ timeoutSeconds: config.timeoutSeconds.value,
|
|
|
},
|
|
|
})
|
|
|
)
|
|
|
@@ -326,11 +334,18 @@ export function deserializeService({
|
|
|
...baseService,
|
|
|
config: {
|
|
|
type: "job" as const,
|
|
|
- allowConcurrent: ServiceField.boolean(
|
|
|
- config.allowConcurrent,
|
|
|
- overrideJobConfig?.allowConcurrent
|
|
|
- ),
|
|
|
+ allowConcurrent:
|
|
|
+ typeof config.allowConcurrent === "boolean" ||
|
|
|
+ typeof overrideJobConfig?.allowConcurrent === "boolean"
|
|
|
+ ? ServiceField.boolean(config.allowConcurrent, overrideJobConfig?.allowConcurrent)
|
|
|
+ : ServiceField.boolean(false, undefined),
|
|
|
cron: ServiceField.string(config.cron, overrideJobConfig?.cron),
|
|
|
+ suspendCron:
|
|
|
+ typeof config.suspendCron === "boolean" ||
|
|
|
+ typeof overrideJobConfig?.suspendCron === "boolean"
|
|
|
+ ? ServiceField.boolean(config.suspendCron, overrideJobConfig?.suspendCron)
|
|
|
+ : ServiceField.boolean(false, undefined),
|
|
|
+ timeoutSeconds: config.timeoutSeconds == 0 ? ServiceField.number(3600, overrideJobConfig?.timeoutSeconds) : ServiceField.number(config.timeoutSeconds, overrideJobConfig?.timeoutSeconds),
|
|
|
},
|
|
|
};
|
|
|
})
|
|
|
@@ -394,6 +409,7 @@ export function serviceProto(service: SerializedService): Service {
|
|
|
config: {
|
|
|
value: {
|
|
|
...config,
|
|
|
+ allowConcurrentOptional: config.allowConcurrent,
|
|
|
},
|
|
|
case: "jobConfig",
|
|
|
},
|
|
|
@@ -456,6 +472,7 @@ export function serializedServiceFromProto({
|
|
|
config: {
|
|
|
type: isPredeploy ? ("predeploy" as const) : ("job" as const),
|
|
|
...value,
|
|
|
+ allowConcurrent: value.allowConcurrentOptional
|
|
|
},
|
|
|
}))
|
|
|
.exhaustive();
|