Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
6af899c
Added new functionality to put snapshot in message data into url tran…
Jun 25, 2021
72fd506
Added unit tests for new paging functionality, added check for missin…
Jun 29, 2021
d838ed3
In progress work on the component. Attachment tests still failing
Jul 15, 2021
fe8db9e
Changing testing back to fatal logging and commented out tests that a…
Jul 16, 2021
4d8a713
Added GitHub Actions to build/test image
Jul 16, 2021
75b4e34
Added Docker Hub repo path as a separate repo secret
Jul 16, 2021
de1a40d
Use newer version on node.js for github workflow
Jul 16, 2021
9a076d0
Fixed local path in test
Jul 16, 2021
1030493
Merge pull request #1 from blendededge/feature/paging
winklerj Jul 16, 2021
71fb0f4
Bump yarn from 1.7.0 to 1.22.0
dependabot[bot] Jul 16, 2021
45ec411
Merge pull request #2 from blendededge/dependabot/npm_and_yarn/yarn-1…
winklerj Jul 16, 2021
dc5b602
Update to REST component for saving received data
Jul 26, 2021
98135bc
Added received data to error message for cfg.dontThrowErrorFlg
Jul 30, 2021
bbacb80
Added savedReceivedData to README
Jul 30, 2021
654661a
Merge pull request #4 from blendededge/feature/error-update
kerriannercrawford Jul 30, 2021
7dc818d
Uncommented requestOptions
Jul 30, 2021
05aec17
Merge branch 'master' of https://github.com/blendededge/REST-API-comp…
Jul 30, 2021
f582fd4
Fixed linting issues and issue with the savedReceived data being adde…
Aug 2, 2021
b336114
Uncommented authorization header to fix broken unit test
Aug 2, 2021
f31e645
Merge pull request #5 from blendededge/feature/fix-linting
winklerj Aug 2, 2021
c8aa276
Added jsonataResponseValidator configuration to rebound/delay a reque…
Aug 3, 2021
2cbefc4
Merge pull request #6 from blendededge/feature/rebound-config
winklerj Aug 3, 2021
cddebc1
Added ability to configure which error status codes cause a rebound. …
Aug 3, 2021
fdfad15
Merge pull request #7 from blendededge/feature/rebound-config
winklerj Aug 3, 2021
c2f111d
Fixed the output for the error message
Aug 4, 2021
dddbf78
Merge pull request #8 from blendededge/feature/fix-error-message
kerriannercrawford Aug 4, 2021
8ea3a54
Simplified code and added await to rebound end emit in line with othe…
Aug 5, 2021
a79094b
Refactored to use async await instead of promise. It will be easier t…
Aug 5, 2021
b4374f7
Refactored to prepare for looping through pages on GET request. Check…
Aug 5, 2021
2d1ff62
Added the ability to loop through pages within the component
Aug 6, 2021
6507df0
Updated readme for paging functionality
Aug 6, 2021
020c34d
Merge pull request #9 from blendededge/feature/paging-loop
winklerj Aug 6, 2021
a62be23
Add helper to extract secret credentials from the config object and p…
Aug 11, 2021
473cbab
Added unit test and fixed one issue
Aug 11, 2021
5e409e5
Merge pull request #10 from blendededge/feature/secret-access
winklerj Aug 11, 2021
6eb4c0e
Bump url-parse from 1.5.1 to 1.5.3
dependabot[bot] Aug 11, 2021
19cb8cb
Merge pull request #11 from blendededge/dependabot/npm_and_yarn/url-p…
winklerj Aug 11, 2021
502f517
Changed the assumption that the first page starts at 0 instead of 1. …
Aug 12, 2021
977f356
Merge pull request #12 from blendededge/feature/nextPage-init
winklerj Aug 12, 2021
1680941
Update to paging to allow post requests
Aug 24, 2021
02b87e8
Update to POST url
Aug 24, 2021
4d0aec2
Added request body to test
Aug 24, 2021
f59c614
Merge pull request #13 from blendededge/feature/paging-update-request…
kerriannercrawford Aug 24, 2021
2387a70
Bump axios from 0.21.1 to 0.21.2
dependabot[bot] Sep 17, 2021
ec1a4dc
Merge pull request #14 from blendededge/dependabot/npm_and_yarn/axios…
winklerj Sep 17, 2021
3423165
Merge branch 'openintegrationhub:master' into master
winklerj Sep 17, 2021
7edbda7
Fixed bug where end event emitted after each page instead of when don…
Sep 22, 2021
0268a64
Merge pull request #15 from blendededge/bugfix/snapshot-end-emit
winklerj Sep 22, 2021
d90123a
Updated dependencies
Sep 22, 2021
9aa06ee
Merge pull request #16 from blendededge/bugfix/snapshot-end-emit
winklerj Sep 22, 2021
7710191
Update master.yml
winklerj Oct 4, 2021
e29cb28
Merge pull request #17 from blendededge/workflow-patch-1
winklerj Oct 4, 2021
29bac3d
Update utils.js
winklerj Oct 7, 2021
e693b6f
Merge pull request #18 from blendededge/winklerj-patch-1
winklerj Oct 7, 2021
d6d9a4c
Switch docker build from npm to yarn to reflect lock file, fixed issu…
Oct 7, 2021
e9ccfdd
Merge pull request #19 from blendededge/bugfix/ferryman-version
winklerj Oct 7, 2021
486827d
Reverted changes to master.yml to see if that caused the docker image…
Oct 7, 2021
ff4ee77
Merge pull request #20 from blendededge/bugfix/ferryman-version
winklerj Oct 7, 2021
cc659f9
Removed build cache to fix wrong ferryman library somehow being included
Oct 8, 2021
308f4d5
Merge pull request #21 from blendededge/bugfix/ferryman-version
winklerj Oct 8, 2021
118a331
Update master.yml
winklerj Oct 8, 2021
a5c33e9
Switched ferryman version definition from caret to tilde since versio…
Oct 8, 2021
6e79c24
Merge pull request #22 from blendededge/bugfix/ferryman-version
winklerj Oct 8, 2021
f0efa72
Update master.yml
winklerj Oct 12, 2021
5283f97
Merge pull request #23 from blendededge/build-patch-1
winklerj Oct 12, 2021
dceeada
Update package.json
winklerj Oct 12, 2021
c2d28d2
Update package.json
winklerj Oct 12, 2021
01c9b6e
Merge pull request #24 from blendededge/ferryman-latest-patch-1
winklerj Oct 12, 2021
4c13628
Created separate GitHub Action workflow for tags. It will now ignore …
Oct 12, 2021
351cf59
Merge pull request #25 from blendededge/auto-version
winklerj Oct 13, 2021
110aad8
added snapshot to process method
kerriannercrawford Oct 16, 2021
031954d
Merge pull request #26 from blendededge/add-snapshot
kerriannercrawford Oct 18, 2021
e764ed8
update axios and specify multiple ferryman versions
BirdHighway Nov 8, 2021
50f4f6f
conditional logic for ferryman version
BirdHighway Nov 8, 2021
65999f5
set entrypoint to shell start script
BirdHighway Nov 8, 2021
d60ffc5
specify python2
BirdHighway Nov 8, 2021
6ba1a68
change NODE_EXCHANGE to ELASTICIO_NODE_EXCHANGE
BirdHighway Nov 9, 2021
30d1010
change python2 to python3
BirdHighway Nov 9, 2021
f72ffaf
Merge pull request #27 from blendededge/feature/ferryman-versions
winklerj Nov 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '34 5 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
62 changes: 62 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI to Docker Hub

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Check Out Repo
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
${{ secrets.DOCKER_REPO_PATH }}/rest-api-component-oih
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
61 changes: 61 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI to Docker Hub

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
tags: ['v*.*.*','!v*.*.*-*']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Check Out Repo
uses: actions/checkout@v2
- name: NPM Increment Version
run: npm version from-git
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
${{ secrets.DOCKER_REPO_PATH }}/rest-api-component-oih
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
unit-tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Check Out Repo
uses: actions/checkout@v2

- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 12.x

- name: use cache
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
run: yarn install

- name: Run unit tests
run: yarn test
66 changes: 0 additions & 66 deletions CHANGELOG.md

This file was deleted.

8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:10-alpine AS base
FROM node:12-alpine AS base
RUN apk --no-cache add \
python \
python3 \
make \
g++ \
libc6-compat
Expand All @@ -9,11 +9,11 @@ WORKDIR /usr/src/app

COPY package.json /usr/src/app

RUN npm install --production
RUN yarn install --production

COPY . /usr/src/app

RUN chown -R node:node .

USER node
ENTRYPOINT ["node", "./node_modules/@openintegrationhub/ferryman/runGlobal.js"]
ENTRYPOINT ["./start.sh"]
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@ _Numbers show: (1) The URL and method of the REST API resource, (2) the HTTP cal
- 504: Gateway Timeout
- DNS lookup timeout

4. `Do not verify SSL certificate (unsafe)` - disable verifying the server certificate - **unsafe**.
5. `Follow redirect mode` - If you want disable Follow Redirect functionality, you can use option `Follow redirect mode`.By default `Follow redirect mode` option has value `Follow redirects`.
6. `Delay` - If you want to slow down requests to your API you can set delay value (in seconds) and the component will delay calling the next request after the previous request.
- `Do not verify SSL certificate (unsafe)` - disable verifying the server certificate - **unsafe**.
- `Follow redirect mode` - If you want disable Follow Redirect functionality, you can use option `Follow redirect mode`.By default `Follow redirect mode` option has value `Follow redirects`.
- `Delay` - If you want to slow down requests to your API you can set delay value (in seconds) and the component will delay calling the next request after the previous request.
Time for the delay is calculated as `Delay`/ `Call Count` and shouldn't be more than 1140 seconds (19 minutes due to platform limitation).
The `Call Count` value by default is 1. If you want to use another value, please set the `Call Count` field.
Notice: See [Known Limitations](#known-limitations) about `Delay` value.
7. `Call Count` - the field should be used only in pair with `Delay`, default to 1.
8. `Request timeout` - Timeout period in milliseconds (1-1140000) while component waiting for server response, also can be configured with REQUEST_TIMEOUT environment variable if configuration field is not provided. Defaults to 100000 (100 sec).
- `Call Count` - the field should be used only in pair with `Delay`, default to 1.
- `jsonataResponseValidator` - This works in coordination with the `enableRebound` configuration to throw a status code 429. When this JSONata configuration is present and `enableRebound` set to `true`, it is assumed the JSONata will resolve to a boolean. If the boolean is false the incoming component message will be requeued and tried again. Otherwise the response will be processed as it normally would.
- `httpReboundErrorCodes` - Array of error status codes from the API response object which will cause the request to be put in the rebound queue. Messages in the rebound queue will be retried at a progressively longer interval (15 sec, 30 sec, 1 min, 2 min, 4 min, 8 min, etc.). Setting this value will override default values [408, 423, 429, 500, 502, 503, 504]. You should include those status codes unless you have a reason not to.
- `Request timeout` - Timeout period in milliseconds (1-1140000) while component waiting for server response, also can be configured with REQUEST_TIMEOUT environment variable if configuration field is not provided. Defaults to 100000 (100 sec).

Notice: Specified for component REQUEST_TIMEOUT enviroment variable would be overwritten by specified value of Request timeout, default value would be also overwritten
- `responseToSnapshotTransform` - This is a JSONata applied to the REST response body and stored in the snapshot as an object.

- `Snapshot in URL tranform` - If a snapshot value is available it is added into the msg.data object as `msg.data.oihsnapshot`. This can be used in conjuction with the `responseToSnapshotTransform` to perform paging. You can save information for the next page from the response in the snapshot and then use the snapshot information in the next request URL.

- `Save Received Data` - If enabled, returned message will include the data received by the REST component and the resulting data.

## Authorisation methods

Expand All @@ -69,6 +77,19 @@ REST API component supports 4 authorisation types:

Please note that the result of creating a credential is an HTTP header automatically placed for you. You can also specify the authorisation in the headers section directly.

### Secret Service Integration

To securely retrieve credentials from the secret service ferryman will inject a secret object by specifying the `credential_id` at the top level of a component configuration in a flow. The `credential_id` should be a secret service secret ID.

The secret service can currently support these secret types:
- SIMPLE - Constains a `username` and `passphrase` and will be used for `Basic Auth`
- MIXED - The `payload` of this type is a stringified JSON object. The `payload` string is parsed into an object before being added to the component config object. Because of the flexible nature of this type a JSONata transformation config is provided `secretAuthTransform`. The output of this transformation will replace the `config.auth` configuration. The `secretAuthTransform` will work for tranforming the data for other types but isn't necessary since the other secret types have well-defined structure.
- API_KEY - Contains a `key` and `headerName` and will be used for `API Key Auth`
- OA1_TWO_LEGGED - Contains `expiresAt`
- OA1_THREE_LEGGED - Contains `accessToken` which will be sent as a Bearer Token in the request header
- OA2_AUTHORIZATION_CODE - Contains `accessToken` which will be sent as a Bearer Token in the request header
- SESSION_AUTH - Contains `accessToken` which will be sent as a Bearer Token in the request header

### Sending JSON data

Here is how to send a JSON data in the body. Change the **content type** to `application/json` and the **body input part** would change accordingly to accept JSON object. Please note that this field supports [JSONata](http://jsonata.org) expressions.
Expand All @@ -89,3 +110,12 @@ In this case output structure of component will be:
statusMessage:<HTTP response status message>
}
```
## Trigger Paging

The component has the ability to loop through pages in one run of the trigger or handle only one page per trigger. If only doing one page of data per trigger you will even out the amount of data over time. You request whatever the page size at each trigger. If looping through all of the pages in one trigger, you will have uneven payload sizes sent through the flow but can expect to get all of the data sooner.

The options for configuraing one page per trigger are part of the general configurations above. For paging within one trigger of the component the following options are available:

- `enablePaging` - This must be enabled for the paging to work
- `responseToSnapshotTransform` - See above and look at paging unit tests for an example. This allows you to extract and build nextPage information for the next iterations url JSONata
- `lastPageValidator` - JSONata applied to the response which evaluates to a boolean. This JSONata determines whether there is a nextPage or stop iterating pages.
Loading