Socket
Socket
Sign inDemoInstall

@clausehq/flows-analysis

Package Overview
Dependencies
Maintainers
8
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clausehq/flows-analysis - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

20

__tests__/validation.js

@@ -59,2 +59,12 @@ const { validation } = require('../index');

});
test('scheduled trigger flow, to be ran periodically, each 20 minutes with a set timezone', () => {
expect(validation.triggerType(
{
$class: 'io.clause.flows.trigger.Schedule',
type: 'periodic',
interval: '20 minutes',
timezone: 'Asia/Gaza',
}
)).toBe(true);
});
test('scheduled trigger flow, to be ran periodically, each 20 minutes (CRON expression)', () => {

@@ -157,3 +167,13 @@ expect(validation.triggerType(

});
test('scheduled trigger flow, to be ran periodically, with an invalid timezone', () => {
expect(() => validation.triggerType(
{
$class: 'io.clause.flows.trigger.Schedule',
type: 'periodic',
interval: '20 minutes',
timezone: 'Europe/Foobaristan'
}
)).toThrow();
});
});
});

27

lib/validation.js
const humanInterval = require('human-interval');
const dayjs = require('dayjs');
const cronParser = require('cron-parser');
const utc = require('dayjs/plugin/utc'); // dependent on utc plugin
const timezone = require('dayjs/plugin/timezone');
dayjs.extend(utc);
dayjs.extend(timezone);
const PERIODIC_INTERVAL_MINIMUM_MS = 1000 * 60 * 10;

@@ -61,3 +66,3 @@

const validateTypePeriodic = ({ interval }) => {
const validateTypePeriodicInterval = ({ interval }) => {
if (isHumanIntervalValid(interval)) {

@@ -86,2 +91,22 @@ if (humanInterval(interval) < PERIODIC_INTERVAL_MINIMUM_MS) {

const validateTypePeriodicTimezone = ({ timezone }) => {
if (timezone && typeof timezone === 'string') {
try {
dayjs().tz(timezone);
return true;
} catch (err) {
if (err.message.includes('Invalid time zone specified')) {
throw buildValidationError(
`Invalid timezone: ${timezone}.`
);
}
throw err;
}
}
return true;
};
const validateTypePeriodic = ({ interval, timezone }) => validateTypePeriodicInterval({ interval })
&& validateTypePeriodicTimezone({ timezone });
const validateScheduledFlowTriggerType = triggerType => {

@@ -88,0 +113,0 @@ if (typeof triggerType.type !== 'string' || typeof triggerType.interval !== 'string') {

2

package.json
{
"name": "@clausehq/flows-analysis",
"version": "0.1.4",
"version": "0.1.5",
"description": "A utility for doing static analysis on flows",

@@ -5,0 +5,0 @@ "license": "UNLICENSED",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc