Skip to main content
Version: Next

createTemplateAction()

Home > @backstage/plugin-scaffolder-node > createTemplateAction

This function is used to create new template actions to get type safety. Will convert zod schemas to json schemas for use throughout the system.

Signature:

function createTemplateAction<TInputSchema extends {
[key in string]: (zImpl: typeof z) => z.ZodType;
}, TOutputSchema extends {
[key in string]: (zImpl: typeof z) => z.ZodType;
}>(action: TemplateActionOptions<{
[key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
}, {
[key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;
}, TInputSchema, TOutputSchema, 'v2'>): TemplateAction<FlattenOptionalProperties<{
[key in keyof TInputSchema]: z.output<ReturnType<TInputSchema[key]>>;
}>, FlattenOptionalProperties<{
[key in keyof TOutputSchema]: z.output<ReturnType<TOutputSchema[key]>>;
}>, 'v2'>;

Parameters

Parameter

Type

Description

action

TemplateActionOptions<{ [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>; }, { [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>; }, TInputSchema, TOutputSchema, 'v2'>

**Returns:**

TemplateAction<FlattenOptionalProperties<{ [key in keyof TInputSchema]: z.output<ReturnType<TInputSchema[key]>>; }>, FlattenOptionalProperties<{ [key in keyof TOutputSchema]: z.output<ReturnType<TOutputSchema[key]>>; }>, 'v2'>