|
| 1 | +package obelisk:webhook@5.1.0; |
| 2 | + |
| 3 | +@since(version = 5.0.0) |
| 4 | +interface webhook-support { |
| 5 | + use obelisk:types/time@4.2.0.{schedule-at, datetime}; |
| 6 | + use obelisk:types/execution@4.2.0.{execution-id, function, submit-config, schedule-json-error}; |
| 7 | + use obelisk:types/backtrace@4.2.0.{wasm-backtrace}; |
| 8 | + |
| 9 | + /// Error variants that may occur when calling `get-status`. |
| 10 | + @since(version = 5.0.0) |
| 11 | + variant get-status-error { |
| 12 | + /// Cannot parse the execution ID. |
| 13 | + execution-id-parsing-error(string), |
| 14 | + /// The execution was not found. |
| 15 | + not-found, |
| 16 | + } |
| 17 | + |
| 18 | + /// Error variants that may occur when calling `get`. |
| 19 | + @since(version = 5.0.0) |
| 20 | + variant get-error { |
| 21 | + /// Cannot parse the execution ID. |
| 22 | + execution-id-parsing-error(string), |
| 23 | + /// The execution was not found. |
| 24 | + not-found, |
| 25 | + } |
| 26 | + |
| 27 | + /// Error variants that may occur when calling `try-get`. |
| 28 | + @since(version = 5.0.0) |
| 29 | + variant try-get-error { |
| 30 | + /// Cannot parse the execution ID. |
| 31 | + execution-id-parsing-error(string), |
| 32 | + /// The execution was not found. |
| 33 | + not-found, |
| 34 | + /// The execution has not finished yet. |
| 35 | + not-finished-yet, |
| 36 | + } |
| 37 | + |
| 38 | + /// The status of an execution. |
| 39 | + @since(version = 5.0.0) |
| 40 | + variant execution-status { |
| 41 | + /// Execution is scheduled to run at a specific time. |
| 42 | + pending-at(datetime), |
| 43 | + /// Execution is currently being processed. |
| 44 | + locked, |
| 45 | + /// Execution is currently paused. |
| 46 | + paused, |
| 47 | + /// Execution is waiting for child executions to complete (workflows only). |
| 48 | + blocked-by-join-set, |
| 49 | + /// Execution has finished. |
| 50 | + finished(execution-status-finished), |
| 51 | + } |
| 52 | + |
| 53 | + /// The finished status of an execution. |
| 54 | + @since(version = 5.0.0) |
| 55 | + variant execution-status-finished { |
| 56 | + /// Execution has finished with a successful result. |
| 57 | + ok, |
| 58 | + /// Execution has finished with an error result (user-level error). |
| 59 | + err, |
| 60 | + /// Execution has terminated due to an execution failure (system-level error). |
| 61 | + execution-failure, |
| 62 | + } |
| 63 | + |
| 64 | + /// Generate a new top-level execution ID. |
| 65 | + @since(version = 5.0.0) |
| 66 | + execution-id-generate: func() -> execution-id; |
| 67 | + |
| 68 | + /// Get the execution ID of the current webhook handler invocation. |
| 69 | + /// Returns the ID assigned to this webhook execution by the engine. |
| 70 | + @since(version = 5.1.0) |
| 71 | + current-execution-id: func() -> execution-id; |
| 72 | + /// Call a function and wait for the result. |
| 73 | + /// Creates a child execution, waits for it to complete, and returns the result. |
| 74 | + /// Parameters are serialized as a JSON array. |
| 75 | + /// Returns Ok(Some(json)) for successful result with value, |
| 76 | + /// Ok(None) for successful result with no value, |
| 77 | + /// Err(Some(json)) for error result with value, |
| 78 | + /// Err(None) for error result with no value. |
| 79 | + @since(version = 5.0.0) |
| 80 | + call-json: func(function: function, params: string, config: option<submit-config>, backtrace: option<wasm-backtrace>) -> result<result<option<string>, option<string>>, schedule-json-error>; |
| 81 | + |
| 82 | + /// Schedule a new top-level execution with its parameters serialized as JSON array. |
| 83 | + /// Use the execution ID returned by `execution-id-generate`. |
| 84 | + @since(version = 5.0.0) |
| 85 | + schedule-json: func(execution-id: execution-id, schedule-at: schedule-at, function: function, params: string, config: option<submit-config>, backtrace: option<wasm-backtrace>) -> result<_, schedule-json-error>; |
| 86 | + |
| 87 | + /// Get the current status of an execution. |
| 88 | + @since(version = 5.0.0) |
| 89 | + get-status: func(execution-id: execution-id, backtrace: option<wasm-backtrace>) -> result<execution-status, get-status-error>; |
| 90 | + |
| 91 | + /// Get the result of an execution, blocking until it finishes. |
| 92 | + /// Returns Ok(Some(json)) for successful result with value, |
| 93 | + /// Ok(None) for successful result with no value, |
| 94 | + /// Err(Some(json)) for error result with value, |
| 95 | + /// Err(None) for error result with no value. |
| 96 | + /// Outer result indicates lookup success/failure. |
| 97 | + @since(version = 5.0.0) |
| 98 | + get: func(execution-id: execution-id, backtrace: option<wasm-backtrace>) -> result<result<option<string>, option<string>>, get-error>; |
| 99 | + |
| 100 | + /// Try to get the result of an execution without blocking. |
| 101 | + /// Returns immediately if the execution has finished, or `not-finished-yet` error otherwise. |
| 102 | + /// Returns Ok(Some(json)) for successful result with value, |
| 103 | + /// Ok(None) for successful result with no value, |
| 104 | + /// Err(Some(json)) for error result with value, |
| 105 | + /// Err(None) for error result with no value. |
| 106 | + /// Outer result indicates lookup success/failure. |
| 107 | + @since(version = 5.0.0) |
| 108 | + try-get: func(execution-id: execution-id, backtrace: option<wasm-backtrace>) -> result<result<option<string>, option<string>>, try-get-error>; |
| 109 | +} |
0 commit comments