@oomol-lab/open-flow 0.1.0-beta.72 → 0.1.0-beta.74

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.
Files changed (432) hide show
  1. package/LICENSE +36 -0
  2. package/NOTICE +7 -0
  3. package/README.md +40 -0
  4. package/dist/browser/{createResourceDialog-BWJkjiOO.js → createResourceDialog-DI9pL-Yr.js} +2 -2
  5. package/dist/browser/{dialog-CUy_fwx9.js → dialog-BYJGvItc.js} +54 -19
  6. package/dist/browser/{flowChanges-CgSnSqqP.js → flowChanges-RL-H4CjD.js} +306 -48
  7. package/dist/browser/{flowWorkspace-Bf7H-r0t.js → flowWorkspace-BkDsETj0.js} +20745 -20186
  8. package/dist/browser/preview.css +73 -3
  9. package/dist/browser/preview.js +21410 -20607
  10. package/dist/browser/{typeScriptSession-B0hC-C8y.js → typeScriptSession-CSRwWmZm.js} +1 -1
  11. package/dist/browser/ui.css +72 -2
  12. package/dist/browser/workbench.css +73 -3
  13. package/dist/browser/workbench.js +14 -76
  14. package/dist/browser/{workbenchSelect-C3e4J93X.js → workbenchSelect-BcWPWGzw.js} +1 -1
  15. package/dist/command/index.js +34 -34
  16. package/dist/common/authoring.d.ts +1 -1
  17. package/dist/common/authoringFields.d.ts +1 -1
  18. package/dist/common/authoringSchema.d.ts +28 -4
  19. package/dist/common/connector-proxy.d.ts +1 -1
  20. package/dist/common/control-api-conformance.d.ts +1 -1
  21. package/dist/common/control-api-conformance.js +61 -24
  22. package/dist/common/control-api.d.ts +4 -3
  23. package/dist/common/control-api.js +90 -42
  24. package/dist/common/control-requests.d.ts +2 -1
  25. package/dist/common/control-requests.js +204 -42
  26. package/dist/common/cron-trigger.d.ts +1 -1
  27. package/dist/common/decision.d.ts +1 -1
  28. package/dist/common/draftOperations.d.ts +1 -1
  29. package/dist/common/engine-contract.d.ts +3 -2
  30. package/dist/common/event-source-definition.d.ts +1 -1
  31. package/dist/common/flow-agent.d.ts +1 -1
  32. package/dist/{browser → common}/flow-authoring-node.d.ts +3 -3
  33. package/dist/{browser → common}/flow-authoring.js +75 -23
  34. package/dist/{browser → common}/flow-change-schema.d.ts +177 -6
  35. package/dist/{browser → common}/flow-change.d.ts +35 -15
  36. package/dist/{browser → common}/flow-change.js +77 -25
  37. package/dist/common/flow-connectionUsage.d.ts +1 -1
  38. package/dist/common/flow-encoding.d.ts +1 -1
  39. package/dist/common/flow-encoding.js +34 -16
  40. package/dist/common/flow-errorHandling.d.ts +1 -1
  41. package/dist/common/flow-graph.d.ts +1 -1
  42. package/dist/common/flow-modules.d.ts +1 -1
  43. package/dist/common/flow-promptTemplate.d.ts +1 -1
  44. package/dist/common/flow-retry.d.ts +1 -1
  45. package/dist/common/flow-semantics.d.ts +1 -1
  46. package/dist/common/flow-semantics.js +151 -32
  47. package/dist/common/flow-workflowFile.d.ts +1 -1
  48. package/dist/common/flowInspection.d.ts +3 -3
  49. package/dist/common/integration-trigger.d.ts +1 -1
  50. package/dist/common/licenses.md +118 -1
  51. package/dist/common/liveDetails.d.ts +1 -1
  52. package/dist/common/mcp.d.ts +2 -1
  53. package/dist/common/mcp.js +59 -22
  54. package/dist/common/openapi.d.ts +1 -1
  55. package/dist/common/poll-trigger.d.ts +1 -1
  56. package/dist/common/run-results.d.ts +8 -1
  57. package/dist/common/runtime-contract.d.ts +8 -2
  58. package/dist/common/runtime-contract.js +22 -5
  59. package/dist/common/scheduler-checkpoint.d.ts +1 -1
  60. package/dist/common/scheduler-dependencies.d.ts +1 -1
  61. package/dist/common/scheduler-node-execution.d.ts +1 -1
  62. package/dist/common/scheduler.d.ts +2 -2
  63. package/dist/common/scheduler.js +31 -12
  64. package/dist/common/trigger-catalog.d.ts +1 -1
  65. package/dist/common/trigger-config-options.d.ts +1 -1
  66. package/dist/common/trigger-config.d.ts +1 -1
  67. package/dist/common/trigger-contract.d.ts +2 -2
  68. package/dist/common/trigger-localization.d.ts +1 -1
  69. package/dist/common/webhook-response.d.ts +1 -1
  70. package/dist/common/webhook-trigger.d.ts +1 -1
  71. package/dist/common/workflow.d.ts +17 -1
  72. package/dist/common/workflow.js +68 -22
  73. package/dist/index.d.ts +6 -3
  74. package/package.json +7 -6
  75. package/src/base/common/json.ts +90 -0
  76. package/src/canvas/common/commands.ts +15 -0
  77. package/src/connector/common/actionSchema.ts +168 -0
  78. package/src/connector/common/proxy.ts +44 -0
  79. package/src/control/common/api.ts +1505 -0
  80. package/src/control/common/authoring.ts +912 -0
  81. package/src/control/common/authoringCondition.ts +110 -0
  82. package/src/control/common/authoringDiagnosticFields.ts +136 -0
  83. package/src/control/common/authoringExamples.ts +192 -0
  84. package/src/control/common/authoringFields.ts +53 -0
  85. package/src/control/common/authoringLlm.ts +70 -0
  86. package/src/control/common/authoringOpenApi.ts +129 -0
  87. package/src/control/common/authoringSchema.ts +404 -0
  88. package/src/control/common/authoringTools.ts +123 -0
  89. package/src/control/common/authoringTriggers.ts +26 -0
  90. package/src/control/common/checkDecoders.ts +65 -0
  91. package/src/control/common/conformance.ts +1989 -0
  92. package/src/control/common/connectorDecoders.ts +370 -0
  93. package/src/control/common/connectorQueries.ts +61 -0
  94. package/src/control/common/decoding.ts +60 -0
  95. package/src/control/common/draftOperations.ts +61 -0
  96. package/src/control/common/errors.ts +114 -0
  97. package/src/control/common/eventSourceSchemas.ts +13 -0
  98. package/src/control/common/eventSources.ts +186 -0
  99. package/src/control/common/flowDecoders.ts +153 -0
  100. package/src/control/common/flowInspection.ts +181 -0
  101. package/src/control/common/flowNotifications.ts +37 -0
  102. package/src/control/common/liveDetails.ts +124 -0
  103. package/src/control/common/mcp.ts +241 -0
  104. package/src/control/common/mcpConformance.ts +142 -0
  105. package/src/control/common/providerAccess.ts +28 -0
  106. package/src/control/common/providerIconSprite.ts +42 -0
  107. package/src/control/common/publicationDecoders.ts +98 -0
  108. package/src/control/common/random.ts +16 -0
  109. package/src/control/common/requests.ts +112 -0
  110. package/src/control/common/resultQuery.ts +8 -0
  111. package/src/control/common/results.ts +176 -0
  112. package/src/control/common/revisionDecoders.ts +52 -0
  113. package/src/control/common/runDecoders.ts +240 -0
  114. package/src/control/common/triggerCatalog.ts +89 -0
  115. package/src/control/common/triggerDecoders.ts +175 -0
  116. package/src/decision/common/decision.ts +168 -0
  117. package/src/event-source/common/catalog.generated.json +65 -0
  118. package/src/event-source/common/definition.ts +66 -0
  119. package/src/event-source/common/index.ts +99 -0
  120. package/src/execution/common/checkpoint.ts +311 -0
  121. package/src/execution/common/dependencies.ts +440 -0
  122. package/src/execution/common/engineContract.ts +80 -0
  123. package/src/execution/common/events.ts +328 -0
  124. package/src/execution/common/node-execution.ts +467 -0
  125. package/src/execution/common/runLifecycle.ts +250 -0
  126. package/src/execution/common/runtime.ts +563 -0
  127. package/src/execution/common/scheduler.ts +696 -0
  128. package/src/execution/common/wait.ts +36 -0
  129. package/src/flow/common/agent.ts +305 -0
  130. package/src/flow/common/authoring.ts +30 -0
  131. package/src/flow/common/change.ts +1036 -0
  132. package/src/flow/common/changeSchema.ts +783 -0
  133. package/src/flow/common/codePermissions.ts +2 -0
  134. package/src/flow/common/condition.ts +265 -0
  135. package/src/flow/common/connectionUsage.ts +131 -0
  136. package/src/flow/common/edgeChanges.ts +35 -0
  137. package/src/flow/common/encoding.ts +437 -0
  138. package/src/flow/common/errorHandling.ts +34 -0
  139. package/src/flow/common/graph.ts +892 -0
  140. package/src/flow/common/inputValue.ts +16 -0
  141. package/src/flow/common/json.ts +8 -0
  142. package/src/flow/common/moduleChanges.ts +31 -0
  143. package/src/flow/common/modules.ts +292 -0
  144. package/src/flow/common/nodeChanges.ts +762 -0
  145. package/src/flow/common/portChanges.ts +36 -0
  146. package/src/flow/common/promptTemplate.ts +15 -0
  147. package/src/flow/common/retry.ts +20 -0
  148. package/src/flow/common/schema.ts +162 -0
  149. package/src/flow/common/schemaCompare.ts +176 -0
  150. package/src/flow/common/schemaComparer.ts +178 -0
  151. package/src/flow/common/schemaKeywords.ts +53 -0
  152. package/src/flow/common/semantics.ts +474 -0
  153. package/src/flow/common/sourceField.ts +35 -0
  154. package/src/flow/common/triggerScheduleSchema.ts +8 -0
  155. package/src/flow/common/wait.ts +30 -0
  156. package/src/flow/common/webhookMethod.ts +7 -0
  157. package/src/flow/common/webhookResponse.ts +75 -0
  158. package/src/flow/common/workflowFile.ts +97 -0
  159. package/src/json-schema-subset/checker/array.ts +142 -0
  160. package/src/json-schema-subset/checker/cache.ts +57 -0
  161. package/src/json-schema-subset/checker/checker.ts +230 -0
  162. package/src/json-schema-subset/checker/enumAndConst.ts +113 -0
  163. package/src/json-schema-subset/checker/equals.ts +93 -0
  164. package/src/json-schema-subset/checker/numeric/checker.ts +50 -0
  165. package/src/json-schema-subset/checker/numeric/float.ts +121 -0
  166. package/src/json-schema-subset/checker/numeric/index.ts +1 -0
  167. package/src/json-schema-subset/checker/numeric/integer.ts +119 -0
  168. package/src/json-schema-subset/checker/numeric/integerNormalizer.ts +72 -0
  169. package/src/json-schema-subset/checker/object.ts +354 -0
  170. package/src/json-schema-subset/checker/range.ts +91 -0
  171. package/src/json-schema-subset/checker/string.ts +60 -0
  172. package/src/json-schema-subset/checker/tools/index.ts +3 -0
  173. package/src/json-schema-subset/checker/tools/mark.ts +82 -0
  174. package/src/json-schema-subset/checker/tools/quantum.ts +106 -0
  175. package/src/json-schema-subset/checker/tools/range.ts +210 -0
  176. package/src/json-schema-subset/checker/validator.ts +23 -0
  177. package/src/json-schema-subset/compiler/array.ts +163 -0
  178. package/src/json-schema-subset/compiler/combination.ts +109 -0
  179. package/src/json-schema-subset/compiler/common.ts +99 -0
  180. package/src/json-schema-subset/compiler/compiler.ts +188 -0
  181. package/src/json-schema-subset/compiler/enumAndConst.ts +75 -0
  182. package/src/json-schema-subset/compiler/index.ts +11 -0
  183. package/src/json-schema-subset/compiler/object.ts +411 -0
  184. package/src/json-schema-subset/compiler/primitive.ts +144 -0
  185. package/src/json-schema-subset/compiler/utils.ts +24 -0
  186. package/src/json-schema-subset/compiler/wrapper.ts +192 -0
  187. package/src/json-schema-subset/error.ts +55 -0
  188. package/src/json-schema-subset/expression/calculator.ts +442 -0
  189. package/src/json-schema-subset/expression/combination.ts +49 -0
  190. package/src/json-schema-subset/expression/expression.ts +191 -0
  191. package/src/json-schema-subset/expression/index.ts +25 -0
  192. package/src/json-schema-subset/expression/result.ts +88 -0
  193. package/src/json-schema-subset/expression/types.ts +36 -0
  194. package/src/json-schema-subset/extends/extendsContext.ts +89 -0
  195. package/src/json-schema-subset/extends/index.ts +2 -0
  196. package/src/json-schema-subset/extends/types.ts +12 -0
  197. package/src/json-schema-subset/global.ts +60 -0
  198. package/src/json-schema-subset/index.ts +8 -0
  199. package/src/json-schema-subset/preprocessing.ts +74 -0
  200. package/src/json-schema-subset/types.ts +8 -0
  201. package/src/json-schema-subset/utils.ts +95 -0
  202. package/src/localization/common/languages.ts +118 -0
  203. package/src/localization/common/timeZone.ts +25 -0
  204. package/src/openapi/common/authBindings.ts +12 -0
  205. package/src/openapi/common/openapi.ts +459 -0
  206. package/src/trigger/common/config.ts +56 -0
  207. package/src/trigger/common/configOptions.ts +15 -0
  208. package/src/trigger/common/configSchema.ts +8 -0
  209. package/src/trigger/common/contract.ts +132 -0
  210. package/src/trigger/common/cron.ts +151 -0
  211. package/src/trigger/common/integration.ts +498 -0
  212. package/src/trigger/common/poll.ts +187 -0
  213. package/src/trigger/common/webhook.ts +412 -0
  214. package/src/trigger/providers/airtable/locales/fr.json +18 -0
  215. package/src/trigger/providers/airtable/locales/ja.json +18 -0
  216. package/src/trigger/providers/airtable/locales/ko.json +18 -0
  217. package/src/trigger/providers/airtable/locales/ru.json +18 -0
  218. package/src/trigger/providers/airtable/locales/zh-CN.json +18 -0
  219. package/src/trigger/providers/airtable/locales/zh-TW.json +18 -0
  220. package/src/trigger/providers/asana/locales/fr.json +15 -0
  221. package/src/trigger/providers/asana/locales/ja.json +15 -0
  222. package/src/trigger/providers/asana/locales/ko.json +15 -0
  223. package/src/trigger/providers/asana/locales/ru.json +15 -0
  224. package/src/trigger/providers/asana/locales/zh-CN.json +15 -0
  225. package/src/trigger/providers/asana/locales/zh-TW.json +15 -0
  226. package/src/trigger/providers/calendly/locales/fr.json +16 -0
  227. package/src/trigger/providers/calendly/locales/ja.json +16 -0
  228. package/src/trigger/providers/calendly/locales/ko.json +16 -0
  229. package/src/trigger/providers/calendly/locales/ru.json +16 -0
  230. package/src/trigger/providers/calendly/locales/zh-CN.json +16 -0
  231. package/src/trigger/providers/calendly/locales/zh-TW.json +16 -0
  232. package/src/trigger/providers/catalog.generated.json +4996 -0
  233. package/src/trigger/providers/clickup/locales/fr.json +16 -0
  234. package/src/trigger/providers/clickup/locales/ja.json +16 -0
  235. package/src/trigger/providers/clickup/locales/ko.json +16 -0
  236. package/src/trigger/providers/clickup/locales/ru.json +16 -0
  237. package/src/trigger/providers/clickup/locales/zh-CN.json +16 -0
  238. package/src/trigger/providers/clickup/locales/zh-TW.json +16 -0
  239. package/src/trigger/providers/definitions.ts +19 -0
  240. package/src/trigger/providers/feishu/locales/fr.json +20 -0
  241. package/src/trigger/providers/feishu/locales/ja.json +20 -0
  242. package/src/trigger/providers/feishu/locales/ko.json +20 -0
  243. package/src/trigger/providers/feishu/locales/ru.json +20 -0
  244. package/src/trigger/providers/feishu/locales/zh-CN.json +20 -0
  245. package/src/trigger/providers/feishu/locales/zh-TW.json +20 -0
  246. package/src/trigger/providers/fieldDescriptions.ts +392 -0
  247. package/src/trigger/providers/fieldLabels.ts +256 -0
  248. package/src/trigger/providers/fireflies/locales/fr.json +17 -0
  249. package/src/trigger/providers/fireflies/locales/ja.json +17 -0
  250. package/src/trigger/providers/fireflies/locales/ko.json +17 -0
  251. package/src/trigger/providers/fireflies/locales/ru.json +17 -0
  252. package/src/trigger/providers/fireflies/locales/zh-CN.json +17 -0
  253. package/src/trigger/providers/fireflies/locales/zh-TW.json +17 -0
  254. package/src/trigger/providers/github/locales/fr.json +30 -0
  255. package/src/trigger/providers/github/locales/ja.json +30 -0
  256. package/src/trigger/providers/github/locales/ko.json +30 -0
  257. package/src/trigger/providers/github/locales/ru.json +30 -0
  258. package/src/trigger/providers/github/locales/zh-CN.json +30 -0
  259. package/src/trigger/providers/github/locales/zh-TW.json +30 -0
  260. package/src/trigger/providers/gitlab/locales/fr.json +18 -0
  261. package/src/trigger/providers/gitlab/locales/ja.json +18 -0
  262. package/src/trigger/providers/gitlab/locales/ko.json +18 -0
  263. package/src/trigger/providers/gitlab/locales/ru.json +18 -0
  264. package/src/trigger/providers/gitlab/locales/zh-CN.json +18 -0
  265. package/src/trigger/providers/gitlab/locales/zh-TW.json +18 -0
  266. package/src/trigger/providers/gmail/locales/fr.json +18 -0
  267. package/src/trigger/providers/gmail/locales/ja.json +18 -0
  268. package/src/trigger/providers/gmail/locales/ko.json +18 -0
  269. package/src/trigger/providers/gmail/locales/ru.json +18 -0
  270. package/src/trigger/providers/gmail/locales/zh-CN.json +18 -0
  271. package/src/trigger/providers/gmail/locales/zh-TW.json +18 -0
  272. package/src/trigger/providers/google-calendar/locales/fr.json +15 -0
  273. package/src/trigger/providers/google-calendar/locales/ja.json +15 -0
  274. package/src/trigger/providers/google-calendar/locales/ko.json +15 -0
  275. package/src/trigger/providers/google-calendar/locales/ru.json +15 -0
  276. package/src/trigger/providers/google-calendar/locales/zh-CN.json +15 -0
  277. package/src/trigger/providers/google-calendar/locales/zh-TW.json +15 -0
  278. package/src/trigger/providers/google-drive/locales/fr.json +48 -0
  279. package/src/trigger/providers/google-drive/locales/ja.json +48 -0
  280. package/src/trigger/providers/google-drive/locales/ko.json +48 -0
  281. package/src/trigger/providers/google-drive/locales/ru.json +48 -0
  282. package/src/trigger/providers/google-drive/locales/zh-CN.json +48 -0
  283. package/src/trigger/providers/google-drive/locales/zh-TW.json +48 -0
  284. package/src/trigger/providers/google-sheets/locales/fr.json +19 -0
  285. package/src/trigger/providers/google-sheets/locales/ja.json +19 -0
  286. package/src/trigger/providers/google-sheets/locales/ko.json +19 -0
  287. package/src/trigger/providers/google-sheets/locales/ru.json +19 -0
  288. package/src/trigger/providers/google-sheets/locales/zh-CN.json +19 -0
  289. package/src/trigger/providers/google-sheets/locales/zh-TW.json +19 -0
  290. package/src/trigger/providers/intercom/locales/fr.json +17 -0
  291. package/src/trigger/providers/intercom/locales/ja.json +17 -0
  292. package/src/trigger/providers/intercom/locales/ko.json +17 -0
  293. package/src/trigger/providers/intercom/locales/ru.json +17 -0
  294. package/src/trigger/providers/intercom/locales/zh-CN.json +17 -0
  295. package/src/trigger/providers/intercom/locales/zh-TW.json +17 -0
  296. package/src/trigger/providers/jira/locales/fr.json +17 -0
  297. package/src/trigger/providers/jira/locales/ja.json +17 -0
  298. package/src/trigger/providers/jira/locales/ko.json +17 -0
  299. package/src/trigger/providers/jira/locales/ru.json +17 -0
  300. package/src/trigger/providers/jira/locales/zh-CN.json +17 -0
  301. package/src/trigger/providers/jira/locales/zh-TW.json +17 -0
  302. package/src/trigger/providers/linear/locales/fr.json +13 -0
  303. package/src/trigger/providers/linear/locales/ja.json +13 -0
  304. package/src/trigger/providers/linear/locales/ko.json +13 -0
  305. package/src/trigger/providers/linear/locales/ru.json +13 -0
  306. package/src/trigger/providers/linear/locales/zh-CN.json +13 -0
  307. package/src/trigger/providers/linear/locales/zh-TW.json +13 -0
  308. package/src/trigger/providers/locales/fr.ts +71 -0
  309. package/src/trigger/providers/locales/ja.ts +71 -0
  310. package/src/trigger/providers/locales/ko.ts +71 -0
  311. package/src/trigger/providers/locales/ru.ts +71 -0
  312. package/src/trigger/providers/locales/zh-CN.ts +71 -0
  313. package/src/trigger/providers/locales/zh-TW.ts +71 -0
  314. package/src/trigger/providers/localization.ts +59 -0
  315. package/src/trigger/providers/notion/locales/fr.json +16 -0
  316. package/src/trigger/providers/notion/locales/ja.json +16 -0
  317. package/src/trigger/providers/notion/locales/ko.json +16 -0
  318. package/src/trigger/providers/notion/locales/ru.json +16 -0
  319. package/src/trigger/providers/notion/locales/zh-CN.json +16 -0
  320. package/src/trigger/providers/notion/locales/zh-TW.json +16 -0
  321. package/src/trigger/providers/one-drive/locales/fr.json +16 -0
  322. package/src/trigger/providers/one-drive/locales/ja.json +16 -0
  323. package/src/trigger/providers/one-drive/locales/ko.json +16 -0
  324. package/src/trigger/providers/one-drive/locales/ru.json +16 -0
  325. package/src/trigger/providers/one-drive/locales/zh-CN.json +16 -0
  326. package/src/trigger/providers/one-drive/locales/zh-TW.json +16 -0
  327. package/src/trigger/providers/outlook/locales/fr.json +18 -0
  328. package/src/trigger/providers/outlook/locales/ja.json +18 -0
  329. package/src/trigger/providers/outlook/locales/ko.json +18 -0
  330. package/src/trigger/providers/outlook/locales/ru.json +18 -0
  331. package/src/trigger/providers/outlook/locales/zh-CN.json +18 -0
  332. package/src/trigger/providers/outlook/locales/zh-TW.json +18 -0
  333. package/src/trigger/providers/pandadoc/locales/fr.json +12 -0
  334. package/src/trigger/providers/pandadoc/locales/ja.json +12 -0
  335. package/src/trigger/providers/pandadoc/locales/ko.json +12 -0
  336. package/src/trigger/providers/pandadoc/locales/ru.json +12 -0
  337. package/src/trigger/providers/pandadoc/locales/zh-CN.json +12 -0
  338. package/src/trigger/providers/pandadoc/locales/zh-TW.json +12 -0
  339. package/src/trigger/providers/pipedrive/locales/fr.json +15 -0
  340. package/src/trigger/providers/pipedrive/locales/ja.json +15 -0
  341. package/src/trigger/providers/pipedrive/locales/ko.json +15 -0
  342. package/src/trigger/providers/pipedrive/locales/ru.json +15 -0
  343. package/src/trigger/providers/pipedrive/locales/zh-CN.json +15 -0
  344. package/src/trigger/providers/pipedrive/locales/zh-TW.json +15 -0
  345. package/src/trigger/providers/remote.ts +163 -0
  346. package/src/trigger/providers/resend/locales/fr.json +16 -0
  347. package/src/trigger/providers/resend/locales/ja.json +16 -0
  348. package/src/trigger/providers/resend/locales/ko.json +16 -0
  349. package/src/trigger/providers/resend/locales/ru.json +16 -0
  350. package/src/trigger/providers/resend/locales/zh-CN.json +16 -0
  351. package/src/trigger/providers/resend/locales/zh-TW.json +16 -0
  352. package/src/trigger/providers/sentry/locales/fr.json +19 -0
  353. package/src/trigger/providers/sentry/locales/ja.json +19 -0
  354. package/src/trigger/providers/sentry/locales/ko.json +19 -0
  355. package/src/trigger/providers/sentry/locales/ru.json +19 -0
  356. package/src/trigger/providers/sentry/locales/zh-CN.json +19 -0
  357. package/src/trigger/providers/sentry/locales/zh-TW.json +19 -0
  358. package/src/trigger/providers/shopify/locales/fr.json +18 -0
  359. package/src/trigger/providers/shopify/locales/ja.json +18 -0
  360. package/src/trigger/providers/shopify/locales/ko.json +18 -0
  361. package/src/trigger/providers/shopify/locales/ru.json +18 -0
  362. package/src/trigger/providers/shopify/locales/zh-CN.json +18 -0
  363. package/src/trigger/providers/shopify/locales/zh-TW.json +18 -0
  364. package/src/trigger/providers/slack/locales/fr.json +18 -0
  365. package/src/trigger/providers/slack/locales/ja.json +18 -0
  366. package/src/trigger/providers/slack/locales/ko.json +18 -0
  367. package/src/trigger/providers/slack/locales/ru.json +18 -0
  368. package/src/trigger/providers/slack/locales/zh-CN.json +18 -0
  369. package/src/trigger/providers/slack/locales/zh-TW.json +18 -0
  370. package/src/trigger/providers/slackbot/locales/fr.json +23 -0
  371. package/src/trigger/providers/slackbot/locales/ja.json +23 -0
  372. package/src/trigger/providers/slackbot/locales/ko.json +23 -0
  373. package/src/trigger/providers/slackbot/locales/ru.json +23 -0
  374. package/src/trigger/providers/slackbot/locales/zh-CN.json +23 -0
  375. package/src/trigger/providers/slackbot/locales/zh-TW.json +23 -0
  376. package/src/trigger/providers/source-events.ts +25 -0
  377. package/src/trigger/providers/stripe/locales/fr.json +17 -0
  378. package/src/trigger/providers/stripe/locales/ja.json +17 -0
  379. package/src/trigger/providers/stripe/locales/ko.json +17 -0
  380. package/src/trigger/providers/stripe/locales/ru.json +17 -0
  381. package/src/trigger/providers/stripe/locales/zh-CN.json +17 -0
  382. package/src/trigger/providers/stripe/locales/zh-TW.json +17 -0
  383. package/src/trigger/providers/tally/locales/fr.json +12 -0
  384. package/src/trigger/providers/tally/locales/ja.json +12 -0
  385. package/src/trigger/providers/tally/locales/ko.json +12 -0
  386. package/src/trigger/providers/tally/locales/ru.json +12 -0
  387. package/src/trigger/providers/tally/locales/zh-CN.json +12 -0
  388. package/src/trigger/providers/tally/locales/zh-TW.json +12 -0
  389. package/src/trigger/providers/telegram/locales/fr.json +17 -0
  390. package/src/trigger/providers/telegram/locales/ja.json +17 -0
  391. package/src/trigger/providers/telegram/locales/ko.json +17 -0
  392. package/src/trigger/providers/telegram/locales/ru.json +17 -0
  393. package/src/trigger/providers/telegram/locales/zh-CN.json +17 -0
  394. package/src/trigger/providers/telegram/locales/zh-TW.json +17 -0
  395. package/src/trigger/providers/typeform/locales/fr.json +12 -0
  396. package/src/trigger/providers/typeform/locales/ja.json +12 -0
  397. package/src/trigger/providers/typeform/locales/ko.json +12 -0
  398. package/src/trigger/providers/typeform/locales/ru.json +12 -0
  399. package/src/trigger/providers/typeform/locales/zh-CN.json +12 -0
  400. package/src/trigger/providers/typeform/locales/zh-TW.json +12 -0
  401. package/src/trigger/providers/vercel/locales/fr.json +18 -0
  402. package/src/trigger/providers/vercel/locales/ja.json +18 -0
  403. package/src/trigger/providers/vercel/locales/ko.json +18 -0
  404. package/src/trigger/providers/vercel/locales/ru.json +18 -0
  405. package/src/trigger/providers/vercel/locales/zh-CN.json +18 -0
  406. package/src/trigger/providers/vercel/locales/zh-TW.json +18 -0
  407. package/src/trigger/providers/woocommerce/locales/fr.json +19 -0
  408. package/src/trigger/providers/woocommerce/locales/ja.json +19 -0
  409. package/src/trigger/providers/woocommerce/locales/ko.json +19 -0
  410. package/src/trigger/providers/woocommerce/locales/ru.json +19 -0
  411. package/src/trigger/providers/woocommerce/locales/zh-CN.json +19 -0
  412. package/src/trigger/providers/woocommerce/locales/zh-TW.json +19 -0
  413. package/src/trigger/providers/zendesk/locales/fr.json +15 -0
  414. package/src/trigger/providers/zendesk/locales/ja.json +15 -0
  415. package/src/trigger/providers/zendesk/locales/ko.json +15 -0
  416. package/src/trigger/providers/zendesk/locales/ru.json +15 -0
  417. package/src/trigger/providers/zendesk/locales/zh-CN.json +15 -0
  418. package/src/trigger/providers/zendesk/locales/zh-TW.json +15 -0
  419. package/src/trigger/providers/zoom/locales/fr.json +17 -0
  420. package/src/trigger/providers/zoom/locales/ja.json +17 -0
  421. package/src/trigger/providers/zoom/locales/ko.json +17 -0
  422. package/src/trigger/providers/zoom/locales/ru.json +17 -0
  423. package/src/trigger/providers/zoom/locales/zh-CN.json +17 -0
  424. package/src/trigger/providers/zoom/locales/zh-TW.json +17 -0
  425. package/src/types/index.ts +112 -0
  426. package/src/workflow/common/workflow.ts +273 -0
  427. package/dist/browser/lib-DrKav3HG.js +0 -11403
  428. /package/dist/{browser → common}/flow-authoring-edge.d.ts +0 -0
  429. /package/dist/{browser → common}/flow-authoring-module.d.ts +0 -0
  430. /package/dist/{browser → common}/flow-authoring.d.ts +0 -0
  431. /package/dist/{browser → common}/flow-input-value.d.ts +0 -0
  432. /package/dist/{browser → common}/webhook-method.d.ts +0 -0
@@ -0,0 +1,1505 @@
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 !== 'llm' &&
679
+ nodeKind !== 'agent' &&
680
+ nodeKind !== 'value' &&
681
+ nodeKind !== 'outputs' &&
682
+ nodeKind !== 'webhook-response' &&
683
+ nodeKind !== 'workflow' &&
684
+ nodeKind !== 'wait'
685
+ )
686
+ return invalidResponse()
687
+ return {
688
+ ...base,
689
+ kind,
690
+ payload: {
691
+ ...node,
692
+ ...(nodeKind === undefined ? {} : { nodeKind }),
693
+ ...(payload.nodeTitle === undefined ? {} : { nodeTitle: string(payload.nodeTitle) }),
694
+ ...(payload.operation === undefined ? {} : { operation: string(payload.operation) }),
695
+ },
696
+ } as const
697
+ }
698
+ case 'node.completed':
699
+ return {
700
+ ...base,
701
+ kind,
702
+ payload: {
703
+ ...node,
704
+ ...(payload.systemOutputs === undefined
705
+ ? {}
706
+ : { systemOutputs: Object.fromEntries(Object.entries(record(payload.systemOutputs)).map(([key, item]) => [key, jsonValue(item)])) }),
707
+ outputs: Object.fromEntries(Object.entries(record(payload.outputs)).map(([key, item]) => [key, jsonValue(item)])),
708
+ },
709
+ } as const
710
+ case 'node.failed': {
711
+ const error = record(payload.error)
712
+ return {
713
+ ...base,
714
+ kind,
715
+ payload: {
716
+ ...node,
717
+ ...(payload.handled === true ? { handled: true as const } : {}),
718
+ ...(payload.systemOutputs === undefined
719
+ ? {}
720
+ : { systemOutputs: Object.fromEntries(Object.entries(record(payload.systemOutputs)).map(([key, item]) => [key, jsonValue(item)])) }),
721
+ error: { code: string(error.code), message: string(error.message) },
722
+ },
723
+ } as const
724
+ }
725
+ case 'node.log': {
726
+ const level = payload.level
727
+ if (level !== 'debug' && level !== 'info' && level !== 'warn' && level !== 'error') return invalidResponse()
728
+ return { ...base, kind, payload: { ...node, level, message: string(payload.message) } } as const
729
+ }
730
+ case 'node.progress':
731
+ return { ...base, kind, payload: { ...node, progress: eventProgress(payload.progress) } } as const
732
+ case 'node.artifact': {
733
+ const artifact = record(payload.artifact)
734
+ const size = integer(artifact.size)
735
+ const digest = string(artifact.digest)
736
+ if (artifact.kind != 'artifact' || size < 0 || !/^sha256:[0-9a-f]{64}$/.test(digest)) return invalidResponse()
737
+ return {
738
+ ...base,
739
+ kind,
740
+ payload: {
741
+ ...node,
742
+ artifact: {
743
+ kind: 'artifact',
744
+ id: string(artifact.id),
745
+ name: string(artifact.name),
746
+ size,
747
+ digest,
748
+ ...(artifact.mediaType === undefined ? {} : { mediaType: string(artifact.mediaType) }),
749
+ },
750
+ },
751
+ } as const
752
+ }
753
+ }
754
+ }
755
+ default:
756
+ return invalidResponse()
757
+ }
758
+ }
759
+
760
+ function eventProgress(value: unknown): number {
761
+ return typeof value == 'number' && Number.isFinite(value) && value >= 0 && value <= 100 ? value : invalidResponse()
762
+ }
763
+
764
+ function runEvents(value: unknown): RunEvents {
765
+ const source = record(value)
766
+ const eventsExpiresAt = source.eventsExpiresAt
767
+ const nextAfter = integer(source.nextAfter)
768
+ if (source.version != 1 || !Array.isArray(source.events) || typeof source.done != 'boolean' || typeof source.historyComplete != 'boolean') {
769
+ return invalidResponse()
770
+ }
771
+ if (eventsExpiresAt != null && typeof eventsExpiresAt != 'string') return invalidResponse()
772
+ if (nextAfter < 0) return invalidResponse()
773
+ return {
774
+ done: source.done,
775
+ events: source.events.map(decodeRunEvent),
776
+ ...(eventsExpiresAt == null ? {} : { eventsExpiresAt }),
777
+ historyComplete: source.historyComplete,
778
+ nextAfter,
779
+ runId: string(source.runId),
780
+ version: 1,
781
+ }
782
+ }
783
+
784
+ const segment = encodeURIComponent
785
+
786
+ function operationKey(operation: string): string {
787
+ return `${operation}-${randomId()}`
788
+ }
789
+
790
+ export type ConditionalResult<T> =
791
+ | { readonly modified: true; readonly data: T; readonly etag: string | null }
792
+ | { readonly modified: false; readonly etag: string | null }
793
+
794
+ export class ControlClient {
795
+ private readonly requestControl: ControlRequest
796
+ private readonly channel: 'workbench' | 'cli' | 'api'
797
+
798
+ constructor(requestControl: ControlRequest, channel: 'workbench' | 'cli' | 'api' = 'api') {
799
+ this.channel = channel
800
+ this.requestControl = requestControl
801
+ }
802
+
803
+ async loadOpenApiDocument(url: string, signal?: AbortSignal): Promise<JsonValue> {
804
+ const result = record(await this.request('/v1/openapi/document', { method: 'POST', body: JSON.stringify({ url, version: 1 }), signal }))
805
+ if (result.version != 1) return invalidResponse()
806
+ return jsonValue(result.document)
807
+ }
808
+
809
+ async listFlows(
810
+ options: { readonly cursor?: string; readonly includeTotal?: boolean; readonly limit?: number; readonly signal?: AbortSignal } = {},
811
+ ): Promise<FlowPage> {
812
+ const parameters = new URLSearchParams()
813
+ if (options.cursor != null) parameters.set('cursor', options.cursor)
814
+ if (options.limit != null) parameters.set('limit', String(options.limit))
815
+ if (options.includeTotal != null) parameters.set('includeTotal', String(options.includeTotal))
816
+ const query = parameters.size == 0 ? '' : `?${parameters}`
817
+ return flowPage(await this.request(`/v1/flows${query}`, options.signal == null ? undefined : { signal: options.signal }))
818
+ }
819
+
820
+ async listEventSources(
821
+ flowId?: string,
822
+ signal?: AbortSignal,
823
+ ): Promise<{ readonly version: 1; readonly sources: readonly EventSource[]; readonly teamId?: string | null }> {
824
+ return decodeEventSources(await this.request('/v1/event-sources' + (flowId == null ? '' : `?flowId=${segment(flowId)}`), { signal }))
825
+ }
826
+
827
+ async listEventSourceConnections(
828
+ teamId: string | null,
829
+ signal?: AbortSignal,
830
+ kind: 'feishu' | 'slack' | 'intercom' | 'sentry' | 'zoom' | 'fireflies' | 'jira' = 'feishu',
831
+ ): Promise<readonly ConnectorConnection[]> {
832
+ const source = record(await this.request(`/v1/event-sources/connections?kind=${kind}${teamId == null ? '' : `&teamId=${segment(teamId)}`}`, { signal }))
833
+ requiredFields(source, ['version', 'connections'])
834
+ if (source.version != 1 || !Array.isArray(source.connections)) return invalidResponse()
835
+ return source.connections.map(connection)
836
+ }
837
+
838
+ async createEventSource(input: CreateEventSource): Promise<EventSource> {
839
+ return decodeEventSource(await this.request('/v1/event-sources', { method: 'POST', body: JSON.stringify(input) }))
840
+ }
841
+
842
+ async updateEventSource(sourceId: string, input: UpdateEventSource): Promise<EventSource> {
843
+ return decodeEventSource(await this.request(`/v1/event-sources/${segment(sourceId)}`, { method: 'PUT', body: JSON.stringify(input) }))
844
+ }
845
+
846
+ async deleteEventSource(sourceId: string, expectedRevision: number): Promise<void> {
847
+ await this.request(`/v1/event-sources/${segment(sourceId)}`, { method: 'DELETE', body: JSON.stringify({ version: 1, expectedRevision }) })
848
+ }
849
+
850
+ async listVariables(): Promise<{ readonly variables: readonly VariableListItem[]; readonly version: 1 }> {
851
+ const source = record(await this.request('/v1/variables'))
852
+ requiredFields(source, ['variables', 'version'])
853
+ if (source.version != 1 || !Array.isArray(source.variables)) return invalidResponse()
854
+ return { variables: source.variables.map(variableListItem), version: 1 }
855
+ }
856
+
857
+ async getFlowReferences(flowId: string, options: { direction?: 'incoming' | 'outgoing'; offset?: number; limit?: number; signal?: AbortSignal } = {}) {
858
+ const query = new URLSearchParams({ direction: options.direction ?? 'incoming', offset: String(options.offset ?? 0), limit: String(options.limit ?? 50) })
859
+ return workflowReferencesSchema.parse(await this.request(`/v1/flows/${segment(flowId)}/references?${query}`, { signal: options.signal }))
860
+ }
861
+
862
+ async getWorkflowContract(flowId: string, signal?: AbortSignal) {
863
+ return workflowContractSchema.parse(await this.request(`/v1/flows/${segment(flowId)}/call-contract`, { signal }))
864
+ }
865
+
866
+ async getVariableReferences(name: string, signal?: AbortSignal): Promise<VariableReferences> {
867
+ return variableReferences(await this.request(`/v1/variables/${segment(name)}/references`, { signal }))
868
+ }
869
+
870
+ async getVariable(name: string): Promise<Variable> {
871
+ return variable(await this.request(`/v1/variables/${segment(name)}`))
872
+ }
873
+
874
+ async putVariable(name: string, value: string): Promise<Variable> {
875
+ return variable(
876
+ await this.request(`/v1/variables/${segment(name)}`, {
877
+ body: JSON.stringify({ value }),
878
+ method: 'PUT',
879
+ }),
880
+ )
881
+ }
882
+
883
+ async deleteVariable(name: string): Promise<void> {
884
+ const source = record(await this.request(`/v1/variables/${segment(name)}`, { method: 'DELETE' }))
885
+ requiredFields(source, ['version'])
886
+ if (source.version != 1) return invalidResponse()
887
+ }
888
+
889
+ async exportFlow(flowId: string): Promise<WorkflowFile> {
890
+ const value = await this.request(`/v1/flows/${segment(flowId)}/export`)
891
+ try {
892
+ return decodeWorkflowFile(value)
893
+ } catch {
894
+ return invalidResponse()
895
+ }
896
+ }
897
+
898
+ async importFlow(file: WorkflowFile, options: { readonly name?: string; readonly teamId?: string; readonly idempotencyKey?: string } = {}): Promise<Flow> {
899
+ return flow(
900
+ await this.request('/v1/flows/import', {
901
+ method: 'POST',
902
+ headers: { 'Idempotency-Key': options.idempotencyKey ?? `flow-${randomId()}` },
903
+ body: JSON.stringify({ file, name: options.name, teamId: options.teamId, version: 1 }),
904
+ }),
905
+ )
906
+ }
907
+
908
+ async createFlow(name: string, idempotencyKey = `flow-${randomId()}`, teamId?: string): Promise<Flow> {
909
+ return flow(
910
+ await this.request('/v1/flows', {
911
+ body: JSON.stringify({ name, ...(teamId == null ? {} : { teamId }), version: 1 }),
912
+ headers: { 'idempotency-key': idempotencyKey },
913
+ method: 'POST',
914
+ }),
915
+ )
916
+ }
917
+
918
+ async broadcastCanvas(flowId: string, command: CanvasCommand): Promise<CanvasBroadcast> {
919
+ const source = record(
920
+ await this.request(`/v1/flows/${segment(flowId)}/canvas`, {
921
+ method: 'POST',
922
+ body: JSON.stringify({ version: 1, command }),
923
+ }),
924
+ )
925
+ requiredFields(source, ['version', 'flowId', 'broadcast'])
926
+ if (source.version != 1 || source.broadcast !== true || source.flowId !== flowId) return invalidResponse()
927
+ return { version: 1, flowId: string(source.flowId), broadcast: true }
928
+ }
929
+
930
+ async getFlow(flowId: string): Promise<Flow> {
931
+ return flow(await this.request(`/v1/flows/${segment(flowId)}`))
932
+ }
933
+
934
+ async getErrorListeners(flowId: string, signal?: AbortSignal): Promise<readonly ErrorListener[]> {
935
+ const source = record(await this.request(`/v1/flows/${segment(flowId)}/error-listeners`, { signal }))
936
+ if (source.version != 1 || !Array.isArray(source.listeners)) return invalidResponse()
937
+ return source.listeners.map(errorListener)
938
+ }
939
+
940
+ async renameFlow(flowId: string, name: string): Promise<Flow> {
941
+ return flow(
942
+ await this.request(`/v1/flows/${segment(flowId)}`, {
943
+ body: JSON.stringify({ name, version: 1 }),
944
+ method: 'PATCH',
945
+ }),
946
+ )
947
+ }
948
+
949
+ async deleteFlow(flowId: string): Promise<Flow> {
950
+ return flow(await this.request(`/v1/flows/${segment(flowId)}`, { method: 'DELETE' }))
951
+ }
952
+
953
+ async listTriggerKeys(signal?: AbortSignal, locale?: string): Promise<readonly TriggerKeySummary[]> {
954
+ const source = record(await this.request(`/v1/trigger-keys${locale == null ? '' : `?locale=${encodeURIComponent(locale)}`}`, { signal }))
955
+ if (source.version != 1 || !Array.isArray(source.keys)) return invalidResponse()
956
+ return source.keys.map(triggerKeySummary)
957
+ }
958
+
959
+ async listTriggerDefinitions(signal?: AbortSignal): Promise<readonly TriggerKeySnapshot[]> {
960
+ const source = record(await this.request('/v1/trigger-keys/catalog', { signal }))
961
+ if (source.version != 2 || !Array.isArray(source.definitions)) return invalidResponse()
962
+ return source.definitions.map(triggerKey)
963
+ }
964
+
965
+ async readCatalog<T>(
966
+ query: { readonly path: string; readonly decode: (data: unknown) => T },
967
+ etag: string | null,
968
+ signal?: AbortSignal,
969
+ ): Promise<ConditionalResult<T>> {
970
+ const headers = new Headers()
971
+ if (etag) headers.set('if-none-match', etag)
972
+ const response = await this.response(query.path, { headers, signal }, true)
973
+ const nextETag = response.headers.get('etag')?.trim() || null
974
+ if (response.status == 304) return { modified: false, etag: nextETag }
975
+ return { modified: true, data: query.decode(await response.json()), etag: nextETag }
976
+ }
977
+
978
+ async getTriggerCatalog(locale: string, cached?: TriggerCatalogCache, signal?: AbortSignal): Promise<TriggerCatalogCache> {
979
+ const headers = new Headers()
980
+ if (cached?.etag) headers.set('if-none-match', cached.etag)
981
+ const response = await this.response(`/v1/trigger-keys/catalog?locale=${encodeURIComponent(locale)}`, { headers, signal }, true)
982
+ if (response.status == 304) {
983
+ if (cached == null) return invalidResponse()
984
+ return { ...cached, etag: response.headers.get('etag')?.trim() || cached.etag }
985
+ }
986
+ return { data: decodeTriggerCatalog(await response.json()), etag: response.headers.get('etag')?.trim() || null }
987
+ }
988
+
989
+ async getTriggerKey(key: string, signal?: AbortSignal): Promise<TriggerKeySnapshot> {
990
+ const source = record(await this.request(`/v1/trigger-keys/${segment(key)}`, { signal }))
991
+ if (source.version != 1) return invalidResponse()
992
+ return triggerKey(source.definition)
993
+ }
994
+
995
+ async listFlowTriggerBindings(flowId: string, signal?: AbortSignal): Promise<readonly TriggerBinding[]> {
996
+ const source = record(await this.request(`/v1/flows/${segment(flowId)}/triggers`, { signal }))
997
+ if (source.version != 1 || string(source.flowId) != flowId || !Array.isArray(source.bindings)) {
998
+ return invalidResponse()
999
+ }
1000
+ return source.bindings.map(triggerBinding)
1001
+ }
1002
+
1003
+ async getFlowTriggerBinding(flowId: string, triggerNodeId: string): Promise<TriggerBindingDetail> {
1004
+ return triggerBindingDetail(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}`))
1005
+ }
1006
+
1007
+ async listFlowTriggerActivities(
1008
+ flowId: string,
1009
+ triggerNodeId: string,
1010
+ options: { readonly cursor?: string; readonly limit?: number } = {},
1011
+ ): Promise<TriggerActivityPage> {
1012
+ const parameters = new URLSearchParams()
1013
+ if (options.cursor != null) parameters.set('cursor', options.cursor)
1014
+ if (options.limit != null) parameters.set('limit', String(options.limit))
1015
+ const query = parameters.size == 0 ? '' : `?${parameters}`
1016
+ return triggerActivityPage(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/activities${query}`))
1017
+ }
1018
+
1019
+ async testFlowPollTrigger(flowId: string, triggerNodeId: string): Promise<PollTriggerTestResult> {
1020
+ return pollTriggerTestResult(
1021
+ await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(triggerNodeId)}/test`, {
1022
+ body: JSON.stringify({ version: 1 }),
1023
+ method: 'POST',
1024
+ }),
1025
+ )
1026
+ }
1027
+
1028
+ async getEditor(
1029
+ flowId: string,
1030
+ ): Promise<{ readonly flow: Flow; readonly draft: Draft; readonly live: Live; readonly presentation: Presentation; readonly version: 1 }> {
1031
+ const source = record(await this.request(`/v1/flows/${segment(flowId)}/editor`))
1032
+ if (source.version != 1) return invalidResponse()
1033
+ const result = {
1034
+ flow: flow(source.flow),
1035
+ draft: draft(source.draft),
1036
+ live: live(source.live),
1037
+ presentation: presentation(source.presentation),
1038
+ version: 1 as const,
1039
+ }
1040
+ if (result.flow.flowId != flowId || result.draft.flowId != flowId || result.live.flowId != flowId || result.flow.draftRevisionId != result.draft.revisionId)
1041
+ return invalidResponse()
1042
+ return result
1043
+ }
1044
+
1045
+ async getPublicationPresentation(flowId: string, publicationId: string, signal?: AbortSignal): Promise<PublicationPresentation> {
1046
+ const source = record(await this.request(`/v1/flows/${segment(flowId)}/publications/${segment(publicationId)}/presentation`, { signal }))
1047
+ if (source.version != 1) return invalidResponse()
1048
+ return { version: 1, presentation: source.presentation === null ? null : presentation(source.presentation) }
1049
+ }
1050
+
1051
+ async getPresentation(flowId: string): Promise<Presentation> {
1052
+ return presentation(await this.request(`/v1/flows/${segment(flowId)}/presentation`))
1053
+ }
1054
+
1055
+ async getDraft(flowId: string): Promise<Draft> {
1056
+ return draft(await this.request(`/v1/flows/${segment(flowId)}/draft`))
1057
+ }
1058
+
1059
+ async syncDraft(flowId: string): Promise<DraftSync> {
1060
+ return draftSync(await this.request(`/v1/flows/${segment(flowId)}/draft/sync`))
1061
+ }
1062
+
1063
+ async getRevision(flowId: string, revisionId: string, signal?: AbortSignal): Promise<Draft> {
1064
+ return draft(await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}`, { signal }))
1065
+ }
1066
+
1067
+ async listTriggerConfigOptions(flowId: string, nodeId: string, field: string, signal?: AbortSignal): Promise<readonly TriggerConfigOption[]> {
1068
+ const source = record(await this.request(`/v1/flows/${segment(flowId)}/triggers/${segment(nodeId)}/options/${segment(field)}`, { signal }))
1069
+ requiredFields(source, ['options', 'version'])
1070
+ if (source.version != 1 || !Array.isArray(source.options) || source.options.length > 1000) return invalidResponse()
1071
+ return source.options.map((value) => {
1072
+ const item = record(value)
1073
+ requiredFields(item, ['value', 'label', ...(item.color == null ? [] : ['color'])])
1074
+ const color = item.color == null ? undefined : string(item.color)
1075
+ if (color != null && !/^#[0-9a-fA-F]{6}$/.test(color)) return invalidResponse()
1076
+ return color == null ? { value: string(item.value), label: string(item.label) } : { value: string(item.value), label: string(item.label), color }
1077
+ })
1078
+ }
1079
+
1080
+ async listConnectorTeams(signal?: AbortSignal) {
1081
+ const source = record(await this.request('/v1/connector/teams', { signal }))
1082
+ requiredFields(source, ['enabled', 'teams', 'version'])
1083
+ if (source.version != 1 || typeof source.enabled != 'boolean' || !Array.isArray(source.teams)) return invalidResponse()
1084
+ return {
1085
+ enabled: source.enabled,
1086
+ teams: source.teams.map((value: unknown) => {
1087
+ const team = record(value)
1088
+ requiredFields(team, ['id', 'name', 'systemCreated'])
1089
+ if (typeof team.systemCreated != 'boolean') return invalidResponse()
1090
+ return { id: string(team.id), name: string(team.name), systemCreated: team.systemCreated }
1091
+ }),
1092
+ version: 1 as const,
1093
+ }
1094
+ }
1095
+
1096
+ async listConnectorProviders(signal?: AbortSignal, flowId?: string, locale?: string): Promise<readonly ConnectorProvider[]> {
1097
+ const query = connectorProvidersQuery(flowId, locale)
1098
+ return this.connectorRequest(query.path, 'providers', signal, query.decode)
1099
+ }
1100
+
1101
+ async listLeinaBots(flowId: string, signal?: AbortSignal): Promise<readonly LeinaBot[]> {
1102
+ return leinaBots(await this.request(`/v1/connector/leina/bots?flowId=${segment(flowId)}`, { signal }))
1103
+ }
1104
+
1105
+ async removeConnectionUsage(
1106
+ flowId: string,
1107
+ connectionId: string,
1108
+ expectedRevisionId: string,
1109
+ expectedAccessRevision: number,
1110
+ idempotencyKey: string,
1111
+ ): Promise<DraftChange> {
1112
+ return draftChange(
1113
+ await this.request(`/v1/flows/${segment(flowId)}/connection-usage/remove`, {
1114
+ method: 'POST',
1115
+ headers: { 'idempotency-key': idempotencyKey },
1116
+ body: JSON.stringify({ connectionId, expectedRevisionId, expectedAccessRevision, version: 1 }),
1117
+ }),
1118
+ )
1119
+ }
1120
+
1121
+ async getConnectorAccess(flowId: string, signal?: AbortSignal): Promise<ConnectorAccess> {
1122
+ return connectorAccess(await this.request(`/v1/flows/${segment(flowId)}/connector-access`, { signal }))
1123
+ }
1124
+
1125
+ async getPublishedConnectorAccess(flowId: string, publicationId: string, signal?: AbortSignal): Promise<ConnectorAccessSnapshot> {
1126
+ return connectorAccessSnapshot(await this.request(`/v1/flows/${segment(flowId)}/connector-access?publicationId=${segment(publicationId)}`, { signal }))
1127
+ }
1128
+
1129
+ async listProviderAccessBindingCandidates(flowId: string, providerIds: readonly string[], signal?: AbortSignal): Promise<ConnectorAccessCandidatesBatch> {
1130
+ return connectorAccessCandidatesBatch(
1131
+ await this.request(`/v1/flows/${segment(flowId)}/connector-access/candidates/query`, {
1132
+ method: 'POST',
1133
+ body: JSON.stringify({ providerIds, version: 1 }),
1134
+ signal,
1135
+ }),
1136
+ providerIds,
1137
+ )
1138
+ }
1139
+
1140
+ async setConnectorService(flowId: string, providerId: string, selected: boolean, expectedAccessRevision: number): Promise<ConnectorAccess> {
1141
+ return connectorAccess(
1142
+ await this.request(`/v1/flows/${segment(flowId)}/connector-access/${segment(providerId)}/service`, {
1143
+ body: JSON.stringify({ expectedAccessRevision, version: 1 }),
1144
+ method: selected ? 'PUT' : 'DELETE',
1145
+ }),
1146
+ )
1147
+ }
1148
+
1149
+ async addProviderAccessBinding(flowId: string, providerId: string, accessBindingId: string, expectedAccessRevision: number): Promise<ConnectorAccess> {
1150
+ return connectorAccess(
1151
+ await this.request(`/v1/flows/${segment(flowId)}/connector-access/${segment(providerId)}`, {
1152
+ body: JSON.stringify({ accessBindingId, expectedAccessRevision, version: 1 }),
1153
+ method: 'PUT',
1154
+ }),
1155
+ )
1156
+ }
1157
+
1158
+ async removeProviderAccessBinding(flowId: string, providerId: string, accessBindingId: string, expectedAccessRevision: number): Promise<ConnectorAccess> {
1159
+ return connectorAccess(
1160
+ await this.request(`/v1/flows/${segment(flowId)}/connector-access/${segment(providerId)}`, {
1161
+ body: JSON.stringify({ accessBindingId, expectedAccessRevision, version: 1 }),
1162
+ method: 'DELETE',
1163
+ }),
1164
+ )
1165
+ }
1166
+
1167
+ async listConnectorActions(serviceId?: string, signal?: AbortSignal, flowId?: string, locale?: string): Promise<readonly ConnectorAction[]> {
1168
+ return await this.connectorActions(
1169
+ { ...(locale == null ? {} : { locale }), ...(flowId == null ? {} : { flowId }), ...(serviceId == null ? {} : { service: serviceId }) },
1170
+ signal,
1171
+ )
1172
+ }
1173
+
1174
+ async searchConnectorActions(query: string, signal?: AbortSignal, flowId?: string, locale?: string): Promise<readonly ConnectorAction[]> {
1175
+ return await this.connectorActions({ ...(locale == null ? {} : { locale }), ...(flowId == null ? {} : { flowId }), q: query.trim() }, signal)
1176
+ }
1177
+
1178
+ async getConnectorAction(actionId: string, signal?: AbortSignal, flowId?: string, locale?: string, fresh = false): Promise<ConnectorAction> {
1179
+ const query = connectorActionQuery(actionId, flowId, locale)
1180
+ return this.connectorRequest(query.path, 'actions', signal, query.decode, fresh)
1181
+ }
1182
+
1183
+ async listAllConnectorConnections(signal?: AbortSignal, flowId?: string, fresh = false): Promise<readonly ConnectorConnection[]> {
1184
+ const query = allConnectorConnectionsQuery(flowId)
1185
+ return this.connectorRequest(query.path, 'connections', signal, query.decode, fresh)
1186
+ }
1187
+
1188
+ async listConnectorConnections(serviceId: string, signal?: AbortSignal, flowId?: string, fresh = false): Promise<readonly ConnectorConnection[]> {
1189
+ const query = connectorConnectionsQuery(serviceId, flowId)
1190
+ return this.connectorRequest(query.path, 'connections', signal, query.decode, fresh)
1191
+ }
1192
+
1193
+ async createConnectorConnectionPage(serviceId: string, flowId?: string, teamId?: string): Promise<string> {
1194
+ const parameters = new URLSearchParams()
1195
+ if (flowId != null) parameters.set('flowId', flowId)
1196
+ if (teamId != null) parameters.set('teamId', teamId)
1197
+ const source = record(
1198
+ await this.request(`/v1/connector/connections/${segment(serviceId)}/page${parameters.size == 0 ? '' : `?${parameters}`}`, {
1199
+ body: JSON.stringify({ version: 1 }),
1200
+ method: 'POST',
1201
+ }),
1202
+ )
1203
+ requiredFields(source, ['url', 'version'])
1204
+ if (source.version != 1) return invalidResponse()
1205
+ try {
1206
+ const url = new URL(string(source.url))
1207
+ if (url.protocol != 'http:' && url.protocol != 'https:') return invalidResponse()
1208
+ return url.href
1209
+ } catch {
1210
+ return invalidResponse()
1211
+ }
1212
+ }
1213
+
1214
+ async readAuthoring(flowId: string, query: AuthoringRead = {}) {
1215
+ return authoringReadResponse.parse(await this.request(`/v1/flows/${segment(flowId)}/authoring/read`, { method: 'POST', body: JSON.stringify(query) }))
1216
+ }
1217
+
1218
+ async searchAuthoring(flowId: string, query: AuthoringSearch) {
1219
+ return authoringSearchResponse.parse(await this.request(`/v1/flows/${segment(flowId)}/authoring/search`, { method: 'POST', body: JSON.stringify(query) }))
1220
+ }
1221
+
1222
+ async authoringSchema(flowId: string, query: { type?: AuthoringType; action?: string }) {
1223
+ return record(await this.request(`/v1/flows/${segment(flowId)}/authoring/schema`, { method: 'POST', body: JSON.stringify(query) }))
1224
+ }
1225
+
1226
+ async editAuthoring(flowId: string, request: AuthoringRequest) {
1227
+ return authoringEditResponse.parse(
1228
+ await this.request(`/v1/flows/${segment(flowId)}/authoring/edit`, {
1229
+ method: 'POST',
1230
+ headers: { 'idempotency-key': request.requestId },
1231
+ body: JSON.stringify(request),
1232
+ }),
1233
+ )
1234
+ }
1235
+
1236
+ async checkAuthoring(flowId: string, revisionId: string) {
1237
+ return authoringCheckResponse.parse(
1238
+ await this.request(`/v1/flows/${segment(flowId)}/authoring/check`, { method: 'POST', body: JSON.stringify({ revisionId }) }),
1239
+ )
1240
+ }
1241
+
1242
+ async changeDraft(
1243
+ flowId: string,
1244
+ expectedRevisionId: string,
1245
+ operations: readonly DraftOperation[],
1246
+ changeId = operationKey('change'),
1247
+ ): Promise<DraftChange> {
1248
+ return draftChange(
1249
+ await this.request(`/v1/flows/${segment(flowId)}/draft/changes`, {
1250
+ body: JSON.stringify({ expectedRevisionId, operations, version: 1 }),
1251
+ headers: { 'idempotency-key': changeId },
1252
+ method: 'POST',
1253
+ }),
1254
+ )
1255
+ }
1256
+
1257
+ async repairDraft(flowId: string, expectedRevisionId: string, changeId = operationKey('repair')): Promise<DraftChange> {
1258
+ return draftChange(
1259
+ await this.request(`/v1/flows/${segment(flowId)}/draft/repair`, {
1260
+ body: JSON.stringify({ expectedRevisionId, version: 1 }),
1261
+ headers: { 'idempotency-key': changeId },
1262
+ method: 'POST',
1263
+ }),
1264
+ )
1265
+ }
1266
+
1267
+ async upgradeDraft(flowId: string, expectedRevisionId: string, options: { readonly idempotencyKey?: string } = {}): Promise<DraftChange> {
1268
+ return draftChange(
1269
+ await this.request(`/v1/flows/${segment(flowId)}/draft/upgrade`, {
1270
+ body: JSON.stringify({ expectedRevisionId, version: 1 }),
1271
+ headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('upgrade') },
1272
+ method: 'POST',
1273
+ }),
1274
+ )
1275
+ }
1276
+
1277
+ async checkFlow(flowId: string, revisionId: string): Promise<FlowCheck> {
1278
+ return flowCheck(
1279
+ await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}/check`, {
1280
+ body: JSON.stringify({ engineContract: currentEngineContract, version: 1 }),
1281
+ method: 'POST',
1282
+ }),
1283
+ )
1284
+ }
1285
+
1286
+ async getLiveDetails(flowId: string, signal?: AbortSignal): Promise<LiveDetails> {
1287
+ const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }))
1288
+ if (details.flowId != flowId) return invalidResponse()
1289
+ return details
1290
+ }
1291
+
1292
+ async getLive(flowId: string, signal?: AbortSignal): Promise<Live> {
1293
+ return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }))
1294
+ }
1295
+
1296
+ async listPublications(
1297
+ flowId: string,
1298
+ options: { readonly cursor?: string; readonly includeTotal?: boolean; readonly limit?: number } = {},
1299
+ signal?: AbortSignal,
1300
+ ): Promise<PublicationPage> {
1301
+ const parameters = new URLSearchParams()
1302
+ if (options.cursor != null) parameters.set('cursor', options.cursor)
1303
+ if (options.limit != null) parameters.set('limit', String(options.limit))
1304
+ if (options.includeTotal != null) parameters.set('includeTotal', String(options.includeTotal))
1305
+ const query = parameters.size == 0 ? '' : `?${parameters}`
1306
+ return publicationPage(await this.request(`/v1/flows/${segment(flowId)}/publications${query}`, { signal }))
1307
+ }
1308
+
1309
+ async createDraftRun(flowId: string, revisionId: string, options: RunOptions): Promise<DraftRun> {
1310
+ const created = runDetails(
1311
+ await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}/runs`, {
1312
+ body: JSON.stringify({ engineContract: currentEngineContract, inputs: options.inputs ?? {}, trigger: options.trigger, version: 2 }),
1313
+ headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('run'), 'x-open-flow-client': this.channel },
1314
+ method: 'POST',
1315
+ }),
1316
+ )
1317
+ return created.source == 'draft' ? created : invalidResponse()
1318
+ }
1319
+
1320
+ async createLiveRun(publicationId: string, options: RunOptions): Promise<LiveRun> {
1321
+ const created = runDetails(
1322
+ await this.request('/v1/runs', {
1323
+ body: JSON.stringify({ inputs: options.inputs ?? {}, trigger: options.trigger, publicationId, version: 2 }),
1324
+ headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('run'), 'x-open-flow-client': this.channel },
1325
+ method: 'POST',
1326
+ }),
1327
+ )
1328
+ return created.source == 'live' ? created : invalidResponse()
1329
+ }
1330
+
1331
+ async setFlowEnabled(flowId: string, publicationId: string, enabled: boolean): Promise<Flow> {
1332
+ return flow(
1333
+ await this.request(`/v1/flows/${segment(flowId)}/enabled`, {
1334
+ method: 'PUT',
1335
+ body: JSON.stringify({ enabled, expectedPublicationId: publicationId, version: 1 }),
1336
+ }),
1337
+ )
1338
+ }
1339
+
1340
+ async publishFlow(flowId: string, revisionId: string, expectedLivePublicationId: string | null, options: PublicationOptions = {}): Promise<PublishOperation> {
1341
+ return publishOperation(
1342
+ await this.request(`/v1/flows/${segment(flowId)}/revisions/${segment(revisionId)}/publications`, {
1343
+ body: JSON.stringify({ engineContract: currentEngineContract, expectedLivePublicationId, version: 1 }),
1344
+ headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('publication') },
1345
+ method: 'POST',
1346
+ }),
1347
+ )
1348
+ }
1349
+
1350
+ async getPublishOperation(flowId: string, operationId: string, signal?: AbortSignal): Promise<PublishOperation> {
1351
+ return publishOperation(await this.request(`/v1/flows/${segment(flowId)}/publish-operations/${segment(operationId)}`, { signal }))
1352
+ }
1353
+
1354
+ async rollbackFlow(flowId: string, publicationId: string, expectedLivePublicationId: string, options: PublicationOptions = {}): Promise<Publication> {
1355
+ return publication(
1356
+ await this.request(`/v1/flows/${segment(flowId)}/publications/${segment(publicationId)}/rollback`, {
1357
+ body: JSON.stringify({ expectedLivePublicationId, version: 1 }),
1358
+ headers: { 'idempotency-key': options.idempotencyKey ?? operationKey('publication') },
1359
+ method: 'POST',
1360
+ }),
1361
+ )
1362
+ }
1363
+
1364
+ async getRun(runId: string, signal?: AbortSignal): Promise<RunDetails> {
1365
+ return runDetails(await this.request(`/v1/runs/${segment(runId)}`, { signal }))
1366
+ }
1367
+
1368
+ async listRuns(
1369
+ flowId: string,
1370
+ options: {
1371
+ readonly createdBefore?: string
1372
+ readonly createdFrom?: string
1373
+ readonly cursor?: string
1374
+ readonly limit?: number
1375
+ readonly pendingWait?: boolean
1376
+ readonly runId?: string
1377
+ readonly source?: Run['source']
1378
+ readonly status?: RunStatus
1379
+ } = {},
1380
+ ): Promise<RunPage> {
1381
+ const parameters = new URLSearchParams()
1382
+ if (options.cursor != null) parameters.set('cursor', options.cursor)
1383
+ if (options.limit != null) parameters.set('limit', String(options.limit))
1384
+ if (options.status != null) parameters.set('status', options.status)
1385
+ if (options.pendingWait != null) parameters.set('pendingWait', String(options.pendingWait))
1386
+ if (options.source != null) parameters.set('source', options.source)
1387
+ if (options.createdFrom != null) parameters.set('createdFrom', options.createdFrom)
1388
+ if (options.createdBefore != null) parameters.set('createdBefore', options.createdBefore)
1389
+ if (options.runId != null) parameters.set('runId', options.runId)
1390
+ const query = parameters.size == 0 ? '' : `?${parameters}`
1391
+ return runPage(await this.request(`/v1/flows/${segment(flowId)}/runs${query}`))
1392
+ }
1393
+
1394
+ async getRunEvents(runId: string, options: { readonly after?: number; readonly limit?: number } = {}, signal?: AbortSignal): Promise<RunEvents> {
1395
+ const parameters = new URLSearchParams()
1396
+ if (options.after != null) parameters.set('after', String(options.after))
1397
+ if (options.limit != null) parameters.set('limit', String(options.limit))
1398
+ const query = parameters.size == 0 ? '' : `?${parameters}`
1399
+ return runEvents(await this.request(`/v1/runs/${segment(runId)}/events${query}`, { signal }))
1400
+ }
1401
+
1402
+ async listRunResults(runId: string, after?: string, signal?: AbortSignal): Promise<ReturnType<typeof decodeResultList>> {
1403
+ return decodeResultList(await this.request(`/v1/runs/${segment(runId)}/results${after == null ? '' : `?after=${encodeURIComponent(after)}`}`, { signal }))
1404
+ }
1405
+
1406
+ async readRunResult(runId: string, resultId: string, options: ResultQuery = {}, signal?: AbortSignal): Promise<ReturnType<typeof decodeResultRead>> {
1407
+ const parameters = new URLSearchParams(Object.entries(options).map(([key, value]) => [key, String(value)]))
1408
+ return decodeResultRead(await this.request(`/v1/runs/${segment(runId)}/results/${segment(resultId)}?${parameters}`, { signal }))
1409
+ }
1410
+
1411
+ async downloadRunResult(runId: string, resultId: string, signal?: AbortSignal): Promise<Blob> {
1412
+ return (await this.response(`/v1/runs/${segment(runId)}/results/${segment(resultId)}/content`, { signal })).blob()
1413
+ }
1414
+
1415
+ async getRunResult(runId: string, signal?: AbortSignal): Promise<RunResult> {
1416
+ return runResult(await this.request(`/v1/runs/${segment(runId)}/result`, { signal }))
1417
+ }
1418
+
1419
+ async cancelRun(runId: string): Promise<RunCancellation> {
1420
+ return runCancellation(
1421
+ await this.request(`/v1/runs/${segment(runId)}/cancel`, {
1422
+ body: JSON.stringify({ version: 1 }),
1423
+ method: 'POST',
1424
+ }),
1425
+ )
1426
+ }
1427
+
1428
+ async resolveRunWait(
1429
+ runId: string,
1430
+ waitId: string,
1431
+ action: WaitAction,
1432
+ comment?: string | null,
1433
+ ): Promise<{
1434
+ readonly action: WaitAction | null
1435
+ readonly comment: string | null
1436
+ readonly resolutionAccepted: boolean
1437
+ readonly resolvedAt: string | null
1438
+ readonly runId: string
1439
+ readonly status: RunStatus
1440
+ readonly version: 1
1441
+ readonly waitId: string
1442
+ }> {
1443
+ return waitResolution(
1444
+ await this.request(`/v1/runs/${segment(runId)}/waits/${segment(waitId)}/resolve`, {
1445
+ body: JSON.stringify({ action, comment, version: 1 }),
1446
+ method: 'POST',
1447
+ }),
1448
+ )
1449
+ }
1450
+
1451
+ private async connectorActions(parameters: Readonly<Record<string, string>>, signal?: AbortSignal): Promise<readonly ConnectorAction[]> {
1452
+ const query = Object.entries(parameters)
1453
+ .map(([key, value]) => `${segment(key)}=${segment(value)}`)
1454
+ .join('&')
1455
+ const suffix = query == '' ? '' : `?${query}`
1456
+ return this.connectorRequest(`/v1/connector/actions${suffix}`, 'actions', signal, (value) => {
1457
+ const source = record(value)
1458
+ requiredFields(source, ['actions', 'version'])
1459
+ if (source.version != 1 || !Array.isArray(source.actions)) return invalidResponse()
1460
+ return source.actions.map(connectorAction)
1461
+ })
1462
+ }
1463
+
1464
+ protected async connectorRequest<Value>(
1465
+ path: string,
1466
+ _kind: 'providers' | 'actions' | 'connections',
1467
+ signal: AbortSignal | undefined,
1468
+ decode: (value: unknown) => Value,
1469
+ _fresh = false,
1470
+ ): Promise<Value> {
1471
+ return decode(await this.request(path, { signal }))
1472
+ }
1473
+
1474
+ protected async response(path: string, init: RequestInit, allowNotModified = false): Promise<Response> {
1475
+ const headers = new Headers(init.headers)
1476
+ if (init.body != null) headers.set('content-type', 'application/json')
1477
+ const response = await this.requestControl(path, { ...init, headers })
1478
+ if (!response.ok && !(allowNotModified && response.status == 304)) {
1479
+ let value: unknown
1480
+ try {
1481
+ value = await response.json()
1482
+ } catch {
1483
+ return invalidResponse()
1484
+ }
1485
+ const error = record(value).error
1486
+ const source = error == null ? undefined : record(error)
1487
+ throw new ApiError(
1488
+ response.status,
1489
+ typeof source?.code == 'string' ? source.code : 'request.failed',
1490
+ typeof source?.message == 'string' ? source.message : `Request failed with status ${response.status}.`,
1491
+ source?.details == null ? undefined : record(source.details),
1492
+ )
1493
+ }
1494
+ return response
1495
+ }
1496
+
1497
+ protected async request<Value = unknown>(path: string, init: RequestInit = {}): Promise<Value> {
1498
+ const response = await this.response(path, init)
1499
+ try {
1500
+ return (await response.json()) as Value
1501
+ } catch {
1502
+ return invalidResponse()
1503
+ }
1504
+ }
1505
+ }