docs: fix core flows reference not generating (#12274)
This commit is contained in:
1 parent
54bae210b8
commit
7d498227d1
386 files changed
+305437
-195486
No files matched your search
+282391
-177322
File diff suppressed because it is too large.
Load diff
@@ -59,6 +59,7 @@ export default async function generate(
|
||||
outputType: "json",
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
formatColoredLog({
|
||||
chalkInstance: chalk.bgRed,
|
||||
title: `Error generating for ${referenceName} models`,
|
||||
@@ -77,6 +78,7 @@ export default async function generate(
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
formatColoredLog({
|
||||
chalkInstance: chalk.bgRed,
|
||||
title: `Error generating for ${referenceName}`,
|
||||
|
||||
@@ -198,6 +198,7 @@ class WorkflowsPlugin {
|
||||
workflow,
|
||||
stepDepth,
|
||||
workflowReflection,
|
||||
constructorFn,
|
||||
})
|
||||
resources.push(...whenResources)
|
||||
} else {
|
||||
@@ -208,6 +209,7 @@ class WorkflowsPlugin {
|
||||
workflowVarName: parentReflection.name,
|
||||
workflowReflection,
|
||||
workflowComments: parentReflection.comment?.blockTags,
|
||||
constructorFn,
|
||||
})
|
||||
|
||||
if (!steps.length) {
|
||||
@@ -248,6 +250,7 @@ class WorkflowsPlugin {
|
||||
workflowVarName,
|
||||
workflowReflection,
|
||||
workflowComments = [],
|
||||
constructorFn,
|
||||
}: {
|
||||
initializer: ts.CallExpression
|
||||
context: Context
|
||||
@@ -255,6 +258,7 @@ class WorkflowsPlugin {
|
||||
workflowVarName: string
|
||||
workflowReflection: SignatureReflection
|
||||
workflowComments?: CommentTag[]
|
||||
constructorFn: ts.ArrowFunction | ts.FunctionExpression
|
||||
}): ParsedStep[] {
|
||||
const steps: ParsedStep[] = []
|
||||
const initializerName = this.helper.normalizeName(
|
||||
@@ -278,6 +282,8 @@ class WorkflowsPlugin {
|
||||
workflow,
|
||||
workflowVarName,
|
||||
workflowReflection,
|
||||
workflowComments,
|
||||
constructorFn,
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -290,14 +296,21 @@ class WorkflowsPlugin {
|
||||
if (stepType === "hook" && "symbol" in initializer.arguments[1]) {
|
||||
// get the hook's name from the first argument
|
||||
stepId = this.helper.normalizeName(initializer.arguments[0].getText())
|
||||
stepReflection = this.assembleHookReflection({
|
||||
stepId,
|
||||
context,
|
||||
inputSymbol: initializer.arguments[1].symbol as ts.Symbol,
|
||||
workflowName: workflowVarName,
|
||||
workflowComments,
|
||||
workflowReflection: workflowReflection.parent,
|
||||
const hookArgumetSymbol = this.getHookArgumentSymbol({
|
||||
argument: initializer.arguments[1],
|
||||
constructorFn,
|
||||
})
|
||||
|
||||
if (hookArgumetSymbol) {
|
||||
stepReflection = this.assembleHookReflection({
|
||||
stepId,
|
||||
context,
|
||||
inputSymbol: hookArgumetSymbol,
|
||||
workflowName: workflowVarName,
|
||||
workflowComments,
|
||||
workflowReflection: workflowReflection.parent,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const initializerReflection = findReflectionInNamespaces(
|
||||
context.project,
|
||||
@@ -373,6 +386,7 @@ class WorkflowsPlugin {
|
||||
workflow,
|
||||
stepDepth,
|
||||
workflowReflection,
|
||||
...rest
|
||||
}: {
|
||||
initializer: ts.CallExpression
|
||||
parentReflection: DeclarationReflection
|
||||
@@ -380,6 +394,7 @@ class WorkflowsPlugin {
|
||||
workflow?: WorkflowDefinition
|
||||
stepDepth: number
|
||||
workflowReflection: SignatureReflection
|
||||
constructorFn: ts.ArrowFunction | ts.FunctionExpression
|
||||
}): {
|
||||
resources: string[]
|
||||
} {
|
||||
@@ -452,6 +467,7 @@ class WorkflowsPlugin {
|
||||
workflow,
|
||||
workflowVarName: parentReflection.name,
|
||||
workflowReflection,
|
||||
...rest,
|
||||
}).forEach((step) => {
|
||||
this.createStepDocumentReflection({
|
||||
...step,
|
||||
@@ -818,6 +834,27 @@ class WorkflowsPlugin {
|
||||
handleForWorkflow(keys[0], this.addTagsAfterParsing[keys[0]])
|
||||
} while (keys.length > 0)
|
||||
}
|
||||
|
||||
getHookArgumentSymbol({
|
||||
argument,
|
||||
constructorFn,
|
||||
}: {
|
||||
argument: ts.Node
|
||||
constructorFn: ts.ArrowFunction | ts.FunctionExpression
|
||||
}): ts.Symbol | undefined {
|
||||
if ("symbol" in argument && argument.symbol) {
|
||||
return argument.symbol as ts.Symbol
|
||||
}
|
||||
|
||||
if (!("locals" in constructorFn) || !constructorFn.locals) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
// try to retrieve from the locals in the constructor function
|
||||
return (constructorFn.locals as Map<string, ts.Symbol>).get(
|
||||
argument.getText()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default WorkflowsPlugin
|
||||
@@ -2,7 +2,9 @@ import {
|
||||
DeclarationReflection,
|
||||
IntrinsicType,
|
||||
ParameterReflection,
|
||||
ReferenceType,
|
||||
Reflection,
|
||||
ReflectionType,
|
||||
} from "typedoc"
|
||||
|
||||
export function getHookChildren(
|
||||
@@ -40,7 +42,13 @@ export function getHookChildren(
|
||||
|
||||
export function cleanUpHookInput(
|
||||
parameters: ParameterReflection[]
|
||||
): ParameterReflection[] {
|
||||
): (ParameterReflection | DeclarationReflection)[] {
|
||||
const hasInvokeParameter = parameters.some(
|
||||
(parameter) => parameter.name === "invoke"
|
||||
)
|
||||
if (hasInvokeParameter) {
|
||||
return getHookInputFromInvoke(parameters)
|
||||
}
|
||||
return parameters.map((parameter) => {
|
||||
if (parameter.type?.type !== "reference" || !parameter.type.reflection) {
|
||||
return parameter
|
||||
@@ -67,6 +75,11 @@ function cleanUpReflectionType(reflection: Reflection): Reflection {
|
||||
) {
|
||||
return reflection
|
||||
}
|
||||
|
||||
if (reflection.name === "__type") {
|
||||
reflection.name = "input"
|
||||
}
|
||||
|
||||
if (
|
||||
reflection.type?.type === "reference" &&
|
||||
reflection.type.name === "WorkflowData" &&
|
||||
@@ -94,3 +107,35 @@ function cleanUpReflectionType(reflection: Reflection): Reflection {
|
||||
|
||||
return reflection
|
||||
}
|
||||
|
||||
function getHookInputFromInvoke(
|
||||
parameters: ParameterReflection[]
|
||||
): DeclarationReflection[] {
|
||||
const invokeParameter = parameters.find(
|
||||
(parameter) =>
|
||||
parameter.name === "invoke" &&
|
||||
parameter.type?.type === "reference" &&
|
||||
parameter.type.typeArguments?.length &&
|
||||
parameter.type.typeArguments[0].type === "reflection"
|
||||
)
|
||||
if (!invokeParameter) {
|
||||
return []
|
||||
}
|
||||
|
||||
const reflection = cleanUpReflectionType(
|
||||
(
|
||||
(invokeParameter.type as ReferenceType)
|
||||
.typeArguments![0] as ReflectionType
|
||||
).declaration
|
||||
)
|
||||
|
||||
if (
|
||||
reflection &&
|
||||
reflection instanceof DeclarationReflection &&
|
||||
reflection.children
|
||||
) {
|
||||
reflection.children.forEach(cleanUpReflectionType)
|
||||
}
|
||||
|
||||
return [reflection] as DeclarationReflection[]
|
||||
}
|
||||
Reference in new issue
Block a user