|
| 1 | +import { z } from 'zod'; |
| 2 | + |
1 | 3 | export enum ApplicationState {
|
2 | 4 | /**
|
3 | 5 | * The application is starting and not yet available.
|
@@ -26,6 +28,41 @@ export type BuildModel = {
|
26 | 28 | startedAt: number;
|
27 | 29 | finishedAt: number;
|
28 | 30 | success: boolean;
|
29 |
| - type: 'incremental' | 'full'; |
| 31 | + type: 'incremental' | 'full' | 'github-workflow'; |
30 | 32 | logs: string;
|
31 | 33 | };
|
| 34 | + |
| 35 | +export const envVarNameSchema = z.string().regex(/^[a-z_][a-z0-9_]*$/i, { |
| 36 | + message: 'Invalid environment variable name', |
| 37 | +}); |
| 38 | + |
| 39 | +export const envVarsSchema = z.record(envVarNameSchema, z.string(), { |
| 40 | + message: 'Invalid environment variables', |
| 41 | +}); |
| 42 | + |
| 43 | +export const workflowPublisherPayloadSchema = z.object( |
| 44 | + { |
| 45 | + callbackUrl: z.string().url(), |
| 46 | + clearCache: z.boolean(), |
| 47 | + environmentVariables: envVarsSchema.optional(), |
| 48 | + }, |
| 49 | + { |
| 50 | + message: 'Invalid publisher payload', |
| 51 | + }, |
| 52 | +); |
| 53 | +export type WorkflowPublisherPayload = z.infer< |
| 54 | + typeof workflowPublisherPayloadSchema |
| 55 | +>; |
| 56 | + |
| 57 | +export const workflowStatusNotificationSchema = z.object( |
| 58 | + { |
| 59 | + status: z.enum(['started', 'success', 'failure']), |
| 60 | + workflowRunUrl: z.string().url(), |
| 61 | + }, |
| 62 | + { |
| 63 | + message: 'Invalid workflow status notification', |
| 64 | + }, |
| 65 | +); |
| 66 | +export type WorkflowStatusNotification = z.infer< |
| 67 | + typeof workflowStatusNotificationSchema |
| 68 | +>; |
0 commit comments