chore: finishing off zod zupport

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2023-02-23 14:20:35 +01:00
parent b1edb1669e
commit f86eb7f17d
12 changed files with 117 additions and 57 deletions
+6 -4
View File
@@ -36,9 +36,10 @@ export type ActionContext<TInput extends JsonObject> = {
export const createTemplateAction: <
TParams,
TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {},
TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {},
>(
templateAction: TemplateAction<TParams, TInputSchema>,
) => TemplateAction<TParams, TInputSchema>;
templateAction: TemplateAction<TParams, TInputSchema, TOutputSchema>,
) => TemplateAction<TParams, TInputSchema, TOutputSchema>;
// @alpha
export interface ScaffolderActionsExtensionPoint {
@@ -56,8 +57,9 @@ export type TaskSecrets = Record<string, string> & {
// @public (undocumented)
export type TemplateAction<
TParams,
TParams = {},
TInputSchema extends Schema | z.ZodType = {},
TOutputSchema extends Schema | z.ZodType = {},
> = {
id: string;
description?: string;
@@ -68,7 +70,7 @@ export type TemplateAction<
supportsDryRun?: boolean;
schema?: {
input?: TInputSchema;
output?: Schema;
output?: TOutputSchema;
};
handler: (
ctx: ActionContext<
@@ -17,7 +17,6 @@
import { TemplateAction } from './types';
import { z } from 'zod';
import { Schema } from 'jsonschema';
/**
* This function is used to create new template actions to get type safety.
*
@@ -26,9 +25,9 @@ import { Schema } from 'jsonschema';
export const createTemplateAction = <
TParams,
TInputSchema extends Schema | z.ZodType = {},
TOutputSchema extends Schema | z.ZodType = {},
>(
templateAction: TemplateAction<TParams, TInputSchema>,
): TemplateAction<TParams, TInputSchema> => {
// TODO(blam): Can add some more validation here to validate the action later on
templateAction: TemplateAction<TParams, TInputSchema, TOutputSchema>,
): TemplateAction<TParams, TInputSchema, TOutputSchema> => {
return templateAction;
};
+3 -2
View File
@@ -64,8 +64,9 @@ export type ActionContext<TInput extends JsonObject> = {
/** @public */
export type TemplateAction<
TParams,
TParams = {},
TInputSchema extends Schema | z.ZodType = {},
TOutputSchema extends Schema | z.ZodType = {},
> = {
id: string;
description?: string;
@@ -73,7 +74,7 @@ export type TemplateAction<
supportsDryRun?: boolean;
schema?: {
input?: TInputSchema;
output?: Schema;
output?: TOutputSchema;
};
handler: (
ctx: ActionContext<