openfn@3.0.3
This adaptor exports the following from common:
- alterState()
- beta
- combine()
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- lastReferenceValue()
- merge()
- sourceValue()
Functions
get
get(path, options) ⇒ Operation
Make a GET request to OpenFn API. Requires authentication first.
Param | Type | Description |
---|---|---|
path | string | Path to resource (relative to /api/). |
options | RequestOptions | Query, Headers and Authentication parameters |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the OpenFn API, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example: GET request with query parameters
get('jobs', {
query: { limit: 10, offset: 0 },
});
post
post(path, data, options) ⇒ operation
Make a POST request to OpenFn API. Requires authentication first.
Param | Type | Description |
---|---|---|
path | string | Path to resource (relative to /api/). |
data | object | Body data to append to the request. JSON will be converted to a string. |
options | RequestOptions | Query, Headers and Authentication parameters |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the OpenFn API, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example: POST a new job
post('jobs', {
name: 'test job',
body: 'fn(state => state)'
});
Example: POST with custom headers
post('jobs', {
name: 'test job',
body: 'fn(state => state)'
}, {
headers: { 'x-custom': 'value' },
});
request
request(method, path, options) ⇒ Operation
Make a HTTP request to OpenFn API. Requires authentication first.
Param | Type | Description |
---|---|---|
method | string | The HTTP method to use. |
path | string | Path to resource (relative to /api/). |
options | RequestOptions | Body, Query, Headers and Authentication parameters |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the parsed response body |
response | the response from the OpenFn API, including headers, statusCode, body, etc |
references | an array of all previous data objects used in the Job |
Example: Make a GET request
request('GET', 'jobs', {
query: { limit: 10 },
});
Example: Make a POST request with a body
request('POST', 'jobs', {
body: {
name: 'test job',
expression: 'fn(state => state)'
},
});
Interfaces
RequestOptions
Options provided to the OpenFn API request
Properties
Name | Type | Description |
---|---|---|
errors | object | Map of errorCodes -> error messages, ie, { 404: 'Resource not found;' } . Pass false to suppress errors for this code. |
body | object | string | body data to append to the request. JSON will be converted to a string. |
query | object | An object of query parameters to be encoded into the URL. |
headers | object | An object of headers to append to the request. |
parseAs | string | Parse the response body as json, text or stream. By default will use the response headers. |
timeout | number | Request timeout in ms. Default: 300 seconds. |