@integraciones_doc24/sdk 1.16.23 → 1.16.24
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/lib/types.d.ts +1 -0
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +22 -7
- package/lib/webhook/index.js +1 -0
- package/package.json +1 -1
package/lib/types.d.ts
CHANGED
package/lib/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const parseDate: (str: string, timeZone?: string | null | undefined) => Date;
|
|
2
2
|
export declare const parseDateTime: (str: string, timeZone?: string | null | undefined) => Date;
|
|
3
|
-
export declare const normalizeTimezoneOffset: (raw
|
|
3
|
+
export declare const normalizeTimezoneOffset: (raw?: string | undefined, defualtTimezone?: number) => string | undefined;
|
package/lib/utils.js
CHANGED
|
@@ -8,16 +8,31 @@ const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, ti
|
|
|
8
8
|
exports.parseDate = parseDate;
|
|
9
9
|
const parseDateTime = (str, timeZone) => date_fns_1.parse(`${str} ${timeZone !== null && timeZone !== void 0 ? timeZone : defaultTimeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
|
|
10
10
|
exports.parseDateTime = parseDateTime;
|
|
11
|
-
const normalizeTimezoneOffset = (raw) => {
|
|
12
|
-
|
|
11
|
+
const normalizeTimezoneOffset = (raw, defualtTimezone = -3) => {
|
|
12
|
+
if (!raw)
|
|
13
|
+
return;
|
|
14
|
+
if (typeof raw !== 'string') {
|
|
15
|
+
throw new Error(`Invalid timezone format: ${raw}`);
|
|
16
|
+
}
|
|
17
|
+
const match = raw.trim().match(/([+-]?\d+(?:[.,]\d+)?)/);
|
|
13
18
|
if (!match) {
|
|
14
19
|
throw new Error(`Invalid timezone format: ${raw}`);
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const numStr = match[1].replace(',', '.');
|
|
22
|
+
const rawHours = Number(numStr);
|
|
23
|
+
if (Number.isNaN(rawHours)) {
|
|
24
|
+
throw new Error(`Invalid numeric timezone value: ${numStr}`);
|
|
25
|
+
}
|
|
26
|
+
const rawMinutes = Math.round(rawHours * 60);
|
|
27
|
+
const argentinaMinutes = Math.round(defualtTimezone * 60);
|
|
28
|
+
const targetMinutes = argentinaMinutes + rawMinutes;
|
|
29
|
+
const sign = targetMinutes >= 0 ? '+' : '-';
|
|
30
|
+
const absMinutes = Math.abs(targetMinutes);
|
|
31
|
+
const hh = Math.floor(absMinutes / 60)
|
|
32
|
+
.toString()
|
|
33
|
+
.padStart(2, '0');
|
|
34
|
+
const mm = (absMinutes % 60).toString().padStart(2, '0');
|
|
35
|
+
return mm === '00' ? `${sign}${hh}` : `${sign}${hh}:${mm}`;
|
|
21
36
|
};
|
|
22
37
|
exports.normalizeTimezoneOffset = normalizeTimezoneOffset;
|
|
23
38
|
// export const getIdetificationTypeId = (type: Doc24.IdentificationType) => {
|
package/lib/webhook/index.js
CHANGED
|
@@ -54,6 +54,7 @@ const handleEvent = async (body, _baseSdk, eventHandlers) => {
|
|
|
54
54
|
status: body.id_estado,
|
|
55
55
|
vcToken: body.vc_token,
|
|
56
56
|
changeDate: date,
|
|
57
|
+
body: body,
|
|
57
58
|
});
|
|
58
59
|
if (body.tipo === 'chat')
|
|
59
60
|
return (_d = eventHandlers.onChatUpdate) === null || _d === void 0 ? void 0 : _d.call(eventHandlers, {
|