generated from OpenFn/project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
projectSpec.yaml
138 lines (135 loc) · 3.85 KB
/
projectSpec.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: unicef-supply
# description:
# credentials:
# globals:
workflows:
SMT-Example:
name: SMT Example
jobs:
build-and-map:
name: build and map
adaptor: '@openfn/language-ocl@latest'
# credential:
# globals:
body: |
fn(state => {
const filteredData = state.data.map(x => {
return {
uid: x.id,
title: `example only ${x.title}`,
program: "food-delivery-v3",
user: x.userId
}
})
return { filteredData }
});
get-data-from-SMT:
name: get data from SMT
adaptor: '@openfn/language-http@latest'
# credential:
# globals:
body: |
// get data from the SMT
get('posts');
// drop everything else, only pluck out what we need
fn(state => {
const stuffWeWant = state.data.slice(0, 10);
return { data: stuffWeWant }
});
load-to-dhis2:
name: load to dhis2
adaptor: '@openfn/language-dhis2@latest'
# credential:
# globals:
body: |
create('dataValueSets', {
completeDate: '2014-02-03',
period: '201401',
orgUnit: "dWOAzMcK2Wt", /*Alkalia CHP*/
dataValues: state.filteredData.map(x => ({
dataElement: 'f7n9E0hX8qk',
value: x.user,
}))
});
handle-errors:
name: handle errors
adaptor: '@openfn/language-http@latest'
# credential:
# globals:
body: |
post('https://jsonplaceholder.typicode.com/posts', {
body: {
"userId": 1,
"title": "The sync to DHIS2 just failed.",
"body": "This failed!"
}
});
finalize-on-SMT:
name: finalize on SMT
adaptor: '@openfn/language-http@latest'
# credential:
# globals:
body: |
fn(state => {
state.testing = 42;
console.log('DHIS2 says', JSON.stringify(state.data.response, null, 2));
return state;
})
post('posts', {
body: {
"userId": 1,
"title": "Everything worked, here's the updated data",
"body": state.data
}
});
triggers:
cron:
type: cron
cron_expression: '15 * * * *'
enabled: false
edges:
cron->get-data-from-SMT:
source_trigger: cron
target_job: get-data-from-SMT
condition_type: always
enabled: true
get-data-from-SMT->build-and-map:
source_job: get-data-from-SMT
target_job: build-and-map
condition_type: on_job_success
enabled: true
build-and-map->load-to-dhis2:
source_job: build-and-map
target_job: load-to-dhis2
condition_type: on_job_success
enabled: true
build-and-map->handle-errors:
source_job: build-and-map
target_job: handle-errors
condition_type: on_job_failure
enabled: true
load-to-dhis2->finalize-on-SMT:
source_job: load-to-dhis2
target_job: finalize-on-SMT
condition_type: on_job_success
enabled: true
Select-from-DB:
name: Select from DB
jobs:
Get-food-hygiene-data:
name: Get food hygiene data
adaptor: '@openfn/language-postgresql@latest'
# credential:
# globals:
body: |
sql(state => `select * from food_hygiene_interview`);
triggers:
webhook:
type: webhook
enabled: false
edges:
webhook->Get-food-hygiene-data:
source_trigger: webhook
target_job: Get-food-hygiene-data
condition_type: always
enabled: true