@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,886 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel export target
|
|
3
|
+
*
|
|
4
|
+
* Generates Vercel serverless functions.
|
|
5
|
+
*/
|
|
6
|
+
import { BaseExportTarget, } from './base.js';
|
|
7
|
+
import { getGeneratedBranding } from '../../generated-branding.js';
|
|
8
|
+
import { generateStandaloneRuntimeModule } from '../../api/inline-runtime.js';
|
|
9
|
+
/**
|
|
10
|
+
* Handler template for Vercel - Basic version
|
|
11
|
+
*/
|
|
12
|
+
const VERCEL_HANDLER_TEMPLATE = `{{GENERATED_HEADER}}
|
|
13
|
+
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
14
|
+
{{WORKFLOW_IMPORT}}
|
|
15
|
+
|
|
16
|
+
export const config = {
|
|
17
|
+
runtime: 'nodejs20.x',
|
|
18
|
+
maxDuration: {{MAX_DURATION}},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|
22
|
+
// Only allow POST requests
|
|
23
|
+
if (req.method !== 'POST') {
|
|
24
|
+
return res.status(405).json({
|
|
25
|
+
success: false,
|
|
26
|
+
error: { code: 'METHOD_NOT_ALLOWED', message: 'Only POST requests are allowed' },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const requestId = req.headers['x-vercel-id'] as string || crypto.randomUUID();
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const params = req.body || {};
|
|
34
|
+
const startTime = Date.now();
|
|
35
|
+
|
|
36
|
+
const result = await {{FUNCTION_NAME}}(true, params);
|
|
37
|
+
|
|
38
|
+
return res
|
|
39
|
+
.setHeader('X-Request-Id', requestId)
|
|
40
|
+
.setHeader('X-Execution-Time', \`\${Date.now() - startTime}ms\`)
|
|
41
|
+
.status(200)
|
|
42
|
+
.json({
|
|
43
|
+
success: true,
|
|
44
|
+
result,
|
|
45
|
+
executionTime: Date.now() - startTime,
|
|
46
|
+
requestId,
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return res
|
|
50
|
+
.setHeader('X-Request-Id', requestId)
|
|
51
|
+
.status(500)
|
|
52
|
+
.json({
|
|
53
|
+
success: false,
|
|
54
|
+
error: {
|
|
55
|
+
code: 'EXECUTION_ERROR',
|
|
56
|
+
message: error instanceof Error ? error.message : String(error),
|
|
57
|
+
},
|
|
58
|
+
requestId,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
/**
|
|
64
|
+
* OpenAPI endpoint handler for Vercel
|
|
65
|
+
*/
|
|
66
|
+
const VERCEL_OPENAPI_HANDLER_TEMPLATE = `{{GENERATED_HEADER}}
|
|
67
|
+
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
68
|
+
import { openApiSpec } from '../openapi.js';
|
|
69
|
+
|
|
70
|
+
export const config = {
|
|
71
|
+
runtime: 'nodejs20.x',
|
|
72
|
+
maxDuration: 10,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|
76
|
+
if (req.method !== 'GET') {
|
|
77
|
+
return res.status(405).json({ error: 'Method not allowed' });
|
|
78
|
+
}
|
|
79
|
+
return res.status(200).json(openApiSpec);
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
/**
|
|
83
|
+
* Swagger UI docs endpoint handler for Vercel
|
|
84
|
+
*/
|
|
85
|
+
const VERCEL_DOCS_HANDLER_TEMPLATE = `{{GENERATED_HEADER}}
|
|
86
|
+
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
87
|
+
|
|
88
|
+
export const config = {
|
|
89
|
+
runtime: 'nodejs20.x',
|
|
90
|
+
maxDuration: 10,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const SWAGGER_UI_HTML = \`<!DOCTYPE html>
|
|
94
|
+
<html lang="en">
|
|
95
|
+
<head>
|
|
96
|
+
<meta charset="UTF-8">
|
|
97
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
98
|
+
<title>{{WORKFLOW_NAME}} API Documentation</title>
|
|
99
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css">
|
|
100
|
+
</head>
|
|
101
|
+
<body>
|
|
102
|
+
<div id="swagger-ui"></div>
|
|
103
|
+
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
|
|
104
|
+
<script>
|
|
105
|
+
SwaggerUIBundle({
|
|
106
|
+
url: '/api/openapi',
|
|
107
|
+
dom_id: '#swagger-ui',
|
|
108
|
+
presets: [SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset],
|
|
109
|
+
layout: 'BaseLayout'
|
|
110
|
+
});
|
|
111
|
+
</script>
|
|
112
|
+
</body>
|
|
113
|
+
</html>\`;
|
|
114
|
+
|
|
115
|
+
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|
116
|
+
if (req.method !== 'GET') {
|
|
117
|
+
return res.status(405).json({ error: 'Method not allowed' });
|
|
118
|
+
}
|
|
119
|
+
res.setHeader('Content-Type', 'text/html');
|
|
120
|
+
return res.status(200).send(SWAGGER_UI_HTML);
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
/**
|
|
124
|
+
* OpenAPI spec file template
|
|
125
|
+
*/
|
|
126
|
+
const OPENAPI_SPEC_TEMPLATE = `// Generated OpenAPI specification
|
|
127
|
+
export const openApiSpec = {{OPENAPI_SPEC}};
|
|
128
|
+
`;
|
|
129
|
+
/**
|
|
130
|
+
* Node type handler template for Vercel
|
|
131
|
+
*/
|
|
132
|
+
const VERCEL_NODE_TYPE_HANDLER_TEMPLATE = `{{GENERATED_HEADER}}
|
|
133
|
+
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
134
|
+
{{NODE_TYPE_IMPORTS}}
|
|
135
|
+
import { openApiSpec } from '../openapi.js';
|
|
136
|
+
|
|
137
|
+
export const config = {
|
|
138
|
+
runtime: 'nodejs20.x',
|
|
139
|
+
maxDuration: {{MAX_DURATION}},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Handler type for node type functions
|
|
143
|
+
type NodeTypeHandler = (execute: boolean, params: Record<string, unknown>) => unknown;
|
|
144
|
+
|
|
145
|
+
// Node type router
|
|
146
|
+
const nodeTypes: Record<string, NodeTypeHandler> = {
|
|
147
|
+
{{NODE_TYPE_ENTRIES}}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const SWAGGER_UI_HTML = \`<!DOCTYPE html>
|
|
151
|
+
<html lang="en">
|
|
152
|
+
<head>
|
|
153
|
+
<meta charset="UTF-8">
|
|
154
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
155
|
+
<title>{{SERVICE_NAME}} API Documentation</title>
|
|
156
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css">
|
|
157
|
+
</head>
|
|
158
|
+
<body>
|
|
159
|
+
<div id="swagger-ui"></div>
|
|
160
|
+
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
|
|
161
|
+
<script>
|
|
162
|
+
SwaggerUIBundle({
|
|
163
|
+
url: '/api/openapi.json',
|
|
164
|
+
dom_id: '#swagger-ui',
|
|
165
|
+
presets: [SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset],
|
|
166
|
+
layout: 'BaseLayout'
|
|
167
|
+
});
|
|
168
|
+
</script>
|
|
169
|
+
</body>
|
|
170
|
+
</html>\`;
|
|
171
|
+
|
|
172
|
+
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|
173
|
+
const { nodeType: nodeTypeName } = req.query;
|
|
174
|
+
const requestId = req.headers['x-vercel-id'] as string || crypto.randomUUID();
|
|
175
|
+
|
|
176
|
+
// Handle special routes
|
|
177
|
+
if (nodeTypeName === 'openapi.json' && req.method === 'GET') {
|
|
178
|
+
return res.status(200).json(openApiSpec);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (nodeTypeName === 'docs' && req.method === 'GET') {
|
|
182
|
+
res.setHeader('Content-Type', 'text/html');
|
|
183
|
+
return res.status(200).send(SWAGGER_UI_HTML);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Find node type
|
|
187
|
+
const nodeType = typeof nodeTypeName === 'string' ? nodeTypes[nodeTypeName] : undefined;
|
|
188
|
+
|
|
189
|
+
if (!nodeType) {
|
|
190
|
+
return res.status(404).json({
|
|
191
|
+
error: \`Node type '\${nodeTypeName}' not found\`,
|
|
192
|
+
availableNodeTypes: Object.keys(nodeTypes),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Only POST for node type execution
|
|
197
|
+
if (req.method !== 'POST') {
|
|
198
|
+
return res.status(405).json({
|
|
199
|
+
success: false,
|
|
200
|
+
error: { code: 'METHOD_NOT_ALLOWED', message: 'Only POST requests are allowed for node type execution' },
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
const params = req.body || {};
|
|
206
|
+
const startTime = Date.now();
|
|
207
|
+
|
|
208
|
+
const result = await nodeType(true, params);
|
|
209
|
+
|
|
210
|
+
return res
|
|
211
|
+
.setHeader('X-Request-Id', requestId)
|
|
212
|
+
.setHeader('X-Execution-Time', \`\${Date.now() - startTime}ms\`)
|
|
213
|
+
.status(200)
|
|
214
|
+
.json({
|
|
215
|
+
success: true,
|
|
216
|
+
result,
|
|
217
|
+
executionTime: Date.now() - startTime,
|
|
218
|
+
requestId,
|
|
219
|
+
});
|
|
220
|
+
} catch (error) {
|
|
221
|
+
return res
|
|
222
|
+
.setHeader('X-Request-Id', requestId)
|
|
223
|
+
.status(500)
|
|
224
|
+
.json({
|
|
225
|
+
success: false,
|
|
226
|
+
error: {
|
|
227
|
+
code: 'EXECUTION_ERROR',
|
|
228
|
+
message: error instanceof Error ? error.message : String(error),
|
|
229
|
+
},
|
|
230
|
+
requestId,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
`;
|
|
235
|
+
/**
|
|
236
|
+
* Multi-workflow router handler for Vercel
|
|
237
|
+
*/
|
|
238
|
+
const VERCEL_MULTI_HANDLER_TEMPLATE = `{{GENERATED_HEADER}}
|
|
239
|
+
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
240
|
+
{{WORKFLOW_IMPORTS}}
|
|
241
|
+
import { functionRegistry } from '../runtime/function-registry.js';
|
|
242
|
+
import '../runtime/builtin-functions.js';
|
|
243
|
+
import { openApiSpec } from '../openapi.js';
|
|
244
|
+
|
|
245
|
+
export const config = {
|
|
246
|
+
runtime: 'nodejs20.x',
|
|
247
|
+
maxDuration: {{MAX_DURATION}},
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// Handler type for workflow functions
|
|
251
|
+
type WorkflowHandler = (execute: boolean, params: Record<string, unknown>) => unknown;
|
|
252
|
+
|
|
253
|
+
// Workflow router
|
|
254
|
+
const workflows: Record<string, WorkflowHandler> = {
|
|
255
|
+
{{WORKFLOW_ENTRIES}}
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const SWAGGER_UI_HTML = \`<!DOCTYPE html>
|
|
259
|
+
<html lang="en">
|
|
260
|
+
<head>
|
|
261
|
+
<meta charset="UTF-8">
|
|
262
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
263
|
+
<title>{{SERVICE_NAME}} API Documentation</title>
|
|
264
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css">
|
|
265
|
+
</head>
|
|
266
|
+
<body>
|
|
267
|
+
<div id="swagger-ui"></div>
|
|
268
|
+
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
|
|
269
|
+
<script>
|
|
270
|
+
SwaggerUIBundle({
|
|
271
|
+
url: '/api/openapi.json',
|
|
272
|
+
dom_id: '#swagger-ui',
|
|
273
|
+
presets: [SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset],
|
|
274
|
+
layout: 'BaseLayout'
|
|
275
|
+
});
|
|
276
|
+
</script>
|
|
277
|
+
</body>
|
|
278
|
+
</html>\`;
|
|
279
|
+
|
|
280
|
+
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|
281
|
+
const { workflow: workflowName } = req.query;
|
|
282
|
+
const requestId = req.headers['x-vercel-id'] as string || crypto.randomUUID();
|
|
283
|
+
|
|
284
|
+
// Handle special routes
|
|
285
|
+
if (workflowName === 'openapi.json' && req.method === 'GET') {
|
|
286
|
+
return res.status(200).json(openApiSpec);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (workflowName === 'docs' && req.method === 'GET') {
|
|
290
|
+
res.setHeader('Content-Type', 'text/html');
|
|
291
|
+
return res.status(200).send(SWAGGER_UI_HTML);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (workflowName === 'functions' && req.method === 'GET') {
|
|
295
|
+
const category = req.query.category as string | undefined;
|
|
296
|
+
const functions = functionRegistry.list(category as any);
|
|
297
|
+
return res.status(200).json(functions);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Find workflow
|
|
301
|
+
const workflow = typeof workflowName === 'string' ? workflows[workflowName] : undefined;
|
|
302
|
+
|
|
303
|
+
if (!workflow) {
|
|
304
|
+
return res.status(404).json({
|
|
305
|
+
error: \`Workflow '\${workflowName}' not found\`,
|
|
306
|
+
availableWorkflows: Object.keys(workflows),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Only POST for workflow execution
|
|
311
|
+
if (req.method !== 'POST') {
|
|
312
|
+
return res.status(405).json({
|
|
313
|
+
success: false,
|
|
314
|
+
error: { code: 'METHOD_NOT_ALLOWED', message: 'Only POST requests are allowed for workflow execution' },
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
try {
|
|
319
|
+
const params = req.body || {};
|
|
320
|
+
const startTime = Date.now();
|
|
321
|
+
|
|
322
|
+
const result = await workflow(true, params);
|
|
323
|
+
|
|
324
|
+
return res
|
|
325
|
+
.setHeader('X-Request-Id', requestId)
|
|
326
|
+
.setHeader('X-Execution-Time', \`\${Date.now() - startTime}ms\`)
|
|
327
|
+
.status(200)
|
|
328
|
+
.json({
|
|
329
|
+
success: true,
|
|
330
|
+
result,
|
|
331
|
+
executionTime: Date.now() - startTime,
|
|
332
|
+
requestId,
|
|
333
|
+
});
|
|
334
|
+
} catch (error) {
|
|
335
|
+
return res
|
|
336
|
+
.setHeader('X-Request-Id', requestId)
|
|
337
|
+
.status(500)
|
|
338
|
+
.json({
|
|
339
|
+
success: false,
|
|
340
|
+
error: {
|
|
341
|
+
code: 'EXECUTION_ERROR',
|
|
342
|
+
message: error instanceof Error ? error.message : String(error),
|
|
343
|
+
},
|
|
344
|
+
requestId,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
`;
|
|
349
|
+
/**
|
|
350
|
+
* Bundle handler template for Vercel - unified workflows and node types
|
|
351
|
+
*/
|
|
352
|
+
const VERCEL_BUNDLE_HANDLER_TEMPLATE = `{{GENERATED_HEADER}}
|
|
353
|
+
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
354
|
+
{{WORKFLOW_IMPORTS}}
|
|
355
|
+
{{NODE_TYPE_IMPORTS}}
|
|
356
|
+
import { functionRegistry } from '../runtime/function-registry.js';
|
|
357
|
+
import '../runtime/builtin-functions.js';
|
|
358
|
+
import { openApiSpec } from '../openapi.js';
|
|
359
|
+
|
|
360
|
+
export const config = {
|
|
361
|
+
runtime: 'nodejs20.x',
|
|
362
|
+
maxDuration: {{MAX_DURATION}},
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// Handler type for workflow/nodeType functions
|
|
366
|
+
type FunctionHandler = (execute: boolean, params: Record<string, unknown>) => unknown;
|
|
367
|
+
|
|
368
|
+
// Exposed workflows (have HTTP endpoints)
|
|
369
|
+
const exposedWorkflows: Record<string, FunctionHandler> = {
|
|
370
|
+
{{EXPOSED_WORKFLOW_ENTRIES}}
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
// Exposed node types (have HTTP endpoints)
|
|
374
|
+
const exposedNodeTypes: Record<string, FunctionHandler> = {
|
|
375
|
+
{{EXPOSED_NODE_TYPE_ENTRIES}}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const SWAGGER_UI_HTML = \`<!DOCTYPE html>
|
|
379
|
+
<html lang="en">
|
|
380
|
+
<head>
|
|
381
|
+
<meta charset="UTF-8">
|
|
382
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
383
|
+
<title>{{SERVICE_NAME}} API Documentation</title>
|
|
384
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css">
|
|
385
|
+
</head>
|
|
386
|
+
<body>
|
|
387
|
+
<div id="swagger-ui"></div>
|
|
388
|
+
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
|
|
389
|
+
<script>
|
|
390
|
+
SwaggerUIBundle({
|
|
391
|
+
url: '/api/openapi.json',
|
|
392
|
+
dom_id: '#swagger-ui',
|
|
393
|
+
presets: [SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset],
|
|
394
|
+
layout: 'BaseLayout'
|
|
395
|
+
});
|
|
396
|
+
</script>
|
|
397
|
+
</body>
|
|
398
|
+
</html>\`;
|
|
399
|
+
|
|
400
|
+
export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|
401
|
+
const requestId = req.headers['x-vercel-id'] as string || crypto.randomUUID();
|
|
402
|
+
const url = new URL(req.url || '/', \`http://\${req.headers.host}\`);
|
|
403
|
+
const pathParts = url.pathname.split('/').filter(Boolean);
|
|
404
|
+
|
|
405
|
+
// Handle special routes
|
|
406
|
+
if (pathParts[1] === 'openapi.json' && req.method === 'GET') {
|
|
407
|
+
return res.status(200).json(openApiSpec);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (pathParts[1] === 'docs' && req.method === 'GET') {
|
|
411
|
+
res.setHeader('Content-Type', 'text/html');
|
|
412
|
+
return res.status(200).send(SWAGGER_UI_HTML);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (pathParts[1] === 'functions' && req.method === 'GET') {
|
|
416
|
+
const category = req.query.category as string | undefined;
|
|
417
|
+
const functions = functionRegistry.list(category as any);
|
|
418
|
+
return res.status(200).json(functions);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Route to workflow: /api/workflows/{name}
|
|
422
|
+
if (pathParts[1] === 'workflows' && pathParts[2]) {
|
|
423
|
+
const workflowName = pathParts[2];
|
|
424
|
+
const workflow = exposedWorkflows[workflowName];
|
|
425
|
+
|
|
426
|
+
if (!workflow) {
|
|
427
|
+
return res.status(404).json({
|
|
428
|
+
error: \`Workflow '\${workflowName}' not found\`,
|
|
429
|
+
availableWorkflows: Object.keys(exposedWorkflows),
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (req.method !== 'POST') {
|
|
434
|
+
return res.status(405).json({
|
|
435
|
+
success: false,
|
|
436
|
+
error: { code: 'METHOD_NOT_ALLOWED', message: 'Only POST requests are allowed for workflow execution' },
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
try {
|
|
441
|
+
const params = req.body || {};
|
|
442
|
+
const startTime = Date.now();
|
|
443
|
+
const result = await workflow(true, params);
|
|
444
|
+
|
|
445
|
+
return res
|
|
446
|
+
.setHeader('X-Request-Id', requestId)
|
|
447
|
+
.setHeader('X-Execution-Time', \`\${Date.now() - startTime}ms\`)
|
|
448
|
+
.status(200)
|
|
449
|
+
.json({
|
|
450
|
+
success: true,
|
|
451
|
+
result,
|
|
452
|
+
executionTime: Date.now() - startTime,
|
|
453
|
+
requestId,
|
|
454
|
+
});
|
|
455
|
+
} catch (error) {
|
|
456
|
+
return res
|
|
457
|
+
.setHeader('X-Request-Id', requestId)
|
|
458
|
+
.status(500)
|
|
459
|
+
.json({
|
|
460
|
+
success: false,
|
|
461
|
+
error: { code: 'EXECUTION_ERROR', message: error instanceof Error ? error.message : String(error) },
|
|
462
|
+
requestId,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Route to node type: /api/nodes/{name}
|
|
468
|
+
if (pathParts[1] === 'nodes' && pathParts[2]) {
|
|
469
|
+
const nodeTypeName = pathParts[2];
|
|
470
|
+
const nodeType = exposedNodeTypes[nodeTypeName];
|
|
471
|
+
|
|
472
|
+
if (!nodeType) {
|
|
473
|
+
return res.status(404).json({
|
|
474
|
+
error: \`Node type '\${nodeTypeName}' not found\`,
|
|
475
|
+
availableNodeTypes: Object.keys(exposedNodeTypes),
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (req.method !== 'POST') {
|
|
480
|
+
return res.status(405).json({
|
|
481
|
+
success: false,
|
|
482
|
+
error: { code: 'METHOD_NOT_ALLOWED', message: 'Only POST requests are allowed for node type execution' },
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
try {
|
|
487
|
+
const params = req.body || {};
|
|
488
|
+
const startTime = Date.now();
|
|
489
|
+
const result = await nodeType(true, params);
|
|
490
|
+
|
|
491
|
+
return res
|
|
492
|
+
.setHeader('X-Request-Id', requestId)
|
|
493
|
+
.setHeader('X-Execution-Time', \`\${Date.now() - startTime}ms\`)
|
|
494
|
+
.status(200)
|
|
495
|
+
.json({
|
|
496
|
+
success: true,
|
|
497
|
+
result,
|
|
498
|
+
executionTime: Date.now() - startTime,
|
|
499
|
+
requestId,
|
|
500
|
+
});
|
|
501
|
+
} catch (error) {
|
|
502
|
+
return res
|
|
503
|
+
.setHeader('X-Request-Id', requestId)
|
|
504
|
+
.status(500)
|
|
505
|
+
.json({
|
|
506
|
+
success: false,
|
|
507
|
+
error: { code: 'EXECUTION_ERROR', message: error instanceof Error ? error.message : String(error) },
|
|
508
|
+
requestId,
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return res.status(404).json({ error: 'Not found' });
|
|
514
|
+
}
|
|
515
|
+
`;
|
|
516
|
+
/**
|
|
517
|
+
* Vercel export target
|
|
518
|
+
*/
|
|
519
|
+
export class VercelTarget extends BaseExportTarget {
|
|
520
|
+
name = 'vercel';
|
|
521
|
+
description = 'Vercel Serverless Functions';
|
|
522
|
+
async generate(options) {
|
|
523
|
+
const files = [];
|
|
524
|
+
const maxDuration = options.targetOptions?.maxDuration || 60;
|
|
525
|
+
const includeDocs = options.includeDocs ?? false;
|
|
526
|
+
// Generate handler - filename becomes the route
|
|
527
|
+
const handlerContent = VERCEL_HANDLER_TEMPLATE
|
|
528
|
+
.replace('{{GENERATED_HEADER}}', getGeneratedBranding().header('export --target vercel'))
|
|
529
|
+
.replace('{{WORKFLOW_IMPORT}}', `import { ${options.workflowName} } from '../workflow.js';`)
|
|
530
|
+
.replace(/\{\{FUNCTION_NAME\}\}/g, options.workflowName)
|
|
531
|
+
.replace('{{MAX_DURATION}}', String(maxDuration));
|
|
532
|
+
// Vercel uses file-based routing under api/
|
|
533
|
+
const handlerFileName = `api/${options.displayName}.ts`;
|
|
534
|
+
files.push(this.createFile(options.outputDir, handlerFileName, handlerContent, 'handler'));
|
|
535
|
+
// Generate docs handlers if enabled
|
|
536
|
+
if (includeDocs) {
|
|
537
|
+
// OpenAPI spec file
|
|
538
|
+
const openApiSpec = this.generateOpenAPISpec(options);
|
|
539
|
+
const openApiContent = OPENAPI_SPEC_TEMPLATE.replace('{{OPENAPI_SPEC}}', JSON.stringify(openApiSpec, null, 2));
|
|
540
|
+
files.push(this.createFile(options.outputDir, 'openapi.ts', openApiContent, 'config'));
|
|
541
|
+
// OpenAPI endpoint handler
|
|
542
|
+
const openApiHandlerContent = VERCEL_OPENAPI_HANDLER_TEMPLATE
|
|
543
|
+
.replace('{{GENERATED_HEADER}}', getGeneratedBranding().header('export --target vercel --docs'));
|
|
544
|
+
files.push(this.createFile(options.outputDir, 'api/openapi.ts', openApiHandlerContent, 'handler'));
|
|
545
|
+
// Docs endpoint handler
|
|
546
|
+
const docsContent = VERCEL_DOCS_HANDLER_TEMPLATE
|
|
547
|
+
.replace('{{GENERATED_HEADER}}', getGeneratedBranding().header('export --target vercel --docs'))
|
|
548
|
+
.replace(/\{\{WORKFLOW_NAME\}\}/g, options.displayName);
|
|
549
|
+
files.push(this.createFile(options.outputDir, 'api/docs.ts', docsContent, 'handler'));
|
|
550
|
+
}
|
|
551
|
+
// Generate package.json
|
|
552
|
+
const packageJson = this.generatePackageJson({
|
|
553
|
+
name: options.displayName,
|
|
554
|
+
description: options.description,
|
|
555
|
+
scripts: {
|
|
556
|
+
dev: 'vercel dev',
|
|
557
|
+
deploy: 'vercel deploy',
|
|
558
|
+
},
|
|
559
|
+
devDependencies: {
|
|
560
|
+
'@vercel/node': '^3.0.0',
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
files.push(this.createFile(options.outputDir, 'package.json', packageJson, 'package'));
|
|
564
|
+
// Generate vercel.json
|
|
565
|
+
const functionsConfig = {
|
|
566
|
+
[`api/${options.displayName}.ts`]: {
|
|
567
|
+
memory: 1024,
|
|
568
|
+
maxDuration,
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
if (includeDocs) {
|
|
572
|
+
functionsConfig['api/openapi.ts'] = { memory: 256, maxDuration: 10 };
|
|
573
|
+
functionsConfig['api/docs.ts'] = { memory: 256, maxDuration: 10 };
|
|
574
|
+
}
|
|
575
|
+
const vercelConfig = { functions: functionsConfig };
|
|
576
|
+
files.push(this.createFile(options.outputDir, 'vercel.json', JSON.stringify(vercelConfig, null, 2), 'config'));
|
|
577
|
+
// Generate README from deploy instructions
|
|
578
|
+
const artifacts = { files, target: this.name, workflowName: options.displayName, entryPoint: handlerFileName };
|
|
579
|
+
const instructions = this.getDeployInstructions(artifacts);
|
|
580
|
+
const readme = this.generateReadme(instructions, options.displayName, 'Vercel');
|
|
581
|
+
files.push(this.createFile(options.outputDir, 'README.md', readme, 'other'));
|
|
582
|
+
return artifacts;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Generate OpenAPI specification for the workflow
|
|
586
|
+
*/
|
|
587
|
+
generateOpenAPISpec(options) {
|
|
588
|
+
return {
|
|
589
|
+
openapi: '3.0.3',
|
|
590
|
+
info: {
|
|
591
|
+
title: `${options.displayName} API`,
|
|
592
|
+
version: '1.0.0',
|
|
593
|
+
description: options.description || `API for the ${options.displayName} workflow`,
|
|
594
|
+
},
|
|
595
|
+
servers: [{ url: '/api', description: 'Vercel API routes' }],
|
|
596
|
+
paths: {
|
|
597
|
+
[`/${options.displayName}`]: {
|
|
598
|
+
post: {
|
|
599
|
+
operationId: `execute_${options.workflowName}`,
|
|
600
|
+
summary: `Execute ${options.displayName} workflow`,
|
|
601
|
+
description: options.description || `Execute the ${options.displayName} workflow`,
|
|
602
|
+
tags: ['workflows'],
|
|
603
|
+
requestBody: {
|
|
604
|
+
description: 'Workflow input parameters',
|
|
605
|
+
required: true,
|
|
606
|
+
content: {
|
|
607
|
+
'application/json': {
|
|
608
|
+
schema: { type: 'object' },
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
responses: {
|
|
613
|
+
'200': {
|
|
614
|
+
description: 'Successful workflow execution',
|
|
615
|
+
content: {
|
|
616
|
+
'application/json': {
|
|
617
|
+
schema: {
|
|
618
|
+
type: 'object',
|
|
619
|
+
properties: {
|
|
620
|
+
success: { type: 'boolean' },
|
|
621
|
+
result: { type: 'object' },
|
|
622
|
+
executionTime: { type: 'number' },
|
|
623
|
+
requestId: { type: 'string' },
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
'500': {
|
|
630
|
+
description: 'Execution error',
|
|
631
|
+
content: {
|
|
632
|
+
'application/json': {
|
|
633
|
+
schema: {
|
|
634
|
+
type: 'object',
|
|
635
|
+
properties: {
|
|
636
|
+
success: { type: 'boolean' },
|
|
637
|
+
error: { type: 'object' },
|
|
638
|
+
requestId: { type: 'string' },
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
tags: [{ name: 'workflows', description: 'Workflow execution endpoints' }],
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
async generateMultiWorkflow(workflows, options) {
|
|
652
|
+
const files = [];
|
|
653
|
+
const maxDuration = options.targetOptions?.maxDuration || 60;
|
|
654
|
+
const serviceName = options.displayName || 'multi-workflow-service';
|
|
655
|
+
// Generate workflow imports and entries
|
|
656
|
+
const workflowImports = workflows
|
|
657
|
+
.map((w) => `import { ${w.functionName} } from '../workflows/${w.name}.js';`)
|
|
658
|
+
.join('\n');
|
|
659
|
+
const workflowEntries = workflows.map((w) => ` '${w.name}': ${w.functionName},`).join('\n');
|
|
660
|
+
// Generate multi-workflow handler
|
|
661
|
+
const handlerContent = VERCEL_MULTI_HANDLER_TEMPLATE
|
|
662
|
+
.replace('{{GENERATED_HEADER}}', getGeneratedBranding().header('export --target vercel --multi'))
|
|
663
|
+
.replace('{{WORKFLOW_IMPORTS}}', workflowImports)
|
|
664
|
+
.replace('{{WORKFLOW_ENTRIES}}', workflowEntries)
|
|
665
|
+
.replace(/\{\{SERVICE_NAME\}\}/g, serviceName)
|
|
666
|
+
.replace('{{MAX_DURATION}}', String(maxDuration));
|
|
667
|
+
// Vercel catch-all route handler
|
|
668
|
+
files.push(this.createFile(options.outputDir, 'api/[workflow].ts', handlerContent, 'handler'));
|
|
669
|
+
// Generate consolidated OpenAPI spec
|
|
670
|
+
const openApiSpec = this.generateConsolidatedOpenAPI(workflows, {
|
|
671
|
+
title: `${serviceName} API`,
|
|
672
|
+
version: '1.0.0',
|
|
673
|
+
baseUrl: '/api',
|
|
674
|
+
});
|
|
675
|
+
const openApiContent = `// Generated OpenAPI specification
|
|
676
|
+
export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
677
|
+
`;
|
|
678
|
+
files.push(this.createFile(options.outputDir, 'openapi.ts', openApiContent, 'config'));
|
|
679
|
+
// Generate vercel.json with rewrites
|
|
680
|
+
const vercelConfig = {
|
|
681
|
+
functions: {
|
|
682
|
+
'api/[workflow].ts': {
|
|
683
|
+
memory: 1024,
|
|
684
|
+
maxDuration,
|
|
685
|
+
},
|
|
686
|
+
},
|
|
687
|
+
};
|
|
688
|
+
files.push(this.createFile(options.outputDir, 'vercel.json', JSON.stringify(vercelConfig, null, 2), 'config'));
|
|
689
|
+
// Generate workflow content files
|
|
690
|
+
files.push(...this.generateWorkflowContentFiles(workflows, options.outputDir));
|
|
691
|
+
return {
|
|
692
|
+
files,
|
|
693
|
+
target: this.name,
|
|
694
|
+
workflowName: serviceName,
|
|
695
|
+
workflowNames: workflows.map((w) => w.name),
|
|
696
|
+
entryPoint: 'api/[workflow].ts',
|
|
697
|
+
openApiSpec,
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
async generateNodeTypeService(nodeTypes, options) {
|
|
701
|
+
const files = [];
|
|
702
|
+
const maxDuration = 60;
|
|
703
|
+
const serviceName = options.serviceName || 'node-type-service';
|
|
704
|
+
// Generate node type imports and entries
|
|
705
|
+
// Use lowercase functionName for import paths to match the generated file names
|
|
706
|
+
const nodeTypeImports = nodeTypes
|
|
707
|
+
.map((nt) => `import { ${nt.functionName} } from '../node-types/${nt.functionName.toLowerCase()}.js';`)
|
|
708
|
+
.join('\n');
|
|
709
|
+
const nodeTypeEntries = nodeTypes.map((nt) => ` '${nt.name}': ${nt.functionName},`).join('\n');
|
|
710
|
+
// Generate node type handler
|
|
711
|
+
const handlerContent = VERCEL_NODE_TYPE_HANDLER_TEMPLATE
|
|
712
|
+
.replace('{{GENERATED_HEADER}}', getGeneratedBranding().header('export --target vercel --node-types'))
|
|
713
|
+
.replace('{{NODE_TYPE_IMPORTS}}', nodeTypeImports)
|
|
714
|
+
.replace('{{NODE_TYPE_ENTRIES}}', nodeTypeEntries)
|
|
715
|
+
.replace(/\{\{SERVICE_NAME\}\}/g, serviceName)
|
|
716
|
+
.replace('{{MAX_DURATION}}', String(maxDuration));
|
|
717
|
+
// Vercel catch-all route handler
|
|
718
|
+
files.push(this.createFile(options.outputDir, 'api/[nodeType].ts', handlerContent, 'handler'));
|
|
719
|
+
// Generate OpenAPI spec
|
|
720
|
+
const openApiSpec = this.generateNodeTypeOpenAPI(nodeTypes, {
|
|
721
|
+
title: `${serviceName} API`,
|
|
722
|
+
version: '1.0.0',
|
|
723
|
+
baseUrl: '/api',
|
|
724
|
+
});
|
|
725
|
+
const openApiContent = `// Generated OpenAPI specification
|
|
726
|
+
export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
727
|
+
`;
|
|
728
|
+
files.push(this.createFile(options.outputDir, 'openapi.ts', openApiContent, 'config'));
|
|
729
|
+
// Generate vercel.json
|
|
730
|
+
const vercelConfig = {
|
|
731
|
+
functions: {
|
|
732
|
+
'api/[nodeType].ts': {
|
|
733
|
+
memory: 1024,
|
|
734
|
+
maxDuration,
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
};
|
|
738
|
+
files.push(this.createFile(options.outputDir, 'vercel.json', JSON.stringify(vercelConfig, null, 2), 'config'));
|
|
739
|
+
// Generate node-type content files
|
|
740
|
+
files.push(...this.generateNodeTypeContentFiles(nodeTypes, options.outputDir));
|
|
741
|
+
return {
|
|
742
|
+
files,
|
|
743
|
+
target: this.name,
|
|
744
|
+
workflowName: serviceName,
|
|
745
|
+
nodeTypeNames: nodeTypes.map((nt) => nt.name),
|
|
746
|
+
entryPoint: 'api/[nodeType].ts',
|
|
747
|
+
openApiSpec,
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
async generateBundle(workflows, nodeTypes, options) {
|
|
751
|
+
const files = [];
|
|
752
|
+
const maxDuration = options.targetOptions?.maxDuration || 60;
|
|
753
|
+
const serviceName = options.displayName || 'bundle-service';
|
|
754
|
+
// Filter to only include items that have generated code
|
|
755
|
+
// Also skip npm imports (names containing '/') as they should be installed via package.json
|
|
756
|
+
const workflowsWithCode = workflows.filter((w) => w.code);
|
|
757
|
+
const nodeTypesWithCode = nodeTypes.filter((nt) => nt.code && !nt.name.includes('/'));
|
|
758
|
+
// Separate exposed and bundled-only items
|
|
759
|
+
const exposedWorkflows = workflows.filter((w) => w.expose);
|
|
760
|
+
const exposedNodeTypes = nodeTypes.filter((nt) => nt.expose);
|
|
761
|
+
// Detect name collisions between workflows and nodeTypes
|
|
762
|
+
const workflowNames = new Set(workflowsWithCode.map((w) => w.functionName));
|
|
763
|
+
const nodeTypeAliases = new Map();
|
|
764
|
+
for (const nt of nodeTypesWithCode) {
|
|
765
|
+
if (workflowNames.has(nt.functionName)) {
|
|
766
|
+
nodeTypeAliases.set(nt.functionName, `${nt.functionName}_nodeType`);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
// Generate all workflow imports (both exposed and bundled-only) - only for those with code
|
|
770
|
+
const workflowImports = workflowsWithCode.length > 0
|
|
771
|
+
? workflowsWithCode
|
|
772
|
+
.map((w) => `import { ${w.functionName} } from '../workflows/${w.name}.js';`)
|
|
773
|
+
.join('\n')
|
|
774
|
+
: '// No workflows';
|
|
775
|
+
// Generate all node type imports (both exposed and bundled-only) with aliases for collisions - only for those with code
|
|
776
|
+
// Use lowercase functionName for import paths to match the generated file names
|
|
777
|
+
const nodeTypeImports = nodeTypesWithCode.length > 0
|
|
778
|
+
? nodeTypesWithCode
|
|
779
|
+
.map((nt) => {
|
|
780
|
+
const alias = nodeTypeAliases.get(nt.functionName);
|
|
781
|
+
const lowerFunctionName = nt.functionName.toLowerCase();
|
|
782
|
+
if (alias) {
|
|
783
|
+
return `import { ${nt.functionName} as ${alias} } from '../node-types/${lowerFunctionName}.js';`;
|
|
784
|
+
}
|
|
785
|
+
return `import { ${nt.functionName} } from '../node-types/${lowerFunctionName}.js';`;
|
|
786
|
+
})
|
|
787
|
+
.join('\n')
|
|
788
|
+
: '// No node types';
|
|
789
|
+
// Filter exposed items to only include those with code
|
|
790
|
+
const exposedWorkflowsWithCode = exposedWorkflows.filter((w) => w.code);
|
|
791
|
+
const exposedNodeTypesWithCode = exposedNodeTypes.filter((nt) => nt.code);
|
|
792
|
+
// Generate entries only for exposed items with code
|
|
793
|
+
const exposedWorkflowEntries = exposedWorkflowsWithCode.length > 0
|
|
794
|
+
? exposedWorkflowsWithCode.map((w) => ` '${w.name}': ${w.functionName},`).join('\n')
|
|
795
|
+
: ' // No exposed workflows';
|
|
796
|
+
const exposedNodeTypeEntries = exposedNodeTypesWithCode.length > 0
|
|
797
|
+
? exposedNodeTypesWithCode
|
|
798
|
+
.map((nt) => {
|
|
799
|
+
const alias = nodeTypeAliases.get(nt.functionName);
|
|
800
|
+
return ` '${nt.name}': ${alias || nt.functionName},`;
|
|
801
|
+
})
|
|
802
|
+
.join('\n')
|
|
803
|
+
: ' // No exposed node types';
|
|
804
|
+
// Generate bundle handler
|
|
805
|
+
const handlerContent = VERCEL_BUNDLE_HANDLER_TEMPLATE
|
|
806
|
+
.replace('{{GENERATED_HEADER}}', getGeneratedBranding().header('export --target vercel --bundle'))
|
|
807
|
+
.replace('{{WORKFLOW_IMPORTS}}', workflowImports)
|
|
808
|
+
.replace('{{NODE_TYPE_IMPORTS}}', nodeTypeImports)
|
|
809
|
+
.replace('{{EXPOSED_WORKFLOW_ENTRIES}}', exposedWorkflowEntries)
|
|
810
|
+
.replace('{{EXPOSED_NODE_TYPE_ENTRIES}}', exposedNodeTypeEntries)
|
|
811
|
+
.replace(/\{\{SERVICE_NAME\}\}/g, serviceName)
|
|
812
|
+
.replace('{{MAX_DURATION}}', String(maxDuration));
|
|
813
|
+
// Vercel catch-all route handler
|
|
814
|
+
files.push(this.createFile(options.outputDir, 'api/[...path].ts', handlerContent, 'handler'));
|
|
815
|
+
// Generate OpenAPI spec for exposed items only
|
|
816
|
+
const openApiSpec = this.generateBundleOpenAPI(workflows, nodeTypes, {
|
|
817
|
+
title: `${serviceName} API`,
|
|
818
|
+
version: '1.0.0',
|
|
819
|
+
baseUrl: '/api',
|
|
820
|
+
});
|
|
821
|
+
const openApiContent = `// Generated OpenAPI specification
|
|
822
|
+
export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
823
|
+
`;
|
|
824
|
+
files.push(this.createFile(options.outputDir, 'openapi.ts', openApiContent, 'config'));
|
|
825
|
+
// Generate vercel.json
|
|
826
|
+
const vercelConfig = {
|
|
827
|
+
functions: {
|
|
828
|
+
'api/[...path].ts': {
|
|
829
|
+
memory: 1024,
|
|
830
|
+
maxDuration,
|
|
831
|
+
},
|
|
832
|
+
},
|
|
833
|
+
};
|
|
834
|
+
files.push(this.createFile(options.outputDir, 'vercel.json', JSON.stringify(vercelConfig, null, 2), 'config'));
|
|
835
|
+
// Generate shared runtime types module (workflows import from this)
|
|
836
|
+
const isProduction = options.production ?? true;
|
|
837
|
+
const runtimeTypesContent = generateStandaloneRuntimeModule(isProduction, 'esm');
|
|
838
|
+
files.push(this.createFile(options.outputDir, 'runtime/types.ts', runtimeTypesContent, 'other'));
|
|
839
|
+
// Generate real runtime files (function registry, builtin functions, parameter resolver)
|
|
840
|
+
files.push(...this.generateRuntimeFiles(options.outputDir, workflows, nodeTypes));
|
|
841
|
+
// Generate workflow and node-type content files
|
|
842
|
+
files.push(...this.generateBundleContentFiles(workflows, nodeTypes, options.outputDir));
|
|
843
|
+
return {
|
|
844
|
+
files,
|
|
845
|
+
target: this.name,
|
|
846
|
+
workflowName: serviceName,
|
|
847
|
+
workflowNames: workflows.map((w) => w.name),
|
|
848
|
+
nodeTypeNames: nodeTypes.map((nt) => nt.name),
|
|
849
|
+
entryPoint: 'api/[...path].ts',
|
|
850
|
+
openApiSpec,
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
getDeployInstructions(artifacts) {
|
|
854
|
+
const outputDir = artifacts.files[0]?.absolutePath
|
|
855
|
+
? artifacts.files[0].absolutePath.replace(/\/[^/]+$/, '')
|
|
856
|
+
: '.';
|
|
857
|
+
const steps = [
|
|
858
|
+
`cd ${outputDir}`,
|
|
859
|
+
'npm install',
|
|
860
|
+
'vercel deploy',
|
|
861
|
+
];
|
|
862
|
+
return {
|
|
863
|
+
title: 'Deploy to Vercel',
|
|
864
|
+
prerequisites: ['Vercel CLI installed (npm install -g vercel)', 'Vercel account'],
|
|
865
|
+
steps,
|
|
866
|
+
localTestSteps: [
|
|
867
|
+
`cd ${outputDir}`,
|
|
868
|
+
'npm install',
|
|
869
|
+
'npm run dev',
|
|
870
|
+
'# API will be available at http://localhost:3000',
|
|
871
|
+
`# Test with: curl -X POST http://localhost:3000/api/${artifacts.workflowName} -H "Content-Type: application/json" -d '{"key": "value"}'`,
|
|
872
|
+
],
|
|
873
|
+
links: [
|
|
874
|
+
{
|
|
875
|
+
label: 'Vercel Serverless Functions',
|
|
876
|
+
url: 'https://vercel.com/docs/functions/serverless-functions',
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
label: 'Vercel CLI',
|
|
880
|
+
url: 'https://vercel.com/docs/cli',
|
|
881
|
+
},
|
|
882
|
+
],
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
//# sourceMappingURL=vercel.js.map
|