Skip to content

Commit

Permalink
chore: shared types for Publisher 3
Browse files Browse the repository at this point in the history
Should be released in advance to make testing possible.
  • Loading branch information
Leksat committed Aug 16, 2024
1 parent d36eedd commit f887f9c
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 353 deletions.
3 changes: 3 additions & 0 deletions packages/npm/@amazeelabs/publisher-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"rollup-plugin-dts": "6.1.0",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.5"
},
"dependencies": {
"zod": "^3.23.8"
}
}
39 changes: 38 additions & 1 deletion packages/npm/@amazeelabs/publisher-shared/src/exports.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { z } from 'zod';

export enum ApplicationState {
/**
* The application is starting and not yet available.
Expand Down Expand Up @@ -26,6 +28,41 @@ export type BuildModel = {
startedAt: number;
finishedAt: number;
success: boolean;
type: 'incremental' | 'full';
type: 'incremental' | 'full' | 'github-workflow';
logs: string;
};

export const envVarNameSchema = z.string().regex(/^[a-z_][a-z0-9_]*$/i, {
message: 'Invalid environment variable name',
});

export const envVarsSchema = z.record(envVarNameSchema, z.string(), {
message: 'Invalid environment variables',
});

export const workflowPublisherPayloadSchema = z.object(
{
callbackUrl: z.string().url(),
clearCache: z.boolean(),
environmentVariables: envVarsSchema.optional(),
},
{
message: 'Invalid publisher payload',
},
);
export type WorkflowPublisherPayload = z.infer<
typeof workflowPublisherPayloadSchema
>;

export const workflowStatusNotificationSchema = z.object(
{
status: z.enum(['started', 'success', 'failure']),
workflowRunUrl: z.string().url(),
},
{
message: 'Invalid workflow status notification',
},
);
export type WorkflowStatusNotification = z.infer<
typeof workflowStatusNotificationSchema
>;
Loading

0 comments on commit f887f9c

Please sign in to comment.