docs-util: fix hook parameters not showing when using workflow input (#12382)
This commit is contained in:
1 parent
80007f3afd
commit
91173f3052
1 file changed
+35
-27
@@ -22,6 +22,7 @@ import {
|
|||||||
addTagsToReflection,
|
addTagsToReflection,
|
||||||
getResolvedResourcesOfStep,
|
getResolvedResourcesOfStep,
|
||||||
getUniqueStrArray,
|
getUniqueStrArray,
|
||||||
|
getWorkflowInputType,
|
||||||
} from "utils"
|
} from "utils"
|
||||||
import { StepType } from "./types.js"
|
import { StepType } from "./types.js"
|
||||||
import Examples from "./utils/examples.js"
|
import Examples from "./utils/examples.js"
|
||||||
@@ -565,38 +566,45 @@ class WorkflowsPlugin {
|
|||||||
ReflectionKind.Parameter,
|
ReflectionKind.Parameter,
|
||||||
signatureReflection
|
signatureReflection
|
||||||
)
|
)
|
||||||
|
const isParameterWorkflowInput =
|
||||||
|
inputSymbol.valueDeclaration?.kind === ts.SyntaxKind.Parameter &&
|
||||||
|
workflowReflection.signatures?.length
|
||||||
|
parameter.type = isParameterWorkflowInput
|
||||||
|
? getWorkflowInputType(workflowReflection.signatures![0]) ||
|
||||||
|
ReferenceType.createSymbolReference(inputSymbol, context)
|
||||||
|
: ReferenceType.createSymbolReference(inputSymbol, context)
|
||||||
|
|
||||||
parameter.type = ReferenceType.createSymbolReference(inputSymbol, context)
|
if (parameter.type.type === "reference") {
|
||||||
|
if (parameter.type.name === "__object") {
|
||||||
|
parameter.type.name = "object"
|
||||||
|
parameter.type.qualifiedName = "object"
|
||||||
|
|
||||||
if (parameter.type.name === "__object") {
|
if (!parameter.comment?.summary) {
|
||||||
parameter.type.name = "object"
|
parameter.comment = new Comment()
|
||||||
parameter.type.qualifiedName = "object"
|
parameter.comment.summary = [
|
||||||
|
{
|
||||||
if (!parameter.comment?.summary) {
|
kind: "text",
|
||||||
parameter.comment = new Comment()
|
text: "The input data for the hook.",
|
||||||
parameter.comment.summary = [
|
},
|
||||||
{
|
]
|
||||||
kind: "text",
|
}
|
||||||
text: "The input data for the hook.",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (parameter.type.reflection instanceof DeclarationReflection) {
|
if (parameter.type.reflection instanceof DeclarationReflection) {
|
||||||
const additionalDataChild = parameter.type.reflection.children?.find(
|
const additionalDataChild = parameter.type.reflection.children?.find(
|
||||||
(child) => child.name === "additional_data"
|
(child) => child.name === "additional_data"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (additionalDataChild) {
|
if (additionalDataChild) {
|
||||||
additionalDataChild.comment =
|
additionalDataChild.comment =
|
||||||
additionalDataChild.comment || new Comment()
|
additionalDataChild.comment || new Comment()
|
||||||
additionalDataChild.comment.summary = [
|
additionalDataChild.comment.summary = [
|
||||||
{
|
{
|
||||||
kind: "text",
|
kind: "text",
|
||||||
text: "Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).",
|
text: "Additional data that can be passed through the `additional_data` property in HTTP requests.\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user