chore: really fix up the api-reports and make them clean and tidy

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2023-02-24 15:20:09 +01:00
parent 14d1a325b7
commit d57708a0c7
11 changed files with 384 additions and 511 deletions
+13 -20
View File
@@ -15,12 +15,12 @@ import { Writable } from 'stream';
import { z } from 'zod';
// @public
export type ActionContext<TInput = unknown> = {
export type ActionContext<TActionInput = unknown> = {
logger: Logger;
logStream: Writable;
secrets?: TaskSecrets;
workspacePath: string;
input: TInput;
input: TActionInput;
output(name: string, value: JsonValue): void;
createTemporaryDirectory(): Promise<string>;
templateInfo?: TemplateInfo;
@@ -36,9 +36,12 @@ export const createTemplateAction: <
TParams,
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,
>(
action: TemplateActionOptions<TParams, TInputSchema, TOutputSchema>,
) => TemplateAction<TParams, TInputSchema, TOutputSchema>;
action: TemplateActionOptions<TActionInput, TInputSchema, TOutputSchema>,
) => TemplateAction<TActionInput>;
// @alpha
export interface ScaffolderActionsExtensionPoint {
@@ -55,11 +58,7 @@ export type TaskSecrets = Record<string, string> & {
};
// @public (undocumented)
export type TemplateAction<
TParams = unknown,
TInputSchema extends Schema | unknown = unknown,
TOutputSchema extends Schema | unknown = unknown,
> = {
export type TemplateAction<TActionInput = unknown> = {
id: string;
description?: string;
examples?: {
@@ -68,15 +67,15 @@ export type TemplateAction<
}[];
supportsDryRun?: boolean;
schema?: {
input?: TInputSchema;
output?: TOutputSchema;
input?: Schema;
output?: Schema;
};
handler: (ctx: ActionContext<TParams>) => Promise<void>;
handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
};
// @public (undocumented)
export type TemplateActionOptions<
TParams = {},
TActionInput = {},
TInputSchema extends Schema | z.ZodType = {},
TOutputSchema extends Schema | z.ZodType = {},
> = {
@@ -91,12 +90,6 @@ export type TemplateActionOptions<
input?: TInputSchema;
output?: TOutputSchema;
};
handler: (
ctx: ActionContext<
TInputSchema extends z.ZodType<any, any, infer IReturn>
? IReturn
: TParams
>,
) => Promise<void>;
handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
};
```
@@ -21,7 +21,7 @@ import zodToJsonSchema from 'zod-to-json-schema';
/** @public */
export type TemplateActionOptions<
TParams = {},
TActionInput = {},
TInputSchema extends Schema | z.ZodType = {},
TOutputSchema extends Schema | z.ZodType = {},
> = {
@@ -33,13 +33,7 @@ export type TemplateActionOptions<
input?: TInputSchema;
output?: TOutputSchema;
};
handler: (
ctx: ActionContext<
TInputSchema extends z.ZodType<any, any, infer IReturn>
? IReturn
: TParams
>,
) => Promise<void>;
handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
};
/**
@@ -51,9 +45,12 @@ export const createTemplateAction = <
TParams,
TInputSchema extends Schema | z.ZodType = {},
TOutputSchema extends Schema | z.ZodType = {},
TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn>
? IReturn
: TParams,
>(
action: TemplateActionOptions<TParams, TInputSchema, TOutputSchema>,
): TemplateAction<TParams> => {
action: TemplateActionOptions<TActionInput, TInputSchema, TOutputSchema>,
): TemplateAction<TActionInput> => {
const inputSchema =
action.schema?.input && 'safeParseAsync' in action.schema.input
? zodToJsonSchema(action.schema.input)
@@ -73,5 +70,5 @@ export const createTemplateAction = <
},
};
return templateAction as TemplateAction<TParams>;
return templateAction;
};
+4 -4
View File
@@ -25,12 +25,12 @@ import { Schema } from 'jsonschema';
* ActionContext is passed into scaffolder actions.
* @public
*/
export type ActionContext<TInput = unknown> = {
export type ActionContext<TActionInput = unknown> = {
logger: Logger;
logStream: Writable;
secrets?: TaskSecrets;
workspacePath: string;
input: TInput;
input: TActionInput;
output(name: string, value: JsonValue): void;
/**
@@ -62,7 +62,7 @@ export type ActionContext<TInput = unknown> = {
};
/** @public */
export type TemplateAction<TParams = unknown> = {
export type TemplateAction<TActionInput = unknown> = {
id: string;
description?: string;
examples?: { description: string; example: string }[];
@@ -71,5 +71,5 @@ export type TemplateAction<TParams = unknown> = {
input?: Schema;
output?: Schema;
};
handler: (ctx: ActionContext<TParams>) => Promise<void>;
handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
};