@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,644 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module jsdoc-port-sync/sync
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional sync between JSDoc annotations and TypeScript signatures.
|
|
5
|
+
* - syncSignatureToJSDoc: Code → JSDoc (regenerate tags from signature)
|
|
6
|
+
* - syncJSDocToSignature: JSDoc → Code (add params/fields to signature)
|
|
7
|
+
*/
|
|
8
|
+
import { SCOPED_PORT_NAMES } from "../constants.js";
|
|
9
|
+
import { JSDOC_BLOCK_REGEX, SCOPE_TAG_REGEX, RESERVED_PARAMS, findBalancedClose, splitParams, } from "./constants.js";
|
|
10
|
+
import { parseFunctionSignature, parseReturnFields, parseReturnBodyFieldsWithTypes, parseReturnTypeFields, parseInputTypeFields, tsTypeToPortType, portTypeToTsType, parseCallbackType, buildCallbackType, callbackHasAllPorts, } from "./signature-parser.js";
|
|
11
|
+
import { parsePortsFromFunctionText, updatePortsInFunctionText, hasOrphanPortLines, getIncompletePortNames, } from "./port-parser.js";
|
|
12
|
+
import { isReservedPortName } from "../constants.js";
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// Sync: Signature → JSDoc
|
|
15
|
+
// =============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Sync function signature to JSDoc (Code → JSDoc).
|
|
18
|
+
*
|
|
19
|
+
* **What it does:**
|
|
20
|
+
* - Adds `@input` tags for params in signature but not in JSDoc
|
|
21
|
+
* - Adds `@output` tags for return fields not in JSDoc
|
|
22
|
+
* - Removes orphan `@input`/`@output` tags (port deleted from signature)
|
|
23
|
+
* - Preserves existing JSDoc content (description, `@label`, etc.)
|
|
24
|
+
*
|
|
25
|
+
* **When to call:** Only on explicit format (Ctrl+P), NOT every keystroke.
|
|
26
|
+
*/
|
|
27
|
+
export function syncSignatureToJSDoc(functionText) {
|
|
28
|
+
// Check for orphan lines - skip sync if user is editing port names
|
|
29
|
+
const orphanLines = hasOrphanPortLines(functionText);
|
|
30
|
+
if (orphanLines.inputs || orphanLines.outputs) {
|
|
31
|
+
return functionText;
|
|
32
|
+
}
|
|
33
|
+
const { inputs: existingInputs, outputs: existingOutputs } = parsePortsFromFunctionText(functionText);
|
|
34
|
+
const { params } = parseFunctionSignature(functionText);
|
|
35
|
+
// Determine return fields source
|
|
36
|
+
const hasReturnTypeAnnotation = /\)\s*:\s*\{[^}]+\}\s*(?:\{|=>)/.test(functionText);
|
|
37
|
+
const returnTypeFields = parseReturnTypeFields(functionText);
|
|
38
|
+
const returnBodyFields = parseReturnFields(functionText);
|
|
39
|
+
const returnBodyFieldTypes = parseReturnBodyFieldsWithTypes(functionText);
|
|
40
|
+
const returnFields = hasReturnTypeAnnotation ? returnTypeFields : returnBodyFields;
|
|
41
|
+
const incompletePortNames = getIncompletePortNames(functionText);
|
|
42
|
+
// Get non-callback param names
|
|
43
|
+
const signatureParamNames = new Set(params
|
|
44
|
+
.filter((p) => !RESERVED_PARAMS.includes(p.name) && !p.tsType?.includes("=>"))
|
|
45
|
+
.map((p) => p.name));
|
|
46
|
+
// Also get input fields from TFlowWeaverNodeType type annotation
|
|
47
|
+
const inputTypeFields = parseInputTypeFields(functionText);
|
|
48
|
+
for (const field of inputTypeFields) {
|
|
49
|
+
signatureParamNames.add(field.name);
|
|
50
|
+
}
|
|
51
|
+
const returnFieldNames = new Set(returnFields);
|
|
52
|
+
// Build merged inputs
|
|
53
|
+
const mergedInputs = { ...existingInputs };
|
|
54
|
+
for (const param of params) {
|
|
55
|
+
if (RESERVED_PARAMS.includes(param.name))
|
|
56
|
+
continue;
|
|
57
|
+
if (incompletePortNames.inputs.has(param.name))
|
|
58
|
+
continue;
|
|
59
|
+
const signatureType = tsTypeToPortType(param.tsType);
|
|
60
|
+
if (!mergedInputs[param.name]) {
|
|
61
|
+
mergedInputs[param.name] = {
|
|
62
|
+
dataType: signatureType,
|
|
63
|
+
...(param.optional && { optional: true }),
|
|
64
|
+
...(param.defaultValue && { default: parseDefaultValue(param.defaultValue) }),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else if (signatureType !== "ANY" && mergedInputs[param.name].dataType !== signatureType) {
|
|
68
|
+
const existingType = mergedInputs[param.name].dataType;
|
|
69
|
+
if (!(existingType === "STEP" && signatureType === "BOOLEAN")) {
|
|
70
|
+
mergedInputs[param.name] = {
|
|
71
|
+
...mergedInputs[param.name],
|
|
72
|
+
dataType: signatureType,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Add inputs from TFlowWeaverNodeType type annotation
|
|
78
|
+
for (const field of inputTypeFields) {
|
|
79
|
+
if (!mergedInputs[field.name] && !incompletePortNames.inputs.has(field.name)) {
|
|
80
|
+
mergedInputs[field.name] = { dataType: tsTypeToPortType(field.tsType) };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Build merged outputs
|
|
84
|
+
const mergedOutputs = { ...existingOutputs };
|
|
85
|
+
for (const field of returnFields) {
|
|
86
|
+
if (!mergedOutputs[field] && !incompletePortNames.outputs.has(field)) {
|
|
87
|
+
const inferredType = returnBodyFieldTypes.get(field);
|
|
88
|
+
const dataType = inferredType ? tsTypeToPortType(inferredType) : "ANY";
|
|
89
|
+
mergedOutputs[field] = { dataType, ...(inferredType && { tsType: inferredType }) };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Get raw signature for additional checks
|
|
93
|
+
const sigMatch = functionText.match(/function\s+\w+\s*\(([^)]*)/s) ||
|
|
94
|
+
functionText.match(/=\s*\(([^)]*)\)\s*(?:=>|:)/s);
|
|
95
|
+
const rawSigText = sigMatch?.[1] || "";
|
|
96
|
+
// Parse callback info for scoped port detection
|
|
97
|
+
const callbackInfo = new Map();
|
|
98
|
+
for (const param of params) {
|
|
99
|
+
if (param.tsType?.includes("=>")) {
|
|
100
|
+
const parsed = parseCallbackType(param.tsType);
|
|
101
|
+
const fieldNames = new Set(parsed.returnFields.map(f => f.name));
|
|
102
|
+
callbackInfo.set(param.name, {
|
|
103
|
+
hasReturnFields: fieldNames.size > 0,
|
|
104
|
+
returnFieldNames: fieldNames,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Auto-remove orphan inputs
|
|
109
|
+
const finalInputs = {};
|
|
110
|
+
for (const [name, port] of Object.entries(mergedInputs)) {
|
|
111
|
+
const hasUserMetadata = port.metadata?.order !== undefined || port.label !== undefined;
|
|
112
|
+
const existsInRawSig = new RegExp(`\\b${name}\\b`).test(rawSigText);
|
|
113
|
+
const isScopedInput = port.scope !== undefined;
|
|
114
|
+
let keepScopedInput = false;
|
|
115
|
+
if (isScopedInput && port.scope) {
|
|
116
|
+
const scopeCallback = callbackInfo.get(port.scope);
|
|
117
|
+
if (scopeCallback) {
|
|
118
|
+
if (scopeCallback.hasReturnFields) {
|
|
119
|
+
keepScopedInput = scopeCallback.returnFieldNames.has(name);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
keepScopedInput = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (signatureParamNames.has(name) || keepScopedInput || incompletePortNames.inputs.has(name) || (hasUserMetadata && existsInRawSig)) {
|
|
127
|
+
finalInputs[name] = port;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Auto-remove orphan outputs
|
|
131
|
+
const finalOutputs = {};
|
|
132
|
+
for (const [name, port] of Object.entries(mergedOutputs)) {
|
|
133
|
+
if (returnFieldNames.has(name) || port.scope || isReservedPortName(name) || incompletePortNames.outputs.has(name)) {
|
|
134
|
+
finalOutputs[name] = port;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Build signature input order
|
|
138
|
+
const rawParamMatches = rawSigText.matchAll(/^\s*(\w+)\s*[?:]|,\s*(\w+)\s*[?:]/gm);
|
|
139
|
+
const rawParamOrder = [];
|
|
140
|
+
for (const match of rawParamMatches) {
|
|
141
|
+
const name = match[1] || match[2];
|
|
142
|
+
if (name && !RESERVED_PARAMS.includes(name) && !rawParamOrder.includes(name)) {
|
|
143
|
+
const afterName = rawSigText.substring(rawSigText.indexOf(name + ":") + name.length + 1);
|
|
144
|
+
if (!afterName.trim().startsWith("(")) {
|
|
145
|
+
rawParamOrder.push(name);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const parsedOrder = params
|
|
150
|
+
.filter((p) => !RESERVED_PARAMS.includes(p.name) && !p.tsType?.includes("=>"))
|
|
151
|
+
.map((p) => p.name);
|
|
152
|
+
const signatureInputOrder = rawParamOrder.length >= parsedOrder.length ? rawParamOrder : parsedOrder;
|
|
153
|
+
// ==========================================================================
|
|
154
|
+
// Auto-generate mandatory scoped ports for declared @scope tags
|
|
155
|
+
// ==========================================================================
|
|
156
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
157
|
+
if (jsdocMatch) {
|
|
158
|
+
const jsdoc = jsdocMatch[0];
|
|
159
|
+
const declaredScopes = new Set();
|
|
160
|
+
SCOPE_TAG_REGEX.lastIndex = 0;
|
|
161
|
+
let scopeMatch;
|
|
162
|
+
while ((scopeMatch = SCOPE_TAG_REGEX.exec(jsdoc)) != null) {
|
|
163
|
+
declaredScopes.add(scopeMatch[1]);
|
|
164
|
+
}
|
|
165
|
+
// For each declared scope, ensure mandatory ports exist
|
|
166
|
+
for (const scopeName of declaredScopes) {
|
|
167
|
+
// Mandatory OUTPUT: start (STEP)
|
|
168
|
+
if (!finalOutputs[SCOPED_PORT_NAMES.START] || finalOutputs[SCOPED_PORT_NAMES.START].scope !== scopeName) {
|
|
169
|
+
// Check if 'start' exists with this scope
|
|
170
|
+
const hasStart = Object.entries(finalOutputs).some(([name, port]) => name === SCOPED_PORT_NAMES.START && port.scope === scopeName);
|
|
171
|
+
if (!hasStart) {
|
|
172
|
+
finalOutputs[SCOPED_PORT_NAMES.START] = {
|
|
173
|
+
dataType: "STEP",
|
|
174
|
+
scope: scopeName,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Mandatory INPUT: success (STEP)
|
|
179
|
+
const hasSuccess = Object.entries(finalInputs).some(([name, port]) => name === SCOPED_PORT_NAMES.SUCCESS && port.scope === scopeName);
|
|
180
|
+
if (!hasSuccess) {
|
|
181
|
+
finalInputs[SCOPED_PORT_NAMES.SUCCESS] = {
|
|
182
|
+
dataType: "STEP",
|
|
183
|
+
scope: scopeName,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// Mandatory INPUT: failure (STEP)
|
|
187
|
+
const hasFailure = Object.entries(finalInputs).some(([name, port]) => name === SCOPED_PORT_NAMES.FAILURE && port.scope === scopeName);
|
|
188
|
+
if (!hasFailure) {
|
|
189
|
+
finalInputs[SCOPED_PORT_NAMES.FAILURE] = {
|
|
190
|
+
dataType: "STEP",
|
|
191
|
+
scope: scopeName,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return updatePortsInFunctionText(functionText, finalInputs, finalOutputs, signatureInputOrder);
|
|
197
|
+
}
|
|
198
|
+
// =============================================================================
|
|
199
|
+
// Sync: JSDoc → Signature
|
|
200
|
+
// =============================================================================
|
|
201
|
+
/**
|
|
202
|
+
* Sync JSDoc to function signature (JSDoc → Code).
|
|
203
|
+
*
|
|
204
|
+
* **What it does:**
|
|
205
|
+
* - Adds missing params from `@input` tags to function signature
|
|
206
|
+
* - Updates return type with fields from `@output` tags
|
|
207
|
+
* - Ensures `execute: boolean` is first param
|
|
208
|
+
* - Builds/updates callback types for scoped ports
|
|
209
|
+
*
|
|
210
|
+
* **When to call:** On every keystroke during editing.
|
|
211
|
+
*/
|
|
212
|
+
export function syncJSDocToSignature(functionText, authoritativePorts) {
|
|
213
|
+
const { inputs: parsedInputs, outputs: parsedOutputs } = parsePortsFromFunctionText(functionText);
|
|
214
|
+
const returnBodyFieldTypes = parseReturnBodyFieldsWithTypes(functionText);
|
|
215
|
+
// Use authoritative ports if provided
|
|
216
|
+
const inputs = {};
|
|
217
|
+
for (const [name, port] of Object.entries(parsedInputs)) {
|
|
218
|
+
inputs[name] = authoritativePorts?.inputs?.[name] ?? port;
|
|
219
|
+
}
|
|
220
|
+
const outputs = {};
|
|
221
|
+
for (const [name, port] of Object.entries(parsedOutputs)) {
|
|
222
|
+
const authoritative = authoritativePorts?.outputs?.[name];
|
|
223
|
+
if (authoritative) {
|
|
224
|
+
outputs[name] = authoritative;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
const inferredTsType = returnBodyFieldTypes.get(name);
|
|
228
|
+
if (inferredTsType && !port.tsType) {
|
|
229
|
+
outputs[name] = { ...port, tsType: inferredTsType };
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
outputs[name] = port;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const { params, functionType } = parseFunctionSignature(functionText);
|
|
237
|
+
// Helper to safely get order from metadata (metadata is Record<string, unknown>)
|
|
238
|
+
const getOrder = (port) => {
|
|
239
|
+
const order = port.metadata?.order;
|
|
240
|
+
return typeof order === "number" ? order : Infinity;
|
|
241
|
+
};
|
|
242
|
+
// Build ordered list of NON-SCOPED ports only
|
|
243
|
+
const orderedInputs = Object.entries(inputs)
|
|
244
|
+
.filter(([_, port]) => !port.scope)
|
|
245
|
+
.map(([name, port]) => ({ name, port, order: getOrder(port) }))
|
|
246
|
+
.sort((a, b) => a.order - b.order);
|
|
247
|
+
// Get existing param names
|
|
248
|
+
const existingParamNames = new Set(params.map((p) => p.name));
|
|
249
|
+
// Also extract from raw signature
|
|
250
|
+
const sigMatch = functionText.match(/function\s+\w+\s*\(([^)]*)/s) ||
|
|
251
|
+
functionText.match(/=\s*\(([^)]*)\)\s*(?:=>|:)/s);
|
|
252
|
+
const rawSigText = sigMatch?.[1] || "";
|
|
253
|
+
const rawParamMatches = rawSigText.matchAll(/\b(\w+)\s*[?:]/g);
|
|
254
|
+
for (const match of rawParamMatches) {
|
|
255
|
+
existingParamNames.add(match[1]);
|
|
256
|
+
}
|
|
257
|
+
// Find params to add
|
|
258
|
+
const paramsToAdd = orderedInputs.filter(({ name }) => !existingParamNames.has(name) && !RESERVED_PARAMS.includes(name));
|
|
259
|
+
// IMPORTANT: Do NOT remove params from signature that don't have @input tags
|
|
260
|
+
// The signature is the source of truth for param existence
|
|
261
|
+
// JSDoc is only for metadata (labels, order, scope, etc.)
|
|
262
|
+
// Removing params would break user workflow of adding params to signature first
|
|
263
|
+
const paramsToRemove = [];
|
|
264
|
+
// Filter out scoped outputs
|
|
265
|
+
const nonScopedOutputs = Object.fromEntries(Object.entries(outputs).filter(([_, port]) => !port.scope));
|
|
266
|
+
// Check for scoped ports
|
|
267
|
+
const scopedInputs = Object.entries(inputs).filter(([_, port]) => port.scope);
|
|
268
|
+
const scopedOutputs = Object.entries(outputs).filter(([_, port]) => port.scope);
|
|
269
|
+
const hasScopedPorts = scopedInputs.length > 0 || scopedOutputs.length > 0;
|
|
270
|
+
const hasSyncableOutputs = Object.keys(nonScopedOutputs).length > 0;
|
|
271
|
+
const hasExecuteParam = existingParamNames.has("execute");
|
|
272
|
+
// Check for outputs to remove
|
|
273
|
+
const existingReturnFields = parseReturnTypeFields(functionText);
|
|
274
|
+
const jsDocOutputNames = new Set(Object.keys(nonScopedOutputs));
|
|
275
|
+
const MANDATORY_RETURN_FIELDS = new Set(["onSuccess", "onFailure"]);
|
|
276
|
+
const hasOutputsToRemove = existingReturnFields.some((field) => !jsDocOutputNames.has(field) && !MANDATORY_RETURN_FIELDS.has(field));
|
|
277
|
+
if (paramsToAdd.length === 0 && paramsToRemove.length === 0 && !hasScopedPorts && !hasSyncableOutputs && !hasOutputsToRemove && hasExecuteParam) {
|
|
278
|
+
return functionText;
|
|
279
|
+
}
|
|
280
|
+
let result = functionText;
|
|
281
|
+
// Remove params not in JSDoc
|
|
282
|
+
for (const param of paramsToRemove) {
|
|
283
|
+
const paramRegex = new RegExp(`(,\\s*)?\\b${param.name}\\s*\\??\\s*:\\s*[^,)]+`, "g");
|
|
284
|
+
result = result.replace(paramRegex, "");
|
|
285
|
+
result = result.replace(/\(\s*,\s*/g, "(");
|
|
286
|
+
result = result.replace(/,\s*,/g, ",");
|
|
287
|
+
result = result.replace(/,\s*\)/g, ")");
|
|
288
|
+
}
|
|
289
|
+
// Ensure execute: boolean is first
|
|
290
|
+
if (!hasExecuteParam) {
|
|
291
|
+
if (functionType === "declaration") {
|
|
292
|
+
const funcMatch = result.match(/function\s+\w+\s*\(/);
|
|
293
|
+
if (funcMatch && funcMatch.index !== undefined) {
|
|
294
|
+
const openParen = funcMatch.index + funcMatch[0].length - 1;
|
|
295
|
+
const closeParen = findBalancedClose(result, openParen);
|
|
296
|
+
if (closeParen !== -1) {
|
|
297
|
+
const existingParams = result.substring(openParen + 1, closeParen).trim();
|
|
298
|
+
const sep = existingParams ? ", " : "";
|
|
299
|
+
result =
|
|
300
|
+
result.substring(0, openParen + 1) +
|
|
301
|
+
"execute: boolean" +
|
|
302
|
+
sep +
|
|
303
|
+
result.substring(openParen + 1);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else if (functionType === "arrow") {
|
|
308
|
+
const arrowMatch = result.match(/(?:const|let|var)\s+\w+\s*=\s*(?:async\s*)?\(/);
|
|
309
|
+
if (arrowMatch && arrowMatch.index !== undefined) {
|
|
310
|
+
const openParen = arrowMatch.index + arrowMatch[0].length - 1;
|
|
311
|
+
const closeParen = findBalancedClose(result, openParen);
|
|
312
|
+
if (closeParen !== -1) {
|
|
313
|
+
const existingParams = result.substring(openParen + 1, closeParen).trim();
|
|
314
|
+
const sep = existingParams ? ", " : "";
|
|
315
|
+
result =
|
|
316
|
+
result.substring(0, openParen + 1) +
|
|
317
|
+
"execute: boolean" +
|
|
318
|
+
sep +
|
|
319
|
+
result.substring(openParen + 1);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// Add missing params
|
|
325
|
+
if (paramsToAdd.length > 0) {
|
|
326
|
+
const newParamStrings = paramsToAdd.map(({ name, port }) => {
|
|
327
|
+
const tsType = portTypeToTsType(port.dataType);
|
|
328
|
+
if (port.optional && port.default !== undefined) {
|
|
329
|
+
return `${name}: ${tsType} = ${JSON.stringify(port.default)}`;
|
|
330
|
+
}
|
|
331
|
+
else if (port.optional) {
|
|
332
|
+
return `${name}?: ${tsType}`;
|
|
333
|
+
}
|
|
334
|
+
return `${name}: ${tsType}`;
|
|
335
|
+
});
|
|
336
|
+
if (functionType === "declaration") {
|
|
337
|
+
const funcMatch = result.match(/function\s+\w+\s*\(/);
|
|
338
|
+
if (funcMatch && funcMatch.index !== undefined) {
|
|
339
|
+
const openParen = funcMatch.index + funcMatch[0].length - 1;
|
|
340
|
+
const closeParen = findBalancedClose(result, openParen);
|
|
341
|
+
if (closeParen !== -1) {
|
|
342
|
+
let existingParams = result.substring(openParen + 1, closeParen);
|
|
343
|
+
const endsWithComma = /,\s*$/.test(existingParams);
|
|
344
|
+
const isMultiline = existingParams.includes("\n");
|
|
345
|
+
let sep;
|
|
346
|
+
if (!existingParams.trim()) {
|
|
347
|
+
sep = "";
|
|
348
|
+
}
|
|
349
|
+
else if (endsWithComma) {
|
|
350
|
+
existingParams = existingParams.replace(/,\s*$/, ",");
|
|
351
|
+
sep = "\n ";
|
|
352
|
+
}
|
|
353
|
+
else if (isMultiline) {
|
|
354
|
+
existingParams = existingParams.trimEnd();
|
|
355
|
+
sep = ",\n ";
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
sep = ", ";
|
|
359
|
+
}
|
|
360
|
+
result =
|
|
361
|
+
result.substring(0, openParen + 1) +
|
|
362
|
+
existingParams +
|
|
363
|
+
sep +
|
|
364
|
+
newParamStrings.join(", ") +
|
|
365
|
+
"\n" +
|
|
366
|
+
result.substring(closeParen);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else if (functionType === "arrow") {
|
|
371
|
+
const arrowMatch = result.match(/(?:const|let|var)\s+\w+\s*=\s*(?:async\s*)?\(/);
|
|
372
|
+
if (arrowMatch && arrowMatch.index !== undefined) {
|
|
373
|
+
const openParen = arrowMatch.index + arrowMatch[0].length - 1;
|
|
374
|
+
const closeParen = findBalancedClose(result, openParen);
|
|
375
|
+
if (closeParen !== -1) {
|
|
376
|
+
let existingParams = result.substring(openParen + 1, closeParen);
|
|
377
|
+
const endsWithComma = /,\s*$/.test(existingParams);
|
|
378
|
+
const isMultiline = existingParams.includes("\n");
|
|
379
|
+
let sep;
|
|
380
|
+
if (!existingParams.trim()) {
|
|
381
|
+
sep = "";
|
|
382
|
+
}
|
|
383
|
+
else if (endsWithComma) {
|
|
384
|
+
existingParams = existingParams.replace(/,\s*$/, ",");
|
|
385
|
+
sep = "\n ";
|
|
386
|
+
}
|
|
387
|
+
else if (isMultiline) {
|
|
388
|
+
existingParams = existingParams.trimEnd();
|
|
389
|
+
sep = ",\n ";
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
sep = ", ";
|
|
393
|
+
}
|
|
394
|
+
result =
|
|
395
|
+
result.substring(0, openParen + 1) +
|
|
396
|
+
existingParams +
|
|
397
|
+
sep +
|
|
398
|
+
newParamStrings.join(", ") +
|
|
399
|
+
"\n" +
|
|
400
|
+
result.substring(closeParen);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
// Handle scoped ports → callback signatures
|
|
406
|
+
if (hasScopedPorts) {
|
|
407
|
+
const scopeNames = new Set([
|
|
408
|
+
...scopedInputs.map(([_, port]) => port.scope),
|
|
409
|
+
...scopedOutputs.map(([_, port]) => port.scope),
|
|
410
|
+
]);
|
|
411
|
+
for (const scopeName of scopeNames) {
|
|
412
|
+
const callbackParams = scopedOutputs.filter(([name, port]) => port.scope === scopeName && port.dataType !== "FUNCTION" && name !== scopeName);
|
|
413
|
+
const callbackReturns = scopedInputs.filter(([_, port]) => port.scope === scopeName);
|
|
414
|
+
if (callbackParams.length > 0 || callbackReturns.length > 0) {
|
|
415
|
+
result = updateCallbackInSignature(result, scopeName, callbackParams, callbackReturns, functionType);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// Handle return type annotation
|
|
420
|
+
const syncableOutputs = Object.entries(nonScopedOutputs).filter(([_, port]) => !port.scope);
|
|
421
|
+
const existingReturnTypeMatch = result.match(/\)\s*:\s*\{([^}]*)\}/);
|
|
422
|
+
const existingFields = new Map();
|
|
423
|
+
if (existingReturnTypeMatch) {
|
|
424
|
+
const existingContent = existingReturnTypeMatch[1];
|
|
425
|
+
const fieldMatches = existingContent.matchAll(/(\w+)\s*:\s*([^;}\s][^;}]*)?/g);
|
|
426
|
+
for (const match of fieldMatches) {
|
|
427
|
+
const fieldName = match[1];
|
|
428
|
+
const fieldType = match[2]?.trim() || "";
|
|
429
|
+
existingFields.set(fieldName, fieldType);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
// Ensure mandatory fields
|
|
433
|
+
if (!existingFields.has("onSuccess")) {
|
|
434
|
+
existingFields.set("onSuccess", "boolean");
|
|
435
|
+
}
|
|
436
|
+
if (!existingFields.has("onFailure")) {
|
|
437
|
+
existingFields.set("onFailure", "boolean");
|
|
438
|
+
}
|
|
439
|
+
// Add fields from JSDoc
|
|
440
|
+
for (const [name, port] of syncableOutputs) {
|
|
441
|
+
if (name === "onSuccess" || name === "onFailure")
|
|
442
|
+
continue;
|
|
443
|
+
const existingType = existingFields.get(name);
|
|
444
|
+
if (!existingType) {
|
|
445
|
+
const typeStr = port.tsType || portTypeToTsType(port.dataType);
|
|
446
|
+
existingFields.set(name, typeStr);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
// Build final fields list
|
|
450
|
+
const allFields = [];
|
|
451
|
+
allFields.push(`onSuccess: ${existingFields.get("onSuccess")}`);
|
|
452
|
+
allFields.push(`onFailure: ${existingFields.get("onFailure")}`);
|
|
453
|
+
for (const [name, type] of existingFields) {
|
|
454
|
+
if (name === "onSuccess" || name === "onFailure")
|
|
455
|
+
continue;
|
|
456
|
+
allFields.push(type ? `${name}: ${type}` : `${name}:`);
|
|
457
|
+
}
|
|
458
|
+
if (allFields.length > 0) {
|
|
459
|
+
const returnType = `{ ${allFields.join("; ")} }`;
|
|
460
|
+
if (functionType === "declaration") {
|
|
461
|
+
const funcMatch = result.match(/function\s+\w+\s*\(/);
|
|
462
|
+
if (funcMatch && funcMatch.index !== undefined) {
|
|
463
|
+
const openParen = funcMatch.index + funcMatch[0].length - 1;
|
|
464
|
+
const closeParen = findBalancedClose(result, openParen);
|
|
465
|
+
if (closeParen !== -1) {
|
|
466
|
+
const afterParen = result.substring(closeParen + 1);
|
|
467
|
+
const existingReturnMatch = afterParen.match(/^\s*:\s*\{[^}]*\}/);
|
|
468
|
+
if (existingReturnMatch) {
|
|
469
|
+
result =
|
|
470
|
+
result.substring(0, closeParen + 1) +
|
|
471
|
+
": " +
|
|
472
|
+
returnType +
|
|
473
|
+
afterParen.substring(existingReturnMatch[0].length);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
const beforeBody = afterParen.match(/^\s*/);
|
|
477
|
+
const whitespace = beforeBody ? beforeBody[0] : " ";
|
|
478
|
+
result =
|
|
479
|
+
result.substring(0, closeParen + 1) +
|
|
480
|
+
": " +
|
|
481
|
+
returnType +
|
|
482
|
+
whitespace +
|
|
483
|
+
afterParen.substring(whitespace.length);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
else if (functionType === "arrow") {
|
|
489
|
+
const arrowMatch = result.match(/(?:const|let|var)\s+\w+\s*=\s*(?:async\s*)?\(/);
|
|
490
|
+
if (arrowMatch && arrowMatch.index !== undefined) {
|
|
491
|
+
const openParen = arrowMatch.index + arrowMatch[0].length - 1;
|
|
492
|
+
const closeParen = findBalancedClose(result, openParen);
|
|
493
|
+
if (closeParen !== -1) {
|
|
494
|
+
const afterParen = result.substring(closeParen + 1);
|
|
495
|
+
const existingReturnMatch = afterParen.match(/^\s*:\s*\{[^}]*\}/);
|
|
496
|
+
if (existingReturnMatch) {
|
|
497
|
+
result =
|
|
498
|
+
result.substring(0, closeParen + 1) +
|
|
499
|
+
": " +
|
|
500
|
+
returnType +
|
|
501
|
+
afterParen.substring(existingReturnMatch[0].length);
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
const beforeArrow = afterParen.match(/^\s*/);
|
|
505
|
+
const whitespace = beforeArrow ? beforeArrow[0] : " ";
|
|
506
|
+
result =
|
|
507
|
+
result.substring(0, closeParen + 1) +
|
|
508
|
+
": " +
|
|
509
|
+
returnType +
|
|
510
|
+
whitespace +
|
|
511
|
+
afterParen.substring(whitespace.length);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return result;
|
|
518
|
+
}
|
|
519
|
+
// =============================================================================
|
|
520
|
+
// Callback Signature Update
|
|
521
|
+
// =============================================================================
|
|
522
|
+
/**
|
|
523
|
+
* Update or add callback parameter for a scope.
|
|
524
|
+
*/
|
|
525
|
+
function updateCallbackInSignature(functionText, scopeName, callbackParams, callbackReturns, functionType) {
|
|
526
|
+
if (functionType === "declaration") {
|
|
527
|
+
const funcMatch = functionText.match(/((?:async\s+)?function\s+)(\w+)\s*\(/);
|
|
528
|
+
if (!funcMatch || funcMatch.index === undefined)
|
|
529
|
+
return functionText;
|
|
530
|
+
const openParenIndex = funcMatch.index + funcMatch[0].length - 1;
|
|
531
|
+
const closeParenIndex = findBalancedClose(functionText, openParenIndex);
|
|
532
|
+
if (closeParenIndex === -1)
|
|
533
|
+
return functionText;
|
|
534
|
+
const paramsStr = functionText.substring(openParenIndex + 1, closeParenIndex);
|
|
535
|
+
const paramTokens = splitParams(paramsStr);
|
|
536
|
+
const callbackIndex = paramTokens.findIndex((p) => p.includes("=>"));
|
|
537
|
+
if (callbackIndex >= 0) {
|
|
538
|
+
const callbackParam = paramTokens[callbackIndex].trim();
|
|
539
|
+
const colonIndex = callbackParam.indexOf(":");
|
|
540
|
+
const existingType = callbackParam.substring(colonIndex + 1).trim();
|
|
541
|
+
if (callbackHasAllPorts(existingType, callbackParams, callbackReturns)) {
|
|
542
|
+
return functionText;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
const beforeFunc = functionText.substring(0, funcMatch.index);
|
|
546
|
+
const funcKeyword = funcMatch[1];
|
|
547
|
+
const funcName = funcMatch[2];
|
|
548
|
+
const suffix = functionText.substring(closeParenIndex + 1);
|
|
549
|
+
const isMultiline = paramsStr.includes("\n");
|
|
550
|
+
if (callbackIndex >= 0) {
|
|
551
|
+
const callbackParam = paramTokens[callbackIndex].trim();
|
|
552
|
+
const colonIndex = callbackParam.indexOf(":");
|
|
553
|
+
const paramName = callbackParam.substring(0, colonIndex).trim();
|
|
554
|
+
const existingType = callbackParam.substring(colonIndex + 1).trim();
|
|
555
|
+
const callbackType = buildCallbackType(callbackParams, callbackReturns, existingType);
|
|
556
|
+
paramTokens[callbackIndex] = `${paramName}: ${callbackType}`;
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
const callbackType = buildCallbackType(callbackParams, callbackReturns);
|
|
560
|
+
paramTokens.push(`${scopeName}: ${callbackType}`);
|
|
561
|
+
}
|
|
562
|
+
if (isMultiline) {
|
|
563
|
+
let result = paramsStr;
|
|
564
|
+
const callbackToken = paramTokens[callbackIndex];
|
|
565
|
+
const callbackStartRegex = new RegExp(`(${scopeName}\\s*:\\s*)\\([^)]*\\)\\s*=>\\s*\\{[^}]*\\}`, 's');
|
|
566
|
+
const match = result.match(callbackStartRegex);
|
|
567
|
+
if (match) {
|
|
568
|
+
result = result.replace(callbackStartRegex, callbackToken);
|
|
569
|
+
}
|
|
570
|
+
return `${beforeFunc}${funcKeyword}${funcName}(${result})${suffix}`;
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
const trimmedTokens = paramTokens.map((p) => p.trim());
|
|
574
|
+
return `${beforeFunc}${funcKeyword}${funcName}(${trimmedTokens.join(", ")})${suffix}`;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
else if (functionType === "arrow") {
|
|
578
|
+
const arrowMatch = functionText.match(/((?:const|let|var)\s+\w+\s*=\s*(?:async\s*)?)\(/);
|
|
579
|
+
if (!arrowMatch || arrowMatch.index === undefined)
|
|
580
|
+
return functionText;
|
|
581
|
+
const openParenIndex = arrowMatch.index + arrowMatch[0].length - 1;
|
|
582
|
+
const closeParenIndex = findBalancedClose(functionText, openParenIndex);
|
|
583
|
+
if (closeParenIndex === -1)
|
|
584
|
+
return functionText;
|
|
585
|
+
const paramsStr = functionText.substring(openParenIndex + 1, closeParenIndex);
|
|
586
|
+
const paramTokens = splitParams(paramsStr);
|
|
587
|
+
const callbackIndex = paramTokens.findIndex((p) => p.includes("=>"));
|
|
588
|
+
if (callbackIndex >= 0) {
|
|
589
|
+
const callbackParam = paramTokens[callbackIndex].trim();
|
|
590
|
+
const colonIndex = callbackParam.indexOf(":");
|
|
591
|
+
const existingType = callbackParam.substring(colonIndex + 1).trim();
|
|
592
|
+
if (callbackHasAllPorts(existingType, callbackParams, callbackReturns)) {
|
|
593
|
+
return functionText;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
const beforeArrow = functionText.substring(0, arrowMatch.index);
|
|
597
|
+
const prefix = arrowMatch[1];
|
|
598
|
+
const afterParams = functionText.substring(closeParenIndex + 1);
|
|
599
|
+
const arrowIndex = afterParams.indexOf("=>");
|
|
600
|
+
if (arrowIndex === -1)
|
|
601
|
+
return functionText;
|
|
602
|
+
const suffix = afterParams.substring(arrowIndex);
|
|
603
|
+
const isMultiline = paramsStr.includes("\n");
|
|
604
|
+
if (callbackIndex >= 0) {
|
|
605
|
+
const callbackParam = paramTokens[callbackIndex].trim();
|
|
606
|
+
const colonIndex = callbackParam.indexOf(":");
|
|
607
|
+
const paramName = callbackParam.substring(0, colonIndex).trim();
|
|
608
|
+
const existingType = callbackParam.substring(colonIndex + 1).trim();
|
|
609
|
+
const callbackType = buildCallbackType(callbackParams, callbackReturns, existingType);
|
|
610
|
+
paramTokens[callbackIndex] = `${paramName}: ${callbackType}`;
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
const callbackType = buildCallbackType(callbackParams, callbackReturns);
|
|
614
|
+
paramTokens.push(`${scopeName}: ${callbackType}`);
|
|
615
|
+
}
|
|
616
|
+
if (isMultiline) {
|
|
617
|
+
let result = paramsStr;
|
|
618
|
+
const callbackToken = paramTokens[callbackIndex];
|
|
619
|
+
const callbackStartRegex = new RegExp(`(${scopeName}\\s*:\\s*)\\([^)]*\\)\\s*=>\\s*\\{[^}]*\\}`, 's');
|
|
620
|
+
const match = result.match(callbackStartRegex);
|
|
621
|
+
if (match) {
|
|
622
|
+
result = result.replace(callbackStartRegex, callbackToken);
|
|
623
|
+
}
|
|
624
|
+
return `${beforeArrow}${prefix}(${result}) ${suffix}`;
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
const trimmedTokens = paramTokens.map((p) => p.trim());
|
|
628
|
+
return `${beforeArrow}${prefix}(${trimmedTokens.join(", ")}) ${suffix}`;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return functionText;
|
|
632
|
+
}
|
|
633
|
+
// =============================================================================
|
|
634
|
+
// Helpers
|
|
635
|
+
// =============================================================================
|
|
636
|
+
function parseDefaultValue(value) {
|
|
637
|
+
try {
|
|
638
|
+
return JSON.parse(value);
|
|
639
|
+
}
|
|
640
|
+
catch {
|
|
641
|
+
return value;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module jsdoc-port-sync
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from modular jsdoc-port-sync/ directory.
|
|
5
|
+
* This file maintains backwards compatibility for existing imports.
|
|
6
|
+
*
|
|
7
|
+
* @see ./jsdoc-port-sync/index.ts for the modular implementation
|
|
8
|
+
*/
|
|
9
|
+
export * from "./jsdoc-port-sync/index.js";
|
|
10
|
+
//# sourceMappingURL=jsdoc-port-sync.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module jsdoc-port-sync
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from modular jsdoc-port-sync/ directory.
|
|
5
|
+
* This file maintains backwards compatibility for existing imports.
|
|
6
|
+
*
|
|
7
|
+
* @see ./jsdoc-port-sync/index.ts for the modular implementation
|
|
8
|
+
*/
|
|
9
|
+
export * from "./jsdoc-port-sync/index.js";
|
|
10
|
+
//# sourceMappingURL=jsdoc-port-sync.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module marketplace
|
|
3
|
+
*
|
|
4
|
+
* Flow Weaver Marketplace — discover, install, and publish reusable
|
|
5
|
+
* node types, workflows, and patterns via npm.
|
|
6
|
+
*/
|
|
7
|
+
export type { TMarketplaceManifest, TManifestNodeType, TManifestWorkflow, TManifestPattern, TManifestPort, TValidationIssue, TValidationSeverity, TPackageValidationResult, TMarketplacePackageInfo, TInstalledPackage, TMarketInitConfig, } from './types.js';
|
|
8
|
+
export { generateManifest, writeManifest, readManifest, type GenerateManifestOptions, type GenerateManifestResult, } from './manifest.js';
|
|
9
|
+
export { validatePackage } from './validator.js';
|
|
10
|
+
export { searchPackages, listInstalledPackages, getInstalledPackageManifest, type SearchOptions, } from './registry.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|