Allow defining output type in createTemplateAction
This change allow to define the output type of the createTemplateAction. This is necessary for zod definitions, which results in "Type instantiation is excessively deep and possibly infinite." Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
This commit is contained in:
@@ -13,8 +13,11 @@ export const createConfluenceToMarkdownAction: (options: {
|
||||
reader: UrlReader;
|
||||
integrations: ScmIntegrations;
|
||||
config: Config;
|
||||
}) => TemplateAction<{
|
||||
confluenceUrls: string[];
|
||||
repoUrl: string;
|
||||
}>;
|
||||
}) => TemplateAction<
|
||||
{
|
||||
confluenceUrls: string[];
|
||||
repoUrl: string;
|
||||
},
|
||||
unknown
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -609,13 +609,17 @@ export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export const createTemplateAction: <
|
||||
TParams,
|
||||
TInputParams,
|
||||
TOutputParams = unknown,
|
||||
TInputSchema extends ZodType<any, ZodTypeDef, any> | Schema = {},
|
||||
TOutputSchema extends ZodType<any, ZodTypeDef, any> | Schema = {},
|
||||
TActionInput = TInputSchema extends ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TParams,
|
||||
TActionOutput extends ActionOutputType<TOutputSchema> = ActionOutputType<TOutputSchema>,
|
||||
: TInputParams,
|
||||
TActionOutput extends ActionOutputType<
|
||||
TOutputSchema,
|
||||
TOutputParams
|
||||
> = ActionOutputType<TOutputSchema, TOutputParams>,
|
||||
>(
|
||||
action: TemplateActionOptions<
|
||||
TActionInput,
|
||||
|
||||
@@ -48,25 +48,28 @@ export type ActionContext<
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type ActionOutputType<TOutputSchema> = TOutputSchema extends z.ZodType<
|
||||
any,
|
||||
any,
|
||||
infer IReturn
|
||||
>
|
||||
export type ActionOutputType<
|
||||
TOutputSchema,
|
||||
FallbackOutput = unknown,
|
||||
> = TOutputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TOutputSchema extends undefined
|
||||
? undefined
|
||||
: unknown;
|
||||
: FallbackOutput;
|
||||
|
||||
// @public
|
||||
export const createTemplateAction: <
|
||||
TParams,
|
||||
TInputParams,
|
||||
TOutputParams = unknown,
|
||||
TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {},
|
||||
TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {},
|
||||
TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TParams,
|
||||
TActionOutput extends ActionOutputType<TOutputSchema> = ActionOutputType<TOutputSchema>,
|
||||
: TInputParams,
|
||||
TActionOutput extends ActionOutputType<
|
||||
TOutputSchema,
|
||||
TOutputParams
|
||||
> = ActionOutputType<TOutputSchema, TOutputParams>,
|
||||
>(
|
||||
action: TemplateActionOptions<
|
||||
TActionInput,
|
||||
|
||||
@@ -20,15 +20,14 @@ import { Schema } from 'jsonschema';
|
||||
import zodToJsonSchema from 'zod-to-json-schema';
|
||||
|
||||
/** @public */
|
||||
export type ActionOutputType<TOutputSchema> = TOutputSchema extends z.ZodType<
|
||||
any,
|
||||
any,
|
||||
infer IReturn
|
||||
>
|
||||
export type ActionOutputType<
|
||||
TOutputSchema,
|
||||
FallbackOutput = unknown,
|
||||
> = TOutputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TOutputSchema extends undefined
|
||||
? undefined
|
||||
: unknown;
|
||||
: FallbackOutput;
|
||||
|
||||
/** @public */
|
||||
export type TemplateActionOptions<
|
||||
@@ -54,13 +53,17 @@ export type TemplateActionOptions<
|
||||
* @public
|
||||
*/
|
||||
export const createTemplateAction = <
|
||||
TParams,
|
||||
TInputParams,
|
||||
TOutputParams = unknown,
|
||||
TInputSchema extends Schema | z.ZodType = {},
|
||||
TOutputSchema extends Schema | z.ZodType = {},
|
||||
TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn>
|
||||
? IReturn
|
||||
: TParams,
|
||||
TActionOutput extends ActionOutputType<TOutputSchema> = ActionOutputType<TOutputSchema>,
|
||||
: TInputParams,
|
||||
TActionOutput extends ActionOutputType<
|
||||
TOutputSchema,
|
||||
TOutputParams
|
||||
> = ActionOutputType<TOutputSchema, TOutputParams>,
|
||||
>(
|
||||
action: TemplateActionOptions<
|
||||
TActionInput,
|
||||
|
||||
Reference in New Issue
Block a user