@integraciones_doc24/sdk 1.16.23 → 1.16.25

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 CHANGED
@@ -133,7 +133,9 @@ export declare namespace Doc24 {
133
133
  type AppointmentStatusChangeEvent = {
134
134
  id: number;
135
135
  status: StatusChangeEventStatus;
136
- vcToken?: string;
136
+ vcTokens: {
137
+ vc_token: string;
138
+ }[];
137
139
  changeDate: Date;
138
140
  };
139
141
  type ChatUpdateEvent = {
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: string) => string;
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
- const match = raw.trim().match(/^([+-]?)(\d{1,2})/);
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
- let [, sign, hours] = match;
17
- if (!sign)
18
- sign = '+';
19
- const paddedHours = hours.padStart(2, '0');
20
- return `${sign}${paddedHours}`;
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) => {
@@ -52,7 +52,7 @@ const handleEvent = async (body, _baseSdk, eventHandlers) => {
52
52
  return (_c = eventHandlers.onAppointmentStatusChange) === null || _c === void 0 ? void 0 : _c.call(eventHandlers, {
53
53
  id: Number(body.id_turno),
54
54
  status: body.id_estado,
55
- vcToken: body.vc_token,
55
+ vcTokens: body.vc_tokens,
56
56
  changeDate: date,
57
57
  });
58
58
  if (body.tipo === 'chat')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "1.16.23",
3
+ "version": "1.16.25",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },