@synergenius/flow-weaver 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +122 -0
- package/README.md +315 -0
- package/dist/annotation-generator.d.ts +45 -0
- package/dist/annotation-generator.js +557 -0
- package/dist/api/builder.d.ts +223 -0
- package/dist/api/builder.js +345 -0
- package/dist/api/compile.d.ts +92 -0
- package/dist/api/compile.js +149 -0
- package/dist/api/extract-types.d.ts +29 -0
- package/dist/api/extract-types.js +57 -0
- package/dist/api/generate-in-place.d.ts +73 -0
- package/dist/api/generate-in-place.js +1353 -0
- package/dist/api/generate.d.ts +83 -0
- package/dist/api/generate.js +510 -0
- package/dist/api/helpers.d.ts +248 -0
- package/dist/api/helpers.js +285 -0
- package/dist/api/index.d.ts +46 -0
- package/dist/api/index.js +45 -0
- package/dist/api/inline-runtime.d.ts +27 -0
- package/dist/api/inline-runtime.js +551 -0
- package/dist/api/manipulation/connections.d.ts +79 -0
- package/dist/api/manipulation/connections.js +151 -0
- package/dist/api/manipulation/index.d.ts +34 -0
- package/dist/api/manipulation/index.js +41 -0
- package/dist/api/manipulation/node-types.d.ts +123 -0
- package/dist/api/manipulation/node-types.js +200 -0
- package/dist/api/manipulation/nodes.d.ts +144 -0
- package/dist/api/manipulation/nodes.js +333 -0
- package/dist/api/manipulation/ports.d.ts +59 -0
- package/dist/api/manipulation/ports.js +228 -0
- package/dist/api/manipulation/scopes.d.ts +52 -0
- package/dist/api/manipulation/scopes.js +156 -0
- package/dist/api/manipulation/validation.d.ts +6 -0
- package/dist/api/manipulation/validation.js +6 -0
- package/dist/api/manipulation/workflow.d.ts +81 -0
- package/dist/api/manipulation/workflow.js +116 -0
- package/dist/api/manipulation.d.ts +8 -0
- package/dist/api/manipulation.js +8 -0
- package/dist/api/parse.d.ts +48 -0
- package/dist/api/parse.js +110 -0
- package/dist/api/patterns.d.ts +112 -0
- package/dist/api/patterns.js +306 -0
- package/dist/api/query.d.ts +429 -0
- package/dist/api/query.js +816 -0
- package/dist/api/templates.d.ts +98 -0
- package/dist/api/templates.js +117 -0
- package/dist/api/transform.d.ts +31 -0
- package/dist/api/transform.js +40 -0
- package/dist/api/validate.d.ts +25 -0
- package/dist/api/validate.js +39 -0
- package/dist/api/workflow-file-operations.d.ts +29 -0
- package/dist/api/workflow-file-operations.js +180 -0
- package/dist/ast/builder.d.ts +210 -0
- package/dist/ast/builder.js +395 -0
- package/dist/ast/index.d.ts +5 -0
- package/dist/ast/index.js +5 -0
- package/dist/ast/serialization-node.d.ts +6 -0
- package/dist/ast/serialization-node.js +30 -0
- package/dist/ast/serialization.d.ts +43 -0
- package/dist/ast/serialization.js +134 -0
- package/dist/ast/types.d.ts +852 -0
- package/dist/ast/types.js +2 -0
- package/dist/ast/workflow-utils.d.ts +54 -0
- package/dist/ast/workflow-utils.js +114 -0
- package/dist/body-generator.d.ts +31 -0
- package/dist/body-generator.js +35 -0
- package/dist/built-in-nodes/delay.d.ts +11 -0
- package/dist/built-in-nodes/delay.js +29 -0
- package/dist/built-in-nodes/index.d.ts +5 -0
- package/dist/built-in-nodes/index.js +4 -0
- package/dist/built-in-nodes/invoke-workflow.d.ts +13 -0
- package/dist/built-in-nodes/invoke-workflow.js +25 -0
- package/dist/built-in-nodes/mock-types.d.ts +18 -0
- package/dist/built-in-nodes/mock-types.js +12 -0
- package/dist/built-in-nodes/wait-for-event.d.ts +13 -0
- package/dist/built-in-nodes/wait-for-event.js +25 -0
- package/dist/chevrotain-parser/connect-parser.d.ts +24 -0
- package/dist/chevrotain-parser/connect-parser.js +98 -0
- package/dist/chevrotain-parser/grammar-diagrams.d.ts +29 -0
- package/dist/chevrotain-parser/grammar-diagrams.js +264 -0
- package/dist/chevrotain-parser/index.d.ts +25 -0
- package/dist/chevrotain-parser/index.js +27 -0
- package/dist/chevrotain-parser/map-parser.d.ts +33 -0
- package/dist/chevrotain-parser/map-parser.js +130 -0
- package/dist/chevrotain-parser/node-parser.d.ts +36 -0
- package/dist/chevrotain-parser/node-parser.js +466 -0
- package/dist/chevrotain-parser/path-parser.d.ts +28 -0
- package/dist/chevrotain-parser/path-parser.js +118 -0
- package/dist/chevrotain-parser/port-parser.d.ts +36 -0
- package/dist/chevrotain-parser/port-parser.js +442 -0
- package/dist/chevrotain-parser/position-parser.d.ts +20 -0
- package/dist/chevrotain-parser/position-parser.js +83 -0
- package/dist/chevrotain-parser/scope-parser.d.ts +19 -0
- package/dist/chevrotain-parser/scope-parser.js +104 -0
- package/dist/chevrotain-parser/tokens.d.ts +78 -0
- package/dist/chevrotain-parser/tokens.js +384 -0
- package/dist/chevrotain-parser/trigger-cancel-parser.d.ts +50 -0
- package/dist/chevrotain-parser/trigger-cancel-parser.js +282 -0
- package/dist/cli/commands/changelog.d.ts +13 -0
- package/dist/cli/commands/changelog.js +135 -0
- package/dist/cli/commands/compile.d.ts +64 -0
- package/dist/cli/commands/compile.js +278 -0
- package/dist/cli/commands/create.d.ts +33 -0
- package/dist/cli/commands/create.js +147 -0
- package/dist/cli/commands/describe.d.ts +68 -0
- package/dist/cli/commands/describe.js +377 -0
- package/dist/cli/commands/dev.d.ts +32 -0
- package/dist/cli/commands/dev.js +384 -0
- package/dist/cli/commands/diagram.d.ts +13 -0
- package/dist/cli/commands/diagram.js +33 -0
- package/dist/cli/commands/diff.d.ts +11 -0
- package/dist/cli/commands/diff.js +59 -0
- package/dist/cli/commands/doctor.d.ts +57 -0
- package/dist/cli/commands/doctor.js +719 -0
- package/dist/cli/commands/export.d.ts +57 -0
- package/dist/cli/commands/export.js +163 -0
- package/dist/cli/commands/grammar.d.ts +9 -0
- package/dist/cli/commands/grammar.js +39 -0
- package/dist/cli/commands/init.d.ts +59 -0
- package/dist/cli/commands/init.js +435 -0
- package/dist/cli/commands/listen.d.ts +16 -0
- package/dist/cli/commands/listen.js +39 -0
- package/dist/cli/commands/market.d.ts +52 -0
- package/dist/cli/commands/market.js +436 -0
- package/dist/cli/commands/migrate.d.ts +13 -0
- package/dist/cli/commands/migrate.js +89 -0
- package/dist/cli/commands/openapi.d.ts +37 -0
- package/dist/cli/commands/openapi.js +67 -0
- package/dist/cli/commands/pattern.d.ts +34 -0
- package/dist/cli/commands/pattern.js +185 -0
- package/dist/cli/commands/plugin.d.ts +16 -0
- package/dist/cli/commands/plugin.js +176 -0
- package/dist/cli/commands/run.d.ts +49 -0
- package/dist/cli/commands/run.js +191 -0
- package/dist/cli/commands/serve.d.ts +45 -0
- package/dist/cli/commands/serve.js +81 -0
- package/dist/cli/commands/templates.d.ts +8 -0
- package/dist/cli/commands/templates.js +54 -0
- package/dist/cli/commands/ui.d.ts +16 -0
- package/dist/cli/commands/ui.js +130 -0
- package/dist/cli/commands/validate.d.ts +12 -0
- package/dist/cli/commands/validate.js +247 -0
- package/dist/cli/commands/watch.d.ts +9 -0
- package/dist/cli/commands/watch.js +70 -0
- package/dist/cli/flow-weaver.mjs +92924 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +742 -0
- package/dist/cli/templates/ai/mock-provider.d.ts +7 -0
- package/dist/cli/templates/ai/mock-provider.js +64 -0
- package/dist/cli/templates/ai/types.d.ts +47 -0
- package/dist/cli/templates/ai/types.js +5 -0
- package/dist/cli/templates/approvals/index.d.ts +15 -0
- package/dist/cli/templates/approvals/index.js +241 -0
- package/dist/cli/templates/index.d.ts +102 -0
- package/dist/cli/templates/index.js +101 -0
- package/dist/cli/templates/nodes/agent-router.d.ts +3 -0
- package/dist/cli/templates/nodes/agent-router.js +114 -0
- package/dist/cli/templates/nodes/aggregator.d.ts +7 -0
- package/dist/cli/templates/nodes/aggregator.js +63 -0
- package/dist/cli/templates/nodes/conversation-memory.d.ts +3 -0
- package/dist/cli/templates/nodes/conversation-memory.js +85 -0
- package/dist/cli/templates/nodes/http.d.ts +7 -0
- package/dist/cli/templates/nodes/http.js +80 -0
- package/dist/cli/templates/nodes/human-approval.d.ts +3 -0
- package/dist/cli/templates/nodes/human-approval.js +110 -0
- package/dist/cli/templates/nodes/json-extractor.d.ts +3 -0
- package/dist/cli/templates/nodes/json-extractor.js +119 -0
- package/dist/cli/templates/nodes/llm-call.d.ts +3 -0
- package/dist/cli/templates/nodes/llm-call.js +106 -0
- package/dist/cli/templates/nodes/prompt-template.d.ts +3 -0
- package/dist/cli/templates/nodes/prompt-template.js +52 -0
- package/dist/cli/templates/nodes/rag-retriever.d.ts +3 -0
- package/dist/cli/templates/nodes/rag-retriever.js +128 -0
- package/dist/cli/templates/nodes/tool-executor.d.ts +3 -0
- package/dist/cli/templates/nodes/tool-executor.js +108 -0
- package/dist/cli/templates/nodes/transformer.d.ts +7 -0
- package/dist/cli/templates/nodes/transformer.js +68 -0
- package/dist/cli/templates/nodes/validator.d.ts +7 -0
- package/dist/cli/templates/nodes/validator.js +62 -0
- package/dist/cli/templates/providers/index.d.ts +14 -0
- package/dist/cli/templates/providers/index.js +239 -0
- package/dist/cli/templates/shared/approval-types.d.ts +9 -0
- package/dist/cli/templates/shared/approval-types.js +31 -0
- package/dist/cli/templates/shared/llm-types.d.ts +15 -0
- package/dist/cli/templates/shared/llm-types.js +104 -0
- package/dist/cli/templates/workflows/aggregator.d.ts +7 -0
- package/dist/cli/templates/workflows/aggregator.js +104 -0
- package/dist/cli/templates/workflows/ai-agent-durable.d.ts +8 -0
- package/dist/cli/templates/workflows/ai-agent-durable.js +338 -0
- package/dist/cli/templates/workflows/ai-agent.d.ts +31 -0
- package/dist/cli/templates/workflows/ai-agent.js +326 -0
- package/dist/cli/templates/workflows/ai-chat.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-chat.js +169 -0
- package/dist/cli/templates/workflows/ai-pipeline-durable.d.ts +8 -0
- package/dist/cli/templates/workflows/ai-pipeline-durable.js +330 -0
- package/dist/cli/templates/workflows/ai-rag.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-rag.js +186 -0
- package/dist/cli/templates/workflows/ai-react.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-react.js +294 -0
- package/dist/cli/templates/workflows/conditional.d.ts +12 -0
- package/dist/cli/templates/workflows/conditional.js +142 -0
- package/dist/cli/templates/workflows/error-handler.d.ts +7 -0
- package/dist/cli/templates/workflows/error-handler.js +147 -0
- package/dist/cli/templates/workflows/foreach.d.ts +7 -0
- package/dist/cli/templates/workflows/foreach.js +143 -0
- package/dist/cli/templates/workflows/sequential.d.ts +7 -0
- package/dist/cli/templates/workflows/sequential.js +198 -0
- package/dist/cli/templates/workflows/webhook.d.ts +7 -0
- package/dist/cli/templates/workflows/webhook.js +161 -0
- package/dist/cli/utils/logger.d.ts +15 -0
- package/dist/cli/utils/logger.js +46 -0
- package/dist/constants.d.ts +100 -0
- package/dist/constants.js +125 -0
- package/dist/defaults.d.ts +3 -0
- package/dist/defaults.js +3 -0
- package/dist/deployment/config/defaults.d.ts +29 -0
- package/dist/deployment/config/defaults.js +98 -0
- package/dist/deployment/config/loader.d.ts +24 -0
- package/dist/deployment/config/loader.js +236 -0
- package/dist/deployment/config/types.d.ts +117 -0
- package/dist/deployment/config/types.js +5 -0
- package/dist/deployment/core/adapters.d.ts +90 -0
- package/dist/deployment/core/adapters.js +251 -0
- package/dist/deployment/core/executor.d.ts +62 -0
- package/dist/deployment/core/executor.js +197 -0
- package/dist/deployment/core/formatters.d.ts +57 -0
- package/dist/deployment/core/formatters.js +170 -0
- package/dist/deployment/index.d.ts +31 -0
- package/dist/deployment/index.js +48 -0
- package/dist/deployment/openapi/generator.d.ts +146 -0
- package/dist/deployment/openapi/generator.js +347 -0
- package/dist/deployment/openapi/schema-converter.d.ts +49 -0
- package/dist/deployment/openapi/schema-converter.js +192 -0
- package/dist/deployment/targets/base.d.ts +316 -0
- package/dist/deployment/targets/base.js +823 -0
- package/dist/deployment/targets/cloudflare.d.ts +23 -0
- package/dist/deployment/targets/cloudflare.js +1125 -0
- package/dist/deployment/targets/inngest.d.ts +38 -0
- package/dist/deployment/targets/inngest.js +926 -0
- package/dist/deployment/targets/lambda.d.ts +23 -0
- package/dist/deployment/targets/lambda.js +1289 -0
- package/dist/deployment/targets/vercel.d.ts +23 -0
- package/dist/deployment/targets/vercel.js +886 -0
- package/dist/deployment/types.d.ts +183 -0
- package/dist/deployment/types.js +8 -0
- package/dist/diagram/geometry.d.ts +26 -0
- package/dist/diagram/geometry.js +850 -0
- package/dist/diagram/index.d.ts +16 -0
- package/dist/diagram/index.js +42 -0
- package/dist/diagram/layout.d.ts +11 -0
- package/dist/diagram/layout.js +143 -0
- package/dist/diagram/orthogonal-router.d.ts +79 -0
- package/dist/diagram/orthogonal-router.js +568 -0
- package/dist/diagram/renderer.d.ts +3 -0
- package/dist/diagram/renderer.js +207 -0
- package/dist/diagram/theme.d.ts +20 -0
- package/dist/diagram/theme.js +189 -0
- package/dist/diagram/types.d.ts +70 -0
- package/dist/diagram/types.js +2 -0
- package/dist/diff/WorkflowDiffer.d.ts +13 -0
- package/dist/diff/WorkflowDiffer.js +429 -0
- package/dist/diff/formatDiff.d.ts +10 -0
- package/dist/diff/formatDiff.js +220 -0
- package/dist/diff/impact.d.ts +29 -0
- package/dist/diff/impact.js +119 -0
- package/dist/diff/index.d.ts +10 -0
- package/dist/diff/index.js +9 -0
- package/dist/diff/types.d.ts +138 -0
- package/dist/diff/types.js +35 -0
- package/dist/doc-metadata/extractors/annotations.d.ts +56 -0
- package/dist/doc-metadata/extractors/annotations.js +337 -0
- package/dist/doc-metadata/extractors/cli-commands.d.ts +17 -0
- package/dist/doc-metadata/extractors/cli-commands.js +355 -0
- package/dist/doc-metadata/extractors/mcp-tools.d.ts +16 -0
- package/dist/doc-metadata/extractors/mcp-tools.js +689 -0
- package/dist/doc-metadata/extractors/plugin-api.d.ts +19 -0
- package/dist/doc-metadata/extractors/plugin-api.js +279 -0
- package/dist/doc-metadata/index.d.ts +5 -0
- package/dist/doc-metadata/index.js +4 -0
- package/dist/doc-metadata/types.d.ts +120 -0
- package/dist/doc-metadata/types.js +5 -0
- package/dist/editor-completions/annotationValues.d.ts +12 -0
- package/dist/editor-completions/annotationValues.js +138 -0
- package/dist/editor-completions/contextParser.d.ts +40 -0
- package/dist/editor-completions/contextParser.js +410 -0
- package/dist/editor-completions/dataTypes.d.ts +16 -0
- package/dist/editor-completions/dataTypes.js +95 -0
- package/dist/editor-completions/goToDefinition.d.ts +27 -0
- package/dist/editor-completions/goToDefinition.js +112 -0
- package/dist/editor-completions/index.d.ts +39 -0
- package/dist/editor-completions/index.js +181 -0
- package/dist/editor-completions/jsDocAnnotations.d.ts +29 -0
- package/dist/editor-completions/jsDocAnnotations.js +357 -0
- package/dist/editor-completions/modifierCompletions.d.ts +17 -0
- package/dist/editor-completions/modifierCompletions.js +197 -0
- package/dist/editor-completions/types.d.ts +119 -0
- package/dist/editor-completions/types.js +8 -0
- package/dist/export/index.d.ts +68 -0
- package/dist/export/index.js +1074 -0
- package/dist/export/templates.d.ts +24 -0
- package/dist/export/templates.js +186 -0
- package/dist/friendly-errors.d.ts +35 -0
- package/dist/friendly-errors.js +375 -0
- package/dist/function-like.d.ts +38 -0
- package/dist/function-like.js +83 -0
- package/dist/generated-branding.d.ts +16 -0
- package/dist/generated-branding.js +22 -0
- package/dist/generator/async-detection.d.ts +27 -0
- package/dist/generator/async-detection.js +56 -0
- package/dist/generator/code-utils.d.ts +76 -0
- package/dist/generator/code-utils.js +410 -0
- package/dist/generator/control-flow.d.ts +54 -0
- package/dist/generator/control-flow.js +284 -0
- package/dist/generator/inngest.d.ts +53 -0
- package/dist/generator/inngest.js +1126 -0
- package/dist/generator/scope-function-generator.d.ts +78 -0
- package/dist/generator/scope-function-generator.js +360 -0
- package/dist/generator/unified.d.ts +42 -0
- package/dist/generator/unified.js +1504 -0
- package/dist/generator.d.ts +54 -0
- package/dist/generator.js +100 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +89 -0
- package/dist/jsdoc-parser.d.ts +308 -0
- package/dist/jsdoc-parser.js +923 -0
- package/dist/jsdoc-port-sync/constants.d.ts +41 -0
- package/dist/jsdoc-port-sync/constants.js +103 -0
- package/dist/jsdoc-port-sync/diff.d.ts +76 -0
- package/dist/jsdoc-port-sync/diff.js +319 -0
- package/dist/jsdoc-port-sync/index.d.ts +42 -0
- package/dist/jsdoc-port-sync/index.js +45 -0
- package/dist/jsdoc-port-sync/port-parser.d.ts +68 -0
- package/dist/jsdoc-port-sync/port-parser.js +579 -0
- package/dist/jsdoc-port-sync/rename.d.ts +21 -0
- package/dist/jsdoc-port-sync/rename.js +256 -0
- package/dist/jsdoc-port-sync/signature-parser.d.ts +104 -0
- package/dist/jsdoc-port-sync/signature-parser.js +559 -0
- package/dist/jsdoc-port-sync/sync.d.ts +36 -0
- package/dist/jsdoc-port-sync/sync.js +644 -0
- package/dist/jsdoc-port-sync.d.ts +10 -0
- package/dist/jsdoc-port-sync.js +10 -0
- package/dist/marketplace/index.d.ts +11 -0
- package/dist/marketplace/index.js +10 -0
- package/dist/marketplace/manifest.d.ts +32 -0
- package/dist/marketplace/manifest.js +176 -0
- package/dist/marketplace/registry.d.ts +30 -0
- package/dist/marketplace/registry.js +100 -0
- package/dist/marketplace/types.d.ts +154 -0
- package/dist/marketplace/types.js +9 -0
- package/dist/marketplace/validator.d.ts +13 -0
- package/dist/marketplace/validator.js +131 -0
- package/dist/mcp/auto-registration.d.ts +3 -0
- package/dist/mcp/auto-registration.js +62 -0
- package/dist/mcp/editor-connection.d.ts +50 -0
- package/dist/mcp/editor-connection.js +125 -0
- package/dist/mcp/event-buffer.d.ts +62 -0
- package/dist/mcp/event-buffer.js +150 -0
- package/dist/mcp/index.d.ts +12 -0
- package/dist/mcp/index.js +11 -0
- package/dist/mcp/resources.d.ts +14 -0
- package/dist/mcp/resources.js +55 -0
- package/dist/mcp/response-utils.d.ts +63 -0
- package/dist/mcp/response-utils.js +89 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +99 -0
- package/dist/mcp/tools-diagram.d.ts +8 -0
- package/dist/mcp/tools-diagram.js +53 -0
- package/dist/mcp/tools-editor.d.ts +5 -0
- package/dist/mcp/tools-editor.js +190 -0
- package/dist/mcp/tools-export.d.ts +9 -0
- package/dist/mcp/tools-export.js +180 -0
- package/dist/mcp/tools-marketplace.d.ts +9 -0
- package/dist/mcp/tools-marketplace.js +132 -0
- package/dist/mcp/tools-pattern.d.ts +3 -0
- package/dist/mcp/tools-pattern.js +783 -0
- package/dist/mcp/tools-query.d.ts +3 -0
- package/dist/mcp/tools-query.js +364 -0
- package/dist/mcp/tools-template.d.ts +10 -0
- package/dist/mcp/tools-template.js +119 -0
- package/dist/mcp/types.d.ts +70 -0
- package/dist/mcp/types.js +8 -0
- package/dist/mcp/workflow-executor.d.ts +47 -0
- package/dist/mcp/workflow-executor.js +133 -0
- package/dist/migration/registry.d.ts +30 -0
- package/dist/migration/registry.js +29 -0
- package/dist/node-types-generator.d.ts +49 -0
- package/dist/node-types-generator.js +139 -0
- package/dist/npm-packages.d.ts +56 -0
- package/dist/npm-packages.js +255 -0
- package/dist/parser.d.ts +204 -0
- package/dist/parser.js +2100 -0
- package/dist/plugin/PluginPanel.d.ts +12 -0
- package/dist/plugin/PluginPanel.js +5 -0
- package/dist/plugin/index.d.ts +13 -0
- package/dist/plugin/index.js +14 -0
- package/dist/plugin/types.d.ts +75 -0
- package/dist/plugin/types.js +8 -0
- package/dist/resolve-package-types.d.ts +17 -0
- package/dist/resolve-package-types.js +123 -0
- package/dist/runtime/CancellationError.d.ts +11 -0
- package/dist/runtime/CancellationError.js +20 -0
- package/dist/runtime/ExecutionContext.d.ts +146 -0
- package/dist/runtime/ExecutionContext.js +235 -0
- package/dist/runtime/builtin-functions.d.ts +8 -0
- package/dist/runtime/builtin-functions.js +549 -0
- package/dist/runtime/events.d.ts +50 -0
- package/dist/runtime/events.js +2 -0
- package/dist/runtime/function-registry.d.ts +59 -0
- package/dist/runtime/function-registry.js +66 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/parameter-resolver.d.ts +62 -0
- package/dist/runtime/parameter-resolver.js +113 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +6 -0
- package/dist/server/types.d.ts +93 -0
- package/dist/server/types.js +5 -0
- package/dist/server/webhook-server.d.ts +50 -0
- package/dist/server/webhook-server.js +269 -0
- package/dist/server/workflow-registry.d.ts +61 -0
- package/dist/server/workflow-registry.js +202 -0
- package/dist/shared-project.d.ts +9 -0
- package/dist/shared-project.js +28 -0
- package/dist/sugar-optimizer.d.ts +40 -0
- package/dist/sugar-optimizer.js +387 -0
- package/dist/testing/assertions.d.ts +51 -0
- package/dist/testing/assertions.js +127 -0
- package/dist/testing/index.d.ts +30 -0
- package/dist/testing/index.js +24 -0
- package/dist/testing/mock-approval.d.ts +81 -0
- package/dist/testing/mock-approval.js +98 -0
- package/dist/testing/mock-llm.d.ts +124 -0
- package/dist/testing/mock-llm.js +119 -0
- package/dist/testing/recorder.d.ts +72 -0
- package/dist/testing/recorder.js +70 -0
- package/dist/testing/replayer.d.ts +56 -0
- package/dist/testing/replayer.js +143 -0
- package/dist/testing/token-tracker.d.ts +71 -0
- package/dist/testing/token-tracker.js +94 -0
- package/dist/type-checker.d.ts +42 -0
- package/dist/type-checker.js +190 -0
- package/dist/type-mappings.d.ts +29 -0
- package/dist/type-mappings.js +125 -0
- package/dist/types/branded-ports.d.ts +151 -0
- package/dist/types/branded-ports.js +121 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.js +15 -0
- package/dist/utils/error-utils.d.ts +15 -0
- package/dist/utils/error-utils.js +27 -0
- package/dist/utils/lru-cache.d.ts +15 -0
- package/dist/utils/lru-cache.js +40 -0
- package/dist/utils/port-ordering.d.ts +26 -0
- package/dist/utils/port-ordering.js +88 -0
- package/dist/utils/port-tag-utils.d.ts +23 -0
- package/dist/utils/port-tag-utils.js +41 -0
- package/dist/utils/string-distance.d.ts +14 -0
- package/dist/utils/string-distance.js +56 -0
- package/dist/validation/agent-detection.d.ts +33 -0
- package/dist/validation/agent-detection.js +115 -0
- package/dist/validation/agent-rules.d.ts +48 -0
- package/dist/validation/agent-rules.js +262 -0
- package/dist/validator.d.ts +92 -0
- package/dist/validator.js +970 -0
- package/package.json +109 -0
|
@@ -0,0 +1,923 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSDoc annotation parser for Flow Weaver
|
|
3
|
+
*
|
|
4
|
+
* Parses @flowWeaver annotations from JSDoc comments.
|
|
5
|
+
*/
|
|
6
|
+
import { isExecutePort, isSuccessPort, isFailurePort, isScopedMandatoryPort } from './constants.js';
|
|
7
|
+
import { inferDataTypeFromTS } from './type-mappings.js';
|
|
8
|
+
import { parsePortLine, parseNodeLine, parseConnectLine, parsePositionLine, parseScopeLine, parseMapLine, parsePathLine, parseTriggerLine, parseCancelOnLine, parseThrottleLine, } from './chevrotain-parser/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Extract the type of a field from a callback's return type using ts-morph Type API.
|
|
11
|
+
*
|
|
12
|
+
* For scoped INPUT ports, we need to find the return type of the callback and extract
|
|
13
|
+
* the type of a specific field from that return type object.
|
|
14
|
+
*
|
|
15
|
+
* @param callbackType - The Type of the callback parameter
|
|
16
|
+
* @param fieldName - The name of the field to extract from the return type
|
|
17
|
+
* @returns The TypeScript type string, or undefined if extraction fails
|
|
18
|
+
*/
|
|
19
|
+
function extractCallbackReturnFieldType(callbackType, fieldName) {
|
|
20
|
+
// Get call signatures from the callback type
|
|
21
|
+
const callSignatures = callbackType.getCallSignatures();
|
|
22
|
+
if (callSignatures.length === 0) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
// Use the first call signature (callbacks typically have one)
|
|
26
|
+
let returnType = callSignatures[0].getReturnType();
|
|
27
|
+
// Unwrap Promise<T> to get T - async callbacks return Promise<{...}>
|
|
28
|
+
const returnTypeText = returnType.getText();
|
|
29
|
+
if (returnTypeText.startsWith('Promise<')) {
|
|
30
|
+
const typeArgs = returnType.getTypeArguments();
|
|
31
|
+
if (typeArgs.length > 0) {
|
|
32
|
+
returnType = typeArgs[0];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Get the property from the return type
|
|
36
|
+
const property = returnType.getProperty(fieldName);
|
|
37
|
+
if (!property) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
// Get the type of the property
|
|
41
|
+
const propertyType = getPropertyType(property, returnType);
|
|
42
|
+
if (!propertyType) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
// Get the type text - use getText() which handles complex types properly
|
|
46
|
+
// Pass undefined to avoid import path expansion
|
|
47
|
+
return propertyType.getText(undefined, 0);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the type of a property Symbol.
|
|
51
|
+
*/
|
|
52
|
+
function getPropertyType(property, containerType) {
|
|
53
|
+
// Try to get the type via getTypeAtLocation on the value declaration
|
|
54
|
+
const valueDecl = property.getValueDeclaration();
|
|
55
|
+
if (valueDecl) {
|
|
56
|
+
return valueDecl.getType();
|
|
57
|
+
}
|
|
58
|
+
// Fallback: get the declared type from the container
|
|
59
|
+
const declaredType = containerType.getPropertyOrThrow(property.getName());
|
|
60
|
+
if (declaredType) {
|
|
61
|
+
// This returns a Symbol, get its type via declarations
|
|
62
|
+
const decls = declaredType.getDeclarations();
|
|
63
|
+
if (decls.length > 0) {
|
|
64
|
+
return decls[0].getType();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Extract the type of a parameter from a callback's parameter list using ts-morph Type API.
|
|
71
|
+
*
|
|
72
|
+
* For scoped OUTPUT ports, we need to find the parameters of the callback and extract
|
|
73
|
+
* the type of a specific parameter by name.
|
|
74
|
+
*
|
|
75
|
+
* @param callbackType - The Type of the callback parameter
|
|
76
|
+
* @param paramName - The name of the parameter to extract
|
|
77
|
+
* @returns The TypeScript type string, or undefined if extraction fails
|
|
78
|
+
*/
|
|
79
|
+
function extractCallbackParamType(callbackType, paramName) {
|
|
80
|
+
// Get call signatures from the callback type
|
|
81
|
+
const callSignatures = callbackType.getCallSignatures();
|
|
82
|
+
if (callSignatures.length === 0) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
// Use the first call signature
|
|
86
|
+
const parameters = callSignatures[0].getParameters();
|
|
87
|
+
// Find the parameter by name
|
|
88
|
+
for (const param of parameters) {
|
|
89
|
+
if (param.getName() === paramName) {
|
|
90
|
+
const valueDecl = param.getValueDeclaration();
|
|
91
|
+
if (valueDecl) {
|
|
92
|
+
const paramType = valueDecl.getType();
|
|
93
|
+
return paramType.getText(undefined, 0);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
export class JSDocParser {
|
|
100
|
+
/**
|
|
101
|
+
* Parse @flowWeaver nodeType from JSDoc comments
|
|
102
|
+
*/
|
|
103
|
+
parseNodeType(func, warnings) {
|
|
104
|
+
const jsdocs = func.getJsDocs();
|
|
105
|
+
if (jsdocs.length === 0)
|
|
106
|
+
return null;
|
|
107
|
+
// Find the JSDoc block that contains @flowWeaver nodeType
|
|
108
|
+
let jsdoc = null;
|
|
109
|
+
let flowWeaverTag = null;
|
|
110
|
+
for (const doc of jsdocs) {
|
|
111
|
+
const tags = doc.getTags();
|
|
112
|
+
const tag = tags.find((t) => t.getTagName() === 'flowWeaver' && t.getCommentText()?.trim() === 'nodeType');
|
|
113
|
+
if (tag) {
|
|
114
|
+
jsdoc = doc;
|
|
115
|
+
flowWeaverTag = tag;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!jsdoc || !flowWeaverTag)
|
|
120
|
+
return null;
|
|
121
|
+
const tags = jsdoc.getTags();
|
|
122
|
+
const config = {
|
|
123
|
+
inputs: {},
|
|
124
|
+
outputs: {},
|
|
125
|
+
};
|
|
126
|
+
// Extract description from JSDoc comment text (before tags)
|
|
127
|
+
const descriptionText = jsdoc.getDescription();
|
|
128
|
+
if (descriptionText && descriptionText.trim()) {
|
|
129
|
+
config.description = descriptionText.trim();
|
|
130
|
+
}
|
|
131
|
+
// Parse tags
|
|
132
|
+
tags.forEach((tag) => {
|
|
133
|
+
const tagName = tag.getTagName();
|
|
134
|
+
const comment = tag.getCommentText() || '';
|
|
135
|
+
switch (tagName) {
|
|
136
|
+
case 'name':
|
|
137
|
+
config.name = comment.trim();
|
|
138
|
+
break;
|
|
139
|
+
case 'label':
|
|
140
|
+
config.label = comment.trim();
|
|
141
|
+
break;
|
|
142
|
+
case 'description':
|
|
143
|
+
config.description = comment.trim();
|
|
144
|
+
break;
|
|
145
|
+
case 'color':
|
|
146
|
+
config.color = comment.trim();
|
|
147
|
+
break;
|
|
148
|
+
case 'icon':
|
|
149
|
+
config.icon = comment.trim();
|
|
150
|
+
break;
|
|
151
|
+
case 'tag':
|
|
152
|
+
config.tags = config.tags || [];
|
|
153
|
+
const tagMatch = comment.match(/^(\S+)(?:\s+"([^"]+)")?$/);
|
|
154
|
+
if (tagMatch) {
|
|
155
|
+
config.tags.push({
|
|
156
|
+
label: tagMatch[1],
|
|
157
|
+
...(tagMatch[2] && { tooltip: tagMatch[2] }),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
case 'executeWhen':
|
|
162
|
+
config.executeWhen = comment.trim();
|
|
163
|
+
break;
|
|
164
|
+
case 'scope':
|
|
165
|
+
config.scope = comment.trim();
|
|
166
|
+
break;
|
|
167
|
+
case 'expression':
|
|
168
|
+
config.expression = true;
|
|
169
|
+
break;
|
|
170
|
+
case 'pullExecution':
|
|
171
|
+
const pullValue = comment.trim();
|
|
172
|
+
if (pullValue) {
|
|
173
|
+
config.defaultConfig = config.defaultConfig || {};
|
|
174
|
+
config.defaultConfig.pullExecution = { triggerPort: pullValue };
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
case 'input':
|
|
178
|
+
this.parseInputTag(tag, config, func, warnings);
|
|
179
|
+
break;
|
|
180
|
+
case 'output':
|
|
181
|
+
this.parseOutputTag(tag, config, func, warnings);
|
|
182
|
+
break;
|
|
183
|
+
case 'step':
|
|
184
|
+
this.parseStepTag(tag, config, func, warnings);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
return config;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Parse @flowWeaver workflow from JSDoc comments
|
|
192
|
+
*/
|
|
193
|
+
parseWorkflow(func, warnings) {
|
|
194
|
+
const jsdocs = func.getJsDocs();
|
|
195
|
+
if (jsdocs.length === 0)
|
|
196
|
+
return null;
|
|
197
|
+
// Find the JSDoc block that contains @flowWeaver workflow
|
|
198
|
+
let jsdoc = null;
|
|
199
|
+
let flowWeaverTag = null;
|
|
200
|
+
for (const doc of jsdocs) {
|
|
201
|
+
const tags = doc.getTags();
|
|
202
|
+
const tag = tags.find((t) => t.getTagName() === 'flowWeaver' && t.getCommentText()?.trim() === 'workflow');
|
|
203
|
+
if (tag) {
|
|
204
|
+
jsdoc = doc;
|
|
205
|
+
flowWeaverTag = tag;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (!jsdoc || !flowWeaverTag)
|
|
210
|
+
return null;
|
|
211
|
+
const tags = jsdoc.getTags();
|
|
212
|
+
const config = {
|
|
213
|
+
imports: [],
|
|
214
|
+
instances: [],
|
|
215
|
+
connections: [],
|
|
216
|
+
scopes: {},
|
|
217
|
+
positions: {},
|
|
218
|
+
};
|
|
219
|
+
// Parse tags
|
|
220
|
+
tags.forEach((tag) => {
|
|
221
|
+
const tagName = tag.getTagName();
|
|
222
|
+
const comment = tag.getCommentText() || '';
|
|
223
|
+
switch (tagName) {
|
|
224
|
+
case 'name':
|
|
225
|
+
config.name = comment.trim();
|
|
226
|
+
break;
|
|
227
|
+
case 'fwImport':
|
|
228
|
+
// Parse @fwImport nodeName functionName from "packageName"
|
|
229
|
+
// Example: @fwImport npm/autoprefixer/autoprefixer autoprefixer from "autoprefixer"
|
|
230
|
+
this.parseImportTag(tag, config, warnings);
|
|
231
|
+
break;
|
|
232
|
+
case 'description':
|
|
233
|
+
config.description = comment.trim();
|
|
234
|
+
break;
|
|
235
|
+
case 'strictTypes':
|
|
236
|
+
// @strictTypes with no value or any truthy value = true
|
|
237
|
+
// @strictTypes false = false
|
|
238
|
+
config.strictTypes = comment.trim().toLowerCase() !== 'false';
|
|
239
|
+
break;
|
|
240
|
+
case 'autoConnect':
|
|
241
|
+
// @autoConnect enables automatic linear connection wiring
|
|
242
|
+
// OPT-IN: only applies when present, without it behavior is unchanged
|
|
243
|
+
config.autoConnect = true;
|
|
244
|
+
break;
|
|
245
|
+
case 'node':
|
|
246
|
+
this.parseNodeTag(tag, config, warnings);
|
|
247
|
+
break;
|
|
248
|
+
case 'position':
|
|
249
|
+
this.parsePositionTag(tag, config, warnings);
|
|
250
|
+
break;
|
|
251
|
+
case 'connect':
|
|
252
|
+
this.parseConnectTag(tag, config, warnings);
|
|
253
|
+
break;
|
|
254
|
+
case 'scope':
|
|
255
|
+
this.parseScopeTag(tag, config, warnings);
|
|
256
|
+
break;
|
|
257
|
+
case 'map':
|
|
258
|
+
this.parseMapTag(tag, config, warnings);
|
|
259
|
+
break;
|
|
260
|
+
case 'path':
|
|
261
|
+
this.parsePathTag(tag, config, warnings);
|
|
262
|
+
break;
|
|
263
|
+
case 'trigger':
|
|
264
|
+
this.parseTriggerTag(tag, config, warnings);
|
|
265
|
+
break;
|
|
266
|
+
case 'cancelOn':
|
|
267
|
+
this.parseCancelOnTag(tag, config, warnings);
|
|
268
|
+
break;
|
|
269
|
+
case 'retries': {
|
|
270
|
+
const n = parseInt(comment.trim(), 10);
|
|
271
|
+
if (!isNaN(n) && n >= 0)
|
|
272
|
+
config.retries = n;
|
|
273
|
+
else
|
|
274
|
+
warnings.push(`Invalid @retries value: "${comment.trim()}". Expected non-negative integer.`);
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
case 'timeout': {
|
|
278
|
+
const val = comment.trim().replace(/^["']|["']$/g, '');
|
|
279
|
+
if (val)
|
|
280
|
+
config.timeout = val;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
case 'throttle':
|
|
284
|
+
this.parseThrottleTag(tag, config, warnings);
|
|
285
|
+
break;
|
|
286
|
+
case 'param':
|
|
287
|
+
this.parseParamTag(tag, config, func, warnings);
|
|
288
|
+
break;
|
|
289
|
+
case 'return':
|
|
290
|
+
case 'returns':
|
|
291
|
+
this.parseReturnTag(tag, config, func, warnings);
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
return config;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Parse @flowWeaver pattern from JSDoc comments
|
|
299
|
+
*/
|
|
300
|
+
parsePattern(func, warnings) {
|
|
301
|
+
const jsdocs = func.getJsDocs();
|
|
302
|
+
if (jsdocs.length === 0)
|
|
303
|
+
return null;
|
|
304
|
+
// Find the JSDoc block that contains @flowWeaver pattern
|
|
305
|
+
let jsdoc = null;
|
|
306
|
+
let flowWeaverTag = null;
|
|
307
|
+
for (const doc of jsdocs) {
|
|
308
|
+
const tags = doc.getTags();
|
|
309
|
+
const tag = tags.find((t) => t.getTagName() === 'flowWeaver' && t.getCommentText()?.trim() === 'pattern');
|
|
310
|
+
if (tag) {
|
|
311
|
+
jsdoc = doc;
|
|
312
|
+
flowWeaverTag = tag;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (!jsdoc || !flowWeaverTag)
|
|
317
|
+
return null;
|
|
318
|
+
const tags = jsdoc.getTags();
|
|
319
|
+
const config = {
|
|
320
|
+
instances: [],
|
|
321
|
+
connections: [],
|
|
322
|
+
ports: [],
|
|
323
|
+
positions: {},
|
|
324
|
+
};
|
|
325
|
+
// Parse tags
|
|
326
|
+
tags.forEach((tag) => {
|
|
327
|
+
const tagName = tag.getTagName();
|
|
328
|
+
const comment = tag.getCommentText() || '';
|
|
329
|
+
switch (tagName) {
|
|
330
|
+
case 'name':
|
|
331
|
+
config.name = comment.trim();
|
|
332
|
+
break;
|
|
333
|
+
case 'description':
|
|
334
|
+
config.description = comment.trim();
|
|
335
|
+
break;
|
|
336
|
+
case 'node':
|
|
337
|
+
this.parsePatternNodeTag(tag, config, warnings);
|
|
338
|
+
break;
|
|
339
|
+
case 'position':
|
|
340
|
+
this.parsePatternPositionTag(tag, config, warnings);
|
|
341
|
+
break;
|
|
342
|
+
case 'connect':
|
|
343
|
+
this.parsePatternConnectTag(tag, config, warnings);
|
|
344
|
+
break;
|
|
345
|
+
case 'port':
|
|
346
|
+
this.parsePatternPortTag(tag, config, warnings);
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
// Apply positions to instances
|
|
351
|
+
if (config.positions && config.instances) {
|
|
352
|
+
for (const instance of config.instances) {
|
|
353
|
+
const pos = config.positions[instance.id];
|
|
354
|
+
if (pos) {
|
|
355
|
+
instance.config = instance.config || {};
|
|
356
|
+
instance.config.x = pos.x;
|
|
357
|
+
instance.config.y = pos.y;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return config;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Parse @node tag for patterns.
|
|
365
|
+
* Format: @node instanceId nodeType
|
|
366
|
+
*/
|
|
367
|
+
parsePatternNodeTag(tag, config, warnings) {
|
|
368
|
+
const comment = tag.getCommentText() || '';
|
|
369
|
+
const result = parseNodeLine(`@node ${comment}`, warnings);
|
|
370
|
+
if (!result) {
|
|
371
|
+
warnings.push(`Invalid @node tag format in pattern: ${comment}`);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
const { instanceId, nodeType } = result;
|
|
375
|
+
config.instances.push({
|
|
376
|
+
id: instanceId,
|
|
377
|
+
nodeType: nodeType,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Parse @position tag for patterns.
|
|
382
|
+
* Format: @position nodeId x y
|
|
383
|
+
*/
|
|
384
|
+
parsePatternPositionTag(tag, config, warnings) {
|
|
385
|
+
const comment = tag.getCommentText() || '';
|
|
386
|
+
const result = parsePositionLine(`@position ${comment}`, warnings);
|
|
387
|
+
if (!result) {
|
|
388
|
+
warnings.push(`Invalid @position tag format in pattern: ${comment}`);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const { nodeId, x, y } = result;
|
|
392
|
+
config.positions[nodeId] = { x, y };
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Parse @connect tag for patterns.
|
|
396
|
+
* Supports IN/OUT pseudo-nodes: IN.port -> node.port, node.port -> OUT.port
|
|
397
|
+
*/
|
|
398
|
+
parsePatternConnectTag(tag, config, warnings) {
|
|
399
|
+
const comment = tag.getCommentText() || '';
|
|
400
|
+
const result = parseConnectLine(`@connect ${comment}`, warnings);
|
|
401
|
+
if (!result) {
|
|
402
|
+
warnings.push(`Invalid @connect tag format in pattern: ${comment}`);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const { source, target } = result;
|
|
406
|
+
config.connections.push({
|
|
407
|
+
from: { node: source.nodeId, port: source.portName },
|
|
408
|
+
to: { node: target.nodeId, port: target.portName },
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Parse @port tag for patterns.
|
|
413
|
+
* Format: @port IN.name - description OR @port OUT.name - description
|
|
414
|
+
*/
|
|
415
|
+
parsePatternPortTag(tag, config, warnings) {
|
|
416
|
+
const comment = tag.getCommentText() || '';
|
|
417
|
+
// Parse format: IN.name - description OR OUT.name - description
|
|
418
|
+
const match = comment.match(/^(IN|OUT)\.(\w+)\s*(?:-\s*(.*))?$/);
|
|
419
|
+
if (!match) {
|
|
420
|
+
warnings.push(`Invalid @port tag format in pattern: ${comment}`);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const [, direction, name, description] = match;
|
|
424
|
+
config.ports.push({
|
|
425
|
+
direction: direction,
|
|
426
|
+
name,
|
|
427
|
+
description: description?.trim(),
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Parse @input tag using Chevrotain parser.
|
|
432
|
+
* Supports: @input name, @input [name], @input [name=default]
|
|
433
|
+
* With optional: scope:scopeName, [order:N], [placement:TOP/BOTTOM], - description
|
|
434
|
+
*/
|
|
435
|
+
parseInputTag(tag, config, func, warnings) {
|
|
436
|
+
const comment = tag.getCommentText() || '';
|
|
437
|
+
const result = parsePortLine(`@input ${comment}`, warnings);
|
|
438
|
+
if (!result) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const { name, defaultValue, isOptional, scope, order, mergeStrategy, description } = result;
|
|
442
|
+
// Infer type from signature or scope callback return type
|
|
443
|
+
let type;
|
|
444
|
+
let tsType;
|
|
445
|
+
// Check for STEP ports: execute OR scoped mandatory ports (success, failure with scope)
|
|
446
|
+
const isScopedStepInput = scope && isScopedMandatoryPort(name);
|
|
447
|
+
if (isExecutePort(name) || isScopedStepInput) {
|
|
448
|
+
type = 'STEP';
|
|
449
|
+
}
|
|
450
|
+
else if (scope) {
|
|
451
|
+
// For scoped INPUT ports, look up type from the scope callback's return type
|
|
452
|
+
// The scope name matches a function parameter that is a callback
|
|
453
|
+
// Scoped INPUT ports become the callback's return values
|
|
454
|
+
const scopeParam = func.getParameters().find((p) => p.getName() === scope);
|
|
455
|
+
if (scopeParam) {
|
|
456
|
+
const scopeParamType = scopeParam.getType();
|
|
457
|
+
// Use ts-morph Type API to extract the return field type
|
|
458
|
+
// This handles complex types (generics, nested objects) that regex can't
|
|
459
|
+
const extractedType = extractCallbackReturnFieldType(scopeParamType, name);
|
|
460
|
+
if (extractedType) {
|
|
461
|
+
tsType = extractedType;
|
|
462
|
+
type = inferDataTypeFromTS(tsType);
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
// Emit warning when type inference fails for a scoped INPUT port
|
|
466
|
+
const nodeTypeName = func.getName() || 'unknown';
|
|
467
|
+
warnings.push(`Cannot infer type for scoped INPUT port '${name}' in scope '${scope}' of node type '${nodeTypeName}'. ` +
|
|
468
|
+
`The callback parameter '${scope}' should have a return type that includes '${name}'. ` +
|
|
469
|
+
`Consider adding an explicit type annotation to the callback signature.`);
|
|
470
|
+
type = 'ANY';
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
// Scope callback parameter not found - emit warning
|
|
475
|
+
const nodeTypeName = func.getName() || 'unknown';
|
|
476
|
+
warnings.push(`Scoped INPUT port '${name}' references scope '${scope}', but no callback parameter named '${scope}' was found ` +
|
|
477
|
+
`in node type '${nodeTypeName}'. Add a callback parameter: ${scope}: (...) => { ${name}: YourType }`);
|
|
478
|
+
type = 'ANY';
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
const param = func.getParameters().find((p) => {
|
|
483
|
+
const pName = p.getName();
|
|
484
|
+
return pName === name || pName === `_${name}`;
|
|
485
|
+
});
|
|
486
|
+
if (param) {
|
|
487
|
+
tsType = param.getType().getText(param);
|
|
488
|
+
type = inferDataTypeFromTS(tsType);
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
type = 'ANY';
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
// Check if description contains an expression
|
|
495
|
+
let label = description?.trim();
|
|
496
|
+
let expression = undefined;
|
|
497
|
+
if (label && label.startsWith('Expression:')) {
|
|
498
|
+
expression = label.substring('Expression:'.length).trim();
|
|
499
|
+
label = undefined;
|
|
500
|
+
}
|
|
501
|
+
config.inputs[name] = {
|
|
502
|
+
type,
|
|
503
|
+
defaultValue: defaultValue ? this.parseDefaultValue(defaultValue) : undefined,
|
|
504
|
+
...(isOptional && { optional: true }),
|
|
505
|
+
label,
|
|
506
|
+
...(expression && { expression }),
|
|
507
|
+
...(scope && { scope }),
|
|
508
|
+
...(mergeStrategy && { mergeStrategy: mergeStrategy }),
|
|
509
|
+
...(order !== undefined && { metadata: { order } }),
|
|
510
|
+
...(tsType && { tsType }),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Parse @output tag using Chevrotain parser.
|
|
515
|
+
* Supports: @output name, scope:scopeName, [order:N], - description
|
|
516
|
+
*/
|
|
517
|
+
parseOutputTag(tag, config, func, warnings) {
|
|
518
|
+
const comment = tag.getCommentText() || '';
|
|
519
|
+
const result = parsePortLine(`@output ${comment}`, warnings);
|
|
520
|
+
if (!result) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
const { name, scope, order, description } = result;
|
|
524
|
+
// Infer type from return type or scope callback parameter
|
|
525
|
+
let type;
|
|
526
|
+
let tsType;
|
|
527
|
+
// Check for STEP ports: onSuccess/onFailure OR scoped mandatory ports (start with scope)
|
|
528
|
+
const isScopedStepOutput = scope && isScopedMandatoryPort(name);
|
|
529
|
+
if (isSuccessPort(name) || isFailurePort(name) || isScopedStepOutput) {
|
|
530
|
+
type = 'STEP';
|
|
531
|
+
}
|
|
532
|
+
else if (scope) {
|
|
533
|
+
// For scoped OUTPUT ports, look up type from the scope callback parameter
|
|
534
|
+
// The scope name matches a function parameter that is a callback
|
|
535
|
+
// Scoped OUTPUT ports become the callback's parameters
|
|
536
|
+
const scopeParam = func.getParameters().find((p) => p.getName() === scope);
|
|
537
|
+
if (scopeParam) {
|
|
538
|
+
const scopeParamType = scopeParam.getType();
|
|
539
|
+
// Use ts-morph Type API to extract the callback parameter type
|
|
540
|
+
const extractedType = extractCallbackParamType(scopeParamType, name);
|
|
541
|
+
if (extractedType) {
|
|
542
|
+
tsType = extractedType;
|
|
543
|
+
type = inferDataTypeFromTS(tsType);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
// Emit warning when type inference fails for a scoped OUTPUT port
|
|
547
|
+
const nodeTypeName = func.getName() || 'unknown';
|
|
548
|
+
warnings.push(`Cannot infer type for scoped OUTPUT port '${name}' in scope '${scope}' of node type '${nodeTypeName}'. ` +
|
|
549
|
+
`The callback parameter '${scope}' should have a parameter named '${name}'. ` +
|
|
550
|
+
`Consider adding an explicit type annotation to the callback signature.`);
|
|
551
|
+
type = 'ANY';
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
// Scope callback parameter not found - emit warning
|
|
556
|
+
const nodeTypeName = func.getName() || 'unknown';
|
|
557
|
+
warnings.push(`Scoped OUTPUT port '${name}' references scope '${scope}', but no callback parameter named '${scope}' was found ` +
|
|
558
|
+
`in node type '${nodeTypeName}'. Add a callback parameter: ${scope}: (${name}: YourType, ...) => { ... }`);
|
|
559
|
+
type = 'ANY';
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
const returnType = func.getReturnType();
|
|
564
|
+
// Use ts-morph API to extract property type (handles generics with commas correctly)
|
|
565
|
+
const property = returnType.getProperty(name);
|
|
566
|
+
if (property) {
|
|
567
|
+
const propertyType = getPropertyType(property, returnType);
|
|
568
|
+
if (propertyType) {
|
|
569
|
+
tsType = propertyType.getText(undefined, 0);
|
|
570
|
+
type = inferDataTypeFromTS(tsType);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
type = 'ANY';
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
type = 'ANY';
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
config.outputs[name] = {
|
|
581
|
+
type,
|
|
582
|
+
label: description?.trim(),
|
|
583
|
+
...(scope && { scope }),
|
|
584
|
+
...(order !== undefined && { metadata: { order } }),
|
|
585
|
+
...(tsType && { tsType }),
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Parse @step tag using Chevrotain parser.
|
|
590
|
+
* Used for explicit STEP/control-flow ports that are not reserved.
|
|
591
|
+
*/
|
|
592
|
+
parseStepTag(tag, config, func, warnings) {
|
|
593
|
+
const comment = tag.getCommentText() || '';
|
|
594
|
+
// Use Chevrotain to parse the port content
|
|
595
|
+
const result = parsePortLine(`@step ${comment}`, warnings);
|
|
596
|
+
if (!result) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const { name, description } = result;
|
|
600
|
+
// @step ports are control flow - determine if input or output from signature
|
|
601
|
+
const param = func.getParameters().find((p) => p.getName() === name);
|
|
602
|
+
if (param) {
|
|
603
|
+
// It's an input STEP port
|
|
604
|
+
config.inputs[name] = {
|
|
605
|
+
type: 'STEP',
|
|
606
|
+
label: description?.trim(),
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
// It's an output STEP port (check return type or assume output)
|
|
611
|
+
config.outputs[name] = {
|
|
612
|
+
type: 'STEP',
|
|
613
|
+
label: description?.trim(),
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Parse @return/@returns tag for workflow functions using Chevrotain.
|
|
619
|
+
* Format: @returns name [order:N] - Description (type inferred from signature)
|
|
620
|
+
*/
|
|
621
|
+
parseReturnTag(tag, config, func, warnings) {
|
|
622
|
+
const comment = tag.getCommentText() || '';
|
|
623
|
+
// Reuse port-parser: @output has same format as @returns
|
|
624
|
+
const result = parsePortLine(`@output ${comment}`, warnings);
|
|
625
|
+
if (!result) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const { name, order, description } = result;
|
|
629
|
+
// Infer type from return type signature
|
|
630
|
+
let type = 'ANY';
|
|
631
|
+
if (isSuccessPort(name) || isFailurePort(name)) {
|
|
632
|
+
type = 'STEP';
|
|
633
|
+
}
|
|
634
|
+
else if (func) {
|
|
635
|
+
const returnType = func.getReturnType();
|
|
636
|
+
const returnTypeText = returnType.getText();
|
|
637
|
+
const fieldMatch = returnTypeText.match(new RegExp(`${name}\\s*:\\s*([^;},]+)`));
|
|
638
|
+
if (fieldMatch) {
|
|
639
|
+
type = inferDataTypeFromTS(fieldMatch[1].trim());
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
config.returnPorts = config.returnPorts || {};
|
|
643
|
+
config.returnPorts[name] = {
|
|
644
|
+
dataType: type,
|
|
645
|
+
label: description?.trim(),
|
|
646
|
+
...(order !== undefined && { metadata: { order } }),
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Parse @param tag for workflow functions using Chevrotain.
|
|
651
|
+
* Format: @param name [order:N] - Description (type inferred from signature)
|
|
652
|
+
*/
|
|
653
|
+
parseParamTag(tag, config, func, warnings) {
|
|
654
|
+
const compilerNode = tag.compilerNode;
|
|
655
|
+
const tagWithGetName = tag;
|
|
656
|
+
const name = compilerNode.name?.getText?.() || (tagWithGetName.getName && tagWithGetName.getName());
|
|
657
|
+
if (!name) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
// Comment contains: [order:N] - Description (name parsed separately by ts-morph)
|
|
661
|
+
// Prepend name to reuse port-parser
|
|
662
|
+
const comment = tag.getCommentText() || '';
|
|
663
|
+
const result = parsePortLine(`@input ${name} ${comment}`, warnings);
|
|
664
|
+
const order = result?.order;
|
|
665
|
+
const description = result?.description;
|
|
666
|
+
// Infer type from function parameter signature
|
|
667
|
+
let type = 'ANY';
|
|
668
|
+
if (isExecutePort(name)) {
|
|
669
|
+
type = 'STEP';
|
|
670
|
+
}
|
|
671
|
+
else if (func) {
|
|
672
|
+
const params = func.getParameters();
|
|
673
|
+
const paramsParam = params.find((p) => p.getName() === 'params');
|
|
674
|
+
if (paramsParam) {
|
|
675
|
+
const paramType = paramsParam.getType();
|
|
676
|
+
const paramTypeText = paramType.getText();
|
|
677
|
+
const fieldMatch = paramTypeText.match(new RegExp(`${name}\\s*:\\s*([^;},]+)`));
|
|
678
|
+
if (fieldMatch) {
|
|
679
|
+
type = inferDataTypeFromTS(fieldMatch[1].trim());
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
config.startPorts = config.startPorts || {};
|
|
684
|
+
config.startPorts[name] = {
|
|
685
|
+
dataType: type,
|
|
686
|
+
label: description?.trim(),
|
|
687
|
+
...(order !== undefined && { metadata: { order } }),
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Parse @fwImport tag for npm package node types.
|
|
692
|
+
* Format: @fwImport nodeName functionName from "packageName"
|
|
693
|
+
* Examples:
|
|
694
|
+
* @fwImport npm/autoprefixer/autoprefixer autoprefixer from "autoprefixer"
|
|
695
|
+
* @fwImport npm/lodash/map map from "lodash"
|
|
696
|
+
* Note: We use @fwImport instead of @import because TypeScript treats @import specially
|
|
697
|
+
* and truncates the first word as a type annotation.
|
|
698
|
+
*/
|
|
699
|
+
parseImportTag(tag, config, warnings) {
|
|
700
|
+
const comment = tag.getCommentText()?.trim() || '';
|
|
701
|
+
// Parse format: nodeName functionName from "packageName"
|
|
702
|
+
const match = comment.match(/^(\S+)\s+(\S+)\s+from\s+["']([^"']+)["']$/);
|
|
703
|
+
if (match) {
|
|
704
|
+
const [, name, functionName, importSource] = match;
|
|
705
|
+
config.imports.push({ name, functionName, importSource });
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
warnings.push(`Invalid @fwImport tag format: "${comment}". Expected: @fwImport nodeName functionName from "packageName"`);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Parse @node tag using Chevrotain parser.
|
|
713
|
+
* Supports: @node instanceId nodeType [parentScope] [label: "..."] [portOrder: port=N] [portLabel: port="label"] [expr: port="val"] [minimized] [pullExecution: triggerPort]
|
|
714
|
+
*/
|
|
715
|
+
parseNodeTag(tag, config, warnings) {
|
|
716
|
+
const comment = tag.getCommentText() || '';
|
|
717
|
+
// Use Chevrotain to parse the node line
|
|
718
|
+
const result = parseNodeLine(`@node ${comment}`, warnings);
|
|
719
|
+
if (!result) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
const { instanceId, nodeType, parentScope, label, expressions, portOrder, portLabel, minimized, pullExecution, size, color, icon, tags, } = result;
|
|
723
|
+
// Capture source location from tag
|
|
724
|
+
const line = tag.getStartLineNumber();
|
|
725
|
+
// Build portConfigs from portOrder, portLabel, and expressions
|
|
726
|
+
let portConfigs;
|
|
727
|
+
if (portOrder) {
|
|
728
|
+
portConfigs = Object.entries(portOrder).map(([portName, order]) => ({
|
|
729
|
+
portName,
|
|
730
|
+
order,
|
|
731
|
+
}));
|
|
732
|
+
}
|
|
733
|
+
if (portLabel) {
|
|
734
|
+
portConfigs = portConfigs || [];
|
|
735
|
+
for (const [portName, labelVal] of Object.entries(portLabel)) {
|
|
736
|
+
const existingIndex = portConfigs.findIndex((pc) => pc.portName === portName);
|
|
737
|
+
if (existingIndex >= 0) {
|
|
738
|
+
portConfigs[existingIndex] = { ...portConfigs[existingIndex], label: labelVal };
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
portConfigs.push({ portName, label: labelVal });
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (expressions) {
|
|
746
|
+
portConfigs = portConfigs || [];
|
|
747
|
+
for (const [portName, expression] of Object.entries(expressions)) {
|
|
748
|
+
const existingIndex = portConfigs.findIndex((pc) => pc.portName === portName);
|
|
749
|
+
if (existingIndex >= 0) {
|
|
750
|
+
portConfigs[existingIndex] = { ...portConfigs[existingIndex], expression };
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
portConfigs.push({ portName, expression });
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
config.instances.push({
|
|
758
|
+
id: instanceId,
|
|
759
|
+
type: nodeType,
|
|
760
|
+
...(parentScope && { parentScope }),
|
|
761
|
+
...(label && { label }),
|
|
762
|
+
...(portConfigs && portConfigs.length > 0 && { portConfigs }),
|
|
763
|
+
...(pullExecution && { pullExecution: { triggerPort: pullExecution } }),
|
|
764
|
+
...(minimized && { minimized }),
|
|
765
|
+
...(color && { color }),
|
|
766
|
+
...(icon && { icon }),
|
|
767
|
+
...(tags && tags.length > 0 && { tags }),
|
|
768
|
+
...(size && { width: size.width, height: size.height }),
|
|
769
|
+
sourceLocation: { line, column: 0 },
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Parse @position tag using Chevrotain parser.
|
|
774
|
+
* Supports: @position nodeId x y
|
|
775
|
+
*/
|
|
776
|
+
parsePositionTag(tag, config, warnings) {
|
|
777
|
+
const comment = tag.getCommentText() || '';
|
|
778
|
+
// Use Chevrotain to parse the position line
|
|
779
|
+
const result = parsePositionLine(`@position ${comment}`, warnings);
|
|
780
|
+
if (!result) {
|
|
781
|
+
warnings.push(`Invalid @position tag format: ${comment}`);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const { nodeId, x, y } = result;
|
|
785
|
+
config.positions[nodeId] = { x, y };
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Parse @connect tag using Chevrotain parser.
|
|
789
|
+
* Supports: node.port -> node.port and node.port:scope -> node.port:scope
|
|
790
|
+
*/
|
|
791
|
+
parseConnectTag(tag, config, warnings) {
|
|
792
|
+
const comment = tag.getCommentText() || '';
|
|
793
|
+
// Use Chevrotain to parse the connect line
|
|
794
|
+
const result = parseConnectLine(`@connect ${comment}`, warnings);
|
|
795
|
+
if (!result) {
|
|
796
|
+
warnings.push(`Invalid @connect tag format: @connect ${comment}`);
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
const { source, target } = result;
|
|
800
|
+
// Capture source location from tag
|
|
801
|
+
const line = tag.getStartLineNumber();
|
|
802
|
+
config.connections.push({
|
|
803
|
+
from: {
|
|
804
|
+
node: source.nodeId,
|
|
805
|
+
port: source.portName,
|
|
806
|
+
...(source.scope && { scope: source.scope }),
|
|
807
|
+
},
|
|
808
|
+
to: {
|
|
809
|
+
node: target.nodeId,
|
|
810
|
+
port: target.portName,
|
|
811
|
+
...(target.scope && { scope: target.scope }),
|
|
812
|
+
},
|
|
813
|
+
sourceLocation: { line, column: 0 },
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Parse @scope tag using Chevrotain parser.
|
|
818
|
+
* Format: @scope scopeName [child1, child2] or @scope container.scopeName [child1, child2]
|
|
819
|
+
*/
|
|
820
|
+
parseScopeTag(tag, config, warnings) {
|
|
821
|
+
const comment = tag.getCommentText() || '';
|
|
822
|
+
const result = parseScopeLine(`@scope ${comment}`, warnings);
|
|
823
|
+
if (!result) {
|
|
824
|
+
warnings.push(`Invalid @scope tag format: ${comment}`);
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
config.scopes[result.scopeName] = result.children;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Parse @map tag using Chevrotain parser.
|
|
831
|
+
* Format: @map instanceId childNode over source.port
|
|
832
|
+
* Or: @map instanceId childNode(inputPort -> outputPort) over source.port
|
|
833
|
+
*/
|
|
834
|
+
parseMapTag(tag, config, warnings) {
|
|
835
|
+
const comment = tag.getCommentText() || '';
|
|
836
|
+
const result = parseMapLine(`@map ${comment}`, warnings);
|
|
837
|
+
if (!result) {
|
|
838
|
+
warnings.push(`Invalid @map tag format: ${comment}`);
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
config.maps = config.maps || [];
|
|
842
|
+
config.maps.push({
|
|
843
|
+
instanceId: result.instanceId,
|
|
844
|
+
childId: result.childId,
|
|
845
|
+
sourceNode: result.sourceNode,
|
|
846
|
+
sourcePort: result.sourcePort,
|
|
847
|
+
...(result.inputPort && { inputPort: result.inputPort }),
|
|
848
|
+
...(result.outputPort && { outputPort: result.outputPort }),
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Parse @path tag using Chevrotain parser.
|
|
853
|
+
* Format: @path Start -> validator:ok -> classifier -> urgencyRouter:fail -> escalate -> Exit
|
|
854
|
+
*/
|
|
855
|
+
parsePathTag(tag, config, warnings) {
|
|
856
|
+
const comment = tag.getCommentText() || '';
|
|
857
|
+
const result = parsePathLine(`@path ${comment}`, warnings);
|
|
858
|
+
if (!result) {
|
|
859
|
+
warnings.push(`Invalid @path tag format: ${comment}`);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
config.paths = config.paths || [];
|
|
863
|
+
config.paths.push({
|
|
864
|
+
steps: result.steps,
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Parse @trigger tag using Chevrotain parser.
|
|
869
|
+
*/
|
|
870
|
+
parseTriggerTag(tag, config, warnings) {
|
|
871
|
+
const comment = tag.getCommentText() || '';
|
|
872
|
+
const result = parseTriggerLine(`@trigger ${comment}`, warnings);
|
|
873
|
+
if (!result) {
|
|
874
|
+
warnings.push(`Invalid @trigger format: @trigger ${comment}`);
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
// Merge: multiple @trigger tags accumulate (event + cron can be separate tags)
|
|
878
|
+
config.trigger = config.trigger || {};
|
|
879
|
+
if (result.event)
|
|
880
|
+
config.trigger.event = result.event;
|
|
881
|
+
if (result.cron)
|
|
882
|
+
config.trigger.cron = result.cron;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Parse @cancelOn tag using Chevrotain parser.
|
|
886
|
+
*/
|
|
887
|
+
parseCancelOnTag(tag, config, warnings) {
|
|
888
|
+
const comment = tag.getCommentText() || '';
|
|
889
|
+
const result = parseCancelOnLine(`@cancelOn ${comment}`, warnings);
|
|
890
|
+
if (!result) {
|
|
891
|
+
warnings.push(`Invalid @cancelOn format: @cancelOn ${comment}`);
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
config.cancelOn = result;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Parse @throttle tag using Chevrotain parser.
|
|
898
|
+
*/
|
|
899
|
+
parseThrottleTag(tag, config, warnings) {
|
|
900
|
+
const comment = tag.getCommentText() || '';
|
|
901
|
+
const result = parseThrottleLine(`@throttle ${comment}`, warnings);
|
|
902
|
+
if (!result) {
|
|
903
|
+
warnings.push(`Invalid @throttle format: @throttle ${comment}`);
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
config.throttle = result;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Parse default value from string
|
|
910
|
+
*/
|
|
911
|
+
parseDefaultValue(value) {
|
|
912
|
+
// Try to parse as JSON
|
|
913
|
+
try {
|
|
914
|
+
return JSON.parse(value);
|
|
915
|
+
}
|
|
916
|
+
catch {
|
|
917
|
+
// Return as string if not valid JSON
|
|
918
|
+
return value;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
export const jsdocParser = new JSDocParser();
|
|
923
|
+
//# sourceMappingURL=jsdoc-parser.js.map
|