Skip to content

Commit 1fb9aa0

Browse files
authored
Revitalize (#68)
1 parent a40e71a commit 1fb9aa0

File tree

19 files changed

+3468
-6902
lines changed

19 files changed

+3468
-6902
lines changed

.circleci/config.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2.1
22
parameters:
33
node-version:
44
type: string
5-
default: "16.13.2"
5+
default: "20.16.0"
66
orbs:
77
node: circleci/node@5.0.0
88
slack: circleci/slack@4.5.3
@@ -72,30 +72,30 @@ commands:
7272
jobs:
7373
test:
7474
docker:
75-
- image: circleci/node:14-stretch
75+
- image: cimg/node:20.16.0
7676
steps:
7777
- checkout
7878
- node/install:
7979
node-version: << pipeline.parameters.node-version >>
80-
- run:
81-
name: Audit Dependencies
82-
command: npm audit --audit-level=high
8380
- node/install-packages:
8481
cache-path: ./node_modules
8582
override-ci-command: npm install
83+
- run:
84+
name: Audit Dependencies
85+
command: npm audit --production --audit-level=high
8686
- run:
8787
name: Running Mocha Tests
8888
command: npm test
8989
build:
9090
docker:
91-
- image: circleci/node:14-stretch
91+
- image: cimg/node:20.16.0
9292
user: root
9393
steps:
9494
- checkout
9595
- node/install:
9696
node-version: << pipeline.parameters.node-version >>
9797
- setup_remote_docker:
98-
version: 19.03.13
98+
version: default
9999
docker_layer_caching: true
100100
# build and push Docker image
101101
- run:
@@ -118,8 +118,10 @@ workflows:
118118
jobs:
119119
- build:
120120
name: "Build and publish docker image"
121+
context:
122+
- componentspusher
121123
filters:
122124
branches:
123125
ignore: /.*/
124126
tags:
125-
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
127+
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/

.eslintrc.js

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,61 @@
11
module.exports = {
2-
'extends': 'airbnb-base',
3-
'env': {
4-
'mocha': true,
5-
'node': true,
6-
}
2+
env: {
3+
es6: true,
4+
node: true,
5+
mocha: true,
6+
},
7+
extends: [
8+
'airbnb-base',
9+
],
10+
globals: {
11+
Atomics: 'readonly',
12+
SharedArrayBuffer: 'readonly',
13+
},
14+
parser: '@typescript-eslint/parser',
15+
parserOptions: {
16+
ecmaVersion: 2018,
17+
sourceType: 'module',
18+
},
19+
plugins: [
20+
'@typescript-eslint',
21+
],
22+
rules: {
23+
'linebreak-style': 0,
24+
'import/no-extraneous-dependencies': ["error", { "devDependencies": ["spec/**/*", "spec-integration/**/*"] }],
25+
'no-plusplus': 0,
26+
'no-unused-vars': 0,
27+
'no-await-in-loop': 0,
28+
'no-restricted-syntax': 0,
29+
'prefer-default-export': 0,
30+
'import/prefer-default-export': 0,
31+
'import/no-import-module-exports': 0,
32+
'class-methods-use-this': 1,
33+
'max-len': ['error', { code: 240 }],
34+
'no-param-reassign': 1,
35+
'no-return-assign': 1,
36+
'no-use-before-define': 0,
37+
"comma-dangle": 0,
38+
"object-curly-newline": 0,
39+
camelcase: 0,
40+
'import/extensions': [
41+
'error',
42+
'ignorePackages',
43+
{
44+
js: 'never',
45+
jsx: 'never',
46+
ts: 'never',
47+
tsx: 'never',
48+
},
49+
],
50+
},
51+
settings: {
52+
'import/parsers': {
53+
'@typescript-eslint/parser': ['.ts', '.tsx'],
54+
},
55+
'import/resolver': {
56+
node: {
57+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
58+
},
59+
},
60+
},
761
};

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.0.0 (January 13, 2025)
2+
* Update Sailor version to 2.7.4
3+
* Removed deprecated action `Send data`
4+
* Removed unnecessary dependencies
5+
* Code migrated to TypeScript (TS)
6+
* Revitalized README
7+
18
## 1.2.12 (November 04, 2022)
29
* Update Sailor version to 2.7.1
310

README.md

Lines changed: 38 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# webhook-component
1+
# Webhook Component
22
## Table of Contents
33

4-
* [General information](#general-information)
5-
* [Description](#description)
6-
* [Purpose](#purpose)
4+
* [Description](#description)
75
* [Credentials](#credentials)
86
* [Triggers](#triggers)
97
* [Receive](#receive)
@@ -12,75 +10,47 @@
1210
* [Known Limitations](#known-limitations)
1311

1412
## Description
15-
### Purpose
16-
An open source component for sending and receiving [WebHooks](https://en.wikipedia.org/wiki/Webhook) on [elastic.io platform](https://www.elastic.io "elastic.io platform").
13+
The Webhook component receives data at the specified URL to initiate your workflow.
1714

1815
## Credentials
19-
Webhook component supports the following authorisation types:
20-
* **No Auth** - use this method to work with any open REST API
21-
* **Basic Auth** - use it to provide login credentials like username/password
22-
* **API Key Auth** - use it to provide API Key to access the resource
23-
* **HMAC verification shared secret** - use it to verify via a shared secret
24-
25-
![Webhook Credentials](https://user-images.githubusercontent.com/8449044/61962330-ec5c2c00-afd1-11e9-8e5f-6a1c89126034.png)
16+
The Webhook component supports the following authorization methods:
17+
18+
* **No Auth** - Use this method to interact with any open REST API.
19+
* **Basic Auth** - Utilize this method to provide login credentials. This method includes the following fields:
20+
* **Username** - (string, required)
21+
* **Password** - (string, required)
22+
* **API Key Auth** - Use this method to provide an API key as part of the headers to access the resource. This method includes the following fields:
23+
* **Header Name** - (string, required)
24+
* **Header Value** - (string, required)
25+
* **HMAC (sha256/sha512) verification with shared secret** - Use this method to verify requests using a shared secret. This method includes the following fields:
26+
* **Header Name** - (string, optional, defaults to `x-eio-signature`)
27+
* **HMAC (sha256/sha512) verification shared secret** - (string, required)
2628

2729
## Triggers
28-
### Receive
29-
Simple webhook trigger which receives data as an input and starts the flow execution after this.
30-
31-
#### Expected output metadata
32-
[Output schema](lib/schemas/base64.out.json)
33-
34-
Example:
35-
```metadata json
30+
### Receive
31+
This is a simple webhook trigger that receives data as input and initiates the execution of the workflow.
32+
33+
#### Output Metadata
34+
The message body emitted from the webhook will contain:
35+
* A JSON object that was transferred using the `POST` method or query parameters in the case of a `GET` request.
36+
* `_query` (object) - Contains the query parameters.
37+
* `_headers` (object) - Contains the headers of the received request.
38+
* `_method` (string, `POST` or `GET`) - Indicates the HTTP method of the received request.
39+
* `_url` (string) - The full URL that was received.
40+
41+
#### Webhook Response
42+
By default, the webhook URL will respond with the following structure:
43+
```json
3644
{
37-
"recievedBody": "recievedBody",
38-
"_query": {},
39-
"_headers": {
40-
"content-type": "application/json",
41-
"accept": "*/*",
42-
"accept-encoding": "gzip, deflate"
43-
},
44-
"_method": "POST",
45-
"_url": "/hook/5d691738cb5a286adc1e68e2"
46-
}
45+
"requestId": "86ad47dfbce4a8ae8a1eb505b85d8bd5",
46+
"message": "thank you"
47+
}
4748
```
4849

49-
## Actions
50-
### Send data
51-
Simply sends data it receives as an input to a URL provided.
52-
53-
WebHook action can also be used to troubleshoot many processes to see the outcome.
54-
For example one could create Invoices (in Salesforce) to Webhook flow and configure the Webhook with a url created in https://webhook.site or with any similar services.
55-
56-
#### List of Expected Config fields
57-
* **[required]** **HTTP Verb**
58-
* **POST**. The WebHook component can POST information to preconfigured WebHook address. This action could be used for different purposes. For example WebHook can be used to inform your custom connector about an event which it waits to work.
59-
* **PUT**. The WebHook component can also PUT a specific preconfigured JSON into specific address where the process will not be handled by the server. For this reason the "Output JSON Sample" field can be used.
60-
* **[required]** **URI**. This is the address to send WebHook.
61-
* **[not required]** **Secret**. This is an optional field to authenticate WebHook POST. There maybe cases when a special password or a secret might be required. For example the WebHook address was generated explicitly with a password so that to prevent any third parties to use it. This could be your specific WebHook address that you use to send your Wordpress posts into your server.
62-
63-
![Send Data config fields](https://user-images.githubusercontent.com/8449044/61964168-eff1b200-afd5-11e9-8928-2890c3360d13.png)
64-
65-
#### Expected output metadata
66-
[Output schema](lib/schemas/base64.out.json)
67-
68-
Example:
69-
```metadata json
70-
{
71-
"recievedBody": "recievedBody",
72-
"_query": {},
73-
"_headers": {
74-
"content-type": "application/json",
75-
"accept": "*/*",
76-
"accept-encoding": "gzip, deflate"
77-
},
78-
"_method": "POST",
79-
"_url": "/hook/5d691738cb5a286adc1e68e2"
80-
}
81-
```
82-
83-
## Known limitations
50+
However, you can specify the exact content of the reply using the [HTTP Reply](https://docs.elastic.io/components/request-reply/index.html) component. In this case, you will receive a reply only when the message reaches the step where the `HTTP Reply` is used, or if an error occurs in other steps between the `Webhook` step and the `HTTP Reply`.
8451

85-
1. Maximal possible size for an attachment is 10 MB.
86-
2. Attachments mechanism does not work with [Local Agent Installation](https://support.elastic.io/support/solutions/articles/14000076461-announcing-the-local-agent-)
52+
## Known Limitations
53+
* Currently, the component supports the following HTTP methods: `POST` and `GET`.
54+
* When using a `POST` request, only `JSON` or `XML` data can be transferred to the workflow; other types, such as text or files, are not supported.
55+
* `XML` data will be automatically converted to `JSON` format.
56+
* The base path of the URL begins with the keyword `hook` followed by the flow ID, for example, `/hook/678119de28021e00129641fe`. You can append the desired path only after this base path, such as `/hook/678119de28021e00129641fe/sales/orders`.

component.json

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "Webhook",
3-
"version": "1.2.12",
3+
"version": "2.0.0",
44
"description": "Webhooks allow you to collect information about events as they happen in near real-time. Provide a URL, select when and where you want that URL to receive data about events on your list, and we'll send it to you as the events take place. It is recommended that you specify a URL using https.",
55
"service": "webhook",
66
"docsUrl": "https://github.com/elasticio/webhook-component",
@@ -19,57 +19,12 @@
1919
"description": "Receives data from an external system to a given URL to start a new execution of the flow. Each incoming request results in a new execution.",
2020
"link": "/components/webhook/index.html#receive"
2121
},
22-
"main": "./lib/triggers/receive.js",
22+
"main": "./src/triggers/receive.js",
2323
"metadata": {
2424
"in": {},
25-
"out": "./lib/schemas/metadata.out.json"
25+
"out": "./src/schemas/receive.out.json"
2626
}
2727
}
2828
},
29-
"actions": {
30-
"post": {
31-
"title": "Send data",
32-
"help": {
33-
"description": "Sends data to a provided URL.",
34-
"link": "/components/webhook/index.html#send-data"
35-
},
36-
"main": "./lib/actions/send.js",
37-
"deprecated": true,
38-
"fields": {
39-
"method": {
40-
"viewClass": "SelectView",
41-
"label": "HTTP Verb",
42-
"prompt": "Please select",
43-
"required": true,
44-
"model": {
45-
"POST": "POST",
46-
"PUT": "PUT"
47-
},
48-
"help": {
49-
"description": "Used to specify the HTTP request method for the given URI."
50-
}
51-
},
52-
"uri": {
53-
"viewClass": "TextFieldView",
54-
"label": "URI",
55-
"required": true,
56-
"help": {
57-
"description": "The URI to send data to."
58-
}
59-
},
60-
"secret": {
61-
"viewClass": "TextFieldView",
62-
"label": "Secret",
63-
"required": false,
64-
"help": {
65-
"description": "May be used to prove the identity of the request sender. The value provided into this field will be sent as 'X-Api-Secret' HTTP header which may be checked on the receiving system."
66-
}
67-
}
68-
},
69-
"metadata": {
70-
"in": {},
71-
"out": "./lib/schemas/metadata.out.json"
72-
}
73-
}
74-
}
29+
"actions": {}
7530
}

lib/actions/send.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/helper/get.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)