@openfn/language-hubtel 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,603 @@
1
+ {
2
+ "operations": [
3
+ {
4
+ "name": "request",
5
+ "params": [
6
+ "method",
7
+ "path",
8
+ "body",
9
+ "options"
10
+ ],
11
+ "docs": {
12
+ "description": "Make a general HTTP request",
13
+ "tags": [
14
+ {
15
+ "title": "example",
16
+ "description": "request(\"POST\", \"patient\", { \"name\": \"Bukayo\" });"
17
+ },
18
+ {
19
+ "title": "function",
20
+ "description": null,
21
+ "name": null
22
+ },
23
+ {
24
+ "title": "public",
25
+ "description": null,
26
+ "type": null
27
+ },
28
+ {
29
+ "title": "param",
30
+ "description": "HTTP method to use",
31
+ "type": {
32
+ "type": "NameExpression",
33
+ "name": "string"
34
+ },
35
+ "name": "method"
36
+ },
37
+ {
38
+ "title": "param",
39
+ "description": "Path to resource",
40
+ "type": {
41
+ "type": "NameExpression",
42
+ "name": "string"
43
+ },
44
+ "name": "path"
45
+ },
46
+ {
47
+ "title": "param",
48
+ "description": "Object which will be attached to the POST body",
49
+ "type": {
50
+ "type": "NameExpression",
51
+ "name": "object"
52
+ },
53
+ "name": "data"
54
+ },
55
+ {
56
+ "title": "param",
57
+ "description": "Optional request options",
58
+ "type": {
59
+ "type": "NameExpression",
60
+ "name": "RequestOptions"
61
+ },
62
+ "name": "options"
63
+ },
64
+ {
65
+ "title": "returns",
66
+ "description": null,
67
+ "type": {
68
+ "type": "NameExpression",
69
+ "name": "Operation"
70
+ }
71
+ },
72
+ {
73
+ "title": "state",
74
+ "description": "{HttpState}"
75
+ }
76
+ ]
77
+ },
78
+ "valid": false
79
+ }
80
+ ],
81
+ "exports": [],
82
+ "common": [
83
+ {
84
+ "name": "fn",
85
+ "params": [
86
+ "func"
87
+ ],
88
+ "docs": {
89
+ "description": "Creates a custom step (or operation) for more flexible job writing.",
90
+ "tags": [
91
+ {
92
+ "title": "public",
93
+ "description": null,
94
+ "type": null
95
+ },
96
+ {
97
+ "title": "function",
98
+ "description": null,
99
+ "name": null
100
+ },
101
+ {
102
+ "title": "example",
103
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
104
+ },
105
+ {
106
+ "title": "param",
107
+ "description": "is the function",
108
+ "type": {
109
+ "type": "NameExpression",
110
+ "name": "Function"
111
+ },
112
+ "name": "func"
113
+ },
114
+ {
115
+ "title": "returns",
116
+ "description": null,
117
+ "type": {
118
+ "type": "NameExpression",
119
+ "name": "Operation"
120
+ }
121
+ }
122
+ ]
123
+ },
124
+ "valid": true
125
+ },
126
+ {
127
+ "name": "sourceValue",
128
+ "params": [
129
+ "path"
130
+ ],
131
+ "docs": {
132
+ "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.",
133
+ "tags": [
134
+ {
135
+ "title": "public",
136
+ "description": null,
137
+ "type": null
138
+ },
139
+ {
140
+ "title": "function",
141
+ "description": null,
142
+ "name": null
143
+ },
144
+ {
145
+ "title": "example",
146
+ "description": "sourceValue('$.key')"
147
+ },
148
+ {
149
+ "title": "param",
150
+ "description": "JSONPath referencing a point in `state`.",
151
+ "type": {
152
+ "type": "NameExpression",
153
+ "name": "String"
154
+ },
155
+ "name": "path"
156
+ },
157
+ {
158
+ "title": "returns",
159
+ "description": null,
160
+ "type": {
161
+ "type": "NameExpression",
162
+ "name": "Operation"
163
+ }
164
+ }
165
+ ]
166
+ },
167
+ "valid": true
168
+ },
169
+ {
170
+ "name": "dataPath",
171
+ "params": [
172
+ "path"
173
+ ],
174
+ "docs": {
175
+ "description": "Ensures a path points at the data.",
176
+ "tags": [
177
+ {
178
+ "title": "public",
179
+ "description": null,
180
+ "type": null
181
+ },
182
+ {
183
+ "title": "function",
184
+ "description": null,
185
+ "name": null
186
+ },
187
+ {
188
+ "title": "example",
189
+ "description": "dataPath('key')"
190
+ },
191
+ {
192
+ "title": "param",
193
+ "description": "JSONPath referencing a point in `data`.",
194
+ "type": {
195
+ "type": "NameExpression",
196
+ "name": "string"
197
+ },
198
+ "name": "path"
199
+ },
200
+ {
201
+ "title": "returns",
202
+ "description": null,
203
+ "type": {
204
+ "type": "NameExpression",
205
+ "name": "string"
206
+ }
207
+ }
208
+ ]
209
+ },
210
+ "valid": true
211
+ },
212
+ {
213
+ "name": "dataValue",
214
+ "params": [
215
+ "path"
216
+ ],
217
+ "docs": {
218
+ "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.",
219
+ "tags": [
220
+ {
221
+ "title": "public",
222
+ "description": null,
223
+ "type": null
224
+ },
225
+ {
226
+ "title": "function",
227
+ "description": null,
228
+ "name": null
229
+ },
230
+ {
231
+ "title": "example",
232
+ "description": "dataValue('key')"
233
+ },
234
+ {
235
+ "title": "param",
236
+ "description": "JSONPath referencing a point in `data`.",
237
+ "type": {
238
+ "type": "NameExpression",
239
+ "name": "String"
240
+ },
241
+ "name": "path"
242
+ },
243
+ {
244
+ "title": "returns",
245
+ "description": null,
246
+ "type": {
247
+ "type": "NameExpression",
248
+ "name": "Operation"
249
+ }
250
+ }
251
+ ]
252
+ },
253
+ "valid": true
254
+ },
255
+ {
256
+ "name": "lastReferenceValue",
257
+ "params": [
258
+ "path"
259
+ ],
260
+ "docs": {
261
+ "description": "Picks out the last reference value from source data.",
262
+ "tags": [
263
+ {
264
+ "title": "public",
265
+ "description": null,
266
+ "type": null
267
+ },
268
+ {
269
+ "title": "function",
270
+ "description": null,
271
+ "name": null
272
+ },
273
+ {
274
+ "title": "example",
275
+ "description": "lastReferenceValue('key')"
276
+ },
277
+ {
278
+ "title": "param",
279
+ "description": "JSONPath referencing a point in `references`.",
280
+ "type": {
281
+ "type": "NameExpression",
282
+ "name": "String"
283
+ },
284
+ "name": "path"
285
+ },
286
+ {
287
+ "title": "returns",
288
+ "description": null,
289
+ "type": {
290
+ "type": "NameExpression",
291
+ "name": "Operation"
292
+ }
293
+ }
294
+ ]
295
+ },
296
+ "valid": true
297
+ },
298
+ {
299
+ "name": "each",
300
+ "params": [
301
+ "dataSource",
302
+ "operation"
303
+ ],
304
+ "docs": {
305
+ "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.",
306
+ "tags": [
307
+ {
308
+ "title": "public",
309
+ "description": null,
310
+ "type": null
311
+ },
312
+ {
313
+ "title": "function",
314
+ "description": null,
315
+ "name": null
316
+ },
317
+ {
318
+ "title": "example",
319
+ "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);",
320
+ "caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
321
+ },
322
+ {
323
+ "title": "example",
324
+ "description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
325
+ "caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
326
+ },
327
+ {
328
+ "title": "example",
329
+ "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);",
330
+ "caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
331
+ },
332
+ {
333
+ "title": "param",
334
+ "description": "JSONPath referencing a point in `state`.",
335
+ "type": {
336
+ "type": "NameExpression",
337
+ "name": "DataSource"
338
+ },
339
+ "name": "dataSource"
340
+ },
341
+ {
342
+ "title": "param",
343
+ "description": "The operation needed to be repeated.",
344
+ "type": {
345
+ "type": "NameExpression",
346
+ "name": "Operation"
347
+ },
348
+ "name": "operation"
349
+ },
350
+ {
351
+ "title": "returns",
352
+ "description": null,
353
+ "type": {
354
+ "type": "NameExpression",
355
+ "name": "Operation"
356
+ }
357
+ }
358
+ ]
359
+ },
360
+ "valid": true
361
+ },
362
+ {
363
+ "name": "field",
364
+ "params": [
365
+ "key",
366
+ "value"
367
+ ],
368
+ "docs": {
369
+ "description": "Returns a key, value pair in an array.",
370
+ "tags": [
371
+ {
372
+ "title": "public",
373
+ "description": null,
374
+ "type": null
375
+ },
376
+ {
377
+ "title": "function",
378
+ "description": null,
379
+ "name": null
380
+ },
381
+ {
382
+ "title": "example",
383
+ "description": "field('destination_field_name__c', 'value')"
384
+ },
385
+ {
386
+ "title": "param",
387
+ "description": "Name of the field",
388
+ "type": {
389
+ "type": "NameExpression",
390
+ "name": "string"
391
+ },
392
+ "name": "key"
393
+ },
394
+ {
395
+ "title": "param",
396
+ "description": "The value itself or a sourceable operation.",
397
+ "type": {
398
+ "type": "NameExpression",
399
+ "name": "Value"
400
+ },
401
+ "name": "value"
402
+ },
403
+ {
404
+ "title": "returns",
405
+ "description": null,
406
+ "type": {
407
+ "type": "NameExpression",
408
+ "name": "Field"
409
+ }
410
+ }
411
+ ]
412
+ },
413
+ "valid": true
414
+ },
415
+ {
416
+ "name": "fields",
417
+ "params": [
418
+ "fields"
419
+ ],
420
+ "docs": {
421
+ "description": "Zips key value pairs into an object.",
422
+ "tags": [
423
+ {
424
+ "title": "public",
425
+ "description": null,
426
+ "type": null
427
+ },
428
+ {
429
+ "title": "function",
430
+ "description": null,
431
+ "name": null
432
+ },
433
+ {
434
+ "title": "example",
435
+ "description": "fields(list_of_fields)"
436
+ },
437
+ {
438
+ "title": "param",
439
+ "description": "a list of fields",
440
+ "type": {
441
+ "type": "NameExpression",
442
+ "name": "Fields"
443
+ },
444
+ "name": "fields"
445
+ },
446
+ {
447
+ "title": "returns",
448
+ "description": null,
449
+ "type": {
450
+ "type": "NameExpression",
451
+ "name": "Object"
452
+ }
453
+ }
454
+ ]
455
+ },
456
+ "valid": true
457
+ },
458
+ {
459
+ "name": "merge",
460
+ "params": [
461
+ "dataSource",
462
+ "fields"
463
+ ],
464
+ "docs": {
465
+ "description": "Merges fields into each item in an array.",
466
+ "tags": [
467
+ {
468
+ "title": "public",
469
+ "description": null,
470
+ "type": null
471
+ },
472
+ {
473
+ "title": "example",
474
+ "description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
475
+ },
476
+ {
477
+ "title": "function",
478
+ "description": null,
479
+ "name": null
480
+ },
481
+ {
482
+ "title": "public",
483
+ "description": null,
484
+ "type": null
485
+ },
486
+ {
487
+ "title": "param",
488
+ "description": null,
489
+ "type": {
490
+ "type": "NameExpression",
491
+ "name": "DataSource"
492
+ },
493
+ "name": "dataSource"
494
+ },
495
+ {
496
+ "title": "param",
497
+ "description": "Group of fields to merge in.",
498
+ "type": {
499
+ "type": "NameExpression",
500
+ "name": "Object"
501
+ },
502
+ "name": "fields"
503
+ },
504
+ {
505
+ "title": "returns",
506
+ "description": null,
507
+ "type": {
508
+ "type": "NameExpression",
509
+ "name": "DataSource"
510
+ }
511
+ }
512
+ ]
513
+ },
514
+ "valid": true
515
+ },
516
+ {
517
+ "name": "cursor",
518
+ "params": [
519
+ "value",
520
+ "options"
521
+ ],
522
+ "docs": {
523
+ "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}",
524
+ "tags": [
525
+ {
526
+ "title": "public",
527
+ "description": null,
528
+ "type": null
529
+ },
530
+ {
531
+ "title": "function",
532
+ "description": null,
533
+ "name": null
534
+ },
535
+ {
536
+ "title": "example",
537
+ "description": "cursor($.cursor, { defaultValue: 'today' })",
538
+ "caption": "Use a cursor from state if present, or else use the default value"
539
+ },
540
+ {
541
+ "title": "example",
542
+ "description": "cursor(22)",
543
+ "caption": "Use a pagination cursor"
544
+ },
545
+ {
546
+ "title": "param",
547
+ "description": "the cursor value. Usually an ISO date, natural language date, or page number",
548
+ "type": {
549
+ "type": "NameExpression",
550
+ "name": "any"
551
+ },
552
+ "name": "value"
553
+ },
554
+ {
555
+ "title": "param",
556
+ "description": "options to control the cursor.",
557
+ "type": {
558
+ "type": "NameExpression",
559
+ "name": "object"
560
+ },
561
+ "name": "options"
562
+ },
563
+ {
564
+ "title": "param",
565
+ "description": "set the cursor key. Will persist through the whole run.",
566
+ "type": {
567
+ "type": "NameExpression",
568
+ "name": "string"
569
+ },
570
+ "name": "options.key"
571
+ },
572
+ {
573
+ "title": "param",
574
+ "description": "the value to use if value is falsy",
575
+ "type": {
576
+ "type": "NameExpression",
577
+ "name": "any"
578
+ },
579
+ "name": "options.defaultValue"
580
+ },
581
+ {
582
+ "title": "param",
583
+ "description": "custom formatter for the final cursor value",
584
+ "type": {
585
+ "type": "NameExpression",
586
+ "name": "Function"
587
+ },
588
+ "name": "options.format"
589
+ },
590
+ {
591
+ "title": "returns",
592
+ "description": null,
593
+ "type": {
594
+ "type": "NameExpression",
595
+ "name": "Operation"
596
+ }
597
+ }
598
+ ]
599
+ },
600
+ "valid": false
601
+ }
602
+ ]
603
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "properties": {
4
+ "baseUrl": {
5
+ "title": "Base URL",
6
+ "anyOf": [
7
+ {
8
+ "type": "string"
9
+ },
10
+ {
11
+ "type": "null"
12
+ }
13
+ ],
14
+ "description": "The base URL (http://www.example.com)",
15
+ "format": "uri",
16
+ "minLength": 1,
17
+ "examples": ["https://example.com"]
18
+ },
19
+ "clientID": {
20
+ "title": "Client ID",
21
+ "type": "string",
22
+ "description": "Client ID",
23
+ "examples": ["xxx-yyy-zzz"]
24
+ },
25
+ "clientSecret": {
26
+ "title": "Client Secret",
27
+ "type": "string",
28
+ "description": "Client Secret",
29
+ "writeOnly": true,
30
+ "examples": ["@some(!)Str0ngSecr3t"]
31
+ }
32
+ },
33
+ "type": "object",
34
+ "additionalProperties": true,
35
+ "required": ["baseUrl", "clientID", "clientSecret"]
36
+ }