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
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
parameters:
node-version:
type: string
default: "18.13.0"
default: "24.10.0"
orbs:
node: circleci/node@5.0.0
slack: circleci/slack@4.5.3
Expand Down Expand Up @@ -72,7 +72,7 @@ commands:
jobs:
test:
docker: # run the steps with Docker
- image: cimg/base:stable
- image: cimg/node:24.10.0
steps:
- checkout
- node/install:
Expand All @@ -88,14 +88,14 @@ jobs:
command: npm test
build:
docker:
- image: cimg/base:stable
- image: cimg/node:24.10.0
user: root
steps:
- checkout
- node/install:
node-version: << pipeline.parameters.node-version >>
- setup_remote_docker:
version: 19.03.13
version: remote
docker_layer_caching: true
# build and push Docker image
- run:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ build/Release
node_modules

.idea/
.vscode
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.3.0 (March 05, 2026)

* Removed legacy `elasticio-node` dependency and transitioned to local utilities
* **Modernized Runtime**: Updated Node.js engine from **18.x** to **24.x**.
* **Dependency Upgrades**:
* `elasticio-sailor-nodejs`: 2.7.1 -> 2.7.8

## 1.2.0 (June 30, 2023)

* Added 'Start Time' and 'End Time' configuration fields to limit polling range
Expand Down
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
# Simple trigger Component
# Simple Trigger Component

A lightweight and efficient component designed to trigger integration flows on a scheduled basis without requiring external data sources. Ideal for heartbeat signals, periodic tasks, or orchestrating flows that don't depend on incoming data payloads.

## Table of Contents

* [Description](#description)
* [Actions](#actions)
* [Triggers](#triggers)
* [Simple trigger](#simple-trigger)
- [Overview](#overview)
- [Features](#features)
- [Triggers](#triggers)
- [Simple Trigger](#simple-trigger)

## Description
## Overview

A component used to trigger integration flows without requesting data from any services.
The Simple Trigger Component provides a reliable way to initiate elastic.io platform flows. It emits a message containing the current execution time and the timestamp of the previous successful execution, allowing for time-windowed logic in subsequent steps.

## Actions
## Features

None.
- **Time-Windowed Triggers:** Leverages snapshots to track polling history.
- **Configurable Range:** Set specific start and end boundaries for trigger activation.
- **Offset Support:** Automatically defaults to the beginning of Unix time if no prior state exists.

## Triggers
## Triggers

### Simple trigger
### Simple Trigger

Send message with information when this and previous message was send
The primary trigger that emits a heartbeat message with polling metadata.

#### Configuration Fields
* **Start Time** - (string, optional): The timestamp to start sending messages from (inclusive) - using ISO 8601 Date time utc format - YYYY-MM-DDThh:mm:ss.sssZ. Default value is the beginning of time (January 1, 1970 at 00:00).
* **End Time** - (string, optional): The timestamp to stop sending messages (exclusive) - using ISO 8601 Date time utc format - YYYY-MM-DDThh:mm:ss.sssZ. Default to never.


#### Input Metadata

None.
| Field | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **Start Time** | String | No | The ISO 8601 timestamp to start sending messages (e.g., `2023-01-01T00:00:00.000Z`). Defaults to `1970-01-01T00:00:00.000Z`. |
| **End Time** | String | No | The ISO 8601 timestamp to stop sending messages. Once reached, the trigger will cease emitting data. |

#### Output Metadata

* **fireTime** - (string, required): The timestamp when trigger was executed in ISO 8601 Date time format - YYYY-MM-DDThh:mm:ss.sssZ.
* **lastPoll** - (string, required): Previous execution timestamp in ISO 8601 Date time utc format - YYYY-MM-DDThh:mm:ss.sssZ
Each emitted message contains the following body fields:

- **fireTime:** (String) The exact UTC timestamp when the trigger was executed.
- **lastPoll:** (String) The timestamp of the previous successful execution (or the `Start Time` if it's the first run).
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Simple trigger",
"version": "1.2.0",
"version": "1.3.0",
"description": "A component used to trigger integration flows without requesting data from any services.",
"buildType": "docker",
"triggers": {
Expand Down
24 changes: 24 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const js = require('@eslint/js');
const globals = require('globals');

module.exports = [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2024,
sourceType: 'commonjs',
globals: {
...globals.node,
...globals.mocha,
},
},
rules: {
'no-unused-expressions': 'off',
// Simulating some essential Airbnb rules if needed,
// but keeping it simple for now to ensure tests pass.
'indent': ['error', 2],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
},
},
];
7 changes: 2 additions & 5 deletions lib/trigger.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const { messages } = require('elasticio-node');
const util = require('./utils/utils');

const isDebugFlow = process.env.ELASTICIO_FLOW_TYPE === 'debug';

async function simpleTrigger(msg, cfg, snapshot = {}) {
const isDebugFlow = process.env.ELASTICIO_FLOW_TYPE === 'debug';
const now = new Date().getTime();
this.logger.info('Trigger execution started');
if (cfg.startTime) util.validateISODate(cfg.startTime);
Expand Down Expand Up @@ -32,7 +29,7 @@ async function simpleTrigger(msg, cfg, snapshot = {}) {
fireTime: new Date(now),
lastPoll,
};
await this.emit('data', messages.newMessageWithBody(body));
await this.emit('data', util.newMessageWithBody(body));
await this.emit('snapshot', newSnapshot);
this.logger.info('Message emitted. Execution finished.');
}
Expand Down
10 changes: 10 additions & 0 deletions lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@ exports.validateISODate = (date) => {
const isoDatePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
if (!isoDatePattern.test(date)) throw new Error(`Date ${date} must be in ISO format (1970-01-01T00:00:00.000Z)`);
};

exports.newMessageWithBody = (body) => ({
body,
headers: {},
});

exports.newEmptyMessage = () => ({
body: {},
headers: {},
});
Loading