Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- node/install:
node-version: << pipeline.parameters.node-version >>
- setup_remote_docker:
version: 19.03.13
version: default
docker_layer_caching: true
# build and push Docker image
- run:
Expand Down
15 changes: 15 additions & 0 deletions .grype-ignore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ignore:
- vulnerability: CVE-2023-2650
package:
name: libssl3
version: 3.1.0-r4

- vulnerability: CVE-2023-2650
package:
name: libcrypto3
version: 3.1.0-r4

- vulnerability: CVE-2023-45853
package:
name: zlib
version: 1.3.1-r2
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.1.0 (November 19, 2025)

* Updated dependencies to the latest versions
* Removed unused `request` and `bunyan` dependencies
* Refactored the code to remove `elasticio-node` dependency to fix security vulnerabilities
* Improved `README.md`

## 1.0.13 (March 22, 2024)

* Updated Sailor version to 2.7.2
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18-alpine AS base
RUN apk add --update git tini python3 make g++ && rm -rf /var/cache/apk/*
WORKDIR /home/node
COPY --chown=node:node . ./
FROM base AS dependencies
ENV LOG_OUTPUT_MODE=short
USER node
RUN npm config set update-notifier false
RUN npm install --no-audit
RUN npm test
RUN npm prune --production
RUN rm -rf spec* .circleci README.md LICENSE .idea
FROM node:18-alpine AS release
LABEL elastic.io.component="{\"title\":\"Transformation\",\"version\":\"1.0.13\",\"description\":\"Generic Data Transformation Component\",\"docsUrl\":\"https://docs.elastic.io/components/jsonata/index.html\",\"actions\":{\"transform\":{\"title\":\"Transform\",\"main\":\"./lib/actions/transform.js\",\"fields\":{\"expression\":{\"label\":\"JSONata Expression\",\"required\":true,\"viewClass\":\"JSONataView\"}},\"metadata\":{\"out\":{}}}},\"sailor_version\":\"2.7.7\",\"language\":\"nodejs\"}"
LABEL elastic.io.logo="iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAAXNSR0IArs4c6QAAAvdQTFRFAAAAAAAAAICAVVVVAFVVQEBAMzMzJ01VK05VKFFXJ05VJVFXJlFRKlNTKFBVKFBUKlBUKVJVKE9TKVFUKFFTKVFUKFBUJ1BUKFFUKFFVKFFTJ1FUKFFUKFJVKFBVKFFUKFJUKFBUKFFVKFBUKFFUKFFTKFFUKFJUKFJUKFFUKFFUKFFUKFJUKFFUKFFUJ1FUKFFUKFFU/////v////7+/v7//f7+/v3+/f3+/f39/P39/Pz8+vv7+fr6+Pn59vj49vf49fb39Pb29PX29PX18vX18vT08fT08fPz8PLy7fDw6+7u6u3t6ezs5+vr5urq5Onp4+fn4ubn4OTl3uPj3OHh2t7f2d7e2N7e1tzc0tfY0NbWztTVzNPTy9LSytHRyM/Qxs3OxcvLwcjJv8fHvsbGvsXGvMTFu8LCucHBs7u8sLq7rbi5q7a3p7GypK+woq2voaytoKusnamqmqaomKWmlaOjlKKjkqChkZ+gjpydipmaiZiahJaXgpKUf5CSfI+ReoyOeIuMeIqLdomKdIeIcISGboKEbIGCaX+BZ36AYXl6X3d5XHR2WXN0VXByUm5wUGxuT2tuTmttUGhrSWhrSmRnQ2RmR2JlQ2BjQmBiQF5hO2BjOV5gOVlbNFtdM1pcNlhaNldaNVdaNFdaNFdZM1daNFZZM1ZZLlhbMlZZMFZZMlVYLVdaMVVYLlZZMFVYK1daLVZZK1ZaK1ZZL1RXKlZZLVRXKlVZKlVYLlNWLVNWLFNWKVRXK1NVLFJVKVNWK1JVKlJVKVJWKVJVK1FUKFJVKVFUKFFVKFFUJ1FUJVFUJ1BTJk9SJU9SHFFUI05RIE1QHUxQHUxPHExPG0xPG0tOEk1RF0pOF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xrdzoad5+SaJuWHVJMl9+cxgM+idSLQCf7N2R5APja7H+66uypXpURuLSOwDzMPtNld/f/tibwil9fiJn10ri07mvnzr4XbzeL8t/I5FJrykHr/saE16TNvYzHi/rYBDcsTN+zsWW+GnBMfXnLXxnxg2AYcWIx4GlexWrRkvpvEeEE4N+bP6rEzbVjQT8Wg55KK9W7N9kQUPIZy28kalPtIGnl3IpcWYjzZr60Ir/IxVd4zpUTbwLGM+LQad9IqiD814KY33X1tQniq3tfdsg04tR70UpWvFksd4yaz1xSVkjJ4dw3bUy0bYTR9b6g+9IPQKCC0rjlW0Ix4JT1vCbkzcTydo2oKSbyEcFbilslCuQO1ZAh0T97PsgqNOQzRz/g2Yu606PzoOtWsRFBN4ZAxeaCbySWWdKc2PItkCbEc+e5j5tkOvWhTLBs8p9MoY2DUT+9Xq2QI4xn65B5+ZYhF8/m9Gv/GE37HH//8F6XCXjUwsUQEAAAAASUVORK5CYII="
WORKDIR /home/node
COPY --from=base --chown=node:node /sbin/tini /sbin/tini
COPY --from=dependencies --chown=node:node /home/node /home/node
USER node
ENTRYPOINT ["/sbin/tini", "-v", "-e", "143", "--"]
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# jsonata-transform-component [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
> Dedicated data transformation component for elastic.io platform based on JSONata
# JSONata Transform Component [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]

> A dedicated data transformation component for the elastic.io platform that is based on JSONata.

## Authentication

This component requires no authentication.

## How it works

This component takes the incoming message body and applies the configured JSONata tranformation on it. It uses
a fact that JSONata expression is a superset of JSON document so that by default any valid JSON document is
a valid JSONata expression.
This component takes the incoming message body and applies the configured JSONata transformation to it. It uses the fact that a JSONata expression is a superset of a JSON document, so by default, any valid JSON document is a valid JSONata expression.

For example let's take this sample incoming message body:
For example, let's take this sample incoming message body:

```json
{
Expand Down Expand Up @@ -56,7 +55,7 @@ For example let's take this sample incoming message body:
}
```

You can use following JSONata expressions to transform it:
You can use the following JSONata expression to transform it:

```jsonata
{
Expand All @@ -65,7 +64,7 @@ You can use following JSONata expressions to transform it:
}
```

result of that transofrmation will be the following JSON document ([jsonata link](http://try.jsonata.org/B1ctn36ub)):
The result of that transformation will be the following JSON document ([JSONata link](http://try.jsonata.org/B1ctn36ub)):

```json
{
Expand All @@ -87,7 +86,7 @@ I hope you've got the idea. Now you can also do something more complicated, like
}
```

resulting in ([jsonata link](http://try.jsonata.org/B1ctn36ub)):
Resulting in ([JSONata link](http://try.jsonata.org/B1ctn36ub)):

```json
{
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Transformation",
"version": "1.0.13",
"version": "1.1.0",
"description": "Generic Data Transformation Component",
"docsUrl": "https://docs.elastic.io/components/jsonata/index.html",
"actions": {
Expand Down
6 changes: 3 additions & 3 deletions lib/actions/transform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const eioUtils = require('elasticio-node').messages;
const { JsonataTransform } = require('@elastic.io/component-commons-library');
const { messages } = require('../utils');

/**
* This method will be called from elastic.io platform providing following data
Expand Down Expand Up @@ -27,13 +27,13 @@ async function processAction(msg, cfg) {
// eslint-disable-next-line no-restricted-syntax
for (const item of result) {
// eslint-disable-next-line no-await-in-loop
await this.emit('data', eioUtils.newMessageWithBody(item));
await this.emit('data', messages.newMessageWithBody(item));
}

return Promise.resolve();
}
this.logger.info('1 message will be send to the next step');
return Promise.resolve(eioUtils.newMessageWithBody(result));
return Promise.resolve(messages.newMessageWithBody(result));
}

module.exports.process = processAction;
4 changes: 4 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports.messages = {
newMessageWithBody: (body) => ({ body, headers: {} }),
newEmptyMessage: () => ({ body: {}, headers: {} }),
};
Loading