|
|
@@ -53,12 +53,18 @@ export const serviceValidator = z.object({
|
|
|
allowConcurrent: serviceBooleanValidator.optional(),
|
|
|
cron: serviceStringValidator,
|
|
|
suspendCron: serviceBooleanValidator.optional(),
|
|
|
- timeoutSeconds: serviceNumberValidator
|
|
|
+ timeoutSeconds: serviceNumberValidator,
|
|
|
}),
|
|
|
z.object({
|
|
|
type: z.literal("predeploy"),
|
|
|
}),
|
|
|
]),
|
|
|
+ domainDeletions: z
|
|
|
+ .object({
|
|
|
+ name: z.string(),
|
|
|
+ })
|
|
|
+ .array()
|
|
|
+ .default([]),
|
|
|
});
|
|
|
|
|
|
export type ClientService = z.infer<typeof serviceValidator>;
|
|
|
@@ -273,6 +279,7 @@ export function deserializeService({
|
|
|
service.ramMegabytes,
|
|
|
override?.ramMegabytes
|
|
|
),
|
|
|
+ domainDeletions: [],
|
|
|
};
|
|
|
|
|
|
return match(service.config)
|
|
|
@@ -280,6 +287,13 @@ export function deserializeService({
|
|
|
const overrideWebConfig =
|
|
|
override?.config.type == "web" ? override.config : undefined;
|
|
|
|
|
|
+ const uniqueDomains = Array.from(
|
|
|
+ new Set([
|
|
|
+ ...config.domains.map((domain) => domain.name),
|
|
|
+ ...(overrideWebConfig?.domains ?? []).map((domain) => domain.name),
|
|
|
+ ])
|
|
|
+ ).map((domain) => ({ name: domain }));
|
|
|
+
|
|
|
return {
|
|
|
...baseService,
|
|
|
config: {
|
|
|
@@ -293,9 +307,7 @@ export function deserializeService({
|
|
|
override: overrideWebConfig?.healthCheck,
|
|
|
}),
|
|
|
|
|
|
- domains: Array.from(
|
|
|
- new Set([...config.domains, ...(overrideWebConfig?.domains ?? [])])
|
|
|
- ).map((domain) => ({
|
|
|
+ domains: uniqueDomains.map((domain) => ({
|
|
|
name: ServiceField.string(
|
|
|
domain.name,
|
|
|
overrideWebConfig?.domains.find(
|
|
|
@@ -337,15 +349,27 @@ export function deserializeService({
|
|
|
allowConcurrent:
|
|
|
typeof config.allowConcurrent === "boolean" ||
|
|
|
typeof overrideJobConfig?.allowConcurrent === "boolean"
|
|
|
- ? ServiceField.boolean(config.allowConcurrent, overrideJobConfig?.allowConcurrent)
|
|
|
+ ? 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(
|
|
|
+ config.suspendCron,
|
|
|
+ overrideJobConfig?.suspendCron
|
|
|
+ )
|
|
|
: ServiceField.boolean(false, undefined),
|
|
|
- timeoutSeconds: config.timeoutSeconds == 0 ? ServiceField.number(3600, overrideJobConfig?.timeoutSeconds) : ServiceField.number(config.timeoutSeconds, overrideJobConfig?.timeoutSeconds),
|
|
|
+ timeoutSeconds:
|
|
|
+ config.timeoutSeconds == 0
|
|
|
+ ? ServiceField.number(3600, overrideJobConfig?.timeoutSeconds)
|
|
|
+ : ServiceField.number(
|
|
|
+ config.timeoutSeconds,
|
|
|
+ overrideJobConfig?.timeoutSeconds
|
|
|
+ ),
|
|
|
},
|
|
|
};
|
|
|
})
|
|
|
@@ -410,6 +434,7 @@ export function serviceProto(service: SerializedService): Service {
|
|
|
value: {
|
|
|
...config,
|
|
|
allowConcurrentOptional: config.allowConcurrent,
|
|
|
+ timeoutSeconds: BigInt(config.timeoutSeconds),
|
|
|
},
|
|
|
case: "jobConfig",
|
|
|
},
|
|
|
@@ -466,14 +491,25 @@ export function serializedServiceFromProto({
|
|
|
...value,
|
|
|
},
|
|
|
}))
|
|
|
- .with({ case: "jobConfig" }, ({ value }) => ({
|
|
|
- ...service,
|
|
|
- name,
|
|
|
- config: {
|
|
|
- type: isPredeploy ? ("predeploy" as const) : ("job" as const),
|
|
|
- ...value,
|
|
|
- allowConcurrent: value.allowConcurrentOptional
|
|
|
- },
|
|
|
- }))
|
|
|
+ .with({ case: "jobConfig" }, ({ value }) =>
|
|
|
+ isPredeploy
|
|
|
+ ? {
|
|
|
+ ...service,
|
|
|
+ name,
|
|
|
+ config: {
|
|
|
+ type: "predeploy" as const,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ : {
|
|
|
+ ...service,
|
|
|
+ name,
|
|
|
+ config: {
|
|
|
+ type: "job" as const,
|
|
|
+ ...value,
|
|
|
+ allowConcurrent: value.allowConcurrentOptional,
|
|
|
+ timeoutSeconds: Number(value.timeoutSeconds),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
.exhaustive();
|
|
|
}
|