@integraciones_doc24/sdk 1.16.21 → 1.16.23

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
@@ -117,7 +117,10 @@ export declare namespace Doc24 {
117
117
  identificationType: string;
118
118
  identificationValue: string;
119
119
  specialtyId: number;
120
- date: Date;
120
+ date: any;
121
+ appointmentTime: string;
122
+ appointmentDate: string;
123
+ userTimeZone: string;
121
124
  };
122
125
  type ConsultationStatusChangeEvent = {
123
126
  id: number;
package/lib/utils.d.ts CHANGED
@@ -1,2 +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;
package/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseDateTime = exports.parseDate = void 0;
3
+ exports.normalizeTimezoneOffset = exports.parseDateTime = exports.parseDate = void 0;
4
4
  const date_fns_1 = require("date-fns");
5
5
  // import {Doc24} from '.';
6
6
  const defaultTimeZone = '-03';
@@ -8,6 +8,18 @@ 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})/);
13
+ if (!match) {
14
+ throw new Error(`Invalid timezone format: ${raw}`);
15
+ }
16
+ let [, sign, hours] = match;
17
+ if (!sign)
18
+ sign = '+';
19
+ const paddedHours = hours.padStart(2, '0');
20
+ return `${sign}${paddedHours}`;
21
+ };
22
+ exports.normalizeTimezoneOffset = normalizeTimezoneOffset;
11
23
  // export const getIdetificationTypeId = (type: Doc24.IdentificationType) => {
12
24
  // if (type === 'ndi') return 6;
13
25
  // if (type === 'passport') return 5;
@@ -28,7 +28,8 @@ const handleEvent = async (body, _baseSdk, eventHandlers) => {
28
28
  vcToken: body.vc_token,
29
29
  patientId: body.id_paciente !== undefined ? Number(body.id_paciente) : undefined,
30
30
  });
31
- if (body.tipo === 'invitacion')
31
+ if (body.tipo === 'invitacion') {
32
+ const normalizedTimeZone = utils_1.normalizeTimezoneOffset(body.user_time_zone);
32
33
  return (_b = eventHandlers.onInvitationStatusChange) === null || _b === void 0 ? void 0 : _b.call(eventHandlers, {
33
34
  status: body.id_estado,
34
35
  changeDate: date,
@@ -41,8 +42,12 @@ const handleEvent = async (body, _baseSdk, eventHandlers) => {
41
42
  identificationValue: body.valor_identificacion,
42
43
  idSharedVc: body.id_shared_vc,
43
44
  specialtyId: body.id_especialidad,
44
- date: utils_1.parseDateTime(`${body.fecha_turno} ${body.hora_turno}`, body.user_time_zone),
45
+ date: utils_1.parseDateTime(`${body.fecha_turno} ${body.hora_turno}`, normalizedTimeZone),
46
+ appointmentDate: body.fecha_turno,
47
+ appointmentTime: body.hora_turno,
48
+ userTimeZone: body.user_time_zone,
45
49
  });
50
+ }
46
51
  if (body.tipo === 'turno')
47
52
  return (_c = eventHandlers.onAppointmentStatusChange) === null || _c === void 0 ? void 0 : _c.call(eventHandlers, {
48
53
  id: Number(body.id_turno),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "1.16.21",
3
+ "version": "1.16.23",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },