@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,1506 @@
|
|
|
1
|
+
import type { CanvasCommand } from '../../canvas/common/commands.ts'
|
|
2
|
+
|
|
3
|
+
import { currentEngineContract } from '../../execution/common/engineContract.ts'
|
|
4
|
+
import { workflowContractSchema, workflowReferencesSchema } from '../../workflow/common/workflow.ts'
|
|
5
|
+
export type { CanvasCommand, CanvasCommandSubscriber } from '../../canvas/common/commands.ts'
|
|
6
|
+
import type { LiveDetails } from './liveDetails.ts'
|
|
7
|
+
|
|
8
|
+
import { decodeLiveDetails } from './liveDetails.ts'
|
|
9
|
+
export { liveEntries } from './liveDetails.ts'
|
|
10
|
+
export { flowInputDefinitions } from './authoringFields.ts'
|
|
11
|
+
export type { LiveDetails, LiveEntry } from './liveDetails.ts'
|
|
12
|
+
import type { AuthoringRead, AuthoringSearch, AuthoringRequest, AuthoringType } from './authoringSchema.ts'
|
|
13
|
+
import type { ProviderIconAppearance } from './providerIconSprite.ts'
|
|
14
|
+
|
|
15
|
+
import { authoringReadResponse, authoringSearchResponse, authoringEditResponse, authoringCheckResponse } from './authoringSchema.ts'
|
|
16
|
+
export { providerIconAppearance } from './providerIconSprite.ts'
|
|
17
|
+
export type { ProviderIconAppearance, ProviderIconSprite, ProviderIconSpriteCatalog } from './providerIconSprite.ts'
|
|
18
|
+
export { connectorAccess as decodeConnectorAccess, connectorAccessSnapshot as decodeConnectorAccessSnapshot } from './connectorDecoders.ts'
|
|
19
|
+
import type { ProviderAccessIdentity, ProviderAccessReference } from './providerAccess.ts'
|
|
20
|
+
export {
|
|
21
|
+
parseProviderAccessSource,
|
|
22
|
+
providerAccessBindingId,
|
|
23
|
+
type ProviderAccessIdentity,
|
|
24
|
+
type ProviderAccessReference,
|
|
25
|
+
type ProviderAccessSource,
|
|
26
|
+
} from './providerAccess.ts'
|
|
27
|
+
import type { DraftOperation } from './draftOperations.ts'
|
|
28
|
+
export { inspectFlowDraft, flowInspection, actionSummary, nodeDetails } from './flowInspection.ts'
|
|
29
|
+
export type { DraftOperation } from './draftOperations.ts'
|
|
30
|
+
import type { SchemaMismatch } from '../../flow/common/change.ts'
|
|
31
|
+
import type { CreateEventSource, UpdateEventSource, EventSource } from './eventSources.ts'
|
|
32
|
+
|
|
33
|
+
import { decodeEventSource, decodeEventSources } from './eventSources.ts'
|
|
34
|
+
export { decodeEventSource, decodeEventSources, type CreateEventSource, type UpdateEventSource, type EventSource } from './eventSources.ts'
|
|
35
|
+
import type { TriggerCatalogCache } from './triggerCatalog.ts'
|
|
36
|
+
|
|
37
|
+
import { decodeTriggerCatalog } from './triggerCatalog.ts'
|
|
38
|
+
export { decodeTriggerCatalog, searchTriggerKeys, type TriggerCatalog, type TriggerCatalogCache, type TriggerDisplay } from './triggerCatalog.ts'
|
|
39
|
+
import type { TriggerConfigOption } from '../../trigger/common/configOptions.ts'
|
|
40
|
+
export type { TriggerConfigOption } from '../../trigger/common/configOptions.ts'
|
|
41
|
+
import type { ResultQuery } from './results.ts'
|
|
42
|
+
|
|
43
|
+
import { decodeResultList, decodeResultRead } from './results.ts'
|
|
44
|
+
export {
|
|
45
|
+
readResult,
|
|
46
|
+
parseResultQuery,
|
|
47
|
+
decodeResultList,
|
|
48
|
+
decodeResultRead,
|
|
49
|
+
type ResultCall,
|
|
50
|
+
type ResultInfo,
|
|
51
|
+
type ResultPage,
|
|
52
|
+
type ResultQuery,
|
|
53
|
+
} from './results.ts'
|
|
54
|
+
import type { RunStatus } from '../../execution/common/runLifecycle.ts'
|
|
55
|
+
import type { WorkflowFile } from '../../flow/common/workflowFile.ts'
|
|
56
|
+
|
|
57
|
+
import { decodeWorkflowFile } from '../../flow/common/workflowFile.ts'
|
|
58
|
+
export type { WorkflowFile, WorkflowCleanupSummary } from '../../flow/common/workflowFile.ts'
|
|
59
|
+
import type { InputPortDefinition, JsonValue, PortDefinition, RevisionContent, TriggerKeySnapshot, WaitAction } from '../../flow/common/change.ts'
|
|
60
|
+
import type { FlowResourceReferences } from '../../flow/common/semantics.ts'
|
|
61
|
+
|
|
62
|
+
import { flowCheck } from './checkDecoders.ts'
|
|
63
|
+
import { connection, connectorAccess, connectorAccessSnapshot, connectorAccessCandidatesBatch, connectorAction, leinaBots } from './connectorDecoders.ts'
|
|
64
|
+
import { allConnectorConnectionsQuery, connectorActionQuery, connectorConnectionsQuery, connectorProvidersQuery } from './connectorQueries.ts'
|
|
65
|
+
import { requiredFields, integer, invalidResponse, jsonValue, record, string } from './decoding.ts'
|
|
66
|
+
import { errorListener, flow, flowPage, variable, variableListItem, variableReferences } from './flowDecoders.ts'
|
|
67
|
+
import { live, publication, publicationPage, publishOperation } from './publicationDecoders.ts'
|
|
68
|
+
import { draft, draftChange, draftSync, presentation } from './revisionDecoders.ts'
|
|
69
|
+
import { runCancellation, runDetails, runPage, runResult, waitResolution } from './runDecoders.ts'
|
|
70
|
+
import { pollTriggerTestResult, triggerActivityPage, triggerBinding, triggerBindingDetail, triggerKey, triggerKeySummary } from './triggerDecoders.ts'
|
|
71
|
+
|
|
72
|
+
export type { JsonValue, TriggerKeySnapshot, WaitAction } from '../../flow/common/change.ts'
|
|
73
|
+
export type { RunStatus } from '../../execution/common/runLifecycle.ts'
|
|
74
|
+
export { ApiError, controlErrorCode, controlErrorMetadata, type ControlErrorCode } from './errors.ts'
|
|
75
|
+
export type { FlowCatalogEvent, FlowChangeEvent } from './flowNotifications.ts'
|
|
76
|
+
|
|
77
|
+
import { ApiError } from './errors.ts'
|
|
78
|
+
import { randomId } from './random.ts'
|
|
79
|
+
|
|
80
|
+
export interface CanvasBroadcast {
|
|
81
|
+
readonly version: 1
|
|
82
|
+
readonly flowId: string
|
|
83
|
+
readonly broadcast: true
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type ControlRequest = (path: string, init?: RequestInit) => Promise<Response>
|
|
87
|
+
|
|
88
|
+
export interface ErrorListener {
|
|
89
|
+
readonly flowId: string
|
|
90
|
+
readonly flowName: string
|
|
91
|
+
readonly nodeId: string
|
|
92
|
+
readonly nodeName: string
|
|
93
|
+
readonly enabled: boolean
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface FlowResources {
|
|
97
|
+
readonly draft: FlowResourceReferences | null
|
|
98
|
+
readonly sharedAccess: {
|
|
99
|
+
readonly accessRevision: number
|
|
100
|
+
readonly providerIds: readonly string[]
|
|
101
|
+
readonly bindings: readonly { readonly providerId: string; readonly connectionId: string | null; readonly accessBindingId: string }[]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface Flow {
|
|
106
|
+
readonly live?: { readonly enabled: boolean; readonly hasStart: boolean; readonly publicationId: string; readonly revisionId: string }
|
|
107
|
+
|
|
108
|
+
readonly createdAt: string
|
|
109
|
+
readonly draftRevisionId: string
|
|
110
|
+
readonly resourceReferences: FlowResources
|
|
111
|
+
readonly flowId: string
|
|
112
|
+
/** Connector Team scope used by the OOMOL resource cache. */
|
|
113
|
+
readonly connectorTeamId?: string
|
|
114
|
+
readonly name: string
|
|
115
|
+
readonly status: 'active' | 'retiring'
|
|
116
|
+
readonly updatedAt: string
|
|
117
|
+
readonly version: 1
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface PublicationPresentation {
|
|
121
|
+
readonly version: 1
|
|
122
|
+
readonly presentation: Presentation | null
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface Presentation {
|
|
126
|
+
readonly revision: number
|
|
127
|
+
readonly updatedAt: string
|
|
128
|
+
readonly value: Readonly<Record<string, JsonValue>>
|
|
129
|
+
readonly version: 1
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface FlowListItem extends Flow {
|
|
133
|
+
readonly referenceCount: number
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface FlowPage {
|
|
137
|
+
readonly flows: readonly FlowListItem[]
|
|
138
|
+
readonly nextCursor?: string
|
|
139
|
+
readonly total?: number
|
|
140
|
+
readonly version: 1
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface VariableReference {
|
|
144
|
+
readonly flowId: string
|
|
145
|
+
readonly flowName: string
|
|
146
|
+
readonly draft: boolean
|
|
147
|
+
readonly live: { readonly publicationId: string; readonly enabled: boolean } | null
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface VariableReferences {
|
|
151
|
+
readonly version: 1
|
|
152
|
+
readonly references: readonly VariableReference[]
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface VariableListItem extends Variable {
|
|
156
|
+
readonly referenceCount: number
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface Variable {
|
|
160
|
+
readonly name: string
|
|
161
|
+
readonly updatedAt: string
|
|
162
|
+
readonly value: string
|
|
163
|
+
readonly version: 1
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface TriggerKeySummary {
|
|
167
|
+
readonly description: string
|
|
168
|
+
readonly displayName: string
|
|
169
|
+
readonly key: string
|
|
170
|
+
readonly name: string
|
|
171
|
+
readonly provider: string
|
|
172
|
+
readonly type: TriggerKeySnapshot['type']
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface TriggerBinding {
|
|
176
|
+
readonly listener?: { readonly health: 'healthy' | 'failed' | 'needs_reauth'; readonly lastErrorCode?: string }
|
|
177
|
+
readonly currentPublicationId?: string
|
|
178
|
+
readonly currentRevisionId?: string
|
|
179
|
+
readonly endpointUrl?: string
|
|
180
|
+
readonly flowId: string
|
|
181
|
+
readonly health: 'failed' | 'healthy' | 'initializing' | 'needs_reauth' | 'suspended'
|
|
182
|
+
readonly kind: 'error' | 'cron' | 'integration' | 'poll' | 'webhook'
|
|
183
|
+
readonly lastErrorCode?: string
|
|
184
|
+
readonly runtimeVersion: number
|
|
185
|
+
readonly triggerNodeId: string
|
|
186
|
+
readonly updatedAt: string
|
|
187
|
+
readonly version: 1
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface TriggerBindingDetail {
|
|
191
|
+
readonly binding: TriggerBinding
|
|
192
|
+
readonly version: 1
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export type TriggerActivityKind =
|
|
196
|
+
| 'delivery.failed'
|
|
197
|
+
| 'health.failed'
|
|
198
|
+
| 'health.needs_reauth'
|
|
199
|
+
| 'health.recovered'
|
|
200
|
+
| 'health.suspended'
|
|
201
|
+
| 'operator.paused'
|
|
202
|
+
| 'operator.resumed'
|
|
203
|
+
|
|
204
|
+
export interface TriggerActivity {
|
|
205
|
+
readonly activityId: string
|
|
206
|
+
readonly createdAt: string
|
|
207
|
+
readonly errorCode?: string
|
|
208
|
+
readonly errorMessage?: string
|
|
209
|
+
readonly kind: TriggerActivityKind
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface TriggerActivityPage {
|
|
213
|
+
readonly activities: readonly TriggerActivity[]
|
|
214
|
+
readonly nextCursor?: string
|
|
215
|
+
readonly version: 1
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface PollTriggerTestResult {
|
|
219
|
+
readonly events: readonly Readonly<Record<string, JsonValue>>[]
|
|
220
|
+
readonly filtered: number
|
|
221
|
+
readonly hasMore: boolean
|
|
222
|
+
readonly version: 1
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface ConnectorConnection {
|
|
226
|
+
readonly providerAccountId?: string
|
|
227
|
+
readonly builtInAccount?: boolean
|
|
228
|
+
readonly alias?: string
|
|
229
|
+
readonly connectionId: string
|
|
230
|
+
readonly displayName: string
|
|
231
|
+
readonly isDefault: boolean
|
|
232
|
+
readonly serviceId: string
|
|
233
|
+
readonly status: 'active' | 'disconnected' | 'error' | 'reauth_required'
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Action metadata independent of account availability and selection. */
|
|
237
|
+
export interface ConnectorActionMetadata extends ProviderIconAppearance {
|
|
238
|
+
/** Upstream operation classification; unknown values remain uncategorized. */
|
|
239
|
+
readonly operationType?: string
|
|
240
|
+
readonly inputSchema?: JsonValue
|
|
241
|
+
readonly outputSchema?: JsonValue
|
|
242
|
+
readonly actionId: string
|
|
243
|
+
readonly authenticated: boolean
|
|
244
|
+
readonly description: string
|
|
245
|
+
readonly homepageUrl?: string
|
|
246
|
+
readonly icon?: string
|
|
247
|
+
readonly inputs: Readonly<Record<string, InputPortDefinition>>
|
|
248
|
+
readonly name: string
|
|
249
|
+
readonly outputs: Readonly<Record<string, PortDefinition>>
|
|
250
|
+
readonly serviceId: string
|
|
251
|
+
readonly serviceName: string
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Existing CLI/MCP representation, including the currently preferred account. */
|
|
255
|
+
export interface ConnectorAction extends ConnectorActionMetadata {
|
|
256
|
+
readonly defaultConnection?: ConnectorConnection
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface ConnectorProvider extends ProviderIconAppearance {
|
|
260
|
+
readonly noSetup?: boolean
|
|
261
|
+
readonly homepageUrl?: string
|
|
262
|
+
readonly icon?: string
|
|
263
|
+
readonly serviceId: string
|
|
264
|
+
readonly serviceName: string
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export type ConnectorAccessMode = 'implicit' | 'selectable'
|
|
268
|
+
|
|
269
|
+
export interface LeinaBot {
|
|
270
|
+
readonly leinaId: string
|
|
271
|
+
readonly name: string
|
|
272
|
+
readonly status: string
|
|
273
|
+
readonly platforms: readonly string[]
|
|
274
|
+
}
|
|
275
|
+
export type ProviderAccessBindingStatus = 'active' | 'forbidden' | 'invalid' | 'missing'
|
|
276
|
+
|
|
277
|
+
export type ProviderAccessBinding = (
|
|
278
|
+
| (ProviderAccessIdentity & { readonly status: ProviderAccessBindingStatus })
|
|
279
|
+
| (Extract<ProviderAccessReference, { readonly source: null }> & { readonly status: 'invalid' })
|
|
280
|
+
) & {
|
|
281
|
+
readonly connectionDisplayName: string
|
|
282
|
+
readonly permissionGroupName?: string | null
|
|
283
|
+
readonly policyRevision?: string
|
|
284
|
+
readonly providerId: string
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface ProviderAccessBindingCandidate extends ProviderAccessIdentity {
|
|
288
|
+
readonly connectionDisplayName: string
|
|
289
|
+
readonly isDefault?: boolean
|
|
290
|
+
readonly permissions?: {
|
|
291
|
+
readonly actionIds: readonly string[]
|
|
292
|
+
readonly allActions: boolean
|
|
293
|
+
readonly triggerIds: readonly string[]
|
|
294
|
+
readonly allTriggers: boolean
|
|
295
|
+
readonly configured: boolean
|
|
296
|
+
readonly proxy: boolean
|
|
297
|
+
}
|
|
298
|
+
readonly permissionGroupName?: string | null
|
|
299
|
+
readonly policyRevision?: string
|
|
300
|
+
readonly providerId: string
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface ConnectorAccess {
|
|
304
|
+
readonly discardedBindingCount?: number
|
|
305
|
+
readonly providerIds?: readonly string[]
|
|
306
|
+
readonly accessRevision: number
|
|
307
|
+
readonly bindings: readonly ProviderAccessBinding[]
|
|
308
|
+
readonly mode: ConnectorAccessMode
|
|
309
|
+
readonly sharedAccessDigest: string
|
|
310
|
+
readonly version: 1
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export type ConnectorAccessGrant = ProviderAccessIdentity & {
|
|
314
|
+
readonly connectionDisplayName: string
|
|
315
|
+
readonly permissionGroupName?: string | null
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface ConnectorAccessSnapshot {
|
|
319
|
+
readonly mode: ConnectorAccessMode
|
|
320
|
+
readonly sharedAccessDigest: string
|
|
321
|
+
readonly sharedBindings: readonly ConnectorAccessGrant[]
|
|
322
|
+
readonly selectedBindings: readonly ConnectorAccessGrant[]
|
|
323
|
+
readonly version: 2
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface ConnectorAccessCandidates {
|
|
327
|
+
readonly candidates: readonly ProviderAccessBindingCandidate[]
|
|
328
|
+
readonly mode: ConnectorAccessMode
|
|
329
|
+
readonly providerId: string
|
|
330
|
+
readonly version: 1
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export interface ConnectorAccessCandidatesBatch {
|
|
334
|
+
readonly results: readonly (
|
|
335
|
+
| ConnectorAccessCandidates
|
|
336
|
+
| { readonly providerId: string; readonly error: { readonly code: string; readonly message: string } }
|
|
337
|
+
)[]
|
|
338
|
+
readonly version: 1
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface RevisionMetadata {
|
|
342
|
+
readonly actorId: string
|
|
343
|
+
readonly createdAt: string
|
|
344
|
+
readonly digest: string
|
|
345
|
+
readonly modelVersion: number
|
|
346
|
+
readonly parentRevisionId: string | null
|
|
347
|
+
readonly flowId: string
|
|
348
|
+
readonly revisionId: string
|
|
349
|
+
readonly version: 1
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface Draft extends RevisionMetadata {
|
|
353
|
+
readonly content: RevisionContent
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface DraftChange {
|
|
357
|
+
readonly revision: RevisionMetadata
|
|
358
|
+
readonly version: 1
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface DraftSync {
|
|
362
|
+
readonly draft: Draft
|
|
363
|
+
readonly kind: 'snapshot'
|
|
364
|
+
readonly version: 1
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface Publication {
|
|
368
|
+
readonly liveEnd?: { readonly enabled: boolean; readonly endedAt: string }
|
|
369
|
+
readonly actorId: string
|
|
370
|
+
readonly closureDigest: string
|
|
371
|
+
readonly createdAt: string
|
|
372
|
+
readonly engineContract: string
|
|
373
|
+
readonly flowId: string
|
|
374
|
+
readonly modelVersion: number
|
|
375
|
+
readonly operation: 'publish' | 'rollback'
|
|
376
|
+
readonly publicationId: string
|
|
377
|
+
readonly sharedAccessDigest: string
|
|
378
|
+
readonly revisionDigest: string
|
|
379
|
+
readonly revisionId: string
|
|
380
|
+
readonly sourcePublicationId?: string
|
|
381
|
+
readonly version: 1
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export type PublishOperation =
|
|
385
|
+
| {
|
|
386
|
+
readonly createdAt: string
|
|
387
|
+
readonly flowId: string
|
|
388
|
+
readonly operationId: string
|
|
389
|
+
readonly revisionId: string
|
|
390
|
+
readonly status: 'pending'
|
|
391
|
+
readonly updatedAt: string
|
|
392
|
+
readonly version: 1
|
|
393
|
+
}
|
|
394
|
+
| {
|
|
395
|
+
readonly createdAt: string
|
|
396
|
+
readonly flowId: string
|
|
397
|
+
readonly operationId: string
|
|
398
|
+
readonly publicationId: string
|
|
399
|
+
readonly revisionId: string
|
|
400
|
+
readonly status: 'succeeded'
|
|
401
|
+
readonly updatedAt: string
|
|
402
|
+
readonly version: 1
|
|
403
|
+
}
|
|
404
|
+
| {
|
|
405
|
+
readonly createdAt: string
|
|
406
|
+
readonly flowId: string
|
|
407
|
+
readonly issue: { readonly code: string; readonly message: string; readonly nodeId?: string }
|
|
408
|
+
readonly operationId: string
|
|
409
|
+
readonly revisionId: string
|
|
410
|
+
readonly status: 'failed'
|
|
411
|
+
readonly updatedAt: string
|
|
412
|
+
readonly version: 1
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface Diagnostic {
|
|
416
|
+
readonly code: string
|
|
417
|
+
readonly column: number
|
|
418
|
+
readonly fields?: readonly string[]
|
|
419
|
+
readonly line: number
|
|
420
|
+
readonly message: string
|
|
421
|
+
readonly mismatch?: SchemaMismatch
|
|
422
|
+
readonly path: string
|
|
423
|
+
readonly values?: Readonly<Record<string, string | number>>
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface FlowCheck {
|
|
427
|
+
readonly closureDigest: string
|
|
428
|
+
readonly diagnostics: readonly Diagnostic[]
|
|
429
|
+
readonly engineContract: string
|
|
430
|
+
readonly flowId: string
|
|
431
|
+
readonly modelVersion: number
|
|
432
|
+
readonly revisionDigest: string
|
|
433
|
+
readonly revisionId: string
|
|
434
|
+
readonly valid: boolean
|
|
435
|
+
readonly version: 1
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface Live {
|
|
439
|
+
readonly flowId: string
|
|
440
|
+
readonly hasUnpublishedChanges: boolean
|
|
441
|
+
readonly publication: Publication | null
|
|
442
|
+
readonly revision: number
|
|
443
|
+
readonly status: 'not-published' | 'runnable' | 'suspended'
|
|
444
|
+
readonly version: 1
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export interface PublicationPage {
|
|
448
|
+
readonly nextCursor?: string
|
|
449
|
+
readonly publications: readonly Publication[]
|
|
450
|
+
readonly total?: number
|
|
451
|
+
readonly version: 1
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export type RunChannel = 'workbench' | 'cli' | 'mcp' | 'api' | 'trigger' | 'workflow'
|
|
455
|
+
|
|
456
|
+
export interface RunInitiator {
|
|
457
|
+
readonly actorId?: string
|
|
458
|
+
readonly channel: RunChannel
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface Run {
|
|
462
|
+
readonly createdAt: string
|
|
463
|
+
readonly finishedAt?: string
|
|
464
|
+
readonly flowId: string
|
|
465
|
+
readonly revisionId: string
|
|
466
|
+
readonly runId: string
|
|
467
|
+
readonly source: 'draft' | 'live'
|
|
468
|
+
readonly startedAt?: string
|
|
469
|
+
readonly status: RunStatus
|
|
470
|
+
readonly version: 1
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface RunWait {
|
|
474
|
+
readonly autoContinueAt?: string
|
|
475
|
+
readonly actions: readonly ['continue'] | readonly ['approve', 'reject']
|
|
476
|
+
readonly expiresAt: string
|
|
477
|
+
readonly nodeId: string
|
|
478
|
+
readonly prompt: string
|
|
479
|
+
readonly waitId: string
|
|
480
|
+
readonly waitingSince: string
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export type ErrorDispatch =
|
|
484
|
+
| { readonly status: 'pending'; readonly flowId: string }
|
|
485
|
+
| { readonly status: 'dispatched'; readonly flowId: string; readonly runId: string }
|
|
486
|
+
| { readonly status: 'failed'; readonly flowId: string; readonly message: string }
|
|
487
|
+
|
|
488
|
+
export interface WorkflowCaller {
|
|
489
|
+
readonly callId?: string
|
|
490
|
+
readonly flowId: string
|
|
491
|
+
readonly runId: string
|
|
492
|
+
readonly nodeId: string
|
|
493
|
+
readonly executionId: string
|
|
494
|
+
}
|
|
495
|
+
export interface WorkflowRunCall extends WorkflowCaller {
|
|
496
|
+
readonly status: RunStatus | null
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
type RunDetailsBase = Run & {
|
|
500
|
+
readonly initiator?: RunInitiator
|
|
501
|
+
readonly caller?: WorkflowCaller
|
|
502
|
+
readonly calls?: readonly WorkflowRunCall[]
|
|
503
|
+
readonly triggerNodeId?: string
|
|
504
|
+
readonly errorDispatches?: readonly ErrorDispatch[]
|
|
505
|
+
readonly errorSource?: { readonly flowId: string; readonly runId: string }
|
|
506
|
+
readonly closureDigest: string
|
|
507
|
+
readonly engineContract: string
|
|
508
|
+
readonly engineDigest: string
|
|
509
|
+
readonly eventsExpiresAt?: string
|
|
510
|
+
readonly modelVersion: number
|
|
511
|
+
readonly sharedAccessDigest: string
|
|
512
|
+
readonly revisionDigest: string
|
|
513
|
+
readonly waits: readonly RunWait[]
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export type DraftRun = RunDetailsBase & { readonly source: 'draft' }
|
|
517
|
+
export type LiveRun = RunDetailsBase & {
|
|
518
|
+
readonly publicationId: string
|
|
519
|
+
readonly source: 'live'
|
|
520
|
+
readonly occurrenceId?: string
|
|
521
|
+
readonly triggerNodeId?: string
|
|
522
|
+
}
|
|
523
|
+
export type RunDetails = DraftRun | LiveRun
|
|
524
|
+
|
|
525
|
+
export interface RunPage {
|
|
526
|
+
readonly flowId: string
|
|
527
|
+
readonly nextCursor?: string
|
|
528
|
+
readonly runs: readonly Run[]
|
|
529
|
+
readonly version: 1
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** Run-level events have no node identity; callers may inspect it without narrowing the event kind. */
|
|
533
|
+
type EventWithNodeContext<Event> = Event extends { readonly payload: infer Payload }
|
|
534
|
+
? Readonly<Event & { readonly payload: Payload & { readonly nodeId?: string } }>
|
|
535
|
+
: never
|
|
536
|
+
export type RunEvent = EventWithNodeContext<ReturnType<typeof decodeRunEvent>>
|
|
537
|
+
export type RunEventKind = RunEvent['kind']
|
|
538
|
+
|
|
539
|
+
export function isRunTerminalEvent(event: RunEvent | undefined): boolean {
|
|
540
|
+
return event?.kind == 'run.completed' || event?.kind == 'run.failed' || event?.kind == 'run.canceled' || event?.kind == 'run.indeterminate'
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export interface RunEvents {
|
|
544
|
+
readonly done: boolean
|
|
545
|
+
readonly events: readonly RunEvent[]
|
|
546
|
+
readonly eventsExpiresAt?: string
|
|
547
|
+
readonly historyComplete: boolean
|
|
548
|
+
readonly nextAfter: number
|
|
549
|
+
readonly runId: string
|
|
550
|
+
readonly version: 1
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export interface RunCancellation {
|
|
554
|
+
readonly cancelAccepted: boolean
|
|
555
|
+
readonly runId: string
|
|
556
|
+
readonly status: Extract<RunStatus, 'canceled' | 'completed' | 'failed' | 'indeterminate'>
|
|
557
|
+
readonly version: 1
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export interface RunFailure {
|
|
561
|
+
readonly code: string
|
|
562
|
+
readonly message: string
|
|
563
|
+
readonly nodeId?: string
|
|
564
|
+
readonly jobId?: string
|
|
565
|
+
readonly path?: readonly string[]
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export type RunResult =
|
|
569
|
+
| { readonly finishedAt: string; readonly result: JsonValue; readonly runId: string; readonly status: 'completed'; readonly version: 1 }
|
|
570
|
+
| {
|
|
571
|
+
readonly error: RunFailure
|
|
572
|
+
readonly finishedAt: string
|
|
573
|
+
readonly runId: string
|
|
574
|
+
readonly status: 'failed' | 'indeterminate'
|
|
575
|
+
readonly version: 1
|
|
576
|
+
}
|
|
577
|
+
| { readonly finishedAt: string; readonly runId: string; readonly status: 'canceled'; readonly version: 1 }
|
|
578
|
+
|
|
579
|
+
interface RunOptions {
|
|
580
|
+
readonly trigger: { readonly nodeId: string; readonly outputs: Readonly<Record<string, JsonValue>> }
|
|
581
|
+
readonly idempotencyKey?: string
|
|
582
|
+
readonly inputs?: Readonly<Record<string, Readonly<Record<string, JsonValue>>>>
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
interface PublicationOptions {
|
|
586
|
+
readonly idempotencyKey?: string
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
export function decodeRunEvent(value: unknown) {
|
|
590
|
+
const source = record(value)
|
|
591
|
+
const sequence = integer(source.sequence)
|
|
592
|
+
if (sequence < 0) return invalidResponse()
|
|
593
|
+
const base = {
|
|
594
|
+
createdAt: string(source.createdAt),
|
|
595
|
+
sequence,
|
|
596
|
+
}
|
|
597
|
+
const payload = record(source.payload)
|
|
598
|
+
const kind = source.kind
|
|
599
|
+
switch (kind) {
|
|
600
|
+
case 'run.queued':
|
|
601
|
+
return { ...base, kind, payload: {} } as const
|
|
602
|
+
case 'run.started':
|
|
603
|
+
return {
|
|
604
|
+
...base,
|
|
605
|
+
kind,
|
|
606
|
+
payload: {
|
|
607
|
+
flowId: string(payload.flowId),
|
|
608
|
+
scopeId: string(payload.scopeId),
|
|
609
|
+
...(payload.parentScopeId === undefined ? {} : { parentScopeId: string(payload.parentScopeId) }),
|
|
610
|
+
},
|
|
611
|
+
} as const
|
|
612
|
+
case 'run.progress':
|
|
613
|
+
return {
|
|
614
|
+
...base,
|
|
615
|
+
kind,
|
|
616
|
+
payload: { flowId: string(payload.flowId), scopeId: string(payload.scopeId), progress: eventProgress(payload.progress) },
|
|
617
|
+
} as const
|
|
618
|
+
case 'run.waiting':
|
|
619
|
+
if (!Array.isArray(payload.waitIds)) return invalidResponse()
|
|
620
|
+
return { ...base, kind, payload: { waitIds: payload.waitIds.map((id) => string(id)) } } as const
|
|
621
|
+
case 'wait.created': {
|
|
622
|
+
const timing: { readonly autoContinueAt?: string } = payload.autoContinueAt === undefined ? {} : { autoContinueAt: string(payload.autoContinueAt) }
|
|
623
|
+
return {
|
|
624
|
+
...base,
|
|
625
|
+
kind,
|
|
626
|
+
payload: {
|
|
627
|
+
...timing,
|
|
628
|
+
expiresAt: string(payload.expiresAt),
|
|
629
|
+
nodeId: string(payload.nodeId),
|
|
630
|
+
waitId: string(payload.waitId),
|
|
631
|
+
waitingSince: string(payload.waitingSince),
|
|
632
|
+
},
|
|
633
|
+
} as const
|
|
634
|
+
}
|
|
635
|
+
case 'run.resolved': {
|
|
636
|
+
const action = payload.action
|
|
637
|
+
const resolutionSource = payload.source
|
|
638
|
+
if (resolutionSource !== undefined && resolutionSource !== 'manual' && resolutionSource !== 'automatic') return invalidResponse()
|
|
639
|
+
const audit: { readonly source?: 'manual' | 'automatic' } = resolutionSource === undefined ? {} : { source: resolutionSource }
|
|
640
|
+
if (action !== 'approve' && action !== 'continue' && action !== 'reject') return invalidResponse()
|
|
641
|
+
if (payload.comment !== null && typeof payload.comment != 'string') return invalidResponse()
|
|
642
|
+
return {
|
|
643
|
+
...base,
|
|
644
|
+
kind,
|
|
645
|
+
payload: { ...audit, action, comment: payload.comment as string | null, resolvedAt: string(payload.resolvedAt), waitId: string(payload.waitId) },
|
|
646
|
+
} as const
|
|
647
|
+
}
|
|
648
|
+
case 'run.completed':
|
|
649
|
+
case 'run.canceled':
|
|
650
|
+
case 'run.failed':
|
|
651
|
+
case 'run.indeterminate':
|
|
652
|
+
return { ...base, kind, payload: { result: jsonValue(payload.result) } } as const
|
|
653
|
+
case 'run.events-truncated':
|
|
654
|
+
return { ...base, kind, payload: Object.fromEntries(Object.entries(payload).map(([key, item]) => [key, jsonValue(item)])) } as const
|
|
655
|
+
case 'node.started':
|
|
656
|
+
case 'node.completed':
|
|
657
|
+
case 'node.failed':
|
|
658
|
+
case 'node.log':
|
|
659
|
+
case 'node.progress':
|
|
660
|
+
case 'node.artifact': {
|
|
661
|
+
const node = {
|
|
662
|
+
flowId: string(payload.flowId),
|
|
663
|
+
scopeId: string(payload.scopeId),
|
|
664
|
+
nodeId: string(payload.nodeId),
|
|
665
|
+
executionId: string(payload.executionId),
|
|
666
|
+
}
|
|
667
|
+
switch (kind) {
|
|
668
|
+
case 'node.started': {
|
|
669
|
+
const nodeKind = payload.nodeKind
|
|
670
|
+
if (
|
|
671
|
+
nodeKind !== undefined &&
|
|
672
|
+
nodeKind !== 'approval' &&
|
|
673
|
+
nodeKind !== 'condition' &&
|
|
674
|
+
nodeKind !== 'connector' &&
|
|
675
|
+
nodeKind !== 'javascript' &&
|
|
676
|
+
nodeKind !== 'decision' &&
|
|
677
|
+
nodeKind !== 'openapi' &&
|
|
678
|
+
nodeKind !== 'http-request' &&
|
|
679
|
+
nodeKind !== 'llm' &&
|
|
680
|
+
nodeKind !== 'agent' &&
|
|
681
|
+
nodeKind !== 'value' &&
|
|
682
|
+
nodeKind !== 'outputs' &&
|
|
683
|
+
nodeKind !== 'webhook-response' &&
|
|
684
|
+
nodeKind !== 'workflow' &&
|
|
685
|
+
nodeKind !== 'wait'
|
|
686
|
+
)
|
|
687
|
+
return invalidResponse()
|
|
688
|
+
return {
|
|
689
|
+
...base,
|
|
690
|
+
kind,
|
|
691
|
+
payload: {
|
|
692
|
+
...node,
|
|
693
|
+
...(nodeKind === undefined ? {} : { nodeKind }),
|
|
694
|
+
...(payload.nodeTitle === undefined ? {} : { nodeTitle: string(payload.nodeTitle) }),
|
|
695
|
+
...(payload.operation === undefined ? {} : { operation: string(payload.operation) }),
|
|
696
|
+
},
|
|
697
|
+
} as const
|
|
698
|
+
}
|
|
699
|
+
case 'node.completed':
|
|
700
|
+
return {
|
|
701
|
+
...base,
|
|
702
|
+
kind,
|
|
703
|
+
payload: {
|
|
704
|
+
...node,
|
|
705
|
+
...(payload.systemOutputs === undefined
|
|
706
|
+
? {}
|
|
707
|
+
: { systemOutputs: Object.fromEntries(Object.entries(record(payload.systemOutputs)).map(([key, item]) => [key, jsonValue(item)])) }),
|
|
708
|
+
outputs: Object.fromEntries(Object.entries(record(payload.outputs)).map(([key, item]) => [key, jsonValue(item)])),
|
|
709
|
+
},
|
|
710
|
+
} as const
|
|
711
|
+
case 'node.failed': {
|
|
712
|
+
const error = record(payload.error)
|
|
713
|
+
return {
|
|
714
|
+
...base,
|
|
715
|
+
kind,
|
|
716
|
+
payload: {
|
|
717
|
+
...node,
|
|
718
|
+
...(payload.handled === true ? { handled: true as const } : {}),
|
|
719
|
+
...(payload.systemOutputs === undefined
|
|
720
|
+
? {}
|
|
721
|
+
: { systemOutputs: Object.fromEntries(Object.entries(record(payload.systemOutputs)).map(([key, item]) => [key, jsonValue(item)])) }),
|
|
722
|
+
error: { code: string(error.code), message: string(error.message) },
|
|
723
|
+
},
|
|
724
|
+
} as const
|
|
725
|
+
}
|
|
726
|
+
case 'node.log': {
|
|
727
|
+
const level = payload.level
|
|
728
|
+
if (level !== 'debug' && level !== 'info' && level !== 'warn' && level !== 'error') return invalidResponse()
|
|
729
|
+
return { ...base, kind, payload: { ...node, level, message: string(payload.message) } } as const
|
|
730
|
+
}
|
|
731
|
+
case 'node.progress':
|
|
732
|
+
return { ...base, kind, payload: { ...node, progress: eventProgress(payload.progress) } } as const
|
|
733
|
+
case 'node.artifact': {
|
|
734
|
+
const artifact = record(payload.artifact)
|
|
735
|
+
const size = integer(artifact.size)
|
|
736
|
+
const digest = string(artifact.digest)
|
|
737
|
+
if (artifact.kind != 'artifact' || size < 0 || !/^sha256:[0-9a-f]{64}$/.test(digest)) return invalidResponse()
|
|
738
|
+
return {
|
|
739
|
+
...base,
|
|
740
|
+
kind,
|
|
741
|
+
payload: {
|
|
742
|
+
...node,
|
|
743
|
+
artifact: {
|
|
744
|
+
kind: 'artifact',
|
|
745
|
+
id: string(artifact.id),
|
|
746
|
+
name: string(artifact.name),
|
|
747
|
+
size,
|
|
748
|
+
digest,
|
|
749
|
+
...(artifact.mediaType === undefined ? {} : { mediaType: string(artifact.mediaType) }),
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
} as const
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
default:
|
|
757
|
+
return invalidResponse()
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function eventProgress(value: unknown): number {
|
|
762
|
+
return typeof value == 'number' && Number.isFinite(value) && value >= 0 && value <= 100 ? value : invalidResponse()
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function runEvents(value: unknown): RunEvents {
|
|
766
|
+
const source = record(value)
|
|
767
|
+
const eventsExpiresAt = source.eventsExpiresAt
|
|
768
|
+
const nextAfter = integer(source.nextAfter)
|
|
769
|
+
if (source.version != 1 || !Array.isArray(source.events) || typeof source.done != 'boolean' || typeof source.historyComplete != 'boolean') {
|
|
770
|
+
return invalidResponse()
|
|
771
|
+
}
|
|
772
|
+
if (eventsExpiresAt != null && typeof eventsExpiresAt != 'string') return invalidResponse()
|
|
773
|
+
if (nextAfter < 0) return invalidResponse()
|
|
774
|
+
return {
|
|
775
|
+
done: source.done,
|
|
776
|
+
events: source.events.map(decodeRunEvent),
|
|
777
|
+
...(eventsExpiresAt == null ? {} : { eventsExpiresAt }),
|
|
778
|
+
historyComplete: source.historyComplete,
|
|
779
|
+
nextAfter,
|
|
780
|
+
runId: string(source.runId),
|
|
781
|
+
version: 1,
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
const segment = encodeURIComponent
|
|
786
|
+
|
|
787
|
+
function operationKey(operation: string): string {
|
|
788
|
+
return `${operation}-${randomId()}`
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export type ConditionalResult<T> =
|
|
792
|
+
| { readonly modified: true; readonly data: T; readonly etag: string | null }
|
|
793
|
+
| { readonly modified: false; readonly etag: string | null }
|
|
794
|
+
|
|
795
|
+
export class ControlClient {
|
|
796
|
+
private readonly requestControl: ControlRequest
|
|
797
|
+
private readonly channel: 'workbench' | 'cli' | 'api'
|
|
798
|
+
|
|
799
|
+
constructor(requestControl: ControlRequest, channel: 'workbench' | 'cli' | 'api' = 'api') {
|
|
800
|
+
this.channel = channel
|
|
801
|
+
this.requestControl = requestControl
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
async loadOpenApiDocument(url: string, signal?: AbortSignal): Promise<JsonValue> {
|
|
805
|
+
const result = record(await this.request('/v1/openapi/document', { method: 'POST', body: JSON.stringify({ url, version: 1 }), signal }))
|
|
806
|
+
if (result.version != 1) return invalidResponse()
|
|
807
|
+
return jsonValue(result.document)
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
async listFlows(
|
|
811
|
+
options: { readonly cursor?: string; readonly includeTotal?: boolean; readonly limit?: number; readonly signal?: AbortSignal } = {},
|
|
812
|
+
): Promise<FlowPage> {
|
|
813
|
+
const parameters = new URLSearchParams()
|
|
814
|
+
if (options.cursor != null) parameters.set('cursor', options.cursor)
|
|
815
|
+
if (options.limit != null) parameters.set('limit', String(options.limit))
|
|
816
|
+
if (options.includeTotal != null) parameters.set('includeTotal', String(options.includeTotal))
|
|
817
|
+
const query = parameters.size == 0 ? '' : `?${parameters}`
|
|
818
|
+
return flowPage(await this.request(`/v1/flows${query}`, options.signal == null ? undefined : { signal: options.signal }))
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
async listEventSources(
|
|
822
|
+
flowId?: string,
|
|
823
|
+
signal?: AbortSignal,
|
|
824
|
+
): Promise<{ readonly version: 1; readonly sources: readonly EventSource[]; readonly teamId?: string | null }> {
|
|
825
|
+
return decodeEventSources(await this.request('/v1/event-sources' + (flowId == null ? '' : `?flowId=${segment(flowId)}`), { signal }))
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
async listEventSourceConnections(
|
|
829
|
+
teamId: string | null,
|
|
830
|
+
signal?: AbortSignal,
|
|
831
|
+
kind: 'feishu' | 'slack' | 'intercom' | 'sentry' | 'zoom' | 'fireflies' | 'jira' = 'feishu',
|
|
832
|
+
): Promise<readonly ConnectorConnection[]> {
|
|
833
|
+
const source = record(await this.request(`/v1/event-sources/connections?kind=${kind}${teamId == null ? '' : `&teamId=${segment(teamId)}`}`, { signal }))
|
|
834
|
+
requiredFields(source, ['version', 'connections'])
|
|
835
|
+
if (source.version != 1 || !Array.isArray(source.connections)) return invalidResponse()
|
|
836
|
+
return source.connections.map(connection)
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
async createEventSource(input: CreateEventSource): Promise<EventSource> {
|
|
840
|
+
return decodeEventSource(await this.request('/v1/event-sources', { method: 'POST', body: JSON.stringify(input) }))
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
async updateEventSource(sourceId: string, input: UpdateEventSource): Promise<EventSource> {
|
|
844
|
+
return decodeEventSource(await this.request(`/v1/event-sources/${segment(sourceId)}`, { method: 'PUT', body: JSON.stringify(input) }))
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
async deleteEventSource(sourceId: string, expectedRevision: number): Promise<void> {
|
|
848
|
+
await this.request(`/v1/event-sources/${segment(sourceId)}`, { method: 'DELETE', body: JSON.stringify({ version: 1, expectedRevision }) })
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
async listVariables(): Promise<{ readonly variables: readonly VariableListItem[]; readonly version: 1 }> {
|
|
852
|
+
const source = record(await this.request('/v1/variables'))
|
|
853
|
+
requiredFields(source, ['variables', 'version'])
|
|
854
|
+
if (source.version != 1 || !Array.isArray(source.variables)) return invalidResponse()
|
|
855
|
+
return { variables: source.variables.map(variableListItem), version: 1 }
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
async getFlowReferences(flowId: string, options: { direction?: 'incoming' | 'outgoing'; offset?: number; limit?: number; signal?: AbortSignal } = {}) {
|
|
859
|
+
const query = new URLSearchParams({ direction: options.direction ?? 'incoming', offset: String(options.offset ?? 0), limit: String(options.limit ?? 50) })
|
|
860
|
+
return workflowReferencesSchema.parse(await this.request(`/v1/flows/${segment(flowId)}/references?${query}`, { signal: options.signal }))
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
async getWorkflowContract(flowId: string, signal?: AbortSignal) {
|
|
864
|
+
return workflowContractSchema.parse(await this.request(`/v1/flows/${segment(flowId)}/call-contract`, { signal }))
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
async getVariableReferences(name: string, signal?: AbortSignal): Promise<VariableReferences> {
|
|
868
|
+
return variableReferences(await this.request(`/v1/variables/${segment(name)}/references`, { signal }))
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
async getVariable(name: string): Promise<Variable> {
|
|
872
|
+
return variable(await this.request(`/v1/variables/${segment(name)}`))
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
async putVariable(name: string, value: string): Promise<Variable> {
|
|
876
|
+
return variable(
|
|
877
|
+
await this.request(`/v1/variables/${segment(name)}`, {
|
|
878
|
+
body: JSON.stringify({ value }),
|
|
879
|
+
method: 'PUT',
|
|
880
|
+
}),
|
|
881
|
+
)
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
async deleteVariable(name: string): Promise<void> {
|
|
885
|
+
const source = record(await this.request(`/v1/variables/${segment(name)}`, { method: 'DELETE' }))
|
|
886
|
+
requiredFields(source, ['version'])
|
|
887
|
+
if (source.version != 1) return invalidResponse()
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
async exportFlow(flowId: string): Promise<WorkflowFile> {
|
|
891
|
+
const value = await this.request(`/v1/flows/${segment(flowId)}/export`)
|
|
892
|
+
try {
|
|
893
|
+
return decodeWorkflowFile(value)
|
|
894
|
+
} catch {
|
|
895
|
+
return invalidResponse()
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
async importFlow(file: WorkflowFile, options: { readonly name?: string; readonly teamId?: string; readonly idempotencyKey?: string } = {}): Promise<Flow> {
|
|
900
|
+
return flow(
|
|
901
|
+
await this.request('/v1/flows/import', {
|
|
902
|
+
method: 'POST',
|
|
903
|
+
headers: { 'Idempotency-Key': options.idempotencyKey ?? `flow-${randomId()}` },
|
|
904
|
+
body: JSON.stringify({ file, name: options.name, teamId: options.teamId, version: 1 }),
|
|
905
|
+
}),
|
|
906
|
+
)
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
async createFlow(name: string, idempotencyKey = `flow-${randomId()}`, teamId?: string): Promise<Flow> {
|
|
910
|
+
return flow(
|
|
911
|
+
await this.request('/v1/flows', {
|
|
912
|
+
body: JSON.stringify({ name, ...(teamId == null ? {} : { teamId }), version: 1 }),
|
|
913
|
+
headers: { 'idempotency-key': idempotencyKey },
|
|
914
|
+
method: 'POST',
|
|
915
|
+
}),
|
|
916
|
+
)
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
async broadcastCanvas(flowId: string, command: CanvasCommand): Promise<CanvasBroadcast> {
|
|
920
|
+
const source = record(
|
|
921
|
+
await this.request(`/v1/flows/${segment(flowId)}/canvas`, {
|
|
922
|
+
method: 'POST',
|
|
923
|
+
body: JSON.stringify({ version: 1, command }),
|
|
924
|
+
}),
|
|
925
|
+
)
|
|
926
|
+
requiredFields(source, ['version', 'flowId', 'broadcast'])
|
|
927
|
+
if (source.version != 1 || source.broadcast !== true || source.flowId !== flowId) return invalidResponse()
|
|
928
|
+
return { version: 1, flowId: string(source.flowId), broadcast: true }
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
async getFlow(flowId: string): Promise<Flow> {
|
|
932
|
+
return flow(await this.request(`/v1/flows/${segment(flowId)}`))
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
async getErrorListeners(flowId: string, signal?: AbortSignal): Promise<readonly ErrorListener[]> {
|
|
936
|
+
const source = record(await this.request(`/v1/flows/${segment(flowId)}/error-listeners`, { signal }))
|
|
937
|
+
if (source.version != 1 || !Array.isArray(source.listeners)) return invalidResponse()
|
|
938
|
+
return source.listeners.map(errorListener)
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
async renameFlow(flowId: string, name: string): Promise<Flow> {
|
|
942
|
+
return flow(
|
|
943
|
+
await this.request(`/v1/flows/${segment(flowId)}`, {
|
|
944
|
+
body: JSON.stringify({ name, version: 1 }),
|
|
945
|
+
method: 'PATCH',
|
|
946
|
+
}),
|
|
947
|
+
)
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
async deleteFlow(flowId: string): Promise<Flow> {
|
|
951
|
+
return flow(await this.request(`/v1/flows/${segment(flowId)}`, { method: 'DELETE' }))
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
async listTriggerKeys(signal?: AbortSignal, locale?: string): Promise<readonly TriggerKeySummary[]> {
|
|
955
|
+
const source = record(await this.request(`/v1/trigger-keys${locale == null ? '' : `?locale=${encodeURIComponent(locale)}`}`, { signal }))
|
|
956
|
+
if (source.version != 1 || !Array.isArray(source.keys)) return invalidResponse()
|
|
957
|
+
return source.keys.map(triggerKeySummary)
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
async listTriggerDefinitions(signal?: AbortSignal): Promise<readonly TriggerKeySnapshot[]> {
|
|
961
|
+
const source = record(await this.request('/v1/trigger-keys/catalog', { signal }))
|
|
962
|
+
if (source.version != 2 || !Array.isArray(source.definitions)) return invalidResponse()
|
|
963
|
+
return source.definitions.map(triggerKey)
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
async readCatalog<T>(
|
|
967
|
+
query: { readonly path: string; readonly decode: (data: unknown) => T },
|
|
968
|
+
etag: string | null,
|
|
969
|
+
signal?: AbortSignal,
|
|
970
|
+
): Promise<ConditionalResult<T>> {
|
|
971
|
+
const headers = new Headers()
|
|
972
|
+
if (etag) headers.set('if-none-match', etag)
|
|
973
|
+
const response = await this.response(query.path, { headers, signal }, true)
|
|
974
|
+
const nextETag = response.headers.get('etag')?.trim() || null
|
|
975
|
+
if (response.status == 304) return { modified: false, etag: nextETag }
|
|
976
|
+
return { modified: true, data: query.decode(await response.json()), etag: nextETag }
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
async getTriggerCatalog(locale: string, cached?: TriggerCatalogCache, signal?: AbortSignal): Promise<TriggerCatalogCache> {
|
|
980
|
+
const headers = new Headers()
|
|
981
|
+
if (cached?.etag) headers.set('if-none-match', cached.etag)
|
|
982
|
+
const response = await this.response(`/v1/trigger-keys/catalog?locale=${encodeURIComponent(locale)}`, { headers, signal }, true)
|
|
983
|
+
if (response.status == 304) {
|
|
984
|
+
if (cached == null) return invalidResponse()
|
|
985
|
+
return { ...cached, etag: response.headers.get('etag')?.trim() || cached.etag }
|
|
986
|
+
}
|
|
987
|
+
return { data: decodeTriggerCatalog(await response.json()), etag: response.headers.get('etag')?.trim() || null }
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
async getTriggerKey(key: string, signal?: AbortSignal): Promise<TriggerKeySnapshot> {
|
|
991
|
+
const source = record(await this.request(`/v1/trigger-keys/${segment(key)}`, { signal }))
|
|
992
|
+
if (source.version != 1) return invalidResponse()
|
|
993
|
+
return triggerKey(source.definition)
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
async listFlowTriggerBindings(flowId: string, signal?: AbortSignal): Promise<readonly TriggerBinding[]> {
|
|
997
|
+
const source = record(await this.request(`/v1/flows/${segment(flowId)}/triggers`, { signal }))
|
|
998
|
+
if (source.version != 1 || string(source.flowId) != flowId || !Array.isArray(source.bindings)) {
|
|
999
|
+
return invalidResponse()
|
|
1000
|
+
}
|
|
1001
|
+
return source.bindings.map(triggerBinding)
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
async getFlowTriggerBinding(flowId: string, triggerNodeId: string): Promise<TriggerBindingDetail> {
|
|
1005
|
+
return triggerBindingDetail(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}`))
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
async listFlowTriggerActivities(
|
|
1009
|
+
flowId: string,
|
|
1010
|
+
triggerNodeId: string,
|
|
1011
|
+
options: { readonly cursor?: string; readonly limit?: number } = {},
|
|
1012
|
+
): Promise<TriggerActivityPage> {
|
|
1013
|
+
const parameters = new URLSearchParams()
|
|
1014
|
+
if (options.cursor != null) parameters.set('cursor', options.cursor)
|
|
1015
|
+
if (options.limit != null) parameters.set('limit', String(options.limit))
|
|
1016
|
+
const query = parameters.size == 0 ? '' : `?${parameters}`
|
|
1017
|
+
return triggerActivityPage(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/activities${query}`))
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
async testFlowPollTrigger(flowId: string, triggerNodeId: string): Promise<PollTriggerTestResult> {
|
|
1021
|
+
return pollTriggerTestResult(
|
|
1022
|
+
await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/test`, {
|
|
1023
|
+
body: JSON.stringify({ version: 1 }),
|
|
1024
|
+
method: 'POST',
|
|
1025
|
+
}),
|
|
1026
|
+
)
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
async getEditor(
|
|
1030
|
+
flowId: string,
|
|
1031
|
+
): Promise<{ readonly flow: Flow; readonly draft: Draft; readonly live: Live; readonly presentation: Presentation; readonly version: 1 }> {
|
|
1032
|
+
const source = record(await this.request(`/v1/flows/${segment(flowId)}/editor`))
|
|
1033
|
+
if (source.version != 1) return invalidResponse()
|
|
1034
|
+
const result = {
|
|
1035
|
+
flow: flow(source.flow),
|
|
1036
|
+
draft: draft(source.draft),
|
|
1037
|
+
live: live(source.live),
|
|
1038
|
+
presentation: presentation(source.presentation),
|
|
1039
|
+
version: 1 as const,
|
|
1040
|
+
}
|
|
1041
|
+
if (result.flow.flowId != flowId || result.draft.flowId != flowId || result.live.flowId != flowId || result.flow.draftRevisionId != result.draft.revisionId)
|
|
1042
|
+
return invalidResponse()
|
|
1043
|
+
return result
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
async getPublicationPresentation(flowId: string, publicationId: string, signal?: AbortSignal): Promise<PublicationPresentation> {
|
|
1047
|
+
const source = record(await this.request(`/v1/flows/${segment(flowId)}/publications/${segment(publicationId)}/presentation`, { signal }))
|
|
1048
|
+
if (source.version != 1) return invalidResponse()
|
|
1049
|
+
return { version: 1, presentation: source.presentation === null ? null : presentation(source.presentation) }
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
async getPresentation(flowId: string): Promise<Presentation> {
|
|
1053
|
+
return presentation(await this.request(`/v1/flows/${segment(flowId)}/presentation`))
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
async getDraft(flowId: string): Promise<Draft> {
|
|
1057
|
+
return draft(await this.request(`/v1/flows/${segment(flowId)}/draft`))
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
async syncDraft(flowId: string): Promise<DraftSync> {
|
|
1061
|
+
return draftSync(await this.request(`/v1/flows/${segment(flowId)}/draft/sync`))
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
async getRevision(flowId: string, revisionId: string, signal?: AbortSignal): Promise<Draft> {
|
|
1065
|
+
return draft(await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}`, { signal }))
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
async listTriggerConfigOptions(flowId: string, nodeId: string, field: string, signal?: AbortSignal): Promise<readonly TriggerConfigOption[]> {
|
|
1069
|
+
const source = record(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(nodeId)}/options/${segment(field)}`, { signal }))
|
|
1070
|
+
requiredFields(source, ['options', 'version'])
|
|
1071
|
+
if (source.version != 1 || !Array.isArray(source.options) || source.options.length > 1000) return invalidResponse()
|
|
1072
|
+
return source.options.map((value) => {
|
|
1073
|
+
const item = record(value)
|
|
1074
|
+
requiredFields(item, ['value', 'label', ...(item.color == null ? [] : ['color'])])
|
|
1075
|
+
const color = item.color == null ? undefined : string(item.color)
|
|
1076
|
+
if (color != null && !/^#[0-9a-fA-F]{6}$/.test(color)) return invalidResponse()
|
|
1077
|
+
return color == null ? { value: string(item.value), label: string(item.label) } : { value: string(item.value), label: string(item.label), color }
|
|
1078
|
+
})
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
async listConnectorTeams(signal?: AbortSignal) {
|
|
1082
|
+
const source = record(await this.request('/v1/connector/teams', { signal }))
|
|
1083
|
+
requiredFields(source, ['enabled', 'teams', 'version'])
|
|
1084
|
+
if (source.version != 1 || typeof source.enabled != 'boolean' || !Array.isArray(source.teams)) return invalidResponse()
|
|
1085
|
+
return {
|
|
1086
|
+
enabled: source.enabled,
|
|
1087
|
+
teams: source.teams.map((value: unknown) => {
|
|
1088
|
+
const team = record(value)
|
|
1089
|
+
requiredFields(team, ['id', 'name', 'systemCreated'])
|
|
1090
|
+
if (typeof team.systemCreated != 'boolean') return invalidResponse()
|
|
1091
|
+
return { id: string(team.id), name: string(team.name), systemCreated: team.systemCreated }
|
|
1092
|
+
}),
|
|
1093
|
+
version: 1 as const,
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
async listConnectorProviders(signal?: AbortSignal, flowId?: string, locale?: string): Promise<readonly ConnectorProvider[]> {
|
|
1098
|
+
const query = connectorProvidersQuery(flowId, locale)
|
|
1099
|
+
return this.connectorRequest(query.path, 'providers', signal, query.decode)
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
async listLeinaBots(flowId: string, signal?: AbortSignal): Promise<readonly LeinaBot[]> {
|
|
1103
|
+
return leinaBots(await this.request(`/v1/connector/leina/bots?flowId=${segment(flowId)}`, { signal }))
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
async removeConnectionUsage(
|
|
1107
|
+
flowId: string,
|
|
1108
|
+
connectionId: string,
|
|
1109
|
+
expectedRevisionId: string,
|
|
1110
|
+
expectedAccessRevision: number,
|
|
1111
|
+
idempotencyKey: string,
|
|
1112
|
+
): Promise<DraftChange> {
|
|
1113
|
+
return draftChange(
|
|
1114
|
+
await this.request(`/v1/flows/${segment(flowId)}/connection-usage/remove`, {
|
|
1115
|
+
method: 'POST',
|
|
1116
|
+
headers: { 'idempotency-key': idempotencyKey },
|
|
1117
|
+
body: JSON.stringify({ connectionId, expectedRevisionId, expectedAccessRevision, version: 1 }),
|
|
1118
|
+
}),
|
|
1119
|
+
)
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
async getConnectorAccess(flowId: string, signal?: AbortSignal): Promise<ConnectorAccess> {
|
|
1123
|
+
return connectorAccess(await this.request(`/v1/flows/${segment(flowId)}/connector-access`, { signal }))
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
async getPublishedConnectorAccess(flowId: string, publicationId: string, signal?: AbortSignal): Promise<ConnectorAccessSnapshot> {
|
|
1127
|
+
return connectorAccessSnapshot(await this.request(`/v1/flows/${segment(flowId)}/connector-access?publicationId=${segment(publicationId)}`, { signal }))
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
async listProviderAccessBindingCandidates(flowId: string, providerIds: readonly string[], signal?: AbortSignal): Promise<ConnectorAccessCandidatesBatch> {
|
|
1131
|
+
return connectorAccessCandidatesBatch(
|
|
1132
|
+
await this.request(`/v1/flows/${segment(flowId)}/connector-access/candidates/query`, {
|
|
1133
|
+
method: 'POST',
|
|
1134
|
+
body: JSON.stringify({ providerIds, version: 1 }),
|
|
1135
|
+
signal,
|
|
1136
|
+
}),
|
|
1137
|
+
providerIds,
|
|
1138
|
+
)
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
async setConnectorService(flowId: string, providerId: string, selected: boolean, expectedAccessRevision: number): Promise<ConnectorAccess> {
|
|
1142
|
+
return connectorAccess(
|
|
1143
|
+
await this.request(`/v1/flows/${segment(flowId)}/connector-access/${segment(providerId)}/service`, {
|
|
1144
|
+
body: JSON.stringify({ expectedAccessRevision, version: 1 }),
|
|
1145
|
+
method: selected ? 'PUT' : 'DELETE',
|
|
1146
|
+
}),
|
|
1147
|
+
)
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
async addProviderAccessBinding(flowId: string, providerId: string, accessBindingId: string, expectedAccessRevision: number): Promise<ConnectorAccess> {
|
|
1151
|
+
return connectorAccess(
|
|
1152
|
+
await this.request(`/v1/flows/${segment(flowId)}/connector-access/${segment(providerId)}`, {
|
|
1153
|
+
body: JSON.stringify({ accessBindingId, expectedAccessRevision, version: 1 }),
|
|
1154
|
+
method: 'PUT',
|
|
1155
|
+
}),
|
|
1156
|
+
)
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
async removeProviderAccessBinding(flowId: string, providerId: string, accessBindingId: string, expectedAccessRevision: number): Promise<ConnectorAccess> {
|
|
1160
|
+
return connectorAccess(
|
|
1161
|
+
await this.request(`/v1/flows/${segment(flowId)}/connector-access/${segment(providerId)}`, {
|
|
1162
|
+
body: JSON.stringify({ accessBindingId, expectedAccessRevision, version: 1 }),
|
|
1163
|
+
method: 'DELETE',
|
|
1164
|
+
}),
|
|
1165
|
+
)
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
async listConnectorActions(serviceId?: string, signal?: AbortSignal, flowId?: string, locale?: string): Promise<readonly ConnectorAction[]> {
|
|
1169
|
+
return await this.connectorActions(
|
|
1170
|
+
{ ...(locale == null ? {} : { locale }), ...(flowId == null ? {} : { flowId }), ...(serviceId == null ? {} : { service: serviceId }) },
|
|
1171
|
+
signal,
|
|
1172
|
+
)
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
async searchConnectorActions(query: string, signal?: AbortSignal, flowId?: string, locale?: string): Promise<readonly ConnectorAction[]> {
|
|
1176
|
+
return await this.connectorActions({ ...(locale == null ? {} : { locale }), ...(flowId == null ? {} : { flowId }), q: query.trim() }, signal)
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
async getConnectorAction(actionId: string, signal?: AbortSignal, flowId?: string, locale?: string, fresh = false): Promise<ConnectorAction> {
|
|
1180
|
+
const query = connectorActionQuery(actionId, flowId, locale)
|
|
1181
|
+
return this.connectorRequest(query.path, 'actions', signal, query.decode, fresh)
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
async listAllConnectorConnections(signal?: AbortSignal, flowId?: string, fresh = false): Promise<readonly ConnectorConnection[]> {
|
|
1185
|
+
const query = allConnectorConnectionsQuery(flowId)
|
|
1186
|
+
return this.connectorRequest(query.path, 'connections', signal, query.decode, fresh)
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
async listConnectorConnections(serviceId: string, signal?: AbortSignal, flowId?: string, fresh = false): Promise<readonly ConnectorConnection[]> {
|
|
1190
|
+
const query = connectorConnectionsQuery(serviceId, flowId)
|
|
1191
|
+
return this.connectorRequest(query.path, 'connections', signal, query.decode, fresh)
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
async createConnectorConnectionPage(serviceId: string, flowId?: string, teamId?: string): Promise<string> {
|
|
1195
|
+
const parameters = new URLSearchParams()
|
|
1196
|
+
if (flowId != null) parameters.set('flowId', flowId)
|
|
1197
|
+
if (teamId != null) parameters.set('teamId', teamId)
|
|
1198
|
+
const source = record(
|
|
1199
|
+
await this.request(`/v1/connector/connections/${segment(serviceId)}/page${parameters.size == 0 ? '' : `?${parameters}`}`, {
|
|
1200
|
+
body: JSON.stringify({ version: 1 }),
|
|
1201
|
+
method: 'POST',
|
|
1202
|
+
}),
|
|
1203
|
+
)
|
|
1204
|
+
requiredFields(source, ['url', 'version'])
|
|
1205
|
+
if (source.version != 1) return invalidResponse()
|
|
1206
|
+
try {
|
|
1207
|
+
const url = new URL(string(source.url))
|
|
1208
|
+
if (url.protocol != 'http:' && url.protocol != 'https:') return invalidResponse()
|
|
1209
|
+
return url.href
|
|
1210
|
+
} catch {
|
|
1211
|
+
return invalidResponse()
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
async readAuthoring(flowId: string, query: AuthoringRead = {}) {
|
|
1216
|
+
return authoringReadResponse.parse(await this.request(`/v1/flows/${segment(flowId)}/authoring/read`, { method: 'POST', body: JSON.stringify(query) }))
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
async searchAuthoring(flowId: string, query: AuthoringSearch) {
|
|
1220
|
+
return authoringSearchResponse.parse(await this.request(`/v1/flows/${segment(flowId)}/authoring/search`, { method: 'POST', body: JSON.stringify(query) }))
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
async authoringSchema(flowId: string, query: { type?: AuthoringType; action?: string }) {
|
|
1224
|
+
return record(await this.request(`/v1/flows/${segment(flowId)}/authoring/schema`, { method: 'POST', body: JSON.stringify(query) }))
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
async editAuthoring(flowId: string, request: AuthoringRequest) {
|
|
1228
|
+
return authoringEditResponse.parse(
|
|
1229
|
+
await this.request(`/v1/flows/${segment(flowId)}/authoring/edit`, {
|
|
1230
|
+
method: 'POST',
|
|
1231
|
+
headers: { 'idempotency-key': request.requestId },
|
|
1232
|
+
body: JSON.stringify(request),
|
|
1233
|
+
}),
|
|
1234
|
+
)
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
async checkAuthoring(flowId: string, revisionId: string) {
|
|
1238
|
+
return authoringCheckResponse.parse(
|
|
1239
|
+
await this.request(`/v1/flows/${segment(flowId)}/authoring/check`, { method: 'POST', body: JSON.stringify({ revisionId }) }),
|
|
1240
|
+
)
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
async changeDraft(
|
|
1244
|
+
flowId: string,
|
|
1245
|
+
expectedRevisionId: string,
|
|
1246
|
+
operations: readonly DraftOperation[],
|
|
1247
|
+
changeId = operationKey('change'),
|
|
1248
|
+
): Promise<DraftChange> {
|
|
1249
|
+
return draftChange(
|
|
1250
|
+
await this.request(`/v1/flows/${segment(flowId)}/draft/changes`, {
|
|
1251
|
+
body: JSON.stringify({ expectedRevisionId, operations, version: 1 }),
|
|
1252
|
+
headers: { 'idempotency-key': changeId },
|
|
1253
|
+
method: 'POST',
|
|
1254
|
+
}),
|
|
1255
|
+
)
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
async repairDraft(flowId: string, expectedRevisionId: string, changeId = operationKey('repair')): Promise<DraftChange> {
|
|
1259
|
+
return draftChange(
|
|
1260
|
+
await this.request(`/v1/flows/${segment(flowId)}/draft/repair`, {
|
|
1261
|
+
body: JSON.stringify({ expectedRevisionId, version: 1 }),
|
|
1262
|
+
headers: { 'idempotency-key': changeId },
|
|
1263
|
+
method: 'POST',
|
|
1264
|
+
}),
|
|
1265
|
+
)
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
async upgradeDraft(flowId: string, expectedRevisionId: string, options: { readonly idempotencyKey?: string } = {}): Promise<DraftChange> {
|
|
1269
|
+
return draftChange(
|
|
1270
|
+
await this.request(`/v1/flows/${segment(flowId)}/draft/upgrade`, {
|
|
1271
|
+
body: JSON.stringify({ expectedRevisionId, version: 1 }),
|
|
1272
|
+
headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('upgrade') },
|
|
1273
|
+
method: 'POST',
|
|
1274
|
+
}),
|
|
1275
|
+
)
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
async checkFlow(flowId: string, revisionId: string): Promise<FlowCheck> {
|
|
1279
|
+
return flowCheck(
|
|
1280
|
+
await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}/check`, {
|
|
1281
|
+
body: JSON.stringify({ engineContract: currentEngineContract, version: 1 }),
|
|
1282
|
+
method: 'POST',
|
|
1283
|
+
}),
|
|
1284
|
+
)
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
async getLiveDetails(flowId: string, signal?: AbortSignal): Promise<LiveDetails> {
|
|
1288
|
+
const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }))
|
|
1289
|
+
if (details.flowId != flowId) return invalidResponse()
|
|
1290
|
+
return details
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
async getLive(flowId: string, signal?: AbortSignal): Promise<Live> {
|
|
1294
|
+
return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }))
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
async listPublications(
|
|
1298
|
+
flowId: string,
|
|
1299
|
+
options: { readonly cursor?: string; readonly includeTotal?: boolean; readonly limit?: number } = {},
|
|
1300
|
+
signal?: AbortSignal,
|
|
1301
|
+
): Promise<PublicationPage> {
|
|
1302
|
+
const parameters = new URLSearchParams()
|
|
1303
|
+
if (options.cursor != null) parameters.set('cursor', options.cursor)
|
|
1304
|
+
if (options.limit != null) parameters.set('limit', String(options.limit))
|
|
1305
|
+
if (options.includeTotal != null) parameters.set('includeTotal', String(options.includeTotal))
|
|
1306
|
+
const query = parameters.size == 0 ? '' : `?${parameters}`
|
|
1307
|
+
return publicationPage(await this.request(`/v1/flows/${segment(flowId)}/publications${query}`, { signal }))
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
async createDraftRun(flowId: string, revisionId: string, options: RunOptions): Promise<DraftRun> {
|
|
1311
|
+
const created = runDetails(
|
|
1312
|
+
await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}/runs`, {
|
|
1313
|
+
body: JSON.stringify({ engineContract: currentEngineContract, inputs: options.inputs ?? {}, trigger: options.trigger, version: 2 }),
|
|
1314
|
+
headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('run'), 'x-open-flow-client': this.channel },
|
|
1315
|
+
method: 'POST',
|
|
1316
|
+
}),
|
|
1317
|
+
)
|
|
1318
|
+
return created.source == 'draft' ? created : invalidResponse()
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
async createLiveRun(publicationId: string, options: RunOptions): Promise<LiveRun> {
|
|
1322
|
+
const created = runDetails(
|
|
1323
|
+
await this.request('/v1/runs', {
|
|
1324
|
+
body: JSON.stringify({ inputs: options.inputs ?? {}, trigger: options.trigger, publicationId, version: 2 }),
|
|
1325
|
+
headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('run'), 'x-open-flow-client': this.channel },
|
|
1326
|
+
method: 'POST',
|
|
1327
|
+
}),
|
|
1328
|
+
)
|
|
1329
|
+
return created.source == 'live' ? created : invalidResponse()
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
async setFlowEnabled(flowId: string, publicationId: string, enabled: boolean): Promise<Flow> {
|
|
1333
|
+
return flow(
|
|
1334
|
+
await this.request(`/v1/flows/${segment(flowId)}/enabled`, {
|
|
1335
|
+
method: 'PUT',
|
|
1336
|
+
body: JSON.stringify({ enabled, expectedPublicationId: publicationId, version: 1 }),
|
|
1337
|
+
}),
|
|
1338
|
+
)
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
async publishFlow(flowId: string, revisionId: string, expectedLivePublicationId: string | null, options: PublicationOptions = {}): Promise<PublishOperation> {
|
|
1342
|
+
return publishOperation(
|
|
1343
|
+
await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}/publications`, {
|
|
1344
|
+
body: JSON.stringify({ engineContract: currentEngineContract, expectedLivePublicationId, version: 1 }),
|
|
1345
|
+
headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('publication') },
|
|
1346
|
+
method: 'POST',
|
|
1347
|
+
}),
|
|
1348
|
+
)
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
async getPublishOperation(flowId: string, operationId: string, signal?: AbortSignal): Promise<PublishOperation> {
|
|
1352
|
+
return publishOperation(await this.request(`/v1/flows/${segment(flowId)}/publish-operations/${segment(operationId)}`, { signal }))
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
async rollbackFlow(flowId: string, publicationId: string, expectedLivePublicationId: string, options: PublicationOptions = {}): Promise<Publication> {
|
|
1356
|
+
return publication(
|
|
1357
|
+
await this.request(`/v1/flows/${segment(flowId)}/publications/${segment(publicationId)}/rollback`, {
|
|
1358
|
+
body: JSON.stringify({ expectedLivePublicationId, version: 1 }),
|
|
1359
|
+
headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('publication') },
|
|
1360
|
+
method: 'POST',
|
|
1361
|
+
}),
|
|
1362
|
+
)
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
async getRun(runId: string, signal?: AbortSignal): Promise<RunDetails> {
|
|
1366
|
+
return runDetails(await this.request(`/v1/runs/${segment(runId)}`, { signal }))
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
async listRuns(
|
|
1370
|
+
flowId: string,
|
|
1371
|
+
options: {
|
|
1372
|
+
readonly createdBefore?: string
|
|
1373
|
+
readonly createdFrom?: string
|
|
1374
|
+
readonly cursor?: string
|
|
1375
|
+
readonly limit?: number
|
|
1376
|
+
readonly pendingWait?: boolean
|
|
1377
|
+
readonly runId?: string
|
|
1378
|
+
readonly source?: Run['source']
|
|
1379
|
+
readonly status?: RunStatus
|
|
1380
|
+
} = {},
|
|
1381
|
+
): Promise<RunPage> {
|
|
1382
|
+
const parameters = new URLSearchParams()
|
|
1383
|
+
if (options.cursor != null) parameters.set('cursor', options.cursor)
|
|
1384
|
+
if (options.limit != null) parameters.set('limit', String(options.limit))
|
|
1385
|
+
if (options.status != null) parameters.set('status', options.status)
|
|
1386
|
+
if (options.pendingWait != null) parameters.set('pendingWait', String(options.pendingWait))
|
|
1387
|
+
if (options.source != null) parameters.set('source', options.source)
|
|
1388
|
+
if (options.createdFrom != null) parameters.set('createdFrom', options.createdFrom)
|
|
1389
|
+
if (options.createdBefore != null) parameters.set('createdBefore', options.createdBefore)
|
|
1390
|
+
if (options.runId != null) parameters.set('runId', options.runId)
|
|
1391
|
+
const query = parameters.size == 0 ? '' : `?${parameters}`
|
|
1392
|
+
return runPage(await this.request(`/v1/flows/${segment(flowId)}/runs${query}`))
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
async getRunEvents(runId: string, options: { readonly after?: number; readonly limit?: number } = {}, signal?: AbortSignal): Promise<RunEvents> {
|
|
1396
|
+
const parameters = new URLSearchParams()
|
|
1397
|
+
if (options.after != null) parameters.set('after', String(options.after))
|
|
1398
|
+
if (options.limit != null) parameters.set('limit', String(options.limit))
|
|
1399
|
+
const query = parameters.size == 0 ? '' : `?${parameters}`
|
|
1400
|
+
return runEvents(await this.request(`/v1/runs/${segment(runId)}/events${query}`, { signal }))
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
async listRunResults(runId: string, after?: string, signal?: AbortSignal): Promise<ReturnType<typeof decodeResultList>> {
|
|
1404
|
+
return decodeResultList(await this.request(`/v1/runs/${segment(runId)}/results${after == null ? '' : `?after=${encodeURIComponent(after)}`}`, { signal }))
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
async readRunResult(runId: string, resultId: string, options: ResultQuery = {}, signal?: AbortSignal): Promise<ReturnType<typeof decodeResultRead>> {
|
|
1408
|
+
const parameters = new URLSearchParams(Object.entries(options).map(([key, value]) => [key, String(value)]))
|
|
1409
|
+
return decodeResultRead(await this.request(`/v1/runs/${segment(runId)}/results/${segment(resultId)}?${parameters}`, { signal }))
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
async downloadRunResult(runId: string, resultId: string, signal?: AbortSignal): Promise<Blob> {
|
|
1413
|
+
return (await this.response(`/v1/runs/${segment(runId)}/results/${segment(resultId)}/content`, { signal })).blob()
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
async getRunResult(runId: string, signal?: AbortSignal): Promise<RunResult> {
|
|
1417
|
+
return runResult(await this.request(`/v1/runs/${segment(runId)}/result`, { signal }))
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
async cancelRun(runId: string): Promise<RunCancellation> {
|
|
1421
|
+
return runCancellation(
|
|
1422
|
+
await this.request(`/v1/runs/${segment(runId)}/cancel`, {
|
|
1423
|
+
body: JSON.stringify({ version: 1 }),
|
|
1424
|
+
method: 'POST',
|
|
1425
|
+
}),
|
|
1426
|
+
)
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
async resolveRunWait(
|
|
1430
|
+
runId: string,
|
|
1431
|
+
waitId: string,
|
|
1432
|
+
action: WaitAction,
|
|
1433
|
+
comment?: string | null,
|
|
1434
|
+
): Promise<{
|
|
1435
|
+
readonly action: WaitAction | null
|
|
1436
|
+
readonly comment: string | null
|
|
1437
|
+
readonly resolutionAccepted: boolean
|
|
1438
|
+
readonly resolvedAt: string | null
|
|
1439
|
+
readonly runId: string
|
|
1440
|
+
readonly status: RunStatus
|
|
1441
|
+
readonly version: 1
|
|
1442
|
+
readonly waitId: string
|
|
1443
|
+
}> {
|
|
1444
|
+
return waitResolution(
|
|
1445
|
+
await this.request(`/v1/runs/${segment(runId)}/waits/${segment(waitId)}/resolve`, {
|
|
1446
|
+
body: JSON.stringify({ action, comment, version: 1 }),
|
|
1447
|
+
method: 'POST',
|
|
1448
|
+
}),
|
|
1449
|
+
)
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
private async connectorActions(parameters: Readonly<Record<string, string>>, signal?: AbortSignal): Promise<readonly ConnectorAction[]> {
|
|
1453
|
+
const query = Object.entries(parameters)
|
|
1454
|
+
.map(([key, value]) => `${segment(key)}=${segment(value)}`)
|
|
1455
|
+
.join('&')
|
|
1456
|
+
const suffix = query == '' ? '' : `?${query}`
|
|
1457
|
+
return this.connectorRequest(`/v1/connector/actions${suffix}`, 'actions', signal, (value) => {
|
|
1458
|
+
const source = record(value)
|
|
1459
|
+
requiredFields(source, ['actions', 'version'])
|
|
1460
|
+
if (source.version != 1 || !Array.isArray(source.actions)) return invalidResponse()
|
|
1461
|
+
return source.actions.map(connectorAction)
|
|
1462
|
+
})
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
protected async connectorRequest<Value>(
|
|
1466
|
+
path: string,
|
|
1467
|
+
_kind: 'providers' | 'actions' | 'connections',
|
|
1468
|
+
signal: AbortSignal | undefined,
|
|
1469
|
+
decode: (value: unknown) => Value,
|
|
1470
|
+
_fresh = false,
|
|
1471
|
+
): Promise<Value> {
|
|
1472
|
+
return decode(await this.request(path, { signal }))
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
protected async response(path: string, init: RequestInit, allowNotModified = false): Promise<Response> {
|
|
1476
|
+
const headers = new Headers(init.headers)
|
|
1477
|
+
if (init.body != null) headers.set('content-type', 'application/json')
|
|
1478
|
+
const response = await this.requestControl(path, { ...init, headers })
|
|
1479
|
+
if (!response.ok && !(allowNotModified && response.status == 304)) {
|
|
1480
|
+
let value: unknown
|
|
1481
|
+
try {
|
|
1482
|
+
value = await response.json()
|
|
1483
|
+
} catch {
|
|
1484
|
+
return invalidResponse()
|
|
1485
|
+
}
|
|
1486
|
+
const error = record(value).error
|
|
1487
|
+
const source = error == null ? undefined : record(error)
|
|
1488
|
+
throw new ApiError(
|
|
1489
|
+
response.status,
|
|
1490
|
+
typeof source?.code == 'string' ? source.code : 'request.failed',
|
|
1491
|
+
typeof source?.message == 'string' ? source.message : `Request failed with status ${response.status}.`,
|
|
1492
|
+
source?.details == null ? undefined : record(source.details),
|
|
1493
|
+
)
|
|
1494
|
+
}
|
|
1495
|
+
return response
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
protected async request<Value = unknown>(path: string, init: RequestInit = {}): Promise<Value> {
|
|
1499
|
+
const response = await this.response(path, init)
|
|
1500
|
+
try {
|
|
1501
|
+
return (await response.json()) as Value
|
|
1502
|
+
} catch {
|
|
1503
|
+
return invalidResponse()
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|