@openfn/language-mpesa 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/LICENSE +674 -0
- package/LICENSE.LESSER +165 -0
- package/README.md +27 -0
- package/ast.json +894 -0
- package/configuration-schema.json +39 -0
- package/dist/index.cjs +237 -0
- package/dist/index.js +211 -0
- package/package.json +48 -0
- package/types/Adaptor.d.ts +241 -0
- package/types/Utils.d.ts +4 -0
- package/types/index.d.ts +3 -0
package/ast.json
ADDED
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
{
|
|
2
|
+
"operations": [
|
|
3
|
+
{
|
|
4
|
+
"name": "stkPush",
|
|
5
|
+
"params": [
|
|
6
|
+
"data",
|
|
7
|
+
"options"
|
|
8
|
+
],
|
|
9
|
+
"docs": {
|
|
10
|
+
"description": "Initiate a STK pin prompt to a Safaricom mobile number.",
|
|
11
|
+
"tags": [
|
|
12
|
+
{
|
|
13
|
+
"title": "function",
|
|
14
|
+
"description": null,
|
|
15
|
+
"name": null
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"title": "public",
|
|
19
|
+
"description": null,
|
|
20
|
+
"type": null
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"title": "param",
|
|
24
|
+
"description": "The object that will be attached to the POST request body",
|
|
25
|
+
"type": {
|
|
26
|
+
"type": "NameExpression",
|
|
27
|
+
"name": "STKPushObject"
|
|
28
|
+
},
|
|
29
|
+
"name": "data"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"title": "param",
|
|
33
|
+
"description": "Optional request object. Includes headers, error mappings and query params",
|
|
34
|
+
"type": {
|
|
35
|
+
"type": "NameExpression",
|
|
36
|
+
"name": "RequestOptions"
|
|
37
|
+
},
|
|
38
|
+
"name": "options"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"title": "example",
|
|
42
|
+
"description": "stkPush({\n\"Amount\": 1,\n\"PartyA\": 254708374149,\n\"PartyB\": 174379,\n\"PhoneNumber\": 254708374149,\n\"CallBackURL\": \"https://mydomain.com/path\",\n\"AccountReference\": \"CompanyXLTD\",\n\"TransactionDesc\": \"Payment of X\"\n});",
|
|
43
|
+
"caption": "Initiate STK Push"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"title": "returns",
|
|
47
|
+
"description": null,
|
|
48
|
+
"type": {
|
|
49
|
+
"type": "NameExpression",
|
|
50
|
+
"name": "Operation"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"title": "state",
|
|
55
|
+
"description": "{HttpState}"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"valid": true
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "checkTransactionStatus",
|
|
63
|
+
"params": [
|
|
64
|
+
"data",
|
|
65
|
+
"options"
|
|
66
|
+
],
|
|
67
|
+
"docs": {
|
|
68
|
+
"description": "Check the status of the transaction",
|
|
69
|
+
"tags": [
|
|
70
|
+
{
|
|
71
|
+
"title": "function",
|
|
72
|
+
"description": null,
|
|
73
|
+
"name": null
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"title": "public",
|
|
77
|
+
"description": null,
|
|
78
|
+
"type": null
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"title": "param",
|
|
82
|
+
"description": "The object that will be attached to the POST request body",
|
|
83
|
+
"type": {
|
|
84
|
+
"type": "NameExpression",
|
|
85
|
+
"name": "TransactionStatusObject"
|
|
86
|
+
},
|
|
87
|
+
"name": "data"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"title": "param",
|
|
91
|
+
"description": "Optional request object. Includes headers, error mappings and query params",
|
|
92
|
+
"type": {
|
|
93
|
+
"type": "NameExpression",
|
|
94
|
+
"name": "RequestOptions"
|
|
95
|
+
},
|
|
96
|
+
"name": "options"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"title": "example",
|
|
100
|
+
"description": "checkTransactionStatus({\n\"Initiator\": \"testapi\",\n\"SecurityCredential\": \"ctHDk+dN14A22B5GyQQvISSTY3K1tVnCTuQGoG7PsTCadzTkl5wz44Rhpkb0BZDvfRA==\",\n\"TransactionID\": \"OEI2AK4Q16\",\n\"PartyA\": 600998,\n\"IdentifierType\": 4,\n\"ResultURL\": \"https://mydomain.com/TransactionStatus/result/\",\n\"QueueTimeOutURL\": \"https://mydomain.com/TransactionStatus/queue/\",\n\"Remarks\": \"fdfdfdfdf\",\n\"Occassion\": \"null\",\n});",
|
|
101
|
+
"caption": "Check status of a transaction"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"title": "returns",
|
|
105
|
+
"description": null,
|
|
106
|
+
"type": {
|
|
107
|
+
"type": "NameExpression",
|
|
108
|
+
"name": "Operation"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"title": "state",
|
|
113
|
+
"description": "{HttpState}"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"valid": true
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "registerUrl",
|
|
121
|
+
"params": [
|
|
122
|
+
"data",
|
|
123
|
+
"options"
|
|
124
|
+
],
|
|
125
|
+
"docs": {
|
|
126
|
+
"description": "Register a URL that allows receiving payment notifications to your paybill.",
|
|
127
|
+
"tags": [
|
|
128
|
+
{
|
|
129
|
+
"title": "public",
|
|
130
|
+
"description": null,
|
|
131
|
+
"type": null
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"title": "function",
|
|
135
|
+
"description": null,
|
|
136
|
+
"name": null
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"title": "param",
|
|
140
|
+
"description": "The object that will be attached to the POST request body",
|
|
141
|
+
"type": {
|
|
142
|
+
"type": "NameExpression",
|
|
143
|
+
"name": "RegisterUrlObject"
|
|
144
|
+
},
|
|
145
|
+
"name": "data"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"title": "param",
|
|
149
|
+
"description": "Optional request object. Includes headers, error mappings and query params",
|
|
150
|
+
"type": {
|
|
151
|
+
"type": "NameExpression",
|
|
152
|
+
"name": "RequestOptions"
|
|
153
|
+
},
|
|
154
|
+
"name": "options"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"title": "example",
|
|
158
|
+
"description": "registerUrl({\n\"ShortCode\": 600426,\n\"ResponseType\": \"Completed\",\n\"ConfirmationURL\": \"https://mydomain.com/confirmation\",\n\"ValidationURL\": \"https://mydomain.com/validation\"\n});",
|
|
159
|
+
"caption": "Register a URL to receive payment notifications"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"title": "returns",
|
|
163
|
+
"description": null,
|
|
164
|
+
"type": {
|
|
165
|
+
"type": "NameExpression",
|
|
166
|
+
"name": "Operation"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"title": "state",
|
|
171
|
+
"description": "{HttpState}"
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
"valid": true
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "remitTax",
|
|
179
|
+
"params": [
|
|
180
|
+
"data",
|
|
181
|
+
"options"
|
|
182
|
+
],
|
|
183
|
+
"docs": {
|
|
184
|
+
"description": "Remit tax to the Kenya Revenue Authority (KRA).",
|
|
185
|
+
"tags": [
|
|
186
|
+
{
|
|
187
|
+
"title": "public",
|
|
188
|
+
"description": null,
|
|
189
|
+
"type": null
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"title": "function",
|
|
193
|
+
"description": null,
|
|
194
|
+
"name": null
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"title": "param",
|
|
198
|
+
"description": "The object that will be attached to the POST request body",
|
|
199
|
+
"type": {
|
|
200
|
+
"type": "NameExpression",
|
|
201
|
+
"name": "RemitTaxObject"
|
|
202
|
+
},
|
|
203
|
+
"name": "data"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"title": "param",
|
|
207
|
+
"description": "Optional request object. Includes headers, error mappings and query params",
|
|
208
|
+
"type": {
|
|
209
|
+
"type": "NameExpression",
|
|
210
|
+
"name": "RequestOptions"
|
|
211
|
+
},
|
|
212
|
+
"name": "options"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"title": "example",
|
|
216
|
+
"description": "remitTax({\n\"Initiator\": \"testapi\",\n\"SecurityCredential\": \"Uq1qluCjSYfMF3XEvlpfuatnWwWerwq42fB+mMd8nsKdAVO04DGHhG/s3xO3g7POki9B8i7cSoEkBux4bQrlDLDWJhaTrt1TdbE+ZQ==\",\n\"Amount\": 1,\n\"PartyA\": 600995,\n\"AccountReference\": 353353,\n\"Remarks\": \"ok\",\n\"QueueTimeOutURL\": \"https://mydomain.com/b2b/queue/\",\n\"ResultURL\": \"https://mydomain.com/b2b/result/\"\n})",
|
|
217
|
+
"caption": "Pay tax to KRA"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"title": "returns",
|
|
221
|
+
"description": null,
|
|
222
|
+
"type": {
|
|
223
|
+
"type": "NameExpression",
|
|
224
|
+
"name": "Operation"
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"title": "state",
|
|
229
|
+
"description": "{HttpState}"
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
"valid": true
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"name": "buyGoods",
|
|
237
|
+
"params": [
|
|
238
|
+
"data",
|
|
239
|
+
"options"
|
|
240
|
+
],
|
|
241
|
+
"docs": {
|
|
242
|
+
"description": "Pay for goods and services directly from your business account to a till number, merchant store number or Merchant HO",
|
|
243
|
+
"tags": [
|
|
244
|
+
{
|
|
245
|
+
"title": "function",
|
|
246
|
+
"description": null,
|
|
247
|
+
"name": null
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"title": "public",
|
|
251
|
+
"description": null,
|
|
252
|
+
"type": null
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"title": "param",
|
|
256
|
+
"description": "The object that will be attached to the POST request body",
|
|
257
|
+
"type": {
|
|
258
|
+
"type": "NameExpression",
|
|
259
|
+
"name": "BuyGoodsObject"
|
|
260
|
+
},
|
|
261
|
+
"name": "data"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"title": "param",
|
|
265
|
+
"description": "Optional request object. Includes headers, error mappings and query params",
|
|
266
|
+
"type": {
|
|
267
|
+
"type": "NameExpression",
|
|
268
|
+
"name": "RequestOptions"
|
|
269
|
+
},
|
|
270
|
+
"name": "options"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"title": "example",
|
|
274
|
+
"description": "buyGoods({\n\"Initiator\": \"testapi\",\n\"SecurityCredential\": \"sbMXpuhMX5LzieNiDrx9TgscfaBxxvie0WlBDdGli4MWu4s5gbhYVlBy+T89xHQdoYwcG202KNp403ln2dLFnytPqw==\",\n\"Amount\": 1,\n\"PartyA\": 600999,\n\"PartyB\": 600000,\n\"AccountReference\": 353353,\n\"Requester\": 254708374149,\n\"Remarks\": \"ok\",\n\"QueueTimeOutURL\": \"https://mydomain.com/b2b/queue/\",\n\"ResultURL\": \"https://mydomain.com/b2b/result/\"\n});",
|
|
275
|
+
"caption": "Pay for goods"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"title": "returns",
|
|
279
|
+
"description": null,
|
|
280
|
+
"type": {
|
|
281
|
+
"type": "NameExpression",
|
|
282
|
+
"name": "Operation"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"title": "state",
|
|
287
|
+
"description": "{HttpState}"
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
"valid": true
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"name": "request",
|
|
295
|
+
"params": [
|
|
296
|
+
"method",
|
|
297
|
+
"path",
|
|
298
|
+
"body",
|
|
299
|
+
"options"
|
|
300
|
+
],
|
|
301
|
+
"docs": {
|
|
302
|
+
"description": "Make a general HTTP request",
|
|
303
|
+
"tags": [
|
|
304
|
+
{
|
|
305
|
+
"title": "example",
|
|
306
|
+
"description": "request(\"POST\", \"/mpesa/c2b/v1/registerurl\", \n {\n \"ShortCode\": 600426,\n \"ResponseType\": \"Completed\",\n \"ConfirmationURL\": \"https://mydomain.com/confirmation\",\n \"ValidationURL\": \"https://mydomain.com/validation\"\n });",
|
|
307
|
+
"caption": "Register a URL to receive payment notifications"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"title": "function",
|
|
311
|
+
"description": null,
|
|
312
|
+
"name": null
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"title": "public",
|
|
316
|
+
"description": null,
|
|
317
|
+
"type": null
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"title": "param",
|
|
321
|
+
"description": "HTTP method to use",
|
|
322
|
+
"type": {
|
|
323
|
+
"type": "NameExpression",
|
|
324
|
+
"name": "string"
|
|
325
|
+
},
|
|
326
|
+
"name": "method"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"title": "param",
|
|
330
|
+
"description": "Path to resource.",
|
|
331
|
+
"type": {
|
|
332
|
+
"type": "NameExpression",
|
|
333
|
+
"name": "string"
|
|
334
|
+
},
|
|
335
|
+
"name": "path"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"title": "param",
|
|
339
|
+
"description": "Object which will be attached to the POST body",
|
|
340
|
+
"type": {
|
|
341
|
+
"type": "NameExpression",
|
|
342
|
+
"name": "object"
|
|
343
|
+
},
|
|
344
|
+
"name": "body"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"title": "param",
|
|
348
|
+
"description": "Optional request options",
|
|
349
|
+
"type": {
|
|
350
|
+
"type": "NameExpression",
|
|
351
|
+
"name": "RequestOptions"
|
|
352
|
+
},
|
|
353
|
+
"name": "options"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"title": "returns",
|
|
357
|
+
"description": null,
|
|
358
|
+
"type": {
|
|
359
|
+
"type": "NameExpression",
|
|
360
|
+
"name": "Operation"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"title": "state",
|
|
365
|
+
"description": "{HttpState}"
|
|
366
|
+
}
|
|
367
|
+
]
|
|
368
|
+
},
|
|
369
|
+
"valid": true
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
"exports": [],
|
|
373
|
+
"common": [
|
|
374
|
+
{
|
|
375
|
+
"name": "fn",
|
|
376
|
+
"params": [
|
|
377
|
+
"func"
|
|
378
|
+
],
|
|
379
|
+
"docs": {
|
|
380
|
+
"description": "Creates a custom step (or operation) for more flexible job writing.",
|
|
381
|
+
"tags": [
|
|
382
|
+
{
|
|
383
|
+
"title": "public",
|
|
384
|
+
"description": null,
|
|
385
|
+
"type": null
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"title": "function",
|
|
389
|
+
"description": null,
|
|
390
|
+
"name": null
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"title": "example",
|
|
394
|
+
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"title": "param",
|
|
398
|
+
"description": "is the function",
|
|
399
|
+
"type": {
|
|
400
|
+
"type": "NameExpression",
|
|
401
|
+
"name": "Function"
|
|
402
|
+
},
|
|
403
|
+
"name": "func"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"title": "returns",
|
|
407
|
+
"description": null,
|
|
408
|
+
"type": {
|
|
409
|
+
"type": "NameExpression",
|
|
410
|
+
"name": "Operation"
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
},
|
|
415
|
+
"valid": true
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"name": "sourceValue",
|
|
419
|
+
"params": [
|
|
420
|
+
"path"
|
|
421
|
+
],
|
|
422
|
+
"docs": {
|
|
423
|
+
"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.",
|
|
424
|
+
"tags": [
|
|
425
|
+
{
|
|
426
|
+
"title": "public",
|
|
427
|
+
"description": null,
|
|
428
|
+
"type": null
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
"title": "function",
|
|
432
|
+
"description": null,
|
|
433
|
+
"name": null
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
"title": "example",
|
|
437
|
+
"description": "sourceValue('$.key')"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"title": "param",
|
|
441
|
+
"description": "JSONPath referencing a point in `state`.",
|
|
442
|
+
"type": {
|
|
443
|
+
"type": "NameExpression",
|
|
444
|
+
"name": "String"
|
|
445
|
+
},
|
|
446
|
+
"name": "path"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"title": "returns",
|
|
450
|
+
"description": null,
|
|
451
|
+
"type": {
|
|
452
|
+
"type": "NameExpression",
|
|
453
|
+
"name": "Operation"
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
]
|
|
457
|
+
},
|
|
458
|
+
"valid": true
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"name": "dataPath",
|
|
462
|
+
"params": [
|
|
463
|
+
"path"
|
|
464
|
+
],
|
|
465
|
+
"docs": {
|
|
466
|
+
"description": "Ensures a path points at the data.",
|
|
467
|
+
"tags": [
|
|
468
|
+
{
|
|
469
|
+
"title": "public",
|
|
470
|
+
"description": null,
|
|
471
|
+
"type": null
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"title": "function",
|
|
475
|
+
"description": null,
|
|
476
|
+
"name": null
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"title": "example",
|
|
480
|
+
"description": "dataPath('key')"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"title": "param",
|
|
484
|
+
"description": "JSONPath referencing a point in `data`.",
|
|
485
|
+
"type": {
|
|
486
|
+
"type": "NameExpression",
|
|
487
|
+
"name": "string"
|
|
488
|
+
},
|
|
489
|
+
"name": "path"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"title": "returns",
|
|
493
|
+
"description": null,
|
|
494
|
+
"type": {
|
|
495
|
+
"type": "NameExpression",
|
|
496
|
+
"name": "string"
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
"valid": true
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"name": "dataValue",
|
|
505
|
+
"params": [
|
|
506
|
+
"path"
|
|
507
|
+
],
|
|
508
|
+
"docs": {
|
|
509
|
+
"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.",
|
|
510
|
+
"tags": [
|
|
511
|
+
{
|
|
512
|
+
"title": "public",
|
|
513
|
+
"description": null,
|
|
514
|
+
"type": null
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
"title": "function",
|
|
518
|
+
"description": null,
|
|
519
|
+
"name": null
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
"title": "example",
|
|
523
|
+
"description": "dataValue('key')"
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"title": "param",
|
|
527
|
+
"description": "JSONPath referencing a point in `data`.",
|
|
528
|
+
"type": {
|
|
529
|
+
"type": "NameExpression",
|
|
530
|
+
"name": "String"
|
|
531
|
+
},
|
|
532
|
+
"name": "path"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
"title": "returns",
|
|
536
|
+
"description": null,
|
|
537
|
+
"type": {
|
|
538
|
+
"type": "NameExpression",
|
|
539
|
+
"name": "Operation"
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
]
|
|
543
|
+
},
|
|
544
|
+
"valid": true
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
"name": "lastReferenceValue",
|
|
548
|
+
"params": [
|
|
549
|
+
"path"
|
|
550
|
+
],
|
|
551
|
+
"docs": {
|
|
552
|
+
"description": "Picks out the last reference value from source data.",
|
|
553
|
+
"tags": [
|
|
554
|
+
{
|
|
555
|
+
"title": "public",
|
|
556
|
+
"description": null,
|
|
557
|
+
"type": null
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
"title": "function",
|
|
561
|
+
"description": null,
|
|
562
|
+
"name": null
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
"title": "example",
|
|
566
|
+
"description": "lastReferenceValue('key')"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
"title": "param",
|
|
570
|
+
"description": "JSONPath referencing a point in `references`.",
|
|
571
|
+
"type": {
|
|
572
|
+
"type": "NameExpression",
|
|
573
|
+
"name": "String"
|
|
574
|
+
},
|
|
575
|
+
"name": "path"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"title": "returns",
|
|
579
|
+
"description": null,
|
|
580
|
+
"type": {
|
|
581
|
+
"type": "NameExpression",
|
|
582
|
+
"name": "Operation"
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
]
|
|
586
|
+
},
|
|
587
|
+
"valid": true
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"name": "each",
|
|
591
|
+
"params": [
|
|
592
|
+
"dataSource",
|
|
593
|
+
"operation"
|
|
594
|
+
],
|
|
595
|
+
"docs": {
|
|
596
|
+
"description": "Iterates over an array of items and invokes an operation upon each one, where the state\nobject is _scoped_ so that state.data is the item under iteration.\nThe rest of the state object is untouched and can be referenced as usual.\nYou can pass an array directly, or use lazy state or a JSONPath string to\nreference a slice of state.",
|
|
597
|
+
"tags": [
|
|
598
|
+
{
|
|
599
|
+
"title": "public",
|
|
600
|
+
"description": null,
|
|
601
|
+
"type": null
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
"title": "function",
|
|
605
|
+
"description": null,
|
|
606
|
+
"name": null
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"title": "example",
|
|
610
|
+
"description": "each(\n $.data,\n // Inside the callback operation, `$.data` is scoped to the item under iteration\n insert(\"patient\", {\n patient_name: $.data.properties.case_name,\n patient_id: $.data.case_id,\n })\n);",
|
|
611
|
+
"caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
"title": "example",
|
|
615
|
+
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
|
|
616
|
+
"caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
"title": "example",
|
|
620
|
+
"description": "each(\n \"$.data[*]\",\n insert(\"patient\", (state) => ({\n patient_name: state.data.properties.case_name,\n patient_id: state.data.case_id,\n }))\n);",
|
|
621
|
+
"caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
"title": "param",
|
|
625
|
+
"description": "JSONPath referencing a point in `state`.",
|
|
626
|
+
"type": {
|
|
627
|
+
"type": "NameExpression",
|
|
628
|
+
"name": "DataSource"
|
|
629
|
+
},
|
|
630
|
+
"name": "dataSource"
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"title": "param",
|
|
634
|
+
"description": "The operation needed to be repeated.",
|
|
635
|
+
"type": {
|
|
636
|
+
"type": "NameExpression",
|
|
637
|
+
"name": "Operation"
|
|
638
|
+
},
|
|
639
|
+
"name": "operation"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
"title": "returns",
|
|
643
|
+
"description": null,
|
|
644
|
+
"type": {
|
|
645
|
+
"type": "NameExpression",
|
|
646
|
+
"name": "Operation"
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
]
|
|
650
|
+
},
|
|
651
|
+
"valid": true
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"name": "field",
|
|
655
|
+
"params": [
|
|
656
|
+
"key",
|
|
657
|
+
"value"
|
|
658
|
+
],
|
|
659
|
+
"docs": {
|
|
660
|
+
"description": "Returns a key, value pair in an array.",
|
|
661
|
+
"tags": [
|
|
662
|
+
{
|
|
663
|
+
"title": "public",
|
|
664
|
+
"description": null,
|
|
665
|
+
"type": null
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
"title": "function",
|
|
669
|
+
"description": null,
|
|
670
|
+
"name": null
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
"title": "example",
|
|
674
|
+
"description": "field('destination_field_name__c', 'value')"
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
"title": "param",
|
|
678
|
+
"description": "Name of the field",
|
|
679
|
+
"type": {
|
|
680
|
+
"type": "NameExpression",
|
|
681
|
+
"name": "string"
|
|
682
|
+
},
|
|
683
|
+
"name": "key"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
"title": "param",
|
|
687
|
+
"description": "The value itself or a sourceable operation.",
|
|
688
|
+
"type": {
|
|
689
|
+
"type": "NameExpression",
|
|
690
|
+
"name": "Value"
|
|
691
|
+
},
|
|
692
|
+
"name": "value"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"title": "returns",
|
|
696
|
+
"description": null,
|
|
697
|
+
"type": {
|
|
698
|
+
"type": "NameExpression",
|
|
699
|
+
"name": "Field"
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
]
|
|
703
|
+
},
|
|
704
|
+
"valid": true
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"name": "fields",
|
|
708
|
+
"params": [
|
|
709
|
+
"fields"
|
|
710
|
+
],
|
|
711
|
+
"docs": {
|
|
712
|
+
"description": "Zips key value pairs into an object.",
|
|
713
|
+
"tags": [
|
|
714
|
+
{
|
|
715
|
+
"title": "public",
|
|
716
|
+
"description": null,
|
|
717
|
+
"type": null
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"title": "function",
|
|
721
|
+
"description": null,
|
|
722
|
+
"name": null
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"title": "example",
|
|
726
|
+
"description": "fields(list_of_fields)"
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
"title": "param",
|
|
730
|
+
"description": "a list of fields",
|
|
731
|
+
"type": {
|
|
732
|
+
"type": "NameExpression",
|
|
733
|
+
"name": "Fields"
|
|
734
|
+
},
|
|
735
|
+
"name": "fields"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
"title": "returns",
|
|
739
|
+
"description": null,
|
|
740
|
+
"type": {
|
|
741
|
+
"type": "NameExpression",
|
|
742
|
+
"name": "Object"
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
]
|
|
746
|
+
},
|
|
747
|
+
"valid": true
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
"name": "merge",
|
|
751
|
+
"params": [
|
|
752
|
+
"dataSource",
|
|
753
|
+
"fields"
|
|
754
|
+
],
|
|
755
|
+
"docs": {
|
|
756
|
+
"description": "Merges fields into each item in an array.",
|
|
757
|
+
"tags": [
|
|
758
|
+
{
|
|
759
|
+
"title": "public",
|
|
760
|
+
"description": null,
|
|
761
|
+
"type": null
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
"title": "example",
|
|
765
|
+
"description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
"title": "function",
|
|
769
|
+
"description": null,
|
|
770
|
+
"name": null
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
"title": "public",
|
|
774
|
+
"description": null,
|
|
775
|
+
"type": null
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
"title": "param",
|
|
779
|
+
"description": null,
|
|
780
|
+
"type": {
|
|
781
|
+
"type": "NameExpression",
|
|
782
|
+
"name": "DataSource"
|
|
783
|
+
},
|
|
784
|
+
"name": "dataSource"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"title": "param",
|
|
788
|
+
"description": "Group of fields to merge in.",
|
|
789
|
+
"type": {
|
|
790
|
+
"type": "NameExpression",
|
|
791
|
+
"name": "Object"
|
|
792
|
+
},
|
|
793
|
+
"name": "fields"
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
"title": "returns",
|
|
797
|
+
"description": null,
|
|
798
|
+
"type": {
|
|
799
|
+
"type": "NameExpression",
|
|
800
|
+
"name": "DataSource"
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
]
|
|
804
|
+
},
|
|
805
|
+
"valid": true
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
"name": "cursor",
|
|
809
|
+
"params": [
|
|
810
|
+
"value",
|
|
811
|
+
"options"
|
|
812
|
+
],
|
|
813
|
+
"docs": {
|
|
814
|
+
"description": "Sets a cursor property on state.\nSupports natural language dates like `now`, `today`, `yesterday`, `n hours ago`, `n days ago`, and `start`,\nwhich will be converted relative to the environment (ie, the Lightning or CLI locale). Custom timezones\nare not yet supported.\nYou can provide a formatter to customise the final cursor value, which is useful for normalising\ndifferent inputs. The custom formatter runs after natural language date conversion.\nSee the usage guide at {@link https://docs.openfn.org/documentation/jobs/job-writing-guide#using-cursors}",
|
|
815
|
+
"tags": [
|
|
816
|
+
{
|
|
817
|
+
"title": "public",
|
|
818
|
+
"description": null,
|
|
819
|
+
"type": null
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
"title": "function",
|
|
823
|
+
"description": null,
|
|
824
|
+
"name": null
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
"title": "example",
|
|
828
|
+
"description": "cursor($.cursor, { defaultValue: 'today' })",
|
|
829
|
+
"caption": "Use a cursor from state if present, or else use the default value"
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
"title": "example",
|
|
833
|
+
"description": "cursor(22)",
|
|
834
|
+
"caption": "Use a pagination cursor"
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
"title": "param",
|
|
838
|
+
"description": "the cursor value. Usually an ISO date, natural language date, or page number",
|
|
839
|
+
"type": {
|
|
840
|
+
"type": "NameExpression",
|
|
841
|
+
"name": "any"
|
|
842
|
+
},
|
|
843
|
+
"name": "value"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
"title": "param",
|
|
847
|
+
"description": "options to control the cursor.",
|
|
848
|
+
"type": {
|
|
849
|
+
"type": "NameExpression",
|
|
850
|
+
"name": "object"
|
|
851
|
+
},
|
|
852
|
+
"name": "options"
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
"title": "param",
|
|
856
|
+
"description": "set the cursor key. Will persist through the whole run.",
|
|
857
|
+
"type": {
|
|
858
|
+
"type": "NameExpression",
|
|
859
|
+
"name": "string"
|
|
860
|
+
},
|
|
861
|
+
"name": "options.key"
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
"title": "param",
|
|
865
|
+
"description": "the value to use if value is falsy",
|
|
866
|
+
"type": {
|
|
867
|
+
"type": "NameExpression",
|
|
868
|
+
"name": "any"
|
|
869
|
+
},
|
|
870
|
+
"name": "options.defaultValue"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"title": "param",
|
|
874
|
+
"description": "custom formatter for the final cursor value",
|
|
875
|
+
"type": {
|
|
876
|
+
"type": "NameExpression",
|
|
877
|
+
"name": "Function"
|
|
878
|
+
},
|
|
879
|
+
"name": "options.format"
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
"title": "returns",
|
|
883
|
+
"description": null,
|
|
884
|
+
"type": {
|
|
885
|
+
"type": "NameExpression",
|
|
886
|
+
"name": "Operation"
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
]
|
|
890
|
+
},
|
|
891
|
+
"valid": false
|
|
892
|
+
}
|
|
893
|
+
]
|
|
894
|
+
}
|