Skip to content

Commit f887f9c

Browse files
committed
chore: shared types for Publisher 3
Should be released in advance to make testing possible.
1 parent d36eedd commit f887f9c

File tree

3 files changed

+127
-353
lines changed

3 files changed

+127
-353
lines changed

packages/npm/@amazeelabs/publisher-shared/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
"rollup-plugin-dts": "6.1.0",
1919
"rollup-plugin-esbuild": "6.1.1",
2020
"typescript": "5.4.5"
21+
},
22+
"dependencies": {
23+
"zod": "^3.23.8"
2124
}
2225
}

packages/npm/@amazeelabs/publisher-shared/src/exports.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { z } from 'zod';
2+
13
export enum ApplicationState {
24
/**
35
* The application is starting and not yet available.
@@ -26,6 +28,41 @@ export type BuildModel = {
2628
startedAt: number;
2729
finishedAt: number;
2830
success: boolean;
29-
type: 'incremental' | 'full';
31+
type: 'incremental' | 'full' | 'github-workflow';
3032
logs: string;
3133
};
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

Comments
 (0)