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