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
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.error = exports.success = exports.PlennaError = exports.Result = exports.HttpStatusCode = void 0;
|
|
4
|
-
class HttpStatusCode {
|
|
5
|
-
httpCode;
|
|
6
|
-
constructor(code) {
|
|
7
|
-
this.httpCode = code;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.HttpStatusCode = HttpStatusCode;
|
|
11
|
-
class Result {
|
|
12
|
-
statusCode;
|
|
13
|
-
code;
|
|
14
|
-
message;
|
|
15
|
-
data;
|
|
16
|
-
headers;
|
|
17
|
-
constructor(statusCode, code, message, data, headers) {
|
|
18
|
-
this.statusCode = statusCode;
|
|
19
|
-
this.code = code;
|
|
20
|
-
this.message = message;
|
|
21
|
-
this.data = data;
|
|
22
|
-
this.headers = { ...headers };
|
|
23
|
-
}
|
|
24
|
-
bodyToString() {
|
|
25
|
-
const exposedHeaders = Object.entries(this.headers).map(([key]) => key).join(',');
|
|
26
|
-
return {
|
|
27
|
-
statusCode: this.statusCode,
|
|
28
|
-
headers: {
|
|
29
|
-
...this.headers,
|
|
30
|
-
'Access-Control-Allow-Origin': '*',
|
|
31
|
-
'Access-Control-Expose-Headers': exposedHeaders,
|
|
32
|
-
'Access-Control-Allow-Credentials': true
|
|
33
|
-
},
|
|
34
|
-
body: JSON.stringify({
|
|
35
|
-
code: this.code,
|
|
36
|
-
message: this.message,
|
|
37
|
-
data: this.data
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.Result = Result;
|
|
43
|
-
class PlennaError extends Error {
|
|
44
|
-
code;
|
|
45
|
-
message;
|
|
46
|
-
httpCode;
|
|
47
|
-
constructor(status) {
|
|
48
|
-
super();
|
|
49
|
-
this.code = status.code;
|
|
50
|
-
this.message = status.message;
|
|
51
|
-
this.httpCode = status.httpCode;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.PlennaError = PlennaError;
|
|
55
|
-
const success = (data, headers) => {
|
|
56
|
-
const result = new Result(200, 0, 'success', data, headers);
|
|
57
|
-
return result.bodyToString();
|
|
58
|
-
};
|
|
59
|
-
exports.success = success;
|
|
60
|
-
const error = (httpStatusCode, message, code = 0) => {
|
|
61
|
-
const result = new Result(httpStatusCode, code, message);
|
|
62
|
-
return result.bodyToString();
|
|
63
|
-
};
|
|
64
|
-
exports.error = error;
|
package/dist/src/mailer/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Mailer = void 0;
|
|
4
|
-
class Mailer {
|
|
5
|
-
apiKey;
|
|
6
|
-
constructor(apiKey) {
|
|
7
|
-
this.apiKey = apiKey;
|
|
8
|
-
}
|
|
9
|
-
async sendEmail(templateId, destiny, params) {
|
|
10
|
-
try {
|
|
11
|
-
const response = await fetch('https://api.sendinblue.com/v3/smtp/email', {
|
|
12
|
-
method: 'post',
|
|
13
|
-
headers: {
|
|
14
|
-
accept: 'application/json',
|
|
15
|
-
'api-key': this.apiKey,
|
|
16
|
-
'content-type': 'application/json'
|
|
17
|
-
},
|
|
18
|
-
body: JSON.stringify({
|
|
19
|
-
to: destiny,
|
|
20
|
-
params,
|
|
21
|
-
templateId
|
|
22
|
-
})
|
|
23
|
-
});
|
|
24
|
-
console.log(JSON.stringify(response));
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.log(JSON.stringify(error));
|
|
29
|
-
console.log('error sending email');
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.Mailer = Mailer;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export interface IWhatsAppMessage {
|
|
2
|
-
phone: string;
|
|
3
|
-
name?: string;
|
|
4
|
-
email?: string;
|
|
5
|
-
ri_body_param_1?: string;
|
|
6
|
-
ri_body_param_2?: string;
|
|
7
|
-
ri_body_param_3?: string;
|
|
8
|
-
ri_body_param_4?: string;
|
|
9
|
-
ri_body_param_5?: string;
|
|
10
|
-
ri_body_param_6?: string;
|
|
11
|
-
ri_body_param_7?: string;
|
|
12
|
-
ri_body_param_8?: string;
|
|
13
|
-
ri_body_param_9?: string;
|
|
14
|
-
ri_body_param_10?: string;
|
|
15
|
-
ri_body_param_11?: string;
|
|
16
|
-
ri_body_param_12?: string;
|
|
17
|
-
ri_body_param_13?: string;
|
|
18
|
-
ri_body_param_14?: string;
|
|
19
|
-
ri_body_param_15?: string;
|
|
20
|
-
ri_body_param_16?: string;
|
|
21
|
-
ri_body_param_17?: string;
|
|
22
|
-
ri_body_param_18?: string;
|
|
23
|
-
ri_body_param_19?: string;
|
|
24
|
-
ri_body_param_20?: string;
|
|
25
|
-
ri_footer_param_1?: string;
|
|
26
|
-
ri_footer_param_2?: string;
|
|
27
|
-
ri_footer_param_3?: string;
|
|
28
|
-
ri_footer_param_4?: string;
|
|
29
|
-
ri_footer_param_5?: string;
|
|
30
|
-
ri_header_type?: string;
|
|
31
|
-
ri_header_text?: string;
|
|
32
|
-
ri_header_link?: string;
|
|
33
|
-
delivery_date?: string;
|
|
34
|
-
delivery_time?: string;
|
|
35
|
-
iana_timezone?: string;
|
|
36
|
-
tags?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface ISendWhatsAppMessagesOptions {
|
|
39
|
-
template_name: string;
|
|
40
|
-
language: string;
|
|
41
|
-
omit_ticket_creation: string;
|
|
42
|
-
ticket_id?: number;
|
|
43
|
-
tags?: string;
|
|
44
|
-
add_to_queue?: boolean;
|
|
45
|
-
origin?: string;
|
|
46
|
-
subdomain?: string;
|
|
47
|
-
messages: IWhatsAppMessage[];
|
|
48
|
-
}
|
|
49
|
-
export interface IWhatsAppMessageDetailQuery {
|
|
50
|
-
id_single_notification: string;
|
|
51
|
-
phone?: string;
|
|
52
|
-
template_name?: string;
|
|
53
|
-
sunco_notification_id?: string;
|
|
54
|
-
origin?: string;
|
|
55
|
-
delivery_date_from?: string;
|
|
56
|
-
delivery_date_to?: string;
|
|
57
|
-
}
|
|
58
|
-
export declare class RespiraInternet {
|
|
59
|
-
private readonly apiKey;
|
|
60
|
-
private readonly username;
|
|
61
|
-
private readonly apiUrl;
|
|
62
|
-
constructor(apiKey: string, username: string, apiUrl: string);
|
|
63
|
-
sendWhatsAppMessages(options: ISendWhatsAppMessagesOptions): Promise<Response>;
|
|
64
|
-
getWhatsAppMessageDetail(query: IWhatsAppMessageDetailQuery): Promise<Response>;
|
|
65
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RespiraInternet = void 0;
|
|
4
|
-
class RespiraInternet {
|
|
5
|
-
apiKey;
|
|
6
|
-
username;
|
|
7
|
-
apiUrl;
|
|
8
|
-
constructor(apiKey, username, apiUrl) {
|
|
9
|
-
this.apiKey = apiKey;
|
|
10
|
-
this.username = username;
|
|
11
|
-
this.apiUrl = apiUrl;
|
|
12
|
-
}
|
|
13
|
-
sendWhatsAppMessages(options) {
|
|
14
|
-
const auth = Buffer.from(`${this.username}:${this.apiKey}`).toString('base64');
|
|
15
|
-
return fetch(`${this.apiUrl}/messages/`, {
|
|
16
|
-
method: 'POST',
|
|
17
|
-
headers: {
|
|
18
|
-
Authorization: `Basic ${auth}`,
|
|
19
|
-
'Content-Type': 'application/json'
|
|
20
|
-
},
|
|
21
|
-
body: JSON.stringify(options)
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
getWhatsAppMessageDetail(query) {
|
|
25
|
-
const params = {};
|
|
26
|
-
Object.entries(query).forEach(([key, value]) => {
|
|
27
|
-
if (value !== undefined) {
|
|
28
|
-
params[key] = value;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const queryString = new URLSearchParams(params).toString();
|
|
32
|
-
const auth = Buffer.from(`${this.username}:${this.apiKey}`).toString('base64');
|
|
33
|
-
return fetch(`${this.apiUrl}/messages?${queryString}`, {
|
|
34
|
-
method: 'GET',
|
|
35
|
-
headers: {
|
|
36
|
-
Authorization: `Basic ${auth}`,
|
|
37
|
-
'Content-Type': 'application/json'
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.RespiraInternet = RespiraInternet;
|
package/dist/src/s3/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ObjectCannedACL, type PutObjectCommandInput, type S3ClientConfig } from '@aws-sdk/client-s3';
|
|
2
|
-
export declare class PlennaS3Service {
|
|
3
|
-
private readonly bucket;
|
|
4
|
-
private readonly acl;
|
|
5
|
-
private readonly options;
|
|
6
|
-
constructor(bucket: string, acl: ObjectCannedACL, options?: Partial<PutObjectCommandInput>);
|
|
7
|
-
getPresignedUrl(keyName: string, clientConfig?: S3ClientConfig): Promise<string>;
|
|
8
|
-
upload(fileName: string, file: PutObjectCommandInput['Body'], options?: Partial<PutObjectCommandInput>): Promise<string>;
|
|
9
|
-
}
|
package/dist/src/s3/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlennaS3Service = void 0;
|
|
4
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
-
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
6
|
-
const REGION = 'us-east-2';
|
|
7
|
-
class PlennaS3Service {
|
|
8
|
-
bucket;
|
|
9
|
-
acl;
|
|
10
|
-
options;
|
|
11
|
-
constructor(bucket, acl, options = {}) {
|
|
12
|
-
this.bucket = bucket;
|
|
13
|
-
this.acl = acl;
|
|
14
|
-
this.options = options;
|
|
15
|
-
}
|
|
16
|
-
async getPresignedUrl(keyName, clientConfig = {}) {
|
|
17
|
-
const s3Client = new client_s3_1.S3Client({ region: REGION, ...clientConfig });
|
|
18
|
-
const command = new client_s3_1.PutObjectCommand({
|
|
19
|
-
...this.options,
|
|
20
|
-
Bucket: this.bucket,
|
|
21
|
-
Key: keyName,
|
|
22
|
-
ACL: this.acl
|
|
23
|
-
});
|
|
24
|
-
const signedUrl = await (0, s3_request_presigner_1.getSignedUrl)(s3Client, command, { expiresIn: 3600 });
|
|
25
|
-
return signedUrl;
|
|
26
|
-
}
|
|
27
|
-
async upload(fileName, file, options = {}) {
|
|
28
|
-
const s3 = new client_s3_1.S3Client({ region: REGION });
|
|
29
|
-
console.log('received file:', fileName);
|
|
30
|
-
const uploadParams = {
|
|
31
|
-
...this.options,
|
|
32
|
-
...options,
|
|
33
|
-
Bucket: this.bucket,
|
|
34
|
-
Key: fileName,
|
|
35
|
-
Body: file,
|
|
36
|
-
ACL: this.acl
|
|
37
|
-
};
|
|
38
|
-
const response = await s3.send(new client_s3_1.PutObjectCommand(uploadParams));
|
|
39
|
-
console.log(response.ETag);
|
|
40
|
-
const fileS3Url = `https://${this.bucket}.s3.${REGION}.amazonaws.com/${fileName}`;
|
|
41
|
-
return fileS3Url;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.PlennaS3Service = PlennaS3Service;
|
package/dist/src/time/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const fixAppointmentDateStart: (date: Date, start: string) => Date;
|
|
2
|
-
export declare const isValidNumeric: (value: number | undefined) => boolean;
|
|
3
|
-
export declare const compare: (left: Date, right: Date) => boolean;
|
|
4
|
-
export declare const getAge: (date: Date) => string;
|
|
5
|
-
export declare const getDeltaTime: (start: Date, end: Date) => number;
|
|
6
|
-
export declare const getMonthDifference: (startDate: Date, endDate: Date) => number;
|
|
7
|
-
export declare const addWorkDays: (startDate: Date, days: number) => Date;
|
package/dist/src/time/index.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addWorkDays = exports.getMonthDifference = exports.getDeltaTime = exports.getAge = exports.compare = exports.isValidNumeric = exports.fixAppointmentDateStart = void 0;
|
|
4
|
-
const fixAppointmentDateStart = (date, start) => {
|
|
5
|
-
const [hour, minutes] = start.split(':');
|
|
6
|
-
const fixedDate = new Date(date).setUTCHours(parseInt(hour ?? 0) + 6, parseInt(minutes ?? 0));
|
|
7
|
-
return new Date(fixedDate);
|
|
8
|
-
};
|
|
9
|
-
exports.fixAppointmentDateStart = fixAppointmentDateStart;
|
|
10
|
-
const isValidNumeric = (value) => {
|
|
11
|
-
return (typeof value === 'number' && !isNaN(value));
|
|
12
|
-
};
|
|
13
|
-
exports.isValidNumeric = isValidNumeric;
|
|
14
|
-
const compare = (left, right) => {
|
|
15
|
-
return left > right;
|
|
16
|
-
};
|
|
17
|
-
exports.compare = compare;
|
|
18
|
-
const getAge = (date) => {
|
|
19
|
-
if (date === null || date === undefined) {
|
|
20
|
-
return 'Pendiente';
|
|
21
|
-
}
|
|
22
|
-
const diffMs = Date.now() - date.getTime();
|
|
23
|
-
const ageDt = new Date(diffMs);
|
|
24
|
-
return `${Math.abs(ageDt.getUTCFullYear() - 1970)}`;
|
|
25
|
-
};
|
|
26
|
-
exports.getAge = getAge;
|
|
27
|
-
const getDeltaTime = (start, end) => {
|
|
28
|
-
const diff = end.getTime() - start.getTime();
|
|
29
|
-
const diffDays = diff / (1000 * 3600);
|
|
30
|
-
return diffDays;
|
|
31
|
-
};
|
|
32
|
-
exports.getDeltaTime = getDeltaTime;
|
|
33
|
-
const getMonthDifference = (startDate, endDate) => {
|
|
34
|
-
const calculated = (endDate.getMonth() - startDate.getMonth() + 12 * (endDate.getFullYear() - startDate.getFullYear()));
|
|
35
|
-
console.log({ startDate, endDate, calculated });
|
|
36
|
-
return calculated;
|
|
37
|
-
};
|
|
38
|
-
exports.getMonthDifference = getMonthDifference;
|
|
39
|
-
const addWorkDays = (startDate, days) => {
|
|
40
|
-
const targetDate = new Date(startDate);
|
|
41
|
-
while (days > 0) {
|
|
42
|
-
targetDate.setUTCDate(targetDate.getUTCDate() + 1);
|
|
43
|
-
if (![6, 0].includes(targetDate.getUTCDay())) {
|
|
44
|
-
days--;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return targetDate;
|
|
48
|
-
};
|
|
49
|
-
exports.addWorkDays = addWorkDays;
|