plenna_utilities 1.13.0 → 1.13.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/package.json +1 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -33
- package/dist/src/AI/bedrock/index.d.ts +0 -10
- package/dist/src/AI/bedrock/index.js +0 -27
- package/dist/src/airTable/index.d.ts +0 -21
- package/dist/src/airTable/index.js +0 -82
- package/dist/src/alerts/application/send-alert-impl.service.d.ts +0 -8
- package/dist/src/alerts/application/send-alert-impl.service.js +0 -20
- package/dist/src/alerts/domain/interfaces/alerts.d.ts +0 -51
- package/dist/src/alerts/domain/interfaces/alerts.js +0 -2
- package/dist/src/alerts/domain/services/send-alert.service.d.ts +0 -4
- package/dist/src/alerts/domain/services/send-alert.service.js +0 -6
- package/dist/src/alerts/domain/usecases/send-alert.usecase.d.ts +0 -9
- package/dist/src/alerts/domain/usecases/send-alert.usecase.js +0 -49
- package/dist/src/alerts/presenter/index.d.ts +0 -2
- package/dist/src/alerts/presenter/index.js +0 -11
- package/dist/src/common/custom/types/index.d.ts +0 -4
- package/dist/src/common/custom/types/index.js +0 -2
- package/dist/src/common/domain/alerts/alerts.d.ts +0 -4
- package/dist/src/common/domain/alerts/alerts.js +0 -6
- package/dist/src/common/domain/configurations/configurations.d.ts +0 -3
- package/dist/src/common/domain/configurations/configurations.js +0 -6
- package/dist/src/common/domain/interfaces/products.interfaces.d.ts +0 -3
- package/dist/src/common/domain/interfaces/products.interfaces.js +0 -7
- package/dist/src/common/domain/interfaces/usecases.interface.d.ts +0 -3
- package/dist/src/common/domain/interfaces/usecases.interface.js +0 -2
- package/dist/src/common/domain/shared/date.transformer.d.ts +0 -4
- package/dist/src/common/domain/shared/date.transformer.js +0 -49
- package/dist/src/common/domain/shared/index.d.ts +0 -2
- package/dist/src/common/domain/shared/index.js +0 -18
- package/dist/src/common/domain/shared/interpolation.transformer.d.ts +0 -3
- package/dist/src/common/domain/shared/interpolation.transformer.js +0 -16
- package/dist/src/common/infrastructure/slack/slack.d.ts +0 -7
- package/dist/src/common/infrastructure/slack/slack.js +0 -37
- package/dist/src/common/infrastructure/yaml-converter/configurations/slack.yaml +0 -137
- package/dist/src/common/infrastructure/yaml-converter/yaml-converter.d.ts +0 -4
- package/dist/src/common/infrastructure/yaml-converter/yaml-converter.js +0 -28
- package/dist/src/customerio/index.d.ts +0 -11
- package/dist/src/customerio/index.js +0 -63
- package/dist/src/general/index.d.ts +0 -3
- package/dist/src/general/index.js +0 -41
- package/dist/src/general/interfaces.d.ts +0 -4
- package/dist/src/general/interfaces.js +0 -2
- package/dist/src/google/index.d.ts +0 -90
- package/dist/src/google/index.js +0 -186
- package/dist/src/google/requestBuilder.d.ts +0 -14
- package/dist/src/google/requestBuilder.js +0 -60
- package/dist/src/lambdas/index.d.ts +0 -28
- package/dist/src/lambdas/index.js +0 -64
- package/dist/src/mailer/index.d.ts +0 -9
- package/dist/src/mailer/index.js +0 -34
- package/dist/src/respira/index.d.ts +0 -65
- package/dist/src/respira/index.js +0 -42
- package/dist/src/s3/index.d.ts +0 -9
- package/dist/src/s3/index.js +0 -44
- package/dist/src/time/index.d.ts +0 -7
- package/dist/src/time/index.js +0 -49
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './src/lambdas';
|
|
2
|
-
export * from './src/time';
|
|
3
|
-
export * from './src/s3';
|
|
4
|
-
export * from './src/google';
|
|
5
|
-
export * from './src/general';
|
|
6
|
-
export * from './src/customerio';
|
|
7
|
-
export * from './src/mailer';
|
|
8
|
-
export * from './src/airTable';
|
|
9
|
-
export * from './src/alerts/presenter';
|
|
10
|
-
export * from './src/common/domain/shared';
|
|
11
|
-
export * from './src/AI/bedrock';
|
|
12
|
-
export * from './src/respira';
|
package/dist/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
21
|
-
dotenv_1.default.config();
|
|
22
|
-
__exportStar(require("./src/lambdas"), exports);
|
|
23
|
-
__exportStar(require("./src/time"), exports);
|
|
24
|
-
__exportStar(require("./src/s3"), exports);
|
|
25
|
-
__exportStar(require("./src/google"), exports);
|
|
26
|
-
__exportStar(require("./src/general"), exports);
|
|
27
|
-
__exportStar(require("./src/customerio"), exports);
|
|
28
|
-
__exportStar(require("./src/mailer"), exports);
|
|
29
|
-
__exportStar(require("./src/airTable"), exports);
|
|
30
|
-
__exportStar(require("./src/alerts/presenter"), exports);
|
|
31
|
-
__exportStar(require("./src/common/domain/shared"), exports);
|
|
32
|
-
__exportStar(require("./src/AI/bedrock"), exports);
|
|
33
|
-
__exportStar(require("./src/respira"), exports);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type PromptVariableValues } from '@aws-sdk/client-bedrock-runtime';
|
|
2
|
-
interface IPlennaBedrockArgs {
|
|
3
|
-
modelId: string;
|
|
4
|
-
}
|
|
5
|
-
export declare class PlennaBedrock {
|
|
6
|
-
private readonly modelId;
|
|
7
|
-
constructor(params: IPlennaBedrockArgs);
|
|
8
|
-
converse(variables: Record<string, PromptVariableValues>): Promise<string>;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlennaBedrock = void 0;
|
|
4
|
-
const client_bedrock_runtime_1 = require("@aws-sdk/client-bedrock-runtime");
|
|
5
|
-
class PlennaBedrock {
|
|
6
|
-
modelId;
|
|
7
|
-
constructor(params) {
|
|
8
|
-
this.modelId = params.modelId;
|
|
9
|
-
}
|
|
10
|
-
async converse(variables) {
|
|
11
|
-
const client = new client_bedrock_runtime_1.BedrockRuntimeClient({ region: 'us-east-2' });
|
|
12
|
-
const command = new client_bedrock_runtime_1.ConverseCommand({
|
|
13
|
-
modelId: this.modelId,
|
|
14
|
-
promptVariables: variables
|
|
15
|
-
});
|
|
16
|
-
try {
|
|
17
|
-
const response = await client.send(command);
|
|
18
|
-
const summary = response?.output?.message?.content?.[0]?.text ?? 'No se pudo generar resumen';
|
|
19
|
-
return summary;
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
console.error('Error en Bedrock:', err);
|
|
23
|
-
return 'Fallo al invocar Bedrock';
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.PlennaBedrock = PlennaBedrock;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type FieldSet, type Records } from 'airtable';
|
|
2
|
-
export type { FieldSet } from 'airtable';
|
|
3
|
-
export type { Records } from 'airtable';
|
|
4
|
-
export declare class AirTable {
|
|
5
|
-
private readonly webhook;
|
|
6
|
-
constructor(webhook: string);
|
|
7
|
-
sendToAirTable(payload: Record<string, unknown>): Promise<boolean>;
|
|
8
|
-
}
|
|
9
|
-
export declare class AirtableAPI {
|
|
10
|
-
private readonly apiKey;
|
|
11
|
-
private readonly baseId;
|
|
12
|
-
private readonly tableName;
|
|
13
|
-
constructor(apiKey: string, baseId: string, tableName: string);
|
|
14
|
-
getRecords(valuesToSearch: string[], fieldToSearch: string, maxRecords: number, view?: string, options?: {
|
|
15
|
-
fields?: string[];
|
|
16
|
-
}): Promise<Array<Records<FieldSet>[number]>>;
|
|
17
|
-
updateRecords(records: Array<{
|
|
18
|
-
id: string;
|
|
19
|
-
fields: Record<string, unknown>;
|
|
20
|
-
}>): Promise<void>;
|
|
21
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AirtableAPI = exports.AirTable = void 0;
|
|
7
|
-
const airtable_1 = __importDefault(require("airtable"));
|
|
8
|
-
class AirTable {
|
|
9
|
-
webhook;
|
|
10
|
-
constructor(webhook) {
|
|
11
|
-
this.webhook = webhook;
|
|
12
|
-
}
|
|
13
|
-
async sendToAirTable(payload) {
|
|
14
|
-
try {
|
|
15
|
-
const response = await fetch(this.webhook, {
|
|
16
|
-
method: 'post',
|
|
17
|
-
body: JSON.stringify(payload),
|
|
18
|
-
headers: {
|
|
19
|
-
'Content-Type': 'application/json'
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
console.log(response);
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.log(error);
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.AirTable = AirTable;
|
|
32
|
-
class AirtableAPI {
|
|
33
|
-
apiKey;
|
|
34
|
-
baseId;
|
|
35
|
-
tableName;
|
|
36
|
-
constructor(apiKey, baseId, tableName) {
|
|
37
|
-
this.apiKey = apiKey;
|
|
38
|
-
this.baseId = baseId;
|
|
39
|
-
this.tableName = tableName;
|
|
40
|
-
}
|
|
41
|
-
async getRecords(valuesToSearch, fieldToSearch, maxRecords, view, options) {
|
|
42
|
-
return await new Promise((resolve, reject) => {
|
|
43
|
-
const base = new airtable_1.default({ apiKey: this.apiKey }).base(this.baseId);
|
|
44
|
-
const allRecords = [];
|
|
45
|
-
const filterByFormula = valuesToSearch.length === 1
|
|
46
|
-
? `{${fieldToSearch}} = '${valuesToSearch[0]}'`
|
|
47
|
-
: `OR(${valuesToSearch.map(v => `{${fieldToSearch}} = '${v}'`).join(', ')})`;
|
|
48
|
-
base(this.tableName)
|
|
49
|
-
.select({ filterByFormula, maxRecords, view: view ?? 'Grid view', ...options })
|
|
50
|
-
.eachPage((records, fetchNextPage) => {
|
|
51
|
-
console.log('records: ', records);
|
|
52
|
-
allRecords.push(...records);
|
|
53
|
-
fetchNextPage();
|
|
54
|
-
}, (err) => {
|
|
55
|
-
if (err !== null) {
|
|
56
|
-
console.error('❌ Error de Airtable:', err);
|
|
57
|
-
reject(err);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
resolve(allRecords);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async updateRecords(records) {
|
|
65
|
-
const base = new airtable_1.default({ apiKey: this.apiKey }).base(this.baseId);
|
|
66
|
-
const chunkSize = 10;
|
|
67
|
-
for (let i = 0; i < records.length; i += chunkSize) {
|
|
68
|
-
const batch = records.slice(i, i + chunkSize).map((record) => (record));
|
|
69
|
-
console.log(`Actualizando batch ${i / chunkSize + 1}...`);
|
|
70
|
-
try {
|
|
71
|
-
await base(this.tableName).update(batch);
|
|
72
|
-
console.log(`✅ Update completado del batch ${i / chunkSize + 1}`);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error('❌ Error de Airtable:', error);
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.AirtableAPI = AirtableAPI;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type AlertsHandler } from '../../common/domain/alerts/alerts';
|
|
2
|
-
import { type AlertResponse, type IAlert } from '../domain/interfaces/alerts';
|
|
3
|
-
import { AlertService } from '../domain/services/send-alert.service';
|
|
4
|
-
export declare class AlertServiceImpl extends AlertService {
|
|
5
|
-
private readonly alertImpl;
|
|
6
|
-
constructor(alertImpl: AlertsHandler);
|
|
7
|
-
sendAlert(alert: IAlert): Promise<AlertResponse | undefined>;
|
|
8
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AlertServiceImpl = void 0;
|
|
4
|
-
const send_alert_service_1 = require("../domain/services/send-alert.service");
|
|
5
|
-
class AlertServiceImpl extends send_alert_service_1.AlertService {
|
|
6
|
-
alertImpl;
|
|
7
|
-
constructor(alertImpl) {
|
|
8
|
-
super();
|
|
9
|
-
this.alertImpl = alertImpl;
|
|
10
|
-
}
|
|
11
|
-
async sendAlert(alert) {
|
|
12
|
-
try {
|
|
13
|
-
return await this.alertImpl.sendAlert(alert);
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
console.info(error);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.AlertServiceImpl = AlertServiceImpl;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export interface TextObject {
|
|
2
|
-
type: 'plain_text' | 'mrkdwn';
|
|
3
|
-
text: string;
|
|
4
|
-
emoji?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface FieldObject {
|
|
7
|
-
type: 'mrkdwn';
|
|
8
|
-
text: string;
|
|
9
|
-
}
|
|
10
|
-
export interface HeaderBlock {
|
|
11
|
-
type: 'header';
|
|
12
|
-
text: TextObject;
|
|
13
|
-
}
|
|
14
|
-
export interface SectionBlock {
|
|
15
|
-
type: 'section';
|
|
16
|
-
text: TextObject;
|
|
17
|
-
fields?: FieldObject[];
|
|
18
|
-
}
|
|
19
|
-
export interface DividerBlock {
|
|
20
|
-
type: 'divider';
|
|
21
|
-
}
|
|
22
|
-
export interface ContextBlock {
|
|
23
|
-
type: 'context';
|
|
24
|
-
elements: TextObject[];
|
|
25
|
-
}
|
|
26
|
-
export type Block = HeaderBlock | SectionBlock | DividerBlock | ContextBlock;
|
|
27
|
-
export interface IAlert {
|
|
28
|
-
channel: string;
|
|
29
|
-
text: string;
|
|
30
|
-
blocks?: Block[];
|
|
31
|
-
threadTs?: string;
|
|
32
|
-
}
|
|
33
|
-
export interface ITemplatesConfiguration {
|
|
34
|
-
templates: Record<string, IAlert>;
|
|
35
|
-
}
|
|
36
|
-
export interface AlertTemplateInput {
|
|
37
|
-
template?: string;
|
|
38
|
-
date?: string;
|
|
39
|
-
reportDate?: string;
|
|
40
|
-
text?: string;
|
|
41
|
-
bookingUser?: string;
|
|
42
|
-
channel?: string;
|
|
43
|
-
origin?: string;
|
|
44
|
-
huliId?: string;
|
|
45
|
-
threadTs?: string;
|
|
46
|
-
toDo?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface AlertResponse {
|
|
49
|
-
channel: string;
|
|
50
|
-
ts: string;
|
|
51
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Configuration } from '../../../common/domain/configurations/configurations';
|
|
2
|
-
import { type UseCase } from '../../../common/domain/interfaces/usecases.interface';
|
|
3
|
-
import { type AlertService } from '../services/send-alert.service';
|
|
4
|
-
export declare class SendAlertUseCase implements UseCase {
|
|
5
|
-
private readonly configuration;
|
|
6
|
-
private readonly alertService;
|
|
7
|
-
constructor(configuration: Configuration, alertService: AlertService);
|
|
8
|
-
exec(...args: any[]): Promise<any>;
|
|
9
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SendAlertUseCase = void 0;
|
|
4
|
-
const products_interfaces_1 = require("../../../common/domain/interfaces/products.interfaces");
|
|
5
|
-
const interpolation_transformer_1 = require("../../../common/domain/shared/interpolation.transformer");
|
|
6
|
-
class SendAlertUseCase {
|
|
7
|
-
configuration;
|
|
8
|
-
alertService;
|
|
9
|
-
constructor(configuration, alertService) {
|
|
10
|
-
this.configuration = configuration;
|
|
11
|
-
this.alertService = alertService;
|
|
12
|
-
}
|
|
13
|
-
async exec(...args) {
|
|
14
|
-
try {
|
|
15
|
-
const [input] = args;
|
|
16
|
-
const alertData = input;
|
|
17
|
-
if ((0, interpolation_transformer_1.isNonEmpty)(alertData?.channel) || !(0, interpolation_transformer_1.isNonEmpty)(alertData?.template)) {
|
|
18
|
-
const alert = {
|
|
19
|
-
channel: alertData?.channel ?? '',
|
|
20
|
-
text: alertData?.text ?? '',
|
|
21
|
-
threadTs: alertData?.threadTs
|
|
22
|
-
};
|
|
23
|
-
return await this.alertService.sendAlert(alert);
|
|
24
|
-
}
|
|
25
|
-
const getConfiguration = await this.configuration.getConfiguration(products_interfaces_1.Products.SLACK);
|
|
26
|
-
if (getConfiguration === undefined)
|
|
27
|
-
throw new Error('configuration not found');
|
|
28
|
-
const templateKey = alertData.template ?? '';
|
|
29
|
-
const templateInfo = getConfiguration.templates[templateKey];
|
|
30
|
-
if (templateInfo === null && templateInfo === undefined)
|
|
31
|
-
throw new Error('template not found');
|
|
32
|
-
templateInfo.channel = (0, interpolation_transformer_1.isNonEmpty)(alertData?.channel)
|
|
33
|
-
? alertData.channel ?? ''
|
|
34
|
-
: templateInfo.channel;
|
|
35
|
-
if (templateInfo.blocks !== undefined) {
|
|
36
|
-
templateInfo.blocks.forEach((block) => {
|
|
37
|
-
if (block.type === 'section' && block.fields != null) {
|
|
38
|
-
block.fields = (0, interpolation_transformer_1.interpolateFields)(block.fields, alertData);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return await this.alertService.sendAlert(templateInfo);
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
console.error(error);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.SendAlertUseCase = SendAlertUseCase;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendAlert = void 0;
|
|
4
|
-
const slack_1 = require("../../common/infrastructure/slack/slack");
|
|
5
|
-
const yaml_converter_1 = require("../../common/infrastructure/yaml-converter/yaml-converter");
|
|
6
|
-
const send_alert_impl_service_1 = require("../application/send-alert-impl.service");
|
|
7
|
-
const send_alert_usecase_1 = require("../domain/usecases/send-alert.usecase");
|
|
8
|
-
const alertImpl = new slack_1.SlackImpl(process.env.SLACK_TOKEN ?? '');
|
|
9
|
-
const configuration = new yaml_converter_1.ConfigurationYaml();
|
|
10
|
-
const alertService = new send_alert_impl_service_1.AlertServiceImpl(alertImpl);
|
|
11
|
-
exports.sendAlert = new send_alert_usecase_1.SendAlertUseCase(configuration, alertService);
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,49 +0,0 @@
|
|
|
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 [year, month, day] = isoDate.split('-').map(Number);
|
|
6
|
-
const fecha = new Date(year, month - 1, day);
|
|
7
|
-
return fecha.toLocaleDateString('es-MX', {
|
|
8
|
-
day: 'numeric',
|
|
9
|
-
month: 'long',
|
|
10
|
-
year: 'numeric'
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
exports.formatDate = formatDate;
|
|
14
|
-
const formatHour = (time24) => {
|
|
15
|
-
const [hours, minutes, seconds] = time24.split(':').map(Number);
|
|
16
|
-
const date = new Date();
|
|
17
|
-
date.setHours(hours, minutes, seconds);
|
|
18
|
-
let formatted = date.toLocaleTimeString('es-MX', {
|
|
19
|
-
hour: 'numeric',
|
|
20
|
-
minute: '2-digit',
|
|
21
|
-
hour12: true
|
|
22
|
-
});
|
|
23
|
-
if (formatted.startsWith('0:')) {
|
|
24
|
-
formatted = formatted.replace('0:', '12:');
|
|
25
|
-
}
|
|
26
|
-
return formatted;
|
|
27
|
-
};
|
|
28
|
-
exports.formatHour = formatHour;
|
|
29
|
-
const getDifferenceInMinutes = (startTime, endTime) => {
|
|
30
|
-
const [h1, m1, s1] = startTime.split(':').map(Number);
|
|
31
|
-
const [h2, m2, s2] = endTime.split(':').map(Number);
|
|
32
|
-
const startDate = new Date();
|
|
33
|
-
startDate.setHours(h1, m1, s1, 0);
|
|
34
|
-
const endDate = new Date();
|
|
35
|
-
endDate.setHours(h2, m2, s2, 0);
|
|
36
|
-
const diffMs = endDate.getTime() - startDate.getTime();
|
|
37
|
-
return Math.floor(diffMs / 60000);
|
|
38
|
-
};
|
|
39
|
-
exports.getDifferenceInMinutes = getDifferenceInMinutes;
|
|
40
|
-
const formatIsoDateToSpanish = (isoString) => {
|
|
41
|
-
const date = new Date(isoString);
|
|
42
|
-
return date.toLocaleDateString('es-MX', {
|
|
43
|
-
day: 'numeric',
|
|
44
|
-
month: 'long',
|
|
45
|
-
year: 'numeric',
|
|
46
|
-
timeZone: 'America/Mexico_City'
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
exports.formatIsoDateToSpanish = formatIsoDateToSpanish;
|
|
@@ -1,18 +0,0 @@
|
|
|
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,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNonEmpty = void 0;
|
|
4
|
-
exports.interpolateFields = interpolateFields;
|
|
5
|
-
function interpolateFields(fields, input) {
|
|
6
|
-
return fields.map((field) => {
|
|
7
|
-
let text = field.text;
|
|
8
|
-
text = text.replace(/\{(\w+)\}/g, (_, key) => {
|
|
9
|
-
const value = input[key];
|
|
10
|
-
return value ?? `{${key}}`;
|
|
11
|
-
});
|
|
12
|
-
return { ...field, text };
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
const isNonEmpty = (value) => { return value !== '' && value !== undefined; };
|
|
16
|
-
exports.isNonEmpty = isNonEmpty;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type AlertResponse } from '../../../alerts/domain/interfaces/alerts';
|
|
2
|
-
import { AlertsHandler } from '../../domain/alerts/alerts';
|
|
3
|
-
export declare class SlackImpl extends AlertsHandler {
|
|
4
|
-
private readonly client;
|
|
5
|
-
constructor(token: string);
|
|
6
|
-
sendAlert(...args: any[]): Promise<AlertResponse | undefined>;
|
|
7
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlackImpl = void 0;
|
|
4
|
-
const alerts_1 = require("../../domain/alerts/alerts");
|
|
5
|
-
const web_api_1 = require("@slack/web-api");
|
|
6
|
-
class SlackImpl extends alerts_1.AlertsHandler {
|
|
7
|
-
client;
|
|
8
|
-
constructor(token) {
|
|
9
|
-
super();
|
|
10
|
-
this.client = new web_api_1.WebClient(token);
|
|
11
|
-
}
|
|
12
|
-
async sendAlert(...args) {
|
|
13
|
-
try {
|
|
14
|
-
const [input] = args;
|
|
15
|
-
const data = input;
|
|
16
|
-
const { channel, text, blocks, threadTs } = data;
|
|
17
|
-
if (typeof channel !== 'string' || channel.trim() === '' ||
|
|
18
|
-
typeof text !== 'string' || text.trim() === '') {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const response = await this.client.chat.postMessage({
|
|
22
|
-
channel,
|
|
23
|
-
text,
|
|
24
|
-
blocks,
|
|
25
|
-
thread_ts: threadTs
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
channel: response?.channel ?? '',
|
|
29
|
-
ts: response?.ts ?? ''
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.info(JSON.stringify(error));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.SlackImpl = SlackImpl;
|