ismx-nexo-node-app 0.4.15 → 0.4.17
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.
|
@@ -17,11 +17,18 @@ class DateUtils {
|
|
|
17
17
|
static getEndOfWeek(year, week) {
|
|
18
18
|
return this.getStartOfWeek(year, week + 1);
|
|
19
19
|
}
|
|
20
|
-
static toIsoTime(date) {
|
|
20
|
+
static toIsoTime(date, precision = DateUtils.SECONDS) {
|
|
21
21
|
let hours = date.getHours().toString().padStart(2, "0");
|
|
22
22
|
let minutes = date.getMinutes().toString().padStart(2, "0");
|
|
23
23
|
let seconds = date.getSeconds().toString().padStart(2, "0");
|
|
24
|
-
|
|
24
|
+
let result = "";
|
|
25
|
+
if (precision !== DateUtils.HOURS)
|
|
26
|
+
result += hours;
|
|
27
|
+
if (precision !== DateUtils.MINUTES)
|
|
28
|
+
result += `:${minutes}`;
|
|
29
|
+
if (precision !== DateUtils.SECONDS)
|
|
30
|
+
result += `:${seconds}`;
|
|
31
|
+
return result;
|
|
25
32
|
}
|
|
26
33
|
static toIsoDate(date) {
|
|
27
34
|
let year = date.getFullYear().toString();
|
|
@@ -35,7 +35,7 @@ class RepositoryRest extends Repository_1.default {
|
|
|
35
35
|
for (const header of Object.keys(headers))
|
|
36
36
|
headers.set(header, (_e = (_d = request.headers) === null || _d === void 0 ? void 0 : _d[header]) !== null && _e !== void 0 ? _e : "");
|
|
37
37
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
38
|
-
let call = fetch(this.baseUrl + endpoint + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method
|
|
38
|
+
let call = fetch(this.baseUrl + endpoint + QueryUtils_1.default.map(request.query), Object.assign(Object.assign({}, request), { body: method !== "GET" ? JSON.stringify(request.body) : undefined, headers }));
|
|
39
39
|
// Añade información adicional a la respuesta y devuelve el resultado (o el error en su caso).
|
|
40
40
|
return call.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
var _a, _b;
|
|
@@ -10,7 +10,7 @@ export default abstract class DateUtils {
|
|
|
10
10
|
static getDay(date: Date, using?: string[]): string;
|
|
11
11
|
static getStartOfWeek(year: number, week: number): Date;
|
|
12
12
|
static getEndOfWeek(year: number, week: number): Date;
|
|
13
|
-
static toIsoTime(date: Date): string;
|
|
13
|
+
static toIsoTime(date: Date, precision?: number): string;
|
|
14
14
|
static toIsoDate(date: Date): string;
|
|
15
15
|
static sum(date: Date, value: number, component: number): Date;
|
|
16
16
|
static sumTime(date: string, value: number, component: number): string;
|
package/package.json
CHANGED
|
@@ -29,11 +29,17 @@ export default abstract class DateUtils {
|
|
|
29
29
|
return this.getStartOfWeek(year, week+1)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
static toIsoTime(date: Date) {
|
|
32
|
+
static toIsoTime(date: Date, precision: number = DateUtils.SECONDS) {
|
|
33
33
|
let hours = date.getHours().toString().padStart(2, "0");
|
|
34
34
|
let minutes = date.getMinutes().toString().padStart(2, "0");
|
|
35
35
|
let seconds = date.getSeconds().toString().padStart(2, "0");
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
let result = ""
|
|
38
|
+
if (precision !== DateUtils.HOURS) result += hours;
|
|
39
|
+
if (precision !== DateUtils.MINUTES) result += `:${minutes}`;
|
|
40
|
+
if (precision !== DateUtils.SECONDS) result += `:${seconds}`;
|
|
41
|
+
|
|
42
|
+
return result;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
static toIsoDate(date: Date) {
|
|
@@ -44,7 +44,7 @@ export default class RepositoryRest<Body=any,Res=any> extends Repository
|
|
|
44
44
|
// Realiza la llamada a la API con las cabeceras y la URL base de la llamada.
|
|
45
45
|
let call = fetch(this.baseUrl + endpoint + QueryUtils.map(request.query), {
|
|
46
46
|
...request,
|
|
47
|
-
body: method
|
|
47
|
+
body: method !== "GET" ? JSON.stringify(request.body) : undefined,
|
|
48
48
|
headers
|
|
49
49
|
});
|
|
50
50
|
|