@oomol-lab/open-flow 0.1.0-beta.73 → 0.1.0-beta.75
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 +36 -0
- package/NOTICE +7 -0
- package/README.md +41 -0
- package/dist/browser/{ContentIcon-CUQHjQIw.js → ContentIcon-FCpKiwjp.js} +2 -1
- package/dist/browser/{FlowCanvas-Dtf8_cQp.js → FlowCanvas-dzRBnlUT.js} +1 -1
- package/dist/browser/{createResourceDialog-BWJkjiOO.js → createResourceDialog-BeYDdUl-.js} +2 -2
- package/dist/browser/{dialog-CUy_fwx9.js → dialog-ZtpsFbl4.js} +337 -31
- package/dist/browser/{exportSvg-BOoy7-Db.js → exportSvg-DqXw1yf-.js} +2 -2
- package/dist/browser/{flowChanges-CgSnSqqP.js → flowChanges-b_5UobFj.js} +586 -87
- package/dist/browser/{flowWorkspace-Bf7H-r0t.js → flowWorkspace-ItojZbO4.js} +21162 -20242
- package/dist/browser/preview.css +254 -179
- package/dist/browser/preview.js +22201 -20625
- package/dist/browser/{typeScriptSession-B0hC-C8y.js → typeScriptSession-CSRwWmZm.js} +1 -1
- package/dist/browser/ui.css +72 -2
- package/dist/browser/workbench.css +254 -179
- package/dist/browser/workbench.js +22 -78
- package/dist/browser/{workbenchSelect-C3e4J93X.js → workbenchSelect-M441Lz0d.js} +1 -1
- package/dist/command/index.js +42 -42
- package/dist/common/authoring.d.ts +5 -5
- package/dist/common/authoringExamples.d.ts +3 -2
- package/dist/common/authoringFields.d.ts +1 -1
- package/dist/common/authoringSchema.d.ts +95 -8
- package/dist/common/connector-proxy.d.ts +1 -1
- package/dist/common/control-api-conformance.d.ts +1 -1
- package/dist/common/control-api-conformance.js +119 -31
- package/dist/common/control-api.d.ts +4 -3
- package/dist/common/control-api.js +117 -29
- package/dist/common/control-requests.d.ts +5 -4
- package/dist/common/control-requests.js +437 -103
- package/dist/common/cron-trigger.d.ts +1 -1
- package/dist/common/decision.d.ts +1 -1
- package/dist/common/draftOperations.d.ts +1 -1
- package/dist/common/engine-contract.d.ts +4 -2
- package/dist/common/event-source-definition.d.ts +1 -1
- package/dist/common/flow-agent.d.ts +1 -1
- package/dist/{browser → common}/flow-authoring-node.d.ts +3 -3
- package/dist/{browser → common}/flow-authoring.js +131 -30
- package/dist/{browser → common}/flow-change-schema.d.ts +177 -6
- package/dist/{browser → common}/flow-change.d.ts +35 -15
- package/dist/{browser → common}/flow-change.js +133 -32
- package/dist/common/flow-connectionUsage.d.ts +1 -1
- package/dist/common/flow-encoding.d.ts +1 -1
- package/dist/common/flow-encoding.js +89 -23
- package/dist/common/flow-errorHandling.d.ts +1 -1
- package/dist/common/flow-graph.d.ts +3 -2
- package/dist/common/flow-modules.d.ts +1 -1
- package/dist/common/flow-promptTemplate.d.ts +1 -1
- package/dist/common/flow-retry.d.ts +2 -2
- package/dist/common/flow-semantics.d.ts +1 -1
- package/dist/common/flow-semantics.js +966 -614
- package/dist/common/flow-workflowFile.d.ts +1 -1
- package/dist/common/flowInspection.d.ts +3 -3
- package/dist/common/http-request.d.ts +156 -0
- package/dist/common/http-request.js +5254 -0
- package/dist/common/integration-trigger.d.ts +1 -1
- package/dist/common/licenses.md +118 -1
- package/dist/common/liveDetails.d.ts +1 -1
- package/dist/common/mcp.d.ts +5 -4
- package/dist/common/mcp.js +117 -29
- package/dist/common/openapi.d.ts +1 -1
- package/dist/common/poll-trigger.d.ts +1 -1
- package/dist/common/run-events.js +11 -9
- package/dist/common/run-results.d.ts +8 -1
- package/dist/common/runtime-contract.d.ts +8 -2
- package/dist/common/runtime-contract.js +25 -5
- package/dist/common/scheduler-checkpoint.d.ts +1 -1
- package/dist/common/scheduler-dependencies.d.ts +1 -1
- package/dist/common/scheduler-node-execution.d.ts +1 -1
- package/dist/common/scheduler.d.ts +3 -3
- package/dist/common/scheduler.js +101 -33
- package/dist/common/trigger-catalog.d.ts +1 -1
- package/dist/common/trigger-config-options.d.ts +1 -1
- package/dist/common/trigger-config.d.ts +1 -1
- package/dist/common/trigger-contract.d.ts +2 -2
- package/dist/common/trigger-localization.d.ts +1 -1
- package/dist/common/webhook-response.d.ts +1 -3
- package/dist/common/webhook-trigger.d.ts +1 -1
- package/dist/common/webhook-trigger.js +12 -11
- package/dist/common/workflow.d.ts +17 -1
- package/dist/common/workflow.js +68 -22
- package/dist/index.d.ts +6 -3
- package/package.json +11 -6
- package/skills/open-flow/references/flow-authoring.md +1 -0
- package/skills/open-flow/references/flow-n8n-conversion.md +19 -15
- package/src/base/common/json.ts +90 -0
- package/src/canvas/common/commands.ts +15 -0
- package/src/connector/common/actionSchema.ts +168 -0
- package/src/connector/common/proxy.ts +44 -0
- package/src/control/common/api.ts +1506 -0
- package/src/control/common/authoring.ts +923 -0
- package/src/control/common/authoringCondition.ts +110 -0
- package/src/control/common/authoringDiagnosticFields.ts +136 -0
- package/src/control/common/authoringExamples.ts +200 -0
- package/src/control/common/authoringFields.ts +53 -0
- package/src/control/common/authoringLlm.ts +70 -0
- package/src/control/common/authoringOpenApi.ts +129 -0
- package/src/control/common/authoringSchema.ts +410 -0
- package/src/control/common/authoringTools.ts +123 -0
- package/src/control/common/authoringTriggers.ts +26 -0
- package/src/control/common/checkDecoders.ts +65 -0
- package/src/control/common/conformance.ts +1989 -0
- package/src/control/common/connectorDecoders.ts +370 -0
- package/src/control/common/connectorQueries.ts +61 -0
- package/src/control/common/decoding.ts +60 -0
- package/src/control/common/draftOperations.ts +61 -0
- package/src/control/common/errors.ts +114 -0
- package/src/control/common/eventSourceSchemas.ts +13 -0
- package/src/control/common/eventSources.ts +186 -0
- package/src/control/common/flowDecoders.ts +153 -0
- package/src/control/common/flowInspection.ts +181 -0
- package/src/control/common/flowNotifications.ts +37 -0
- package/src/control/common/liveDetails.ts +124 -0
- package/src/control/common/mcp.ts +241 -0
- package/src/control/common/mcpConformance.ts +142 -0
- package/src/control/common/providerAccess.ts +28 -0
- package/src/control/common/providerIconSprite.ts +42 -0
- package/src/control/common/publicationDecoders.ts +98 -0
- package/src/control/common/random.ts +16 -0
- package/src/control/common/requests.ts +112 -0
- package/src/control/common/resultQuery.ts +8 -0
- package/src/control/common/results.ts +176 -0
- package/src/control/common/revisionDecoders.ts +52 -0
- package/src/control/common/runDecoders.ts +240 -0
- package/src/control/common/triggerCatalog.ts +89 -0
- package/src/control/common/triggerDecoders.ts +175 -0
- package/src/decision/common/decision.ts +168 -0
- package/src/event-source/common/catalog.generated.json +65 -0
- package/src/event-source/common/definition.ts +66 -0
- package/src/event-source/common/index.ts +99 -0
- package/src/execution/common/checkpoint.ts +311 -0
- package/src/execution/common/dependencies.ts +440 -0
- package/src/execution/common/engineContract.ts +84 -0
- package/src/execution/common/events.ts +331 -0
- package/src/execution/common/node-execution.ts +469 -0
- package/src/execution/common/runLifecycle.ts +250 -0
- package/src/execution/common/runtime.ts +563 -0
- package/src/execution/common/scheduler.ts +697 -0
- package/src/execution/common/wait.ts +36 -0
- package/src/flow/common/agent.ts +305 -0
- package/src/flow/common/authoring.ts +30 -0
- package/src/flow/common/change.ts +1037 -0
- package/src/flow/common/changeSchema.ts +792 -0
- package/src/flow/common/codePermissions.ts +2 -0
- package/src/flow/common/condition.ts +265 -0
- package/src/flow/common/connectionUsage.ts +131 -0
- package/src/flow/common/edgeChanges.ts +35 -0
- package/src/flow/common/encoding.ts +437 -0
- package/src/flow/common/errorHandling.ts +34 -0
- package/src/flow/common/graph.ts +898 -0
- package/src/flow/common/inputValue.ts +16 -0
- package/src/flow/common/json.ts +8 -0
- package/src/flow/common/moduleChanges.ts +31 -0
- package/src/flow/common/modules.ts +292 -0
- package/src/flow/common/nodeChanges.ts +762 -0
- package/src/flow/common/portChanges.ts +36 -0
- package/src/flow/common/promptTemplate.ts +15 -0
- package/src/flow/common/retry.ts +20 -0
- package/src/flow/common/schema.ts +162 -0
- package/src/flow/common/schemaCompare.ts +176 -0
- package/src/flow/common/schemaComparer.ts +178 -0
- package/src/flow/common/schemaKeywords.ts +53 -0
- package/src/flow/common/semantics.ts +531 -0
- package/src/flow/common/sourceField.ts +35 -0
- package/src/flow/common/triggerScheduleSchema.ts +8 -0
- package/src/flow/common/wait.ts +30 -0
- package/src/flow/common/webhookMethod.ts +7 -0
- package/src/flow/common/webhookResponse.ts +71 -0
- package/src/flow/common/workflowFile.ts +97 -0
- package/src/http/common/authBindings.ts +12 -0
- package/src/http/common/headers.ts +5 -0
- package/src/http/common/httpRequest.ts +251 -0
- package/src/json-schema-subset/checker/array.ts +142 -0
- package/src/json-schema-subset/checker/cache.ts +57 -0
- package/src/json-schema-subset/checker/checker.ts +230 -0
- package/src/json-schema-subset/checker/enumAndConst.ts +113 -0
- package/src/json-schema-subset/checker/equals.ts +93 -0
- package/src/json-schema-subset/checker/numeric/checker.ts +50 -0
- package/src/json-schema-subset/checker/numeric/float.ts +121 -0
- package/src/json-schema-subset/checker/numeric/index.ts +1 -0
- package/src/json-schema-subset/checker/numeric/integer.ts +119 -0
- package/src/json-schema-subset/checker/numeric/integerNormalizer.ts +72 -0
- package/src/json-schema-subset/checker/object.ts +354 -0
- package/src/json-schema-subset/checker/range.ts +91 -0
- package/src/json-schema-subset/checker/string.ts +60 -0
- package/src/json-schema-subset/checker/tools/index.ts +3 -0
- package/src/json-schema-subset/checker/tools/mark.ts +82 -0
- package/src/json-schema-subset/checker/tools/quantum.ts +106 -0
- package/src/json-schema-subset/checker/tools/range.ts +210 -0
- package/src/json-schema-subset/checker/validator.ts +23 -0
- package/src/json-schema-subset/compiler/array.ts +163 -0
- package/src/json-schema-subset/compiler/combination.ts +109 -0
- package/src/json-schema-subset/compiler/common.ts +99 -0
- package/src/json-schema-subset/compiler/compiler.ts +188 -0
- package/src/json-schema-subset/compiler/enumAndConst.ts +75 -0
- package/src/json-schema-subset/compiler/index.ts +11 -0
- package/src/json-schema-subset/compiler/object.ts +411 -0
- package/src/json-schema-subset/compiler/primitive.ts +144 -0
- package/src/json-schema-subset/compiler/utils.ts +24 -0
- package/src/json-schema-subset/compiler/wrapper.ts +192 -0
- package/src/json-schema-subset/error.ts +55 -0
- package/src/json-schema-subset/expression/calculator.ts +442 -0
- package/src/json-schema-subset/expression/combination.ts +49 -0
- package/src/json-schema-subset/expression/expression.ts +191 -0
- package/src/json-schema-subset/expression/index.ts +25 -0
- package/src/json-schema-subset/expression/result.ts +88 -0
- package/src/json-schema-subset/expression/types.ts +36 -0
- package/src/json-schema-subset/extends/extendsContext.ts +89 -0
- package/src/json-schema-subset/extends/index.ts +2 -0
- package/src/json-schema-subset/extends/types.ts +12 -0
- package/src/json-schema-subset/global.ts +60 -0
- package/src/json-schema-subset/index.ts +8 -0
- package/src/json-schema-subset/preprocessing.ts +74 -0
- package/src/json-schema-subset/types.ts +8 -0
- package/src/json-schema-subset/utils.ts +95 -0
- package/src/localization/common/languages.ts +118 -0
- package/src/localization/common/timeZone.ts +25 -0
- package/src/openapi/common/openapi.ts +459 -0
- package/src/trigger/common/config.ts +56 -0
- package/src/trigger/common/configOptions.ts +15 -0
- package/src/trigger/common/configSchema.ts +8 -0
- package/src/trigger/common/contract.ts +132 -0
- package/src/trigger/common/cron.ts +151 -0
- package/src/trigger/common/integration.ts +498 -0
- package/src/trigger/common/poll.ts +187 -0
- package/src/trigger/common/webhook.ts +413 -0
- package/src/trigger/providers/airtable/locales/fr.json +18 -0
- package/src/trigger/providers/airtable/locales/ja.json +18 -0
- package/src/trigger/providers/airtable/locales/ko.json +18 -0
- package/src/trigger/providers/airtable/locales/ru.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-CN.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-TW.json +18 -0
- package/src/trigger/providers/asana/locales/fr.json +15 -0
- package/src/trigger/providers/asana/locales/ja.json +15 -0
- package/src/trigger/providers/asana/locales/ko.json +15 -0
- package/src/trigger/providers/asana/locales/ru.json +15 -0
- package/src/trigger/providers/asana/locales/zh-CN.json +15 -0
- package/src/trigger/providers/asana/locales/zh-TW.json +15 -0
- package/src/trigger/providers/calendly/locales/fr.json +16 -0
- package/src/trigger/providers/calendly/locales/ja.json +16 -0
- package/src/trigger/providers/calendly/locales/ko.json +16 -0
- package/src/trigger/providers/calendly/locales/ru.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-CN.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-TW.json +16 -0
- package/src/trigger/providers/catalog.generated.json +4996 -0
- package/src/trigger/providers/clickup/locales/fr.json +16 -0
- package/src/trigger/providers/clickup/locales/ja.json +16 -0
- package/src/trigger/providers/clickup/locales/ko.json +16 -0
- package/src/trigger/providers/clickup/locales/ru.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-CN.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-TW.json +16 -0
- package/src/trigger/providers/definitions.ts +19 -0
- package/src/trigger/providers/feishu/locales/fr.json +20 -0
- package/src/trigger/providers/feishu/locales/ja.json +20 -0
- package/src/trigger/providers/feishu/locales/ko.json +20 -0
- package/src/trigger/providers/feishu/locales/ru.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-CN.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-TW.json +20 -0
- package/src/trigger/providers/fieldDescriptions.ts +392 -0
- package/src/trigger/providers/fieldLabels.ts +256 -0
- package/src/trigger/providers/fireflies/locales/fr.json +17 -0
- package/src/trigger/providers/fireflies/locales/ja.json +17 -0
- package/src/trigger/providers/fireflies/locales/ko.json +17 -0
- package/src/trigger/providers/fireflies/locales/ru.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-CN.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-TW.json +17 -0
- package/src/trigger/providers/github/locales/fr.json +30 -0
- package/src/trigger/providers/github/locales/ja.json +30 -0
- package/src/trigger/providers/github/locales/ko.json +30 -0
- package/src/trigger/providers/github/locales/ru.json +30 -0
- package/src/trigger/providers/github/locales/zh-CN.json +30 -0
- package/src/trigger/providers/github/locales/zh-TW.json +30 -0
- package/src/trigger/providers/gitlab/locales/fr.json +18 -0
- package/src/trigger/providers/gitlab/locales/ja.json +18 -0
- package/src/trigger/providers/gitlab/locales/ko.json +18 -0
- package/src/trigger/providers/gitlab/locales/ru.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-TW.json +18 -0
- package/src/trigger/providers/gmail/locales/fr.json +18 -0
- package/src/trigger/providers/gmail/locales/ja.json +18 -0
- package/src/trigger/providers/gmail/locales/ko.json +18 -0
- package/src/trigger/providers/gmail/locales/ru.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-TW.json +18 -0
- package/src/trigger/providers/google-calendar/locales/fr.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ja.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ko.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ru.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-CN.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-TW.json +15 -0
- package/src/trigger/providers/google-drive/locales/fr.json +48 -0
- package/src/trigger/providers/google-drive/locales/ja.json +48 -0
- package/src/trigger/providers/google-drive/locales/ko.json +48 -0
- package/src/trigger/providers/google-drive/locales/ru.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-CN.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-TW.json +48 -0
- package/src/trigger/providers/google-sheets/locales/fr.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ja.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ko.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ru.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-CN.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-TW.json +19 -0
- package/src/trigger/providers/intercom/locales/fr.json +17 -0
- package/src/trigger/providers/intercom/locales/ja.json +17 -0
- package/src/trigger/providers/intercom/locales/ko.json +17 -0
- package/src/trigger/providers/intercom/locales/ru.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-TW.json +17 -0
- package/src/trigger/providers/jira/locales/fr.json +17 -0
- package/src/trigger/providers/jira/locales/ja.json +17 -0
- package/src/trigger/providers/jira/locales/ko.json +17 -0
- package/src/trigger/providers/jira/locales/ru.json +17 -0
- package/src/trigger/providers/jira/locales/zh-CN.json +17 -0
- package/src/trigger/providers/jira/locales/zh-TW.json +17 -0
- package/src/trigger/providers/linear/locales/fr.json +13 -0
- package/src/trigger/providers/linear/locales/ja.json +13 -0
- package/src/trigger/providers/linear/locales/ko.json +13 -0
- package/src/trigger/providers/linear/locales/ru.json +13 -0
- package/src/trigger/providers/linear/locales/zh-CN.json +13 -0
- package/src/trigger/providers/linear/locales/zh-TW.json +13 -0
- package/src/trigger/providers/locales/fr.ts +71 -0
- package/src/trigger/providers/locales/ja.ts +71 -0
- package/src/trigger/providers/locales/ko.ts +71 -0
- package/src/trigger/providers/locales/ru.ts +71 -0
- package/src/trigger/providers/locales/zh-CN.ts +71 -0
- package/src/trigger/providers/locales/zh-TW.ts +71 -0
- package/src/trigger/providers/localization.ts +59 -0
- package/src/trigger/providers/notion/locales/fr.json +16 -0
- package/src/trigger/providers/notion/locales/ja.json +16 -0
- package/src/trigger/providers/notion/locales/ko.json +16 -0
- package/src/trigger/providers/notion/locales/ru.json +16 -0
- package/src/trigger/providers/notion/locales/zh-CN.json +16 -0
- package/src/trigger/providers/notion/locales/zh-TW.json +16 -0
- package/src/trigger/providers/one-drive/locales/fr.json +16 -0
- package/src/trigger/providers/one-drive/locales/ja.json +16 -0
- package/src/trigger/providers/one-drive/locales/ko.json +16 -0
- package/src/trigger/providers/one-drive/locales/ru.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-CN.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-TW.json +16 -0
- package/src/trigger/providers/outlook/locales/fr.json +18 -0
- package/src/trigger/providers/outlook/locales/ja.json +18 -0
- package/src/trigger/providers/outlook/locales/ko.json +18 -0
- package/src/trigger/providers/outlook/locales/ru.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-CN.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-TW.json +18 -0
- package/src/trigger/providers/pandadoc/locales/fr.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ja.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ko.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ru.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-CN.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-TW.json +12 -0
- package/src/trigger/providers/pipedrive/locales/fr.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ja.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ko.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ru.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-CN.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-TW.json +15 -0
- package/src/trigger/providers/remote.ts +163 -0
- package/src/trigger/providers/resend/locales/fr.json +16 -0
- package/src/trigger/providers/resend/locales/ja.json +16 -0
- package/src/trigger/providers/resend/locales/ko.json +16 -0
- package/src/trigger/providers/resend/locales/ru.json +16 -0
- package/src/trigger/providers/resend/locales/zh-CN.json +16 -0
- package/src/trigger/providers/resend/locales/zh-TW.json +16 -0
- package/src/trigger/providers/sentry/locales/fr.json +19 -0
- package/src/trigger/providers/sentry/locales/ja.json +19 -0
- package/src/trigger/providers/sentry/locales/ko.json +19 -0
- package/src/trigger/providers/sentry/locales/ru.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-CN.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-TW.json +19 -0
- package/src/trigger/providers/shopify/locales/fr.json +18 -0
- package/src/trigger/providers/shopify/locales/ja.json +18 -0
- package/src/trigger/providers/shopify/locales/ko.json +18 -0
- package/src/trigger/providers/shopify/locales/ru.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-CN.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slack/locales/fr.json +18 -0
- package/src/trigger/providers/slack/locales/ja.json +18 -0
- package/src/trigger/providers/slack/locales/ko.json +18 -0
- package/src/trigger/providers/slack/locales/ru.json +18 -0
- package/src/trigger/providers/slack/locales/zh-CN.json +18 -0
- package/src/trigger/providers/slack/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slackbot/locales/fr.json +23 -0
- package/src/trigger/providers/slackbot/locales/ja.json +23 -0
- package/src/trigger/providers/slackbot/locales/ko.json +23 -0
- package/src/trigger/providers/slackbot/locales/ru.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-CN.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-TW.json +23 -0
- package/src/trigger/providers/source-events.ts +25 -0
- package/src/trigger/providers/stripe/locales/fr.json +17 -0
- package/src/trigger/providers/stripe/locales/ja.json +17 -0
- package/src/trigger/providers/stripe/locales/ko.json +17 -0
- package/src/trigger/providers/stripe/locales/ru.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-CN.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-TW.json +17 -0
- package/src/trigger/providers/tally/locales/fr.json +12 -0
- package/src/trigger/providers/tally/locales/ja.json +12 -0
- package/src/trigger/providers/tally/locales/ko.json +12 -0
- package/src/trigger/providers/tally/locales/ru.json +12 -0
- package/src/trigger/providers/tally/locales/zh-CN.json +12 -0
- package/src/trigger/providers/tally/locales/zh-TW.json +12 -0
- package/src/trigger/providers/telegram/locales/fr.json +17 -0
- package/src/trigger/providers/telegram/locales/ja.json +17 -0
- package/src/trigger/providers/telegram/locales/ko.json +17 -0
- package/src/trigger/providers/telegram/locales/ru.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-CN.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-TW.json +17 -0
- package/src/trigger/providers/typeform/locales/fr.json +12 -0
- package/src/trigger/providers/typeform/locales/ja.json +12 -0
- package/src/trigger/providers/typeform/locales/ko.json +12 -0
- package/src/trigger/providers/typeform/locales/ru.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-CN.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-TW.json +12 -0
- package/src/trigger/providers/vercel/locales/fr.json +18 -0
- package/src/trigger/providers/vercel/locales/ja.json +18 -0
- package/src/trigger/providers/vercel/locales/ko.json +18 -0
- package/src/trigger/providers/vercel/locales/ru.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-CN.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-TW.json +18 -0
- package/src/trigger/providers/woocommerce/locales/fr.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ja.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ko.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ru.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-CN.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-TW.json +19 -0
- package/src/trigger/providers/zendesk/locales/fr.json +15 -0
- package/src/trigger/providers/zendesk/locales/ja.json +15 -0
- package/src/trigger/providers/zendesk/locales/ko.json +15 -0
- package/src/trigger/providers/zendesk/locales/ru.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-CN.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-TW.json +15 -0
- package/src/trigger/providers/zoom/locales/fr.json +17 -0
- package/src/trigger/providers/zoom/locales/ja.json +17 -0
- package/src/trigger/providers/zoom/locales/ko.json +17 -0
- package/src/trigger/providers/zoom/locales/ru.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-TW.json +17 -0
- package/src/types/index.ts +112 -0
- package/src/workflow/common/workflow.ts +273 -0
- package/dist/browser/lib-DrKav3HG.js +0 -11403
- /package/dist/{browser → common}/flow-authoring-edge.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring-module.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring.d.ts +0 -0
- /package/dist/{browser → common}/flow-input-value.d.ts +0 -0
- /package/dist/{browser → common}/webhook-method.d.ts +0 -0
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
import type { ChangeOperation, FlowDocument, JsonValue, RevisionContent } from './change.ts'
|
|
2
|
+
|
|
3
|
+
import { dequal } from 'dequal/lite'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
import { limitDecisionTask } from '../../decision/common/decision.ts'
|
|
6
|
+
import { assertHttpAuthBindings } from '../../http/common/authBindings.ts'
|
|
7
|
+
import { httpRequestExecutorSchema } from '../../http/common/httpRequest.ts'
|
|
8
|
+
import { checkJsonDepth } from './json.ts'
|
|
9
|
+
import { retryConfigurationSchema } from './retry.ts'
|
|
10
|
+
import { triggerScheduleSchema } from './triggerScheduleSchema.ts'
|
|
11
|
+
import { waitAutoContinueDraftSchema, waitAutoContinueSchema } from './wait.ts'
|
|
12
|
+
import { webhookMethods } from './webhookMethod.ts'
|
|
13
|
+
import { webhookResponseTimeout } from './webhookResponse.ts'
|
|
14
|
+
|
|
15
|
+
export const currentFlowModelVersion = 11
|
|
16
|
+
const text = z.string()
|
|
17
|
+
const actionConnection = text.describe(
|
|
18
|
+
'Account selection: omit while unconfigured; use an account ID to select it; use "" to explicitly defer configuration. Deferred Actions fail if called; deferred Agent tools are excluded from the callable tool set. Not supported by Triggers.',
|
|
19
|
+
)
|
|
20
|
+
const json = z.json()
|
|
21
|
+
const strings = z.array(text)
|
|
22
|
+
const port = z.object({ description: text.optional(), jsonSchema: json, nullable: z.boolean(), handle: text })
|
|
23
|
+
const workflowInputDefs = z.array(port.strict())
|
|
24
|
+
const input = port.extend({ value: json.optional() })
|
|
25
|
+
const group = z.object({ collapsed: z.boolean().optional(), group: text })
|
|
26
|
+
const nodeSource = z.object({ kind: z.literal('node'), nodeId: text, output: text, system: z.literal(true).optional(), field: text.optional() })
|
|
27
|
+
const source = z.union([nodeSource, z.object({ kind: z.literal('binding'), bindingId: text })])
|
|
28
|
+
const fixedInput = z.union([z.object({ kind: z.literal('unset') }), z.object({ kind: z.literal('value'), value: json })])
|
|
29
|
+
const mapping = z.union([fixedInput, z.object({ kind: z.literal('sources'), sources: z.array(source) })])
|
|
30
|
+
const inputs = z.record(text, mapping)
|
|
31
|
+
const ports = { inputs: z.array(z.union([input, group])), outputs: z.array(z.union([port, group])) }
|
|
32
|
+
const legacyCapability = z.strictObject({
|
|
33
|
+
kind: z.literal('connector'),
|
|
34
|
+
action: text,
|
|
35
|
+
connectionId: text.optional(),
|
|
36
|
+
connections: z.array(z.strictObject({ connectionId: text, alias: text.optional() })),
|
|
37
|
+
})
|
|
38
|
+
export const connectorCapabilitySchema = z.union([
|
|
39
|
+
legacyCapability,
|
|
40
|
+
z.strictObject({ kind: z.literal('connector'), mode: z.literal('shared') }),
|
|
41
|
+
z.strictObject({
|
|
42
|
+
kind: z.literal('connector'),
|
|
43
|
+
mode: z.literal('independent'),
|
|
44
|
+
actions: z.array(z.strictObject({ action: text, connectionId: actionConnection.optional() })),
|
|
45
|
+
}),
|
|
46
|
+
z.strictObject({
|
|
47
|
+
kind: z.literal('connector'),
|
|
48
|
+
actionHints: z.array(text).optional(),
|
|
49
|
+
connectionHints: z.array(z.strictObject({ action: text, connectionId: text, alias: text.optional() })).optional(),
|
|
50
|
+
}),
|
|
51
|
+
])
|
|
52
|
+
export const workflowCapabilitySchema = z.strictObject({
|
|
53
|
+
kind: z.literal('workflow'),
|
|
54
|
+
name: text,
|
|
55
|
+
flowId: text,
|
|
56
|
+
revisionId: text,
|
|
57
|
+
inputs: z.array(port),
|
|
58
|
+
outputs: z.array(port).nullable(),
|
|
59
|
+
})
|
|
60
|
+
const capability = z.union([connectorCapabilitySchema, workflowCapabilitySchema])
|
|
61
|
+
const inline = z.object({ ...ports, name: text, moduleId: text, capabilities: z.array(capability).optional() })
|
|
62
|
+
const agentValue = z.union([z.object({ kind: z.literal('value'), value: json }), z.object({ kind: z.literal('input'), input: text })])
|
|
63
|
+
const agentInput = z.union([agentValue, z.object({ kind: z.literal('model') })])
|
|
64
|
+
export const agentToolFields = {
|
|
65
|
+
id: text,
|
|
66
|
+
name: text,
|
|
67
|
+
description: text,
|
|
68
|
+
approval: z.boolean(),
|
|
69
|
+
inputs: z.array(input.extend({ source: agentInput })),
|
|
70
|
+
}
|
|
71
|
+
export const connectorAgentToolSchema = z.object({
|
|
72
|
+
...agentToolFields,
|
|
73
|
+
kind: z.literal('connector').optional(),
|
|
74
|
+
action: text,
|
|
75
|
+
connectionId: actionConnection.optional(),
|
|
76
|
+
})
|
|
77
|
+
export const workflowAgentToolSchema = workflowCapabilitySchema.extend(agentToolFields)
|
|
78
|
+
const decisionQuestion = z.discriminatedUnion('type', [
|
|
79
|
+
z.strictObject({
|
|
80
|
+
name: text,
|
|
81
|
+
instructions: text,
|
|
82
|
+
type: z.literal('noul'),
|
|
83
|
+
criteria: z.strictObject({ true: text.optional(), false: text.optional() }).optional(),
|
|
84
|
+
}),
|
|
85
|
+
z.strictObject({ name: text, instructions: text, type: z.literal('choice'), criteria: z.array(z.strictObject({ name: text, description: text })) }),
|
|
86
|
+
z.strictObject({ name: text, instructions: text, type: z.literal('score'), criteria: strings }),
|
|
87
|
+
])
|
|
88
|
+
const managedFields = z.object({
|
|
89
|
+
...ports,
|
|
90
|
+
name: text,
|
|
91
|
+
executor: z.union([
|
|
92
|
+
z.object({ kind: z.literal('connector'), action: text, connectionId: actionConnection.optional(), outputMode: z.literal('value').optional() }),
|
|
93
|
+
z.object({
|
|
94
|
+
kind: z.literal('openapi'),
|
|
95
|
+
sourceUrl: text,
|
|
96
|
+
method: text,
|
|
97
|
+
path: text,
|
|
98
|
+
serverUrl: text,
|
|
99
|
+
document: json,
|
|
100
|
+
auth: z.array(z.object({ id: text, type: z.enum(['bearer', 'basic', 'apiKey']), name: text.optional(), in: z.enum(['header', 'query']).optional() })),
|
|
101
|
+
}),
|
|
102
|
+
z.strictObject({ kind: z.literal('decision'), questions: z.array(decisionQuestion) }),
|
|
103
|
+
z.object({ kind: z.literal('llm'), mode: z.enum(['chat', 'json']) }),
|
|
104
|
+
z.object({
|
|
105
|
+
kind: z.literal('agent'),
|
|
106
|
+
code: z.boolean().optional(),
|
|
107
|
+
model: text,
|
|
108
|
+
prompt: text,
|
|
109
|
+
maxRounds: z.number(),
|
|
110
|
+
tools: z.array(z.union([workflowAgentToolSchema, connectorAgentToolSchema])),
|
|
111
|
+
notification: z
|
|
112
|
+
.object({
|
|
113
|
+
action: text,
|
|
114
|
+
connectionId: actionConnection.optional(),
|
|
115
|
+
inputDefinitions: z.array(input),
|
|
116
|
+
messageHandle: text,
|
|
117
|
+
inputs: z.record(text, agentValue),
|
|
118
|
+
})
|
|
119
|
+
.optional(),
|
|
120
|
+
}),
|
|
121
|
+
z.strictObject({ kind: z.literal('workflow'), flowId: text, revisionId: text }),
|
|
122
|
+
httpRequestExecutorSchema,
|
|
123
|
+
]),
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const managed = managedFields.transform(limitDecisionTask)
|
|
127
|
+
const operand = z.union([
|
|
128
|
+
z.object({ kind: z.literal('value'), value: json.optional(), jsonSchema: json.optional() }),
|
|
129
|
+
z.object({ kind: z.literal('source'), source }),
|
|
130
|
+
])
|
|
131
|
+
const condition = {
|
|
132
|
+
matchMode: z.enum(['first', 'all']),
|
|
133
|
+
cases: z.array(
|
|
134
|
+
z.object({
|
|
135
|
+
description: text.optional(),
|
|
136
|
+
output: text,
|
|
137
|
+
groups: z.array(
|
|
138
|
+
z.object({
|
|
139
|
+
expressions: z.array(
|
|
140
|
+
z.object({
|
|
141
|
+
left: operand,
|
|
142
|
+
operator: z.enum([
|
|
143
|
+
'!=',
|
|
144
|
+
'<',
|
|
145
|
+
'<=',
|
|
146
|
+
'==',
|
|
147
|
+
'>',
|
|
148
|
+
'>=',
|
|
149
|
+
'contains',
|
|
150
|
+
'endsWith',
|
|
151
|
+
'hasKey',
|
|
152
|
+
'hasValue',
|
|
153
|
+
'isEmpty',
|
|
154
|
+
'isFalse',
|
|
155
|
+
'isNotEmpty',
|
|
156
|
+
'isNotNull',
|
|
157
|
+
'isNull',
|
|
158
|
+
'isTrue',
|
|
159
|
+
'notContains',
|
|
160
|
+
'notHasKey',
|
|
161
|
+
'notHasValue',
|
|
162
|
+
'startsWith',
|
|
163
|
+
]),
|
|
164
|
+
right: operand.optional(),
|
|
165
|
+
}),
|
|
166
|
+
),
|
|
167
|
+
}),
|
|
168
|
+
),
|
|
169
|
+
}),
|
|
170
|
+
),
|
|
171
|
+
}
|
|
172
|
+
const wait = {
|
|
173
|
+
inputDefinitions: z.array(input),
|
|
174
|
+
prompt: text,
|
|
175
|
+
}
|
|
176
|
+
const webhookOptions = z.object({
|
|
177
|
+
allowedMethods: z.never().optional(),
|
|
178
|
+
allowedOrigins: strings.optional(),
|
|
179
|
+
noResponseBody: z.never().optional(),
|
|
180
|
+
responseBody: z
|
|
181
|
+
.discriminatedUnion('kind', [
|
|
182
|
+
z.strictObject({
|
|
183
|
+
kind: z.literal('workflow-outputs'),
|
|
184
|
+
output: text.optional(),
|
|
185
|
+
timeoutMs: z.number().int().min(webhookResponseTimeout.minMs).max(webhookResponseTimeout.maxMs).optional(),
|
|
186
|
+
}),
|
|
187
|
+
z.strictObject({
|
|
188
|
+
kind: z.literal('webhook-response'),
|
|
189
|
+
nodeId: text.optional(),
|
|
190
|
+
timeoutMs: z.number().int().min(webhookResponseTimeout.minMs).max(webhookResponseTimeout.maxMs).optional(),
|
|
191
|
+
}),
|
|
192
|
+
])
|
|
193
|
+
.optional(),
|
|
194
|
+
responseData: text.optional(),
|
|
195
|
+
responseHeaders: z.record(text, text).optional(),
|
|
196
|
+
responseHeadersSource: z.strictObject({ kind: z.literal('workflow-outputs'), output: text.optional() }).optional(),
|
|
197
|
+
responseHeaderOutputs: z.record(text, text).optional(),
|
|
198
|
+
responseStatusCode: z.number().int().min(200).max(599).optional(),
|
|
199
|
+
responseStatusCodeOutput: text.optional(),
|
|
200
|
+
})
|
|
201
|
+
const webhook = {
|
|
202
|
+
bodyFields: z.array(input),
|
|
203
|
+
method: z.enum(webhookMethods),
|
|
204
|
+
options: webhookOptions.optional(),
|
|
205
|
+
}
|
|
206
|
+
const definition = {
|
|
207
|
+
configInputs: ports.inputs,
|
|
208
|
+
definitionVersion: z.literal(2),
|
|
209
|
+
description: text,
|
|
210
|
+
displayName: text,
|
|
211
|
+
key: text,
|
|
212
|
+
name: text,
|
|
213
|
+
outputs: z
|
|
214
|
+
.array(port)
|
|
215
|
+
.refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, 'Duplicate Trigger output handle.'),
|
|
216
|
+
provider: text,
|
|
217
|
+
}
|
|
218
|
+
const endpoint = z.object({
|
|
219
|
+
body: z.object({ allowArray: z.boolean(), allowEmpty: z.boolean(), formats: z.array(z.enum(['form', 'json', 'multipart', 'text'])) }),
|
|
220
|
+
methods: z.array(z.enum(['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT'])),
|
|
221
|
+
successStatus: z.number(),
|
|
222
|
+
})
|
|
223
|
+
const sourceFlowIds = z.array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, 'Duplicate source Flow ID.')
|
|
224
|
+
const trigger = { name: text, description: text.optional(), icon: text.optional() }
|
|
225
|
+
const base = {
|
|
226
|
+
maxExecutions: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
227
|
+
inputs,
|
|
228
|
+
name: text.optional(),
|
|
229
|
+
description: text.optional(),
|
|
230
|
+
icon: text.optional(),
|
|
231
|
+
timeoutMs: z.number().optional(),
|
|
232
|
+
retry: retryConfigurationSchema.optional(),
|
|
233
|
+
onError: z.enum(['stop', 'error']).optional(),
|
|
234
|
+
}
|
|
235
|
+
const node = z.union([
|
|
236
|
+
z.strictObject({ ...base, kind: z.literal('webhook-response'), retry: z.never().optional(), onError: z.never().optional() }),
|
|
237
|
+
z.strictObject({ ...base, kind: z.literal('outputs'), outputDefs: z.array(port.strict()), outputMappings: inputs }).omit({ inputs: true }),
|
|
238
|
+
z.object({ ...base, inputs: z.record(text, z.never()), kind: z.literal('condition'), ...condition }),
|
|
239
|
+
z.object({
|
|
240
|
+
...base,
|
|
241
|
+
inputs: z
|
|
242
|
+
.unknown()
|
|
243
|
+
.transform(() => ({}))
|
|
244
|
+
.default({}),
|
|
245
|
+
kind: z.literal('value'),
|
|
246
|
+
values: z.array(input),
|
|
247
|
+
}),
|
|
248
|
+
z.object({ ...base, kind: z.literal('task'), task: z.union([inline, managed]), additionalInputs: z.array(input).optional() }),
|
|
249
|
+
z.strictObject({ ...base, kind: z.literal('approval'), ...wait }).omit({ timeoutMs: true }),
|
|
250
|
+
z.strictObject({ ...base, kind: z.literal('wait'), ...wait, autoContinue: waitAutoContinueDraftSchema.optional() }).omit({ timeoutMs: true }),
|
|
251
|
+
z.object({ ...trigger, kind: z.literal('manual') }),
|
|
252
|
+
z.strictObject({ ...trigger, kind: z.literal('start'), inputDefs: workflowInputDefs }),
|
|
253
|
+
z.strictObject({ ...trigger, kind: z.literal('error'), sourceFlowIds: sourceFlowIds.optional() }),
|
|
254
|
+
z.object({ ...trigger, kind: z.literal('webhook'), ...webhook }),
|
|
255
|
+
z.object({ ...trigger, kind: z.literal('cron'), cronTimes: triggerScheduleSchema }),
|
|
256
|
+
z.object({
|
|
257
|
+
...trigger,
|
|
258
|
+
kind: z.literal('poll'),
|
|
259
|
+
connectionId: text.min(1).optional(),
|
|
260
|
+
config: z.record(text, fixedInput),
|
|
261
|
+
definition: z.object({ ...definition, type: z.literal('poll') }),
|
|
262
|
+
pollTimes: triggerScheduleSchema,
|
|
263
|
+
}),
|
|
264
|
+
z.object({
|
|
265
|
+
...trigger,
|
|
266
|
+
kind: z.literal('integration'),
|
|
267
|
+
connectionId: text.min(1).optional(),
|
|
268
|
+
config: z.record(text, fixedInput),
|
|
269
|
+
definition: z.object({ ...definition, type: z.literal('integration'), endpoint }),
|
|
270
|
+
}),
|
|
271
|
+
])
|
|
272
|
+
/** Configuration schemas shared by the node authoring boundary. */
|
|
273
|
+
export const authoringDefinitionSchemas = {
|
|
274
|
+
input,
|
|
275
|
+
port,
|
|
276
|
+
ports,
|
|
277
|
+
condition: z.strictObject(condition),
|
|
278
|
+
wait: z.strictObject(wait),
|
|
279
|
+
waitAutoContinue: waitAutoContinueSchema,
|
|
280
|
+
webhook: z.strictObject(webhook),
|
|
281
|
+
schedule: triggerScheduleSchema,
|
|
282
|
+
capabilities: z.array(capability),
|
|
283
|
+
connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
|
|
284
|
+
openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
|
|
285
|
+
decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
|
|
286
|
+
llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
|
|
287
|
+
agent: managedFields.shape.executor.options[4].omit({ kind: true, notification: true }).strict(),
|
|
288
|
+
}
|
|
289
|
+
const edge = z.object({ source: text, target: text, sourceHandle: text.optional() })
|
|
290
|
+
const at = { nodeId: text, target: z.never().optional() }
|
|
291
|
+
const graph = z.object({ nodes: z.record(text, node), edges: z.array(edge).default([]) })
|
|
292
|
+
const binding = z.object({ kind: z.literal('variable'), target: text })
|
|
293
|
+
const module = z.object({ name: text, imports: strings, source: text })
|
|
294
|
+
const document = z.preprocess(
|
|
295
|
+
normalizeDocument,
|
|
296
|
+
z.object({
|
|
297
|
+
bindings: z.record(text, binding),
|
|
298
|
+
graph,
|
|
299
|
+
}),
|
|
300
|
+
)
|
|
301
|
+
const revision = z.object({
|
|
302
|
+
modelVersion: z.union([
|
|
303
|
+
z.literal(2),
|
|
304
|
+
z.literal(4),
|
|
305
|
+
z.literal(5),
|
|
306
|
+
z.literal(6),
|
|
307
|
+
z.literal(7),
|
|
308
|
+
z.literal(8),
|
|
309
|
+
z.literal(9),
|
|
310
|
+
z.literal(10),
|
|
311
|
+
z.literal(currentFlowModelVersion),
|
|
312
|
+
]),
|
|
313
|
+
document,
|
|
314
|
+
modules: z.record(text, module),
|
|
315
|
+
})
|
|
316
|
+
const envelope = revision.extend({ kind: z.literal('open-flow-flow-revision'), version: z.literal(1) })
|
|
317
|
+
|
|
318
|
+
function normalizeDocument(value: unknown): unknown {
|
|
319
|
+
const candidate = record(value)
|
|
320
|
+
if (
|
|
321
|
+
candidate.tasks !== undefined &&
|
|
322
|
+
(candidate.tasks === null || typeof candidate.tasks !== 'object' || Array.isArray(candidate.tasks) || Object.keys(candidate.tasks).length > 0)
|
|
323
|
+
)
|
|
324
|
+
throw new TypeError('Independent Task definitions are no longer supported.')
|
|
325
|
+
if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record(candidateNode), 'taskId')))
|
|
326
|
+
throw new TypeError('Task references are no longer supported.')
|
|
327
|
+
const subflows = candidate.subflows
|
|
328
|
+
if (subflows !== undefined && (subflows === null || typeof subflows !== 'object' || Array.isArray(subflows) || Object.keys(subflows).length > 0))
|
|
329
|
+
throw new TypeError('Subflows are no longer supported.')
|
|
330
|
+
if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => record(candidateNode).kind === 'subflow'))
|
|
331
|
+
throw new TypeError('Subflow nodes are no longer supported.')
|
|
332
|
+
if (['inputDefs', 'outputDefs', 'outputMappings'].some((field) => Object.hasOwn(candidate, field)))
|
|
333
|
+
throw new TypeError('Workflow interface configuration must belong to Start and Outputs nodes.')
|
|
334
|
+
if (
|
|
335
|
+
Object.values(record(record(candidate.graph).nodes)).some(
|
|
336
|
+
(candidateNode) => record(candidateNode).kind == 'start' && Object.hasOwn(record(candidateNode), 'parameters'),
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
throw new TypeError('Legacy Start.parameters is unsupported; configure node.inputDefs.')
|
|
340
|
+
return value
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Explicit storage upgrade only. Normal reads and authoring still reject retired fields. */
|
|
344
|
+
export function upgradeWorkflowInterfaceDocument(value: unknown): unknown {
|
|
345
|
+
const candidate = record(value)
|
|
346
|
+
const sourceGraph = record(candidate.graph)
|
|
347
|
+
const sourceNodes = record(sourceGraph.nodes)
|
|
348
|
+
const needsUpgrade =
|
|
349
|
+
['inputDefs', 'outputDefs', 'outputMappings'].some((field) => Object.hasOwn(candidate, field)) ||
|
|
350
|
+
Object.values(sourceNodes).some((entry) => {
|
|
351
|
+
const candidateNode = record(entry)
|
|
352
|
+
return (
|
|
353
|
+
(candidateNode.kind == 'start' && (!Object.hasOwn(candidateNode, 'inputDefs') || Object.hasOwn(candidateNode, 'parameters'))) ||
|
|
354
|
+
(candidateNode.kind == 'outputs' && (!Object.hasOwn(candidateNode, 'outputDefs') || !Object.hasOwn(candidateNode, 'outputMappings')))
|
|
355
|
+
)
|
|
356
|
+
})
|
|
357
|
+
if (!needsUpgrade) return value
|
|
358
|
+
if (candidate.graph !== sourceGraph || sourceGraph.nodes !== sourceNodes) throw new TypeError('Cannot migrate an invalid workflow graph.')
|
|
359
|
+
const starts = Object.values(sourceNodes).filter((entry) => record(entry).kind == 'start')
|
|
360
|
+
const outputs = Object.values(sourceNodes).filter((entry) => record(entry).kind == 'outputs')
|
|
361
|
+
if (starts.length > 1 || outputs.length > 1) throw new TypeError('Cannot migrate duplicate Start or Outputs nodes.')
|
|
362
|
+
const { inputDefs, outputDefs, outputMappings, ...sourceDocument } = candidate
|
|
363
|
+
if (starts.length == 0 && inputDefs !== undefined && workflowInputDefs.parse(inputDefs).length > 0)
|
|
364
|
+
throw new TypeError('Cannot migrate inputDefs without a Start node.')
|
|
365
|
+
if (
|
|
366
|
+
outputs.length == 0 &&
|
|
367
|
+
((outputDefs !== undefined && workflowInputDefs.parse(outputDefs).length > 0) ||
|
|
368
|
+
(outputMappings !== undefined && Object.keys(inputs.parse(outputMappings)).length > 0))
|
|
369
|
+
)
|
|
370
|
+
throw new TypeError('Cannot migrate output configuration without an Outputs node.')
|
|
371
|
+
return {
|
|
372
|
+
...sourceDocument,
|
|
373
|
+
graph: {
|
|
374
|
+
...sourceGraph,
|
|
375
|
+
nodes: Object.fromEntries(
|
|
376
|
+
Object.entries(sourceNodes).map(([id, nodeValue]) => {
|
|
377
|
+
const candidateNode = record(nodeValue)
|
|
378
|
+
if (candidateNode.kind == 'start') {
|
|
379
|
+
const { parameters, ...rest } = candidateNode
|
|
380
|
+
return [id, { ...rest, inputDefs: workflowInputDefs.parse(mergeInterfaceConfiguration([candidateNode.inputDefs, parameters, inputDefs], [])) }]
|
|
381
|
+
}
|
|
382
|
+
if (candidateNode.kind == 'outputs')
|
|
383
|
+
return [
|
|
384
|
+
id,
|
|
385
|
+
{
|
|
386
|
+
...candidateNode,
|
|
387
|
+
outputDefs: workflowInputDefs.parse(mergeInterfaceConfiguration([candidateNode.outputDefs, outputDefs], [])),
|
|
388
|
+
outputMappings: inputs.parse(mergeInterfaceConfiguration([candidateNode.outputMappings, outputMappings], {})),
|
|
389
|
+
},
|
|
390
|
+
]
|
|
391
|
+
return [id, nodeValue]
|
|
392
|
+
}),
|
|
393
|
+
),
|
|
394
|
+
},
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function mergeInterfaceConfiguration(values: unknown[], fallback: unknown): unknown {
|
|
399
|
+
const present = values.filter((value) => value !== undefined)
|
|
400
|
+
if (present.some((value) => !dequal(value, present[0]))) throw new TypeError('Conflicting workflow interface configuration.')
|
|
401
|
+
return present.length == 0 ? fallback : present[0]
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function record(value: unknown): Record<string, unknown> {
|
|
405
|
+
return value != null && typeof value == 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function upgradeLegacySources(value: unknown, resolutionIds: ReadonlySet<string>): unknown {
|
|
409
|
+
if (!Array.isArray(value)) return value
|
|
410
|
+
return value.map((sourceCandidate) => {
|
|
411
|
+
const candidate = record(sourceCandidate)
|
|
412
|
+
return candidate.kind == 'node' && typeof candidate.nodeId == 'string' && resolutionIds.has(candidate.nodeId) && candidate.output == 'notification'
|
|
413
|
+
? { ...candidate, output: 'pending' }
|
|
414
|
+
: sourceCandidate
|
|
415
|
+
})
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function upgradeLegacyInputs(value: unknown, resolutionIds: ReadonlySet<string>): unknown {
|
|
419
|
+
return Object.fromEntries(
|
|
420
|
+
Object.entries(record(value)).map(([handle, inputCandidate]) => {
|
|
421
|
+
const inputMapping = record(inputCandidate)
|
|
422
|
+
return [handle, inputMapping.kind == 'sources' ? { ...inputMapping, sources: upgradeLegacySources(inputMapping.sources, resolutionIds) } : inputCandidate]
|
|
423
|
+
}),
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function upgradeLegacyGraph(value: unknown): { readonly graph: unknown; readonly resolutionIds: ReadonlySet<string> } {
|
|
428
|
+
const candidate = record(value)
|
|
429
|
+
const resolutionIds = new Set<string>()
|
|
430
|
+
const nodes = Object.fromEntries(
|
|
431
|
+
Object.entries(record(candidate.nodes)).map(([id, nodeCandidate]) => {
|
|
432
|
+
const graphNode = record(nodeCandidate)
|
|
433
|
+
if (graphNode.kind == 'approval') throw new TypeError('Legacy Flow models do not support Approval nodes.')
|
|
434
|
+
if (graphNode.kind != 'wait') return [id, nodeCandidate]
|
|
435
|
+
const actions = graphNode.actions
|
|
436
|
+
let kind: 'approval' | 'wait'
|
|
437
|
+
if (Array.isArray(actions) && actions.length == 1 && actions[0] == 'continue') kind = 'wait'
|
|
438
|
+
else if (Array.isArray(actions) && actions.length == 2 && actions[0] == 'approve' && actions[1] == 'reject') kind = 'approval'
|
|
439
|
+
else throw new TypeError('Legacy Wait actions are invalid.')
|
|
440
|
+
resolutionIds.add(id)
|
|
441
|
+
const { actions: _, input: legacyInput, ...upgraded } = graphNode
|
|
442
|
+
return [id, { ...upgraded, inputDefinitions: [legacyInput], kind }]
|
|
443
|
+
}),
|
|
444
|
+
)
|
|
445
|
+
for (const [id, nodeCandidate] of Object.entries(nodes)) {
|
|
446
|
+
const graphNode = record(nodeCandidate)
|
|
447
|
+
if (graphNode.inputs != null) nodes[id] = { ...graphNode, inputs: upgradeLegacyInputs(graphNode.inputs, resolutionIds) }
|
|
448
|
+
}
|
|
449
|
+
const edges = Array.isArray(candidate.edges)
|
|
450
|
+
? candidate.edges.map((edgeCandidate) => {
|
|
451
|
+
const graphEdge = record(edgeCandidate)
|
|
452
|
+
return typeof graphEdge.source == 'string' && resolutionIds.has(graphEdge.source) && graphEdge.sourceHandle == 'notification'
|
|
453
|
+
? { ...graphEdge, sourceHandle: 'pending' }
|
|
454
|
+
: edgeCandidate
|
|
455
|
+
})
|
|
456
|
+
: candidate.edges
|
|
457
|
+
return { graph: { ...candidate, nodes, edges }, resolutionIds }
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function upgradeLegacyDocument(value: unknown): unknown {
|
|
461
|
+
const candidate = record(value)
|
|
462
|
+
const root = upgradeLegacyGraph(candidate.graph)
|
|
463
|
+
return { ...candidate, graph: root.graph }
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function repairedEntries<Value>(value: unknown, schema: z.ZodType<Value>, repair?: (value: unknown) => unknown): Record<string, Value> {
|
|
467
|
+
return Object.fromEntries(
|
|
468
|
+
Object.entries(record(value)).flatMap(([key, candidate]) => {
|
|
469
|
+
const result = schema.safeParse(repair?.(candidate) ?? candidate)
|
|
470
|
+
return result.success ? [[key, result.data] as const] : []
|
|
471
|
+
}),
|
|
472
|
+
)
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function repairTriggerNode(value: unknown): unknown {
|
|
476
|
+
const candidate = record(value)
|
|
477
|
+
if (candidate.kind == 'webhook' && candidate.bodyFields == null && candidate.inputsDef != null)
|
|
478
|
+
return { ...candidate, bodyFields: candidate.inputsDef, inputsDef: undefined }
|
|
479
|
+
if ((candidate.kind == 'poll' || candidate.kind == 'integration') && candidate.definition != null) {
|
|
480
|
+
const legacyDefinition = record(candidate.definition)
|
|
481
|
+
if (legacyDefinition.outputs == null && legacyDefinition.payloadSchema != null) {
|
|
482
|
+
return {
|
|
483
|
+
...candidate,
|
|
484
|
+
definition: {
|
|
485
|
+
...legacyDefinition,
|
|
486
|
+
definitionVersion: 2,
|
|
487
|
+
outputs: [{ handle: 'payload', jsonSchema: legacyDefinition.payloadSchema, nullable: false }],
|
|
488
|
+
payloadSchema: undefined,
|
|
489
|
+
},
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return candidate
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function repairGraph(value: unknown, bindings: Record<string, unknown>): z.infer<typeof graph> {
|
|
497
|
+
const candidate = record(value)
|
|
498
|
+
const nodes = repairedEntries(candidate.nodes, node, (entry) => {
|
|
499
|
+
const repaired = record(repairTriggerNode(entry))
|
|
500
|
+
if ((repaired.kind == 'poll' || repaired.kind == 'integration') && repaired.connectionId == null && typeof repaired.bindingId == 'string') {
|
|
501
|
+
const connection = record(bindings[repaired.bindingId])
|
|
502
|
+
if (connection.kind == 'connection' && typeof connection.target == 'string' && connection.target.length > 0)
|
|
503
|
+
return { ...repaired, connectionId: connection.target }
|
|
504
|
+
}
|
|
505
|
+
return repaired
|
|
506
|
+
})
|
|
507
|
+
const webhookIds = new Set(Object.entries(nodes).flatMap(([id, graphNode]) => (graphNode.kind == 'webhook' ? [id] : [])))
|
|
508
|
+
for (const graphNode of Object.values(nodes)) {
|
|
509
|
+
if (!('inputs' in graphNode)) continue
|
|
510
|
+
for (const inputMapping of Object.values(graphNode.inputs)) {
|
|
511
|
+
if (inputMapping.kind != 'sources') continue
|
|
512
|
+
for (const inputSource of inputMapping.sources) {
|
|
513
|
+
if (inputSource.kind == 'node' && inputSource.output == 'payload' && webhookIds.has(inputSource.nodeId)) inputSource.output = 'body'
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
nodes,
|
|
519
|
+
edges: Array.isArray(candidate.edges) ? candidate.edges.flatMap((edgeCandidate) => edge.safeParse(edgeCandidate).data ?? []) : [],
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function upgradeTaskNodes(candidateDocument: Record<string, unknown>): Record<string, unknown> {
|
|
524
|
+
const definitions = record(candidateDocument.tasks)
|
|
525
|
+
const sourceGraph = record(candidateDocument.graph)
|
|
526
|
+
const nodes = Object.fromEntries(
|
|
527
|
+
Object.entries(record(sourceGraph.nodes)).map(([id, value]) => {
|
|
528
|
+
const candidateNode = record(value)
|
|
529
|
+
if (candidateNode.kind != 'task' || !Object.hasOwn(candidateNode, 'taskId')) return [id, value]
|
|
530
|
+
if (typeof candidateNode.taskId != 'string' || candidateNode.task !== undefined) throw new TypeError('Invalid legacy Task reference.')
|
|
531
|
+
const task = record(definitions[candidateNode.taskId])
|
|
532
|
+
const executor = record(task.executor)
|
|
533
|
+
let upgraded = task
|
|
534
|
+
if (executor.kind == 'agent' && executor.notification != null) {
|
|
535
|
+
const notice = record(executor.notification)
|
|
536
|
+
const connector = record(definitions[String(notice.taskId)])
|
|
537
|
+
const config = record(connector.executor)
|
|
538
|
+
if (config.kind != 'connector') throw new TypeError('Invalid legacy Agent notification reference.')
|
|
539
|
+
const { taskId: _, ...rest } = notice
|
|
540
|
+
upgraded = {
|
|
541
|
+
...task,
|
|
542
|
+
executor: {
|
|
543
|
+
...executor,
|
|
544
|
+
notification: {
|
|
545
|
+
...rest,
|
|
546
|
+
action: config.action,
|
|
547
|
+
connectionId: config.connectionId,
|
|
548
|
+
inputDefinitions: Array.isArray(connector.inputs)
|
|
549
|
+
? connector.inputs.filter((candidatePort) => Object.hasOwn(record(candidatePort), 'handle'))
|
|
550
|
+
: connector.inputs,
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
const { taskId: _, ...rest } = candidateNode
|
|
556
|
+
return [id, { ...rest, task: managed.parse(upgraded) }]
|
|
557
|
+
}),
|
|
558
|
+
)
|
|
559
|
+
const { tasks: _, ...rest } = candidateDocument
|
|
560
|
+
return { ...rest, graph: { ...sourceGraph, nodes } }
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** Best-effort recovery for a parseable Revision envelope. Invalid collection entries are discarded. */
|
|
564
|
+
export function repairRevisionEnvelope(value: unknown): RevisionContent {
|
|
565
|
+
checkJsonDepth(value)
|
|
566
|
+
const envelopeSource = record(value)
|
|
567
|
+
if (envelopeSource.kind != 'open-flow-flow-revision' || envelopeSource.version != 1) throw new TypeError('The value is not an Open Flow Revision envelope.')
|
|
568
|
+
if (typeof envelopeSource.modelVersion == 'number' && envelopeSource.modelVersion > currentFlowModelVersion)
|
|
569
|
+
throw new TypeError('The Flow model is newer than this package.')
|
|
570
|
+
let sourceDocument = record(
|
|
571
|
+
envelopeSource.modelVersion == 1 || envelopeSource.modelVersion == 2 ? upgradeLegacyDocument(envelopeSource.document) : envelopeSource.document,
|
|
572
|
+
)
|
|
573
|
+
if (typeof envelopeSource.modelVersion == 'number' && envelopeSource.modelVersion < 6) sourceDocument = upgradeTaskNodes(sourceDocument)
|
|
574
|
+
sourceDocument = record(normalizeDocument(sourceDocument))
|
|
575
|
+
const bindings = record(sourceDocument.bindings)
|
|
576
|
+
const sourceGraph = repairGraph(sourceDocument.graph, bindings)
|
|
577
|
+
return decodeRevisionContent({
|
|
578
|
+
modelVersion: currentFlowModelVersion,
|
|
579
|
+
document: {
|
|
580
|
+
bindings: repairedEntries(sourceDocument.bindings, binding),
|
|
581
|
+
graph: sourceGraph,
|
|
582
|
+
},
|
|
583
|
+
modules: repairedEntries(envelopeSource.modules, module),
|
|
584
|
+
})
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export function decodeFlowDocument(value: unknown): FlowDocument {
|
|
588
|
+
checkJsonDepth(value)
|
|
589
|
+
return document.parse(value) as FlowDocument
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export function decodeRevisionContent(value: unknown): RevisionContent {
|
|
593
|
+
checkJsonDepth(value)
|
|
594
|
+
const content = revision.parse(value) as RevisionContent
|
|
595
|
+
checkModelVersion(content)
|
|
596
|
+
assertHttpAuthBindings(content.document)
|
|
597
|
+
return content
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export function decodeRevisionEnvelope(value: unknown): RevisionContent {
|
|
601
|
+
checkJsonDepth(value)
|
|
602
|
+
const revisionSource = record(value)
|
|
603
|
+
const candidate = revisionSource.modelVersion == 2 ? { ...revisionSource, document: upgradeLegacyDocument(revisionSource.document) } : value
|
|
604
|
+
const content = envelope.parse(candidate) as RevisionContent
|
|
605
|
+
checkModelVersion(content)
|
|
606
|
+
assertHttpAuthBindings(content.document)
|
|
607
|
+
return { modelVersion: content.modelVersion, document: content.document, modules: content.modules }
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const shapes = {
|
|
611
|
+
'graph.trigger.sources.set': { nodeId: text, before: sourceFlowIds.optional(), value: sourceFlowIds.optional() },
|
|
612
|
+
'binding.create': { bindingId: text, binding },
|
|
613
|
+
'binding.delete': { bindingId: text },
|
|
614
|
+
'binding.target.set': { bindingId: text, before: text, value: text },
|
|
615
|
+
'graph.edge.connect': { edge, target: z.never().optional() },
|
|
616
|
+
'graph.edge.disconnect': { edge, target: z.never().optional() },
|
|
617
|
+
'graph.node.create': { ...at, node },
|
|
618
|
+
'graph.node.replace': { ...at, before: node, node },
|
|
619
|
+
'graph.node.delete': at,
|
|
620
|
+
'graph.node.field.set': z.union([
|
|
621
|
+
z.object({
|
|
622
|
+
...at,
|
|
623
|
+
kind: z.literal('graph.node.field.set'),
|
|
624
|
+
field: z.literal('retry'),
|
|
625
|
+
before: retryConfigurationSchema.optional(),
|
|
626
|
+
value: retryConfigurationSchema.optional(),
|
|
627
|
+
}),
|
|
628
|
+
z.object({
|
|
629
|
+
...at,
|
|
630
|
+
kind: z.literal('graph.node.field.set'),
|
|
631
|
+
field: z.literal('connectionId'),
|
|
632
|
+
before: text.min(1).optional(),
|
|
633
|
+
value: text.min(1).optional(),
|
|
634
|
+
}),
|
|
635
|
+
z.object({
|
|
636
|
+
...at,
|
|
637
|
+
kind: z.literal('graph.node.field.set'),
|
|
638
|
+
field: z.enum(['description', 'icon', 'name', 'onError']),
|
|
639
|
+
before: text.optional(),
|
|
640
|
+
value: text.optional(),
|
|
641
|
+
}),
|
|
642
|
+
z.object({
|
|
643
|
+
...at,
|
|
644
|
+
kind: z.literal('graph.node.field.set'),
|
|
645
|
+
field: z.literal('maxExecutions'),
|
|
646
|
+
before: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
647
|
+
value: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
648
|
+
}),
|
|
649
|
+
z.object({
|
|
650
|
+
...at,
|
|
651
|
+
kind: z.literal('graph.node.field.set'),
|
|
652
|
+
field: z.literal('timeoutMs'),
|
|
653
|
+
before: z.number().optional(),
|
|
654
|
+
value: z.number().optional(),
|
|
655
|
+
}),
|
|
656
|
+
]),
|
|
657
|
+
'graph.node.input.set': { ...at, handle: text, before: mapping.optional(), value: mapping.optional() },
|
|
658
|
+
'graph.node.additional-inputs.set': { ...at, before: z.array(input).optional(), value: z.array(input).optional() },
|
|
659
|
+
'graph.node.condition.set': { ...at, before: z.object(condition), value: z.object(condition) },
|
|
660
|
+
'graph.node.values.set': { ...at, before: z.array(input), value: z.array(input) },
|
|
661
|
+
'graph.node.resolution.set': {
|
|
662
|
+
...at,
|
|
663
|
+
before: z.strictObject({ ...wait, autoContinue: waitAutoContinueDraftSchema.optional() }),
|
|
664
|
+
value: z.strictObject({ ...wait, autoContinue: waitAutoContinueDraftSchema.optional() }),
|
|
665
|
+
},
|
|
666
|
+
'graph.node.webhook.set': {
|
|
667
|
+
...at,
|
|
668
|
+
|
|
669
|
+
before: z.object(webhook),
|
|
670
|
+
value: z.object(webhook),
|
|
671
|
+
},
|
|
672
|
+
'graph.node.task.ports.set': { ...at, before: z.object(ports), value: z.object(ports) },
|
|
673
|
+
'graph.node.task.name.set': { ...at, before: text, value: text },
|
|
674
|
+
'graph.node.task.capabilities.set': { ...at, before: z.array(capability).optional(), value: z.array(capability).optional() },
|
|
675
|
+
'graph.trigger.config.set': { nodeId: text, name: text, before: fixedInput.optional(), value: fixedInput.optional() },
|
|
676
|
+
'graph.trigger.schedule.set': { nodeId: text, before: triggerScheduleSchema, value: triggerScheduleSchema },
|
|
677
|
+
'module.create': { moduleId: text, module },
|
|
678
|
+
'module.delete': { moduleId: text },
|
|
679
|
+
'module.rename': { moduleId: text, before: text, name: text },
|
|
680
|
+
'module.source.replace': { moduleId: text, beforeImports: strings, beforeSource: text, imports: strings, source: text },
|
|
681
|
+
'graph.node.task.set': { ...at, before: z.union([inline, managed]), value: z.union([inline, managed]) },
|
|
682
|
+
} satisfies Record<ChangeOperation['kind'], z.ZodRawShape | z.ZodType>
|
|
683
|
+
const variants = new Map(
|
|
684
|
+
Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof z.ZodType ? shape : z.object({ kind: z.literal(kind), ...shape })]),
|
|
685
|
+
)
|
|
686
|
+
const operations = z.array(z.union([...variants.values()])).min(1)
|
|
687
|
+
|
|
688
|
+
export function parseOperation<Value>(candidate: unknown, index: number, parse: (value: unknown) => Value): Value {
|
|
689
|
+
try {
|
|
690
|
+
return parse(candidate)
|
|
691
|
+
} catch (error) {
|
|
692
|
+
if (!(error instanceof z.ZodError)) throw error
|
|
693
|
+
throw new TypeError(`operations[${index}]: ${error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ')}`, { cause: error })
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export function decodeChangeOperation(candidate: unknown, index: number): ChangeOperation {
|
|
698
|
+
const { kind } = parseOperation(candidate, index, z.object({ kind: text }).parse)
|
|
699
|
+
const schema = variants.get(kind)
|
|
700
|
+
if (schema == null) throw new TypeError(`operations[${index}]: Unknown operation ${JSON.stringify(kind)}.`)
|
|
701
|
+
return parseOperation<unknown>(candidate, index, schema.parse) as ChangeOperation
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
export function decodeChangeOperations(value: unknown): readonly ChangeOperation[] {
|
|
705
|
+
checkJsonDepth(value)
|
|
706
|
+
return z.array(z.unknown()).min(1).parse(value).map(decodeChangeOperation)
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
export function changeOperationsSchema(kind?: string): JsonValue {
|
|
710
|
+
const schema = kind == null ? operations : variants.get(kind)
|
|
711
|
+
if (schema == null) throw new TypeError(`Unknown operation ${JSON.stringify(kind)}.`)
|
|
712
|
+
return z.toJSONSchema(schema, { io: 'input' }) as JsonValue
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function checkModelVersion(content: RevisionContent): void {
|
|
716
|
+
if (
|
|
717
|
+
content.modelVersion < 11 &&
|
|
718
|
+
Object.values(content.document.graph.nodes).some(
|
|
719
|
+
(candidateNode) => candidateNode.kind == 'task' && 'executor' in candidateNode.task && candidateNode.task.executor.kind == 'http-request',
|
|
720
|
+
)
|
|
721
|
+
)
|
|
722
|
+
throw new TypeError('HTTP Request requires Flow model version 11.')
|
|
723
|
+
if (
|
|
724
|
+
content.modelVersion < 11 &&
|
|
725
|
+
Object.values(content.document.graph.nodes).some(
|
|
726
|
+
(candidateNode) =>
|
|
727
|
+
candidateNode.kind == 'task' &&
|
|
728
|
+
('moduleId' in candidateNode.task
|
|
729
|
+
? candidateNode.task.capabilities?.some((item) => item.kind == 'workflow')
|
|
730
|
+
: candidateNode.task.executor.kind == 'agent' && candidateNode.task.executor.tools.some((item) => item.kind == 'workflow')),
|
|
731
|
+
)
|
|
732
|
+
)
|
|
733
|
+
throw new TypeError('Workflow tools require Flow model version 11.')
|
|
734
|
+
|
|
735
|
+
if (
|
|
736
|
+
content.modelVersion < 10 &&
|
|
737
|
+
Object.values(content.document.graph.nodes).some(
|
|
738
|
+
(candidateNode) =>
|
|
739
|
+
candidateNode.kind == 'webhook' &&
|
|
740
|
+
(candidateNode.options?.responseBody != null ||
|
|
741
|
+
candidateNode.options?.responseStatusCodeOutput != null ||
|
|
742
|
+
candidateNode.options?.responseHeadersSource != null ||
|
|
743
|
+
candidateNode.options?.responseHeaderOutputs != null),
|
|
744
|
+
)
|
|
745
|
+
)
|
|
746
|
+
throw new TypeError('Dynamic Webhook responses require Flow model version 10.')
|
|
747
|
+
if (content.modelVersion < 9 && Object.values(content.document.graph.nodes).some((candidateNode) => 'retry' in candidateNode && candidateNode.retry != null))
|
|
748
|
+
throw new TypeError('Node retries require Flow model version 9.')
|
|
749
|
+
if (
|
|
750
|
+
content.modelVersion < 9 &&
|
|
751
|
+
Object.values(content.document.graph.nodes).some((candidateNode) => {
|
|
752
|
+
if (candidateNode.onError != null) return true
|
|
753
|
+
const mappings = [
|
|
754
|
+
...Object.values('inputs' in candidateNode ? candidateNode.inputs : {}),
|
|
755
|
+
...Object.values(candidateNode.kind == 'outputs' ? candidateNode.outputMappings : {}),
|
|
756
|
+
]
|
|
757
|
+
if (
|
|
758
|
+
mappings.some(
|
|
759
|
+
(candidateMapping) =>
|
|
760
|
+
candidateMapping.kind == 'sources' && candidateMapping.sources.some((candidateSource) => candidateSource.kind == 'node' && candidateSource.system),
|
|
761
|
+
)
|
|
762
|
+
)
|
|
763
|
+
return true
|
|
764
|
+
return (
|
|
765
|
+
candidateNode.kind == 'condition' &&
|
|
766
|
+
candidateNode.cases.some((item) =>
|
|
767
|
+
item.groups.some((candidateGroup) =>
|
|
768
|
+
candidateGroup.expressions.some((expression) =>
|
|
769
|
+
[expression.left, expression.right].some(
|
|
770
|
+
(candidateOperand) => candidateOperand?.kind == 'source' && candidateOperand.source.kind == 'node' && candidateOperand.source.system,
|
|
771
|
+
),
|
|
772
|
+
),
|
|
773
|
+
),
|
|
774
|
+
)
|
|
775
|
+
)
|
|
776
|
+
})
|
|
777
|
+
)
|
|
778
|
+
throw new TypeError('Node error handling requires Flow model version 9.')
|
|
779
|
+
if (content.modelVersion < 10 && Object.values(content.document.graph.nodes).some((candidate) => candidate.kind === 'webhook-response'))
|
|
780
|
+
throw new TypeError('Webhook response nodes require Flow model version 10.')
|
|
781
|
+
if (content.modelVersion < 8 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == 'outputs'))
|
|
782
|
+
throw new TypeError('Workflow outputs require Flow model version 8.')
|
|
783
|
+
if (content.modelVersion < 7 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == 'start'))
|
|
784
|
+
throw new TypeError('Start Triggers require Flow model version 7.')
|
|
785
|
+
if (
|
|
786
|
+
content.modelVersion < 6 &&
|
|
787
|
+
Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == 'task' && 'executor' in candidateNode.task)
|
|
788
|
+
)
|
|
789
|
+
throw new TypeError('Node-owned managed Tasks require Flow model version 6.')
|
|
790
|
+
if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == 'error'))
|
|
791
|
+
throw new TypeError('Error workflows require Flow model version 5.')
|
|
792
|
+
}
|