plenna_utilities 1.7.0 → 1.7.1
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/src/alerts/domain/interfaces/alerts.d.ts +2 -0
- package/dist/src/alerts/domain/usecases/send-alert.usecase.js +6 -5
- package/dist/src/common/domain/shared/date.transformer.d.ts +4 -0
- package/dist/src/common/domain/shared/date.transformer.js +43 -0
- package/dist/src/common/domain/shared/index.d.ts +2 -0
- package/dist/src/common/domain/shared/index.js +18 -0
- package/dist/src/common/domain/shared/interpolation.transformer.d.ts +1 -0
- package/dist/src/common/domain/shared/interpolation.transformer.js +3 -0
- package/dist/src/common/infrastructure/yaml-converter/configurations/slack.yaml +6 -6
- package/dist/src/time/index.d.ts +0 -1
- package/dist/src/time/index.js +1 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,3 +28,4 @@ __exportStar(require("./src/customerio"), exports);
|
|
|
28
28
|
__exportStar(require("./src/mailer"), exports);
|
|
29
29
|
__exportStar(require("./src/airTable"), exports);
|
|
30
30
|
__exportStar(require("./src/alerts/presenter"), exports);
|
|
31
|
+
__exportStar(require("./src/common/domain/shared"), exports);
|
|
@@ -36,12 +36,14 @@ export interface ITemplatesConfiguration {
|
|
|
36
36
|
export interface AlertTemplateInput {
|
|
37
37
|
template?: string;
|
|
38
38
|
date?: string;
|
|
39
|
+
reportDate?: string;
|
|
39
40
|
text?: string;
|
|
40
41
|
bookingUser?: string;
|
|
41
42
|
channel?: string;
|
|
42
43
|
origin?: string;
|
|
43
44
|
huliId?: string;
|
|
44
45
|
threadTs?: string;
|
|
46
|
+
toDo?: string;
|
|
45
47
|
}
|
|
46
48
|
export interface AlertResponse {
|
|
47
49
|
channel: string;
|
|
@@ -14,12 +14,10 @@ class SendAlertUseCase {
|
|
|
14
14
|
try {
|
|
15
15
|
const [input] = args;
|
|
16
16
|
const alertData = input;
|
|
17
|
-
if (alertData?.
|
|
18
|
-
return;
|
|
19
|
-
if (alertData?.channel !== '' && alertData?.channel !== undefined) {
|
|
17
|
+
if ((0, interpolation_transformer_1.isNonEmpty)(alertData?.channel) || !(0, interpolation_transformer_1.isNonEmpty)(alertData?.template)) {
|
|
20
18
|
const alert = {
|
|
21
|
-
channel: alertData
|
|
22
|
-
text: alertData
|
|
19
|
+
channel: alertData?.channel ?? '',
|
|
20
|
+
text: alertData?.text ?? '',
|
|
23
21
|
threadTs: alertData?.threadTs
|
|
24
22
|
};
|
|
25
23
|
return await this.alertService.sendAlert(alert);
|
|
@@ -31,6 +29,9 @@ class SendAlertUseCase {
|
|
|
31
29
|
const templateInfo = getConfiguration.templates[templateKey];
|
|
32
30
|
if (templateInfo === null && templateInfo === undefined)
|
|
33
31
|
throw new Error('template not found');
|
|
32
|
+
templateInfo.channel = (0, interpolation_transformer_1.isNonEmpty)(alertData?.channel)
|
|
33
|
+
? alertData.channel ?? ''
|
|
34
|
+
: templateInfo.channel;
|
|
34
35
|
if (templateInfo.blocks !== undefined) {
|
|
35
36
|
templateInfo.blocks.forEach((block) => {
|
|
36
37
|
if (block.type === 'section' && block.fields != null) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const formatDate: (isoDate: string) => string;
|
|
2
|
+
export declare const formatHour: (time24: string) => string;
|
|
3
|
+
export declare const getDifferenceInMinutes: (startTime: string, endTime: string) => number;
|
|
4
|
+
export declare const formatIsoDateToSpanish: (isoString: string) => string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatIsoDateToSpanish = exports.getDifferenceInMinutes = exports.formatHour = exports.formatDate = void 0;
|
|
4
|
+
const formatDate = (isoDate) => {
|
|
5
|
+
const date = new Date(isoDate);
|
|
6
|
+
return date.toLocaleDateString('es-ES', {
|
|
7
|
+
day: 'numeric',
|
|
8
|
+
month: 'long',
|
|
9
|
+
year: 'numeric'
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
exports.formatDate = formatDate;
|
|
13
|
+
const formatHour = (time24) => {
|
|
14
|
+
const [hours, minutes, seconds] = time24.split(':').map(Number);
|
|
15
|
+
const date = new Date();
|
|
16
|
+
date.setHours(hours, minutes, seconds);
|
|
17
|
+
return date.toLocaleTimeString('es-ES', {
|
|
18
|
+
hour: 'numeric',
|
|
19
|
+
minute: '2-digit',
|
|
20
|
+
hour12: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.formatHour = formatHour;
|
|
24
|
+
const getDifferenceInMinutes = (startTime, endTime) => {
|
|
25
|
+
const [h1, m1, s1] = startTime.split(':').map(Number);
|
|
26
|
+
const [h2, m2, s2] = endTime.split(':').map(Number);
|
|
27
|
+
const startDate = new Date();
|
|
28
|
+
startDate.setHours(h1, m1, s1, 0);
|
|
29
|
+
const endDate = new Date();
|
|
30
|
+
endDate.setHours(h2, m2, s2, 0);
|
|
31
|
+
const diffMs = endDate.getTime() - startDate.getTime();
|
|
32
|
+
return Math.floor(diffMs / 60000);
|
|
33
|
+
};
|
|
34
|
+
exports.getDifferenceInMinutes = getDifferenceInMinutes;
|
|
35
|
+
const formatIsoDateToSpanish = (isoString) => {
|
|
36
|
+
const date = new Date(isoString);
|
|
37
|
+
return date.toLocaleDateString('es-ES', {
|
|
38
|
+
day: 'numeric',
|
|
39
|
+
month: 'long',
|
|
40
|
+
year: 'numeric'
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.formatIsoDateToSpanish = formatIsoDateToSpanish;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./date.transformer"), exports);
|
|
18
|
+
__exportStar(require("./interpolation.transformer"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNonEmpty = void 0;
|
|
3
4
|
exports.interpolateFields = interpolateFields;
|
|
4
5
|
function interpolateFields(fields, input) {
|
|
5
6
|
return fields.map((field) => {
|
|
@@ -11,3 +12,5 @@ function interpolateFields(fields, input) {
|
|
|
11
12
|
return { ...field, text };
|
|
12
13
|
});
|
|
13
14
|
}
|
|
15
|
+
const isNonEmpty = (value) => { return value !== '' && value !== undefined; };
|
|
16
|
+
exports.isNonEmpty = isNonEmpty;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
templates:
|
|
2
2
|
noInfo:
|
|
3
3
|
channel: 'C08S575SWCF'
|
|
4
|
-
text: '
|
|
4
|
+
text: '🚨 Error de Agenda'
|
|
5
5
|
blocks:
|
|
6
6
|
- type: header
|
|
7
7
|
text:
|
|
@@ -11,20 +11,20 @@ templates:
|
|
|
11
11
|
- type: section
|
|
12
12
|
text:
|
|
13
13
|
type: mrkdwn
|
|
14
|
-
text: '*Motivo:* Se
|
|
14
|
+
text: '*Motivo:* Se creó una cita en Huli con información errónea, por lo que esta agenda no es válida.'
|
|
15
15
|
fields:
|
|
16
16
|
- type: mrkdwn
|
|
17
17
|
text: "*ID de cita en Huli:*\n{huliId}"
|
|
18
18
|
- type: mrkdwn
|
|
19
19
|
text: "*Persona que intentó agendar:*\n<{bookingUser}>"
|
|
20
20
|
- type: mrkdwn
|
|
21
|
-
text: "
|
|
21
|
+
text: "*Fecha y hora de la cita:*\n{date}"
|
|
22
22
|
- type: mrkdwn
|
|
23
|
-
text: "*¿Qué
|
|
23
|
+
text: "*¿Qué pasó?:*\n{text}"
|
|
24
24
|
- type: mrkdwn
|
|
25
|
-
text: "
|
|
25
|
+
text: "*¿Qué debes hacer?:*\n{toDo}"
|
|
26
26
|
- type: mrkdwn
|
|
27
|
-
text: "*
|
|
27
|
+
text: "*Fecha de reporte:*\n{reportDate}"
|
|
28
28
|
- type: divider
|
|
29
29
|
- type: context
|
|
30
30
|
elements:
|
package/dist/src/time/index.d.ts
CHANGED
|
@@ -5,4 +5,3 @@ export declare const getAge: (date: Date) => string;
|
|
|
5
5
|
export declare const getDeltaTime: (start: Date, end: Date) => number;
|
|
6
6
|
export declare const getMonthDifference: (startDate: Date, endDate: Date) => number;
|
|
7
7
|
export declare const addWorkDays: (startDate: Date, days: number) => Date;
|
|
8
|
-
export declare const helloTime: () => void;
|
package/dist/src/time/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addWorkDays = exports.getMonthDifference = exports.getDeltaTime = exports.getAge = exports.compare = exports.isValidNumeric = exports.fixAppointmentDateStart = void 0;
|
|
4
4
|
const fixAppointmentDateStart = (date, start) => {
|
|
5
5
|
const [hour, minutes] = start.split(':');
|
|
6
6
|
const fixedDate = new Date(date).setUTCHours(parseInt(hour ?? 0) + 6, parseInt(minutes ?? 0));
|
|
@@ -47,7 +47,3 @@ const addWorkDays = (startDate, days) => {
|
|
|
47
47
|
return targetDate;
|
|
48
48
|
};
|
|
49
49
|
exports.addWorkDays = addWorkDays;
|
|
50
|
-
const helloTime = () => {
|
|
51
|
-
console.log('hola');
|
|
52
|
-
};
|
|
53
|
-
exports.helloTime = helloTime;
|