Socket
Socket
Sign inDemoInstall

node-red-contrib-sun-position

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-sun-position - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

5

CHANGELOG.md
# node-red-contrib-sun-position
#### 1.1.6: BugFix
- general
- reworked JSONATA (preparation is now done on node creation)
#### 1.1.5: BugFix

@@ -4,0 +9,0 @@

3

nodes/locales/en-US/position-config.json

@@ -315,3 +315,4 @@ {

"notEvaluablePropertyAdd":"Error \"__err__\", could not evaluate __type__.__value__",
"invalidParameter":"Parameter \"__param__\" is invalid \"__type__\" (using __newValue__)"
"invalidParameter":"Parameter \"__param__\" is invalid \"__type__\" (using __newValue__)",
"invalid-expr": "Invalid JSONata expression: __error__"
},

@@ -318,0 +319,0 @@ "position-config": {

@@ -20,2 +20,37 @@ /********************************************

// this.debug('initialize time Node ' + util.inspect(config, { colors: true, compact: 10, breakLength: Infinity }));
this.input = {
type: config.inputType,
value: config.input,
format: config.inputFormat,
offsetType: config.inputOffsetType,
offset: config.inputOffset,
multiplier: config.inputOffsetMultiplier
};
this.result1 = {
type : config.result1Type,
value : config.result1,
format : config.result1Format
};
this.result1Value = {
type: config.result1ValueType,
value: config.result1Value,
format: config.result1Format,
offsetType: config.result1OffsetType,
offset: config.result1Offset,
multiplier: config.result1Multiplier,
next: true
};
if (this.positionConfig && this.result1Value.type === 'jsonata') {
try {
this.result1Value.expr = this.positionConfig.getJSONataExpression(this, this.result1Value.value);
} catch (err) {
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error:err.message }));
this.result1Value.expr = null;
}
}
this.rules = config.rules;
this.checkall = config.checkall;
const node = this;

@@ -30,4 +65,4 @@

typeof node.positionConfig === 'undefined' ||
config.inputType === null ||
typeof config.inputType === 'undefined') {
node.input.type === null ||
typeof node.input.type === 'undefined') {
node.status({

@@ -42,11 +77,4 @@ fill: 'red',

try {
// const inputData = node.positionConfig.getDateFromProp(node, msg, config.inputType, config.input, config.inputFormat, config.inputOffset, config.inputOffsetType, config.inputOffsetMultiplier);
const inputData = node.positionConfig.getTimeProp(node, msg, {
type: config.inputType,
value: config.input,
format: config.inputFormat,
offsetType: config.inputOffsetType,
offset: config.inputOffset,
multiplier: config.inputOffsetMultiplier
});
// const inputData = node.positionConfig.getDateFromProp(node, msg, node.input.type, node.input.value);
const inputData = node.positionConfig.getTimeProp(node, msg, node.input);
if (inputData.error) {

@@ -56,24 +84,16 @@ throw new Error(inputData.error);

if (config.result1Type !== 'none') {
if (node.result1.type !== 'none') {
let resultObj = null;
if (config.result1ValueType === 'input') {
resultObj = hlp.getFormattedDateOut(inputData.value, config.result1Format);
if (node.result1Value.type === 'input') {
resultObj = hlp.getFormattedDateOut(inputData.value, node.result1.format);
} else {
resultObj = node.positionConfig.getOutDataProp(node, msg, {
type: config.result1ValueType,
value: config.result1Value,
format: config.result1Format,
offsetType: config.result1OffsetType,
offset: config.result1Offset,
multiplier: config.result1Multiplier,
next: true
});
resultObj = node.positionConfig.getOutDataProp(node, msg, node.result1Value);
}
if (resultObj === null || typeof resultObj === 'undefined') {
throw new Error('could not evaluate ' + config.result1ValueType + '.' + config.result1Value);
throw new Error('could not evaluate ' + node.result1Value.type + '.' + node.result1Value.value);
} else if (resultObj.error) {
node.error('error on getting result: ' + resultObj.error);
} else {
node.positionConfig.setMessageProp(this, msg, config.result1Type, config.result1, resultObj);
node.positionConfig.setMessageProp(this, msg, node.result1.type, node.result1.value, resultObj);
}

@@ -83,6 +103,5 @@ }

const resObj = [];
const rules = config.rules;
const rulesLength = rules.length;
const rulesLength = node.rules.length;
for (let i = 0; i < rulesLength; ++i) {
const rule = rules[i];
const rule = node.rules[i];
let operatorValid = true;

@@ -231,3 +250,3 @@ if (rule.propertyType !== 'none') {

node.debug(i + ' result=' + util.inspect(result, { colors: true, compact: 10, breakLength: Infinity }));
if (config.checkall != 'true') { // eslint-disable-line eqeqeq
if (node.checkall != 'true') { // eslint-disable-line eqeqeq
node.debug(i + ' end cause checkall');

@@ -234,0 +253,0 @@ break;

@@ -96,5 +96,5 @@ /********************************************

try {
this.property.expr = this.positionConfig.getJSONataExpression(this.property.value, node);
this.property.expr = this.positionConfig.getJSONataExpression(this, this.property.value);
} catch (err) {
this.error(RED._('inject.errors.invalid-expr', { error:err.message }));
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error:err.message }));
this.property.expr = null;

@@ -306,5 +306,5 @@ }

try {
propNew.expr = this.positionConfig.getJSONataExpression(propNew.value, node);
propNew.expr = this.positionConfig.getJSONataExpression(this, propNew.value);
} catch (err) {
this.error(RED._('inject.errors.invalid-expr', { error:err.message }));
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error:err.message }));
propNew.expr = null;

@@ -311,0 +311,0 @@ }

@@ -270,2 +270,19 @@ /********************************************

this.positionConfig = RED.nodes.getNode(config.positionConfig);
this.result1Value = {
type: config.result1ValueType,
value: config.result1Value,
format: config.result1Format,
offsetType: config.result1OffsetType,
offset: config.result1Offset,
multiplier: config.result1Multiplier,
next: true
};
if (this.positionConfig && this.result1Value.type === 'jsonata') {
try {
this.result1Value.expr = this.positionConfig.getJSONataExpression(this, this.result1Value.value);
} catch (err) {
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error:err.message }));
this.result1Value.expr = null;
}
}
const node = this;

@@ -335,22 +352,14 @@

let resultObj = null;
if (config.result1ValueType === 'timespan') {
if (node.result1Value.type === 'timespan') {
resultObj = getFormattedTimeSpanOut(node, operand1.value, operand2.value, config.result1TSFormat);
} else if (config.result1ValueType === 'operand1') {
} else if (node.result1Value.type === 'operand1') {
resultObj = hlp.getFormattedDateOut(operand1.value, config.result1Format);
} else if (config.result1ValueType === 'operand2') {
} else if (node.result1Value.type === 'operand2') {
resultObj = hlp.getFormattedDateOut(operand2.value, config.result1Format);
} else {
resultObj = node.positionConfig.getOutDataProp(node, msg, {
type: config.result1ValueType,
value: config.result1Value,
format: config.result1Format,
offsetType: config.result1OffsetType,
offset: config.result1Offset,
multiplier: config.result1Multiplier,
next: true
});
resultObj = node.positionConfig.getOutDataProp(node, msg, node.result1Value);
}
// node.debug('resultObj=' + util.inspect(resultObj, { colors: true, compact: 10, breakLength: Infinity }));
if (resultObj === null || typeof resultObj === 'undefined') {
throw new Error('could not evaluate ' + config.result1ValueType + '.' + config.result1Value);
throw new Error('could not evaluate ' + node.result1Value.type + '.' + node.result1Value.value);
} else if (resultObj.error) {

@@ -357,0 +366,0 @@ node.error('error on getting result: ' + resultObj.error);

@@ -103,4 +103,4 @@ /********************************************

endSuffix: '',
altStartTime: (node.propertyStartType !== 'none') && (msg || (node.propertyStartType !== 'msg')),
altEndTime: (node.propertyEndType !== 'none') && (msg || (node.propertyEndType !== 'msg')),
altStartTime: (node.propertyStart.type !== 'none') && (msg || (node.propertyStart.type !== 'msg')),
altEndTime: (node.propertyEnd.type !== 'none') && (msg || (node.propertyEnd.type !== 'msg')),
valid: false,

@@ -162,12 +162,9 @@ warn: ''

if (result.altStartTime) {
// node.debug('alternate start times enabled ' + node.propertyStartType + '.' + node.propertyStart);
// node.debug('alternate start times enabled ' + node.propertyStart.type + '.' + node.propertyStart.value);
try {
result.altStartTime = node.positionConfig.comparePropValue(node, msg, { type:node.propertyStartType, value:node.propertyStart},
node.propertyStartOperator, {type: node.propertyStartThresholdType, value:node.propertyStartThresholdValue});
result.altStartTime = node.positionConfig.comparePropValue(node, msg, node.propertyStart,
node.propertyStartOperator, node.propertyStartThreshold);
} catch (err) {
result.altStartTime = false;
hlp.handleError(node, RED._('within-time-switch.errors.invalid-propertyStart-type', {
type: node.propertyStartType,
value: node.propertyStart
}), err);
hlp.handleError(node, RED._('within-time-switch.errors.invalid-propertyStart-type', node.propertyStart), err);
node.log(util.inspect(err, Object.getOwnPropertyNames(err)));

@@ -178,12 +175,9 @@ }

if (result.altEndTime) {
// node.debug('alternate end times enabled ' + node.propertyEndType + '.' + node.propertyEnd);
// node.debug('alternate end times enabled ' + node.propertyEnd.type + '.' + node.propertyEnd.value);
try {
result.altEndTime = node.positionConfig.comparePropValue(node, msg, { type:node.propertyEndType, value:node.propertyEnd},
node.propertyEndOperator, {type:node.propertyEndThresholdType, value:node.propertyEndThresholdValue});
result.altEndTime = node.positionConfig.comparePropValue(node, msg, node.propertyEnd,
node.propertyEndOperator, node.propertyEndThreshold);
} catch (err) {
result.altEndTime = false;
hlp.handleError(node, RED._('within-time-switch.errors.invalid-propertyEnd-type', {
type: node.propertyEndType,
value: node.propertyEnd
}), err);
hlp.handleError(node, RED._('within-time-switch.errors.invalid-propertyEnd-type', node.propertyEnd), err);
}

@@ -249,13 +243,37 @@ }

this.propertyStart = config.propertyStart || '';
this.propertyStartType = config.propertyStartType || 'none';
this.propertyStartOperator = config.propertyStartCompare || 'true';
this.propertyStartThresholdValue = config.propertyStartThreshold;
this.propertyStartThresholdType = config.propertyStartThresholdType;
this.propertyStart = {
type : config.propertyStartType || 'none',
value : config.propertyStart || ''
};
this.propertyStartThreshold = {
type : config.propertyStartThresholdType || 'none',
value : config.propertyStartThreshold || ''
};
if (this.positionConfig && this.propertyStart.type === 'jsonata') {
try {
this.propertyStart.expr = this.positionConfig.getJSONataExpression(this, this.propertyStart.value);
} catch (err) {
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error:err.message }));
this.propertyStart.expr = null;
}
}
this.propertyEnd = config.propertyEnd || '';
this.propertyEndType = config.propertyEndType || 'none';
this.propertyEndOperator = config.propertyEndCompare || 'true';
this.propertyEndThresholdValue = config.propertyEndThreshold;
this.propertyEndThresholdType = config.propertyEndThresholdType;
this.propertyEnd = {
type : config.propertyEndType || 'none',
value : config.propertyEnd || ''
};
this.propertyEndThreshold = {
type : config.propertyEndThresholdType || 'none',
value : config.propertyEndThreshold || ''
};
if (this.positionConfig && this.propertyEnd.type === 'jsonata') {
try {
this.propertyEnd.expr = this.positionConfig.getJSONataExpression(this, this.propertyEnd.value);
} catch (err) {
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error:err.message }));
this.propertyEnd.expr = null;
}
}

@@ -262,0 +280,0 @@ this.timeOnlyEvenDays = config.timeOnlyEvenDays;

{
"name": "node-red-contrib-sun-position",
"version": "1.1.5",
"version": "1.1.6",
"description": "NodeRED nodes to get sun and moon position",

@@ -98,5 +98,3 @@ "keywords": [

"eslint-plugin-json": "^2.1.2",
"eslint-plugin-node": "^11.1.0",
"minimist": ">=1.2.5",
"yargs-parser": ">=19.0.1"
"eslint-plugin-node": "^11.1.0"
},

@@ -103,0 +101,0 @@ "disabledSettings": {

Sorry, the diff of this file is too big to display

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