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;
} | ((zImpl: typeof z) => z.ZodType), TOutputSchema extends {
[key in string]: (zImpl: typeof z) => z.ZodType;
} | ((zImpl: typeof z) => z.ZodType)>(action: TemplateActionOptions<TInputSchema extends {
[key in string]: (zImpl: typeof z) => z.ZodType;
} ? {
[key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
} : TInputSchema extends (zImpl: typeof z) => z.ZodType ? z.infer<ReturnType<TInputSchema>> : never, TOutputSchema extends {
[key in string]: (zImpl: typeof z) => z.ZodType;
} ? {
[key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;
} : TOutputSchema extends (zImpl: typeof z) => z.ZodType ? z.infer<ReturnType<TOutputSchema>> : never, TInputSchema, TOutputSchema, 'v2'>): TemplateAction<FlattenOptionalProperties<TInputSchema extends {
[key in string]: (zImpl: typeof z) => z.ZodType;
} ? {
[key in keyof TInputSchema]: z.output<ReturnType<TInputSchema[key]>>;
} : TInputSchema extends (zImpl: typeof z) => z.ZodType ? z.output<ReturnType<TInputSchema>> : never>, FlattenOptionalProperties<TOutputSchema extends {
[key in string]: (zImpl: typeof z) => z.ZodType;
} ? {
[key in keyof TOutputSchema]: z.output<ReturnType<TOutputSchema[key]>>;
} : TOutputSchema extends (zImpl: typeof z) => z.ZodType ? z.output<ReturnType<TOutputSchema>> : never>, 'v2'>;

Parameters

Parameter

Type

Description

action

TemplateActionOptions<TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; } ? { [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>; } : TInputSchema extends (zImpl: typeof z) => z.ZodType ? z.infer<ReturnType<TInputSchema>> : never, TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType; } ? { [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>; } : TOutputSchema extends (zImpl: typeof z) => z.ZodType ? z.infer<ReturnType<TOutputSchema>> : never, TInputSchema, TOutputSchema, 'v2'>

**Returns:**

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