docs: fix input type of some hooks in workflow reference (#12995)

This commit is contained in:
Shahed Nasser
2025-07-18 18:11:41 +03:00
committed by GitHub
parent 9c94580d17
commit b46bbfae12
6 changed files with 21 additions and 9 deletions

View File

@@ -115,7 +115,10 @@ export default function (theme: MarkdownTheme) {
str += `Handlers consuming this hook accept the following input.\n\n`
str += Handlebars.helpers.parameterComponent.call(
cleanUpHookInput(signatures[0].parameters),
cleanUpHookInput(
signatures[0].parameters,
this.name === "addToCartWorkflow" && hook.name === "validate"
),
{
hash: {
sectionTitle: hook.name,

View File

@@ -41,11 +41,15 @@ export function getHookChildren(
}
export function cleanUpHookInput(
parameters: ParameterReflection[]
parameters: ParameterReflection[],
debug = false
): (ParameterReflection | DeclarationReflection)[] {
const hasInvokeParameter = parameters.some(
(parameter) => parameter.name === "invoke"
)
if (debug) {
console.log(parameters, hasInvokeParameter)
}
if (hasInvokeParameter) {
return getHookInputFromInvoke(parameters)
}
@@ -98,7 +102,12 @@ function cleanUpReflectionType(reflection: Reflection): Reflection {
reflection.type?.type === "intersection" &&
reflection.type.types.length >= 2
) {
reflection.type = reflection.type.types[1]
const allReferences = reflection.type.types.every(
(type) => type.type === "reference"
)
if (!allReferences) {
reflection.type = reflection.type.types[1]
}
}
if (reflection instanceof DeclarationReflection && reflection.children) {