Skip to content

Commit c9586cd

Browse files
committed
tweaks
1 parent bf453e6 commit c9586cd

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

docs/build/workflows-api.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ A Workflow has the following structure:
5151
"project_id": "79efba60-072a-4d4f-8d6c-22dfd3852176",
5252
"edges": [
5353
{
54+
"id": "759fe475-ed23-4914-8a6d-155968bc0aa1"
5455
"condition_type": "always",
5556
"enabled": true,
5657
"source_job_id": null,
@@ -83,9 +84,11 @@ When creating a new Workflow, the server will generate UUIDs for the workflow
8384
and all steps and edges. You can use any id string you like in the creation of
8485
new nodes and edges - so long as id usage is consistent.
8586

86-
When matching a PUT or PATCH request, new steps and edges must be given UUIDs.
87+
When matching a PUT or PATCH request, new steps and edges MUST be assigned
88+
UUIDs. If using the `http` adaptor, you can use `util.uuid()` for this (see the
89+
example below).
8790

88-
You MUST ensure that all steps and triggers referenced by an edge are defined
91+
You MUST ensure that any steps and triggers referenced by an edge are defined
8992
within the same workflow.
9093

9194
## HTTP Adaptor Examples
@@ -96,7 +99,7 @@ Access Token (PAT) and `baseUrl` set to your OpenFn instance (ie,
9699

97100
Create new Workflow:
98101

99-
```
102+
```js
100103
post(`/api/projects/${$.projectId}/workflows`, {
101104
body: {
102105
name: 'My Workflow',
@@ -128,18 +131,20 @@ post(`/api/projects/${$.projectId}/workflows`, {
128131
```
129132

130133
The resulting workflow with updated UUIDs and metadata will be written to
131-
state.data.workflow
134+
`state.data.workflow`.
132135

133-
Add a new step to an existing Workflow:
136+
Add a new step and edge to an existing Workflow:
134137

135-
```
136-
fn((state) => {
137-
const jobId = util.uuid()
138+
```js
139+
fn(state => {
140+
const jobId = util.uuid();
138141
state.diff = {
139142
edges: [
140143
{
144+
id: util.uuid(),
141145
source_job_id: 'c79ce46c-ab0f-4f5b-bf2d-fed52aef2a41',
142146
target_job_id: jobId,
147+
condition_type: 'always',
143148
},
144149
],
145150
jobs: [
@@ -149,12 +154,13 @@ fn((state) => {
149154
adaptor: '@openfn/language-common@latest',
150155
},
151156
],
152-
}
157+
};
153158
return state;
154-
})
159+
});
155160
patch(`/api/projects/${$.projectId}/workflows/${$.workflowId}`, {
156161
body: $.diff,
157162
headers: { 'content-type': 'application/json' },
158163
});
159-
160164
```
165+
166+
The resulting workflow will be written to `state.data.workflow`.

0 commit comments

Comments
 (0)