sim-node-lib 0.3.13 → 0.3.15

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.
@@ -0,0 +1 @@
1
+ export default function TestVerification(): Promise<void>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ function TestVerification() {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ if (process.env.NODE_ENV !== 'test') {
15
+ throw 'Para executar os testes é necessário estar no ambiente de test (NODE_ENV=test)';
16
+ }
17
+ });
18
+ }
19
+ exports.default = TestVerification;
@@ -13,4 +13,15 @@ export declare class DateHelper {
13
13
  static stringToDate(dateTime: string): Date;
14
14
  static minusTime(date: Date, days?: number, hours?: number, minutes?: number, seconds?: number, milisseconds?: number): Date;
15
15
  static plusTime(date: Date, days?: number, hours?: number, minutes?: number, seconds?: number, milisseconds?: number): Date;
16
+ static formatDateToSave(date: string): Date;
17
+ static validateDateVoucher(fromDate: Date, toDate: Date): boolean;
18
+ static validateVoucher(fromDate: Date, toDate: Date, givenDate: Date): boolean;
19
+ static formatToBR(data: Date): string;
20
+ static addMinutesToCurrentDateTime(minutes: number): Date;
21
+ static getExpireTime(minutes: number): string;
22
+ static convertStringDatetimePTBRtoDate(data: string, hora: string): Date;
23
+ static dateDiffInDays(a: Date, b: Date): number;
24
+ static padTo2Digits(num: number): string;
25
+ static formatDate(date: Date): string;
26
+ static getTime(date: Date): string;
16
27
  }
@@ -73,5 +73,50 @@ class DateHelper {
73
73
  var returnedDate = new Date(date.getTime() + subtractedMilisseconds);
74
74
  return returnedDate;
75
75
  }
76
+ static formatDateToSave(date) {
77
+ var data = moment(date, 'DD/MM/yyyy').toDate();
78
+ return data;
79
+ }
80
+ static validateDateVoucher(fromDate, toDate) {
81
+ return this.validateVoucher(fromDate, toDate, new Date());
82
+ }
83
+ static validateVoucher(fromDate, toDate, givenDate) {
84
+ givenDate = new Date(givenDate.setHours(0, 0, 0, 0));
85
+ return (givenDate.toISOString() >= fromDate.toISOString() &&
86
+ givenDate.toISOString() <= toDate.toISOString());
87
+ }
88
+ static formatToBR(data) {
89
+ return data.toLocaleString('pt-BR');
90
+ }
91
+ static addMinutesToCurrentDateTime(minutes) {
92
+ return new Date(new Date().getTime() + minutes * 60000);
93
+ }
94
+ static getExpireTime(minutes) {
95
+ return new Date(new Date().getTime() + minutes * 60000).toLocaleString('pt-BR').replace(',', '');
96
+ }
97
+ static convertStringDatetimePTBRtoDate(data, hora) {
98
+ let dataString = data.split('/');
99
+ let horaString = hora.split(':');
100
+ return new Date(Number(dataString[2]), Number(dataString[1]) - 1, Number(dataString[0]), Number(horaString[0]), Number(horaString[1]), Number(horaString[2]));
101
+ }
102
+ static dateDiffInDays(a, b) {
103
+ const msPerDay = 1000 * 60 * 60 * 24;
104
+ const utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
105
+ const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
106
+ return Math.floor((utc2 - utc1) / msPerDay);
107
+ }
108
+ static padTo2Digits(num) {
109
+ return num.toString().padStart(2, '0');
110
+ }
111
+ static formatDate(date) {
112
+ return [
113
+ this.padTo2Digits(date.getDate()),
114
+ this.padTo2Digits(date.getMonth() + 1),
115
+ date.getFullYear(),
116
+ ].join('/');
117
+ }
118
+ static getTime(date) {
119
+ return date.getHours() + ':' + date.getMinutes();
120
+ }
76
121
  }
77
122
  exports.DateHelper = DateHelper;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { GooglePubSubCreateSubscription } from './Class/GooglePubSubCreateSubscription';
2
2
  export { GooglePubSubPublish } from './Class/GooglePubSubPublish';
3
3
  export { GooglePubSubSubscription } from './Class/GooglePubSubSubscription';
4
+ export * from './Functions/TestVerification';
4
5
  export { PubSubHandlerAction } from './Handlers/PubSubHandlerAction';
5
6
  export { CryptHelper } from './Helpers/CryptHelper';
6
7
  export { DateHelper } from './Helpers/DateHelper';
package/dist/index.js CHANGED
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.CombustivelService = exports.AxiosService = exports.VendaReduzida = exports.VendaOrigem = exports.VendaItemReduzido = exports.VendaFormaPagamentoReduzida = exports.PriceToSale = exports.PriceToConsult = exports.AxiosModel = exports.UpdateUtil = exports.StringHelper = exports.PromiseHelper = exports.NumberHelper = exports.HashHelper = exports.DateHelper = exports.CryptHelper = exports.PubSubHandlerAction = exports.GooglePubSubSubscription = exports.GooglePubSubPublish = exports.GooglePubSubCreateSubscription = void 0;
4
18
  var GooglePubSubCreateSubscription_1 = require("./Class/GooglePubSubCreateSubscription");
@@ -7,6 +21,7 @@ var GooglePubSubPublish_1 = require("./Class/GooglePubSubPublish");
7
21
  Object.defineProperty(exports, "GooglePubSubPublish", { enumerable: true, get: function () { return GooglePubSubPublish_1.GooglePubSubPublish; } });
8
22
  var GooglePubSubSubscription_1 = require("./Class/GooglePubSubSubscription");
9
23
  Object.defineProperty(exports, "GooglePubSubSubscription", { enumerable: true, get: function () { return GooglePubSubSubscription_1.GooglePubSubSubscription; } });
24
+ __exportStar(require("./Functions/TestVerification"), exports);
10
25
  var PubSubHandlerAction_1 = require("./Handlers/PubSubHandlerAction");
11
26
  Object.defineProperty(exports, "PubSubHandlerAction", { enumerable: true, get: function () { return PubSubHandlerAction_1.PubSubHandlerAction; } });
12
27
  var CryptHelper_1 = require("./Helpers/CryptHelper");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",