@openfn/language-intuit 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 +43 -0
- package/ast.json +525 -0
- package/configuration-schema.json +29 -0
- package/dist/index.cjs +148 -0
- package/dist/index.js +132 -0
- package/package.json +48 -0
- package/types/Adaptor.d.ts +1 -0
- package/types/Utils.d.ts +2 -0
- package/types/http.d.ts +82 -0
- package/types/index.d.ts +4 -0
package/ast.json
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
{
|
|
2
|
+
"operations": [],
|
|
3
|
+
"exports": [],
|
|
4
|
+
"common": [
|
|
5
|
+
{
|
|
6
|
+
"name": "fn",
|
|
7
|
+
"params": [
|
|
8
|
+
"func"
|
|
9
|
+
],
|
|
10
|
+
"docs": {
|
|
11
|
+
"description": "Creates a custom step (or operation) for more flexible job writing.",
|
|
12
|
+
"tags": [
|
|
13
|
+
{
|
|
14
|
+
"title": "public",
|
|
15
|
+
"description": null,
|
|
16
|
+
"type": null
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"title": "function",
|
|
20
|
+
"description": null,
|
|
21
|
+
"name": null
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"title": "example",
|
|
25
|
+
"description": "fn(state => {\n // do some things to state\n return state;\n});"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"title": "param",
|
|
29
|
+
"description": "is the function",
|
|
30
|
+
"type": {
|
|
31
|
+
"type": "NameExpression",
|
|
32
|
+
"name": "Function"
|
|
33
|
+
},
|
|
34
|
+
"name": "func"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"title": "returns",
|
|
38
|
+
"description": null,
|
|
39
|
+
"type": {
|
|
40
|
+
"type": "NameExpression",
|
|
41
|
+
"name": "Operation"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"valid": true
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "sourceValue",
|
|
50
|
+
"params": [
|
|
51
|
+
"path"
|
|
52
|
+
],
|
|
53
|
+
"docs": {
|
|
54
|
+
"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.",
|
|
55
|
+
"tags": [
|
|
56
|
+
{
|
|
57
|
+
"title": "public",
|
|
58
|
+
"description": null,
|
|
59
|
+
"type": null
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"title": "function",
|
|
63
|
+
"description": null,
|
|
64
|
+
"name": null
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"title": "example",
|
|
68
|
+
"description": "sourceValue('$.key')"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"title": "param",
|
|
72
|
+
"description": "JSONPath referencing a point in `state`.",
|
|
73
|
+
"type": {
|
|
74
|
+
"type": "NameExpression",
|
|
75
|
+
"name": "String"
|
|
76
|
+
},
|
|
77
|
+
"name": "path"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"title": "returns",
|
|
81
|
+
"description": null,
|
|
82
|
+
"type": {
|
|
83
|
+
"type": "NameExpression",
|
|
84
|
+
"name": "Operation"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"valid": true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "dataPath",
|
|
93
|
+
"params": [
|
|
94
|
+
"path"
|
|
95
|
+
],
|
|
96
|
+
"docs": {
|
|
97
|
+
"description": "Ensures a path points at the data.",
|
|
98
|
+
"tags": [
|
|
99
|
+
{
|
|
100
|
+
"title": "public",
|
|
101
|
+
"description": null,
|
|
102
|
+
"type": null
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"title": "function",
|
|
106
|
+
"description": null,
|
|
107
|
+
"name": null
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"title": "example",
|
|
111
|
+
"description": "dataPath('key')"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"title": "param",
|
|
115
|
+
"description": "JSONPath referencing a point in `data`.",
|
|
116
|
+
"type": {
|
|
117
|
+
"type": "NameExpression",
|
|
118
|
+
"name": "string"
|
|
119
|
+
},
|
|
120
|
+
"name": "path"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"title": "returns",
|
|
124
|
+
"description": null,
|
|
125
|
+
"type": {
|
|
126
|
+
"type": "NameExpression",
|
|
127
|
+
"name": "string"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"valid": true
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "dataValue",
|
|
136
|
+
"params": [
|
|
137
|
+
"path"
|
|
138
|
+
],
|
|
139
|
+
"docs": {
|
|
140
|
+
"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.",
|
|
141
|
+
"tags": [
|
|
142
|
+
{
|
|
143
|
+
"title": "public",
|
|
144
|
+
"description": null,
|
|
145
|
+
"type": null
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"title": "function",
|
|
149
|
+
"description": null,
|
|
150
|
+
"name": null
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"title": "example",
|
|
154
|
+
"description": "dataValue('key')"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"title": "param",
|
|
158
|
+
"description": "JSONPath referencing a point in `data`.",
|
|
159
|
+
"type": {
|
|
160
|
+
"type": "NameExpression",
|
|
161
|
+
"name": "String"
|
|
162
|
+
},
|
|
163
|
+
"name": "path"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"title": "returns",
|
|
167
|
+
"description": null,
|
|
168
|
+
"type": {
|
|
169
|
+
"type": "NameExpression",
|
|
170
|
+
"name": "Operation"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
"valid": true
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "lastReferenceValue",
|
|
179
|
+
"params": [
|
|
180
|
+
"path"
|
|
181
|
+
],
|
|
182
|
+
"docs": {
|
|
183
|
+
"description": "Picks out the last reference value from source data.",
|
|
184
|
+
"tags": [
|
|
185
|
+
{
|
|
186
|
+
"title": "public",
|
|
187
|
+
"description": null,
|
|
188
|
+
"type": null
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"title": "function",
|
|
192
|
+
"description": null,
|
|
193
|
+
"name": null
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"title": "example",
|
|
197
|
+
"description": "lastReferenceValue('key')"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"title": "param",
|
|
201
|
+
"description": "JSONPath referencing a point in `references`.",
|
|
202
|
+
"type": {
|
|
203
|
+
"type": "NameExpression",
|
|
204
|
+
"name": "String"
|
|
205
|
+
},
|
|
206
|
+
"name": "path"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"title": "returns",
|
|
210
|
+
"description": null,
|
|
211
|
+
"type": {
|
|
212
|
+
"type": "NameExpression",
|
|
213
|
+
"name": "Operation"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
"valid": true
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "each",
|
|
222
|
+
"params": [
|
|
223
|
+
"dataSource",
|
|
224
|
+
"operation"
|
|
225
|
+
],
|
|
226
|
+
"docs": {
|
|
227
|
+
"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.",
|
|
228
|
+
"tags": [
|
|
229
|
+
{
|
|
230
|
+
"title": "public",
|
|
231
|
+
"description": null,
|
|
232
|
+
"type": null
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"title": "function",
|
|
236
|
+
"description": null,
|
|
237
|
+
"name": null
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"title": "example",
|
|
241
|
+
"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);",
|
|
242
|
+
"caption": "Using lazy state ($) to iterate over items in state.data and pass each into an \"insert\" operation"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"title": "example",
|
|
246
|
+
"description": "each(\n $.data,\n insert(\"patient\", (state) => ({\n patient_id: state.data.case_id,\n ...state.data\n }))\n);",
|
|
247
|
+
"caption": "Iterate over items in state.data and pass each one into an \"insert\" operation"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"title": "example",
|
|
251
|
+
"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);",
|
|
252
|
+
"caption": "Using JSON path to iterate over items in state.data and pass each one into an \"insert\" operation"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"title": "param",
|
|
256
|
+
"description": "JSONPath referencing a point in `state`.",
|
|
257
|
+
"type": {
|
|
258
|
+
"type": "NameExpression",
|
|
259
|
+
"name": "DataSource"
|
|
260
|
+
},
|
|
261
|
+
"name": "dataSource"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"title": "param",
|
|
265
|
+
"description": "The operation needed to be repeated.",
|
|
266
|
+
"type": {
|
|
267
|
+
"type": "NameExpression",
|
|
268
|
+
"name": "Operation"
|
|
269
|
+
},
|
|
270
|
+
"name": "operation"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"title": "returns",
|
|
274
|
+
"description": null,
|
|
275
|
+
"type": {
|
|
276
|
+
"type": "NameExpression",
|
|
277
|
+
"name": "Operation"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
"valid": true
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"name": "field",
|
|
286
|
+
"params": [
|
|
287
|
+
"key",
|
|
288
|
+
"value"
|
|
289
|
+
],
|
|
290
|
+
"docs": {
|
|
291
|
+
"description": "Returns a key, value pair in an array.",
|
|
292
|
+
"tags": [
|
|
293
|
+
{
|
|
294
|
+
"title": "public",
|
|
295
|
+
"description": null,
|
|
296
|
+
"type": null
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"title": "function",
|
|
300
|
+
"description": null,
|
|
301
|
+
"name": null
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"title": "example",
|
|
305
|
+
"description": "field('destination_field_name__c', 'value')"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"title": "param",
|
|
309
|
+
"description": "Name of the field",
|
|
310
|
+
"type": {
|
|
311
|
+
"type": "NameExpression",
|
|
312
|
+
"name": "string"
|
|
313
|
+
},
|
|
314
|
+
"name": "key"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"title": "param",
|
|
318
|
+
"description": "The value itself or a sourceable operation.",
|
|
319
|
+
"type": {
|
|
320
|
+
"type": "NameExpression",
|
|
321
|
+
"name": "Value"
|
|
322
|
+
},
|
|
323
|
+
"name": "value"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"title": "returns",
|
|
327
|
+
"description": null,
|
|
328
|
+
"type": {
|
|
329
|
+
"type": "NameExpression",
|
|
330
|
+
"name": "Field"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
},
|
|
335
|
+
"valid": true
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"name": "fields",
|
|
339
|
+
"params": [
|
|
340
|
+
"fields"
|
|
341
|
+
],
|
|
342
|
+
"docs": {
|
|
343
|
+
"description": "Zips key value pairs into an object.",
|
|
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": "fields(list_of_fields)"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"title": "param",
|
|
361
|
+
"description": "a list of fields",
|
|
362
|
+
"type": {
|
|
363
|
+
"type": "NameExpression",
|
|
364
|
+
"name": "Fields"
|
|
365
|
+
},
|
|
366
|
+
"name": "fields"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"title": "returns",
|
|
370
|
+
"description": null,
|
|
371
|
+
"type": {
|
|
372
|
+
"type": "NameExpression",
|
|
373
|
+
"name": "Object"
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
"valid": true
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"name": "merge",
|
|
382
|
+
"params": [
|
|
383
|
+
"dataSource",
|
|
384
|
+
"fields"
|
|
385
|
+
],
|
|
386
|
+
"docs": {
|
|
387
|
+
"description": "Merges fields into each item in an array.",
|
|
388
|
+
"tags": [
|
|
389
|
+
{
|
|
390
|
+
"title": "public",
|
|
391
|
+
"description": null,
|
|
392
|
+
"type": null
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"title": "example",
|
|
396
|
+
"description": "merge(\n \"$.books[*]\",\n fields(\n field( \"publisher\", sourceValue(\"$.publisher\") )\n )\n)"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"title": "function",
|
|
400
|
+
"description": null,
|
|
401
|
+
"name": null
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"title": "public",
|
|
405
|
+
"description": null,
|
|
406
|
+
"type": null
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"title": "param",
|
|
410
|
+
"description": null,
|
|
411
|
+
"type": {
|
|
412
|
+
"type": "NameExpression",
|
|
413
|
+
"name": "DataSource"
|
|
414
|
+
},
|
|
415
|
+
"name": "dataSource"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"title": "param",
|
|
419
|
+
"description": "Group of fields to merge in.",
|
|
420
|
+
"type": {
|
|
421
|
+
"type": "NameExpression",
|
|
422
|
+
"name": "Object"
|
|
423
|
+
},
|
|
424
|
+
"name": "fields"
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"title": "returns",
|
|
428
|
+
"description": null,
|
|
429
|
+
"type": {
|
|
430
|
+
"type": "NameExpression",
|
|
431
|
+
"name": "DataSource"
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
]
|
|
435
|
+
},
|
|
436
|
+
"valid": true
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"name": "cursor",
|
|
440
|
+
"params": [
|
|
441
|
+
"value",
|
|
442
|
+
"options"
|
|
443
|
+
],
|
|
444
|
+
"docs": {
|
|
445
|
+
"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}",
|
|
446
|
+
"tags": [
|
|
447
|
+
{
|
|
448
|
+
"title": "public",
|
|
449
|
+
"description": null,
|
|
450
|
+
"type": null
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"title": "function",
|
|
454
|
+
"description": null,
|
|
455
|
+
"name": null
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
"title": "example",
|
|
459
|
+
"description": "cursor($.cursor, { defaultValue: 'today' })",
|
|
460
|
+
"caption": "Use a cursor from state if present, or else use the default value"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"title": "example",
|
|
464
|
+
"description": "cursor(22)",
|
|
465
|
+
"caption": "Use a pagination cursor"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"title": "param",
|
|
469
|
+
"description": "the cursor value. Usually an ISO date, natural language date, or page number",
|
|
470
|
+
"type": {
|
|
471
|
+
"type": "NameExpression",
|
|
472
|
+
"name": "any"
|
|
473
|
+
},
|
|
474
|
+
"name": "value"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"title": "param",
|
|
478
|
+
"description": "options to control the cursor.",
|
|
479
|
+
"type": {
|
|
480
|
+
"type": "NameExpression",
|
|
481
|
+
"name": "object"
|
|
482
|
+
},
|
|
483
|
+
"name": "options"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"title": "param",
|
|
487
|
+
"description": "set the cursor key. Will persist through the whole run.",
|
|
488
|
+
"type": {
|
|
489
|
+
"type": "NameExpression",
|
|
490
|
+
"name": "string"
|
|
491
|
+
},
|
|
492
|
+
"name": "options.key"
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"title": "param",
|
|
496
|
+
"description": "the value to use if value is falsy",
|
|
497
|
+
"type": {
|
|
498
|
+
"type": "NameExpression",
|
|
499
|
+
"name": "any"
|
|
500
|
+
},
|
|
501
|
+
"name": "options.defaultValue"
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"title": "param",
|
|
505
|
+
"description": "custom formatter for the final cursor value",
|
|
506
|
+
"type": {
|
|
507
|
+
"type": "NameExpression",
|
|
508
|
+
"name": "Function"
|
|
509
|
+
},
|
|
510
|
+
"name": "options.format"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"title": "returns",
|
|
514
|
+
"description": null,
|
|
515
|
+
"type": {
|
|
516
|
+
"type": "NameExpression",
|
|
517
|
+
"name": "Operation"
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
]
|
|
521
|
+
},
|
|
522
|
+
"valid": false
|
|
523
|
+
}
|
|
524
|
+
]
|
|
525
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"properties": {
|
|
4
|
+
"baseUrl": {
|
|
5
|
+
"title": "Base URL",
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "The Quickbooks(intuit) base URL",
|
|
8
|
+
"format": "uri",
|
|
9
|
+
"minLength": 1,
|
|
10
|
+
"examples": [
|
|
11
|
+
"https://sandbox-quickbooks.api.intuit.com"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"access_token": {
|
|
15
|
+
"title": "Access Token",
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Your Quickbooks(intuit) access token",
|
|
18
|
+
"examples": [
|
|
19
|
+
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3ZRdVhoODQ2WVR3RUlCdyIsI"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": true,
|
|
25
|
+
"required": [
|
|
26
|
+
"access_token",
|
|
27
|
+
"baseUrl"
|
|
28
|
+
]
|
|
29
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/index.js
|
|
20
|
+
var src_exports = {};
|
|
21
|
+
__export(src_exports, {
|
|
22
|
+
cursor: () => import_language_common.cursor,
|
|
23
|
+
dataPath: () => import_language_common.dataPath,
|
|
24
|
+
dataValue: () => import_language_common.dataValue,
|
|
25
|
+
dateFns: () => import_language_common.dateFns,
|
|
26
|
+
default: () => src_default,
|
|
27
|
+
each: () => import_language_common.each,
|
|
28
|
+
field: () => import_language_common.field,
|
|
29
|
+
fields: () => import_language_common.fields,
|
|
30
|
+
fn: () => import_language_common.fn,
|
|
31
|
+
http: () => http_exports,
|
|
32
|
+
lastReferenceValue: () => import_language_common.lastReferenceValue,
|
|
33
|
+
merge: () => import_language_common.merge,
|
|
34
|
+
sourceValue: () => import_language_common.sourceValue
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
|
|
38
|
+
// src/Adaptor.js
|
|
39
|
+
var Adaptor_exports = {};
|
|
40
|
+
__export(Adaptor_exports, {
|
|
41
|
+
cursor: () => import_language_common.cursor,
|
|
42
|
+
dataPath: () => import_language_common.dataPath,
|
|
43
|
+
dataValue: () => import_language_common.dataValue,
|
|
44
|
+
dateFns: () => import_language_common.dateFns,
|
|
45
|
+
each: () => import_language_common.each,
|
|
46
|
+
field: () => import_language_common.field,
|
|
47
|
+
fields: () => import_language_common.fields,
|
|
48
|
+
fn: () => import_language_common.fn,
|
|
49
|
+
lastReferenceValue: () => import_language_common.lastReferenceValue,
|
|
50
|
+
merge: () => import_language_common.merge,
|
|
51
|
+
sourceValue: () => import_language_common.sourceValue
|
|
52
|
+
});
|
|
53
|
+
var import_language_common = require("@openfn/language-common");
|
|
54
|
+
|
|
55
|
+
// src/http.js
|
|
56
|
+
var http_exports = {};
|
|
57
|
+
__export(http_exports, {
|
|
58
|
+
get: () => get,
|
|
59
|
+
post: () => post
|
|
60
|
+
});
|
|
61
|
+
var import_util2 = require("@openfn/language-common/util");
|
|
62
|
+
|
|
63
|
+
// src/Utils.js
|
|
64
|
+
var import_language_common2 = require("@openfn/language-common");
|
|
65
|
+
var import_util = require("@openfn/language-common/util");
|
|
66
|
+
var prepareNextState = (state, response) => {
|
|
67
|
+
const { body, ...responseWithoutBody } = response;
|
|
68
|
+
if (!state.references) {
|
|
69
|
+
state.references = [];
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...(0, import_language_common2.composeNextState)(state, response.body),
|
|
73
|
+
response: responseWithoutBody
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
var request = (state, method, path, options = {}) => {
|
|
77
|
+
const { baseUrl, access_token } = state.configuration;
|
|
78
|
+
if (!access_token) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"No access_token found in state.configuration. Please ensure you have authenticated before making a request."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const { query = {}, body = {}, headers = {}, parseAs = "json" } = options;
|
|
84
|
+
const opts = {
|
|
85
|
+
parseAs,
|
|
86
|
+
baseUrl,
|
|
87
|
+
body,
|
|
88
|
+
query,
|
|
89
|
+
headers: {
|
|
90
|
+
Authorization: `Bearer ${access_token}`,
|
|
91
|
+
"Content-type": "application/json",
|
|
92
|
+
Accept: "application/json",
|
|
93
|
+
...headers
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return (0, import_util.request)(method, path, opts).then(import_util.logResponse);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// src/http.js
|
|
100
|
+
function get(path, options = {}) {
|
|
101
|
+
return async (state) => {
|
|
102
|
+
const [resolvedPath, resolvedOptions = {}] = (0, import_util2.expandReferences)(
|
|
103
|
+
state,
|
|
104
|
+
path,
|
|
105
|
+
options
|
|
106
|
+
);
|
|
107
|
+
const response = await request(
|
|
108
|
+
state,
|
|
109
|
+
"GET",
|
|
110
|
+
resolvedPath,
|
|
111
|
+
resolvedOptions
|
|
112
|
+
);
|
|
113
|
+
return prepareNextState(state, response);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function post(path, data, options = {}) {
|
|
117
|
+
return async (state) => {
|
|
118
|
+
const [resolvedPath, resolvedBody, resolvedOptions = {}] = (0, import_util2.expandReferences)(
|
|
119
|
+
state,
|
|
120
|
+
path,
|
|
121
|
+
data,
|
|
122
|
+
options
|
|
123
|
+
);
|
|
124
|
+
const response = await request(state, "POST", resolvedPath, {
|
|
125
|
+
...resolvedOptions,
|
|
126
|
+
body: resolvedBody
|
|
127
|
+
});
|
|
128
|
+
return prepareNextState(state, response);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/index.js
|
|
133
|
+
var src_default = Adaptor_exports;
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
cursor,
|
|
137
|
+
dataPath,
|
|
138
|
+
dataValue,
|
|
139
|
+
dateFns,
|
|
140
|
+
each,
|
|
141
|
+
field,
|
|
142
|
+
fields,
|
|
143
|
+
fn,
|
|
144
|
+
http,
|
|
145
|
+
lastReferenceValue,
|
|
146
|
+
merge,
|
|
147
|
+
sourceValue
|
|
148
|
+
});
|