@synergenius/flow-weaver 0.33.1 → 0.44.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 +201 -226
- package/NOTICE +13 -0
- package/README.md +152 -244
- package/dist/agent/agent-loop.d.ts +4 -2
- package/dist/agent/cli-session.d.ts +3 -3
- package/dist/agent/cli-session.js +511 -438
- package/dist/agent/cli-spawn-config.d.ts +4 -4
- package/dist/agent/gate.d.ts +164 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +174 -28
- package/dist/agent/mcp-bridge.d.ts +1 -1
- package/dist/agent/mcp-bridge.js +114 -128
- package/dist/agent/mcp-tool-server.d.ts +2 -2
- package/dist/agent/mcp-tool-server.js +147 -189
- package/dist/agent/profiles.d.ts +69 -0
- package/dist/agent/providers/anthropic.d.ts +2 -4
- package/dist/agent/providers/claude-cli.d.ts +4 -5
- package/dist/agent/providers/openai-compat.d.ts +8 -1
- package/dist/agent/streaming.d.ts +2 -2
- package/dist/agent/types.d.ts +16 -10
- package/dist/api/builder.d.ts +3 -3
- package/dist/api/compile.d.ts +9 -4
- package/dist/api/durable-validation.d.ts +15 -0
- package/dist/api/generate-in-place.d.ts +21 -19
- package/dist/api/generate.d.ts +21 -16
- package/dist/api/generated-module/local-node-functions.d.ts +24 -0
- package/dist/api/generated-module/module-format.d.ts +23 -0
- package/dist/api/generated-module/module-writer.d.ts +34 -0
- package/dist/api/generated-module/node-type-imports.d.ts +39 -0
- package/dist/api/generated-module/preamble.d.ts +16 -0
- package/dist/api/generated-module/workflow-functions.d.ts +29 -0
- package/dist/api/graph-identity.d.ts +39 -0
- package/dist/api/helpers.d.ts +4 -60
- package/dist/api/in-place/built-in-nodes.d.ts +18 -0
- package/dist/api/in-place/function-body.d.ts +21 -0
- package/dist/api/in-place/fw-imports.d.ts +30 -0
- package/dist/api/in-place/macro-coverage.d.ts +14 -0
- package/dist/api/in-place/node-type-functions.d.ts +18 -0
- package/dist/api/in-place/node-type-jsdoc.d.ts +20 -0
- package/dist/api/in-place/orphaned-node-types.d.ts +16 -0
- package/dist/api/in-place/runtime-section.d.ts +16 -0
- package/dist/api/in-place/signature.d.ts +47 -0
- package/dist/api/in-place/source-file.d.ts +19 -0
- package/dist/api/in-place/workflow-jsdoc.d.ts +19 -0
- package/dist/api/index.d.ts +18 -21
- package/dist/api/index.js +259 -53
- package/dist/api/inline-engine.generated.d.ts +3 -0
- package/dist/api/inline-runtime.d.ts +10 -2
- package/dist/api/manipulation/connections.d.ts +1 -1
- package/dist/api/manipulation/index.d.ts +8 -8
- package/dist/api/manipulation/node-types.d.ts +1 -1
- package/dist/api/manipulation/nodes.d.ts +3 -13
- package/dist/api/manipulation/ports.d.ts +1 -1
- package/dist/api/manipulation/scopes.d.ts +1 -1
- package/dist/api/manipulation/workflow.d.ts +1 -1
- package/dist/api/modify-operation.d.ts +0 -2
- package/dist/api/parse.d.ts +22 -1
- package/dist/api/port-references.d.ts +66 -0
- package/dist/api/query.d.ts +18 -2
- package/dist/api/templates.d.ts +1 -1
- package/dist/api/transform.d.ts +1 -1
- package/dist/api/validate.d.ts +1 -1
- package/dist/api/validation-registry.d.ts +2 -2
- package/dist/artifacts/brief.d.ts +43 -0
- package/dist/artifacts/index.d.ts +31 -0
- package/dist/artifacts/pdf.d.ts +19 -0
- package/dist/ast/builder.d.ts +3 -3
- package/dist/ast/index.d.ts +4 -4
- package/dist/ast/index.js +60 -5
- package/dist/ast/serialization-node.d.ts +1 -1
- package/dist/ast/serialization.d.ts +1 -1
- package/dist/ast/types.d.ts +82 -291
- package/dist/ast/workflow-utils.d.ts +4 -4
- package/dist/built-in-nodes/coercion-types.d.ts +1 -1
- package/dist/built-in-nodes/delay.d.ts +3 -1
- package/dist/built-in-nodes/generated-registry.d.ts +1 -1
- package/dist/built-in-nodes/index.d.ts +6 -5
- package/dist/built-in-nodes/index.js +79 -5
- package/dist/built-in-nodes/invoke-workflow.d.ts +2 -1
- package/dist/built-in-nodes/mock-types.d.ts +45 -14
- package/dist/built-in-nodes/sleep.d.ts +12 -0
- package/dist/built-in-nodes/wait-for-agent.d.ts +2 -1
- package/dist/built-in-nodes/wait-for-event.d.ts +2 -1
- package/dist/chevrotain-parser/coerce-parser.d.ts +1 -1
- package/dist/chevrotain-parser/connect-parser.d.ts +1 -1
- package/dist/chevrotain-parser/grammar-diagrams.d.ts +1 -1
- package/dist/chevrotain-parser/index.d.ts +20 -23
- package/dist/chevrotain-parser/node-parser.d.ts +7 -8
- package/dist/chevrotain-parser/parse-line.d.ts +54 -0
- package/dist/chevrotain-parser/tokens.d.ts +0 -17
- package/dist/chevrotain-parser/trigger-cancel-parser.d.ts +6 -1
- package/dist/chunks/chunk-4EUSHAY6.js +298 -0
- package/dist/chunks/chunk-4KDUEOFD.js +197 -0
- package/dist/chunks/chunk-5Y3AIUWY.js +911 -0
- package/dist/chunks/chunk-6KMVP6AU.js +20 -0
- package/dist/chunks/chunk-6PNJORFL.js +128 -0
- package/dist/chunks/chunk-7AAQNGRH.js +2001 -0
- package/dist/chunks/chunk-7YYKTPJ5.js +22705 -0
- package/dist/chunks/chunk-A5MBOFVY.js +33 -0
- package/dist/chunks/chunk-AXNQRVJB.js +18 -0
- package/dist/chunks/chunk-B6HQ6YS5.js +572 -0
- package/dist/chunks/chunk-CY3RNVML.js +296 -0
- package/dist/chunks/chunk-CYHYDLV4.js +653 -0
- package/dist/chunks/chunk-CZBCCK4Y.js +82 -0
- package/dist/chunks/chunk-DCMGQP5V.js +505 -0
- package/dist/chunks/chunk-DIAA66GL.js +72 -0
- package/dist/chunks/chunk-DUO6H5PR.js +20 -0
- package/dist/chunks/chunk-E5WN7IGO.js +125 -0
- package/dist/chunks/chunk-EFGFXXQF.js +184 -0
- package/dist/chunks/chunk-F3RTZV2A.js +2811 -0
- package/dist/chunks/chunk-FMTLP5ZX.js +1397 -0
- package/dist/chunks/chunk-HKZLQJDV.js +79 -0
- package/dist/chunks/chunk-INDEVYEC.js +146 -0
- package/dist/chunks/chunk-JQTF4R5L.js +390 -0
- package/dist/chunks/chunk-KMCAYNUM.js +331 -0
- package/dist/chunks/chunk-KMWCCOUJ.js +1444 -0
- package/dist/chunks/chunk-KU3CLJI2.js +338 -0
- package/dist/chunks/chunk-NDSTGMKR.js +3300 -0
- package/dist/chunks/chunk-NQNLUAPO.js +505 -0
- package/dist/chunks/chunk-O2U2LO57.js +466 -0
- package/dist/chunks/chunk-OOQG7UPP.js +457 -0
- package/dist/chunks/chunk-OZQAW5ZG.js +112 -0
- package/dist/chunks/chunk-P2CVDGHR.js +487 -0
- package/dist/chunks/chunk-P44RIZ7C.js +592 -0
- package/dist/chunks/chunk-PEZCT37T.js +1475 -0
- package/dist/chunks/chunk-PKWSAW6O.js +152 -0
- package/dist/chunks/chunk-Q6MDDZMT.js +4373 -0
- package/dist/chunks/chunk-QDE4Z7KW.js +6 -0
- package/dist/chunks/chunk-QJDAVSNY.js +8 -0
- package/dist/chunks/chunk-QYPORSLO.js +7552 -0
- package/dist/chunks/chunk-R4QGNK34.js +183 -0
- package/dist/chunks/chunk-REEYC73I.js +3002 -0
- package/dist/chunks/chunk-SEWDMQ6Q.js +46 -0
- package/dist/chunks/chunk-TAIUWKZB.js +3057 -0
- package/dist/chunks/chunk-TN4YZ3O7.js +196 -0
- package/dist/chunks/chunk-TRMFB43C.js +143 -0
- package/dist/chunks/chunk-VO4QXG2X.js +1016 -0
- package/dist/chunks/chunk-VP2P3BPA.js +1002 -0
- package/dist/chunks/chunk-VQ7H33J4.js +2176 -0
- package/dist/chunks/chunk-VWA7MCV2.js +105 -0
- package/dist/chunks/chunk-XAV22WD7.js +253 -0
- package/dist/chunks/chunk-YSPBPZDV.js +148 -0
- package/dist/chunks/chunk-ZKEGXO73.js +282 -0
- package/dist/chunks/chunk-ZMGN6F3S.js +4256 -0
- package/dist/chunks/grammar-diagrams-AI7VDXOM.js +14 -0
- package/dist/chunks/index.min-ECJD6GZC.js +37 -0
- package/dist/chunks/manifest-EPTR5MYH.js +21 -0
- package/dist/chunks/openapi-document-6TCGVDUW.js +69 -0
- package/dist/chunks/registry-K2U5KUTY.js +23 -0
- package/dist/chunks/serialization-node-UGY6CFH6.js +38 -0
- package/dist/chunks/validate-GEKSZPIN.js +24 -0
- package/dist/chunks/validation-registry-IQZX3UE3.js +7 -0
- package/dist/chunks/validator-VXFHLPDW.js +26 -0
- package/dist/chunks/workflow-executor-KBGFKHNR.js +36 -0
- package/dist/cli/commands/agents.d.ts +16 -0
- package/dist/cli/commands/artifact.d.ts +10 -0
- package/dist/cli/commands/compile.d.ts +0 -30
- package/dist/cli/commands/console.d.ts +32 -0
- package/dist/cli/commands/context.d.ts +0 -3
- package/dist/cli/commands/describe.js +386 -352
- package/dist/cli/commands/dev.d.ts +9 -4
- package/dist/cli/commands/diagram.d.ts +3 -5
- package/dist/cli/commands/doctor.d.ts +27 -4
- package/dist/cli/commands/doctor.js +3307 -633
- package/dist/cli/commands/export.d.ts +6 -4
- package/dist/cli/commands/grammar.d.ts +0 -3
- package/dist/cli/commands/implement.d.ts +1 -1
- package/dist/cli/commands/init/agent-handoff.d.ts +28 -0
- package/dist/cli/commands/init/config.d.ts +3 -0
- package/dist/cli/commands/init/files.d.ts +12 -0
- package/dist/cli/commands/init/naming.d.ts +13 -0
- package/dist/cli/commands/init/output.d.ts +12 -0
- package/dist/cli/commands/init/setup.d.ts +21 -0
- package/dist/cli/commands/init/types.d.ts +53 -0
- package/dist/cli/commands/init-personas.d.ts +9 -1
- package/dist/cli/commands/init.d.ts +24 -88
- package/dist/cli/commands/market.d.ts +1 -1
- package/dist/cli/commands/mcp-setup.d.ts +1 -4
- package/dist/cli/commands/modify.d.ts +0 -5
- package/dist/cli/commands/openapi.d.ts +9 -11
- package/dist/cli/commands/run.d.ts +0 -4
- package/dist/cli/commands/serve.d.ts +24 -26
- package/dist/cli/commands/status.d.ts +1 -1
- package/dist/cli/exports.d.ts +3 -4
- package/dist/cli/exports.js +124 -23
- package/dist/cli/flow-weaver-agents-H653446S.mjs +81 -0
- package/dist/cli/flow-weaver-artifact-WBFYTW76.mjs +58 -0
- package/dist/cli/flow-weaver-chunk-265CEK74.mjs +2 -0
- package/dist/cli/flow-weaver-chunk-2C7PZCV5.mjs +186 -0
- package/dist/cli/flow-weaver-chunk-3BSYCWPL.mjs +3109 -0
- package/dist/cli/flow-weaver-chunk-3MKUQP3D.mjs +547 -0
- package/dist/cli/flow-weaver-chunk-3ZLMPQTH.mjs +27 -0
- package/dist/cli/flow-weaver-chunk-4DVY73ML.mjs +280 -0
- package/dist/cli/flow-weaver-chunk-54M4KNEL.mjs +200 -0
- package/dist/cli/flow-weaver-chunk-55QMUZIA.mjs +256 -0
- package/dist/cli/flow-weaver-chunk-6ZUJ7LMX.mjs +2003 -0
- package/dist/cli/flow-weaver-chunk-7ET6N32V.mjs +419 -0
- package/dist/cli/flow-weaver-chunk-7G63RR4K.mjs +8880 -0
- package/dist/cli/flow-weaver-chunk-A6M5K3W7.mjs +4418 -0
- package/dist/cli/flow-weaver-chunk-AA3NATMX.mjs +154 -0
- package/dist/cli/flow-weaver-chunk-APX6MQ5A.mjs +5652 -0
- package/dist/cli/flow-weaver-chunk-BHCC5FE5.mjs +17 -0
- package/dist/cli/flow-weaver-chunk-DM4BBRRU.mjs +35 -0
- package/dist/cli/flow-weaver-chunk-DRN7KPWY.mjs +168 -0
- package/dist/cli/flow-weaver-chunk-EKWF27G6.mjs +23 -0
- package/dist/cli/flow-weaver-chunk-EM5HWQ4R.mjs +338 -0
- package/dist/cli/flow-weaver-chunk-FPPPU2DG.mjs +226 -0
- package/dist/cli/flow-weaver-chunk-GAQXZHNO.mjs +3005 -0
- package/dist/cli/flow-weaver-chunk-GBUNNP33.mjs +1329 -0
- package/dist/cli/flow-weaver-chunk-HMAKDE55.mjs +636 -0
- package/dist/cli/flow-weaver-chunk-HQ3ZAN44.mjs +367 -0
- package/dist/cli/flow-weaver-chunk-I4APCXYN.mjs +21442 -0
- package/dist/cli/flow-weaver-chunk-IJJ4JXTL.mjs +2297 -0
- package/dist/cli/flow-weaver-chunk-J7EPZW2I.mjs +33 -0
- package/dist/cli/flow-weaver-chunk-KOEMJHLG.mjs +83 -0
- package/dist/cli/flow-weaver-chunk-M6CBWQKJ.mjs +271 -0
- package/dist/cli/flow-weaver-chunk-MHJ4N652.mjs +1580 -0
- package/dist/cli/flow-weaver-chunk-MKAFQWLP.mjs +202 -0
- package/dist/cli/flow-weaver-chunk-MMV2XGD3.mjs +3291 -0
- package/dist/cli/flow-weaver-chunk-MSI2UJES.mjs +125 -0
- package/dist/cli/flow-weaver-chunk-N767YRAI.mjs +48 -0
- package/dist/cli/flow-weaver-chunk-NQKKWDGF.mjs +56 -0
- package/dist/cli/flow-weaver-chunk-NYZDQYFU.mjs +45 -0
- package/dist/cli/flow-weaver-chunk-OMVWSNHJ.mjs +14 -0
- package/dist/cli/flow-weaver-chunk-PUWZ47H5.mjs +2188 -0
- package/dist/cli/flow-weaver-chunk-QOPRVDES.mjs +46 -0
- package/dist/cli/flow-weaver-chunk-RIWE7YTR.mjs +216 -0
- package/dist/cli/flow-weaver-chunk-S63Q3JIU.mjs +789 -0
- package/dist/cli/flow-weaver-chunk-T7X5A23H.mjs +558 -0
- package/dist/cli/flow-weaver-chunk-TLV3VZUN.mjs +2 -0
- package/dist/cli/flow-weaver-chunk-TS5P3PIN.mjs +194 -0
- package/dist/cli/flow-weaver-chunk-U3EO3X4B.mjs +649 -0
- package/dist/cli/flow-weaver-chunk-UNFS3NQP.mjs +34 -0
- package/dist/cli/flow-weaver-chunk-V6DHWFQG.mjs +2811 -0
- package/dist/cli/flow-weaver-chunk-VXWNLYQU.mjs +9 -0
- package/dist/cli/flow-weaver-chunk-W3YNK26P.mjs +149 -0
- package/dist/cli/flow-weaver-chunk-XG2WKXYZ.mjs +324 -0
- package/dist/cli/flow-weaver-chunk-YLSRZWFK.mjs +2219 -0
- package/dist/cli/flow-weaver-chunk-YVPURWS6.mjs +40 -0
- package/dist/cli/flow-weaver-chunk-Z44JK332.mjs +582 -0
- package/dist/cli/flow-weaver-chunk-Z5ZJPNSY.mjs +517 -0
- package/dist/cli/flow-weaver-chunk-ZQALO25T.mjs +594 -0
- package/dist/cli/flow-weaver-compile-A2CABDSB.mjs +37 -0
- package/dist/cli/flow-weaver-console-6EBHDBTN.mjs +71 -0
- package/dist/cli/flow-weaver-context-ECLYANFF.mjs +17 -0
- package/dist/cli/flow-weaver-context-ZRUMW2KE.mjs +69 -0
- package/dist/cli/flow-weaver-create-WIP4EFNP.mjs +124 -0
- package/dist/cli/flow-weaver-deployment-WJJRK7NO.mjs +14 -0
- package/dist/cli/flow-weaver-describe-XDIFF5LI.mjs +41 -0
- package/dist/cli/flow-weaver-dev-LG2NSQAU.mjs +196 -0
- package/dist/cli/flow-weaver-diagram-3EVQARQE.mjs +52 -0
- package/dist/cli/flow-weaver-diagram-7LR7O4M2.mjs +44 -0
- package/dist/cli/flow-weaver-diff-USF7DJLU.mjs +85 -0
- package/dist/cli/flow-weaver-docs-QU2ZOXKH.mjs +96 -0
- package/dist/cli/flow-weaver-doctor-K447YWHR.mjs +43 -0
- package/dist/cli/flow-weaver-export-LAS6N56Y.mjs +140 -0
- package/dist/cli/flow-weaver-grammar-RIRUS3Q6.mjs +49 -0
- package/dist/cli/flow-weaver-grammar-diagrams-WXRTW5SK.mjs +15 -0
- package/dist/cli/flow-weaver-implement-5JG6BCFZ.mjs +114 -0
- package/dist/cli/flow-weaver-index.min-OR5SIHXD.mjs +39 -0
- package/dist/cli/flow-weaver-init-34YZNPQX.mjs +972 -0
- package/dist/cli/flow-weaver-init-personas-NOGZTQQ2.mjs +48 -0
- package/dist/cli/flow-weaver-manifest-4JNUSEB3.mjs +18 -0
- package/dist/cli/flow-weaver-market-WA4CKHKV.mjs +444 -0
- package/dist/cli/flow-weaver-mcp-setup-O26MGXSD.mjs +22 -0
- package/dist/cli/flow-weaver-migrate-VFVEUTPH.mjs +119 -0
- package/dist/cli/flow-weaver-modify-VM3JP5K6.mjs +97 -0
- package/dist/cli/flow-weaver-openapi-IRBWI3HM.mjs +71 -0
- package/dist/cli/flow-weaver-openapi-document-7N6YMPG3.mjs +30 -0
- package/dist/cli/flow-weaver-pack-commands-OS2QRXAK.mjs +146 -0
- package/dist/cli/flow-weaver-registry-5MLFRPPT.mjs +25 -0
- package/dist/cli/flow-weaver-run-DSTLSTHR.mjs +555 -0
- package/dist/cli/flow-weaver-serialization-node-LE6PCG4M.mjs +50 -0
- package/dist/cli/flow-weaver-serve-NVLCLSOW.mjs +192 -0
- package/dist/cli/flow-weaver-server-7IERLVXE.mjs +2925 -0
- package/dist/cli/flow-weaver-server-KWF4PXYC.mjs +19112 -0
- package/dist/cli/flow-weaver-status-75W2S3YB.mjs +138 -0
- package/dist/cli/flow-weaver-strip-AZPXUYVA.mjs +79 -0
- package/dist/cli/flow-weaver-templates-DSNMB6K7.mjs +72 -0
- package/dist/cli/flow-weaver-validate-A4UWDQN6.mjs +19 -0
- package/dist/cli/flow-weaver-validate-GRBZ5W4C.mjs +296 -0
- package/dist/cli/flow-weaver-validation-registry-BINGUNXX.mjs +9 -0
- package/dist/cli/flow-weaver-validator-TY56CI42.mjs +21 -0
- package/dist/cli/flow-weaver-watch-OPPERXL6.mjs +114 -0
- package/dist/cli/flow-weaver-workflow-executor-6AHYPXAN.mjs +26 -0
- package/dist/cli/flow-weaver.mjs +3557 -89498
- package/dist/cli/index.d.ts +5 -2
- package/dist/cli/pack-commands-needed.d.ts +12 -0
- package/dist/cli/program.d.ts +14 -0
- package/dist/cli/templates/ai/mock-provider.d.ts +1 -1
- package/dist/cli/templates/index.d.ts +1 -8
- package/dist/cli/templates/nodes/agent-router.d.ts +1 -1
- package/dist/cli/templates/nodes/aggregator.d.ts +1 -1
- package/dist/cli/templates/nodes/conversation-memory.d.ts +1 -1
- package/dist/cli/templates/nodes/http.d.ts +1 -1
- package/dist/cli/templates/nodes/human-approval.d.ts +1 -1
- package/dist/cli/templates/nodes/json-extractor.d.ts +1 -1
- package/dist/cli/templates/nodes/llm-call.d.ts +1 -1
- package/dist/cli/templates/nodes/prompt-template.d.ts +1 -1
- package/dist/cli/templates/nodes/rag-retriever.d.ts +1 -1
- package/dist/cli/templates/nodes/tool-executor.d.ts +1 -1
- package/dist/cli/templates/nodes/transformer.d.ts +1 -1
- package/dist/cli/templates/nodes/validator.d.ts +1 -1
- package/dist/cli/templates/shared/approval-types.d.ts +1 -1
- package/dist/cli/templates/shared/case.d.ts +14 -0
- package/dist/cli/templates/shared/llm-types.d.ts +4 -4
- package/dist/cli/templates/workflows/aggregator.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-agent.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-chat.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-rag.d.ts +1 -1
- package/dist/cli/templates/workflows/ai-react.d.ts +1 -1
- package/dist/cli/templates/workflows/approval.d.ts +10 -0
- package/dist/cli/templates/workflows/conditional.d.ts +2 -2
- package/dist/cli/templates/workflows/error-handler.d.ts +2 -2
- package/dist/cli/templates/workflows/foreach.d.ts +1 -1
- package/dist/cli/templates/workflows/sequential.d.ts +1 -1
- package/dist/cli/templates/workflows/webhook.d.ts +1 -1
- package/dist/cli/utils/interactive.d.ts +6 -0
- package/dist/cli/utils/json-option.d.ts +8 -0
- package/dist/cli/utils/logger.d.ts +2 -0
- package/dist/compiler/durable-source-proof.d.ts +23 -0
- package/dist/compiler/executable-artifact.d.ts +29 -0
- package/dist/compiler/index.d.ts +4 -0
- package/dist/compiler/index.js +36 -0
- package/dist/console/app.js +106 -0
- package/dist/console/assets/synergenius.svg +18 -0
- package/dist/console/author.d.ts +32 -0
- package/dist/console/cli-catalog.d.ts +21 -0
- package/dist/console/cli-run.d.ts +35 -0
- package/dist/console/cli-run.js +46 -0
- package/dist/console/debug.d.ts +67 -0
- package/dist/console/diff-view.d.ts +96 -0
- package/dist/console/export.d.ts +36 -0
- package/dist/console/git.d.ts +27 -0
- package/dist/console/index.d.ts +4 -0
- package/dist/console/index.html +16 -0
- package/dist/console/index.js +203 -0
- package/dist/console/packs.d.ts +100 -0
- package/dist/console/request-guard.d.ts +10 -0
- package/dist/console/respond.d.ts +16 -0
- package/dist/console/router.d.ts +64 -0
- package/dist/console/routes-agents.d.ts +14 -0
- package/dist/console/routes-project.d.ts +3 -0
- package/dist/console/routes-runs.d.ts +3 -0
- package/dist/console/routes-services.d.ts +7 -0
- package/dist/console/routes-tools.d.ts +3 -0
- package/dist/console/runs.d.ts +69 -0
- package/dist/console/scan.d.ts +49 -0
- package/dist/console/schema.d.ts +74 -0
- package/dist/console/server.d.ts +34 -0
- package/dist/console/server.js +43264 -0
- package/dist/console/services.d.ts +119 -0
- package/dist/console/source.d.ts +23 -0
- package/dist/console/status.d.ts +68 -0
- package/dist/console/styles.css +1023 -0
- package/dist/console/terminals.d.ts +22 -0
- package/dist/console/workflow-view.d.ts +153 -0
- package/dist/constants.d.ts +5 -1
- package/dist/constants.js +56 -167
- package/dist/context/index.d.ts +10 -0
- package/dist/context/index.js +14 -191
- package/dist/coordinator/agent-gate.d.ts +107 -0
- package/dist/coordinator/bundle-digest.d.ts +20 -0
- package/dist/coordinator/clock-tick.d.ts +4 -0
- package/dist/coordinator/effect-receipts.d.ts +10 -0
- package/dist/coordinator/errors.d.ts +31 -0
- package/dist/coordinator/file-store.d.ts +3 -0
- package/dist/coordinator/gate-labeling.d.ts +33 -0
- package/dist/coordinator/gate-resolution.d.ts +28 -0
- package/dist/coordinator/index.d.ts +12 -0
- package/dist/coordinator/index.js +107 -0
- package/dist/coordinator/memory-store.d.ts +3 -0
- package/dist/coordinator/params.d.ts +18 -0
- package/dist/coordinator/run-annotations.d.ts +6 -0
- package/dist/coordinator/run-context.d.ts +11 -0
- package/dist/coordinator/run-ending.d.ts +5 -0
- package/dist/coordinator/run-outcome.d.ts +31 -0
- package/dist/coordinator/run-resume.d.ts +6 -0
- package/dist/coordinator/run-start.d.ts +4 -0
- package/dist/coordinator/run-store.d.ts +275 -0
- package/dist/coordinator/run-trace.d.ts +41 -0
- package/dist/coordinator/run-views.d.ts +12 -0
- package/dist/coordinator/runs-dir.d.ts +26 -0
- package/dist/coordinator/store.d.ts +67 -0
- package/dist/coordinator/time.d.ts +39 -0
- package/dist/coordinator/workflow-selection.d.ts +6 -0
- package/dist/deployment/index.d.ts +11 -16
- package/dist/deployment/index.js +541 -50
- package/dist/deployment/targets/base.d.ts +11 -13
- package/dist/deployment/targets/openapi-parts.d.ts +92 -0
- package/dist/diagram/arms.d.ts +70 -0
- package/dist/diagram/ascii-renderer.d.ts +1 -1
- package/dist/diagram/geometry.d.ts +22 -29
- package/dist/diagram/graph/bounds.d.ts +30 -0
- package/dist/diagram/graph/metrics.d.ts +21 -0
- package/dist/diagram/graph/nodes.d.ts +33 -0
- package/dist/diagram/graph/placement.d.ts +22 -0
- package/dist/diagram/graph/ports.d.ts +23 -0
- package/dist/diagram/graph/routing.d.ts +40 -0
- package/dist/diagram/graph/scopes.d.ts +30 -0
- package/dist/diagram/index.d.ts +15 -23
- package/dist/diagram/index.js +632 -111
- package/dist/diagram/labels.d.ts +12 -0
- package/dist/diagram/lanes.d.ts +93 -0
- package/dist/diagram/layout.d.ts +1 -1
- package/dist/diagram/material-symbols.d.ts +7 -0
- package/dist/diagram/orthogonal-router.d.ts +15 -51
- package/dist/diagram/process-view.d.ts +79 -0
- package/dist/diagram/spine.d.ts +25 -0
- package/dist/diagram/theme.d.ts +3 -5
- package/dist/diagram/types.d.ts +6 -20
- package/dist/diff/index.js +53 -9
- package/dist/diff/types.d.ts +1 -5
- package/dist/doc-metadata/extractors/annotations.d.ts +0 -4
- package/dist/doc-metadata/extractors/cli-commands.d.ts +2 -1
- package/dist/doc-metadata/extractors/core-metadata.d.ts +19 -4
- package/dist/doc-metadata/extractors/error-codes.d.ts +1 -1
- package/dist/doc-metadata/extractors/mcp-tools.d.ts +7 -3
- package/dist/doc-metadata/index.d.ts +1 -2
- package/dist/doc-metadata/index.js +2368 -9
- package/dist/doc-metadata/types.d.ts +7 -24
- package/dist/docs/guide.d.ts +33 -0
- package/dist/docs/index.d.ts +7 -4
- package/dist/docs/index.js +298 -298
- package/dist/docs/pack-topics.d.ts +18 -0
- package/dist/editor-completions/annotationValues.d.ts +1 -1
- package/dist/editor-completions/contextParser.d.ts +3 -2
- package/dist/editor-completions/dataTypes.d.ts +1 -1
- package/dist/editor-completions/goToDefinition.d.ts +1 -1
- package/dist/editor-completions/index.d.ts +8 -8
- package/dist/editor-completions/index.js +1244 -175
- package/dist/editor-completions/jsDocAnnotations.d.ts +1 -1
- package/dist/editor-completions/modifierCompletions.d.ts +1 -1
- package/dist/export/index.d.ts +7 -1
- package/dist/generated-branding.js +8 -21
- package/dist/generated-version.d.ts +1 -1
- package/dist/generated-version.js +7 -3
- package/dist/generator/annotation-generator.d.ts +84 -0
- package/dist/generator/async-detection.d.ts +1 -1
- package/dist/{body-generator.d.ts → generator/body-generator.d.ts} +7 -3
- package/dist/generator/code-utils.d.ts +15 -60
- package/dist/generator/connection-reads.d.ts +94 -0
- package/dist/generator/control-flow-plan.d.ts +74 -0
- package/dist/generator/control-flow.d.ts +1 -1
- package/dist/generator/exit-assembly.d.ts +11 -0
- package/dist/generator/index.d.ts +4 -5
- package/dist/generator/index.js +34 -11
- package/dist/generator/input-port-values.d.ts +22 -0
- package/dist/generator/{scope-function-generator.d.ts → node-arguments.d.ts} +76 -1
- package/dist/generator/node-invocation.d.ts +74 -0
- package/dist/{node-types-generator.d.ts → generator/node-types-generator.d.ts} +3 -2
- package/dist/generator/scope-closure.d.ts +23 -0
- package/dist/generator/scoped-child.d.ts +49 -0
- package/dist/{sugar-optimizer.d.ts → generator/sugar-optimizer.d.ts} +1 -1
- package/dist/generator/unified.d.ts +14 -2
- package/dist/generator/workflow-generator.d.ts +37 -0
- package/dist/index.d.ts +29 -26
- package/dist/index.js +1322 -92
- package/dist/jsdoc-port-sync/apply-diff.d.ts +15 -0
- package/dist/jsdoc-port-sync/callback-signature.d.ts +17 -0
- package/dist/jsdoc-port-sync/diff.d.ts +5 -7
- package/dist/jsdoc-port-sync/incomplete-lines.d.ts +41 -0
- package/dist/jsdoc-port-sync/index.d.ts +11 -11
- package/dist/jsdoc-port-sync/index.js +88 -45
- package/dist/jsdoc-port-sync/jsdoc-to-signature.d.ts +66 -0
- package/dist/jsdoc-port-sync/port-parser.d.ts +6 -24
- package/dist/jsdoc-port-sync/port-tag-placement.d.ts +55 -0
- package/dist/jsdoc-port-sync/scoped-ports.d.ts +21 -0
- package/dist/jsdoc-port-sync/signature-parser.d.ts +8 -1
- package/dist/jsdoc-port-sync/signature-to-jsdoc.d.ts +77 -0
- package/dist/jsdoc-port-sync/sync.d.ts +4 -1
- package/dist/marketplace/index.d.ts +5 -3
- package/dist/marketplace/index.js +62 -10
- package/dist/marketplace/install.d.ts +24 -0
- package/dist/marketplace/manifest.d.ts +1 -1
- package/dist/marketplace/npmrc.d.ts +24 -0
- package/dist/marketplace/registry.d.ts +46 -11
- package/dist/marketplace/types.d.ts +41 -24
- package/dist/marketplace/validator.d.ts +1 -1
- package/dist/mcp/debug-session.d.ts +2 -4
- package/dist/mcp/dist-imports.d.ts +12 -0
- package/dist/mcp/response-utils.d.ts +11 -9
- package/dist/mcp/server.d.ts +0 -1
- package/dist/mcp/tools-context.d.ts +11 -0
- package/dist/mcp/tools-diagram.d.ts +1 -2
- package/dist/mcp/tools-export.d.ts +2 -2
- package/dist/mcp/tools-marketplace.d.ts +1 -1
- package/dist/mcp/tools-run.d.ts +17 -0
- package/dist/mcp/tools-workflow.d.ts +3 -0
- package/dist/mcp/types.d.ts +4 -14
- package/dist/mcp/workflow-executor.d.ts +57 -19
- package/dist/npm-packages.d.ts +1 -1
- package/dist/npm-packages.js +10 -473
- package/dist/parser/annotation-parser.d.ts +88 -0
- package/dist/parser/annotation-suggestion.d.ts +23 -0
- package/dist/parser/durable-effect-contract.d.ts +10 -0
- package/dist/parser/expression-references.d.ts +101 -0
- package/dist/parser/external-node-types.d.ts +69 -0
- package/dist/{function-like.d.ts → parser/function-like.d.ts} +10 -3
- package/dist/parser/generated-sections.d.ts +25 -0
- package/dist/parser/import-resolution.d.ts +67 -0
- package/dist/parser/import-stub.d.ts +29 -0
- package/dist/parser/jsdoc/config-types.d.ts +209 -0
- package/dist/parser/jsdoc/graph-tags.d.ts +54 -0
- package/dist/parser/jsdoc/node-type-block.d.ts +23 -0
- package/dist/parser/jsdoc/parse-line-once.d.ts +11 -0
- package/dist/parser/jsdoc/port-tags.d.ts +42 -0
- package/dist/parser/jsdoc/runtime-tags.d.ts +65 -0
- package/dist/parser/jsdoc/signature-types.d.ts +52 -0
- package/dist/parser/jsdoc/workflow-block.d.ts +22 -0
- package/dist/parser/jsdoc-parser.d.ts +23 -0
- package/dist/parser/macro-expansion.d.ts +80 -0
- package/dist/parser/module-resolution.d.ts +38 -0
- package/dist/parser/node-inference.d.ts +39 -0
- package/dist/parser/npm-node-types.d.ts +24 -0
- package/dist/parser/pack-handlers.d.ts +12 -0
- package/dist/parser/path-data-resolution.d.ts +75 -0
- package/dist/parser/port-inference.d.ts +15 -0
- package/dist/{resolve-package-types.d.ts → parser/resolve-package-types.d.ts} +4 -0
- package/dist/parser/serialize-deploy-annotations.d.ts +19 -0
- package/dist/parser/tag-registry.d.ts +22 -0
- package/dist/parser/workflow-extraction.d.ts +39 -0
- package/dist/runtime/ExecutionContext.d.ts +87 -99
- package/dist/runtime/continuation-core.d.ts +147 -0
- package/dist/runtime/continuation.d.ts +48 -0
- package/dist/runtime/debug-controller.d.ts +7 -22
- package/dist/runtime/durable-execution.d.ts +176 -0
- package/dist/runtime/events.d.ts +16 -1
- package/dist/runtime/executable-module-contract.d.ts +16 -0
- package/dist/runtime/index.d.ts +13 -10
- package/dist/runtime/index.js +947 -9
- package/dist/runtime/strict-json.d.ts +15 -0
- package/dist/server/access.d.ts +12 -0
- package/dist/server/api.d.ts +126 -0
- package/dist/server/callback-delivery.d.ts +62 -0
- package/dist/server/callback-url.d.ts +44 -0
- package/dist/server/context.d.ts +35 -0
- package/dist/server/http-error.d.ts +10 -0
- package/dist/server/index.d.ts +7 -1
- package/dist/server/index.js +125 -6
- package/dist/server/openapi-document.d.ts +33 -0
- package/dist/server/openapi.d.ts +32 -0
- package/dist/server/respond.d.ts +35 -0
- package/dist/server/route-params.d.ts +17 -0
- package/dist/server/route-plan.d.ts +41 -0
- package/dist/server/routes-catalog.d.ts +5 -0
- package/dist/server/routes-declared.d.ts +12 -0
- package/dist/server/routes-runs.d.ts +8 -0
- package/dist/server/run-driver.d.ts +58 -0
- package/dist/server/run-view.d.ts +26 -0
- package/dist/server/transport.d.ts +35 -0
- package/dist/server/types.d.ts +143 -52
- package/dist/server/webhook-server.d.ts +12 -38
- package/dist/server/workflow-registry.d.ts +7 -4
- package/dist/service-registry.d.ts +49 -0
- package/dist/service-registry.js +123 -0
- package/dist/testing/assertions.d.ts +2 -2
- package/dist/testing/index.d.ts +14 -13
- package/dist/testing/index.js +582 -24
- package/dist/testing/mock-approval.d.ts +3 -5
- package/dist/testing/mock-llm.d.ts +2 -3
- package/dist/testing/recorder.d.ts +5 -6
- package/dist/testing/replayer.d.ts +6 -7
- package/dist/testing/run-store-check.d.ts +3 -0
- package/dist/testing/token-tracker.d.ts +2 -2
- package/dist/{type-mappings.d.ts → types/type-mappings.d.ts} +13 -1
- package/dist/utils/error-utils.d.ts +4 -2
- package/dist/utils/port-ordering.d.ts +2 -2
- package/dist/utils/port-tag-utils.d.ts +1 -1
- package/dist/validation/agent-detection.d.ts +17 -5
- package/dist/validation/agent-rules.d.ts +6 -7
- package/dist/validation/core-rules.d.ts +49 -0
- package/dist/validation/design-rules.d.ts +9 -3
- package/dist/validation/rule-registry.d.ts +3 -3
- package/dist/validation/rules/connections.d.ts +27 -0
- package/dist/validation/rules/context.d.ts +11 -0
- package/dist/validation/rules/cycles.d.ts +17 -0
- package/dist/validation/rules/data-flow.d.ts +19 -0
- package/dist/validation/rules/scope-topology.d.ts +35 -0
- package/dist/validation/rules/type-compatibility.d.ts +30 -0
- package/dist/validation/type-checker.d.ts +39 -0
- package/dist/validation/validator-helpers.d.ts +31 -0
- package/dist/validation/validator.d.ts +30 -0
- package/docs/reference/advanced-annotations.md +277 -60
- package/docs/reference/built-in-nodes.md +164 -94
- package/docs/reference/cancellation.md +44 -0
- package/docs/reference/cli-reference.md +252 -234
- package/docs/reference/compilation.md +36 -109
- package/docs/reference/concepts.md +80 -63
- package/docs/reference/console.md +169 -0
- package/docs/reference/debugging.md +26 -57
- package/docs/reference/deployment.md +217 -143
- package/docs/reference/durable-gates.md +445 -0
- package/docs/reference/error-codes.md +90 -43
- package/docs/reference/export-interface.md +91 -26
- package/docs/reference/iterative-development.md +50 -28
- package/docs/reference/jsdoc-grammar.md +66 -311
- package/docs/reference/library.md +250 -0
- package/docs/reference/marketplace.md +301 -152
- package/docs/reference/mcp-tools.md +102 -0
- package/docs/reference/node-conversion.md +84 -59
- package/docs/reference/orientation.md +68 -0
- package/docs/reference/scaffold.md +5 -4
- package/docs/reference/tutorial.md +106 -166
- package/docs/reference/visual-reference.md +1 -1
- package/package.json +85 -50
- package/dist/agent/agent-loop.js +0 -156
- package/dist/agent/cli-spawn-config.js +0 -65
- package/dist/agent/device-connection.d.ts +0 -79
- package/dist/agent/device-connection.js +0 -184
- package/dist/agent/env-allowlist.js +0 -60
- package/dist/agent/providers/anthropic.js +0 -198
- package/dist/agent/providers/claude-cli.js +0 -161
- package/dist/agent/providers/openai-compat.js +0 -205
- package/dist/agent/providers/platform.d.ts +0 -23
- package/dist/agent/providers/platform.js +0 -132
- package/dist/agent/streaming.js +0 -186
- package/dist/agent/types.js +0 -20
- package/dist/annotation-generator.d.ts +0 -50
- package/dist/annotation-generator.js +0 -743
- package/dist/api/builder.js +0 -345
- package/dist/api/command-runner.js +0 -787
- package/dist/api/compile.js +0 -148
- package/dist/api/extract-types.js +0 -57
- package/dist/api/generate-in-place.js +0 -1477
- package/dist/api/generate.js +0 -514
- package/dist/api/helpers.js +0 -285
- package/dist/api/inline-runtime.js +0 -526
- package/dist/api/manipulation/connections.js +0 -151
- package/dist/api/manipulation/index.js +0 -41
- package/dist/api/manipulation/node-types.js +0 -200
- package/dist/api/manipulation/nodes.js +0 -355
- package/dist/api/manipulation/ports.js +0 -228
- package/dist/api/manipulation/scopes.js +0 -156
- package/dist/api/manipulation/workflow.js +0 -116
- package/dist/api/modify-operation.js +0 -177
- package/dist/api/parse.js +0 -115
- package/dist/api/patterns.d.ts +0 -112
- package/dist/api/patterns.js +0 -303
- package/dist/api/query.js +0 -840
- package/dist/api/templates.js +0 -117
- package/dist/api/transform.js +0 -40
- package/dist/api/validate.js +0 -64
- package/dist/api/validation-registry.js +0 -10
- package/dist/api/workflow-file-operations.js +0 -180
- package/dist/ast/builder.js +0 -395
- package/dist/ast/serialization-node.js +0 -30
- package/dist/ast/serialization.js +0 -134
- package/dist/ast/types.js +0 -2
- package/dist/ast/workflow-utils.js +0 -114
- package/dist/body-generator.js +0 -35
- package/dist/built-in-nodes/coercion-types.js +0 -61
- package/dist/built-in-nodes/delay.js +0 -29
- package/dist/built-in-nodes/generated-registry.js +0 -299
- package/dist/built-in-nodes/invoke-workflow.js +0 -36
- package/dist/built-in-nodes/mock-types.js +0 -42
- package/dist/built-in-nodes/wait-for-agent.js +0 -31
- package/dist/built-in-nodes/wait-for-event.js +0 -25
- package/dist/chevrotain-parser/coerce-parser.js +0 -103
- package/dist/chevrotain-parser/connect-parser.js +0 -136
- package/dist/chevrotain-parser/fan-parser.js +0 -149
- package/dist/chevrotain-parser/grammar-diagrams.js +0 -273
- package/dist/chevrotain-parser/index.js +0 -31
- package/dist/chevrotain-parser/map-parser.js +0 -130
- package/dist/chevrotain-parser/node-parser.js +0 -558
- package/dist/chevrotain-parser/path-parser.js +0 -140
- package/dist/chevrotain-parser/port-parser.js +0 -519
- package/dist/chevrotain-parser/position-parser.d.ts +0 -20
- package/dist/chevrotain-parser/position-parser.js +0 -83
- package/dist/chevrotain-parser/scope-parser.js +0 -104
- package/dist/chevrotain-parser/tokens.js +0 -429
- package/dist/chevrotain-parser/trigger-cancel-parser.js +0 -291
- package/dist/cli/commands/account.d.ts +0 -4
- package/dist/cli/commands/account.js +0 -50
- package/dist/cli/commands/ai-credentials.d.ts +0 -12
- package/dist/cli/commands/ai-credentials.js +0 -95
- package/dist/cli/commands/apikey.d.ts +0 -4
- package/dist/cli/commands/apikey.js +0 -64
- package/dist/cli/commands/auth.d.ts +0 -9
- package/dist/cli/commands/auth.js +0 -255
- package/dist/cli/commands/compile.js +0 -331
- package/dist/cli/commands/connect.d.ts +0 -4
- package/dist/cli/commands/connect.js +0 -163
- package/dist/cli/commands/context.js +0 -51
- package/dist/cli/commands/create.js +0 -139
- package/dist/cli/commands/deploy.d.ts +0 -6
- package/dist/cli/commands/deploy.js +0 -74
- package/dist/cli/commands/dev.js +0 -227
- package/dist/cli/commands/diagram.js +0 -39
- package/dist/cli/commands/diff.js +0 -57
- package/dist/cli/commands/docs.js +0 -74
- package/dist/cli/commands/export.js +0 -153
- package/dist/cli/commands/grammar.js +0 -40
- package/dist/cli/commands/implement.js +0 -91
- package/dist/cli/commands/init-personas.js +0 -541
- package/dist/cli/commands/init.js +0 -797
- package/dist/cli/commands/market.js +0 -440
- package/dist/cli/commands/mcp-setup.js +0 -433
- package/dist/cli/commands/migrate.js +0 -91
- package/dist/cli/commands/modify.js +0 -58
- package/dist/cli/commands/openapi.js +0 -71
- package/dist/cli/commands/org.d.ts +0 -8
- package/dist/cli/commands/org.js +0 -136
- package/dist/cli/commands/pattern.d.ts +0 -34
- package/dist/cli/commands/pattern.js +0 -186
- package/dist/cli/commands/plugin.d.ts +0 -16
- package/dist/cli/commands/plugin.js +0 -176
- package/dist/cli/commands/run.js +0 -742
- package/dist/cli/commands/serve.js +0 -93
- package/dist/cli/commands/status.js +0 -123
- package/dist/cli/commands/strip.js +0 -61
- package/dist/cli/commands/templates.js +0 -58
- package/dist/cli/commands/validate.js +0 -267
- package/dist/cli/commands/watch.js +0 -71
- package/dist/cli/config/credentials.d.ts +0 -15
- package/dist/cli/config/credentials.js +0 -43
- package/dist/cli/config/platform-client.d.ts +0 -123
- package/dist/cli/config/platform-client.js +0 -248
- package/dist/cli/env-setup.js +0 -12
- package/dist/cli/index.js +0 -850
- package/dist/cli/pack-commands.js +0 -122
- package/dist/cli/postinstall.d.ts +0 -16
- package/dist/cli/postinstall.js +0 -119
- package/dist/cli/templates/ai/mock-provider.js +0 -64
- package/dist/cli/templates/ai/types.js +0 -5
- package/dist/cli/templates/approvals/index.d.ts +0 -15
- package/dist/cli/templates/approvals/index.js +0 -241
- package/dist/cli/templates/index.js +0 -123
- package/dist/cli/templates/nodes/agent-router.js +0 -114
- package/dist/cli/templates/nodes/aggregator.js +0 -63
- package/dist/cli/templates/nodes/conversation-memory.js +0 -85
- package/dist/cli/templates/nodes/http.js +0 -80
- package/dist/cli/templates/nodes/human-approval.js +0 -109
- package/dist/cli/templates/nodes/json-extractor.js +0 -119
- package/dist/cli/templates/nodes/llm-call.js +0 -106
- package/dist/cli/templates/nodes/prompt-template.js +0 -52
- package/dist/cli/templates/nodes/rag-retriever.js +0 -128
- package/dist/cli/templates/nodes/tool-executor.js +0 -108
- package/dist/cli/templates/nodes/transformer.js +0 -68
- package/dist/cli/templates/nodes/validator.js +0 -62
- package/dist/cli/templates/pack-loader.js +0 -58
- package/dist/cli/templates/providers/index.js +0 -239
- package/dist/cli/templates/shared/approval-types.js +0 -31
- package/dist/cli/templates/shared/llm-types.js +0 -109
- package/dist/cli/templates/workflows/aggregator.js +0 -101
- package/dist/cli/templates/workflows/ai-agent.js +0 -326
- package/dist/cli/templates/workflows/ai-chat.js +0 -167
- package/dist/cli/templates/workflows/ai-rag.js +0 -184
- package/dist/cli/templates/workflows/ai-react.js +0 -293
- package/dist/cli/templates/workflows/conditional.js +0 -139
- package/dist/cli/templates/workflows/error-handler.js +0 -145
- package/dist/cli/templates/workflows/foreach.js +0 -140
- package/dist/cli/templates/workflows/sequential.js +0 -200
- package/dist/cli/templates/workflows/webhook.js +0 -158
- package/dist/cli/utils/cli-helpers.d.ts +0 -44
- package/dist/cli/utils/cli-helpers.js +0 -99
- package/dist/cli/utils/logger.js +0 -126
- package/dist/cli/utils/parse-int-strict.js +0 -17
- package/dist/cli/utils/safe-write.js +0 -54
- package/dist/deployment/config/defaults.d.ts +0 -29
- package/dist/deployment/config/defaults.js +0 -98
- package/dist/deployment/config/loader.d.ts +0 -24
- package/dist/deployment/config/loader.js +0 -237
- package/dist/deployment/config/types.d.ts +0 -117
- package/dist/deployment/config/types.js +0 -5
- package/dist/deployment/core/adapters.d.ts +0 -66
- package/dist/deployment/core/adapters.js +0 -156
- package/dist/deployment/core/executor.d.ts +0 -62
- package/dist/deployment/core/executor.js +0 -197
- package/dist/deployment/core/formatters.d.ts +0 -42
- package/dist/deployment/core/formatters.js +0 -146
- package/dist/deployment/openapi/generator.d.ts +0 -146
- package/dist/deployment/openapi/generator.js +0 -347
- package/dist/deployment/openapi/schema-converter.d.ts +0 -49
- package/dist/deployment/openapi/schema-converter.js +0 -192
- package/dist/deployment/targets/base.js +0 -855
- package/dist/deployment/types.d.ts +0 -140
- package/dist/deployment/types.js +0 -8
- package/dist/diagram/ascii-renderer.js +0 -528
- package/dist/diagram/geometry.js +0 -1267
- package/dist/diagram/html-viewer.d.ts +0 -21
- package/dist/diagram/html-viewer.js +0 -1689
- package/dist/diagram/layout.js +0 -143
- package/dist/diagram/orthogonal-router.js +0 -568
- package/dist/diagram/renderer.d.ts +0 -3
- package/dist/diagram/renderer.js +0 -266
- package/dist/diagram/theme.js +0 -282
- package/dist/diagram/types.js +0 -2
- package/dist/diff/WorkflowDiffer.js +0 -429
- package/dist/diff/formatDiff.js +0 -239
- package/dist/diff/impact.js +0 -119
- package/dist/diff/types.js +0 -35
- package/dist/doc-metadata/extractors/annotations.js +0 -638
- package/dist/doc-metadata/extractors/cli-commands.js +0 -326
- package/dist/doc-metadata/extractors/core-metadata.js +0 -61
- package/dist/doc-metadata/extractors/error-codes.js +0 -372
- package/dist/doc-metadata/extractors/grammar-rules.js +0 -51
- package/dist/doc-metadata/extractors/mcp-tools.js +0 -705
- package/dist/doc-metadata/extractors/plugin-api.d.ts +0 -19
- package/dist/doc-metadata/extractors/plugin-api.js +0 -279
- package/dist/doc-metadata/types.js +0 -5
- package/dist/editor-completions/annotationValues.js +0 -146
- package/dist/editor-completions/contextParser.js +0 -410
- package/dist/editor-completions/dataTypes.js +0 -95
- package/dist/editor-completions/goToDefinition.js +0 -112
- package/dist/editor-completions/jsDocAnnotations.js +0 -359
- package/dist/editor-completions/modifierCompletions.js +0 -197
- package/dist/editor-completions/types.js +0 -8
- package/dist/export/index.js +0 -212
- package/dist/extensions/index.d.ts +0 -16
- package/dist/extensions/index.js +0 -17
- package/dist/friendly-errors.js +0 -761
- package/dist/function-like.js +0 -84
- package/dist/generator/async-detection.js +0 -56
- package/dist/generator/code-utils.js +0 -551
- package/dist/generator/compile-target-registry.d.ts +0 -20
- package/dist/generator/compile-target-registry.js +0 -20
- package/dist/generator/control-flow.js +0 -358
- package/dist/generator/dev-mode-registry.d.ts +0 -27
- package/dist/generator/dev-mode-registry.js +0 -20
- package/dist/generator/scope-function-generator.js +0 -397
- package/dist/generator/unified.js +0 -1831
- package/dist/generator.d.ts +0 -54
- package/dist/generator.js +0 -101
- package/dist/jsdoc-parser.d.ts +0 -377
- package/dist/jsdoc-parser.js +0 -1189
- package/dist/jsdoc-port-sync/constants.js +0 -103
- package/dist/jsdoc-port-sync/diff.js +0 -319
- package/dist/jsdoc-port-sync/port-parser.js +0 -579
- package/dist/jsdoc-port-sync/rename.js +0 -256
- package/dist/jsdoc-port-sync/signature-parser.js +0 -559
- package/dist/jsdoc-port-sync/sync.js +0 -653
- package/dist/marketplace/manifest.js +0 -194
- package/dist/marketplace/registry.js +0 -198
- package/dist/marketplace/types.js +0 -9
- package/dist/marketplace/validator.js +0 -150
- package/dist/mcp/agent-channel.d.ts +0 -35
- package/dist/mcp/agent-channel.js +0 -61
- package/dist/mcp/auto-registration.d.ts +0 -3
- package/dist/mcp/auto-registration.js +0 -62
- package/dist/mcp/debug-session.js +0 -25
- package/dist/mcp/index.d.ts +0 -11
- package/dist/mcp/index.js +0 -10
- package/dist/mcp/pack-tools.js +0 -59
- package/dist/mcp/prompts.js +0 -68
- package/dist/mcp/response-utils.js +0 -97
- package/dist/mcp/run-registry.d.ts +0 -29
- package/dist/mcp/run-registry.js +0 -24
- package/dist/mcp/server.js +0 -63
- package/dist/mcp/tools-context.js +0 -51
- package/dist/mcp/tools-debug.js +0 -451
- package/dist/mcp/tools-diagram.js +0 -97
- package/dist/mcp/tools-docs.js +0 -62
- package/dist/mcp/tools-export.js +0 -222
- package/dist/mcp/tools-marketplace.js +0 -132
- package/dist/mcp/tools-model.d.ts +0 -3
- package/dist/mcp/tools-model.js +0 -279
- package/dist/mcp/tools-pattern.d.ts +0 -3
- package/dist/mcp/tools-pattern.js +0 -604
- package/dist/mcp/tools-query.js +0 -377
- package/dist/mcp/tools-resources.js +0 -41
- package/dist/mcp/tools-template.js +0 -119
- package/dist/mcp/tools-workflow-run.d.ts +0 -40
- package/dist/mcp/tools-workflow-run.js +0 -150
- package/dist/mcp/types.js +0 -2
- package/dist/mcp/workflow-executor.js +0 -242
- package/dist/migration/registry.js +0 -29
- package/dist/node-types-generator.js +0 -139
- package/dist/parser/tag-registry.js +0 -57
- package/dist/parser.d.ts +0 -232
- package/dist/parser.js +0 -2500
- package/dist/plugin/PluginPanel.d.ts +0 -12
- package/dist/plugin/PluginPanel.js +0 -5
- package/dist/plugin/index.d.ts +0 -13
- package/dist/plugin/index.js +0 -14
- package/dist/plugin/types.d.ts +0 -75
- package/dist/plugin/types.js +0 -8
- package/dist/resolve-package-types.js +0 -123
- package/dist/runtime/CancellationError.js +0 -20
- package/dist/runtime/ExecutionContext.js +0 -280
- package/dist/runtime/builtin-functions.js +0 -549
- package/dist/runtime/checkpoint.d.ts +0 -84
- package/dist/runtime/checkpoint.js +0 -225
- package/dist/runtime/debug-controller.js +0 -247
- package/dist/runtime/events.js +0 -2
- package/dist/runtime/function-registry.js +0 -66
- package/dist/runtime/parameter-resolver.js +0 -113
- package/dist/server/types.js +0 -5
- package/dist/server/webhook-server.js +0 -269
- package/dist/server/workflow-registry.js +0 -202
- package/dist/shared-project.js +0 -28
- package/dist/sugar-optimizer.js +0 -498
- package/dist/testing/assertions.js +0 -127
- package/dist/testing/mock-approval.js +0 -98
- package/dist/testing/mock-llm.js +0 -119
- package/dist/testing/recorder.js +0 -70
- package/dist/testing/replayer.js +0 -143
- package/dist/testing/token-tracker.js +0 -94
- package/dist/type-checker.d.ts +0 -42
- package/dist/type-checker.js +0 -190
- package/dist/type-mappings.js +0 -131
- package/dist/types/branded-ports.d.ts +0 -151
- package/dist/types/branded-ports.js +0 -121
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -5
- package/dist/types.d.ts +0 -139
- package/dist/types.js +0 -15
- package/dist/utils/error-utils.js +0 -27
- package/dist/utils/lru-cache.js +0 -40
- package/dist/utils/port-ordering.js +0 -81
- package/dist/utils/port-tag-utils.js +0 -41
- package/dist/utils/string-distance.js +0 -56
- package/dist/validation/agent-detection.js +0 -115
- package/dist/validation/agent-rules.js +0 -262
- package/dist/validation/design-rules.js +0 -377
- package/dist/validation/rule-registry.js +0 -37
- package/dist/validator.d.ts +0 -113
- package/dist/validator.js +0 -1631
- package/docs/reference/patterns.md +0 -159
- package/scripts/postinstall.cjs +0 -86
- /package/dist/{shared-project.d.ts → parser/shared-project.d.ts} +0 -0
- /package/dist/{friendly-errors.d.ts → validation/friendly-errors.d.ts} +0 -0
|
@@ -0,0 +1,1397 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JSDOC_BLOCK_REGEX,
|
|
3
|
+
ORPHAN_PORT_LINE_REGEX,
|
|
4
|
+
PORT_TAG_REGEX,
|
|
5
|
+
RESERVED_PARAMS,
|
|
6
|
+
SCOPE_TAG_REGEX,
|
|
7
|
+
buildCallbackType,
|
|
8
|
+
callbackHasAllPorts,
|
|
9
|
+
findBalancedClose,
|
|
10
|
+
parseCallbackType,
|
|
11
|
+
parseFunctionSignature,
|
|
12
|
+
parseInputTypeFields,
|
|
13
|
+
parseReturnBodyFieldsWithTypes,
|
|
14
|
+
parseReturnFields,
|
|
15
|
+
parseReturnTypeFields,
|
|
16
|
+
parseReturnTypeFieldsWithTypes,
|
|
17
|
+
portTypeToTsType,
|
|
18
|
+
rawParamListText,
|
|
19
|
+
splitParams,
|
|
20
|
+
tsTypeToPortType
|
|
21
|
+
} from "./chunk-NQNLUAPO.js";
|
|
22
|
+
import {
|
|
23
|
+
generateJSDocPortTag
|
|
24
|
+
} from "./chunk-VP2P3BPA.js";
|
|
25
|
+
import {
|
|
26
|
+
inferDataTypeFromTS
|
|
27
|
+
} from "./chunk-E5WN7IGO.js";
|
|
28
|
+
import {
|
|
29
|
+
isValidPortLine,
|
|
30
|
+
parsePortLine,
|
|
31
|
+
parsePortsFromJSDoc
|
|
32
|
+
} from "./chunk-QYPORSLO.js";
|
|
33
|
+
import {
|
|
34
|
+
SCOPED_PORT_NAMES,
|
|
35
|
+
isExecutePort,
|
|
36
|
+
isFailurePort,
|
|
37
|
+
isReservedPortName,
|
|
38
|
+
isScopedMandatoryPort,
|
|
39
|
+
isSuccessPort
|
|
40
|
+
} from "./chunk-R4QGNK34.js";
|
|
41
|
+
|
|
42
|
+
// src/jsdoc-port-sync/incomplete-lines.ts
|
|
43
|
+
function partialPortTag(line) {
|
|
44
|
+
const partialMatch = line.match(/\*\s*@(input|output|step)\s+\[?(\w+)/);
|
|
45
|
+
if (!partialMatch) return null;
|
|
46
|
+
return { tagType: partialMatch[1], portName: partialMatch[2] };
|
|
47
|
+
}
|
|
48
|
+
function hasOrphanPortLines(functionText) {
|
|
49
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
50
|
+
if (!jsdocMatch) return { inputs: false, outputs: false };
|
|
51
|
+
const lines = jsdocMatch[0].split("\n");
|
|
52
|
+
let hasOrphanInputs = false;
|
|
53
|
+
let hasOrphanOutputs = false;
|
|
54
|
+
for (const line of lines) {
|
|
55
|
+
const orphanMatch = line.match(ORPHAN_PORT_LINE_REGEX);
|
|
56
|
+
if (orphanMatch) {
|
|
57
|
+
const [, tagType] = orphanMatch;
|
|
58
|
+
if (tagType === "input") hasOrphanInputs = true;
|
|
59
|
+
else hasOrphanOutputs = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return { inputs: hasOrphanInputs, outputs: hasOrphanOutputs };
|
|
63
|
+
}
|
|
64
|
+
function getIncompletePortNames(functionText) {
|
|
65
|
+
const inputs = /* @__PURE__ */ new Set();
|
|
66
|
+
const outputs = /* @__PURE__ */ new Set();
|
|
67
|
+
const steps = /* @__PURE__ */ new Set();
|
|
68
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
69
|
+
if (!jsdocMatch) return { inputs, outputs, steps };
|
|
70
|
+
const lines = jsdocMatch[0].split("\n");
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
if (!PORT_TAG_REGEX.test(line)) continue;
|
|
73
|
+
if (isValidPortLine(line)) continue;
|
|
74
|
+
const partial = partialPortTag(line);
|
|
75
|
+
if (partial) {
|
|
76
|
+
const { tagType, portName } = partial;
|
|
77
|
+
if (tagType === "input") {
|
|
78
|
+
inputs.add(portName);
|
|
79
|
+
} else if (tagType === "output") {
|
|
80
|
+
outputs.add(portName);
|
|
81
|
+
} else if (tagType === "step") {
|
|
82
|
+
steps.add(portName);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { inputs, outputs, steps };
|
|
87
|
+
}
|
|
88
|
+
function isIncompletePortLine(line) {
|
|
89
|
+
if (!PORT_TAG_REGEX.test(line)) return false;
|
|
90
|
+
if (!isValidPortLine(line)) return true;
|
|
91
|
+
const cleanLine = line.replace(/^\s*\*\s*/, "").trim();
|
|
92
|
+
if (/\s-\s*$/.test(cleanLine)) return true;
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/jsdoc-port-sync/port-tag-placement.ts
|
|
97
|
+
function tagLine(name, port, direction) {
|
|
98
|
+
return ` * ${generateJSDocPortTag(name, port, direction)}`;
|
|
99
|
+
}
|
|
100
|
+
function markInputLine(scan, name, index) {
|
|
101
|
+
scan.seenInputs.add(name);
|
|
102
|
+
scan.lastInputLineIndex = index;
|
|
103
|
+
}
|
|
104
|
+
function markOutputLine(scan, name, index) {
|
|
105
|
+
scan.seenOutputs.add(name);
|
|
106
|
+
scan.lastOutputLineIndex = index;
|
|
107
|
+
}
|
|
108
|
+
function keepOrphanLine(scan, line, tagType) {
|
|
109
|
+
const lineIndex = scan.preservedLines.length;
|
|
110
|
+
scan.preservedLines.push(line);
|
|
111
|
+
if (tagType === "input") {
|
|
112
|
+
scan.orphanInputLines.push({ index: lineIndex, type: "ANY" });
|
|
113
|
+
scan.lastInputLineIndex = lineIndex;
|
|
114
|
+
} else if (tagType === "output" || tagType === "step") {
|
|
115
|
+
scan.orphanOutputLines.push({ index: lineIndex, type: "ANY" });
|
|
116
|
+
scan.lastOutputLineIndex = lineIndex;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function keepIncompleteLine(scan, line) {
|
|
120
|
+
const lineIndex = scan.preservedLines.length;
|
|
121
|
+
scan.preservedLines.push(line);
|
|
122
|
+
const partial = partialPortTag(line);
|
|
123
|
+
if (!partial) return;
|
|
124
|
+
const { tagType, portName } = partial;
|
|
125
|
+
if (tagType === "input") {
|
|
126
|
+
markInputLine(scan, portName, lineIndex);
|
|
127
|
+
} else if (tagType === "output") {
|
|
128
|
+
markOutputLine(scan, portName, lineIndex);
|
|
129
|
+
} else if (tagType === "step") {
|
|
130
|
+
scan.seenInputs.add(portName);
|
|
131
|
+
scan.seenOutputs.add(portName);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function keepParsedLine(scan, line, parsed, inputs, outputs) {
|
|
135
|
+
const lineIndex = scan.preservedLines.length;
|
|
136
|
+
if (parsed.type === "input") {
|
|
137
|
+
if (!inputs[parsed.name]) return;
|
|
138
|
+
scan.preservedLines.push(line.trimEnd());
|
|
139
|
+
markInputLine(scan, parsed.name, lineIndex);
|
|
140
|
+
} else if (parsed.type === "output") {
|
|
141
|
+
if (!outputs[parsed.name]) return;
|
|
142
|
+
scan.preservedLines.push(line.trimEnd());
|
|
143
|
+
markOutputLine(scan, parsed.name, lineIndex);
|
|
144
|
+
} else if (parsed.type === "step") {
|
|
145
|
+
const isInput = inputs[parsed.name] !== void 0;
|
|
146
|
+
const isOutput = outputs[parsed.name] !== void 0;
|
|
147
|
+
if (!isInput && !isOutput) return;
|
|
148
|
+
scan.preservedLines.push(line.trimEnd());
|
|
149
|
+
if (isInput) markInputLine(scan, parsed.name, lineIndex);
|
|
150
|
+
if (isOutput) markOutputLine(scan, parsed.name, lineIndex);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function scanPortLine(scan, line, inputs, outputs) {
|
|
154
|
+
const orphanMatch = line.match(ORPHAN_PORT_LINE_REGEX);
|
|
155
|
+
if (orphanMatch) {
|
|
156
|
+
keepOrphanLine(scan, line, orphanMatch[1]);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (isIncompletePortLine(line)) {
|
|
160
|
+
keepIncompleteLine(scan, line);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const cleanLine = line.replace(/^\s*\*\s*/, "").trim();
|
|
164
|
+
const parsed = parsePortLine(cleanLine, []);
|
|
165
|
+
if (parsed) {
|
|
166
|
+
keepParsedLine(scan, line, parsed, inputs, outputs);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
scan.preservedLines.push(line);
|
|
170
|
+
}
|
|
171
|
+
function scanPortLines(lines, inputs, outputs) {
|
|
172
|
+
const scan = {
|
|
173
|
+
preservedLines: [],
|
|
174
|
+
hasFlowWeaverTag: false,
|
|
175
|
+
seenInputs: /* @__PURE__ */ new Set(),
|
|
176
|
+
seenOutputs: /* @__PURE__ */ new Set(),
|
|
177
|
+
orphanInputLines: [],
|
|
178
|
+
orphanOutputLines: [],
|
|
179
|
+
lastInputLineIndex: -1,
|
|
180
|
+
lastOutputLineIndex: -1
|
|
181
|
+
};
|
|
182
|
+
for (const line of lines) {
|
|
183
|
+
if (line.trim() === "/**" || line.trim() === "*/") {
|
|
184
|
+
scan.preservedLines.push(line);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (PORT_TAG_REGEX.test(line)) {
|
|
188
|
+
scanPortLine(scan, line, inputs, outputs);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (line.includes("@flowWeaver")) {
|
|
192
|
+
scan.hasFlowWeaverTag = true;
|
|
193
|
+
}
|
|
194
|
+
scan.preservedLines.push(line);
|
|
195
|
+
}
|
|
196
|
+
return scan;
|
|
197
|
+
}
|
|
198
|
+
function fillOrphanLines(newLines, portsToAdd, orphanLines, direction) {
|
|
199
|
+
const remaining = [];
|
|
200
|
+
for (const [name, port] of portsToAdd) {
|
|
201
|
+
const orphanIndex = orphanLines.findIndex((o) => o.type === port.dataType);
|
|
202
|
+
if (orphanIndex !== -1) {
|
|
203
|
+
const orphan = orphanLines[orphanIndex];
|
|
204
|
+
newLines[orphan.index] = tagLine(name, port, direction);
|
|
205
|
+
orphanLines.splice(orphanIndex, 1);
|
|
206
|
+
} else if (orphanLines.length > 0) {
|
|
207
|
+
const orphan = orphanLines.shift();
|
|
208
|
+
newLines[orphan.index] = tagLine(name, port, direction);
|
|
209
|
+
} else {
|
|
210
|
+
remaining.push([name, port]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return remaining;
|
|
214
|
+
}
|
|
215
|
+
function insertOutputTags(newLines, outputsToAdd, scan) {
|
|
216
|
+
const newOutputTags = outputsToAdd.map(([name, port]) => tagLine(name, port, "output"));
|
|
217
|
+
const closingIndex = newLines.findIndex((l) => l.trim() === "*/");
|
|
218
|
+
if (newOutputTags.length === 0) return;
|
|
219
|
+
const outputInsertIndex = scan.lastOutputLineIndex >= 0 ? scan.lastOutputLineIndex + 1 : scan.lastInputLineIndex >= 0 ? scan.lastInputLineIndex + 1 : closingIndex;
|
|
220
|
+
newLines.splice(outputInsertIndex, 0, ...newOutputTags);
|
|
221
|
+
}
|
|
222
|
+
function insertInputsInSignatureOrder(newLines, inputsToAdd, signatureInputOrder2, flowWeaverIndex) {
|
|
223
|
+
const existingInputLineIndices = {};
|
|
224
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
225
|
+
const cleanLine = newLines[i].replace(/^\s*\*\s*/, "").trim();
|
|
226
|
+
const parsed = parsePortLine(cleanLine, []);
|
|
227
|
+
if (parsed && parsed.type === "input") {
|
|
228
|
+
existingInputLineIndices[parsed.name] = i;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const sortedInputsToAdd = inputsToAdd.map(([name, port]) => ({ name, port, sigIndex: signatureInputOrder2.indexOf(name) })).filter((item) => item.sigIndex !== -1).sort((a, b) => b.sigIndex - a.sigIndex);
|
|
232
|
+
for (const { name, port, sigIndex } of sortedInputsToAdd) {
|
|
233
|
+
const newTag = tagLine(name, port, "input");
|
|
234
|
+
let insertIndex = -1;
|
|
235
|
+
for (let i = sigIndex + 1; i < signatureInputOrder2.length; i++) {
|
|
236
|
+
const nextName = signatureInputOrder2[i];
|
|
237
|
+
if (existingInputLineIndices[nextName] !== void 0) {
|
|
238
|
+
insertIndex = existingInputLineIndices[nextName];
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (insertIndex === -1) {
|
|
243
|
+
for (let i = sigIndex - 1; i >= 0; i--) {
|
|
244
|
+
const prevName = signatureInputOrder2[i];
|
|
245
|
+
if (existingInputLineIndices[prevName] !== void 0) {
|
|
246
|
+
insertIndex = existingInputLineIndices[prevName] + 1;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (insertIndex === -1) {
|
|
251
|
+
insertIndex = flowWeaverIndex >= 0 ? flowWeaverIndex + 1 : 1;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
newLines.splice(insertIndex, 0, newTag);
|
|
255
|
+
for (const [portName, idx] of Object.entries(existingInputLineIndices)) {
|
|
256
|
+
if (idx >= insertIndex) {
|
|
257
|
+
existingInputLineIndices[portName] = idx + 1;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
existingInputLineIndices[name] = insertIndex;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function insertInputTags(newLines, inputsToAdd, scan, signatureInputOrder2) {
|
|
264
|
+
const flowWeaverIndex = newLines.findIndex((l) => l.includes("@flowWeaver"));
|
|
265
|
+
const scopedInputsToAdd = inputsToAdd.filter(([_, port]) => port.scope);
|
|
266
|
+
const nonScopedInputsToAdd = inputsToAdd.filter(([_, port]) => !port.scope);
|
|
267
|
+
if (signatureInputOrder2 && signatureInputOrder2.length > 0 && nonScopedInputsToAdd.length > 0) {
|
|
268
|
+
insertInputsInSignatureOrder(newLines, nonScopedInputsToAdd, signatureInputOrder2, flowWeaverIndex);
|
|
269
|
+
} else if (nonScopedInputsToAdd.length > 0) {
|
|
270
|
+
const nonScopedInputTags = nonScopedInputsToAdd.map(([name, port]) => tagLine(name, port, "input"));
|
|
271
|
+
const inputInsertIndex = scan.lastInputLineIndex >= 0 ? scan.lastInputLineIndex + 1 : flowWeaverIndex >= 0 ? flowWeaverIndex + 1 : 1;
|
|
272
|
+
newLines.splice(inputInsertIndex, 0, ...nonScopedInputTags);
|
|
273
|
+
}
|
|
274
|
+
if (scopedInputsToAdd.length > 0) {
|
|
275
|
+
const scopedInputTags = scopedInputsToAdd.map(([name, port]) => tagLine(name, port, "input"));
|
|
276
|
+
const closingIdx = newLines.findIndex((l) => l.trim() === "*/");
|
|
277
|
+
const insertIdx = scan.lastOutputLineIndex >= 0 ? scan.lastOutputLineIndex + 1 : closingIdx >= 0 ? closingIdx : newLines.length - 1;
|
|
278
|
+
newLines.splice(insertIdx, 0, ...scopedInputTags);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/jsdoc-port-sync/port-parser.ts
|
|
283
|
+
var SCOPE_TAG_REGEX2 = /\*\s*@scope\s+(\w+)/g;
|
|
284
|
+
function hasScopes(functionText) {
|
|
285
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
286
|
+
if (!jsdocMatch) return false;
|
|
287
|
+
SCOPE_TAG_REGEX2.lastIndex = 0;
|
|
288
|
+
return SCOPE_TAG_REGEX2.test(jsdocMatch[0]);
|
|
289
|
+
}
|
|
290
|
+
function getScopeNames(functionText) {
|
|
291
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
292
|
+
if (!jsdocMatch) return [];
|
|
293
|
+
const scopes = [];
|
|
294
|
+
SCOPE_TAG_REGEX2.lastIndex = 0;
|
|
295
|
+
let match;
|
|
296
|
+
while ((match = SCOPE_TAG_REGEX2.exec(jsdocMatch[0])) != null) {
|
|
297
|
+
scopes.push(match[1]);
|
|
298
|
+
}
|
|
299
|
+
return scopes;
|
|
300
|
+
}
|
|
301
|
+
function readSignatureLookup(functionText) {
|
|
302
|
+
const { params } = parseFunctionSignature(functionText);
|
|
303
|
+
const returnFields = parseReturnTypeFieldsWithTypes(functionText);
|
|
304
|
+
const paramTypeMap = /* @__PURE__ */ new Map();
|
|
305
|
+
const paramOptionalMap = /* @__PURE__ */ new Map();
|
|
306
|
+
for (const param of params) {
|
|
307
|
+
if (param.tsType) {
|
|
308
|
+
paramTypeMap.set(param.name, param.tsType);
|
|
309
|
+
}
|
|
310
|
+
if (param.optional) {
|
|
311
|
+
paramOptionalMap.set(param.name, true);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const returnTypeMap = /* @__PURE__ */ new Map();
|
|
315
|
+
for (const field of returnFields) {
|
|
316
|
+
returnTypeMap.set(field.name, field.tsType);
|
|
317
|
+
}
|
|
318
|
+
const callbackParamNames = new Set(params.filter((p) => p.tsType?.includes("=>")).map((p) => p.name));
|
|
319
|
+
return { paramTypeMap, paramOptionalMap, returnTypeMap, callbackParamNames };
|
|
320
|
+
}
|
|
321
|
+
function portMetadata(port) {
|
|
322
|
+
const metadata = {};
|
|
323
|
+
if (port.order !== void 0) metadata.order = port.order;
|
|
324
|
+
if (port.placement) metadata.placement = port.placement;
|
|
325
|
+
return Object.keys(metadata).length > 0 ? { metadata } : void 0;
|
|
326
|
+
}
|
|
327
|
+
function portType(isStepPort, tsTypeOf) {
|
|
328
|
+
if (isStepPort) return { dataType: "STEP" };
|
|
329
|
+
const tsType = tsTypeOf();
|
|
330
|
+
return { dataType: tsType ? inferDataTypeFromTS(tsType) : "ANY", tsType };
|
|
331
|
+
}
|
|
332
|
+
function inputPortDefinition(port, lookup, validatedScope) {
|
|
333
|
+
const { name, description, defaultValue, isOptional } = port;
|
|
334
|
+
const isStepPort = isExecutePort(name) || !!(validatedScope && isScopedMandatoryPort(name));
|
|
335
|
+
const { dataType, tsType } = portType(isStepPort, () => lookup.paramTypeMap.get(name));
|
|
336
|
+
const signatureOptional = lookup.paramOptionalMap.get(name) || false;
|
|
337
|
+
const portOptional = isOptional || signatureOptional;
|
|
338
|
+
return {
|
|
339
|
+
dataType,
|
|
340
|
+
...tsType && { tsType },
|
|
341
|
+
...portOptional && { optional: true },
|
|
342
|
+
...defaultValue === void 0 ? {} : { default: parseDefaultValue(defaultValue) },
|
|
343
|
+
...validatedScope && { scope: validatedScope },
|
|
344
|
+
...description && { label: description },
|
|
345
|
+
...portMetadata(port)
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function outputPortDefinition(port, lookup, validatedScope) {
|
|
349
|
+
const { name, description } = port;
|
|
350
|
+
const isStepPort = isSuccessPort(name) || isFailurePort(name) || !!(validatedScope && isScopedMandatoryPort(name));
|
|
351
|
+
const { dataType, tsType } = portType(isStepPort, () => lookup.returnTypeMap.get(name));
|
|
352
|
+
return {
|
|
353
|
+
dataType,
|
|
354
|
+
...tsType && { tsType },
|
|
355
|
+
...validatedScope && { scope: validatedScope },
|
|
356
|
+
...description && { label: description },
|
|
357
|
+
...portMetadata(port)
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function parsePortsFromFunctionText(functionText) {
|
|
361
|
+
const inputs = {};
|
|
362
|
+
const outputs = {};
|
|
363
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
364
|
+
if (!jsdocMatch) {
|
|
365
|
+
return { inputs, outputs };
|
|
366
|
+
}
|
|
367
|
+
const lookup = readSignatureLookup(functionText);
|
|
368
|
+
const hasAnyScope = getScopeNames(functionText).length > 0 || lookup.callbackParamNames.size > 0;
|
|
369
|
+
const validateScope = (scope) => scope && hasAnyScope ? scope : void 0;
|
|
370
|
+
for (const port of parsePortsFromJSDoc(jsdocMatch[0])) {
|
|
371
|
+
const { type, name, description } = port;
|
|
372
|
+
if (type === "step") {
|
|
373
|
+
const portDef = {
|
|
374
|
+
dataType: "STEP",
|
|
375
|
+
...description && { label: description }
|
|
376
|
+
};
|
|
377
|
+
if (lookup.paramTypeMap.has(name)) {
|
|
378
|
+
inputs[name] = portDef;
|
|
379
|
+
} else {
|
|
380
|
+
outputs[name] = portDef;
|
|
381
|
+
}
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (type === "input" && !inputs[name]) {
|
|
385
|
+
inputs[name] = inputPortDefinition(port, lookup, validateScope(port.scope));
|
|
386
|
+
}
|
|
387
|
+
if (type === "output" && !outputs[name]) {
|
|
388
|
+
outputs[name] = outputPortDefinition(port, lookup, validateScope(port.scope));
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return { inputs, outputs };
|
|
392
|
+
}
|
|
393
|
+
function updatePortsInFunctionText(functionText, inputs, outputs, signatureInputOrder2) {
|
|
394
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
395
|
+
const incompletePortNames = getIncompletePortNames(functionText);
|
|
396
|
+
const inputTags = Object.entries(inputs).filter(([name]) => !incompletePortNames.inputs.has(name)).map(([name, port]) => ` * ${generateJSDocPortTag(name, port, "input")}`);
|
|
397
|
+
const outputTags = Object.entries(outputs).filter(([name]) => !incompletePortNames.outputs.has(name)).map(([name, port]) => ` * ${generateJSDocPortTag(name, port, "output")}`);
|
|
398
|
+
if (!jsdocMatch) {
|
|
399
|
+
const newJsDoc2 = ["/**", " * @flowWeaver nodeType", ...inputTags, ...outputTags, " */"].join(
|
|
400
|
+
"\n"
|
|
401
|
+
);
|
|
402
|
+
return newJsDoc2 + "\n" + functionText;
|
|
403
|
+
}
|
|
404
|
+
const scan = scanPortLines(jsdocMatch[0].split("\n"), inputs, outputs);
|
|
405
|
+
const newLines = [...scan.preservedLines];
|
|
406
|
+
if (!scan.hasFlowWeaverTag) {
|
|
407
|
+
newLines.splice(1, 0, " * @flowWeaver nodeType");
|
|
408
|
+
}
|
|
409
|
+
const inputsToAdd = Object.entries(inputs).filter(
|
|
410
|
+
([name]) => !scan.seenInputs.has(name) && !incompletePortNames.inputs.has(name)
|
|
411
|
+
);
|
|
412
|
+
const outputsToAdd = Object.entries(outputs).filter(
|
|
413
|
+
([name]) => !scan.seenOutputs.has(name) && !incompletePortNames.outputs.has(name)
|
|
414
|
+
);
|
|
415
|
+
const remainingInputsToAdd = fillOrphanLines(newLines, inputsToAdd, scan.orphanInputLines, "input");
|
|
416
|
+
const remainingOutputsToAdd = fillOrphanLines(newLines, outputsToAdd, scan.orphanOutputLines, "output");
|
|
417
|
+
insertOutputTags(newLines, remainingOutputsToAdd, scan);
|
|
418
|
+
if (remainingInputsToAdd.length > 0) {
|
|
419
|
+
insertInputTags(newLines, remainingInputsToAdd, scan, signatureInputOrder2);
|
|
420
|
+
}
|
|
421
|
+
const newJsDoc = newLines.join("\n");
|
|
422
|
+
return functionText.replace(JSDOC_BLOCK_REGEX, newJsDoc);
|
|
423
|
+
}
|
|
424
|
+
function parseDefaultValue(value) {
|
|
425
|
+
try {
|
|
426
|
+
return JSON.parse(value);
|
|
427
|
+
} catch {
|
|
428
|
+
return value;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/jsdoc-port-sync/callback-signature.ts
|
|
433
|
+
function syncScopeCallbacks(functionText, scopedInputs, scopedOutputs, functionType) {
|
|
434
|
+
const scopeNames = /* @__PURE__ */ new Set([
|
|
435
|
+
...scopedInputs.map(([_, port]) => port.scope),
|
|
436
|
+
...scopedOutputs.map(([_, port]) => port.scope)
|
|
437
|
+
]);
|
|
438
|
+
let result = functionText;
|
|
439
|
+
for (const scopeName of scopeNames) {
|
|
440
|
+
const callbackParams = scopedOutputs.filter(
|
|
441
|
+
([name, port]) => port.scope === scopeName && port.dataType !== "FUNCTION" && name !== scopeName
|
|
442
|
+
);
|
|
443
|
+
const callbackReturns = scopedInputs.filter(([_, port]) => port.scope === scopeName);
|
|
444
|
+
if (callbackParams.length > 0 || callbackReturns.length > 0) {
|
|
445
|
+
result = updateCallbackInSignature(result, scopeName, callbackParams, callbackReturns, functionType);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return result;
|
|
449
|
+
}
|
|
450
|
+
function locateParamListSite(text, functionType) {
|
|
451
|
+
if (functionType === "declaration") {
|
|
452
|
+
const funcMatch = text.match(/((?:async\s+)?function\s+)(\w+)\s*\(/);
|
|
453
|
+
if (!funcMatch || funcMatch.index === void 0) return null;
|
|
454
|
+
const openParenIndex = funcMatch.index + funcMatch[0].length - 1;
|
|
455
|
+
const closeParenIndex = findBalancedClose(text, openParenIndex);
|
|
456
|
+
if (closeParenIndex === -1) return null;
|
|
457
|
+
return {
|
|
458
|
+
head: `${text.substring(0, funcMatch.index)}${funcMatch[1]}${funcMatch[2]}`,
|
|
459
|
+
paramsStr: text.substring(openParenIndex + 1, closeParenIndex),
|
|
460
|
+
tail: `)${text.substring(closeParenIndex + 1)}`
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
if (functionType === "arrow") {
|
|
464
|
+
const arrowMatch = text.match(/((?:const|let|var)\s+\w+\s*=\s*(?:async\s*)?)\(/);
|
|
465
|
+
if (!arrowMatch || arrowMatch.index === void 0) return null;
|
|
466
|
+
const openParenIndex = arrowMatch.index + arrowMatch[0].length - 1;
|
|
467
|
+
const closeParenIndex = findBalancedClose(text, openParenIndex);
|
|
468
|
+
if (closeParenIndex === -1) return null;
|
|
469
|
+
const afterParams = text.substring(closeParenIndex + 1);
|
|
470
|
+
const arrowIndex = afterParams.indexOf("=>");
|
|
471
|
+
return {
|
|
472
|
+
head: `${text.substring(0, arrowMatch.index)}${arrowMatch[1]}`,
|
|
473
|
+
paramsStr: text.substring(openParenIndex + 1, closeParenIndex),
|
|
474
|
+
tail: arrowIndex === -1 ? null : `) ${afterParams.substring(arrowIndex)}`
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
function splitParamToken(token) {
|
|
480
|
+
const callbackParam = token.trim();
|
|
481
|
+
const colonIndex = callbackParam.indexOf(":");
|
|
482
|
+
return {
|
|
483
|
+
paramName: callbackParam.substring(0, colonIndex).trim(),
|
|
484
|
+
existingType: callbackParam.substring(colonIndex + 1).trim()
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function updateCallbackInSignature(functionText, scopeName, callbackParams, callbackReturns, functionType) {
|
|
488
|
+
const site = locateParamListSite(functionText, functionType);
|
|
489
|
+
if (!site) return functionText;
|
|
490
|
+
const { paramsStr } = site;
|
|
491
|
+
const paramTokens = splitParams(paramsStr);
|
|
492
|
+
const callbackIndex = paramTokens.findIndex((p) => p.includes("=>"));
|
|
493
|
+
if (callbackIndex >= 0) {
|
|
494
|
+
const { existingType } = splitParamToken(paramTokens[callbackIndex]);
|
|
495
|
+
if (callbackHasAllPorts(existingType, callbackParams, callbackReturns)) {
|
|
496
|
+
return functionText;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const { head, tail } = site;
|
|
500
|
+
if (tail === null) return functionText;
|
|
501
|
+
if (callbackIndex >= 0) {
|
|
502
|
+
const { paramName, existingType } = splitParamToken(paramTokens[callbackIndex]);
|
|
503
|
+
const callbackType = buildCallbackType(callbackParams, callbackReturns, existingType);
|
|
504
|
+
paramTokens[callbackIndex] = `${paramName}: ${callbackType}`;
|
|
505
|
+
} else {
|
|
506
|
+
const callbackType = buildCallbackType(callbackParams, callbackReturns);
|
|
507
|
+
paramTokens.push(`${scopeName}: ${callbackType}`);
|
|
508
|
+
}
|
|
509
|
+
if (paramsStr.includes("\n")) {
|
|
510
|
+
let result = paramsStr;
|
|
511
|
+
const callbackToken = paramTokens[callbackIndex];
|
|
512
|
+
const callbackStartRegex = new RegExp(`(${scopeName}\\s*:\\s*)\\([^)]*\\)\\s*=>\\s*\\{[^}]*\\}`, "s");
|
|
513
|
+
const match = result.match(callbackStartRegex);
|
|
514
|
+
if (match) {
|
|
515
|
+
result = result.replace(callbackStartRegex, callbackToken);
|
|
516
|
+
}
|
|
517
|
+
return `${head}(${result}${tail}`;
|
|
518
|
+
}
|
|
519
|
+
const trimmedTokens = paramTokens.map((p) => p.trim());
|
|
520
|
+
return `${head}(${trimmedTokens.join(", ")}${tail}`;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// src/jsdoc-port-sync/jsdoc-to-signature.ts
|
|
524
|
+
function resolveSyncPorts(functionText, authoritativePorts) {
|
|
525
|
+
const { inputs: parsedInputs, outputs: parsedOutputs } = parsePortsFromFunctionText(functionText);
|
|
526
|
+
const returnBodyFieldTypes = parseReturnBodyFieldsWithTypes(functionText);
|
|
527
|
+
const inputs = {};
|
|
528
|
+
for (const [name, port] of Object.entries(parsedInputs)) {
|
|
529
|
+
inputs[name] = authoritativePorts?.inputs?.[name] ?? port;
|
|
530
|
+
}
|
|
531
|
+
const outputs = {};
|
|
532
|
+
for (const [name, port] of Object.entries(parsedOutputs)) {
|
|
533
|
+
const authoritative = authoritativePorts?.outputs?.[name];
|
|
534
|
+
if (authoritative) {
|
|
535
|
+
outputs[name] = authoritative;
|
|
536
|
+
} else {
|
|
537
|
+
const inferredTsType = returnBodyFieldTypes.get(name);
|
|
538
|
+
if (inferredTsType && !port.tsType) {
|
|
539
|
+
outputs[name] = { ...port, tsType: inferredTsType };
|
|
540
|
+
} else {
|
|
541
|
+
outputs[name] = port;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return { inputs, outputs };
|
|
546
|
+
}
|
|
547
|
+
var MANDATORY_RETURN_FIELDS = /* @__PURE__ */ new Set(["onSuccess", "onFailure"]);
|
|
548
|
+
function portOrder(port) {
|
|
549
|
+
const order = port.metadata?.order;
|
|
550
|
+
return typeof order === "number" ? order : Infinity;
|
|
551
|
+
}
|
|
552
|
+
function planSignatureSync(functionText, inputs, outputs) {
|
|
553
|
+
const { params, functionType } = parseFunctionSignature(functionText);
|
|
554
|
+
const orderedInputs = Object.entries(inputs).filter(([_, port]) => !port.scope).map(([name, port]) => ({ name, port, order: portOrder(port) })).sort((a, b) => a.order - b.order);
|
|
555
|
+
const existingParamNames = new Set(params.map((p) => p.name));
|
|
556
|
+
for (const match of rawParamListText(functionText).matchAll(/\b(\w+)\s*[?:]/g)) {
|
|
557
|
+
existingParamNames.add(match[1]);
|
|
558
|
+
}
|
|
559
|
+
const paramsToAdd = orderedInputs.filter(
|
|
560
|
+
({ name }) => !existingParamNames.has(name) && !RESERVED_PARAMS.includes(name)
|
|
561
|
+
);
|
|
562
|
+
const nonScopedOutputs = Object.fromEntries(
|
|
563
|
+
Object.entries(outputs).filter(([_, port]) => !port.scope)
|
|
564
|
+
);
|
|
565
|
+
const scopedInputs = Object.entries(inputs).filter(([_, port]) => port.scope);
|
|
566
|
+
const scopedOutputs = Object.entries(outputs).filter(([_, port]) => port.scope);
|
|
567
|
+
const hasScopedPorts = scopedInputs.length > 0 || scopedOutputs.length > 0;
|
|
568
|
+
const hasSyncableOutputs = Object.keys(nonScopedOutputs).length > 0;
|
|
569
|
+
const hasExecuteParam = existingParamNames.has("execute");
|
|
570
|
+
const jsDocOutputNames = new Set(Object.keys(nonScopedOutputs));
|
|
571
|
+
const hasOutputsToRemove = parseReturnTypeFields(functionText).some(
|
|
572
|
+
(field) => !jsDocOutputNames.has(field) && !MANDATORY_RETURN_FIELDS.has(field)
|
|
573
|
+
);
|
|
574
|
+
return {
|
|
575
|
+
functionType,
|
|
576
|
+
hasExecuteParam,
|
|
577
|
+
paramsToAdd,
|
|
578
|
+
nonScopedOutputs,
|
|
579
|
+
scopedInputs,
|
|
580
|
+
scopedOutputs,
|
|
581
|
+
upToDate: paramsToAdd.length === 0 && !hasScopedPorts && !hasSyncableOutputs && !hasOutputsToRemove && hasExecuteParam
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function locateParamList(text, functionType) {
|
|
585
|
+
let match = null;
|
|
586
|
+
if (functionType === "declaration") {
|
|
587
|
+
match = text.match(/function\s+\w+\s*\(/);
|
|
588
|
+
} else if (functionType === "arrow") {
|
|
589
|
+
match = text.match(/(?:const|let|var)\s+\w+\s*=\s*(?:async\s*)?\(/);
|
|
590
|
+
}
|
|
591
|
+
if (!match || match.index === void 0) return null;
|
|
592
|
+
const open = match.index + match[0].length - 1;
|
|
593
|
+
const close = findBalancedClose(text, open);
|
|
594
|
+
return close === -1 ? null : { open, close };
|
|
595
|
+
}
|
|
596
|
+
function ensureExecuteParam(text, functionType) {
|
|
597
|
+
const list = locateParamList(text, functionType);
|
|
598
|
+
if (!list) return text;
|
|
599
|
+
const existingParams = text.substring(list.open + 1, list.close).trim();
|
|
600
|
+
const sep = existingParams ? ", " : "";
|
|
601
|
+
return text.substring(0, list.open + 1) + "execute: boolean" + sep + text.substring(list.open + 1);
|
|
602
|
+
}
|
|
603
|
+
function formatParam({ name, port }) {
|
|
604
|
+
const tsType = portTypeToTsType(port.dataType);
|
|
605
|
+
if (port.optional && port.default !== void 0) {
|
|
606
|
+
return `${name}: ${tsType} = ${JSON.stringify(port.default)}`;
|
|
607
|
+
} else if (port.optional) {
|
|
608
|
+
return `${name}?: ${tsType}`;
|
|
609
|
+
}
|
|
610
|
+
return `${name}: ${tsType}`;
|
|
611
|
+
}
|
|
612
|
+
function appendParams(text, functionType, paramsToAdd) {
|
|
613
|
+
const newParamStrings = paramsToAdd.map(formatParam);
|
|
614
|
+
const list = locateParamList(text, functionType);
|
|
615
|
+
if (!list) return text;
|
|
616
|
+
let existingParams = text.substring(list.open + 1, list.close);
|
|
617
|
+
const endsWithComma = /,\s*$/.test(existingParams);
|
|
618
|
+
const isMultiline = existingParams.includes("\n");
|
|
619
|
+
let sep;
|
|
620
|
+
if (!existingParams.trim()) {
|
|
621
|
+
sep = "";
|
|
622
|
+
} else if (endsWithComma) {
|
|
623
|
+
existingParams = existingParams.replace(/,\s*$/, ",");
|
|
624
|
+
sep = "\n ";
|
|
625
|
+
} else if (isMultiline) {
|
|
626
|
+
existingParams = existingParams.trimEnd();
|
|
627
|
+
sep = ",\n ";
|
|
628
|
+
} else {
|
|
629
|
+
sep = ", ";
|
|
630
|
+
}
|
|
631
|
+
return text.substring(0, list.open + 1) + existingParams + sep + newParamStrings.join(", ") + "\n" + text.substring(list.close);
|
|
632
|
+
}
|
|
633
|
+
function returnTypeFieldList(text, nonScopedOutputs) {
|
|
634
|
+
const existingFields = /* @__PURE__ */ new Map();
|
|
635
|
+
const existingReturnTypeMatch = text.match(/\)\s*:\s*\{([^}]*)\}/);
|
|
636
|
+
if (existingReturnTypeMatch) {
|
|
637
|
+
for (const match of existingReturnTypeMatch[1].matchAll(/(\w+)\s*:\s*([^;}\s][^;}]*)?/g)) {
|
|
638
|
+
existingFields.set(match[1], match[2]?.trim() || "");
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (!existingFields.has("onSuccess")) {
|
|
642
|
+
existingFields.set("onSuccess", "boolean");
|
|
643
|
+
}
|
|
644
|
+
if (!existingFields.has("onFailure")) {
|
|
645
|
+
existingFields.set("onFailure", "boolean");
|
|
646
|
+
}
|
|
647
|
+
for (const [name, port] of Object.entries(nonScopedOutputs)) {
|
|
648
|
+
if (name === "onSuccess" || name === "onFailure") continue;
|
|
649
|
+
if (!existingFields.get(name)) {
|
|
650
|
+
existingFields.set(name, port.tsType || portTypeToTsType(port.dataType));
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
const allFields = [];
|
|
654
|
+
allFields.push(`onSuccess: ${existingFields.get("onSuccess")}`);
|
|
655
|
+
allFields.push(`onFailure: ${existingFields.get("onFailure")}`);
|
|
656
|
+
for (const [name, type] of existingFields) {
|
|
657
|
+
if (name === "onSuccess" || name === "onFailure") continue;
|
|
658
|
+
allFields.push(type ? `${name}: ${type}` : `${name}:`);
|
|
659
|
+
}
|
|
660
|
+
return allFields;
|
|
661
|
+
}
|
|
662
|
+
function syncReturnType(text, functionType, nonScopedOutputs) {
|
|
663
|
+
const returnType = `{ ${returnTypeFieldList(text, nonScopedOutputs).join("; ")} }`;
|
|
664
|
+
const list = locateParamList(text, functionType);
|
|
665
|
+
if (!list) return text;
|
|
666
|
+
const afterParen = text.substring(list.close + 1);
|
|
667
|
+
const existingReturnMatch = afterParen.match(/^\s*:\s*\{[^}]*\}/);
|
|
668
|
+
if (existingReturnMatch) {
|
|
669
|
+
return text.substring(0, list.close + 1) + ": " + returnType + afterParen.substring(existingReturnMatch[0].length);
|
|
670
|
+
}
|
|
671
|
+
const leading = afterParen.match(/^\s*/);
|
|
672
|
+
const whitespace = leading ? leading[0] : " ";
|
|
673
|
+
return text.substring(0, list.close + 1) + ": " + returnType + whitespace + afterParen.substring(whitespace.length);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// src/jsdoc-port-sync/scoped-ports.ts
|
|
677
|
+
function collectDeclaredScopes(functionText, inputs, outputs, callbackNames) {
|
|
678
|
+
const declaredScopes = /* @__PURE__ */ new Set();
|
|
679
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
680
|
+
if (jsdocMatch) {
|
|
681
|
+
const jsdoc = jsdocMatch[0];
|
|
682
|
+
SCOPE_TAG_REGEX.lastIndex = 0;
|
|
683
|
+
let scopeMatch;
|
|
684
|
+
while ((scopeMatch = SCOPE_TAG_REGEX.exec(jsdoc)) != null) {
|
|
685
|
+
declaredScopes.add(scopeMatch[1]);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
for (const port of Object.values(inputs)) {
|
|
689
|
+
if (port.scope && callbackNames.has(port.scope)) declaredScopes.add(port.scope);
|
|
690
|
+
}
|
|
691
|
+
for (const port of Object.values(outputs)) {
|
|
692
|
+
if (port.scope && callbackNames.has(port.scope)) declaredScopes.add(port.scope);
|
|
693
|
+
}
|
|
694
|
+
return declaredScopes;
|
|
695
|
+
}
|
|
696
|
+
function hasPortForScope(ports, portName, scope) {
|
|
697
|
+
return Object.entries(ports).some(
|
|
698
|
+
([name, port]) => (name === portName || port._realName === portName) && port.scope === scope
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
function addMandatoryPort(ports, portName, scope, extra) {
|
|
702
|
+
if (hasPortForScope(ports, portName, scope)) return;
|
|
703
|
+
const key = !ports[portName] || ports[portName].scope === scope ? portName : `${portName}\0${scope}`;
|
|
704
|
+
ports[key] = {
|
|
705
|
+
dataType: "STEP",
|
|
706
|
+
scope,
|
|
707
|
+
...key !== portName && { _realName: portName },
|
|
708
|
+
...extra
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function addMandatoryScopedPorts(inputs, outputs, scopes) {
|
|
712
|
+
for (const scopeName of scopes) {
|
|
713
|
+
addMandatoryPort(outputs, SCOPED_PORT_NAMES.START, scopeName);
|
|
714
|
+
addMandatoryPort(inputs, SCOPED_PORT_NAMES.SUCCESS, scopeName);
|
|
715
|
+
addMandatoryPort(inputs, SCOPED_PORT_NAMES.FAILURE, scopeName, { failure: true });
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// src/jsdoc-port-sync/signature-to-jsdoc.ts
|
|
720
|
+
var isCallbackParam = (param) => param.tsType?.includes("=>") ?? false;
|
|
721
|
+
function readSignatureShape(functionText) {
|
|
722
|
+
const { params } = parseFunctionSignature(functionText);
|
|
723
|
+
const hasReturnTypeAnnotation = /\)\s*:\s*\{[^}]+\}\s*(?:\{|=>)/.test(functionText);
|
|
724
|
+
const returnFields = hasReturnTypeAnnotation ? parseReturnTypeFields(functionText) : parseReturnFields(functionText);
|
|
725
|
+
const signatureParamNames = new Set(
|
|
726
|
+
params.filter((p) => !RESERVED_PARAMS.includes(p.name) && !isCallbackParam(p)).map((p) => p.name)
|
|
727
|
+
);
|
|
728
|
+
const inputTypeFields = parseInputTypeFields(functionText);
|
|
729
|
+
for (const field of inputTypeFields) {
|
|
730
|
+
signatureParamNames.add(field.name);
|
|
731
|
+
}
|
|
732
|
+
const callbacks = /* @__PURE__ */ new Map();
|
|
733
|
+
for (const param of params) {
|
|
734
|
+
if (param.tsType?.includes("=>")) {
|
|
735
|
+
const parsed = parseCallbackType(param.tsType);
|
|
736
|
+
const fieldNames = new Set(parsed.returnFields.map((f) => f.name));
|
|
737
|
+
callbacks.set(param.name, { hasReturnFields: fieldNames.size > 0, returnFieldNames: fieldNames });
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return {
|
|
741
|
+
params,
|
|
742
|
+
returnFields,
|
|
743
|
+
returnBodyFieldTypes: parseReturnBodyFieldsWithTypes(functionText),
|
|
744
|
+
inputTypeFields,
|
|
745
|
+
incompletePortNames: getIncompletePortNames(functionText),
|
|
746
|
+
signatureParamNames,
|
|
747
|
+
rawSigText: rawParamListText(functionText),
|
|
748
|
+
callbacks
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
function mergeSignatureInputs(existingInputs, shape) {
|
|
752
|
+
const { params, inputTypeFields, incompletePortNames } = shape;
|
|
753
|
+
const mergedInputs = { ...existingInputs };
|
|
754
|
+
for (const param of params) {
|
|
755
|
+
if (RESERVED_PARAMS.includes(param.name)) continue;
|
|
756
|
+
if (incompletePortNames.inputs.has(param.name)) continue;
|
|
757
|
+
const signatureType = tsTypeToPortType(param.tsType);
|
|
758
|
+
if (!mergedInputs[param.name]) {
|
|
759
|
+
mergedInputs[param.name] = {
|
|
760
|
+
dataType: signatureType,
|
|
761
|
+
...param.optional && { optional: true },
|
|
762
|
+
...param.defaultValue === void 0 ? {} : { default: parseDefaultValue(param.defaultValue) }
|
|
763
|
+
};
|
|
764
|
+
} else if (signatureType !== "ANY" && mergedInputs[param.name].dataType !== signatureType) {
|
|
765
|
+
const existingType = mergedInputs[param.name].dataType;
|
|
766
|
+
if (!(existingType === "STEP" && signatureType === "BOOLEAN")) {
|
|
767
|
+
mergedInputs[param.name] = {
|
|
768
|
+
...mergedInputs[param.name],
|
|
769
|
+
dataType: signatureType
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
for (const field of inputTypeFields) {
|
|
775
|
+
if (!mergedInputs[field.name] && !incompletePortNames.inputs.has(field.name)) {
|
|
776
|
+
mergedInputs[field.name] = { dataType: tsTypeToPortType(field.tsType) };
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return mergedInputs;
|
|
780
|
+
}
|
|
781
|
+
function mergeSignatureOutputs(existingOutputs, shape) {
|
|
782
|
+
const { returnFields, returnBodyFieldTypes, incompletePortNames } = shape;
|
|
783
|
+
const mergedOutputs = { ...existingOutputs };
|
|
784
|
+
for (const field of returnFields) {
|
|
785
|
+
if (!mergedOutputs[field] && !incompletePortNames.outputs.has(field)) {
|
|
786
|
+
const inferredType = returnBodyFieldTypes.get(field);
|
|
787
|
+
const dataType = inferredType ? tsTypeToPortType(inferredType) : "ANY";
|
|
788
|
+
mergedOutputs[field] = { dataType, ...inferredType && { tsType: inferredType } };
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return mergedOutputs;
|
|
792
|
+
}
|
|
793
|
+
function scopedInputIsLive(name, port, callbacks) {
|
|
794
|
+
if (!port.scope) return false;
|
|
795
|
+
const scopeCallback = callbacks.get(port.scope);
|
|
796
|
+
if (!scopeCallback) return false;
|
|
797
|
+
return scopeCallback.hasReturnFields ? scopeCallback.returnFieldNames.has(name) : true;
|
|
798
|
+
}
|
|
799
|
+
function keepLiveInputs(mergedInputs, shape) {
|
|
800
|
+
const { signatureParamNames, incompletePortNames, rawSigText, callbacks } = shape;
|
|
801
|
+
const finalInputs = {};
|
|
802
|
+
for (const [name, port] of Object.entries(mergedInputs)) {
|
|
803
|
+
const hasUserMetadata = port.metadata?.order !== void 0 || port.label !== void 0;
|
|
804
|
+
const existsInRawSig = new RegExp(`\\b${name}\\b`).test(rawSigText);
|
|
805
|
+
if (signatureParamNames.has(name) || scopedInputIsLive(name, port, callbacks) || incompletePortNames.inputs.has(name) || hasUserMetadata && existsInRawSig) {
|
|
806
|
+
finalInputs[name] = port;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return finalInputs;
|
|
810
|
+
}
|
|
811
|
+
function keepLiveOutputs(mergedOutputs, shape) {
|
|
812
|
+
const { incompletePortNames } = shape;
|
|
813
|
+
const returnFieldNames = new Set(shape.returnFields);
|
|
814
|
+
const finalOutputs = {};
|
|
815
|
+
for (const [name, port] of Object.entries(mergedOutputs)) {
|
|
816
|
+
if (returnFieldNames.has(name) || port.scope || isReservedPortName(name) || incompletePortNames.outputs.has(name)) {
|
|
817
|
+
finalOutputs[name] = port;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return finalOutputs;
|
|
821
|
+
}
|
|
822
|
+
function signatureInputOrder(shape) {
|
|
823
|
+
const { params, rawSigText } = shape;
|
|
824
|
+
const rawParamMatches = rawSigText.matchAll(/^\s*(\w+)\s*[?:]|,\s*(\w+)\s*[?:]/gm);
|
|
825
|
+
const rawParamOrder = [];
|
|
826
|
+
for (const match of rawParamMatches) {
|
|
827
|
+
const name = match[1] || match[2];
|
|
828
|
+
if (name && !RESERVED_PARAMS.includes(name) && !rawParamOrder.includes(name)) {
|
|
829
|
+
const afterName = rawSigText.substring(rawSigText.indexOf(name + ":") + name.length + 1);
|
|
830
|
+
if (!afterName.trim().startsWith("(")) {
|
|
831
|
+
rawParamOrder.push(name);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
const parsedOrder = params.filter((p) => !RESERVED_PARAMS.includes(p.name) && !isCallbackParam(p)).map((p) => p.name);
|
|
836
|
+
return rawParamOrder.length >= parsedOrder.length ? rawParamOrder : parsedOrder;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// src/jsdoc-port-sync/sync.ts
|
|
840
|
+
function syncSignatureToJSDoc(functionText) {
|
|
841
|
+
const orphanLines = hasOrphanPortLines(functionText);
|
|
842
|
+
if (orphanLines.inputs || orphanLines.outputs) {
|
|
843
|
+
return functionText;
|
|
844
|
+
}
|
|
845
|
+
const { inputs: existingInputs, outputs: existingOutputs } = parsePortsFromFunctionText(functionText);
|
|
846
|
+
const shape = readSignatureShape(functionText);
|
|
847
|
+
const inputs = keepLiveInputs(mergeSignatureInputs(existingInputs, shape), shape);
|
|
848
|
+
const outputs = keepLiveOutputs(mergeSignatureOutputs(existingOutputs, shape), shape);
|
|
849
|
+
const inputOrder = signatureInputOrder(shape);
|
|
850
|
+
const scopes = collectDeclaredScopes(functionText, inputs, outputs, shape.callbacks);
|
|
851
|
+
addMandatoryScopedPorts(inputs, outputs, scopes);
|
|
852
|
+
return updatePortsInFunctionText(functionText, inputs, outputs, inputOrder);
|
|
853
|
+
}
|
|
854
|
+
function syncJSDocToSignature(functionText, authoritativePorts) {
|
|
855
|
+
const { inputs, outputs } = resolveSyncPorts(functionText, authoritativePorts);
|
|
856
|
+
const plan = planSignatureSync(functionText, inputs, outputs);
|
|
857
|
+
if (plan.upToDate) {
|
|
858
|
+
return functionText;
|
|
859
|
+
}
|
|
860
|
+
let result = functionText;
|
|
861
|
+
if (!plan.hasExecuteParam) {
|
|
862
|
+
result = ensureExecuteParam(result, plan.functionType);
|
|
863
|
+
}
|
|
864
|
+
if (plan.paramsToAdd.length > 0) {
|
|
865
|
+
result = appendParams(result, plan.functionType, plan.paramsToAdd);
|
|
866
|
+
}
|
|
867
|
+
if (plan.scopedInputs.length > 0 || plan.scopedOutputs.length > 0) {
|
|
868
|
+
result = syncScopeCallbacks(result, plan.scopedInputs, plan.scopedOutputs, plan.functionType);
|
|
869
|
+
}
|
|
870
|
+
return syncReturnType(result, plan.functionType, plan.nonScopedOutputs);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// src/jsdoc-port-sync/rename.ts
|
|
874
|
+
function renamePortInCode(code, oldPortName, newPortName, portType2) {
|
|
875
|
+
const reservedNames = ["execute", "onSuccess", "onFailure"];
|
|
876
|
+
if (reservedNames.includes(oldPortName) || reservedNames.includes(newPortName)) {
|
|
877
|
+
return code;
|
|
878
|
+
}
|
|
879
|
+
const { inputs, outputs } = parsePortsFromFunctionText(code);
|
|
880
|
+
const allPorts = { ...inputs, ...outputs };
|
|
881
|
+
const ports = portType2 === "input" ? inputs : outputs;
|
|
882
|
+
if (!ports[oldPortName]) {
|
|
883
|
+
return code;
|
|
884
|
+
}
|
|
885
|
+
if (allPorts[newPortName]) {
|
|
886
|
+
return code;
|
|
887
|
+
}
|
|
888
|
+
let result = code;
|
|
889
|
+
const portDef = ports[oldPortName];
|
|
890
|
+
const isScoped = !!portDef.scope;
|
|
891
|
+
const tagType = portType2 === "input" ? "@input" : "@output";
|
|
892
|
+
const jsDocPattern = new RegExp(
|
|
893
|
+
`(${tagType}\\s+)(\\[?)${oldPortName}(\\]?)`,
|
|
894
|
+
"g"
|
|
895
|
+
);
|
|
896
|
+
result = result.replace(jsDocPattern, `$1$2${newPortName}$3`);
|
|
897
|
+
if (portType2 === "input") {
|
|
898
|
+
if (isScoped) {
|
|
899
|
+
result = renameFieldInReturnType(result, oldPortName, newPortName, true);
|
|
900
|
+
} else {
|
|
901
|
+
result = renameParameterInSignature(result, oldPortName, newPortName);
|
|
902
|
+
}
|
|
903
|
+
} else {
|
|
904
|
+
if (isScoped) {
|
|
905
|
+
result = renameCallbackParameter(result, oldPortName, newPortName);
|
|
906
|
+
} else {
|
|
907
|
+
result = renameFieldInReturnType(result, oldPortName, newPortName, false);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return result;
|
|
911
|
+
}
|
|
912
|
+
function renameParameterInSignature(code, oldName, newName) {
|
|
913
|
+
const paramPattern = new RegExp(
|
|
914
|
+
`([(,]\\s*)${oldName}(\\s*[?:]|\\s*=)`,
|
|
915
|
+
"g"
|
|
916
|
+
);
|
|
917
|
+
return code.replace(paramPattern, `$1${newName}$2`);
|
|
918
|
+
}
|
|
919
|
+
function removeParameterFromSignature(code, paramName) {
|
|
920
|
+
const middleOrLastPattern = new RegExp(
|
|
921
|
+
`,\\s*${paramName}\\s*[?]?\\s*:\\s*[^,)]+`,
|
|
922
|
+
"g"
|
|
923
|
+
);
|
|
924
|
+
let result = code.replace(middleOrLastPattern, "");
|
|
925
|
+
const firstWithCommaPattern = new RegExp(
|
|
926
|
+
`([(])\\s*${paramName}\\s*[?]?\\s*:\\s*[^,)]+,\\s*`,
|
|
927
|
+
"g"
|
|
928
|
+
);
|
|
929
|
+
result = result.replace(firstWithCommaPattern, "$1");
|
|
930
|
+
const onlyParamPattern = new RegExp(
|
|
931
|
+
`([(])\\s*${paramName}\\s*[?]?\\s*:\\s*[^,)]+\\s*([)])`,
|
|
932
|
+
"g"
|
|
933
|
+
);
|
|
934
|
+
result = result.replace(onlyParamPattern, "$1$2");
|
|
935
|
+
return result;
|
|
936
|
+
}
|
|
937
|
+
function removeFieldFromReturnType(code, fieldName) {
|
|
938
|
+
const middleOrLastPattern = new RegExp(
|
|
939
|
+
`[;,]\\s*${fieldName}\\s*:\\s*[^;,}]+`,
|
|
940
|
+
"g"
|
|
941
|
+
);
|
|
942
|
+
let result = code.replace(middleOrLastPattern, "");
|
|
943
|
+
const firstWithSemiPattern = new RegExp(
|
|
944
|
+
`(\\{\\s*)${fieldName}\\s*:\\s*[^;,}]+[;,]\\s*`,
|
|
945
|
+
"g"
|
|
946
|
+
);
|
|
947
|
+
result = result.replace(firstWithSemiPattern, "$1");
|
|
948
|
+
const onlyFieldPattern = new RegExp(
|
|
949
|
+
`(\\{\\s*)${fieldName}\\s*:\\s*[^;,}]+\\s*(\\})`,
|
|
950
|
+
"g"
|
|
951
|
+
);
|
|
952
|
+
result = result.replace(onlyFieldPattern, "$1$2");
|
|
953
|
+
return result;
|
|
954
|
+
}
|
|
955
|
+
function renameFieldInReturnType(code, oldName, newName, isCallback) {
|
|
956
|
+
if (isCallback) {
|
|
957
|
+
const callbackPattern = new RegExp(
|
|
958
|
+
`(=>\\s*\\{[^}]*?)\\b${oldName}(\\s*:)`,
|
|
959
|
+
"g"
|
|
960
|
+
);
|
|
961
|
+
return code.replace(callbackPattern, `$1${newName}$2`);
|
|
962
|
+
} else {
|
|
963
|
+
const returnPattern = new RegExp(
|
|
964
|
+
`(\\)\\s*:\\s*\\{[^}]*?)\\b${oldName}(\\s*:)`,
|
|
965
|
+
"g"
|
|
966
|
+
);
|
|
967
|
+
return code.replace(returnPattern, `$1${newName}$2`);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
function renameCallbackParameter(code, oldName, newName) {
|
|
971
|
+
const callbackParamPattern = new RegExp(
|
|
972
|
+
`(:\\s*\\([^)]*?)\\b${oldName}(\\s*:)`,
|
|
973
|
+
"g"
|
|
974
|
+
);
|
|
975
|
+
return code.replace(callbackParamPattern, `$1${newName}$2`);
|
|
976
|
+
}
|
|
977
|
+
function getSyncableInputNames(code) {
|
|
978
|
+
const { inputs } = parsePortsFromFunctionText(code);
|
|
979
|
+
return Object.entries(inputs).filter(([name, port]) => !port.scope && !isReservedPortName(name)).map(([name]) => name);
|
|
980
|
+
}
|
|
981
|
+
function getSyncableOutputNames(code) {
|
|
982
|
+
const { outputs } = parsePortsFromFunctionText(code);
|
|
983
|
+
return Object.entries(outputs).filter(([name, port]) => !port.scope && !isReservedPortName(name)).map(([name]) => name);
|
|
984
|
+
}
|
|
985
|
+
function getSyncableParamNames(code) {
|
|
986
|
+
const { params } = parseFunctionSignature(code);
|
|
987
|
+
return params.filter((p) => !isReservedPortName(p.name) && !p.tsType?.includes("=>")).map((p) => p.name);
|
|
988
|
+
}
|
|
989
|
+
function getSyncableReturnFieldNames(code) {
|
|
990
|
+
const returnTypeFields = parseReturnTypeFields(code);
|
|
991
|
+
return returnTypeFields.filter((f) => !isReservedPortName(f));
|
|
992
|
+
}
|
|
993
|
+
function renamePortInJSDoc(code, oldName, newName, type) {
|
|
994
|
+
const tag = type === "input" ? "@input" : "@output";
|
|
995
|
+
const pattern = new RegExp(
|
|
996
|
+
`(${tag}\\s+)${oldName}(\\b)`,
|
|
997
|
+
"g"
|
|
998
|
+
);
|
|
999
|
+
return code.replace(pattern, `$1${newName}$2`);
|
|
1000
|
+
}
|
|
1001
|
+
function syncCodeRenames(previousCode, currentCode) {
|
|
1002
|
+
if (!previousCode.trim()) {
|
|
1003
|
+
return currentCode;
|
|
1004
|
+
}
|
|
1005
|
+
const prevOrphanLines = hasOrphanPortLines(previousCode);
|
|
1006
|
+
const currOrphanLines = hasOrphanPortLines(currentCode);
|
|
1007
|
+
let result = currentCode;
|
|
1008
|
+
if (currOrphanLines.inputs) {
|
|
1009
|
+
result = removeParamsOfClearedInputs(previousCode, currentCode, result);
|
|
1010
|
+
} else if (!prevOrphanLines.inputs) {
|
|
1011
|
+
result = syncInputRenames(previousCode, currentCode, result);
|
|
1012
|
+
}
|
|
1013
|
+
if (currOrphanLines.outputs) {
|
|
1014
|
+
result = removeFieldsOfClearedOutputs(previousCode, currentCode, result);
|
|
1015
|
+
} else if (!prevOrphanLines.outputs) {
|
|
1016
|
+
result = syncOutputRenames(previousCode, currentCode, result);
|
|
1017
|
+
}
|
|
1018
|
+
return result;
|
|
1019
|
+
}
|
|
1020
|
+
function removeParamsOfClearedInputs(previousCode, currentCode, result) {
|
|
1021
|
+
const prevJSDocInputs = getSyncableInputNames(previousCode);
|
|
1022
|
+
const currJSDocInputs = getSyncableInputNames(currentCode);
|
|
1023
|
+
const currSigParams = getSyncableParamNames(currentCode);
|
|
1024
|
+
for (const prevName of prevJSDocInputs) {
|
|
1025
|
+
if (!currJSDocInputs.includes(prevName) && currSigParams.includes(prevName)) {
|
|
1026
|
+
result = removeParameterFromSignature(result, prevName);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
return result;
|
|
1030
|
+
}
|
|
1031
|
+
function syncInputRenames(previousCode, currentCode, result) {
|
|
1032
|
+
const prevJSDocInputs = getSyncableInputNames(previousCode);
|
|
1033
|
+
const currJSDocInputs = getSyncableInputNames(currentCode);
|
|
1034
|
+
const prevSigParams = getSyncableParamNames(previousCode);
|
|
1035
|
+
const currSigParams = getSyncableParamNames(currentCode);
|
|
1036
|
+
const prevJSDocSet = new Set(prevJSDocInputs);
|
|
1037
|
+
const currJSDocSet = new Set(currJSDocInputs);
|
|
1038
|
+
const prevSigSet = new Set(prevSigParams);
|
|
1039
|
+
const currSigSet = new Set(currSigParams);
|
|
1040
|
+
const rawSigText = rawParamListText(currentCode);
|
|
1041
|
+
const jsDocPortsInRawButNotParsed = currJSDocInputs.some(
|
|
1042
|
+
(name) => new RegExp(`\\b${name}\\b`).test(rawSigText) && !currSigSet.has(name)
|
|
1043
|
+
);
|
|
1044
|
+
if (jsDocPortsInRawButNotParsed) return result;
|
|
1045
|
+
for (let i = 0; i < Math.min(currJSDocInputs.length, currSigParams.length); i++) {
|
|
1046
|
+
const currJSDoc = currJSDocInputs[i];
|
|
1047
|
+
const currSig = currSigParams[i];
|
|
1048
|
+
if (currJSDoc === currSig) continue;
|
|
1049
|
+
const jsDocChanged = prevJSDocInputs[i] !== currJSDoc;
|
|
1050
|
+
const sigChanged = prevSigParams[i] !== currSig;
|
|
1051
|
+
if (jsDocChanged && !sigChanged) {
|
|
1052
|
+
const oldJSDoc = prevJSDocInputs[i];
|
|
1053
|
+
if (oldJSDoc && !currJSDocSet.has(oldJSDoc) && !prevJSDocSet.has(currJSDoc)) {
|
|
1054
|
+
result = renameParameterInSignature(result, currSig, currJSDoc);
|
|
1055
|
+
}
|
|
1056
|
+
} else if (sigChanged && !jsDocChanged) {
|
|
1057
|
+
const oldSig = prevSigParams[i];
|
|
1058
|
+
const oldNameInRawSig = new RegExp(`\\b${oldSig}\\b`).test(rawSigText);
|
|
1059
|
+
if (oldSig && !currSigSet.has(oldSig) && !prevSigSet.has(currSig) && !oldNameInRawSig) {
|
|
1060
|
+
result = renamePortInJSDoc(result, currJSDoc, currSig, "input");
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
return result;
|
|
1065
|
+
}
|
|
1066
|
+
function removeFieldsOfClearedOutputs(previousCode, currentCode, result) {
|
|
1067
|
+
const prevJSDocOutputs = getSyncableOutputNames(previousCode);
|
|
1068
|
+
const currJSDocOutputs = getSyncableOutputNames(currentCode);
|
|
1069
|
+
const currReturnFields = getSyncableReturnFieldNames(currentCode);
|
|
1070
|
+
for (const prevName of prevJSDocOutputs) {
|
|
1071
|
+
if (!currJSDocOutputs.includes(prevName) && currReturnFields.includes(prevName)) {
|
|
1072
|
+
result = removeFieldFromReturnType(result, prevName);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return result;
|
|
1076
|
+
}
|
|
1077
|
+
function syncOutputRenames(previousCode, currentCode, result) {
|
|
1078
|
+
const prevJSDocOutputs = getSyncableOutputNames(previousCode);
|
|
1079
|
+
const currJSDocOutputs = getSyncableOutputNames(currentCode);
|
|
1080
|
+
const prevReturnFields = getSyncableReturnFieldNames(previousCode);
|
|
1081
|
+
const currReturnFields = getSyncableReturnFieldNames(currentCode);
|
|
1082
|
+
const prevJSDocSet = new Set(prevJSDocOutputs);
|
|
1083
|
+
const currJSDocSet = new Set(currJSDocOutputs);
|
|
1084
|
+
const prevReturnSet = new Set(prevReturnFields);
|
|
1085
|
+
const currReturnSet = new Set(currReturnFields);
|
|
1086
|
+
for (let i = 0; i < Math.min(currJSDocOutputs.length, currReturnFields.length); i++) {
|
|
1087
|
+
const currJSDoc = currJSDocOutputs[i];
|
|
1088
|
+
const currReturn = currReturnFields[i];
|
|
1089
|
+
if (currJSDoc === currReturn) continue;
|
|
1090
|
+
const jsDocChanged = prevJSDocOutputs[i] !== currJSDoc;
|
|
1091
|
+
const returnChanged = prevReturnFields[i] !== currReturn;
|
|
1092
|
+
if (jsDocChanged && !returnChanged) {
|
|
1093
|
+
const oldJSDoc = prevJSDocOutputs[i];
|
|
1094
|
+
if (oldJSDoc && !currJSDocSet.has(oldJSDoc) && !prevJSDocSet.has(currJSDoc)) {
|
|
1095
|
+
result = renameFieldInReturnType(result, currReturn, currJSDoc, false);
|
|
1096
|
+
}
|
|
1097
|
+
} else if (returnChanged && !jsDocChanged) {
|
|
1098
|
+
const oldReturn = prevReturnFields[i];
|
|
1099
|
+
if (oldReturn && !currReturnSet.has(oldReturn) && !prevReturnSet.has(currReturn)) {
|
|
1100
|
+
result = renamePortInJSDoc(result, currJSDoc, currReturn, "output");
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
return result;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// src/jsdoc-port-sync/apply-diff.ts
|
|
1108
|
+
function tagFor(direction) {
|
|
1109
|
+
return direction === "INPUT" ? "@input" : "@output";
|
|
1110
|
+
}
|
|
1111
|
+
function removePortLines(code, removed) {
|
|
1112
|
+
let result = code;
|
|
1113
|
+
for (const { name, direction } of removed) {
|
|
1114
|
+
const tag = tagFor(direction);
|
|
1115
|
+
const lineRegex = new RegExp(`^\\s*\\*\\s*${tag}\\s+\\[?${name}\\]?(?:[^\\S\\n]+|[^\\S\\n]*-|[^\\S\\n]*\\[order|$).*$\\n?`, "gm");
|
|
1116
|
+
result = result.replace(lineRegex, "");
|
|
1117
|
+
}
|
|
1118
|
+
return result;
|
|
1119
|
+
}
|
|
1120
|
+
function renamePortTags(code, renamed) {
|
|
1121
|
+
let result = code;
|
|
1122
|
+
for (const { from, to, direction } of renamed) {
|
|
1123
|
+
const tag = tagFor(direction);
|
|
1124
|
+
const renameRegex = new RegExp(`(${tag}\\s+)(\\[?)${from}(\\]?\\b)`, "g");
|
|
1125
|
+
result = result.replace(renameRegex, `$1$2${to}$3`);
|
|
1126
|
+
}
|
|
1127
|
+
return result;
|
|
1128
|
+
}
|
|
1129
|
+
function updatePortLabels(code, labelChanged) {
|
|
1130
|
+
let result = code;
|
|
1131
|
+
for (const { name, label, direction, scope } of labelChanged) {
|
|
1132
|
+
const tag = tagFor(direction);
|
|
1133
|
+
const labelRegex = new RegExp(
|
|
1134
|
+
`(\\*\\s*${tag}\\s+\\[?${name}\\]?)(?:\\s+scope:\\w+)?(?:\\s+\\[order:\\s*\\d+\\])?(?:\\s+-\\s+[^\\n]*)?`,
|
|
1135
|
+
"g"
|
|
1136
|
+
);
|
|
1137
|
+
const beforeReplace = result;
|
|
1138
|
+
result = result.replace(labelRegex, `$1${scope ? ` scope:${scope}` : ""} - ${label}`);
|
|
1139
|
+
if (result === beforeReplace) {
|
|
1140
|
+
const scopePart = scope ? ` scope:${scope}` : "";
|
|
1141
|
+
const labelPart = ` - ${label}`;
|
|
1142
|
+
const newLine = ` * ${tag} ${name}${scopePart}${labelPart}`;
|
|
1143
|
+
result = insertBeforeClose(result, newLine);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return result;
|
|
1147
|
+
}
|
|
1148
|
+
var SIMPLE_TYPE_PATTERN = `[\\w\\[\\]\\?]+`;
|
|
1149
|
+
var STANDARD_FUNCTION_PATTERN = `\\(\\.\\.\\.args:\\s*any\\[\\]\\)\\s*=>\\s*any`;
|
|
1150
|
+
function updateParamType(code, name, tsType) {
|
|
1151
|
+
const simpleParamRegex = new RegExp(
|
|
1152
|
+
`(\\b${name}\\??\\s*):\\s*(${SIMPLE_TYPE_PATTERN})\\s*([,)])`,
|
|
1153
|
+
"g"
|
|
1154
|
+
);
|
|
1155
|
+
const result = code.replace(simpleParamRegex, `$1: ${tsType}$3`);
|
|
1156
|
+
if (result !== code) return result;
|
|
1157
|
+
const funcParamRegex = new RegExp(
|
|
1158
|
+
`(\\b${name}\\??\\s*):\\s*(${STANDARD_FUNCTION_PATTERN})\\s*([,)])`,
|
|
1159
|
+
"g"
|
|
1160
|
+
);
|
|
1161
|
+
return code.replace(funcParamRegex, `$1: ${tsType}$3`);
|
|
1162
|
+
}
|
|
1163
|
+
function updateReturnFieldType(code, name, tsType) {
|
|
1164
|
+
const returnTypeMatch = code.match(/(\)\s*:\s*)(\{[^}]+\})(\s*(?:\{|=>))/);
|
|
1165
|
+
if (!returnTypeMatch) return code;
|
|
1166
|
+
const beforeReturnType = code.substring(0, returnTypeMatch.index + returnTypeMatch[1].length);
|
|
1167
|
+
const returnTypeContent = returnTypeMatch[2];
|
|
1168
|
+
const afterReturnType = code.substring(returnTypeMatch.index + returnTypeMatch[1].length + returnTypeContent.length);
|
|
1169
|
+
const simpleReturnRegex = new RegExp(
|
|
1170
|
+
`(\\b${name}\\s*):\\s*(${SIMPLE_TYPE_PATTERN})\\s*([,;}])`,
|
|
1171
|
+
"g"
|
|
1172
|
+
);
|
|
1173
|
+
let newReturnType = returnTypeContent.replace(simpleReturnRegex, `$1: ${tsType}$3`);
|
|
1174
|
+
if (newReturnType === returnTypeContent) {
|
|
1175
|
+
const funcReturnRegex = new RegExp(
|
|
1176
|
+
`(\\b${name}\\s*):\\s*(${STANDARD_FUNCTION_PATTERN})\\s*([,;}])`,
|
|
1177
|
+
"g"
|
|
1178
|
+
);
|
|
1179
|
+
newReturnType = returnTypeContent.replace(funcReturnRegex, `$1: ${tsType}$3`);
|
|
1180
|
+
}
|
|
1181
|
+
return beforeReturnType + newReturnType + afterReturnType;
|
|
1182
|
+
}
|
|
1183
|
+
function updateSignatureTypes(code, typeChanged) {
|
|
1184
|
+
let result = code;
|
|
1185
|
+
for (const { name, type, direction } of typeChanged) {
|
|
1186
|
+
const tsType = portTypeToTsType(type);
|
|
1187
|
+
result = direction === "INPUT" ? updateParamType(result, name, tsType) : updateReturnFieldType(result, name, tsType);
|
|
1188
|
+
}
|
|
1189
|
+
return result;
|
|
1190
|
+
}
|
|
1191
|
+
function insertBeforeClose(result, newLine) {
|
|
1192
|
+
return result.replace(/(\n)(\s*\*\/)/, `$1${newLine}
|
|
1193
|
+
$2`);
|
|
1194
|
+
}
|
|
1195
|
+
function insertBeforeFirstLine(result, newLine, predicates) {
|
|
1196
|
+
const lines = result.split("\n");
|
|
1197
|
+
for (const matches of predicates) {
|
|
1198
|
+
const insertIndex = lines.findIndex(matches);
|
|
1199
|
+
if (insertIndex !== -1) {
|
|
1200
|
+
lines.splice(insertIndex, 0, newLine);
|
|
1201
|
+
return lines.join("\n");
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return insertBeforeClose(result, newLine);
|
|
1205
|
+
}
|
|
1206
|
+
var UNSCOPED_INPUT_ANCHORS = [
|
|
1207
|
+
/(\n)(\s*\*\s*@output\s+\w+\s+scope:)/,
|
|
1208
|
+
/(\n)(\s*\*\s*@input\s+\w+\s+scope:)/,
|
|
1209
|
+
/(\n)(\s*\*\s*@output\s+)/
|
|
1210
|
+
];
|
|
1211
|
+
var isScopedInputLine = (line) => /@input\s+\w+/.test(line) && line.includes("scope:");
|
|
1212
|
+
var isUnscopedOutputLine = (line) => /@output\s+\w+/.test(line) && !line.includes("scope:");
|
|
1213
|
+
function insertPortLine(code, newLine, direction, scope) {
|
|
1214
|
+
if (direction === "INPUT" && !scope) {
|
|
1215
|
+
const anchor = UNSCOPED_INPUT_ANCHORS.find((regex) => regex.test(code));
|
|
1216
|
+
return anchor ? code.replace(anchor, `$1${newLine}
|
|
1217
|
+
$2`) : insertBeforeClose(code, newLine);
|
|
1218
|
+
}
|
|
1219
|
+
if (direction === "OUTPUT" && scope) {
|
|
1220
|
+
return insertBeforeFirstLine(code, newLine, [isScopedInputLine, isUnscopedOutputLine]);
|
|
1221
|
+
}
|
|
1222
|
+
if (direction === "INPUT" && scope) {
|
|
1223
|
+
return insertBeforeFirstLine(code, newLine, [isUnscopedOutputLine]);
|
|
1224
|
+
}
|
|
1225
|
+
return insertBeforeClose(code, newLine);
|
|
1226
|
+
}
|
|
1227
|
+
function addPortLines(code, added) {
|
|
1228
|
+
let result = code;
|
|
1229
|
+
for (const { name, direction, label, scope, placement } of added) {
|
|
1230
|
+
const tag = tagFor(direction);
|
|
1231
|
+
const existsRegex = new RegExp(`@${tag === "@input" ? "input" : "output"}\\s+\\[?${name}[\\]\\s\\[\\-]?`, "i");
|
|
1232
|
+
if (existsRegex.test(result)) {
|
|
1233
|
+
continue;
|
|
1234
|
+
}
|
|
1235
|
+
const scopePart = scope ? ` scope:${scope}` : "";
|
|
1236
|
+
const placementPart = placement ? ` [placement:${placement}]` : "";
|
|
1237
|
+
const labelPart = label ? ` - ${label}` : "";
|
|
1238
|
+
const newLine = ` * ${tag} ${name}${scopePart}${placementPart}${labelPart}`;
|
|
1239
|
+
result = insertPortLine(result, newLine, direction, scope);
|
|
1240
|
+
}
|
|
1241
|
+
return result;
|
|
1242
|
+
}
|
|
1243
|
+
function applyPortsDiffToCode(code, diff) {
|
|
1244
|
+
let result = removePortLines(code, diff.removed);
|
|
1245
|
+
result = renamePortTags(result, diff.renamed);
|
|
1246
|
+
result = updatePortLabels(result, diff.labelChanged);
|
|
1247
|
+
result = updateSignatureTypes(result, diff.typeChanged);
|
|
1248
|
+
return addPortLines(result, diff.added);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
// src/jsdoc-port-sync/diff.ts
|
|
1252
|
+
function computePortsDiff(before, after) {
|
|
1253
|
+
const diff = { added: [], removed: [], renamed: [], labelChanged: [], typeChanged: [] };
|
|
1254
|
+
const beforeMap = new Map(before.map((p) => [p.name, p]));
|
|
1255
|
+
const afterMap = new Map(after.map((p) => [p.name, p]));
|
|
1256
|
+
for (const [name, port] of beforeMap) {
|
|
1257
|
+
if (!afterMap.has(name)) {
|
|
1258
|
+
diff.removed.push({ name, direction: port.direction });
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
for (const [name, port] of afterMap) {
|
|
1262
|
+
if (!beforeMap.has(name)) {
|
|
1263
|
+
diff.added.push({
|
|
1264
|
+
name,
|
|
1265
|
+
type: port.type,
|
|
1266
|
+
direction: port.direction,
|
|
1267
|
+
label: port.label,
|
|
1268
|
+
scope: port.scope,
|
|
1269
|
+
placement: port.placement
|
|
1270
|
+
});
|
|
1271
|
+
} else {
|
|
1272
|
+
const beforePort = beforeMap.get(name);
|
|
1273
|
+
if (beforePort.label !== port.label && port.label) {
|
|
1274
|
+
diff.labelChanged.push({
|
|
1275
|
+
name,
|
|
1276
|
+
label: port.label,
|
|
1277
|
+
direction: port.direction,
|
|
1278
|
+
type: port.type,
|
|
1279
|
+
scope: port.scope
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
if (beforePort.type !== port.type) {
|
|
1283
|
+
diff.typeChanged.push({
|
|
1284
|
+
name,
|
|
1285
|
+
type: port.type,
|
|
1286
|
+
direction: port.direction
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
if (diff.removed.length === 1 && diff.added.length === 1) {
|
|
1292
|
+
const removed = diff.removed[0];
|
|
1293
|
+
const added = diff.added[0];
|
|
1294
|
+
const removedPort = before.find((p) => p.name === removed.name);
|
|
1295
|
+
if (removedPort && removedPort.type === added.type && removedPort.direction === added.direction) {
|
|
1296
|
+
diff.renamed.push({ from: removed.name, to: added.name, direction: added.direction });
|
|
1297
|
+
diff.removed = [];
|
|
1298
|
+
diff.added = [];
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return diff;
|
|
1302
|
+
}
|
|
1303
|
+
function portOrder2(port) {
|
|
1304
|
+
const order = port.metadata?.order;
|
|
1305
|
+
return typeof order === "number" ? order : Infinity;
|
|
1306
|
+
}
|
|
1307
|
+
function orderedPortTags(inputs, outputs) {
|
|
1308
|
+
const sortedInputs = Object.entries(inputs).sort((a, b) => portOrder2(a[1]) - portOrder2(b[1]));
|
|
1309
|
+
const sortedOutputs = Object.entries(outputs).sort((a, b) => portOrder2(a[1]) - portOrder2(b[1]));
|
|
1310
|
+
const externalInputs = sortedInputs.filter(([_, p]) => !p.scope);
|
|
1311
|
+
const scopedInputs = sortedInputs.filter(([_, p]) => p.scope);
|
|
1312
|
+
const externalOutputs = sortedOutputs.filter(([_, p]) => !p.scope);
|
|
1313
|
+
const scopedOutputs = sortedOutputs.filter(([_, p]) => p.scope);
|
|
1314
|
+
const externalInputTags = externalInputs.map(
|
|
1315
|
+
([name, port]) => ` * ${generateJSDocPortTag(name, port, "input")}`
|
|
1316
|
+
);
|
|
1317
|
+
const scopedOutputTags = scopedOutputs.map(
|
|
1318
|
+
([name, port]) => ` * ${generateJSDocPortTag(name, port, "output")}`
|
|
1319
|
+
);
|
|
1320
|
+
const scopedInputTags = scopedInputs.map(
|
|
1321
|
+
([name, port]) => ` * ${generateJSDocPortTag(name, port, "input")}`
|
|
1322
|
+
);
|
|
1323
|
+
const externalOutputTags = externalOutputs.map(
|
|
1324
|
+
([name, port]) => ` * ${generateJSDocPortTag(name, port, "output")}`
|
|
1325
|
+
);
|
|
1326
|
+
return [...externalInputTags, ...scopedOutputTags, ...scopedInputTags, ...externalOutputTags];
|
|
1327
|
+
}
|
|
1328
|
+
function jsdocLinesWithoutPorts(existingJsDoc) {
|
|
1329
|
+
const preservedLines = [];
|
|
1330
|
+
let hasFlowWeaverTag = false;
|
|
1331
|
+
for (const line of existingJsDoc.split("\n")) {
|
|
1332
|
+
if (line.trim() === "/**" || line.trim() === "*/") {
|
|
1333
|
+
preservedLines.push(line);
|
|
1334
|
+
continue;
|
|
1335
|
+
}
|
|
1336
|
+
if (PORT_TAG_REGEX.test(line)) {
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
if (line.includes("@flowWeaver")) {
|
|
1340
|
+
hasFlowWeaverTag = true;
|
|
1341
|
+
}
|
|
1342
|
+
preservedLines.push(line);
|
|
1343
|
+
}
|
|
1344
|
+
if (!hasFlowWeaverTag) {
|
|
1345
|
+
preservedLines.splice(1, 0, " * @flowWeaver nodeType");
|
|
1346
|
+
}
|
|
1347
|
+
return preservedLines;
|
|
1348
|
+
}
|
|
1349
|
+
function dropTrailingEmptyLines(lines) {
|
|
1350
|
+
let closingIdx = lines.findIndex((l) => l.trim() === "*/");
|
|
1351
|
+
while (closingIdx > 1) {
|
|
1352
|
+
const prevLine = lines[closingIdx - 1];
|
|
1353
|
+
const isEmptyJsDocLine = /^\s*\*\s*$/.test(prevLine);
|
|
1354
|
+
const isBlankLine = prevLine.trim() === "";
|
|
1355
|
+
if (isEmptyJsDocLine || isBlankLine) {
|
|
1356
|
+
lines.splice(closingIdx - 1, 1);
|
|
1357
|
+
closingIdx--;
|
|
1358
|
+
} else {
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
function formatPortsInFunctionText(functionText, inputs, outputs) {
|
|
1364
|
+
const jsdocMatch = functionText.match(JSDOC_BLOCK_REGEX);
|
|
1365
|
+
const allPortTags = orderedPortTags(inputs, outputs);
|
|
1366
|
+
if (!jsdocMatch) {
|
|
1367
|
+
const newJsDoc2 = [
|
|
1368
|
+
"/**",
|
|
1369
|
+
" * @flowWeaver nodeType",
|
|
1370
|
+
...allPortTags,
|
|
1371
|
+
" */"
|
|
1372
|
+
].join("\n");
|
|
1373
|
+
return newJsDoc2 + "\n" + functionText;
|
|
1374
|
+
}
|
|
1375
|
+
const newLines = jsdocLinesWithoutPorts(jsdocMatch[0]);
|
|
1376
|
+
dropTrailingEmptyLines(newLines);
|
|
1377
|
+
const insertIndex = newLines.findIndex((l) => l.trim() === "*/");
|
|
1378
|
+
newLines.splice(insertIndex, 0, ...allPortTags);
|
|
1379
|
+
const newJsDoc = newLines.join("\n");
|
|
1380
|
+
return functionText.replace(JSDOC_BLOCK_REGEX, newJsDoc);
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
export {
|
|
1384
|
+
hasOrphanPortLines,
|
|
1385
|
+
getIncompletePortNames,
|
|
1386
|
+
hasScopes,
|
|
1387
|
+
getScopeNames,
|
|
1388
|
+
parsePortsFromFunctionText,
|
|
1389
|
+
updatePortsInFunctionText,
|
|
1390
|
+
syncSignatureToJSDoc,
|
|
1391
|
+
syncJSDocToSignature,
|
|
1392
|
+
renamePortInCode,
|
|
1393
|
+
syncCodeRenames,
|
|
1394
|
+
applyPortsDiffToCode,
|
|
1395
|
+
computePortsDiff,
|
|
1396
|
+
formatPortsInFunctionText
|
|
1397
|
+
};
|