@openfn/language-magpi 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ast.json ADDED
@@ -0,0 +1,510 @@
1
+ {
2
+ "operations": [
3
+ {
4
+ "name": "fetchSurveyData",
5
+ "params": [
6
+ "params"
7
+ ],
8
+ "docs": {
9
+ "description": "Make a POST request to fetch Magpi data and POST it somewhere else",
10
+ "tags": [
11
+ {
12
+ "title": "public",
13
+ "description": null,
14
+ "type": null
15
+ },
16
+ {
17
+ "title": "example",
18
+ "description": "fetchSurveyData({\n \"surveyId\": \"37479\",\n \"afterDate\": \"2017-09-27\",\n \"postUrl\": \"https://www.openfn.org/inbox/your-inbox-url\"\n})"
19
+ },
20
+ {
21
+ "title": "function",
22
+ "description": null,
23
+ "name": null
24
+ },
25
+ {
26
+ "title": "param",
27
+ "description": "data to make the fetch",
28
+ "type": {
29
+ "type": "NameExpression",
30
+ "name": "object"
31
+ },
32
+ "name": "params"
33
+ },
34
+ {
35
+ "title": "returns",
36
+ "description": null,
37
+ "type": {
38
+ "type": "NameExpression",
39
+ "name": "Operation"
40
+ }
41
+ }
42
+ ]
43
+ },
44
+ "valid": true
45
+ },
46
+ {
47
+ "name": "submitRecord",
48
+ "params": [
49
+ "jsonData"
50
+ ],
51
+ "docs": {
52
+ "description": "Submit a record for a form/survey which already exists in a Magpi user account",
53
+ "tags": [
54
+ {
55
+ "title": "public",
56
+ "description": null,
57
+ "type": null
58
+ },
59
+ {
60
+ "title": "example",
61
+ "description": "submitRecord(jsonData)"
62
+ },
63
+ {
64
+ "title": "function",
65
+ "description": null,
66
+ "name": null
67
+ },
68
+ {
69
+ "title": "param",
70
+ "description": "Payload data for the record",
71
+ "type": {
72
+ "type": "NameExpression",
73
+ "name": "object"
74
+ },
75
+ "name": "jsonData"
76
+ },
77
+ {
78
+ "title": "returns",
79
+ "description": null,
80
+ "type": {
81
+ "type": "NameExpression",
82
+ "name": "Operation"
83
+ }
84
+ }
85
+ ]
86
+ },
87
+ "valid": true
88
+ }
89
+ ],
90
+ "exports": [],
91
+ "common": [
92
+ {
93
+ "name": "fn",
94
+ "params": [
95
+ "func"
96
+ ],
97
+ "docs": {
98
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
99
+ "tags": [
100
+ {
101
+ "title": "public",
102
+ "description": null,
103
+ "type": null
104
+ },
105
+ {
106
+ "title": "example",
107
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
108
+ },
109
+ {
110
+ "title": "function",
111
+ "description": null,
112
+ "name": null
113
+ },
114
+ {
115
+ "title": "param",
116
+ "description": "is the function",
117
+ "type": {
118
+ "type": "NameExpression",
119
+ "name": "Function"
120
+ },
121
+ "name": "func"
122
+ },
123
+ {
124
+ "title": "returns",
125
+ "description": null,
126
+ "type": {
127
+ "type": "NameExpression",
128
+ "name": "Operation"
129
+ }
130
+ }
131
+ ]
132
+ },
133
+ "valid": true
134
+ },
135
+ {
136
+ "name": "sourceValue",
137
+ "params": [
138
+ "path"
139
+ ],
140
+ "docs": {
141
+ "description": "Picks out a single value from source data.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
142
+ "tags": [
143
+ {
144
+ "title": "public",
145
+ "description": null,
146
+ "type": null
147
+ },
148
+ {
149
+ "title": "example",
150
+ "description": "sourceValue('$.key')"
151
+ },
152
+ {
153
+ "title": "function",
154
+ "description": null,
155
+ "name": null
156
+ },
157
+ {
158
+ "title": "param",
159
+ "description": "JSONPath referencing a point in `state`.",
160
+ "type": {
161
+ "type": "NameExpression",
162
+ "name": "String"
163
+ },
164
+ "name": "path"
165
+ },
166
+ {
167
+ "title": "returns",
168
+ "description": null,
169
+ "type": {
170
+ "type": "NameExpression",
171
+ "name": "Operation"
172
+ }
173
+ }
174
+ ]
175
+ },
176
+ "valid": true
177
+ },
178
+ {
179
+ "name": "dataPath",
180
+ "params": [
181
+ "path"
182
+ ],
183
+ "docs": {
184
+ "description": "Ensures a path points at the data.",
185
+ "tags": [
186
+ {
187
+ "title": "public",
188
+ "description": null,
189
+ "type": null
190
+ },
191
+ {
192
+ "title": "example",
193
+ "description": "dataPath('key')"
194
+ },
195
+ {
196
+ "title": "function",
197
+ "description": null,
198
+ "name": null
199
+ },
200
+ {
201
+ "title": "param",
202
+ "description": "JSONPath referencing a point in `data`.",
203
+ "type": {
204
+ "type": "NameExpression",
205
+ "name": "string"
206
+ },
207
+ "name": "path"
208
+ },
209
+ {
210
+ "title": "returns",
211
+ "description": null,
212
+ "type": {
213
+ "type": "NameExpression",
214
+ "name": "string"
215
+ }
216
+ }
217
+ ]
218
+ },
219
+ "valid": true
220
+ },
221
+ {
222
+ "name": "dataValue",
223
+ "params": [
224
+ "path"
225
+ ],
226
+ "docs": {
227
+ "description": "Picks out a single value from the source data object—usually `state.data`.\nIf a JSONPath returns more than one value for the reference, the first\nitem will be returned.",
228
+ "tags": [
229
+ {
230
+ "title": "public",
231
+ "description": null,
232
+ "type": null
233
+ },
234
+ {
235
+ "title": "example",
236
+ "description": "dataValue('key')"
237
+ },
238
+ {
239
+ "title": "function",
240
+ "description": null,
241
+ "name": null
242
+ },
243
+ {
244
+ "title": "param",
245
+ "description": "JSONPath referencing a point in `data`.",
246
+ "type": {
247
+ "type": "NameExpression",
248
+ "name": "String"
249
+ },
250
+ "name": "path"
251
+ },
252
+ {
253
+ "title": "returns",
254
+ "description": null,
255
+ "type": {
256
+ "type": "NameExpression",
257
+ "name": "Operation"
258
+ }
259
+ }
260
+ ]
261
+ },
262
+ "valid": true
263
+ },
264
+ {
265
+ "name": "lastReferenceValue",
266
+ "params": [
267
+ "path"
268
+ ],
269
+ "docs": {
270
+ "description": "Picks out the last reference value from source data.",
271
+ "tags": [
272
+ {
273
+ "title": "public",
274
+ "description": null,
275
+ "type": null
276
+ },
277
+ {
278
+ "title": "example",
279
+ "description": "lastReferenceValue('key')"
280
+ },
281
+ {
282
+ "title": "function",
283
+ "description": null,
284
+ "name": null
285
+ },
286
+ {
287
+ "title": "param",
288
+ "description": "JSONPath referencing a point in `references`.",
289
+ "type": {
290
+ "type": "NameExpression",
291
+ "name": "String"
292
+ },
293
+ "name": "path"
294
+ },
295
+ {
296
+ "title": "returns",
297
+ "description": null,
298
+ "type": {
299
+ "type": "NameExpression",
300
+ "name": "Operation"
301
+ }
302
+ }
303
+ ]
304
+ },
305
+ "valid": true
306
+ },
307
+ {
308
+ "name": "each",
309
+ "params": [
310
+ "dataSource",
311
+ "operation"
312
+ ],
313
+ "docs": {
314
+ "description": "Scopes an array of data based on a JSONPath.\nUseful when the source data has `n` items you would like to map to\nan operation.\nThe operation will receive a slice of the data based of each item\nof the JSONPath provided.\n\nIt also ensures the results of an operation make their way back into\nthe state's references.",
315
+ "tags": [
316
+ {
317
+ "title": "public",
318
+ "description": null,
319
+ "type": null
320
+ },
321
+ {
322
+ "title": "example",
323
+ "description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
324
+ },
325
+ {
326
+ "title": "function",
327
+ "description": null,
328
+ "name": null
329
+ },
330
+ {
331
+ "title": "param",
332
+ "description": "JSONPath referencing a point in `state`.",
333
+ "type": {
334
+ "type": "NameExpression",
335
+ "name": "DataSource"
336
+ },
337
+ "name": "dataSource"
338
+ },
339
+ {
340
+ "title": "param",
341
+ "description": "The operation needed to be repeated.",
342
+ "type": {
343
+ "type": "NameExpression",
344
+ "name": "Operation"
345
+ },
346
+ "name": "operation"
347
+ },
348
+ {
349
+ "title": "returns",
350
+ "description": null,
351
+ "type": {
352
+ "type": "NameExpression",
353
+ "name": "Operation"
354
+ }
355
+ }
356
+ ]
357
+ },
358
+ "valid": true
359
+ },
360
+ {
361
+ "name": "field",
362
+ "params": [
363
+ "key",
364
+ "value"
365
+ ],
366
+ "docs": {
367
+ "description": "Returns a key, value pair in an array.",
368
+ "tags": [
369
+ {
370
+ "title": "public",
371
+ "description": null,
372
+ "type": null
373
+ },
374
+ {
375
+ "title": "example",
376
+ "description": "field('destination_field_name__c', 'value')"
377
+ },
378
+ {
379
+ "title": "function",
380
+ "description": null,
381
+ "name": null
382
+ },
383
+ {
384
+ "title": "param",
385
+ "description": "Name of the field",
386
+ "type": {
387
+ "type": "NameExpression",
388
+ "name": "string"
389
+ },
390
+ "name": "key"
391
+ },
392
+ {
393
+ "title": "param",
394
+ "description": "The value itself or a sourceable operation.",
395
+ "type": {
396
+ "type": "NameExpression",
397
+ "name": "Value"
398
+ },
399
+ "name": "value"
400
+ },
401
+ {
402
+ "title": "returns",
403
+ "description": null,
404
+ "type": {
405
+ "type": "NameExpression",
406
+ "name": "Field"
407
+ }
408
+ }
409
+ ]
410
+ },
411
+ "valid": true
412
+ },
413
+ {
414
+ "name": "fields",
415
+ "params": [
416
+ "fields"
417
+ ],
418
+ "docs": {
419
+ "description": "Zips key value pairs into an object.",
420
+ "tags": [
421
+ {
422
+ "title": "public",
423
+ "description": null,
424
+ "type": null
425
+ },
426
+ {
427
+ "title": "example",
428
+ "description": "fields(list_of_fields)"
429
+ },
430
+ {
431
+ "title": "function",
432
+ "description": null,
433
+ "name": null
434
+ },
435
+ {
436
+ "title": "param",
437
+ "description": "a list of fields",
438
+ "type": {
439
+ "type": "NameExpression",
440
+ "name": "Fields"
441
+ },
442
+ "name": "fields"
443
+ },
444
+ {
445
+ "title": "returns",
446
+ "description": null,
447
+ "type": {
448
+ "type": "NameExpression",
449
+ "name": "Object"
450
+ }
451
+ }
452
+ ]
453
+ },
454
+ "valid": true
455
+ },
456
+ {
457
+ "name": "merge",
458
+ "params": [
459
+ "dataSource",
460
+ "fields"
461
+ ],
462
+ "docs": {
463
+ "description": "Merges fields into each item in an array.",
464
+ "tags": [
465
+ {
466
+ "title": "public",
467
+ "description": null,
468
+ "type": null
469
+ },
470
+ {
471
+ "title": "example",
472
+ "description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
473
+ },
474
+ {
475
+ "title": "function",
476
+ "description": null,
477
+ "name": null
478
+ },
479
+ {
480
+ "title": "param",
481
+ "description": null,
482
+ "type": {
483
+ "type": "NameExpression",
484
+ "name": "DataSource"
485
+ },
486
+ "name": "dataSource"
487
+ },
488
+ {
489
+ "title": "param",
490
+ "description": "Group of fields to merge in.",
491
+ "type": {
492
+ "type": "NameExpression",
493
+ "name": "Object"
494
+ },
495
+ "name": "fields"
496
+ },
497
+ {
498
+ "title": "returns",
499
+ "description": null,
500
+ "type": {
501
+ "type": "NameExpression",
502
+ "name": "DataSource"
503
+ }
504
+ }
505
+ ]
506
+ },
507
+ "valid": true
508
+ }
509
+ ]
510
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "properties": {
4
+ "username": {
5
+ "title": "username",
6
+ "type": "string",
7
+ "description": "Magpi username",
8
+ "minLength": 1
9
+ },
10
+ "accessToken": {
11
+ "title": "Access Token",
12
+ "type": "string",
13
+ "description": "Magpi access token",
14
+ "writeOnly": true,
15
+ "minLength": 1
16
+ }
17
+ },
18
+ "type": "object",
19
+ "additionalProperties": true,
20
+ "required": [
21
+ "username",
22
+ "accessToken"
23
+ ]
24
+ }