investira.sdk 2.3.22 → 2.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -541,3 +541,11 @@ O contrutor para a criação das mensagem foi alterado.
541
541
  # 2.3.22
542
542
 
543
543
  - [dates] scheduleToDate com seleção do dia da semana, no tipo 'M' e 'Y'.
544
+
545
+ # 2.3.23
546
+
547
+ - [dates] scheduleToDate correção para dia da semana '0' .
548
+
549
+ # 2.3.24
550
+
551
+ - [validators] Otimização do isObject.
package/lib/hofs/tasks.js CHANGED
@@ -27,7 +27,7 @@ function task(pOptions, pSource = {}) {
27
27
  {
28
28
  type: null, //'D'-Dia, 'W'-Semana, 'M'-Mês, 'Y'-Ano
29
29
  time: null, //'hh:mm' Hora da execução
30
- weekday: null, //Número da semana quando type for 'W', 0-Domingo até 6-sábado.
30
+ weekday: null, //Número da semana quando type for 'W','M' ou 'Y' , 0-Domingo até 6-sábado.
31
31
  day: null, //Dia do mês quando type for 'M'
32
32
  month: null, //Número do mês quando type for 'Y'
33
33
  workingDay: null //Boolean indicando se cálculo será em dias úteis.
@@ -952,15 +952,11 @@ const dates = {
952
952
  xNextDate = dates.addDays(xNextDate, 1);
953
953
  }
954
954
  } else if (pSchedule.type === 'W') {
955
- if (!pSchedule.weekday) {
956
- pSchedule.weekday = 0;
957
- } else {
958
- const xWeekday = numbers.toNumber(pSchedule.weekday);
959
- if (xWeekday === null || xWeekday < 0 || xWeekday > 6) {
960
- throw Error('scheduleToDate: invalid weekday');
961
- }
955
+ const xWeekday = numbers.toNumber(pSchedule.weekday || pSchedule.weekDay || 0);
956
+ if (xWeekday === null || xWeekday < 0 || xWeekday > 6) {
957
+ throw Error(`scheduleToDate: invalid weekday ${pSchedule.weekday || pSchedule.weekDay}`);
962
958
  }
963
- let xDif = pSchedule.weekday - xCurrentDate.getDay();
959
+ let xDif = xWeekday - xCurrentDate.getDay();
964
960
  //Adiciona os dias até ser o dia da semana desejado
965
961
  if (xDif < 0) {
966
962
  xDif = 7 - Math.abs(xDif);
@@ -969,7 +965,6 @@ const dates = {
969
965
  if (!xNextDate) {
970
966
  return null;
971
967
  }
972
- // const xNextDataObject = dates.dateToObject(new Date(xNextDate.tl()));
973
968
  xNextDate = dates.toDate(
974
969
  `${xNextDate.getFullYear()}${String(xNextDate.getMonth() + 1).padStart(2, '0')}${String(
975
970
  xNextDate.getDate()
@@ -1007,7 +1002,7 @@ const dates = {
1007
1002
  xNextDate = dates.nextMonthAnniversary(xNextDate);
1008
1003
  }
1009
1004
  //Se dia da semana estive configurado, ajusta data para o dia da semana informado
1010
- if (pSchedule.weekday) {
1005
+ if (pSchedule?.weekday >= 0 || pSchedule?.weekDay >= 0) {
1011
1006
  xNextDate = dates.scheduleToDate({ ...pSchedule, type: 'W' }, xNextDate);
1012
1007
  }
1013
1008
  } else if (pSchedule.type === 'Y') {
@@ -1029,7 +1024,7 @@ const dates = {
1029
1024
  xNextDate = dates.addYears(xNextDate, 1);
1030
1025
  }
1031
1026
  //Se dia da semana estive configurado, ajusta data para o dia da semana informado
1032
- if (pSchedule.weekday) {
1027
+ if (pSchedule?.weekday >= 0 || pSchedule?.weekDay >= 0) {
1033
1028
  xNextDate = dates.scheduleToDate({ ...pSchedule, type: 'W' }, xNextDate);
1034
1029
  }
1035
1030
  }
@@ -54,7 +54,10 @@ const validators = {
54
54
  * @returns {boolean}
55
55
  */
56
56
  isObject: toValidate => {
57
- return toValidate && validators.trueTypeOf(toValidate) === 'object' && toValidate.constructor === Object;
57
+ return (
58
+ toValidate && (toValidate.constructor === Object || Object.getPrototypeOf(toValidate) === Object.prototype)
59
+ );
60
+ // return toValidate && validators.trueTypeOf(toValidate) === 'object' && toValidate.constructor === Object;
58
61
  },
59
62
 
60
63
  /**
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "investira.sdk",
3
- "version": "2.3.22",
3
+ "version": "2.3.24",
4
4
  "author": "Investira",
5
5
  "description": "Investira SDK",
6
6
  "main": "index.js",
7
7
  "type": "commonjs",
8
8
  "registry": true,
9
- "raw": "investira.sdk@2.3.22",
9
+ "raw": "investira.sdk@2.3.24",
10
10
  "escapedName": "investira.sdk",
11
- "rawSpec": "2.3.22",
11
+ "rawSpec": "2.3.24",
12
12
  "saveSpec": null,
13
- "fetchSpec": "2.3.22",
13
+ "fetchSpec": "2.3.24",
14
14
  "homepage": "https://investira.com.br/",
15
15
  "engines": {
16
16
  "node": ">=11.11.0 <=18.12",